How to assign a default constant value in a function declaration
rzed
rzantow at ntelos.net
Mon Apr 5 16:51:59 EDT 2004
Scott David Daniels <Scott.Daniels at Acm.Org> wrote in
news:4071a362 at nntp0.pdx.net:
> Marco Bartel wrote:
>
>> rzed wrote:
>>
[...]
>>> Do you mean in a context like this?
>>> class Const:
>>> someVal=255
>>> otherVal=0
>>>
>>> def blip(Const.someVal):
> Should be:
> def blip(test=Const.someVal):
>>
>> i checked this out, and i think its the name you were using:
>> Const
> Nope, it is the missing arg name.
>
Well, not so much that as an incorrectly formed parameter name. I
can legally do this:
def blip( someVal ):
...
but not this:
def blip( x.someVal ):
=> SyntaxError aimed at the dot.
Since there is no argname to assign a value to, "Const.someVal" is
taken as an identifier for a passed-in parameter. But it seems
(sensibly enough) that an identifier can't contain a '.' character,
which evidently is reserved for a qualifier separator (or some such
term) in that context.
--
rzed
More information about the Python-list
mailing list