473,287 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Tuples part 2

Hi Everyone,

i have another question. What if i wanted to make n tuples, each with
a list of coordinates. For example :
coords = list()
for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
coords.append((i,j,k))
lista+str(h)= tuple coords
print tuple(coords)
so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
it the way i show you above but it is not working properly. I wish you
could help me with that. Thanks again,
Jun 27 '08 #1
10 974
victor.hera...@gmail.com:

Do you mean something like this? (notice the many formatting
differences, use a formatting similar to this one in your code)

coords = []

for i in xrange(1, 5):
for j in xrange(1, 5):
for k in xrange(1, 2):
coords.append( (i, j, k) )

coords *= 10
print coords

Bye,
bearophile
Jun 27 '08 #2
On 5 ÉÀÎ, 01:57, "victor.hera...@gmail.com" <victor.hera...@gmail.com>
wrote:
Hi Everyone,

i have another question. What if i wanted to make n tuples, each with
a list of coordinates. For example :

coords = list()
for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
coords.append((i,j,k))
lista+str(h)= tuple coords
print tuple(coords)

so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
it the way i show you above but it is not working properly. I wish you
could help me with that. Thanks again,
>>from itertools import repeat, izip
coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for kin xrange(1,2))
locals().update(("tuple%s" % i, coord) for i, coord in izip(xrange(1,11), repeat(coords)))
tuple1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
3, 1), (2
, 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
1), (4, 3
, 1), (4, 4, 1))

Does this help?

But I don't understand why you need this?

Ivan
Jun 27 '08 #3
On Jun 5, 3:49 pm, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 ÉÀÎ, 01:57, "victor.hera...@gmail.com" <victor.hera...@gmail.com>
wrote:
Hi Everyone,
i have another question. What if i wanted to make n tuples, each with
a list of coordinates. For example :
coords = list()
for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
coords.append((i,j,k))
lista+str(h)= tuple coords
print tuple(coords)
so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
it the way i show you above but it is not working properly. I wish you
could help me with that. Thanks again,
>from itertools import repeat, izip
coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) fork in xrange(1,2))
locals().update(("tuple%s" % i, coord) for i, coord in izip(xrange(1,11), repeat(coords)))
tuple1

((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
3, 1), (2
, 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
1), (4, 3
, 1), (4, 4, 1))

Does this help?

But I don't understand why you need this?

Ivan
Hi,

What i need is, for example:

tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))

tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))

tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))

and so on. Please help me and sorry for not taking the time to post my
questions properly.

Victor
Jun 27 '08 #4
On 5 июн, 18:19, "victor.hera...@gmail.com" <victor.hera...@gmail.com>
wrote:
On Jun 5, 3:49 pm, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 ÉÀÎ, 01:57, "victor.hera...@gmail.com" <victor.hera....@gmail.com>
wrote:
Hi Everyone,
i have another question. What if i wanted to make n tuples, each with
a list of coordinates. For example :
coords = list()
for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
coords.append((i,j,k))
lista+str(h)= tuple coords
print tuple(coords)
so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
it the way i show you above but it is not working properly. I wish you
could help me with that. Thanks again,
>>from itertools import repeat, izip
>>coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for k in xrange(1,2))
>>locals().update(("tuple%s" % i, coord) for i, coord in izip(xrange(1,11), repeat(coords)))
>>tuple1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
3, 1), (2
, 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
1), (4, 3
, 1), (4, 4, 1))
Does this help?
But I don't understand why you need this?
Ivan

Hi,

What i need is, for example:

tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))

tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))

tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))

and so on. Please help me and sorry for not taking the time to post my
questions properly.

Victor


>>coords = [(i, tuple((i,j,k) for j in range(1,5) for k in range(1,2))) for i in range(1,5)]
locals().update(("tuple_%s" % i, coord) for i, coord in coords)
tuple_1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))
>>tuple_2
((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))
>>tuple_3
((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))
Is this what you want?

Ivan
Jun 27 '08 #5
On 5 июн, 18:19, "victor.hera...@gmail.com" <victor.hera...@gmail.com>
wrote:
On Jun 5, 3:49 pm, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 ÉÀÎ, 01:57, "victor.hera...@gmail.com" <victor.hera....@gmail.com>
wrote:
Hi Everyone,
i have another question. What if i wanted to make n tuples, each with
a list of coordinates. For example :
coords = list()
for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
coords.append((i,j,k))
lista+str(h)= tuple coords
print tuple(coords)
so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
it the way i show you above but it is not working properly. I wish you
could help me with that. Thanks again,
>>from itertools import repeat, izip
>>coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for k in xrange(1,2))
>>locals().update(("tuple%s" % i, coord) for i, coord in izip(xrange(1,11), repeat(coords)))
>>tuple1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
3, 1), (2
, 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
1), (4, 3
, 1), (4, 4, 1))
Does this help?
But I don't understand why you need this?
Ivan

Hi,

What i need is, for example:

tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))

tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))

tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))

and so on. Please help me and sorry for not taking the time to post my
questions properly.

Victor
Or even so:

locals().update(("tuple_%s" % i, tuple((i,j,k) for j in range(1,5) for
k in range(1,2))) for i in range(1,5))
Ivan
Jun 27 '08 #6
On 5 июн, 18:56, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 июн, 18:19, "victor.hera...@gmail.com" <victor.hera...@gmail.com>
wrote:
On Jun 5, 3:49 pm, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 ÉÀÎ, 01:57, "victor.hera...@gmail.com" <victor.hera...@gmail.com>
wrote:
Hi Everyone,
i have another question. What if i wanted to make n tuples, each with
a list of coordinates. For example :
coords = list()
for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
coords.append((i,j,k))
lista+str(h)= tuple coords
print tuple(coords)
so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
it the way i show you above but it is not working properly. I wish you
could help me with that. Thanks again,
>from itertools import repeat, izip
>coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5)for k in xrange(1,2))
>locals().update(("tuple%s" % i, coord) for i, coord in izip(xrange(1,11), repeat(coords)))
>tuple1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
3, 1), (2
, 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
1), (4, 3
, 1), (4, 4, 1))
Does this help?
But I don't understand why you need this?
Ivan
Hi,
What i need is, for example:
tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))
tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))
tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))
and so on. Please help me and sorry for not taking the time to post my
questions properly.
Victor

Or even so:

locals().update(("tuple_%s" % i, tuple((i,j,k) for j in range(1,5) for
k in range(1,2))) for i in range(1,5))

Ivan
Tried to make it readable:

def iter_coords(i):
for j in xrange(1,5):
for k in xrange(1,2):
yield i, j, k

def iter_vars():
for i in xrange(1, 5):
yield "tuple_%s" % i, tuple(iter_coords(i))

locals().update(dict(iter_vars()))
>>tuple_1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))
>>tuple_2
((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))
>>tuple_3
((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))
>>tuple_4
((4, 1, 1), (4, 2, 1), (4, 3, 1), (4, 4, 1))

Ivan
Jun 27 '08 #7
On Jun 5, 11:21 am, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 июн, 18:56, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 июн, 18:19, "victor.hera...@gmail.com" <victor.hera....@gmail.com>
wrote:
On Jun 5, 3:49 pm, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 ÉÀÎ, 01:57, "victor.hera...@gmail.com" <victor.hera...@gmail.com>
wrote:
Hi Everyone,
i have another question. What if i wanted to make n tuples, each with
a list of coordinates. For example :
coords = list()
for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
coords.append((i,j,k))
lista+str(h)= tuple coords
print tuple(coords)
so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
it the way i show you above but it is not working properly. I wishyou
could help me with that. Thanks again,
>>from itertools import repeat, izip
>>coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for k in xrange(1,2))
>>locals().update(("tuple%s" % i, coord) for i, coord in izip(xrange(1,11), repeat(coords)))
>>tuple1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
3, 1), (2
, 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
1), (4, 3
, 1), (4, 4, 1))
Does this help?
But I don't understand why you need this?
Ivan
Hi,
What i need is, for example:
tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))
tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))
tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))
and so on. Please help me and sorry for not taking the time to post my
questions properly.
Victor
Or even so:
locals().update(("tuple_%s" % i, tuple((i,j,k) for j in range(1,5) for
k in range(1,2))) for i in range(1,5))
Ivan

Tried to make it readable:

def iter_coords(i):
for j in xrange(1,5):
for k in xrange(1,2):
yield i, j, k

def iter_vars():
for i in xrange(1, 5):
yield "tuple_%s" % i, tuple(iter_coords(i))

locals().update(dict(iter_vars()))
locals().update() works by accident here because it's in global scope;
it doesn't work within a function.

Use a proper data structure, like a dict or a list, and access each
tuple list as 'tuples[n]' instead of 'tuple_n'.

George
Jun 27 '08 #8
On 5 июн, 19:38, George Sakkis <george.sak...@gmail.comwrote:
On Jun 5, 11:21 am, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 июн, 18:56, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 июн, 18:19, "victor.hera...@gmail.com" <victor.hera...@gmail.com>
wrote:
On Jun 5, 3:49 pm, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 ÉÀÎ, 01:57, "victor.hera...@gmail.com" <victor..hera...@gmail.com>
wrote:
Hi Everyone,
i have another question. What if i wanted to make n tuples, eachwith
a list of coordinates. For example :
coords = list()
for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
coords.append((i,j,k))
lista+str(h)= tuple coords
print tuple(coords)
so that i will have tuple1, tuple2,..., tupleN, etc. I am tryingto do
it the way i show you above but it is not working properly. I wish you
could help me with that. Thanks again,
>from itertools import repeat, izip
>coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for k in xrange(1,2))
>locals().update(("tuple%s" % i, coord) for i, coord in izip(xrange(1,11), repeat(coords)))
>tuple1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1),(2,
3, 1), (2
, 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
1), (4, 3
, 1), (4, 4, 1))
Does this help?
But I don't understand why you need this?
Ivan
Hi,
What i need is, for example:
tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))
tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))
tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))
and so on. Please help me and sorry for not taking the time to post my
questions properly.
Victor
Or even so:
locals().update(("tuple_%s" % i, tuple((i,j,k) for j in range(1,5) for
k in range(1,2))) for i in range(1,5))
Ivan
Tried to make it readable:
def iter_coords(i):
for j in xrange(1,5):
for k in xrange(1,2):
yield i, j, k
def iter_vars():
for i in xrange(1, 5):
yield "tuple_%s" % i, tuple(iter_coords(i))
locals().update(dict(iter_vars()))

locals().update() works by accident here because it's in global scope;
it doesn't work within a function.

Use a proper data structure, like a dict or a list, and access each
tuple list as 'tuples[n]' instead of 'tuple_n'.

George
OP wanted variables and I showed him how to do this. I agree that a
list or a dict would be better.

Ivan
Jun 27 '08 #9
On Jun 5, 11:48 am, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 июн, 19:38, George Sakkis <george.sak...@gmail.comwrote:
On Jun 5, 11:21 am, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 июн, 18:56, Ivan Illarionov <ivan.illario...@gmail..comwrote:
On 5 июн, 18:19, "victor.hera...@gmail.com" <victor.hera...@gmail.com>
wrote:
On Jun 5, 3:49 pm, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 ÉÀÎ, 01:57, "victor.hera...@gmail.com" <victor.hera...@gmail.com>
wrote:
Hi Everyone,
i have another question. What if i wanted to make n tuples, each with
a list of coordinates. For example :
coords = list()
for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
coords.append((i,j,k))
lista+str(h)= tuple coords
print tuple(coords)
so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
it the way i show you above but it is not working properly. I wish you
could help me with that. Thanks again,
>>from itertools import repeat, izip
>>coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for k in xrange(1,2))
>>locals().update(("tuple%s" % i, coord) for i, coord in izip(xrange(1,11), repeat(coords)))
>>tuple1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
3, 1), (2
, 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
1), (4, 3
, 1), (4, 4, 1))
Does this help?
But I don't understand why you need this?
Ivan
Hi,
What i need is, for example:
tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))
tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))
tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))
and so on. Please help me and sorry for not taking the time to post my
questions properly.
Victor
Or even so:
locals().update(("tuple_%s" % i, tuple((i,j,k) for j in range(1,5) for
k in range(1,2))) for i in range(1,5))
Ivan
Tried to make it readable:
def iter_coords(i):
for j in xrange(1,5):
for k in xrange(1,2):
yield i, j, k
def iter_vars():
for i in xrange(1, 5):
yield "tuple_%s" % i, tuple(iter_coords(i))
locals().update(dict(iter_vars()))
locals().update() works by accident here because it's in global scope;
it doesn't work within a function.
Use a proper data structure, like a dict or a list, and access each
tuple list as 'tuples[n]' instead of 'tuple_n'.
George

OP wanted variables and I showed him how to do this. I agree that a
list or a dict would be better.

Ivan
Generating variable names at runtime doesn't work for locals and it is
a bad solution for globals in 99.9% of the cases. It is usually more
helpful to point someone who can't even express his problem clearly to
the right direction, rather than taking his pseudocode literally and
coming up with a semi-working translation.

George
Jun 27 '08 #10
On 5 июн, 21:22, George Sakkis <george.sak...@gmail.comwrote:
On Jun 5, 11:48 am, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 июн, 19:38, George Sakkis <george.sak...@gmail.comwrote:
On Jun 5, 11:21 am, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 июн, 18:56, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 июн, 18:19, "victor.hera...@gmail.com" <victor..hera...@gmail.com>
wrote:
On Jun 5, 3:49 pm, Ivan Illarionov <ivan.illario...@gmail.comwrote:
On 5 ÉÀÎ, 01:57, "victor.hera...@gmail.com" <victor.hera...@gmail.com>
wrote:
Hi Everyone,
i have another question. What if i wanted to make n tuples, each with
a list of coordinates. For example :
coords = list()
for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
coords.append((i,j,k))
lista+str(h)= tuple coords
print tuple(coords)
so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
it the way i show you above but it is not working properly. I wish you
could help me with that. Thanks again,
>from itertools import repeat, izip
>coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for k in xrange(1,2))
>locals().update(("tuple%s" % i, coord) for i, coord in izip(xrange(1,11), repeat(coords)))
>tuple1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2,1), (2,
3, 1), (2
, 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
1), (4, 3
, 1), (4, 4, 1))
Does this help?
But I don't understand why you need this?
Ivan
Hi,
What i need is, for example:
tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))
tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))
tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))
and so on. Please help me and sorry for not taking the time to post my
questions properly.
Victor
Or even so:
locals().update(("tuple_%s" % i, tuple((i,j,k) for j in range(1,5)for
k in range(1,2))) for i in range(1,5))
Ivan
Tried to make it readable:
def iter_coords(i):
for j in xrange(1,5):
for k in xrange(1,2):
yield i, j, k
def iter_vars():
for i in xrange(1, 5):
yield "tuple_%s" % i, tuple(iter_coords(i))
locals().update(dict(iter_vars()))
locals().update() works by accident here because it's in global scope;
it doesn't work within a function.
Use a proper data structure, like a dict or a list, and access each
tuple list as 'tuples[n]' instead of 'tuple_n'.
George
OP wanted variables and I showed him how to do this. I agree that a
list or a dict would be better.
Ivan

Generating variable names at runtime doesn't work for locals and it is
a bad solution for globals in 99.9% of the cases. It is usually more
helpful to point someone who can't even express his problem clearly to
the right direction, rather than taking his pseudocode literally and
coming up with a semi-working translation.

George
Understanding of how to create variables dynamically can be good for
OP's learning curve even though it's a bad solution in this particular
case.

I agree that it was my mistake to not point him in the right
direction.

Ivan
Jun 27 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Thorsten Kampe | last post by:
I found out that I am rarely using tuples and almost always lists because of the more flexible usability of lists (methods, etc.) To my knowledge, the only fundamental difference between tuples...
8
by: Nickolay Kolev | last post by:
Hi all, I have a list whose length is a multiple of 3. I want to get a list of tuples each of which has 3 consecutive elements from the original list, thus packing the list into smaller...
66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
44
by: seberino | last post by:
Tuples are defined with regards to parentheses ()'s as everyone knows. This causes confusion for 1 item tuples since (5) can be interpreted as a tuple OR as the number 5 in a mathematical...
14
by: Richard | last post by:
I have a large list of two element tuples. I want two separate lists: One list with the first element of every tuple, and the second list with the second element of every tuple. Each tuple...
66
by: Mike Meyer | last post by:
It seems that the distinction between tuples and lists has slowly been fading away. What we call "tuple unpacking" works fine with lists on either side of the assignment, and iterators on the...
7
by: MTD | last post by:
Hello, I'm wondering if there's a quick way of resolving this problem. In a program, I have a list of tuples of form (str,int), where int is a count of how often str occurs e.g. L = would...
122
by: C.L. | last post by:
I was looking for a function or method that would return the index to the first matching element in a list. Coming from a C++ STL background, I thought it might be called "find". My first stop was...
4
by: =?utf-8?B?TWFjaWVqIEJsaXppxYRza2k=?= | last post by:
Hi Pythonistas! I've got a question about storing tuples in a dictionary. First, a small test case which creates a list of dictionaries: import time list_of_dicts = keys = prev_clk =...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.