I am new to Python and I have written this simple script:
#!/usr/bin/python3
import sys
class Hello:
def printHello():
print(\'Hello!\')
def ma
If you want printHello as instance method, it should receive self as argument always(ant python will pass implicitly) Unless you want printHello as a static method, then you'll have to use @staticmethod
#!/usr/bin/python3
import sys
class Hello:
def printHello(self):
print('Hello!')
def main():
helloObject = Hello()
helloObject.printHello() # Here is the error
if __name__ == '__main__':
main()
As '@staticmethod'
#!/usr/bin/python3
import sys
class Hello:
@staticmethod
def printHello():
print('Hello!')
def main():
Hello.printHello() # Here is the error
if __name__ == '__main__':
main()