newbie questions about imports, threads, and optimizations

Bryce Sellers bryce.sellers at trw.com
Wed Jun 28 12:10:04 EDT 2000


I have been using python off and on (unfortunately, mostly off) for about a
year now, and have got a couple of questions for someone who knows more than
I.

First, is there a way to do something like this:

import string, mystring
m = 'string'
`m`.captalize('hello')
m='mystring'
`m`.capitalize('hello')

In other words, use a string as a module or function name and execute that
portion of code.

Second, are there any tutorials or even reference manuals out there on using
Python with threads?  I haven't so much as even seen any sample code,
although I admit I haven't looked very hard.

Finally, I've noticed that a lot of the discussions surrounding
optimizations center on the fact that even the standard library function
names can be overwritten.  Why can't we just have a command-line argument
(or something along those lines) that tells python that all variables
defined in modules are read-only?  Now the interpreter can optimize the heck
out of it, and throw an exception if anything tries to modify something.  Of
course, this idea is so simple that I'm sure the only reason it hasn't been
done is because its a bad idea.  My question is, why is it a bad idea?

Thanks for the help,
Bryce





More information about the Python-list mailing list