Re: [Python-ideas] Delay evaluation of annotations

2016-09-27 Thread Neil Girdhar
On Friday, September 23, 2016 at 2:23:58 AM UTC-4, Nick Coghlan wrote: > > On 23 September 2016 at 15:50, Greg Ewing > wrote: > > אלעזר wrote: > >> > >> it feels like a > >> placeholder for this meaning would be better. E.g.: > >> > >> class A: > >> def __add__(self, other:

Re: [Python-ideas] Delay evaluation of annotations

2016-09-27 Thread Neil Girdhar
I really like this idea, and in the rare case that someone adds an element to a class with the same name as the class that would shadow your definition, but that seems fine to me. On Thursday, September 22, 2016 at 11:09:28 PM UTC-4, Nick Coghlan wrote: > > On 23 September 2016 at 12:05, אלעזר

Re: [Python-ideas] Delay evaluation of annotations

2016-09-27 Thread Nick Coghlan
On 27 September 2016 at 17:29, Neil Girdhar wrote: > On Friday, September 23, 2016 at 2:23:58 AM UTC-4, Nick Coghlan wrote: >> The difference between that and the "methods referring to the class >> they're defined in" case is that it's likely to be pretty normal to >> want to do the latter, so it

Re: [Python-ideas] Delay evaluation of annotations

2016-09-27 Thread Stephen J. Turnbull
Neil Girdhar writes: > I agree that circularity should in general be avoided, but it's not always > possible or elegant to do that. Sometimes you really need two classes to > refer to each other. In that case, why not expose your placeholder idea to > the user via a library? Why not just

Re: [Python-ideas] Delay evaluation of annotations

2016-09-27 Thread Neil Girdhar
I don't understand why that would work and this clearly doesn't? Mutual2 = "Mutual2" # Pre-declare Mutual2 class Mutual1: def spam(self, x=Mutual2): print(type(x)) class Mutual2: def spam(self): pass Mutual1().spam() prints class "str" rather than "type". On Tue, Sep

Re: [Python-ideas] Delay evaluation of annotations

2016-09-27 Thread Oleg Broytman
On Tue, Sep 27, 2016 at 11:54:40AM +, Neil Girdhar wrote: > I don't understand why that would work and this clearly doesn't? > > Mutual2 = "Mutual2" # Pre-declare Mutual2 > > class Mutual1: > def spam(self, x=Mutual2): ^^^ - calculated at compile time,

Re: [Python-ideas] Delay evaluation of annotations

2016-09-27 Thread Neil Girdhar
Yes, I understand that, but I don't see how that would help at all with annotations. Aren't annotations also evaluated at "compile time"? On Tue, Sep 27, 2016 at 8:14 AM Oleg Broytman wrote: > On Tue, Sep 27, 2016 at 11:54:40AM +, Neil Girdhar < > mistersh...@gmail.com> wrote: > > I don't u

Re: [Python-ideas] Delay evaluation of annotations

2016-09-27 Thread Paul Moore
On 27 September 2016 at 13:46, Neil Girdhar wrote: > Yes, I understand that, but I don't see how that would help at all with > annotations. Aren't annotations also evaluated at "compile time"? Yes, but a string whose value is a class name is treated as being the same annotation (i.e., meaning th

Re: [Python-ideas] Delay evaluation of annotations

2016-09-27 Thread Neil Girdhar
On Tue, Sep 27, 2016 at 5:01 AM Nick Coghlan wrote: > On 27 September 2016 at 17:29, Neil Girdhar wrote: > > On Friday, September 23, 2016 at 2:23:58 AM UTC-4, Nick Coghlan wrote: > >> The difference between that and the "methods referring to the class > >> they're defined in" case is that it's

Re: [Python-ideas] Delay evaluation of annotations

2016-09-27 Thread Nick Coghlan
On 27 September 2016 at 22:46, Neil Girdhar wrote: > Yes, I understand that, but I don't see how that would help at all with > annotations. Aren't annotations also evaluated at "compile time"? This thread isn't about circular references in general, just circular references in the context of type

Re: [Python-ideas] if-statement in for-loop

2016-09-27 Thread Erik Bray
On Sun, Sep 11, 2016 at 12:28 PM, Bernardo Sulzbach wrote: > On 09/11/2016 06:36 AM, Dominik Gresch wrote: >> >> So I asked myself if a syntax as follows would be possible: >> >> for i in range(10) if i != 5: >> body >> >> Personally, I find this extremely intuitive since this kind of >> if-st

Re: [Python-ideas] if-statement in for-loop

2016-09-27 Thread Nick Coghlan
On 28 September 2016 at 00:55, Erik Bray wrote: > On Sun, Sep 11, 2016 at 12:28 PM, Bernardo Sulzbach > wrote: >> On 09/11/2016 06:36 AM, Dominik Gresch wrote: >>> >>> So I asked myself if a syntax as follows would be possible: >>> >>> for i in range(10) if i != 5: >>> body >>> >>> Personally

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-27 Thread Dennis Brakhane via Python-ideas
I don't know if it works on Windows, but at least in Linux pressing Ctrl-L will do exactly what you describe (as long as the REPL uses readline) On 17.09.2016 12:51, João Matos wrote: > Hello, > > I would like to suggest adding a clear command (not function) to Python. > It's simple purpose would

Re: [Python-ideas] if-statement in for-loop

2016-09-27 Thread Erik Bray
On Tue, Sep 27, 2016 at 5:33 PM, Nick Coghlan wrote: > On 28 September 2016 at 00:55, Erik Bray wrote: >> On Sun, Sep 11, 2016 at 12:28 PM, Bernardo Sulzbach >> wrote: >>> On 09/11/2016 06:36 AM, Dominik Gresch wrote: So I asked myself if a syntax as follows would be possible: >>>

Re: [Python-ideas] if-statement in for-loop

2016-09-27 Thread Paul Moore
On 27 September 2016 at 16:54, Erik Bray wrote: > Then following my own logic it > would be desirable to also allow the nested for loop syntax of list > comprehensions outside them as well. I'd say that it's a case where we should either allow arbitrary concatenation outside of comprehensions, or

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-27 Thread João Matos
Hello, It doesn't work in Windows. Best regards, JM terça-feira, 27 de Setembro de 2016 às 16:40:42 UTC+1, Dennis Brakhane via Python-ideas escreveu: > I don't know if it works on Windows, but at least in Linux pressing > Ctrl-L will do exactly what you describe (as long as the REPL uses

Re: [Python-ideas] if-statement in for-loop

2016-09-27 Thread Greg Ewing
Erik Bray wrote: Then following my own logic it would be desirable to also allow the nested for loop syntax of list comprehensions outside them as well. The only use for such a syntax would be to put an inadvisable amount of stuff on one line. When describing a procedural series of steps, the