Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Arbitrary attributes on funcs and methods

Skip Montanaroskip@mojam.com (Skip Montanaro)
Wed, 12 Apr 2000 12:47:01 -0500 (CDT)


    Moshe> On Wed, 12 Apr 2000, Skip Montanaro wrote:    >> To pollute this discussion with an example from another one:    >>     >> i = 3.1416    >> i.__precision__ = 4    >>     Moshe> And voila! Numbers are no longer immutable. Using any numbers as    Moshe> keys in dicts?Yes, and I use functions on occasion as dict keys as well.    >>> def foo(): pass    ...     >>> d = {foo: 1}    >>> print d[foo]    1I suspect adding methods to functions won't invalidate their use in thatcontext, nor would adding attributes to numbers.  At any rate, it was justan example.Skip


[8]ページ先頭

©2009-2025 Movatter.jp