in reply to Re^6: RFC: Simulating Ruby's "yield" and "blocks" in Perl (Python)
in thread RFC: Simulating Ruby's "yield" and "blocks" in Perl
Here be Python...
A decorator doesn't have to return a callable -- eg you could decorate class SomeClass with @id, and get a fairly useless number bound to the name SomeClass. And in theory you could fiddle with the code in the callable that's passed, and return the identical object but you wouldn't.def deco(callable): # Do something with callable retval = callable return retval @ deco def example1(): pass #...is identical to def example1(): pass example1 = deco(example1)
One cannot @decorate a lambda, and "_" as a name is just convention.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: RFC: Simulating Ruby's "yield" and "blocks" in Perl (Python)
by LanX (Saint) on Apr 26, 2013 at 17:54 UTC | |
by MonkOfAnotherSect (Sexton) on Apr 27, 2013 at 14:11 UTC | |
by LanX (Saint) on Apr 27, 2013 at 15:07 UTC | |
by MonkOfAnotherSect (Sexton) on Apr 28, 2013 at 00:45 UTC | |
by LanX (Saint) on Apr 28, 2013 at 13:10 UTC |