If you intend to make a text editor (something which allows the user to browse
through the text and manipulate it at will) using just raw_input and print, I
think you've set yourself an impossible task. For a console editor you should
probably look at curses (http://www.amk.ca/python/howto/curses/) - which don't
work on Windows, so you'll probably need this:
http://adamv.com/dev/python/curses/ (but according to the site it's incomplete).

Ok.

lines = []
while True:
    lines.append(raw_input(''))

(But that offers no way to e.g. save and continue.)

Ok again.

Text editors are IMO not applications suitable for learning vanilla Python, or
OOP for that matter. Text editors are used as example applications in the RAD
IDE world (VB, Delphi and such) because in those environments a text editor is
literally three clicks away (click on memo component, click on form, click on
run). Vanilla Python has no GUI, so no memo component - hence my recommendation
for Tkinter or wxPython. PythonCard and Boa provide an experience somewhat
similar to commercial RAD IDE's if that's what you're looking for.

I got my idea from looking at Nano, Vi, Joe and a few other UNIX text editors. Nano and Joe are console programs. That's why I thought I would try a console ed. in Python.


Having one function for each line is a bad idea whether you code it by hand or
automatically

Ah.

A function implements certain behavior. Having the same behavior (raw_input)
implemented separately for each line is an extremely wasteful way of
programming.

Is there a way of telling Python to make a new line after you press Enter (return)?

I would suggest that you learn a bit more about Python's facilities before
embarking on an ambitious project :) - you won't get very far without knowing
how to use lists and dictionaries.

So that's one of the ways Dicts, and lists are used for? I never could fully grasp their use.

Thanks,
        JQ

-----------------------------------
Proud to be a true hacker
(You may have a bad impression of the word "hacker". Do some homework,
go to: http://catb.org/~esr/faqs/hacker-howto.html and become enlightened)

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to