Movatterモバイル変換


[0]ホーム

URL:


Idiom gone, or did it really ever exist? () is ()

Steve Purcellstephen_purcell at yahoo.com
Wed Apr 18 03:02:33 EDT 2001


Delaney, Timothy wrote:> > The convention is to use 'None' for this purpose. 'None'> > never changes, so> > 'argument is None' will work correctly for you.>> This will not actually work for the purpose though. The idea is to> distinguish between whether a parameter was passed, or whether the default> parameter is being used. Note: I've never tried this myself ...>> If you have a default of None, it is impossible to determine this if the> user passes None - because it will be the same instance of None in almost> all cases.Agreed. I'm just saying that this *is* the convention, not that replacingthe magic tuple values with None will work without further changes.Given   def foo(bar=None):      ...I think it's reasonable that   foo()and   foo(None)do the same thing.Why prevent people from explicitly calling your function in the default way?-Steve-- Steve Purcell, PythangelistGet testing athttp://pyunit.sourceforge.net/Any opinions expressed herein are my own and not necessarily those of Yahoo


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp