Dmitriy
странно, я всегда думал, что надо опускать else, а на производительность, будем честными это же немного повлияет?
Denis
>>> def f():
... if a:
... return 1 ... else:
... return 2 ...
>>> def g():
... if a:
... return 1
... return 2
...
>>> dis.dis(f)
2 0 LOAD_GLOBAL 0 (a)
2 POP_JUMP_IF_FALSE 8
3 4 LOAD_CONST 1 (1)
6 RETURN_VALUE
5 >> 8 LOAD_CONST 2 (2)
10 RETURN_VALUE
12 LOAD_CONST 0 (None)
14 RETURN_VALUE
>>> dis.dis(g)
2 0 LOAD_GLOBAL 0 (a)
2 POP_JUMP_IF_FALSE 8
3 4 LOAD_CONST 1 (1)
6 RETURN_VALUE
4 >> 8 LOAD_CONST 2 (2)
10 RETURN_VALUE
>>>
Прикол
Anonymous
2020-11-08 20:16:10,344 (util.py:75 WorkerThread1) ERROR - TeleBot: "ApiTelegramException occurred, args=("A request to the Telegram API was unsuccessful. Error code: 400 Description: Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 1160",)
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/telebot/util.py", line 69, in run
task(*args, **kwargs)
File "mainex2.py", line 549, in admin_ras
bot.send_message(iid, f"{dadatext}", parse_mode="Markdown", reply_markup = menu_admin_keyboard)
File "/usr/local/lib/python3.8/dist-packages/telebot/__init__.py", line 640, in send_message
apihelper.send_message(self.token, chat_id, text, disable_web_page_preview, reply_to_message_id,
File "/usr/local/lib/python3.8/dist-packages/telebot/apihelper.py", line 201, in send_message
return _make_request(token, method_url, params=payload, method='post')
File "/usr/local/lib/python3.8/dist-packages/telebot/apihelper.py", line 108, in _make_request
json_result = _check_result(method_name, result)
File "/usr/local/lib/python3.8/dist-packages/telebot/apihelper.py", line 135, in _check_result
raise ApiTelegramException(method_name, result, result_json)
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400 Description: Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 1160
"
2020-11-08 20:16:10,345 (__init__.py:455 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 400 Description: Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 1160"
из-за чего возникает такая ошибка при попытке отправить сообщение телеграм юзеру по его юзерайди?
Dmitriy
я вроде когда-то тут писал, что нан в питоне занимает аж 16 байт, если таких функций будет много или это будет в цикле с миллионом итераций то память можно сэкономить прилично
decorator-factory
class UnicodeString(object):
"""
Represents a unicode string
"""
def __init__(self, source: str) -> None:
"""
Create a unicode string from a given source
:param source: The source to create a unicode string from
:return: A unicode string
>>> u = UnicodeString("string")
>>> u.source
"string"
"""
self._source = source
@property
def source(self) -> str:
"""
Get the source
:return: THe source
"""
return self._source
@source.setter
def source(self, new_source: str) -> None:
"""
Set the source
:param new_source: The new source
:return: The singleton None object
"""
self._source = new_source