473,395 Members | 1,941 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,395 software developers and data experts.

mod_speling for python

PT
Hi,
I'm not looking to get into a debate about case-sensitive vs.
insensitive programming languages,
but I was looking for suggestions about how it might be possible to
add a hook to the python parser similar to the Apache mod_speling
module (links below). So that for example if there is a NameError
exception, python walks the globals() and locals() to see if it might
be just a minor spelling/capitalization error.

I can see how this might be done for ImportErrors, using ihooks or iu,
but I don't see how to do it for NameErrors. The python compiler
module doesn't seem to be the answer.

I know there are drawbacks, disadvantages, this is "evil", etc. I
only wanted to know what ways there are to add such a hook if it is
possible without altering the C source for python itself.

Possible End-User Solution A:
Simply add an "import spelling" to a python file to enable
spell-checking, sort of like how you use the psyco module (speaking of
which, how many times have you misspelled that).

Possible End-User Solution B:
Create an alternative executable that wraps the python interpreter.
This wrapper may or may not have to use its own source code parser,
like the unreleased mobius-python project.

http://httpd.apache.org/docs/mod/mod_speling.html
http://lxr.webperf.org/source.cgi/mo.../mod_speling.c
http://www.mcmillan-inc.com/importhooks.html
http://www.python.org/doc/current/li...-compiler.html
http://sourceforge.net/projects/mobiuspython
Jul 18 '05 #1
4 1348

prtk3> ... if there is a NameError exception, python walks the globals()
prtk3> and locals() to see if it might be just a minor
prtk3> spelling/capitalization error.

prtk3> I can see how this might be done for ImportErrors, using ihooks
prtk3> or iu, but I don't see how to do it for NameErrors. The python
prtk3> compiler module doesn't seem to be the answer.

prtk3> I know there are drawbacks, disadvantages, this is "evil", etc.
prtk3> I only wanted to know what ways there are to add such a hook if
prtk3> it is possible without altering the C source for python itself.

Take a look at sys.excepthook. Actual implementation is left as an exercise
for the reader. <wink>

Skip

Jul 18 '05 #2
> prtk3> I know there are drawbacks, disadvantages, this is "evil",
etc. prtk3> I only wanted to know what ways there are to add such
a hook if prtk3> it is possible without altering the C source for
python itself.

Take a look at sys.excepthook. Actual implementation is left as an
exercise for the reader. <wink>


And be carefull: it breaks the Zen of Python and thereby removes it's mojo.
Jul 18 '05 #3
> I know there are drawbacks, disadvantages, this is "evil", etc. I
only wanted to know what ways there are to add such a hook if it is
possible without altering the C source for python itself.


Ambiguities during execution are bad. I've got two functions Foo and
foO, if I type in foo, what did I mean?

- Josiah
Jul 18 '05 #4
I know there are drawbacks, disadvantages, this is "evil", etc. I
only wanted to know what ways there are to add such a hook if it is
possible without altering the C source for python itself.


Josiah> Ambiguities during execution are bad. I've got two functions
Josiah> Foo and foO, if I type in foo, what did I mean?

I didn't interpret the OP's question as wanting to automatically map Foo to
foO, but to give the user a more helpful error message, suggesting other
candidate names which he might have mistyped.

Skip

Jul 18 '05 #5

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

Similar topics

1
by: Emile van Sebille | last post by:
QOTW: "If we get 2.3.3c1 out in early December, we could release 2.3.3 final before the end of the year, and start 2004 with a 100% bug-free codebase <wink>." -- Tim Peters "cjOr proWe vbCould...
0
by: Emile van Sebille | last post by:
QOTW: "Have you ever used the copy module? I am *not* a beginner, and have used it *once* (and I can't remember what for, either)." -- Michael Hudson "It will likely take a little practice...
0
by: Emile van Sebille | last post by:
QOTW (in the OS agnostic category): "There is a (very popular) Python package out there which exposes the win32 api. I'm not sure what it's called. (win32api? pythonwin? win32all?)" -- Francis...
0
by: Emile van Sebille | last post by:
QOTW (advanced interfaces track): "I'm firmly in favour of any language that can DWIMNWIS." -- Tim Delaney QOTW (MS roadkill track): "Underestimate MS at your own risk. It is one thing to not...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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,...

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.