On Sun, 18 Oct 2009 14:33:17 +1100, Ben Finney wrote:
> Jabba Laci writes:
>
>> Hi,
>>
>> I have some difficulties with list -> tuple conversion:
>>
>> t = ('a', 'b')
>> li = list(t) # tuple -> list, works print li # ['a', 'b']
>>
>> tu = tuple(li) # list -> tuple, error print tu # what
On 10月18日, 下午1时32分, Ben Finney wrote:
> StarWing writes:
> > On 10月18日, 下午12时19分, Ben Finney wrote:
> > > Jabba Laci writes:
> > > > Right, it was my bad. After removal the tuple() function works
> > > > perfectly.
>
> > > Note that, though it is callable, ‘tuple’ is not a function but a
> > >
StarWing writes:
> On 10月18日, 下午12时19分, Ben Finney wrote:
> > Jabba Laci writes:
> > > Right, it was my bad. After removal the tuple() function works
> > > perfectly.
> >
> > Note that, though it is callable, ‘tuple’ is not a function but a
> > type:
>
> A type is always callable.
Yes (modulo
On 10月18日, 下午12时19分, Ben Finney wrote:
> Jabba Laci writes:
> > Right, it was my bad. After removal the tuple() function works
> > perfectly.
>
> Note that, though it is callable, ‘tuple’ is not a function but a type:
>
> >>> tuple
>
> >>> len
>
>
> You can use the built-in ‘typ
Jabba Laci writes:
> Right, it was my bad. After removal the tuple() function works
> perfectly.
Note that, though it is callable, ‘tuple’ is not a function but a type:
>>> tuple
>>> len
You can use the built-in ‘type’ type to get the type of any object:
>>> foo = 12
>> The error message is: "TypeError: 'tuple' object is not callable".
>
> You created a variable named "tuple" somewhere, which is shadowing the
> built-in type. Rename that variable to something else.
Right, it was my bad. After removal the tuple() function works perfectly.
Thanks,
Laszlo
--
h
Jabba Laci writes:
> Hi,
>
> I have some difficulties with list -> tuple conversion:
>
> t = ('a', 'b')
> li = list(t) # tuple -> list, works
> print li # ['a', 'b']
>
> tu = tuple(li) # list -> tuple, error
> print tu # what I'd expect: ('a', 'b')
Works fine for me:
Python 2.5.4 (r
On Sat, Oct 17, 2009 at 8:24 PM, Jabba Laci wrote:
> Hi,
>
> I have some difficulties with list -> tuple conversion:
>
> t = ('a', 'b')
> li = list(t) # tuple -> list, works
> print li # ['a', 'b']
>
> tu = tuple(li) # list -> tuple, error
> print tu # what I'd expect: ('a', 'b')
>
> The e