473,473 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Try Python update

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 <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 1 '06 #1
29 2186
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

Jan 1 '06 #2

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!)

Jan 1 '06 #3
"Devan L" <de****@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.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 2 '06 #4
Mike Meyer wrote:
"Devan L" <de****@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.

Jan 2 '06 #5
"Devan L" <de****@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.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 2 '06 #6
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

Jan 3 '06 #7
"au******@gmail.com" <au******@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.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 3 '06 #8
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

Jan 4 '06 #9
br*****@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,
<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 4 '06 #10

br*****@verizon.net wrote:
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


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

Jan 4 '06 #11
Mike Meyer wrote:
br*****@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.

Jan 4 '06 #12
> 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."

Jan 4 '06 #13
Bas
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

Jan 4 '06 #14
"Bas" <we*****@gmail.com> writes:
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.


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,
<mike

--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 4 '06 #15
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


Jan 4 '06 #16
"Szabolcs Nagy" <ns*******@gmail.com> writes:
Hello
Thanks for trypython, it's a cool idea
Thank you.
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


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.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 5 '06 #17
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
Jan 5 '06 #18
Steven Bethard <st************@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.
<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 5 '06 #19
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.
Jan 6 '06 #20
Xavier Morel <xa**********@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.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 6 '06 #21
Mike Meyer wrote:
Xavier Morel <xa**********@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.

Jan 7 '06 #22
Mike Meyer <mw*@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
Jan 7 '06 #23
al***@mail.comcast.net (Alex Martelli) writes:
Mike Meyer <mw*@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.


"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,
<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 7 '06 #24
Mike Meyer <mw*@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
Jan 8 '06 #25
al***@mail.comcast.net (Alex Martelli) writes:
Mike Meyer <mw*@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.

<mike

--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 8 '06 #26
Mike Meyer <mw*@mired.org> wrote:
al***@mail.comcast.net (Alex Martelli) writes:
Mike Meyer <mw*@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
Jan 8 '06 #27
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,
<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 9 '06 #28
Mike Meyer <mw*@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
Jan 9 '06 #29
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.

Thanks,
<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jan 9 '06 #30

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

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
18
by: David Rysdam | last post by:
What module is most recommended for accessing Sybase from Python? This one: http://www.object-craft.com.au/projects/sybase/sybase/ ? Also, is there any module that provides a generic DB API and...
22
by: lechequier | last post by:
Let's say I define a list of pairs as follows: >>l = Can anyone explain why this does not work? >>h = {}.update(l) and instead I have to go: >>h = {} >>h.update(l) to initialize a...
4
by: vagrantbrad | last post by:
I'm using python 2.4 running on Fedora Core 4. I have written a python program called ipscan.py that checks the external ip address of my cable internet connection, and on change, will update the...
0
by: | last post by:
Greetings. In an effort to get python2.4 on my Centos 3.7, I installed the python bootstrap rpm. This installed 2.4 alongside 2.2 and updated yum to 2.4.0. Oddly, it didn't create a symlink...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 385 open (+21) / 3790 closed (+21) / 4175 total (+42) Bugs : 1029 open (+43) / 6744 closed (+43) / 7773 total (+86) RFE : 262 open...
1
by: Steve Mavronis | last post by:
I tried to install Python 2.51 on Microsoft Vista Ultimate 32-bit because I use the 3D modeler software Blender 2.44, in case I needed additional Python support in the future for add-on scripts. ...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.