473,805 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1366

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
2400
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 vbSettle prpFor noEnglish prpIn adjHungarian noNotation :-)" -- noPeter Jack Jensen reveals that python on mac continues as an osx option only starting with python2.4.
0
1899
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 before this stuff rattles off your fingertips easily." -- Paul Rubin BJ MacNevin wants to run python from a CD. http://groups.google.com/groups?threadm=BhVyb.389117$Tr4.1144562@attbi_s03
0
2244
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 Avila QOTW (in the popular vote category): "So far, python has been the easiest language to learn I've ever come across. I tried learning perl, and it was a disaster.... Too convoluted. Python is a breath of fresh air. Also, the docs and...
0
1571
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 like MS, and possibly a reasonable position to take. However, underestimating them is for fools." -- Mark Hammond, on Microsoft's commitment to .net. Anthony Baxter releases Python 2.3.3 final.
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10361
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10103
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9179
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7644
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6874
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.