Discussion:
[Tutor] noob python question
bob5487
2015-10-25 23:16:30 UTC
Permalink
Howdy!

Reading *Learn Python the Hard Way* Zed Shaw

All good so far but got to Ex 42 dealing with classes...

I get a TypeError: getattr(): attribute name must be a string when I run the
program...

I looked online, python reference manual 3rd edition, etc...

I was wondering if anyone has experience with this book because I hit a road
block





--
View this message in context: http://python.6.x6.nabble.com/noob-python-question-tp5174789.html
Sent from the Python - tutor mailing list archive at Nabble.com.
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ben Finney
2015-10-26 02:43:52 UTC
Permalink
Post by bob5487
Reading *Learn Python the Hard Way* Zed Shaw
All good so far but got to Ex 42 dealing with classes...
Can you give a URL to the exact code so that we can know we're seeing
the same thing that you are?
Post by bob5487
I get a TypeError: getattr(): attribute name must be a string when I
run the program...
Please show the full text of the traceback, and preferably the code you
ran which led to that error.
--
\ “The WWW is exciting because Microsoft doesn't own it, and |
`\ therefore, there's a tremendous amount of innovation |
_o__) happening.” —Steve Jobs |
Ben Finney

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/list
Cameron Simpson
2015-10-26 04:22:48 UTC
Permalink
Post by bob5487
Reading *Learn Python the Hard Way* Zed Shaw
All good so far but got to Ex 42 dealing with classes...
I get a TypeError: getattr(): attribute name must be a string when I run the
program...
I looked online, python reference manual 3rd edition, etc...
I was wondering if anyone has experience with this book because I hit a road
block
As always with this list, please post the code you're trying. Even if we had
the book (I do not, personally), we don't know if your failing code matches the
code in the book, or if the code in the book is correct.

So please post the code, and the complete error message your computer gives
you.

Also not that getattr takes a string, per the error message. So to fetch the
.foo attribute from some object "o" you would write:

attribute = getattr(o, 'foo')

Note the quotes.

CHeers,
Cameron Simpson <***@zip.com.au>
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Asokan Pichai
2015-10-26 06:27:29 UTC
Permalink
Can you retype the question and your code?
Post by bob5487
Howdy!
Reading *Learn Python the Hard Way* Zed Shaw
All good so far but got to Ex 42 dealing with classes...
I get a TypeError: getattr(): attribute name must be a string when I run the
program...
I looked online, python reference manual 3rd edition, etc...
I was wondering if anyone has experience with this book because I hit a road
block
--
http://python.6.x6.nabble.com/noob-python-question-tp5174789.html
Sent from the Python - tutor mailing list archive at Nabble.com.
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
--
Asokan Pichai
*-------------------*
We will find a way. Or, make one. (Hannibal)

*To find everything profound — that is an inconvenient trait.* It makes one
strain one's eyes all the time, and in the end one finds more than one
might have wished. -- Nietzsche
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription option
boB Stepp
2015-10-26 13:54:33 UTC
Permalink
Greetings!
Post by bob5487
Howdy!
Reading *Learn Python the Hard Way* Zed Shaw
All good so far but got to Ex 42 dealing with classes...
I get a TypeError: getattr(): attribute name must be a string when I run the
program...
I looked online, python reference manual 3rd edition, etc...
I was wondering if anyone has experience with this book because I hit a road
block
As many will not have access to this book, what is usually done here
is to copy and paste your code as well as your FULL error message into
a plain text email. Also, it is usually helpful to state your Python
version and OS type and version. This will give everyone the
information they need to help you. Also, you probably need to
summarize what exercise 42 is asking you to do.

I have a copy of that book at home. If memory serves me correctly, it
is written for Python 2. If that is the case you probably want to be
looking at the Python 2 documentation. Also, if you are trying to run
Python 2 code and you have Python 3 installed on your computer, you
will from time to time run into issues just because there ARE
differences between Python 2 and 3 syntax in some areas.

HTH,
--
boB
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Bob Gailer
2015-10-26 15:11:21 UTC
Permalink
Welcome to the tutor list. In order for us to help you please post the
following:
Python version
Operating system
The code you are running
To trace back you are getting
The trace back will be several lines of references to various programs and
line numbers

Once we have that information then it becomes easy to help good luck
Post by bob5487
Howdy!
Reading *Learn Python the Hard Way* Zed Shaw
All good so far but got to Ex 42 dealing with classes...
I get a TypeError: getattr(): attribute name must be a string when I run the
program...
I looked online, python reference manual 3rd edition, etc...
I was wondering if anyone has experience with this book because I hit a road
block
--
http://python.6.x6.nabble.com/noob-python-question-tp5174789.html
Sent from the Python - tutor mailing list archive at Nabble.com.
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Continue reading on narkive:
Loading...