Idea about method parameters
John Roth
johnroth at ameritech.net
Tue Sep 25 18:42:44 EDT 2001
More information about the Python-list mailing list
Tue Sep 25 18:42:44 EDT 2001
- Previous message (by thread): Idea about method parameters
- Next message (by thread): Idea about method parameters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Markus Schaber" <markus at schabi.de> wrote in message news:5243253.PRQshPE9Mp at lunix.schabi.de... > Chris Barker <chrishbarker at home.net> schrub: > > > Markus Schaber wrote: > > > >> Now I'd love to have the possibility to shorten this by typing: > >> > >> class A: > >> def m(self, self.value): > >> pass # or the other work to be done > > > > I suspect that this will clash with the internals somewhere, but I > > love it! > > This is why I gave the following semantic definition: > > class A: > def m(self, value): > self.value = value > del value > #the other work here I like the idea - it's one of those neat little shortcuts that makes initializaing a class much simpler, and may even make 'setter' attribute functions trivial. What bugs me a bit is the 'del' in your semantic definition. It's obviously there to reinforce the notion that the binding is to the instance variable, not to the local variable, but should it be? I don't have any problem with binding it to the local variable, and it does make it semantically equivalent to the current situation - that is, binding to a local variable, and then rebinding to an instance variable. The other thing I find problematic is the notion that it could bind to any visible object, such as the class, superclass or module. Frankly, I'd consider this to be an invitation to obfuscation. Granted, it's easy enough to do with an additional assignment, but I'd rather not tax my brain with having to check exactly where the parameter wound up. That way lies errors, especially when I've been working too late. > markus > -- John Roth
- Previous message (by thread): Idea about method parameters
- Next message (by thread): Idea about method parameters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list