Strange digit appears on list from PyDataSet

I had this code on the click of a button which produced a list?? of column names, it has just been noticed that the results of this have changed in that every column name in the list is preceeded by a “u”, i.e. [u’Mains_Water’, u’Hotwell_Water’, u’Hotwell_Steam’, u’Energy_parasitic’]. The “u” never used to be there. Did upgrade to 7.4 a couple of weeks ago, other than that I am baffled?? :scratch:
if I add “print value” into the loop the values are correct, if I add “print search” then the “u”'s appear in the console.

[code]event.source.parent.start = 1
event.source.parent.end = 5

search =
columns = system.dataset.toPyDataSet(event.source.parent.column_names)
for row in columns:
for value in row:
search.append(value)

event.source.parent.search = search[event.source.parent.start:event.source.parent.end]
[/code]

Those u’s are indicating that it’s a Python unicode string. When printing the list as a whole you should see them; this is the correct behavior.

Oops! posted this in wrong Forum! - But how come this used to work (no “U”'s) and now errors with a fault that indicates the SQL query is wrong! When I added an extra expression to “replace” the “U”'s with “” the code then worked like it did originally!! Something has changed??? :scratch:

Hmm, not sure what you’re doing that would cause those u’s to get in the way of something. Can you post your whole script?

The change is because for 7.4 we upgraded from Jython 2.1 to Jython 2.5.

Basically the result of the code originally posted goes to a custom property type ‘string’ which I then filter using three more custom properties (all expressions using the replace function to get rid of all [] and , the end result is used in a SQL query to populate a tables data. This SQL query was where the error came as no columns were called u’Mains’, u’water’ …etc, hence the need to suddenly add a fourth replace expression to get rid of the newly appearing U’s.

I guess my whole method is too basic and the sort of thing a beginner would do but I just wanted to understand why a 3 month old screen suddendly went bad so as to avoid the same in future work.

Right, basically what’s happening is your relying Python’s str implementation for a list of strings. This changed between Python 2.1 and Python 2.5.

The str (toString() in Java) is not something that should be relied upon in the way you’re using it.