Dennis Lee Bieber wrote:
> 
> 
(snip)
> but that may not be desirable if None is a valid value => myA.f(None),
> so...
> 
> class A(object):
>     def __init__(self, n):
>         self.data =n
>     def f(self, *arg):
>         if len(arg) == 0:
>             x = self.data
>         else:
>             x = arg[0]
>         print x

Another solution to this is the use of a 'marker' object and identity test:

_marker = []
class A(object):
    def __init__(self, n):
        self.data =n
    def f(self, x = _marker):
        if x is _marker:
            x = self.data
        print x


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to