converting to string

A

Ajay Brar

hi!

how do i go about converting a Python object or tuple to a string.
i am currently doing
import cPickle as pickle
str = pickle.dumps(obj)

is that efficient? is that the best way to do it?

thanks

cheers

--
Ajay Brar
CS Honours 2004
Smart Internet Technology Research Group

http://www.it.usyd.edu.au/~abrar1
 
J

Josef Dalcolmo

how do i go about converting a Python object or tuple to a string.

I guess the simplest is to use the built-in functions: str or repr

str(object) if you just need a printable string
repr(object) if you need to reconstruct later the original object from the string

- Josef
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top