[issue41629] __class__ not set defining 'X' as
Richard Neumann added the comment: I just stumbled across this issue trying to resolve this: https://bugs.python.org/issue42765? While this fails: from typing import NamedTuple class Spamm(NamedTuple): foo: int bar: str def __getitem__(self, index_or_key): """Returns the respective item.""" if isinstance(index_or_key, str): try: return getattr(self, index_or_key) except AttributeError: raise IndexError(index_or_key) from None return super().__getitem__(index_or_key) def keys(self): return self._fields def main(): spamm = Spamm(12, 'hello') print(dir(spamm)) print(spamm._fields) d = dict(spamm) print(d) if __name__ == '__main__': main() with Traceback (most recent call last): File "/home/neumann/test.py", line 4, in class Spamm(NamedTuple): RuntimeError: __class__ not set defining 'Spamm' as . Was __classcell__ propagated to type.__new__? The following works: from typing import NamedTuple def _getitem(instance, index_or_key): """Returns the respective item.""" if isinstance(index_or_key, str): try: return getattr(instance, index_or_key) except AttributeError: raise IndexError(index_or_key) from None return super().__getitem__(index_or_key) def dicttuple(cls: tuple): """Extends a tuple class with methods for the dict constructor.""" cls.keys = lambda self: self._fields cls.__getitem__ = _getitem return cls @dicttuple class Spamm(NamedTuple): foo: int bar: str def main(): spamm = Spamm(12, 'hello') print(dir(spamm)) print(spamm._fields) d = dict(spamm) print(d) if __name__ == '__main__': main() And produces: ['__add__', '__annotations__', '__class__', '__class_getitem__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__orig_bases__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '_asdict', '_field_defaults', '_fields', '_make', '_replace', 'bar', 'count', 'foo', 'index', 'keys'] ('foo', 'bar') {'foo': 12, 'bar': 'hello'} I am a bit baffled, why it works when the method is injected via a decorator. -- nosy: +conqp ___ Python tracker <https://bugs.python.org/issue41629> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42765] Introduce new data model method __iter_items__
Richard Neumann added the comment: Okay, I found the solution. Not using super() works: from typing import NamedTuple class Spamm(NamedTuple): foo: int bar: str def __getitem__(self, index_or_key): if isinstance(index_or_key, str): try: return getattr(self, index_or_key) except AttributeError: raise KeyError(index_or_key) from None return tuple.__getitem__(self, index_or_key) def keys(self): yield 'foo' yield 'bar' def main(): spamm = Spamm(12, 'hello') print(spamm.__getitem__) print(spamm.__getitem__(1)) d = dict(spamm) print(d) if __name__ == '__main__': main() Result: hello {'foo': 12, 'bar': 'hello'} -- ___ Python tracker <https://bugs.python.org/issue42765> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42765] Introduce new data model method __iter_items__
Richard Neumann added the comment: Thank you all for your input. I had a look at aforementioned discussion and learned something new. So I tried to implement the dict data model by implementing keys() and __getitem__() accordingly: from typing import NamedTuple class Spamm(NamedTuple): foo: int bar: str def __getitem__(self, item): if isinstance(item, str): try: return getattr(self, item) except AttributeError: raise KeyError(item) from None return super().__getitem__(item) def keys(self): yield 'foo' yield 'bar' def main(): spamm = Spamm(12, 'hello') print(spamm.__getitem__) print(spamm.__getitem__(1)) d = dict(spamm) if __name__ == '__main__': main() Unfortunately this will result in an error: Traceback (most recent call last): File "/home/neumann/test.py", line 4, in class Spamm(NamedTuple): RuntimeError: __class__ not set defining 'Spamm' as . Was __classcell__ propagated to type.__new__? Which seems to be caused by the __getitem__ implementation. I found a corresponding issue here: https://bugs.python.org/issue41629 Can I assume, that this is a pending bug and thusly I cannot implement the desired behaviour until a fix? -- ___ Python tracker <https://bugs.python.org/issue42765> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42768] super().__new__() of list expands arguments
Richard Neumann added the comment: I could have sworn, that this worked before, but it was obviously me being tired at the end of the work day. Thanks for pointing this out and sorry for the noise. -- ___ Python tracker <https://bugs.python.org/issue42768> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42768] super().__new__() of list expands arguments
New submission from Richard Neumann : When sublassing the built-in list, the invocation of super().__new__ will unexpectedly expand the passed arguments: class MyTuple(tuple): def __new__(cls, *items): print(cls, items) return super().__new__(cls, items) class MyList(list): def __new__(cls, *items): print(cls, items) return super().__new__(cls, items) def main(): my_tuple = MyTuple(1, 2, 3, 'foo', 'bar') print('My tuple:', my_tuple) my_list = MyList(1, 2, 3, 'foo', 'bar') print('My list:', my_list) if __name__ == '__main__': main() Actual result: (1, 2, 3, 'foo', 'bar') My tuple: (1, 2, 3, 'foo', 'bar') (1, 2, 3, 'foo', 'bar') Traceback (most recent call last): File "/home/neumann/listbug.py", line 24, in main() File "/home/neumann/listbug.py", line 19, in main my_list = MyList(1, 2, 3, 'foo', 'bar') TypeError: list expected at most 1 argument, got 5 Expected: (1, 2, 3, 'foo', 'bar') My tuple: (1, 2, 3, 'foo', 'bar') (1, 2, 3, 'foo', 'bar') My list: [1, 2, 3, 'foo', 'bar'] -- components: ctypes messages: 383902 nosy: conqp priority: normal severity: normal status: open title: super().__new__() of list expands arguments type: behavior versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue42768> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42765] Introduce new data model method __iter_items__
New submission from Richard Neumann : I have use cases in which I use named tuples to represent data sets, e.g: class BasicStats(NamedTuple): """Basic statistics response packet.""" type: Type session_id: BigEndianSignedInt32 motd: str game_type: str map: str num_players: int max_players: int host_port: int host_ip: IPAddressOrHostname I want them to behave as intended, i.e. that unpacking them should behave as expected from a tuple: type, session_id, motd, … = BasicStats(…) I also want to be able to serialize them to a JSON-ish dict. The NamedTuple has an _asdict method, that I could use. json = BasicStats(…)._asdict() But for the dict to be passed to JSON, I need customization of the dict representation, e.g. set host_ip to str(self.host_ip), since it might be a non-serializable ipaddress.IPv{4,6}Address. Doing this in an object hook of json.dumps() is a non-starter, since I cannot force the user to remember, which types need to be converted on the several data structures. Also, using _asdict() seems strange as an exposed API, since it's an underscore method and users hence might not be inclined to use it. So what I did is to add a method to_json() to convert the named tuple into a JSON-ish dict: def to_json(self) -> dict: """Returns a JSON-ish dict.""" return { 'type': self.type.value, 'session_id': self.session_id, 'motd': self.motd, 'game_type': self.game_type, 'map': self.map, 'num_players': self.num_players, 'max_players': self.max_players, 'host_port': self.host_port, 'host_ip': str(self.host_ip) } It would be nicer to have my type just return this appropriate dict when invoking dict(BasicStats(…)). This would require me to override the __iter__() method to yield key / value tuples for the dict. However, this would break the natural behaviour of tuple unpacking as described above. Hence, I propose to add a method __iter_items__(self) to the python data model with the following properties: 1) __iter_items__ is expected to return an iterator of 2-tuples representing key / value pairs. 2) the built-in function dict(), when called on an object, will attempt to create the object from __iter_items__ first and fall back to __iter__. Alternative names could also be __items__ or __iter_dict__. -- components: C API messages: 383897 nosy: conqp priority: normal severity: normal status: open title: Introduce new data model method __iter_items__ type: enhancement versions: Python 3.10 ___ Python tracker <https://bugs.python.org/issue42765> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41795] Allow assignment in yield statement
Richard Neumann added the comment: Awesome, I didn't know that. I tried it without the parens and it gave me a SyntaxError. This can be closed then as it's obviously already implemented. Let's get to refactoring. -- ___ Python tracker <https://bugs.python.org/issue41795> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41795] Allow assignment in yield statement
New submission from Richard Neumann : I often write factory (deserialization) methods for ORM models for web application backends that produce a number of records (ORM model instances) of itself and related database tables: @classmethod def from_json(cls, json): """Yields records from a JSON-ish dict.""" modules = json.pop('modules', None) or () order = super().from_json(json) yield order for module in modules: yield OrderedModule(order=order, module=Module(module)) This yields the main record "order" and related records from OrderedModules, which have a foreign key to Order. Thusly I can save all records by: for record in Order.from_json(json): record.save() Since I have several of those deserialization functions for multiple tables in multiple databases, it'd be nice to reduce the amount of code with some extra syntactic sugar, like: @classmethod def from_json(cls, json): """Yields records from a JSON-ish dict.""" modules = json.pop('modules', None) or () yield order = super().from_json(json) # Assignment via "=" for module in modules: yield OrderedModule(order=order, module=Module(module)) or: @classmethod def from_json(cls, json): """Yields records from a JSON-ish dict.""" modules = json.pop('modules', None) or () yield order := super().from_json(json) # Assignment via ":=" for module in modules: yield OrderedModule(order=order, module=Module(module)) I therefor propose to allow assignment of names in generator-like yield statements as described above. -- messages: 376979 nosy: conqp priority: normal severity: normal status: open title: Allow assignment in yield statement type: enhancement versions: Python 3.10 ___ Python tracker <https://bugs.python.org/issue41795> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40054] Allow formatted strings as docstrings
New submission from Richard Neumann : Currently only plain strings can be used as docstrings, such as: class Foo: """Spamm eggs.""" For dynamic class generation, it would be useful to allow format strings as docstrings as well: doc = 'eggs' class Foo: """Spamm {}.""".format(doc) or: doc = 'eggs' class Foo: f"""Spamm {doc}.""" A current use case in which I realized that this feature was missing is: class OAuth2ClientMixin(Model, ClientMixin): # pylint: disable=R0904 """An OAuth 2.0 client mixin for peewee models.""" @classmethod def get_related_models(cls, model=Model): """Yields related models.""" for mixin, backref in CLIENT_RELATED_MIXINS: yield cls._get_related_model(model, mixin, backref) @classmethod def _get_related_model(cls, model, mixin, backref): """Returns an implementation of the related model.""" class ClientRelatedModel(model, mixin): f"""Implementation of {mixin.__name__}.""" client = ForeignKeyField( cls, column_name='client', backref=backref, on_delete='CASCADE', on_update='CASCADE') return ClientRelatedModel It actually *is* possible to dynamically set the docstring via the __doc__ attribute: doc = 'eggs' class Foo: pass Foo.__doc__ = doc Allowing format strings would imho be more obvious when reading the code as it is set, where a docstring is expected i.e. below the class / function definition. -- messages: 364934 nosy: conqp priority: normal severity: normal status: open title: Allow formatted strings as docstrings type: enhancement versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue40054> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37113] 'ß'.upper() should return 'ẞ'
Richard Neumann added the comment: See also: https://en.wikipedia.org/wiki/Capital_%E1%BA%9E -- ___ Python tracker <https://bugs.python.org/issue37113> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37113] 'ß'.upper() should return 'ẞ'
New submission from Richard Neumann : Currently, calling the method .upper() on a string containing 'ß' will replace this character by 'SS'. It should, however, be replaced by 'ẞ'. -- components: Unicode messages: 344065 nosy: Richard Neumann, ezio.melotti, vstinner priority: normal severity: normal status: open title: 'ß'.upper() should return 'ẞ' type: behavior versions: Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue37113> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34732] uuid returns version more than 5
Richard Neumann added the comment: I updated my pull request. Since "_windll_getnode()" is only returning a (random?) node for a UUID, I circumevented the value checking by introducing a new keyword-only argument "strict" defaulting to "True", there being set to "False". -- ___ Python tracker <https://bugs.python.org/issue34732> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31958] UUID versions are not validated to lie in the documented range
Richard Neumann added the comment: @xtreak Indeed. It fails on _windll_getnode(). == ERROR: test_windll_getnode (test.test_uuid.TestInternalsWithoutExtModule) -- Traceback (most recent call last): File "C:\projects\cpython\lib\test\test_uuid.py", line 748, in test_windll_getnode node = self.uuid._windll_getnode() File "C:\projects\cpython\lib\uuid.py", line 659, in _windll_getnode return UUID(bytes=bytes_(_buffer.raw)).node File "C:\projects\cpython\lib\uuid.py", line 208, in __init__ raise ValueError('illegal version number') ValueError: illegal version number -- Apparently on Windows systems, there are UUIDs of type RFC_4122 being used which have versions not in 1..5, which actually makes them non-RFC 4122 compliant. Unfortunately I cannot investigate this further, since I do not have a windows machine available right now. -- nosy: +conqp ___ Python tracker <https://bugs.python.org/issue31958> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34732] uuid returns version more than 5
Richard Neumann added the comment: Typos: "For explicitely checking the version" → "For explicitely *setting* the version". "on not 1<= verision 1<=5" → "on not 1 <= version <= 5". -- ___ Python tracker <https://bugs.python.org/issue34732> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34732] uuid returns version more than 5
Richard Neumann added the comment: @xtreak RFC 4122, section 4.1.3. specifies only versions 1 to 5. For explicitely checking the version, there is already a test in UUID.__init__, raising a ValueError on not 1<= verision 1<=5. I moved it to the bottom of __init__, i.e. after setting the "int" property, causing the test to run on the actual instance's property value. -- ___ Python tracker <https://bugs.python.org/issue34732> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34732] uuid returns version more than 5
Richard Neumann added the comment: I'm not sure whether the property method should be changed. I think it'd be more appropriate to raise a value error upon __init__ in this case as it is done with other checks. -- nosy: +conqp ___ Python tracker <https://bugs.python.org/issue34732> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33028] tempfile.TemporaryDirectory incorrectly documented
New submission from Richard Neumann <r.neum...@homeinfo.de>: The tempfile.TemporaryDirectory is incorrectly documented at https://docs.python.org/3.6/library/tempfile.html#tempfile.TemporaryDirectory. It is described as a function, though actually being a class (unlinke tempfile.NamedTemporaryFile). The respective property "name" and method "cleanup" are only documented in the continuous text but not explicitely highlighted as the properties and method of e.g. TarFile (https://docs.python.org/3/library/tarfile.html#tarfile-objects). -- assignee: docs@python components: Documentation messages: 313431 nosy: Richard Neumann, docs@python priority: normal severity: normal status: open title: tempfile.TemporaryDirectory incorrectly documented type: enhancement versions: Python 3.6 ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33028> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32664] Connector "|" missing between ImportError and LookupError
New submission from Richard Neumann <r.neum...@homeinfo.de>: In the documentation of the built-in exceptions hierarchy, there is a "|" missing connecting ImportError and LookupError. https://docs.python.org/3/library/exceptions.html#exception-hierarchy >From LookupError.__mro__ we can tell, that it is actually derived from >Exception, thus there should be a "|" connecting it to the hierarchy under >Exception to emphasize that (like between ArithmeticError and AssertionError). -- assignee: docs@python components: Documentation messages: 310666 nosy: Richard Neumann, docs@python priority: normal severity: normal status: open title: Connector "|" missing between ImportError and LookupError type: enhancement versions: Python 3.6 ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32664> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31992] Make iteration over dict_items yield namedtuples
Richard Neumann <r.neum...@homeinfo.de> added the comment: Maybe there is no need to sacrifice performance, if a new, optional keyword argument would be introduced to dict.items(): def items(self, named=False): if named: else: Currently I need to define a namedtuple everywhere I do this and starmap the dicts' items. It'd be nice to have this option built-in or a new collections class like: from collections import namedtuple from itertools import starmap DictItem = namedtuple('DictItem', ('key', 'value')) class NamedDict(dict): """Dictionary that yields named tuples on item iterations.""" def items(self): """Yields DictItem named tuples.""" return starmap(DictItem, super().items()) -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31992> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31992] Make iteration over dict_items yield namedtuples
New submission from Richard Neumann <r.neum...@homeinfo.de>: Currently, iterating over dict_items will yield plain tuples, where the first item will be the key and the second item will be the respective value. This has some disadvantages when e.g. sorting dict items by value and key: def sort_by_value_len(dictionary): return sorted(dictionary.items(), key=lambda item: (len(item[1]), item[0])) I find this index accessing extremely unelegant and unnecessarily hard to read. If dict_items would instead yield namedtuples like DictItem = namedtuple('DictItem', ('key', 'value')) this would make constructs like def sort_by_value_len(dictionary): return sorted(dictionary.items(), key=lambda item: (len(item.value), item.key)) possible and increase code clarity a lot. Also, namedtuples mimic the behaviour of plain tuples regarding unpacking and index accessing, so that backward-compatipility should exist. -- components: Library (Lib) messages: 305970 nosy: Richard Neumann priority: normal severity: normal status: open title: Make iteration over dict_items yield namedtuples type: enhancement versions: Python 3.8 ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31992> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25452] Add __bool__() method to subprocess.CompletedProcess
Richard Neumann added the comment: Thank you for the hint. I never before contributed code to the python foundation and thus am not familiar with the process. I will look into it when I find the time. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25452> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25452] Add __bool__() method to subprocess.CompletedProcess
Richard Neumann added the comment: Please excuse my ambiguous phrasing. What I meant was I created the patch _from_ the Python 3.5.1 module _for_ Python 3.6. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25452> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25452] Add __bool__() method to subprocess.CompletedProcess
Richard Neumann added the comment: I took the liberty to create a patch for Python v3.5.1. -- keywords: +patch nosy: +Richard Neumann Added file: http://bugs.python.org/file42828/subprocess.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25452> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()
Changes by Richard Neumann <r.neum...@homeinfo.de>: Added file: http://bugs.python.org/file42827/logger.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26999> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()
Changes by Richard Neumann <r.neum...@homeinfo.de>: Removed file: http://bugs.python.org/file42825/logger.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26999> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()
Richard Neumann added the comment: Added proposed patch -- keywords: +patch Added file: http://bugs.python.org/file42825/logger.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26999> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()
Richard Neumann added the comment: PS: @vinay.sajip You do realize that I want this argument to be optional and to retain '.' as default setting in order to keep the current behaviour?! -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26999> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()
Richard Neumann added the comment: I am using loggers and sub-loggers (getChild()) in classes, which contain sub-classes, wich contain sub-sub-classes and so on for complex data processing. Hence I was using the logging library with sub-loggers to see in which of the (sub-)classes things happen. Most classes are, however, instanced for different configuration and are represented by strings like {instance_config}@{class_name} where {instance_config} often contains dots as separators for IDs. Example: INFO1000@TerminalsSyncer: Aggregating customer data: 1031002@Facebook INFO1000@TerminalsSyncer: Aggregating virtual data: v60.1031002@Config INFO1000@TerminalsSyncer: Aggregating virtual data: v60.1031002@Presentation WARNING 1000@TerminalsSyncer->1.1000@TerminalSyncer:Terminal 1.1000 is offline However, if you still think that this is not, what the logging library is meant for, I'd appreciate to know. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26999> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()
Changes by Richard Neumann <r.neum...@homeinfo.de>: -- title: Add child seperator keyword to logging.basicConfig and use it in Logger.getChild() -> Add child separator keyword to logging.basicConfig and use it in Logger.getChild() ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26999> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26999] Add child seperator keyword to logging.basicConfig and use it in Logger.getChild()
New submission from Richard Neumann: Currently Python's logging library has the Child-Separator hard-coded in Logger.getChild() as '.'. It would be useful to have the ability to preset this via an optional basicConfig() argument like 'child_sep=' and preset it to '.' to retain the current behaviour. In my case I will need to monkey-patch the getChild() method to use a different separator ('->') because I use '.' for different purposes within the loggers' names. The current behaviour would lead to ugly and mistakable output. -- components: Library (Lib) messages: 265312 nosy: Richard Neumann priority: normal severity: normal status: open title: Add child seperator keyword to logging.basicConfig and use it in Logger.getChild() type: enhancement versions: Python 3.5 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26999> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25452] Add __bool__() method to subprocess.CompletedProcess
Richard Neumann added the comment: A useless use case is attached. Basically it boils down to having the ability to evaluate the CompletedProcess directly by if/else rather than comparing its returncode attribute to zero each time or handling the exception raised by check_returncode(). I use this quite frequently in programs which run system commands. Before the new subprocess.run() method and subprocess.CompletedProcess were introduced with python 3.5 I already wrote my own library for that, wich now nearly became obsoleted by the new subprocess library of python 3.5 with the expection that it does not have this feature. See the class ProcessResult here: https://github.com/HOMEINFO/homeinfo-lib/blob/master/homeinfo/lib/system.py -- Added file: http://bugs.python.org/file40836/usecase.py ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25452> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25452] Add __bool__() method to subprocess.CompletedProcess
New submission from Richard Neumann: The class subprocess.CompletedProcess is currently lacking a __bool__() method. It might be a practical feature to have the possibility to evaluate a CompletedProcess instance in an if/else block without the necessity to handle the exception raised by CompletedProcess.check_returncode(). Hence, I suggest adding the method def __bool__(self): return self.returncode == 0 to the class. -- components: Library (Lib) messages: 253282 nosy: conqp priority: normal severity: normal status: open title: Add __bool__() method to subprocess.CompletedProcess type: enhancement versions: Python 3.5 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25452> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com