Typical Python errors

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Mummel
 
Posts: 23
Joined: Sun Aug 23, 2015 9:12 am

Typical Python errors

Post by Mummel »

Hello,

I think a common topic with typical errors would be useful...

I wanna start with the error: "'tuple' object is not callable".. What I wanted to do? I wanted to pass a tupel as a parameter to a called function. The Tupel should to contain to ints as matrix index for an neopixel matrix? What did I do wrong? What does this error, mean? There are no out or inout parameter in python, or am I wrong?

What do you think, of an common error topic? I am eager to hear from you.

User avatar
adafruit_support_carter
 
Posts: 29189
Joined: Tue Nov 29, 2016 2:45 pm

Re: Typical Python errors

Post by adafruit_support_carter »

Can you post the full code you are having issues with.

User avatar
tannewt
 
Posts: 3305
Joined: Thu Oct 06, 2016 8:48 pm

Re: Typical Python errors

Post by tannewt »

I'd like this troubleshooting doc to be the central place for "typical" error messages: https://circuitpython.readthedocs.io/en ... oting.html

I'd be happy to add specific errors to it that you've found.

User avatar
Mummel
 
Posts: 23
Joined: Sun Aug 23, 2015 9:12 am

Re: Typical Python errors

Post by Mummel »

For what I found out while debugging the code in spyder3, was a missmatch of brackets. What I wanted to was...

x = sometuple[0]

What I did was:

x = sometuple(0)... Which is the functioncall mentioned in the error message

How I then changed the code was:

x, y = sometuple

User avatar
adafruit_support_carter
 
Posts: 29189
Joined: Tue Nov 29, 2016 2:45 pm

Re: Typical Python errors

Post by adafruit_support_carter »

This is how to address any ordered sequence object (list, string, tuple).

Code: Select all

x = sometuple[0]
This is called tuple unpacking. A pythony way of doing things.

Code: Select all

x, y = sometuple
This is the syntax for a function call, which...well...what the error message said.

Code: Select all

x = sometuple(0)

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”