Posts: 3,746
Joined: May 2004
Reputation:
20
Livin
Posting Freak
Posts: 3,746
is this normal?
if i do this...
cwd = os.getcwd()
xbmcgui.dialog().ok('device info',cwd)
it shows the path with a ; at the end... totally screwing things up.
I'm not an expert but I play one at work.
Posts: 928
Joined: Feb 2004
Reputation:
0
Asteron
"Skilled" Python Coder
Posts: 928
yes it is fine.
in scripts you typically see os.getcwd()[:-1] which removes the final char.
if you didnt know, list[x:y] is a slicing operation and returns a sublist from position x up to (not including) y.
if x is omitted 0 is used. if y omitted than len(list) is used. negative numbers count backwards from the end of the list (-1 is the last element).
[:-1] is then everything from 0 up to but not including the last element.
Posts: 529
Joined: Sep 2003
Reputation:
0
darkie
Team-Kodi Member
Posts: 529
not normal. may i ask, how do you run that piece of code? is it in a .py file that is started directly from gui?
Posts: 3,746
Joined: May 2004
Reputation:
20
Livin
Posting Freak
Posts: 3,746
i cannot beleive this had not been found before?
i'm on my 3rd day of python... and struggling!
i'm used to asp, vbs & js so very different in many ways! whew!
I'm not an expert but I play one at work.
Posts: 3,746
Joined: May 2004
Reputation:
20
Livin
Posting Freak
Posts: 3,746
this problem seemed to have dissapeared!
i did not change a darn thing with how i was using it.
but!
i have not been able to get cwd = os.getcwd() to work...
it seems to be getting the correct path but when i use it no images display... so i've had to hard-code the path for now.
when i print the cwd and my appended image file names, the path looks perfect.
if you know of a fix, please let me know.
I'm not an expert but I play one at work.
Posts: 3,746
Joined: May 2004
Reputation:
20
Livin
Posting Freak
Posts: 3,746
i'm now using that "trick" too... there is definitely a bug in the function if it works correctly some time and not others... strange!
I'm not an expert but I play one at work.