[issue36827] Overriding __new__ method with itself changes behaviour of the class

2019-05-11 Thread Alexey Muranov
Alexey Muranov added the comment: I see that I am not the only one who got bitten by this unexpected behaviour (though the others might have not realised it). There is a question ["Creating a singleton in Python"][1] on StackOverflow which was posted in 2011 and by now has the to

[issue36827] Overriding __new__ method with itself changes behaviour of the class

2019-05-07 Thread Alexey Muranov
Alexey Muranov added the comment: Here is an example of code where i got surprised by the current behaviour and had to apply some (ugly) workaround: https://gist.github.com/alexeymuranov/04e2807eb5679ac7e36da4454a58fa7e -- ___ Python tracker

[issue32768] object.__new__ does not accept arguments if __bases__ is changed

2019-05-07 Thread Alexey Muranov
Alexey Muranov added the comment: There were problems with the use case for mutable bases that i posted (see #36827). Here is an updated version: https://gist.github.com/alexeymuranov/04e2807eb5679ac7e36da4454a58fa7e -- ___ Python tracker

[issue36827] Overriding __new__ method with itself changes behaviour of the class

2019-05-07 Thread Alexey Muranov
Alexey Muranov added the comment: I've noticed some faults in my code examples: `super(__class__, __class__)` instead of a more appropriate `super(__class__, cls)`, forgotten `return` before `super(__class__, self).foo(*args, **kwarg)`, maybe there are more. I cannot edit previous com

[issue36827] Overriding __new__ method with itself changes behaviour of the class

2019-05-07 Thread Alexey Muranov
Alexey Muranov added the comment: Incidentally, the documentation gives the following signature of __new__: object.__new__(cls[, ...]) which suggests a variable number of arguments. -- ___ Python tracker <https://bugs.python.org/issue36

[issue36827] Overriding __new__ method with itself changes behaviour of the class

2019-05-07 Thread Alexey Muranov
Alexey Muranov added the comment: The issue is the following: i expect overriding a method with itself to not change behaviour of the class. I do not see how my understanding of `__new__` or its point could be relevant. Do we agree that overriding a method with itself should not change

[issue36827] Overriding __new__ method with itself changes behaviour of the class

2019-05-07 Thread Alexey Muranov
New submission from Alexey Muranov : I expect that overriding methods with themselves like in the following example should not change the behaviour of the class: class C: a = 1 def __init__(self, b): self.b = b def f(self, x): return x

[issue32768] object.__new__ does not accept arguments if __bases__ is changed

2019-05-07 Thread Alexey Muranov
Alexey Muranov added the comment: Here is a use case for writable bases: https://stackoverflow.com/q/56007866 class Stateful: """ Abstract base class for "stateful" classes. Subclasses must implement InitState mixin. """

[issue32768] object.__new__ does not accept arguments if __bases__ is changed

2019-05-07 Thread Alexey Muranov
Alexey Muranov added the comment: IMO "overriding" a method with itself should not change the behaviour. So it seems to me that the following is a bug: class C: def __init__(self, m): print(m) class D: @staticmethod

[issue26645] argparse prints help messages to stdout instead of stderr by default

2016-03-27 Thread Alexey Muranov
Alexey Muranov added the comment: My grep man page says --help Print a brief help message. but indeed there is no `--help` in usage message. Maybe this is a bug of the man page. Thanks for the explanation. -- ___ Python tracker <h

[issue26645] argparse prints help messages to stdout instead of stderr by default

2016-03-26 Thread Alexey Muranov
Alexey Muranov added the comment: Thanks for the explanation, this makes sense. I did not notice that argparse outputs to stderr if command line arguments are wrong, i was probably wrong when said it prints error messages to stdout. I did not notice indeed that there were no `-h` option in

[issue26645] argparse prints help messages to stdout instead of stderr by default

2016-03-26 Thread Alexey Muranov
New submission from Alexey Muranov: I believe that printing help and usage messages to stdout is a design error. In stdout i expect to find the output of my program, not help or diagnostic messages. It is strange to see nothing printed on the screen (where stderr usually goes), and then to