Re: Python 2.5 install on Gentoo Linux: failed dmb and _tkinter

2007-01-12 Thread Martin v. Löwis
Sorin Schwimmer schrieb:
>> Did you add /usr/local/lib to /etc/ld.so.conf?
> 
> It's there

It is it also listed with "ldconfig -p"?

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python nuube needs Unicode help

2007-01-12 Thread Peter Otten
[EMAIL PROTECTED] wrote:

> HELP!
> Guy who was here before me wrote a script to parse files in Python.
> 
> Includes line:
> print u

According to your other posts 'u' seems to be an instance of a custom
Utterance class with a __str__() method that accidentally returns unicode.
Try changing the print statement to

print unicode(u)

If you're lucky, it works. Otherwise we need a piece of the actual code. To
give you an idea what a self-contained demonstration of your problem might
look like:

>>> class Utterance(object):
... def __str__(self): return u"äöü"
...
>>> u = Utterance()
>>> print u
Traceback (most recent call last):
  File "", line 1, in 
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2:
ordinal not in range(128)
>>> print unicode(u)
äöü

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


RE: Learning Python book, new edition?

2007-01-12 Thread Demel, Jeff
John wrote:
>So what happens with google bots etc... Information provided 
>in the email could be helpful to others that are NOT the original 
> recipient.  And what happens to the archive stuff?

I will forward your response to our crack legal department.  Perhaps
they can help you with your very astute questions.

-Jeff
This email is intended only for the individual or entity to which it is 
addressed.  This email may contain information that is privileged, confidential 
or otherwise protected from disclosure. Dissemination, distribution or copying 
of this e-mail or any attachments by anyone other than the intended recipient, 
or an employee or agent responsible for delivering the message to the intended 
recipient, is prohibited. If you are not the intended recipient of this message 
or the employee or agent responsible for delivery of this email to the intended 
recipient, please notify the sender by replying to this message and then delete 
it from your system.  Any use, dissemination, distribution, or reproduction of 
this message by unintended recipients is strictly prohibited and may be 
unlawful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: maximum number of threads

2007-01-12 Thread Hendrik van Rooyen
 "William Heymann" <[EMAIL PROTECTED]> wrote:


> So you know I tried this on ubuntu edgy 64bit edition on a dual 2218 opteron 
> system with 8G of ram and I got
> 
> 
> Exception raised: can't start new thread
> Biggest number of threads: 32274
> 

This almost looks as if the number of threads is a sixteen bit signed int... 

- Hendrik

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


Re: What happened to SPE?

2007-01-12 Thread Paulo Pinto
Hi,

Thanks for the feedback.
Paulo 


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


pygame and python 2.5

2007-01-12 Thread siggi
Hi all,

when I rtry to install pygame (pygame-1.7.1release.win32-py2.4.exe, the most
ciurrent version I found) it requires Python 2.4! Will I really have to
uninstall my Python 2.5  and install the old Python 2.4 in order to use
pygame?

Thanks,

Siggi



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


Re: Maths error

2007-01-12 Thread Nick Maclaren

In article <[EMAIL PROTECTED]>,
"Hendrik van Rooyen" <[EMAIL PROTECTED]> writes:
|> 
|> I would have thought that this sort of thing was a natural consequence
|> of rounding errors - if I round (or worse truncate) a binary, I can be off
|> by at most one, with an expectation of a half of a least significant digit,
|> while if I use hex digits, my expectation is around eight, and for decimal
|> around five...
|> 
|> So it would seem natural that errors would propagate 
|> faster on big base systems, AOTBE, but this may be 
|> a naive view.. 

Yes, indeed, and that is precisely why the "we must use binary" camp won
out.  The problem was that computers of the early 1970s were not quite
powerful enough to run real applications with simulated floating-point
arithmetic.  I am one of the half-dozen people who did ANY actual tests
on real numerical code, but there may have been some work since!

Nowadays, it would be easy, and it would make quite a good PhD.  The
points to look at would be the base and the rounding rules (including
IEEE rounding versus probabilistic versus last bit forced[*]).  We know
that the use or not of denormalised numbers and the exact details of
true rounding make essentially no difference.

In a world ruled by reason rather than spin, this investigation
would have been done before claiming that decimal floating-point is an
adequate replacement for binary for numerical work, but we don't live
in such a world.  No matter.  Almost everyone in the area agrees that
decimal floating-point isn't MUCH worse than binary, from a numerical
point of view :-)


[*] Assuming signed magnitude, calculate the answer truncated towards
zero but keep track of whether it is exact.  If not, force the last
bit to 1.  An old, cheap approximation to rounding.


Regards,
Nick Maclaren.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to run external program?

2007-01-12 Thread Lad
How  can I run external program from Python?
I use Python with XP
Thank you for help
LB

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


Re: How to run external program?

2007-01-12 Thread Gary Herron
Lad wrote:
> How  can I run external program from Python?
> I use Python with XP
> Thank you for help
> LB
>
>   
The subprocess module is what you want for this.

It's got ways of running external executables as separate subprocesses, 
and interacting with the subprocess and both its input and output.

Gary Herron

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


Re: pygame and python 2.5

2007-01-12 Thread Ben Sizer
siggi wrote:

> when I rtry to install pygame (pygame-1.7.1release.win32-py2.4.exe, the most
> ciurrent version I found) it requires Python 2.4! Will I really have to
> uninstall my Python 2.5  and install the old Python 2.4 in order to use
> pygame?

For now, yes. This is a long-standing problem with Python really,
requiring extensions to always be recompiled for newer versions. I
usually have to wait about 6 months to a year after any new release
before I can actually install it, due to the extension lag.

-- 
Ben Sizer

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


Re: How to modify object attribute by python C API

2007-01-12 Thread Ben Sizer
Huayang Xia wrote:

> PyObject* py_obj_attr1 = PyObject_GetAttrString(obj, "attr1");
> PyObject_SetAttrString(py_obj_attr1, "attr2",
> PyString_FromString("a"));
> Py_DECREF(py_obj_attr1);
>
> The object py_obj_attr1 is said to be a "New reference". It's
> confusing, does it refer to the same object as "obj.attr1" in python's
> term?

Yes, it refers to the same object. Each object can have many
references, and is deleted when all the references are gone. The new
reference in this case means that Python has taken note that there's a
new use of that object - your C code. It means it won't delete that
object, even if no more Python code refers to it, because it knows your
C code holds a reference to it. Therefore, when your C code no longer
needs to access the object, you call Py_DECREF.

-- 
Ben Sizer

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


Re: pygame and python 2.5

2007-01-12 Thread Laurent Pointal
siggi a écrit :
> Hi all,
> 
> when I rtry to install pygame (pygame-1.7.1release.win32-py2.4.exe, the most
> ciurrent version I found) it requires Python 2.4! Will I really have to
> uninstall my Python 2.5  and install the old Python 2.4 in order to use
> pygame?

Note: You can have both versions installed, just be sure to use the
right one when using pygame (until there is a 2.5 compatible version).

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


Re: How to run external program?

2007-01-12 Thread Lad

Gary Herron wrote:
> Lad wrote:
> > How  can I run external program from Python?
> > I use Python with XP
> > Thank you for help
> > LB
> >
> >
> The subprocess module is what you want for this.
>
> It's got ways of running external executables as separate subprocesses,
> and interacting with the subprocess and both its input and output.
>
 Gary ,
Thank you for your reply.
I use os.popen3 but it does not work properly for me all the time.

Here is a part of my Python  program
I use an external  program ( here mpeg.exe) for converting sourcefile
into targetfile
###...
...
...
mpeg = "mpeg.exe -i %s codec mp3  -s 320x240 %s" % (sourcefile,
targetfile)
stdin, stdout, stderr = os.popen3(mpeg)
mpegresult = stdout.read()
mpegerrors = stderr.read()
stdin.close(); stdout.close(); stderr.close()
print ffmpegerrors
print ffmpegresult
#

It works  if the sourcefile is small but if it is large( 30MB) it does
NOT work.It hangs or the file is not converted in full.
Any advice how I should change the program?
Thank you.
L.

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


Re: Is there a good example on instantiating, calling, using, an API from Python on Windows?

2007-01-12 Thread Ben Sizer
kj7ny wrote:

> To be more exact, I am trying to use Python to talk to a Livelink
> system (http://www.opentext.com/) through their LAPI interface (.dll's,
> I think).  I'll see if I can generate a more intelligent answer to your
> question, but for now, I'm far enough in the dark that this is as good
> as I can get.

API is a vague term referring to the interface to an application, which
could take one of many forms. The form it takes dictates the method you
need to use here.

If indeed it is via DLLs, then the ctypes module may help. Otherwise,
you need to find out precisely what form the API takes.

-- 
Ben Sizer

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


Re: maximum number of threads

2007-01-12 Thread Ganesan Rajagopal
> Felipe Almeida Lessa <[EMAIL PROTECTED]> writes:
>> 
>> to modify the maximum number of user process (AFAIK each thread use a
>> process entry on Linux)

> I don't think it's only this.

It isn't that at all. The default Linux POSIX threads stack size is
8MB. Linux user space is 3GB (Kernel is mapped at upper 1GB). 

382 * 8 = 3056MB.

Basically, you're running out of address space. I don't know if you have any
control at python level. In C you can call pthread_attr_setstacksize(). 

Ganesan

-- 
Ganesan Rajagopal

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


Re: Parallel Python

2007-01-12 Thread Paul Boddie
[EMAIL PROTECTED] wrote:
>
> The main difference between MPI python solutions and ppsmp is that with
> MPI you have to organize both computations
> {MPI_Comm_rank(MPI_COMM_WORLD, &id); if id==1 then ... else } and
> data distribution (MPI_Send / MPI_Recv) by yourself. While with ppsmp
> you just submit a function with arguments to the execution server and
> retrieve the results later.

Couldn't you just provide similar conveniences on top of MPI? Searching
for "Python MPI" yields a lot of existing work (as does "Python PVM"),
so perhaps someone has already done so. Also, what about various grid
toolkits?

[...]

> Overall ppsmp is still work in progress and there are other interesting
> features which I would like to implement. This is the main reason why I
> do not open the source of ppsmp - to have better control of its future
> development, as advised here: http://en.wikipedia.org/wiki/Freeware :-)

Despite various probable reactions from people who will claim that
they're comfortable with binary-only products from a single vendor, I
think more people would be inclined to look at your software if you did
distribute the source code, even if they then disregarded what you've
done. My own experience with regard to releasing software is that even
with an open source licence, most people are likely to ignore your
projects than to suddenly jump on board and take control, and even if
your project somehow struck a chord and attracted a lot of interested
developers, would it really be such a bad thing? Many developers have
different experiences and insights which can only make your project
better, anyway.

Related to your work, I've released a parallel execution solution
called parallel/pprocess [1] under the LGPL and haven't really heard
about anyone really doing anything with it, let alone forking it and
showing my original efforts in a bad light. Perhaps most of the
downloaders believe me to be barking up the wrong tree (or just
barking) with the approach I've taken, but I think the best thing is to
abandon any fears of not doing things the best possible way and just be
open to improvements and suggestions.

Paul

[1] http://www.python.org/pypi/parallel

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


Re: Integer solutions to linear equation?

2007-01-12 Thread scolnik
http://mathworld.wolfram.com/DiophantineEquation.html

You can use this web application for solving diophantine equations:

http://www.math.uwaterloo.ca/~snburris/htdocs/linear.html

Hugo Scolnik

Imagination is more important than knowledge.-- 
http://mail.python.org/mailman/listinfo/python-list

Integer solutions to linear equation?

2007-01-12 Thread scolnik
The answer to your integer solutions problem can be found in

http://www.alpertron.com.ar/QUAD.HTM

Best

Hugo Scolnik

Imagination is more important than knowledge.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Read from database, write to another database, simultaneously

2007-01-12 Thread Paul Boddie
Dennis Lee Bieber wrote:
>  The problem though, is that the original poster claimed the Oracle
> data was being emitted in multiple chunks, not as a single output -- and
> they want to avoid collecting the data in a temporary file...

I think he wanted to know whether concurrent reads from Oracle and
writes to PostgreSQL would be faster or more efficient. I'd argue that
the temporary file approach is likely to be faster and more efficient
(disk space usage for temporary files disregarded). Sure, if you can
have two concurrent processes with minimal contention, one reading from
Oracle, one writing to PostgreSQL, where the PostgreSQL one never lags
behind and thus completes shortly after the Oracle data has been
completely downloaded, then that might be the ideal solution, but I'm
inclined to believe that unless the stream of data from Oracle were
arriving really slowly, it wouldn't work out that way.

Anyway, that's what my experiences with PostgreSQL suggest so far.
Further commentary on the topic is, as noted, available in the manual.

Paul

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


Re: Learning Python book, new edition?

2007-01-12 Thread Steven Wayne
On Thu, 11 Jan 2007 16:42:34 -0600, Demel, Jeff
<[EMAIL PROTECTED]> wrote:
> John wrote:
>>So what happens with google bots etc... Information provided 
>>in the email could be helpful to others that are NOT the original 
>> recipient.  And what happens to the archive stuff?
>
> I will forward your response to our crack legal department.  Perhaps
> they can help you with your very astute questions.
>
> -Jeff
> This email is intended only for the individual or entity to which it is
> addressed.

Hi,

Don't take this the wrong way, but this isn't an email, it's a usenet
posting.

I'm also not the "individual or entity to which it is addressed" because
I read it from a news server and it was addressed to "comp.lang.python".

>This email may contain information that is privileged,
> confidential or otherwise protected from disclosure.

Then you would do well to not publish it in a public forum.

>Dissemination,
> distribution or copying of this e-mail or any attachments by anyone
> other than the intended recipient, or an employee or agent responsible
> for delivering the message to the intended recipient, is prohibited.

So if this /were/ actually an email you've just given permission for an
admin of any mail server the email passes through to disseminate or copy
it.

For those not aware:

Disseminate:

Verb:  disseminate - cause to become widely known; "spread information";
"circulate a rumor"; "broadcast the news"

>  If
> you are not the intended recipient of this message or the employee or
> agent responsible for delivery of this email to the intended recipient,
> please notify the sender by replying to this message and then delete it
> from your system. Any use, dissemination, distribution, or reproduction
> of this message by unintended recipients is strictly prohibited and may
> be unlawful.

Unlawful how? You've already given permission for an "agent responsible
for delivering the message" to broadcast it around the world.

Sorry for the rant, but I'm an email admin and I've just been told about
the change to UK law.

I'm giving our legal department even more grief.

Steven
-- 
 .''`.
: :'  :
`. `'`
  `-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to run external program?

2007-01-12 Thread Viewer T.

Lad wrote:
> How  can I run external program from Python?
> I use Python with XP
> Thank you for help

A possible way to do this is the following:
Let's say we want to run a program called program.exe from the path
C/Program/Program.exe. We would first need to import the os module and
type the following:

import os#import the os module
path = 'C:/Program/Program.exe'  #give the pathname of the external
program as a string
os.system(path)  #execute the program from
python using the os module

There are many other ways, but this should work for short pathnames
without spaces.

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


Re: Learning Python book, new edition?

2007-01-12 Thread Duncan Booth
Steven Wayne <[EMAIL PROTECTED]> wrote:

> Don't take this the wrong way, but this isn't an email, it's a usenet
> posting.

It is now, but it started as an email. If you examine its headers he sent 
it to the list but the list administrator had set up software up to copy 
the email to a newsgroup. Fortunately, as you said, the email gave him 
permission to do that otherwise the entire legal profession might have 
collapsed under its own weight.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to protect a piece of critical code?

2007-01-12 Thread robert
Hendrik van Rooyen wrote:
> "robert" <[EMAIL PROTECTED]> wrote:
> 
> 
>> pushing data objects through an inter-thread queue is a major source for
> trouble - as this thread shows again.
>> Everybody builds up a new protocol and worries about Empty/Full,
> Exception-handling/passing, None-Elements, ...
>> I've noticed that those troubles disappear when a functional queue is used -
> which is very easy with a functional language like Python.
>> For example with
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491281
>>
>> One would just use a  cq=CallQueue()
>>
>> On the producer side one would just write the functional code one wants to
> execute in a target thread:
>> cq.call( what_i_want_do_func )
>>
>>
>> The consumer/receiver thread would just do (periodically) a non-blocking
>>
>> cq.receive()
>>
>>
>> => Without any object fumbling, protocol worries and very fast.
>>
>> And note: This way - working with functional jobs - one can also "protect a
> piece of critical code" most naturally and specifically for certain threads
> without spreading locks throughout the code.
>> Even things which are commonly claimed "forbidden" (even when using lots of
> locks) can be magically done in perfect order and effectively this way. Think 
> of
> worker threads doing things in the GUI or in master / database owner threads
> etc.
>> Similarly discrete background thread jobs can be used in a functional style
> this way:
>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491280
>> ( an alternative for the laborious OO-centric threading.Thread which mostly 
>> is
> a lazy copy from Java )
>> or for higher job frequencies by using "default consumer threads" as also
> shown in the 1st example of
>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491281
>>
> 
> Thank you - had a (very) quick look and I will return to it
> later - It is not immediately obvious to my assembler
> programmer's mentality - looks like in the one case
> the thread starts up, does its job and then dies, and in
> the other its a sort of "remote" daemon like engine,
> that you can "tell what to do", from "here"...
> 
> Both concepts seem nice and I will try to wrap my head
> around them properly.
> 
> So far I have only used dicts to pass functions around
> in a relatively unimaginative static jump table like way...


Probably one has just to see that one can a pass a function object 
(or any callable) around as any other object.
Similar to a function address in assembler/C but very comfortable 
and with the comfort of closures (which automatically hold the 
status of local variables):

def f():
 print "hello"

def g(func):
 print "I'll do it ..."
 func()
 print "done."


def run(x):
 g(f)
 a="local variable\n"
 def h():
 b="inner local"
 print "inner function"
 print x,a,b
 g(h)
 g(lambda:sys.stdout.write(a))

run(1)



 From there its just natural to not pass dead objects through an 
inter-thread queue, but just code as it or even a "piece of 
critical code" ...
A small step in thought, but a big step in effect - soon 
eliminating bunches of worries about queues, pop-races/None 
objects, protocol, serialization, critical sections, thousands of 
locks etc.


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


Re: Parallel Python

2007-01-12 Thread Nick Maclaren

In article <[EMAIL PROTECTED]>,
"Paul Boddie" <[EMAIL PROTECTED]> writes:
|> [EMAIL PROTECTED] wrote:
|> >
|> > The main difference between MPI python solutions and ppsmp is that with
|> > MPI you have to organize both computations
|> > {MPI_Comm_rank(MPI_COMM_WORLD, &id); if id==1 then ... else } and
|> > data distribution (MPI_Send / MPI_Recv) by yourself. While with ppsmp
|> > you just submit a function with arguments to the execution server and
|> > retrieve the results later.
|> 
|> Couldn't you just provide similar conveniences on top of MPI? Searching
|> for "Python MPI" yields a lot of existing work (as does "Python PVM"),
|> so perhaps someone has already done so. 

Yes.  No problem.

|> Also, what about various grid toolkits?

If you can find one that is robust enough for real work by someone who
is not deeply into developing Grid software, I will be amazed.


Regards,
Nick Maclaren.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Learning Python book, new edition?

2007-01-12 Thread Steven D'Aprano
On Fri, 12 Jan 2007 04:50:21 -0600, Steven Wayne wrote:

[snip stupid disclaimer and response to it]

> Unlawful how? You've already given permission for an "agent responsible
> for delivering the message" to broadcast it around the world.
> 
> Sorry for the rant, but I'm an email admin and I've just been told about
> the change to UK law.

What change to UK law?

> I'm giving our legal department even more grief.

For those interested in an amateur analysis of email disclaimers:

http://goldmark.org/jeff/stupid-disclaimers/

If you get a Forbidden error, try going to the top level of the site first
http://goldmark.org/ and navigating down by following links. Try not to
laugh at all the "an error occurred while processing this directive"
messages.



-- 
Steven.

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


Re: Parallel Python

2007-01-12 Thread robert
Paul Boddie wrote:
> [EMAIL PROTECTED] wrote:
>> The main difference between MPI python solutions and ppsmp is that with
>> MPI you have to organize both computations
>> {MPI_Comm_rank(MPI_COMM_WORLD, &id); if id==1 then ... else } and
>> data distribution (MPI_Send / MPI_Recv) by yourself. While with ppsmp
>> you just submit a function with arguments to the execution server and
>> retrieve the results later.
> 
> Couldn't you just provide similar conveniences on top of MPI? Searching
> for "Python MPI" yields a lot of existing work (as does "Python PVM"),
> so perhaps someone has already done so. Also, what about various grid
> toolkits?
> 
> [...]
> 
>> Overall ppsmp is still work in progress and there are other interesting
>> features which I would like to implement. This is the main reason why I
>> do not open the source of ppsmp - to have better control of its future
>> development, as advised here: http://en.wikipedia.org/wiki/Freeware :-)
> 
> Despite various probable reactions from people who will claim that
> they're comfortable with binary-only products from a single vendor, I
> think more people would be inclined to look at your software if you did
> distribute the source code, even if they then disregarded what you've
> done. My own experience with regard to releasing software is that even
> with an open source licence, most people are likely to ignore your
> projects than to suddenly jump on board and take control, and even if
> your project somehow struck a chord and attracted a lot of interested
> developers, would it really be such a bad thing? Many developers have
> different experiences and insights which can only make your project
> better, anyway.
> 
> Related to your work, I've released a parallel execution solution
> called parallel/pprocess [1] under the LGPL and haven't really heard
> about anyone really doing anything with it, let alone forking it and
> showing my original efforts in a bad light. Perhaps most of the
> downloaders believe me to be barking up the wrong tree (or just
> barking) with the approach I've taken, but I think the best thing is to
> abandon any fears of not doing things the best possible way and just be
> open to improvements and suggestions.
> 
> Paul
> 
> [1] http://www.python.org/pypi/parallel

I'd be interested in an overview.
For ease of use a major criterion for me would be a pure python 
solution, which also does the job of starting and controlling the 
other process(es) automatically right (by default) on common 
platforms.
Which of the existing (RPC) solutions are that nice?


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


Re: Learning Python book, new edition?

2007-01-12 Thread Steven Wayne
On 12 Jan 2007 11:06:29 GMT, Duncan Booth
<[EMAIL PROTECTED]> wrote:
> Steven Wayne <[EMAIL PROTECTED]> wrote:
>
>> Don't take this the wrong way, but this isn't an email, it's a usenet
>> posting.
>
> It is now, but it started as an email. If you examine its headers he sent 
> it to the list but the list administrator had set up software up to copy 
> the email to a newsgroup.

There's a list?

>   Fortunately, as you said, the email gave him 
> permission to do that otherwise the entire legal profession might have 
> collapsed under its own weight.

:-)

Not seeing a down side to that.

But it brings up and interesting point.

Is automatic email to newsgroup software now defunct?

What if the disclaimer were better written and it forbade such an action?


Steven
-- 
 .''`.
: :'  :
`. `'`
  `-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parallel Python

2007-01-12 Thread Neal Becker
[EMAIL PROTECTED] wrote:

> Has anybody tried to run parallel python applications?
> It appears that if your application is computation-bound using 'thread'
> or 'threading' modules will not get you any speedup. That is because
> python interpreter uses GIL(Global Interpreter Lock) for internal
> bookkeeping. The later allows only one python byte-code instruction to
> be executed at a time even if you have a multiprocessor computer.
> To overcome this limitation, I've created ppsmp module:
> http://www.parallelpython.com
> It provides an easy way to run parallel python applications on smp
> computers.
> I would appreciate any comments/suggestions regarding it.
> Thank you!
> 

Looks interesting, but is there any way to use this for a cluster of
machines over a network (not smp)?

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


Re: Learning Python book, new edition?

2007-01-12 Thread Steven Wayne
On Fri, 12 Jan 2007 22:44:33 +1100, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Fri, 12 Jan 2007 04:50:21 -0600, Steven Wayne wrote:
>
> [snip stupid disclaimer and response to it]
>
>> Unlawful how? You've already given permission for an "agent responsible
>> for delivering the message" to broadcast it around the world.
>> 
>> Sorry for the rant, but I'm an email admin and I've just been told about
>> the change to UK law.
>
> What change to UK law?

http://www.theregister.co.uk/2006/12/21/new_web_email_regulation/


Steven
-- 
 .''`.
: :'  :
`. `'`
  `-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parallel Python

2007-01-12 Thread Paul Boddie
robert wrote:
> Paul Boddie wrote:
> >
> > [1] http://www.python.org/pypi/parallel
>
> I'd be interested in an overview.

I think we've briefly discussed the above solution before, and I don't
think you're too enthusiastic about anything using interprocess
communication, which is what the above solution uses. Moreover, it's
intended as a threading replacement for SMP/multicore architectures
where one actually gets parallel execution (since it uses processes).

> For ease of use a major criterion for me would be a pure python
> solution, which also does the job of starting and controlling the
> other process(es) automatically right (by default) on common
> platforms.
> Which of the existing (RPC) solutions are that nice?

Many people have nice things to say about Pyro, and there seem to be
various modules attempting parallel processing, or at least some kind
of job control, using that technology. See Konrad Hinsen's
ScientificPython solution for an example of this - I'm sure I've seen
others, too.

Paul

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


Re: Tools Designing large/complicated applications

2007-01-12 Thread Torabisu

Carl J. Van Arsdall wrote:
> For those of you that work on larger applications but still code in
> python... do your development teams use any tools to facilitate the
> design? (i'm not asking about editors here, i'm really asking about
> software design tools)  Are these the same tools you would use to help
> engineer software in another language?
>
> Is there anyone here who is forced to use a tool to design python
> software that completely hates it?  Why do you hate it?
>
> Thanks!
>
> -carl
>
>
> --
>
> Carl J. Van Arsdall
> [EMAIL PROTECTED]
> Build and Release
> MontaVista Software

Our software architects use Enterprise Architect.  Its probably one of
the cheaper modeling and UML design applications, but loaded with
features.  They do all the use cases, analysis and design with it, then
give us the necessary flow / activity diagrams and information that we
then use to construct our python applications.  It does have a python
interface (and obviously c, c#, java, php etc etc) allowing python code
to be imported for class design etc etc.

I've played with a few open source UML based tools, but unfortunately
its not one of my strengths, I leave that up to the guys that know it
well.

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


Hint :Easy_Install Documentation

2007-01-12 Thread Norbert
Hello list,
just in the moment I wanted to write about then lacking documentation
about Easy_Install, but then I found this one :
http://www-128.ibm.com/developerworks/library/l-cppeak3.html.

Just for google.


HTH

Norbert

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


Re: Parallel Python

2007-01-12 Thread Konrad Hinsen
On Jan 12, 2007, at 11:21, Paul Boddie wrote:

> done. My own experience with regard to releasing software is that even
> with an open source licence, most people are likely to ignore your
> projects than to suddenly jump on board and take control, and even if

My experience is exactly the same. And looking into the big world of  
Open Source programs, the only case I ever heard of in which a  
project was forked by someone else is the Emacs/XEmacs split. I'd be  
happy if any of my projects ever reached that level of interest.

> Related to your work, I've released a parallel execution solution
> called parallel/pprocess [1] under the LGPL and haven't really heard
> about anyone really doing anything with it, let alone forking it and

That's one more project... It seems that there is significant  
interest in parallel computing in Python. Perhaps we should start a  
special interest group? Not so much in order to work on a single  
project; I believe that at the current state of parallel computing we  
still need many different approaches to be tried. But an exchange of  
experience could well be useful for all of us.

Konrad.
--
-
Konrad Hinsen
Centre de Biophysique Moléculaire, CNRS Orléans
Synchrotron Soleil - Division Expériences
Saint Aubin - BP 48
91192 Gif sur Yvette Cedex, France
Tel. +33-1 69 35 97 15
E-Mail: [EMAIL PROTECTED]
-


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


Re: Parallel Python

2007-01-12 Thread Paul Boddie
Konrad Hinsen wrote:
>
> That's one more project... It seems that there is significant
> interest in parallel computing in Python. Perhaps we should start a
> special interest group? Not so much in order to work on a single
> project; I believe that at the current state of parallel computing we
> still need many different approaches to be tried. But an exchange of
> experience could well be useful for all of us.

I think a special interest group might be productive, but I've seen
varying levels of special interest in the different mailing lists
associated with such groups: the Web-SIG list started with enthusiasm,
produced a cascade of messages around WSGI, then dried up; the XML-SIG
list seems to be a sorry indication of how Python's XML scene has
drifted onto other matters; other such groups have also lost their
momentum.

It seems to me that a more useful first step would be to create an
overview of the different modules and put it on the python.org Wiki:

http://wiki.python.org/moin/FrontPage
http://wiki.python.org/moin/UsefulModules (a reasonable entry point)

If no-one beats me to it, I may write something up over the weekend.

Paul

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


Re: Rational Numbers

2007-01-12 Thread Carsten Haese
On Thu, 2007-01-11 at 23:47 +, Nick Maclaren wrote:
> In article <[EMAIL PROTECTED]>,
> Facundo Batista <[EMAIL PROTECTED]> writes:
> |> Noud Aldenhoven wrote:
> |> 
> |> > When I was programming in a mathematical project I began to wonder if 
> python
> |> > supports rational numbers[1]. In a language like magma[2] it's not such a
> |> > problem. Does python supports something simular?
> |> 
> |> Python does not have rational numbers.
> |> 
> |> There's a (rejected) PEP about this, PEP-239:
> |> 
> |>   http://www.python.org/dev/peps/pep-0239/
> |> 
> |> Maybe you also want to read the section "Why not rational?" of
> |> PEP-327...
> |> 
> |>   http://www.python.org/dev/peps/pep-0327/#why-not-rational
> 
> Oh, God.  Decimal delusions again :-(
> 
> There are good arguments for not having a rational type, but the idea
> that decimal floating-point is in any way a replacement is cuckoo.

You're putting words in Facundo's mouth. Facundo didn't say why we
should read that section of PEP 327. I think he merely pointed to the
slow performance of rational numbers that's explained in that section.
(Facundo is the author of PEP 327, so I find it unlikely that he has
delusions about what decimals can and can't do.)

It is true that decimal arithmetic is not a replacement for rational
arithmetic, but I don't see anybody on this thread or in PEP 327 stating
that it is.

-Carsten


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


Re: How much slower is dict indexing vs. list indexing?

2007-01-12 Thread Emin
On Jan 11, 5:53 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> What technique were you thinking of to look up the cached index values
> in Python, just as a matter of curiosity? Storing them in a dict? It
> would be hard to think of a faster way ... ;-)

I didn't have anything fancy in mind. I was just wondering whether it
makes sense to replace a block of code like

data = {'a' : 1, 'b' :2, 'c' : 3}
for i in someLargeList:
   for name in ['a','b','c']:
  result.append(data[name])

with somthing like

data = {'a' : 1, 'b' :2, 'c' : 3}
dataValues = [data[k] for k in ['a','b','c']
for i in someLargeList:
   for index in [0,1,2]:
  result.append(dataValues[index])

It sounds like it's probably not worth the effort in general, but might
be for extremely ultra-critical parts of code.

Thanks

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


context managers and co-routines

2007-01-12 Thread Bob . Sidebotham
I'm happily using context managers and co-routines, and would like to
use both at the same time, e.g.

with foo():
...
x = yield y
...

In this code multiple copies of this code can be executing at the
"same" time, interleaved by the yield statement. This doesn't work
well, since the context manager is dealing with global state
(specifically, re-routing stdout).

The problem is that all of my state (local variables, etc.) is nicely
saved over the yield, but the context is not. So I end up having to
write the code like this:

with foo():
...
x = yield y
with foo():
...

which is not so pretty. What I'd like is some way to transparently save
and restore context over a yield, but I don't see an easy way to do
this.

Any suggestions?

Thanks,
Bob Sidebotham

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


Newbie imap lib question

2007-01-12 Thread jrpfinch
I have three messages in my inbox.  Why does messageCount =
gServer.select('INBOX') not just return OK and 3.  See below for
examples - seems to be completely random how many threes it returns.
The documentation for imaplib seems sparse.  Does anybody have any good
links?  Many thanks, Jon

messageCount =
 0 : OK
 1 : ['3']
messageCount =
 0 : OK
 1 : ['3', '3', '3']
messageCount =
 0 : OK
 1 : [None]
messageCount =
 0 : OK
 1 : ['3', '3']

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


Re: How much slower is dict indexing vs. list indexing?

2007-01-12 Thread skip

Emin> It sounds like it's probably not worth the effort in general, but
Emin> might be for extremely ultra-critical parts of code.

Even in extremely ultra-critical parts of code I doubt the loss of
readability would be worth it.  If there are situations where you can really
gain by switching from a natural indexing scheme to lists, there are
probably other places in your code where you will gain just as much benefit
without the corresponding loss of readability.  Indexing lists only appears
to be about twice as fast as indexing dicts:

% timeit.py -s "data = {'a' : 1, 'b' :2, 'c' : 3}" "for k in 'abc': x = 
data[k]"
10 loops, best of 3: 4.61 usec per loop
% timeit.py -s "data = [1, 2, 3]" "for k in [0, 1, 2]: x = data[k]"
10 loops, best of 3: 2.97 usec per loop

If you're worried about regaining a couple microseconds per index you
probably shouldn't be using Python.

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


Re: Tools Designing large/complicated applications

2007-01-12 Thread Nick Vatamaniuc
Carl,

Some well known design applications have plugins for UML<->Python
translation. For example EnterpriseArchitect
(http://www.sparxsystems.com.au/resources/mdg_tech/) has a plugin for
Python.  ObjectDomain though supports it natively:
http://www.objectdomain.com/products/od/overview.do

The good thing about Python is that it is concise enough to not need
UML diagrams. Python can be used as a prototype language itself. In
other words it could take longer to draw the UML diagram than it would
take to type up a mock-up in Python. While with Java, for example, it
is very helpful to have a code generation application to take care of
all the getters and setters.

But of course if you have non-technical people who just know how to
read UML diagrams, it makes sense to invest in a good design tool.

Hope this helps,
-Nick


Carl J. Van Arsdall wrote:
> For those of you that work on larger applications but still code in
> python... do your development teams use any tools to facilitate the
> design? (i'm not asking about editors here, i'm really asking about
> software design tools)  Are these the same tools you would use to help
> engineer software in another language?
>
> Is there anyone here who is forced to use a tool to design python
> software that completely hates it?  Why do you hate it?
>
> Thanks!
>
> -carl
>
>
> --
>
> Carl J. Van Arsdall
> [EMAIL PROTECTED]
> Build and Release
> MontaVista Software

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


setup.py ./configure arguments

2007-01-12 Thread km

Hi,

how do i pass '--enable-shared' etc arguments to Python2.5 setup.py ?
do i need to edit some file ?
regards,
KM
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How much slower is dict indexing vs. list indexing?

2007-01-12 Thread Paul McGuire
"Emin" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Jan 11, 5:53 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>>
>> What technique were you thinking of to look up the cached index values
>> in Python, just as a matter of curiosity? Storing them in a dict? It
>> would be hard to think of a faster way ... ;-)
>
> I didn't have anything fancy in mind. I was just wondering whether it
> makes sense to replace a block of code like
>
> data = {'a' : 1, 'b' :2, 'c' : 3}
> for i in someLargeList:
>   for name in ['a','b','c']:
>  result.append(data[name])
>
> with somthing like
>
> data = {'a' : 1, 'b' :2, 'c' : 3}
> dataValues = [data[k] for k in ['a','b','c']
> for i in someLargeList:
>   for index in [0,1,2]:
>  result.append(dataValues[index])
>

[Your as-posted code doesn't run, you are missing a trailing ']' in your 
list comprehension. ]

So what you want is this?
1. Get the values from the data dict in order of their key, ['a','b','c'] 
(which is not the same as getting the data.values() list, which is in 
unpredictable order)
2. For every element in some larger list, append each of the elements in 
order from step 1 to some other result list.

First of all, realize that:
>   for index in [0,1,2]:
>  result.append(dataValues[index])
is the same as
result.extend(dataValues)
assuming that dataValues has exactly 3 elements in it.

Second, why are you iterating over someLargeList?  You are doing nothing 
with i, and neither the data dict nor the dataValues list changes as you 
iterate.

This will do the job more quickly, I should think:

data = {'a' : 1, 'b' :2, 'c' : 3}
dataValues = [data[k] for k in ['a','b','c']]
result.extend( dataValues * len(someLargeList) )

-- Paul


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


Re: What about this?

2007-01-12 Thread Diez B. Roggisch
Dr. Who wrote:

> What's more amazing is that anyone would click on the link at all given
> the increasing number of website that provide hidden content that tries
> to deliver spyware or viruses just by getting visitors.

Me LinuxBoy, me not in danger... SCNR :)

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


Re: Python nuube needs Unicode help

2007-01-12 Thread [EMAIL PROTECTED]
Can you attach files in this forum? Couldn't find the option. Oh well,
here's the file.

#!/usr/bin/python
# Version: 1.1
# Author:  Steve Losh

from sets import Set
from optparse import OptionParser
from xml.dom.minidom import parse

AudioPath = 'audio/'
DatafilePath  = 'utterances.trmxml'
CONFIDENCE_LOW  = None #'500'
CONFIDENCE_HIGH = None #'500'

utterancesFile = None


class Utterance:
def __init__(self, audio, grammarSet, text):
self.audio  = audio
self.grammarSet = grammarSet
self.text   = text

def __str__(self):
return "SWIrecAcousticStateReset\ntranscription " + self.text \
+ "\nrecognize " + AudioPath + self.audio


def getGrammarPaths():
"""Get the paths of all the grammars needed.  Returns a Set
containing the results.
If a grammar is listed more than once in the transcription manifest it
will only appear once in these results.

TODO:
Find a less fragile way to split off the server half of the URIs."""
grammarTags  = utterancesFile.getElementsByTagName('Grammar')
grammarURIs  = [tag.getAttribute('uri') for tag in grammarTags]
grammarPaths = [uri.split('servlet/CA/')[1] for uri in grammarURIs]
return Set(grammarPaths)


def createGrammarNameFromPath(path):
"""Convert a given path into an appropriate name for the
grammar."""
path = path.replace('/', '-')  # Strip the directory slashes
path = path.replace('.', '_')  # and the dot before the extension.
return path


def loadGrammars():
"""Output the statements that will load the required grammars."""
grammarPaths = list(getGrammarPaths())
grammarsToLoad = {}
for path in grammarPaths:
grammarName = createGrammarNameFromPath(path)
grammarsToLoad[grammarName] = "grammars/" + path
for grammarName in grammarsToLoad:
print "SWIrecGrammarLoad", grammarName,
grammarsToLoad[grammarName]


def loadGrammarSets():
"""Output the statements that will define the grammar
sets/contexts.  Returns a list of the grammar set names."""
grammarSetList  =
utterancesFile.getElementsByTagName('GrammarSets')
grammarSets =
grammarSetList[0].getElementsByTagName('GrammarSet')
grammarSetNames = []
for gs in grammarSets:
grammarSetName = gs.getAttribute('id')
print "context_define", grammarSetName, CONFIDENCE_LOW,
CONFIDENCE_HIGH
for g in gs.getElementsByTagName('Grammar'):
path = g.getAttribute('uri').split('servlet/CA/')[1]
print "context_add", createGrammarNameFromPath(path),
'1000'
print "context_end\n"
grammarSetNames.append(grammarSetName)
return grammarSetNames


def buildUtterances(call):
"""This function takes a call tag, builds the utterances belonging
to it and returns a list containing them."""
utts = call.getElementsByTagName('Utt')
utterances = [Utterance( utt.getAttribute('audio'), \
 utt.getAttribute('grammarSet'),
 utt.getAttribute('transcribedText') ) \
  for utt in utts]
return utterances


def getUtterances():
"""Returns a list of all the utterances we want to test."""
callList = utterancesFile.getElementsByTagName('Calls')[0]
calls = callList.getElementsByTagName('Call')
utterances = []
for c in calls:
utterances.extend(buildUtterances(c))
return utterances


def loadData(utterances):
"""Outputs the statements that will tell rec_test what to test."""
contexts = {}
for u in utterances:
if u.grammarSet not in contexts:
contexts[u.grammarSet] = []
contexts[u.grammarSet].append(u)
for c in contexts:
print "open errors " + c + ".errors"
print "open utd "+ c + ".utd"
print "context_use", c
for u in contexts[c]:
print u
print "close utd"
print "close errors"
print "\n"


def makeParser():
parser = OptionParser( "usage: %prog -l LOWER CONFIDENCE -h UPPER
CONFIDENCE [-f FILTER1 -f FILTER2 ...] file" )
parser.add_option("-l", "--low-confidence", dest="lower", \
  help="The lower confidence level to test at.",
metavar="CONFIDENCE")
parser.add_option("-u", "--upper-confidence", dest="upper", \
  help="The upper confidence level to test at.",
metavar="CONFIDENCE")
parser.add_option("-f", "--filter", dest="filter", action="append",
\
  help="Only test utterances transcribed as WORD.",
metavar="WORD")
return parser


def main():
global utterancesFile, CONFIDENCE_HIGH, CONFIDENCE_LOW
parser = makeParser()
(options, args) = parser.parse_args()
if len(args) != 1:
parser.error("One data file must be specified.")
elif options.lower == None:
parser.error("A lower confidence level must be specified.")
elif options.upper == None:
parser.error("An upper confidence level must be specified.

Re: Python nuube needs Unicode help

2007-01-12 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote:

> Can you attach files in this forum? Couldn't find the option. Oh well,
> here's the file.
> 
> #!/usr/bin/python
> # Version: 1.1
> # Author:  Steve Losh
> 
> from sets import Set
> from optparse import OptionParser
> from xml.dom.minidom import parse
> 
> AudioPath = 'audio/'
> DatafilePath  = 'utterances.trmxml'
> CONFIDENCE_LOW  = None #'500'
> CONFIDENCE_HIGH = None #'500'
> 
> utterancesFile = None
> 
> 
> class Utterance:
> def __init__(self, audio, grammarSet, text):
> self.audio  = audio
> self.grammarSet = grammarSet
> self.text   = text
> 
> def __str__(self):
> return "SWIrecAcousticStateReset\ntranscription " + self.text \
> + "\nrecognize " + AudioPath + self.audio

There your __str__-method is. self.text and self.audio come from the
xml-parsing and are unicode objects - so they need to be encoded, like
this:

def __str__(self):
return "SWIrecAcousticStateReset\ntranscription " +
self.text.encode('utf-8') + "\nrecognize " + AudioPath +
self.audio.encode('utf-8')


Diez

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


Command line arguments on Vista

2007-01-12 Thread jmike
So I write this sript called printargs.py:

--
#!/usr/local/bin/python
import sys
print 'there are %d args' % len(sys.argv)
for arg in sys.argv:
print 'arg: %s' % arg
--

and make it executable.  On pretty much every platform I can get my
hands on, when I run

 printargs.py booga -a wooga

I get this output:

 there are 4 args
 arg: printargs.py
 arg: booga
 arg: -a
arg: wooga

But on Windows Vista, when I run that command, I get

 there are 1 args
 arg: printargs.py

What's up with that?
   --JMike

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


Re: context managers and generators

2007-01-12 Thread Jean-Paul Calderone
On 12 Jan 2007 06:17:01 -0800, [EMAIL PROTECTED] wrote:
>I'm happily using context managers and co-routines, and would like to
>use both at the same time, e.g.

Python has generators, not co-routines.

>
>with foo():
>...
>x = yield y
>...
>
>In this code multiple copies of this code can be executing at the
>"same" time, interleaved by the yield statement. This doesn't work
>well, since the context manager is dealing with global state
>(specifically, re-routing stdout).
>
>The problem is that all of my state (local variables, etc.) is nicely
>saved over the yield, but the context is not. So I end up having to
>write the code like this:
>
>with foo():
>...
>x = yield y
>with foo():
>...
>
>which is not so pretty. What I'd like is some way to transparently save
>and restore context over a yield, but I don't see an easy way to do
>this.

Wrap the generator in a function which co-operates with your context
managers to clean-up or re-instate whatever they are interacting with
whenever execution leaves or re-enters the generator.

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


Re: Command line arguments on Vista

2007-01-12 Thread jmike
By the way, note that if I say (on Vista)

python printargs.py booga -a wooga

I get the desired output:

>  there are 4 args
>  arg: printargs.py
>  arg: booga
>  arg: -a
>  arg: wooga

So the quesiton still stands, what's up with that?

Thanks,
  --JMike

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


Re: Rational Numbers

2007-01-12 Thread Nick Maclaren

In article <[EMAIL PROTECTED]>,
Carsten Haese <[EMAIL PROTECTED]> writes:
|> On Thu, 2007-01-11 at 23:47 +, Nick Maclaren wrote:
|> > In article <[EMAIL PROTECTED]>,
|> > Facundo Batista <[EMAIL PROTECTED]> writes:
|> > |> Noud Aldenhoven wrote:
|> > |> 
|> > |> > When I was programming in a mathematical project I began to wonder if 
python
|> > |> > supports rational numbers[1]. In a language like magma[2] it's not 
such a
|> > |> > problem. Does python supports something simular?
|> > |> 
|> > |> Python does not have rational numbers.
|> > |> 
|> > |> There's a (rejected) PEP about this, PEP-239:
|> > |> 
|> > |>   http://www.python.org/dev/peps/pep-0239/
|> > |> 
|> > |> Maybe you also want to read the section "Why not rational?" of
|> > |> PEP-327...
|> > |> 
|> > |>   http://www.python.org/dev/peps/pep-0327/#why-not-rational
|> > 
|> > Oh, God.  Decimal delusions again :-(
|> > 
|> > There are good arguments for not having a rational type, but the idea
|> > that decimal floating-point is in any way a replacement is cuckoo.
|> 
|> You're putting words in Facundo's mouth. Facundo didn't say why we
|> should read that section of PEP 327. I think he merely pointed to the
|> slow performance of rational numbers that's explained in that section.
|> (Facundo is the author of PEP 327, so I find it unlikely that he has
|> delusions about what decimals can and can't do.)

You're putting words in MY mouth!  I didn't say that he did.  But I
agree that my words could easily be read that way, so I apologise for
any misunderstanding.

|> It is true that decimal arithmetic is not a replacement for rational
|> arithmetic, but I don't see anybody on this thread or in PEP 327 stating
|> that it is.

Read them again, more carefully :-(

The BDFL Pronouncement rejecting PEP 239 does, even if it does qualify
it by saying "to some extent".  And it was that PEP that I was primarily
referring to in that remark.

The "Why not rational?" section of PEP 327 quotes Alex Martelli as saying
that Rational are not worth doing without Decimal, which makes no sense
at all.  All it does is to plug Decimal for a purpose for which it is
completely unsuited; not all rational numbers have denumerators that are
powers of 10.


Regards,
Nick Maclaren.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: context managers and generators

2007-01-12 Thread [EMAIL PROTECTED]
Jean-Paul Calderone wrote:
> On 12 Jan 2007 06:17:01 -0800, [EMAIL PROTECTED] wrote:
> >I'm happily using context managers and co-routines, and would like to
> >use both at the same time, e.g.
>
> Python has generators, not co-routines.

They may be called generators, but I'm using them as co-routines.

> Wrap the generator in a function which co-operates with your context
> managers to clean-up or re-instate whatever they are interacting with
> whenever execution leaves or re-enters the generator.

I don't think wrapping the generator will do it. I think I would have
to wrap the actual yield call. Maybe that wouldn't be so bad.

There's not even any guarantee, by the way, that the yield even
returns: an exception outside the generator will not trigger the
exception in the context manager. In general, there is no hook (that I
can see) that helps with this.

I'm still thinking there is a better way to do it, and would appreciate
any ideas.

Bob

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


Re: Command line arguments on Vista

2007-01-12 Thread jmike
Some further information: perl seems to do the same thing (losing
arguments).
We think it may have something to do with file association.

Any ideas anyone?
   --JMike

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


Re: Command line arguments on Vista

2007-01-12 Thread Duncan Booth
[EMAIL PROTECTED] wrote:

> But on Windows Vista, when I run that command, I get
> 
>  there are 1 args
>  arg: printargs.py
> 
> What's up with that?

It sounds like the registry entry for running Python files is messed up. 
Can you go to a command line and see what the command 'ftype Python.File' 
displays? (Assuming that command lines and ftype still work on Vista)

The output should be:
Python.File="C:\Python25\python.exe" "%1" %*

but if it only says:
Python.File="C:\Python25\python.exe" "%1"

then you would get the behaviour you observed (on any version of Windows, 
not just Vista).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What about this?

2007-01-12 Thread Dr. Who
What's more amazing is that anyone would click on the link at all given
the increasing number of website that provide hidden content that tries
to deliver spyware or viruses just by getting visitors.

Jeff

Bjoern Schliessmann wrote:
> new wrote:
>
> > www.magicoz.com
> > amazing
>
> Yeah, it *is* really amazing that someone dares to spam for such an
> unprofessional homepage. Even too stupid to include a doctype ...
> 
> 
> Björn
> 
> -- 
> BOFH excuse #61:
> 
> not approved by the FCC

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


Re: context managers and generators

2007-01-12 Thread Laszlo Nagy

> I'm still thinking there is a better way to do it, and would appreciate
> any ideas.
>   
Everything can be implemented with goto and arrays.

http://entrian.com/goto/

:-P




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


Re: Python nuube needs Unicode help

2007-01-12 Thread [EMAIL PROTECTED]
Diez, you are awesome! This works! Thank you so much!!! You are so
awesome!


Diez B. Roggisch wrote:
> [EMAIL PROTECTED] wrote:
>
> > Can you attach files in this forum? Couldn't find the option. Oh well,
> > here's the file.
> >
> > #!/usr/bin/python
> > # Version: 1.1
> > # Author:  Steve Losh
> >
> > from sets import Set
> > from optparse import OptionParser
> > from xml.dom.minidom import parse
> >
> > AudioPath = 'audio/'
> > DatafilePath  = 'utterances.trmxml'
> > CONFIDENCE_LOW  = None #'500'
> > CONFIDENCE_HIGH = None #'500'
> >
> > utterancesFile = None
> >
> >
> > class Utterance:
> > def __init__(self, audio, grammarSet, text):
> > self.audio  = audio
> > self.grammarSet = grammarSet
> > self.text   = text
> >
> > def __str__(self):
> > return "SWIrecAcousticStateReset\ntranscription " + self.text \
> > + "\nrecognize " + AudioPath + self.audio
>
> There your __str__-method is. self.text and self.audio come from the
> xml-parsing and are unicode objects - so they need to be encoded, like
> this:
>
> def __str__(self):
> return "SWIrecAcousticStateReset\ntranscription " +
> self.text.encode('utf-8') + "\nrecognize " + AudioPath +
> self.audio.encode('utf-8')
> 
> 
> Diez

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


Re: Rational Numbers

2007-01-12 Thread Carsten Haese
On Fri, 2007-01-12 at 15:05 +, Nick Maclaren wrote:
> In article <[EMAIL PROTECTED]>,
> Carsten Haese <[EMAIL PROTECTED]> writes:
> |> On Thu, 2007-01-11 at 23:47 +, Nick Maclaren wrote:
> |> > In article <[EMAIL PROTECTED]>,
> |> > Facundo Batista <[EMAIL PROTECTED]> writes:
> |> > |> Python does not have rational numbers.
> |> > |> 
> |> > |> There's a (rejected) PEP about this, PEP-239:
> |> > |> 
> |> > |>   http://www.python.org/dev/peps/pep-0239/
> |> > |> 
> |> > |> Maybe you also want to read the section "Why not rational?" of
> |> > |> PEP-327...
> |> > |> 
> |> > |>   http://www.python.org/dev/peps/pep-0327/#why-not-rational
> |> > 
> |> > Oh, God.  Decimal delusions again :-(
> |> > 
> |> > There are good arguments for not having a rational type, but the idea
> |> > that decimal floating-point is in any way a replacement is cuckoo.
> |> 
> |> You're putting words in Facundo's mouth. Facundo didn't say why we
> |> should read that section of PEP 327. I think he merely pointed to the
> |> slow performance of rational numbers that's explained in that section.
> |> (Facundo is the author of PEP 327, so I find it unlikely that he has
> |> delusions about what decimals can and can't do.)
> 
> You're putting words in MY mouth!  I didn't say that he did.  But I
> agree that my words could easily be read that way, so I apologise for
> any misunderstanding.
> [...]
> The BDFL Pronouncement rejecting PEP 239 does, even if it does qualify
> it by saying "to some extent".  And it was that PEP that I was primarily
> referring to in that remark.

Ah, so now you're putting words in the BDFL's mouth. ;)

The pronouncement does say "The needs outlined in the rationale section
have been addressed to some extent by the acceptance of PEP 327 for
decimal arithmetic," but it doesn't say to which extent, and it
certainly doesn't claim that decimal arithmetic is a replacement for
rational arithmetic.

> The "Why not rational?" section of PEP 327 quotes Alex Martelli as saying
> that Rational are not worth doing without Decimal, which makes no sense
> at all.  All it does is to plug Decimal for a purpose for which it is
> completely unsuited; not all rational numbers have denumerators that are
> powers of 10.

The sentence you're referring to is "There are excellent Rational
implementations [...]. Probably worth PEPping, not worth doing without
Decimal." I agree that this sentence is poorly worded, but I think it
means "Even if we had Rational, we'd still need Decimal" in the sense
that Rational is not an adequate replacement for Decimal.

The bottom line is that there are use cases for both Rational and
Decimal, and neither one can replace the other, but there are more use
cases for Decimal than for Rational.

-Carsten


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


Re: ValueError from dict - some detail would be helpful

2007-01-12 Thread Facundo Batista
metaperl wrote:

>   File "/sw/lib/python2.5/csv.py", line 120, in _dict_to_list
> raise ValueError, "dict contains fields not in fieldnames"
>
>
> --- it would be nice if it said what field it was

Yeap, nice and useful... but, for example, what'd happen if the fields
that are not in fieldnames are 10, or 100? How the message could be?

-- 
.   Facundo
.
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/


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


Re: Rational Numbers

2007-01-12 Thread Nick Maclaren

In article <[EMAIL PROTECTED]>,
Carsten Haese <[EMAIL PROTECTED]> writes:
|> 
|> Ah, so now you're putting words in the BDFL's mouth. ;)
|> 
|> The pronouncement does say "The needs outlined in the rationale section
|> have been addressed to some extent by the acceptance of PEP 327 for
|> decimal arithmetic," but it doesn't say to which extent, and it
|> certainly doesn't claim that decimal arithmetic is a replacement for
|> rational arithmetic.

Eh?  If the needs are addressed to some extent, then to some extent
it is a replacement.

|> The sentence you're referring to is "There are excellent Rational
|> implementations [...]. Probably worth PEPping, not worth doing without
|> Decimal." I agree that this sentence is poorly worded, but I think it
|> means "Even if we had Rational, we'd still need Decimal" in the sense
|> that Rational is not an adequate replacement for Decimal.

Which would be justifiable, but is not what it said.  What it SAID is
what I said it said 

|> The bottom line is that there are use cases for both Rational and
|> Decimal, and neither one can replace the other,

So far, so good.  With reservations, I agree.

|> but there are more use
|> cases for Decimal than for Rational.

That is dubious, but let's not start that one again.


Regards,
Nick Maclaren.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Matching Directory Names and Grouping Them

2007-01-12 Thread Neil Cerutti
On 2007-01-11, J <[EMAIL PROTECTED]> wrote:
> Steve-
>
> Thanks for the reply. I think what I'm trying to say by similar
> is pattern matching. Essentially, walking through a directory
> tree starting at a specified root folder, and returning a list
> of all folders that matches a pattern, in this case, a folder
> name containing a four digit number representing year and a
> subdirectory name containing a two digit number representing a
> month. The matches are grouped together and written into a text
> file. I hope this helps.

Here's a solution using itertools.groupby, just because this is
the first programming problem I've seen that seemed to call for
it. Hooray!

from itertools import groupby

def print_by_date(dirs):
r""" Group a directory list according to date codes.

>>> data = [
... "/Input2/2002/03/",
... "/Input1/2001/01/",
... "/Input3/2005/05/",
... "/Input3/2001/01/",
... "/Input1/2002/03/",
... "/Input3/2005/12/",
... "/Input2/2001/01/",
... "/Input3/2002/03/",
... "/Input2/2005/05/",
... "/Input1/2005/12/"]
>>> print_by_date(data)
/Input1/2001/01/
/Input2/2001/01/
/Input3/2001/01/

/Input1/2002/03/
/Input2/2002/03/
/Input3/2002/03/

/Input2/2005/05/
/Input3/2005/05/

/Input1/2005/12/
/Input3/2005/12/


"""
def date_key(path):
return path[-7:]
groups = [list(g) for _,g in groupby(sorted(dirs, key=date_key), date_key)]
for g in groups:
print '\n'.join(path for path in sorted(g))
print

if __name__ == "__main__":
import doctest
doctest.testmod()

I really wanted nested join calls for the output, to suppress
that trailing blank line, but I kept getting confused and
couldn't sort it out.

It would better to use the os.path module, but I couldn't find
the function in there lets me pull out path tails.

I didn't filter out stuff that didn't match the date path
convention you used.

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


Any python based "Live Web Chat Support"

2007-01-12 Thread johnny
Is there any open source "live web chat support" program or script out
there?  Any you can recommend?

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


Re: Rational Numbers

2007-01-12 Thread Facundo Batista
Noud Aldenhoven wrote:

> There are a (small) couple of other issues where rational numbers could be
> handy. That's because rational numbers are exact, irrational numbers (in
> python) aren't. But these issues are probably too mathematical to be used in

For the sake of me being less ignorant, could you please point me a
language where irrational numbers are exact?

Regards,

-- 
.   Facundo
.
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/


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


Re: Need better run/edit method. I have to restart the shell after every script change.

2007-01-12 Thread Mark
Thanks guys.  I'll give it a try.
Brian Blais wrote:
> Mark wrote:
> > I'm currently running the IDLE shell under Python 2.5, on Windows XP.
> >
> > Every time I edit my .txt or .py file, I have to restart the IDLE shell
> > for the changes to take effect. It's pretty annoying. Assuming IDLE is
> > already open, here are the steps that I typically take:
> >
> > 1. Open .txt version of module or script using notepad
> > 2. make changes
> > 3. save .txt file as .txt file
> > 4. save .txt file as .py file
> > 5. reset IDLE
> > 6. import module again
> >
>
> why do you involve notepad, and .txt files?  Instead, try this:
>
> 1. Run Idle
> 2. Choose File/New Window
> 3. Edit your .py file, and save it as a .py file
> 4. Choose Run/Run Module
> 5. Make changes, and save again
> 6. Choose Run/Run Module
> 7. etc...
>
> you don't need to close IDLE ever.  IDLE refers to the editor, and the shell 
> that
> runs connected to it.  If you have just the shell, you can open the editor 
> with
> File/New Window.  If you have just the editor, you can choose Run/Python 
> Shell   or
> Run/Run Module depending on what you want to do, to get the shell.
>
> You can also take a .py file in the Windows explorer, right-click, and choose 
> "Open
> with IDLE" to start editing it directly.
>
> You shouldn't save things as .txt, because then IDLE will not recognize it is 
> python
> you are writing, and the right-click trick probably won't work either.  You 
> should
> never use Notepad, because it is just icky, and doesn't know about any 
> programming
> languages.  :)
>
> Hope this helps,
>
>   Brian Blais
>
>
> --
> -
>
>   [EMAIL PROTECTED]
>   http://web.bryant.edu/~bblais

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


Re: How to modify object attribute by python C API

2007-01-12 Thread Huayang Xia
Thanks for the replies.

For the checking, I found we have to spend a lot of codes to check the
Python API's results. That is a pain. Is it reasonable to ignore the
result check of APIs like PyString_FromString and PyString_AsString
which will fail only when out of memory. Unfortunately there is no
exception thrown (in C++) so that we can integrate the error handling.
What is the best way(less code) to handle the error checking in normal
practice?

On Jan 11, 4:37 pm, "Huayang Xia" <[EMAIL PROTECTED]> wrote:
> I get a python object by running a class' constructor. Then I need to
> modify the instance's attribute just like obj.attr1.attr2 = 'a' if in
> python's term.
>
> PyObject* py_obj_attr1 = PyObject_GetAttrString(obj, "attr1");
> PyObject_SetAttrString(py_obj_attr1, "attr2",
> PyString_FromString("a"));
> Py_DECREF(py_obj_attr1);
>
> The object py_obj_attr1 is said to be a "New reference". It's
> confusing, does it refer to the same object as "obj.attr1" in python's
> term? So that the above code equals: obj.attr1.attr2 = 'a' in python's
> term.
> 
> I

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


getting the name of hyperlinks in a file

2007-01-12 Thread CSUIDL PROGRAMMEr
folks,
I am trying to write a script that would open a download server and
download all the files  and store them in a list

for example Download server is
http://download.fedora.redhat.com/pub/fedora/linux/core/updates/5/SRPMS/


is there any way this can be done in python??

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


ArchGenXML please help

2007-01-12 Thread tonydevlin

I am creating a workflow in plone using argouml and archgenxml.  I have been
following the steps on the site:-
http://plone.org/documentation/tutorial/anonymously-adding-custom-content-types-with-argouml-and-archgenxml/creating-a-class-and-workflow-with-argouml

However I am confused at step 9 in creating the class section, where it
says:
"Now, save this file as "ProcessImprovement.zargo".  Pull up a command
prompt and navigate to that directory.  Make sure that you've added the
ArchGenXML directory to your env path, and type the following:
C:\Sandbox\Plone\Tutorial>ArchGenXML.py ProcessImprovement.zargo"

I have saved the file in the location 
C:\Documents and Settings\Tony\Desktop\Test\ProcessImprovement.zargo
However I dont know what to type in the python command prompt!!!

Can anyone help my, I would be very greatful, or if I am in the wrong place
do you know another forum where I could go as I have tried the plone online
on and it is no good.
Thank you.
-- 
View this message in context: 
http://www.nabble.com/ArchGenXML-please-help-tf2966867.html#a8301441
Sent from the Python - python-list mailing list archive at Nabble.com.

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


module file

2007-01-12 Thread Imbaud Pierre
I am willing to retrieve the file an imported module came from;
module.__file__, or inspect.getfile(module) only gives me the
relative file name. How do I determine the path?
Its obviously possible from python: ipython displays the information
(interactively: *module?*).
Python 2.4 on Suse 9.3 (clueless, I guess)
-- 
http://mail.python.org/mailman/listinfo/python-list


modules...n methods

2007-01-12 Thread lee
First of all thnx guys for ur cover on ma questionsOk some more
then...whats the way to read the sourcecode of methods and built in
functions?

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


Re: ArchGenXML please help

2007-01-12 Thread Bruno Desthuilliers
tonydevlin a écrit :
> I am creating a workflow in plone using argouml and archgenxml.  I have been
> following the steps on the site:-
> http://plone.org/documentation/tutorial/anonymously-adding-custom-content-types-with-argouml-and-archgenxml/creating-a-class-and-workflow-with-argouml
> 
> However I am confused at step 9 in creating the class section, where it
> says:
> "Now, save this file as "ProcessImprovement.zargo".  Pull up a command
> prompt and navigate to that directory.  Make sure that you've added the
> ArchGenXML directory to your env path, and type the following:
> C:\Sandbox\Plone\Tutorial>ArchGenXML.py ProcessImprovement.zargo"
> 
> I have saved the file in the location 
> C:\Documents and Settings\Tony\Desktop\Test\ProcessImprovement.zargo
> However I dont know what to type in the python command prompt!!!

Which *python* command prompt ? The author is talking about a shell, 
here (you know, this strange stuff that looks like good ole time DOS...).


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


'LoadFile' not found when invoking Acrobat via wx.lib.pdfwin

2007-01-12 Thread Christian Stapfer
Hi,

 I get the following traceback when trying to have
wx.lib.pdfwin.PDFWindow open a PDF file:

E:\Tutoring\Teacher\Flashcards>python pdfwin1.py
Traceback (most recent call last):
  File "pdfwin1.py", line 50, in OnOpenButton
self.pdf.LoadFile(dlg.GetPath())
  File 
"C:\Python24\lib\site-packages\wx-2.6-msw-unicode-enthought\wx\lib\pdfwin
.py", line 34, in LoadFile
return self.CallAXMethod('LoadFile', fileName)
  File 
"C:\Python24\lib\site-packages\wx-2.6-msw-unicode-enthought\wx\activex.py
", line 385, in CallAXMethod
return self._CallAXMethod(name, args)
  File 
"C:\Python24\lib\site-packages\wx-2.6-msw-unicode-enthought\wx\activex.py
", line 378, in _CallAXMethod
return _activex.ActiveXWindow__CallAXMethod(*args)
KeyError: 'method  not found'

The code in pdfwin1.py is from
http://www.daniweb.com/code/snippet618.html

How could the ActiveX control PDFWindow possibly
*not* find the 'LoadFile' method, I wonder. - Or
am I misinterpreting the message?
(I am running Enthought Python 2.4 on Windows XP.)

Thank you in advance for any ideas as to what
the problem might be,

Christian

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


Re: modules...n methods

2007-01-12 Thread Bjoern Schliessmann
lee wrote:

> whats the way to read the sourcecode of methods

Easy. Look up the .py file and open it in an editor of your choice.
Those files are, for example, in "/usr/lib/python".

> and built in functions?

Get your python interpreter's source code and look up the functions
there.

Regards,


Björn

-- 
BOFH excuse #370:

Virus due to computers having unsafe sex.

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


Re: context managers and generators

2007-01-12 Thread Bjoern Schliessmann
Laszlo Nagy wrote:
 
>> I'm still thinking there is a better way to do it, and would
>> appreciate any ideas.
>   
> Everything can be implemented with goto and arrays.

But is that really better?

Regards,


Björn

-- 
BOFH excuse #174:

Backbone adjustment

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


Re: What about this?

2007-01-12 Thread Bjoern Schliessmann
Dr. Who wrote:

> What's more amazing is that anyone would click on the link at all
> given the increasing number of website that provide hidden content
> that tries to deliver spyware or viruses just by getting visitors.

How could active input reach *me* if I just fed the W3C validator
with the URL?

Regards,


Björn

-- 
BOFH excuse #184:

loop found in loop in redundant loopback

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


Re: Parallel Python

2007-01-12 Thread Konrad Hinsen
On Jan 12, 2007, at 15:08, Paul Boddie wrote:

> It seems to me that a more useful first step would be to create an
> overview of the different modules and put it on the python.org Wiki:
>
> http://wiki.python.org/moin/FrontPage
> http://wiki.python.org/moin/UsefulModules (a reasonable entry point)
>
> If no-one beats me to it, I may write something up over the weekend.

That sounds like a good idea. I won't beat you to it, but I'll have a  
look next week and perhaps add information that I have.

Konrad.
--
-
Konrad Hinsen
Centre de Biophysique Moléculaire, CNRS Orléans
Synchrotron Soleil - Division Expériences
Saint Aubin - BP 48
91192 Gif sur Yvette Cedex, France
Tel. +33-1 69 35 97 15
E-Mail: [EMAIL PROTECTED]
-


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


Re: Rational Numbers

2007-01-12 Thread Nick Maclaren

In article <[EMAIL PROTECTED]>,
Facundo Batista <[EMAIL PROTECTED]> writes:
|> Noud Aldenhoven wrote:
|> 
|> > There are a (small) couple of other issues where rational numbers could be
|> > handy. That's because rational numbers are exact, irrational numbers (in
|> > python) aren't. But these issues are probably too mathematical to be used 
in
|> 
|> For the sake of me being less ignorant, could you please point me a
|> language where irrational numbers are exact?

Some of the algebraic languages.  (2/3)^(1/5) is held as such and
manipulated appropriately.

Yes, I know that's "cheating" :-)


Regards,
Nick Maclaren.
-- 
http://mail.python.org/mailman/listinfo/python-list


parsing a file name

2007-01-12 Thread CSUIDL PROGRAMMEr
I have a filename
cairo-2.3.4.src.rpm
Is there any way i can only get 2.3.4 from this file name
thanks

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


Re: Newbie imap lib question

2007-01-12 Thread jrpfinch
All I have to go on is the RFC2060 standard which says:

7.3.1.  EXISTS Response

   Contents:   none

  The EXISTS response reports the number of messages in the
mailbox.
  This response occurs as a result of a SELECT or EXAMINE command,
  and if the size of the mailbox changes (e.g. new mail).

  The update from the EXISTS response MUST be recorded by the
  client.

   Example:S: * 23 EXISTS

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


What is a perl hash in python

2007-01-12 Thread Karyn Williams
I am new to Pyton. I am trying to modify and understand a script someone
else wrote. I am trying to make sense of the following code snippet. I know
line 7 would be best coded with regex. I first would like to understand
what was coded originally. thelistOut looks like a hash to me (I'm more
familiar with perl). Perhaps someone could translate from perl to python
for me - not in code but just in concept.


Here is the code. This script is reading the list thelistOut and then
removing any items in RSMlist and taking the remainder and putting them in
graphAddressOut with the formatting.

This is a SAMPLE of what is in the lists referenced below in the loop:


thelistOut = [(632,
['/usr/local/www/data-dist/mrtg/main/test/172.16.0.23_9.log']), (145,
['/usr/local/www/data-dist/mrtg/main/test/172.16.0.23_13.log']), (0,
['/usr/local/www/data-dist/mrtg/main/test/172.16.0.23_5.log'])]

RSMList = ['172.16.0.1_1', '172.16.0.1_2', '172.16.0.1_3', '172.16.0.1_4',
'172.16.0.1_5']



#--Loop 1 -
   
w = 0
while w < 45:
   
   fileOut = string.split(thelistOut[w][1][0],".log")
   fileOutSplitedCommon = string.split(fileOut[0], "main/")
   fileOut2D = string.split(fileOutSplitedCommon[1], "/")
   fileOut = string.split(fileOut[0],"data-dist")

   if fileOut2D[1] in RSMList:
  w = w + 1
  continue
   graphAddressOut = tag1 + logUrl + fileOut[1] + extention1 + tag2 +
"SWITCH: " + string.swapcase(fileOut2D[0]) + "  &
nbsp;PORT ID: " + fileOut2D[1] + "" + imgTitleTag + imgTag1 +
logUrl + fileOut[1] + extention2 + imgTag2 + tag3 + tag5
   outputOut.append(graphAddressOut)
   strOut = strOut + graphAddressOut

   w = w + 1

#--Loop 1 -

-- 

Karyn Williams
Network Services Manager
California Institute of the Arts
[EMAIL PROTECTED]
http://www.calarts.edu/network
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Any python based "Live Web Chat Support"

2007-01-12 Thread Kartic
johnny sayeth,  on 01/12/2007 11:11 AM:
 > Is there any open source "live web chat support" program or script out
 > there?  Any you can recommend?

Why don't you install ejabberd (a Jabber server implemented in erlang) 
and install Muckl (http://zeank.in-berlin.de/muckl/), an AJAX client for 
multi-user chat (or Jwchat for one on one chat). Both Muckl and JWChat 
are embeddable in a web page, as they use just HTML/Javascript, with 
some work.

Other than that, if you want to stick to a Python solution, I do believe 
Nevow project comes with a live chat demo, which you can customize.

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


Re: ArchGenXML please help

2007-01-12 Thread tonydevlin



Bruno Desthuilliers wrote:
> 
> tonydevlin a écrit :
>> I am creating a workflow in plone using argouml and archgenxml.  I have
>> been
>> following the steps on the site:-
>> http://plone.org/documentation/tutorial/anonymously-adding-custom-content-types-with-argouml-and-archgenxml/creating-a-class-and-workflow-with-argouml
>> 
>> However I am confused at step 9 in creating the class section, where it
>> says:
>> "Now, save this file as "ProcessImprovement.zargo".  Pull up a command
>> prompt and navigate to that directory.  Make sure that you've added the
>> ArchGenXML directory to your env path, and type the following:
>> C:\Sandbox\Plone\Tutorial>ArchGenXML.py ProcessImprovement.zargo"
>> 
>> I have saved the file in the location 
>> C:\Documents and Settings\Tony\Desktop\Test\ProcessImprovement.zargo
>> However I dont know what to type in the python command prompt!!!
> 
> Which *python* command prompt ? The author is talking about a shell, 
> here (you know, this strange stuff that looks like good ole time DOS...).
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
> I yes sorry I was obviously not thinking properly, however there is still
> a problem, when I run this in dos after I have changed to the correct
> directory the ArchGenXML file that I downloaded does not work.  I renamed
> it from its original name because that did not work, it just came up with
> can not find program for it to run off.  It still does the same.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/ArchGenXML-please-help-tf2966867.html#a8302734
Sent from the Python - python-list mailing list archive at Nabble.com.

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

Re: parsing a file name

2007-01-12 Thread Tim Williams
On 12 Jan 2007 09:16:51 -0800, CSUIDL PROGRAMMEr <[EMAIL PROTECTED]> wrote:
> I have a filename
> cairo-2.3.4.src.rpm
> Is there any way i can only get 2.3.4 from this file name

Is this a one off,  or do you have to process multiple files with similar names?


-- 

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


Re: parsing a file name

2007-01-12 Thread Chris Mellon
On 12 Jan 2007 09:16:51 -0800, CSUIDL PROGRAMMEr <[EMAIL PROTECTED]> wrote:
> I have a filename
> cairo-2.3.4.src.rpm
> Is there any way i can only get 2.3.4 from this file name
> thanks
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

I'm trying to think of a good reason to extract the version from the
filename instead of using RPM to get the real version from the
metadata and I can't come up with one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parsing a file name

2007-01-12 Thread Paul Boddie
Chris Mellon wrote:
>
> I'm trying to think of a good reason to extract the version from the
> filename instead of using RPM to get the real version from the
> metadata and I can't come up with one.

The inquirer doesn't have any RPM handling tools installed/available or
is dealing with a lot of versioned filenames which might be a selection
of different, arbitrary formats.

Try harder! ;-)

Paul

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


Re: What is a perl hash in python

2007-01-12 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Karyn Williams
wrote:

> I am new to Pyton. I am trying to modify and understand a script someone
> else wrote. I am trying to make sense of the following code snippet. I know
> line 7 would be best coded with regex.

What is line 7 in the snippet?

> I first would like to understand what was coded originally. thelistOut
> looks like a hash to me (I'm more familiar with perl).

It's a list which contains tuples.  Each tuple contains an integer and a
list with one string that looks like a pathname.

> Perhaps someone could translate from perl to python for me - not in code
> but just in concept.

Which Perl?  You gave us Python!?

> Here is the code. This script is reading the list thelistOut and then
> removing any items in RSMlist and taking the remainder and putting them
> in graphAddressOut with the formatting.

There's nothing removed from `thelistOut`.  Names where the
filename/basename without the extension is in `RSMList` are not processed
and added to `outputOut`.

> This is a SAMPLE of what is in the lists referenced below in the loop:
> 
> 
> thelistOut = [(632,
> ['/usr/local/www/data-dist/mrtg/main/test/172.16.0.23_9.log']), (145,
> ['/usr/local/www/data-dist/mrtg/main/test/172.16.0.23_13.log']), (0,
> ['/usr/local/www/data-dist/mrtg/main/test/172.16.0.23_5.log'])]
> 
> RSMList = ['172.16.0.1_1', '172.16.0.1_2', '172.16.0.1_3',
> '172.16.0.1_4', '172.16.0.1_5']
> 
> 
> 
> #--Loop 1 -
>
> w = 0
> while w < 45:

The loop looks odd.  Is it really a literal 45 here or are all elements of
`thelistOut` processed?  Then a for loop over the list if you don't need
`w` for something other than indexing into the list or an `xrange()`
object are much cleaner than using a while loop and updating the counter
manually. That the second element of the tuple seems to be always a list
with one item looks odd too.

>fileOut = string.split(thelistOut[w][1][0],".log")
>fileOutSplitedCommon = string.split(fileOut[0], "main/")
>fileOut2D = string.split(fileOutSplitedCommon[1], "/")
>fileOut = string.split(fileOut[0],"data-dist")

This might be more readable and understandable if `os.path.splitext()` and
`os.path.split()` where used.

>if fileOut2D[1] in RSMList:
>   w = w + 1
>   continue

Might be cleaner to negate the test and use the remaining code as body of
that ``if`` statement.

>graphAddressOut = tag1 + logUrl + fileOut[1] + extention1 + tag2
>+
> "SWITCH: " + string.swapcase(fileOut2D[0]) + "  & nbsp;PORT
> ID: " + fileOut2D[1] + "" + imgTitleTag + imgTag1 + logUrl +
> fileOut[1] + extention2 + imgTag2 + tag3 + tag5
>outputOut.append(graphAddressOut)
>strOut = strOut + graphAddressOut

That's an unreadable mess.  Better use string formatting.

And last but not least: a hash is called dictionary in Python.

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


I need to consume a .NET web service in a Python client

2007-01-12 Thread mohit
Hello,

I am a .NET developer experimenting with Python.
I need to consume a .NET web service in a Python client. how do I go
about it?
which libraries do i need?
pointers to help me get started would be much appreciated.
I am just a newbie to the Python world so please be bear with my novice
queries.

thanks in advance,
Mohit

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


Re: parsing a file name

2007-01-12 Thread Chris Mellon
On 12 Jan 2007 10:23:41 -0800, Paul Boddie <[EMAIL PROTECTED]> wrote:
> Chris Mellon wrote:
> >
> > I'm trying to think of a good reason to extract the version from the
> > filename instead of using RPM to get the real version from the
> > metadata and I can't come up with one.
>
> The inquirer doesn't have any RPM handling tools installed/available or
> is dealing with a lot of versioned filenames which might be a selection
> of different, arbitrary formats.
>
> Try harder! ;-)
>
> Paul

Well, the answer to the first is "get some", so that's not a good
reason. And the second would mean that they asked a question on c.l.p
without giving all the background information on the task they were
doing, and we know that never happens.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rational Numbers

2007-01-12 Thread Noud Aldenhoven

On 1/12/07, Facundo Batista <[EMAIL PROTECTED]> wrote:


Noud Aldenhoven wrote:

> There are a (small) couple of other issues where rational numbers could
be
> handy. That's because rational numbers are exact, irrational numbers (in
> python) aren't. But these issues are probably too mathematical to be
used in

For the sake of me being less ignorant, could you please point me a
language where irrational numbers are exact?



I'm not sure, but I tought MAPLE could do it. This language has been
designed for solving mathimatical equotations (and other simulair stuf) and
could handle irrational numbers.
But ofcourse irrational numbers could never be exact when printed in an
g-notation (g > 1) system.

But now I mention that sentense is wrong... it should be: "That's because
rational numbers are exact, but in python they aren't most of the time."

To make irrational numbers exact in python should be, I think, more
unefficient than making rational numbers. But they could be very handy too
for calculating maths or physics equotations.

Regards,

Noud

--
<:3 )~
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: I need to consume a .NET web service in a Python client

2007-01-12 Thread Ravi Teja

mohit wrote:
> Hello,
>
> I am a .NET developer experimenting with Python.
> I need to consume a .NET web service in a Python client. how do I go
> about it?
> which libraries do i need?
> pointers to help me get started would be much appreciated.
> I am just a newbie to the Python world so please be bear with my novice
> queries.
>
> thanks in advance,
> Mohit


Start Here
http://www.diveintopython.org/soap_web_services/index.html
Example Client
http://www.diveintopython.org/soap_web_services/first_steps.html

Ravi Teja

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


Re: I need to consume a .NET web service in a Python client

2007-01-12 Thread Simon Brunning
On 12 Jan 2007 11:11:21 -0800, Ravi Teja <[EMAIL PROTECTED]> wrote:
> Start Here
> http://www.diveintopython.org/soap_web_services/index.html
> Example Client
> http://www.diveintopython.org/soap_web_services/first_steps.html

Sadly, SOAPpy doesn't seem to be maintained any more. I'd take a look
at ZSI, instead.



-- 
Cheers,
Simon B
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rational Numbers

2007-01-12 Thread Simon Brunning
On 12 Jan 2007 15:55:39 GMT, Nick Maclaren <[EMAIL PROTECTED]> wrote:
>
> In article <[EMAIL PROTECTED]>,
> Carsten Haese <[EMAIL PROTECTED]> writes:
> |> but there are more use
> |> cases for Decimal than for Rational.
>
> That is dubious, but let's not start that one again.

Decimals are good for holding financial values. There's a whole lot of
software out there that deals with money.

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rational Numbers

2007-01-12 Thread Nick Maclaren

In article <[EMAIL PROTECTED]>,
"Simon Brunning" <[EMAIL PROTECTED]> writes:
|>
|> > |> but there are more use
|> > |> cases for Decimal than for Rational.
|> >
|> > That is dubious, but let's not start that one again.
|> 
|> Decimals are good for holding financial values. There's a whole lot of
|> software out there that deals with money.

Sigh.  I was hoping not to have that myth perpetrated again.

Financial calculations need decimal FIXED-point, with a precisely
specified precision.  It is claimed that decimal FLOATING-point
helps with providing that, but that claim is extremely dubious.
I can explain the problem in as much detail as you want, but would
very much rather not.


Regards,
Nick Maclaren.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rational Numbers

2007-01-12 Thread Thomas Ploch
Simon Brunning schrieb:
> On 12 Jan 2007 15:55:39 GMT, Nick Maclaren <[EMAIL PROTECTED]> wrote:
>> In article <[EMAIL PROTECTED]>,
>> Carsten Haese <[EMAIL PROTECTED]> writes:
>> |> but there are more use
>> |> cases for Decimal than for Rational.
>>
>> That is dubious, but let's not start that one again.
> 
> Decimals are good for holding financial values. There's a whole lot of
> software out there that deals with money.
> 

Do not forget:

- Time
- Personal Data (like birthdays, age)

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


Re: Rational Numbers

2007-01-12 Thread Simon Brunning
On 12 Jan 2007 19:41:52 GMT, Nick Maclaren <[EMAIL PROTECTED]> wrote:
> Sigh.  I was hoping not to have that myth perpetrated again.
>
> Financial calculations need decimal FIXED-point, with a precisely
> specified precision.  It is claimed that decimal FLOATING-point
> helps with providing that, but that claim is extremely dubious.
> I can explain the problem in as much detail as you want, but would
> very much rather not.

Sorry, Nick, you might have to. ;-)

I'm not educated in these matters, so I'd genuinely like to know why
you say that. Not educated, but I do have some experience; I've used
both fixed and floating point Decimal types extensively, and I've
found floating types superior. More fiddly, certainly, 'cos you have
to explicitly round back down to the precision that you want when you
want. But explicit is better than implicit - the number of subtle
rounding bugs that I've had to fix 'cos someone didn't realise where
rounding was occurring is, uh, well, it happens from time to time. ;-)

What am I missing?

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] XPN 0.7.0

2007-01-12 Thread Nemesis
XPN (X Python Newsreader) is a multi-platform newsreader with Unicode
support. It is written with Python+GTK. It has features like
scoring/actions, X-Face and Face decoding, muting of quoted text,
newsrc import/export, find article and search in the body, spoiler
char/rot13, random taglines and configurable attribution lines.

You can find it on:

http://xpn.altervista.org/index-en.html

or

http://sf.net/projects/xpn


Changes in this release:

* v0.7.0: added basic multiserver support. 
  This change has required some modifications to the groups db 
  format, in order to keep your subscriptions you need to export 
  to a newsrc file from XPN-0.6.5 and reimport it in XPN-0.7.0.
* v0.7.0: now is possible to use Function keys for customized keybindings   
* v0.7.0: modified the command used to test the connection in order to
  prevent hamster hang-ups.
* v0.7.0: fixed a bug that caused XPN to crash trying to export newsrc
  file with empty groups subscribed.
* v0.7.0: fixed a bug in "Apply Scoring and Actions Rules" feature that 
  caused XPN crashes trying to apply !kill rule.
* v0.7.0: some minor fixes.

XPN is translated in Italian French and German, if you'd like to translate it
in your language and you are familiar with gettext and po-files
editing please contact me ([EMAIL PROTECTED]).

-- 
I may not have gone where I intended to go, but I think I have ended up
where I needed to be.

 |\ |   |HomePage   : http://nem01.altervista.org
 | \|emesis |XPN (my nr): http://xpn.altervista.org


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


Re: Rational Numbers

2007-01-12 Thread Simon Brunning
On 1/12/07, Thomas Ploch <[EMAIL PROTECTED]> wrote:
> Do not forget:
>
> - Time
> - Personal Data (like birthdays, age)

The datetime module has perfectly good classes for holding date and
time values, and age sounds like an integer to me.

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


How to respond to a confirmation prompt automatically

2007-01-12 Thread Coby
Just to give you some background about my problem:

I execute os.system(command), where command is a string.

On the command line in windows, I get:

"Continue, and unload these objects? [no]"

I need to respond 'y' to continue, but I am uncertain on how to output
the 'y' automatically.


Thanks in advance.

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


dynamic argument name for functions

2007-01-12 Thread mark

I want to pass a value to an argument of a function. The argument name is
dynamic and is stored in a
variable. How do I call the function using with arg_name and value as the
parameters.
thanks
mark

For ex:
def function(arg1='None', arg2='None', arg3='None'):
 print arg1
 print arg2
 print arg3


arg_name = 'arg1'
arg_value = 'i am passing a value to argument 1'
function(???)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: dynamic argument name for functions

2007-01-12 Thread Carsten Haese
On Fri, 2007-01-12 at 12:17 -0800, mark wrote:
> I want to pass a value to an argument of a function. The argument name
> is dynamic and is stored in a 
> variable. How do I call the function using with arg_name and value as
> the parameters.
> thanks
> mark
> 
> For ex:
> def function(arg1='None', arg2='None', arg3='None'):
>   print arg1
>   print arg2
>   print arg3
> 
> 
> arg_name = 'arg1'
> arg_value = 'i am passing a value to argument 1'
> function(???)

function(**{arg_name: arg_value})

-Carsten


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


Re: dynamic argument name for functions

2007-01-12 Thread Simon Brunning
On 1/12/07, mark <[EMAIL PROTECTED]> wrote:
> I want to pass a value to an argument of a function. The argument name is
> dynamic and is stored in a
>  variable. How do I call the function using with arg_name and value as the
> parameters.
>  thanks
>  mark
>
>  For ex:
>  def function(arg1='None', arg2='None', arg3='None'):
>print arg1
>print arg2
>print arg3
>
>
>  arg_name = 'arg1'
>  arg_value = 'i am passing a value to argument 1'
>  function(???)

Untested:

function(**{arg_name: arg_value})

-- 
Cheers,
Simon B
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dynamic argument name for functions

2007-01-12 Thread Carsten Haese
On Fri, 2007-01-12 at 20:22 +, Simon Brunning wrote:
> On 1/12/07, mark <[EMAIL PROTECTED]> wrote:
> > I want to pass a value to an argument of a function. The argument name is
> > dynamic and is stored in a
> >  variable. How do I call the function using with arg_name and value as the
> > parameters.
> >  thanks
> >  mark
> >
> >  For ex:
> >  def function(arg1='None', arg2='None', arg3='None'):
> >print arg1
> >print arg2
> >print arg3
> >
> >
> >  arg_name = 'arg1'
> >  arg_value = 'i am passing a value to argument 1'
> >  function(???)
> 
> Untested:
> 
> function(**{arg_name: arg_value})

My version is superior: I tested it before replying. ;)

-Carsten


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


Re: Newbie imap lib question

2007-01-12 Thread Roel Schroeven
jrpfinch schreef:
> I have three messages in my inbox.  Why does messageCount =
> gServer.select('INBOX') not just return OK and 3.  See below for
> examples - seems to be completely random how many threes it returns.
> The documentation for imaplib seems sparse.  Does anybody have any good
> links?  Many thanks, Jon
> 
> messageCount =
>  0 : OK
>  1 : ['3']
> messageCount =
>  0 : OK
>  1 : ['3', '3', '3']
> messageCount =
>  0 : OK
>  1 : [None]
> messageCount =
>  0 : OK
>  1 : ['3', '3']

I'm afraid I can't help you: all I can say is that it works for my. It 
gives consistent results each time I run it.

 >>> import imaplib
 >>> M = imaplib.IMAP4('...')
 >>> M.login('...', '...')
('OK', ['User logged in'])
 >>> M.select('INBOX')
('OK', ['740'])

Always the same. Though the number changes if I receive or delete mail 
of course.

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


  1   2   >