Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Python pattern repository

3 views
Skip to first unread message

Robin Munn

unread,
Oct 15, 2002, 2:33:13 PM10/15/02
to
It's been a couple of days since Holger Krekel's post to the "Buffering
control in python?" thread and I haven't seen anyone start up a thread
on this subject, so I'm starting one. I'd also like to see this happen.
I don't have server space to contribute, but I could help with coding,
administration, etc.

Holger's original post is duplicated below.

>From: holger krekel <py...@devel.trillke.net>
>Newsgroups: comp.lang.python
>Subject: Re: Buffering control in python?
>Date: Sun, 13 Oct 2002 10:31:08 +0200
>
>Hi Bengt,
>
>Bengt Richter wrote:
>> ...
>>
>> >Yip, proxying is a nice pattern especially with python.
>> >
>> Is there a Python pattern repository somewhere?
>
>No that i know off. The closest is the aspn-cookbook.
>
>Heck, I can't believe it.
>
>We still don't have a useful repository for all
>the nice snippets, recipes and patterns posted and
>discussed everywhere. Although there is plenty of nice
>web-software, mailing lists and whatnot written in python.
>Sometimes people say that we have a great standard lib
>aka "batteries included". True, but i don't think that's
>enough. E.g.
>
>1) i have figured out two screens of code
> to use the Spread-module for basic things.
> Is there a generic place to publish this example
> so that others can find it, use it, discuss it,
> enhance it?
>
>2) i have a nice filename class which has all the os.path
> methods and filtering walks and and and. It needs some
> work but if people use it i would definitely enhance it.
> Now am i supposed to setup a sourceforge project for it?
> No, thanks.
>
>3) i have done a new introspecting rlcompleter ...
>
>4) i need a small class that ...
>
>hopefully, we as a community will finally come up with a
>hybrid web/mail approach (aka roundup) to serve these needs.
>I am definitely interested to code, implement/design concepts
>and offer server-space/cvs for it.
>
>sorry, but i couldn't help it :-)
>
>regards,
>
> holger


--
Robin Munn
rm...@pobox.com

Erik Max Francis

unread,
Oct 15, 2002, 4:07:55 PM10/15/02
to
Robin Munn wrote:

> It's been a couple of days since Holger Krekel's post to the
> "Buffering
> control in python?" thread and I haven't seen anyone start up a thread
> on this subject, so I'm starting one. I'd also like to see this
> happen.
> I don't have server space to contribute, but I could help with coding,
> administration, etc.
>
> Holger's original post is duplicated below.

Well, here's a start:

http://www.python.org/workshops/1997-10/proceedings/savikko.html

The Cookbook (both online and in paper form) obviously contains a great
deal of material, as well.

--
Erik Max Francis / m...@alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ Life is an effort that deserves a better cause.
\__/ Karl Kraus
7 Sisters Productions / http://www.7sisters.com/
Web design for the future.

Bengt Richter

unread,
Oct 15, 2002, 7:09:06 PM10/15/02
to

==========================================

The fact that there is so much that can be found via Google
(which deserves some kind of Nobel Prize for increasing the
planet's aggregate IQ several notches, IMO) means that there
is a kind of distributed repository already.

It just isn't optimally indexed and organized for retrieval
of python code and info. But my thought was that we could
leverage Google and newsgroups etc. to improve on the retrieval,
rather than trying to concentrate material in various specialized
locations such as Parnassus and the cookbook (which are great,
don't get me wrong).

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 Google would find '++PyPan++' and show an interesting list. The "/clp/forcomment/"
part of the expression is optional, but the intent is to express the location of mySnippet.py
in a classification hierarchy, to aid in searching, to limit hits to particular topics etc.
mySnippet.py is a recommended file name, and comes first after the '++PyPAN++' tag.

The classification path is also for optional use as an actual directory path
which can be rooted anywhere convenient for the user (e.g., ~/PyPAN or C:\pywk\PyPan etc.)
and thereby support automatic extraction/downloading/placement from e.g., newsgroup archives,
disk files, etc.

One common usage would be to see a PyPAN snippet in a post -- like the above in this post.
To make it available to the extraction tool as a file, I wrote a little program [2] called
getclip.exe which simply gets the text from the windows clipboard and writes it to stdout.
This makes the clipboard visible as a file object using os.popen('getclip') -- which
you can pass to anything that wants to read a file. (getclip is also handy outside of Python,
since you can easily pipe the output or redirect it to a file, without having to go to an
editor an pasting and saving-as. Instead you just type getclip>theFile.txt).

The intent is not to require you to select the exact lines, but just do a select-all, copy
or whatever is easy. Then getclip will make all that available to the actual snippet extractor,
which can put it in particular directories, etc.

I am putting together a PyPAN.py module to provide convenient methods for retrieving PyPAN
snippets from clipboard, files, or urls, etc. by regex pattern matches, but it's not finished.
It will be runnable from the command line or importable for programmatic use. There will be
options for file placement similar to winzip extraction. I.e., you can ignore paths and put
everything in a specified directory, or you can root the paths where you like etc. I guess if
there is no interest in PyPAN, I may only be able to retrieve my own snippets ;-)

In any case, I would be interested in hearing of any standard hierarchy for classifying software.
Is there real librarian in the house?

---------------
[1] Variations on the PyPAN tags:
(Note that PyPAN will search based on space-delimited tags, therefore quoting them as in the
following makes them safe against inadvertently interfering with searching for an actual snippet
like the (not quite) minimal one above).

'++PyPAN++' => start with current line
'++PyPAN++-' => start with previous line
'++PyPAN+++' => start with next line
'++PyPAN--' => reserved for future expressions within a snippet
'--PyPAN--' => end with current line
'--PyPAN---' => end with previous line
'--PyPAN--+' => end with next line
---------------

[2]
/* ++PyPAN++ getclip.c -- get and write win32 clipboard text to stdout */
/*
** To compile with msvc++60 at command line use
** cl getclip.c /link /defaultlib:user32
*/

#include <io.h>
#include <string.h>
#include <windows.h>

int main (){
HANDLE hClipData; /* handle to clip data */
LPSTR lpClipData; /* pointer to clip data */
if (!OpenClipboard(NULL)) return 0; /* NULL <=> current task */
/* get text from the clipboard */
if( (hClipData = GetClipboardData(CF_TEXT)) &&
(lpClipData = GlobalLock(hClipData))
){
write(1, lpClipData, strlen(lpClipData)); /*text string to stdout */
GlobalUnlock(hClipData);
CloseClipboard(); return 0;
} else {
CloseClipboard(); return 1;
}
}
/* --PyPAN-- */


Note: The cl command assumes environment settings, which
you can set by invoking D:\VC98\Bin\VCVARS32.BAT (or
whatever your path to it is).

BTW, getclip.exe is not big (freshly recompiled):

02-10-15 15:58 24,576 getclip.exe

BTW2, ISTM it ought to be possible to make a getclip for unix (maybe talking to gpm or
some gui thing?) so that os.popen(getclip) will be a platform-independent thing to write.

Further ideas?

Regards,
Bengt Richter

Ian Bicking

unread,
Oct 15, 2002, 7:24:37 PM10/15/02
to
On Tue, 2002-10-15 at 18:09, Bengt Richter wrote:
> BTW2, ISTM it ought to be possible to make a getclip for unix (maybe talking to gpm or
> some gui thing?) so that os.popen(getclip) will be a platform-independent thing to write.

xclip -o (don't know about gpm, though)

Ian

Bengt Richter

unread,
Oct 15, 2002, 8:15:55 PM10/15/02
to
On 15 Oct 2002 23:09:06 GMT, bo...@oz.net (Bengt Richter) wrote:
[...]

>BTW2, ISTM it ought to be possible to make a getclip for unix (maybe talking to gpm or
>some gui thing?) so that os.popen(getclip) will be a platform-independent thing to write.
Oops, os.popen('getclip')

Regards,
Bengt Richter

Fernando Pérez

unread,
Oct 15, 2002, 8:38:00 PM10/15/02
to
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.

Chris Liechti

unread,
Oct 15, 2002, 9:19:26 PM10/15/02
to
[posted and mailed]

bo...@oz.net (Bengt Richter) wrote in news:aoi76i$b1m$0...@216.39.172.122:


> On Tue, 15 Oct 2002 18:33:13 GMT, Robin Munn <rm...@pobox.com> wrote:
> The fact that there is so much that can be found via Google

...


> 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.

while i think your idea is nice, this can be the first problem...
google is only includeing pages that are linked somewhere. it took many
months until it indexed my page with a gcc port...



> 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 Google would find '++PyPan++' and show an interesting list.

why do you use "+-" etc in the marker? those are special characters to
google and it ignores punctuation/special chars in other cases.
i'd stay with letters only.

oh, i think if it's that simple to use that many people will use the marker
in their news posts.

> In any case, I would be interested in hearing of any standard
> hierarchy for classifying software. Is there real librarian in the
> house?

well i'm no expert in that area... but i found the reverse URL type of
hierarchy of Java a good idea. that way you avoid name conflicts. on the
other hand many people will prefer an order by topic rather than
organization/author.

> ---------------
> [1] Variations on the PyPAN tags:
> (Note that PyPAN will search based on space-delimited tags, therefore
> quoting them as in the following makes them safe against inadvertently
> interfering with searching for an actual snippet like the (not quite)
> minimal one above).
>
> '++PyPAN++' => start with current line
> '++PyPAN++-' => start with previous line
> '++PyPAN+++' => start with next line
> '++PyPAN--' => reserved for future expressions within a snippet
> '--PyPAN--' => end with current line
> '--PyPAN---' => end with previous line
> '--PyPAN--+' => end with next line

as mentioned above, i'm not sure how well the special characters will work.
e.g. google searches for entire words and ignores special chars, but i
think it understands "+" and "-" as include/exclude word so that --PyPAN--
would possibly mean no results containing that string...

why do you want to complicate thigs with that many magic tags anyway?
why not '# PyPANsnippet filename.py /hier/archy version'

hehe. 3'584 Bytes GCC/stripped.

--makefile--
CFLAGS = -mno-cygwin
getclip.exe: getclip.o
$(CC) -mno-cygwin -o $@ $^
strip $@
------------

> Further ideas?

as mentioned above, google is a bit picky if a site is not referenced
anywhere. so it would mabe make sense if there were a page (where many
links point to) where anyone could enter his URL, so that the chances are
increased that it is found by google and other search engines.
a simple wikki page would do, or a mailinglist with HTML accessible
archive.
a bunch of people should place a link to that site on their pages to
increase the google pagerank and to increase the probability that the
linked pages are found.

i think this is a nice idea. with your PyPAN module there could be an easy
access to the information and we get a lot of infrastructure "sponsored"
(storage space for the snippets (with redundancy :-) search engines, ...)

it may be a bit slow 'cause most pages are not refreshed that often. so it
may take a week or two until a snipped is indexed.

and an other problem might come up. i'll just mention "versions"...
it will become difficult to find the best snipped if there are so many
similar entries etc.

oh, and maybe there should be some convention for keywords, like that they
should follow right after the tagline as python comment or so. or do you
think that the source code + message around it is enough to find it?

there will be ground for many tools, like pygoogle combined with xx etc,
indexing bots, that collect all snippets and place them on their own page,
spcialized search engines, ...

chris

--
Chris <clie...@gmx.net>

Erik Max Francis

unread,
Oct 15, 2002, 9:49:23 PM10/15/02
to
Fernando Pérez wrote:

> 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.

It's still not clear to me what the distinction between this and the
ASPN Python Cookbook would be. What snippet would go into a "pattern
repository" that would be inappropriate for the online Cookbook, and/or
vice versa?

From "pattern" I would have guessed that people were referring to
high-level design patterns a la _Design Patterns_ (Gamma et al), but
it's sounding more and more like people are just thinking about a
collection of snippets for handling certain tasks, which is exactly what
the Cookbook is already for.

--
Erik Max Francis / m...@alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE

/ \ Be able to be alone. Lose not the advantage of solitude.
\__/ Sir Thomas Browne
Max Pandaemonium / http://www.maxpandaemonium.com/
A sampling of Max Pandameonium's music.

Conrad Schneiker

unread,
Oct 15, 2002, 9:49:33 PM10/15/02
to
"Bengt Richter" <bo...@oz.net> wrote in message
news:aoi76i$b1m$0...@216.39.172.122...

> The fact that there is so much that can be found via Google
> (which deserves some kind of Nobel Prize for increasing the
> planet's aggregate IQ several notches, IMO) means that there
> is a kind of distributed repository already.

Amen!

> It just isn't optimally indexed and organized for retrieval
> of python code and info. But my thought was that we could
> leverage Google and newsgroups etc. to improve on the retrieval,
> rather than trying to concentrate material in various specialized
> locations such as Parnassus and the cookbook (which are great,
> don't get me wrong).

> Further ideas?

Somehow make use of this google feature?

http://directory.google.com/Top/Computers/Software/

See http://www.google.com/dirhelp.html for more info.

--
Regards,
Conrad

1-408-975-0248
Schn...@AthenaLab.com


Fernando Pérez

unread,
Oct 16, 2002, 1:45:38 AM10/16/02
to
Erik Max Francis wrote:

> Fernando Pérez wrote:
>
>> 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.
>
> It's still not clear to me what the distinction between this and the
> ASPN Python Cookbook would be. What snippet would go into a "pattern
> repository" that would be inappropriate for the online Cookbook, and/or
> vice versa?

It's simply convenience. I may well find a relevant piece of code I have lying
around during a discussion here and quickly paste it on my post, with the
surrounding PyPan markers. I am _far_ less likely to go through the trouble
of going to ASPN, submitting a recipe, etc. Remember, any time you can lower
the activation barrier for a reaction, your product rate increases
dramatically.

cheers,

f

Fernando Pérez

unread,
Oct 16, 2002, 1:46:51 AM10/16/02
to
Chris Liechti wrote:

>> 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.
>
> while i think your idea is nice, this can be the first problem...
> google is only includeing pages that are linked somewhere. it took many
> months until it indexed my page with a gcc port...

Usenet is indexed very quickly. You could simply post to c.l.py and bang, it's
stored by google.

>
>> 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 Google would find '++PyPan++' and show an interesting list.
>
> why do you use "+-" etc in the marker? those are special characters to
> google and it ignores punctuation/special chars in other cases.
> i'd stay with letters only.

If I recall correctly, it's no problem if you search with quotes around your
string. But maybe a different marker set can make life easier.

Cheers,

f.

Bengt Richter

unread,
Oct 17, 2002, 11:57:07 PM10/17/02
to
On Tue, 15 Oct 2002 18:38:00 -0600, Fernando =?ISO-8859-1?Q?P=E9rez?= <fper...@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

Bengt Richter

unread,
Oct 18, 2002, 1:07:04 AM10/18/02
to
On 16 Oct 2002 03:19:26 +0200, Chris Liechti <clie...@gmx.net> wrote:

>[posted and mailed]
>
>bo...@oz.net (Bengt Richter) wrote in news:aoi76i$b1m$0...@216.39.172.122:
>> On Tue, 15 Oct 2002 18:33:13 GMT, Robin Munn <rm...@pobox.com> wrote:
>> The fact that there is so much that can be found via Google
>...
>> 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.
>
>while i think your idea is nice, this can be the first problem...
>google is only includeing pages that are linked somewhere. it took many
>months until it indexed my page with a gcc port...

Your post was on google the day after (maybe sooner). clp posts get there
very quickly.

>
>> 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 Google would find '++PyPan++' and show an interesting list.
>
>why do you use "+-" etc in the marker? those are special characters to
>google and it ignores punctuation/special chars in other cases.
>i'd stay with letters only.

Ok, point taken. But I want something that will stand out visually as well
as make a unique search target. Since google seems to treat underscores
as letters, I will use those. If google just whitewashes punctuation
it shouldn't hurt to use +- for PyPAN processing purposes, so long as
it's not meant to be used as part of a google search pattern. Will have
to test... ;-)

Well, I hope so, but there has to be a way to separate the wheat from the chaff.
People shouldn't be afraid to use it casually, but real gems should wind up
with a different search key when they have been polished to that state. I am
thinking a tag should be reserved for casual ng use, e.g., __PyPAN_CLP.

How to classify stuff requries some thought...


>
>> In any case, I would be interested in hearing of any standard
>> hierarchy for classifying software. Is there real librarian in the
>> house?
>
>well i'm no expert in that area... but i found the reverse URL type of
>hierarchy of Java a good idea. that way you avoid name conflicts. on the
>other hand many people will prefer an order by topic rather than
>organization/author.

I prefer to search by topic unless I know an exact file...

>
>> ---------------
>> [1] Variations on the PyPAN tags:
>> (Note that PyPAN will search based on space-delimited tags, therefore
>> quoting them as in the following makes them safe against inadvertently
>> interfering with searching for an actual snippet like the (not quite)
>> minimal one above).
>>
>> '++PyPAN++' => start with current line
>> '++PyPAN++-' => start with previous line
>> '++PyPAN+++' => start with next line
>> '++PyPAN--' => reserved for future expressions within a snippet
>> '--PyPAN--' => end with current line
>> '--PyPAN---' => end with previous line
>> '--PyPAN--+' => end with next line
>
>as mentioned above, i'm not sure how well the special characters will work.
>e.g. google searches for entire words and ignores special chars, but i
>think it understands "+" and "-" as include/exclude word so that --PyPAN--
>would possibly mean no results containing that string...
>
>why do you want to complicate thigs with that many magic tags anyway?
>why not '# PyPANsnippet filename.py /hier/archy version'

Yes that would work. But I'd like something to make the delimiting lines
stand out visually, so I'd tend to prefix a couple of underscores.
I still want to deal with including a preceding #! line or not.

I'll have to look into that ;-) I remember when hello world was a 34-byte .com ;-)

>
>--makefile--
>CFLAGS = -mno-cygwin
>getclip.exe: getclip.o
> $(CC) -mno-cygwin -o $@ $^
> strip $@
>------------
>
>> Further ideas?
>
>as mentioned above, google is a bit picky if a site is not referenced
>anywhere. so it would mabe make sense if there were a page (where many
>links point to) where anyone could enter his URL, so that the chances are
>increased that it is found by google and other search engines.
>a simple wikki page would do, or a mailinglist with HTML accessible
>archive.
>a bunch of people should place a link to that site on their pages to
>increase the google pagerank and to increase the probability that the
>linked pages are found.
>

At least for newsgroup postings, it seems to go fast. And for that we
also have the python.org archives.

>i think this is a nice idea. with your PyPAN module there could be an easy
>access to the information and we get a lot of infrastructure "sponsored"
>(storage space for the snippets (with redundancy :-) search engines, ...)
>

Thanks, I think the idea generalizes to embedded documents (which of course
rings the MIME bell), but I think want to resist the urge widen the scope
too much ;-)

Other things to leverage might be the restructuredtext (?) and/or YAML.
But anything can be put beween the covers of the covers are simple.
I am thinking of PyPAN_822 as a flag for optional immediately following
rfc822 headers (ending normally in a blank line, but then continuing as
if the block wasn't there). Sort of transparent metadata.

I would allow it to be indented as a block lined up with the flag, so
it could be inside of python comments and posting quotes etc.

>it may be a bit slow 'cause most pages are not refreshed that often. so it
>may take a week or two until a snipped is indexed.
>

As mentioned, this doesn't seem to apply to clp postings.

>and an other problem might come up. i'll just mention "versions"...
>it will become difficult to find the best snipped if there are so many
>similar entries etc.

A really important point! I don't have a good plan yet...

>
>oh, and maybe there should be some convention for keywords, like that they
>should follow right after the tagline as python comment or so. or do you
>think that the source code + message around it is enough to find it?

Well, google seems to include the search tag +- a small amount of context
which may just amount to seeking backwards n characters in the file and
reading forward 2*n and sanitizing it a bit. I don't know. But the
tag and the line it makes stands a good chance of being listed, and I think
it's important to make that human-usable.

I was hoping the hierachy would work somewhat like keywords. Of course
with PyPan_822 you could follow with Keywords: whatever ...
and other metadata as well.

I am thinking that casual use for discussion should use a tag like
__PyPan_CLP filename /hier/archy/ -- human-usable description
and then when newsgroup discussion evolves it to where it's archive ready,
I am thinking it might be useful to differentiate types of snippets by xxx in
__PyPAN_xxx , where xxx might be e.g., PEP, PEPX, Tip, Faq, Arcanum, Warn, Alarm, Doc, Info, etc.
for non-code and maybe __PyPAN_Py fname.ext followed by hierarchy prefixes such as /Tool/,
/Tcl/, /Demo/, /Tut/, etc. for code. Maybe /PEP/nnn/ for suggested code re PEPnnn.

This is just OTTOMH ;-)


>
>there will be ground for many tools, like pygoogle combined with xx etc,
>indexing bots, that collect all snippets and place them on their own page,
>spcialized search engines, ...
>

There are lots of possibilities.
I hope I haven't miffed the catalog and cookbook people by trespassing on their turf.
That's not the intent. This is to start something where it isn't happening, not to
replace something. I think there could be some synergy. ;-)

Regards,
Bengt Richter

Chris Liechti

unread,
Oct 18, 2002, 3:20:11 PM10/18/02
to
bo...@oz.net (Bengt Richter) wrote in news:aoo4to$lli$0...@216.39.172.122:
>>google is only including pages that are linked somewhere. it took

>>many months until it indexed my page with a gcc port...
...

> At least for newsgroup postings, it seems to go fast. And for that we
> also have the python.org archives.

yup. news and some news sites are quickly indexed, but some wepages use a
long time. and i think your idea is very useful for webpages too.



>>and an other problem might come up. i'll just mention "versions"...
>>it will become difficult to find the best snipped if there are so many
>>similar entries etc.
> A really important point! I don't have a good plan yet...

well, maybe "sort by date" is a good and easy starting point

> I hope I haven't miffed the catalog and cookbook people by trespassing
> on their turf. That's not the intent. This is to start something where
> it isn't happening, not to replace something. I think there could be
> some synergy. ;-)

i understood it that way. the work to paste a simple marker may be small
enough so that one can do it often. the cookbook and the vaults are fine
for but pypan is better to mark snippets that are crafted "on the fly"
during discusions etc.

chris
--
Chris <clie...@gmx.net>

Ian Holmes

unread,
Oct 23, 2002, 11:50:31 AM10/23/02
to
bo...@oz.net (Bengt Richter) wrote in message news:<aoi76i$b1m$0...@216.39.172.122>...

>
> [2]
> /* ++PyPAN++ getclip.c -- get and write win32 clipboard text to stdout */
> /*
> ** To compile with msvc++60 at command line use
> ** cl getclip.c /link /defaultlib:user32
> */
>
> #include <io.h>

I am sure you have all implemented this in python already but here is
getclip.exe in py for use/ridicule.

#++PyPan++ getclip.py -- get and write win32 clipboard to file
#Requires Mark Hammond's win32all extensions or the activestate
distribution

from win32clipboard import *

def main():
try:
OpenClipboard()
except:
return 0
#get text from the clipboard
try:
cliptext = GetClipboardData()
file = open(filename,'wb') #open file for writing
file.write(cliptext)
file.close()
CloseClipboard()
return 0
except:
CloseClipboard()
return 1

if __name__ == '__main__':
if len(sys.argv) == 1:
#use default file name
filename = 'default.txt'
else:
#use command line argument
filename = sys.argv[1]
main()
#--PyPan--

On the subject of sizes 816 bytes (excluding of course the python
install <wink>)

Would PyPan message writter be of use?

That allowed addition of tags(is that the most appropriate word?) /
comments specific to PyPan to the clipboards content and returned the
whole lot to the clipboard(textfile) for pasting into postings.

0 new messages