473,386 Members | 1,720 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,386 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 1130
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.