What is the best way to get the text from a file into a string? The only thing that I can figure is to create a tempoarary Text Control and then using it’s LoadFile function.
any ideas?
What is the best way to get the text from a file into a string? The only thing that I can figure is to create a tempoarary Text Control and then using it’s LoadFile function.
any ideas?
What is the best way to get the text from a file into a string?
The only thing that I can figure is to create a tempoarary Text
Control and then using it's LoadFile function.
You don't need wxWindows to do it, just use Python:
text = open(file).read()
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!
This worked great for reading. Now I am wanting to write. I'm having a lot
of trouble finding these commands in the Documentation. where do I look?
-Mikhael
----- Original Message -----
From: "Robin Dunn" <robin@alldunn.com>
To: <wxpython-users@lists.wxwindows.org>
Sent: Wednesday, May 23, 2001 5:29 PM
Subject: Re: [wxPython] Reading a text file to a wxString
> What is the best way to get the text from a file into a string?
> The only thing that I can figure is to create a tempoarary Text
> Control and then using it's LoadFile function.You don't need wxWindows to do it, just use Python:
text = open(file).read()
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users
Hi Mikhael,
This worked great for reading. Now I am wanting to write. I'm having a lot
of trouble finding these commands in the Documentation. where do I look?
Try:
http://www.python.org/doc/current/
This is all described in the standard Python docs -- the "Library Reference" contains everything you need to know. It's a good idea to become familiar with this, as it describes everything in quite a bit of detail...
- Erik.
PS: To open a file for writing, try:
f = open(fileName, "w")
This is all described in the standard Python docs -- the "Library
Reference" contains everything you need to know. It's a good idea to
become familiar with this, as it describes everything in quite a bit of
detail...
Yes, except if you look there, you get all confused about fancy ways
to do fileIO, and never find the builtins.
The doc BADLY needs a way to search it. Discussion of file builtins
is here:
http://www.python.org/doc/current/tut/node9.html
and you might consider running through, or at least skimming the whole tutorial:
Hi Patricia,
This is all described in the standard Python docs -- the "Library
Reference" contains everything you need to know. It's a good idea to
become familiar with this, as it describes everything in quite a bit of
detail...Yes, except if you look there, you get all confused about fancy ways
to do fileIO, and never find the builtins.The doc BADLY needs a way to search it. Discussion of file builtins
is here:http://www.python.org/doc/current/tut/node9.html
and you might consider running through, or at least skimming the whole tutorial:
Interesting -- I've been working with Python full-time for nearly a year now, and I guess I must know the docs well enough not to let these things confuse me.
Thanks for pointing this out!
- Erik.
PS: You *can* search the docs if you download them. Under Linux you can use grep; under Windows, the MS Help file includes the ability to search anyway. The only thing that's lacking is searching online...