PROPOSAL: Packages in Python lib
Christopher Petrilli
petrilli at trump.amber.org
Sun May 2 11:45:52 EDT 1999
Peter A. Koren <pkoren at hex.net> wrote:
> Hans Nowak wrote:
>>
> I have been trying
>> myself to organize all kinds of modules in a package collection, and a
>> problem that occurs quite often is, that a module can logically belong in
>> more than one package. For instance, modules dealing with HTML parsing, do
>> they belong in the Internet package, or in the Text package? (Yes, you don't
>> have those packages here... but I do. :^)
> Hmmmmm, it sounds like we need some conditional import mechanism. C uses
> the preprocessor:
> #ifndef themodule
> #define themodule
> ...
> #endif
> I am too new to Python to hack the solution, but a conditional import
> approach might work.
>From billions of modules I've written:
try:
import cPickle
pickle=cPickle
except ImportError:
import pickle
Is this what you meant? :-)
This gives me a 'pickle' object which refers to the C implementation if
available, and the regular python one if not.
Chris
--
| Christopher Petrilli ``Television is bubble-gum for
| petrilli at amber.org the mind.''-Frank Lloyd Wright
More information about the Python-list
mailing list