Using assingment as an operator.

Steve Holden sholden at holdenweb.com
Fri Oct 12 10:10:17 EDT 2001


"Emil S. Hansen" <esh at berlingske.dk> wrote in message
news:pan.2001.10.12.15.32.13.366.11244 at berlingske.dk...
> In <R5Cx7.27887$I83.413182 at atlpnn01.usenetserver.com>, Steve Holden wrote:
>
> >> while re.search("[^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.

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list