Can global variable be passed into Python function?
torriem at gmail.com
Sun Mar 2 22:44:08 CET 2014
On 03/02/2014 02:03 PM, Marko Rauhamaa wrote:
> Michael Torrie <torriem at gmail.com>:
>> I don't see why == wouldn't continue to work if os.POSIX_FADV_RANDOM
>> became an object of a different type.
> It probably would.
> If one were begging for trouble, one *could* define:
> class ABC:
> A = 1
> B = 1.0
> C = 1+0j
And one could also set A=1 and B=1 if he was trying to be stupid. That
would fail the equality test and the identity test (in CPython). Seems
like this argument is getting a bit on the absurd side. The normal
idiom is to use equality checks to test state variables' *values*. I
don't know of any developer that would purposely try to break that when
defining a new module or class.
If Mark H wants to use an idiom that isn't conventional, or isn't widely
used, he is free to do so; I can't see much harm in it. But certainly
it's not the "normal" way that it's done in Python from what I can see.
More information about the Python-list