Is there a Python module that already does this?

Karl M. Syring syring at email.com
Wed Feb 6 10:40:18 EST 2002


"MDK" <mdk at mdk.com> schrieb
> "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in
message
> news:mailman.1013003651.8981.python-list at python.org...
> > ----- Original Message -----
> > From: "MDK" <mdk at mdk.com>
> >
> >
> > > I need to convert a list into a list of characters.
> > >
> > > For example:
> > >
> > > ("cat",5,['dog',[3,3,1]],"zoo")
> >
> > That's not a "list", it's a tuple containing strings, ints, and lists;
> > further, you have nested lists.  Ouch.
> >
> > > Would become:
> > >
> > > ('c','a','t',5,'d','o','g',3,3,1,'z','o','o')
> > >
> > > Any information would be appreciated.
> >
> > This is doable, but there is no Python builtin I am aware of that can
> > do it.  Why do you need to do this?  If we understand what you are
trying
> > to do, we may be able to steer you away from this mess.
> >
> >
> P.S   Sorry, I used the wrong symbols.  I meant
> ["cat",5,['dog',[3,3,1]],"zoo"].

# Does not matter:
import pickle
ob = ["cat",5,['dog',[3,3,1]],"zoo"]
pickle.dumps(ob)

Flat enough?
Karl M. Syring





More information about the Python-list mailing list