error 'unexpected indent' in super small script
#1
Code:
from datetime import datetime, timedelta
import xbmc, xbmcgui
import time


while True:
    myplayer = xbmc.Player()
    if myplayer.isPlaying():
        ntime = myplayer.getTime() + 10
        nctime = myplayer.getTotalTime()

        sec = timedelta(seconds=int(ntime))
        ct = datetime(1,1,1) + sec
        s1 = "%d:%d:%d" % (ct.hour, ct.minute, ct.second)
        sec = timedelta(seconds=int(nctime))
        ct = datetime(1,1,1) + sec
        s2 = "%d:%d:%d" % (ct.hour, ct.minute, ct.second)

        xbmc.log(msg="CTIME: %s / %s" % (s1, s2))
        time.sleep(1)

Error Contents: ('unexpected indent', ('C:\\Program Files (x86)\\XBMC\\scripts\\time.py', 8, 1, '\tif myplayer.isPlaying():\n'))
why is that?
Reply
#2
i fixed it but i want it in format 00:01:01 when its 0:1:1 , is it possible?
Reply
#3
ok i managed to fix it, thanks anyway, someone on #python @ freenode helped me.
Reply
#4
(2014-02-19, 08:38)hayuto Wrote:  
Code:
[b]Error Contents: ('unexpected indent', ('C:\\Program Files (x86)\\XBMC\\scripts\\time.py', 8, 1, '\tif myplayer.isPlaying():\n'))[/b]
why is that? 
As the error message indicates, you have an unexpected indent error. This error occurs when a statement is unnecessarily indented or its indentation does not match the indentation of former statements in the same block. Python not only insists on indentation, it insists on consistent indentation . You are free to choose the number of spaces of indentation to use, but you then need to stick with it. If you indent one line by 4 spaces, but then indent the next by 2 (or 5, or 10, or ...), you'll get this error. Whenever you have a situation with code inside of a statement, that inside code must be indented, and must be indented consistently. It is used by the interpreter to know how to delimit blocks of instructions.
Reply
#5
(2019-11-26, 08:37)creigelde Wrote: As the error message indicates...

Why are you reacting to an almost 6 year old topic?
Got a Kodi problem? Provide us with a full Debug log (wiki) || Usefull pages: First time user (wiki) || Troubleshooting (wiki) || Free content (wiki) || Forum rules (wiki) || VPN policy (wiki)
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
error 'unexpected indent' in super small script00