Re: [Python-ideas] Idea: msgfmt.py and pygettext..py should be -m executable modules

2018-07-30 Thread Petr Viktorin
On Mon, Jul 23, 2018 at 2:16 PM, Miro Hrončok wrote: > Currently, the documentation (as well as plenty of other places on the > Internet, such as Stack Overflow answers) mentions msgfmt.py and > pygettext.py. > > See https://docs.python.org/3/library/gettext.html > >> (Python also includes pure-Py

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-30 Thread Rhodri James
On 28/07/18 21:07, Abe Dillon wrote: [>> = Me] We could argue about how intuitive or not these operators are, but they are used in other languages, so they clearly aren't completely unintuitive. Other languages are other languages. Other languages use the " ? : " form of the the ternary operat

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-30 Thread Rhodri James
On 29/07/18 16:12, Abe Dillon wrote: spam?.eggs.cheese.aardvark # why would you ever do this? If you knew that if you really have something in "spam", your program guarantees it will have an "eggs" attribute with a "cheese" attribute, etc, you just don't know if "spam" is not None. It's the

[Python-ideas] Redefining method

2018-07-30 Thread Jamesie Pic
Hi all, Not sure if this subject has been brought up already, but why can't we redefine methods as such for example: c = MyClass o = c() def c.foo(cls): ... def o.bar(self): ... Thanks in advance for sharing some of your insight -- ∞ ___ Python-idea

Re: [Python-ideas] Idea: msgfmt.py and pygettext..py should be -m executable modules

2018-07-30 Thread Nick Timkovich
On Mon, Jul 30, 2018 at 8:43 AM, Petr Viktorin wrote: > On Mon, Jul 23, 2018 at 2:16 PM, Miro Hrončok wrote: > > > It might be: > > > > $ python3 -m gettext > > +1 > > > And: > > > > $ python3 -m gettext.msgfmt > > +1 > Note that this means gettext will need to become a package. > > > And (p

Re: [Python-ideas] Redefining method

2018-07-30 Thread Jonathan Fine
Hi Jamesie Thank you for your question. You asked why not > c = MyClass > o = c() > > def c.foo(cls): ... > def o.bar(self): ... I've the same same query, but never had the courage to ask. So that you for asking. And also giving me a chance to share my thoughts. In Ruby, I believe, you can 'open

Re: [Python-ideas] Redefining method

2018-07-30 Thread Nick Coghlan
On 31 July 2018 at 01:35, Jonathan Fine wrote: > Hi Jamesie > > Thank you for your question. You asked why not >> c = MyClass >> o = c() >> >> def c.foo(cls): ... >> def o.bar(self): ... > > I've the same same query, but never had the courage to ask. So that > you for asking. And also giving me a

Re: [Python-ideas] Idea: msgfmt.py and pygettext..py should be -m executable modules

2018-07-30 Thread Robert Vanden Eynde
Shortcuts designed for CLI are just to "be more mnemonic" have to be considered with caution. If gettext is a package, it means the whole python community shoud agree on that. msgfmt is part of gettext, so yes, python -m gettest.msgfmt is the best long lasting command. Or it could be 'python -m

Re: [Python-ideas] Idea: msgfmt.py and pygettext..py should be -m executable modules

2018-07-30 Thread Robert Vanden Eynde
Shortcuts designed for CLI are just to "be more mnemonic" have to be considered with caution. If gettext is a package, it means the whole python community shoud agree on that. msgfmt is part of gettext, so yes, python -m gettest.msgfmt is the best long lasting command. Or it could be 'python -m

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-30 Thread Abe Dillon
[Rhodri James] > We could argue about how intuitive or not these operators are, but they >>> are used in other languages, so they clearly aren't completely >>> unintuitive. >>> >> >> Other languages are other languages. Other languages use the " >> ? >> : " form of the the ternary operator. That

Re: [Python-ideas] Redefining method

2018-07-30 Thread Chris Barker via Python-ideas
On Mon, Jul 30, 2018 at 9:10 AM, Nick Coghlan wrote: If you need to replace them for some reason, it will preferably be > within a temporary bounded scope, using a tool like > unittest.mock.patch, rather than as a permanent change that affects > every other use of the class within the process.

[Python-ideas] Is this PEP-able? "with" statement inside genexps / list comprehensions

2018-07-30 Thread Rudy Matela
Hello, Do you think it would be nice to allow with statements inside genexps or list comprehensions? The functions __enter__ and __exit__ would be automatically called as iterables are traversed. I am thinking of drafting a PEP about this. Examples: This g = (f.read() for fn in file

Re: [Python-ideas] Redefining method

2018-07-30 Thread Kyle Lahnakoski
I think C# calls methods that are added to a class "extension methods". You can make a decorator that will do that for you: > def extend(cls): >     """ >     DECORATOR TO ADD METHODS TO CLASSES >     :param cls: THE CLASS TO ADD THE METHOD TO >     :return: >     """ >     def extender(func): >

Re: [Python-ideas] Is this PEP-able? "with" statement inside genexps / list comprehensions

2018-07-30 Thread Kyle Lahnakoski
Rudy, I think your proposal may be very specific to iterable context managers; in which case, make a method that makes that assumption: > def iter_with(obj): > with obj as context: > yield from context and use it > g = ( > f.read() > for fn in filenames > for f in iter_w

Re: [Python-ideas] Is this PEP-able? "with" statement inside genexps / list comprehensions

2018-07-30 Thread Oscar Benjamin
On 30 July 2018 at 20:15, Rudy Matela wrote: > Hello, Hi Rudy, > Do you think it would be nice to allow with statements inside genexps or > list comprehensions? The functions __enter__ and __exit__ would be > automatically called as iterables are traversed. I am thinking of > drafting a PEP ab

Re: [Python-ideas] Redefining method

2018-07-30 Thread Greg Ewing
Jamesie Pic wrote: def o.bar(self): ... You could get almost the same effect with from functools import partial def bar(self, other_args): ... o.bar = partial(bar, o) But IMO this is nowhere near being a common enough thing to do to justify having special syntax for it. -- G

Re: [Python-ideas] Idea: msgfmt.py and pygettext..py should be -m executable modules

2018-07-30 Thread Terry Reedy
On 7/30/2018 9:43 AM, Petr Viktorin wrote: On Mon, Jul 23, 2018 at 2:16 PM, Miro Hrončok wrote: $ python3 -m gettext.msgfmt +1 Note that this means gettext will need to become a package. Once there is a command line interface, arguments can be supplied to the module, as in python -m g

Re: [Python-ideas] Redefining method

2018-07-30 Thread Steven D'Aprano
On Tue, Jul 31, 2018 at 10:10:32AM +1200, Greg Ewing wrote: > Jamesie Pic wrote: > >def o.bar(self): ... > > You could get almost the same effect with > >from functools import partial > >def bar(self, other_args): > ... > >o.bar = partial(bar, o) Why are you using functools.p

Re: [Python-ideas] Redefining method

2018-07-30 Thread Stephan Houben
Here is an example of how it could be done. https://gist.github.com/stephanh42/97b47506e5e416f97f5790c070be7878 Stephan Op di 31 jul. 2018 01:29 schreef Steven D'Aprano : > On Tue, Jul 31, 2018 at 10:10:32AM +1200, Greg Ewing wrote: > > Jamesie Pic wrote: > > >def o.bar(self): ... > > > > You

Re: [Python-ideas] slice[] to get more complex slices

2018-07-30 Thread Stephan Hoyer
On Sat, Jul 28, 2018 at 9:44 AM Jonathan Fine wrote: > By all means start a PEP (on github) if you find it helps you. I think > it's too early. > > If this problem has a pure Python solution, then I think it best to > develop it as a third party module. I suggest the name slicetools. > When slice