Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMichael Sothan
8,048 PointsWhat is the purpose of always adding an extra object in front of the method?
I noticed in all of Kenneth's examples he will test using a new object like "jso" and then assign it to a class so he can run his method on it, like
jso = javascriptobject.JavaScriptObject({'name:' 'Kenneth'})
It seems like the 'javascriptobject' in front is redundant. It can't just be?:
jso = JavaScriptObject({'name': 'Kenneth'})
Is it because this newly created class only exists within the "javascriptobject.py" program?
1 Answer
Chris Freeman
Treehouse Moderator 68,457 PointsIs it because this newly created class only exists within the "javascriptobject.py" program? Correct.
If Kenneth had used JavaScriptObject({'name': 'Kenneth'})
then the object JavaScriptObject
would be looked for in the current module name space. Including the module name javascriptobject
indicates to look for the object in the import module.
Post back if you need more help. Good luck!!