Can someone explain why I'm getting the error:
global name 'helloWorld' is not defined
when executing the following:
class A:
def helloWorld():
print 'hello world'
class B(A):
def displayHelloWorld(self):
helloWorld()
class Main:
def main:
b = B()
b.displayHelloWorld()
I'm used to java where class B would obviously have a copy of class A's method "helloWorld" and thus this code would run fine when executing main. This however appears to think class B doesn't have any method called "helloWorld"
helloworldfrom another method in A? The answer should show you that this has nothing to do with inheritance.def main:), and it has no code that actually calls the method in question, and your error message is not an actual Python error message. If you want people to debug your code for you, you really need to give the actual code and the actual bugs, not just something vaguely similar that we have to guess at.