
Aragaer
26.11.2018
09:01:26
>>> o = io.BytesIO()
>>> w = codecs.getwriter("utf-8")(o)
>>> print("hello", "world", file=w)
>>> o.getvalue()
b'hello world\n'
но не знаю, как оно там будет работать под капотом
то есть есть надежда, что под BytesIO будет какая-то разумная буферизация, куда будут последовательно складываться байтики

Tishka17
26.11.2018
09:08:04
эм
>>> timeit('a("hello, world!")', globals={"a": a}, number=10000000)
3.0316345890000207
>>> timeit('a("hello, world!")', globals={"a": b}, number=10000000)
2.9606989260000205
a и b - дв варианта реализации

Арсений
26.11.2018
09:08:59
PyTelegramBotApi
С чем может быть связано?
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/util.py", line 59, in run
task(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 277, in __retrieve_updates
self.process_new_updates(updates)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 314, in process_new_updates
self.process_new_messages(new_messages)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 336, in process_new_messages
self._notify_command_handlers(self.message_handlers, new_messages)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 1489, in _notify_command_handlers
if self._test_message_handler(message_handler, message):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 1470, in _test_message_handler
if not self._test_filter(filter, filter_value, message):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 1484, in _test_filter
return test_cases.get(filter, lambda msg: False)(message)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 1480, in <lambda>
'commands': lambda msg: msg.content_type == 'text' and util.extract_command(msg.text) in filter_value,
TypeError: 'in <string>' requires string as left operand, not NoneType
"
Exception in thread PollingThread:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/util.py", line 59, in run
task(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 277, in __retrieve_updates
self.process_new_updates(updates)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 314, in process_new_updates
self.process_new_messages(new_messages)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 336, in process_new_messages
self._notify_command_handlers(self.message_handlers, new_messages)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 1489, in _notify_command_handlers
if self._test_message_handler(message_handler, message):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 1470, in _test_message_handler
if not self._test_filter(filter, filter_value, message):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 1484, in _test_filter
return test_cases.get(filter, lambda msg: False)(message)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/__init__.py", line 1480, in <lambda>
'commands': lambda msg: msg.content_type == 'text' and util.extract_command(msg.text) in filter_value,
TypeError: 'in <string>' requires string as left operand, not NoneType
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/telebot/util.py", line 65, in run
logger.error(type(e).__name__ + " occurred, args=" + str(e.args) + "\n" + traceback.format_exc())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 1361, in error
self._log(ERROR, msg, args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 1468, in _log
self.handle(record)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 1478, in handle
self.callHandlers(record)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 1539, in callHandlers
if record.levelno >= hdlr.level:
AttributeError: 'NoneType' object has no attribute 'level’