noob question about passing attributes.
#1
I am sorry if this has been covered I am not sure how to look it up.

I see in many scrpits ppl are passing attributes or info to there script from the skin, up til now I have only used a simple RunScript for what I have been doing and have the actual code linear just doing simple if then checks.

What I would like to do is make my add on actually take advantage of classes and only use certain classes based on arguments set at RunScript

Basically I am hoping someone could guide me in how to do something like

RunScript (script.test, arg1,arg2,...agr5)

Where agr1 will set the class or entry point
Agr 2 thru 5 would be varabiles

How would I decipher that on the python side?
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#2
Hey man... I see you are still plug-in away (pun intended) at python development.

IMO you would be better off with some fundamentals first... trying to reverse engineer other scripts or working with other system API's before basics will take you twice as long.

Try downloading pycharm or pyscripter... you can learn some great starting examples here: http://www.pythonforbeginners.com/

Passing arguments is a python basic and is not specific to kodi... well "runscript" is but classes and args/kwargs aren't.

Once you get some working code in your IDE it can be easily ported to Kodi...

http://kodi.wiki/view/Python_development

http://kodi.wiki/view/HOW-TO_write_Pytho..._Arguments
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#3
Thanks will have a look
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#4
Thanks that's what I needed.... Smile now have args coming in and splitting to sent back out hahaha perfect. Thanks a lot.
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#5
One more quick question.

So i am thinking i am going to have a couple smaller classes, my idea is the script can run fast because it will not have to got through a lot of code just to do little something.

so my question is if each class has its own while loop is there a limit to how many while loops i can have before it i get negative effects on speed?

I see some scripts use thread. would i need to run each while loop in a thread, are there any benefits to adding threading?

each while loop may be 20 lines of code at most. if that make a difference.
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#6
A single script (Python program) is executed consequently one instruction at a time. Threading is a pretty advanced topic, especially in Python with its infamous GIL. There's a saying that "premature optimization is like premature ejaculation" so I would recommend to get your code working as intended first, and then worry about speed issues, if there will be any.
Reply
#7
gotcha
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#8
(2017-08-09, 10:14)Roman_V_M Wrote: A single script (Python program) is executed consequently one instruction at a time. Threading is a pretty advanced topic, especially in Python with its infamous GIL. There's a saying that "premature optimization is like premature ejaculation" so I would recommend to get your code working as intended first, and then worry about speed issues, if there will be any.
+1 there is no point in worrying about performance right now... Down the road when your abilities improve you can write code with optimization in mind.

BTW compartmentalizing (ie classes) doesn't necessarily mean optimization.

Also avoid using to many loops, unless your function is time sensitive you might be better off with a single loop, or a basic thread timer.

Sent from my SM-G935T
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply

Logout Mark Read Team Forum Stats Members Help
noob question about passing attributes.0