"Frank Millman"  wrote in message news:o5hnbq$q36$1...@blaine.gmane.org...

"Frank Millman"  wrote in message news:o5hlh4$1sb$1...@blaine.gmane.org...
>
> If you are saying -
>     for item in list:
>         print(item)
>
> you can say instead -
>   for item in list:
>         print(str(item))
>

This is not correct, sorry.

print(item) will automatically print the string representation of item, so it makes no difference.

The principle is still correct, though.

If you want to convert what you call the memory address of the item to the string representation, just wrap it in str(...)


I keep thinking of something else just after I have posted - sorry about that.

When you say you print the list, maybe you are literally doing the following -
   print(list)

In that case, the solution is to turn it into a list comprehension, and apply str() to each item -
   print([str(item) for item in list])

Frank


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to