Using PyQt 4, Python 2.7, Windows 7 on a x64 machine.
I have been developing a bit of code using a Python console with PyQt4 and passing strings from QLineEdit() widgets to OS commands with no issues using os.system(cmd)
But when I tried running from the command line in Windows I get the following error,
TypeError: sequence item 0: expected string, QString found
I got around this by converting the offending string via str(cmd)
but it has left me curious about, why this should happen only when the code is called from the command line and not when called within a Python console?
I think that this problem happens because the command line parameters are actually byte arrays and not strings, strings are encoded in Unicode, but byte arrays are not. Calling
str(cmd)
return the content ofcmd
as a string.