hello i am trying to learn python i was doing ok
can somone please tell me why this don't work from
5.6 Looping Techniques
thanks
knights = {'gallahad': 'the pure', 'robin': 'the brave'}
for k, v in knights.iteritems():
print k, v
i get this error
19:18:02 M: 36392960 INFO: Q:\scripts\test.py
19:18:02 M: 36392960 INFO: ", line
19:18:02 M: 36392960 INFO: 13
19:18:02 M: 36392960 INFO:
19:18:02 M: 36392960 INFO:
19:18:02 M: 36392960 INFO: for k, v in knights.iteritems():
19:18:02 M: 36392960 INFO:
19:18:02 M: 36392960 INFO: ^
19:18:02 M: 36392960 INFO: SyntaxError
19:18:02 M: 36392960 INFO: :
19:18:02 M: 36392960 INFO: invalid syntax
got it to work from a funtion but
Code:
knights={'gallahad': 'the pure', 'robin': 'the brave'}
import xbmcgui
ACTION_PREVIOUS_MENU = 10
[color=Red]# why doesn't this work here
#
# for k, v in knights.iteritems():
# print k, v[/color]
class MyClass(xbmcgui.Window):
def __init__(self):
# Begin setting up the GUI background
self.pic = xbmcgui.ControlImage(0,0,0,0,'')
self.addControl(self.pic)
self.test1()
self.test2()
def onAction(self, action):
if action == ACTION_PREVIOUS_MENU:
self.close()
def test1(self):
for x in knights.keys():
print x, knights[x]
def test2(self):
for k, v in knights.iteritems():
print k, v
mydisplay = MyClass()
mydisplay .doModal()
del mydisplay
Nuka1195 Wrote:indentation
thanks for your reply
i have had the indentation error and corrected it
but this error is invalid syntax
can i ask another quesion
why doesn't a directory keep its order
params = {"server":"mpilgrim", "database":"master", "uid":"sa", "pwd":"secret"}
print params.items()
[('pwd', 'secret'), ('database', 'master'), ('uid', 'sa'), ('server', 'mpilgrim')]
please can you tell me whats wrong with the indentation of the code in red
Code:
knights={'gallahad': 'the pure', 'robin': 'the brave'}
import xbmcgui
ACTION_PREVIOUS_MENU = 10
[color=Red]# why doesn't this work here
#
# for k, v in knights.iteritems():
# print k, v[/color]
class MyClass(xbmcgui.Window):
def __init__(self):
# Begin setting up the GUI background
self.pic = xbmcgui.ControlImage(0,0,0,0,'')
self.addControl(self.pic)
self.test1()
self.test2()
def onAction(self, action):
if action == ACTION_PREVIOUS_MENU:
self.close()
def test1(self):
for x in knights.keys():
print x, knights[x]
def test2(self):
for k, v in knights.iteritems():
print k, v
mydisplay = MyClass()
mydisplay .doModal()
del mydisplay
get a great program called "PyScripter" - this checks ur code for syntax + indentation errors
:-)
stanley87 Wrote:get a great program called "PyScripter" - this checks ur code for syntax + indentation errors
:-)
thanks for the link, but i have not got python installed on my pc
i am using notepad and the xbmc log file
can you tell me whats wrong with the indentation for the code in red
thanks
the code in red is commented out, so unless you post it the exact way you want, how could we possible tell you. maybe it's a mix of tabs and spaces.
Nuka1195 Wrote:the code in red is commented out, so unless you post it the exact way you want, how could we possible tell you. maybe it's a mix of tabs and spaces.
thanks again for your reply
to rephase my question should the for loop statement in red work if so
can you tell me whats wrong with it
thanks
Code:
knights={'gallahad': 'the pure', 'robin': 'the brave'}
import xbmcgui
ACTION_PREVIOUS_MENU = 10
[color=Red]# why doesn't this work here
for k, v in knights.iteritems():
print k, v[/color]
class MyClass(xbmcgui.Window):
def __init__(self):
# Begin setting up the GUI background
self.pic = xbmcgui.ControlImage(0,0,0,0,'')
self.addControl(self.pic)
self.test1()
self.test2()
def onAction(self, action):
if action == ACTION_PREVIOUS_MENU:
self.close()
def test1(self):
for x in knights.keys():
print x, knights[x]
def test2(self):
for k, v in knights.iteritems():
print k, v
mydisplay = MyClass()
mydisplay .doModal()
del mydisplay
big thanks to
Nuka1195 for making me look at indentation
big thanks to
stanley87 for making me look at PyScripter
i have now install python and got
Alexpoet's XBMC Emulator Scripts working
what a difference a day makes
question to stanley87 when i close PyScripter after using this code blow i get
"
PyScripter.exe has encountered a problem and needs to close. We are sorry for the inconvenience."
but it run fine in the pythons IDLE
just wondering if you have encountered any problems with PyScripter.
other than the error when i close PyScripter its cool.
thanks for making me see the light
Code:
knights={'gallahad': 'the pure', 'robin': 'the brave'}
import xbmcgui
try: Emulating = xbmcgui.Emulating
except: Emulating = False
ACTION_PREVIOUS_MENU = 10
# [color=red]got to this work was indentation error[/color]
for k, v in knights.iteritems():
print k, v
class MyClass(xbmcgui.Window):
def __init__(self):
if Emulating: xbmcgui.Window.__init__(self)
# Begin setting up the GUI background
self.pic = xbmcgui.ControlImage(0,0,0,0,'background.png')
self.addControl(self.pic)
self.test1()
self.test2()
def onAction(self, action):
if action == ACTION_PREVIOUS_MENU:
self.close()
def test1(self):
for x in knights.keys():
print x, knights[x]
def test2(self):
for k, v in knights.iteritems():
print k, v
mydisplay = MyClass()
mydisplay .doModal()
del mydisplay
i would get a hold of XBMC_PC.exe (T3ch builds include it) and use that to test scripts that run in XBMC.
Nuka1195 Wrote:i would get a hold of XBMC_PC.exe (T3ch builds include it) and use that to test scripts that run in XBMC.
thanks i will try that later to night going to sit in the garden to get some rays now
been playing with
XBMC Emulator Scripts now thats cool
is XBMC_PC.exe like that
any links for help setting XBMC_PC.exe up or is it get and go
XBMC_PC.exe = XBMC running on your PC - its not a full port but very good for testing scripts and skins.
XBMC_PC.exe isn't in the fat 2.0.1 T3CH distro. :confused2: