By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,621 Members | 1,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,621 IT Pros & Developers. It's quick & easy.

new to python, looking for streams clues

P: n/a
Hello peoples,

As I said, I'm new to python, and particularly to XML generation in
python.
Using the 4suite XML package, I have been able to produce XML, but
only directly to STDOUT.

Refering to the 4suite markupWriter refrence, the class needs a stream
to output the generated XML, and if none is specified, it's the STDOUT
stream that is used.

What I would like, would be to store the generated XML into a python
object which implement the stream interface to be able to transform it
via XSLT if needed (it's in a web based project).

But, I've read the python doc for the last 12 hours without finding
anything about an existing object that implements that interface.
Am I missing something, or should I really create that object myself ?

I mean, I just need something that I can write into and read
thereafter.
It should already exists, no ?
Jun 27 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Thierry wrote:
Hello peoples,

As I said, I'm new to python, and particularly to XML generation in
python.
Using the 4suite XML package, I have been able to produce XML, but
only directly to STDOUT.

Refering to the 4suite markupWriter refrence, the class needs a stream
to output the generated XML, and if none is specified, it's the STDOUT
stream that is used.

What I would like, would be to store the generated XML into a python
object which implement the stream interface to be able to transform it
via XSLT if needed (it's in a web based project).

But, I've read the python doc for the last 12 hours without finding
anything about an existing object that implements that interface.
Am I missing something, or should I really create that object myself ?

I mean, I just need something that I can write into and read
thereafter.
It should already exists, no ?
See the modules StringIO and cStringIO - which are mentioned on

http://docs.python.org/lib/lib.html

with the words:

4.5 StringIO -- Read and write strings as files

HTH,

Diez
Jun 27 '08 #2

P: n/a
Thierry a écrit :
Hello peoples,

As I said, I'm new to python, and particularly to XML generation in
python.
Using the 4suite XML package, I have been able to produce XML, but
only directly to STDOUT.

Refering to the 4suite markupWriter refrence, the class needs a stream
to output the generated XML, and if none is specified, it's the STDOUT
stream that is used.

What I would like, would be to store the generated XML into a python
object which implement the stream interface to be able to transform it
via XSLT if needed (it's in a web based project).

But, I've read the python doc for the last 12 hours without finding
anything about an existing object that implements that interface.
Am I missing something, or should I really create that object myself ?

I mean, I just need something that I can write into and read
thereafter.
It should already exists, no ?
It does, it's named StringIO (or cStringIO for the faster C
implementation), and it's part of the standard lib. AFAICT, it should
fit your needs.
Jun 27 '08 #3

P: n/a
On Jun 4, 1:50*pm, Bruno Desthuilliers <bruno.
42.desthuilli...@websiteburo.invalidwrote:
Thierry a écrit :
Hello peoples,
As I said, I'm new to python, and particularly to XML generation in
python.
Using the 4suite XML package, I have been able to produce XML, but
only directly to STDOUT.
Refering to the 4suite markupWriter refrence, the class needs a stream
to output the generated XML, and if none is specified, it's the STDOUT
stream that is used.
What I would like, would be to store the generated XML into a python
object which implement the stream interface to be able to transform it
via XSLT if needed (it's in a web based project).
But, I've read the python doc for the last 12 hours without finding
anything about an existing object that implements that interface.
Am I missing something, or should I really create that object myself ?
I mean, I just need something that I can write into and read
thereafter.
It should already exists, no ?

It does, it's named StringIO (or cStringIO for the faster C
implementation), and it's part of the standard lib. AFAICT, it should
fit your needs.
Thanks everyone.

I had seen it, but understood that you had to give it an already
existing string to operate on that one.
I feel a bit stupid. Time to get back to those lost sleep hours, I
presume.

But again, thanks everyone.
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.