Re: Why new Python 2.5 feature "class C()" return old-style class ?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Why new Python 2.5 feature "class C()" return old-style class ?

From: Aahz <aahz@pythoncraft.com>
Date: Tue Apr 11 2006 - 22:24:30 CEST

In article <mailman.4386.1144773906.27775.python-list@python.org>,
Felipe Almeida Lessa <felipe.lessa@gmail.com> wrote:
>Em Ter, 2006-04-11 às 07:17 -0700, Aahz escreveu:
>>
>> Can, yes. But should it? The whole point of adding the () option to
>> classes was to ease the learning process for newbies who don't
>> understand why classes have a different syntax from functions. Having
>>
>> class C(): pass
>>
>> behave differently from
>>
>> class C: pass
>>
>> would be of no benefit for that purpose.
>
>Why should a newbie use an old-style class?

Because that's the default. Because lots of existing code still uses
classic classes, so you need to learn them anyway. Because you can't use
new-style classes in code intended for 2.1 or earlier; because of the
changes made in 2.3, I don't particularly recommend new-style classes for
2.2. Because even the second edition of _Learning Python_ (targeted at
Python 2.3) doesn't cover new-style classes much, so I'm certainly not
alone in believing that new-style classes are better avoided for newbies.

-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/
"LL YR VWL R BLNG T S"
Received on Sun Apr 30 22:54:32 2006