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
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
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
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.
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
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
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
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,
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
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
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
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;
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
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
--
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
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
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:
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
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
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
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
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
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
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
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
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
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
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
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
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
,
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
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
--
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
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
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
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,
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
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
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().
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
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
41 matches
Mail list logo