Re: Doc suggestions (was: Why "class exceptions" are not deprecated?)

2006-04-01 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> > and for the record: the infogami setup had never happened if Ed hadn't
> > written that post.
>
> I wouldn't rest on my laurels quite yet if I were you.
> You've provided a good piece to take care of the input
> collection side of the equasion but I've seen nothing
> that deals with the output side (wiki -> docs).

no, but that's because you're the kind of pathetic loser who only sees
problem with things, and only pops up when you have a chance to piss
on something.





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


PySimpleXML 1.0 Stable

2006-04-01 Thread Vic Fryzel
PySimpleXML 1.0 stable has been released. It allows a Python user to easily 
access XML elements via a structure of Python dictionaries and lists, 
xml.dom.minidom Document, or string.

PySimpleXML simplifies the translation of XML documents into very usable trees 
of Python structures (dictionaries, lists, etc), and also simplifies the 
translation from those structures back to XML or pretty XML. Specifically, 
this library can convert a DOM object, Python struct, XML file, or XML string 
into any other item in that list.

Cheese Show Package: 
http://cheeseshop.python.org/pypi?name=PySimpleXML&version=1.0&:action=display

For more information, examples, documentation, or to download PySimpleXML, 
please visit the homepage for PySimpleXML:
http://shellsage.com/?q=node/12

-- 
Vic Fryzel (lists at shellsage dot com)
http://shellsage.com/
Key id 237BD73A = 4511 20DB 3DCF 6856 12BB  888B 9343 B277 237B D73A


pgpe5r0R8abhD.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Fredrik Lundh
"walterbyrd" wrote:

> Please post a link to the original article. Not just a post to a blog.

the pyfound blog is the official PSF blog; it's linked from the PSF:s
homepage:

http://www.python.org/psf/





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


Re: Site err? - modpython - django?

2006-04-01 Thread Fredrik Lundh
"EP" <[EMAIL PROTECTED]> wrote:

> i am gettng slow response from thssite en wonder if problem with gil? or
> django bug.  is this coded in modpython and to many instances?  i need
> to select web teknology en maybe python en zope is too old to handle
> high volume of download objs.  what cas problem? thks for your help.

not sure what you're really saying here, but feeding downloads through
mod_python is not a very efficient thing to do (no matter what frame-
work you're using).  the following page contains some more info:

http://www.jacobian.org/2005/dec/12/django-performance-tips/

(alse see the comments)





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


Re: Scatter/gather on sockets?

2006-04-01 Thread Jean-Paul Calderone
On 1 Apr 2006 14:56:02 -0500, Roy Smith <[EMAIL PROTECTED]> wrote:
>I've got a bunch of strings in a list:
>
>vector = []
>vector.append ("foo")
>vector.append ("bar")
>vector.append ("baz")
>
>I want to send all of them out a socket in a single send() call, so
>they end up in a single packet (assuming the MTU is large enough).  I
>can do:
>
>mySocket.send ("".join (vector))
>
>but that involves creating an intermediate string.  Is there a more
>efficient way, that doesn't involve that extra data copy?

There is a thing called "scatter-gather I/O", but it has nothing to do with 
lumping things together in a single packet.  It's all about minimizing memory 
copying on the way to the network.  The underlying call is writev(), and it is 
not exposed to Python applications in the standard library.  There are, 
however, several third-party modules which provide access to it (google for 
"python writev" - you'll find plenty of material).  You can also call it via 
the dl module, and in Python 2.5, the ctypes module.

Twisted also exposes this functionality via ITransport.writeSequence (silently 
falling back to writing "".join(iovec) if a more efficient scatter-gather 
mechanism is not available (which it isn't in any of the official Twisted 
reactors (but someday it will be and your program will magically go faster))).

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


Re: Looking for a language/framework

2006-04-01 Thread Gregor Horvath
Scott David Daniels schrieb:

> Using a relational DBMS is most definitely _not_ premature optimization.
> A relational system provides a way to store data so that it is later

I did not mean that using a relational DBMS is premature optimization
but not using a ORM because of performance considerations is one .

If it turns out that the ORM is a performance problem you can always
tune it afterwards. (probably by the DBMS setup, indexes etc.)

> structure.  The database structures built are as good a DB organization
> as code generated by code generation programs: the meaning is obscured,
> and the generated (structure / code) is hard to work with.

Its just a layer and therefore the endresult is SQL much the same as the
one you would hand code. (and you still can use direct SQL if you like
with most of them)

In any way you have to bridge the logical gap between the relational and
the object data model in your programm.
So you will end up in building a layer between your persistence code and
your problem and domain specific application code, so what you are
actually doing is writing an ORM.

Not reinventing the wheel every time and using a existing one is IMHO a
better approach.

-- 
Mit freundlichen Grüßen,
  Ing. Gregor Horvath, Industrieberatung & Softwareentwicklung
  http://www.gregor-horvath.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pickle or Mysql

2006-04-01 Thread Klaas
> Can I use Pickle to store about 500,000 key value pairs.. or should I
> use mySql. Which one is best for performance, as the key value pair
> increases.

Pickle: absolutely out of the question.
Mysql: might work, albeit slowly.

Use berkeley DB (bsddb3), or zodb.  I have no experience with the
latter, but bdb's scale far beyond that magnitude if necessary.

-Mike

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


Re: Should any() and all() take a key= argument?

2006-04-01 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> >> any(map(lambda x: x==42, lst))
> ...
> In any case, I question your assumption that the version using map must
> automatically "waste memory". 

There's also always itertools.imap.

> But then, unless these are big complex objects, why are we
> micro-optimizing our code anyway? I'm running a Python process, and
> it is consuming 6.7MB of memory at the moment. Do I really care about
> saving 80 or 100 bytes?, or even 100 kilobytes? I don't think so.

The idea is to write code to be assumption-free when possible.  A
general purpose library function should work efficiently on big
complex objects even if some specific application might use it only
for small objects.  Similarly, application programs that will stay in
use for a while should be written to be able to handle large workloads
even if the initial requirements are small, unless significant extra
development effort is needed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Ray

Steve Holden wrote:
> Grant Edwards wrote:
> > On 2006-04-01, walterbyrd <[EMAIL PROTECTED]> wrote:
> >
> >
> >>Is this an April fool's joke?
> >
> >
> > Did you read the blog entry?
> >
> I suspect he didn't. I'm guessing that eventually we'll have to remove
> the blog entry just so's nobobdy's tempted to take it seriously.

If a big corporation wants to take it seriously and pay 1.25, what's
wrong with that? :)



>
> regards
>   Steve
> --
> Steve Holden   +44 150 684 7255  +1 800 494 3119
> Holden Web LLC/Ltd www.holdenweb.com
> Love me, love my blog holdenweb.blogspot.com

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


Re: Should any() and all() take a key= argument?

2006-04-01 Thread Steven D'Aprano
On Sat, 01 Apr 2006 08:12:25 -0300, Felipe Almeida Lessa wrote:

> Em Sáb, 2006-04-01 às 20:44 +1000, Steven D'Aprano escreveu:
>> Here's another way of doing it:
>> 
>> lst = [2, 4, 42]
>> any(map(lambda x: x==42, lst))
> 
> In fact, as we're talking about Python 2.5 anyway, it would be better
> not to waste memory and use:
> 
> any(x == 42 for x in lst)

You might be talking about Python 2.5, but I certainly am not. any()
and all() are easy to (almost) implement in earlier Python versions:

try:
any
except NameError:
# warning: this version will consume an iterator
def any(seq):
for s in seq:
if s: return True
return False

and similarly for all(). 

In any case, I question your assumption that the version using map must
automatically "waste memory". Iterators carry a certain amount of overhead
which lists do not. For small enough lists, that overhead will be smaller
than the extra memory used by the list. "Small enough" will depend on the
type of objects involved: big complex objects created on the fly by
the generator gives the generator the advantage, small simple objects
like ints give the list the advantage. As Python doesn't give us any way to
measure the memory used by an object, it is hard to say where that
cut-off lies, but my wild guess is that for ints, it would probably be in
the multiple tens.

But then, unless these are big complex objects, why are we
micro-optimizing our code anyway? I'm running a Python process, and
it is consuming 6.7MB of memory at the moment. Do I really care about
saving 80 or 100 bytes?, or even 100 kilobytes? I don't think so.



-- 
Steven.

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

Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Steve Holden
Grant Edwards wrote:
> On 2006-04-01, walterbyrd <[EMAIL PROTECTED]> wrote:
> 
> 
>>Is this an April fool's joke?
> 
> 
> Did you read the blog entry?
> 
I suspect he didn't. I'm guessing that eventually we'll have to remove 
the blog entry just so's nobobdy's tempted to take it seriously.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Steve Holden
Grant Edwards wrote:
> On 2006-04-01, Steve Holden <[EMAIL PROTECTED]> wrote:
> 
>>As the only director of the Python Software Foundation to vote against a 
>>recent Board motion to implement the change in licensing terms described in
>>
>>   http://pyfound.blogspot.com/2006/04/python-25-licensing-change.html
> 
> 
> Good one Steve.
> 
> I particularly liked the Comments section. 
> 
> :)
> 
Yes, lots of people joined in the spirit of the original post - the 
comments were added by others. Thanks for pointing them out: I hadn't 
noticed, having been out all day at a Make Beer Free rally.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


Re: Berkeley DB XML vs 4suite for fast searching in XML DB?

2006-04-01 Thread Ravi Teja
Last time I tried, BDB XML's Python extension crashed and I did not try
too hard to figure out why and switched to something else that did not
(eXist). BDB has been marketed for long as a fast database and will
probably be faster than 4Suite. I doubt that you will find any
benchmarks comparing those two. Why don't you try both yourself, with
your own data and decide?

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


Re: DO NOT USE JAVA BECAUSE IT IS NOT OPEN SOURCE

2006-04-01 Thread Luc The Perverse
"steve" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Sat, 1 Apr 2006 13:06:52 +0800, Luc The Perverse wrote
> (in article <[EMAIL PROTECTED]>):
>
>> <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>>> Programing Languiges Are Ment to be free. That is why i am starting The
>>> Coo De Tar thats french for Blow of state it is a flash/java
>>> alternative and if you are going to use a server side languige use
>>> Perl,Python or better yet Ruby. What is the point of a languige without
>>> a standerd and without a open source distrabution. Coo De Tar will be
>>> released as a api for perl,python and ruby. Java sucks because it IS
>>> NOT FREE. I AM A GNU GUY I BELEVE THAT SOFTWARE MUST AND SHALL BE
>>> FREE!! do not use java because it is an oxymoron
>>>
>>
>> Dear Mr Troll,
>>
>> There are GNU implementations of JVM and compiler.
>>
>> And just because Sun's Java is not GNU does not mean it is not free.
>>
>> Now go get a life.
>>
>> --
>> LTP
>>

>>
>>
>
> it's April 1st remember

Ah!  Thank you

--
LTP

:) 


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


Re: any() and all() on empty list?

2006-04-01 Thread Ron Adam
Ron Adam wrote:
> Steve R. Hastings wrote:

>> This neatly replaces truecount(), and you can use it for other things as
>> well.
> 
> if True in talley(S): do_somthing()
> 
> Works for me...  ;-)
> 
> 
> Cheers,
>   Ron

Actulley talley isn't needed for this...

  if True in S: do_domething()


That's what I get for staying up way too late last night.

Cheers, Ron

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


Re: any() and all() on empty list?

2006-04-01 Thread Ron Adam
Steve R. Hastings wrote:
> On Sat, 01 Apr 2006 14:35:58 -0300, Felipe Almeida Lessa wrote:
>> Two changes:
>>  - Use "is None".
>>  - Use "try ... except" instead of "in"
> 
> Yes.
> 
> 
>> Maybe you don't like my version, and the gains aren't that much, but
>> please use "is None" instead of "== None".
> 
> Actually, I do like your version.  And I try to always use "is None"
> instead of "== None"; today I made a mistake about it.  Thank you for your
> comments.
> 
> Ideally there should be an official tally() function in some module in
> Python, and then we can just use it and not worry about how to write it. :-)

And it's a good candidate to be written in C as well.

Cheers,
Ron
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: any() and all() on empty list?

2006-04-01 Thread Ron Adam
Steve R. Hastings wrote:

> Here is a function called "tally()".  It reduces a list to a dictionary
> of counts, with one key for each value from the list.  The value for
> each key is the count of how many times it appeared in the list.
>
 >
> def tally(seq, d=None):
> if d == None:
> d = {}
> 
> for x in seq:
> if x in d:
> d[x] += 1
> else:
> d[x] = 1
> return d
> 
> 
> This neatly replaces truecount(), and you can use it for other things as
> well.

 if True in talley(S): do_somthing()

Works for me...  ;-)


Cheers,
   Ron




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


Re: running IDLE from another program?

2006-04-01 Thread John Salerno
Kent Johnson wrote:
> John Salerno wrote:
>> Kent Johnson wrote:
>>
>>> The working directory must be wrong. Try calling Python directly with 
>>> full paths:
>>>
>>> C:\Python24\pythonw C:\Python24\Lib\idlelib\idle.pyw -r C:\path\to\myprog.py
>>
>> Perfect! Thank you so much!
>>
>> I put this line in the command line field, and I left "working 
>> directory" empty because I'm not sure what goes there. Should it be the 
>> main python directory, or the directory of the file being run? Either 
>> way, it seems to work without a working directory.
> 
> Great! I would set the working directory to the dir containing your 
> program. That way if you have multiple modules in the program you will 
> be able to import them without any trouble.
> 
> Kent

Ok, thanks again! I love how this works now! :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Doc suggestions

2006-04-01 Thread Kent Johnson
Terry Reedy wrote:
> Yes, there have been claims that doc patches have to be in Latex or are 
> otherwise not welcome.  

This is counter to my own experience and this page which says, "There's 
no need to worry about text markup; our documentation team will gladly 
take care of that."
http://docs.python.org/about.html

Submitting a proposed change or fix is easier and quicker than arguing 
about it on c.l.py and it seems to get pretty quickly to the actual 
document maintainers.

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


Re: any() and all() on empty list?

2006-04-01 Thread Steve R. Hastings
On Sat, 01 Apr 2006 14:35:58 -0300, Felipe Almeida Lessa wrote:
> Two changes:
>  - Use "is None".
>  - Use "try ... except" instead of "in"

Yes.


> Maybe you don't like my version, and the gains aren't that much, but
> please use "is None" instead of "== None".

Actually, I do like your version.  And I try to always use "is None"
instead of "== None"; today I made a mistake about it.  Thank you for your
comments.

Ideally there should be an official tally() function in some module in
Python, and then we can just use it and not worry about how to write it. :-)
-- 
Steve R. Hastings"Vita est"
[EMAIL PROTECTED]http://www.blarg.net/~steveha

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


Re: running IDLE from another program?

2006-04-01 Thread Kent Johnson
John Salerno wrote:
> Kent Johnson wrote:
> 
>>The working directory must be wrong. Try calling Python directly with 
>>full paths:
>>
>>C:\Python24\pythonw C:\Python24\Lib\idlelib\idle.pyw -r C:\path\to\myprog.py
> 
> 
> Perfect! Thank you so much!
> 
> I put this line in the command line field, and I left "working 
> directory" empty because I'm not sure what goes there. Should it be the 
> main python directory, or the directory of the file being run? Either 
> way, it seems to work without a working directory.

Great! I would set the working directory to the dir containing your 
program. That way if you have multiple modules in the program you will 
be able to import them without any trouble.

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


Re: Identifying filled circles in a scanned image

2006-04-01 Thread Terry Reedy

"> Douglas Douglas <[EMAIL PROTECTED]> writes:
>
>> Hi everybody.
>>
>> I have a paper form that I scan into an image. My user fills some 
>> circles in
>> this paper form using black ink. Every form has ten rows with five 
>> circles each
>> and the user fills only one circle for each row.
>>
>> I was wondering if I could use the Python Imaging Library to process 
>> these
>> forms. I know the Image class is really powerful, but I can't think of a 
>> way of
>> how to locate wich circle was filled.

I though about this problem once but never had occasion to do anything 
concrete.  The key is to have some landmarks on the paper form that the 
analysis program can find.  One can then convert between printed image 
coordinates and scanned image coordinates.  This corrects for both 
variations in image placement on the sheet and sheet placement on the 
scanner.

Terry Jan Reedy



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


Re: Doc suggestions

2006-04-01 Thread Terry Reedy

<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Terry Reedy" wrote:
> Not sure how premature it is.  I've been reading
> c.l.p. on and off for nearly a year.

Yes, there have been claims that doc patches have to be in Latex or are 
otherwise not welcome.  But these mostly (all?) have lacked relevant 
concrete data, which would be actual responses to actual submissions to the 
Python SourceForge change trackers.

There have also been fact-based postings at least partly refuting such 
claims, including some by me.

>> >  I gather corrections of factual
>> > errors are welcome, but stylistic, or organizational
>> > ones are not.

I would not be surprised if the volunteer doc editors see corrections and 
the writing of missing docs as higher priority than sylistic upgrades, but 
that is different from 'not welcome'.

Some time ago, Alex Martelli submitted several style change suggestions for 
at least one of the docs.  As I remember, at least most of them were 
accepted.  In any case, all were considered.  And there have since been 
other changes that I have been involved with that were arguably style 
upgrades rather than corrections.

A few organizational changes might be considered, especially if accompanied 
by an offer to make at least a prototype, but someone with fundamentally 
different ideas should write their own doc under their own name.

>> If you wish to become a volunteer Python improver, let me know either
>> here or privately and I will respond with a suggestion and an offer.
>
> Yes, please do.

Frederik has one idea.  Here is what I was going to say, and will anyway.

Suggestion: You could submit the one improved sentence you previously 
suggested.  But the overhead of any change is a bit high for just that.  So 
gather at least a few suggestions, put them in order, include section 
number and identifier for each, and cut-and-paste urls from current docs at 
python.org.

Offer: If you submit your 'text patch' to SourceForge and let me know, I 
will review it right away.  If you prefer, post or email to me and I will 
'pre' review it before submission.  You can collect ideas from others if 
you want; I only care about formating that make the proposed change sites 
and contexts easy to find.

Terry Jan Reedy



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


Re: Scatter/gather on sockets?

2006-04-01 Thread Paul Rubin
Roy Smith <[EMAIL PROTECTED]> writes:
> This is true, but I'm generating the message being sent in very small 
> chunks (often as small as 4 bytes at a time), and typically need to flush a 
> packet out onto the network after a few dozen bytes.  Maybe at most a few 
> hundred.  I don't know of any networks with MTU's smaller than that.  
> Measurements show a 10-fold improvement in protocol throughput with large 
> packets vs. small ones.  The only question is what's the most efficient way 
> in Python to generate the large packets.

Probably: build up the packet with cStringIO or with the array module
instead of as a list of small strings.  But if you time both versions
I don't think it'll matter much.  Python (at least CPython) simply
will not be very fast no matter what you do.  The overhead of building
a large string (with ''.join, say) from a bunch of small ones isn't
that big a deal compared with what you already lose in interpreter
overhead running the application.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Scatter/gather on sockets?

2006-04-01 Thread Roy Smith
In article <[EMAIL PROTECTED]>,
 Anthony Greene <[EMAIL PROTECTED]> wrote:

> On Sat, 01 Apr 2006 14:56:02 -0500, Roy Smith wrote:
> 
> > I've got a bunch of strings in a list:
> > 
> > vector = []
> > vector.append ("foo")
> > vector.append ("bar")
> > vector.append ("baz")
> > 
> > I want to send all of them out a socket in a single send() call, so
> > they end up in a single packet (assuming the MTU is large enough).  I
> > can do:
> > 
> > mySocket.send ("".join (vector))
> > 
> > but that involves creating an intermediate string.  Is there a more
> > efficient way, that doesn't involve that extra data copy?
> 
> Is sendall() what you're looking for?

No.  Sendall() is actually what I'm using now.  It handles the other side 
of the issue; issuing repeated send() calls if the system fragments your 
buffer.  I'm trying to aggregate lots of small buffers into one large one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Scatter/gather on sockets?

2006-04-01 Thread Roy Smith
Peter Hansen <[EMAIL PROTECTED]> wrote:
> B. Don't bother trying, because even if the MTU is large enough there is 
> absolutely no guarantee that the packet will stay intact all the way 
> through the network anyway (even if you use sendall() instead of send()).

This is true, but I'm generating the message being sent in very small 
chunks (often as small as 4 bytes at a time), and typically need to flush a 
packet out onto the network after a few dozen bytes.  Maybe at most a few 
hundred.  I don't know of any networks with MTU's smaller than that.  
Measurements show a 10-fold improvement in protocol throughput with large 
packets vs. small ones.  The only question is what's the most efficient way 
in Python to generate the large packets.

> So fixing your design not to require this appears to be the only viable 
> solution.

My design is not broken.  I'm writing code to drive a pre-existing binary 
communications protocol.  It is what it is.  The functionality I seek 
exists at the Unix system call level (writev, sendmsg), but doesn't appear 
to be exposed in the Python socket API.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Bruno Desthuilliers
Grant Edwards a écrit :
> On 2006-04-01, Steve Holden <[EMAIL PROTECTED]> wrote:
> 
>>As the only director of the Python Software Foundation to vote against a 
>>recent Board motion to implement the change in licensing terms described in
>>
>>   http://pyfound.blogspot.com/2006/04/python-25-licensing-change.html
> 
> 
> Good one Steve.
> 
> I particularly liked the Comments section. 
> 
> :)
> 
+42

And this pretty intersting link:
http://www2.sqlonrails.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running IDLE from another program?

2006-04-01 Thread John Salerno
Kent Johnson wrote:

> The working directory must be wrong. Try calling Python directly with 
> full paths:
> 
> C:\Python24\pythonw C:\Python24\Lib\idlelib\idle.pyw -r C:\path\to\myprog.py

Perfect! Thank you so much!

I put this line in the command line field, and I left "working 
directory" empty because I'm not sure what goes there. Should it be the 
main python directory, or the directory of the file being run? Either 
way, it seems to work without a working directory.

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


Re: Connecting to gnuplot with Popen?

2006-04-01 Thread John J. Lee
Anton81 <[EMAIL PROTECTED]> writes:

> > Hi Anton,
> > 
> > here is a little snippet using os.popen:
> 
> Unfortunately I'm having more problem getting the output from Gnuplot, which
> I'd like to examine for error messages and settings of options.

If you must roll your own, look at standard module subprocess.


John

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


Re: Identifying filled circles in a scanned image

2006-04-01 Thread John J. Lee
Douglas Douglas <[EMAIL PROTECTED]> writes:

> Hi everybody.
> 
> I have a paper form that I scan into an image. My user fills some circles in
> this paper form using black ink. Every form has ten rows with five circles 
> each
> and the user fills only one circle for each row.
> 
> I was wondering if I could use the Python Imaging Library to process these
> forms. I know the Image class is really powerful, but I can't think of a way 
> of
> how to locate wich circle was filled.
> 
> Could anybody please give me an advice on this?

I think in astronomical / biological circles this kind or problem is
known as "blob analysis", or something like that (certainly I remember
the word "blob" correctly ;-).

Try one of the numpy / numarray / Numerical Python / SciPy lists,
bound to be people there who know a lot about this sort of problem,
and your problem sounds quite a bit easier than the general one.


John

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


Re: running IDLE from another program?

2006-04-01 Thread Kent Johnson
John Salerno wrote:
> Kent Johnson wrote:
>>One thing that is really useful about running in an editor window is 
>>that (in TextPad, anyway) I can double-click on an error message and go 
>>directly to the line with the error.
> 
> 
> Interesting. The way I have it now, it shows errors the way I want to, 
> but it shows them just in a text file, nothing special, and I don't seem 
> to be able to double-click them. Is this just a feature of TextPad, or 
> did you have to set it up so you can double-click the errors?

mmm, both. TextPad lets me set a regular expression to interpret errors 
as file/line. When that is set correctly the double-clicking works.
> 
>>Try
>>C:\Python24\Lib\idlelib\idle -r C:\path\to\myprog.py
> 
> 
> I tried this but it said it couldn't find idle.pyw (even though it is 
> there).

The working directory must be wrong. Try calling Python directly with 
full paths:

C:\Python24\pythonw C:\Python24\Lib\idlelib\idle.pyw -r C:\path\to\myprog.py

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


Re: Can I export my datas in pickle format safely ?

2006-04-01 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, DurumDara
wrote:

> I thinking about that I can use the pickle to serialize/load my datas 
> from the file.
> 
> But: I remember that in the year of 2004(?) I tried this thing. I store 
> my CD informations in pickled objects (in files).
> And when I changed my python version from ??? to 2.3(?), and I get some 
> error messages...

What are the error messages?  Pickled data should survive such a version
change.  Remember that even "text protocol" pickles are binary data which
may break across platforms if the files are not opened in binary mode for
writing and reading.  And all classes of the types that were pickled must
be "reachable" when unpickling.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: urllib2 through basic auth'ed proxy

2006-04-01 Thread John J. Lee
[EMAIL PROTECTED] (John J. Lee) writes:

> Alejandro Dubrovsky <[EMAIL PROTECTED]> writes:
[...Alejandro complains about non-working HTTP proxy auth in urllib2...]

[...John notes urllib2 bug...]
> A workaround is to supply a stupid HTTPPasswordMgr that always returns
> the proxy credentials regardless of what the handler asks it for (only
> tested with a perhaps-broken 2.5 install, since I've broken my 2.4
> install):
[...snip ugly code]
> Yuck, yuck, yuck!  I had realised the auth/proxies code in urllib2 was
> buggy, but...  And all those hoops to jump through.
> 
> Also, if you're using 2.5 SVN HEAD, it seems revision 42133 broke
> ProxyHandler in an attempt to fix the URL host:post syntax!
[...]

In fact the following also works with Python 2.3.4:

import urllib2
proxy_handler = urllib2.ProxyHandler({"http": "http://john:[EMAIL 
PROTECTED]:3128"})
print urllib2.build_opener(proxy_handler).open('http://python.org/').read()


...but only just barely skirts around the bugs!-)  :-(

(at least, the current bugs: I've no reason to work out what things
were like back in 2.3.4, but the above certainly works with that
version)


John

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


Python-implimenting-valueweb

2006-04-01 Thread brandon.mcginty
Hi All,
I hope this post is acceptable on this list.
I'm wondering if anyone here has experience using python on a web server?
Specifically, has anyone used python on value web's servers?
If anyone has any info, general or specific, please let me know.
All help is appreciated.
Sincerely,
Brandon mcginty




--
Feel free to contact me for technical support, or just to chat; I always
have time to talk and help, and an open ear.
Email:[EMAIL PROTECTED]
Skype:brandon.mcginty
Msn:[EMAIL PROTECTED]
Aim:brandonmcginty (Not currently available.)
Cell:4802025790 (Weekends and nights only, please.)
"Kindness is a language that the deaf can hear and the blind can see."
Mark Twain

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.4/299 - Release Date: 3/31/2006
 

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


Berkeley DB XML vs 4suite for fast searching in XML DB?

2006-04-01 Thread Sullivan WxPyQtKinter
Storing XML in relational database with indexing feature is exactly
what I need. But 4suite is mentioned from time to time and seemingly
holding better support for python. I have no idea if 4 suite has
provide strong support for random access or relatively random access
for XML database and with indexing features, to support fast search.

Who could compare the efficiency different between the two?

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


Re: Scatter/gather on sockets?

2006-04-01 Thread Anthony Greene
On Sat, 01 Apr 2006 14:56:02 -0500, Roy Smith wrote:

> I've got a bunch of strings in a list:
> 
> vector = []
> vector.append ("foo")
> vector.append ("bar")
> vector.append ("baz")
> 
> I want to send all of them out a socket in a single send() call, so
> they end up in a single packet (assuming the MTU is large enough).  I
> can do:
> 
> mySocket.send ("".join (vector))
> 
> but that involves creating an intermediate string.  Is there a more
> efficient way, that doesn't involve that extra data copy?

Is sendall() what you're looking for?

-- 
A wise man knows he knows nothing.

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


Re: running IDLE from another program?

2006-04-01 Thread John Salerno
Kent Johnson wrote:

> I'm not sure what you mean by a 'debug' type environment. If you mean, 
> you want to run the program in a debugger and step through it, then this 
> approach won't work. If you just mean that you want to see the output of 
> the program, it will work.

No, just an environment like IDLE that shows errors instead of just 
killing the program.

> OK, your program is reading from standard input and the environment set 
> up by UltraEdit doesn't support this. If you are trying to run 
> interactive programs this approach won't work.

Oh, I see! I had the raw_input() in there so it would pause the DOS 
prompt for me, but after taking out that line, then it works how I want 
it to.

> One thing that is really useful about running in an editor window is 
> that (in TextPad, anyway) I can double-click on an error message and go 
> directly to the line with the error.

Interesting. The way I have it now, it shows errors the way I want to, 
but it shows them just in a text file, nothing special, and I don't seem 
to be able to double-click them. Is this just a feature of TextPad, or 
did you have to set it up so you can double-click the errors?

> Anyway, it turns out IDLE has a command-line switch that lets you pass a 
> file to run. Try
> C:\Python24\Lib\idlelib\idle -r C:\path\to\myprog.py

I tried this but it said it couldn't find idle.pyw (even though it is 
there).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Scatter/gather on sockets?

2006-04-01 Thread Peter Hansen
Roy Smith wrote:
> I've got a bunch of strings in a list:
> 
> vector = []
> vector.append ("foo")
> vector.append ("bar")
> vector.append ("baz")
> 
> I want to send all of them out a socket in a single send() call, so
> they end up in a single packet (assuming the MTU is large enough).  I
> can do:
> 
> mySocket.send ("".join (vector))
> 
> but that involves creating an intermediate string.  Is there a more
> efficient way, that doesn't involve that extra data copy?

Two possible answers that I can see:

A. No, the send call is implemented in C and requires a single buffer 
with the entire piece of data that will be sent.  Ultimately this gets 
passed down to the NIC hardware in some fashion, so there's certainly no 
hope of using something like a generator to send it in pieces.

B. Don't bother trying, because even if the MTU is large enough there is 
absolutely no guarantee that the packet will stay intact all the way 
through the network anyway (even if you use sendall() instead of send()).

So fixing your design not to require this appears to be the only viable 
solution.

-Peter

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


Re: wx.checklistbox

2006-04-01 Thread luca72
Thank Fredrik

I try and then i will inform you

Luca

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


Scatter/gather on sockets?

2006-04-01 Thread Roy Smith
I've got a bunch of strings in a list:

vector = []
vector.append ("foo")
vector.append ("bar")
vector.append ("baz")

I want to send all of them out a socket in a single send() call, so
they end up in a single packet (assuming the MTU is large enough).  I
can do:

mySocket.send ("".join (vector))

but that involves creating an intermediate string.  Is there a more
efficient way, that doesn't involve that extra data copy?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: DO NOT USE JAVA BECAUSE IT IS NOT OPEN SOURCE

2006-04-01 Thread Michael Ekstrand
Jack Diederich wrote:
> Xah, is that you?  

Nope, can't be. Xah doesn't use caps like that, and Xah also is very big
Free Software not Open Source...

Xah also tends to communicate in a slightly more intelligent fashion.

(note: do not take this as a defense of Xah)

- Michael

-- 
mouse, n: a device for pointing at the xterm in which you want to type.
-- Fortune
Visit me on the Web: http://www.elehack.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Grant Edwards
On 2006-04-01, walterbyrd <[EMAIL PROTECTED]> wrote:

> Is this an April fool's joke?

Did you read the blog entry?

-- 
Grant Edwards   grante Yow!  I will invent "TIDY
  at   BOWL"...
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Site err? - modpython - django?

2006-04-01 Thread EP
Hi

i am gettng slow response from thssite en wonder if problem with gil? or 
django bug.  is this coded in modpython and to many instances?  i need 
to select web teknology en maybe python en zope is too old to handle 
high volume of download objs.  what cas problem? thks for your help.   
http://www2.sqlonrails.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


wxpython in action book

2006-04-01 Thread Butternut squash
any recommendations? any opinions?

I want to learn to program in python and need a gui reference. I'll be
updating various mysql tables. I have most of the code ready to roll by
using a command line. I need put some lipstick on my project.

pyQT seems viable but there is not really a good reference and tutorial

so now I'm considering wxPython and saw this book and I'm wanting to know if
if's even worth spending my $40 on.

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


Re: DO NOT USE JAVA BECAUSE IT IS NOT OPEN SOURCE

2006-04-01 Thread Jack Diederich
Xah, is that you?  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread walterbyrd
Is this an April fool's joke?

Please post a link to the original article. Not just a post to a blog.

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


Re: PIL ImageDraw line not long enough

2006-04-01 Thread Bob Greschke
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Bob Greschke wrote:
>
>> I have to extend the vertical line to y+8, instead of y+7 to get the line
>> segment to be drawn long enough.  This is on Linux, Solaris, 2.x versions
>> of
>> Python, 1.1.5 version of PIL, and on Windows with the latest of
>> everything.
>> Am I missing a setting somewhere?
>
> I recently got another bug reported that talked about the same thing, so
> it's probably a bug in 1.1.5 that nobody has noticed before.
>
> (as nikie mentions, the low-level line segment drawer avoids drawing over-
> lapping points, but the "line" wrapper should add the last pixel)
>
> 

Hey! It's not ME for once. :)  It seems to only happen with lines that have
a vertical-ness to them (straight up-down or diagonal).  It doesn't seem to
happen when the line segment is just horizontal.

These are the characters that I am drawing

www.greschke.com/unlinked/images/graphs.png

It works really well.

Thanks!

Bob



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


Application Generators

2006-04-01 Thread walterbyrd
I would like to put together a very simple inventory program. When I
ship an item, and edit the quantity; I would like the quantity _on_hand
to auto-decrement, and the quantity_to_reorder to auto-increment.

Also, when the data is displayed in a table format, I would like to be
able to edit the quantity field as I
would in a spreadsheet, just edit that field, without having to change
to an edit-record screen.

I thought the easiest way to do this would be to use a PHP code
generator. But I'm not having any luck. Maybe I give up and code by
hand? Or maybe I should use django? It seems that application
generators never do exactly what you want, and even if they do, what
about future development? I am looking for something that will make it
easy to put together this simple project, and be flexible enough that I
can easily modify the project.

This application is supposed to run on hosted server, so that is also a
concern. The present host doesn't even have python, but I could move
the site to a new host, which has cgi python.

I have an open mind. If anybody can suggest anything, I will take a
look.

Application generators that I have tried:

dbQwikSite: I found it difficult to get it to work, and very slow. I
had to uninstall Xampp, and install AppServ just to get it to work at
all. I don't know why, maybe Xampp's versions of php/mysql were too
new? I still can not get it to generate php code that I can use.

AppGini: works as advertised, easy to use, inexpensive, and fast. But,
frankly, it doesn't do much. As far as I could see, it doesn't even
offer the basic security of a login. It just displays data, and allows
you to add/delete records. I don't even think you can interactively
edit records. Not much reporting capability.

PHP-Runner: the best so far. Fast, easy, nice looking display, has
basic security, allows editing records.  Still does not seem to have
the basic functionallity I'm looking for.

Other app generators that I have looked at, but not tried:

PHP-Peanuts
PHPMaker
phpmysql
DaDaBik
WizzyWeb
Navicat

Again, glad to read any opinions.

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


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread EP
>
>
>Hmmm... after due consideration (and reading the announcmement
>properly), I support this license change in full.
>
>  
>


If I could read past the first paragraph do you think I would really 
hang onto this newsgroup asking stupid questions?!

The personal harm caused readers of this announcement should entitle 
each reader to a free beer (or for those with bad hearts, a 
nitroglycerin pill) at the expense of the perpetrator - though I imagine 
the PSF team of lawyers retained for license enforcement may take up the 
case on his side - money talks.


- As an aside, I should mention that I have countered the announced 
licensing change with a patent application for the use of 3, 4, or 5 
spaces as an indent for purposes of establishing a code block. I have 
written a tidy little program that will count indent spaces in all 
Python programs and expect to negotiate royalty settlements on a per 
space basis ($.0001 per space proposed).  Anyone who prefers to avoid a 
call from my legal team can simply send me their source code for royalty 
calculation, and provide a credit card or bank account number.  Thanks.

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


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Martin P. Hellwig
Fuzzyman wrote:

> 
 From the site:
"Advanced Program for Research In Licensing, whose First Object-Oriented 
License"

string = "Advanced Program for Research In Licensing, whose First 
Object-Oriented License"
for letter in string:
 if ord(letter) in range(65,91):
 print(letter),

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


Re: Looking for a language/framework

2006-04-01 Thread Scott David Daniels
Gregor Horvath wrote:
>> But what you overlook is SQL's strength:
>>
>> SQL can be translated into _very_ efficient query plans w/o changing
>> the SQL.  SQL's query optimizers (more properly, de-pessimizers) give
> 
> Premature optimization is the root of all evil.
> 
> On the top level of an appliciation the goal is to only have problem or
> domain specific code.
> Middelware or ORM is a way to this goal because it encapsulates and
> hides the technical details of persistence and helps for cleaner code.
> 
Using a relational DBMS is most definitely _not_ premature optimization.
A relational system provides a way to store data so that it is later
possible to go back into your DBMS setup and improve the performance
of your program _without_changing_the_program's_code_.  The ORM
structure prevents this ability by abstracting away the meaningful
structure.  The database structures built are as good a DB organization
as code generated by code generation programs: the meaning is obscured,
and the generated (structure / code) is hard to work with.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Python Logo Revealed

2006-04-01 Thread Paul Boddie
Giovanni Bajo wrote:
> robin wrote:
>
> > http://diagrammes-modernes.blogspot.com
>
> Tell me tell me it's an april's joke, please? :)

Well, I thought that the Python mimetype icon from the Crystal SVG icon
set always looked pretty good - it employs a recognisable snake image,
although no batteries are included.

Paul

P.S. A search for source_py.svgz gave the following URL, for those
unfamiliar with the icon concerned:

http://suse.osuosl.org/people/wimer/already_checked_into_kde/crsc-mime-source_py.svgz

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


Re: Doc suggestions (was: Why "class exceptions" are not deprecated?)

2006-04-01 Thread rurpy

"Fredrik Lundh" wrote:
>
> > I'm not much of an expert in anything yet, but I had an idea, and then
> > managed to put the documents in a wiki, which was at least trying to
> > do something.  Fredrik beat me to it and did a much better job, but
> > even so I feel quite proud that I did something and tried to move
> > things on, rather than just post to a mailing list and hope someone
> > else does it.
>
> and for the record: the infogami setup had never happened if Ed hadn't
> written that post.

I wouldn't rest on my laurels quite yet if I were you.
You've provided a good piece to take care of the input
collection side of the equasion but I've seen nothing
that deals with the output side (wiki -> docs).  Are the
same people who don't have time to deal with doc patches
going to be sifting though the wiki entries, editing for
consistent style, etc, and updating the docs?  Without
that we have just YAW (yet another wiki).

I notice that Postgresql has user-annotated pages.  They
dump the added comments with each new doc point release
becauase it is too much work to merge them into the docs.

> (sure, the wiki idea isn't new, and I've been investigating edit-through-
> the-web solutions a lot lately in response to the python.org fiasco, but
> there's a lot of stop energy in the python universe these days.  python
> needs more "let's try it; it may work" and less "let's set up a committee
> and thoroughly investigate all possible technical solutions before anyone
> is allowed to do anything"...)

The two approaches are often not mutually exclusive.

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


datetime, tzinfo ... strange conversion?

2006-04-01 Thread Tino Lange
Hi!

I'm surprised about the following code, maybe you can give me a hint whether
that's bug or feature? I'm just trying to convert local time to GMT and one
method gives a strange result: 

##

> #! /usr/bin/env python
> 
> import datetime, pytz
> 
> _tz_utc = pytz.timezone("UTC")
> _tz_germany = pytz.timezone("Europe/Berlin")
> 
> local = datetime.datetime.now(_tz_germany)
> print "Local: ", local
> 
> gmt = local.astimezone(_tz_utc)
> print "GMT (1)", gmt
> 
> gmt = datetime.datetime.combine(local.date(),
local.timetz()).astimezone(_tz_utc)
> print "GMT (2)", gmt
> 
> gmt = datetime.datetime.combine(datetime.date.today(),
datetime.time(local.hour, local.minute, local.second, local.microsecond,
_tz_germany)).astimezone(_tz_utc)
> print "GMT (3)", gmt
> 
> gmt = datetime.datetime.combine(datetime.date.today(),
datetime.time(local.hour, local.minute, local.second, local.microsecond,
local.tzinfo)).astimezone(_tz_utc)
> print "GMT (4)", gmt
> 
> print "_tz_germany:", _tz_germany, "(id: %s)" % id(_tz_germany), ",
local.tzinfo:", local.tzinfo, "(id: %s)" % id(local.tzinfo)

##

Result:

> [EMAIL PROTECTED]:~/is.work/Scripts$ ./timeconv.py
> Local:  2006-04-01 20:09:26.469445+02:00
> GMT (1) 2006-04-01 18:09:26.469445+00:00
> GMT (2) 2006-04-01 18:09:26.469445+00:00
> GMT (3) 2006-04-01 19:09:26.469445+00:00
> GMT (4) 2006-04-01 18:09:26.469445+00:00
> _tz_germany: Europe/Berlin (id: -1212869684) , local.tzinfo: Europe/Berlin
(id: -1212868756)

--> Why is GMT (3) wrong?

Cheers,

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


trouble with mxODBC, unixODBC and MSSQL

2006-04-01 Thread erik . myllymaki
I am using a script that's worked for me in the past on Windows, but
now that i've moved it to a Linux machine it is not. The trouble seems
to be when trying to insert escaped characters into a  varchar field
(\n \r ,etc.).

-
# conn = mx.ODBC.WINDOWS.DriverConnect('DSN=myDSN;UID=sa;PWD=pwd')

conn = mx.ODBC.unixODBC.DriverConnect('DSN=myDSN;UID=sa;PWD=pwd')
curr = conn.cursor()

# These strings do not work:
# mystring = "Some text \n and some other text"
# mystring = "Some text \t and some other text"
# mystring = """Some text
and some other text"""

# This tring works just fine:
mystring = "Some text and some other text"


sql_insert = "insert into DEV..msg(message_id,body) values(?,?)"

curr.execute(sql_insert, (1,mystring))
curr.close()
conn.commit()
-

Here's the error message:

Error Type: OperationalError
Error Value: ('', 8179, '[unixODBC][FreeTDS][SQL Server]Could not find
prepared statement with handle 0.', 6083)

Any ideas greatly appreciated.

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


Re: newbie string conversion question

2006-04-01 Thread Scott David Daniels
Rohit wrote:
> As part of a proprietary socket based protocol I have  to convert a
> string of length 10,
> 
>   say, "1234567890"
> 
> to send it as 5 characters such that their hex values are
> 
>   0x21 0x43 0x65 0x87 0x09
> 
> (Hex value of each character is got by transposing two digits at a
> time)
> 
>  How can I do this in python? I would like the result to be available
> as a string since I am concatenating it to another string before
> sending it out. 
> 
> Thanks,
> Rohit
> 
For a horrendously obscure version, try:

 def mangle(digits):
 length = (len(digits) + 1) >> 1
 v = int(digits, 16)
 mask = int('0F' * length, 16)
 smunch = (v ^ (v >> 4)) & mask
 swapped = v ^ (smunch | (smunch << 4))
 return ''.join(chr(255 & (swapped >> (8 * n)))
for n in reversed(range(length)))

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Python Logo Revealed

2006-04-01 Thread Giovanni Bajo
robin wrote:

> I have an entry on my blog discussing the new Python logo, which is
> apparently due to replace the current one within the month. I'd be
> interested in what people think of it.
>
> Surf:
> http://diagrammes-modernes.blogspot.com

Tell me tell me it's an april's joke, please? :)
-- 
Giovanni Bajo


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


Re: any() and all() on empty list?

2006-04-01 Thread Felipe Almeida Lessa
Em Sáb, 2006-04-01 às 08:35 -0800, Steve R. Hastings escreveu:
> def tally(seq, d=None):
> if d == None:
> d = {}
> 
> for x in seq:
> if x in d:
> d[x] += 1
> else:
> d[x] = 1
> return d 

Two changes:
 - Use "is None".
 - Use "try ... except" instead of "in"

def tally2(seq, d=None):
if d is None:
d = {}
for x in seq:
try:
d[x] += 1
except KeyError:
d[x]  = 1
return d

It's also faster:

>>> from random import choice
>>> a = []
>>> for i in xrange(10):
... a.append(choice([False, True]))
...
>>> tally(a)
{False: 49922, True: 50078}
>>> tally2(a)
{False: 49922, True: 50078}
>>> from timeit import Timer
>>> min(Timer(stmt='b=tally(a)', setup='from __main__ import a,
tally').repeat(3, 100))
4.2756481170654297
>>> min(Timer(stmt='b=tally2(a)', setup='from __main__ import a,
tally2').repeat(3, 100))
3.812028169631958

Maybe you don't like my version, and the gains aren't that much, but
please use "is None" instead of "== None".

Cheers,

-- 
Felipe.

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

Re: wx.checklistbox

2006-04-01 Thread Fredrik Lundh
"luca72" wrote:

> i have again one simple problem:
>  the script is this:
>
>  def output(self):
> global lista2
> lista2 = open('/lista2', 'w')
> iteminlista2 = self.checkListBox2.GetStrings()
> lista2.writelines(iteminlista2)
>
> def input1(self):
> lista2leggi = open('/lista2', 'r')
> cd = lista2leggi.readlines()
> self.checkListBox2.AppendItems(cd)
>
> The write file is like:
>
> item1item2item3

writelines doesn't add newlines; you have to do that yourself.  try
using a plain loop instead:

for item in iteminlista2:
lista2.write(item + "\n")





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


Re: Exception handling....dumb question?

2006-04-01 Thread Peter Hansen
kbperry wrote:
> I have a Python book, but it didn't mention this at all.  I also tried
> looking through the online docs to no avail.

This is covered by the tutorial though, and if you're a Python rookie it 
would be a good idea to step your way through most of it soon:

See http://docs.python.org/tut/node10.html for the section on exception 
handling.

-Peter

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


New Python Logo Revealed

2006-04-01 Thread robin
I have an entry on my blog discussing the new Python logo, which is
apparently due to replace the current one within the month. I'd be
interested in what people think of it.

Surf:
http://diagrammes-modernes.blogspot.com

-
robin
noisetheatre.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: smtplib "authentication required" error

2006-04-01 Thread [EMAIL PROTECTED]
Dear tjg: That was extremely helpful. Thank you very kindly. The server
did not respond to the .starttls() method but authentication was
successful after, it seems, the .ehlo() was specified. I have tried the
script without the first s.ehlo() and without s.starttls() and it works
perfectly. My authentication problems seem to have been that the server
uses EHLO, which must be specified! Thank you very kindly.

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


Re: any() and all() on empty list?

2006-04-01 Thread Steve R. Hastings
On Sat, 01 Apr 2006 00:38:08 -0800, Steve R. Hastings wrote:
> my proposed truecount() returns a tuple, with the length and
> the count of true values.

I never liked the name truecount(), and the more I think about it, the
less I like the function.  It should either solve a very important need,
or else it should be general enough to solve multiple needs; truecount()
doesn't really do either.

I kept thinking about this, and then suddenly I remembered an idea I read
about before.  I'm not sure who invented this idea, but it wasn't me.

Here is a function called "tally()".  It reduces a list to a dictionary
of counts, with one key for each value from the list.  The value for
each key is the count of how many times it appeared in the list.


def tally(seq, d=None):
if d == None:
d = {}

for x in seq:
if x in d:
d[x] += 1
else:
d[x] = 1
return d



This neatly replaces truecount(), and you can use it for other things as
well.

Let's revisit my example from before:

> Suppose you wanted, for some reason, to know how many lines in a file
> start with a vowel:

 
vowels = frozenset("aeiouAEIOU")
f = open("a_file.txt")  # note that f is an iterator

counts = tally(line[0] in vowels for line in f)
# counts is a dict; counts.keys() == [False, True]
count_nonvowels, count_vowels = counts.values()

total = count_nonvowels + count_vowels
print "%d lines in file; %d start with a vowel" % (total, count_vowels)

-- 
Steve R. Hastings"Vita est"
[EMAIL PROTECTED]http://www.blarg.net/~steveha

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


Re: wx.checklistbox

2006-04-01 Thread Philippe Martin
Hi,

I do not see where you close the file: I beleve you need to close it to
flush information prior to reading again.

Philippe



luca72 wrote:

> i have again one simple problem:
>  the script is this:
> 
>  def output(self):
> global lista2
> lista2 = open('/lista2', 'w')
> iteminlista2 = self.checkListBox2.GetStrings()
> lista2.writelines(iteminlista2)
> 
> def input1(self):
> lista2leggi = open('/lista2', 'r')
> cd = lista2leggi.readlines()
> self.checkListBox2.AppendItems(cd)
> 
> 
> 
> The write file is like:
> 
> item1item2item3
> 
> when i read the and i put the item in the checklistbox , i don't find :
> 
> item1
> item2
> item3
> 
> but :
> 
> item1item2item3
> 
> How to do for have it like :
> 
> item1
> item2
> item3
> 
> Regards
> 
> Luca

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


Re: Logging and threading

2006-04-01 Thread usenet
As simple and as obvious as I expected, thanks Dennis.

-Alex

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


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread reedobrien
That isn't in the published 2.5 License.

http://docs.python.org/dev/ref/node110.html

Thanks for the scare..

~r

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


Re: newbie string conversion question

2006-04-01 Thread Duncan Booth
Felipe Almeida Lessa wrote:

 a = "1234567890"
 b = []
 for i in range(len(a)/2):
> ... b.append(chr(int(a[i*2:i*2+2][::-1], 16)))
> ...
 b = ''.join(b)
 print b
> !Ce�
 print repr(b)
> '!Ce\x87\t'

Alternatively:

>>> s = "1234567890"
>>> ''.join(chr(int(b+a,16)) for a,b in zip(s[::2],s[1::2]))
'!Ce\x87\t'

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


Re: python tutorial: popular/informative Python sites ?

2006-04-01 Thread gene tani

Fredrik Lundh wrote:
> the "what now?" page in the tutorial
>
> to replace it with something else, what should that be?  what sites
> do pythoneers and pythonistas visit these days?
>
> post your suggestions in this thread or on this page:
>
Pilgrims tricks/ips
http://diveintopython.org/appendix/tips.html

online cookbook
http://aspn.activestate.com/ASPN/Cookbook/Python

soem quick refs
http://www.onlamp.com/pub/a/python/excerpt/PythonPocketRef/index.html
http://rgruet.free.fr/PQR24/PQR2.4.html

tutorials
http://www.awaretek.com/tutorials.html

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


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Roy Smith
In article <[EMAIL PROTECTED]>,
 Steve Holden <[EMAIL PROTECTED]> wrote:

> As the only director of the Python Software Foundation to vote against a 
> recent Board motion to implement the change in licensing terms described in
> 
>http://pyfound.blogspot.com/2006/04/python-25-licensing-change.html
> 
> I would like to place on record my protest against this change. I think 
> it will harm the Python language and ultimately be counter-productive, 
> reducing the user base and discouraging open source programmers from 
> contributing to the code base.
> 
> If you disagree with this proposed change it's not too late to do 
> something about it. If this change goes ahead it will be the end of 
> Python as we know it.
> 
> regards
>   Steve

Absolutely agree.  This is a disaster.  Specifying the use of $US will shut 
out our friends who use quatloos or gold pressed latinum for currency.  Bad 
idea.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: PyGUI 1.7

2006-04-01 Thread greg
PyGUI 1.7 is now available:

   http://www.cosc.canterbury.ac.nz/~greg/python_gui/

New features:

   * GL.DisplayList class for managing OpenGL display
 lists in a similar way to the GL.Texture class
 introduced in 1.6.

   * Facilites for displaying a chosen cursor when the
 mouse is over a View.

   * Facilities for locating resources associated with
 an application.

Bug fixes:

   * Cocoa: Getting the extent property of a ScrollableView
 did not work.

   * Cocoa: Worked around a PyObjC bug that was causing Tasks
 to leak memory.

   * Cocoa: Request New File dialog with a file type having
 a Macintosh type code did not work.

Plus a number of other modifications, see CHANGES.txt in the
distribution for details.


What is PyGUI?
--

PyGUI is an experimental highly-Pythonic cross-platform
GUI API. Implementations are currently available for
MacOSX and Gtk. For a full description of the project
goals, see the PyGUI web page at the above address.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie string conversion question

2006-04-01 Thread Felipe Almeida Lessa
Em Sáb, 2006-04-01 às 06:17 -0800, Rohit escreveu:
> As part of a proprietary socket based protocol I have  to convert a
> string of length 10,
> 
>   say, "1234567890"
> 
> to send it as 5 characters such that their hex values are
> 
>   0x21 0x43 0x65 0x87 0x09
> 
> (Hex value of each character is got by transposing two digits at a
> time)
> 
>  How can I do this in python? I would like the result to be available
> as a string since I am concatenating it to another string before
> sending it out. 

You mean:

>>> a = "1234567890"
>>> b = []
>>> for i in range(len(a)/2):
... b.append(chr(int(a[i*2:i*2+2][::-1], 16)))
...
>>> b = ''.join(b)
>>> print b
!Ce�
>>> print repr(b)
'!Ce\x87\t'
>>> print [ord(x).__hex__() for x in b]
['0x21', '0x43', '0x65', '0x87', '0x9']

??

But I'm not sure if this is the best solution...

> Thanks,
> Rohit

HTH,

-- 
Felipe.

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

Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Grant Edwards
On 2006-04-01, Piet van Oostrum <[EMAIL PROTECTED]> wrote:
>> "Fuzzyman" <[EMAIL PROTECTED]> (F) wrote:
>
>>F> Can I ask for clarification. The charge applies to any commercial use
>>F> of a derivative work based on the Python source code ?
>
>>F> Normal applications that use Python, including bunding the standard
>>F> CPython as an executable, using tools like py2exe, won't be covered.
>>F> Right ?
>
> As I understand it, distributing Python is also covered. For a commercial
> vendor $1.25 is peanuts, but for the PSA it is a significant amount (think
> about all the Mac OSX copies if Apple decides to switch to 2.5).

I just found last night that my spankin' new Thinkpad came with
Python 2.2 pre-installed underneath an "IBMTOOLS" directory on
the C: drive.

Don't let Lenovo slide by without paying...

-- 
Grant Edwards   grante Yow!  I'll take ROAST BEEF
  at   if you're out of LAMB!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Grant Edwards
On 2006-04-01, Steve Holden <[EMAIL PROTECTED]> wrote:
> As the only director of the Python Software Foundation to vote against a 
> recent Board motion to implement the change in licensing terms described in
>
>http://pyfound.blogspot.com/2006/04/python-25-licensing-change.html

Good one Steve.

I particularly liked the Comments section. 

:)

-- 
Grant Edwards   grante Yow!  I represent a
  at   sardine!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


newbie string conversion question

2006-04-01 Thread Rohit
As part of a proprietary socket based protocol I have  to convert a
string of length 10,

say, "1234567890"

to send it as 5 characters such that their hex values are

0x21 0x43 0x65 0x87 0x09

(Hex value of each character is got by transposing two digits at a
time)

 How can I do this in python? I would like the result to be available
as a string since I am concatenating it to another string before
sending it out. 

Thanks,
Rohit

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


Re: String pattern matching

2006-04-01 Thread forward
Firstly sort variable expressions by its length

xy  = 'abca'
xyz = 'abcaaab'
vxw = 'eeabcac'

Expand all expressions by its values except itself

xy   = 'abca'
'abca' z = 'abcaaab'
vxw  = 'eeabcac'

Cut all left and right matches

xy  = 'abca'
z   = 'aab'
vxw = 'eeabcac'

Repeat until you can.

z   = 'aab'
xy  = 'abca'
vxw = 'eeabcac'

Get first variable expression intersection
- variables: x is longest intersection of xy and vxw
- value: 'abca' starting at position 2 of vxw (longest intersection
of 'abca' and 'eeabcac')
 'a' starting at position 5 of vxw

Then try matching:
x='abca' (at position 2 of vxw)
x='abc'  (at position 2 of vxw)
x='ab'   (at position 2 of vxw)
x='a'(at position 2 of vxw)
x='a'(at position 5 of vxw)
x='' (at position arbitrary position of vxw)
and calculate the others.

Repeat all step until you can.


In your example, there are 13 results.
x='abca' y='' z='aab' v='ee'  w='c'
x='abc'  y='a'z='aab' v='ee'  w='ac'
x='ab'   y='ca'   z='aab' v='ee'  w='cac'
x='a'y='bca'  z='aab' v='ee'  w='bcac'
x='a'y='bca'  z='aab' v='eeabc'   w='c'
x='' y='abca' z='aab' v=''w=''
x='' y='abca' z='aab' v='e'   w='eabcac'
x='' y='abca' z='aab' v='ee'  w='abcac'
x='' y='abca' z='aab' v='eea' w='bcac'
x='' y='abca' z='aab' v='eeab'w='cac'
x='' y='abca' z='aab' v='eeabc'   w='ac'
x='' y='abca' z='aab' v='eeabca'  w='c'
x='' y='abca' z='aab' v='eeabcac' w=''

with the same original expressions

xy  = 'abca'
xyz = 'abcaaab'
vxw = 'eeabcac'

Note that maximum matching is best matching in some kind of problems.

Cutting off empty values, you can get 4 results:
x='abc'  y='a'z='aab' v='ee'  w='ac'
x='ab'   y='ca'   z='aab' v='ee'  w='cac'
x='a'y='bca'  z='aab' v='ee'  w='bcac'
x='a'y='bca'  z='aab' v='eeabc'   w='c'

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


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread [EMAIL PROTECTED]
Look at the date.
Worry about this if it is still around tomarrow

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


Re: wx.checklistbox

2006-04-01 Thread luca72
i have again one simple problem:
 the script is this:

 def output(self):
global lista2
lista2 = open('/lista2', 'w')
iteminlista2 = self.checkListBox2.GetStrings()
lista2.writelines(iteminlista2)

def input1(self):
lista2leggi = open('/lista2', 'r')
cd = lista2leggi.readlines()
self.checkListBox2.AppendItems(cd)



The write file is like:

item1item2item3

when i read the and i put the item in the checklistbox , i don't find :

item1
item2
item3

but :

item1item2item3

How to do for have it like :

item1
item2
item3

Regards

Luca

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


Re: Tkinter divider

2006-04-01 Thread Jim Lewis
That did the trick - thanks.

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


Re: why doesn't is work?a script to backup a directory

2006-04-01 Thread obeeker
i am very sorry .
the erroer was from my Portable Hard Disk
because its disk sign has changed from "o" to "h" ,from "p" to "i"
i'm very sorry

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


Re: why doesn't is work?a script to backup a directory

2006-04-01 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> please don't read the prevous post ,please read this one:
>
> thank you for your suggestion and apologize for my mistake.
> if i run it and answer the raw_input with "Enter" i get
>
> sth is wrong
> press Return>
>
> i comment the try-except and run it and answer the raw_input with
> "Enter"
> and get message  following:
>
>
> Traceback (most recent call last):
>   File "G:\9\Eb\updateEbBb.py", line 41, in -toplevel-
> updateNow(base)
>   File "G:\9\Eb\updateEbBb.py", line 28, in updateNow
> update(d0)
>   File "G:\9\Eb\updateEbBb.py", line 16, in update
> shutil.rmtree(i)
>   File "D:\Program Files\Python24\lib\shutil.py", line 155, in rmtree
> onerror(os.listdir, path, sys.exc_info())
>   File "D:\Program Files\Python24\lib\shutil.py", line 153, in rmtree
> names = os.listdir(path)
> WindowsError: [Errno 3] : 'O:/eb/mb/S/*.*'

shutil.rmtree() expects a directory name, not a file pattern.  if you leave
out the "*.*" part at the end, it should do what you want.

(assuming you want to remove the eb/mb/S directory, that is)





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


Re: Tkinter divider

2006-04-01 Thread Fredrik Lundh
Jim Lewis wrote:

> Anyone know how to create a draggable divider between two Tkinter
> windows?

http://effbot.org/tkinterbook/panedwindow.htm

might be what you need.





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


COM Server & wxPython

2006-04-01 Thread nelson
Hi all,
 i'm doing a COM server that have to expose some graphics (panels and
configuration controls), that would be embedded in an application through
OLE. I was wondering if I can do this using wxPython. Another question is
if my COM server would inherits from one of the wxPython class. If it's
true, from which? wx.App, wx.Frame, wx.Panel.

The important thing is that i would to have the same effect that you have
when you the calendar OLE control on a Delphi or VB form (you see the
graphics ;) )

thanks,
  nelson 

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


Re: why doesn't is work?a script to backup a directory

2006-04-01 Thread obeeker
please don't read the prevous post ,please read this one:


thank you for your suggestion and apologize for my mistake.
if i run it and answer the raw_input with "Enter" i get

sth is wrong
press Return>


i comment the try-except and run it and answer the raw_input with
"Enter"
and get message  following:


Traceback (most recent call last):
  File "G:\9\Eb\updateEbBb.py", line 41, in -toplevel-
updateNow(base)
  File "G:\9\Eb\updateEbBb.py", line 28, in updateNow
update(d0)
  File "G:\9\Eb\updateEbBb.py", line 16, in update
shutil.rmtree(i)
  File "D:\Program Files\Python24\lib\shutil.py", line 155, in rmtree
onerror(os.listdir, path, sys.exc_info())
  File "D:\Program Files\Python24\lib\shutil.py", line 153, in rmtree
names = os.listdir(path)
WindowsError: [Errno 3] : 'O:/eb/mb/S/*.*'

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


Re: why doesn't is work?a script to backup a directory

2006-04-01 Thread obeeker
thank you for your suggestion and apologize for my mistake.
if i run it and answer the raw_input with "Enter" i get

sth is wrong
press Return>


i comment the try-except and run it and answer the raw_input with
"Enter"
and get message  following:


Traceback (most recent call last):
  File "G:\9\Eb\updateEbBb.py", line 41, in -toplevel-
updateNow(base)
  File "G:\9\Eb\updateEbBb.py", line 28, in updateNow
update(d0)
  File "G:\9\Eb\updateEbBb.py", line 16, in update
shutil.rmtree(i)
  File "D:\Program Files\Python24\lib\shutil.py", line 155, in rmtree
onerror(os.listdir, path, sys.exc_info())
  File "D:\Program Files\Python24\lib\shutil.py", line 153, in rmtree
names = os.listdir(path)
WindowsError: [Errno 3] : 'O:/eb/mb/SCIL/*.*'

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


Tkinter divider

2006-04-01 Thread Jim Lewis
Anyone know how to create a draggable divider between two Tkinter
windows?

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


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Kent Johnson
[EMAIL PROTECTED] wrote:
> Aww, but I liked the idea of copying Perl 6 REs, and porting python to
> the toy CPU :-)

I think if PSF is going to support porting of Python to "toy" CPUs then 
the Digi-Comp should be the first target. This will breathe new life 
into these toys which for years have been relegated to the backs of 
closets and dusty attics. Having a modern programming language available 
will bring them out of the dark ages of counters and logic tables and 
make them useful for such purposes as web servers and biological 
research. And for the developers or others who need to target this 
platform, it is again in production.
http://paperforest.blogspot.com/2006/02/digi-comp-1.html

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


Re: running IDLE from another program?

2006-04-01 Thread Kent Johnson
John Salerno wrote:
> Kent Johnson wrote:
> 
>>John Salerno wrote:
>>
>>>Kent Johnson wrote:
>>>
You probably don't need to do that. Just run the file in python 
directly. I don't know UE, but when you configure an external tool, tell 
it to run python.exe and pass the current file as a command line parameter.

>>>
>>>I've tried a lot of combinations for the command line to execute, but 
>>>nothing is working. What format should it be in? Should it look like this:
>>>
>>>C:\Python24\python.exe module   ?
>>
>>C:\Python24\python.exe D:\full\path\to\myprogram.py
>>
>>There is a post on the UltraEdit forum from JohnJSal, is that not you? 
>>Whoever it is got this working...
>>http://www.ultraedit.com/index.php?name=Forums&file=viewtopic&t=2732&highlight=python
>>
>>Kent
> 
> 
> Yes, that's me. :) But all that that post accomplished was getting me to 
> run the file itself, as if I had double-clicked on it. This isn't what I 
> want. I want it to run in a 'debug' type of environment like IDLE so I 
> can see any error messages.

I'm not sure what you mean by a 'debug' type environment. If you mean, 
you want to run the program in a debugger and step through it, then this 
approach won't work. If you just mean that you want to see the output of 
the program, it will work.
> 
> I tried your suggestion and seems to half-way work. But it doesn't open 
> the program in a different environment (such as IDLE), it just opens the 
> output in a new text window in UE. Here's the output:
> 
> ['qIQNlQSLi', 'eOEKiVEYj', 'aZADnMCZq', 'bZUTkLYNg', 'uCNDeHSBj', 
> 'kOIXdKBFh', 'dXJVlGZVm', 'gZAGiLQZx', 'vCJAsACFl', 'qKWGtIDCj']
> Traceback (most recent call last):
>File "C:\Python24\myscripts\challenge\small_letter.py", line 15, in ?
>  raw_input()
> EOFError: EOF when reading a line

OK, your program is reading from standard input and the environment set 
up by UltraEdit doesn't support this. If you are trying to run 
interactive programs this approach won't work.
> 
> 
> The list is the output from the script. I don't know why the end of file 
> error is raised though, because it wouldn't have been raised if I ran 
> the file in IDLE. So something still isn't quite right.

Because IDLE does support input.

I may have put too much interpretation on your original question because 
I have my editor (TextPad) configured to run the front window in Python 
and I find it a very productive way to work. But it's not IDLE and it 
doesn't allow interactive input. I rarely write a program that requires 
keyboard input so that's not a problem for me.

One thing that is really useful about running in an editor window is 
that (in TextPad, anyway) I can double-click on an error message and go 
directly to the line with the error.

Anyway, it turns out IDLE has a command-line switch that lets you pass a 
file to run. Try
C:\Python24\Lib\idlelib\idle -r C:\path\to\myprog.py

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


Re: Doc suggestions (was: Why "class exceptions" are not deprecated?)

2006-04-01 Thread Fredrik Lundh
Ed Singleton wrote:

> I'm not much of an expert in anything yet, but I had an idea, and then
> managed to put the documents in a wiki, which was at least trying to
> do something.  Fredrik beat me to it and did a much better job, but
> even so I feel quite proud that I did something and tried to move
> things on, rather than just post to a mailing list and hope someone
> else does it.

and for the record: the infogami setup had never happened if Ed hadn't
written that post.

(sure, the wiki idea isn't new, and I've been investigating edit-through-
the-web solutions a lot lately in response to the python.org fiasco, but
there's a lot of stop energy in the python universe these days.  python
needs more "let's try it; it may work" and less "let's set up a committee
and thoroughly investigate all possible technical solutions before anyone
is allowed to do anything"...)





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


python tutorial: popular/informative Python sites ?

2006-04-01 Thread Fredrik Lundh
the "what now?" page in the tutorial

http://www.python.org/doc/tut/node14.html

lists a couple of relevant web sites for Python users, including:

http://www.python.org
http://starship.python.net
http://www.python.org/pypi

the starship link has been there since 1998 or so (Python 1.5), but
I don't think the starship is very active these days.  but if we were
to replace it with something else, what should that be?  what sites
do pythoneers and pythonistas visit these days?

post your suggestions in this thread or on this page:

http://pytut.infogami.com/node14.html

thanks /F



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


Re: Should any() and all() take a key= argument?

2006-04-01 Thread Felipe Almeida Lessa
Em Sáb, 2006-04-01 às 20:44 +1000, Steven D'Aprano escreveu:
> Here's another way of doing it:
> 
> lst = [2, 4, 42]
> any(map(lambda x: x==42, lst))

In fact, as we're talking about Python 2.5 anyway, it would be better
not to waste memory and use:

any(x == 42 for x in lst)

-- 
Felipe.

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

String pattern matching

2006-04-01 Thread Jim Lewis
Anyone have experience with string pattern matching?
I need a fast way to match variables to strings. Example:

string - variables

abcaaab - xyz
abca - xy
eeabcac - vxw

x matches abc
y matches a
z matches aab
w maches ac
v maches ee

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


Re: packaging question - documentation

2006-04-01 Thread schwehr
Sorry about not being clear.  I have been downloading quite a few
packages for examples, but have not found a good example of man page
building from optparse.

seismic-py
   - setup.py
   - seismic
- __init.py__
- bulk of the code *.py
   - scripts
- programs that go in bin/the users executable path (no .py
extension)

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


Re: Should any() and all() take a key= argument?

2006-04-01 Thread Steven D'Aprano
On Fri, 31 Mar 2006 22:35:10 -0800, Steve R. Hastings wrote:

> The list.sort() method accepts a "key=" parameter to let you specify a
> function that will change the way it sorts.  In Python 2.5, min() and
> max() now accept a "key=" parameter that changes how the functions decide
> min or max.
> 
> Should any() and all() take a key= argument?
> 
> Example:
> 
 lst = [2, 4, 42]
 any(lst, key=lambda x: x == 42)
> True

In my opinion, that's an abuse of the term "key".

Here's another way of doing it:

lst = [2, 4, 42]
any(map(lambda x: x==42, lst))


> I kind of like the key= option.  The need isn't as strong as with
> .sort(), min(), and max(), but consistency can be a good thing.  I'd
> personally like to see key= anywhere it makes sense.

This isn't one of those places.


-- 
Steven.

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


Re: why doesn't is work?a script to backup a directory

2006-04-01 Thread Steven D'Aprano
On Fri, 31 Mar 2006 18:37:11 -0800, obeeker wrote:

> """there is threee directories,one of these is used for the base
> directory,decided by the user, default is d0"""

[snip code]

It doesn't work? Have you tried running it to see what it does? When you
do, please post a description of what it does, including any exception
tracebacks, and just as importantly, what you expect it to do.


-- 
Steven.

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


Re: DO NOT USE JAVA BECAUSE IT IS NOT OPEN SOURCE

2006-04-01 Thread steve
On Sat, 1 Apr 2006 13:06:52 +0800, Luc The Perverse wrote
(in article <[EMAIL PROTECTED]>):

> <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> Programing Languiges Are Ment to be free. That is why i am starting The
>> Coo De Tar thats french for Blow of state it is a flash/java
>> alternative and if you are going to use a server side languige use
>> Perl,Python or better yet Ruby. What is the point of a languige without
>> a standerd and without a open source distrabution. Coo De Tar will be
>> released as a api for perl,python and ruby. Java sucks because it IS
>> NOT FREE. I AM A GNU GUY I BELEVE THAT SOFTWARE MUST AND SHALL BE
>> FREE!! do not use java because it is an oxymoron
>> 
> 
> Dear Mr Troll,
> 
> There are GNU implementations of JVM and compiler.
> 
> And just because Sun's Java is not GNU does not mean it is not free.
> 
> Now go get a life.
> 
> --
> LTP
> 
>>> 
> 
> 

it's April 1st remember

-- 
NewsGuy.Com 30Gb $9.95 Carry Forward and On Demand Bandwidth
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread bearophileHUGS
Ivan Herman>I would certainly look at *all details* of the
announcement,<

Aww, but I liked the idea of copying Perl 6 REs, and porting python to
the toy CPU :-)
(But making strings mutable sounds too much strange).

Bye and thank you,
bearophile

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


Re: a simple regex question

2006-04-01 Thread Roel Schroeven
John Salerno schreef:
>> pattern = '([a-z][A-Z]{3}[a-z][A-Z]{3}[a-z])+'
>> print re.search(pattern, mess).groups()
>>
>> Anyway, this returns one matching string, but when I put this letter in 
>> as the solution to the problem, I get a message saying "yes, but there 
>> are more", so assuming this means that there is more than one character 
>> with three caps on either side, is my RE written correctly to find them 
>> all? I didn't have the parentheses or + sign at first, but I added them 
>> to find all the possible matches, but still only one comes up.
>>
>> Thanks.
> 
> A quick note: I found nine more matches by using findall() instead of 
> search(), but I'm still curious how to write the RE so that it works 
> with search, especially since findall wouldn't have returned overlapping 
> matches. I guess I didn't write it to properly check multiple times.

It seems to me you should be able to find all matches with search(). Not 
with the pattern you mention above: that will only find matches if they 
come right after each other, as in
xXXXxXXXxyYYYyYYYyzZZZzZZZz

You'll need something more like
pattern = '([a-z][A-Z]{3}[a-z][A-Z]{3}[a-z]+)+'
so that it will find matches that are further apart from each other.

That said, I think findall() is a better solution for this problem. I 
don't think search() will find overlapping matches either, so that's no 
reason not to use findall(), and the pattern is simpler with findall(); 
I solved this challenge with findall() and this regular expression:

pattern = r'[a-z][A-Z]{3}[a-z][A-Z]{3}[a-z]'


-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

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


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Ivan Herman
I would certainly look at *all details* of the announcement, including
the second line from the top which gives the date:-)

Ivan


Caleb Hattingh wrote:
> WAIT-
> 
> Did I just get caught by an April Fools Joke?
> 
> I have a nasty feeling about this :))
> 
> C
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Piet van Oostrum
> "Fuzzyman" <[EMAIL PROTECTED]> (F) wrote:

>F> Can I ask for clarification. The charge applies to any commercial use
>F> of a derivative work based on the Python source code ?

>F> Normal applications that use Python, including bunding the standard
>F> CPython as an executable, using tools like py2exe, won't be covered.
>F> Right ?

As I understand it, distributing Python is also covered. For a commercial
vendor $1.25 is peanuts, but for the PSA it is a significant amount (think
about all the Mac OSX copies if Apple decides to switch to 2.5).
-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4.3 Documentation: Bad link

2006-04-01 Thread bones17
Now, it works well... I really don't know why it before report 404 Not
Found... I was tested it 5x... I'm sorry for unwanted false bug report.

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


  1   2   >