Python pattern repository

Fernando Pérez fperez528 at yahoo.com
Tue Oct 15 20:38:00 EDT 2002


Bengt Richter wrote:

> Introducing PyPAN: Python Pervasive Archive Network ;-)
> 
> Here's the concept: If you want to include your code snippet
> in the PyPAN, post it embedded in a document that Google will see.
> 
> You embed it for easy extraction by putting a PyPAN expression
> in the first and last (+/- 1, discussed later[1]) lines of your snippet,
> e.g.,
> 
> # ++PyPAN++ mySnippet.py /clp/forcomment/ -- minimal PyPan snippet
> def mySnippet():
>     print 'Hello PyPAN!'
> # --PyPAN--

I think this is a _great_ idea. I still believe that we _do_ need a CPAN-like 
system for larger things (full packages), but this is a great complement and 
would make it much easier to retrieve small stuff by leveraging google.

But I'd like to suggest that we use the Python language itself as much as 
possible for tagging the code. I hate having to do parsing of special formats 
when a perfectly good language is there to begin with. So I would instead 
suggest that each PyPAN snippet has a PyPAN_info dictionary with all 
necessary information defined in it. Something like:

#++PyPAN++

PyPAN_info = {'filename':'mySnippet.py',
                'hierarchy':'text/xml',
                'homepage':'myhomepage.com',
                'keywords':['xml','data extraction'],
                }
# code follows...

#--PyPAN--

Something like the above would make it much easier to write the extraction 
tools, and it would be therefore easy to keep an automatically updated 
database of existing PyPAN snippets. The fields in the _info dictionary 
should be commonly agreed on, the above is just a basic example.

With the existing google api it would be trivial to write a little tool to 
search the web for these guys and extract them. With google's permission it 
would be possible to keep a 'snippet searcher' on the python.org site which 
returns this nicely organized and formatted for download.

Thoughts?

f.



More information about the Python-list mailing list