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
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 error message is: "TypeError: 'tuple' object is not callable".
Thanks,
En Wed, 01 Oct 2008 04:51:33 -0300, sc <[EMAIL PROTECTED]> escribió:
Thanx to a recent thread I am able to have a print string
with a variable number of formatters -- what I now lack for
the creation of an elegant print statement is a tuple --
following is the code, the last line of which does n
Gary M. Josack wrote:
> sc wrote:
>> clp:
>>
>> Thanx to a recent thread I am able to have a print string
>> with a variable number of formatters -- what I now lack for
>> the creation of an elegant print statement is a tuple --
>> following is the code, the last line of which does not work:
>>
>>
sc wrote:
clp:
Thanx to a recent thread I am able to have a print string
with a variable number of formatters -- what I now lack for
the creation of an elegant print statement is a tuple --
following is the code, the last line of which does not work:
#!/usr/bin/python
import xml.sax
import e
2008/10/1 sc <[EMAIL PROTECTED]>:
> If there were a builtin function that took a list and
> returned a tuple, I'd be there, but if there is such a
> thing I need someone to point me at it. I can't help
> thinking I am missing some obvious construct, and I'll
> be advised to go reread the tutorial,
clp:
Thanx to a recent thread I am able to have a print string
with a variable number of formatters -- what I now lack for
the creation of an elegant print statement is a tuple --
following is the code, the last line of which does not work:
#!/usr/bin/python
import xml.sax
import eaddyhandler
p
Davy wrote:
> Hi all,
>
> I am curious about whether there is function to fransform pure List to
> pure Tuple and pure Tuple to pure List?
>
Isn't that just the same topic as in your other thread? I think it is
somewhat unfriendly that you ignore that one. It makes me feel that you
see this grou
Davy wrote:
> Hi all,
>
> I am curious about whether there is function to fransform pure List to
> pure Tuple and pure Tuple to pure List?
>
> For example,
>
> I have list L = [[1,2,3],[4,5,6]]
> something list2tuple() will have T=list2tuple(L)=((1,2,3),(4,5,6))
>
> And the tuple2list()
>
> An
On Nov 6, 11:18 am, Davy <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I am curious about whether there is function to fransform pure List to
> pure Tuple and pure Tuple to pure List?
>
> For example,
>
> I have list L = [[1,2,3],[4,5,6]]
> something list2tuple() will have T=list2tuple(L)=((1,2,3),(4,5,
Hi all,
I am curious about whether there is function to fransform pure List to
pure Tuple and pure Tuple to pure List?
For example,
I have list L = [[1,2,3],[4,5,6]]
something list2tuple() will have T=list2tuple(L)=((1,2,3),(4,5,6))
And the tuple2list()
Any suggestions are welcome!
Best regar
Thanks for your help.
--
http://mail.python.org/mailman/listinfo/python-list
Try this:
>>> a,b,c = list('tab'),list('era'),list('net')
>>> a,b,c
(['t', 'a', 'b'], ['e', 'r', 'a'], ['n', 'e', 't'])
>>> tuple(((x,y,z) for x,y,z in zip(a,b,c)))
(('t', 'e', 'n'), ('a', 'r', 'e'), ('b', 'a', 't'))
>>>
- Paddy.
--
http://mail.python.org/mailman/listinfo/python-list
"zxo102" <[EMAIL PROTECTED]> writes:
> Hi,
>I got several dynamic lists a1, b1, c1, from a python
> application such as
>a1 = [1,5,3,2,5,...], the len(a1) varies. Same to b1, c1,
>
>With python, I would like to reorganize them into a tuple like
>
>t1 = ((a1[0],b1[0],c1[0]
Try the zip funciton:
py> a = [11,12,13,14]
py> b = [2,3,4,5]
py> c = [20,21,22,23,24,25]
py> zip(a,b,c)
[(11, 2, 20), (12, 3, 21), (13, 4, 22), (14, 5, 23)]
On Thursday 11 August 2005 09:05 pm, zxo102 wrote:
> Hi,
>I got several dynamic lists a1, b1, c1, from a python
> application
Hi,
I got several dynamic lists a1, b1, c1, from a python
application such as
a1 = [1,5,3,2,5,...], the len(a1) varies. Same to b1, c1,
With python, I would like to reorganize them into a tuple like
t1 = ((a1[0],b1[0],c1[0],...),(a1[1],b1[1],c1[1],...),...)
Anybody knows
23 matches
Mail list logo