By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,275 Members | 1,745 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,275 IT Pros & Developers. It's quick & easy.

A strange and annoying restriction, possibly a bug. A glance by amore experienced would be nice.

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This is the case:
n=(100,) tuple(*n)
Traceback (most recent call last):
File "<pyshell#31>", line 1, in -toplevel-
tuple(*n)
TypeError: iteration over non-sequence

To be sure I searched for ways to check if something is a sequence:
n.__iter__().next() 100 n.__getitem__(0) 100 iter(n).next()

100

So as you see, as far as I can see, I gave a sequence, but the
Traceback says the opposite.
To me it seems like a bug, but I haven't filed any bugs before, so a
little help wouldn't be bad. I haven't checked if there is bug for
this, but I don't consider me finding a bug as obvious as this very
propable and something like this not to be fixed a long time ago.

I tried this with python 2.3 and 2.4.

If possible, could you send any anwsers to my own address also. Thanks
in advance.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCvdUActNFyQJObrsRAha+AJ9oEyL7sufkXCcsQxuMDv yxNqvGGACglBrF
le8HmOgXAyRqAY3DASArjM4=
=F9NR
-----END PGP SIGNATURE-----

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
D H
Elmo Mäntynen wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This is the case:

n=(100,) tuple(*n)

Traceback (most recent call last):
File "<pyshell#31>", line 1, in -toplevel-
tuple(*n)
TypeError: iteration over non-sequence


The star (*n) means you are essentially calling tuple(100). And 100
alone isn't a sequence. The star explodes or expands the sequence, like
in this example:

def doit(x, y, z):
print x, y, z

vals = (1,2,3)

doit(*vals) #see the star symbol
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.