bruno at modulix wrote:
> TG wrote:
>> Hmm ... I'm definitely not a python wizard, but it seems to be quite a
>> special case that breaks the rules ...
>
> Yes and no. The primary use case for __new__ was to allow subclassing of
> immutable types. array.array is not immutable, but it's still a sp
TG wrote:
> Hmm ... I'm definitely not a python wizard, but it seems to be quite a
> special case that breaks the rules ...
Yes and no. The primary use case for __new__ was to allow subclassing of
immutable types. array.array is not immutable, but it's still a special
case, in that it enforce typ
Hmm ... I'm definitely not a python wizard, but it seems to be quite a
special case that breaks the rules ... unpythonic, isn't it ?
Has anyone seen a PEP on this subject ?
Just in case a troll reads this message : i'm not saying python sucks
or has huge design flaws here ...
--
http://mail.pyt
Sion Arrowsmith wrote:
> TG <[EMAIL PROTECTED]> wrote [something like]:
>>from array import array
>
>>class Vector(array):
>> def __init__(self,size):
>> array.__init__('f')
>>
>>v = Vector('c')
>>print repr(v)
>>
>>will output :
>>
>>array('c')
>
>
> Is this a case of new-sytle classes
TG <[EMAIL PROTECTED]> wrote [something like]:
>from array import array
>class Vector(array):
>def __init__(self,size):
>array.__init__('f')
>
>v = Vector('c')
>print repr(v)
>
>will output :
>
>array('c')
Is this a case of new-sytle classes being confusing? Because
I'm certainly confu
Philippe Martin wrote:
>
> bruno at modulix wrote:
>>TG wrote:
>>
>>>Hi there.
>>>
>>>I'm trying to create a simple class called Vector which inherit from
>>>array.
>>
>>Which array ?
>
> I think he did
>
> fr
TG wrote:
> Obviously, there is something I didn't catch in python's inheritance.
Nope. Obviously, array.array doesn't respect the usual rules.
> from array import array
> class Vector(array):
> def __init__(self,size):
> print self.typecode
> array.__init__(self,'f')
>
>
>>
Obviously, there is something I didn't catch in python's inheritance.
from array import array
class Vector(array):
def __init__(self,size):
print self.typecode
array.__init__(self,'f')
>>> v = Vector('c')
c
Here, it says the typecode is 'c' - I thought such an information was
I think he did
from array import *
Philippe
bruno at modulix wrote:
> TG wrote:
>> Hi there.
>>
>> I'm trying to create a simple class called Vector which inherit from
>> array.
>
> Which array ?
>
> [EMAIL PROTECTED] ~ $ python
> Python
from array import array
class Vector(array):
def __init__(self,size):
print "pouet"
array.__init__('f')
print "pouet"
v = Vector('c')
print repr(v)
will output :
pouet
pouet
array('c')
--
http://mail.python.org/mailman/listinfo/python-list
TG wrote:
> Hi there.
>
> I'm trying to create a simple class called Vector which inherit from
> array.
Which array ?
[EMAIL PROTECTED] ~ $ python
Python 2.4.2 (#1, Feb 9 2006, 02:40:32)
[GCC 3.4.5 (Gentoo 3.4.5, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
Type "help"
Hi there.
I'm trying to create a simple class called Vector which inherit from
array.
class Vector(array):
def __init__(self,length):
"""initialize a vector of random floats of size length. floats
are in interval [0;1]"""
array.__init_
12 matches
Mail list logo