Re: Having both if() and for() statements in one liner

2013-09-18 Thread Chris Angelico
On Wed, Sep 18, 2013 at 3:55 PM, Joshua Landau wrote: > range(person == "simon" and 5) +1 for the BOFH reference. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Joshua Landau
On 18 September 2013 03:10, Steven D'Aprano wrote: > On Tue, 17 Sep 2013 18:54:51 +, Dave Angel wrote: > >> for times in range(0, 5 if person=="George" else 0): > > > Oh that is evil. Truly evil. > > Thank you, I will treasure that piece of code forever. range(person == "simon" and 5) -- htt

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Steven D'Aprano
On Tue, 17 Sep 2013 18:54:51 +, Dave Angel wrote: > for times in range(0, 5 if person=="George" else 0): Oh that is evil. Truly evil. Thank you, I will treasure that piece of code forever. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Dave Angel
On 17/9/2013 09:21, Ferrous Cranus wrote: > I just want to say tot he program that > > that only run the for statement if and only if person=='George' > > I dont see nay reason as to why this fails > > perhaps like: > > for times in range(0, 5) if person=='George': > > but that fails too... > the

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Joel Goldstick
On Tue, Sep 17, 2013 at 11:04 AM, Chris Angelico wrote: > On Tue, Sep 17, 2013 at 11:00 PM, Roy Smith wrote: > > They just discovered a huge newline vein in Montana and they're mining > > the things like crazy. There's no shortage of them so feel free to use > > as many as you like. They even

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Chris Angelico
On Tue, Sep 17, 2013 at 11:00 PM, Roy Smith wrote: > They just discovered a huge newline vein in Montana and they're mining > the things like crazy. There's no shortage of them so feel free to use > as many as you like. They even get recycled. Can they keep up with the considerable demand even

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Joel Goldstick
On Tue, Sep 17, 2013 at 10:17 AM, Tim Chase wrote: > On 2013-09-17 16:21, Ferrous Cranus wrote: > > I just want to say tot he program that > > > > that only run the for statement if and only if person=='George' > > > > I dont see nay reason as to why this fails > > > > perhaps like: > > > > for ti

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Tim Chase
On 2013-09-17 16:21, Ferrous Cranus wrote: > I just want to say tot he program that > > that only run the for statement if and only if person=='George' > > I dont see nay reason as to why this fails > > perhaps like: > > for times in range(0, 5) if person=='George': > > but that fails too... >

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Heiko Wundram
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 17.09.2013 15:21, schrieb Ferrous Cranus: > ... there must be written on soem way. You've already given yourself the answer in the initial post. The Python way to write this is: if person == "George": for times in range(5): ... Why no

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Ferrous Cranus
Στις 17/9/2013 4:00 μμ, ο/η Roy Smith έγραψε: In article , Ferrous Cranus wrote: o want to avoid having to type somehting like this: if person="George": times in range(0, 5): Why it gives me an error when i'm trying to write it like this: if person="George" for times in range(0,

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Roy Smith
In article , Ferrous Cranus wrote: > o want to avoid having to type somehting like this: > > if person="George": > times in range(0, 5): > > > Why it gives me an error when i'm trying to write it like this: > > > if person="George" for times in range(0, 5): Step One when reporting a

Re: Having both if() and for() statements in one liner

2013-09-17 Thread Robert Kern
On 2013-09-17 13:02, Ferrous Cranus wrote: o want to avoid having to type somehting like this: if person="George": times in range(0, 5): Why it gives me an error when i'm trying to write it like this: if person="George" for times in range(0, 5): Can't i ahve both if and for in a one li

Having both if() and for() statements in one liner

2013-09-17 Thread Ferrous Cranus
o want to avoid having to type somehting like this: if person="George": times in range(0, 5): Why it gives me an error when i'm trying to write it like this: if person="George" for times in range(0, 5): Can't i ahve both if and for in a one liner? -- https://mail.python.org/mailman/l