text processing in python - 417
descriptions of how to reach them. 4rdf deals with "meta-data" that documents use to identify their semantic characteristics. I detail 4Suite technologies in a bit more detail in an article at:
< http://gnosis.cx/publish/programming/xml_matters_15.html >
yaml
The native data structures of object-oriented programming languages are not straightforward to represent in XML. While XML is in principle powerful enough to represent any compound data, the only inherent mapping in XML is within attributes—but that only maps strings to strings. Moreover, even when a suitable XML format is found for a given data structure, the XML is quite verbose and difficult to scan visually, or especially to edit manually. The YAML format is designed to match the structure of datatypes prevalent in scripting languages: Python, Perl, Ruby, and Java all have support libraries at the time of this writing. Moreover, the YAML format is extremely concise and unobtrusive—in fact, the acronym cutely stands for "YAML Ain't Markup Language." In many ways, YAML can act as a better pretty-printer than pprint, while simultaneously working as a format that can be used for configuration files or to exchange data between different programming languages. There is no fully general and clean way, however, to convert between YAML and XML. You can use the yaml module to read YAML data files, then use the gnosis.xml.pickle module to read and write to one particular XML format. But when XML data starts out in other XML dialects than gnosis.xml.pickle, there are ambiguities about the best Python native and YAML representations of the same data. On the plus side—and this can be a very big plus—there is essentially a straight-forward and one-to-one correspondence between Python data structures and YAML representations. In the YAML example below, refer back to the same Python instance serialized using gnosis.xml.pickle and pprint in their respective discussions. As with gnosis.xml.pickle—but in this case unlike pprint—the serialization can be read back in to re-create an identical object (or to create a different object after editing the text, by hand or by application). >>> class Container: pass ... >>> inst = Container() >>> dct = {1.7:2.5, ('t','u','p'):'tuple'} >>> inst.this, inst.num, inst.dct = 'that', 38, dct >>> import yaml >>> print yaml.dump(inst) --- !!__main__.Container dct: 1.7: 2.5 ? -t -u -p : tuple num: 38 this: that SEE ALSO: pprint 94; gnosis.xml.pickle 410;
[ Team LiB ]
- Pro možnost psaní komentářů se přihlašte nebo zaregistrujte.



































































