Re: [Tutor] Class errors
If the code I'm seeing is correct, the problem is the class is Jobs, and you instantiated a Job, which doesn't exit. Replace one with the other in either case should fix it. On Thu, Jan 22, 2015 at 11:11 AM, jarod...@libero.it wrote: > Dear All, > > I created a class that invoke from another file another class > I get an error that I do not understand: gobal name Job is not defined > However If I see the class imported I found the class Job. > Any suggestion or example on class invoke another class > > #job,py > class Jobs: > . > > #trial.py > > from core.job import * > class Second: > def __initi__: > tp = open("/tmp/file.txt") > > def gus(self): > tr = Job() > > thanks so much!1 > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Class errors
On 22Jan2015 17:11, jarod...@libero.it wrote: I created a class that invoke from another file another class I get an error that I do not understand: gobal name Job is not defined However If I see the class imported I found the class Job. Any suggestion or example on class invoke another class First, please cut/paste error messages, filenames and code. Do not hand type them, as that introduces errors. #job,py For example, I suspect you mean "job.py", not "job,py". class Jobs: . #trial.py from core.job import * It is not recommended to import "*". Just impor the names you need. It avoids _unexpected_ names leaking into your program: you might be using such a name for something else! class Second: def __initi__: tp = open("/tmp/file.txt") def gus(self): tr = Job() Because you have hand typed things I cannot be sure - it may just be a mistake - but "job.py" defines a class "Jobs". In "trial.py" you use the name "Job". Not the same! Cheers, Cameron Simpson Beware of bugs in the above code; I have only proved it correct, not tried it. - Donald E. Knuth ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Class errors
On Thu, Jan 22, 2015 at 8:11 AM, jarod...@libero.it wrote: > Dear All, > > I created a class that invoke from another file another class > I get an error that I do not understand: gobal name Job is not defined Please use copy-and-paste. You just typed out the error message by hand: we can tell because the error message you're presenting is misspelled. Copy-and-paste it, as well as the surrounding text around it. > However If I see the class imported I found the class Job. Ok. But where? In the code you present: > #job,py > class Jobs: > . > > #trial.py > > from core.job import * > class Second: > def __initi__: > tp = open("/tmp/file.txt") > > def gus(self): > tr = Job() I don't see a class named 'Job'. I see a class named 'Jobs' defined in 'job.py', but that's a different class. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor