BUG trace realtime

2005-12-29 Thread malv
How would you approach the following?
In a multithreaded realtime data acquisition system (all python v2.4),
after hours of running without a snag, without warning python hangs at
once without leaving any error message or error traceback at all. After
the incident, the OS itself (linux) appears to remain fully functional.
Thank you!
malv

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


Warning instaling python-2.3.5 on FreeBSD 5.3

2005-12-29 Thread spanov
i've got problem installing python-2.3.5 from sources on FreeBSD 5.3

[EMAIL PROTECTED] ./configure > conf_log
configure: WARNING: curses.h: present but cannot be compiled
configure: WARNING: curses.h: check for missing prerequisite
headers?
configure: WARNING: curses.h: see the Autoconf documentation
configure: WARNING: curses.h: section "Present But Cannot Be
Compiled"
configure: WARNING: curses.h: proceeding with the preprocessor's result
configure: WARNING: curses.h: in the future, the compiler will take
precedence
configure: WARNING: ## - ##
configure: WARNING: ## Report this to the python lists.  ##
configure: WARNING: ## - ##
configure: WARNING: ncurses.h: present but cannot be compiled
configure: WARNING: ncurses.h: check for missing prerequisite
headers?
configure: WARNING: ncurses.h: see the Autoconf documentation
configure: WARNING: ncurses.h: section "Present But Cannot Be
Compiled"
configure: WARNING: ncurses.h: proceeding with the preprocessor's
result
configure: WARNING: ncurses.h: in the future, the compiler will take
precedence
configure: WARNING: ## - ##
configure: WARNING: ## Report this to the python lists.  ##
configure: WARNING: ## - ##

Can anybody explain me what kind of problem do i have and how much
serious it could be?
Will be gratefull for any help. Sorry, english is not my native
language :)

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


Re: Draw over video

2005-12-29 Thread Zarathustra
THank you, very interesting!!
Merry Xmas and Happy new year!!!

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


Re: [EVALUATION] - E04 - Leadership! Google, Guido van Rossum, PSF

2005-12-29 Thread Ilias Lazaridis
Martin P. Hellwig wrote:
> Ilias Lazaridis wrote:
> 
> 
>>> The only thing that holds "you" theoretically back is "acknowledged 
>>> authority by the participating group _and_ yourself" and of course 
>>> the resource for "restricted" information.
>>
>> what do you mean by "resource for "restricted" information"?
>>
> Well, I mean that you should know before the others that Guido is 
> working for google otherwise such a publication is a bit late :-), 
> nevertheless better late then never.

I operate only based on publically available information.

Possibly you have something missunderstood (or I have explained missleading)

here is the actual diagramm:

http://lazaridis.com/efficiency/graph/index.html

>>> For the first part you got my vote, for second, well that should grow 
>>> in time.
>>
>> second part = "resource for "restricted" information" ?
> 
> yup
> 

ok.

[I will answer to the other messages of this thread later]

.

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


Re: python coding contest

2005-12-29 Thread Simon Hengel
> A funny thing happened to me.
> 
>The http://www.pycontest.net/ site was down for some minutes because :
> 
>"A problem occurred in a Python script. "
> 
> it seems, that
> 
>'some clever cheat'
> 
> has crashed it.
That was me, i broke things while tweaking some stuff.

Sorry for the inconveniences,

Simon Hengel

-- 
python coding contest - http://www.pycontest.net/

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


Re: python coding contest

2005-12-29 Thread Marius Gedminas
I cannot not reach the contest site at since all this morning.  :-(

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


Re: python coding contest

2005-12-29 Thread Marius Gedminas
I cannot reach the contest site at since all this morning.  :-(

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


Re: build curiosities of svn head (on WinXP)

2005-12-29 Thread Fredrik Lundh
Fredrik Lundh wrote:

> David Murmann wrote:
>
> > so this is where the problem has to be, but i am still not sure what to do
> > about this. is this a problem with my configuration, with my build or
> > with python?
>
> it's a python bug, and it has been introduced relatively recently.  iirc,
> there has been some recent tweaks to the floating-point parsing code...
>
> please file a report over at the bug tracker (and mark it as urgent).

see

http://www.python.org/sf/1391872

for bug report and patch.





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


Re: [EVALUATION] - E04 - Leadership! Google, Guido van Rossum, PSF

2005-12-29 Thread Martin P. Hellwig
Ilias Lazaridis wrote:

I'm suspecting that we have different definitions (or at least the 
implications of that) of used terms.
I think it's important to first define these definition in a form 
acceptable to both of us.

In the link you gave, the title was "Efficiency Management".
Now I believe that in _most_ implementations the words in the titles are 
mutual exclusive. So my first question is, please define "Efficiency" my 
second one is, please define "Management".

-- 
mph

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


split text file with x0Dx0A

2005-12-29 Thread ownowl
Hello

beginer under python, I have a problem to get lines in a text file. 
lines have inside the \n (x0A) char, and le readline method split the 
line at this char too (not only at x0Dx0A).
for resume, I want to split a file to lines with only those chars : x0Dx0A

A idea ?
thank's
Olivier
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: split text file with x0Dx0A

2005-12-29 Thread Fredrik Lundh
"ownowl" wrote:

> beginer under python, I have a problem to get lines in a text file.
> lines have inside the \n (x0A) char, and le readline method split the
> line at this char too (not only at x0Dx0A).

that's not a very clever design, at least if you plan to read the files
from C or compatible languages...

> for resume, I want to split a file to lines with only those chars : x0Dx0A
>
> A idea ?

the easiest way to do this is to open the file in binary mode, gobble up
the entire file, and split it yourself:

for line in open(filename, "rb").read().split("\r\n"):
...





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


Re: Warning instaling python-2.3.5 on FreeBSD 5.3

2005-12-29 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> i've got problem installing python-2.3.5 from sources on FreeBSD 5.3
>
> [EMAIL PROTECTED] ./configure > conf_log
> configure: WARNING: curses.h: present but cannot be compiled
> configure: WARNING: curses.h: check for missing prerequisite
> headers?
> configure: WARNING: curses.h: see the Autoconf documentation
> configure: WARNING: curses.h: section "Present But Cannot Be
> Compiled"
> configure: WARNING: curses.h: proceeding with the preprocessor's result
> configure: WARNING: curses.h: in the future, the compiler will take
> precedence
> configure: WARNING: ## - ##
> configure: WARNING: ## Report this to the python lists.  ##
> configure: WARNING: ## - ##
> configure: WARNING: ncurses.h: present but cannot be compiled
> configure: WARNING: ncurses.h: check for missing prerequisite
> headers?
> configure: WARNING: ncurses.h: see the Autoconf documentation
> configure: WARNING: ncurses.h: section "Present But Cannot Be
> Compiled"
> configure: WARNING: ncurses.h: proceeding with the preprocessor's
> result
> configure: WARNING: ncurses.h: in the future, the compiler will take
> precedence
> configure: WARNING: ## - ##
> configure: WARNING: ## Report this to the python lists.  ##
> configure: WARNING: ## - ##
>
> Can anybody explain me what kind of problem do i have and how much
> serious it could be?

your system contains slightly broken include files.  see

http://www.python.org/sf/1244610

for a discussion and a workaround (for openbsd), and

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=84219

for a freebsd-specific fix.





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


Re: Newbie needs help extracting data from XML

2005-12-29 Thread Alan Kennedy
[Rodney]
> Im a Python newbie and am trying to get the data out of a series of XML 
> files.

As Paul McGuire already noted, it's unusual to extract information from 
a SOAP message this way: it is more usual to use a SOAP toolkit to do 
the job for you.

But, assuming that you know what you're doing, and that you're doing it 
for good reasons, here's a snippet that uses xpath to do what you want.

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
document = """\

http://schemas.xmlsoap.org/soap/envelope/";
   xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
   xmlns:tns="http://www.ExchangeNetwork.net/schema/v1.0/node.wsdl";
   xmlns:types="http://www.ExchangeNetwork.net/schema/v1.0/node.wsdl";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
   
 http://schemas.xmlsoap.org/ws/2002/07/utility";>
   2005-12-28T05:59:38Z
   2005-12-28T06:04:38Z
 
   
   http://schemas.xmlsoap.org/soap/encoding/";>
 http://www.ExchangeNetwork.net/schema/v1.0/node.xsd";>
   Ready
 
   

"""

import xml.dom.minidom
import xml.xpath

#dom_tree = xml.dom.minidom.parse('my_xml_file.xml')
dom_tree = xml.dom.minidom.parseString(document)
return_node = xml.xpath.Evaluate('//return', dom_tree)[0]
print "Return status is: '%s'" % return_node.childNodes[0].nodeValue
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

You have to install PyXML to get xpath support: http://pyxml.sf.net

There are other ways to do it, e.g. using ElementTree, but I'll leave it 
to others to suggest the best way to do that.

HTH,

-- 
alan kennedy
--
email alan:  http://xhaus.com/contact/alan
-- 
http://mail.python.org/mailman/listinfo/python-list


Guido working on Pypy?

2005-12-29 Thread Luis M. González
This article is in Dutch:
http://www.computable.nl/nieuws.htm?id=1039941&WT.mc_id=rss

According to this blog entry, it says that Guido has been hired by
Google to work on Pypy:
http://zephyrfalcon.org/weblog2/arch_e10_00870.html

Is there anyone who can confirm this information?
Luis

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


Re: [EVALUATION] - E04 - Leadership! Google, Guido van Rossum, PSF

2005-12-29 Thread Ilias Lazaridis
Martin P. Hellwig wrote:
> Ilias Lazaridis wrote:
> 
> I'm suspecting that we have different definitions (or at least the 
> implications of that) of used terms.
> I think it's important to first define these definition in a form 
> acceptable to both of us.
> 
> In the link you gave, the title was "Efficiency Management".
> Now I believe that in _most_ implementations the words in the titles are 
> mutual exclusive. So my first question is, please define "Efficiency" my 
> second one is, please define "Management".

"
 *  The terminology is not yet aligned to commonly used business or 
standards organisation terminology [like e.g. ISO].
 * This will happen after the process definition has finalized.
"
source: http://lazaridis.com/efficiency/process.html (V 0.8c - alpha)

-

I am a few steps from having the final diagramms ready, then I can align 
the terminology (e.g. asking for feedback, thus people can detect 
existent constructs and suggest terminology changes)

I'll send you an email with some details (thus we don't discuss this 
off-topic in public).

.

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


Re: Newbie needs help extracting data from XML

2005-12-29 Thread Fredrik Lundh
Alan Kennedy wrote

> There are other ways to do it, e.g. using ElementTree, but I'll leave it
> to others to suggest the best way to do that.

using ElementTree with SOAP is discussed here:

http://effbot.org/zone/elementsoap-1.htm





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


Re: python coding contest

2005-12-29 Thread Claudio Grondi
Simon Hengel wrote:
> Hello,
> we are hosting a python coding contest an we even managed to provide a
> price for the winner...
> 
> http://pycontest.net/
> 
> The contest is coincidentally held during the 22c3 and we will be
> present there.
> 
> https://events.ccc.de/congress/2005/wiki/Python_coding_contest
> 
> Please send me comments, suggestions and ideas.
> 
> Have fun,
> 

It seems, that the site had some trouble to stay online and especially 
to provide the ranking today.

I am a bit dissapointed, that my idea of not duplicating, but utilizing 
the efforts others put into solving the job (titled by the submitter ID 
'TheParasite') which resulted in a submission of a 15 Bytes large full 
functional module was evaluated as having a 'syntax error' problem and 
was placed in the ranking at the position according to the size of the 
331 byte large .zip archive it was put into along with some necessary 
installation instructions.

By the way: trying to submit along with the module complete installation 
instructions and comments failed because there is a 345 bytes limit for 
size of allowed uploads.

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


Re: run line or selection

2005-12-29 Thread Fuzzyman
SPE has that - see http://www.stani.be/python/spe/blog/

It's a *very* nice Python IDE, and has recently had some pretty cool
features added.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

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


Re: some suggestions about GUI toolkits?

2005-12-29 Thread Fuzzyman
wxGlade is built into SPE the Python IDE.
http://www.stani.be/python/spe/blog/

I personally use Wax - http://sf.net/projects/waxgui

This is another layer *on top* of wxPython, but makes it much nicer to
program with.

For *small* GUIs you're probably better using Tkinter, which can be
made to look nice - and has the easiest learning curve (and a much
lower installation overhead than the others, because it comes with most
distributions of Python).

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

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


Re: python coding contest

2005-12-29 Thread Simon Hengel
> It seems, that the site had some trouble to stay online and especially 
> to provide the ranking today.
There was a problem with our server, sorry for that.

Have fun,

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


Re: BUG trace realtime

2005-12-29 Thread Peter Hansen
malv wrote:
> How would you approach the following?
> In a multithreaded realtime data acquisition system (all python v2.4),
> after hours of running without a snag, without warning python hangs at
> once without leaving any error message or error traceback at all. After
> the incident, the OS itself (linux) appears to remain fully functional.

1. Define "hangs" more precisely.  It's rare that an app can hang 
without any behaviour that can tell you something more about it.  For 
example, can you Ctrl-C out of it?  Does it have sockets open still?  Is 
it using any CPU time?  etc...   While you're at it, define "realtime" 
too, since many people use it incorrectly and it might mean something 
different to you than it does to everyone else reading it...

2. Use logging.  "import logging" and proceed from there...  without 
logging, you have no idea where the problem occurred, and are going to 
spend lots of time guessing where the cause is.

3. Make sure you are using Queues exclusively for inter-thread 
communication.

4. Consider whether your external source of data (assuming there is one) 
is the cause.  How are you interfacing to it?  Serial port?  ctypes? 
Something SWIGged for Python?  A true "hang" is much more likely in an 
external package than in Python code.

5. Tell us more about the platform.  Which Linux (including version), 
does it have a GUI, what's the basic architecture of the app as it 
relates to the threading and data acquisition stuff, etc.  (Of course, 
the problem might not come from threads or data acquisition, but until 
we learn more who could say?)

-Peter

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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2005-12-29 Thread Ilias Lazaridis
Anton Vredegoor wrote:
> Robert Kern wrote:
> 
> 
>>I have a friend who works at Google. He has no backstabbing history at all. 
>>Stop
>>insulting my friends.
> 
> Your friends work for people who would never hire me. My resume sucks,
> but I'm not a bad person or a mediocre programmer. They sold out.
> 
>>For Software Engineer:
>>
>>"""
>>Requirements:
>>
>>* BS or MS in Computer Science or equivalent (PhD a plus).
> 
> Right here.

This requirement is really funny.

I thought google is somehow different.

>>* Several years of software development experience.
>>* Enthusiasm for solving interesting problems.
>>* Experience with Unix/Linux or Windows environments, C++ development,
>>distributed systems, machine learning, information retrieval, network
>>programming and/or developing large software systems a plus.
>>"""
>>
>>I don't see any "damaged soul" requirement.
> 
> I do. Experience here is an eufemism for having worked for the man.

I think I understand your thought.

Although I have very much experience, I have not "worked for the man":

http://lazaridis.com/resumes/lazaridis.html

which would mean that Google would not hire me.

[No problem, it's their lost.]

[...]
>>Prove yourself right.
> 
> Ok. That's a bit harder. I suppose we agree that if we have an
> intelligent program that is more intelligent than a human and have this
> program design an even more intelligent program than things start to
> accelerate pretty fast?

ok

> Now the combination of a programmer with a tool (program) that can be
> used to make a better tool. This gives a better human-machine
> combination, which then can be used to further improve the combination.

=> high evolutive system

http://lazaridis.com/core/system/evolution.html

> I don't think I have completely proven my point now, but since the
> danger is very real and big, coming close is already reason enough to
> watch this carefully. Why hasn't it happened yet with lisp? I don't
> know, 

http://lazaridis.com/core/eval/lisp.html

> why didn't the world get destroyed by all out atomic warfare?
> Couldn't it have happened?

Of course.

But we should focus on that it don't happen in future.

> If we create AI why would AI keep us around if we ourselves won't even
> hire people that do not comply to absurdly specific preconditions?
> Don't we let our poor people starve in the undeveloped countries or
> even in our own cities? If we want to prove we belong to the next world
> we should start now. Open work communities where everyone can start
> working and get paid. The same thing as open source code or usenet but
> now with money for everyone.

Very nice thoughts - but just thoughts.

You should act.

As a first step, you should have your thoughts collected on a website, 
thus you can point to them.

And then comes the difficult thing:

Transforming thoughts to real-life actions.

I'll contact you via email, thus this thread remains 'clean'.

> Anton
> 
> 'sorry, I don't want to start a flamewar, but I really believe what I
> wrote here'

.

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


Re: some suggestions about GUI toolkits?

2005-12-29 Thread iclinux
thanks all,
There're so many GUI toolkits that make newbie(like me) feel confused.
If there's a much up-to-date evaluation about that, things may become
easier.

Now, I'm trying PythonCard(http://pythoncard.sourceforge.net/). and
hope everything goes well: )

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


Graphviz/dot language formatter

2005-12-29 Thread samhng
Hi,
I am new to Graphviz/dot language, the source .dot files are chaos so I
am looking for source formatter for the .dot files, any ideas?

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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2005-12-29 Thread Michael Schneider
Congratulations to Guide,

Mike

Harald Armin Massa wrote:
> Guido at Google: a message in THE public forum c.l.p.
> 
> A confirmation by Martellibot, that Guido is IN FACT sitting 15m
> distant from him; and everybody in Python knows where Martellibot has
> his desk.
> 
> Can it get more official than this?
> 
> yeah:
> a confirmation by Greg Stein @ Google within slashdot, that Guido is
> working at Google.
> 
> I am sure that more people in the Python community are reading c.l.p.
> and /. than the washington post, the people affected have been
> informed.
> 
> I guess that's as formal and official as it can get.
> 
> And concerning Guido, Python, community and leadership:
> 
> Guido is the designer, the creator of Python. He has nearly unlimeted
> trust in his design decisions: we all know, that he is THE gifted
> language designer. His proclamations are accepted because he has proven
> over time that he knows what's best for the language.
> 
> Allow me to quote Greg Stein:
> "Ha! Guido would quit in a heartbeat if you tried to make him manage
> people. That just isn't where he's at. He's absolutely brilliant and
> loves to write excellent code. Great. We're gonna let him do just that
> :-)"
> 
> So, Google with their geek-version of the Playboy-Mansion, free massage
> parleurs, free lunch and dinner and best recruitment tactics on the
> planet and the known universe will not be able to make Guido manage
> people.
> 
> Somehow the Python community managed itself through the years... Python
> grew healthy and steadily; forked less then usual, inspired other
> languages and got faster and faster and faster.
> 
> Maybe only mediocre and less ideas need a great leader. Maybe a great
> idea can lead for itself?
> 
> Harald
> 
> --
> GHUM Harald Massa
> persuadere et programmare
> Harald Armin Massa
> Reinsburgstraße 202b
> 70197 Stuttgart
> 0173/9409607
> 


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: split text file with x0Dx0A

2005-12-29 Thread ownowl
Fredrik Lundh a écrit :
> "ownowl" wrote:
> 
> 
>>beginer under python, I have a problem to get lines in a text file.
>>lines have inside the \n (x0A) char, and le readline method split the
>>line at this char too (not only at x0Dx0A).
> 
> 
> that's not a very clever design, at least if you plan to read the files
> from C or compatible languages...
> 
> 
>>for resume, I want to split a file to lines with only those chars : x0Dx0A
>>
>>A idea ?
> 
> 
> the easiest way to do this is to open the file in binary mode, gobble up
> the entire file, and split it yourself:
> 
> for line in open(filename, "rb").read().split("\r\n"):
> ...
> 
> 

great
thank's
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E04 - Leadership! Google, Guido van Rossum, PSF

2005-12-29 Thread Martin P. Hellwig
Ilias Lazaridis wrote:
> Martin P. Hellwig wrote:
>> Ilias Lazaridis wrote:
>> 
>> I'm suspecting that we have different definitions (or at least the 
>> implications of that) of used terms.
>> I think it's important to first define these definition in a form 
>> acceptable to both of us.
>>
>> In the link you gave, the title was "Efficiency Management".
>> Now I believe that in _most_ implementations the words in the titles 
>> are mutual exclusive. So my first question is, please define 
>> "Efficiency" my second one is, please define "Management".
> 
> "
> *  The terminology is not yet aligned to commonly used business or 
> standards organisation terminology [like e.g. ISO].
> * This will happen after the process definition has finalized.
> "
> source: http://lazaridis.com/efficiency/process.html (V 0.8c - alpha)
> 
> -
> 
> I am a few steps from having the final diagramms ready, then I can align 
> the terminology (e.g. asking for feedback, thus people can detect 
> existent constructs and suggest terminology changes)
> 
> I'll send you an email with some details (thus we don't discuss this 
> off-topic in public).
> 
> .
> 
 > Ilias Lazaridis wrote in email:
 > Hi,
 >
 > just point me to a website you are related to (your personal one, 
your business one, ...) and I'll initialize the process, as defined in 
the draft-document:
 >
 > http://lazaridis.com/efficiency/textual.html
 >
 > -
 >
 > What I need at this point:
 >
 > - Website adress
 > - your requirements & constraints for my processing
 >
 > .
 >

Hey,

I respond on your "private" mail and list in one and to both, I don't 
regard this as off-topic because it is still in regard of your OP, 
although that post can be seen as a bait to go OT.

I didn't ask you for making an analyze, I asked you for your definitions 
because I think they are not the same as used in my contexts.

Now definitions like the ones in the dictionary are all fine and such 
but it still doesn't say what the strings are, for example communication 
is a word used to describe the process of information transfer (by 
whatever means, could be smoke signals or drum sounds for my part).
Information transfer is a broad term raising immediately the question: 
"Transfer? . In what direction?"
The answer depends on the situation, if both parties are equal in terms 
of information authority, the transfer will resemble a dialog i.e. two way.
If both parties are not on par in terms of information authority, the 
transfer will resemble a monolog i.e. one way.
Now this is taken in the extremes, in reality there are usual more than 
2 parties and the information authority can vary on the subject while 
the subjects are still related with each other (no wonder why there is 
so much miscommunication).

An interesting note is that to describe the relation of communication I 
have to use another term, "information authority", this term is IMHO 
very important and very difficult because you can not define this term 
in such a way that it's  acceptable for all involving parties without 
being authoritative on that specific information piece. Unfortunately 
these kind of situations are all but rare just take a look at 
http://en.wikipedia.org/wiki/Bootstrap .

Which leads to the interesting question, when is someone authoritative 
on information without the use of ipsedixitism.
The answer is IMO actually quite simple: Never, your only authoritative 
if others accept you as being authoritative, of course this can be 
enforced by various means, like the use of hierarchy or religion.
However more modern organization revert to the use of democracy 
(everybody has an equal vote) or play along (if you don't like, you are 
not enforced to stay, so accept it or beat it)  because  if you let 
people decide for them self who is authoritative for them it's easier 
for that authority to be accepted as such.

Now I don't say that I'm right here and you are not, actually I'm still 
puzzled about what your intention of your original post was anyway.
Thus what I said above should also apply to myself, so I do not have the 
authority by myself to say that I'm authoritative to say that I'm right 
and you are not, but what are your reasons to assume that you are 
authoritative over me? (This is a genuine question and not intended as 
rhetorical)

So the sum it up my unanswered question to you so far are:
- What is your definition of "Efficiency"
- What is your definition of "Management"
- What is you definition of "Communication" (to compare it with mine above)
- What are your reasons that I should accept you as authoritative on the 
subject of "Efficiency Management"?
- What has all that to do with Python except for that Guido is related 
to Google and Python?

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


Re: Graphviz/dot language formatter

2005-12-29 Thread Paul McGuire

[EMAIL PROTECTED] wrote:
> Hi,
> I am new to Graphviz/dot language, the source .dot files are chaos so I
> am looking for source formatter for the .dot files, any ideas?

Pydot is a pyparsing-based parser at http://dkbza.org/pydot.html.  This
may give you a jump on source formatting.

-- Paul

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


Re: [EVALUATION] - E04 - Leadership! Google, Guido van Rossum, PSF

2005-12-29 Thread Ilias Lazaridis
Martin P. Hellwig wrote:
> Ilias Lazaridis wrote:
>> Martin P. Hellwig wrote:
>>> Ilias Lazaridis wrote:
>>> 
>>> I'm suspecting that we have different definitions (or at least the 
>>> implications of that) of used terms.
>>> I think it's important to first define these definition in a form 
>>> acceptable to both of us.
>>>
>>> In the link you gave, the title was "Efficiency Management".
>>> Now I believe that in _most_ implementations the words in the titles 
>>> are mutual exclusive. So my first question is, please define 
>>> "Efficiency" my second one is, please define "Management".
>>
>> "
>> *  The terminology is not yet aligned to commonly used business or 
>> standards organisation terminology [like e.g. ISO].
>> * This will happen after the process definition has finalized.
>> "
>> source: http://lazaridis.com/efficiency/process.html (V 0.8c - alpha)
>>
>> -
>>
>> I am a few steps from having the final diagramms ready, then I can 
>> align the terminology (e.g. asking for feedback, thus people can 
>> detect existent constructs and suggest terminology changes)
>>
>> I'll send you an email with some details (thus we don't discuss this 
>> off-topic in public).
>>
>> .
>>
>  > Ilias Lazaridis wrote in email:
>  > Hi,
>  >
>  > just point me to a website you are related to (your personal one, 
>  > your business one, ...) and I'll initialize the process, as defined in 
>  > the draft-document:
>  >
>  > http://lazaridis.com/efficiency/textual.html
>  >
>  > -
>  >
>  > What I need at this point:
>  >
>  > - Website adress
>  > - your requirements & constraints for my processing
> 
> Hey,
> 
> I respond on your "private" mail and list in one and to both, I don't 
> regard this as off-topic because it is still in regard of your OP, 
> although that post can be seen as a bait to go OT.

You should not reproduce private conversation on public media.

> I didn't ask you for making an analyze, I asked you for your definitions 
> because I think they are not the same as used in my contexts.
[...]

Making an small analysis can assist you to understand the terminology 
(and me to align the terminology). You are free to reject this.

As I am free to terminate the discussion here.

Feel free to contact me with private email (after a few hours).

Thank you.

.

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


Re: Python as a Server vs Running Under Apache

2005-12-29 Thread Matt Helm

<[EMAIL PROTECTED]> writes:
> Running under Apache is nice if you need other apache services like
> proxying, mod_rewrite, some of the accelerated static file serving
> plugins, etc.

Not needed, this is web services only. That is, Apache is needed, but
only to handle the PHP consumers of the web services.


> Also, there may be some political/marketing gain (easier to pitch your
> proposal if it's running under Apache).

Not a problem. I get the final say-so on the design, platform, and
languages we use.


> But basically, if you're doing a pure-python system from scratch then
> there's not much gained by running under Apache.

Thanks, that is exactly what I was needing to know.

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


Re: How do I redirect output to a file and to the console screen?

2005-12-29 Thread 28tommy
Thank U.

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


how to tell the version of tk shipped with Python

2005-12-29 Thread pipehappy
I am a newbie to the Python and wonder how I can know version of tk
bound with Python

Can some one tell me?

Thanks

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


Passing cgi parameters to script...

2005-12-29 Thread sophie_newbie
Is there any way that I can pass cgi parameters to my script locally,
before i upload it to the webserver, so that i can debug it.

Normally I would pass parameters like this:

www.webserver.com/script.cgi?TERM1=hello&FIELD1=TTL&TERM2=goodby&FIELD2=GOVT

The problem is that I get errors that do not show up when I run the
script locally and I do not have access to the error logs.

So is there a way I can pass the form values TERM1, FIELD1 etc to the
script without having to upload it to the server?

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


Re: how to tell the version of tk shipped with Python

2005-12-29 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> I am a newbie to the Python and wonder how I can know version of tk
> bound with Python
>
> Can some one tell me?

>>> import Tkinter
>>> print Tkinter.TclVersion
8.4





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


Modifying values in a list

2005-12-29 Thread tron . thomas
The following code:

numbers = [1, 2, 3]
for value in numbers:
value *= 2
print numbers

results in the following output:
[1, 2, 3]

The intent of the code was to produce this output:
[2, 4, 6]

What is the reason for the output produced?
What code should be used to obtain the desired output?

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


Re: Simple question on Parameters...

2005-12-29 Thread Fredrik Lundh
Hans Nowak wrote:

> You don't have to use fillColor[0], you can use tuple unpacking to name
> the elements of the tuple.  E.g.
>
> def renderABezierPath(self, path, closePath=True, outlineColor=(1.0,
> 1.0, 1.0, 1.0), fillColor=(0.0, 0.0, 0.0, 0.25)):
>  r, g, b, a = outlineColor
>  fr, fg, fb, fa = fillColor
>  ...do something with these values...

note that you can do the unpacking in the parameter list, if you
prefer:

>>> def render((r, g, b, a)=(1, 0, 0, 1)):
... print r, g, b, a
...
>>> render()
1 0 0 1
>>> render((1, 1, 1, 0.5))
1 1 1 0.5

(but I'm not sure that combining unpacking and default values is
the best way to write readable code, though...)





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


Re: Modifying values in a list

2005-12-29 Thread Björn Lindström
[EMAIL PROTECTED] writes:

> The following code:
>
> numbers = [1, 2, 3]
> for value in numbers:
>   value *= 2
> print numbers
>
> results in the following output:
> [1, 2, 3]
>
> The intent of the code was to produce this output:
> [2, 4, 6]
>
> What is the reason for the output produced?
> What code should be used to obtain the desired output?

How about this?

numbers = [1, 2, 3]
print [x * 2 for x in numbers]

-- 
Björn Lindström <[EMAIL PROTECTED]>
Student of computational linguistics, Uppsala University, Sweden
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Passing cgi parameters to script...

2005-12-29 Thread Diez B. Roggisch
sophie_newbie wrote:

> Is there any way that I can pass cgi parameters to my script locally,
> before i upload it to the webserver, so that i can debug it.
> 
> Normally I would pass parameters like this:
> 
>
www.webserver.com/script.cgi?TERM1=hello&FIELD1=TTL&TERM2=goodby&FIELD2=GOVT
> 
> The problem is that I get errors that do not show up when I run the
> script locally and I do not have access to the error logs.
> 
> So is there a way I can pass the form values TERM1, FIELD1 etc to the
> script without having to upload it to the server?


You might think of using CGIHttpServer to test your scripts in a
server-environment - while still being local.

Regards,

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


Re: Modifying values in a list

2005-12-29 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 29/12/05 10:43 AM:
> The following code:
> 
> numbers = [1, 2, 3]
> for value in numbers:
>   value *= 2
> print numbers
> 
> results in the following output:
> [1, 2, 3]
> 
> The intent of the code was to produce this output:
> [2, 4, 6]
> 
> What is the reason for the output produced?
> What code should be used to obtain the desired output?

value is bound in the for loop, but none of that affects the list to 
which numbers is bound.

One way:

IDLE 1.1.2
 >>> numbers = [1, 2, 3]
 >>> numbers = [x * 2 for x in numbers]
 >>> print numbers
[2, 4, 6]
 >>>

HTH,

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


Re: Modifying values in a list

2005-12-29 Thread Carsten Haese
On Thu, 2005-12-29 at 11:43, [EMAIL PROTECTED] wrote:
> The following code:
> 
> numbers = [1, 2, 3]
> for value in numbers:
>   value *= 2
> print numbers
> 
> results in the following output:
> [1, 2, 3]
> 
> The intent of the code was to produce this output:
> [2, 4, 6]
> 
> What is the reason for the output produced?
> What code should be used to obtain the desired output?

1) Read http://www.effbot.org/zone/python-objects.htm and reread it
until you understand why your code doesn't work.

2) Use a list comprehension:
numbers = [ value*2 for value in numbers ]

-Carsten


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


Re: Modifying values in a list

2005-12-29 Thread Tim Williams (gmail)
On 29 Dec 2005 08:43:17 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]
> wrote:The following code:numbers = [1, 2, 3]for value in numbers:
value *= 2print numbers
Above,  you are modifying "value", not the item in the list


>>> numbers = [1, 2, 3]
>>> for x in range(len(numbers)):
...     numbers[x] = numbers[x]*2
>>> numbers
[2, 4, 6]
HTH :)-- Tim Williams
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Passing cgi parameters to script...

2005-12-29 Thread Mike Meyer
"sophie_newbie" <[EMAIL PROTECTED]> writes:
> Is there any way that I can pass cgi parameters to my script locally,
> before i upload it to the webserver, so that i can debug it.
>
> Normally I would pass parameters like this:
>
> www.webserver.com/script.cgi?TERM1=hello&FIELD1=TTL&TERM2=goodby&FIELD2=GOVT

CGI paramaters are set in the environment. On Unix, in an sh-like
shell, do:

QUERY_STRING='TERM1=hello&FIELD1=TTL&TERM2=goodby&FIELD2=GOVT' 
www.webserver.com/script.cgi

Depending on the package you're using for handling CGI, you may need
to set other CGI parameters as well. The traceback from trying this
should give you a KeyError naming the environment variable it's
looking for.

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


Re: Is this a refrence issue?

2005-12-29 Thread Scott David Daniels
KraftDiner wrote:
> I have a list and want to make a copy of it and add an element
> to the end of the new list, but keep the original intact

Nobody has mentioned the obvious yet:

 tmp = myList + [something]

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


Extending Python with C++

2005-12-29 Thread jeremito
I am learning how to extend Pythong with C++.  I have will be writing
some code in C++ and want/need Python to interact with it.  I am not
having success following the online documentation from
http://docs.python.org/ext/ext.html.  I have also looked briefly at
some of the demos in the source code distribution.  Can anyone help me?
 I am using the MacPython (version 2.4) distribution.

I have one specific question.  The documentation online states:

"If the main program (the Python interpreter) is compiled and linked by
the C compiler, global or static objects with constructors cannot be
used. This is not a problem if the main program is linked by the C++
compiler."

Thanks,
Jeremy

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


Re: BUG trace realtime

2005-12-29 Thread malv
Hi Peter,
Thank you for your extensive reply.
In the meantime, I solved the problem. I had started out to trace the
path of the randomly arriving external data through the different
threaded processing stages. After one of those 'hangs', with some luck,
I was able to spot the cause of the trouble: a piece of old code that
wasn't supposed to be out there! Really dumb.
FYI, to my surprise, Python really quit. No more CPU time, no message,
nothing. I can't recall having seen this before. You are quite right
about queues. I use these extensively and carefully. This kind of
enabled me to trace the path of the externally triggered events without
too much of a hassle.
Thanks again,
malv

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


Re: Extending Python with C++

2005-12-29 Thread Fredrik Lundh
"jeremito" <[EMAIL PROTECTED]> wrote:

> I have one specific question.  The documentation online states:
>
> "If the main program (the Python interpreter) is compiled and linked by
> the C compiler, global or static objects with constructors cannot be
> used. This is not a problem if the main program is linked by the C++
> compiler."

what is the question ?





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


Re: "Humane" programmer interfaces

2005-12-29 Thread colinwb
Apologies if I'm misunderstanding some points in kpd's post, but:

http://www.rubycentral.com/ref/ref_c_array.html

[ ]
arr[anInteger] -> anObject or nil
arr[start, length] -> aSubArray or nil
arr[aRange] -> aSubArray or nil

Element Reference

Returns the element at index anInteger, or returns a subarray starting
at index start and continuing for length elements, or

returns a subarray specified by aRange. Negative indices count backward
from the end of the array (-1 is the last element).

Returns nil if any indices are out of range.

[ ]=
arr[anInteger] = anObject -> anObject
arr[start, length] = aSubArray -> aSubArray
arr[aRange] = aSubArray -> aSubArray


http://tryruby.hobix.com

Interactive ruby ready.
>> ck = Array [ 'C', 'K', 'S', 'vvg' ]
=> ["C", "K", "S", "vvg"]

>> puts ck.first, ck[0], '*', ck.last, ck[-1]
   C   C  * vvg  vvg
=> nil

>> puts ck[0..2], '*', ck[-4..-2]
C  K  S*C  K  S
=> nil

>> puts ck.size, ck.length
   4  4
=> nil

(The print elements in these example were actually
printed on separate lines. I've put them on the
same line for clarity and to save email space.)

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


Re: Extending Python with C++

2005-12-29 Thread Brian van den Broek
jeremito said unto the world upon 29/12/05 11:39 AM:
> I am learning how to extend Pythong with C++.  I have will be writing
> some code in C++ and want/need Python to interact with it.  I am not
> having success following the online documentation from
> http://docs.python.org/ext/ext.html.  I have also looked briefly at
> some of the demos in the source code distribution.  Can anyone help me?
>  I am using the MacPython (version 2.4) distribution.
> 
> I have one specific question.  The documentation online states:
> 
> "If the main program (the Python interpreter) is compiled and linked by
> the C compiler, global or static objects with constructors cannot be
> used. This is not a problem if the main program is linked by the C++
> compiler."
> 
> Thanks,
> Jeremy

I have a specific answer.

Best,

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


Re: Extending Python with C++

2005-12-29 Thread jeremito
Oops, sorry.  My question is, how can I know if my Python interpreter
was lined by C++?  The non-specific questions are, of course, does
anyone have any hints or suggestions?  Good websites to visit?
Thanks,
Jeremy

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


Re: BUG trace realtime

2005-12-29 Thread Peter Hansen
malv wrote:
> After one of those 'hangs', with some luck,
> I was able to spot the cause of the trouble: a piece of old code that
> wasn't supposed to be out there! Really dumb.
> FYI, to my surprise, Python really quit. No more CPU time, no message,
> nothing. I can't recall having seen this before. 

If you post the relevant "old code" it's very likely someone could point 
out exactly why it failed, and how it wasn't *Python* that "quit", but 
merely something in your code that was blocking.  (In other words, 
Python probably did exactly what you told it to do.)

In general, Python does not "quit".  It's very robust.  When you get a 
failure like that, always suspect your own code structure.

-Peter

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


Re: getting the status codes from the ftplib module

2005-12-29 Thread John J. Lee
"Alvin A. Delagon" <[EMAIL PROTECTED]> writes:

> I'm writing a simple python code that will upload files onto a ftp 
> server. Everything's fine and working great except that the script I 
> wrote don't know is an upload is successful or not. Is there a way to 
> obtain the ftp status codes with this module? Thanks in advance!

forgot to mention that the urllib2 example I posted is for Python 2.4
-- won't work with 2.3.

For 2.3, 2.2, and 2.1, you have to do:

import urllib2

try:
response = urllib2.urlopen("http://www.reportlab.com/blarney";)
except urllib2.HTTPError, e:
print e.code
else:
print 200


urllib2 in 2.0 is a bit broken, IIRC.


John

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


rss parsing: sax or dom

2005-12-29 Thread Sakcee
hi

I am trying to parse rss2 feeds in python, should I use sax and define
handler and then functions for each tag or should I go for dom
approach.

thanks for any comments

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


Re: how to tell the version of tk shipped with Python

2005-12-29 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] wrote:
>
>> I am a newbie to the Python and wonder how I can know version of tk
>> bound with Python
>>
>> Can some one tell me?
>
 import Tkinter
 print Tkinter.TclVersion
>8.4
>
>
>
>
>

... and, if you need more detail,

>>> print Tkinter.TkVersion
8.4
>>> Tkinter.Tk().tk.eval("info patchlevel")
'8.4.7'
>>> print Tkinter.__version__
$Revision: 1.177 $
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: rss parsing: sax or dom

2005-12-29 Thread Jarek Zgoda
Sakcee napisał(a):

> I am trying to parse rss2 feeds in python, should I use sax and define
> handler and then functions for each tag or should I go for dom
> approach.

You should use feedparser.

-- 
Jarek Zgoda
http://jpa.berlios.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modifying values in a list

2005-12-29 Thread Paul McGuire
As others have already posted, changing the value of 'value' has
nothing to do with the list variable 'numbers'.  To modify the list in
place, you need to access its members by index.  The following code
does this:

numbers = [1,2,3]
for i in range(len(numbers)):
numbers[i] *= 2
print numbers

But this is how a C or Java programmer would approach this task, and is
not very Pythonic.

A bit better is to use enumerate (avoids the ugly range(len(blah))
looping):

numbers = [1,2,3]
for i,val in enumerate(numbers):
numbers[i] = val*2

This also modifies the list in place, so that if you are modifying a
very long (and I mean really quite long - long enough to question why
you are doing this in the first place) list, then this approach avoids
making two lists, one with the old value and one with the new.

But the most Pythonic is to use one of the list comprehension forms
already posted, such as:

numbers = [ x*2 for x in numbers ]

-- Paul

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


Re: tutorials on xslt

2005-12-29 Thread gene tani

Iyer, Prasad C wrote:
> Hi,
> Is there any tutorial available for python-xslt processing.

Yes, but instead of giving you a fish:

use google groups "Searth this group" button, sort the numerous results
by date, you'll get what you need

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


Re: Extending Python with C++

2005-12-29 Thread Martin v. Löwis
jeremito wrote:
> Oops, sorry.  My question is, how can I know if my Python interpreter
> was lined by C++?

Ah. This documentation fragment is somewhat wrong: it depends on the
target operating system and compiler whether you have to link main
with a C++ compiler. For many modern systems, this isn't necessary.

Anyway, finding out whether the executable was linked with a C++
compiler is only possible with platform-dependent tools. For example,
on Linux and many Unix systems, ldd(1) will tell you whether a C++
library was linked into the binary; do 'ldd python'.

> The non-specific questions are, of course, does
> anyone have any hints or suggestions?

You should really understand the concept of 'extern "C"' in C++.
That's all you need to know write Python extensions in C++.

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


Distributions, RE-verb and the like

2005-12-29 Thread bearophileHUGS
Psyco is finished now, and it works on the x86, for Win, the new macs,
many linux boxes, etc, and it's quite useful, so maybe it can be added
to the standard Python distribution.

PyChecker (and the other similar ones that work differently) is very
useful too, and it's pure Python, so maybe it too (or something
similar) can be added to the standard distribution.



Regular Expressions can be useful but:
- They look really an-pythonic
- Their syntax is difficult to remember
- It's not easy to understand and debug REs written by other people,
comments help a little.
- They can have hidden bugs (because of their low readability)
- they mix their opeators/syntax with the data (this is thier advantage
too), this can create problems, and makes them less general (because
you have to avoid mistaking syntax elements with the data).
- Python has already syntax to define structures, loops, etc, so
another syntax can be seen as a kind of duplication.

Such things go against lot of points of the Python Zen. So I'd like a
more pythonic syntax, easy to remember, easy to read and debug, where
data and operators are fully separated. The "reverb" library does
something like that already:
http://home.earthlink.net/~jasonrandharper/reverb.py

It compiles RE written like this:

xdigit = set(digits, char('a').to('f'), char('A').to('F'))
pat = RE((text('$') | text('0x') | text('0X')) + required(hexdigit, max
= 8) - followedBy(hexdigit))

I have already "improved" reverb a little, but I think a better and
simpler syntax can be invented by people more expert than me in REs.
Here are some alrernative syntax possibilities, I don't like them, most
of them are impossible, silly, stupid, etc, but I am sure a good syntax
can be invented.

Standard RE:
pat.pattern: (?:\$|0x|0X)[\da-gA-G]{1,8}(?![\da-gA-G])

hexdigit = set(digits, chrint('a','f'), chrint('A','F'))
pat = RE((text('$') | text('0x') | text('0X')) + repeated(hexdigit, 1,
8) - followedBy(hexdigit))

hexdigit = alt(digits, chrint('a','f'), chrint('A','F'))
pat = optional("-") + alt('$', '0x', '0X') + times(hexdigit, 1, 8) -
hexdigit

hexdigit = VR(digits, interval('a', 'f'), interval('A', 'F'))
pat = optional("-") + VR('$', '0x', '0X') + times(hexdigit, 1, 8)-
hexdigit

hexdigit = VR(digits, interval('a', 'f'), interval('A', 'F'))
pat = VR("-", min=0) + VR('$', '0x', '0X') + VR(hexdigit, min=1, max=8)
- hexdigit

hexdigit = VR( VR(digits) | interval('a', 'f') | interval('A', 'F') )
pat = VR("-", 0) + VR(VR('$') | VR('0x') | VR('0X')) + VR(hexdigit, 1,
8) - hexdigit

hexdigit = Alt(digits, interval('a', 'f'), interval('A', 'F'))
pat = VR("-", 0) + Alt('$', '0x', '0X') + VR(hexdigit, 1, 8) - hexdigit

hexdigit = Alternative(digits, Interval('a', 'f'), Interval('A', 'F'))
pat = Optional("-") + Alternative('$', '0x', '0X') + RE(Hexdigit, 1, 8)
- Hexdigit

hexdigit = Alternative(digits, Interval('a', 'f'), Interval('A', 'F'))
pat = RE("-", 0) + Alternative('$', '0x', '0X') + RE(Hexdigit, 1, 8) -
Hexdigit

hexdigit = RE([digits, Interval('a', 'f'), Interval('A', 'F')]) #
flatten sul primo parametro
pat = RE("-", 0) + RE(['$', '0x', '0X']) + RE(Hexdigit, 1, 8) -
Hexdigit

hexdigit = RE(digits, Interval('a', 'f'), Interval('A', 'F'))
pat = RE("-").repeat(0) + RE('$', '0x', '0X') + Hexdigit.repeat(1, 8) -
Hexdigit

hexdigit = VRE(digits, Interval('a', 'f'), Interval('A', 'F'))
pat = VRE("-").repeat(0) + VRE('$', '0x', '0X') + Hexdigit.repeat(1, 8)
- Hexdigit

hexdigit = Vre(digits, Interval('a', 'f'), Interval('A', 'F'))
hexnum = Vre("-").repeat(0) + Vre('$', '0x', '0X') + Hexdigit.repeat(1,
8) - Hexdigit

hexdigit = Vre(digits, Interval('a', 'f'), Interval('A', 'F'))
hexnum = Vre("-").optional() + Vre('$', '0x', '0X') +
Hexdigit.repeat(1, 8) - Hexdigit

hexdigit = Vre(Vre().digits, Interval('a', 'f'), Interval('A', 'F'))
hexnum = Optional("-") + Vre('$', '0x', '0X') + Repeat(Hexdigit, 1, 8)
- Hexdigit

hexdigit = Vre(Vre().digits, Interval('a', 'f'), Interval('A', 'F'))
hexnum = Vre("-").optional() + Vre('$', '0x', '0X') +
Hexdigit.repeat(1, 8) - Hexdigit

hexdigit = Vre(Vre().digits, Interval('a', 'f')).ignorecase()
hexnum = Vre("-").optional() + Vre('$', '0x').ignorecase() +
Hexdigit.repeat(1, 8) - Hexdigit

hexdigit = Alternative(Digits, Interval('a', 'f')).ignorecase()
hexnum = Optional("-") + Alternative('$', '0x').ignorecase() +
Repeat(Hexdigit, 1, 8) - Hexdigit


I think that once the best syntax is found, implementing a better
reverb-like module isn't too much work (my modified version of reverb
is only about 130 LOCs).

Bye,
bearophile

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


Application Portability?

2005-12-29 Thread greg . kujawa
I have a CRM application that I've written in Ruby that currently runs
on Win32 clients as well as Linux ARM clients (Sharp Zaurus PDA's). The
application uses Qt for its GUI presentation and XMLRPC calls to
push/pull contact data back and forth. It suits my purposes, but I am
looking to port it to other platforms, such as Windows Mobile and Palm
OS PDA's.

Getting Ruby compiled for the Palm OS is out of the question, and
getting Ruby to compile for Windows Mobile has hit many roadblocks. I
have tried looking at some Smalltalk implementations to accomplish
this, as I am willing to recode my app in another OO language if I can
definitely port it over to Windows Mobile and Palm OS. But even the
Smalltalk scenario would force me to recode the Smalltalk source itself
since one implementation wouldn't port between both platforms.

How about Python? Could I code the application once in Python and then
port it to both PDA platforms easily? Or is this a pipe dream? I don't
know much about Python yet, but would start picking it up if it could
fit the bill...

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


Re: help with lists and writing to file in correct order

2005-12-29 Thread homepricemaps
hey kent thanks for your help.

so i ended up using a loop but find that i end up getting the same set
of results every time.  the code is here:

for incident in bs('tr'):
data2 = []
for incident in bs('h2',  {'id' : 'dealName'}):
product2 = ""
for oText in incident.fetchText( oRE):
product2 += oText.strip() + ';'



for incident in bs('a',  {'name' : 'D0L3'}):
store2 = ""
for oText in incident.fetchText( oRE):
store2 += oText.strip() + ';'


for incident in bs('a',  {'class' : 'nojs'}):
price2 = ""
for oText in incident.fetchText( oRE):
price2 += oText.strip() + ';'


tuple2 = (product2, store2, price2)
data2.append(tuple2)
print data2

and i end up getting the following instead of unique results

pizza, pizzahut, 3.94
pizza, pizzahut, 3.94
pizza, pizzahut, 3.94
pizza, pizzahut, 3.94
>
> I would use a loop that finds the row for a single item with something like
> for item in bs('tr',  {'class' : 'base'}):
>
> then inside the loop fetch the values for store, food and price for that
> item and write them to your output file.
> 
> Kent

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


Re: BUG trace realtime

2005-12-29 Thread malv
What happened in fact was that a graphics plotting function for
monitoring got called twice  frorm a different thread, due to an 'old'
instruction inadvertently left. Due to the quasi random nature of the
incoming data streams, this happened rather very sparingly. As the
plotting itself involves quite a bit of code, there are probably
several if not many reasons why problems could arise. It was never my
intention to reenter this function and make it thread safe. Problem
solved.

I was indeed a surprise for me to see Python quit this way.
Thanks again for your commentary.
malv

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


Re: help with lists and writing to file in correct order

2005-12-29 Thread Mike Meyer
[EMAIL PROTECTED] writes:
> hey kent thanks for your help.
>
> so i ended up using a loop but find that i end up getting the same set
> of results every time.  the code is here:
>
> for incident in bs('tr'):
>   data2 = []
>   for incident in bs('h2',  {'id' : 'dealName'}):
>   product2 = ""
>   for oText in incident.fetchText( oRE):
>   product2 += oText.strip() + ';'
>
>
>
>   for incident in bs('a',  {'name' : 'D0L3'}):
>   store2 = ""
>   for oText in incident.fetchText( oRE):
>   store2 += oText.strip() + ';'
>
>
>   for incident in bs('a',  {'class' : 'nojs'}):
>   price2 = ""
>   for oText in incident.fetchText( oRE):
>   price2 += oText.strip() + ';'
>
>
>   tuple2 = (product2, store2, price2)
>   data2.append(tuple2)
>   print data2

Two things here that are bad in general:
1) Doing string catenations to build strings. This is slow in
   Python. Build lists of strings and join them, as below.

2) Using incident as the index variable for all four loops. This is
   very confusing, and certainly part of your problem.

> and i end up getting the following instead of unique results
>
> pizza, pizzahut, 3.94
> pizza, pizzahut, 3.94
> pizza, pizzahut, 3.94
> pizza, pizzahut, 3.94

Right. The outer loop doesn't do anything to change what the inner
loops search, so they do the same thing every time through the outer
loop. You want them to search the row returned by the outer loop each
time.

for row in bs('tr'):
data2 = []
for incident in row('h2', {'id' :'dealName'}):
product2list = []
for oText in incident.fetchText(oRE):
product2list.append(OText.strip() + ';')
product2 = ''.join(product2list)
# etc.

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


Question about the 'code' module

2005-12-29 Thread Thomas Heller
I'm using the code module to implement an interactive interpreter
console in a GUI application, the interpreter running in a separate
thread.  To provide clean shutdown of the application, I have to make
sure that objects used in the interpreter thread are deleted when the
thread ends.

I delete the sys.last_type, sys.last_value, and sys.last_traceback
attributes which are set when an exception occured in the interpreter
thread (*).  To clean up the '_' symbol that the interpreter maintains,
I have found no other solution than to execute 'console.runsource("0")'
at the end of the thread.  Where is this symbol stored? How can I delete
it without the .runsource() call?

(*) It seems to me that the code modules usage of the sys.last_type,
sys.last_value, and sys.last_traceback attributes is not thread safe.
The docs mention that this doesn't matter because there's only one
interactive thread - which does not need to be true when using the code
module.  You could easily run several interactive interpreters at the
same time, which is exactly the purpose of this module.

Why is the (non thread-safe) sys.last_traceback used at all?  Couldn't
it be replaced with the (thread-safe) sys.exc_info()[2]?

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


Strange behaviour with eval() and globals() copy

2005-12-29 Thread Geert Jansen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
 
Hi,

I'm experiencing a weird problem with eval(), providing it a copy of
the globals() dictionary.

The following code works:


s = """
def func(level):
if level < 2:
func(level+1)
func(0)
"""
c = compile(s, '', 'exec')
g = globals()
#g = g.copy()
l = locals()
eval(c, g, l)


But if I comment in the line "g = g.copy()" and run the same snippet
again, I get the following error:

Traceback (most recent call last):
  File "test.py", line 12, in ?
eval(c, g, l)
  File "", line 5, in ?
  File "", line 4, in func
NameError: global name 'func' is not defined

Any ideas?

Basically I'm trying to evaluate code with a specific global and local
namespace. However, I cannot get this to work unless I use the exact
global namespace as returned by globals(), any other mapping makes
this code fail.

Python version is 2.4.2 on Linux.

Regards,
Geert


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
iQEVAwUBQ7RFwprPkVOV4lDgAQKK+Af/eEHbkHiUtH79trDsgvyTwY6xTayk+nB2
nHZL6iD0aRlDfLtccsP2OTLafJdNwb764vK6hqQFuvN2ol4v5SVwEnsJ4EvtwKyH
iJcByEXZSrPjBsCejKPsoLCCCJ3q8UdkO4zsYsd+xSqCuJAYzfEnSf75yu6PY3Hh
N7uzPT626BdUq5wHaWlbAKqtmCfN5kOodgkTE3s7/h9JlP4EeKyF4s5sCFQdJ0jw
CWXr28gOMcWBvlVLOVSbeDq5/n5YWfaJKpbGYXolv5H9Cyxa4rZ1AMy628u1DnPa
he7sX2T0pTNOaeVJGWanSR99jbq2VxDaiocQdpjUnEHqaUSY8YhFTw==
=lbmj
-END PGP SIGNATURE-

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


KixForm, a (little) GUI for Python + PyWin32 ?

2005-12-29 Thread Do Re Mi chel La Si Do
Hi!

I had found (since only 2 hours) that KixForm can to do used by Python + 
PyWin32

At the end of the message, a very small example

It's an Active-X, in one file (.DLL), and one help-file (.CHM)

It is limited, but simple

Download here :
  http://www.kixforms.org/assets/files/kixforms/KiXforms_230.zip


@-salutations

Michel Claveau






# -*- coding: cp1252 -*-

import time
import win32com.client

kgui = win32com.client.Dispatch('Kixtart.System')

def rgb(r,g,b):
return (r*256+g)*256+b

form=kgui.Form()
form.ClientSize=(520,220)
form.Font = "Verdana"
form.Text = "Titre de la fenêtre"

label = form.Controls.Label()
label.Font = "Verdana",
label.FontSize = 18
label.ForeColor = rgb(127,0,0)
label.FontBold = True
label.Text = "(vide)"
label.Top=40
label.Left=40
label.Size=(550,30)

bouton1= form.Controls.Button()
bouton1.Size=(80,30)
bouton1.Text="vraiment"
bouton1.Font = "Verdana",
bouton1.FontSize = 12
bouton1.OnClick="BT1"
bouton1.Left=20
bouton1.Top=100

bouton2= form.Controls.Button()
bouton2.Size=(80,30)
bouton2.Text="On"
bouton2.Font = "Verdana",
bouton2.FontSize = 12
bouton2.OnClick="BT2"
bouton2.Left=120
bouton2.Top=100

bouton3= form.Controls.Button()
bouton3.Size=(80,30)
bouton3.Text="a"
bouton3.Font = "Verdana",
bouton3.FontSize = 12
bouton3.OnClick="BT3"
bouton3.Left=220
bouton3.Top=100

bouton4= form.Controls.Button()
bouton4.Size=(80,30)
bouton4.Text="soif."
bouton4.Font = "Verdana",
bouton4.FontSize = 12
bouton4.OnClick="BT4"
bouton4.Left=320
bouton4.Top=100

bouton5= form.Controls.Button()
bouton5.Size=(80,30)
bouton5.Text="très"
bouton5.Font = "Verdana",
bouton5.FontSize = 12
bouton5.OnClick="BT5"
bouton5.Left=420
bouton5.Top=100

btquit= form.Controls.Button()
btquit.Size=(160,30)
btquit.Text="Terminer "
btquit.Font = "Verdana",
btquit.FontBold = True
btquit.FontItalic = True
btquit.FontSize = 18
btquit.OnClick="QUIT"
btquit.Top=170
btquit.Left=180


form.Show()
txt=''
while form.Visible:
action=kgui.Application.DoEvents()
if action=='BT1':txt=txt+' '+bouton1.Text
if action=='BT2':txt=txt+' '+bouton2.Text
if action=='BT3':txt=txt+' '+bouton3.Text
if action=='BT4':txt=txt+' '+bouton4.Text
if action=='BT5':txt=txt+' '+bouton5.Text
if action=="QUIT": break
label.Text=txt
time.sleep(0.5)

print 'Résultat :',label.Text




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

Re: csv.Sniffer: wrong detection of the end of line delimiter

2005-12-29 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Steve Holden
wrote:

> Laurent Laporte wrote:
>
>> I'm using cvs standard module under Python 2.3 / 2.4 to read a CSV
>> file. The file is opened in binary mode, so I keep the end of line
>> terminator.
>> 
> It's not advisable to open a file like a CSV, intended for use as text, 
> in binary mode.

But the docs "demand" this explicitly and all examples in the docs fulfill
that demand.

>From http://docs.python.org/lib/csv-contents.html :

  If csvfile is a file object, it must be opened with the 'b' flag on
  platforms where that makes a difference.

I guess the reason is the same as for "text" pickle format:  If you don't
use binary mode the file is not platform independend anymore because some
OSes "manipulate" the data in text mode.

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


Re: Application Portability?

2005-12-29 Thread UrsusMaximus
You might look at http://www.awaretek.com/pymo.html which shows links
to Python versions for both PALM and Win CE as well as Sharp Zaurus and
other mobile platforms; however, the only mobile platform I have
personally used python on is the Zaurus, which works very smoothly, not
problems at all. 

Good luck.

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


Detecting problems in a forked process

2005-12-29 Thread James Colannino
Hey everyone.  I'm writing a small application in Python that uses 
os.fork() to create a separate process in which another application is 
run in the background.  The problem is that I need to know whether or 
not that separate application managed to start and return from within 
the parent appropriately.  Here's, roughly, a pseudo example of what I 
want to do (I know the code itself is not correct):

def function():

pid = os.fork()

if pid:
 do parent stuff
else:
 try:
  execute the application
 exeption:
  somehow return -1 from within the parent process

#try to start another application in the background from within a forked 
process
if (function() == -1):
fail

Is there a way that I can do this?  I thought, only for a *VERY* brief 
second, about cheating my way around this with a global variable, but 
then I realized that this wouldn't work due to the fact that I will have 
multiple forks doing the same thing at the same time.  Thanks in advance :)

James

-- 
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

"If Carpenters made houses the way programmers design programs, the first 
woodpecker to come along would destroy all of civilization." --Computer Proverb

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


Re: using NamedTemporaryFile on windows

2005-12-29 Thread Lee Harr
On 2005-12-29, Peter Hansen <[EMAIL PROTECTED]> wrote:
> Lee Harr wrote:
>> Is there any other reason to use a named tempfile other than
>> to be able to open it again?

> As it says, if you *don't close* the file, you can open it again if you 
> are on a platform which supports that.
>

Ok. I just started wondering if maybe there was some other reason,
like stat()ing the file, or taking a picture of Elvis pointing at
it in a directory listing or something.


> NamedTemporaryFile doesn't appear to have much purpose on Windows, but 
> that's more or less what the docs already say.  I think the only thing 
> you were missing perhaps was this idea of "opening a file a second time" 
> *without having closed it first*.
>
> What I don't understand is why you _can't_ reopen the NamedTemporaryFile 
> under Windows when you can reopen the file created by mkstemp (and the 
> files created by TemporaryFile are created by mkstemp in the first place).
>


Are you saying you tried it and you actually can do what it says
you can't do?

I don't have any windows system to test this, but I want to write
some code that will work on windows. I'm just going to use mkstemp.

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


Re: using NamedTemporaryFile on windows

2005-12-29 Thread Chris Lambacher
On Thu, Dec 29, 2005 at 12:40:34AM -0500, Peter Hansen wrote:
> 
> What I don't understand is why you _can't_ reopen the NamedTemporaryFile 
> under Windows when you can reopen the file created by mkstemp (and the 
> files created by TemporaryFile are created by mkstemp in the first place).

Basically the only reason that you want a NamedTemporaryFile is so that you
can write something to a file, tell another process to use that file (that you
have just written to) and then have file cleanup taken care of for you
automatically.  This works on Unix where you can have process open a
file for reading while another process has the file open for writing.  You
can't do this on Windows without jumping through a lot of hoops(sqlite and MS
Access come to mind as programs that manage this, though they may start a
server process to manage it).

mkstemp does create a file for you, but you are responsible for removing the
file when you are done.  Unfortunately this is what you are left with on
Windows.

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


Re: Extending Python with C++

2005-12-29 Thread Brian van den Broek
Brian van den Broek said unto the world upon 29/12/05 12:03 PM:
> jeremito said unto the world upon 29/12/05 11:39 AM:
> 
>>I am learning how to extend Pythong with C++.  I have will be writing
>>some code in C++ and want/need Python to interact with it.  I am not
>>having success following the online documentation from
>>http://docs.python.org/ext/ext.html.  I have also looked briefly at
>>some of the demos in the source code distribution.  Can anyone help me?
>> I am using the MacPython (version 2.4) distribution.
>>
>>I have one specific question.  The documentation online states:
>>
>>"If the main program (the Python interpreter) is compiled and linked by
>>the C compiler, global or static objects with constructors cannot be
>>used. This is not a problem if the main program is linked by the C++
>>compiler."
>>
>>Thanks,
>>Jeremy
> 
> 
> I have a specific answer.
> 
> Best,
> 
> Brian vdB


Hello all,

while I think the point I was making was correct, I know I expressed 
it in a snide and unkind way. Apologies to all, especially to the OP.

Sheepishly,

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


Re: Distributions, RE-verb and the like

2005-12-29 Thread Paul McGuire
Bearophile -

Well, I fear this may end up being another of those "easier to
reinvent" wheels.  All of your issues with RE's are the same ones I had
with lex/yacc (and re's too) when I wrote pyparsing.

Any chance for convergence here?

(BTW, there is nothing inherently wrong with "reinventing wheels".  The
metaphor is a bit flawed, since there are many different types of
wheels in the world, and not all interchangeable - consider a tractor
wheel vs. a bicycle wheel.  Some legitimate/valid/justified endeavors
are wrongly indicted for "reinventing the wheel" when in fact they are
focusing on a particular niche of wheeldom, deserving of its own
specialized invention.)

-- Paul

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


Re: Question about the 'code' module

2005-12-29 Thread Fernando Perez
Thomas Heller wrote:

> I'm using the code module to implement an interactive interpreter
> console in a GUI application, the interpreter running in a separate
> thread.  To provide clean shutdown of the application, I have to make
> sure that objects used in the interpreter thread are deleted when the
> thread ends.
> 
> I delete the sys.last_type, sys.last_value, and sys.last_traceback
> attributes which are set when an exception occured in the interpreter
> thread (*).  To clean up the '_' symbol that the interpreter maintains,
> I have found no other solution than to execute 'console.runsource("0")'
> at the end of the thread.  Where is this symbol stored? How can I delete
> it without the .runsource() call?

Wild guess: try defining your own sys.displayhook to manage output.  This may be
done there, though I'm not really sure.  Otherwise, it's done by the
interpreter internally when exec is called on a code object compiled in
'single' mode.

Cheers,

f

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


Re: Detecting problems in a forked process

2005-12-29 Thread Jim Segrave
In article <[EMAIL PROTECTED]>,
James Colannino  <[EMAIL PROTECTED]> wrote:
>Hey everyone.  I'm writing a small application in Python that uses 
>os.fork() to create a separate process in which another application is 
>run in the background.  The problem is that I need to know whether or 
>not that separate application managed to start and return from within 
>the parent appropriately.  Here's, roughly, a pseudo example of what I 
>want to do (I know the code itself is not correct):
>
>def function():
>
>pid = os.fork()
>
>if pid:
> do parent stuff
>else:
> try:
>  execute the application
> exeption:
>  somehow return -1 from within the parent process
>
>#try to start another application in the background from within a forked 
>process
>if (function() == -1):
>fail
>
>Is there a way that I can do this?  I thought, only for a *VERY* brief 
>second, about cheating my way around this with a global variable, but 
>then I realized that this wouldn't work due to the fact that I will have 
>multiple forks doing the same thing at the same time.  Thanks in advance :)

options:

Have the child set it's exit code to indicate success or failure and
use one of the various os.wait functions in the parent to retrieve it.

or

create a pipe before forking and you can pass data back and forth
between the parent and child

or

look at one of the shared memory libraries



-- 
Jim Segrave   ([EMAIL PROTECTED])

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


Re: Distributions, RE-verb and the like

2005-12-29 Thread Paul McGuire
Oh, the pyparsing rendition of your initial pat expression would be
something like:

import pyparsing as pp
pat = pp.Combine( pp.oneOf("$ 0x 0X") + pp.Word(pp.hexnums,max=8) )

Combine is needed to ensure that the leading $, 0x, or 0X is
immediately followed by 1-8 (and no more than 8) hex digits.
Otherwise, pyparsing is pretty tolerant of whitespace cropping up
wherever.

As for some of your other syntaxes:

I'm not sure what "Vre" means.

I found that "Alternative" needs to support both greedy and non-greedy
matches, so I provided Or and MatchFirst, respectively.  They are also
definable using '^' and '|' operators, again respectively.  Finally, I
ran into Literal("this") | Literal("that") | Literal("other") so often
that I just added a helper method oneOf that would take the string
"this that other" and build the right expression out of it.  This too
is non-trivial, as you have to take care that some short literals may
mask longer ones in the list, as in oneOf("< = > <= >= !=").  Just
replacing this directly with Literal("<") | Literal("=") | ... would
prevent any matching of the ">=" or "<=" literals.  You could replace
with the Or (^) form, but this exhaustively checks all alternatives all
the time, a regrettable run-time performance penalty.  Pyparsing's
implementation of oneOf leaves the literals in the given order, unless
a duplicate is given, or an earlier literal masks a later one - in that
case, the longer literal is moved ahead of the shorter.

I implemented Optional as a wrapper-type class, as opposed to the
.optional() method that you have given - I'd say there are tradeoffs
either way, just making the comparison.

Your "repeated" or "times" seem to map roughly to pyparsing's OneOrMore
and ZeroOrMore.

Any thought how a recursive grammar might look?

I don't find 'Interval' to be very easy on the eyes.  In this case, I
stole^H^H^H^H^H borrowed the re form of "[A-Za-z0-9]", providing a
method named srange ("s" is for "string") such that srange("a-fA-F")
would return the string "abcdefABCDEF".

The other end of this process has to do with how the calling program
will process the parsed results.  Once a grammar gets too deeply
nested, or has too many Optional elements, just returning a simple list
or nested list of tokens isn't enough.  Pyparsing returns ParseResults
objects, which can be accessed as a list, dictionary, or object with
attributes (provided individual fields have been given names at grammar
definition time).  I *have* had some complaints about ParseResults
("ParseResults are evil"), but the named access is a life-saver for
complex grammars.  (Simple case, the first token for your hex number is
an optional sign - without names, you can't just access field 2, say,
of the expression, you have to first test to see if the sign was
provided or not, and then access field 2 or 3 accordingly.  On the
other hand, if you had given field 2 a name, your parser would be more
robust, even you later changed your grammar to include other elements,
such as a leading, um, currency symbol or something.)

Just some fodder for your reverb considerations...

-- Paul

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


Re: "Humane" programmer interfaces

2005-12-29 Thread Andrew Durdin
On 29 Dec 2005 09:50:57 -0800, colinwb <[EMAIL PROTECTED]> wrote:
>
> >> puts ck.first, ck[0], '*', ck.last, ck[-1]

One of the points at issue (minimalism/monotony) relates to TOOWTDI,
which has implications for language/module design and for code
readability. Ruby supports negative indices in the same way as Python,
so why add .last as an alias for [-1]? It's just added mental baggage.
And if you think .last is significantly more readable or convenient
than [-1], why not add .secondlast ?  And .first, and .second ?   With
one simple, obvious, general interface, these special cases only add
unneeded complexity.

Non est ponenda pluritas sine necessitate -- William of Ockham.

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


Re: Guido working on Pypy?

2005-12-29 Thread Andrew Durdin
On 29 Dec 2005 04:12:53 -0800, Luis M. González <[EMAIL PROTECTED]> wrote:
>
> According to this blog entry, it says that Guido has been hired by
> Google to work on Pypy:
> http://zephyrfalcon.org/weblog2/arch_e10_00870.html
>
> Is there anyone who can confirm this information?
> Luis

Or deny it:

http://zephyrfalcon.org/weblog2/arch_e10_00870.html#e872

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


Re: python coding contest

2005-12-29 Thread Christian Tismer
Duncan Booth wrote:
> Christian Tismer wrote:
> 
>> And then help me to setup a different contest about content -- chris
>>
> Count me in.

Great! Let's find a problem small enough to solve in reasonably
time and large enough to exploit Python qualities.

sincerely -- chris (below 130)

-- 
Christian Tismer :^)   
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


reading files into dicts

2005-12-29 Thread rbt
What's a good way to write a dictionary out to a file so that it can be 
easily read back into a dict later? I've used realines() to read text 
files into lists... how can I do the same thing with dicts? Here's some 
sample output that I'd like to write to file and then read back into a dict:

{'.\\sync_pics.py': 1135900993, '.\\file_history.txt': 1135900994, 
'.\\New Text Document.txt': 1135900552}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: reading files into dicts

2005-12-29 Thread Tim Williams (gmail)
On 30/12/05, rbt <[EMAIL PROTECTED]> wrote:
What's a good way to write a dictionary out to a file so that it can beeasily read back into a dict later? I've used realines() to read textfiles into lists... how can I do the same thing with dicts? Here's some
sample output that I'd like to write to file and then read back into a dict:
Depending on how often you need to read/write/access the dict, 
either the shelve module,  or the pickle / cpickle modules will do
what you need.
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: reading files into dicts

2005-12-29 Thread Giovanni Bajo
rbt wrote:

> What's a good way to write a dictionary out to a file so that it can
> be easily read back into a dict later? I've used realines() to read
> text
> files into lists... how can I do the same thing with dicts? Here's
> some sample output that I'd like to write to file and then read back
> into a dict:
>
> {'.\\sync_pics.py': 1135900993, '.\\file_history.txt': 1135900994,
> '.\\New Text Document.txt': 1135900552}



>>> d = {'.\\sync_pics.py': 1135900993, '.\\file_history.txt': 1135900994,
... '.\\New Text Document.txt': 1135900552}
>>> file("foo", "w").write(repr(d))
>>> data = file("foo").read()
>>> data
"{'.sync_pics.py': 1135900993, '.file_history.txt': 1135900994,
'.New Text Document.txt': 1135900552}"
>>> d = eval(data)
>>> d
{'.\\sync_pics.py': 1135900993, '.\\file_history.txt': 1135900994, '.\\New Text
Document.txt': 1135900552}

-- 
Giovanni Bajo


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


Re: reading files into dicts

2005-12-29 Thread Tim Williams (gmail)
On 30/12/05, Giovanni Bajo <[EMAIL PROTECTED]> wrote:
>>> d = {'.\\sync_pics.py': 1135900993, '.\\file_history.txt': 1135900994, '.\\New Text Document.txt': 1135900552}>>> file("foo", "w").write(repr(d))>>> data = ""
>>> data"{'.sync_pics.py': 1135900993, '.file_history.txt': 1135900994,'.New Text Document.txt': 1135900552}">>> d = eval(data)>>> d{'.\\sync_pics.py': 1135900993, '.\\file_history.txt': 1135900994, '.\\New Text
Document.txt': 1135900552}eval() is risky if you can't control the contents of the file  :)

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

Re: python coding contest

2005-12-29 Thread Andrew Durdin
On 12/28/05, Shane Hathaway <[EMAIL PROTECTED]> wrote:
> I just found a 125 character solution.  It's actually faster and more
> readable than the 133 character solution (though it's still obscure.)

Having spent a good deal of time and effort, and not getting below 144
characters, I am now very eager to see how these shorter versions
work, particularly the 6  120-character solutions. I also expect that
someone (I'll certainly give it a try) will produce a yet shorter
version after the contest closes, based on the knowledge from the
winning solutions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help with lists and writing to file in correct order

2005-12-29 Thread homepricemaps
hey mike-the sample code was very useful.  have 2 questions

when i use what you wrote which is listed below i get told
unboundlocalerror: local variable 'product' referenced before
assignment.  if i however chnage row to incident in "for incident in
bs('tr'):" i then get mytuples printed out nicely but once again get a
long list of

[('pizza;','pizza hut;', '3.94;')]
[('pizza;','pizza hut;', '3.94;')]


 for row in bs('tr'):
data=[]
for incident in row('h2',  {'id' : 'dealName'}):
productlist = []
for oText in incident.fetchText( oRE):
productlist.append(oText.strip() + ';')
product = ''.join(productlist)

for incident in row('a',  {'name' : 'D0L3'}):
storelist = []
for oText in incident.fetchText( oRE):
storelist.append(oText.strip() + ';')
store = ''.join(storelist)

 tuple = (product, store, price)
 data.append(tuple)
 print data




> [EMAIL PROTECTED] writes:
> > hey kent thanks for your help.
> >
> > so i ended up using a loop but find that i end up getting the same set
> > of results every time.  the code is here:
> >
> > for incident in bs('tr'):
> > data2 = []
> > for incident in bs('h2',  {'id' : 'dealName'}):
> > product2 = ""
> > for oText in incident.fetchText( oRE):
> > product2 += oText.strip() + ';'
> >
> >
> >
> > for incident in bs('a',  {'name' : 'D0L3'}):
> > store2 = ""
> > for oText in incident.fetchText( oRE):
> > store2 += oText.strip() + ';'
> >
> >
> > for incident in bs('a',  {'class' : 'nojs'}):
> > price2 = ""
> > for oText in incident.fetchText( oRE):
> > price2 += oText.strip() + ';'
> >
> >
> > tuple2 = (product2, store2, price2)
> > data2.append(tuple2)
> > print data2
>
> Two things here that are bad in general:
> 1) Doing string catenations to build strings. This is slow in
>Python. Build lists of strings and join them, as below.
>
> 2) Using incident as the index variable for all four loops. This is
>very confusing, and certainly part of your problem.
>
> > and i end up getting the following instead of unique results
> >
> > pizza, pizzahut, 3.94
> > pizza, pizzahut, 3.94
> > pizza, pizzahut, 3.94
> > pizza, pizzahut, 3.94
>
> Right. The outer loop doesn't do anything to change what the inner
> loops search, so they do the same thing every time through the outer
> loop. You want them to search the row returned by the outer loop each
> time.
>
> for row in bs('tr'):
> data2 = []
> for incident in row('h2', {'id' :'dealName'}):
> product2list = []
> for oText in incident.fetchText(oRE):
> product2list.append(OText.strip() + ';')
> product2 = ''.join(product2list)
> # etc.
>
>  --
> Mike Meyer <[EMAIL PROTECTED]>
> http://www.mired.org/home/mwm/
> Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

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


Re: reading files into dicts

2005-12-29 Thread limodou
2005/12/30, rbt <[EMAIL PROTECTED]>:
> What's a good way to write a dictionary out to a file so that it can be
> easily read back into a dict later? I've used realines() to read text
> files into lists... how can I do the same thing with dicts? Here's some
> sample output that I'd like to write to file and then read back into a dict:
>
> {'.\\sync_pics.py': 1135900993, '.\\file_history.txt': 1135900994,
> '.\\New Text Document.txt': 1135900552}
> --
> http://mail.python.org/mailman/listinfo/python-list
>

You can try the dict4ini module written by me.

http://wiki.woodpecker.org.cn/moin/Dict4Ini

The dict can be saved as an Ini file, and can be read back from the
Ini file.Just like:

 >>> import dict4ini
 >>> x = {'.\\sync_pics.py': 1135900993, '.\\file_history.txt':
1135900994, '.\\New Text Document.txt': 1135900552}
 >>> d = dict4ini.DictIni(values=x)
 >>> d['.\sync_pics.py']
 1135900993

--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie needs help extracting data from XML

2005-12-29 Thread Rodney
Thanks for the help

This was a SOAP Webservice message.  I used httplib instead of SOAPpy or ZSI 
because SOAPpy cann't do arrays of complex type and ZSI was confusing.

Thanks again



"Rodney" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
>
> Im a Python newbie and am trying to get the data out of a series of XML 
> files.  So for example the xml is:
>
>  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; 
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; 
> xmlns:tns="http://www.ExchangeNetwork.net/schema/v1.0/node.wsdl"; 
> xmlns:types="http://www.ExchangeNetwork.net/schema/v1.0/node.wsdl"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema";> xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility";>2005-12-28T05:59:38Z2005-12-28T06:04:38Z  
> soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>  
> xmlns:q1="http://www.ExchangeNetwork.net/schema/v1.0/node.xsd";> xsi:type="xsd:string">Ready
>
>
> and I want to get the value from the element "return" which currently has 
> a value of "Ready".
>
> Other XML files I want to work with may have several elements I want to 
> pull data from.  This seem relatively easy but I have been reading and 
> cruising google for hours and none of the examples make any sense.
>
> I appreciate any code writing help with this.
>
>
> 


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


Newbie - SOAP return message with embedded ZIP file

2005-12-29 Thread Rodney
Hi again, thanks for the help with figuring out how to parse a SOAP return 
message.  I know have a return message that has an embedded ZIP file in it. 
Can anyone help me figure out how to extract this file from the SOAP return 
message.  The message looks as following:

'\x0c 
\x00\x00\x00)\x00)\x00\x00\x05Xuuid:42bd2573-8c94-4b7c-9bd6-a1e29856f751\x00\x00\x00http://schemas.xmlsoap.org/soap/envelope/\x00\x00\x00http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:tns="http://www.ExchangeNetwork.net/schema/v1.0/node.wsdl"; 
xmlns:types="http://www.ExchangeNetwork.net/schema/v1.0/node.wsdl"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>http://schemas.xmlsoap.org/ws/2002/07/utility";>2005-12-30T00:41:54Z2005-12-30T00:46:54Zhttp://schemas.xmlsoap.org/soap/encoding/";>http://www.ExchangeNetwork.net/schema/v1.0/node.xsd";>http://www.ExchangeNetwork.net/schema/v1.0/node.xsd"; 
soapenc:arrayType="q2:NodeDocument[1]">http://www.ExchangeNetwork.net/schema/v1.0/node.xsd";>3c613fde-2b1e-46dd-a60e-3c8323517eb0.zipapplication/x-zip-compressedhttp://xml.apache.org/xml-soap"; 
/>\n\x10\x00\x00\x00$\x00\x18\x00\x00\x07\

MESSAGE CONTINUES AS ABOVE AND ENDS WITH THE FOLLOWING:

-2b1e-46dd-a60e-3c8323517eb0.xmlPK\x05\x06\x00\x00\x00\x00\x01\x00\x01\x00V\x00\x00\x00I\x07\x00\x00\x00\x00\x00\x00\x00'

Sorry for being so helpless on this.

Thanks for any help you can give.



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


Re: reading files into dicts

2005-12-29 Thread Gary Herron
rbt wrote:

>What's a good way to write a dictionary out to a file so that it can be 
>easily read back into a dict later? I've used realines() to read text 
>files into lists... how can I do the same thing with dicts? Here's some 
>sample output that I'd like to write to file and then read back into a dict:
>
>{'.\\sync_pics.py': 1135900993, '.\\file_history.txt': 1135900994, 
>'.\\New Text Document.txt': 1135900552}
>  
>


A better way, than rolling your own marshaling (as this is called), 
would be to use the cPickle module. It can write almost any Python 
object to a file, and then read it back in later. It's more efficient, 
and way more general than any code you're likely to write yourself.

The contents of the file are quite opaque to anything except the cPickle 
and pickle modules. If you *do* want to roll you own input and output to 
the file, the standard lib functions "repr" and "eval" can be used. Repr 
is meant to write out objects so they can be read back in and recovered 
with eval. If the contents of your dictionary are well behaved enough 
(simple Python objects are, and classes you create may be made so), then 
you may be able to get away with as little as this:

f = file('file.name', 'wb')
f.write(repr(myDictionary))
f.close()

and

f = file('file.name', 'rb')
myDictionary = eval(f.read())
f.close()

Simple as that is, I'd still recommend the cPickle module.

As always, this security warning applys: Evaluating arbitrary text 
allows anyone, who can change that text, to take over complete control 
of your program. So be carefully.

Gary Herron


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


Re: reading files into dicts

2005-12-29 Thread Tim Williams (gmail)
A further thought, if you write the data to a file in the correct
format, you can use import and reload to access the data later instead
of repr.





On 12/29/05, Tim Williams (gmail) <[EMAIL PROTECTED]> wrote:
> On 30/12/05, Giovanni Bajo <[EMAIL PROTECTED]> wrote:
> >
> >
> > >>> d = {'.\\sync_pics.py': 1135900993, '.\\file_history.txt':
> 1135900994,
> >  '.\\New Text Document.txt': 1135900552}
> > >>> file("foo", "w").write(repr(d))
> > >>> data = file("foo").read()
> > >>> data
> > "{'.sync_pics.py': 1135900993, '.file_history.txt': 1135900994,
> > '.New Text Document.txt': 1135900552}"
> > >>> d = eval(data)
> > >>> d
> > {'.\\sync_pics.py': 1135900993, '.\\file_history.txt': 1135900994,
> '.\\New
> > Text
> > Document.txt': 1135900552}
> >
> > eval() is risky if you can't control the contents of the file  :)
>
>


--

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


Re: reading files into dicts

2005-12-29 Thread Tim Williams (gmail)
Apologies for the top post, it was my first attempt at using gmail's
pda-enabled web interface. There is no option to bottom post.

Apart from the mistake in my previous reply, when I meant to suggest
using import instead of eval() not repr(). I also omitted an example.
So here goes -but I don't know how gmail-CE will format this!!

Save your dict to a file  with a .PY extension using

outdata = 'mydict =' + repr(dict) # or somesuch
 similar

dictfile.py
---
mydict = {'key1':'a', 'key2':'b'}
---

Then:

import dictfile
print dictfile.mydict.keys()
>>>['key1','key2']
reload(dictfile)

HTH :-)

--

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


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2005-12-29 Thread Chris Smith
> "John" == John J Lee <[EMAIL PROTECTED]> writes:

John> Guido may or may not realise it, but he seems to have been
John> managing people (in some sense of 'managing', anyway) quite
John> successfully over the past decade or so.


John> John

Just you shush!
If he hears you, he'll return to being a newt!

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


Re: reading files into dicts

2005-12-29 Thread rbt
Gary Herron wrote:
> rbt wrote:
> 
>> What's a good way to write a dictionary out to a file so that it can 
>> be easily read back into a dict later? I've used realines() to read 
>> text files into lists... how can I do the same thing with dicts? 
>> Here's some sample output that I'd like to write to file and then read 
>> back into a dict:
>>
>> {'.\\sync_pics.py': 1135900993, '.\\file_history.txt': 1135900994, 
>> '.\\New Text Document.txt': 1135900552}
>>  
>>
> 
> 
> A better way, than rolling your own marshaling (as this is called), 
> would be to use the cPickle module. It can write almost any Python 
> object to a file, and then read it back in later. It's more efficient, 
> and way more general than any code you're likely to write yourself.
> 
> The contents of the file are quite opaque to anything except the cPickle 
> and pickle modules. If you *do* want to roll you own input and output to 
> the file, the standard lib functions "repr" and "eval" can be used. Repr 
> is meant to write out objects so they can be read back in and recovered 
> with eval. If the contents of your dictionary are well behaved enough 
> (simple Python objects are, and classes you create may be made so), then 
> you may be able to get away with as little as this:
> 
> f = file('file.name', 'wb')
> f.write(repr(myDictionary))
> f.close()
> 
> and
> 
> f = file('file.name', 'rb')
> myDictionary = eval(f.read())
> f.close()
> 
> Simple as that is, I'd still recommend the cPickle module.
> 
> As always, this security warning applys: Evaluating arbitrary text 
> allows anyone, who can change that text, to take over complete control 
> of your program. So be carefully.
> 
> Gary Herron
> 
> 

Thanks to everyone for the tips on eval and repr. I went with the 
cPickle suggestion... this is awesome! It was the easiest and quickest 
solution performance-wise. Just makes me think, "Wow... how the heck 
does pickle do that?!"

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


fetching webpage

2005-12-29 Thread yookyung
I am trying to crawl webpages in citeseer domain (a collection of research 
papers mostly in computer science).

I have used the following code snippet.

#
import urllib

sock = urllib.urlopen("http://citeseer.ist.psu.edu";)
webcontent = sock.read().split('\n')
sock.close()
print webcontent


Then I get the following error message.


['', '', '  ', '', 'The server encountered an 
internal error and was ', 'unable to complete your request.', '', ' 
', '', 'Error message:', ' 
', '', ' 
', '', 'The server encountered an internal error and was ', 
'unable to complete your request. Either the server is', 'overloaded 
or there was an error in a CGI script.', '', '  ', '', 
'', '']

However, the url is valid and it works fine if I open the url in my web 
browser.
Or, if I use a different url (http://www.google.com  instead of 
http://citeseer.ist.psu.edu),
then it works.

What is wrong?
Could it be that the citeseer webserver checks the http request, and it sees 
something
that it doesn't like and reject the request?
What should I do?

Thank you.

Best regards,
Yookyung





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


Best library for basic stats

2005-12-29 Thread MKoool
Is there any decent library for basic stats?  I am just looking for the
basics, like quartiles, median, standard deviation, mean, min, max,
regression, etc.

I was going to use SciPy, but I use Python 2.4, and it seems to be
supported primarily for 2.3...

What other statistical packages have any level of public support at
this point?

thanks

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


Re: pyfltk2 tutorial

2005-12-29 Thread drobinow

Siraj Kutlusan wrote:
> I want to use pyfltk2 because of its simplicity but there seem to be no
> tutorials done for it. Could anyone give me a link to one please?
  I think pyfltk is even simpler.  There's a tutorial included at the
URL below

http://junk.mikeasoft.com/pyfltkmanual.pdf

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


Re: fetching webpage

2005-12-29 Thread charlespina
I went to the URL you posted, and it looks like that error is the
content you should be recieving. Try refreshing your browser cache, you
could be loading a cached page.

Charles

yookyung wrote:
> I am trying to crawl webpages in citeseer domain (a collection of research
> papers mostly in computer science).
>
> I have used the following code snippet.
>
> #
> import urllib
>
> sock = urllib.urlopen("http://citeseer.ist.psu.edu";)
> webcontent = sock.read().split('\n')
> sock.close()
> print webcontent
> 
>
> Then I get the following error message.
>
>
> ['', '', '  ', '', 'The server encountered an
> internal error and was ', 'unable to complete your request.', '', '
> ', '', 'Error message:', '
> ', '', '
> ', '', 'The server encountered an internal error and was ',
> 'unable to complete your request. Either the server is', 'overloaded
> or there was an error in a CGI script.', '', '  ', '',
> '', '']
>
> However, the url is valid and it works fine if I open the url in my web
> browser.
> Or, if I use a different url (http://www.google.com  instead of
> http://citeseer.ist.psu.edu),
> then it works.
>
> What is wrong?
> Could it be that the citeseer webserver checks the http request, and it sees
> something
> that it doesn't like and reject the request?
> What should I do?
> 
> Thank you.
> 
> Best regards,
> Yookyung

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


Re: Extending Python with C++

2005-12-29 Thread jeremito
Unfortunately, I need to know a bit more than just the concept 'extern
"C"'.  I am really slow at this.  Can anyone point me towards some
examples or a tutorial (other than the one from python.org, I didn't
understand that one)?
Thanks,
Jeremy

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


Re: Windows and python execution

2005-12-29 Thread Thorsten Kampe
* Mark Carter (2005-12-26 23:06 +0100)
> I had installed python 2.4 in the standard way, so py files were already 
> associated with python when you double-clicked them from Explorer. Using 
> my set meant that if I wanted to use py files from the command line, I 
> could just type out the script name (you have to be in the right 
> directory, of course), and it works. Here's a snippit from my 
> autoexec.bat files:
> set PATH=C:\python24;%PATH%
> set .py=c:\python24\python.exe

If you installed Python the normal way, .py files are already
associated with Python. Windows uses the registry and doesn't make any
difference whether you doubleclick a file or type the name on the
command line
-- 
http://mail.python.org/mailman/listinfo/python-list


Is len() restricted to (positive) 32-bit values?

2005-12-29 Thread Josh Taylor
I have a class that wraps a large file and tries to make it look like a
string w.r.t. slicing.  Here, "large file" means on the order of
hundreds of GB.  All the slicing/indexing stuff through __getitem__()
works fine, but len() is quite broken.  It seems to be converting the
value returned by __len__() to a 32-bit integer.  If the conversion
yields a negative number, it raises an exception.

I'm running Python 2.4.1 on an Opteron running RedHat FC3.  It's a
64-bit processor, and Python ints appear to be 64-bit as well, so even
if len() only works with ints, it should still be able to handle 64-bit
values.

Here's a simple example that shows what I'm talking about:

>>> import sys
>>> sys.version
'2.4.1 (#1, Jun 22 2005, 16:00:46) \n[GCC 3.4.2 20041017 (Red Hat
3.4.2-6.fc3)]'
>>> type(1<<50)

>>> type(1<<70)

>>> class LenTest:
... def __len__(self):
... return 490
...
>>> x = LenTest()
>>> x.__len__()
490
>>> len(x)
1755359744

Is this a bug, a design decision, or do I have something misconfigured
in my Python build?

-Josh

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


Re: Is len() restricted to (positive) 32-bit values?

2005-12-29 Thread Jean-Paul Calderone
On 29 Dec 2005 19:14:36 -0800, Josh Taylor <[EMAIL PROTECTED]> wrote:
>I have a class that wraps a large file and tries to make it look like a
>string w.r.t. slicing.  Here, "large file" means on the order of
>hundreds of GB.  All the slicing/indexing stuff through __getitem__()
>works fine, but len() is quite broken.  It seems to be converting the
>value returned by __len__() to a 32-bit integer.  If the conversion
>yields a negative number, it raises an exception.
>
>I'm running Python 2.4.1 on an Opteron running RedHat FC3.  It's a
>64-bit processor, and Python ints appear to be 64-bit as well, so even
>if len() only works with ints, it should still be able to handle 64-bit
>values.

Conspicuous timing:

  

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


  1   2   >