embedded scripts debugging

2005-01-07 Thread Andrey Tatarinov
Hi all. I have custom resource editor and wish python to be scripting language in it. But I don't want to lose ability of debugging which I currently have implementing all logic in C++. So the question is: Is there suitable library for simple python gui debugger, or may be there are some other

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

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

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

Re: python3: accessing the result of 'if'

2005-01-09 Thread Andrey Tatarinov
Carl Banks wrote: As a compromise, howabout: . if m > 20 where m=something(): . do_something_with(m) That's good, but first idea was about 'where' block that contains any expressions, that we need, for example function definition. the syntax you proposed has same problems as 'lambda'. The ma

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 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 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 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
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 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: Pygame and pyopengl with py2exe ?

2005-01-09 Thread Andrey Tatarinov
Nyx42 wrote: Second program (pygame + pyopenGL): Py2exe can't import OpenGL.GL and OpenGL.GLU :( about that, may be names of imports are generated in runtime, so you can try to specify them directly options = {"py2exe": {"packages": ["OpenGL.GL","OpenGL.GLU"]}}, -- http://mail.python.org/mailman/

Python3: on removing map, reduce, filter

2005-01-09 Thread Andrey Tatarinov
Hi. How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Andrey Tatarinov
Paul Rubin wrote: How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html I think that article was written before list comprehensions were added to Python. anyway list comprehensions ar

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread Andrey Tatarinov
Steve Holden wrote: Andrey Tatarinov wrote: Hi. How does GvR suggestions on removing map(), reduce(), filter() correlate with the following that he wrote himself (afaik): http://www.python.org/doc/essays/list2str.html > And note that the summary in the conclusiogn BEGINS with "Rule num

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 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: exceptions and items in a list

2005-01-10 Thread Andrey Tatarinov
rbt wrote: If I have a Python list that I'm iterating over and one of the objects in the list raises an exception and I have code like this: try: do something to object in list except Exception: pass Does the code just skip the bad object and continue with the other objects in the list,

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 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: embedded scripts debugging

2005-01-11 Thread Andrey Tatarinov
Miki Tebeka wrote: So the question is: Is there suitable library for simple python gui debugger, or may be there are some other techniques for debugging embedded scripts? What I usually do is add from pdb import set_trace in the embedded module somewhere and then add a call to set_trace (brea

Re: else condition in list comprehension

2005-01-13 Thread Andrey Tatarinov
Steve Holden wrote: Nick Coghlan wrote: Luis M. Gonzalez wrote: Hi there, I'd like to know if there is a way to add and else condition into a list comprehension. I'm sure that I read somewhere an easy way to do it, but I forgot it and now I can't find it... for example: z=[i+2 for i in range(10) if

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: 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: protecting the python code.

2005-01-17 Thread Andrey Tatarinov
nell wrote: First the "10x in advance" means thanks in advance. The main importance of protecting my code is to save headache of customers that want to be smart and change it and then complain on bugs also you can try to use py2exe -- http://mail.python.org/mailman/listinfo/python-list

Re: dot products

2004-12-19 Thread Andrey Tatarinov
Rahul wrote: I want to compute dot product of two vectors stored as lists a and b.a and b are of the same length. one simple way is sum(a[i]*b[i] for i in range(len(a))) btw, imho the most "Pythonic" would be: sum(i*j for (i,j) in zip(a,b)) -- http://mail.python.org/mailman/listinfo/python-list