Using assingment as an operator.

Steve Holden sholden at
Fri Oct 12 16:10:17 CEST 2001

"Emil S. Hansen" <esh at> wrote in message
news:pan.2001. at
> In <R5Cx7.27887$I83.413182 at>, Steve Holden wrote:
> >> while"[^a-z0-9.]", domainname = raw_input("Please enter
> > domainname: ")) != None:
> >>         print "Error in domainname, please use lovercase letters and
> > numbers only."
> > You can't. See Frequently Asked Question 6.30 for why. The syntax you
> > use is for keyword arguments to functions, another subject entirely.
> I guessed that, but I hoped there was another way to do what I want. But
> I'll have a look at the FAQ. Thanks for your time,
Not a problem. I presume the reason you wanted assignment inside an
expression was to use the value of domainname later in your program.
Python's general philosophy seems to be that a couple of extra lines of code
is worth it for the improvement in clarity. You could, of course, define
your own function with a side-effect of setting global domainname, but that
wouldn't be any shorter, really.

There's actually another thread current about assignment and expressions.
There have been several wacky suggestions, but my bet would be you might
expect Hell to freeze over before we see it in Python.


More information about the Python-list mailing list