Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] variable assignments inside expressions in python
- Date: Wed, 11 Jul 2007 15:00:55 +0900
- From: "david.blomberg@example.com" <david.blomberg@example.com>
- Subject: Re: [tlug] variable assignments inside expressions in python
- References: <a96ae3bb0707100001y7ab2b100g2cb1df846451193e@mail.gmail.com>
On Tue, 2007-07-10 at 16:01 +0900, Hector Akamine wrote: > Hi, > > In C, I can do a variable assignment inside a while expression, like: > > while ( (myvar = get_time( ) ) < DEADLINE) { > /* use the value of myvar somewhere*/ > ... > } > > Trying to do the same in python > while ( (myvar = get_time( ) ) < DEADLINE): > > throws an error. Is there a "python way" to do this? (I have googled > a little and the answer seems that I can't, but I refuse to accept it > :-) ) In the "Ppython Tutorial Release 2.5" at the end of 5.7 you will find a note about this behaviour. http://docs.python.org/tut/node7.html#SECTION007700000000000000000 That said the following is some sample code that will allow you to do something like what you are asking. ************start code******************** #!/usr/bin/python def get_time(n): return n; deadline = [1,2,3,4,5,6]; for i in deadline: myvar = get_time(i) print myvar ***********end code*********************** > > Thanks, > Hector >
- References:
- [tlug] variable assignments inside expressions in python
- From: Hector Akamine
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] [OT] Say _no_ to the Microsoft Office format as an ISO standard
- Next by Date: Re: [tlug] [OT] Say _no_ to the Microsoft Office format as an ISO standard
- Previous by thread: Re: [tlug] variable assignments inside expressions in python
- Next by thread: [tlug] linux on Dell news
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links