Overriding a global

Joshua Landau joshua.landau.ws at gmail.com
Thu Dec 15 15:42:37 EST 2011


On 14 December 2011 17:06, Jean-Michel Pichavant <jeanmichel at sequans.com>wrote:

> Joshua Landau wrote:
>
>> [snip]
>> Using currentLogger is just padding, in my opinion. *Every *value is
>> "current<value>".
>>
> Not always. I try to keep names on the same object because that object is
> supposed to be named that way.
> I can change one of the object attribute, but the object named that way
> keep being the same.
>
> Class Foo:
>  self.__init__(self):
>    self.banana = 5
>
> myFoo = Foo()
>
> Now there's a slight difference between
>
> myFoo = Exception()
> and
> myFoo.banana = 4
>
> The first statement rebind myFoo to something complitely different.
> the second statement change one of the object rightfully named myFoo ..
> attribute (not sure about this construct :D )
>
> Int being inmutable, you can rebind a name without changing its meaning.
>

type(myFoo) before != type(myFoo) after
type(myFoo.bannana) before == type(myFoo.bannana) after
type(logger) before == type(logger) after

You are changing the int to a new value, but it's OK for you - if I
understand rightly - because it's not changing its "meaning". The "meaning"
of logger is the same too, as it does the same thing, in approximately the
same way. I agree that "logger = Exception()" would be vary bad in that
sense, too. The point is you use it the same way and it's not going to
cause problems from misunderstanding what the object type is. And because
"logger = childLogger('this_function')" is explicit and hopefully at the
top 'o the function, any conceivable errors should be pretty obvious.

Note that I used quotation marks around "meaning" not to mock the use or
whatnot, but because I was trying to show that I was trying to use the same
version of the word you did. I don't know if that was clear from the
passage itself.

That said, you did keep the myFoo the same, even with the int change. That
makes the change global to all myFoo instances. But I didn't get that as a
main point from your argument, and if it was I fear we're too close to
recursive arguments.


And in regards to your own commentary on your English, I wouldn't like you
to see it as trouble. I'm currently thoroughly enjoying the debate, and
wouldn't like to see myself scaring you off...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111215/a1e499fc/attachment.html>


More information about the Python-list mailing list