[issue44523] weakref.proxy documentation might be outdated

2021-06-28 Thread Alexander Neumann
New submission from Alexander Neumann : The documentation currently states: > Proxy objects are not hashable regardless of the referent; this avoids a > number of problems related to their fundamentally mutable nature, and prevent > their use as dictionary keys. callback is

[issue41629] __class__ not set defining 'X' as

2021-01-06 Thread Richard Neumann
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): "&quo

[issue42765] Introduce new data model method __iter_items__

2021-01-06 Thread Richard Neumann
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

[issue42765] Introduce new data model method __iter_items__

2021-01-06 Thread Richard Neumann
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

[issue42768] super().__new__() of list expands arguments

2020-12-28 Thread Richard Neumann
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.

[issue42768] super().__new__() of list expands arguments

2020-12-28 Thread Richard Neumann
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

[issue42765] Introduce new data model method __iter_items__

2020-12-28 Thread Richard Neumann
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

[issue41795] Allow assignment in yield statement

2020-09-16 Thread Richard Neumann
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 <ht

[issue41795] Allow assignment in yield statement

2020-09-16 Thread Richard Neumann
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): "&qu

[issue40054] Allow formatted strings as docstrings

2020-03-24 Thread Richard Neumann
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'

[issue38241] Pickle with protocol=0 in python 3 does not produce a 'human-readable' format

2019-09-23 Thread Nicholas Neumann
Nicholas Neumann added the comment: Apologies as I'm not super-familiar with Latin1 or how Python refers to Latin1, but it seems a little odd to even call it Latin1. It can be decoded as Latin1, but it can contain every possible byte, including 0x7f through 0x9f, which aren't really Latin1

[issue38241] Pickle with protocol=0 in python 3 does not produce a 'human-readable' format

2019-09-21 Thread Nicholas Neumann
Nicholas Neumann added the comment: Wow, that's a great catch with bytearray on py2. Protocols 0-2 are all actually supposed to work with python 2, and I was using 0 from Py3 as it's the default for Py2, and what I want to use during a short transition where both Py3 and Py2 are operating

[issue38241] Pickle with protocol=0 in python 3 does not produce a 'human-readable' format

2019-09-20 Thread Nicholas Neumann
New submission from Nicholas Neumann : The docs for pickle, in python 2, say that the default pickle protocol, 0, produces ASCII. In the python 3 docs, this has changed to "human-readable". While the pickle output with protocol 0 loads fine in python2, it is definitely not huma

[issue37113] 'ß'.upper() should return 'ẞ'

2019-05-31 Thread Richard Neumann
Richard Neumann added the comment: See also: https://en.wikipedia.org/wiki/Capital_%E1%BA%9E -- ___ Python tracker <https://bugs.python.org/issue37113> ___ ___

[issue37113] 'ß'.upper() should return 'ẞ'

2019-05-31 Thread Richard Neumann
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

[issue34732] uuid returns version more than 5

2018-09-20 Thread Richard Neumann
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&qu

[issue31958] UUID versions are not validated to lie in the documented range

2018-09-19 Thread Richard Neumann
Richard Neumann added the comment: @xtreak Indeed. It fails on _windll_getnode(). == ERROR: test_windll_getnode (test.test_uuid.TestInternalsWithoutExtModule

[issue34732] uuid returns version more than 5

2018-09-19 Thread Richard Neumann
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". -- ___

[issue34732] uuid returns version more than 5

2018-09-19 Thread Richard Neumann
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 th

[issue34732] uuid returns version more than 5

2018-09-19 Thread Richard Neumann
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

[issue33249] Unpickling objects with recursive references and partials fail due to incomplete state passed to __setstate__

2018-04-09 Thread Alexander Neumann
Alexander Neumann <alen...@gmail.com> added the comment: Changed issue title to summarise the actual problem better. -- title: Pickling objects with recursive references and partials fail -> Unpickling objects with recursive references and partials fail due to incomplete sta

[issue33249] Pickling objects with recursive references and partials fail

2018-04-09 Thread Alexander Neumann
New submission from Alexander Neumann <alen...@gmail.com>: The code below causes a AttributeError: 'Event' object has no attribute 'name' It seems like the entries of `Machine.events` are not available during `__setstate__`. However, the behaviour depends on the Python v

[issue33028] tempfile.TemporaryDirectory incorrectly documented

2018-03-08 Thread Richard Neumann
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 (u

[issue32664] Connector "|" missing between ImportError and LookupError

2018-01-25 Thread Richard Neumann
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.

[issue31992] Make iteration over dict_items yield namedtuples

2017-11-10 Thread Richard Neumann
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

[issue31992] Make iteration over dict_items yield namedtuples

2017-11-09 Thread Richard Neumann
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:

[issue25452] Add __bool__() method to subprocess.CompletedProcess

2016-05-12 Thread Richard Neumann
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.

[issue25452] Add __bool__() method to subprocess.CompletedProcess

2016-05-12 Thread Richard Neumann
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/i

[issue25452] Add __bool__() method to subprocess.CompletedProcess

2016-05-12 Thread Richard Neumann
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>

[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()

2016-05-12 Thread Richard Neumann
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

[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()

2016-05-12 Thread Richard Neumann
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

[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()

2016-05-12 Thread Richard Neumann
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/i

[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()

2016-05-12 Thread Richard Neumann
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>

[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()

2016-05-12 Thread Richard Neumann
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

[issue26999] Add child separator keyword to logging.basicConfig and use it in Logger.getChild()

2016-05-11 Thread Richard Neumann
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() _

[issue26999] Add child seperator keyword to logging.basicConfig and use it in Logger.getChild()

2016-05-11 Thread Richard Neumann
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

[issue25452] Add __bool__() method to subprocess.CompletedProcess

2015-10-22 Thread Richard Neumann
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

[issue25452] Add __bool__() method to subprocess.CompletedProcess

2015-10-21 Thread Richard Neumann
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

Re: function that counts...

2010-05-19 Thread René 'Necoro' Neumann
Am 19.05.2010 21:58, schrieb superpollo: ... how many positive integers less than n have digits that sum up to m: In [197]: def prttn(m, n): tot = 0 for i in range(n): s = str(i) sum = 0 for j in range(len(s)): sum += int(s[j]) if sum

Re: function that counts...

2010-05-19 Thread René 'Necoro' Neumann
Am 19.05.2010 22:58, schrieb superpollo: In [277]: prttn(25, 1) Out[277]: 348 In [278]: prttn2(25, 1) Out[278]: 348 In [279]: prttn3(25, 1) Out[279]: 348 ok, bye! Just because I was curios: nec...@zakarumiy ~ % python -m timeit import test; test.prttn(25,1) 10

Re: recall function definition from shell

2010-05-18 Thread René 'Necoro' Neumann
Am 18.05.2010 20:55, schrieb superpollo: yes python does not, but maybe the *shell* does, or so i thought. i just wanted to dump the code for the function in a file, after i tested in the shell... You might want to have a look at the IPython shell [1]. I personally do not use it myself, but

Re: object vs class oriented -- xotcl

2008-01-31 Thread neumann
On 29 Jan., 19:22, William Pursell [EMAIL PROTECTED] wrote: I believe per object mixin is the correct term for such an animal. The first several google hits on that phrase all reference xotcl, so I'm not sure if that is an xotcl inspired vocabulary that isn't really standard. well, it

Re: removing characters before writing to file

2006-02-09 Thread Stefan Neumann
[EMAIL PROTECTED] wrote: hi i have some output that returns a lines of tuples eg ('sometext1', 1421248118, 1, 'P ') ('sometext2', 1421248338, 2, 'S ') and so on If the braces are always at the begining and at the end of the string, you could also use: ('sometext1',

Daemon terminates unexpected

2006-02-06 Thread Stefan Neumann
I have written a daemon which should run endlessly. The structure looks like this: - start-stop-daemon forks my python program then: if __name__==__main__: try: main() except Exception,e write exception def main(): # I need a starter to use the program also from the

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Stefan Neumann
Danny wrote: How could I make this print: texttexttexttexttext? Ive researched and looked through google and so far I can't find anything that will help (or revelent for that matter). I am not quite sure, if I simplify the problem but i thought about something like that: print