Not getting expected script errors
#1
Does importing everything from a py file mean you have imported everything thats imported in that file too?

I was trying to figure out why this line wasnt playing any TV episodes, when no script error was being reported.
Code:
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "episodeid": %d }, "options":{ "resume": "true" }  }, "id": 1 }' % (epid))

So I looked through the code for some try/exception:pass I may have missed but didnt find anything. Then I noticed that I hadnt imported xbmc. WTF? Surely I should have gotten a script error for that!

My first thought is that maybe the xbmc module gets imported along with everything else in this fille?

Code:
from resources.lazy_lib import *

tx
Reply
#2
Short answer? Probably. Read up on name spaces for the long answer
Reply
#3
So I understood name spaces but I read up on name spaces anyway and now I dont understand name spaces Smile

I'll just do some more work in IDLE to get my head around it.

Thanks.

PS. For anyone stumbling on to this post, the problem with the json dict was that "resume: "true" needed to be "resume": true.
Reply
#4
Once something is imported, a reference is kept in sys.modules. Whenever you try to import something, Python first checks to see if that module is already in sys.modules and if so, just returns the stored reference instead of importing all over again. This is useful if you need to modify the functionality of a built-in library (a technique called "monkey patching"), by replacing the stored reference with your own. See an example here: https://github.com/bstrdsmkr/plugin.vide...default.py
Reply
#5
Brilliant answer. Thanks.
Reply

Logout Mark Read Team Forum Stats Members Help
Not getting expected script errors0