[issue27793] Double underscore variables in module are mangled when used in class

2020-03-06 Thread R. David Murray
R. David Murray added the comment: You are welcome to open a doc-enhancement issue for the global docs. For the other, as noted already if you want to advocate for a change to this behavior you need to start on python-ideas, but I don't think you will get any traction. Another possible enha

[issue27793] Double underscore variables in module are mangled when used in class

2020-03-06 Thread Jan Christoph
Jan Christoph added the comment: In particular, this might conflict with the documentation of global, which states: > If the target is an identifier (name): > >If the name does not occur in a global statement in the current code > block: the name is bound to the object in the current loc

[issue27793] Double underscore variables in module are mangled when used in class

2020-03-04 Thread Jan Christoph
Jan Christoph added the comment: Just because it is documented, doesn't mean it's not a bug or illogical and unexpected. -- ___ Python tracker ___ ___

[issue27793] Double underscore variables in module are mangled when used in class

2020-03-04 Thread Jan Christoph
Jan Christoph added the comment: I would argue to reopen this. Seeing I and other people run into that issue (e.g. https://stackoverflow.com/q/40883083/789308) quiet frequently. Especially since it breaks the `global` keyword, e.g.: __superprivate = "mahog" class AClass(object): def __i

[issue27793] Double underscore variables in module are mangled when used in class

2016-08-18 Thread R. David Murray
R. David Murray added the comment: This is working as designed (https://docs.python.org/3/tutorial/classes.html#private-variables): "This mangling is done without regard to the syntactic position of the identifier, as long as it occurs within the definition of a class." If you want to advocat

[issue27793] Double underscore variables in module are mangled when used in class

2016-08-18 Thread avraf
New submission from avraf: import re __no_spaces_pattern = r'\S+' __match_chars_until_space = re.compile(__no_spaces_pattern).match __match_chars_from_last_space = re.compile(__no_spaces_pattern + '$').match def __get_chars_until_space(name): return __match_chars_until_space(n