On 4 July 2013 06:39, Peter Otten <__pete...@web.de> wrote:
> Joshua Landau wrote:
>
>> On 3 July 2013 23:19, Joshua Landau wrote:
>>> If you don't want to do that, you'd need to use introspection of a
>>> remarkably hacky sort. If you want that, well, it'll take a mo.
>>
>> After some effort I'm
>Well, technically it's
>
>func.func_closure[0].cell_contents.__name__
>
>but of course you cannot know that for the general case.
Hah, I admit I lacked perseverance in looking at this in PyCharms debugger as I
missed
that.
Much appreciated!
jlc
--
http://mail.python.org/mailman/listinfo/python
Joshua Landau wrote:
> On 3 July 2013 23:19, Joshua Landau wrote:
>> If you don't want to do that, you'd need to use introspection of a
>> remarkably hacky sort. If you want that, well, it'll take a mo.
>
> After some effort I'm pretty confident that the hacky way is impossible.
Well, technical
>> If you don't want to do that, you'd need to use introspection of a
>> remarkably hacky sort. If you want that, well, it'll take a mo.
>
> After some effort I'm pretty confident that the hacky way is impossible.
Hah, I fired it in PyCharm's debugger and spent a wack time myself, thanks
for the c
On 3 July 2013 23:19, Joshua Landau wrote:
> If you don't want to do that, you'd need to use introspection of a
> remarkably hacky sort. If you want that, well, it'll take a mo.
After some effort I'm pretty confident that the hacky way is impossible.
--
http://mail.python.org/mailman/listinfo/py
On 3 July 2013 23:09, Joseph L. Casale wrote:
> I have a set of methods which take args that I decorate twice,
>
> def wrapped(func):
> def wrap(*args, **kwargs):
> try:
> val = func(*args, **kwargs)
> # some work
> except BaseException as error:
>
I have a set of methods which take args that I decorate twice,
def wrapped(func):
def wrap(*args, **kwargs):
try:
val = func(*args, **kwargs)
# some work
except BaseException as error:
log.exception(error)
return []
return wra
Jason Swails於 2013年3月28日星期四UTC+8上午4時33分08秒寫道:
> On Wed, Mar 27, 2013 at 3:49 PM, Joseph L. Casale
> wrote:
>
> I have a class which sets up some class vars, then several methods that are
> passed in data
>
> and do work referencing the class vars.
>
>
>
>
>
> I want to decorate these meth
> When you say "class vars", do you mean variables which hold classes?
You guessed correctly, and thanks for pointing out the ambiguity in my
references.
> The one doesn't follow from the other. Writing decorators as classes is
> fairly unusual. Normally, they will be regular functions.
I
On Wed, 27 Mar 2013 22:38:11 -0400, Jason Swails wrote:
>> The second case is the easiest. Suppose you have a class like this,
>> with many methods which have code in common. Here's a toy example:
>>
>>
>> def MyClass(object):
>> x = "class attribute"
>>
>> def __init__(self, y):
>>
On Wed, Mar 27, 2013 at 7:29 PM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:
>
> The one doesn't follow from the other. Writing decorators as classes is
> fairly unusual. Normally, they will be regular functions. If your
> decorator needs to store so much state that it needs to
On Wed, 27 Mar 2013 19:49:54 +, Joseph L. Casale wrote:
> I have a class which sets up some class vars, then several methods that
> are passed in data and do work referencing the class vars.
When you say "class vars", do you mean variables which hold classes? Like
"string vars" are variable
> So decorators will never take instance variables as arguments (nor should
>they, since no instance
> can possibly exist when they execute).
Right, I never thought of it that way, my only use of them has been trivial, in
non class scenarios so far.
> Bear in mind, a decorator should take a
On Wed, Mar 27, 2013 at 3:49 PM, Joseph L. Casale wrote:
> I have a class which sets up some class vars, then several methods that
> are passed in data
> and do work referencing the class vars.
>
>
> I want to decorate these methods, the decorator needs access to the class
> vars, so I thought
>
On 27 March 2013 19:49, Joseph L. Casale wrote:
> I have a class which sets up some class vars, then several methods that are
> passed in data
> and do work referencing the class vars.
>
>
> I want to decorate these methods, the decorator needs access to the class
> vars, so I thought
> about ma
I have a class which sets up some class vars, then several methods that are
passed in data
and do work referencing the class vars.
I want to decorate these methods, the decorator needs access to the class vars,
so I thought
about making the decorator its own class and allowing it to accept args
16 matches
Mail list logo