Perl XML::Simple and Data::Dumper - exists in Python?

M

Miguel Manso

Hi there,

I'm a Perl programmer trying to get into Python. I've been reading some
documentation and I've choosed Python has being the "next step" to give.

Can you point me out to Python solutions for:

1) Perl's Data::Dumper

It dumps any perl variable to the stdout in a "readable" way.

2) Perl's XML::Simple

It maps a XML file into a Perl data structure.

Does Python have something like these two tools? I've been googling
before posting this and didn't find anything.

Thanks for the help.
 
W

Wallace Owen

Miguel said:
Hi there,

I'm a Perl programmer trying to get into Python. I've been reading some
documentation and I've choosed Python has being the "next step" to give.

Can you point me out to Python solutions for:

1) Perl's Data::Dumper

It dumps any perl variable to the stdout in a "readable" way.

All Python objects support reflection and can be serialized to a data
stream. There's about four ways to do it (Kinda perl-like in that
regard, but typically for a particular application there's one obvious
right choice). You control the way your objects appear as strings, by
defining a __str__ member function that'll be invoked if the user does:

% print str(yourObject)

You can print any builtin type with just:
>>> lst = ["one", "two", (3, 4.56), 1]
>>> print lst ['one', 'two', (3, 4.5599999999999996), 1]
>>>
2) Perl's XML::Simple

It maps a XML file into a Perl data structure.

Python's got a Document Object Model lib that essentially maps an XML
file to objects that have built-in-type behavior - you can treat a
NodeList object as a python list, indexing into it, iterating over it's
contents, etc.

It's also got SAX and expat bindings.
Does Python have something like these two tools? I've been googling
before posting this and didn't find anything.

Do your searches at python.org.


// Wally
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top