[Tutor] (2.7.3) Inexplicable change of type
eryksun
eryksun at gmail.com
Fri Sep 14 11:09:29 CEST 2012
On Fri, Sep 14, 2012 at 4:43 AM, Ray Jones <crawlzone at gmail.com> wrote:
>
> source = source.remove('')
>
> Between the two arrows, 'source' inexplicably switches from <type list>
> to <type NoneType>. Why?
>>> x = [1,2,3]
>>> result = x.remove(1)
>>> type(result)
<type 'NoneType'>
>>> x
[2, 3]
Methods that mutate an object typically return None. Just call
remove() without reassignment.
More information about the Tutor
mailing list