newbie: self.member syntax seems /really/ annoying
mail at timgolden.me.uk
Wed Sep 12 16:56:51 CEST 2007
Charles Fox wrote:
> Thanks guys -- yeah these two stategies (short s.varname; and explicit
> rescoping, a=self.a etc) are more or less what I was using. That's
> still kind of annoying though.
> The s.varname approach still makes numerical code much harder to read.
> I had a nasty bug with the boilerplate approach when forgetting to
> reassign some of the variables back to members (self.a=a). And that's
> a lot of boilerplate you need -- I thought the python way was to
> minimize redundant code? (Ditching header files and curley brackets
> was a main reason for me coming here).
> I see the argument for making self explicit -- what would be wrong
> with just .a instead of self.a though? That's still explicit but much
> easier to read. (I think I've seen that somewhere else, is it C#?)
Charles, while you are quite right to air your ideas, do bear in mind
that this issue has been thrashed out again and again on this group
and in other forums. I hope you have at least read the FAQ:
and PEP 3099:
If you take the trouble to search the archives of this list alone
for, say, explicit+self, you'll see that there are quite strong arguments
(and argumentors) on both sides. In that sort of situation the status quo
tends to hold sway. (And in this case, GvR has only recently responded to
similar comments by Bruce Eckels -- a couple of heavyweights -- in a way
which makes it unlikely that this is going to change).
I think it's one of those things which comes down, fairly enough, to: we
do things this way and it works for us; other languages do other things
and it works for them.
More information about the Python-list