Re: decorators and mangled names for "private" methods

2013-10-26 Thread Tim Chase
On 2013-10-25 22:01, Peter Otten wrote: > > from functools import wraps > > class require_keys: > > def __init__(self, *keys): > > self.keys = keys > > def __call__(decorator_self, fn): > > @wraps(fn) > > def result_fn(method_self, *args, **kwargs): > > # import pdb; pdb.set_t

Re: decorators and mangled names for "private" methods

2013-10-25 Thread Peter Otten
Tim Chase wrote: > Given the following example 2.7 code: > > from functools import wraps > class require_keys: > def __init__(self, *keys): > self.keys = keys > def __call__(decorator_self, fn): > @wraps(fn) > def result_fn(method_self, *args, **kwargs): > # import pdb; pdb.

decorators and mangled names for "private" methods

2013-10-25 Thread Tim Chase
Given the following example 2.7 code: from functools import wraps class require_keys: def __init__(self, *keys): self.keys = keys def __call__(decorator_self, fn): @wraps(fn) def result_fn(method_self, *args, **kwargs): # import pdb; pdb.set_trace() req = method_self.__

Re: Private methods

2012-11-01 Thread Ian Kelly
On Tue, Oct 9, 2012 at 5:51 PM, Steven D'Aprano wrote: > On Tue, 09 Oct 2012 11:08:13 -0600, Ian Kelly wrote: > >> I tend to view name mangling as being more for avoiding internal >> attribute collisions in complex inheritance structures than for >> designating names as private. > > Really? I tend

Re: Private methods

2012-10-10 Thread Dieter Maurer
alex23 writes: > On 10 Oct, 17:03, real-not-anti-spam-addr...@apple-juice.co.uk (D.M. > Procida) wrote: >> It certainly makes it quick to build a class with the attributes I need, >> but it does make tracing logic sometimes a pain in the neck. >> >> I don't know what the alternative is though. >

Re: Private methods

2012-10-10 Thread 88888 Dihedral
D.M. Procida於 2012年10月9日星期二UTC+8下午9時24分30秒寫道: > What exactly is the point of a private method? Why or when would I want > Private methods in the object level are searched first in the run time of python interpreter. I did turn some private methods in to c programs from time t

Re: Private methods

2012-10-10 Thread Steven D'Aprano
On Wed, 10 Oct 2012 18:34:01 -0700, alex23 wrote: > On 10 Oct, 17:03, real-not-anti-spam-addr...@apple-juice.co.uk (D.M. > Procida) wrote: >> It certainly makes it quick to build a class with the attributes I >> need, but it does make tracing logic sometimes a pain in the neck. >> >> I don't know

Re: Private methods

2012-10-10 Thread alex23
On 11 Oct, 02:14, Mark Lawrence wrote: > What language? I think he's objecting to "bitch". I had to block him on G+ because he kept asking me to self-censor posts that he had _chosen to read_. -- http://mail.python.org/mailman/listinfo/python-list

Re: Private methods

2012-10-10 Thread alex23
On 10 Oct, 17:03, real-not-anti-spam-addr...@apple-juice.co.uk (D.M. Procida) wrote: > It certainly makes it quick to build a class with the attributes I need, > but it does make tracing logic sometimes a pain in the neck. > > I don't know what the alternative is though. Components. The examples

Re: Private methods

2012-10-10 Thread Grant Edwards
On 2012-10-10, Mark Lawrence wrote: > On 10/10/2012 16:56, Ramchandra Apte wrote: >> On Wednesday, 10 October 2012 18:38:04 UTC+5:30, Roy Smith wrote: >>> Public: I hereby declare that this method or attribute is part of the >>> promised never to change interface of this class. I might possibly

Re: Private methods

2012-10-10 Thread Mark Lawrence
On 10/10/2012 16:56, Ramchandra Apte wrote: On Wednesday, 10 October 2012 18:38:04 UTC+5:30, Roy Smith wrote: Public: I hereby declare that this method or attribute is part of the promised never to change interface of this class. I might possibly break that promise at some point in the future,

Re: Private methods

2012-10-10 Thread Ramchandra Apte
> > > > > > > > > > Hardly a Python question but using a search engine could have got you > > > > here, and rather faster :) > > > > > > > http://stackoverflow.com/questions/2620699/why-private-methods-in-the-ob > > > ject-ori

Re: Private methods

2012-10-10 Thread Roy Smith
method? Why or when would I want > > > to use one? > > > > > > Daniele > > > > > > > Hardly a Python question but using a search engine could have got you > > here, and rather faster :) > > > http://stackoverflow.com/questions/262069

Re: Private methods

2012-10-10 Thread Robert Kern
On 10/10/12 12:51 AM, Steven D'Aprano wrote: On Tue, 09 Oct 2012 11:08:13 -0600, Ian Kelly wrote: On Tue, Oct 9, 2012 at 8:08 AM, Demian Brecht wrote: A single underscore semantically means private. A double underscore will name mangle the function such that it's only accessible strictly by n

Re: Private methods

2012-10-10 Thread D.M. Procida
Demian Brecht wrote: > On 12-10-09 04:51 PM, Steven D'Aprano wrote: > > Really? I tend to view name mangling as a waste of time, and complex > > inheritance structures as something to avoid. > > Yep, I've been coming around to this as of late. I have a lot of inheritance. I don't know whether y

Re: Private methods

2012-10-09 Thread Demian Brecht
On 12-10-09 04:51 PM, Steven D'Aprano wrote: Really? I tend to view name mangling as a waste of time, and complex inheritance structures as something to avoid. Yep, I've been coming around to this as of late. -- Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.o

Re: Private methods

2012-10-09 Thread Steven D'Aprano
On Tue, 09 Oct 2012 11:08:13 -0600, Ian Kelly wrote: > On Tue, Oct 9, 2012 at 8:08 AM, Demian Brecht > wrote: >> A single underscore semantically means private. A double underscore >> will name mangle the function such that it's only accessible strictly >> by name through the class that it's defi

Re: Private methods

2012-10-09 Thread Tim Chase
On 10/09/12 08:59, D.M. Procida wrote: >> On 09/10/2012 14:24, D.M. Procida wrote: >>> What exactly is the point of a private method? Why or when would I want >>> to use one? > > In Python, using an underscore is simply a convention to note that a > method is private - it doesn't actually hide it

Re: Private methods

2012-10-09 Thread Robert Kern
:) http://stackoverflow.com/questions/2620699/why-private-methods-in-the-ob ject-oriented Thanks. Sometimes I prefer to talk to real people on Usenet than do web searches. Just my preference. That's understandable, but the real people on Usenet who will answer your questions usually p

Re: Private methods

2012-10-09 Thread Demian Brecht
On 12-10-09 06:59 AM, D.M. Procida wrote: In Python, using an underscore is simply a convention to note that a method is private - it doesn't actually hide it from other things - correct? Daniele A single underscore semantically means private. A double underscore will name mangle the functio

Re: Private methods

2012-10-09 Thread D.M. Procida
ou > here, and rather faster :) > http://stackoverflow.com/questions/2620699/why-private-methods-in-the-ob ject-oriented Thanks. Sometimes I prefer to talk to real people on Usenet than do web searches. Just my preference. Anyway, one of the answers on that page explains that public methods are i

Re: Private methods

2012-10-09 Thread Mark Lawrence
On 09/10/2012 14:24, D.M. Procida wrote: What exactly is the point of a private method? Why or when would I want to use one? Daniele Hardly a Python question but using a search engine could have got you here, and rather faster :) http://stackoverflow.com/questions/2620699/why-private

Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Adriano Ferreira
>but why does it hava not private methods? Because it does not need them, ain't it? >Private stuff always makes programming much easier. Does it? Sometimes contortion is needed to get rid of declarations that restrain access, for example, when writing tests. I think the point-of-vie

Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Peter Hansen <[EMAIL PROTECTED]> wrote: >Roy Smith wrote: >> Simon Brunning <[EMAIL PROTECTED]> wrote: >>>On 4/19/05, could ildg <[EMAIL PROTECTED]> wrote: Private stuff always makes programming much easier. >>> >>>That contention is, at best, debatable. See >>

Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Jaime Wyant
Have I missed something? Doesn't this mangle class methods: class Foo: def __bar(self): print "bar" Granted, you could probably figure out how the names are being mangled. In the example above __bar is a defacto private method. Griping about it not having `private' in front of it is asin

Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Peter Hansen
Roy Smith wrote: Simon Brunning <[EMAIL PROTECTED]> wrote: On 4/19/05, could ildg <[EMAIL PROTECTED]> wrote: Private stuff always makes programming much easier. That contention is, at best, debatable. See http://groups-beta.google.com/group/comp.lang.python/msg/b977ed1312e10b21. Nice essay. Now,

Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Simon Brunning <[EMAIL PROTECTED]> wrote: > On 4/19/05, could ildg <[EMAIL PROTECTED]> wrote: > > Python is an oop language, > > Yes. > > > Private stuff always makes programming much easier. > > That contention is, at best, debatable. See > http://groups-beta.g

Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Simon Brunning
On 4/19/05, could ildg <[EMAIL PROTECTED]> wrote: > Python is an oop language, Yes. > Private stuff always makes programming much easier. That contention is, at best, debatable. See http://groups-beta.google.com/group/comp.lang.python/msg/b977ed1312e10b21. -- Cheers, Simon B, [EMAIL PROTECTED]

Re: Why does python class have not private methods? Will this neverchanged?

2005-04-19 Thread James
Trolls? On 4/19/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > "could ildg" <[EMAIL PROTECTED]> wrote: > > > Private stuff always makes programming much easier. > > says who? > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-l

Re: Why does python class have not private methods? Will this neverchanged?

2005-04-19 Thread Fredrik Lundh
"could ildg" <[EMAIL PROTECTED]> wrote: > Private stuff always makes programming much easier. says who? -- http://mail.python.org/mailman/listinfo/python-list

Why does python class have not private methods? Will this never changed?

2005-04-19 Thread could ildg
Python is an oop language, but why does it hava not private methods? And it even has not real private fields. Will this never changed? Private stuff always makes programming much easier. -- 鹦鹉聪明绝顶、搞笑之极,是人类的好朋友。 直到有一天,我才发觉,我是鹦鹉。 我是翻墙的鹦鹉。 -- http://mail.python.org/mailman/listinfo/python-list