By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,171 Members | 809 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,171 IT Pros & Developers. It's quick & easy.

Difference between str and string

P: n/a
I've been seeing some somewhat strange behaviour in a python script
that I'm writing and was wondering whether someone could help me out

I have the following code:

path = getPath(bundle, item)
path = hub.parseString(path)

getPath is a function that returns a string, and hub.parseString is an
external C++ function that also returns a string..

When I run this at the moment, it gives:

TypeError: argument 1 must be string without null bytes, not str

However, if I add a print statement somewhere else in the code
completely (after this is executed, and printing out a different
variable altogether) it works (but only with some - it would only work
if I had both of the lines:

print "Details:"
print details

but it wouldn't work with just one...)
Anyway, any idea what I'm doing wrong or what python's doing wrong?

For the moment, I've got around this by doing:

path = hub.parseString((StringIO.StringIO(path)).getvalue ())

Which works, but I don't like doing it...

any suggestions would be most welcome...

Hugh Macdonald
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Hugh Macdonald wrote:
Anyway, any idea what I'm doing wrong or what python's doing wrong?

It looks you have a string with embedded null bytes, which is not
supported where you want to use it. Do

print repr(path)

to find out what precisely the value of path is (doing a plain print
would send the null bytes to the terminal, which might ignore them)


Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.