Re: __debug__ http://stackoverflow.com/questions/15305688/conditional-debug-statement-not-executed-though-debug-is-true

2016-11-16 Thread Steven D'Aprano
On Wednesday 16 November 2016 16:21, Veek M wrote: > Trying to make sense of that article. My understanding of debug was > simple: > 1. __debug__ is always True, unless -O or -OO > 2. 'if' is optimized out when True and the expr is inlined. > > So what does he mean by: > > 1. 'If you rebind

Re: __debug__ http://stackoverflow.com/questions/15305688/conditional-debug-statement-not-executed-though-debug-is-true

2016-11-16 Thread dieter
Veek M writes: > Trying to make sense of that article. My understanding of debug was > simple: > 1. __debug__ is always True, unless -O or -OO > 2. 'if' is optimized out when True and the expr is inlined. > > So what does he mean by: > > 1. 'If you rebind __debug__, it can

__debug__ http://stackoverflow.com/questions/15305688/conditional-debug-statement-not-executed-though-debug-is-true

2016-11-15 Thread Veek M
Trying to make sense of that article. My understanding of debug was simple: 1. __debug__ is always True, unless -O or -OO 2. 'if' is optimized out when True and the expr is inlined. So what does he mean by: 1. 'If you rebind __debug__, it can cause symptoms' 2. 'During module compilation, the

Re: __debug__ http://stackoverflow.com/questions/15305688/conditional-debug-statement-not-executed-though-debug-is-true

2016-11-15 Thread Veek M
Veek M wrote: > Trying to make sense of that article. My understanding of debug was > simple: > 1. __debug__ is always True, unless -O or -OO > 2. 'if' is optimized out when True and the expr is inlined. > > So what does he mean by: > > 1. 'If you rebind __debug__, it can cause symptoms' > 2.

Re: conditional for-statement

2009-08-26 Thread seb
On Aug 25, 11:57 pm, Piet van Oostrum p...@cs.uu.nl wrote: You can also say: [x+y for x in range(3) for y in range(4) if x y] If you want to write this as a loop you have to put the for's on separate lines separated by colons, so why not the if also? Or would you also like to have the for's

Re: conditional for-statement

2009-08-25 Thread seb
On Aug 23, 11:02 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Aug 23, 2009 at 1:36 PM, sebsdemen...@gmail.com wrote: On Aug 23, 6:18 pm, John Posner jjpos...@optimum.net wrote: Hi, i was wondering if there is a syntax alike: for i in range(10) if i 5:     print i You can

Re: conditional for-statement

2009-08-25 Thread seb
On Aug 24, 12:05 am, Mel mwil...@the-wire.com wrote: seb wrote: On Aug 23, 6:18 pm, John Posner jjpos...@optimum.net wrote: [ ... ] How about using a generator expression instead of a list? for i in (x for x in range(10) if x 5): print i -John Indeed, but we could have the same

Re: conditional for-statement

2009-08-25 Thread Rami Chowdhury
We could as consistenly explain that the syntax for n in range(10) if n%3==0: body means for n in range(10): if n%3==0: body This syntax has also the benefit of avoiding an extra level of indentation (the one for the if) that bears no real meaning on a structural level. I'm sorry,

Re: conditional for-statement

2009-08-25 Thread Falcolas
On Aug 25, 11:25 am, seb sdemen...@gmail.com wrote: We could as consistenly explain that the syntax for n in range(10) if n%3==0:   body means for n in range(10):   if n%3==0:     body This syntax has also the benefit of avoiding an extra level of indentation (the one for the if) that

Re: conditional for-statement

2009-08-25 Thread seb
On Aug 25, 9:42 pm, Falcolas garri...@gmail.com wrote: On Aug 25, 11:25 am, seb sdemen...@gmail.com wrote: We could as consistenly explain that the syntax for n in range(10) if n%3==0:   body means for n in range(10):   if n%3==0:     body This syntax has also the benefit

Re: conditional for-statement

2009-08-25 Thread Falcolas
On Aug 25, 1:58 pm, seb sdemen...@gmail.com wrote: On Aug 25, 9:42 pm, Falcolas garri...@gmail.com wrote: On Aug 25, 11:25 am, seb sdemen...@gmail.com wrote: So, what part of the statement does the if statement belong to; particularly a concern considering this is valid python: for x in

Re: conditional for-statement

2009-08-25 Thread seb
On Aug 25, 10:46 pm, Falcolas garri...@gmail.com wrote: On Aug 25, 1:58 pm, seb sdemen...@gmail.com wrote: On Aug 25, 9:42 pm, Falcolas garri...@gmail.com wrote: On Aug 25, 11:25 am, seb sdemen...@gmail.com wrote: So, what part of the statement does the if statement belong to;

Re: conditional for-statement

2009-08-25 Thread Piet van Oostrum
seb sdemen...@gmail.com (s) wrote: s i am still a bit puzzle by the following. s I read in http://en.wikipedia.org/wiki/Python_syntax_and_semantics#Generators s Python 3.0 unifies all collection types by introducing dict and set s comprehensions, similar to list comprehensions: [ n*n for n

Re: conditional for-statement

2009-08-24 Thread Bruno Desthuilliers
seb a écrit : Hi, i was wondering if there is a syntax alike: for i in range(10) if i 5: print i equivalent to for i in (for i in range(10) if i5): print i what about : for i in range(6, 10): print i g More seriously: for i in range(10): if i 5: print i --

conditional for-statement

2009-08-23 Thread seb
Hi, i was wondering if there is a syntax alike: for i in range(10) if i 5: print i equivalent to for i in (for i in range(10) if i5): print i sebastien -- http://mail.python.org/mailman/listinfo/python-list

Re: conditional for-statement

2009-08-23 Thread Benjamin Peterson
seb sdementen at gmail.com writes: Hi, i was wondering if there is a syntax alike: for i in range(10) if i 5: print i for i in range(10): if i 5: print i -- http://mail.python.org/mailman/listinfo/python-list

Re: conditional for-statement

2009-08-23 Thread Francesco Bochicchio
On Aug 23, 10:09 am, seb sdemen...@gmail.com wrote: Hi, i was wondering if there is a syntax alike: for i in range(10) if i 5:     print i equivalent to for i in (for i in range(10) if i5):     print i sebastien AFAIK, no syntax fo that. But the standard syntax is not too different:

Re: conditional for-statement

2009-08-23 Thread David
Il Sun, 23 Aug 2009 01:09:04 -0700 (PDT), seb ha scritto: Hi, i was wondering if there is a syntax alike: for i in range(10) if i 5: print i You can write for i in filter(lambda i: i 5, range(10)): print i but for i in range(10): if i 5: print i it' better

Re: conditional for-statement

2009-08-23 Thread John Posner
Hi, i was wondering if there is a syntax alike: for i in range(10) if i 5: print i You can write for i in filter(lambda i: i 5, range(10)): print i but for i in range(10): if i 5: print i it' better readable, and for i in range(6,10): print i it's

Re: conditional for-statement

2009-08-23 Thread seb
On Aug 23, 6:18 pm, John Posner jjpos...@optimum.net wrote: Hi, i was wondering if there is a syntax alike: for i in range(10) if i 5:     print i You can write for i in filter(lambda i: i 5, range(10)):     print i but for i in range(10):     if i 5:         print i

Re: conditional for-statement

2009-08-23 Thread seb
On Aug 23, 10:36 pm, seb sdemen...@gmail.com wrote: On Aug 23, 6:18 pm, John Posner jjpos...@optimum.net wrote: Hi, i was wondering if there is a syntax alike: for i in range(10) if i 5:     print i You can write for i in filter(lambda i: i 5, range(10)):     print

Re: conditional for-statement

2009-08-23 Thread Chris Rebert
On Sun, Aug 23, 2009 at 1:36 PM, sebsdemen...@gmail.com wrote: On Aug 23, 6:18 pm, John Posner jjpos...@optimum.net wrote: Hi, i was wondering if there is a syntax alike: for i in range(10) if i 5:     print i You can write for i in filter(lambda i: i 5, range(10)):     print

Re: conditional for-statement

2009-08-23 Thread Mel
seb wrote: On Aug 23, 6:18 pm, John Posner jjpos...@optimum.net wrote: [ ... ] How about using a generator expression instead of a list? for i in (x for x in range(10) if x 5): print i -John Indeed, but we could have the same syntax than for generators but directly in the for

[issue5823] feature request: a conditional for statement

2009-04-23 Thread Michael Gilbert
request: a conditional for statement type: feature request versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5823

[issue5823] feature request: a conditional for statement

2009-04-23 Thread Benjamin Peterson
Benjamin Peterson benja...@python.org added the comment: You should bring this up on the python-ideas mailing list. I'm closing this unless it gets support on that list or python-dev. -- nosy: +benjamin.peterson resolution: - rejected status: open - closed

[issue5823] feature request: a conditional for statement

2009-04-23 Thread Michael Gilbert
Michael Gilbert michael.s.gilb...@gmail.com added the comment: hello, i've recently been working on some code where i am processing a list, but excluding certain items. the solution is to use a list comprehension in the for statement, which for example looks like: for m in [n for n in

Re: having problems with a multi-conditional while statement

2009-01-07 Thread Hendrik van Rooyen
Philip Semanchuk ph...@nchuk.com wrote: 8 nice explanation Change the and to an or and you'll get the result you expected. Also google for De Morgan, or De Morgan's laws Almost everybody stumbles over this or one of it's corollaries at least once in their

having problems with a multi-conditional while statement

2009-01-06 Thread bowman.jos...@gmail.com
Hi, I'm trying to write a multi-conditional while statement, and am having problems. I've broken it down to this simple demo. #!/usr/bin/python2.5 condition1 = False condition2 = False while not condition1 and not condition2: print 'conditions met' if condition1: condition2

Re: having problems with a multi-conditional while statement

2009-01-06 Thread Philip Semanchuk
On Jan 6, 2009, at 7:18 PM, bowman.jos...@gmail.com wrote: Hi, I'm trying to write a multi-conditional while statement, and am having problems. I've broken it down to this simple demo. #!/usr/bin/python2.5 condition1 = False condition2 = False while not condition1 and not condition2

Re: having problems with a multi-conditional while statement

2009-01-06 Thread Ned Deily
In article 40a44d6b-c638-464d-b166-ef66496a0...@l16g2000yqo.googlegroups.com, bowman.jos...@gmail.com bowman.jos...@gmail.com wrote: Hi, I'm trying to write a multi-conditional while statement, and am having problems. I've broken it down to this simple demo. #!/usr/bin/python2.5

Re: having problems with a multi-conditional while statement

2009-01-06 Thread bowman.jos...@gmail.com
,  bowman.jos...@gmail.com bowman.jos...@gmail.com wrote: Hi, I'm trying to write a multi-conditional while statement, and am having problems. I've broken it down to this simple demo. #!/usr/bin/python2.5 condition1 = False condition2 = False while not condition1 and not condition2

Re: conditional print statement ?

2007-04-27 Thread stef
or (untested): if Print_Info: def printOrNot(arg): print arg else: def printOrNot(arg): pass printOrNot(Datafile.readline()) thanks for the creative solution, and indeed it does work ;-) cheers, Stef Mientki --

Re: conditional print statement ?

2007-04-27 Thread Paul McGuire
On Apr 26, 7:31 am, Dustan [EMAIL PROTECTED] wrote: On Apr 26, 1:58 am, Antoon Pardon [EMAIL PROTECTED] wrote: On 2007-04-25, Stef Mientki [EMAIL PROTECTED] wrote: hello, As part of a procedure I've a number sequences like this: Python if Print_Info: print

Re: conditional print statement ?

2007-04-27 Thread Duncan Booth
Paul McGuire [EMAIL PROTECTED] wrote: The Enable/Disable decorators on the Python wiki (http:// wiki.python.org/moin/PythonDecoratorLibrary?highlight=%28decorator %29#head-8298dbf9ac7325d9ef15e7130e676378bbbda572) help you do something very similar, without having to replicate the function

Re: conditional print statement ?

2007-04-27 Thread Paul McGuire
On Apr 27, 9:45 am, Duncan Booth [EMAIL PROTECTED] wrote: Paul McGuire [EMAIL PROTECTED] wrote: The Enable/Disable decorators on the Python wiki (http:// wiki.python.org/moin/PythonDecoratorLibrary?highlight=%28decorator %29#head-8298dbf9ac7325d9ef15e7130e676378bbbda572) help you do

Re: conditional print statement ?

2007-04-26 Thread Antoon Pardon
On 2007-04-25, Stef Mientki [EMAIL PROTECTED] wrote: hello, As part of a procedure I've a number sequences like this: Python if Print_Info: print Datafile.readline() else:Datafile.readline() /Python Is there a more compressed way to write such a statement,

Re: conditional print statement ?

2007-04-26 Thread stef
Antoon Pardon wrote: On 2007-04-25, Stef Mientki [EMAIL PROTECTED] wrote: hello, As part of a procedure I've a number sequences like this: Python if Print_Info: print Datafile.readline() else:Datafile.readline() /Python Is there a more compressed way to

Re: conditional print statement ?

2007-04-26 Thread Dustan
On Apr 26, 1:58 am, Antoon Pardon [EMAIL PROTECTED] wrote: On 2007-04-25, Stef Mientki [EMAIL PROTECTED] wrote: hello, As part of a procedure I've a number sequences like this: Python if Print_Info: print Datafile.readline() else:Datafile.readline() /Python

conditional print statement ?

2007-04-25 Thread Stef Mientki
hello, As part of a procedure I've a number sequences like this: Python if Print_Info: print Datafile.readline() else:Datafile.readline() /Python Is there a more compressed way to write such a statement, especially I dislike the redundancy Datafile.readline().

Re: conditional print statement ?

2007-04-25 Thread Martin v. Löwis
Stef Mientki schrieb: hello, As part of a procedure I've a number sequences like this: Python if Print_Info: print Datafile.readline() else:Datafile.readline() /Python Is there a more compressed way to write such a statement, especially I dislike the

Re: conditional print statement ?

2007-04-25 Thread Terry Reedy
Stef Mientki [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | if Print_Info: print Datafile.readline() | else:Datafile.readline() Since both branches discard the data read, I presume Martin's fix is what you really want. | Is there a more compressed way to