Michal Kwiatkowski wrote:
> def init_arguments(fun):
> def new_f(self):
> var_one = self.attr_one
> var_two = self.attr_two.another_attr
> empty_list = []
>
> fun(self, var_one, var_two, empty_list)
>
> return new_f
>
> @init_arguments
> def method(self, v
Alex Martelli wrote:
> But of course, then the method's body would have to use _.one rather
> than var_one, _.two rather than var_two, and _.empty_list rather than
> empty_list (what a strange name -- does it STAY empty throughout the
> method's execution?!). To me this looks like a small price to
Michal Kwiatkowski <[EMAIL PROTECTED]> wrote:
...
> The problem wouldn't be such a problem if Python had implicit self...
> but on the other side, it's another ambiguity.
In your example, you could avoid assigning var_one, but the purpose of
assigning var_two and empty_list obviously would not
Alex Martelli wrote:
> Michal Kwiatkowski <[EMAIL PROTECTED]> wrote:
>...
>> def method(self):
>> var_one = self.attr_one
>> var_two = self.attr_two.another_attr
>> empty_list = []
>> # significant code goes here
>...
> Personally, I would keep pushing back against this app
Michal Kwiatkowski <[EMAIL PROTECTED]> wrote:
...
> def method(self):
> var_one = self.attr_one
> var_two = self.attr_two.another_attr
> empty_list = []
> # significant code goes here
...
> know, I know ;), but maybe there is a way? I would like to code it that way:
>
> @init
Hi!
I'm building a class that most of methods have similar intro, something
like this:
def method(self):
var_one = self.attr_one
var_two = self.attr_two.another_attr
empty_list = []
# significant code goes here
# ...
It's done for clarity reasons, aliasing most used variabl