How to assign a default constant value in a function declaration

rzed rzantow at ntelos.net
Mon Apr 5 08:05:50 EDT 2004


"Vineet Jain" <vineet at eswap.com> wrote in
news:mailman.341.1081121191.20120.python-list at python.org: 

> The following does not work although it seems like something you
> should be able to do.
> 
> def someFunction(option=Constants.DEFAULT_VALUE):
> 
Do you mean in a context like this?

>>> class Const:
...    someVal=255
...    otherVal=0
...
>>> Const.someVal
255
>>> someVal=255
>>> someVal
255
>>> def blip(Const.someVal):
  File "<stdin>", line 1
    def blip(Const.someVal):
                  ^
SyntaxError: invalid syntax
>>> def blip(someVal):
...    (no syntax error)


I've wondered about that, too. 


-- 
rzed




More information about the Python-list mailing list