Re: if statement, with function inside it: if (t = Test()) == True:

2009-05-04 Thread Scott David Daniels
MRAB wrote: If you're not limited to ASCII then there's '←' (U+2190, 'LEFTWARDS ARROW'). It's a little too late now, though. Well, if you are old enough, that was the ASCII graphic for the character now printed as '_' (ASCII), and SAIL used it for assignment statements, causing much consternatio

Re: if statement, with function inside it: if (t = Test()) == True:

2009-05-04 Thread Terry Reedy
Antoon Pardon wrote: On 2009-04-24, Steven D'Aprano wrote: On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: Hello, I'm trying to do a if statement with a function inside it. I want to use that variable inside that if loop , without defining it. def Test(): return 'Vla' I searching

Re: if statement, with function inside it: if (t = Test()) == True:

2009-05-04 Thread MRAB
Rhodri James wrote: On Mon, 04 May 2009 15:25:44 +0100, Antoon Pardon wrote: On 2009-04-24, Steven D'Aprano wrote: On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: Hello, I'm trying to do a if statement with a function inside it. I want to use that variable inside that if loop , w

Re: if statement, with function inside it: if (t = Test()) == True:

2009-05-04 Thread Rhodri James
On Mon, 04 May 2009 15:25:44 +0100, Antoon Pardon wrote: On 2009-04-24, Steven D'Aprano wrote: On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: Hello, I'm trying to do a if statement with a function inside it. I want to use that variable inside that if loop , without defining it

Re: if statement, with function inside it: if (t = Test()) == True:

2009-05-04 Thread Antoon Pardon
On 2009-04-24, Steven D'Aprano wrote: > On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: > >> Hello, >> >> I'm trying to do a if statement with a function inside it. I want to use >> that variable inside that if loop , without defining it. >> >> def Test(): >> return 'Vla' >> >> I sear

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Lawrence D'Oliveiro
In message , GC-Martijn wrote: > Nothing is wrong with it , but it cost more lines (= more scrolling) > When possible I want to keep my code small. Maybe you'd be better off with Perl than Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Piet van Oostrum
> Steven D'Aprano (SD) wrote: >SD> On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: >>> -- The long way >>> t = Test() >>> if (t == 'Vla': >>> print t # must contain Vla >SD> What's wrong with that? Missing ')' or better spurious '(' :=) -- Pi

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Paul McGuire
On Apr 24, 5:00 am, GC-Martijn wrote: > Hello, > > I'm trying to do a if statement with a function inside it. > I want to use that variable inside that if loop , without defining it. > > def Test(): >     return 'Vla' > > I searching something like this: > > if (t = Test()) == 'Vla': >     print t

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Marco Mariani
Ulrich Eckhardt wrote: t = Test() if (t == 'Vla': print t # must contain Vla What's wrong with that? It unnecessarily injects the name 't' into the scope. Since there is no concept in Python of a scope local to block statements, I don't understant what you would like to happen instead

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread MRAB
GC-Martijn wrote: On 24 apr, 12:15, Chris Rebert wrote: On Fri, Apr 24, 2009 at 3:00 AM, GC-Martijn wrote: Hello, I'm trying to do a if statement with a function inside it. I want to use that variable inside that if loop , without defining it. def Test(): return 'Vla' I searching something

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Ulrich Eckhardt
Steven D'Aprano wrote: > On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: >> t = Test() >> if (t == 'Vla': >> print t # must contain Vla > > > What's wrong with that? It unnecessarily injects the name 't' into the scope. Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amts

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Paul Rubin
Chris Rebert writes: > Python forces you to do it the "long way" (the Right Way(tm) if you > ask most Python partisans). > > If you could explain your situation and the context of your question > in greater detail, someone might be able to suggest an alternate > structure for your code which obvi

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread GC-Martijn
On 24 apr, 12:15, Chris Rebert wrote: > On Fri, Apr 24, 2009 at 3:00 AM, GC-Martijn wrote: > > Hello, > > > I'm trying to do a if statement with a function inside it. > > I want to use that variable inside that if loop , without defining it. > > > def Test(): > >    return 'Vla' > > > I searching

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread GC-Martijn
On 24 apr, 12:11, Steven D'Aprano wrote: > On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: > > Hello, > > > I'm trying to do a if statement with a function inside it. I want to use > > that variable inside that if loop , without defining it. > > > def Test(): > >     return 'Vla' > > > I sea

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Chris Rebert
On Fri, Apr 24, 2009 at 3:00 AM, GC-Martijn wrote: > Hello, > > I'm trying to do a if statement with a function inside it. > I want to use that variable inside that if loop , without defining it. > > def Test(): >    return 'Vla' > > I searching something like this: > > if (t = Test()) == 'Vla': >

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Steven D'Aprano
On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote: > Hello, > > I'm trying to do a if statement with a function inside it. I want to use > that variable inside that if loop , without defining it. > > def Test(): > return 'Vla' > > I searching something like this: > > if (t = Test()) ==

if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread GC-Martijn
Hello, I'm trying to do a if statement with a function inside it. I want to use that variable inside that if loop , without defining it. def Test(): return 'Vla' I searching something like this: if (t = Test()) == 'Vla': print t # Vla or if (t = Test()): print t # Vla ---