Dave Angel da...@davea.name wrote:
The decorator function will execute while *compiling* the class A, and
the one in class B is unreferenced.
No, the decorator function is called when *executing* the class body of A.
Compilation could have happened weeks earlier.
It really does make it a
Jason Swails於 2013年1月31日星期四UTC+8上午8時34分03秒寫道:
Hello,
I was having some trouble understanding decorators and inheritance and all
that. This is what I was trying to do:
# untested
class A(object):
def _protector_decorator(fcn):
def newfcn(self, *args, **kwargs):
On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
On Wed, 30 Jan 2013 19:34:03 -0500, Jason Swails wrote:
Hello,
I was having some trouble understanding decorators and inheritance and
all that. This is what I was trying to do:
# untested
On Fri, Feb 1, 2013 at 12:25 AM, Jason Swails jason.swa...@gmail.com wrote:
On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
On Wed, 30 Jan 2013 19:34:03 -0500, Jason Swails wrote:
Hello,
I was having some trouble understanding decorators and
On Thu, Jan 31, 2013 at 10:28 AM, Chris Angelico ros...@gmail.com wrote:
Well, that surely isn't going to work, because it always decorates the
same function, the global fcn.
I don't think this is right. fcn is a passed function (at least if it
acts
as a decorator) that is declared
On Thu, Jan 31, 2013 at 11:00 AM, Jason Swails jason.swa...@gmail.comwrote:
On Thu, Jan 31, 2013 at 10:28 AM, Chris Angelico ros...@gmail.com wrote:
Well, that surely isn't going to work, because it always decorates the
same function, the global fcn.
I don't think this is right.
Steven D'Aprano wrote:
def _protector_decorator(fcn):
def newfcn(self, *args, **kwargs):
return fcn(self, *args, **kwargs)
return newfcn
Well, that surely isn't going to work, because it always decorates the
same function, the global fcn.
Good grief, I can't believe I
Jason Swails wrote:
On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
Well, that surely isn't going to work, because it always decorates the
same function, the global fcn.
I don't think this is right.
It certainly isn't. Sorry for the
On Thu, Jan 31, 2013 at 6:16 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
Normally, subclasses should extend functionality, not take it away. A
fundamental principle of OO design is that anywhere you could sensibly
allow an instance, should also be able to use a subclass.
Hello,
I was having some trouble understanding decorators and inheritance and all
that. This is what I was trying to do:
# untested
class A(object):
def _protector_decorator(fcn):
def newfcn(self, *args, **kwargs):
return fcn(self, *args, **kwargs)
return newfcn
On 01/30/2013 07:34 PM, Jason Swails wrote:
Hello,
I was having some trouble understanding decorators and inheritance and all
that. This is what I was trying to do:
# untested
class A(object):
def _protector_decorator(fcn):
def newfcn(self, *args, **kwargs):
return
On Wed, 30 Jan 2013 19:34:03 -0500, Jason Swails wrote:
Hello,
I was having some trouble understanding decorators and inheritance and
all that. This is what I was trying to do:
# untested
class A(object):
def _protector_decorator(fcn):
def newfcn(self, *args, **kwargs):
Hi group,
I'm a bit confused regarding decorators. Recently started playing with
them with Python3 and wanted (as an excercise) to implement a simple
type checker first: I know there are lots of them out there, this is
actually one of the reasons I chose that particular function (to compare
my
On 12/12/2011 01:27 PM, Henrik Faber wrote:
Hi group,
I'm a bit confused regarding decorators. Recently started playing with
them with Python3 and wanted (as an excercise) to implement a simple
type checker first: I know there are lots of them out there, this is
actually one of the reasons I
On 12 December 2011 13:27, Henrik Faber hfa...@invalid.net wrote:
Hi group,
I'm a bit confused regarding decorators. Recently started playing with
them with Python3 and wanted (as an excercise) to implement a simple
type checker first: I know there are lots of them out there, this is
On 12.12.2011 14:37, Andrea Crotti wrote:
On 12/12/2011 01:27 PM, Henrik Faber wrote:
Hi group,
I'm a bit confused regarding decorators. Recently started playing with
them with Python3 and wanted (as an excercise) to implement a simple
type checker first: I know there are lots of them out
On 12.12.2011 14:45, Arnaud Delobelle wrote:
Can someone please enlighten me?
You can (need to?) use the descriptor protocol to deal with methods.
from functools import partial
[...]
def __get__(self, obj, objtype):
return partial(self, obj)
Whoa. This is absolutely
On 12 December 2011 13:52, Henrik Faber hfa...@invalid.net wrote:
On 12.12.2011 14:45, Arnaud Delobelle wrote:
Can someone please enlighten me?
You can (need to?) use the descriptor protocol to deal with methods.
from functools import partial
[...]
def __get__(self, obj, objtype):
On 12.12.2011 15:01, Arnaud Delobelle wrote:
I am very amazed -- I've been programming Python for about 5 years now
and have never even come close to something as a descriptor protocol.
Python never ceases to amaze me. Do you have any beginners guide how
this works? The Pydoc (Data Model) is
19 matches
Mail list logo