os.getcwd() return semicolon at the end?
#1
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.
Reply
#2
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.
Reply
#3
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?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#4
(darkie @ jan. 10 2006,17:09 Wrote: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?
yes, exactly!
I'm not an expert but I play one at work.
Reply
#5
(darkie @ jan. 10 2006,19:09 Wrote: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?
if it's not intended i wouldn't recommend fixing it. too many scripts do os.getcwd()[:-1] and they will break.
Reply
#6
Quote:if it's not intended i wouldn't recommend fixing it. too many scripts do os.getcwd()[:-1] and they will break
agreed, will leave it as it is for now. however, i think it is better to fix this when the next official xbmc release is.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#7
ho !
it would be a bad thing for many many scripts !! i mean sooo many scripts to update....

anyway, if it is not normal, just fix it.... lol

it is like when you give your blood.. you know ? it is better for your health as your blood can regenerate Smile
Reply
#8
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.
Reply
#9
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.
Reply
#10
sorry, but my english seems to be not enough correct to understand clearly...

i'm using in my script
homedir = os.getcwd()[:-1]+"\\"
then for a pic directory :
picsdir = homedir + "pics\\"

and it works like a charm... i don't know if this way is a correct python use, or if this trick (pulling out the last char because it is not a correct one) should not be used in python...
you posts make me losing my mind... Shocked :joker:
Reply
#11
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.
Reply

Logout Mark Read Team Forum Stats Members Help
os.getcwd() return semicolon at the end?0