Soy nuevo en Python y he escrito este guión sencillo:"<method> no tiene argumentos (1 dada)" pero me dio ninguna
#!/usr/bin/python3
import sys
class Hello:
def printHello():
print('Hello!')
def main():
helloObject = Hello()
helloObject.printHello() # Here is the error
if __name__ == '__main__':
main()
Cuando lo ejecuto (./hello.py
) me sale el siguiente mensaje de error :
Traceback (most recent call last): File "./hello.py", line 13, in <module> main() File "./hello.py", line 10, in main helloObject.printHello() TypeError: printHello() takes no arguments (1 given)
¿Por qué Python piensan que di printHello()
un argumento mientras yo claramente no lo hice? ¿Qué he hecho mal?
posible duplicado de [error del compilador Python, x no tiene argumentos (1 determinado)] (http://stackoverflow.com/questions/4445405/python-compiler-error -x-takes-no-arguments-1-given) – IanAuld