Not Defined error in basic code
Where are you seeing something like this? The two lines under `class
weapon:` are not correct because they are variable names that you've never
Maybe you intended this to "declare" the attributes for the class? That
isn't something you need to do in Python. If you simply remove these lines
your example should work.
On Thu, Mar 14, 2019 at 10:05 AM Jack Dangler <tdldev at gmail.com> wrote:
> Just getting started with tutorials and such, and don't understand this -
> <file: class_weapon.py>
> class weapon:
> def printWeaponInfo(self):
> infoString = "ID: %d Mfg: %s Model: %s" % (self.weaponId,
> return infoString
> <file: weaponTrack.py>
> import class_weapon
> MyWeapon.weaponId = 100
> MyWeapon.manufacturerName = "Glock"
> executing 'python3 weaponTrack.py' results in this bailing on the first
> element in the class with "not defined". I've been staring at templates
> of this exact structure for about an hour trying to figure out why this
> isn't running at all. Is it simply because it isn't all in one file?
> Thanks for any guidance. Really appreciate the help.
SENIOR QUALITY ENGINEER
cspealma at redhat.com M: +1.336.210.5107
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>