I've found myself holding a beautiful data structure (parsed rss using the excellent
Universal Feed Parser) but with no way to manipulate it since I don't really know python and that's a python
module (not some handy script written in python)...
so after exploring a multitude of ways of coercing this data structure into a perl data structure i've decided it's time to stop and ask for help. so far, attempts have included:
- YAML, my first choice - but PyYAML won't dump_safe and so the output isn't useful to me (since it's not standard YAML, d'oh) .. i could subclass python's yaml module and teach it how to dump these, but i don't know python, and don't really have time to learn it properly for this project
- Python's Pickling routines - sounds like their version of Storable (pickles store well..), but Perl's unpickler doesn't work so well, 'specially for these "custom objects" ... IOW, fails for the same reason as YAML
- pyperl - some mysterious set of tools that allow you embed perl code in a python script, and access it's native data structures as well... but i can't get it to compile ... we'll not go into that in this post.
the thing that kills me is that if you just print the object using python's native printer (which sort of behaves like Data::Dumper apparently) the output looks very similar to a perl hash, but not quite. doing some regex's and then eval'ing the resultant string is .. sub-par, but so tempting at this point. before i damn myself that way,
i put to the clergy:
how have you coerced your python data structres into perl?
It's not what you look like, when you're doin' what you’re doin'.
It's what you’re doin' when you’re doin' what you look like you’re doin'!
- Charles Wright & the Watts 103rd Street Rhythm Band, Express yourself
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.