Hello, I've started with python (3) recently. Initialy only for scripting. Now I'm trying the object oriented bit.
I'm getting the following error message
<Atom.Atom object at 0x7f0b09597fd0>
Traceback (most recent call last):
File "./Main.py", line 7, in <module>
print (t.getAtomName())
File "/home/jorge/Documentos/projetos/mestrado/códigos/cartesian_zmatrix/Atom.py", line 22, in getAtomName
return atomName
NameError: global name 'atomName' is not defined
when calling the function 'getAtomName()' of the 'Atom' class. This class is on the file Atom.py on the same directory as the test code.
below is my test code and Atom class code:
#! /usr/bin/python3
from Atom import *
t = Atom("C",12)
print (t.getAtomName())
class Atom:
cartesian = dict()
bondList = list()
atomName = str()
atomicNum = int()
def __init__(self,name, atNum):
self.atomName = name
self.atomicNum = atNum
def setCoordinates(x, y, z):
catesian['x'] = x
catesian['y'] = y
catesian['z'] = z
def addBondedAtom(Atom):
bondList.append(Atom)
def getAtomName():
return atomName
def getAtomicNumber():
return atomicNum
def getBondList():
return bondList
def getCartesian():
return cartesian
I appreciate any help, and also any tip you might have considering I've just started with python.
Abraço,
Jorge