473,288 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

Question about files?

I want to create a program where a user can type what ever they want
to, have it saved to a file, and the be able to re-open it and read
it. How would I do this? Thanks!
May 31 '08 #1
3 1128
On May 31, 3:25*pm, Dennis Lee Bieber <wlfr...@ix.netcom.comwrote:
On Sat, 31 May 2008 11:44:14 -0700 (PDT), corvettecra...@gmail.com
declaimed the following in comp.lang.python:
I want to create a program where a user can type what ever they want
to, have it saved to a file, and the be able to re-open it and read
it. How would I do this? Thanks!

import os
os.system("edit") * * # may be Windows specific

* * * * Start with:http://www.catb.org/~esr/faqs/smart-questions.html

(or, to expand on it... Exactly what part of the task are you having
problems with? Opening files for read/write/update? Designing a command
set for an editor? Designing a GUI for a text editor; what toolkit, does
it have a generic text edit widget already? Do you really need to write
another text editor when there are so many available that come with most
operating systems (Windows: edit, notepad, maybe even wordpad;
UNIX/Linux type systems: vi, vim, gvim, emacs) or can be downloaded
(SciTE) )

--
* * * * Wulfraed * * * *Dennis Lee Bieber * * * * * * * KD6MOG
* * * * wlfr...@ix.netcom.com * * * * * * *wulfr...@bestiaria.com
* * * * * * * * HTTP://wlfraed.home.netcom.com/
* * * * (Bestiaria Support Staff: * * * * * * * web-a...@bestiaria.com)
* * * * * * * * HTTP://www.bestiaria.com/
No, what I mean is for the user to input text directly into the python
program, then the program would save it to a file and display it after
it is created.
May 31 '08 #2
On 31 Mag, 21:28, corvettecra...@gmail.com wrote:
On May 31, 3:25*pm, Dennis Lee Bieber <wlfr...@ix.netcom.comwrote:


On Sat, 31 May 2008 11:44:14 -0700 (PDT), corvettecra...@gmail.com
declaimed the following in comp.lang.python:
I want to create a program where a user can type what ever they want
to, have it saved to a file, and the be able to re-open it and read
it. How would I do this? Thanks!
import os
os.system("edit") * * # may be Windows specific
* * * * Start with:http://www.catb.org/~esr/faqs/smart-questions..html
(or, to expand on it... Exactly what part of the task are you having
problems with? Opening files for read/write/update? Designing a command
set for an editor? Designing a GUI for a text editor; what toolkit, does
it have a generic text edit widget already? Do you really need to write
another text editor when there are so many available that come with most
operating systems (Windows: edit, notepad, maybe even wordpad;
UNIX/Linux type systems: vi, vim, gvim, emacs) or can be downloaded
(SciTE) )
--
* * * * Wulfraed * * * *Dennis Lee Bieber * * * * * * * KD6MOG
* * * * wlfr...@ix.netcom.com * * * * * * *wulfr....@bestiaria.com
* * * * * * * * HTTP://wlfraed.home.netcom.com/
* * * * (Bestiaria Support Staff: * * * * * * * web-a...@bestiaria.com)
* * * * * * * * HTTP://www.bestiaria.com/

No, what I mean is for the user to input text directly into the python
program
You can use raw_input() to ask user to type something, then use open()
to create a file and write in it.
http://docs.python.org/lib/bltin-file-objects.html
then the program would save it to a file and display it after
it is created.
What do you mean by "display"?
Open that file with a text editor? Print the content of the file on
screen?
--- Giampaolo
http://code.google.com/p/pyftpdlib/
May 31 '08 #3
Lie
On Jun 1, 1:44*am, corvettecra...@gmail.com wrote:
I want to create a program where a user can type what ever they want
to, have it saved to a file, and the be able to re-open it and read
it. How would I do this? Thanks!
Use a multi-line text-input widget (available on any widget library)

To open a file in python for reading:
filepointer = file('path/to/file', 'r')

then read it like this:
for line in filepointer:
dosomethingwith(f)

or:
filecontent = filepointer.read()

To open a file for writing:
filepointer = file('path/to/file', 'w')

to write to a file:
filepointer.write(somestring)

Jun 1 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
35
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
2
by: cjl | last post by:
PHPers: I am a total beginner, so please excuse my very simple question. I have been playing with PHP on Windows XP, and mostly using Notepad2 (http://www.flos-freeware.ch/notepad2.html) for...
13
by: Eric_Dexter | last post by:
All I am after realy is to change this reline = re.line.split('instr', '/d$') into something that grabs any line with instr in it take all the numbers and then grab any comment that may or may...
7
by: James | last post by:
Today my friend ask me a question about setting logsecond to -1. The following sentences were copied from DB2 InforCenter: "By setting logsecond to -1, you will have no limit on the size of the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.