Why the expression "(1)" is not an one-arity tuple, but int ?

  • Thread starter ðÅÔÒÏ× áÌÅËÓÁÎÄÒ
  • Start date
Ð

ðÅÔÒÏ× áÌÅËÓÁÎÄÒ

Hello All !

In my code I try to use a generic approach to work with tuples. Let
"X" be a tuple.
When I want to access a first element of a tuple, I can write: "X[0]".
And that is really working when X is a n-arity tuple, with n>1 (for
example "foo( (1,2,3) )" ).
But when I call my library function with a 1-arity tuple (for example
"foo( (1) )" ) I have an error:

TypeError: 'int' object is unsubscriptable

How could I tell Python that "(1)" is not an integer, but an one-arity tuple ?

Thank you,
Alexander Petrov
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top