Re: A question on scope...

0 views
Skip to first unread message

MRAB

unread,
Jun 18, 2009, 1:05:53 PM6/18/09
to pytho...@python.org
Wells Oliver wrote:
> In writing out python classes, it seems the 'self' is optional, meaning
> that inside a class method, "self.foo = bar" has the same effect as "foo
> = bar". Is this right? If so, it seems a little odd- what's the rationale?
>
> Or am I mistaken?
>
Inside a function or method "foo = bar" would make "foo" local by
default. In an instance method an attribute "foo" of the instance needs
a reference to the instance itself, by convention "self", therefore
"self.foo". In a class method a reference to the class itself is by
convention "cls", therefore "cls.foo".

Bruno Desthuilliers

unread,
Jun 19, 2009, 5:43:54 AM6/19/09
to
MRAB a �crit :
> Wells Oliver wrote:

NB : answering the OP (original post didn't show up on c.l.py ???)

>> In writing out python classes, it seems the 'self' is optional,

You mean, inside a method ?

>> meaning that inside a class method,

<warning topic="semantic issue">
In Python, a "class method" is a method that operates on the class
object itself instead of operating on an instance of the class.
</warning>

>> "self.foo = bar" has the same
>> effect as "foo = bar". Is this right?

It's obviously false, cf MRAB's answer.

Aahz

unread,
Jun 20, 2009, 12:27:51 AM6/20/09
to
In article <4a3b5dc3$0$2985$426a...@news.free.fr>,

Bruno Desthuilliers <bruno.42.de...@websiteburo.invalid> wrote:
>
>NB : answering the OP (original post didn't show up on c.l.py ???)

Correct. There's a problem with the mail->news gateway, I think that
MIME messages are failing. I "fixed" the problem for c.l.py.announce by
making the list reject non-ASCII messages, but I don't think that's an
option for python-list.
--
Aahz (aa...@pythoncraft.com) <*> http://www.pythoncraft.com/

"as long as we like the same operating system, things are cool." --piranha

Bruno Desthuilliers

unread,
Jun 22, 2009, 5:13:42 AM6/22/09
to
Aahz a �crit :

> In article <4a3b5dc3$0$2985$426a...@news.free.fr>,
> Bruno Desthuilliers <bruno.42.de...@websiteburo.invalid> wrote:
>> NB : answering the OP (original post didn't show up on c.l.py ???)
>
> Correct. There's a problem with the mail->news gateway, I think that
> MIME messages are failing. I "fixed" the problem for c.l.py.announce by
> making the list reject non-ASCII messages, but I don't think that's an
> option for python-list.

Hu, I see. FWIW, it's not the first time I observe this (posts not
showing up, only answers...), but at least I now know why. Well, I guess
it might be possible to have the gateway "extract" the text part from
MIME messages, but I'm not sure I'd volunteer to work on this... Just
out of curiousity, where can I find more infos on this gateway ?

Aahz

unread,
Jun 22, 2009, 9:17:43 AM6/22/09
to
In article <4a3f4b46$0$11882$426a...@news.free.fr>,

It's part of Mailman, so that's where you should start.

Reply all
Reply to author
Forward
0 new messages