[Python-bugs-list] [ python-Feature Requests-517920 ] = (assignment) as expression

noreply@sourceforge.net noreply@sourceforge.net
Sat, 16 Feb 2002 15:58:23 -0800


Feature Requests item #517920, was opened at 2002-02-15 02:41
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=517920&group_id=5470

Category: Python Interpreter Core
Group: None
>Status: Closed
>Resolution: Works For Me
Priority: 5
Submitted By: Frank Sonnenburg (sonnenburg)
Assigned to: Nobody/Anonymous (nobody)
Summary: = (assignment) as expression

Initial Comment:
Hi Python-Developers

I am new to python and maybe this was considered 
before. I think it would be VERY helpful, if one 
could use assignments as expressions as it is in C, 
e.g. in while-loops:


import mailbox

file = open('mailfile')
mbox = mailbox.PortableUnixMailbox(file)

# the following line produces
# SyntaxError: invalid syntax
while mail = mbox.next():
    # do something with this mail
    ...



Best regards

      Frank Sonnenburg



----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2002-02-16 15:58

Message:
Logged In: YES 
user_id=21627

In Python 2.2, iterators solve this problem:

for mail in mbox:
  #do something

Closing this as "works for me".

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=517920&group_id=5470