You return four variables s1,s2,s3,s4 and receive them using a single variable obj. This is what is called a tuple, obj is associated with 4 values, the values of s1,s2,s3,s4. So, use index as you use in a list to get the value you want, in order.
Copyobj=list_benefits()
print obj[0] + " is a benefit of functions!"
print obj[1] + " is a benefit of functions!"
print obj[2] + " is a benefit of functions!"
print obj[3] + " is a benefit of functions!"
Answer from Aswin Murugesh on Stack OverflowYou return four variables s1,s2,s3,s4 and receive them using a single variable obj. This is what is called a tuple, obj is associated with 4 values, the values of s1,s2,s3,s4. So, use index as you use in a list to get the value you want, in order.
Copyobj=list_benefits()
print obj[0] + " is a benefit of functions!"
print obj[1] + " is a benefit of functions!"
print obj[2] + " is a benefit of functions!"
print obj[3] + " is a benefit of functions!"
You're returning a tuple. Index it.
Copyobj=list_benefits()
print obj[0] + " is a benefit of functions!"
print obj[1] + " is a benefit of functions!"
print obj[2] + " is a benefit of functions!"
python 3.x - AttributeError: 'tuple' object has no attribute 'type' upon importing tensorflow - Stack Overflow
'tuple' object has no attribute 'to' in pytorch
AttributeError: 'tuple' object has no attribute 'type'
Getting AttributeError: 'tuple' object has no attribute 'items'
Videos
In fact, this means you have multiple versions of numpy installed somehow (or there are multiple versions that are overlapping). You need to make sure that numpy is fully uninstalled from your system, then reinstall.
For me, I did
pip uninstall numpy
sudo apt-get purge python3-numpy
Then I had to go to /usr/local/lib/python3.6/dist-packages and delete the numpy folders that were still there for some reason. After that, reinstalling numpy with
pip install numpy
worked. Here is the github issue I opened on it:
https://github.com/numpy/numpy/issues/12775
Had the same issue, fixed by going back to Numpy 1.15.4 Thanks wordsforthewise
from kubernetes import client, config
config.load_kube_config()
v1 = client.CoreV1Api()
print("Listing services with their IPs:")
ret = v1.list_service_for_all_namespaces_with_http_info(watch=False)
for i in ret.items:
print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name)) This throws this error: File "filename.py", line 8, in <module> for i in ret.items: AttributeError: 'tuple' object has no attribute 'items'
But when I simply print(ret), it certainly LOOKS like a tuple, which means I should be able to iterate through with tuple.items, no?
I am trying out the PySerial library, and I'm coming across an issue.
I am using a section of code designed to select the COM port that my Arduino is connected to. The code is:
import warnings
import serial
import serial.tools.list_ports
arduino_ports = [
p.device
for p in serial.tools.list_ports.comports()
if 'Arduino' in p.description
]
if not arduino_ports:
raise IOError("No Arduino found")
if len(arduino_ports) > 1:
warnings.warn('Multiple Arduinos found - using the first')
ser = serial.Serial(arduino_ports[0])When I run the code in Python (tried in 3.6 and 2.7) I get the following error:
AttributeError Traceback (most recent call last) <ipython-input-1-f19fcecc00c1> in <module>() 6 p.device 7 for p in serial.tools.list_ports.comports() ----> 8 if 'Arduino' in p.description 9 ] 10 if not arduino_ports: AttributeError: 'tuple' object has no attribute 'description'
What exactly am I doing wrong?
The docs on the method note:
New in version 2.6.
Changed in version 3.0: returning ListPortInfo objects instead of a tuple
So my first guess would be that you're using an outdated version.
Weird, works for me on Linux. serial.tools.list_ports.comports() seems to return something strange in your case, not what it should. You can try this to see what the hell the function is actually returning:
import serial.tools.list_ports
print(serial.tools.list_ports.comports())
print(serial.tools.list_ports.comports()[0])
print(type(serial.tools.list_ports.comports()[0]))