Re: Advice to a Junior in High School?

2005-01-18 Thread collegebabe2004
wow! Aren't we getting ahead of ourselves?  Well, I'm glad you are
beefing up your college knowledge but let's just sit back for a minute
and breathe..there, feel better? Now, listen.  When I was a
freshman and sophomore in high school I was so sure I wanted to be an
artist and attend one of the most highly recognized and expensive art
schools in the country. I wanted to go to college back east away from
my parents.  Now I'm a psychology major in community college and I want
to attend UCLA!  First of all, NEVER SETTLE FOR LESS when it comes to
your major.  Do what it is true to your heart and never let people say
you can't! You can double major if you want to be on the safe side.
Compsci isn't an easy thing to do as you know and it's a highly
regarded profffession! By the time you graduate college, the world
could be a completely different place. But let's just worry about here
and now.  If you think too much about the future IT WILL DRIVE YOU
CRAZY!  Trust me, you are doing everything right so far.  I applaud
your effort but relax and everything will fall into place eventually!
I would suggest taking Japanese because you will have to work with them
eventually if you do decide to choose compsci as your proffesion.
Margaux

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


Re: wxPython and PyGame - do they play well together?

2005-01-18 Thread Terry Reedy

Erik Bethke [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 I am having a great time with python and pygame, and last night I took
 a long look at the wxPython demo.  I think that rocks as well.

 So now, my question is do wxPython and PyGame work together?

I have no personal experience, but based on posts to the Pygame mailing 
list, also accessible via Google or as newsgroup thru Gmane (where I read 
it), the answer is yes.  The subject of Pygame with guis has been discussed 
in the past couple of months.  I recommend that you read the archives for 
the recent past and then join the list or subscribe via gmane or google. 
It is a low volume, low noise, list.

Terry J. Reedy



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


Re: Fuzzy matching of postal addresses

2005-01-18 Thread Aaron Bingham
Andrew McLean wrote:
I have a problem that is suspect isn't unusual and I'm looking to see if 
there is any code available to help. I've Googled without success.

Basically, I have two databases containing lists of postal addresses and 
need to look for matching addresses in the two databases. More 
precisely, for each address in database A I want to find a single 
matching address in database B.
I had a similar problem to solve a while ago.  I can't give you my code, 
but I used this paper as the basis for my solution (BibTeX entry from 
http://citeseer.ist.psu.edu/monge00adaptive.html):

@misc{ monge-adaptive,
  author = Alvaro E. Monge,
  title = An Adaptive and Efficient Algorithm for Detecting 
Approximately Duplicate
Database Records,
  url = citeseer.ist.psu.edu/monge00adaptive.html }

There is a lot of literature--try a google search for approximate 
string match--but very little publically available code in this area, 
from what I could gather.  Removing punctuation, etc., as others have 
suggested in this thread, is _not_sufficient_.  Presumably you want to 
be able to match typos or phonetic errors as well.  This paper's 
algorithm deals with those problems quite nicely,

--

Aaron Bingham
Application Developer
Cenix BioScience GmbH

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


Re: [ANN] iCalendar package 0.9

2005-01-18 Thread Roger Binns

Max M [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 http://www.mxm.dk/products/public/ical/

 Any feedback would be welcome.

How well do you cope with the crud that real programs generate?  Does it work
with the different dialects uses out there?  Can it at least identify them?

The reason why I ask is this would be useful for BitPim.  When I wrote the
code for doing vCards, I soon found that there wasn't actually a single
program out there on Windows, Linux or Mac that actually generated 100%
standards conformant vCards.  They generally complied with the spirit,
but screwed up character encoding, misspelled fields names, didn't do
the right thing when commas and semi-colons were present in values etc.
I assume the thing happens with ical.

Roger 


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


Re: lambda

2005-01-18 Thread Antoon Pardon
Op 2005-01-17, Steve Holden schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:

 Mostly, though, I was trying to say that I found your nitpicking 
 insistence on terminological exactitude, even when giving advice to 
 those new to the language, both inappropriate and tedious in the extreme.

I think it is appropiate because not all new to the language are new to
programming and even newbees have a right to know how it really is.  Otherwise
after some time you get experienced users who don't know the fact. In
this case for example there are a number of people who flat out assert that
muatble dict keys in pyhthon is impossible.

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


Re: lambda

2005-01-18 Thread Steven Bethard
Antoon Pardon wrote:
In this case for example there are a number of people who flat out
assert that muatble dict keys in pyhthon is impossible.
If you run into any of these folks, please point them to:
http://www.python.org/moin/DictionaryKeys
It's a pretty good summary of one of the more recent threads on this 
topic by Peter Maas and myself.  If you feel like your point is not 
covered[1], feel free to add some additional material.  (That is, after 
all, the point of a wiki.)

Steve
[1] I assume that you feel this way because you have repeated 
essentially the same point about 5 times in this thread.  The wiki is a 
chance to make your statement once, and then simply post a pointer once 
per appropriate thread.  It might save you some time...
--
http://mail.python.org/mailman/listinfo/python-list


inbuilt function buffer()

2005-01-18 Thread km
Hi all,
I which context is the inbuilt function buffer() used ? 
regards,
KM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Integration with java

2005-01-18 Thread Dan Bishop
Istvan Albert wrote:
 Joachim Boomberschloss wrote:

   the code is already written in Python, using the
   standard libraries and several extension modules

 One thing to keep in mind is that Jython does not
 integrate CPython, instead it understands python code
 directly. So if you have a C extension that works with python
 it won't work with Jython.

Also, Jython is several versions behind CPython, so any Python code
that uses generators or new-style division won't work either.

 My feeling is that if you had a lot of Java code written and
 wanted to build on that with python Jython would be a better
 fit than vice versa.

I agree.

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


Re: [Python-Dev] Getting rid of unbound methods: patch available

2005-01-18 Thread Nick Coghlan
Guido van Rossum wrote:
What do people think? (My main motivation for this, as stated before,
is that it adds complexity without much benefit.)
Something important that came up in my response to Marc-Andre:
What about C method implementations which are relying on this typecheck and 
assuming that 'self' is (nearly) guaranteed to be of the correct type?

The string object implementation is where I noticed this assumption being made, 
but I suspect it would be fairly widespread.

Obviously, use of im_func can break such code already, but that's a far cry from 
having C.f skip the type check.

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: extension module, thread safety?

2005-01-18 Thread Nick Coghlan
Pierre Barbier de Reuille wrote:
With the current CPython, it's very hard to mix Python and C in a 
multithreading application (with C-threads, not Python-threads). In fact 
I never really succeeded in that task because of that GIL ! I have a 
multi-thread application but every bit of Python code must be run into a 
Python thread. To be more precise, I wanted to be able to call Python 
code in response to some GUI events, and I didn't want to instanciate a 
new interpreter for I wanted to be able to access the environment of my 
main Python interpreter.
I don't understand. This is what PyGILState_Ensure and PyGILState_Release are 
for - so C code can leave the GIL unlocked by default, and only grab it when 
they want to call into the C/Python API.

Regards,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: extension module, thread safety?

2005-01-18 Thread Pierre Barbier de Reuille
Nick Coghlan a écrit :
Pierre Barbier de Reuille wrote:
With the current CPython, it's very hard to mix Python and C in a 
multithreading application (with C-threads, not Python-threads). In 
fact I never really succeeded in that task because of that GIL ! I 
have a multi-thread application but every bit of Python code must be 
run into a Python thread. To be more precise, I wanted to be able to 
call Python code in response to some GUI events, and I didn't want to 
instanciate a new interpreter for I wanted to be able to access the 
environment of my main Python interpreter.

I don't understand. This is what PyGILState_Ensure and 
PyGILState_Release are for - so C code can leave the GIL unlocked by 
default, and only grab it when they want to call into the C/Python API.

Regards,
Nick.
Ok, I wondered why I didn't know these functions, but they are new to 
Python 2.4 ( and I didn't take the time to look closely at Python 2.4 as 
some modules I'm working with are still not available for Python 2.4). 
But if it really allows to call Python code outside a Python thread ... 
then I'll surely use that as soon as I can use Python 2.4 :) Thanks for 
the hint :)

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


Re: wxPython and PyGame - do they play well together?

2005-01-18 Thread Erik Bethke
Thank you,

My apologies to all for insufficient googling

-Erik

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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Nick Coghlan
Raymond Hettinger wrote:
[Delaney, Timothy C]
Nick's other suggestion - that genexps propagate __len__ - might
still be interesting. Of course, it would only be applicable for
unconditional genexps(i.e. no if clause).
Length transparency for iterators is not as general as one would expect.  I 
once
spent a good deal of effort exploring where it made sense, and I was surprised
to find that it only rarely works out.  Length transparency is an unexpectedly
thorny subject with many dead-ends which precludes a fully general solution such
as that proposed by Nick.
For a recap of my research, see the docstring for Lib/test/test_iterlen.py .
The situation slightly more involved whenever an object allows length 
mutation during iteration. 

Ouch. Nice understatement.
It's rather unfortunate that we can't make use of the length information even 
when the source *doesn't* mutate, though. I'll have to think some more to see if 
I can come up with any concrete ideas for you to shoot down :)

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: Socket and Tkinter Problem

2005-01-18 Thread Tonino
hi,

was wondering if you ever got a reply ?
Did you mannage to sort this out ?

I am wanting todo the same thing - just have a window that connects to
a port and displays the data it receives from that port in the window?
Thanks
Tonino

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


Re: [ANN] iCalendar package 0.9

2005-01-18 Thread Max M
Roger Binns wrote:
Max M [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
http://www.mxm.dk/products/public/ical/
Any feedback would be welcome.

How well do you cope with the crud that real programs generate?  Does it work
with the different dialects uses out there?  Can it at least identify them?

It depends on how badly the data is screwed up. But generally it should 
be able to work on incorrect implementations.

It doesn't care of the spelling of property and parameter names. Though 
type conversions will need to be done slightly more manual.

If something like 'dtstart' is misspelled it will not return a datetime
 cal.decoded('datestart')
But if you know that it is misspelled you can get it, and convert it 
manually like:

 from PropertyValues import vDDDType
 vDDDType.from_ical(cal['datestart'])
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem parsing namespaces with xml.dom.minidom

2005-01-18 Thread Fredrik Lundh
Mike McGavin wrote:

 is the DOM API an absolute requirement?

 It wouldn't need to conform to the official specifications of the DOM API, 
 but I guess I'm after 
 some comparable functionality.

 In particular, I need to be able to parse a namespace-using XML document into 
 some kind of node 
 tree, and then being able to query the tree to select elements based on their 
 namespace and local 
 tag names, and so on. I don't mind if the methods provided don't conform 
 exactly to DOM 
 specifications.

sounds like this might be exactly what you need:

http://effbot.org/zone/element-index.htm

(it's also the fastest and most memory-efficient Python-only parser you
can get, but I suppose that's not a problem ;-)

/F 



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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Antoon Pardon
Op 2005-01-18, Nick Coghlan schreef [EMAIL PROTECTED]:
 Raymond Hettinger wrote:
 [Delaney, Timothy C]
 
Nick's other suggestion - that genexps propagate __len__ - might
still be interesting. Of course, it would only be applicable for
unconditional genexps(i.e. no if clause).
 
 Length transparency for iterators is not as general as one would expect.  I 
 once
 spent a good deal of effort exploring where it made sense, and I was 
 surprised
 to find that it only rarely works out.  Length transparency is an 
 unexpectedly
 thorny subject with many dead-ends which precludes a fully general solution 
 such
 as that proposed by Nick.
 
 For a recap of my research, see the docstring for Lib/test/test_iterlen.py .

 The situation slightly more involved whenever an object allows length 
 mutation during iteration. 

 Ouch. Nice understatement.

 It's rather unfortunate that we can't make use of the length information even 
 when the source *doesn't* mutate, though. I'll have to think some more to see 
 if 
 I can come up with any concrete ideas for you to shoot down :)

Something else I was thinking about. I think it would be nice if the
python compilor could figure out whether a genexp in a list or tuple
expression always generates the same list or tuple and then instead
of generating code would generate the list or tuple in place.

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


Re: Problem parsing namespaces with xml.dom.minidom

2005-01-18 Thread Paul Prescod
You've reversed some function parameters. Here's a program that works 
fine (note that you don't need to set up a SAX parser):

from xml.dom import minidom
text = '''?xml version=1.0 encoding=UTF-8?
xte:xte xmlns:xte='http://www.mcs.vuw.ac.nz/renata/xte'
   xte:creatoralias/xte:creator
   xte:dateThu Jan 30 15:06:06 NZDT 2003/xte:date
   xte:object objectid=object1
 Nothing
   /xte:object
/xte:xte
'''
# Parse the string into a minidom
mydom = minidom.parseString(text)
# Look for some elements
# This one shouldn't return any (I think).
object_el1 = mydom.getElementsByTagName(xte:object)
# This one definitely should, at least for what I want.
object_el2 = mydom.getElementsByTagNameNS(
'http://www.mcs.vuw.ac.nz/renata/xte',object,
)
print '1: ' + str(object_el1)
print '2: ' + str(object_el2)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fuzzy matching of postal addresses

2005-01-18 Thread Simon Brunning
You might find these at least periperally useful:
http://www.brunningonline.net/simon/blog/archives/001291.html
http://www.brunningonline.net/simon/blog/archives/001292.html

They refer to address formatting rather than de-duping - but
normalising soulds like a useful first step to me.

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda

2005-01-18 Thread Simon Brunning
On 18 Jan 2005 07:51:00 GMT, Antoon Pardon [EMAIL PROTECTED] wrote:
 3 mutating an item in a sorted list *does* *always* cause problems

No, it doesn't. It might cause the list no longer to be sorted, but
that might or might no be a problem.

 More specific the Decimal class is mutable and usable as dict key.

Decimal objects are immutable, so far as I know.

 from decimal import Decimal
 spam = Decimal('1.2')
 eggs = spam
 eggs is spam
True
 eggs += 1
 eggs is spam
False

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda

2005-01-18 Thread Antoon Pardon
Op 2005-01-18, Simon Brunning schreef [EMAIL PROTECTED]:
 On 18 Jan 2005 07:51:00 GMT, Antoon Pardon [EMAIL PROTECTED] wrote:
 3 mutating an item in a sorted list *does* *always* cause problems

 No, it doesn't. It might cause the list no longer to be sorted, but
 that might or might no be a problem.

Than in the same vain I can say that mutating a key in a dictionary
doesn't always cause problems either. Sure it may probably make a
key unaccessible directly, but that might or might not be a problem.

 More specific the Decimal class is mutable and usable as dict key.

 Decimal objects are immutable, so far as I know.

 from decimal import Decimal
 spam = Decimal('1.2')
 eggs = spam
 eggs is spam
 True
 eggs += 1
 eggs is spam
 False


 from decimal import Decimal
 spam = Decimal('1.2')
 egg = spam
 spam._int = (1, 3)
 spam
Decimal(1.3)
 spam is egg
True

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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Steve Holden
Antoon Pardon wrote:
Op 2005-01-18, Nick Coghlan schreef [EMAIL PROTECTED]:
Raymond Hettinger wrote:
[Delaney, Timothy C]

Nick's other suggestion - that genexps propagate __len__ - might
still be interesting. Of course, it would only be applicable for
unconditional genexps(i.e. no if clause).
Length transparency for iterators is not as general as one would expect.  I 
once
spent a good deal of effort exploring where it made sense, and I was surprised
to find that it only rarely works out.  Length transparency is an unexpectedly
thorny subject with many dead-ends which precludes a fully general solution such
as that proposed by Nick.
For a recap of my research, see the docstring for Lib/test/test_iterlen.py .
The situation slightly more involved whenever an object allows length 
mutation during iteration. 

Ouch. Nice understatement.
It's rather unfortunate that we can't make use of the length information even 
when the source *doesn't* mutate, though. I'll have to think some more to see if 
I can come up with any concrete ideas for you to shoot down :)

Something else I was thinking about. I think it would be nice if the
python compilor could figure out whether a genexp in a list or tuple
expression always generates the same list or tuple and then instead
of generating code would generate the list or tuple in place.
Since it doesn't yet optimize 2+5 to a constant-folded 7 you should 
realize that you are suggesting a large increase in the compiler's 
analytical powers.

I agree it would be nice under certain circumstances, but don't forget 
that unlike list comprehensions (for which it would be even nicer) the 
whole point of generator expressions is often to defer the generation of 
the individual items until they are required and thereby relieve stress 
on memory.

As an edge case to demonstrate the point, what about a constant but 
infinite sequence?

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Central New Jersey PIG Meeting -- Python Interest Group In Princeton PIG/IP

2005-01-18 Thread [EMAIL PROTECTED]
Yes Jay. PIG/IP meetings are publicly open with no RSVP necessary.
Most of the folks coming are LUG/IP members, as I am and the location
is the same as LUG/IP meetings. We haven't formalized the group's
affiliation yet. 

-- Jon

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


Re: Integration with java

2005-01-18 Thread Steve Holden
Dan Bishop wrote:
Istvan Albert wrote:
Joachim Boomberschloss wrote:

the code is already written in Python, using the
standard libraries and several extension modules
One thing to keep in mind is that Jython does not
integrate CPython, instead it understands python code
directly. So if you have a C extension that works with python
it won't work with Jython.

Also, Jython is several versions behind CPython, so any Python code
that uses generators or new-style division won't work either.

My feeling is that if you had a lot of Java code written and
wanted to build on that with python Jython would be a better
fit than vice versa.

I agree.
Also let's not forget that the PSF has funded a project that's intended 
to help Jython get up to the curve - see 
http://www.python.org/psf/grants/Jython_PSF_Grant_Proposal.pdf. If that 
project succeeds, and if 2.5 development *does* focus mostly on the 
library, there's a sporting chance that Jython can be fully up to date 
for the 2.5 release.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


MDaemon Warning - virus found: Returned mail: Data format error

2005-01-18 Thread Mail Administrator

*** WARNING **
Este mensaje ha sido analizado por MDaemon AntiVirus y ha encontrado 
un fichero anexo(s) infectado(s).  Por favor revise el reporte de abajo.

AttachmentVirus name   Action taken
--
instruction.zip   I-Worm.Mydoom.m  Removed


**


Your message was undeliverable due to the following reason:

Your message was not delivered because the destination server was
unreachable within the allowed queue period. The amount of time
a message is queued before it is returned depends on local configura-
tion parameters.

Most likely there is a network problem that prevented delivery, but
it is also possible that the computer is turned off, or does not
have a mail system running right now.

Your message could not be delivered within 8 days:
Mail server 169.58.69.124 is not responding.

The following recipients did not receive this message:
python-list@python.org

Please reply to [EMAIL PROTECTED]
if you feel this message to be in error.

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

Re: lambda

2005-01-18 Thread Nick Coghlan
Antoon Pardon wrote:
More specific the Decimal class is mutable and usable as dict key.
It's *meant* to be immutable though. The fact that we used __slots__ instead of 
__setattr__ to implement the immutability, so you *can* overwrite the slot 
variables if you really want to is merely an artifact of the current Python 
implementation.

The limited mutability bug will disappear in Python 2.5, so it's not a good 
example of a 'mutable' dict key (especially given that the only way to mutate it 
is to modify private variables directly).

And, as I've stated previously, if the issue of sane mutable keys in 
dictionaries and sets really bugs you so much - implement identity_dict and 
identity_set in C and lobby for their inclusion in the collections module.

On the more general point of don't use mutable objects with non-identity based 
comparisons as dictionary keys, try teaching students for a while (or listen to 
those who have):

When stating useful general principles, it is never, ever worth it to get into 
the quibbly little details about exceptions to the principle. If students ask, 
admit that they exist, but point out that the exceptions are rare, and not worth 
worrying about at that point in their learning.

Only when one is aware of the reasons for a principle, can one be aware of good 
reasons not to follow it :)

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: generator expressions: performance anomaly?

2005-01-18 Thread Diez B. Roggisch
 Something else I was thinking about. I think it would be nice if the
 python compilor could figure out whether a genexp in a list or tuple
 expression always generates the same list or tuple and then instead
 of generating code would generate the list or tuple in place.

This won't ever happen in python - at least not in python otherwise similar
to the one we know...

The thing you're after is known as common subexpression elemination and
can only be done in purely functional languages. While that certainly is an
interesting property of a language, it e.g. forbids functions like
time.time() - a too huge paradigm shift for python.

-- 
Regards,

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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Antoon Pardon
Op 2005-01-18, Steve Holden schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:

 Op 2005-01-18, Nick Coghlan schreef [EMAIL PROTECTED]:
 
Raymond Hettinger wrote:

[Delaney, Timothy C]


Nick's other suggestion - that genexps propagate __len__ - might
still be interesting. Of course, it would only be applicable for
unconditional genexps(i.e. no if clause).

Length transparency for iterators is not as general as one would expect.  I 
once
spent a good deal of effort exploring where it made sense, and I was 
surprised
to find that it only rarely works out.  Length transparency is an 
unexpectedly
thorny subject with many dead-ends which precludes a fully general solution 
such
as that proposed by Nick.

For a recap of my research, see the docstring for Lib/test/test_iterlen.py .

The situation slightly more involved whenever an object allows length 
mutation during iteration. 

Ouch. Nice understatement.

It's rather unfortunate that we can't make use of the length information 
even 
when the source *doesn't* mutate, though. I'll have to think some more to 
see if 
I can come up with any concrete ideas for you to shoot down :)
 
 
 Something else I was thinking about. I think it would be nice if the
 python compilor could figure out whether a genexp in a list or tuple
 expression always generates the same list or tuple and then instead
 of generating code would generate the list or tuple in place.
 
 Since it doesn't yet optimize 2+5 to a constant-folded 7 you should 
 realize that you are suggesting a large increase in the compiler's 
 analytical powers.

Well I can dream, cant I?

 I agree it would be nice under certain circumstances, but don't forget 
 that unlike list comprehensions (for which it would be even nicer) the 
 whole point of generator expressions is often to defer the generation of 
 the individual items until they are required and thereby relieve stress 
 on memory.

 As an edge case to demonstrate the point, what about a constant but 
 infinite sequence?

Maybe I was not clear enough. I meant to limit it to cases such as

   lst = list(genexp)
   tpl = tuple(genexp)


Since in such cases the object is build in memory any way, I don't
think it would be a problem of having them prebuilt in memory, or am
I missing something?

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


Re: List problems in C code ported to Python

2005-01-18 Thread Bengt Richter
On Mon, 17 Jan 2005 15:28:56 GMT, Lucas Raab [EMAIL PROTECTED] wrote:

Lucas Raab wrote:
 I'm done porting the C code, but now when running the script I 
 continually run into problems with lists. I tried appending and 
 extending the lists, but with no avail. Any help is much appreciated 
 Please see both the Python and C code at 
 http://home.earthlink.net/~lvraab. The two files are ENIGMA.C and engima.py
 
 TIA

OK, here's the Python code and the corresponding C code:

def init_mach():
   import string
   #setup rotor data
   i=1
   j=0
   for j in j26, j+1:
I urge you to explore interactively. And do it line by line
(and even expression by expression when you get mystifying results) until you
are more familiar with the language.

E.g., what do you think the values of j will be here?
  j=0
  for j in j26, j+1: print j,
 ...
 True 1

Surprised?

  j26, j+1
 (True, 2)

Hm, surprised at the 2 here?

  j=0
  j26, j+1
 (True, 1)

IOW, your 'for' line was equivalent to iterating through a length-2 tuple
   for j in (True, 1):  # since if j is 0, j26 is True, and j+1 is 1
What you probably wanted was j starting with 0 and ending with 25, which you 
get by

  for j in xrange(26): print j,
 ...
 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

(The comma at the end of the print statement is to get a space before
 the next output instead of a newline).
   
   data[4],[j] = (ref_rotor[j] - 'A'+26) % 26
Had you tried an interactive experiment, you would have had some real questions 
to ask ;-)

  j=0
  for j in xrange(26):
 ... data[4],[j] = (ref_rotor[j] - 'A'+26) % 26
 ...
 Traceback (most recent call last):
   File stdin, line 2, in ?
 NameError: name 'ref_rotor' is not defined

Ok, fix that with something
  ref_rotor = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'  # something legal
  j=0
  for j in xrange(26):
 ... data[4],[j] = (ref_rotor[j] - 'A'+26) % 26
 ...
 Traceback (most recent call last):
   File stdin, line 2, in ?
 TypeError: unsupported operand type(s) for -: 'str' and 'str'

You might have had to ask at this point what that meant, but you could get 
closer by
trying the expressions and their terms:

  (ref_rotor[j] - 'A'+26) % 26
 Traceback (most recent call last):
   File stdin, line 1, in ?
 TypeError: unsupported operand type(s) for -: 'str' and 'str'

Pare it down

  (ref_rotor[j] - 'A'+26)
 Traceback (most recent call last):
   File stdin, line 1, in ?
 TypeError: unsupported operand type(s) for -: 'str' and 'str'

Check pieces
  j
 0
  ref_rotor[j]
 'A'

Substitute to make painfully clear

  ('A' - 'A'+26)
 Traceback (most recent call last):
   File stdin, line 1, in ?
 TypeError: unsupported operand type(s) for -: 'str' and 'str'
  ('A' - 'A')
 Traceback (most recent call last):
   File stdin, line 1, in ?
 TypeError: unsupported operand type(s) for -: 'str' and 'str'

What is 'A' ?
  type('A')
 type 'str'

Hm, characters are strings, not char types that are directly type compatible
with int. It takes a conversion. To get from single-char string to its integer 
code
and back:

  ord('A')
 65
  chr(65)
 'A'

Another experiment:

  ord('AB')
 Traceback (most recent call last):
   File stdin, line 1, in ?
 TypeError: ord() expected a character, but string of length 2 found


Now you are in a position to use ord, and get a little further:

  j=0
  for j in xrange(26):
 ... data[4],[j] = (ord(ref_rotor[j]) - ord('A')+26) % 26
 ...
 Traceback (most recent call last):
   File stdin, line 2, in ?
 TypeError: unpack non-sequence

Was the right hand side a problem?
  j
 0
  (ord(ref_rotor[j]) - ord('A')+26) % 26
 0

Apparently not, so what it was trying to do was

  data[4],[j] = 0
 Traceback (most recent call last):
   File stdin, line 1, in ?
 TypeError: unpack non-sequence

What was it trying to unpack? And why?
Well, you might have known if you had been through the tutorial, but at least
you would have had a specific question about a specific error at this point.

Note:
  a, b = 0
 Traceback (most recent call last):
   File stdin, line 1, in ?
 TypeError: unpack non-sequence

I.e., when you have commas (or even one) on the left hand side of an assignment,
that is asking python to unpack a sequence on the right hand side and assign to
corresponding items on the left. So e.g.,

  a, b = 0, 1
will unpack the tuple formed by 0, 1
  a
 0
  b
 1
You can unpack any sequence of the same length, and strings happen to be 
sequences:

  a,b = 'XY'
  a
 'X'
  b
 'Y'

Ok, enough of that. The comma was obviously a problem so, try it without:


  data[4][j] = 0
 Traceback (most recent call last):
   File stdin, line 1, in ?
 NameError: name 'data' is not defined

I could go on, but IMO if you expect help, you should do your part, and at least
post code that you have tried and which compiles or runs up to the point where
it shows an error that you need help with.

And show a verbatim copy/paste from your interactive session, not uncompilable
and obviously 

Re: generator expressions: performance anomaly?

2005-01-18 Thread Ola Natvig
Antoon Pardon wrote:
Op 2005-01-18, Steve Holden schreef [EMAIL PROTECTED]:
Antoon Pardon wrote:

Op 2005-01-18, Nick Coghlan schreef [EMAIL PROTECTED]:

Raymond Hettinger wrote:

[Delaney, Timothy C]

Nick's other suggestion - that genexps propagate __len__ - might
still be interesting. Of course, it would only be applicable for
unconditional genexps(i.e. no if clause).
Length transparency for iterators is not as general as one would expect.  I 
once
spent a good deal of effort exploring where it made sense, and I was surprised
to find that it only rarely works out.  Length transparency is an unexpectedly
thorny subject with many dead-ends which precludes a fully general solution such
as that proposed by Nick.
For a recap of my research, see the docstring for Lib/test/test_iterlen.py .
The situation slightly more involved whenever an object allows length 
mutation during iteration. 

Ouch. Nice understatement.
It's rather unfortunate that we can't make use of the length information even 
when the source *doesn't* mutate, though. I'll have to think some more to see if 
I can come up with any concrete ideas for you to shoot down :)

Something else I was thinking about. I think it would be nice if the
python compilor could figure out whether a genexp in a list or tuple
expression always generates the same list or tuple and then instead
of generating code would generate the list or tuple in place.
Since it doesn't yet optimize 2+5 to a constant-folded 7 you should 
realize that you are suggesting a large increase in the compiler's 
analytical powers.

Well I can dream, cant I?

I agree it would be nice under certain circumstances, but don't forget 
that unlike list comprehensions (for which it would be even nicer) the 
whole point of generator expressions is often to defer the generation of 
the individual items until they are required and thereby relieve stress 
on memory.

As an edge case to demonstrate the point, what about a constant but 
infinite sequence?

Maybe I was not clear enough. I meant to limit it to cases such as
   lst = list(genexp)
   tpl = tuple(genexp)
Since in such cases the object is build in memory any way, I don't
think it would be a problem of having them prebuilt in memory, or am
I missing something?
Perhaps it had been better if that kind of functionality were 
implemented with a different syntax, I don't know enough about how the 
python interpreter works but perhaps it should be possible to execute 
some expressions with genexp syntax when compiling to bytecode. That 
should be a quite trivial extension.

examples using '' list-comp/genexp syntax '':
lst = i for i in range(100)
or perhaps
lst = list(i for i in range(100))
Would result in the same bytecode as this expression
lst = [0, 1, 2, 3, ..., 98, 99]
It could be called static list comprehensions. But if it is a usefull 
extension is another dicussion.

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


Re: how to find site-packages path (Michael Hoffman) - use distutils

2005-01-18 Thread Philippe C. Martin
 Why would you want to copy any *.pyc instead of compiling them on
site?



I know that sounds terrible to the open source community, but I do not
intend to release the source code for my product - pls go to
philippecmartin.com/applications.html for my _small_ contributions :-))

Regards,

Philippe



-- 
***
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
***

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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Diez B. Roggisch

lst = list(genexp)
tpl = tuple(genexp)
 
 
 Since in such cases the object is build in memory any way, I don't
 think it would be a problem of having them prebuilt in memory, or am
 I missing something?

Yes. Consider this:

lst = list(time.time() for i in xrange(10))
tpl = tuple(time.time() for i in xrange(10))


-- 
Regards,

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


Re: news feed problem -- anyone else?

2005-01-18 Thread Bengt Richter
On 17 Jan 2005 16:48:24 EST, Tim Daneliuk [EMAIL PROTECTED] wrote:

Bengt Richter wrote:

 I can see postings on google, but my news service
 is having a problem since sometime during the weekend.
 Can get old stuff from other n.g., but no new.
 Wondering whether I'll see this via google.
 
 Regards,
 Bengt Richter

Bengt -

I've had very good luck using the following *free* newsfeed:

 http://individual.net/


HTH,
Thanks,
I can see this via normal news now. But that looks good.

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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Ola Natvig
Diez B. Roggisch wrote:
  lst = list(genexp)
  tpl = tuple(genexp)
Since in such cases the object is build in memory any way, I don't
think it would be a problem of having them prebuilt in memory, or am
I missing something?

Yes. Consider this:
lst = list(time.time() for i in xrange(10))
tpl = tuple(time.time() for i in xrange(10))


Would it be a bad solution to make that a list or tuple of ten 
time.time() calls, you could also restrict what theese prebuilding 
sequenses could contain, or perhaps try to prebuild them, and then fail 
if it's impossible.

--
--
 Ola Natvig [EMAIL PROTECTED]
 infoSense AS / development
--
http://mail.python.org/mailman/listinfo/python-list


[wxpython] exclude files in a wx.FileDialog?

2005-01-18 Thread John Field
Hello, 

Is it possible to exclude certain files in a wx.FileDialog, so that the user 
won't see them and can't select them with the mouse in de File open window?

I was thinking of somehow extending the class FileDialog(Dialog) 
in the wx module _windows.py to a subclass, but I'm not sure how to do that 
(if feasible). 


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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Diez B. Roggisch
 Would it be a bad solution to make that a list or tuple of ten
 time.time() calls, you could also restrict what theese prebuilding
 sequenses could contain, or perhaps try to prebuild them, and then fail
 if it's impossible.

I don't fully understand what you mean. Restricting them would mean to add
static declarations that say I return the same whenever you call me -
which is even more than the already fragile const  declaration of c++
allows. 

And for your second suggestion - how exactly do you check for failing?
Generating 2 elements and checking if they are equal to the first two of
the old list? What about overloaded __cmp__/__eq__, or just the last
element differing?

This problem is too complex to solve automatically - domain knowledge is
needed. As the code Antoon presented also suggests the simple solution:


lst = list(time.time() for i in xrange(10))
tpl = tuple(lst)


I don't see why this is a desirable feature at all. Keep in mind that
putting statements or even stackframes between those two statements above
utterly complicates things. And we even didn't dig into the dynamic
features of python that for example make it possible to alter time.time
like this

time.time = random.random()

so that it behaves totally different - while the syntactically equivalence
still holds. No chance of catching that. 
-- 
Regards,

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


Re: lambda

2005-01-18 Thread Antoon Pardon
Op 2005-01-18, Nick Coghlan schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:
 More specific the Decimal class is mutable and usable as dict key.

 It's *meant* to be immutable though. The fact that we used __slots__ instead 
 of 
 __setattr__ to implement the immutability, so you *can* overwrite the slot 
 variables if you really want to is merely an artifact of the current Python 
 implementation.

 The limited mutability bug will disappear in Python 2.5, so it's not a good 
 example of a 'mutable' dict key (especially given that the only way to mutate 
 it 
 is to modify private variables directly).

 And, as I've stated previously, if the issue of sane mutable keys in 
 dictionaries and sets really bugs you so much - implement identity_dict and 
 identity_set in C and lobby for their inclusion in the collections module.

I'm not bugged by its absence in Python. I'm bugged by the attitude
about them. But anyway I'm thinking about implementing a safe dictionary
that will copy whenever it would otherwise allow the risk of mutating a
key.

 On the more general point of don't use mutable objects with non-identity 
 based 
 comparisons as dictionary keys, try teaching students for a while (or listen 
 to 
 those who have):

What kind of students?

I have implemented a hash table when I was a student and its
implementation allowed the use of 'mutable' objects as a key
without a problem. It simply always made copies when appropiate
and didn't allow external access to the keys. So although the
key objects were 'mutable' there was no way a user could accidently
mutate a key.

So don't use a mutable as a dictionary key isn't so much a dictionary
limitation in general but a specific limitation of the python implementation.

And yes I understand, the current implenatation is the result of the
fact that the same dictionaries are used internally for variables in
scopes and attributes in objects and the fact that no copies are
involved gives a boost to performance. But it could be argued that
providing these same dictionaries with those semantics to the users
was a premature optimisation.

 When stating useful general principles, it is never, ever worth it to get 
 into 
 the quibbly little details about exceptions to the principle. If students 
 ask, 
 admit that they exist, but point out that the exceptions are rare, and not 
 worth 
 worrying about at that point in their learning.

But don't use mutable keys is not a general principle. It is a principle
introduced by the limitations of the python implementations.

I don't like it when a good rule of thumb because of implementation
limitations is sold as a general principle.

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


Re: [perl-python] 20050118 keyed list

2005-01-18 Thread Jay Tilton
Xah Lee [EMAIL PROTECTED] wrote:

: # the syntax of keyed list in Perl is too complex
: # to be covered in a short message.

You've got to be joking.  You couldn't even muster enough skill to provide
Perl equivalents for the four simple Python statements you showed?

: # see perldoc perldata for an unix-styled course.

It's good to see your opinion on the _fantastic incompetent writting_[1] of
Perl's documentation has changed enough that you can recommend it to
novices.

[1]Message-ID: [EMAIL PROTECTED]

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


Re: strange note in fcntl docs

2005-01-18 Thread John Lenton
On Mon, Jan 17, 2005 at 09:54:46PM -0600, Skip Montanaro wrote:
 
 John And, even if they were, the note is *still* wrong and misleading:
 John fcntl is available on Windows, and os.open's flags won't be.
 
 Does this read better?
 
 [snip]

yes, and it takes me back to considering why file objects don't have
methods suck as lock, stat and mmap where those calls are available
through other mechanisms...

-- 
John Lenton ([EMAIL PROTECTED]) -- Random fortune:
Yo mando a mi gato y mi gato manda a su rabo. 


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: [wxpython] exclude files in a wx.FileDialog?

2005-01-18 Thread Franz Steinhaeusler
On 18 Jan 2005 13:23:24 GMT, John Field [EMAIL PROTECTED] wrote:

Hello, 

Is it possible to exclude certain files in a wx.FileDialog, so that the user 
won't see them and can't select them with the mouse in de File open window?

I was thinking of somehow extending the class FileDialog(Dialog) 
in the wx module _windows.py to a subclass, but I'm not sure how to do that 
(if feasible). 


cheers

wx.FileDialog is only a wrapper for the api FileDialog (at least this 
applies for windows) and therefore it is not possible to derive from it.

Really exclude, I think, is not possible.

You can put a mask 
wx.FileDialog(...wildcard = BMP files (*.bmp)|*.bmp|GIF files
(*.gif)|*.gif)

Otherwise you have to create your own FileDialog.
-- 
Franz Steinhaeusler
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: generator expressions: performance anomaly?

2005-01-18 Thread Stephen Thorne
On Tue, 18 Jan 2005 07:12:18 -0500, Steve Holden [EMAIL PROTECTED] wrote:
 Since it doesn't yet optimize 2+5 to a constant-folded 7 you should
 realize that you are suggesting a large increase in the compiler's
 analytical powers.

As in interesting aside to this, you might be interested to know that
PHP has constant folding, allowing you to do things like
$foo = 7+9; and have it generate bytecode that is let 'foo' equal 16
or somesuch.

PHP achieves this by having a subset of expression parsing available
only for situations where a folded constant is allowed.

i.e.
class Foo {
  var $bar = 1+4; /* this constant is folded */
}

static_scalar: /* compile-time evaluated scalars */
common_scalar |   T_STRING |   '+' static_scalar |
  '-' static_scalar |   T_ARRAY '(' static_array_pair_list ')'
;
common_scalar:
/* all numbers, strings-not-containing-variable-interpolation and a
few hacks like __FILE__ and __LINE__ */
;

As you can see from the grammar, there are any number of ways this can break.

i.e.
Parse Error, * isn't allowed:
class Foo { var $bar = 60*60*24; }

Parse Error, neither is anything except + and -:
class Foo { var $bar = 256  18; }

Parse Error, and definately not variables:
$baz = 12;
class Foo { var $bar = $baz*2; }

I compute 60*60*24 every time around the loop:
foreach ($myarray as $value) { $x = 60*60*24*$value; }

Thankful, Former PHP Programmer,
Stephen Thorne.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: generator expressions: performance anomaly?

2005-01-18 Thread Ola Natvig
Diez B. Roggisch wrote:
Would it be a bad solution to make that a list or tuple of ten
time.time() calls, you could also restrict what theese prebuilding
sequenses could contain, or perhaps try to prebuild them, and then fail
if it's impossible.

I don't fully understand what you mean. Restricting them would mean to add
static declarations that say I return the same whenever you call me -
which is even more than the already fragile const  declaration of c++
allows. 

And for your second suggestion - how exactly do you check for failing?
Generating 2 elements and checking if they are equal to the first two of
the old list? What about overloaded __cmp__/__eq__, or just the last
element differing?
This problem is too complex to solve automatically - domain knowledge is
needed. As the code Antoon presented also suggests the simple solution:
lst = list(time.time() for i in xrange(10))
tpl = tuple(lst)
I don't see why this is a desirable feature at all. Keep in mind that
putting statements or even stackframes between those two statements above
utterly complicates things. And we even didn't dig into the dynamic
features of python that for example make it possible to alter time.time
like this
time.time = random.random()
so that it behaves totally different - while the syntactically equivalence
still holds. No chance of catching that. 
My thoughts where to let the 'leftmost' section of the expression to be 
intact so that any of the dynamic things done to this part, i.e. 
replacing time.time with random.random are taken into consideration. 
What can be done is to extract the expression into a loopless structure

lst = list(time.time() for i in xrange(10))
would be compiled to the bytecode version of:
lst = [time.time(), time.time(), time.time(), time.time() ...]
Then time.time can do whatever it wants to. It's the (x)range function 
that we need to enshure returns the same values in every execution. This 
*IS* a useless feature, but I think it's possible to make it work.

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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Diez B. Roggisch

 My thoughts where to let the 'leftmost' section of the expression to be
 intact so that any of the dynamic things done to this part, i.e.
 replacing time.time with random.random are taken into consideration.
 What can be done is to extract the expression into a loopless structure
 
 lst = list(time.time() for i in xrange(10))
 would be compiled to the bytecode version of:
 lst = [time.time(), time.time(), time.time(), time.time() ...]
 
 Then time.time can do whatever it wants to. It's the (x)range function
 that we need to enshure returns the same values in every execution. This
 *IS* a useless feature, but I think it's possible to make it work.

What makes the leftmost expression different from the iterable returning
expression inside the for? The same arguments apply there.

-- 
Regards,

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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Antoon Pardon
Op 2005-01-18, Diez B. Roggisch schreef [EMAIL PROTECTED]:
 Something else I was thinking about. I think it would be nice if the
 python compilor could figure out whether a genexp in a list or tuple
 expression always generates the same list or tuple and then instead
 of generating code would generate the list or tuple in place.

 This won't ever happen in python - at least not in python otherwise similar
 to the one we know...

 The thing you're after is known as common subexpression elemination and
 can only be done in purely functional languages. While that certainly is an
 interesting property of a language, it e.g. forbids functions like
 time.time() - a too huge paradigm shift for python.


I don't see how generating byte code for a = 9; when seeing the
expression a = 3 + 6, would be a problem for non-functional
languages.

I agree that things like [time.time() for i in xrange(10)] shouldn't
be pregenerated and that the problem is more complicated as I thought.

But during compilation the compilor could do an anlysis of the code
do determine whether there are side effects or not. If the compilor
then would store a code in the byte code for functions that are
guaranteed side-effect free and only pregenerated objects generated
by expressions with no side-effect, some common subexpression
elimination could be done even in a non-functional language.

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


MemoryError with parser.suite and wrong encoding declaration

2005-01-18 Thread Sylvain Thenault
Hi there !
I've noticed the following problem with python = 2.3 (actually 2.3.4 and
2.4):

[EMAIL PROTECTED]:test$ python
Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
[GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
Type help, copyright, credits or license for more information.
 import parser
 parser.suite('# -*- coding: IBO-8859-1 -*-')
Traceback (most recent call last):
  File stdin, line 1, in ?
MemoryError
 parser.suite('# -*- coding: ISO-8859-1 -*-')
parser.st object at 0xb7e5e060

Shouldn't parser.suite just ignore the wrong encoding declaration, or at
least raise a more appropriate exception. IMHO the first solution
would be better, since that's the behaviour of the (C) python interpreter.

-- 
Sylvain Thénault   LOGILAB, Paris (France).

http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org


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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Ola Natvig
What makes the leftmost expression different from the iterable returning
expression inside the for? The same arguments apply there.
It's not different, but it's a requirement that the iterable returns the 
same data every time. I know that anyone can type range = fancyRange and 
make this return a random number of random items.

But if that happens the expression cannot be transformed into a static 
list / tuple. Thats obvious.
--
http://mail.python.org/mailman/listinfo/python-list


Re: lambda

2005-01-18 Thread John Lenton
On Mon, Jan 17, 2005 at 03:20:01PM +, Antoon Pardon wrote:
 Op 2005-01-17, John Lenton schreef [EMAIL PROTECTED]:
 
  knowledgeable and experienced users know when to ignore the rules.
 
 Then why seems there to be so few acknowledgement that these rules
 may indeed be broken by users. My experience is that anyone who suggests
 so runs the risk of being branded a (python) heretic.

First you learn the basics, then you think you're knowledgeable and
experienced, then you learn the rules, then you become one with the
rules, and then you may break them.

Most people suggesting these things haven't gotten past step #3. Using
Craig's parallel to C's goto, every and all newbie using gotos should
be lambasted: even if the use might be correct for the problem they
are trying to solve, the reasons for its correctness are far too
complex for them to grasp. But really, in practically any system, the
rules are generalizations, and they exist because the particulars are
too delicate to trust the unexperienced. The small print is
unprintable.

He dicho.

-- 
John Lenton ([EMAIL PROTECTED]) -- Random fortune:
Yo siempre seré el futuro Nobel. Debe ser una tradición escandinava.
-- Jorge Luis Borges. (1899-1986) Escritor argentino. 


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: lambda

2005-01-18 Thread Steve Holden
Antoon Pardon wrote:
Op 2005-01-18, Nick Coghlan schreef [EMAIL PROTECTED]:
[...]
But don't use mutable keys is not a general principle. It is a principle
introduced by the limitations of the python implementations.
Sorry, but it *is* a general principle, adduced from the potential 
pitfalls available to inexperienced programmers when breaking the principle.

I don't like it when a good rule of thumb because of implementation
limitations is sold as a general principle.
So, since you are so good at nit-picking, perhaps you will explain the 
difference between rule of thumb and general principle.

preferably-in-less-than-three-thousand-words-ly y'rs  - steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: generator expressions: performance anomaly?

2005-01-18 Thread Steve Holden
Stephen Thorne wrote:
On Tue, 18 Jan 2005 07:12:18 -0500, Steve Holden [EMAIL PROTECTED] wrote:
Since it doesn't yet optimize 2+5 to a constant-folded 7 you should
realize that you are suggesting a large increase in the compiler's
analytical powers.

As in interesting aside to this, you might be interested to know that
PHP has constant folding, allowing you to do things like
$foo = 7+9; and have it generate bytecode that is let 'foo' equal 16
or somesuch.
PHP achieves this by having a subset of expression parsing available
only for situations where a folded constant is allowed.
i.e.
class Foo {
  var $bar = 1+4; /* this constant is folded */
}
static_scalar: /* compile-time evaluated scalars */
common_scalar |   T_STRING |   '+' static_scalar |
  '-' static_scalar |   T_ARRAY '(' static_array_pair_list ')'
;
common_scalar:
/* all numbers, strings-not-containing-variable-interpolation and a
few hacks like __FILE__ and __LINE__ */
;
As you can see from the grammar, there are any number of ways this can break.
i.e.
Parse Error, * isn't allowed:
class Foo { var $bar = 60*60*24; }
Parse Error, neither is anything except + and -:
class Foo { var $bar = 256  18; }
Parse Error, and definately not variables:
$baz = 12;
class Foo { var $bar = $baz*2; }
I compute 60*60*24 every time around the loop:
foreach ($myarray as $value) { $x = 60*60*24*$value; }
Thankful, Former PHP Programmer,
Stephen Thorne.
Yes, well, this just goes to confirm my belief that PHP isn't a 
programming language. I am always amazed at what's been achieved with it 
(though I sometimes wonder at what cost).

You probably already know that sensible compiled language systems have 
used constant folding since time immemorial, but Python has always 
eschewed it. That's what comes of being a pragmatist's language: if such 
optimizations really are required the programmer is expected to perform 
them.

and-ninety-nine-point-nine-nine-percent-of-the-time-they-aren't-ly y'rs 
 - steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119

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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Diez B. Roggisch
 I don't see how generating byte code for a = 9; when seeing the
 expression a = 3 + 6, would be a problem for non-functional
 languages.

Most probably. But I don't see much code of that type that it would be worth
optimizing for, either. The cost for re-evaluation such an expression
doesn't really account for any performance problems you hit - in python, of
course.
See this:

[EMAIL PROTECTED]:/usr/lib/python2.3$ python timeit.py -c [4*5 for i in
xrange(1)]
100 loops, best of 3: 5.5e+03 usec per loop
[EMAIL PROTECTED]:/usr/lib/python2.3$ python timeit.py -c [20 for i in
xrange(1)]
100 loops, best of 3: 4.3e+03 usec per loop


Now of course the longer the expressions get, the more time it costs - but
how many long arithmetical expression of constant evaluation value do you
have?

 
 I agree that things like [time.time() for i in xrange(10)] shouldn't
 be pregenerated and that the problem is more complicated as I thought.
 
 But during compilation the compilor could do an anlysis of the code
 do determine whether there are side effects or not. If the compilor
 then would store a code in the byte code for functions that are
 guaranteed side-effect free and only pregenerated objects generated
 by expressions with no side-effect, some common subexpression
 elimination could be done even in a non-functional language.

This analysis would only be possible for the most primitive of examples, 
the reason beeing that due to the dynamic features syntactically equivalent
expressions can have totally different semantics. So its not really worth
the effort.

-- 
Regards,

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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Steve Holden
Antoon Pardon wrote:
Op 2005-01-18, Diez B. Roggisch schreef [EMAIL PROTECTED]:
Something else I was thinking about. I think it would be nice if the
python compilor could figure out whether a genexp in a list or tuple
expression always generates the same list or tuple and then instead
of generating code would generate the list or tuple in place.
This won't ever happen in python - at least not in python otherwise similar
to the one we know...
The thing you're after is known as common subexpression elemination and
can only be done in purely functional languages. While that certainly is an
interesting property of a language, it e.g. forbids functions like
time.time() - a too huge paradigm shift for python.

I don't see how generating byte code for a = 9; when seeing the
expression a = 3 + 6, would be a problem for non-functional
languages.
I agree that things like [time.time() for i in xrange(10)] shouldn't
be pregenerated and that the problem is more complicated as I thought.
But during compilation the compilor could do an anlysis of the code
do determine whether there are side effects or not. If the compilor
then would store a code in the byte code for functions that are
guaranteed side-effect free and only pregenerated objects generated
by expressions with no side-effect, some common subexpression
elimination could be done even in a non-functional language.
Indeed, and it has been, which is a matter of well-recorded history. 
Constant folding has been used since the early Fortran compilers.

But you've already stated that the problem is more complicated than you 
thought. I presume you are already prepared to bail on any function that 
calls into external modules or extensions, since clearly nothing can be 
known about their behaviors vis a vis side effects.

Python is *designed* as a dynamic language. I wish you would embrace 
this aspect rather than continually trying to shoehorn it into a static 
straitjacket. Efficiency is good. Flexibility is better.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] 20050118 keyed list

2005-01-18 Thread Jürgen Exner
Xah Lee wrote:
 © # in perl, keyed-list is done like this:

Just FYI: those thingies are called hashes. The legacy name would be 
associative array.

 © %a = ('john',3, 'mary', 4, 'jane', 5, 'vicky',7);
 © use Data::Dumper qw(Dumper);
 © print Dumper \%a;

Wow, my compliments. The very first time that using Data::Dumper actually 
may do something useful (formats the data more nicely). Still, why you are 
passing a reference is beyond me.

 © # the syntax of keyed list in Perl is too complex
 © # to be covered in a short message.

Excuse me? If (using the same examples as for your Python section)
print Mary is $a{mary};
delete $a{vicky}; print %a;
print keys(%a);
exists $a{mary};
is too complex for your to cover, then I strongly suggest you stop posting 
your explanations.

 © # see perldoc perldata for an unix-styled course.

Excuse me? Do you mind explaining where exactly perldata is Unix-styled?

jue 


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


Re: lambda

2005-01-18 Thread Antoon Pardon
Op 2005-01-18, Steve Holden schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:

 Op 2005-01-18, Nick Coghlan schreef [EMAIL PROTECTED]:
 [...]
 But don't use mutable keys is not a general principle. It is a principle
 introduced by the limitations of the python implementations.
 
 Sorry, but it *is* a general principle, adduced from the potential 
 pitfalls available to inexperienced programmers when breaking the principle.

But if these inexperienced programmers would have used dictionaries
that were implemented more safely, those pitfalls would have been
avoided. So are the pitfalls caused by breaking the principle
or by using an unsafe dictionary implementation?

 I don't like it when a good rule of thumb because of implementation
 limitations is sold as a general principle.
 
 So, since you are so good at nit-picking, perhaps you will explain the 
 difference between rule of thumb and general principle.

A rule of thumb is context sensitive. If circumstances change,
so do the rules of thumb. Principles have a broader field
of application.

IMO there is nothing principally wrong with using a mutable object
as a dictionary key. But avoiding doing so is a good rule of
thumb if you have a python-like implementation of a dictionary.

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


bind error!!!!!

2005-01-18 Thread Perrin Aybara
hi..
my code was working pretty well until yesterday.suddenly it started
giving me bind error: address already in use.
but i have logged out and again logged in, but still the problem is not solved
can somebody give me solution for this

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


ANNOUNCE: Altova DiffDog 2005 - the dedicated differencing utility for developers and power users

2005-01-18 Thread Altova Announcements

Altova Unveils DiffDog(tm) 2005
---

This week, Altova added a new dedicated differencing utility to its 
award-winning product line. DiffDog 2005 is a powerful, easy-to-use 
synchronization tool that facilitates the comparison and merging of files, 
folders, and directories for application developers and power users.

DiffDog 2005 Standard and Professional editions allow users to quickly 
compare source code files, HTML files, or any text-based files then merge 
changes with a click of the mouse. Both editions deliver versatile 
comparison and merging options for all file directories as well. Uniquely, 
DiffDog 2005 Professional Edition also provides advanced XML-aware 
differencing and editing capabilities based on those popularized in Altova 
XMLSpy.

DiffDog 2005 integrates with any version control system that supports 
external differencing applications. For optimal efficiency, you can edit 
content directly within its differencing display, merge changes, and 
instantly re-compare the edited files. Intelligent syntax-coloring, line 
numbering, indentation guides, folding margins, and other innovative 
features are provided to assist in comparing source-code and XML files.

DiffDog 2005 also provides powerful capabilities for directory comparisons, 
allowing you to compare and merge directories, and open and edit file pairs 
directly from the directory comparison view. You can instantly identify the 
differences in two versions of a large directory, open and edit files 
side-by-side, then move what you want into your target directories. With all 
this you can reconcile source code versions, synch-up files on your laptop 
and desktop computers, or even modify and merge your play lists or photo 
collections in a matter of seconds. DiffDog 2005 is the latest in Altova's 
line of award-winning developer tools.

Let DiffDog 2005 track down the differences in your development and 
integration projects.

Download a 30-day FREE trial today: 
http://www.altova.com/download_diffdog.html.

For more information on Altova DiffDog 2005 please visit: 
http://www.altova.com/products_diffdog.html.



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


Re: generator expressions: performance anomaly?

2005-01-18 Thread Antoon Pardon
Op 2005-01-18, Steve Holden schreef [EMAIL PROTECTED]:

 Python is *designed* as a dynamic language. I wish you would embrace 
 this aspect rather than continually trying to shoehorn it into a static 
 straitjacket. Efficiency is good. Flexibility is better.

Flexibility is better? IMO flexibilty implies more than one way to do
things. But that is a big no no here in c.l.py.

I also see a lot of remarks that go: Don't do this! when some of
the more dynamic aspects are talked about, because there are 
security risks involved. One of the results was that I ended up
writing a parser for some kind of game instead of just dumping the
structure in textual form and doing an eval of the file when reading
it in. But if I need a parser I could just as well used a static
language.

I'm beginning to guess the dynamic aspect of python is overrated.

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


RE: bind error!!!!!

2005-01-18 Thread Batista, Facundo
Title: RE: bind error!





[Perrin Aybara]


#- my code was working pretty well until yesterday.suddenly it started
#- giving me bind error: address already in use.
#- but i have logged out and again logged in, but still the 
#- problem is not solved
#- can somebody give me solution for this


Do you really think that somebody could help you with the information that you're giving?


You should read this: http://www.catb.org/~esr/faqs/smart-questions.html


Regards,


. Facundo


Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - Python Argentina: http://pyar.decode.com.ar/



  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA.


La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje.

Muchas Gracias.



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

Re: generator expressions: performance anomaly?

2005-01-18 Thread Steve Holden
Antoon Pardon wrote:
Op 2005-01-18, Steve Holden schreef [EMAIL PROTECTED]:

Python is *designed* as a dynamic language. I wish you would embrace 
this aspect rather than continually trying to shoehorn it into a static 
straitjacket. Efficiency is good. Flexibility is better.

Flexibility is better? IMO flexibilty implies more than one way to do
things. But that is a big no no here in c.l.py.
Become one with the language.
I also see a lot of remarks that go: Don't do this! when some of
the more dynamic aspects are talked about, because there are 
security risks involved. One of the results was that I ended up
writing a parser for some kind of game instead of just dumping the
structure in textual form and doing an eval of the file when reading
it in. But if I need a parser I could just as well used a static
language.

Wow, you mean you actually *took* some advice? :-) Perhaps this whole 
thing has arisen because you feel you were badly advised. It looks as 
though your programming skill level might have been underestimated. Your 
ability to wring an argument to a merciless death could never be.

I'm beginning to guess the dynamic aspect of python is overrated.
You shouldn't have to guess, and it isn't.
Certain of its dynamic aspects do demand a certain care rather than 
casual usage, however, which leads to rules of thumb like don't use 
mutables as dictionary keys. Yes, of course you can, but to a newbie 
your behavior (it seems to me) is a bit like this:

Me (to newbie): ... And, of course, you want to be careful not to shoot 
yourself in the foot.

You: :Well, actually, if you use a .22 and aim very carefully between 
the big toe and its neighbor there's a 96% chance that you will only 
suffer serious burns.

So, please understand, I'm not trying to say that (most of) your 
utterances are untrue, or question your knowledge of the Python 
environment. I'm just trying to bring the day closer when you will be 
able to watch me write something that's only 99% true and happily walk 
away without writing a thousand-word essay on the remaining 1% case.

This anal behavior is unlikely to win friends and influence people.
Anyway, I've just about had my say on this topic now. I'm left with the 
uncomfortable feeling that having led you patiently (or at least as 
patiently as I can) down to the water, I will now have to watch you die 
of thirst rather than take a well-deserved drink.

Life's too short. I'm going to stop disagreeing with you now, even if 
this means stopping communicating with you. I'm sure you won't miss my 
crotchety ramblings anyway.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: bind error!!!!!

2005-01-18 Thread Steve Holden
Perrin Aybara wrote:
hi..
my code was working pretty well until yesterday.suddenly it started
giving me bind error: address already in use.
but i have logged out and again logged in, but still the problem is not solved
can somebody give me solution for this
thankx
perrin
Next time, please ask a slightly smarter question:
www.catb.org/~esr/faqs/smart-questions.html
I presume you are talking about a socket-based server program?
There's a timeout period during which your server port will be left 
unusable (according to the TCP standards). You can avoid this by setting 
the socket.SO_REUSEADDR option when you open your server socket.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


script to automate GUI application (newbie)

2005-01-18 Thread bogdan romocea
Dear Python experts,

I have a GUI application (Windows; apparently written in Java) which I
want to use through a script (without a mouse or keyboard). First, one
of several buttons needs to be clicked (no keyboard shortcuts
available, but I can measure the coordinates in pixels from the top
left corner of the window to the center of the button to be clicked).
Then, a window with a few drop-down lists pops up - I have to make some
choices and click OK (it's possible to navigate from one drop-down to
the next with Tab, and hit Enter for OK). 

I want to run the script above from code (if this then click ... and
OK) and perhaps by means of several desktop shortcuts (one shortcut
for each set of GUI inputs). 

Is such a script possible? If yes, how do I get there? I searched
comp.lang.python but didn't find something directly applicable (or so
it seemed to me - I'm a beginner). Directions (and sample code, if
possible) will be warmly appreciated.

Thank you,
b.






__ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Integration with java (Jpype vs. JPE)

2005-01-18 Thread Istvan Albert
Steve Menard wrote:
To asnwer your question more fully, the jpype-specific cide is only for 
looking up the Classes and startting/stopping the environment. For 
everything else, Java objects and classes are used as regular Python 
objects.
Thanks for the response. Currently I don't need to use java but
in the past when I explored such a possibility I looked at jpype
and I was unable to understand from the documentation what it
actually does.
There is a lot of text there, but it is all concerning catching
errors or other subtleties. For a new visitor the most important
question is about how it works, what does it do, and how can it be
applied for the given problem.
 everything else, Java objects and classes are used as regular Python
 objects.
This is too generic. My question was a little more specific,
how would I pass a python list as an argument of a java class/method or
transform a java list into a python one? You don't have to
answer it here, I'm just pointing out the kind of
questions that I was unable to get an answer for on the jpype
website.
best,
Istvan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: bind error!!!!!

2005-01-18 Thread Fredrik Lundh
Perrin Aybara wrote:

 my code was working pretty well until yesterday.suddenly it started
 giving me bind error: address already in use.

google has the details:

http://hea-www.harvard.edu/~fine/Tech/addrinuse.html

 but i have logged out and again logged in, but still the problem is not solved
 can somebody give me solution for this

and you're sure that nobody else on this computer is running a process
that's using the same port?  on most platforms, you can use netstat to
list all active connections and ports.

/F 



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


RE: script to automate GUI application (newbie)

2005-01-18 Thread Tim Golden
[bogdan romocea]
| I have a GUI application (Windows; apparently written in Java) which I
| want to use through a script (without a mouse or keyboard). First, one
| of several buttons needs to be clicked (no keyboard shortcuts
| available, but I can measure the coordinates in pixels from the top
| left corner of the window to the center of the button to be clicked).
| Then, a window with a few drop-down lists pops up - I have to 
| make some
| choices and click OK (it's possible to navigate from one drop-down to
| the next with Tab, and hit Enter for OK). 
| 
| I want to run the script above from code (if this then click ... and
| OK) and perhaps by means of several desktop shortcuts (one shortcut
| for each set of GUI inputs). 
| 
| Is such a script possible? If yes, how do I get there? I searched
| comp.lang.python but didn't find something directly applicable (or so
| it seemed to me - I'm a beginner). Directions (and sample code, if
| possible) will be warmly appreciated.

Have a look at WATSUP. I think it's the kind of thing you're after.

http://www.tizmoi.net/watsup/intro.html

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: how to find site-packages path

2005-01-18 Thread Eric S. Johansson
Michael Hoffman wrote:
Philippe C. Martin wrote:
I am using my own install script for my software and am looking for a
flawless way to figure out where python, and more specifically
site-packages is installed.

The flawless way would be to use distutils. In fact you shouldn't even
need your own install script--it should do most of the work for you.
can distutils install in any directory?  for example, an application 
which has its own modules should be completely isolated from the general 
Python module namespace.  how would you make distutils install in a 
completely separate directory hierarchy and not touch any of the 
site-packages directories or files?

it looked like that was impossible from the documentation which is why I 
wrote my own installer.

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


Re: Integration with java (Jpype vs. JPE)

2005-01-18 Thread Joachim Boomberschloss
Thanks for the info. I understand now the background
and possibilities, but would like to refine my query:
As I see it, writing a hybrid Java/Python application
faces approximately three possibilities: (i) write the
core in Java and do some scripting with Jython, (ii)
write independent code in Java and in Python, and
integrate using JPype (or similar), using Python also
as a glue layer, (iii) write independent code in Java
and in Python, and integrate using a neutral
technology.

Since much of the code in my project is already
written, I am considering options ii and iii. This is
how I perceive the work required in each case:

Option ii would enable writing independent packages in
Python and Java, and will require a glue layer in
Python consisting of general administration and
wrappers around Java packages written using JPype. I
don't yet have a clear perception of how difficult it
would be to make such wrappers, or to put my faith in
JPype at this stage.

Option iii would also enable writing independent
packages in Python and Java, but its glue layer will
be distributed between Python and Java using Jython
and Pyro (I chose Pyro because it works in both
CPython and Jython, and can be used to communicate
between them). This would (to the best of my
understanding) enable a smoother interface between
Java and Python, but will probably complicate somewhat
the glue layer, both because it would use networking
to communicate, and because it would probably involve
taking special measures to overcome the differences
between CPython and Jython (since the glue layer will
need to run on both of them).

Joe.
--- Cameron Laird [EMAIL PROTECTED] wrote:

 In article [EMAIL PROTECTED],
 Jon Perez  [EMAIL PROTECTED] wrote:
 Can someone summarize in a nutshell what is the
 difference between JPype and JPE?
 
 JPE's the original.  It provided more functionality
 than JPype has
 achieved so far, I believe (though that could change
 any day).  I
 think no one now maintains JPE.
 
 Someone really ought to include a couple of
 sentences to that effect
 on the front page of URL: http://jpype.sf.net/ .
 -- 
 http://mail.python.org/mailman/listinfo/python-list
 





__ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Advice to a Junior in High School?

2005-01-18 Thread Peter Hansen
collegebabe2004 wrote:
I would suggest taking Japanese because you will have to work with them
eventually if you do decide to choose compsci as your proffesion.
Over what time frame should I expect this requirement to become
critical?  I'd like to know so I can reserve a spot in the next
Japanese course in the area, if you think it's really urgent.
Also, should I plan on adopting various aspects of the Japanese
culture as well, or will a mastery of the language be sufficient?
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: MemoryError with parser.suite and wrong encoding declaration

2005-01-18 Thread Sylvain Thenault
On Tue, 18 Jan 2005 16:16:32 +0100, Thomas Heller wrote:

 Sylvain Thenault [EMAIL PROTECTED] writes:
 
 Hi there !
 I've noticed the following problem with python = 2.3 (actually 2.3.4
 and 2.4):

 [EMAIL PROTECTED]:test$ python
 Python 2.3.4 (#2, Sep 24 2004, 08:39:09) [GCC 3.3.4 (Debian 1:3.3.4-12)]
 on linux2 Type help, copyright, credits or license for more
 information.
 import parser
 parser.suite('# -*- coding: IBO-8859-1 -*-')
 Traceback (most recent call last):
   File stdin, line 1, in ?
 MemoryError
 parser.suite('# -*- coding: ISO-8859-1 -*-')
 parser.st object at 0xb7e5e060

 Shouldn't parser.suite just ignore the wrong encoding declaration, or at
 least raise a more appropriate exception. IMHO the first solution would
 be better, since that's the behaviour of the (C) python interpreter.
 
 Ignore the wrong declaration?  All Python's that I have (on windows, at
 least) raise a SyntaxError:
 
   File x.py, line 1
 SyntaxError: 'unknown encoding: IBO-8859-1'

hum, right (with python = 2.3 which is the first release using those
declaration...). I was sure to have checked this but I've obviously
missed something. Maybe the fact that being able to parse it anyway is
the solution I wish has driven me to write this ;) I would like this
behaviour so that pylint can check a module with a wrong encoding
declaration anyway. But at least, SyntaxError would be better than
MemoryError.

 See also:
 
 http://www.python.org/sf/979739

thanks
-- 
Sylvain Thénault   LOGILAB, Paris (France).

http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org


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


Re: script to automate GUI application (newbie)

2005-01-18 Thread Grig Gheorghiu
Bogdan,

If your app is written in Java, take a look at Marathon
(http://marathonman.sourceforge.net/). It uses Jython as its scripting
language and it's pretty smart about how it does automation (i.e. it
doesn't look at screen coordinates, but at control names). It also
offers a capture/replay functionality, and it automatically builds the
Jython script that drives your flow of actions. You can then edit and
enhance the script manually.

Grig

bogdan romocea wrote:
 Dear Python experts,

 I have a GUI application (Windows; apparently written in Java) which
I
 want to use through a script (without a mouse or keyboard). First,
one
 of several buttons needs to be clicked (no keyboard shortcuts
 available, but I can measure the coordinates in pixels from the top
 left corner of the window to the center of the button to be clicked).
 Then, a window with a few drop-down lists pops up - I have to make
some
 choices and click OK (it's possible to navigate from one drop-down to
 the next with Tab, and hit Enter for OK).

 I want to run the script above from code (if this then click ... and
 OK) and perhaps by means of several desktop shortcuts (one shortcut
 for each set of GUI inputs).

 Is such a script possible? If yes, how do I get there? I searched
 comp.lang.python but didn't find something directly applicable (or so
 it seemed to me - I'm a beginner). Directions (and sample code, if
 possible) will be warmly appreciated.

 Thank you,
 b.






 __
 Do you Yahoo!?
 Yahoo! Mail - Easier than ever with enhanced search. Learn more.
 http://info.mail.yahoo.com/mail_250

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


simultaneous multiple requests to very simple database

2005-01-18 Thread Eric S. Johansson
I have an application where I need a very simple database, effectively a 
very large dictionary.  The very large dictionary must be accessed from 
multiple processes simultaneously.  I need to be able to lock records 
within the very large dictionary when records are written to.  Estimated 
number of records will be in the ballpark of 50,000 to 100,000 in his 
early phase and 10 times that in the future.  Each record will run about 
100 to 150 bytes.

speed is not a huge concern although I must complete processing in less 
than 90 seconds.  The longer the delay however the greater number of 
processes must be running parallel in order to keep the throughput up. 
It's the usual trade-off we have all come to know and love.

it is not necessary for the dictionary to persist beyond the life of the 
parent process although I have another project coming up in which this 
would be a good idea.

at this point, I know they will be some kind souls suggesting various 
SQL solutions.  While I appreciate the idea, unfortunately I do not have 
time to puzzle out yet another component.  Someday I will figure it out 
because I really liked what I see with SQL lite but unfortunately, today 
is not that day (unless they will give me their work, home and cell 
phone numbers so I can call when I am stuck. ;-)

So the solutions that come to mind are some form of dictionary in shared 
memory with locking semaphore scoreboard or a multithreaded process 
containing a single database (Python native dictionary, metakit, gdbm??) 
and have all of my processes speak to it using xmlrpc which leaves me 
with the question of how to make a multithreaded server using stock xmlrpc.

so feedback and pointers to information would be most welcome.  I'm 
still exploring the idea so I am open to any and all suggestions (except 
maybe SQL :-)

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


Re: Advice to a Junior in High School? [OT]

2005-01-18 Thread TZOTZIOY
On Tue, 18 Jan 2005 11:04:01 -0500, rumours say that Peter Hansen
[EMAIL PROTECTED] might have written:

collegebabe2004 wrote:
 I would suggest taking Japanese because you will have to work with them
 eventually if you do decide to choose compsci as your proffesion.

[Peter]
Over what time frame should I expect this requirement to become
critical?  I'd like to know so I can reserve a spot in the next
Japanese course in the area, if you think it's really urgent.
Also, should I plan on adopting various aspects of the Japanese
culture as well, or will a mastery of the language be sufficient?

I think having a katana next to your keyboard will suffice to give the
*impression* you have mastered enough of the japanese culture, Peter :)
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


makepy crashing

2005-01-18 Thread markscottwright
Has anyone sucessfully run makepy and Microsoft Word Object Library
(9.0)?  Mine crashes under XP Pro and Python 2.4.

It only seems to be word that has the problem, though.

I get a dialog that says that pythonwin.exe has crashed:
AppName: pythonwin.exe   AppVer: 0.0.0.0 ModName: ntdll.dll
ModVer: 5.1.2600.1217Offset: 96f9

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


Re: [perl-python] 20050118 keyed list

2005-01-18 Thread Tassilo v. Parseval
Also sprach Jürgen Exner:

 Xah Lee wrote:

 © %a = ('john',3, 'mary', 4, 'jane', 5, 'vicky',7);
 © use Data::Dumper qw(Dumper);
 © print Dumper \%a;

 Wow, my compliments. The very first time that using Data::Dumper actually 
 may do something useful (formats the data more nicely). Still, why you are 
 passing a reference is beyond me.

How else would you use 'Dumper' on a hash?

Tassilo
-- 
$_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: simultaneous multiple requests to very simple database

2005-01-18 Thread Robert Brewer
Eric S. Johansson wrote:
 I have an application where I need a very simple database, 
 effectively a very large dictionary.  The very large
 dictionary must be accessed from multiple processes
 simultaneously.  I need to be able to lock records within
 the very large dictionary when records are written to.

Just to clarify, you want shared-read until a write, at which point you
want to lock just the item being written? Or would page or table locking
be acceptable at that point?


Robert Brewer
MIS
Amor Ministries
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


One-Shot Property?

2005-01-18 Thread Kevin Smith

I have many cases in my code where I use a property for calculating a 
value on-demand.  Quite a few of these only need to be called once.  
After that the value is always the same.  In these properties, I set a 
variable in the instance as a cached value and return that value on 
subsequent calls.  It would be nice if there was a descriptor that would 
do this automatically.  Actually, what would be really nice is if I 
could replace the property altogether and put the calculated value in 
its place after the first call, but the property itself prevents me from 
doing that.  Is this possible?

-- 
Kevin Smith
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [perl-python] 20050118 keyed list

2005-01-18 Thread Reinhold Birkenfeld
Jay Tilton wrote:

: # the syntax of keyed list in Perl is too complex
: # to be covered in a short message.

JFTR: keyed lists are called dictionaries in Python.

 
 [1]Message-ID: [EMAIL PROTECTED]
 

This guy's wish-wash is starting to be funny, after all!

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


Tkinter in thread hangs on windows but not on Linux

2005-01-18 Thread Philippe C. Martin
Hi,

I need to pop-up in a modless manner some windows from an existing
Tkinter loop. The following code works OK under Linux: the second window
opens, shows the information, and quits cleanly when destroyed. However,
under windows, I get the second window without the content (so I hang in
run I guess), and both the thread and the calling process hang.

Any clue ?

Thanks
Philippe





#***
class SC_DOCS(threading.Thread):
  __m_smg = None
  __m_title = None
  def __init__(self,p_msg,p_title):
threading.Thread.__init__(self)
self.__m_msg = p_msg
self.__m_title = p_title

#***
  def run (self):
l_r = Tk()
l_r.title(self.__m_title)
l_f = Frame(l_r)
l_f.pack(side=TOP, expand=YES, fill=BOTH)
l_st = ScrolledText(l_f)
l_st.pack(side=TOP, expand=YES, fill=BOTH)
l_st.insert(END,self.__m_msg)

l_r.mainloop()


.
.
.

l_d = SC_DOCS('A MESSAGE', 'A TITLE')
l_d.start()


.
.
.
-- 
***
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
***

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


Re: [perl-python] 20050118 keyed list

2005-01-18 Thread Reinhold Birkenfeld
Jürgen Exner wrote:

 © # see perldoc perldata for an unix-styled course.
 
 Excuse me? Do you mind explaining where exactly perldata is Unix-styled?

Remember: Perl == Unix == Satan.

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


Re: simultaneous multiple requests to very simple database

2005-01-18 Thread Eric S. Johansson
Robert Brewer wrote:
Eric S. Johansson wrote:
I have an application where I need a very simple database, 
effectively a very large dictionary.  The very large
dictionary must be accessed from multiple processes
simultaneously.  I need to be able to lock records within
the very large dictionary when records are written to.

Just to clarify, you want shared-read until a write, at which point you
want to lock just the item being written? Or would page or table locking
be acceptable at that point?
just the item/record.  I'm doing arrival rate calculations.  each record 
contains a set of arrival times and I am rewriting the record every time 
a new entry arrives.  complete page or table locking will work in the 
sense that it will prevent collisions but it will have an increasing 
impact as load and simultaneous table but not record accesses increase.

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


Re: One-Shot Property?

2005-01-18 Thread Dave Benjamin
Kevin Smith wrote:
I have many cases in my code where I use a property for calculating a 
value on-demand.  Quite a few of these only need to be called once.  
After that the value is always the same.  In these properties, I set a 
variable in the instance as a cached value and return that value on 
subsequent calls.  It would be nice if there was a descriptor that would 
do this automatically.  Actually, what would be really nice is if I 
could replace the property altogether and put the calculated value in 
its place after the first call, but the property itself prevents me from 
doing that.  Is this possible?
I was going to recommend taking a look at the memoize example on the 
Python wiki, but it seems to be missing at the moment. In any case, 
here's the URL:

http://www.python.org/moin/PythonDecoratorLibrary
There are also a few examples on the Cookbook, like this one:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/325205
It shouldn't be too difficult to adapt this technique so that it can be 
used to create properties. I wouldn't bother replacing the property with 
an attribute unless you have a specific reason to do so (performance, 
perhaps).

HTH,
Dave
--
http://mail.python.org/mailman/listinfo/python-list


Re: script to automate GUI application (newbie)

2005-01-18 Thread Jim

It sounds like a case for the Expect program, to me.  Try Google-ing
for Expect.  If you are looking for a Python approach, then try
googling for Expect Python.

Jim

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


Re: One-Shot Property?

2005-01-18 Thread Daniel Dittmar
Kevin Smith wrote:
I have many cases in my code where I use a property for calculating a 
value on-demand.  Quite a few of these only need to be called once.  
After that the value is always the same.  In these properties, I set a 
variable in the instance as a cached value and return that value on 
subsequent calls.  It would be nice if there was a descriptor that would 
do this automatically.  Actually, what would be really nice is if I 
could replace the property altogether and put the calculated value in 
its place after the first call, but the property itself prevents me from 
doing that.  Is this possible?
If you use the old-fashioned __getattr__ method instead of properties. 
__getattr__ gets called only if the value can't be found in the instance 
dictionary.

def __getattr__ (self, attrname):
try:
method = getattr (self, 'calculate_' + attrname)
except AttributeError:
raise AttributeError, attrname
value = method ()
setattr (self, attrname, value)
return value
And probably also through metaclasses. And decorators.
Daniel
--
http://mail.python.org/mailman/listinfo/python-list


Re: generator expressions: performance anomaly?

2005-01-18 Thread Jeremy Bowers
On Tue, 18 Jan 2005 14:05:15 +, Antoon Pardon wrote:
 I don't see how generating byte code for a = 9; when seeing the
 expression a = 3 + 6, would be a problem for non-functional
 languages.

To answer nearly every post you've made to this thread, because Python
doesn't have the resources to program to special cases.

And as is often the case in this sort of discussion, sure, adding this
might be only a little work, but there's thousands of enhancements of the
same general work level and performance gain. So remember you're not just
espousing this particular enhancement, you're implicitly arguing for the
entire class (because there is nothing to discriminate in the argument
this is fairly easy between this particular feature on your mind today
and the other thousands of such features).

To address your point more specifically, you can do this subexpression
elimination to the extent that your expression is a purely functional one.
a = 3 + 6, while written in an imperative language and setting a
variable in an imperative manner, has a functional subexpression 3 +
6, that has no side-effects, etc., so the compiler could reduce it if it
knew how. (In Python, that's a function call, but since you can't change
__add__ on ints, you could do this, although there's still some special
casing you're doing that will ripple unpleasantly through the code.) But
as soon as you call any sort of method or function, you're done.

Ultimately, the use is fairly limited; I can't imagine the execution time
saved would reach the time of implementation for weeks after a release,
even aggregating across all Python use in the world, and real time
gained (i.e., time useful to a human) would probably never add up to the
implementation time. So why bother? That's a horrid trade off when there
are so many other real gains to be had.

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


Re: ANNOUNCE: Altova ... blah blah blah

2005-01-18 Thread Irmen de Jong
Altova Announcements wrote:
Altova Unveils .
[spam]
Well now, I didn't like their products very much already,
but this spam has certainly made them drop another few
steps down on my scale. Hmpf.
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: One-Shot Property?

2005-01-18 Thread Leif K-Brooks
Kevin Smith wrote:
I have many cases in my code where I use a property for calculating a 
value on-demand.  Quite a few of these only need to be called once.  
After that the value is always the same.  In these properties, I set a 
variable in the instance as a cached value and return that value on 
subsequent calls.  It would be nice if there was a descriptor that would 
do this automatically.  Actually, what would be really nice is if I 
could replace the property altogether and put the calculated value in 
its place after the first call, but the property itself prevents me from 
doing that.
This should do it:
class CachingProperty(object):
def __init__(self, attr_name, calculate_function):
self._name = attr_name
self._calculate = calculate_function
def __get__(self, obj, type=None):
if obj is None:
return self
else:
value = self._calculate(obj)
setattr(obj, self._name, value)
return value
And example code:
 class Foo(object):
... def calculate_value(self):
... print 'Calculating...'
... return 42
... foo = CachingProperty('foo', calculate_value)
...
 bar = Foo()
 bar.__dict__
{}
 bar.foo
Calculating...
42
 bar.foo # Notice that the print statement doesn't run this time
42
 bar.__dict__
{'foo': 42}
--
http://mail.python.org/mailman/listinfo/python-list


Re: Integration with java (Jpype vs. JPE)

2005-01-18 Thread Irmen de Jong
Joachim Boomberschloss wrote:
Option iii would also enable writing independent
packages in Python and Java, but its glue layer will
be distributed between Python and Java using Jython
and Pyro (I chose Pyro because it works in both
CPython and Jython, and can be used to communicate
between them).
Please note that currently it is not possible to use Pyro
as a server in Jython. Only as a client.
Also; last time I checked there were some bugs in the Jython
compiler that were triggered by Pyro's code (parts of it
would give a compile error).
See http://www.razorvine.net/python/PyroAndJython
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Print to Windows default Printer

2005-01-18 Thread Samantha
I am new to Python and I am having considerable trouble trying to print 
(using a simple script) to the default printer rather than the screen.
Thanks for any help.
S 


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


Re: Print to Windows default Printer

2005-01-18 Thread Peter Hansen
Samantha wrote:
I am new to Python and I am having considerable trouble trying to print 
(using a simple script) to the default printer rather than the screen.
Thanks for any help.
Please show some example code, and explain in more detail
what you are trying to do.  There are perhaps *dozens*
of different ways to do printing under Windows, and we
can't guess which approach you are trying, nor which
might be suitable for your needs.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


pickling extension class

2005-01-18 Thread harold fellermann
Hi all,
I have a problem pickling an extension class. As written in the 
Extending/Embedding Manual, I
provided a function __reduce__ that returns the appropreate tuple. This 
seams to work fine,
but I still cannot pickle because of the following error:

 from model import hyper
 g = hyper.PeriodicGrid(4,4,1)
 g.__reduce__()
(type 'hyper.PeriodicGrid',(4.,4.,1.))
 import pickle
 pickle.dump(g,file(test,w))
Traceback (most recent call last):
  File pickle_test.py, line 5, in ?
pickle.dump(g,file(test,w))
  File /sw/lib/python2.4/pickle.py, line 1382, in dump
Pickler(file, protocol, bin).dump(obj)
  File /sw/lib/python2.4/pickle.py, line 231, in dump
self.save(obj)
  File /sw/lib/python2.4/pickle.py, line 338, in save
self.save_reduce(obj=obj, *rv)
  File /sw/lib/python2.4/pickle.py, line 414, in save_reduce
save(func)
  File /sw/lib/python2.4/pickle.py, line 293, in save
f(self, obj) # Call unbound method with explicit self
  File /sw/lib/python2.4/pickle.py, line 760, in save_global
raise PicklingError(
pickle.PicklingError: Can't pickle type 'hyper.PeriodicGrid': it's 
not found as hyper.PeriodicGrid
 dir(hyper)
['Dir', 'Neighbors', 'PeriodicGrid', 'PeriodicPos', '__doc__', 
'__file__', '__name__', 'refcount']
 hyper.PeriodicGrid
type 'hyper.PeriodicGrid'

So pickle complains about the class PeriodicGrid not being found in the 
module hyper, but a dir()
proves that python can find it. Has anyone an idea what's going wrong 
here?

Any help appreceated,
- harold -
--
What is mind? -- Doesn't matter.
What is matter? -- Never mind!
--
--
http://mail.python.org/mailman/listinfo/python-list


Re: hex notation funtion

2005-01-18 Thread Irmen de Jong
tertius wrote:
Hi,
Is there a builtin function that will enable me to display the hex 
notation of a given binary string? (example below)
Does this help:
 hello.encode(hex)
'68656c6c6f'
 deadbeef.decode(hex)
'\xde\xad\xbe\xef'
?
--Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Re: hex notation funtion

2005-01-18 Thread Philippe C. Martin
Would that do it?

for i in my_byte_string:
   = atoi(binascii.hexlify(i),16)

Regards,

Philippe





On Tue, 18 Jan 2005 20:43:44 +0200, tertius wrote:

 Hi,
 
 Is there a builtin function that will enable me to display the hex 
 notation of a given binary string? (example below)
 
 many thanks
 Tertius
 
 
 
 ()  02 11 00 00 46 5A 1A 82  02 11 00 39 36 39 33 39 
 FZ.96939
 
 0016(0010)  36 39 33 00 0A 30 33 37  34 34 39 35 38 25 DD 01 
 693..03744958%..

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


Re: Print to Windows default Printer

2005-01-18 Thread Samantha
Thanks for he quick response. This is small sample code from a PSP script to 
get Exit Info of a digital image. I want to print to the printer rather than 
the screen.
---
Info = App.Do( Environment, 'ReturnImageInfo' )

print
print 'Input Device Information'
for key in InputDeviceKeys:
if OnlyExistingData == 0 or Info[key] != '':
print key, ': ', Info[key]
print

print 'Artist Information'
for key in ArtistKeys:
if OnlyExistingData == 0 or Info[key] != '':
print key, ': ', Info[key]
print
--
Is there an easy way to do it. Right now I  copy and paste to a txt file 
then print the file?
S

Peter Hansen [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Samantha wrote:
 I am new to Python and I am having considerable trouble trying to print 
 (using a simple script) to the default printer rather than the screen.
 Thanks for any help.

 Please show some example code, and explain in more detail
 what you are trying to do.  There are perhaps *dozens*
 of different ways to do printing under Windows, and we
 can't guess which approach you are trying, nor which
 might be suitable for your needs.

 -Peter 


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


Re: how to find site-packages path (Michael Hoffman) - use distutils

2005-01-18 Thread vincent wehren
Philippe C. Martin wrote:
Why would you want to copy any *.pyc instead of compiling them on
site?

I know that sounds terrible to the open source community, 

but I do not
intend to release the source code for my product 
That's not why I asked. I'll leave the politics up to you. The thing is, 
that the path info gets cached in the *.pyc file. This may lead to 
confusing tracebacks - might they occur - when the user does not install 
to the exact same drive/path as you did.

Additionally: if you *do* want to distribute *.pyc only, I personally 
wouldn't find it terribly neat if you stuck those into the site-packages 
directory of my Python installation. I - for one - would want to know 
what kind of source code you place along *my* sys.path.

Maybe you should consider using py2exe to distribute - keeping your 
*.pyc out of the user's Python directory tree, if any, entirely. Also, 
you may want to consider using Inno Setup as deployment tool (if Windows 
is your target platform). Using distutils for a *.py-less installer 
seems pretty pointless.


Regards,
--
Vincent Wehren
- pls go to
philippecmartin.com/applications.html for my _small_ contributions :-))

Regards,
Philippe

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


Re: how to find site-packages path (Michael Hoffman) - use distutils

2005-01-18 Thread Philippe C. Martin
I actually target Unix and windows so pyexe won't cut it I'm afraid -
same issue with Inno.

As far as the site-package target, I don't fully understand your
relunctancy. Just as my potential users might not own a compiler, they
might not be computer proficient enough to easily understand how to
change the sys.path. So until I have found a clean cross platform
solution I'm going to have to stick to site-packages.

Best regards,

Philippe




-- 
***
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
***

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


Re: How to prevent the script from stopping before it should

2005-01-18 Thread python

Fredrik Lundh wrote:
 Steve Holden wrote:

  You will need to import the socket module and then call
socket.setdefaulttimeout() to ensure that
  communication with non-responsive servers results in a socket
exception that you can trap.

 or you can use asynchronous sockets, so your program can keep
processing
 the sites that do respond at once while it's waiting for the ones
that don't.  for
 one way to do that, see Using HTTP to Download Files here:

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

 (make sure you read the second and third article as well)

Dear Fredrik Lundh,
Thank you for the link. I checked it. But I have not found an answer to
my question.
My problem is that I can not finish( sometimes) to download all pages.
Sometimes my script freezes and I can not do nothing but restart the
script from the last successfully downloaded web page. There is no
error saying that was an error. I do not know why; maybe the server is
programed to reduce the numbers of connection or there maybe  different
reasons.So, my idea was two threads. One master ,suprevising the slave
thread that would do downloading and if the slave thread stopped,
master thread would start another slave. Is it a good solution? Or is
there a better solution?
Thanks for help
Lad

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


Re: hex notation funtion

2005-01-18 Thread [EMAIL PROTECTED]
This will do it:
 int('1000', 2)
128
 hex(int('1000', 2))
'0x80'


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


Re: hex notation funtion

2005-01-18 Thread Grant Edwards
On 2005-01-18, tertius [EMAIL PROTECTED] wrote:

 Is there a builtin function that will enable me to display the hex 
 notation of a given binary string? (example below)

' '.join('%02x' % ord(b) for b in s)

-- 
Grant Edwards   grante Yow!  This is a NO-FRILLS
  at   flight -- hold th' CANADIAN
   visi.comBACON!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickling extension class

2005-01-18 Thread Alex Martelli
harold fellermann [EMAIL PROTECTED] wrote:

File /sw/lib/python2.4/pickle.py, line 760, in save_global
  raise PicklingError(
 pickle.PicklingError: Can't pickle type 'hyper.PeriodicGrid': it's 
 not found as hyper.PeriodicGrid
   dir(hyper)
 ['Dir', 'Neighbors', 'PeriodicGrid', 'PeriodicPos', '__doc__', 
 '__file__', '__name__', 'refcount']
   hyper.PeriodicGrid
 type 'hyper.PeriodicGrid'
 
 So pickle complains about the class PeriodicGrid not being found in the
 module hyper, but a dir()
 proves that python can find it. Has anyone an idea what's going wrong
 here?

These symptomps are pretty weird -- let's try to pin things down a bit
more.  The relevant few lines of pickle.py are:

try:
__import__(module)
mod = sys.modules[module]
klass = getattr(mod, name)
except (ImportError, KeyError, AttributeError):
raise PicklingError(

so, could you please edit your pickle.py to provide VASTLY more info,
say:

try:
print 'Here it goes...:'
_xx = __import__(module)
print '  __import__ says: %r' % (_xx,)
mod = sys.modules[module]
print '  in sys.modules: %r' % (mod,)
klass = getattr(mod, name)
print '  klass is: %r' % (klass,)
except (ImportError, KeyError, AttributeError), _xx:
print '  OOPS, error (%s): %s' % (_xx.__class__, _xx)
raise PicklingError(

and let us know exactly what his modified pickle.py outputs...?


Thanks,

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


Re: pickling extension class

2005-01-18 Thread harold fellermann
On 18.01.2005, at 20:31, Alex Martelli wrote:
harold fellermann [EMAIL PROTECTED] wrote:
   File /sw/lib/python2.4/pickle.py, line 760, in save_global
 raise PicklingError(
pickle.PicklingError: Can't pickle type 'hyper.PeriodicGrid': it's
not found as hyper.PeriodicGrid
dir(hyper)
['Dir', 'Neighbors', 'PeriodicGrid', 'PeriodicPos', '__doc__',
'__file__', '__name__', 'refcount']
hyper.PeriodicGrid
type 'hyper.PeriodicGrid'
So pickle complains about the class PeriodicGrid not being found in 
the
module hyper, but a dir()
proves that python can find it. Has anyone an idea what's going wrong
here?
These symptomps are pretty weird -- let's try to pin things down a bit
more.  The relevant few lines of pickle.py are:
try:
__import__(module)
mod = sys.modules[module]
klass = getattr(mod, name)
except (ImportError, KeyError, AttributeError):
raise PicklingError(
so, could you please edit your pickle.py to provide VASTLY more info,
[...]
and let us know exactly what his modified pickle.py outputs...?

Here it goes...:
 OOPS, error (exceptions.ImportError): No module named hyper
Traceback (most recent call last):
  File pickle_test.py, line 5, in ?
pickle.dump(g,file(test,w))
  File /Volumes/space/Users/harold/uni/pace/ono/pickle.py, line 1387, 
in dump
Pickler(file, protocol, bin).dump(obj)
  File /Volumes/space/Users/harold/uni/pace/ono/pickle.py, line 231, 
in dump
self.save(obj)
  File /Volumes/space/Users/harold/uni/pace/ono/pickle.py, line 338, 
in save
self.save_reduce(obj=obj, *rv)
  File /Volumes/space/Users/harold/uni/pace/ono/pickle.py, line 414, 
in save_reduce
save(func)
  File /Volumes/space/Users/harold/uni/pace/ono/pickle.py, line 293, 
in save
f(self, obj) # Call unbound method with explicit self
  File /Volumes/space/Users/harold/uni/pace/ono/pickle.py, line 765, 
in save_global
raise PicklingError(
pickle.PicklingError: Can't pickle type 'hyper.PeriodicGrid': it's 
not found as hyper.PeriodicGrid

I have noticed that the error does not occur, when the imported module 
('hyper') is in the same directory as the script that pickles. When it 
is imported from a subpackage (like in the code
I sent you) it goes wrong.

- harold -
--
Reality is for people who lack imagination.
--
http://mail.python.org/mailman/listinfo/python-list


Re: hex notation funtion

2005-01-18 Thread Grant Edwards
On 2005-01-18, Grant Edwards [EMAIL PROTECTED] wrote:
 On 2005-01-18, tertius [EMAIL PROTECTED] wrote:

 Is there a builtin function that will enable me to display the hex 
 notation of a given binary string? (example below)

 ' '.join('%02x' % ord(b) for b in s)

Oops.  Should be:

' '.join(['%02x' % ord(b) for b in s])

-- 
Grant Edwards   grante Yow!  .. Am I in a SOAP
  at   OPERA??
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fuzzy matching of postal addresses

2005-01-18 Thread [EMAIL PROTECTED]
I think you guys are missing the point. All you would need to add to
get a 'probable match' is add another search that goes through the 10%
that didnt get matched and do a endswith search on the data. From the
example data you showed me, that would match a good 90% of the 10%,
leaving you with a 1% that must be hand matched. You would have to
combine this idea with Jeff Shannon's idea to make it work more
efficiently.

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


  1   2   >