Using assingment as an operator.

Steve Holden sholden at holdenweb.com
Fri Oct 12 09:23:20 EDT 2001


"Emil S. Hansen" <esh at berlingske.dk> wrote ...
> Hello fellow PP.
>
> I have a simple question. In a program I have a statement like this:
> while re.search("[^a-z0-9.]", domainname = raw_input("Please enter
domainname: ")) != None:
>         print "Error in domainname, please use lovercase letters and
numbers only."
>
> When I run the program I get a
> "TypeError: unexpected keyword argument: domainname",
> how can I use an assigment as an operator for a function?

You can't. See Frequently Asked Question 6.30 for why. The syntax you use is
for keyword arguments to functions, another subject entirely.

def f(a):
    return a*a

can be called using

f(a=123)

and you can explicity declare an argument as a keyword argument with a
default value. I only mention all this to explain the apprently bizarre
error message.

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








More information about the Python-list mailing list