Re: OpenSource documentation problems

2005-09-01 Thread Paul Rubin
Michael Sparks <[EMAIL PROTECTED]> writes:
> > I've submitted a number of doc bugs to sourceforge and the ones that
> > are simple errors and omissions do get fixed.  
> 
> Cool. 

Better than nothing, but it's only one class of problem, and maybe the
easiest kind to report.  

There's another type of doc problem though, which is when the doc
simply doesn't explain how to use something.  It's not easy to submit
a bug report that says more than "this doc is no good".  Example: I
want to scrape a web page with urllib2 that involves logging into a
site, then going to the page I want to scrape and presenting a cookie
that came from the login page.  OK, urllib2 recently got a feature
for that, thanks to John J. Lee:

   http://www.python.org/doc/2.4.1/lib/http-cookie-processor.html

But reading that page, or the parent page for urllib2 itself, how the
heck am I supposed to use the feature?  Answering that would probably
take an hour or two of pondering the source code.  I found another way
to solve my problem instead.  And without spending that pondering
time, I can't submit a better bug report than "this doc page doesn't
explain how to use the feature".

I think PHP's online doc system is way superior for this kind of issue
since it's easy to post questions about the doc page directly to the
page, and for other people to answer.  Later, the doc editors can read
over the comments and merge the good info from them into the doc
source.

> OK, it's not the best solution in the world I'll agree, but my point was in
> general very few people like writing docs even when paid, let alone when
> not. As a result it's not that suprising IMO that if paid you end up with
> more docs. 

I think people like doing good work whether they're paid or not
(assuming it's work that they want to do at all).  Therefore, if
someone goes in with the view that software isn't good unless it's
well-documented, then good documentation will result.  So, GNU has
good docs because RMS was very emphatic about that view and got other
people involved in the project to share the view.  See for example:

http://www.gnu.org/software/emacs/manual/html_node/Bug-Criteria.html

"If after careful rereading of the manual you still do not understand
what the command should do, that indicates a bug in the manual, which
you should report. The manual's job is to make everything clear to
people who are not Emacs experts--including you. It is just as
important to report documentation bugs as program bugs.

"If the on-line documentation string of a function or variable
disagrees with the manual, one of them must be wrong; that is a bug."

With Python the docs seem like much more of an afterthought.

> > I usually do report doc bugs, but my frustration (and I think Bryan's)
> > is that there are so many bugs in the first place.  It means that the
> > authors are not applying high enough quality standards to their own
> > work before releasing it.  That applies to Python's code as well as
> > its docs.  It's not crap,
> 
> Or maybe they're just doing their best? 

I don't think so.  How could you consider that example above about the
http cookie processor class to be an example of someone doing their
best?  The feature is mentioned tantalizingly but there's flat-out
zero description of how to use it.  Good documentation was simply not
a priority when that patch got added.

Another example from last week (now fixed): the shelve module doc
didn't mention the sync() operation without which there's no way to
flush updates to disc.  One thing I remember about RMS preparing Emacs
releases is whenever he did one, he'd go over the code change log
starting from the previous release, and make sure that every code
change had a corresponding doc update if it needed one.  From the
number of little doc ommissions I see like the shelve.sync operation
(maybe not that specific one), it's pretty clear to me that nobody is
doing anything like that cross-checking for Python releases.

> It might seem silly but when I do write docs, personally it takes me
> around 4-10 times longer to write the same number of lines as
> documentation than as code, whilst trying to maintain a similar
> quality. I think thats on a good day.

Well, docs have more characters per line than code, so that ratio
isn't surprising.  On the other hand, docs usually don't need
intricate design or debugging the way code does.  I could usually slog
out docs while too tired to code accurately.  Another RMS doc recipe
was: after writing each sentence, re-read it and ask yourself what
someone reading that sentence will want to know next.  That tells you
what the next sentence should be.  Following that formula til
everything was covered, printing out the result and circulating it to
a few people for review, and incorporating the comments, generally
resulted in a usable doc.

The main difference between writing code and docs that maybe bothers
programmers is that docs don't interact with yo

Re: OpenSource documentation problems

2005-09-01 Thread Terry Hancock
On Thursday 01 September 2005 10:11 pm, Paul Rubin wrote:
> "Fred L. Drake, Jr." <[EMAIL PROTECTED]> writes:
> > Ideally, emails to docs at python.org would result in issues being
> > created somewhere, simply so they don't get lost.  It probably
> > doesn't make sense for those to land in SourceForge automatically,
> > since then everyone has to read every plea for a printable version
> > of the documents.
> 
> Until not that long ago, it was possible to submit sf bugs without
> being logged into sf.  Why did that change?  What was the problem with
> non-logged-in bug reports?  I submitted some number of them just
> because I couldn't be bothered logging in, and they got handled like
> any other bug reports.  

Hmm. Still sounds like "there ought to be a wiki".  I've seen references
to two different ones on this thread. One was then debunked as a "failed
experiment".  The other just gave me a DNS lookup failure (maybe the
URL was wrong).

If there is one, or if one is established, then some work would
need to be done to direct people to it from the existing documentation.
The main issue to be resolved would be establishing which wiki
Mr. Drake is going to read, I suppose. ;-)

Of course, I have a SF account, so I could use the existing system.
But in the interest of reducing obstacles to contribution it would
seem like a good idea. I've only ever set up ZWiki, though, and I
don't seem to completely understand it, as I keep having permissions
problems with it. But I know there are serious wiki people on this
list.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Are there free molecular libraries written in python ?

2005-09-01 Thread Alessandro Bottoni
Xiao Jianfeng wrote:

> Hi,
> 
> Are there any free libraries for the analysis and manipulation of
> molecular structural models, implemented in the Python programming
> language ?
> 
> Thanks.

What about the followings? 
MMTK = http://starship.python.net/crew/hinsen/MMTK/
PyMol = http://pymol.sourceforge.net/ (Just model visualization, I'm afraid)
Chimera = http://www.cgl.ucsf.edu/chimera/

Other projects you should be aware of:
SciPy = http://www.scipy.org/
BioPython = http://biopython.org/scriptcentral/

Other Python/Science resources and articles:
http://starship.python.net/crew/hinsen/
http://www.dalkescientific.com/writings/PyCon2004.html
http://www.foretec.com/python/workshops/1998-11/demosession/dalke.html
http://www.swig.org/papers/Py97/beazley.html

And, of course, have a look at these Python software repositories:
http://www.python.org/pypi
http://www.vex.net/parnassus/

And at these generic software repositories:
http://freshmeat.net/
http://sourceforge.net/
(search or browse for scientific/chemistry)

HTH

---
Alessandro Bottoni
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Are there free molecular libraries written in python ?

2005-09-01 Thread Robert Kern
Xiao Jianfeng wrote:
> Hi,
> 
> Are there any free libraries for the analysis and manipulation of
> molecular structural models, implemented in the Python programming
> language ?

Google is your friend.

http://starship.python.net/crew/hinsen/mmtk.html
http://pymol.sourceforge.net/
http://www.scripps.edu/~sanner/python/

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python C module questions

2005-09-01 Thread Thomas Heller
[EMAIL PROTECTED] writes:

[...]
> /* convert sequences to tuples if necessary */
> ra1 = PySequence_Fast(ra1, "ra1 must be iterable");
> if (ra1 == NULL) {
> return NULL;
> }
>
> dec1 = PySequence_Fast(dec1, "dec1 must be iterable");
> if (dec1 == NULL) {
> return NULL;
> }

You leak a refcount to ra1 here in the case the the second
PySequence_Fast fails.

[...]
> /* allocate memory for C arrays */
> r1 = (double *) malloc(len1 * sizeof(double));
> if (r1 == NULL) {
> Py_DECREF(ra1);
> Py_DECREF(dec1);
> Py_DECREF(ra2);
> Py_DECREF(dec2);
> return PyErr_NoMemory();
> }
>
> d1 = (double *) malloc(len1 * sizeof(double));
> if (d1 == NULL) {
> Py_DECREF(ra1);
> Py_DECREF(dec1);
> Py_DECREF(ra2);
> Py_DECREF(dec2);
> return PyErr_NoMemory();
> }
and so on, and so on.

You should probably better start your code initializing all local vars
to NULL, like this:

PyObject *ra1 = NULL, *dec1 = NULL, ...
char *r1 = NULL, char *d1 = NULL, ...;

Then in the body of the function

d1 = (double *) malloc(len1 * sizeof(double));
if (d1 == NULL) {
PyErr_NoMemory();
goto error;
}

and have a cleanup section at the end:

  error:
if (d1) free(d1);

Py_XDECREF(ra1);
Py_XDECREF(dec1);
return NULL;
}

Reading the sources for a few builtin modules of the Python sources
itself should give you also an idea.

> I also find it hard to believe that there's no
> standard Python function for converting sequences of one object to
> arrays in C (a friend mentioned that Ruby's C API has this).

The builtin array module does help with this, you can build the
C-compatible arrays in Python, pass them to your extension, and access
them using the buffer api.

Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list


Are there free molecular libraries written in python ?

2005-09-01 Thread Xiao Jianfeng

Hi,

Are there any free libraries for the analysis and manipulation of 
molecular structural models, implemented in the Python programming 
language ?


Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: global interpreter lock

2005-09-01 Thread Bryan Olson
Mike Meyer wrote:
 > Bryan Olson writes:
 >>With Python threads/queues how do I wait for two queues (or
 >>locks or semaphores) at one call? (I know some methods to
 >>accomplish the same effect, but they suck.)
 >
 > By "not as good as", I meant the model they provide isn't as managable
 > as the one provided by Queue/Threading. Like async I/O,
 > Queue/Threading provides a better model at the cost of
 > generality.

I can't tell why you think that.

 > Instead of making vague assertions, why don't you provide us
 > with facts?

Yeah, I'll keep doing that. You're the one proclaiming a 'model'
to be more manageable with no evidence.

 > I.e. - what are the things you think are obvious that turned
 > out not to be true? Name some software that implements sophisticated
 > services that we can go look out. And so on...

Thought we went over that. Look at the popular relational-
database engines. Implementing such a service with one line of
execution and async I/O is theoretically possible, but I've not
heard of anyone who has managed to do it. MySQL, PostgreSQL,
IBPhoenix, MaxDB, all have multiple simultaneous threads and/or
processes (as do the competitive commercial database engines,
though you can't look under the hood so easily).


-- 
--Bryan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python doc problems example: gzip module

2005-09-01 Thread EP
"Xah Lee" <[EMAIL PROTECTED]> wrote:

> today i need to  decompress

> since i'm familiar with 

  what the fuck


> Fuck the  

> I just need to decompress 

 that fucking doc 
 whatever fuck 



Is it just me or, do you suppose, with so much unnecessary "f" word, this is 
not a post at all, but a cleverly encoded message to fellow unsavory 
characters.  The "f"'s are just enough to thwart (ahem,lesser!) intellects from 
critically analyzing the text.  And as far as I can tell, there was no real 
content in the post.

Could the position of the f words be the key to the encrypted message?

I need to enlist the help of smarter minds to decode the message - I have zero 
experience in this, but I am sure there are minds bright enough on this list to 
crack the XL posts.


Here's all I could get going, trying to see if there was something in the name 
itself (but clearly the below is kindergarten level, at best)


>>> eName="xahlee"
>>> def fName(name="", offset=0, p=1):
newName="".join([chr(ord(c)+ offset  -(26*((ord(c)+offset)>122))) for c 
in name])
if p==1:
print newName
return newName

>>> for i in range(0,26):
nn=fName(name,i)


xahlee
ybimff
zcjngg
adkohh
belpii
cfmqjj
dgnrkk
ehosll
fiptmm
gjqunn
hkrvoo
ilswpp
jmtxqq
knuyrr
lovzss
mpwatt
nqxbuu
orycvv
pszdww
qtaexx
rubfyy
svcgzz
twdhaa
uxeibb
vyfjcc
wzgkdd

Certainly this one caught my eye ("rubfyy") - Ruby with the f-you acronym 
inside it!


Sorry, folks, its been a long week and I need to decompress.



EP



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python C module questions

2005-09-01 Thread Robert Kern
jbrewer wrote:

[I wrote:]
>>You probably shouldn't post such large pieces of code to the list.
> 
> OK.

BTW, please attribute your quotes.

[Still me:]
>>You mean a docstring on the module object itself?
> 
> Actually, I meant docstrings to the module and the functions, objects,
> methods, whatever else in the module.  My code was derived from the
> Python Cookbook, which left that part out (rather important for
> building real C modules).

In the method definition tables for top-level functions and type methods
there is a place for the docstrings. You had them in your code.

Please read the documentation on writing extensions.

  http://docs.python.org/ext/ext.html

Specifically,

  http://docs.python.org/ext/methodTable.html
  http://docs.python.org/ext/node22.html

[Thomas Heller wrote:]
>>You should give up C with a dumb algorithm running at fast speed.
>>Implement a better algorithm in Python, maybe you can even outperform
>>the dumb code.
> 
> That would be the next step if I needed even more speed, but the better
> algorithm here would be to use KDTrees, which would be overkill (and
> would require lots of development time). 

Not for you, it won't.

google('kdtree python')

> The C brute force
> implementation runs plenty fast for me.  It took only took a few hours
> to implement and yielded a factor of 7 performance increase.  I was
> mostly interested in feedback on whether I had done things in a
> properly efficient way (there are so many Python list / tuple /
> sequence functions).  I also find it hard to believe that there's no
> standard Python function for converting sequences of one object to
> arrays in C (a friend mentioned that Ruby's C API has this).
> 
> Another question: how does the distutils package handle version
> upgrades?  Say for example I find some bugs in my C code and need to
> recompile it, will it just overwrite what's present in the
> site-packages directory?

It will overwrite the files that have been changed.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing formatted data (numeric) to a binary file

2005-09-01 Thread Robert Kern
[EMAIL PROTECTED] wrote:

> I'm conscious that the "write" command would allow me to write text to
> a binary file, but I'm not clear how to:
> 1) format my numeric data such that it matches the real*4 format
> 2) parse an entire row of a 2D array without using a for loop.

For homogeneous blocks of numbers like this, you'll probably want to use
Numeric of numarray.

  http://numeric.scipy.org

import Numeric
data = Numeric.array(all_of_the_numbers, Numeric.Float32)
s = data.tostring()
f = open(filename, 'wb')
f.write(s)
f.close()

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sockets: code works locally but fails over LAN

2005-09-01 Thread Bryan Olson
n00m wrote:
 >>Bryan;
 >
 > I tested your code locally (in I*D*L*E) - it works fine!

Glad it worked, but I'd still disrecommend IDLE for that
version. Threads may live after the program seems to be done
(and may still own the port you need). Below is a version that
respects ^C to terminate more-or-less cleanly.

 > And of course I'll test it over LAN but only tomorrow - at work.
 > See the picture of my IDLE window with output of your code:
 > http://free.7host02.com/n00b/socket_Br.gif

I didn't touch the printing, so it should output the same thing
as your version. Looks like you've got some UTF-16 action there,
and Python may be able to print it nicer if you use the
unicode/codec stuff.


--
--Bryan


import socket, threading, select

sqls_host, sqls_port = '192.168.0.3', 1443
proxy_host, proxy_port = '', 1434


def start_deamon_thread(func, args):
  """ Run func(*args) in a deamon thread.
  """
  thread = threading.Thread(target=func, args=args)
  thread.setDaemon(True)
  thread.start()


def sock_copy(s_from, s_to, annotation):
 while 1:
 data = s_from.recv(4096)
 if not data:
 break
 s_to.sendall(data)
 print annotation + data + '\n\n'


s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s1.bind((proxy_host, proxy_port))
s1.listen(5)

while 1:
 s, _, _ = select.select([s1], [], [], 1.0)
 if s:
 cn, _ = s1.accept()
 s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 s2.connect((sqls_host, sqls_port))
 start_deamon_thread(sock_copy, (cn, s2, 'VB_SCRIPT:'))
 start_deamon_thread(sock_copy, (s2, cn, 'SQL_SERVER:'))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Terry Hancock
On Thursday 01 September 2005 04:03 am, Fredrik Lundh wrote:
> Steve Holden wrote:
> > I agree that maintaining documentation is a generic problem of the open
> > source world, but it's a sad fact of life that generally people are
> > better-motivated to complain about documentation (and almost everything
> > else) than to help improve it.
> 
> another problem is that to be able to do really good work on the
> documentation, you need to know things well enough to "have the
> big picture".  and once you have that, you'll find that the docs aren't
> really as bad as you once thought they were.

Or "Once you understand the problem well enought to explain it to
someone, it suddenly seems a lot less urgent to do so."  That's kind
of a viscious circle, isn't it?

Honestly, I wouldn't mind helping out with documentation myself, as
I'm pretty confident I could do fairly good work (though I doubt I
would ever please XL), but I just haven't found anything that bothered
me about Python's existing documentation.  Maybe I should look harder.

I do notice that we seem to have "learning styles" issues. The one
thing I've gathered from Xah Lee's execrable posts is that he learns
exclusively by studying examples, and gets nothing from descriptive
text. I'm almost exactly the opposite -- when I go to the documentation,
I'm looking for "the big picture" as you say. 

I have loads of example code to check for exact usage.  And after a
couple of weeks with Python, I stopped finding the library modules'
approach to things at all surprising. I generally could guess the
correct behavior and test it right away (I have been really surprised
at the number of times I just took a wild guess at what a method would
be called, and turned out to be right).

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Add lists to class?

2005-09-01 Thread Mike Meyer
"BBands" <[EMAIL PROTECTED]> writes:

> I have a list with some strings in in it, 'one', 'two' 'three' and so
> on. I would like to add lists to a class with those names. I have no
> way of knowing what will be in the list or how long the list will be in
> advance.

Others have told you how to do it. Now I'm going to tell you why you
shouldn't.

First, since you don't know the names of the attributes you added, you
can't possibly write code that references them in the normal way. So
is there really much point in making them an attribute at all?

Second, since you don't know the names of the attributes you added,
you don't know if one of more of them is going to clobber a feafure of
the class that you want to use for something else. I.e., consider:

>>> class C:
...  pass
... 
>>> c = C()
>>> print c
<__main__.C instance at 0x8270b4c>
>>> c.__str__ = 'foo'
>>> print c
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: 'str' object is not callable
>>> 

I.e. - if someone adds a __str__ attribute to your class, you won't be
able to print it any more. Not a good thing.

In general, you probably want a dictionary instead of attributes:

>>> class C(dict):
...  def __init__(self, l):
...   for i in l:
...self[i] = []
... 
>>> c = C(['a', 'b', 'c'])
>>> c['a']
[]
>>> 

You didn't say why you wanted to do this; maybe you really do have a
good reason. But that would be an exceptional case.

   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python C module questions

2005-09-01 Thread jbrewer
>You probably shouldn't post such large pieces of code to the list.

OK.

>You mean a docstring on the module object itself?

Actually, I meant docstrings to the module and the functions, objects,
methods, whatever else in the module.  My code was derived from the
Python Cookbook, which left that part out (rather important for
building real C modules).

>You should give up C with a dumb algorithm running at fast speed.
>Implement a better algorithm in Python, maybe you can even outperform
>the dumb code.

That would be the next step if I needed even more speed, but the better
algorithm here would be to use KDTrees, which would be overkill (and
would require lots of development time).  The C brute force
implementation runs plenty fast for me.  It took only took a few hours
to implement and yielded a factor of 7 performance increase.  I was
mostly interested in feedback on whether I had done things in a
properly efficient way (there are so many Python list / tuple /
sequence functions).  I also find it hard to believe that there's no
standard Python function for converting sequences of one object to
arrays in C (a friend mentioned that Ruby's C API has this).

Another question: how does the distutils package handle version
upgrades?  Say for example I find some bugs in my C code and need to
recompile it, will it just overwrite what's present in the
site-packages directory?

Jeremy

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'isa' keyword

2005-09-01 Thread Terry Hancock
On Thursday 01 September 2005 07:28 am, Fuzzyman wrote:
> On 1 Sep 2005 00:52:54 -0700, "talin at acm dot org"
> <[EMAIL PROTECTED]> wrote:

> What's the difference between this and ``isinstance`` ?

Other than proposing a keyword operator instead of a function,
apparently nothing.

isinstance() even checks for subclasses, if I'm not mistaken,
so the semantics should be identical.

I must confess that an "isa" operator sounds like it would
have been slightly nicer syntax than the isinstance() built-in
function. But not enough nicer to change, IMHO.

Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing formatted data (numeric) to a binary file

2005-09-01 Thread Grant Edwards
On 2005-09-02, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> I'm conscious that the "write" command would allow me to write
> text to a binary file, but I'm not clear how to:
> 1) format my numeric data such that it matches the real*4 format
> 2) parse an entire row of a 2D array without using a for loop.

http://docs.python.org/lib/module-struct.html

-- 
Grant Edwards   grante Yow!  I'm in DISGUISE as a
  at   BAGGAGE CHECKERI can
   visi.comwatch the house, if it's
   ORANGE...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python / web

2005-09-01 Thread Mike Meyer
Robert <[EMAIL PROTECTED]> writes:
> Hi,
> I know general Python pretty well and interested in using Python for a
> web project. It will have the standard display, user input, fields,
> look-ups, reports, database routines, etc. Been looking though the
> Python web docs. and seeing stuff like mod_python, CGI, PSP, CherryPy,
> etc...,  Also a fair amount of googling. I'll say there's a large
> amount of technology to pick from.  Rather than spend time going down
> the wrong road, can I get some feedback as directions from you folks
> that's "been there, done that."

Well, as usual when answering such questions, the answer is "It
depends." If you're interested in getting a web site up with a
Python-like tool, then you want a framework. Others have already
suggested Zope/Plone, which seems to be the most popular such
system. I only have limit experience with Zope, but I found that it
tended to own the resulting code, such that reusing it in another
framework would be a PITA.

If you're more interested in working in Python, with a cleaner
representation of the HTML than as Python strings with %()'s scattered
through them, then you want a templating systems. I recently evaluated
a number of templating systems for a client, and we settled on
Cheetah. The reasons for this were:

 1) Cheetah is not just a web templating language; it can be
used for anything. My first Cheetah template generated XML
to feed to an XMLHttpRequest.

 2) Cheetah templates compile to Python classes, so anything I
can use to hook Python up to my web server I can use with Cheetah
templates.

 3) Cheetah constructs don't try and look like HTML.  This
means less typing to use them, and they won't cause problems
with whatever HTML/XML-aware editor you may want to use.

In refernce to the "owning" affect above, all the real work on our
pages is done in pure Python classes that the Cheetah templates
inherit from. So we can remove the dependency on Cheetah by changing
one fixed line in each file to a different line - which change can be
made mechanically.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Epydoc - Documenting class members?

2005-09-01 Thread Terry Hancock
On Thursday 01 September 2005 03:01 am, Miki Tebeka wrote:
> [Miki]
> >> Is there a way to document class members in Epydoc?
> 
> [Terry]
> > Yes. See additions below:

> I don't like this, I want to document where I declare the variable below.
> Doxygen (www.doxygen.org), for one example, knows how to do this.

Then use Doxygen if it's a superior product. I presume
it knows how to handle Python code, then?

You asked how to do this in epydoc. Which I use. So I told you.
It works fine for me just like it is.

If you feel it ought to be smarter, you could of course

1) Submit a patch to the author.

2) At least place a feature request on the SF tracker for
   the project.

Epydoc is based on pydoc, and does not interpret comments at all.
Happydoc does (or did), but it did not provide any means to document
class or instance attributes that I could find. It is also regrettably
not being maintained anymore, AFIACT, which is why I switched
to epydoc (although epydoc seems to be a very nice product itself).


--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Writing formatted data (numeric) to a binary file

2005-09-01 Thread Trevor . Dhu
I am just starting to use python, and as such my question may well be a
bit simplistic.  I am currently trying to write what should be a very
basic set of routines for reading and writing to a binary grid format
(ERMapper).  However:

I am struggling to find the correct tools to write a row of a
2-dimensional array to a binary file.  In matlab the command looks
like:

fid=fopen(filename,'wb');
for y=1:NrOfLines
   fwrite(fid,in(y,:)','real*4');
end
fclose(fid);

I'm conscious that the "write" command would allow me to write text to
a binary file, but I'm not clear how to:
1) format my numeric data such that it matches the real*4 format
2) parse an entire row of a 2D array without using a for loop.

If anyone has any suggestions on how to do this (or even hints as to
what modules I should be looking at) they would be greatly appreciated.
 Alternativly, if anyone has written routines for dealing with basic
ERMapper grids (as opposed to the wavelet compressed data) I'd love to
save myself from re-inventing the wheel.

Thanks
Trevor Dhu

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Steve Holden
Fred L. Drake, Jr. wrote:
> On Thursday 01 September 2005 22:53, Steve Holden wrote:
>  > So, probably the best outcome of this current dialogue would be a change
>  > to the bottom-of-page comment so instead of saying
>  >
>  > """Release 2.4, documentation updated on 29 November 2004.
>  > See About this document... for information on suggesting changes. """
>  >
>  > it said
>  >
>  > """Release 2.4, documentation updated on 29 November 2004.
>  > See About this document... for information on suggesting changes, or
>  > mail your suggestions to [EMAIL PROTECTED]"""
> 
> The reason I changed the text there and on the "About..." page was to avoid 
> it 
> all coming to the doc team (of one) as email, where it too often was lost 
> whenever I was swamped by whatever work projects I was involved in at the 
> time.  That's a big reason to continue to emphasize using SourceForge instead 
> of my mailbox.
> 
> Ideally, emails to docs at python.org would result in issues being created 
> somewhere, simply so they don't get lost.  It probably doesn't make sense for 
> those to land in SourceForge automatically, since then everyone has to read 
> every plea for a printable version of the documents.
> 
> At one time, there was hope that we could get a Roundup tracker running for 
> the webmaster address, to help make sure that each request received an 
> appropriate response, and I secretly hoped to point the docs address at that 
> as well.  Unfortunately, not enough time was available from people with 
> sufficient Roundup know-how to finish that effort.  I still think that would 
> be really nice.
> 
> 
>   -Fred
> 
I suspected as as much, but I'm glad of your confirmation. Symptomatic 
that nobody else on this thread bothered to Cc docs at python dot org to 
see what "the team" (all one of you) had to say about it.

Given that my suggestion was nixed for good reason, my fallback position 
is that you need help on the documentation, and also on a subsystem to 
channel comments effectively into issues that can be followed up, by 
whatever means available, and by more than one person. Maybe we should 
work on that.

In the meantime thanks for your hard work on the docs, which is IMHO 
insufficiently appreciated.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pain

2005-09-01 Thread Steve Holden
James Stroud wrote:
> On Thursday 04 August 2005 07:49 am, projecktzero wrote:
[...]
>>The manager may have his reasons for choosing the tools.
> 
> 
> Reason: ignorance.
> 
[...]

and the day managers stop being ignorant we'll all be able to fly around 
on pigs. Not wishing to offend the pigs, of course.

still-working-for-myself-ly y'rs  - steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is there a better way to check an array?

2005-09-01 Thread Mike Meyer
"Steve M" <[EMAIL PROTECTED]> writes:
> You can check for membership in a list at least these ways:

Two ways - idnex and the in keyword.

> my_list.find(candidate)
> -returns the index into my_list of the first occurrence of candidate.
> Returns -1 if candidate doesn't occur in my_list.

Lists don't have a find method. strings do. Why is a good question.

http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Steve Holden
Paul Rubin wrote:
[snip snippety snip snip, snip snip]
> 
> Calling the Python docs "worthless" is false and unconstructive;
> saying that the docs have shortcomings in part because the Python
> project itself places too little priority on doc quality is perfectly
> legitimate.  Python's core developers are in a leadership position for
> Python whether they like it or not; and users and volunteers absorb
> the attitudes of the leaders.

So, what you are saying is because the developers (I explain in another 
post on this thread that I'm not a developer, but I *am* a director for 
the PSF), having taken the time and trouble to produce something that 
you (for want of a better example) find incredibly useful, are now 
beholden to improve it still further and make it still more useful, 
because otherwise nobody else will feel it necessary to create and 
maintain documentation of high quality?

>  The PSF and the FSF both sometimes fund
> people to do coding projects.  Why does the PSF (apparently) not fund
> anyone to do doc projects, like the FSF does?  I would say this shows
> the PSF's priorities are screwed up.  Documentation is every bit as
> important as code.
> 
Bear in mind that the PSF made its very first grants last year. The 
reason none of those grants was awarded to a documentation project was 
that the (volunteer) Grants Committee and helpers didn't see any 
documentation projects worthy of support. I'm not actually sure they saw 
any documentation proposals at all. So they chose to support the 
development of new teaching materials (hey, that might be 
documentation), an update to Jython and an improved SNMP implementation.

I guess your proposal must have been lost in the mail ;-)

What Python really needs is for Python enthusiasts to understand that 
the future of the language is largely in their hands. It's easy to say 
"but I can't do this" or "I can't do that". Forget such negativity. Find 
something you *can* do to improve Python - document a module, chair a 
conference, or (as *you* already do) contribute your knowledge and 
experience to c.l.py to improve the level of Python awareness.

I have done all of these things, and I firmly believe that each could 
have been done better. Unfortunately those with superior skills chose 
not to engage the Python community. Which left it stuck with me. Poor 
Python.

Most of all, realise that there is no "us" and "them". *We* are "them", 
and it's up to *us* to accept that and try to improve things.

Please understand that I don't mean to belittle anyone who has made any 
kind of contribution to Python (even Xah Lee has his place, though I 
tremble to think so). I just want more Python users to understand that 
there are many contributions they could make that are well within their 
capabilities, and to get off their butts and start doing something!

existential-ly y'rs  - steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Holden Web Ltd

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cgi, reusing html. common problem?

2005-09-01 Thread John M. Gabriele
On Thu, 01 Sep 2005 20:57:56 -0500, Steve Holden wrote:

> John M. Gabriele wrote:
>> [snip]
>> 
>> Is that how it's usually done? If not, what *is* the
>> usual way of handling this?
>> 
> There are a million ways to solve this particular problem, despite 
> Python's "TSBOAPOOOWTDI" (see "import this") philosophy (because the 
> philosophy is addressing primitive programming rather than application 
> frameworks).

Yes. :)

> You could do something as simple as writing a module "webPage" that 
> defines a function page(path, content) that does something along the 
> lines of:
> 
> def page(path, content):
>  return """\
> 
> If you want titles, add another argument
> 
> 
>  the path given as an argument - I'm just ignoring it in this example>
> %s
> 
> 
> """ % content

Ah yes, I see. If the content is completely static, you
can use a text file (html fragment) and just read it and
paste it in, but for fragments that are *mostly* static,
I really like that idea to use a module as you suggest.


> [snip]
> 
> Hope this gives you a few ideas. This problem has been considered by 
> many people, but clearly no outstanding solution has yet been devised, 
> otherwise we'd all be using it.
> 
> regards
>   Steve

Thanks Steve!

---John

-- 
--- if contacting via email, remove zees ---


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Paul Rubin
"Fred L. Drake, Jr." <[EMAIL PROTECTED]> writes:
> Ideally, emails to docs at python.org would result in issues being
> created somewhere, simply so they don't get lost.  It probably
> doesn't make sense for those to land in SourceForge automatically,
> since then everyone has to read every plea for a printable version
> of the documents.

Until not that long ago, it was possible to submit sf bugs without
being logged into sf.  Why did that change?  What was the problem with
non-logged-in bug reports?  I submitted some number of them just
because I couldn't be bothered logging in, and they got handled like
any other bug reports.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Fred L. Drake, Jr.
On Thursday 01 September 2005 22:53, Steve Holden wrote:
 > So, probably the best outcome of this current dialogue would be a change
 > to the bottom-of-page comment so instead of saying
 >
 > """Release 2.4, documentation updated on 29 November 2004.
 > See About this document... for information on suggesting changes. """
 >
 > it said
 >
 > """Release 2.4, documentation updated on 29 November 2004.
 > See About this document... for information on suggesting changes, or
 > mail your suggestions to [EMAIL PROTECTED]"""

The reason I changed the text there and on the "About..." page was to avoid it 
all coming to the doc team (of one) as email, where it too often was lost 
whenever I was swamped by whatever work projects I was involved in at the 
time.  That's a big reason to continue to emphasize using SourceForge instead 
of my mailbox.

Ideally, emails to docs at python.org would result in issues being created 
somewhere, simply so they don't get lost.  It probably doesn't make sense for 
those to land in SourceForge automatically, since then everyone has to read 
every plea for a printable version of the documents.

At one time, there was hope that we could get a Roundup tracker running for 
the webmaster address, to help make sure that each request received an 
appropriate response, and I secretly hoped to point the docs address at that 
as well.  Unfortunately, not enough time was available from people with 
sufficient Roundup know-how to finish that effort.  I still think that would 
be really nice.


  -Fred

-- 
Fred L. Drake, Jr.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bug in string.find

2005-09-01 Thread Paul Rubin
Ron Adam <[EMAIL PROTECTED]> writes:
> All of the following get the center 'd' from the string.
> 
> a = 'abcdefg'
> print a[3] # d   4 gaps from beginning
> print a[-4]# d   5 gaps from end
> print a[3:4]   # d
> print a[-4:-3] # d
> print a[-4:4]  # d
> print a[3:-3]  # d
> print a[3:2:-1]# d   These are symetric?!
> print a[-4:-5:-1]  # d
> print a[3:-5:-1]   # d
> print a[-4:2:-1]   # d

+1 QOTW
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Steve Holden
Fredrik Lundh wrote:
> Rocco Moretti wrote:
> 
> 
>>Something a simple as allowing doc bugs to be submitted from a webform
>>w/o login would reduce the barrier to contribute. - Increasing the size
>>of the "About" text wouldn't hurt either. (To be honest, I've never
>>noticed that text before, and it never occurred to me look at the
>>"About" page for information on error reports.)
> 
> 
> the useredit approach I'm using over at the librarybook site works
> pretty well.  for example, if you go to
> 
> http://effbot.org/librarybook/mailbox.htm
> 
> and click "suggest changes" at the bottom, you can edit the page
> source, preview the changes, and generate a patch when you're
> done, all without signing up or logging in.
> 
> (unfortunately, Python's documentation is written in LaTeX, using
> a rather advanced tool chain to get from sources to HTML, so the
> librarybook approach won't really work "out of the box")
> 
That's true, but (as I mentioned a few minutes ago in another post) the 
docs team will happily accept plain text of that's all the contributor 
can provide. It's *that* fact that needs to become more obvious.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Steve Holden
Rocco Moretti wrote:
> Steve Holden wrote:
> 
> 
>>Every page of the docs links to "About this document", which contains 
>>the following: """If you are able to provide suggested text, either to 
>>replace existing incorrect or unclear material, or additional text to 
>>supplement what's already available, we'd appreciate the contribution. 
>>There's no need to worry about text markup; our documentation team will 
>>gladly take care of that."""
> 
> 
> There is just one giant roadblock to that suggestion - Sourceforge 
> requires a login to post bugs/patches.
> 
Well OK, I have to descend to observations based on personal experience 
here, but way back when I was a Python noob and I had a suggestion about 
how the docs might be [slightly] improved I just actioned the first 
sentence in the paragraph from which I extracted my previous quote. That 
reads:

"""General comments and questions regarding this document should be sent 
by email to [EMAIL PROTECTED]"""

Shortly after emailing [EMAIL PROTECTED] I had an extremely polite reply 
from Fred Drake thanking me for the suggestion and agreeing to make the 
suggested change.

I don't know what stops people from jumping in with both feet, but it 
certainly isn't the unapproachability of the documentation team - all 
one of him.

> It doesn't seem like much, but as Paul Rubin mentioned, most people who 
> find bugs/unclear passages in the docs aren't scanning the docs 
> explicitly to edit them - they've uncovered the bug after working on 
> some other project, and likely only after banging their head against the 
> wall a few times trying to get it to work. If they have to go through 
> the song and dance of signing up for another website to report the 
> problem, they might just say "forget it."
> 
I can understand people's recitence, so *maybe* it would be better if 
the request for contributions clearly stated that amendments in plain 
text would be welcomed. Having done a bit of writing myself I am pretty 
sure that Fred would have to spend far less time deciding how to mark up 
some intelligent reader's plain text revisions than he would having to 
express the same thoughts coherently himself.

The developers have full-time jobs as well, so everything we can do to 
help them (I have had sourceforge commit rights in the past but I 
recently gave them up and never really regarded myself as a "developer") 
will give them more time to focus on improving the language.

> Sure, it's not hard to sign up for Sourceforge, but even a little 
> barrier can stop you from contributing if you're not enthusiastic about 
> it in the first place.
> 
I refuse to believe that it's harder to sign up for Sourceforge than it 
is to post a bitching comment on c.l.py. This is not to say that it 
couldn't be easier to contribute change suggestions to the docs, but I 
still believe that most of the bitching and moaning comes from people 
who'd rather bitch and moan than roll their sleeves up.

Otherwise it wouldn't have taken me three years to offload the PyCon 
chair (thanks, Andrew :-)

> Something a simple as allowing doc bugs to be submitted from a webform 
> w/o login would reduce the barrier to contribute. - Increasing the size 
> of the "About" text wouldn't hurt either. (To be honest, I've never 
> noticed that text before, and it never occurred to me look at the 
> "About" page for information on error reports.)
> 
So, probably the best outcome of this current dialogue would be a change 
to the bottom-of-page comment so instead of saying

"""Release 2.4, documentation updated on 29 November 2004.
See About this document... for information on suggesting changes. """

it said

"""Release 2.4, documentation updated on 29 November 2004.
See About this document... for information on suggesting changes, or 
mail your suggestions to [EMAIL PROTECTED]"""

> That said, I think the Python manuals are great. But saying that they 
> are perfect, or that the editing process couldn't be improved is just 
> deluding yourself.

Well I make a habit of deluding myself. The world is a beautiful place, 
every reader of c.l.py has my welfare at heart, and even Perl 
programmers will learn better in time; and all contributors who debate 
this topic will be happy to volunteer to help process the additional 
mails that would result from the suggested change.

I'll just point to my book and my three years as PyCon chair as an 
excuse for not getting off my butt in this particular instance :-)

with-a-sense-of-community-ly y'rs  - steve

PS Anyone who contributes will also have the delight of being able to 
point to their name at http://docs.python.org/acks.html. I was surprised 
to find I made it on that list just for a suggestion, way before I took 
on the task of documenting asyncore and asynchat.
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: global interpreter lock

2005-09-01 Thread Mike Meyer
Bryan Olson <[EMAIL PROTECTED]> writes:
> Mike Meyer wrote:
>  > Bryan Olson writes:
>  >>System support for threads has advanced far beyond what Mr. Meyer
>  >>dealt with in programming the Amiga.
>  >
>  > I don't think it has - but see below.
>  >
>  >>In industry, the two major camps are Posix threads, and Microsoft's
>  >>Win32 threads (on NT or better).  Some commercial Unix vendors have
>  >>mature support for Posix threads; on Linux, the NPTL is young but
>  >>clearly the way to move forward.
>  >
>  > I haven't looked at Win32 threading. Maybe it's better than Posix
>  > threads. Sure, Posix threads is better than what I dealt with 10 years
>  > ago, but there's no way I'd call it "advanced beyond" that model. They
>  > aren't even as good as the Python Threading/Queue model.
> With Python threads/queues how do I wait for two queues (or
> locks or semaphores) at one call? (I know some methods to
> accomplish the same effect, but they suck.)

By "not as good as", I meant the model they provide isn't as managable
as the one provided by Queue/Threading. Like async I/O,
Queue/Threading provides a better model at the cost of
generality. There are things it doesn't do well, and others it doesn't
do at all. If it didn't have those problems, I wouldn't be looking for
alternatives.

>  >>Java and Ada will wrap the native thread package, which
>  >>C(++) offers it directly.
>  > Obviously, any good solution will wrap the native threads [...]
> I recommend looking at how software that implements
> sophisticated services actually words. Many things one
> might think to be obvious turn out not to be true.

Instead of making vague assertions, why don't you provide us with
facts? I.e. - what are the things you think are obvious that turned
out not to be true? Name some software that implements sophisticated
services that we can go look out. And so on...

   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: descriptors for container items

2005-09-01 Thread Terry Reedy

"Brock Filer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> countries['us']['Colorado']['Denver']['@population']
>
> This is going to be used in user-input formulae, so I'm willing to do a
> lot of work for minor beautifications. I'd like to be able to say (I
> know, the quotes are still ugly, but at least you save a bracket):
>
> countries/'us'/'Colorado'/'Denver'/'@population'
>
> That's easy to do with a __div__ method, but it only works for getting,
> not setting or deleting.
>
> I'd appreciate any thoughts on this problem.

I personally would first try to dump the quotes and use standard 
attributes --  countries.us.Colorado... -- and the  __get/set/delattr__ 
methods.

> I keep thinking descriptors might be involved somehow in the solution,
> but I may be on a completely wrong track.

As far as I know, 'descriptor' is a behind-the-scenes concept, not 
something you directly program with.  Perhaps you meant 'property'. 
However, properties are fixed in number when you create the class.

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bug in string.find

2005-09-01 Thread Terry Reedy

"Ron Adam" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Fredrik Lundh wrote:
>> Ron Adam wrote:
>>>The problem with negative index's are that positive index's are zero
>>>based, but negative index's are 1 based.  Which leads to a non
>>>symmetrical situations.
>>
>> indices point to the "gap" between items, not to the items themselves.
>
> So how do I express a -0?

You just did ;-) but I probably do not know what you mean.

>  Which should point to the gap after the last  item.

The slice index of the gap after the last item is len(seq).

>> straight indexing returns the item just to the right of the given gap 
>> (this is
>> what gives you the perceived assymmetry), slices return all items 
>> between
>> the given gaps.
>
> If this were symmetrical, then positive index's would return the value
> to the right and negative index's would return the value to the left.

As I posted before (but perhaps it arrived after you sent this), one number 
indexing rounds down, introducing a slight asymmetry.

> Have you looked at negative steps?  They also are not symmetrical.

???

> All of the following get the center 'd' from the string.
>
> a = 'abcdefg'
> print a[3] # d   4 gaps from beginning
> print a[-4]# d   5 gaps from end

It is 3 and 4 gaps *from* the left and right end to the left side of the 
'd'.  You can also see the asymmetry as coming from rounding 3.5 and -3.5 
down to 3 and down to -4.

> print a[3:4]   # d
> print a[-4:-3] # d

These are is symmetric, as we claimed.

> print a[-4:4]  # d

Here you count down past and up past the d.

> print a[3:-3]  # d

Here you count up to and down to the d.  The count is one more when you 
cross the d than when you do not.  You do different actions, you get 
different counts.  I would not recommend mixing up and down counting to a 
beginner, and not down and up counting to anyone who did not absolutely 
have to.

> print a[3:2:-1]# d   These are symetric?!
> print a[-4:-5:-1]  # d
> print a[3:-5:-1]   # d
> print a[-4:2:-1]   # d

The pattern seems to be: left-gap-index : farther-to-left-index : -1 is 
somehow equivalent to left:right, but I never paid much attention to 
strides and don't know the full rule.

Stride slices are really a different subject from two-gap slicing.  They 
were introduced in the early years of Python specificly and only for 
Numerical Python.  The rules were those needed specificly for Numerical 
Python arrays.  They was made valid for general sequence use only a few 
years ago.  I would say that they are only for careful mid-level to expert 
use by those who actually need them for their code.

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SpamBayes wins PCW Editors Choice Award for anti-spam software.

2005-09-01 Thread Mike Meyer
Alan Kennedy <[EMAIL PROTECTED]> writes:
> [Tony Meyer]
>> Should the Python developers likewise get some cryptic name?
> No, they'll always be the python-dev cabal to me.

And here I thought I was dealing with the SMOP.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'isa' keyword

2005-09-01 Thread D H
talin at acm dot org wrote:
> Although I realize the perils of even suggesting polluting the Python
> namespace with a new keyword, I often think that it would be useful to
> consider defining an operator for testing whether or not an item is a
> member of a category.

It's a good idea but not likely to be added to python, at least not til 
python 3000 comes out with type checking.  The default way is "if 
isinstance(image, jpeg)".
Also there is "if image |isa| jpeg:" using one of the various python 
hacks out there:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/384122

But since Python doesn't have interfaces or type checking today, there 
really is not much need for isa or isinstance anyway, but you might use 
hasattr or try/except instead: http://www.canonical.org/~kragen/isinstance/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Mike Meyer
Asbjørn Sæbø <[EMAIL PROTECTED]> writes:
> "Xah Lee" <[EMAIL PROTECTED]> writes:
>> I'm very sorry to say, that the Python doc is one of the worst possible
>> in the industry. [...]
> I suppose you are going to volounteer to fix it, then.  Right?

He once did, for one part of it. The problem he ran into was that he
was the only person who thought his version was an improvement.

He knows what constitutes good writing - or at least he knows how to
quote rules that produce good writing. Unfortunately, he doesn't seem
to be able to follow them. On top of it, his writings are typically
strewn with errors. He really needs to find somebody proof-read his
documents.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Proposal: add sys to __builtins__

2005-09-01 Thread MrJbQ7
Steve Holden wrote:
> I wonder if it would be worth special-casing the AttributeError [snip]

What is it that Tim Peters said? "Special cases aren't special
enough..."

Besides, a better way is to use your ~/.pythonrc file for customizing
according to your needs.

A simple:

  echo "import sys, os" >> ~./pythonrc

will do the job.

Thanks,
John Benediktsson

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Mike Meyer
"Terry Reedy" <[EMAIL PROTECTED]> writes:
> "Rocco Moretti" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> There is just one giant roadblock to that suggestion - Sourceforge
>> requires a login to post bugs/patches.
>
> After reading this and the rest of your post, and remembering others like 
> it, I decided this maybe is a real point.  Remembering that the site 
> invited emailed doc comments, I rechecked the About this Document page 
> referenced at the bottom of each doc page and found the following:
>
> "General comments and questions regarding this document should be sent by 
> email to [EMAIL PROTECTED] If you find specific errors in this document, 
> either in the content or the presentation, please report the bug at the 
> Python Bug Tracker at SourceForge."
>
> So I emailed a general suggestion (with specific wording ;-) that error 
> reports also be allowed via email -- and quoted your post to explain why.

How about extending that, and bundle a tool with python that helps a
user send a properly-formatted bug report, with prompts for all the
relevant information? This combines the nice feature of the web form -
that you get some control over the format of the report - with ease of
use.

FreeBSD, for instance, comes with the "send-pr" command, which fires
up $VISUAL on a bug report template that it's already partially filled
out from the environment. See http://tinyurl.com/7anxz > for the
man page.

That's probably not appropriate for Python. But the idea still seems
like something worthwhile to add.

   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Proposal: add sys to __builtins__

2005-09-01 Thread Steve Holden
Rick Wotnaz wrote:
> Michael Hoffman <[EMAIL PROTECTED]> wrote in
> news:[EMAIL PROTECTED]: 
> 
> 
>>What would people think about adding sys to __builtins__ so that
>>"import sys" is no longer necessary? This is something I must
>>add to every script I write that's not a one-liner since they
>>have this idiom at the bottom:
>>
>>if __name__ == "__main__":
>> sys.exit(main(sys.argv[1:]))
>>
>>Additionally, the necessity of "import sys" makes some
>>one-liners a little more unwieldy than they should be--it is
>>surely the module I am missing the most in one-liners. For
>>example, with this proposal, this inelegant one-liner:
>>
>>$ python -c "import sys; print
>>''.join(sorted(sys.stdin.readlines()))" 
>>
>>could be replaced by:
>>
>>$ python -c "print ''.join(sorted(sys.stdin.readlines()))"
>>
>>Since sys is surely the most commonly used module (it is
>>imported in 108 of 188 Python 2.4 stdlib modules on my system,
>>and certainly more than any other module), I would hope few
>>people would be affected by a namespace collision.
>>
>>Other languages (e.g. C#) always make their system namespace
>>available without needing a special import.
>>
>>In short, given the wide use of sys, its unambiguous nature, and
>>the fact that it really is built-in already, although not
>>exposed as such, I think we would be better off if sys were
>>always allowed even without an import statement.
> 
> 
> +1 here. As far as I'm concerned, both os and sys could be special-
> cased that way. That said, I would guess the likelihood of that 
> happening is 0. 
> 
I wonder if it would be worth special-casing the AttributeError 
exception handling at the outermost lexical scope to try and import a 
module with the troublesome name and then retrying the attribute access 
if the import succeeded (possibly even from a path limited to the 
standard locations).

That way none of the standard library modules would need to be imported 
before use.

I can see that this would create problems as well as solving some, but 
it would be nice not to have to import the standard library modules. I 
don't personally find it a hardship, but some people do.

though-i-could-just-be-raving-ly y'rs  - steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pain

2005-09-01 Thread James Stroud

On Thursday 04 August 2005 07:49 am, projecktzero wrote:
> "a manager telling me what tools to use to do my job is a bad
> manager by definition because he should realize that the people who
> best
> know what tools to use are the peope who use the tools*."
>
> I'm sorry, this doesn't make much sense to me. In an ideal world where
> all developers are all knowing and know every language inside and out,
> then allowing each developer to choose his tools(languages) would work.
> You don't see a problem with programmer Joe using Perl, Brad using
> Python, Carl uses Smalltalk, Nate uses Java, Steve using Ruby, and Ed
> using Haskell?

A library could be written in python and interfaced in java for others to use 
who are too lazy to know both.

> "* Did you know that most good chef cooks have their own knive set?
> And what do you think is the reason a restaurant manager don't tell
> them
> to use the company in-house Amefa blades instead of his global knives?
> "
>
> This is a very poor analogy. The next chef doesn't have to re-cook what
> the previous chef has done(well, that didn't work either)...er...This
> has nothing to do with programming.
>
> The manager may have his reasons for choosing the tools.

Reason: ignorance.

> Perhaps nearly 
> all projects that have been developed and are in development are using
> paticular tools. It's easy for team members to work on any project.(I'm
> speaking more of languages and frameworks not down to the editors and
> IDEs.) It would be nice if the team could decide on tools, and
> sometimes that's appropriate. Maybe they want to migrate to a new
> language or framework. Maybe there's a throw away project that could be
> a test for the new language or framework. If you want to try a
> new/different language, you need to show the benefit other than "it's
> cool/new".

A manager insisting on java is probably only thinking about name recognition 
anyway. Hey Mr. Client, were using java. Isn't that "cool"?



-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cgi, reusing html. common problem?

2005-09-01 Thread Steve Holden
John M. Gabriele wrote:
> I'm putting together a small site using Python and cgi.
> 
> (I'm pretty new to this, but I've worked a little with
> JSP/servlets/Java before.)
> 
> Almost all pages on the site will share some common (and
> static) html, however, they'll also have dynamic aspects.
> I'm guessing that the common way to build sites like this
> is to have every page (which contains active content) be
> generated by a cgi script, but also have some text files
> hanging around containing incomplete html fragments which
> you read and paste-in as-needed (I'm thinking:
> header.html.txt, footer.html.txt, and so on).
> 
> Is that how it's usually done? If not, what *is* the
> usual way of handling this?
> 
There are a million ways to solve this particular problem, despite 
Python's "TSBOAPOOOWTDI" (see "import this") philosophy (because the 
philosophy is addressing primitive programming rather than application 
frameworks).

You could do something as simple as writing a module "webPage" that 
defines a function page(path, content) that does something along the 
lines of:

def page(path, content):
 return """\

If you want titles, add another argument



%s


""" % content

Then in your generation routines you can build up content in the 
traditional way by generating individual fragments of HTML and appending 
them to a list. So you start with

content = []

then for every fragment you generate you do

content.append(fragment)

and finally your content is generated with something like

content = webPage.page("siteroot/subdir/page1.html", "".join(content))

If you don't care that a page contains a navbar link to itself (a sign 
of web immaturity, but by no means inexcusable) then you don't even need 
to pass the page's path into the function.

Hope this gives you a few ideas. This problem has been considered by 
many people, but clearly no outstanding solution has yet been devised, 
otherwise we'd all be using it.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The penis is way too delicate for masturbation

2005-09-01 Thread Steve Holden
Ilya the Recusant wrote:
> In a not so bright galaxy nowhere near intelligent space, "Eve S."
> <[EMAIL PROTECTED]> wrote:
> 
>><[EMAIL PROTECTED]> schreef in bericht
>>news:[EMAIL PROTECTED]
>>
>>>.
>>>
>>
>>A decent amount of gentle sucking on the other hand never goes amiss.
> 
> 
> Must...not...make...joke...
> 
> 
> Ilya the Recusant
> -
> "Asshole" has a special place in my childhood, the point at which I
> first learned that typical Americans were assholes.
>  - C&J

Thank God they aren't all typical if that's the case. Personally I find 
that most individuals, no matter how misguided, have their hearts in the 
right place.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'isa' keyword

2005-09-01 Thread Steve Holden
phil hunt wrote:
> On 1 Sep 2005 00:52:54 -0700, talin at acm dot org <[EMAIL PROTECTED]> wrote:
> 
>>The "isa" operator would of course be overloadable, perhaps by an
>>accessor functions called __isa__, which works similarly to
>>__contains__. The potential uses for this are not limited to
>>isinstance() sugar, however. For example:
>>
>>   if image isa gif:
>>   elif image isa jpeg:
>>   elif image isa png:
> 
> 
> What's wrong with:
> 
> if image.isa(gif):
> elif image.isa(jpeg):
> elif image.isa(png):
> 
> In short, I see no need to add further complexity to Python's 
> grammar.
> 
> It could be argued of course, that an OOPL should allow methods to 
> be sent with a grammar:
> 
>receiver selector argument
> 
> (which is almost what Smalltalk does), but you're not arguing for 
> that (and I'm not sure it would work with the rest of python's 
> grammar).
> 
Even if it did it might mangle operator precedence in the same way 
SmallTalk did, which I always felt was one of the least attractive 
features" of the language.

I don't think a change to a message-passing paradigm would necessarily 
benefit Python at this stage. Some people are still under the 
misapprehension that message-passing is a fundamental of object-oriented 
programming because of Smalltalk, but they are wrong.

The addition of an "isa" operator would be an unnecessary addition of 
pure syntactic sugar.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


descriptors for container items

2005-09-01 Thread Brock Filer
... or something like that.

I have an XMLish data structure whose nodes'  __get/set/del item__ 
methods resolve as:

node['foo'] -> node.children['foo']
node['@bar'] -> node.attributes['bar']

so you can say:

countries['us']['Colorado']['Denver']['@population']

This is going to be used in user-input formulae, so I'm willing to do a 
lot of work for minor beautifications. I'd like to be able to say (I 
know, the quotes are still ugly, but at least you save a bracket):

countries/'us'/'Colorado'/'Denver'/'@population'

That's easy to do with a __div__ method, but it only works for getting, 
not setting or deleting.

I'd appreciate any thoughts on this problem. I keep thinking 
descriptors might be involved somehow in the solution, but I may be on 
a completely wrong track.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python doc problems example: gzip module

2005-09-01 Thread pspierce

Peter Maas wrote:

> Xah Lee schrieb:
> > today i need to use Python to decompress gzip files.
> >
> > since i'm familiar with Python doc and have 10 years of computing
> > experience with 4 years in unix admin and perl, i have quickly located
> > the official doc:
> >
> >  http://python.org/doc/2.4.1/lib/module-gzip.html
> >
> > but after a minute of scanning, please someone tell me what the fuck is
> > it talking about?
> >
> > Fuck the Python programing morons.
> >
> > Thanks.
> >
> > I just need to decompress files. Is it:
> >
> > import gzip;
> > gzip.GzipFile("/Users/xah/access_log.1.gz");
> >
> > can someone put a example into that fucking doc so that people don't
> > have to wade thru whatever fuck it is trying to sound big?
>
> Here's the example:
> import gzip
>
> # read fucked
> fuckedfile = gzip.GzipFile('somefile.gz')
> content = fuckedfile.read()
> fuckedfile.close()
>
> # write unfucked
> unfuckedfile = file('somefile','w')
> unfuckedfile.write(content)
> unfuckedfile.close()
>
> Please feel free to insert this fucking example into the fucking docs.
>
> Have a nice ... eh fucking day :)
>
> --
> ---
> Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
> E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
> ---

The word has now completely lost any meaning for me.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bug in string.find

2005-09-01 Thread Ron Adam
Fredrik Lundh wrote:
> Ron Adam wrote:
> 
> 
>>The problem with negative index's are that positive index's are zero
>>based, but negative index's are 1 based.  Which leads to a non
>>symmetrical situations.
> 
> 
> indices point to the "gap" between items, not to the items themselves.

So how do I express a -0?  Which should point to the gap after the last 
item.


> straight indexing returns the item just to the right of the given gap (this is
> what gives you the perceived assymmetry), slices return all items between
> the given gaps.


If this were symmetrical, then positive index's would return the value 
to the right and negative index's would return the value to the left.

Have you looked at negative steps?  They also are not symmetrical.

All of the following get the center 'd' from the string.

a = 'abcdefg'
print a[3] # d   4 gaps from beginning
print a[-4]# d   5 gaps from end
print a[3:4]   # d
print a[-4:-3] # d
print a[-4:4]  # d
print a[3:-3]  # d
print a[3:2:-1]# d   These are symetric?!
print a[-4:-5:-1]  # d
print a[3:-5:-1]   # d
print a[-4:2:-1]   # d

This is why it confuses so many people.  It's a shame too, because slice 
objects could be so much more useful for indirectly accessing list 
ranges. But I think this needs to be fixed first.

Cheers,
Ron














-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cgi, reusing html. common problem?

2005-09-01 Thread John M. Gabriele
On Thu, 01 Sep 2005 19:10:14 +0200, Walter Dörwald wrote:

> John M. Gabriele wrote:
> 
>> I'm putting together a small site using Python and cgi.
>> 
>> (I'm pretty new to this, but I've worked a little with
>> JSP/servlets/Java before.)
>> 
>> Almost all pages on the site will share some common (and
>> static) html, however, they'll also have dynamic aspects.
>> I'm guessing that the common way to build sites like this
>> is to have every page (which contains active content) be
>> generated by a cgi script, but also have some text files
>> hanging around containing incomplete html fragments which
>> you read and paste-in as-needed (I'm thinking:
>> header.html.txt, footer.html.txt, and so on).
>> 
>> Is that how it's usually done? If not, what *is* the
>> usual way of handling this?
> 
> I don't know if it's the *usual* way, but you could give XIST a try 
> (http://www.livinglogic.de/Python/xist). It was developed for exactly 
> this purpose: You implement reusable HTML fragments in Python and you 
> can use any kind of embedded dynamic language (PHP and JSP are supported 
> out of the box).
> 
> Bye,
> Walter Dörwald

Thanks Walt. :) Though, it seems simpler to me to just stick with some
plain vanilla static html, and pull that in to my cgi scripts as
necessary.

---John

-- 
--- if contacting via email, remove zees ---


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cgi, reusing html. common problem?

2005-09-01 Thread John M. Gabriele
On Thu, 01 Sep 2005 13:12:14 +0100, Fuzzyman wrote:

> On Thu, 01 Sep 2005 03:10:07 -0400, "John M. Gabriele"
> <[EMAIL PROTECTED]> wrote:
> 
>>I'm putting together a small site using Python and cgi.
>>
>>(I'm pretty new to this, but I've worked a little with
>>JSP/servlets/Java before.)
>>
>>Almost all pages on the site will share some common (and
>>static) html, however, they'll also have dynamic aspects.
>>I'm guessing that the common way to build sites like this
>>is to have every page (which contains active content) be
>>generated by a cgi script, but also have some text files
>>hanging around containing incomplete html fragments which
>>you read and paste-in as-needed (I'm thinking:
>>header.html.txt, footer.html.txt, and so on).
>>
>>Is that how it's usually done? If not, what *is* the
>>usual way of handling this?
>>
> 
> Having a template and inserting dynamic values into it is very common.
> 
> You'll have more luck looking for  'python templating systems'.
> 
> I use a module called 'embedded code' - which is part of firedrop by
> Hans Nowak. See http://www.voidspace.org.uk/python/firedrop2/
> 
> Popular templating engines include Cheetah and TAL.
> 
> You can also roll your own basic one using the string method
> ``replace``. 


Thanks for the reply Fuzzy.

I'm going to try rolling my own. I found this *great* article:
http://www.devshed.com/index2.php?option=content&task=view&id=198&pop=1&page=0&hide_js=1

and it shows pretty much exactly what I think I want: separate
html files containing fragments of a complete page, then some
python code to read in the html fragment, and replace your
generated code with some placeholder.


> 
> I'm pretty sure their is an entry on the Python.org WIKI about
> templating.

Whoops. I ended up hitting this page first:
http://wiki.python.org/moin/CgiScripts
and now I'm sticking with it. :)

I like CGI. I want to keep things as simple as possible. :)

---John


> 
> All the best,
> 
> Fuzzy
> http://www.voidspace.org.uk/python
> 
> 
>>Thanks,
>>---John

-- 
--- if contacting via email, remove zees ---


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cgi, reusing html. common problem?

2005-09-01 Thread John M. Gabriele
On Thu, 01 Sep 2005 09:20:51 +0200, Diez B. Roggisch wrote:

> John M. Gabriele wrote:
>> I'm putting together a small site using Python and cgi.
>> 
>> (I'm pretty new to this, but I've worked a little with
>> JSP/servlets/Java before.)
>> 
>> Almost all pages on the site will share some common (and
>> static) html, however, they'll also have dynamic aspects.
>> I'm guessing that the common way to build sites like this
>> is to have every page (which contains active content) be
>> generated by a cgi script, but also have some text files
>> hanging around containing incomplete html fragments which
>> you read and paste-in as-needed (I'm thinking:
>> header.html.txt, footer.html.txt, and so on).
>> 
>> Is that how it's usually done? If not, what *is* the
>> usual way of handling this?
> 
> The basic idea is correct - but there are sooo many other people that 
> had the same problem, and thus they creted web-framworks like e.g. 
> CherryPy or Django or... and then there is ZOPE. Search this group for 
> webframeworks, and you might get more answers than you wanted :)
> 
> Diez


Thanks Diez. Glad to hear I'm on the right track. :)

>From poking around, it looks to me like these Python web
frameworks are to Python as JSP is to Java.

I really don't want to use a "templating language" (a la
JSP) -- I was hoping to just stick with straight Python
and then also html + css. Though I've heard good things
about CherryPy.

Looks like mod_python also comes with it's own solution too:
http://www.onlamp.com/pub/a/python/2004/02/26/python_server_pages.html



-- 
--- if contacting via email, remove zees ---


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTML tags optimization [ interesting problem]

2005-09-01 Thread Sybren Stuvel
DENG enlightened us with:
> i use SGMLParser to process HTML files, in order to do some
> optimizations,
>
> something like this:
>
>TEXT1TEXT2
>
> optimise to
>
>TEXT1TEXT2

Why not optimize it to:

TEXT1
TEXT2?

> [ snipped stuff about  tags ]

If you're serious about using HTML, I suggest you read a book that's
not ten years old.

> anyone can give me some advices?

Yes, read the following:

http://www.w3.org/QA/Tips/
http://www.w3.org/TR/CSS21/
http://www.w3.org/TR/xhtml1/
http://validator.w3.org/

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Sybren Stuvel
Bryan Olson enlightened us with:
> > Why don't you help us by improving the documentation?
>
> Workin' on it.

That's all I needed to know ;-)

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: named pipe input

2005-09-01 Thread Donn Cave
In article <[EMAIL PROTECTED]>,
 "max(01)*" <[EMAIL PROTECTED]> wrote:

> i have some problems understanding following behaviour.
> 
> consider this:

> $ cat file_input_3.pl
> #!/usr/bin/perl
> 
> open MIAPIPE, "una_pipe";
> 
> while ($riga = )
...

> $ cat file_input_3.py
> #!/usr/bin/python
> 
> import sys
> 
> MIAPIPE = open("una_pipe", "r")
> 
> for riga in MIAPIPE:

...
> BUT if i try to do the same with the python code, something different 
> happens: i have to type ALL the lines on console #2 and complete the cat 
> command (ctrl-d) before seeing the lines echoed on console #1.


Seems to me something like this came up here
not long ago.  It turns out that

  for line in file:

doesn't do the same thing as Perl's

   while ($line = )

If you use file.readline() instead (in a loop,
of course, I think you'll get the data one line
at a time, but "in file" apparently reads the
whole file first.  That's what I vaguely remember,
I don't use it myself.

   Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 'isa' keyword

2005-09-01 Thread phil hunt
On 1 Sep 2005 00:52:54 -0700, talin at acm dot org <[EMAIL PROTECTED]> wrote:
>
>The "isa" operator would of course be overloadable, perhaps by an
>accessor functions called __isa__, which works similarly to
>__contains__. The potential uses for this are not limited to
>isinstance() sugar, however. For example:
>
>if image isa gif:
>elif image isa jpeg:
>elif image isa png:

What's wrong with:

if image.isa(gif):
elif image.isa(jpeg):
elif image.isa(png):

In short, I see no need to add further complexity to Python's 
grammar.

It could be argued of course, that an OOPL should allow methods to 
be sent with a grammar:

   receiver selector argument

(which is almost what Smalltalk does), but you're not arguing for 
that (and I'm not sure it would work with the rest of python's 
grammar).

-- 
Email: zen19725 at zen dot co dot uk


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: telnet.read_until() from telnetlib

2005-09-01 Thread [EMAIL PROTECTED]
then you are using a regex expression that is a wildcard match, and
that is non-deterministic.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread A.M. Kuchling
On Thu, 1 Sep 2005 17:09:27 +0200, 
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> the useredit approach I'm using over at the librarybook site works
> pretty well.  for example, if you go to

That looks pleasantly simple.

I don't consider the pydoc.amk.ca experiment to have been really successful.
It was a half-hour hack that's usable with some pain, but the JavaScript and
frame display needs quite a bit of polishing to be usable by a random
newbie.

There's a Firefox extension (http://www.wikalong.org/) that allows wiki
annotation, but a browser-specific annotation tool doesn't solve the general
problem.

I suspect the best solution is something Python-doc-specific that runs the
generated HTML for the docs through a preprocessor that inserts comments and
an editing form.  It would be a great topic for a user group sprint or
weekend project.

(If someone volunteers to do this: if you decide to use an RDBMS, please use
PostgreSQL, because it's already installed on one of the python.org
servers.)

--amk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Add lists to class?

2005-09-01 Thread Bruno Desthuilliers
BBands a écrit :
(snip)
> class master:
> def __init__(self, list):

Don't use 'list' as an identifier, it will shadow the builtin list type.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Improving my text processing script

2005-09-01 Thread Paul McGuire
Yes indeed, the real data often has surprising differences from the
simulations! :)

It turns out that pyparsing LineStart()'s are pretty fussy.  Usually,
pyparsing is very forgiving about whitespace between expressions, but
it turns out that LineStart *must* be followed by the next expression,
with no leading whitespace.

Fortunately, your syntax is really quite forgiving, in that your
key-value pairs appear to always be an unquoted word (for the key) and
a quoted string (for the value).  So you should be able to get this
working just by dropping the LineStart()'s from your expressions, that
is:

identLine=('Identifier'
  + prs.quotedString
  + prs.LineEnd()
  ).setResultsName('prog')


tableLine=('Value'
  + prs.quotedString
  + prs.LineEnd()
  ).setResultsName('table')

See if that works any better for you.

-- Paul

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Add lists to class?

2005-09-01 Thread Michael Ekstrand
On Sep 1, 2005, at 3:18 PM, BBands wrote:
> Something like:
>
> class master:
> def __init__(self, list):
> self.count = len(list)
> for line in list:
> self.line = [] # obviously this doesn't work

No, but this does:

class master:
def __init__(self, lst):
for line in list:
setattr(self, line, [])

 From library reference section 2.1, Built-In Functions:
--8<--
setattr(object, name, value)
This is the counterpart of getattr(). The arguments are an object, a 
string and an arbitrary value. The string may name an existing 
attribute or a new attribute. The function assigns the value to the 
attribute, provided the object allows it. For example, setattr(x, 
'foobar', 123) is equivalent to x.foobar = 123.
--8<--

- Michael

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Add lists to class?

2005-09-01 Thread BBands
tested and working...

jab, now possessing an embarrassment of riches, says "Thanks!"

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python / web

2005-09-01 Thread dimitri pater
On 9/1/05, Larry Bates <[EMAIL PROTECTED]> wrote:
flexibility comes complexity.  For less complex needs there are othermore lightweight things like CherryPy.
Yes, I agree CherryPy is very nice. I am currently updating my site
using CherryPy (and CherryTemplate) and it all works very nice. You'll
learn most of the basic stuff in a day or two. It is not as
sophisticated as Zope I suppose but I do not have the time for the
steep learning curve and my site doesn't just need it. So the choice
does depends on your requirements and the time you are willing to spend
learning it. CherryPy is very nice, try it. Run it on
http://localhost:8080 and just test it.

regards,
dimtiri-- All truth passes through three
stages. First, it is ridiculed. Second, it is violently opposed. Third,
it is accepted as being self-evident.Arthur Schopenhauer -Please visit dimitri's website: www.serpia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Weekly Python Patch/Bug Summary

2005-09-01 Thread Terry Reedy

"Kurt B. Kaiser" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>Patches :  903 open (+551) /  5222 closed (+2324) /  6125 total (+2875)
>Bugs:  903 open (-23) /  5222 closed (+45) /  6125 total (+22)

Something went awry, as the patch totals did not really rise up to exactly 
the bug totals ;-)

Terry J. Reedy





-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Add lists to class?

2005-09-01 Thread Larry Bates
I think what you want is this (not tested):

class master:
def __init__(self, list):
self.count = len(list)
for entry in list:
self.__dict__[entry]= []


This will get you master class with three attributes

a = master(list)

a.one
a.two
a.three

each containing an empty list.  You can then do things
like:

a.one.append(something)
a.three.append(something)

Larry Bates

BBands wrote:
> I have a list with some strings in in it, 'one', 'two' 'three' and so
> on. I would like to add lists to a class with those names. I have no
> way of knowing what will be in the list or how long the list will be in
> advance.
> 
> Something like:
> 
> class master:
> def __init__(self, list):
> self.count = len(list)
> for line in list:
> self.line = [] # obviously this doesn't work
> 
> list = ['one', 'two', 'three']
> 
> a = master(list)
> 
> so that I get:
> 
> dir(a)
> 
> ['_doc__', '_init__', '_module__', 'one', 'two', 'three']
> 
> instead of:
> 
> dir(a)
> 
> ['_doc__', '_init__', '_module__', 'line']
> 
> 
> TIA,
> 
>  jab
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python / web

2005-09-01 Thread Larry Bates
IMHO it all depends on the complexity required by the final product that
you are attempting to create.  For complex projects, it is hard to beat
Zope/Plone.  They have lots of built in things that you don't have to
write and are nearly infinitely extensible.  We recently chose Zope for
a project and have been very happy with the outcome.  With Zope it was
easy to design an AJAX API (connect via XMLRPC) and provide a WebDAV
interface to our applications which would have been extremely hard with
a lighter weight application engine.  The learning curve has been steep,
but no more steep than it would be to do in WebLogic or WebSphere.  With
flexibility comes complexity.  For less complex needs there are other
more lightweight things like CherryPy.

Hope info helps.
Larry Bates

Robert wrote:
> Hi,
> I know general Python pretty well and interested in using Python for a
> web project. It will have the standard display, user input, fields,
> look-ups, reports, database routines, etc. Been looking though the
> Python web docs. and seeing stuff like mod_python, CGI, PSP, CherryPy,
> etc...,  Also a fair amount of googling. I'll say there's a large amount
> of technology to pick from.  Rather than spend time going down  the
> wrong road, can I get some feedback as directions from you folks that's
> "been there, done that."
> 
> thanks a bunch.
> Robert
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Add lists to class?

2005-09-01 Thread BBands
Thanks to a generous Pyhtonista replied with a pointer to setattr().

 jab

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is there a better way to check an array?

2005-09-01 Thread jdonnell
Thanks for all the help everyone.

Steve, sets are perfect. I didn't even realize they existed. Somehow I
completely missed that part of the tutorial. Thanks :)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Michael Sparks
A.M. Kuchling wrote:

> On 1 Sep 2005 05:04:33 -0700,
> Paul Boddie <[EMAIL PROTECTED]> wrote:
>> Please note that I'm not labelling you as a troll.
> 
> No, he's simply barking mad.  I was amused by a rec.arts.sf.written
> discussion [1] where Lee complains that Jonathan Swift (1667-1745)'s
> writing was unclear in style; apparently he's not aware that conventions
> and styles change over time.
> 
> --amk
> 
> [1] http://groups.google.com/group/alt.usage.english/msg/0ec9871395fc90d3

Oddly that makes me wonder if Xah Lee is a some kind of bot - given it
follows a similar fashion:
 
oh, this writing is [criticism] of [ specific]

"the "allow that" should be "allow the notion that". But the 
 whole thing is written in a confounded way. "

Specific grammar correction and note that the grammar subsystem detected too
many errors.

Better: Grammar correction suggestion. Not actually any clearer to many
people. 

more better with logicality: Similar bad parsing. A person would translate
the old style english into a more modern style if what they're doing is
criticising old english.

The whole thing just smacks to me of some text analyser. The final paragraph
contains some standard writing advice and cliches:
   * to write clearly, the first thing is to think clearly
   * get rid of big words and use  short sentences.

It'd certainly explain the online tourettes syndrome of swearing all the way
through a post - the text generator getting stuck on a particular word
sets...

Not-really-seriously :-) 
(Though usenet would be an interesting, if antisocial and annoying place to
test such a beast :-)


Michael.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Improving my text processing script

2005-09-01 Thread pruebauno
[EMAIL PROTECTED] wrote:
> Paul McGuire wrote:
> > match...), this program has quite a few holes.

> tried run it though and it is not working for me. The following code
> runs but prints nothing at all:
>
> import pyparsing as prs
>
And this is the point where I have to post the real stuff because your
code works with the example i posted and not with the real thing. The
identifier I am interested in is (if I understood the the requirements
correctly) the one after the "title with the stars"

So here is the "real" data for tlst some info replaced with z to
protect privacy:

*


   Identifier "zzz0main"


*


   Identifier "zz501"


 Value "zzz_CLCL_,zz_ID"


 Name "z"


 Name "zz"


*


   Identifier "3main"


*


   Identifier "zzz505"


 Value "dba.zzz_CKPY__SUM"


 Name "xxx_xxx_xxx_DT"


--


 Value "zzz__zzz_zzz"


 Name "zzz_zz_zzz"


--


 Value "zzz_zzz_zzz_HIST"


 Name "zzz_zzz"


--


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The penis is way too delicate for masturbation

2005-09-01 Thread Ilya the Recusant
In a not so bright galaxy nowhere near intelligent space, "Eve S."
<[EMAIL PROTECTED]> wrote:
>
><[EMAIL PROTECTED]> schreef in bericht
>news:[EMAIL PROTECTED]
>> .
>>
>
>A decent amount of gentle sucking on the other hand never goes amiss.

Must...not...make...joke...


Ilya the Recusant
-
"Asshole" has a special place in my childhood, the point at which I
first learned that typical Americans were assholes.
 - C&J
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: named pipe input

2005-09-01 Thread max(01)*
Eric Nieuwland wrote:
> max(01)* wrote:
> 
>> $ cat file_input_3.py
>> #!/usr/bin/python
>>
>> import sys
>>
>> MIAPIPE = open("una_pipe", "r")
>>
>> for riga in MIAPIPE:
>>print riga,
>> ...
>> [...]
>> BUT if i try to do the same with the python code, something different
>> happens: i have to type ALL the lines on console #2 and complete the cat
>> command (ctrl-d) before seeing the lines echoed on console #1.
> 
> 
> You could try:
> 
> for riga in MIAPIPE:
> print riga # NO COMMA!
> sys.stdout.flush()
> 

doesn't work! :-(
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Proposal: add sys to __builtins__

2005-09-01 Thread Rick Wotnaz
Michael Hoffman <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> What would people think about adding sys to __builtins__ so that
> "import sys" is no longer necessary? This is something I must
> add to every script I write that's not a one-liner since they
> have this idiom at the bottom:
> 
> if __name__ == "__main__":
>  sys.exit(main(sys.argv[1:]))
> 
> Additionally, the necessity of "import sys" makes some
> one-liners a little more unwieldy than they should be--it is
> surely the module I am missing the most in one-liners. For
> example, with this proposal, this inelegant one-liner:
> 
> $ python -c "import sys; print
> ''.join(sorted(sys.stdin.readlines()))" 
> 
> could be replaced by:
> 
> $ python -c "print ''.join(sorted(sys.stdin.readlines()))"
> 
> Since sys is surely the most commonly used module (it is
> imported in 108 of 188 Python 2.4 stdlib modules on my system,
> and certainly more than any other module), I would hope few
> people would be affected by a namespace collision.
> 
> Other languages (e.g. C#) always make their system namespace
> available without needing a special import.
> 
> In short, given the wide use of sys, its unambiguous nature, and
> the fact that it really is built-in already, although not
> exposed as such, I think we would be better off if sys were
> always allowed even without an import statement.

+1 here. As far as I'm concerned, both os and sys could be special-
cased that way. That said, I would guess the likelihood of that 
happening is 0. 

-- 
rzed
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding bound methods dynamically... CORRECTED

2005-09-01 Thread Bruno Desthuilliers
Kevin Little a écrit :

Oops, sorry, forgot to answer

> '''
> I want to dynamically add or replace bound methods in a class. 
(snip)
> Is there a more pythonic way that's as straight forward?

What's wrong with:

class Foo:
   pass

def method(self):
   print "%s" % self

f = Foo()
Foo.method = method
f.method()
-- 
http://mail.python.org/mailman/listinfo/python-list


Starting twisted service manually

2005-09-01 Thread qvx
I want to start twisted app from another GUI application and not via
twistd.
It works fine when started via twistd (1 & 2) but not when I try to
start it
manually (1 & 3) - nothing is listening to 8080 port.


# (1) common part
from nevow import rend, appserver
from twisted.application import service, internet
from twisted.internet import reactor

class Index(rend.Page):
...


# (2) part used when running via twistd
application = service.Application("my-app")
internet.TCPServer(8080,
appserver.NevowSite(Index(r'D:\www'))).setServiceParent(application)


# (3) attempt to start the same thing but inside a larger (wxPython)
app
def run_in_thread():
def runner():
application = service.Application("my-app")
internet.TCPServer(8080,
appserver.NevowSite(Index(r'D:\www'))).setServiceParent(application)
reactor.run(0)
thread.start_new_thread(runner, ())


I feel lost in twisted documentation and HOWTOs.

Please help!

Qvx

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The penis is way too delicate for masturbation

2005-09-01 Thread Eve S.

<[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
> .
>

A decent amount of gentle sucking on the other hand never goes amiss.





-- 
sexy .sig wanted


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Improving my text processing script

2005-09-01 Thread pruebauno
Paul McGuire wrote:
> match...), this program has quite a few holes.
>
> What if the word "Identifier" is inside one of the quoted strings?
> What if the actual value is "tablename10"?  This will match your
> "tablename1" string search, but it is certainly not what you want.
> Did you know there are trailing blanks on your table names, which could
> prevent any program name from matching?

Good point. I did not think about that. I got lucky because none of the
table names had trailing blanks (google groups seems to add those) the
word identifier is not used inside of quoted strings anywhere and  I do
not have tablename10, but I do have "dba.tablename1" and that one has
to match with tablename1 (and magically did).

>
> So here is an alternative approach using, as many have probably
> predicted by now if they've spent any time on this list, the pyparsing
> module.  You may ask, "isn't a parser overkill for this problem?" and

You had to plug pyparsing! :-). Thanks for the info I did not know
something like pyparsing existed. Thanks for the code too, because
looking at the module it was not totally obvious to me how to use it. I
tried run it though and it is not working for me. The following code
runs but prints nothing at all:

import pyparsing as prs

f=file('tlst'); tlst=[ln.strip() for ln in f if ln]; f.close()
f=file('plst'); plst=f.read()  ; f.close()

prs.quotedString.setParseAction(prs.removeQuotes)

identLine=(prs.LineStart()
  + 'Identifier'
  + prs.quotedString
  + prs.LineEnd()
  ).setResultsName('prog')

tableLine=(prs.LineStart()
  + 'Value'
  + prs.quotedString
  + prs.LineEnd()
  ).setResultsName('table')

interestingLines=(identLine | tableLine)

for toks,start,end in interestingLines.scanString(plst):
print toks,start,end

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Michael Sparks
Hi Paul,


Paul Rubin wrote:
> Michael Sparks <[EMAIL PROTECTED]> writes:
[[[ some random stuff, /intended/ at supporting people who have contributed
  docs, rather than saying people who offer constructive suggestions are
  bad. Possibly badly written. ]]]
> I've submitted a number of doc bugs to sourceforge and the ones that
> are simple errors and omissions do get fixed.  

Cool. 

> However, your 
> suggestion doesn't constitute good Python advocacy, if that's what you
> were attempting.  

Nope. I rarely attempt advocacy because I'd suck at it if I tried (worse
than my docs :), and also I'm not a fan of advocacy anyway - I prefer to
make up my own mind rather than be told. 

> When I use a tool like Python, I like to think I'm 
> working on one project at a time, that project being whatever I'm
> trying to develop.  

> Telling me that whenever I use Python, I should 
> really consider myself to be working on two projects at once

I didn't mean it that way (I probably put it over the wrong way). What I did
mean is that when someone in here says "someone here should make the docs
better", is naturally including themselves in the set of people who can
write docs. If they then attack people who /can/ write docs they're
attacking themselves. 

Stating that something needs writing or updating I'd agree is good. People
whinging because no-one has written it, or constantly dissing docs without
helping improve them strikes me as unfair.

To my mind yourself, Bryan, Steve, Terry and others in the thread contribute
amazingly (and I wish I had more time to do so), by simply being nice and
helpful in *here*.

>> [ O'Reilly, and friends, books as a docs for open source ]
> 
> If those docs aren't free to redistribute, then that's not an
> open-source solution at all; if anything, it's an anti-solution, since
> it decreases the motivation to write good free docs.

OK, it's not the best solution in the world I'll agree, but my point was in
general very few people like writing docs even when paid, let alone when
not. As a result it's not that suprising IMO that if paid you end up with
more docs. 

> Even weirder is the amount of gratis (free as in beer) but unfree (as
> in freedom) docs out there for Python.  

I'm not aware of those, so I don't feel able to comment sensibly.

>> The best way to repay those who have spent the time writing what can
>> be viewed as a first draft is to provide corrections. If you
>> (generic, not just you personally) don't have the time, effort,
>> inclination or effort to summarise and feedback a documentation
>> patch *why should anyone else* ?
> 
> I usually do report doc bugs, but my frustration (and I think Bryan's)
> is that there are so many bugs in the first place.  It means that the
> authors are not applying high enough quality standards to their own
> work before releasing it.  That applies to Python's code as well as
> its docs.  It's not crap,

Or maybe they're just doing their best? It might seem silly but when I do
write docs, personally it takes me around 4-10 times longer to write the
same number of lines as documentation than as code, whilst trying to
maintain a similar quality. I think thats on a good day.

> but it's not at the level that those of us 
> from the non-Windows world like to (realistically or otherwise) expect.

FWIW, I'm not part of the windows crowd. Ceased using windows regularly
around Windows 3.1, and have periodically gone back (95, 98, ME, 2000, XP)
to see whether it's improved, and come to the conclusion for me it's a
downgrade in the way I work. It is sometimes useful for playing DVDs on
long journeys though since the power management works better IME.

[ specific example of bad or missing docs snipped ]

I agree there's always valid criticisms.

> I think there is an attitude problem in the central Python development
> community, which is to expect external volunteers to do stuff with no
> cajoling and no guidance.  That just doesn't work very well.  

I have no idea what to do about that. Giving T-Shirts to people who write a
decent tutorial that covers an entire library module? (Semi-serious if
there's a way of making that work)

> I was the first FSF staff programmer on the GNU project and we spent a LOT
> of our time coordinating volunteers and maintaining lists of tasks to
> recruit people to do, and generally trying to make stuff happen
> according to what we saw as the project's priorities, as opposed to
> simply passively waiting for code and doc contributions to come to us
> fully done.  We also saw doing gap-filling and grunt-work that didn't
> excite volunteers to be an important part of our purpose as paid
> staff: if somebody had to do it and no one volunteered, then the
> somebody was us.

This might sound really dumb, but I'd be genuinely interested to hear more
about how you organised this, how you managed to motivate people to do
these things, what "rewards" the people got for doing this. (Working on the
assumption that rewards

Re: Improving my text processing script

2005-09-01 Thread pruebauno
Miki Tebeka wrote:

> Look at re.findall, I think it'll be easier.

Minor changes aside the interesting thing, as you pointed out, would be
using re.findall. I could not figure out how to.

-- 
http://mail.python.org/mailman/listinfo/python-list


Add lists to class?

2005-09-01 Thread BBands
I have a list with some strings in in it, 'one', 'two' 'three' and so
on. I would like to add lists to a class with those names. I have no
way of knowing what will be in the list or how long the list will be in
advance.

Something like:

class master:
def __init__(self, list):
self.count = len(list)
for line in list:
self.line = [] # obviously this doesn't work

list = ['one', 'two', 'three']

a = master(list)

so that I get:

dir(a)

['_doc__', '_init__', '_module__', 'one', 'two', 'three']

instead of:

dir(a)

['_doc__', '_init__', '_module__', 'line']


TIA,

 jab

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Equivalent for an internal write in Python ?

2005-09-01 Thread Fredrik Lundh
Madhusudan Singh wrote:

> I am looking to write a formatted string to a string variable :
>
> Say I have 1.067e-01, I need to write 106.700 to some string.
>
> In Fortran 95, this would be accomplished with a :
>
> character(len=7) :: stringvar
> real :: stringval
>
> ...
>
> write(stringvar,'(f7.3)') stringval
>
> How does one do something like this in Python ? I need a string formatted in
> this way for one of my applications.

stringvar = "%.3f" % stringval

for details, see

http://docs.python.org/tut/node9.html
http://docs.python.org/lib/typesseq-strings.html

 



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Equivalent for an internal write in Python ?

2005-09-01 Thread Michael Hoffman
Madhusudan Singh wrote:

> Say I have 1.067e-01, I need to write 106.700 to some string.

Uh, I'm going to assume you meant 1.067e2, because 1.067e-01 != 106.700.

> character(len=7) :: stringvar
> real :: stringval
> 
> ...
> 
> write(stringvar,'(f7.3)') stringval

 >>> stringval = 1.067e2
 >>> stringvar = "%7.3f" % stringval
 >>> stringvar
'106.700'

String formatting is described here:

http://docs.python.org/lib/typesseq-strings.html
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Equivalent for an internal write in Python ?

2005-09-01 Thread Madhusudan Singh
Hi

I am looking to write a formatted string to a string variable :

Say I have 1.067e-01, I need to write 106.700 to some string.

In Fortran 95, this would be accomplished with a :

character(len=7) :: stringvar
real :: stringval

...

write(stringvar,'(f7.3)') stringval

How does one do something like this in Python ? I need a string formatted in
this way for one of my applications.
-- 
http://mail.python.org/mailman/listinfo/python-list


named pipe input

2005-09-01 Thread max(01)*
hi there.

i have some problems understanding following behaviour.

consider this:

...
$ cat file_input_3.pl
#!/usr/bin/perl

open MIAPIPE, "una_pipe";

while ($riga = )
   {
 print STDOUT ("$riga");
   }

$ cat file_input_3.py
#!/usr/bin/python

import sys

MIAPIPE = open("una_pipe", "r")

for riga in MIAPIPE:
   print riga,
...

where una_pipe is a named pipe (created with mkfifo).

when i run this on console #1:

...
$ ./file_input_3.pl
...

and this un console #2:

...
$ cat > una_pipe
aaa
bbb
ccc
...

then each line typed in console #2 appears on console #1 as soon as the 
line is terminated (hit return).

BUT if i try to do the same with the python code, something different 
happens: i have to type ALL the lines on console #2 and complete the cat 
command (ctrl-d) before seeing the lines echoed on console #1.

i tried the -u flag but doesnt seem to work.

any help?

bye
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Terry Reedy

"Paul Rubin" <"http://phr.cx"@NOSPAM.invalid> wrote in message 
news:[EMAIL PROTECTED]
> I think there is an attitude problem in the central Python development
> community, which is to expect external volunteers to do stuff with no
> cajoling and no guidance.

You are correct.  No one has volunteered to be a volunteer volunteer 
coordinator.

 > That just doesn't work very well.

Improvements are possible, certainly.

 > I was
> the first FSF staff programmer on the GNU project and we spent a LOT
> of our time coordinating volunteers and maintaining lists of tasks to
> recruit people to do, and generally trying to make stuff happen
> according to what we saw as the project's priorities, as opposed to
> simply passively waiting for code and doc contributions to come to us
> fully done.  We also saw doing gap-filling and grunt-work that didn't
> excite volunteers to be an important part of our purpose as paid
> staff: if somebody had to do it and no one volunteered, then the
> somebody was us.

As far as I know, there currently is no paid staff for Python.  Everything 
is either volunteer or employer-donated time.  You could suggest that 
someone be paid for a few hours a week of volunteer coordination and 
explain what such work would, concretely, consist of.

>The PSF and the FSF both sometimes fund
> people to do coding projects.  Why does the PSF (apparently) not fund
> anyone to do doc projects, like the FSF does?

Last fall, PSF funded two projects out of many submissions.  Were any doc 
projects submitted.  Perhaps next round, one of us will.  One could also 
send an uninvited proposal.

This summer, Google funded about 18 Python-related Summer of Code student 
projects.  Hmm.  The title does suggest code, not docs.

Terry J. Reedy




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: named pipe input

2005-09-01 Thread Eric Nieuwland
max(01)* wrote:
> $ cat file_input_3.py
> #!/usr/bin/python
>
> import sys
>
> MIAPIPE = open("una_pipe", "r")
>
> for riga in MIAPIPE:
>print riga,
> ...
> [...]
> BUT if i try to do the same with the python code, something different
> happens: i have to type ALL the lines on console #2 and complete the 
> cat
> command (ctrl-d) before seeing the lines echoed on console #1.

You could try:

for riga in MIAPIPE:
print riga # NO COMMA!
sys.stdout.flush()

-- 
http://mail.python.org/mailman/listinfo/python-list


Proposal: add sys to __builtins__

2005-09-01 Thread Michael Hoffman
What would people think about adding sys to __builtins__ so that
"import sys" is no longer necessary? This is something I must add to 
every script I write that's not a one-liner since they have this idiom 
at the bottom:

if __name__ == "__main__":
 sys.exit(main(sys.argv[1:]))

Additionally, the necessity of "import sys" makes some one-liners a 
little more unwieldy than they should be--it is surely the module I am 
missing the most in one-liners. For example, with this proposal, this 
inelegant one-liner:

$ python -c "import sys; print ''.join(sorted(sys.stdin.readlines()))"

could be replaced by:

$ python -c "print ''.join(sorted(sys.stdin.readlines()))"

Since sys is surely the most commonly used module (it is imported in 108 
of 188 Python 2.4 stdlib modules on my system, and certainly more than 
any other module), I would hope few people would be affected by a 
namespace collision.

Other languages (e.g. C#) always make their system namespace available 
without needing a special import.

In short, given the wide use of sys, its unambiguous nature, and the 
fact that it really is built-in already, although not exposed as such, I 
think we would be better off if sys were always allowed even without an 
import statement.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Terry Reedy

"Rocco Moretti" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> There is just one giant roadblock to that suggestion - Sourceforge
> requires a login to post bugs/patches.

After reading this and the rest of your post, and remembering others like 
it, I decided this maybe is a real point.  Remembering that the site 
invited emailed doc comments, I rechecked the About this Document page 
referenced at the bottom of each doc page and found the following:

"General comments and questions regarding this document should be sent by 
email to [EMAIL PROTECTED] If you find specific errors in this document, 
either in the content or the presentation, please report the bug at the 
Python Bug Tracker at SourceForge."

So I emailed a general suggestion (with specific wording ;-) that error 
reports also be allowed via email -- and quoted your post to explain why.

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python C module questions

2005-09-01 Thread Thomas Heller
Robert Kern <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED] wrote:
>> Hi,
>> 
>> I'm rather new to Python, and I've just written my first Python C
>> module.  I was wondering if some more experience Pythonista would look
>> over what I've written and given me some pointers (or find some bugs).
>> I had a few questions while writing this as well.
>> 
>> Also, I know that there are much better ways to compute nearest
>> neighbors than the brute force n^2 method, but this is plenty fast for
>> this application (at least the C version is).

You should give up C with a dumb algorithm running at fast speed.
Implement a better algorithm in Python, maybe you can even outperform
the dumb code.

>> 1.  How do I add docstrings to my module?
>
> You mean a docstring on the module object itself? In initmodule() make a
> string object with the contents of the docstring and assign it to
> module.__doc__ . There might be a more idiomatic way, but I can't think
> of it without trawling through the docs.

Use Py_InitModule3() instead.

Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing Multithreaded Client-Server in Python.

2005-09-01 Thread Paul Rubin
[EMAIL PROTECTED] writes:
> > I suspect he was trying to say that BaseHTTPServer has no mechanism for
> > handling state. As you know, of course, this is most relevant across
> > multiple successive connections to a server from the same client, and
> > has little to do with threads.

Usually you would do that with browser cookies.

> Correct. My own 'brew' is multi-session-clients enabled (in fact I test
> with two applets from the same PC) but indeed I used confusing language
> saying 'client' for 'session'.
>
> Again: ThreadingMixIn doesn't give you 'session threads' in which you
> store persistent information - a candidate for some generic extension
> of SocketServer ?

What exactly do you mean by session?  Let's say the client does
the following:

   1. Sends 
 GET /abcde HTTP/1.1
 Connection: Keep-Alive
  and downloads the abcde page

   2. Sends
GET /fghij HTTP/1.1
  and downloads the fghij page, re-using the TCP connection from step 1

   3. Opens a completely new TCP connection and sends
   GET /klmno HTTP/1.1
  through the new connection, and downloads klmno through that
  connection.

How many sessions took place here?  It sounds like you want the answer
to be one session, that operations 2 and 3 are part of the same session.
But that makes no sense unless you associate them somehow, say using
a client cookie and a global session table indexed by the cookie.

Why don't you take a look at any of the web frameworks that get
discussed here (Spyce, CherryPy, Zope, Django, whatever).  They all
have mechanisms like that.   BaseHTTPServer doesn't try to operate
at that level.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python C module questions

2005-09-01 Thread Robert Kern
[EMAIL PROTECTED] wrote:
> Hi,
> 
> I'm rather new to Python, and I've just written my first Python C
> module.  I was wondering if some more experience Pythonista would look
> over what I've written and given me some pointers (or find some bugs).
> I had a few questions while writing this as well.
> 
> Also, I know that there are much better ways to compute nearest
> neighbors than the brute force n^2 method, but this is plenty fast for
> this application (at least the C version is).
> 
> 1.  How do I add docstrings to my module?

You mean a docstring on the module object itself? In initmodule() make a
string object with the contents of the docstring and assign it to
module.__doc__ . There might be a more idiomatic way, but I can't think
of it without trawling through the docs.

> 2.  The Python reference counting and memory managment seemes awfully
> repetetive and error prone.  Is there a nicer way of doing this?  I
> know there are some wrappers out there such as Pyrex and SWIG that
> might prove useful.

I'm quite a fan of Pyrex. You may also want to give ctypes a shot. SWIG
doesn't help as much with the reference counting

> 3.  This module consisted of turning 4 Python sequences into C double
> arrays, performing some calculations, and then turning a C int array
> into a Python tuple for return.  And it was a lot of work.  Are there
> any nice wrapper functions out there for turning Python sequences into
> C arrays and vice versa?

http://numeric.scipy.org

> Thanks,
> Jeremy Brewer
> 
> The code is below:

You probably shouldn't post such large pieces of code to the list.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python / web

2005-09-01 Thread Jagged
Check out Django:
http://www.djangoproject.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Paul Rubin
"Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> another problem is that to be able to do really good work on the
> documentation, you need to know things well enough to "have the
> big picture".  and once you have that, you'll find that the docs aren't
> really as bad as you once thought they were.

One thing that might help is a comments/questions area on each online
doc page, like PHP has.  That would let users easily point out the
areas where the docs need improvement, and collect wisdom about the
library functions attached to the docs for those functions instead of
getting it lost in clpy archives.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python / web

2005-09-01 Thread Robert
Hi,
I know general Python pretty well and interested in using Python for a 
web project. It will have the standard display, user input, fields, 
look-ups, reports, database routines, etc. Been looking though the 
Python web docs. and seeing stuff like mod_python, CGI, PSP, CherryPy, 
etc...,  Also a fair amount of googling. I'll say there's a large 
amount of technology to pick from.  Rather than spend time going down 
  the wrong road, can I get some feedback as directions from you folks 
that's "been there, done that."

thanks a bunch.
Robert
-- 
http://mail.python.org/mailman/listinfo/python-list


Python C module questions

2005-09-01 Thread jeremy . d . brewer
Hi,

I'm rather new to Python, and I've just written my first Python C
module.  I was wondering if some more experience Pythonista would look
over what I've written and given me some pointers (or find some bugs).
I had a few questions while writing this as well.

Also, I know that there are much better ways to compute nearest
neighbors than the brute force n^2 method, but this is plenty fast for
this application (at least the C version is).

1.  How do I add docstrings to my module?
2.  The Python reference counting and memory managment seemes awfully
repetetive and error prone.  Is there a nicer way of doing this?  I
know there are some wrappers out there such as Pyrex and SWIG that
might prove useful.
3.  This module consisted of turning 4 Python sequences into C double
arrays, performing some calculations, and then turning a C int array
into a Python tuple for return.  And it was a lot of work.  Are there
any nice wrapper functions out there for turning Python sequences into
C arrays and vice versa?

Thanks,
Jeremy Brewer

The code is below:

#include 
#include 
#include 
#include 
#include 

/* xmatch: Takes 2 sets of positions (ra1, dec1 of size len1 and ra2,
dec2 of
   of size len2) and computes the nearest neighbors.  An array
of
   integers for the nearest neighbors of ra1, dec1 that
correspond to
   the positions in ra2, dec2 is returned, where points further
away
   than mindist (in degrees) on the sky are marked as
   -(closest index + 1). */

static int *xmatch(double *ra1, double *dec1, int len1, double *ra2,
   double *dec2, int len2, double mindist)
{
int i, j, closest, *neighbors;
double mindist2, dist, old_dist;

/* allocate memory for the neighbors */
neighbors = (int *) malloc(len1 * sizeof(int));
if (neighbors == NULL) {
return NULL;
}

/* compare to mindist^2 to save computational time (saves many
calls to
   sqrt in inner loop) */
mindist2 = mindist * mindist;

for (i = 0; i < len1; i++) {
/* intial closest match is as far off as possible */
closest = 0;
old_dist = DBL_MAX;

for (j = 0; j < len2; j++) {
/* angular distance on the sky squared */
dist = pow((cos(dec1[i]) * (ra1[i] - ra2[j])), 2) +
   pow((dec1[i] - dec2[j]), 2);

/* keep track of only the closest point */
if (dist < old_dist) {
closest = j;
old_dist = dist;
}
}

/* mark points that lie outside the specified distance */
if (old_dist > mindist2) {
neighbors[i] = -(closest + 1);
}
else {
neighbors[i] = closest;
}
}

return neighbors;
}

/* wrap_xmatch: Python wrapper function for xmatch above */
static PyObject *wrap_xmatch(PyObject *self, PyObject *args)
{
PyObject *ra1, *dec1, *ra2, *dec2, *ntup;
int i, len1, len2, len_chk1, len_chk2;
int *neighbors;
double mindist;
double *r1, *d1, *r2, *d2;

/* read 4 sequences (ra1, dec1, ra2, dec2) and a double (mindist)
*/
if (!PyArg_ParseTuple(args, "d", &ra1, &dec1, &ra2, &dec2,
&mindist)) {
return NULL;
}

/* check that mindist is > 0 */
if (mindist <= 0.0) {
PyErr_SetString(PyExc_ValueError, "mindist must be > 0");
return NULL;
}

/* convert sequences to tuples if necessary */
ra1 = PySequence_Fast(ra1, "ra1 must be iterable");
if (ra1 == NULL) {
return NULL;
}

dec1 = PySequence_Fast(dec1, "dec1 must be iterable");
if (dec1 == NULL) {
return NULL;
}

ra2 = PySequence_Fast(ra2, "ra2 must be iterable");
if (ra2 == NULL) {
return NULL;
}

dec2 = PySequence_Fast(dec2, "dec2 must be iterable");
if (dec2 == NULL) {
return NULL;
}

/* length of input sequences */
len1 = PySequence_Fast_GET_SIZE(ra1);
len_chk1 = PySequence_Fast_GET_SIZE(dec1);

if (len1 != len_chk1) {
PyErr_SetString(PyExc_ValueError, "ra1 and dec1 must be the
same size");
return NULL;
}

len2 = PySequence_Fast_GET_SIZE(ra2);
len_chk2 = PySequence_Fast_GET_SIZE(dec2);

if (len2 != len_chk2) {
PyErr_SetString(PyExc_ValueError, "ra2 and dec2 must be the
same size");
return NULL;
}

/* allocate memory for C arrays */
r1 = (double *) malloc(len1 * sizeof(double));
if (r1 == NULL) {
Py_DECREF(ra1);
Py_DECREF(dec1);
Py_DECREF(ra2);
Py_DECREF(dec2);
return PyErr_NoMemory();
}

d1 = (double *) malloc(len1 * sizeof(double));
if (d1 == NULL) {
Py_DECREF(ra1);
Py_DECREF(dec1);
Py_DECREF(ra2);
Py_DECREF(dec2);
return PyErr_NoMemory();
}

r2 = (double *) malloc(len2 * sizeof(double));
if (r2 == NULL) {
Py_DECREF(ra1);
Py_DECREF(dec1);
Py_DECREF(ra2);
  

Re: Well, Reading is hard to learn...

2005-09-01 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
Paul Boddie <[EMAIL PROTECTED]> wrote:
>bruno wrote:
>> 
>> I have spent 1 week on learning reading and felt good. but I still don't
>> understand most part of Emmanuel Kant's writings.
>> 
>
>Monty Python really missed out there: cut to a sketch featuring three
>year olds discussing Kant. ;-)
>
>Paul
>

"It's not fair!  I told Mommy about the immanent
pragmatics of taking my sister's blankie, and she
*still* said I had to take a nap!"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python built email message doesn't support OutLook Express

2005-09-01 Thread Robert Kern
praba kar wrote:
> --- "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> 
>>That is not what Sybren requested - we need the
>>message text. If you
>>send html, make sure your paragraphs are html
>>paragraphs (enclosed in
>>-tags) and not pure whitespace, as html ignores
>>these.
> 
> I am sending text message as a paragraph 

We. Need. To. See. The. Actual. String.

Otherwise, we cannot help you.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sockets: code works locally but fails over LAN

2005-09-01 Thread n00m
>Bryan;
I tested your code locally (in I*D*L*E) - it works fine!
And of course I'll test it over LAN but only tomorrow - at work.
See the picture of my IDLE window with output of your code:
http://free.7host02.com/n00b/socket_Br.gif
Note the 4th line in Blue: there Z is the name of my home machine,
qwe is the login name (from VBS(ADO) connection string) and right
after "qwe" - this login's password ("asdasd") but it's encrypted
by oledb provider.


>Dennis;
I understand pretty well what you mean. Thank you for the repr().


>Fredrik;
Locally it works! The rest - tomorrow.


>John;
How exactly should I "correct" the code?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python doc problems example: gzip module

2005-09-01 Thread plainsane

Peter Maas wrote:

> Xah Lee schrieb:
> > today i need to use Python to decompress gzip files.
> >
> > since i'm familiar with Python doc and have 10 years of computing
> > experience with 4 years in unix admin and perl, i have quickly located
> > the official doc:
> >
> >  http://python.org/doc/2.4.1/lib/module-gzip.html
> >
> > but after a minute of scanning, please someone tell me what the fuck is
> > it talking about?
> >
> > Fuck the Python programing morons.
> >
> > Thanks.
> >
> > I just need to decompress files. Is it:
> >
> > import gzip;
> > gzip.GzipFile("/Users/xah/access_log.1.gz");
> >
> > can someone put a example into that fucking doc so that people don't
> > have to wade thru whatever fuck it is trying to sound big?
>
> Here's the example:
> import gzip
>
> # read fucked
> fuckedfile = gzip.GzipFile('somefile.gz')
> content = fuckedfile.read()
> fuckedfile.close()
>
> # write unfucked
> unfuckedfile = file('somefile','w')
> unfuckedfile.write(content)
> unfuckedfile.close()
>
> Please feel free to insert this fucking example into the fucking docs.
>
> Have a nice ... eh fucking day :)
>
> --
> ---
> Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
> E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
> ---

yes yes yes, i love this "fucking" post...nice "fucking" response
man

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: global interpreter lock

2005-09-01 Thread Bryan Olson
Dennis Lee Bieber wrote:
 >  Well, at that point, you could substitute "waiting on a queue" with
 > "waiting on a socket" and still have the same problem -- regardless of
 > the nature of the language/libraries for threading; it's a problem with
 > the design of the classes as applied to a threaded environment.

It's a problem for all levels; pretty much any of them can botch
it. Not only do we want to be able to wait on two queues or two
sockets, we might have good cause to wait on two queues *and*
two sockets. Win32 provides WaitMultipleObjects which lets the
programmer efficiently wait on many objects of various types at
one call; the Linux kernel Gurus are looking at supporting a
similar feature.

Library designers can botch the functionality by wrapping the
waitable object in their own classes with their own special wait
operation, and hiding the OS object.


-- 
--Bryan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: graphical or flow charting design aid for python class development?

2005-09-01 Thread Florian Diesch
William Gill <[EMAIL PROTECTED]> wrote:
> Being somewhat new to Python, and having a tendency to over complicate 
> things in my class design, I was wondering if anyone can suggest a 
> simple graphical or flowcharting tool that they use to organize their 
> class and program  design?  Because of a 55 mph head-on accident a few 

For Linux/Unix there is dia  to make
a class diagram and dia2code  to create
Python code from it.

Probably you can find some other UML tools that support Python.


> I have used editors for other languages that allow the view to expand 
> and collapse functions/methods (like message threads here on the board), 
> which help, but I haven't seen anything like this for python.

For questions like "Is there an editor that supports...", "Emacs" is
about always an answer ;-) It has outline-mode for this.


   Florian
-- 
begin  signature_virus
 Hi! I'm a signature virus. Please copy me to your signature to help me spread.
end
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding bound methods dynamically... CORRECTED

2005-09-01 Thread bruno modulix
Mike Meyer wrote:
> bruno modulix <[EMAIL PROTECTED]> writes:
> 
>>Devan L wrote:
>>
>>>Kevin Little wrote:
>>>
>>>
I want to dynamically add or replace bound methods in a class.  
>>
>>(snip)
>>
>>
>>>I'm not an expert, but why do you need to dynamically add or replace
>>>bound methods?
>>
>>To modify the behaviour at runtime ?-)
>>
(snip)
> 
> Yes, but rather than going through the contortions you do to bind a
> new method into place, 

Contortion ? Which contortion ?

class Foo(object):
def __init__(self, name):
self.name = name

def greet1(self, who):
print "hello %s, this is %s" % (who, self.name)

def greet2(self, who):
print "Yo %s, have a drink with Daddy %s" % (who, self.name)

f = Foo('Python')

Foo.greet = greet1
f.greet('Monty')
Foo.greet = greet2
f.greet('Monty')

> why not make the method in question act as a
> proxy for the real method? 

Please show us an implementation.


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenSource documentation problems

2005-09-01 Thread Alan Balmer
On 1 Sep 2005 03:51:55 -0700, "Xah Lee" <[EMAIL PROTECTED]> wrote:

>On Python's Documentation

Thinking about it, I can't imagine why I've waited so long to filter
this idiot.
-- 
Al Balmer
Balmer Consulting
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is there a better way to check an array?

2005-09-01 Thread Steve M
You can check for membership in a list at least these ways:

my_list.index(candidate)
-returns the index into my_list of the first occurrence of candidate.
Raises ValueError if candidate doesn't occur in my_list.

my_list.find(candidate)
-returns the index into my_list of the first occurrence of candidate.
Returns -1 if candidate doesn't occur in my_list.

candidate in my_list
-returns True if candidate occurs in my_list


The last is nicest (most pythonic?) if you don't actually need the
index, which it seems you don't. That being said, you should consider
the, what I believe is called, Complexity of your algorithm. In
particular, you should recall that checking for membership in a list
takes an amount of time proportional to the length of the list, while
checking for membership in a set (or dictionary) takes a constant
amount of time regardless of the size of the set. From what I see, it
appears that you don't necessarily need to keep the notRequiredAry
things in order, but that you really just need to kknow the set of
things that are not required. If you are making this check a lot, for
instance looping over a big list and checking for each member whether
it is not required, you should consider using a set instead of a list.
It might have the benefit of making your code more readable too.

-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >