• Advertisement
Sign in to follow this  

Python 3.0 classes?

This topic is 3392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have recently been reading the most recent Byte of Python that is edited for python 3.0 and I have had some problems with it's example for a simple class. Here is the coding

class Person():
    def sayHI(self):
            print('Hello,how are you?')


p = Person()
p.sayHi()

I keep getting this error. Traceback (most recent call last): File "C:\Users\Eric\Desktop\Python Progs\Person Class.py", line 8, in <module> p.sayHi() AttributeError: 'Person' object has no attribute 'sayHi' can anyone tell me what I am doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
Python is case sensitive. sayHi is not the same as sayHI.

Share this post


Link to post
Share on other sites
OH MY GOD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!. I can't belive I didn't catch that!>< I feel like an idiot. I checked and checked and I couldn't tell that a stinkin 'i' was screwing me over. :(. Thanks for pointing that out.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement