Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17225
| Date | 2011-12-14 18:06 +0100 |
|---|---|
| From | Jean-Michel Pichavant <jeanmichel@sequans.com> |
| Subject | Re: Overriding a global |
| References | (6 earlier) <4ee733d4$0$29979$c3e8da3$5496439d@news.astraweb.com> <4EE75382.9060104@sequans.com> <CAN1F8qWRN8_ktQP1WRgPPQaG=mMV=TizcTpoRb=+1RyhznnvOg@mail.gmail.com> <4EE8771D.1050902@sequans.com> <CAN1F8qU9=_123uMQ3OkaCF9wTfhhfSMAdvRPQ1xqEipvh-sGbQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3651.1323882381.27778.python-list@python.org> (permalink) |
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.
>
> In regards to a second name - yes this could work and in many cases
> would be desirable, but it doesn't really help this circumstance.
> [assume, for a moment, a lot of functions used a local logger]
> "localLogger" would tell you very little about what the logger
> actually /is/. You still have to look that up. [end assumption]
> Additionally, this would make changing a logger that uses the default
> to a local one /much/ harder. And don't say "but you can just always
> make a local copy", as then you lose the advantage of a global.
>
> Typing something like "logger = childLogger(id)" to the start of a
> function call *is explicit*, it's clean, and it makes sense to have a
> default that's global. You're not appending cruft ("current") and you
> have consistency. If you added "logger = globalLogger" to every
> function start as well you can argue that it's better. I agree it's
> more explicit. But then you lose unneeded if only a small portion of
> your code localises logger. But I would recommend it if a large
> portion of code used local variants.
>
> AND:
>
> The next time I'll illustrate meaningful names, I'll write a 3000
> lines function, just to be sure no one states that my point
> does'nt apply to a function named spam which only counts from 1 to 3.
> And don't answer that the spam function above does not count from
> 1 to 3, I know it doesn't.
>
>
> You're acting in sarcasm to a comment on scale, when you yourself said
> that one of my comments was invalid due to names that were scaled down
> for exampling. It seems a bit hypocritical to me. That said, not all
> functions are long. If the short ones use short names that's fine: I'm
> pretty sure you said it's not.
>
> And in regards to the link:
> 1) __add__ says otherwise (technically, the operator "+"). It's rarely
> confused me.
> 2) That's not what we're discussing. As it said: "As long as the
> parameter lists are semantically equal and the desired result is the
> same, all is well." They're doing semantically the same thing (to
> different log levels) with the same parameter lists and they're not
> class methods. You /could/ say that the semantics are different, but
> classes act in a context in the same way local variables can be
> thought of doing, and semantics are the same for them. Instead of a
> different self, it's a different log file/level. Same semantics.
I'd like to argue about that but I won't cause I have the feeling my
lack of ultra precise english would cause me more trouble. Note that I'm
not blaming anyone but me, no sarcasm inside.
JM
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Overriding a global Roy Smith <roy@panix.com> - 2011-12-10 15:47 -0500
Re: Overriding a global MRAB <python@mrabarnett.plus.com> - 2011-12-10 21:07 +0000
Re: Overriding a global Roy Smith <roy@panix.com> - 2011-12-10 16:10 -0500
Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-12 12:13 +0100
Re: Overriding a global Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-12 21:28 +0000
Re: Overriding a global Dave Angel <d@davea.name> - 2011-12-12 16:43 -0500
Re: Overriding a global Ben Finney <ben+python@benfinney.id.au> - 2011-12-13 09:27 +1100
Re: Overriding a global Dave Angel <d@davea.name> - 2011-12-12 20:46 -0500
Re: Overriding a global Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-13 01:48 +0000
Re: Overriding a global Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-12 22:50 -0700
Re: Overriding a global Joshua Landau <joshua.landau.ws@gmail.com> - 2011-12-13 08:34 +0000
Re: Overriding a global Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-13 12:34 -0700
Re: Overriding a global Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-13 12:54 -0700
Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-13 10:54 +0100
Re: Overriding a global Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-13 11:15 +0000
Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-13 14:30 +0100
Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-14 11:14 +0100
Re: Overriding a global Chris Angelico <rosuav@gmail.com> - 2011-12-14 21:32 +1100
Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-14 13:05 +0100
Re: Overriding a global Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-14 12:53 +0000
Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-14 14:35 +0100
Re: Overriding a global Chris Angelico <rosuav@gmail.com> - 2011-12-14 23:21 +1100
Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-14 18:06 +0100
Re: Overriding a global Terry Reedy <tjreedy@udel.edu> - 2011-12-10 19:14 -0500
Re: Overriding a global Terry Reedy <tjreedy@udel.edu> - 2011-12-10 19:19 -0500
Re: Overriding a global Peter Otten <__peter__@web.de> - 2011-12-11 09:14 +0100
Re: Overriding a global Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2011-12-13 10:15 +0100
csiph-web