Jump to content
  • Advertisement
Sign in to follow this  
steveworks

Python 3.0 classes?

This topic is 3658 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
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
Quote:
Original post by steveworks
can anyone tell me what I am doing wrong?
Python is case-sensitive. You are trying to call a method 'sayHi', when the method is actually called 'sayHI'.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!