Try Python update

57 views
Skip to first unread message

Mike Meyer

unread,
Jan 1, 2006, 11:11:41 AM1/1/06
to
After spending time I should have been sleeping working on it, the try
python site is much more functional. It now allows statements,
including multi-line statements and expressions. You can't create code
objects yet, so it's still more a programmable calculator than
anything real.

I've got some of the tutorial text (literally) up as well. I hope to
make it easier to read the tutorial and interact with python at the
same time in the near future.

The url is http://www.mired.org/home/mwm/try_python/. Reports of
problems would appreciated.

If you want to try an online P{ython tool that lets you save code, try
Devan L's at http://www.datamech.com/devan/trypython/trypython.py.

<mike
--
Mike Meyer <m...@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

UrsusM...@gmail.com

unread,
Jan 1, 2006, 2:10:05 PM1/1/06
to
Cool. I think its really a good thing. Could come in handy when one is
on a strange Windows machine with no Python installed, or when using a
PDA that doesn't have Python etc.

And its just a neat feat. ;-)))

Ron

Devan L

unread,
Jan 1, 2006, 5:46:04 PM1/1/06
to

Mike Meyer wrote:
> After spending time I should have been sleeping working on it, the try
> python site is much more functional. It now allows statements,
> including multi-line statements and expressions. You can't create code
> objects yet, so it's still more a programmable calculator than
> anything real.
>
> I've got some of the tutorial text (literally) up as well. I hope to
> make it easier to read the tutorial and interact with python at the
> same time in the near future.
>
> The url is http://www.mired.org/home/mwm/try_python/. Reports of
> problems would appreciated.
>
> If you want to try an online P{ython tool that lets you save code, try
> Devan L's at http://www.datamech.com/devan/trypython/trypython.py.

My code uses one of the recipes from the Python Cookbook, 7.6 Pickling
Code Objects. It's limited to closures though, just like in the recipe.
So uh, you can't write closures in mine.

On a side note, my brother has tinkered with the C internals and now
__subclasses__ is restricted and many, many os and posix commands are
restricted (not that you can get them anyways, since importing is
broken!)

Mike Meyer

unread,
Jan 1, 2006, 7:32:07 PM1/1/06
to
"Devan L" <dev...@gmail.com> writes:
>> If you want to try an online P{ython tool that lets you save code, try
>> Devan L's at http://www.datamech.com/devan/trypython/trypython.py.
> My code uses one of the recipes from the Python Cookbook, 7.6 Pickling
> Code Objects. It's limited to closures though, just like in the recipe.
> So uh, you can't write closures in mine.

I don't have the dead trees version, and the online version doesn't
have chapter numbers. Is that <URL:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/212565>?

> On a side note, my brother has tinkered with the C internals and now
> __subclasses__ is restricted and many, many os and posix commands are
> restricted (not that you can get them anyways, since importing is
> broken!)

I got import to work by pickling pairs of names - the variable name
that references the module, and the name of the module. When it
unpickles the list, it reimports them and points the appropriate
variable at them. This had unwanted effects if you did an "import
this". It also doesn't work for objects that contain references to
modules.

I tried for a bit to restrict things, then gave up and did it
externally. There's no access to any files but those required to run
the script that deals with thing, and some other python modules that I
decided would be nice to have. Normally, nothing in the tree is
writable, either. Once I'm happy with it, I'll save a copy of the tree
somewhere and set up a cron job to "refresh" it at regular intervals.

Devan L

unread,
Jan 1, 2006, 8:25:10 PM1/1/06
to
Mike Meyer wrote:
> "Devan L" <dev...@gmail.com> writes:
> >> If you want to try an online P{ython tool that lets you save code, try
> >> Devan L's at http://www.datamech.com/devan/trypython/trypython.py.
> > My code uses one of the recipes from the Python Cookbook, 7.6 Pickling
> > Code Objects. It's limited to closures though, just like in the recipe.
> > So uh, you can't write closures in mine.
>
> I don't have the dead trees version, and the online version doesn't
> have chapter numbers. Is that <URL:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/212565>?

It was one of the recipes of the day, actually. They don't keep them up
for more than a week, though, I think. But more or less it has all of
the attributes used for creating an object from types.CodeType in
correct order.

> > On a side note, my brother has tinkered with the C internals and now
> > __subclasses__ is restricted and many, many os and posix commands are
> > restricted (not that you can get them anyways, since importing is
> > broken!)
>
> I got import to work by pickling pairs of names - the variable name
> that references the module, and the name of the module. When it
> unpickles the list, it reimports them and points the appropriate
> variable at them. This had unwanted effects if you did an "import
> this". It also doesn't work for objects that contain references to
> modules.

My general method of storing is to store everything possible. See a
function? Store the function object itself. See a class? Store the
class object. Unfortunately, I can't store builtin methods or
functions, so this breaks on most modules. Don't try to reference the
__builtins__, by the way, otherwise it won't be removed and modjelly
will break.


> I tried for a bit to restrict things, then gave up and did it
> externally. There's no access to any files but those required to run
> the script that deals with thing, and some other python modules that I
> decided would be nice to have. Normally, nothing in the tree is
> writable, either. Once I'm happy with it, I'll save a copy of the tree
> somewhere and set up a cron job to "refresh" it at regular intervals.

I don't have enough control on the server to effectively restrict it
externally (no running as an unprivelleged user!), so I have to lock it
down as tightly as possible internally.

Mike Meyer

unread,
Jan 1, 2006, 9:30:38 PM1/1/06
to
"Devan L" <dev...@gmail.com> writes:
>> > On a side note, my brother has tinkered with the C internals and now
>> > __subclasses__ is restricted and many, many os and posix commands are
>> > restricted (not that you can get them anyways, since importing is
>> > broken!)
>> I got import to work by pickling pairs of names - the variable name
>> that references the module, and the name of the module. When it
>> unpickles the list, it reimports them and points the appropriate
>> variable at them. This had unwanted effects if you did an "import
>> this". It also doesn't work for objects that contain references to
>> modules.
> My general method of storing is to store everything possible. See a
> function? Store the function object itself. See a class? Store the
> class object. Unfortunately, I can't store builtin methods or
> functions, so this breaks on most modules. Don't try to reference the
> __builtins__, by the way, otherwise it won't be removed and modjelly
> will break.

I think the idea I used for modules would generalize: If you can't
store it, store the information you need to relocate it, and recreate
the binding.

>> I tried for a bit to restrict things, then gave up and did it
>> externally. There's no access to any files but those required to run
>> the script that deals with thing, and some other python modules that I
>> decided would be nice to have. Normally, nothing in the tree is
>> writable, either. Once I'm happy with it, I'll save a copy of the tree
>> somewhere and set up a cron job to "refresh" it at regular intervals.
> I don't have enough control on the server to effectively restrict it
> externally (no running as an unprivelleged user!), so I have to lock it
> down as tightly as possible internally.

My ISP provides this facility. They provided a less strict version,
and worked with me to create this facility. While they aren't perfect,
I can't say enough good things about them. If you need internet
connectivity, web hosting, whatever - idiom.com is good people to work
with.

auro...@gmail.com

unread,
Jan 3, 2006, 2:53:14 PM1/3/06
to
Very nice :)

I found this online Ruby tutorial:
http://tryruby.hobix.com/

I think it would be cool to have something similar for Python. Want to
go further and make a nice tutorial to accompany this :)

wy

Mike Meyer

unread,
Jan 3, 2006, 4:39:53 PM1/3/06
to
"auro...@gmail.com" <auro...@gmail.com> writes:
> Very nice :)
>
> I found this online Ruby tutorial:
> http://tryruby.hobix.com/

That's what inspired me to create my version.

> I think it would be cool to have something similar for Python. Want to
> go further and make a nice tutorial to accompany this :)

Well, *I* like the python.org tutorial. I've already started steal,
uh, using, material from it. I intend to include more as time goes
by.

One thing that annoyed me about the tryruby version is that it changed
the text - apparently arbitrarily - with each expression. I *detest*
UI's that change things when they want to (I regularly close dialogs
accidently on OSX because they come up while I'm working in *some
other application* and steal the focus from me). I'm not going to do
that; that's why I list all the sections, and you can display (or not)
by clicking on them. I'm planning on adding a "suggested reading" link
(it's already there if you know where to look, but always does the
same thing :-) under the console that will do what the ruby thing
does, except when the user asks for it, not when I think it should
happen.

bro...@verizon.net

unread,
Jan 3, 2006, 10:00:15 PM1/3/06
to
I like the form, no matter what its limitations may be. Three notes:

It might be a good way to catch newbi mistakes (those are the kind I
make :P, thereby providing a feedback loop to improved error messages.

I had no trouble with from math import * followed by print pi, but
there was no >>> prompt after the result appeared .. is that part of
the 'closures' thing mentioned earlier?

Then I followed you "type 'help'" suggestion, which had me in stitches
(sorry, it's been a long day and the Knob Creek was kicking in) -- I
got exactly the message you'd expect, about help not being recognized
and maybe help() would work. That's what triggered the idea for
trapping errors.

Nice work!

George

Mike Meyer

unread,
Jan 3, 2006, 11:03:51 PM1/3/06
to
bro...@verizon.net writes:
> I like the form, no matter what its limitations may be. Three notes:
>
> It might be a good way to catch newbi mistakes (those are the kind I
> make :P, thereby providing a feedback loop to improved error messages.

I'm doing almost no error catching. I think I catch two:

If you muck with the prompt, it throws away what you sent it, because
I'd have to guess at the expression.

There were (I think I worked around them) browser bugs that caused
the result of an expression to get lost - it notices that, and tells
you about it.

Well, I do catch exceptions in general, to tailor the traceback for
the environment. But that's all I do.

> I had no trouble with from math import * followed by print pi, but
> there was no >>> prompt after the result appeared .. is that part of
> the 'closures' thing mentioned earlier?

Hmm. Are you looking at mine <URL:
http://www.mired.org/home/mwm/try_python/ >, or Devans <URL:
http://www.datamech.com/devan/trypython/trypython.py >? Mine doesn't
handle code (though he's provide pointers I plan on using to make it
do so). I think he said his has problems with closures.

> Then I followed you "type 'help'" suggestion, which had me in stitches
> (sorry, it's been a long day and the Knob Creek was kicking in) -- I
> got exactly the message you'd expect, about help not being recognized
> and maybe help() would work. That's what triggered the idea for
> trapping errors.

Hmm. help seems to work fine in both of them. license() fails the same
way in both of them (it tries to read from stdin, so....), which means
that you can probalby make help fail on them both if you work at it.

thanks,

Devan L

unread,
Jan 4, 2006, 12:21:30 AM1/4/06
to

Uh, I'm messing with import right now, but essentially, I wouldn't
recommend importing (one line __import__ hacks only!) or printing.

Devan L

unread,
Jan 4, 2006, 12:36:44 AM1/4/06
to
Mike Meyer wrote:
> bro...@verizon.net writes:
[comments about Mike Meyer's try python, I think]

> > I had no trouble with from math import * followed by print pi, but
> > there was no >>> prompt after the result appeared .. is that part of
> > the 'closures' thing mentioned earlier?
>
> Hmm. Are you looking at mine <URL:
> http://www.mired.org/home/mwm/try_python/ >, or Devans <URL:
> http://www.datamech.com/devan/trypython/trypython.py >? Mine doesn't
> handle code (though he's provide pointers I plan on using to make it
> do so). I think he said his has problems with closures.

I'm renaming mine to the Python Online REPL or Online Python REPL,
whichever you prefer, to help differentiate from Mike's.

>From the actual recipe:
<http://www.onlamp.com/python/pythoncook2/solution.csp?day=2>
(The url changes every day as they move it one day back)
if co.co_freevars or co.co_cellvars:
raise ValueError, "Sorry, cannot pickle code objects from
closures"

I think that the code constructor (types.CodeType) doesn't take
co_freevars or co_cellvars as an arg, so I can't directly create a new
code object from the attribute of the old one with co_freevars and
co_cellvars. I might be able to set the attributes after,but I'll have
to test it out to see.

> > Then I followed you "type 'help'" suggestion, which had me in stitches
> > (sorry, it's been a long day and the Knob Creek was kicking in) -- I
> > got exactly the message you'd expect, about help not being recognized
> > and maybe help() would work. That's what triggered the idea for
> > trapping errors.
>
> Hmm. help seems to work fine in both of them. license() fails the same
> way in both of them (it tries to read from stdin, so....), which means
> that you can probalby make help fail on them both if you work at it.
>

Printing and most things not explicitly called by my code isn't done
correctly (strings to lines to strings again!), so most any printing
non-single statements or input will probably break it.

jaso...@gmail.com

unread,
Jan 4, 2006, 6:17:36 AM1/4/06
to
> I think that the code constructor (types.CodeType) doesn't take
> co_freevars or co_cellvars as an arg, so I can't directly create a new
> code object from the attribute of the old one with co_freevars and
> co_cellvars.

Yay for hidden documentation:

"code(argcount, nlocals, stacksize, flags, codestring, constants,
names, varnames, filename, name, firstlineno, lnotab[, freevars[,
cellvars]])

Create a code object. Not for the faint of heart."

Bas

unread,
Jan 4, 2006, 7:27:53 AM1/4/06
to
To expand on this idea:

You could somehow combine the official tuturial (or any other good
introductory text) and make all the examples in the text 'live'. Maybe
use a split screen with the tutorial text on one side and the trypython
console on the other. The newbie could then immediately try the example
by typing it over himself or by clicking a button 'run in console' next
to the example. Target audience should be only the real beginners who
are afraid/too lazy to install the complete Python enviroment. Advanced
users should be able to do a full install themselves.

Cheers,
Bas

Mike Meyer

unread,
Jan 4, 2006, 2:17:59 PM1/4/06
to

This is pretty much what I had in mind. I'm moving the tutorial into
the thing (slowly). I've set it up as two regions one above the
other. The text of the tutorial will scroll in that region if it needs
to. The console region may be scrollable as well, depending on the
fonts and sizes that get used for the console window. I go through the
text of the tutorial typing in the expressions and verifying that I
get the correct results back.

Making the examples links that insesrt the text of the example?
Certainly possible. I'm not sure I want to do that, though. I think
people learn better if they actually do things themselves, and I'm not
sure that clicking a link qualifieas as "doing it themselves."

Thanks,

Szabolcs Nagy

unread,
Jan 4, 2006, 2:41:17 PM1/4/06
to
Hello
Thanks for trypython, it's a cool idea

I got TryPythonError after an IdentationError and i could not get rid
of it (other than refreshing the page):

Python 2.4.2 (#3, Dec 16 2005, 23:54:20)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits", or "license" for more information.
>>> if 1:
... qwerty
IndentationError: expected an indented block (<stdin>, line 2)
>>> a=2
TryPythonError: I couldn't find the prompt, so did nothing
>>> 1
TryPythonError: I couldn't find the prompt, so did nothing
>>>
TryPythonError: I couldn't find the prompt, so did nothing
>>>

Mike Meyer

unread,
Jan 5, 2006, 1:23:05 AM1/5/06
to
"Szabolcs Nagy" <nsza...@gmail.com> writes:
> Hello
> Thanks for trypython, it's a cool idea

Thank you.

Thanks for the report. It's fixed, and all I had to do was totally
restructure the routine that did all the work. But I like the new
structure better.

Steven Bethard

unread,
Jan 5, 2006, 10:40:09 AM1/5/06
to
Mike Meyer wrote:
> The url is http://www.mired.org/home/mwm/try_python/. Reports of
> problems would appreciated.

You're probably already aware of this, but the online help utility
doesn't work. It exits before you can type anything into it:

----------------------------------------------------------------------
>>> help()

Welcome to Python 2.4! This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://www.python.org/doc/tut/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics". Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help>
You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)". Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.
>>>
----------------------------------------------------------------------

STeVe

Mike Meyer

unread,
Jan 5, 2006, 2:12:15 PM1/5/06
to
Steven Bethard <steven....@gmail.com> writes:
> Mike Meyer wrote:
>> The url is http://www.mired.org/home/mwm/try_python/. Reports of
>> problems would appreciated.
> You're probably already aware of this, but the online help utility
> doesn't work. It exits before you can type anything into it:

Actually, I'd say the interactive help utility doesn't work. As long
as you don't use it interactively, it works fine. You can do
help(int) (for instance) and so on.

And yes, I know about this. It's listed in "Known Problems". Anything
that tries to read from standard input will fail. I'm thinking about
fixes, but it's not a high-priority item at the moment.

Thanks for the report.

Xavier Morel

unread,
Jan 3, 2006, 3:09:49 PM1/3/06
to
Mike Meyer wrote:
> After spending time I should have been sleeping working on it, the try
> python site is much more functional. It now allows statements,
> including multi-line statements and expressions. You can't create code
> objects yet, so it's still more a programmable calculator than
> anything real.
>
> I've got some of the tutorial text (literally) up as well. I hope to
> make it easier to read the tutorial and interact with python at the
> same time in the near future.
>
> The url is http://www.mired.org/home/mwm/try_python/. Reports of
> problems would appreciated.
>
> If you want to try an online P{ython tool that lets you save code, try
> Devan L's at http://www.datamech.com/devan/trypython/trypython.py.
>
> <mike

Mike, may I ask whether that box has been secured? And if yes how?

Since Python doesn't have any way to secure the interface built-in, i'd
be interrested in that.

Mike Meyer

unread,
Jan 6, 2006, 2:20:57 PM1/6/06
to
Xavier Morel <xavier...@masklinn.net> writes:

> Mike Meyer wrote:
>> The url is http://www.mired.org/home/mwm/try_python/. Reports of
>> problems would appreciated.
>> If you want to try an online P{ython tool that lets you save code,
>> try
>> Devan L's at http://www.datamech.com/devan/trypython/trypython.py.
> Mike, may I ask whether that box has been secured? And if yes how?

If you go to my try_python page and click the "Security" heading,
it'll tell you that the interpreter is run in a chrooted sandbox
inside a FreeBSD jail. You don't have access to anything in the file
system but the code needed to run the interpreter. That's all
write-protected, though I do sometimes forget to write-protect an
upgraded file. I've also removed things from the library that weren't
essential to the application.

> Since Python doesn't have any way to secure the interface built-in,
> i'd be interrested in that.

Devan apparently doesn't have as cooperative an ISP, and is working on
securing the interpreter. What he's done may be more interesting.

Devan L

unread,
Jan 6, 2006, 7:40:09 PM1/6/06
to
Mike Meyer wrote:
> Xavier Morel <xavier...@masklinn.net> writes:
[Old message and Xavier's question]
[Mike's reply to Xavier]

>
> > Since Python doesn't have any way to secure the interface built-in,
> > i'd be interrested in that.
>
> Devan apparently doesn't have as cooperative an ISP, and is working on
> securing the interpreter. What he's done may be more interesting.

It's not particularily interesting. The C code simply has more
attributes restricted in restricted mode, disabling in particular
__subclasses__. The rest is creating safe __builtins__ and only giving
them some modules (but again, importing is still largely broken,
although one liners are still possible).

In any case, I don't know how secure it actually is, since nobody seems
to go further than import os or import sys. So if you're bored, you can
try to break into it. I haven't secured modjelly entirely, and it might
be possible to trick modjelly into executing code by using descriptors
when it tries to pull out all of the information. Then again, I haven't
even added support for properties in it yet. Plus it has no support for
if you delete critical attributes which are needed to recreate the
object. Still, I think it's good enough to deter any random person from
trying to wipe the server for now.

Alex Martelli

unread,
Jan 7, 2006, 1:41:51 PM1/7/06
to
Mike Meyer <m...@mired.org> wrote:

> And yes, I know about this. It's listed in "Known Problems". Anything

What's the URL to "Known Problems"? There's a strange cursor-placement
bug on Apple's Safari browser (not in Firefox), but I don't want to add
a bug report if you already know about it -- 'Try Python' is a neat
hack, and useful, it well deserves some care from would-be bug
reporters... but I can't see any links to "known problems" (or other
bug-reporting facilities) from the base page.


Alex

Mike Meyer

unread,
Jan 7, 2006, 3:06:26 PM1/7/06
to

"Known problems" doesn't have URL (isn't "urlable"?) other than
http://www.mird.org/home/mwm/try_python/. It's on that page - click on
"Known Problems" to open up the section. That particular problem is
listed under "Tested Browsers" (which heading I'm going to change), as
I believe it's a place where the browser fails to follow the standards
- or maybe the standards fail to specify the expected behavior with
sufficient explicitness, as Safari shares this problem with OmmiWeb
and Shiira.

If you can provide the JavaScript fragment to reliably get Safari to
put the cursor after all the text in a textarea, I'll fix this
now.

Thanx,

Alex Martelli

unread,
Jan 8, 2006, 1:14:06 AM1/8/06
to
Mike Meyer <m...@mired.org> wrote:
...

> "Known problems" doesn't have URL (isn't "urlable"?) other than
> http://www.mird.org/home/mwm/try_python/. It's on that page - click on

s/mird/mired/ -- the URL as given goes to some 'oxide' thing.

> "Known Problems" to open up the section. That particular problem is

For some reason, I couldn't see the links at the end of the page; now I
can, though they look sort of "ragged", but, OK.

> If you can provide the JavaScript fragment to reliably get Safari to
> put the cursor after all the text in a textarea, I'll fix this
> now.

I'm no Safari expert (and no great shakes at Javascript!), but, I'll ask
around and report back here, thanks.


Alex

Mike Meyer

unread,
Jan 8, 2006, 3:03:02 AM1/8/06
to
al...@mail.comcast.net (Alex Martelli) writes:
> Mike Meyer <m...@mired.org> wrote:
> For some reason, I couldn't see the links at the end of the page; now I
> can, though they look sort of "ragged", but, OK.

Probably the fonts I chose. I'm in no way a good visual designer. I'm
hoping someone who is will step up to help with this.

Alex Martelli

unread,
Jan 8, 2006, 12:37:28 PM1/8/06
to
Mike Meyer <m...@mired.org> wrote:

> al...@mail.comcast.net (Alex Martelli) writes:
> > Mike Meyer <m...@mired.org> wrote:
> > For some reason, I couldn't see the links at the end of the page; now I
> > can, though they look sort of "ragged", but, OK.
>
> Probably the fonts I chose. I'm in no way a good visual designer. I'm
> hoping someone who is will step up to help with this.

I'm finding it hard to arrange my own experiments with Safari (I'm using
a loaner machine since my normal one[s] are all having problems and
under repair) but I'm told the solution for cursor positioning is to set
the caretPos attribute of the textarea, like for example at
<http://www.codingforums.com/showthread.php?t=43245> ...


Alex

Mike Meyer

unread,
Jan 8, 2006, 10:12:45 PM1/8/06
to
al...@mail.comcast.net (Alex Martelli) writes:
> I'm finding it hard to arrange my own experiments with Safari (I'm using
> a loaner machine since my normal one[s] are all having problems and
> under repair) but I'm told the solution for cursor positioning is to set
> the caretPos attribute of the textarea, like for example at
> <http://www.codingforums.com/showthread.php?t=43245> ...

caretPos is apparently an MS extension; it's not supported by Safari
or the Gecko browsers.

setSelectionRange is the standards-compliant version. It's not
supported by Safari either :-(.

Thanks,

Alex Martelli

unread,
Jan 8, 2006, 10:35:48 PM1/8/06
to
Mike Meyer <m...@mired.org> wrote:

> al...@mail.comcast.net (Alex Martelli) writes:
> > I'm finding it hard to arrange my own experiments with Safari (I'm using
> > a loaner machine since my normal one[s] are all having problems and
> > under repair) but I'm told the solution for cursor positioning is to set
> > the caretPos attribute of the textarea, like for example at
> > <http://www.codingforums.com/showthread.php?t=43245> ...
>
> caretPos is apparently an MS extension; it's not supported by Safari
> or the Gecko browsers.
>
> setSelectionRange is the standards-compliant version. It's not
> supported by Safari either :-(.

Meanwhile, other JS/DOM experts have told me that there's NO way to set
cursor position within a textarea according to w3c standards. In this
case, what your site does now may be the "least bad" approach, and that
fact might be noted in the "browsers" subpage, together with a request
for anybody who has other ideas to submit them, I guess.

Sorry for wasting your time, I'm still having trouble believing that the
standards didn't bother to specify SOME way to perform such an
elementary functionality.


Alex

Mike Meyer

unread,
Jan 9, 2006, 12:59:15 AM1/9/06
to
al...@mail.comcast.net (Alex Martelli) writes:
> Meanwhile, other JS/DOM experts have told me that there's NO way to set
> cursor position within a textarea according to w3c standards. In this
> case, what your site does now may be the "least bad" approach, and that
> fact might be noted in the "browsers" subpage, together with a request
> for anybody who has other ideas to submit them, I guess.

I've done that, and it should show up next time I push the code to the
production server.

> Sorry for wasting your time, I'm still having trouble believing that the
> standards didn't bother to specify SOME way to perform such an
> elementary functionality.

How many pages do you know of that actually want to do this? It may be
fundamental, but it's atypical. I found three different ways to do it
- none of them supported by Safari. Ironically, the browsers that do
support any of those methods all keep the cursor at the end of the
textarea when I add the new text, and so don't need them.

Reply all
Reply to author
Forward
0 new messages