469,277 Members | 1,959 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,277 developers. It's quick & easy.

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

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.

--
Miguel Manso <mm****@opalaconsult.com>
Nov 6 '05 #1
1 3138
Miguel Manso wrote:
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
Jun 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Greg Yasko | last post: by
13 posts views Thread by Paulo Pinto | last post: by
7 posts views Thread by Edward wijaya | last post: by
reply views Thread by Eric | last post: by
14 posts views Thread by horos | last post: by
reply views Thread by JohnLucas | last post: by
1 post views Thread by srinivasan srinivas | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.