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"]
> .
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
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
"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
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
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():
>.
"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
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
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
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
"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
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
"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
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
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
"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?
...
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).
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
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
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
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
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
22 matches
Mail list logo