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. The claim was

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 clearly states that an

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 expression statement,

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 arguing that

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 on the end

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 so

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 expressions is also

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 (maybe it's

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(): use-suite def _in_clause(): in-suite return names return _in_clause() __use_stmt_args = {} names = __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

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.

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 definition

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 a

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

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: every

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? /F -- http://mail.python.org/mailman/listinfo/python-list

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-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. /F --

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 difference, please

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

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

2005-01-13 Thread Nick Coghlan
Nick Coghlan wrote: Semantics - The code:: statement with: suite translates to:: def unique_name(): suite statement 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

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

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 answers

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. And what else

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:: statement with: suite translates to:: def unique_name(): suite statement 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 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 is a statement. if

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, that is

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

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. So

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 something

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 suspect the walls

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 straightforward

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 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

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 there

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

2005-01-11 Thread Nick Coghlan
Nick Coghlan wrote: Semantics - The code:: statement with: suite translates to:: def unique_name(): suite statement 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

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

2005-01-11 Thread Andrey Tatarinov
Nick Coghlan wrote: Semantics - The code:: statement with: suite translates to:: def unique_name(): suite statement 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

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, but

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:: statement with: suite translates to:: def unique_name(): suite statement 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

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 = statement where: suite translates to: def unique_name(): suite return statement 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

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 to: stmt1()

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

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

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 effort.

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

2005-01-11 Thread michele . simionato
Paul Rubin: [EMAIL PROTECTED] writes: about Scheme macros 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

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: 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 could make by

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 statements were

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:: statement with:

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 we'd get if

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 statement would be minor

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 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: 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 Flat is

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 make it?

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 to make, why

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 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: 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 issues

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 used

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 such

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 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 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 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'd

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: def f(x):

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

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 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

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

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

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 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 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 enforce

Re: python3: 'where' keyword

2005-01-08 Thread Carl Banks
Nick Coghlan wrote: Andrey Tatarinov wrote: Hi. It would be great to be able to reverse usage/definition parts in haskell-way with where keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable sources. Usage could be something like: res =

Re: python3: 'where' keyword

2005-01-08 Thread AdSR
Nick Coghlan wrote: 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! AdSR -- http://mail.python.org/mailman/listinfo/python-list

Re: python3: 'where' keyword

2005-01-08 Thread Paul Rubin
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()

Re: python3: 'where' keyword

2005-01-08 Thread Andrey Tatarinov
Bengt Richter wrote: It also allows the necessary but uninteresting setup for an expression to be moved out of the way, bringing the expression that does the real work to prominence. Killer app for this keyword: class C(object): x = property(get, set) where: def get(self): return Silly

Re: python3: 'where' keyword

2005-01-08 Thread Andrey Tatarinov
Nick Coghlan wrote: It also allows the necessary but uninteresting setup for an expression to be moved out of the way, bringing the expression that does the real work to prominence. Killer app for this keyword: class C(object): x = property(get, set) where: def get(self): return

Re: python3: 'where' keyword

2005-01-08 Thread André
At the risk of generating controversy, here's another type of example: def gcd(a, b): where: a: int, b: int return c where: c: int while a: a, b = b%a, a return b More can be found at http://aroberge.blogspot.com Andre -- http://mail.python.org/mailman/listinfo/python-list

Re: python3: 'where' keyword

2005-01-08 Thread André
Darn space-eater google groups :-( Here is it again, at teh risk of generating controversy .def gcd(a, b): .where: .a: int, b: int .return c where: .c: int .while a: .a, b = b%a, a .return b more examples can be found at aroberge.blogspot.com André --

Re: python3: 'where' keyword

2005-01-08 Thread oren
When I first saw this I thought: hmmm... this seems as redundant as adding a repeat/until loop to Python; there's no chance in hell it will ever be accepted by the community or Guido, but I actually kinda like it. It's nice to see mostly positive reactions to this idea so far. I think it's a

Re: python3: 'where' keyword

2005-01-08 Thread Peter Hansen
Andrey Tatarinov 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. -Peter --

Re: python3: 'where' keyword

2005-01-08 Thread Carlos Ribeiro
On Sat, 08 Jan 2005 12:53:05 -0500, Peter Hansen [EMAIL PROTECTED] wrote: Andrey Tatarinov 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

Re: python3: 'where' keyword

2005-01-08 Thread Carl Banks
Peter Hansen wrote: Andrey Tatarinov 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

Re: python3: 'where' keyword

2005-01-08 Thread Paul Rubin
Carl Banks [EMAIL PROTECTED] writes: You misunderstand. There where is not part of the expression but the statement. The above example would be a modified print statement, a print...where statement, if you will. Under this suggestion, there would be modified versions of various simple

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 is not part

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 . b = 3.0 The idea

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 would that be any

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 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: 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() where:

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. When

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

python3: 'where' keyword

2005-01-07 Thread Andrey Tatarinov
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with where keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable sources. Usage could be something like: res = [ f(i) for i in objects ] where: def f(x): #do

Re: python3: 'where' keyword

2005-01-07 Thread Steven Bethard
Andrey Tatarinov wrote: Hi. It would be great to be able to reverse usage/definition parts in haskell-way with where keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable sources. Usage could be something like: res = [ f(i) for i in objects ] where:

Re: python3: 'where' keyword

2005-01-07 Thread Steven Bethard
Steven Bethard wrote: How often is this really necessary? Could you describe some benefits of this? I think the only time I've ever run into scoping problems is with lambda, e.g. [lambda x: f(x) for x, f in lst] instead of [lambda x, f=f: for x, f in lst] Sorry, bad example, this

Re: python3: 'where' keyword

2005-01-07 Thread Donn Cave
In article [EMAIL PROTECTED], Steven Bethard [EMAIL PROTECTED] wrote: Andrey Tatarinov wrote: It would be great to be able to reverse usage/definition parts in haskell-way with where keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable sources.

Re: python3: 'where' keyword

2005-01-07 Thread AdSR
Andrey Tatarinov wrote: Hi. It would be great to be able to reverse usage/definition parts in haskell-way with where keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable sources. Usage could be something like: res = [ f(i) for i in objects ] where:

Re: python3: 'where' keyword

2005-01-07 Thread Paul Rubin
Donn Cave [EMAIL PROTECTED] writes: I don't by any means agree that this notation is worth adopting, and in general I think this kind of readability issue is more or less a lost cause for a language with Python's scoping rules, but the motive makes sense to me. But we're talking about the

Re: python3: 'where' keyword

2005-01-07 Thread Nick Coghlan
Andrey Tatarinov wrote: Hi. It would be great to be able to reverse usage/definition parts in haskell-way with where keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable sources. Usage could be something like: res = [ f(i) for i in objects ] where:

  1   2   >