Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-16 Thread Andrey Tatarinov
Nick Coghlan wrote: # Anonymous functions use res: def f(x): d = {} exec x in d return d in: res = [f(i) for i in executable] as for me, I found construction "use :" unobvious and confusing. Also there is great possibility to forget some of variables names. I think that syntax wher

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Steve Holden
Paul Rubin wrote: "Fredrik Lundh" <[EMAIL PROTECTED]> writes: Huh? Expressions are not statements except when they're "expression statements"? What kind of expression is not an expression statement? any expression that is used in a content that is not an expression statement, of course. Come on

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Roel Schroeven
Antoon Pardon wrote: Op 2005-01-14, Roel Schroeven schreef <[EMAIL PROTECTED]>: Antoon Pardon wrote: IMO we have a: dogs are mamals kind of relationship in Python. I see what you mean, but I don't think it's true. Every expression can be used where a statement is expected. (And this can be worded

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Fredrik Lundh
Antoon Pardon wrote: > Well IMO I have explained clearly that I understood this in a set > logical sense in my first response. what does "first" mean on your planet? -- http://mail.python.org/mailman/listinfo/python-list

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Antoon Pardon
Op 2005-01-14, Roel Schroeven schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> IMO we have a: dogs are mamals kind of relationship in Python. > > I see what you mean, but I don't think it's true. > >> Every expression can be used where a statement is expected. >> (And this can be worded as: e

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Roel Schroeven
Antoon Pardon wrote: IMO we have a: dogs are mamals kind of relationship in Python. I see what you mean, but I don't think it's true. Every expression can be used where a statement is expected. (And this can be worded as: every expression is a statement.) Not really. An expression statement is a st

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Roel Schroeven
Skip Montanaro wrote: Fredrik> no, expressions CAN BE USED as statements. that doesn't mean Fredrik> that they ARE statements, unless you're applying belgian logic. Hmmm... I'd never heard the term "belgian logic" before. Googling provided a few uses, but no formal definition (maybe it's

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Carl Banks
Tim Jarman wrote: > IANA French person, but I believe that Belgians are traditionally > regarded as stupid in French culture, so "Belgian logic" would be > similar to "Irish logic" for an English person. (Feel free to insert > your own cultural stereotypes as required. :) Ok. http://www.urbandic

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Tim Jarman
Skip Montanaro wrote: > > Fredrik> no, expressions CAN BE USED as statements. that doesn't mean > Fredrik> that they ARE statements, unless you're applying belgian > logic. > > Hmmm... I'd never heard the term "belgian logic" before. Googling > provided a few uses, but no formal d

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Peter Maas
Craig Ringer schrieb: And then we have iteration (generator expressions, list comprehensions, for loops, ...?) over (sequences, iterators, generators) Just sequences and iterators. Generators are functions which return iterators. Sequences and iterators provide two ways to build containers. My

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-14 Thread Nick Coghlan
Nick Coghlan wrote: as equivalent to: def __use_stmt(): def _in_clause(): return return _in_clause() __use_stmt_args = {} = __use_stmt() del __use_stmt The more I think about this return-based approach, the less I like it. It could probably be made to work, but it just feels like

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Carl Banks
Skip Montanaro wrote: > Fredrik> no, expressions CAN BE USED as statements. that doesn't mean > Fredrik> that they ARE statements, unless you're applying belgian logic. > > Hmmm... I'd never heard the term "belgian logic" before. Googling provided > a few uses, but no formal definition (may

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Antoon Pardon
Op 2005-01-14, Fredrik Lundh schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: > >>> no, expressions CAN BE USED as statements. that doesn't mean >>> that they ARE statements, unless you're applying belgian logic. >> >> No I am applying set logic. Any string that is in the set of >> valid expres

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Skip Montanaro
Fredrik> no, expressions CAN BE USED as statements. that doesn't mean Fredrik> that they ARE statements, unless you're applying belgian logic. Hmmm... I'd never heard the term "belgian logic" before. Googling provided a few uses, but no formal definition (maybe it's a European phrase s

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Antoon Pardon
Op 2005-01-14, Nick Coghlan schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> No I am applying set logic. Any string that is in the set of >> valid expressions is also in the set of valid statements. > > According to Python's grammar, this is not the case. It requires a NEWLINE or > ";" token

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Fredrik Lundh
Antoon Pardon wrote: >> no, expressions CAN BE USED as statements. that doesn't mean >> that they ARE statements, unless you're applying belgian logic. > > No I am applying set logic. Any string that is in the set of > valid expressions is also in the set of valid statements. since you're arguin

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Nick Coghlan
Antoon Pardon wrote: No I am applying set logic. Any string that is in the set of valid expressions is also in the set of valid statements. According to Python's grammar, this is not the case. It requires a NEWLINE or ";" token on the end to turn the expression into a statement. Actually appending

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Antoon Pardon
Op 2005-01-14, Fredrik Lundh schreef <[EMAIL PROTECTED]>: > Paul Rubin wrote: > >>> > Huh? Expressions are not statements except when they're "expression >>> > statements"? What kind of expression is not an expression statement? >>> >>> any expression that is used in a content that is not an expr

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Antoon Pardon
Op 2005-01-13, Terry Reedy schreef <[EMAIL PROTECTED]>: > > "Antoon Pardon" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Op 2005-01-13, Fredrik Lundh schreef <[EMAIL PROTECTED]>: >>> Antoon Pardon wrote: >>> Well, it seems that Guido is wrong then. The documentation clearl

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-14 Thread Fredrik Lundh
Paul Rubin wrote: >> > Huh? Expressions are not statements except when they're "expression >> > statements"? What kind of expression is not an expression statement? >> >> any expression that is used in a content that is not an expression statement, >> of course. > > Come on, that is vacuous. Th

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Paul Rubin
Nick Coghlan <[EMAIL PROTECTED]> writes: > So, precisely how should one go about cleanly embedding something that > cares about whitespace into a context which doesn't care in the > slightest? Treat the macro like a function call whose arguments are thunks made from the macro arguments, or somethi

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Nick Coghlan
Paul Rubin wrote: Come on, that is vacuous. The claim was "expressions are not statements". But it turns out that expressions ARE statements. The explanation is "well, that's because they're expression statements". And there is no obvious case of an expression that can't be used as a statement.

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-13 Thread Nick Coghlan
Bengt Richter wrote: Problems? (Besides NIH, which I struggle with regularly, and had to overcome to accept Tim's starting point in this ;-) The ideas regarding creating blocks whose name bindings affect a different scope are certainly interesting (and relevant to the 'using' out-of-order executi

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Paul Rubin
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > > Huh? Expressions are not statements except when they're "expression > > statements"? What kind of expression is not an expression statement? > > any expression that is used in a content that is not an expression statement, > of course. Come on, th

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Fredrik Lundh
Bengt Richter wrote: > Hm, that makes me wonder, is there an intermediate "returning of value" in >x = y = z = 123 > ? no. that statement evaluates the expression (123 in this case), and assigns the result (the integer object 123) to each target (x, y, z), in order. or to quote the languag

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Bengt Richter
On Thu, 13 Jan 2005 09:29:49 -0500, Steve Holden <[EMAIL PROTECTED]> wrote: >Fredrik Lundh wrote: > >> Antoon Pardon wrote: >> >> >>>Well, it seems that Guido is wrong then. The documentation clearly >>>states that an expression is a statement. >> >> >> no, it says that an expression statement

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Fredrik Lundh
Paul Rubin wrote: > Huh? Expressions are not statements except when they're "expression > statements"? What kind of expression is not an expression statement? any expression that is used in a content that is not an expression statement, of course. reading the python language reference should h

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-13 Thread Bengt Richter
On Fri, 14 Jan 2005 01:48:48 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote: >Nick Coghlan wrote: >> Semantics >> - >> The code:: >> >> with: >> >> >> translates to:: >> >> def unique_name(): >> >> >> unique_name() > >I've come to the conclusion that these semantics aren't

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Paul Rubin
"Terry Reedy" <[EMAIL PROTECTED]> writes: > >>> Well, it seems that Guido is wrong then. The documentation clearly > >>> states that an expression is a statement. > >> > >> no, it says that an expression statement is a statement. if you don't > >> understand the difference, please *plonk* yourself

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-13 Thread Bengt Richter
On Thu, 13 Jan 2005 22:41:54 +0300, Andrey Tatarinov <[EMAIL PROTECTED]> wrote: >Nick Coghlan wrote: >> Nick Coghlan wrote: >> >>> Semantics >>> - >>> The code:: >>> >>> with: >>> >>> >>> translates to:: >>> >>> def unique_name(): >>> >>> >>> unique_name() >> I've come to t

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Terry Reedy
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Op 2005-01-13, Fredrik Lundh schreef <[EMAIL PROTECTED]>: >> Antoon Pardon wrote: >> >>> Well, it seems that Guido is wrong then. The documentation clearly >>> states that an expression is a statement. >> >> no, it says

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-13 Thread Andrey Tatarinov
Nick Coghlan wrote: Nick Coghlan wrote: Semantics - The code:: with: translates to:: def unique_name(): unique_name() I've come to the conclusion that these semantics aren't what I would expect from the construct. Exactly what I would expect can't really be expressed in cur

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Craig Ringer
On Thu, 2005-01-13 at 08:39 +, Antoon Pardon wrote: > > At best it would offer new paradigms for existing constructs (violating > > the "there should be one obvious way to do it" zen); at worst it would > > obfuscate the whole language. > > That zen is already broken. Look at the number of

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-13 Thread Jeff Shannon
Nick Coghlan wrote: def f(): a = 1 b = 2 print 1, locals() print 3, locals() using: a = 2 c = 3 print 2, locals() print 4, locals() I think the least suprising result would be: 1 {'a': 1, 'b': 2} # Outer scope 2 {'a': 2, 'c': 3} # Inner sc

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-13 Thread Nick Coghlan
Nick Coghlan wrote: Semantics - The code:: with: translates to:: def unique_name(): unique_name() I've come to the conclusion that these semantics aren't what I would expect from the construct. Exactly what I would expect can't really be expressed in current Python due to t

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Steve Holden
Fredrik Lundh wrote: Antoon Pardon wrote: Well, it seems that Guido is wrong then. The documentation clearly states that an expression is a statement. no, it says that an expression statement is a statement. if you don't understand the difference, please *plonk* yourself. OK then, "The documenta

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Antoon Pardon
Op 2005-01-13, Fredrik Lundh schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: > >> Well, it seems that Guido is wrong then. The documentation clearly >> states that an expression is a statement. > > no, it says that an expression statement is a statement. if you don't > understand the differenc

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Fredrik Lundh
Antoon Pardon wrote: > Well, it seems that Guido is wrong then. The documentation clearly > states that an expression is a statement. no, it says that an expression statement is a statement. if you don't understand the difference, please *plonk* yourself. -- http://mail.python.org/mailman

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-13 Thread Antoon Pardon
Op 2005-01-12, Steve Holden schreef <[EMAIL PROTECTED]>: > > Given that Guido is on record as saying that expressions aren't > statements because he wants those things to be separate, I don't really > see why there's this consistent pressure to reverse that decision. Well, it seems that Guido is

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-12 Thread Steve Holden
Paul Rubin wrote: [EMAIL PROTECTED] writes: I can't imagine how it could be worse than the learning curve of __metaclass__, which we already have. To me, learning macros *and their subtilities* was much more difficult than learning metaclasses. I guess I've only used Lisp macros in pretty straight

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-12 Thread Steve Holden
Paul Rubin wrote: [EMAIL PROTECTED] writes: 2. One could proposed hygienic pattern-matching macros in Python, similar to Scheme syntax-rules macros. Again, it is not obvious how to implement pattern-matching in Python in a non-butt-ugly way. Plus, I feel hygienic macros quite limited and not worth

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-12 Thread Paul Rubin
[EMAIL PROTECTED] writes: > > I can't imagine how it could be worse than the learning curve of > > __metaclass__, which we already have. > > To me, learning macros *and their subtilities* was much more difficult > than learning metaclasses. I guess I've only used Lisp macros in pretty straightfor

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-12 Thread Simo Melenius
[EMAIL PROTECTED] writes: > This is a bizarre idea if you want to make Python run faster. It is > not so bizarre if what you want is to have access to Python from > Lisp/Scheme in the same sense Jython has access to Java. And it sounds very nice if you prefer writing Lisp code (or resort to it if

Re: python3: 'where' keyword

2005-01-12 Thread Antoon Pardon
Op 2005-01-11, Jeff Shannon schreef <[EMAIL PROTECTED]>: > Paul Rubin wrote: > >> Steve Holden <[EMAIL PROTECTED]> writes: >> >>>[...] and if you think that >>>newbies will have their lives made easier by the addition of ad hoc >>>syntax extensions then you and I come from a different world (and I

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-11 Thread michele . simionato
Paul Rubin: > [EMAIL PROTECTED] writes: >> > It wasn't obvious how to do it in Scheme either. There was quite > a bit of head scratching and experimental implementation before > there was consensus. Actually I am not convinced there is consensus yet, i.e. there is a non-negligible minority of s

Re: python and macros (again) [Was: python3: 'where' keyword]

2005-01-11 Thread Paul Rubin
[EMAIL PROTECTED] writes: > 2. One could proposed hygienic pattern-matching macros in Python, > similar to > Scheme syntax-rules macros. Again, it is not obvious how to > implement pattern-matching in Python in a non-butt-ugly way. Plus, > I feel hygienic macros quite limited and not worth the effo

Re: python3: 'where' keyword

2005-01-11 Thread Jeff Shannon
Paul Rubin wrote: Steve Holden <[EMAIL PROTECTED]> writes: [...] and if you think that newbies will have their lives made easier by the addition of ad hoc syntax extensions then you and I come from a different world (and I suspect the walls might be considerably harder in mine than in yours). I'm s

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-11 Thread Andrey Tatarinov
So of the four keywords suggested so far ('where', 'with', 'in', 'using'), I'd currently vote for 'using' with 'where' a fairly close second. My vote goes to 'using' because it has a fairly clear meaning ('execute the statement using this extra information'), and doesn't have the conflicting ex

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-11 Thread Nick Coghlan
Andrey Tatarinov wrote: I think using 'with' keyword can cause some ambiguity. for example I would surely try to write >>> x = a+b with self: >>> b = member and using with at the end of block brings more ambiguity: >>> stmt1() >>> stmt2() >>> with self: >>> member = stmt3() compare

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-11 Thread Nick Coghlan
Andrey Tatarinov wrote: afair you told yourself that var = where: translates to: def unique_name(): return var = unique_name() in this case class gets unique_name() function? is it that bad? No, I wasn't thinking clearly and saw problems that weren't there. However, you're right tha

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-11 Thread Nick Coghlan
Nick Coghlan wrote: Nick Coghlan wrote: Semantics - The code:: with: translates to:: def unique_name(): unique_name() Bleh. Not only was my proposed grammar change wrong, my suggested semantics are wrong, too. Raise your hand if you can see the problem with applying the abo

python and macros (again) [Was: python3: 'where' keyword]

2005-01-11 Thread michele . simionato
Paul Rubin wrote: > How about macros? Some pretty horrible things have been done in C > programs with the C preprocessor. But there's a movememnt afloat to > add hygienic macros to Python. Got any thoughts about that? "Movement" seems quite an exaggeration. Maybe 2-3 people made some experiments,

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-11 Thread Andrey Tatarinov
Nick Coghlan wrote: Semantics - The code:: with: translates to:: def unique_name(): unique_name() Bleh. Not only was my proposed grammar change wrong, my suggested semantics are wrong, too. Raise your hand if you can see the problem with applying the above semantics to the

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-11 Thread Nick Coghlan
Nick Coghlan wrote: Semantics - The code:: with: translates to:: def unique_name(): unique_name() Bleh. Not only was my proposed grammar change wrong, my suggested semantics are wrong, too. Raise your hand if you can see the problem with applying the above semantics to the

Re: python3: 'where' keyword

2005-01-11 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > Well I for one disagreed with many of your estimates of the zen's > applicability to macros, but I just couldn't be arsed saying so. Well, I was being somewhat flip with them, as I felt Carl was being snotty in referring me to the Zen list. The point the

Re: python3: 'where' keyword

2005-01-10 Thread Steve Holden
Paul Rubin wrote: "Carl Banks" <[EMAIL PROTECTED]> writes: When I asked you to do this, it was just a rhetorical way to tell you that I didn't intend to play this game. It's plain as day you're trying to get me to admit something. I'm not falling for it. If you have a point to make, why don't you

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-10 Thread Andrey Tatarinov
Nick Coghlan wrote: Abstract The proposal is to add the capacity for statement local namespaces to Python. This allows a statement to be placed at the current scope, while the statement's 'setup code' is indented after the statement:: with: I think using 'with' keyword can c

Re: python3: 'where' keyword

2005-01-10 Thread Andrey Tatarinov
Nick Coghlan wrote: And about examples for usage "where" keyword reading http://manatee.mojam.com/~skip/python/fastpython.html I understand that almost every example should use that keyword =) I suspect polluting the outer namespace would still be faster, since Python wouldn't have to create the

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-10 Thread Anna
+1 I really like the idea of this. It removes all my objections to lambdas, and replaces it with something clear and readable. I look forward to seeing what comes of it. Anna -- http://mail.python.org/mailman/listinfo/python-list

Re: python3: 'where' keyword

2005-01-10 Thread Carl Banks
Paul Rubin wrote: > "Carl Banks" <[EMAIL PROTECTED]> writes: > > When I asked you to do this, it was just a rhetorical way to tell you > > that I didn't intend to play this game. It's plain as day you're > > trying to get me to admit something. I'm not falling for it. > > > > If you have a point

Re: python3: 'where' keyword

2005-01-10 Thread Paul Rubin
"Carl Banks" <[EMAIL PROTECTED]> writes: > When I asked you to do this, it was just a rhetorical way to tell you > that I didn't intend to play this game. It's plain as day you're > trying to get me to admit something. I'm not falling for it. > > If you have a point to make, why don't you just m

Re: python3: 'where' keyword

2005-01-10 Thread Carl Banks
Paul Rubin wrote: > > The Zen of Python, by Tim Peters > > Beautiful is better than ugly. => +1 macros > Explicit is better than implicit. => +1 macros > Simple is better than complex. => +1 macros > Complex is better than complicated. => I don't understand this, +0 > Fl

Re: python3: 'where' keyword

2005-01-10 Thread Jonas Galvez
Andrey Tatarinov wrote: > It would be great to be able to reverse usage/definition parts > in haskell-way with "where" keyword. Hi folks, I really like this idea. But I couldn't help but think of a few alternative ways. I'm no language design expert by any means, but I'm a little concerned with

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-10 Thread Nick Coghlan
Nick Coghlan wrote: Disallowing local namespaces for statement lists would suggest something like this: statement ::= (simple_stmt (NEWLINE | ";" stmt_list NEWLINE | local_namespace) ) | (compound_stmt [local_namespace]) local_namespace ::= "

Re: python3: 'where' keyword

2005-01-10 Thread Paul Rubin
"Carl Banks" <[EMAIL PROTECTED]> writes: > Paul Rubin wrote: > > "Carl Banks" <[EMAIL PROTECTED]> writes: > > > > So do you approve of the movement to get rid of the print > statement? > > > > > > Any little incremental change in Python you could make by having or > not > > > having a print statem

Re: python3: 'where' keyword

2005-01-10 Thread Carl Banks
Paul Rubin wrote: > "Carl Banks" <[EMAIL PROTECTED]> writes: > > > So do you approve of the movement to get rid of the print statement? > > > > Any little incremental change in Python you could make by having or not > > having a print statement would be minor compared to the H-Bomb of > > ugliness

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-10 Thread Nick Coghlan
Duncan Booth wrote: Nick Coghlan wrote: Grammar Change -- Current:: statement ::=stmt_list NEWLINE | compound_stmt New:: statement ::=(stmt_list NEWLINE | compound_stmt) [local_namespace] local_namespace ::= "with" ":" suite Semantics - The code:: with: trans

Re: python3: 'where' keyword

2005-01-10 Thread Paul Rubin
"Carl Banks" <[EMAIL PROTECTED]> writes: > > So do you approve of the movement to get rid of the print statement? > > Any little incremental change in Python you could make by having or not > having a print statement would be minor compared to the H-Bomb of > ugliness we'd get if suites of stateme

Re: python3: 'where' keyword

2005-01-10 Thread Carl Banks
Paul Rubin wrote: > "Carl Banks" <[EMAIL PROTECTED]> writes: > > And a suite, be it a def statement, a where block, or whatever, belongs > > in a statement, not an expression. > > So do you approve of the movement to get rid of the print statement? Any little incremental change in Python you coul

Re: python3: 'where' keyword

2005-01-10 Thread Nick Coghlan
Andrey Tatarinov wrote: And about examples for usage "where" keyword reading http://manatee.mojam.com/~skip/python/fastpython.html I understand that almost every example should use that keyword =) I suspect polluting the outer namespace would still be faster, since Python wouldn't have to create

Re: Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-10 Thread Duncan Booth
Nick Coghlan wrote: > Grammar Change > -- > Current:: >statement ::=stmt_list NEWLINE | compound_stmt > > New:: >statement ::=(stmt_list NEWLINE | compound_stmt) [local_namespace] >local_namespace ::= "with" ":" suite > > > Semantics > - > The code:: > >

Re: python3: 'where' keyword

2005-01-09 Thread Paul Rubin
"Carl Banks" <[EMAIL PROTECTED]> writes: > And a suite, be it a def statement, a where block, or whatever, belongs > in a statement, not an expression. So do you approve of the movement to get rid of the print statement? -- http://mail.python.org/mailman/listinfo/python-list

Re: python3: 'where' keyword

2005-01-09 Thread Carl Banks
Paul Rubin wrote: > Nick Coghlan <[EMAIL PROTECTED]> writes: > > Trying to push it a level further (down to expressions) would, IMO, be > > a lot of effort for something which would hurt readability a lot. > > I think we should just try to do things in a simple and general way > and not try to enf

Re: python3: 'where' keyword

2005-01-09 Thread Bengt Richter
On 09 Jan 2005 03:10:15 -0800, Paul Rubin wrote: >Nick Coghlan <[EMAIL PROTECTED]> writes: >> Trying to push it a level further (down to expressions) would, IMO, be >> a lot of effort for something which would hurt readability a lot. > >I think we should just try to do t

Re: python3: 'where' keyword

2005-01-09 Thread Steve Holden
Alex Martelli wrote: AdSR <[EMAIL PROTECTED]> wrote: I don't know haskell, but it looks SQL-ish to me (only by loose Indeed, the fact that many MANY more people are familiar with SQL than with Haskell may be the strongest practical objection to this choice of syntax sugar; the WHERE clause in an

Re: python3: 'where' keyword

2005-01-09 Thread Andrey Tatarinov
And about examples for usage "where" keyword reading http://manatee.mojam.com/~skip/python/fastpython.html I understand that almost every example should use that keyword =) -- http://mail.python.org/mailman/listinfo/python-list

Re: python3: 'where' keyword

2005-01-09 Thread Andrey Tatarinov
Alex Martelli wrote: Indeed, the fact that many MANY more people are familiar with SQL than with Haskell may be the strongest practical objection to this choice of syntax sugar; the WHERE clause in an SQL SELECT has such wildly different semantics from Haskell's "where" that it might engender huge

Statement local namespaces summary (was Re: python3: 'where' keyword)

2005-01-09 Thread Nick Coghlan
Andrey Tatarinov wrote: So it seems that people loved the idea of 'where' keyword, may be it's time to think about PEP draft? I appreciate any help (cause my english is not that good =)). There's certainly a PEP in the idea. Here's a summary of what we have so far in this thread in a PEPish form

Re: python3: 'where' keyword

2005-01-09 Thread Andrey Tatarinov
Paul Rubin wrote: What would be the advantage of that over this? . x = sqrt(a) + sqrt(b) where: . a = 2.0 . b = 3.0 The idea of "where" is to allow re-using variable names instead of having to keep track of which ones are in use. I just tried to give a very simple example of how you might

Re: python3: 'where' keyword

2005-01-09 Thread Nick Coghlan
Paul Rubin wrote: Nick Coghlan <[EMAIL PROTECTED]> writes: Trying to push it a level further (down to expressions) would, IMO, be a lot of effort for something which would hurt readability a lot. I think we should just try to do things in a simple and general way and not try to enforce readability

Re: python3: 'where' keyword

2005-01-09 Thread Nick Coghlan
Andrey Tatarinov wrote: sorry, I used "expression" carelessly. I mean that >>> print words[3], words[5] is a single expression (and that would be in Python 3, when print would be subtituted with write()/writeln()). 'statement' is the appropriate word in Python's grammar. And I don't think we'd ac

Re: python3: 'where' keyword

2005-01-09 Thread Alex Martelli
Nick Coghlan <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > I wonder if 'with', which GvR is already on record as wanting to > > introduce in 3.0, might not be overloaded instead. > > Perhaps we could steal 'using' from the rejected decorator syntax. > > x = [f(x) for x in seq] using: >

Re: python3: 'where' keyword

2005-01-09 Thread Andrey Tatarinov
Nick Coghlan wrote: sorry, I used "expression" carelessly. I mean that >>> print words[3], words[5] is a single expression (and that would be in Python 3, when print would be subtituted with write()/writeln()). 'statement' is the appropriate word in Python's grammar. thanks ) And I don't think we

Re: python3: 'where' keyword

2005-01-09 Thread Andrey Tatarinov
Nick Coghlan wrote: Current: assignment_stmt ::= (target_list "=")+ expression_list augmented_assignment_stmt ::=target augop expression_list New: assignment_stmt ::= (target_list "=")+ expression_list [where_clause] augmented_assignment_stmt ::=target augop expression_list [where_

Re: python3: 'where' keyword

2005-01-09 Thread Nick Coghlan
Alex Martelli wrote: I wonder if 'with', which GvR is already on record as wanting to introduce in 3.0, might not be overloaded instead. Perhaps we could steal 'using' from the rejected decorator syntax. x = [f(x) for x in seq] using: def f(x): return x * x Cheers, Nick. -- Nick Coghlan |

Re: python3: 'where' keyword

2005-01-09 Thread Paul Rubin
Nick Coghlan <[EMAIL PROTECTED]> writes: > Trying to push it a level further (down to expressions) would, IMO, be > a lot of effort for something which would hurt readability a lot. I think we should just try to do things in a simple and general way and not try to enforce readability. For example

Re: python3: 'where' keyword

2005-01-09 Thread Andrey Tatarinov
Paul Rubin wrote: You mean I can't say # compute sqrt(2) + sqrt(3) x = (sqrt(a) where: a = 2.) \ + sqrt (a) where: a = 3. No, I'd prefer to not embed 'where' into expression. -- http://mail.python.org/mailman/listinfo/python-list

Re: python3: 'where' keyword

2005-01-09 Thread Alex Martelli
AdSR <[EMAIL PROTECTED]> wrote: > I don't know haskell, but it looks SQL-ish to me (only by loose Indeed, the fact that many MANY more people are familiar with SQL than with Haskell may be the strongest practical objection to this choice of syntax sugar; the WHERE clause in an SQL SELECT has suc

Re: python3: 'where' keyword

2005-01-09 Thread Andrey Tatarinov
Peter Hansen wrote: >>> print words[3], words[5] where: >>> words = input.split() - defining variables in "where" block would restrict their visibility to one expression Then your example above doesn't work... print takes a sequence of expressions, not a tuple as you seem to think. sorry, I

Re: python3: 'where' keyword

2005-01-09 Thread Carlos Ribeiro
On Sun, 09 Jan 2005 15:54:08 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Here's another nice one if 'where' is added to compound statements as well: > > @dbc(pre, post) > def foo(): >pass > where: >def pre(): > pass >def post(): > pass Interesting. It solves some of the

Re: python3: 'where' keyword

2005-01-08 Thread Paul Rubin
Nick Coghlan <[EMAIL PROTECTED]> writes: >x = (sqrt(a) where (a=2.0)) + (sqrt(b) where (a=3.0)) Hmm, I like that too. -- http://mail.python.org/mailman/listinfo/python-list

Re: python3: 'where' keyword

2005-01-08 Thread Nick Coghlan
Paul Rubin wrote: Nick Coghlan <[EMAIL PROTECTED]> writes: I think having to keep the names unique within the statement you are currently writing is a reasonable request :) Um, you could say the same thing about the function, the module, etc. ;) And, indeed, that is what Python currently says. Whe

Re: python3: 'where' keyword

2005-01-08 Thread Nick Coghlan
Paul Rubin wrote: AdSR <[EMAIL PROTECTED]> writes: Killer app for this keyword: class C(object): x = property(get, set) where: def get(self): return "Silly property" def set(self, val): self.x = "Told you it was silly" Hey, this is super-elegant! Heh, even further: z = C() whe

Re: python3: 'where' keyword

2005-01-08 Thread Paul Rubin
Nick Coghlan <[EMAIL PROTECTED]> writes: > I think having to keep the names unique within the statement you are > currently writing is a reasonable request :) Um, you could say the same thing about the function, the module, etc. ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: python3: 'where' keyword

2005-01-08 Thread Nick Coghlan
Paul Rubin wrote: What would be the advantage of that over this? . x = sqrt(a) + sqrt(b) where: . a = 2.0 . b = 3.0 The idea of "where" is to allow re-using variable names instead of having to keep track of which ones are in use. I just tried to give a very simple example of how you might

Re: python3: 'where' keyword

2005-01-08 Thread Nick Coghlan
Bengt Richter wrote: On Sat, 08 Jan 2005 16:42:16 +1000, Nick Coghlan <[EMAIL PROTECTED]> wrote: And, is the whole thing after the '=' an expression? E.g., x = ( foo(x) where: x = math.pi/4.0 ) where: def foo(x): print 'just for illustration', x or is this legal? for y i

Re: python3: 'where' keyword

2005-01-08 Thread Bengt Richter
On 8 Jan 2005 16:13:39 -0800, "Carl Banks" <[EMAIL PROTECTED]> wrote: > >Bengt Richter wrote: >> And, is the whole thing after the '=' an expression? E.g., >> >> x = ( foo(x) where: >> x = math.pi/4.0 >> ) where: >> def foo(x): print 'just for illustration', x > >How woul

Re: python3: 'where' keyword

2005-01-08 Thread Paul Rubin
"Carl Banks" <[EMAIL PROTECTED]> writes: > ># compute sqrt(2) + sqrt(3) > >x = (sqrt(a) where: > > a = 2.) \ > >+ sqrt (a) where: > >a = 3. > > > > Hmmm. > > What would be the advantage of that over this? > > . x = sqrt(a) + sqrt(b) where: > . a = 2.0 > .

Re: python3: 'where' keyword

2005-01-08 Thread Carl Banks
Paul Rubin wrote: > "Carl Banks" <[EMAIL PROTECTED]> writes: > > You misunderstand. BTW, Peter, I guess I should have said "I misunderstand, but it can be legal if you consider it part of the statements", since it appears the author did intend it to be part of an expression. > > There "where" i

Re: python3: 'where' keyword

2005-01-08 Thread Carl Banks
Bengt Richter wrote: > And, is the whole thing after the '=' an expression? E.g., > > x = ( foo(x) where: > x = math.pi/4.0 > ) where: > def foo(x): print 'just for illustration', x How would that be any improvement over this? . x = foo(x) where: . x = math.pi/4.0 .

  1   2   >