Sponsored Links:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2. Functions, Statements & Indentation
#1
This episode we go through the if/elif/else/and/or statements.

We also create our own function and even pass through some paramaters and show how different paramaters sent through can be used as variables in our code.

As a bonus we also touch on the importance of indentation, tabs vs spaces!

Please only use this thread for discussion on any of the topics listed above (or relevant to the video below), thank you.




WANT EARLY DEVELOPMENT RELEASE ACCESS?
All users who've helped out with a donation can now gain early access to the
latest test versions of add-ons, often weeks or months ahead of the public stable releases.

[Image: 11i3ihd.jpg]
  Reply
Sponsored Links:
#2
Hi Team

Been working ON Python koding 2  video


and towards the end it out puts a number to login meant to be 200  I keep getting 100  ( on the Test parm link ** as per log below)

my Kodi log is like this

Code:
###### BARRONI 2 STATEMENT ####

00:19:26 T:4708  NOTICE: test param = ###### IS THIS WORKING DEEZZEL? whatever = 100


here is my Code for my Default .py (* some code changes just to be different to video but works the same*)
Code:
# Addon Code by Thomas (@teamxkodi Twitter)

import xbmc, xbmcgui
import os


# Global Variables
# Variables assign different values to different items

deezel          = 1
barroni         = 2
shan            = 'Two'
arb             = "three's"
dunc            = 'he says "hi guys"'
lee             = "what\'s all \"this\" about?"


def index():
   xbmc.log('#######  '+str(barroni))


def deeztest():
   xbmc.log('##### arb = %s  dunc = %s   barroni= %s' % (arb, dunc, barroni))
   whatevernew = whatever * 2
   xbmc.log(str(whatevernew))

def luketest(testparam, whatever):
   xbmc.log('test param = %s whatever = %s' %  (testparam, whatever))

if deezel == 1 and barroni == 0:
   xbmc.log('###### DEEZEL & BARRONI  STATEMENT ####')
   deeztest()
elif barroni == 2:
   xbmc.log('###### BARRONI 2 STATEMENT ####')
   luketest('###### IS THIS WORKING DEEZZEL?' , 100)
elif deezel == 1:
   xbmc.log('###### DEEZEL 0 STATEMENT ####')
   index()
else:
   xbmc.log('###### ELSE STATEMENT ####')
   deeztest()

  


Could some help me to get 200 instead  of 100  on test pram  (*luketest)

Cheers
Thomas

Here is my files so you can can download view on your Computer as well
(addon.zip  default.py & addon.xml  -->  Click here to download my addon files )
  Reply
#3
(12-19-2016, 11:50 AM)tdbnz Wrote: Hi Team

Been working ON Python koding 2  video


and towards the end it out puts a number to login meant to be 200  I keep getting 100  ( on the Test parm link ** as per log below)

my Kodi log is like this

Code:
###### BARRONI 2 STATEMENT ####

00:19:26 T:4708  NOTICE: test param = ###### IS THIS WORKING DEEZZEL? whatever = 100


here is my Code for my Default .py (* some code changes just to be different to video but works the same*)
Code:
# Addon Code by Thomas (@teamxkodi Twitter)

import xbmc, xbmcgui
import os


# Global Variables
# Variables assign different values to different items

deezel          = 1
barroni         = 2
shan            = 'Two'
arb             = "three's"
dunc            = 'he says "hi guys"'
lee             = "what\'s all \"this\" about?"


def index():
   xbmc.log('#######  '+str(barroni))


def deeztest():
   xbmc.log('##### arb = %s  dunc = %s   barroni= %s' % (arb, dunc, barroni))
   whatevernew = whatever * 2
   xbmc.log(str(whatevernew))

def luketest(testparam, whatever):
   xbmc.log('test param = %s whatever = %s' %  (testparam, whatever))

if deezel == 1 and barroni == 0:
   xbmc.log('###### DEEZEL & BARRONI  STATEMENT ####')
   deeztest()
elif barroni == 2:
   xbmc.log('###### BARRONI 2 STATEMENT ####')
   luketest('###### IS THIS WORKING DEEZZEL?' , 100)
elif deezel == 1:
   xbmc.log('###### DEEZEL 0 STATEMENT ####')
   index()
else:
   xbmc.log('###### ELSE STATEMENT ####')
   deeztest()

  


Could some help me to get 200 instead  of 100  on test pram  (*luketest)

Cheers
Thomas

Here is my files so you can can download view on your Computer as well
(addon.zip  default.py & addon.xml  -->  Click here to download my addon files )





def deeztest():
    xbmc.log('############ arb = %s  houdin = %s    barroni = %s ' % (arb, houdin, barroni))



def luketest(testparam, whatever):
    xbmc.log('test param = %s      whatever = %s' % (testparam, whatever))
    whatevernew = whatever * 2
    xbmc.log(str(whatevernew))
  Reply
#4
Thank you for your help I just made a slight mistake now it is working

cheers
Thomas
  Reply
#5
Just so you fully understand what's happening there...

deeztest() was the only function you were telling it to multiply by 2.
However in your code that was never being called due to barroni being equal to 2 and so the 100 remained unchanged.
WANT EARLY DEVELOPMENT RELEASE ACCESS?
All users who've helped out with a donation can now gain early access to the
latest test versions of add-ons, often weeks or months ahead of the public stable releases.

[Image: 11i3ihd.jpg]
  Reply
#6
(12-20-2016, 09:55 PM)whufclee Wrote: Just so you fully understand what's happening there...

deeztest() was the only function you were telling it to multiply by 2.
However in your code that was never being called due to barroni being equal to 2 and so the 100 remained unchanged.

Thank you  Whufclee I totally understand now it was  just a slight mistake I did glad it is working now

Thanks for your videos
Cheers
Thomas
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)