Re: Getting rid of "self."

2005-01-10 Thread Alex Martelli
BJörn Lindqvist <[EMAIL PROTECTED]> wrote: ... > > http://starship.python.net/crew/mwh/hacks/selfless.py > > That's excellent! There is one small problem with the code though: It shows the fundamentals of how to rewrite the bytecode, yes. > .class Hi(Selfless): > .__attrs__ = ["x"] > .

Re: Getting rid of "self."

2005-01-09 Thread Jeremy Bowers
var is local to the function or an instance member. For me, I prefer the explicit "self" and getting rid of "self" now leaves you with the need to declare member variables *somehow*, which I don't consider progress. But no matter what other magic Alex works, you're only g

Re: Getting rid of "self."

2005-01-09 Thread BJörn Lindqvist
Thank you for your replies. It is very nice to see that a thread you started is generating so much discussion, but please, I have read the previous debates so I know all about what people think about self. Spare the "you shouldn't do that" and "self is here to stay" replies to the threads in which

Re: Getting rid of "self."

2005-01-09 Thread John Roth
"Alex Martelli" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] BJörn Lindqvist <[EMAIL PROTECTED]> wrote: I think it would be cool if you could refer to instance variables without prefixing with "self." I know noone else thinks like me so Some do -- Kent Beck's excellent book on TDD-b

Re: Getting rid of "self."

2005-01-09 Thread Alex Martelli
BJörn Lindqvist <[EMAIL PROTECTED]> wrote: > I think it would be cool if you could refer to instance variables > without prefixing with "self." I know noone else thinks like me so Some do -- Kent Beck's excellent book on TDD-by-example has a specific grouse against that in the chapter where he de

Re: Getting rid of "self."

2005-01-09 Thread Tim Roberts
BJörn Lindqvist <[EMAIL PROTECTED]> wrote: >I think it would be cool if you could refer to instance variables >without prefixing with "self." I know noone else thinks like me so >Python will never be changed, but maybe you can already do it with >Python today? > >.import sys >. >.def magic(): >.

Re: Getting rid of "self."

2005-01-08 Thread Terry Reedy
"BJörn Lindqvist" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I think it would be cool if you could refer to instance variables >without prefixing with "self." Others have expressed such a wish -- this comes up perhaps once a year. The bottom line is that as long as Python has

Re: Getting rid of "self."

2005-01-07 Thread Nick Coghlan
Roy Smith wrote: It's actually kind of neat, but boy does it play headgames with me when I switch back and forth between that and Python. Switching back and forth betwen C++ and Python plays headgames *anyway* }:> Cheers, Nick. Hardware control with Python is nice. . . -- Nick Coghlan | [EMAIL

Re: Getting rid of "self."

2005-01-07 Thread Roy Smith
Jeremy Bowers <[EMAIL PROTECTED]> wrote: > were I programming in C++ routinely now I'd prefix "this" and > dispense with that ugly "m_" garbage. (One of the things I ***hate*** > about C++ culture is its acceptance of hideously ugly variable names, > but now I'm two parentheticals deep so I prob

Re: Getting rid of "self."

2005-01-07 Thread Jeremy Bowers
On Fri, 07 Jan 2005 14:39:09 +0100, BJÃrn Lindqvist wrote: > It works! exec(magic()) does the needed hi = self.hi. No it doesn't. Try "hi = 'newValue'" and see what happens. So the next step is to write an "unmagic" function. So now how do you add instance variables? There is no way to avoid "se

Re: Getting rid of "self."

2005-01-07 Thread Sean Ross
"BJörn Lindqvist" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Thank you for your replies. But they don't deal with my original question. :) I have read the thousands of posts all saying "self is good" and they are right. But this time I want to be different m-kay? I figure that ther

Re: Getting rid of "self."

2005-01-07 Thread Roy Smith
In article <[EMAIL PROTECTED]>, John Roth <[EMAIL PROTECTED]> wrote: > >"Roy Smith" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >> Simon Brunning <[EMAIL PROTECTED]> wrote: >>>On 7 Jan 2005 08:10:14 -0800, Luis M. Gonzalez <[EMAIL PROTECTED]> wrote: The word "self" is not ma

Re: Getting rid of "self."

2005-01-07 Thread John Roth
"Roy Smith" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Simon Brunning <[EMAIL PROTECTED]> wrote: On 7 Jan 2005 08:10:14 -0800, Luis M. Gonzalez <[EMAIL PROTECTED]> wrote: The word "self" is not mandatory. You can type anything you want instead of self, as long as you supply a key

Re: Getting rid of "self."

2005-01-07 Thread BJörn Lindqvist
Thank you for your replies. But they don't deal with my original question. :) I have read the thousands of posts all saying "self is good" and they are right. But this time I want to be different m-kay? I figure that there might be some way to solve my problem by doing this: .def instancevar2local

Re: Getting rid of "self."

2005-01-07 Thread Michael Hobbs
Nick Coghlan <[EMAIL PROTECTED]> wrote: > > Wait for Python 3k when this will work: > > class c: > def __init__(self): > with self: > .x = 1 > .y = 2 > .hi = "Hi there!" Python is looking more like JavaScript every day... -- http://mail.python.org/mailman/listinfo/pytho

Re: Getting rid of "self."

2005-01-07 Thread John Roth
"BJörn Lindqvist" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I think it would be cool if you could refer to instance variables without prefixing with "self." I know noone else thinks like me so Python will never be changed, but maybe you can already do it with Python today? ...

Re: Getting rid of "self."

2005-01-07 Thread Roy Smith
Simon Brunning <[EMAIL PROTECTED]> wrote: >On 7 Jan 2005 08:10:14 -0800, Luis M. Gonzalez <[EMAIL PROTECTED]> wrote: >> The word "self" is not mandatory. You can type anything you want >> instead of self, as long as you supply a keyword in its place (it can >> be "self", "s" or whatever you want).

Re: Getting rid of "self."

2005-01-07 Thread Simon Brunning
On 7 Jan 2005 08:10:14 -0800, Luis M. Gonzalez <[EMAIL PROTECTED]> wrote: > The word "self" is not mandatory. You can type anything you want > instead of self, as long as you supply a keyword in its place (it can > be "self", "s" or whatever you want). You *can*, yes, but please don't, not if ther

Re: Getting rid of "self."

2005-01-07 Thread Luis M. Gonzalez
You can do it easier now without any black magic: class c: def __init__(s): s.x = 1 s.y = 2 s.hi = "Hi there!" The word "self" is not mandatory. You can type anything you want instead of self, as long as you supply a keyword in its place (it can be "self", "s" or whatever you want). -- http://m

Re: Getting rid of "self."

2005-01-07 Thread Nick Coghlan
BJörn Lindqvist wrote: So I'm asking here if someone knows a better way, maybe using decorators or metaclasses or other black magic? Wait for Python 3k when this will work: class c: def __init__(self): with self: .x = 1 .y = 2 .hi = "Hi there!" Cheers, Nick. -- Nick Coghlan

Re: Getting rid of "self."

2005-01-07 Thread Bruno Desthuilliers
BJörn Lindqvist a écrit : I think it would be cool if you could refer to instance variables without prefixing with "self." I know noone else thinks like me so Python will never be changed, but maybe you can already do it with Python today? (snip code) It works! exec(magic()) does the needed hi = se

Getting rid of "self."

2005-01-07 Thread BJörn Lindqvist
I think it would be cool if you could refer to instance variables without prefixing with "self." I know noone else thinks like me so Python will never be changed, but maybe you can already do it with Python today? .import sys . .def magic(): .s = "" .for var in sys._getframe(1).f_locals["s