[issue38909] module name 'stat.py'
New submission from da-dada : well, call your module 'stat.py' and python takes over full ownership: it's somewhat all public.. -- components: Windows messages: 357444 nosy: da-dada, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: module name 'stat.py' type: compile error versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue38909> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38998] dict.setdefault (setdefault of dictionary)
New submission from da-dada : from the docu I expected at the second call just a return of value and not a second calculation: there is room for improvement, as Elon Musk would say.. class Ddefault: def __init__(self): vars(self).setdefault('default', self.set_default()) vars(self).setdefault('default', self.set_default()) def set_default(self): print(vars(self)) return 'default' if __name__ == "__main__": Ddefault() -- messages: 358016 nosy: da-dada priority: normal severity: normal status: open title: dict.setdefault (setdefault of dictionary) type: enhancement versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue38998> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38998] dict.setdefault (setdefault of dictionary)
da-dada added the comment: I have no problem of making my programme run properly (asking first if in dict etc), but I just read the docu of dict.setdefault setdefault(key[, default]) If key is in the dictionary, return its value. If not, insert key with a value of default and return default. default defaults to None. and it clearly reads if the key is.. return its value, with a full stop; so either the docu is wrong (but proposes exactly the needed shortcut) or python is as it is: come in & find out -- ___ Python tracker <https://bugs.python.org/issue38998> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38998] dict.setdefault (setdefault of dictionary)
da-dada added the comment: my use case is different (I do a loop), but what I expected from the docs (just for fun!) class Ddefault: def __init__(self): vars(self).setdefault('default', self.set_default() if not 'default' in vars(self) else self.default) vars(self).setdefault('default', self.set_default() if not 'default' in vars(self) else self.default) print(vars(self)) def set_default(self): print(vars(self)) return 'default' if __name__ == "__main__": Ddefault() may be the coding diverted from the docs after the fixing of issue 13521 and no one dares correcting.. anyway, I will probably keep my old coding (performance, if there is any) -- ___ Python tracker <https://bugs.python.org/issue38998> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com