Python pattern repository

Bengt Richter bokr at oz.net
Thu Oct 17 23:57:07 EDT 2002


On Tue, 15 Oct 2002 18:38:00 -0600, Fernando =?ISO-8859-1?Q?P=E9rez?= <fperez528 at yahoo.com> wrote:

>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.
>
Thanks for your reply. I am having too many thoughts to get all the revisions
consolidated. I think I will try to concentrate an summarize in a new post.
Anyway, Chris's objections to using + and - as a google search target are valid,
even quoted, so I am going to something with underscores. I want something that
is obvious visually, and google seems to treat underscores as letters.

>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.
>
I see the motivation, but I think using python is too restrictive, since I
believe this will be a good vehicle for non-code stuff as well. Think of
it as an embedded MIME kind of thing, but made very simple to use in
whatever text. I am thinking of rfc822 as an optional format for including
extended information like the PyPan_info you show.

>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.
>
Yes, but the trick is to do something easy and useful without creating a
slashdot slurry with only occasional gems (which they do have).

Regards,
Bengt Richter



More information about the Python-list mailing list