Why new Python 2.5 feature "class C()" return old-style class ?
bruno at modulix
onurb at xiludom.gro
Tue Apr 11 10:30:10 EDT 2006
looping wrote:
> bruno at modulix wrote:
>
>>looping wrote:
>>
>>>Peter Hansen wrote:
>>>
>>>
>>>>Georg Brandl wrote:
>>>>
>>>>
>>>>>class C():
>>>>>
>>>>>is meant to be synonymous with
>>>>>
>>>>>class C:
>>>>>
>>>>>and therefore cannot create a new-style class.
>>>>
>>>>I think "looping" understands that, but is basically asking why anyone
>>>>is bothering with a change that involves a part of the language that is
>>>>effectively deprecated. In other words, class(): never used to be
>>>>valid, so why make it valid now?
>>>>
>>>>-Peter
>>>
>>>
>>>Exact.
>>>But I think that if we make "class C():" a synonym of "class
>>>C(object):", it will save lot of keystrokes ;-)
>>
>>Since the class statement without superclass actually creates an
>>old-style class, I'd expect the "class MyClass():" variant to behave
>>the same. Sacrifying readability and expliciteness just to save half a
>>dozen keystrokes is not pythonic IMHO.
>>
>
>
> I don't think readability suffer
It does. The statement "class X():" imply there's no superclass, so it
definitiveley should behave the same as "class X:".
> and expliciteness could sometimes be
> sacrified to simplify the life of developer: ex "abcd"[0:3] ->
> "abcd"[:3].
Here there's no ambiguity.
> And for newbies, the somewhat magic behavior of the "object" superclass
> is not so clear even that it is very explicit.
There's no magic involved here. And I really doubt that having
inconsistant behaviour for "class X():" wrt/ "class X:" will help here.
> When I write script I don't use new-style class
You should.
> cause is bother me to
> type "(object)" when I don't need their features.
Please repeat this 101 times each morning:
"thou shall not use old-style classes for they are deprecated".
(snip)
> So this new syntax is a good way to boost their uses without bother
> with compatibility of existing code IMHO.
It's mostly a good way to add inconsistency and confusion to a situation
that's already confusing enough for newbies.
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list