Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17225

Re: Overriding a global

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=322fd6406=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'context': 0.04; 'operator': 0.04; 'parameter': 0.05; 'attribute': 0.07; 'function,': 0.07; 'consistency.': 0.09; 'discussing.': 0.09; 'meaningful': 0.13; 'typing': 0.15; '"as': 0.16; 'attribute,': 0.16; 'blaming': 0.16; 'desirable,': 0.16; 'different,': 0.16; "doesn't.": 0.16; 'doing,': 0.16; 'logger.': 0.16; 'sarcasm': 0.16; 'scaled': 0.16; 'self,': 0.16; 'semantically': 0.16; 'subject:Overriding': 0.16; 'subject:global': 0.16; 'unneeded': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'int': 0.18; 'seems': 0.20; 'cc:no real name:2**0': 0.20; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'statement': 0.23; 'long.': 0.23; 'precise': 0.23; 'cc:2**0': 0.24; 'up.': 0.25; 'says': 0.25; 'code': 0.25; 'classes': 0.26; "i'm": 0.26; 'function': 0.27; 'not.': 0.28; 'invalid': 0.28; 'bit': 0.28; 'lists': 0.28; 'cc:addr:python.org': 0.29; 'second': 0.29; 'class': 0.29; 'lines': 0.30; '"but': 0.30; 'argue': 0.30; 'clean,': 0.30; 'confused': 0.30; 'construct': 0.30; 'rarely': 0.30; 'semantics': 0.30; 'anyone': 0.31; "i'll": 0.31; 'does': 0.32; 'cases': 0.32; 'comment': 0.32; 'pretty': 0.32; "won't": 0.33; 'header:User- Agent:1': 0.33; 'actually': 0.33; 'instead': 0.33; 'named': 0.33; 'agree': 0.33; 'object': 0.33; "we're": 0.34; '(not': 0.35; 'changing': 0.35; 'something': 0.35; 'supposed': 0.35; 'apply': 0.35; 'equal': 0.36; 'uses': 0.36; '(to': 0.37; 'variables': 0.37; 'skip:" 10': 0.37; 'but': 0.37; "there's": 0.37; 'could': 0.37; 'doing': 0.38; 'using': 0.38; 'portion': 0.38; 'comments': 0.38; 'same.': 0.39; "i'd": 0.39; 'being': 0.39; 'help': 0.39; "it's": 0.40; 'difference': 0.40; 'more': 0.61; 'your': 0.61; 'act': 0.65; 'due': 0.66; 'cause': 0.67; 'said:': 0.67; 'yourself': 0.69; 'received:62': 0.70; 'link:': 0.72; 'ultra': 0.73; 'lose': 0.84; '[end': 0.84; 'and:': 0.84; 'different.': 0.84; 'inside.': 0.84; 'opinion.': 0.84
X-IronPort-AV E=Sophos;i="4.71,353,1320620400"; d="scan'208";a="42027"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Wed, 14 Dec 2011 18:06:19 +0100
From Jean-Michel Pichavant <jeanmichel@sequans.com>
User-Agent Mozilla-Thunderbird 2.0.0.24 (X11/20100328)
MIME-Version 1.0
To Joshua Landau <joshua.landau.ws@gmail.com>
Subject Re: Overriding a global
References <roy-B236C9.15475310122011@news.panix.com> <mailman.3500.1323551240.27778.python-list@python.org> <roy-EC9997.16105310122011@news.panix.com> <mailman.3542.1323688423.27778.python-list@python.org> <4ee671f6$0$29979$c3e8da3$5496439d@news.astraweb.com> <mailman.3583.1323770094.27778.python-list@python.org> <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>
In-Reply-To <CAN1F8qU9=_123uMQ3OkaCF9wTfhhfSMAdvRPQ1xqEipvh-sGbQ@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3651.1323882381.27778.python-list@python.org> (permalink)
Lines 77
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1323882381 news.xs4all.nl 6864 [2001:888:2000:d::a6]:33366
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17225

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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