Re: What is "self"?

2005-09-27 Thread Michael Spencer
Ron Adam wrote: > What I've noticed is you can block the visibility of a class attribute, > which include methods, by inserting an object in the instance with the > same name. > [snip example of this behavior] Yes, that's true for "non-data descriptors" (see last two bullets below) Raymond Het

Re: What is "self"?

2005-09-27 Thread Ron Adam
Diez B. Roggisch wrote: >> This still seems not quite right to me... Or more likely seems to be >> missing something still. >> >> (But it could be this migraine I've had the last couple of days >> preventing me from being able to concentrate on things with more than >> a few levels of complexit

Re: What is "self"?

2005-09-26 Thread Diez B. Roggisch
> This still seems not quite right to me... Or more likely seems to be > missing something still. > > (But it could be this migraine I've had the last couple of days > preventing me from being able to concentrate on things with more than a > few levels of complexity.) > > Playing around with

Re: What is "self"?

2005-09-25 Thread Ron Adam
Michael Spencer wrote: > All is explained at: > http://users.rcn.com/python/download/Descriptor.htm#functions-and-methods > and further at: > http://www.python.org/pycon/2005/papers/36/pyc05_bla_dp.pdf > > "For objects, the machinery is in object.__getattribute__ which > transforms b.x into type

Re: What is "self"?

2005-09-23 Thread Michael Spencer
Ron Adam wrote: > Erik Max Francis wrote: > >>Ron Adam wrote: >> >> >>>When you call a method of an instance, Python translates it to... >>> >>> leader.set_name(leader, "John") >> >> >>It actually translates it to >> >>Person.set_name(leader, "John") >> > > > I thought that I might have

Re: What is "self"?

2005-09-23 Thread Ron Adam
Erik Max Francis wrote: > Ron Adam wrote: > >> When you call a method of an instance, Python translates it to... >> >> leader.set_name(leader, "John") > > > It actually translates it to > > Person.set_name(leader, "John") > I thought that I might have missed something there. Is ther

Re: What is "self"?

2005-09-23 Thread Terry Hancock
On Friday 23 September 2005 10:41 am, Rick Wotnaz wrote: > Oh, 'ix' would be fine. Single-letter loop counters are also semi- > fine if that is in fact their only use. It too-frequently happens > that at some point the handy 'i' identifier is used outside the > loop (for another placeholder), and

Re: What is "self"?

2005-09-23 Thread Terry Hancock
On Friday 23 September 2005 10:42 am, Peter wrote: > Terry Hancock wrote: > >How exactly is that? Anybody who uses "i" as a variable name for > >anything other than an innermost loop index is a sick and twisted > >code sadist. > > > Agreed, though to say "code sadist" is a little hard don't ya thi

Re: What is "self"?

2005-09-23 Thread Rick Wotnaz
Terry Hancock <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > On Friday 23 September 2005 07:11 am, Rick Wotnaz wrote: >> I've long thought that Guido missed an opportunity by not >> choosing to use 'i' as the instance identifier, and making it a >> reserved word. For one thing, it would r

Re: What is "self"?

2005-09-23 Thread Peter
Terry Hancock wrote: >On Friday 23 September 2005 07:11 am, Rick Wotnaz wrote: > > >>I've long thought that Guido missed an opportunity by not choosing >>to use 'i' as the instance identifier, and making it a reserved >>word. For one thing, it would resonate with the personal pronoun >>'I', a

Re: What is "self"?

2005-09-23 Thread Terry Hancock
On Friday 23 September 2005 07:11 am, Rick Wotnaz wrote: > I've long thought that Guido missed an opportunity by not choosing > to use 'i' as the instance identifier, and making it a reserved > word. For one thing, it would resonate with the personal pronoun > 'I', and so carry essentially the s

Re: What is "self"?

2005-09-23 Thread Sion Arrowsmith
Rick Wotnaz <[EMAIL PROTECTED]> wrote: >I've long thought that Guido missed an opportunity by not choosing >to use 'i' as the instance identifier, and making it a reserved >word. For one thing, it would resonate with the personal pronoun >'I', and so carry essentially the same meaning as 'self'

Re: What is "self"?

2005-09-23 Thread Jeff Schwab
Rick Wotnaz wrote: > Roy Smith <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > > >>Ron Adam <[EMAIL PROTECTED]> wrote: >> >>>You can actually call it anything you want but "self" is sort >>>of a tradition. >> >>That's true, but I think needs to be said a bit more >>emphatically. There'

Re: What is "self"?

2005-09-23 Thread Rick Wotnaz
Roy Smith <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Ron Adam <[EMAIL PROTECTED]> wrote: >> You can actually call it anything you want but "self" is sort >> of a tradition. > > That's true, but I think needs to be said a bit more > emphatically. There's no reason to call it anything

Re: What is "self"?

2005-09-23 Thread Roy Smith
Ron Adam <[EMAIL PROTECTED]> wrote: > You can actually call it anything you want but "self" is sort of a > tradition. That's true, but I think needs to be said a bit more emphatically. There's no reason to call it anything other than "self" and a newcomer to the language would be well advised

Re: What is "self"?

2005-09-22 Thread Erik Max Francis
Ron Adam wrote: > When you call a method of an instance, Python translates it to... > > leader.set_name(leader, "John") It actually translates it to Person.set_name(leader, "John") -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20

Re: What is "self"?

2005-09-22 Thread James Stroud
I'm sure there are answers to this out there, but I'm typing this one up so I can show it to people that I try to teach this language. They consistently get hung up on what self is. So here is my try: == Self is one of those python concepts that new python programmers have a little difficulty

Re: What is "self"?

2005-09-22 Thread Ron Adam
Wayne Sutton wrote: > OK, I'm a newbie... > I'm trying to learn Python & have had fun with it so far. But I'm having > trouble following the many code examples with the object "self." Can > someone explain this usage in plain english? > > Thanks, > Wayne I'll give it a try.. When you have

Re: What is "self"?

2005-09-22 Thread marduk
On Thu, 2005-09-22 at 21:36 -0400, Wayne Sutton wrote: > OK, I'm a newbie... > I'm trying to learn Python & have had fun with it so far. But I'm having > trouble following the many code examples with the object "self." Can > someone explain this usage in plain english? "self" references the ob

Re: What is "self"?

2005-09-22 Thread Sam Pointon
self is the class instance that the bound function being called belongs to. This example should illustrate a bit. class Foo(object): def __init__(self, value): self.value = value # so the Foo instance now has an attribute, value def get_value(self): return self.value # Th

What is "self"?

2005-09-22 Thread Wayne Sutton
OK, I'm a newbie... I'm trying to learn Python & have had fun with it so far. But I'm having trouble following the many code examples with the object "self." Can someone explain this usage in plain english? Thanks, Wayne -- http://mail.python.org/mailman/listinfo/python-list