Idiom gone, or did it really ever exist? () is ()
Stephen
news at myNOSPAM.org
Wed Apr 18 15:39:01 EDT 2001
I _really_ just don't get why you're going through all the trouble.
IMHO the below looks cleaner, and works, and can't possibly be considered
evil. :)
def fun(*args):
if args == ((),):
print 'We passed an empty tuple'
elif args == ():
print 'We didn't pass any arguments'
else:
print 'We passed the following arguments:' % args
--Stephen
(replace 'NOSPAM' with 'seraph' to respond in email)
"Mike C. Fletcher" <mcfletch at home.com> wrote in message
news:mailman.987608307.19862.python-list at python.org...
> Yup, I mentioned that in the original article ;) (same with the *args,
> **namedargs approaches). I actually switched to using this:
>
> class NULLARGUMENT: pass
>
> Then I use the class as the default value for is-checking.
> Which I'm told is evil :) .
> Mike
>
> -----Original Message-----
> From: Alex Martelli [mailto:aleaxit at yahoo.com]
> Sent: Wednesday, April 18, 2001 07:01
> To: python-list at python.org
> Subject: Re: Idiom gone, or did it really ever exist? () is ()
> ...
> Why not
>
> _NULL = []
>
> and then
> def x(y=_NULL):
> if y is _NULL: print "no argument"
>
> i.e., your original trick, but with a _mutable_ object. This
> way it should keep working forever, I believe.
> ...
>
>
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
More information about the Python-list
mailing list