[ANN] Data Plotting Library DISLIN for Python 2.4/Windows

2004-12-02 Thread Helmut Michels
DISLIN is a high-level and easy to use plotting library for
displaying data as curves, bar graphs, pie charts, surfaces,
contours and maps.
I have created a new DISLIN distribution that supports the
final Python version 2.4 on Windows. The distribution is
available from the DISLIN home page
http://www.dislin.de
--
Helmut Michels
Max Planck Institute for Solar System Research
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


"encoding specified in XML declaration is incorrect"

2004-12-02 Thread Gustaf Liljegren
I'm using xml.sax.parseString to read an XML file. The XML file contains 
a few words in Russian, and is encoded in UTF-8 using C#. In the example 
below, MyParser() is my SAX ContentHandler class. My first try was:

f = open('words.xml', 'r')
s = f.read()
xml.sax.parseString(s, MyParser())
This produced the following error:
Traceback (most recent call last):
  File "sax5.py", line 87, in ?
xml.sax.parseString(s, MyParser())
  File "D:\Python\lib\xml\sax\__init__.py", line 49, in parseString
parser.parse(inpsrc)
  File "D:\Python\lib\xml\sax\expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
  File "D:\Python\lib\xml\sax\xmlreader.py", line 125, in parse
self.close()
  File "D:\Python\lib\xml\sax\expatreader.py", line 218, in close
self._cont_handler.endDocument()
  File "sax5.py", line 81, in endDocument
f.write(header + self.all + footer)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 
745-751: ordinal not in range(128)

The XML declaration should be enough to tell the encoding. Anyway, I 
read some previous posts, and found that the unicode() function may help:

f = open('words.xml', 'r')
s = f.read()
u = unicode(s, "utf-8")
xml.sax.parseString(u, MyParser())
But I just got another error:
Traceback (most recent call last):
  File "sax5.py", line 87, in ?
xml.sax.parseString(u, MyParser())
  File "D:\Python\lib\xml\sax\__init__.py", line 49, in parseString
parser.parse(inpsrc)
  File "D:\Python\lib\xml\sax\expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
  File "D:\Python\lib\xml\sax\xmlreader.py", line 123, in parse
self.feed(buffer)
  File "D:\Python\lib\xml\sax\expatreader.py", line 211, in feed
self._err_handler.fatalError(exc)
  File "D:\Python\lib\xml\sax\handler.py", line 38, in fatalError
raise exception
xml.sax._exceptions.SAXParseException: :1:30: encoding 
specified in XML declaration is incorrect

I see nothing wrong with my XML declaration:

And the file is indeed in UTF-8 (or I wouldn't be able to open it in IE 
and FF). I tried removing the BOM, but it didn't help. What more can be 
wrong?

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


Re: Delphi underrated, IDE clues for Python

2004-12-02 Thread johng2001
Yes! Boa goes a long way. I have been using it for almost 2 1/2 years
now. But it does not come close to the comfort of Delphi. But then of
course, Delphi is not just a WYSIWYG GUI designer. VCL is very advanced
compared to GUI toolkits available for Python. The community has over
the years created an amazing number of open source components. Just go
to torry.net to find literally thousands of good quality freebies (not
to mention commercial GUI components). How many third party controls do
we see for wxPython?

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


Re: Microsoft Patents 'IsNot'

2004-12-02 Thread johng2001
All the VB fans I know have not experienced Delphi. They just don't
know what they are missing. I am sure there are people who actually
chose VB, but not any one I know. When I marvelled at VB myself, it was
back when I myself was unaware of Delphi/C++ Builder. I used to think
C++ programming on Windows had to be with VC++ and MFC and VB was the
only sane choice for most of my apps. When I first tried Delphi, it
only took me a couple of hours to realize that I will never use VB
again.

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


Re: Python 2.4 and Tkinter

2004-12-02 Thread Eric Brunel
Jeffrey Barish wrote:
[snip]
Here's what I get when I import Tkinter at a python prompt:
[EMAIL PROTECTED]:~$ python
Python 2.4 (#1, Nov 30 2004, 08:58:13)
[GCC 3.2.3 20030316 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import Tkinter
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/local/lib/python2.4/lib-tk/Tkinter.py", line 38, in ?
import _tkinter # If this fails your Python may not be configured
for Tk
ImportError: No module named _tkinter
I tried make clean and make.  Same result.  Ah, now I see that the
output from make includes:
INFO: Can't locate Tcl/Tk libs and/or headers
Aren't the libs and headers included in Python-2.4.tgz?
On Windows, the Python distribution does include Tkinter and tcl/tk. It's 
different on Unices (including Linux): since tcl/tk is very often installed by 
default, it is not included in the Python distribution.

Have you looked for libraries / header files in /usr/lib and /usr/include? This 
is usually where they go when you install them with Linux. Since you mentionned 
you upgraded to Python 2.4, I assume you had a working installation of a 
previous Python version. So the tcl/tk libraries and header files must be there 
somewhere. Did you look at your Modules/Setup for the older Python? If Tkinter 
was working with this version, the setup for the _tkinter module should use the 
correct paths.

HTH
--
- Eric Brunel  -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 2)

2004-12-02 Thread Robin Becker
Cameron Laird wrote:
QOTW:  "... why does Microsoft try so hard to protect its sources?"
.
2.4 is final, buildable under Windows in at least a couple 
of ways, improved, ...
http://www.brunningonline.net/simon/blog/archives/001657.html

asyncore, Twisted, the Python core...--do you understand how
they relate to TLS, serial-port usage, GUI-oriented event
processing, and so on?
http://groups.google.com/groups?th=752ebdb8b57fa3f3
Ian Bicking and others describe the meaning of "Python 3000".
http://groups.google.com/groups?frame=left&th=8f9b6a3959888f2b
Reading without blocking is possible--with care.
http://groups.google.com/groups?frame=left&th=78654cfc06d2fbbe
Josiah Carlson and Paul McGuire explain decorators.
http://groups.google.com/groups?th=5bfb80b43887bc1f
Nick Coghlan knows sick ways to spell "file".
http://groups.google.com/groups?frame=right&th=e562a771d1c827c9
Python works in Frontier.
http://radio.weblogs.com/0100039/2004/11/30.html#a626

...
For some reason I can't seem to make use of the google links. When I use 
the above eg

http://groups.google.com/groups?frame=right&th=e562a771d1c827c9
I get a not found google page with url
http://groups-beta.google.com/groups?frame=right&th=e562a771d1c827c9
really wanted to spell file in a sickly manner :)
Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and
sponsor the "Python-URL!" project.


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


Re: M2Crypto for 2.4

2004-12-02 Thread elbertlev
//I will do it in the next day or two.

Me too!

Remember, this is a programmer and a manager
telling you his plan. :) But, if I do not, nobody in my department will
:(

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


Re: Python Win32 Silent Install

2004-12-02 Thread David Fraser
Thomas Heller wrote:
"Matt Gerrans" <[EMAIL PROTECTED]> writes:

Looks like the installer for the Win32 extensions has changed from Wise to 
distutils, so now my automated silent installations don't work anymore. 
Anyone know if the distutils binary installer can be run silently?I 
haven't been able find a command line reference for distutils binaries (I'm 
still sifting through http://www.python.org/doc/current/dist/, though...).

There are no command line options for the distutils created installer,
and silent installation is not possible.

What I've often done is combine other people's extensions into my 
package by importing stuff from their distutils setup scripts. Now that 
pywin32 is using distutils this should be possible too :-)

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


Re: pre-PEP generic objects

2004-12-02 Thread Nick Craig-Wood
Scott David Daniels <[EMAIL PROTECTED]> wrote:
>  Nick Craig-Wood wrote:
> > class Hash:
> > def __init__(self, **kwargs):
> > for key,value in kwargs.items():
> > setattr(self, key, value)
> > def __getitem__(self, x):
> > return getattr(self, x)
> > def __setitem__(self, x, y):
> > setattr(self, x, y)
> 
>  You can simplify this:
>  class Hash(object):
>   def __init__(self, **kwargs):
>   for key,value in kwargs.items():
>   setattr(self, key, value)
>   __getitem__ = getattr
>   __setitem__ = setattr

That doesn't work unfortunately...

>>> class Hash(object):
... def __init__(self, **kwargs):
... for key,value in kwargs.items():
... setattr(self, key, value)
... __getitem__ = getattr
... __setitem__ = setattr
... 
>>> h=Hash(a=1,b=2)
>>> h.a
1
>>> h['a']
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: getattr expected at least 2 arguments, got 1
>>>

I'm not exactly sure why though!
-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


installing wxPython on Linux and Windows

2004-12-02 Thread Peter Maas
Recently I replaced Win2k with Linux on my desktop computer. Using mostly
multi-platform software I thought this would be easy. It was not as
easy as expected getting wxPython to work. There seemed to be no SuSE RPM
so I installed from source. Here are my steps (gtk 2.4 was already
installed):
- Built wxWidgets (.configure --enable-unicode)
- Built wxPython (python setup.py install)
  error: "you should use wx-config program for compilation"
- Tried wx-config with various options
- Examined (huge) error output more closely: There was a message
  "Usage: wx-config [options]" right at the beginning
- Debugged setup.py: message was caused by wx-config option unicode=no
- Debugged config.py: wx-config option unicode=no was caused by UNICODE=0
- Set UNICODE=1, next build, error: compiler couldn't find stc.h
- Set BUILD_STC = 0 and some other BUILD_s as well
- I worked! started demo.py, splash screen started up and - error in
  demo's Main.py 'DemoCodeEditor' object has no attribute 'editor'
- Ah, STC is for StyledTextControl! set BUILD_STC = 1 again but how can
  I get styledTextControl?
- Downloaded/built scintilla, but where's the slot for scintilla.a?
- Realized that I had to build STC (wxWidgets' contribs) separately.
- Built wxPython, start demo.py - it worked FINALLY!
Took me with all tries and dead ends approx. 8 hours.
Same task on Win2k: download wxPython-setup.exe, double-click, done.
Took me approx. 1 minute. This strikes me. Why are some tasks so hard
on Linux and so easy on Windows? After all wxPython/Win and wxPython/Lin
are made by the same developers. My guess: the software deployment
infrastructure on Linux needs to be improved.
Disclaimer: I don't want to blame anyone here. wxPython is a fine
piece of software otherwise I wouldn't have tried so hard to get
it working.
--
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
--
http://mail.python.org/mailman/listinfo/python-list


Try to install PythonCard-0.8.1 on Python2.4

2004-12-02 Thread Werner Merkl
Hi,
I like to switch from Python 2.3.4 to 2.4. So I tried to reinstall
all apps I need. Most works fine When I start PythonCard I get following 
error:

  ---
  Setup PythonCard-0.8.1: PythonCard-0.8.1.win32.exe - Application Error
  ---
  The instruction at "0x77f69ecd" referenced memory at "0x0010".
  The memory could not be "written".
  Click on OK to terminate the program
  Click on CANCEL to debug the program
  ---
  OK   Cancel
  ---
Anybody any idea?
BTW: WxPython is not available for Python2.4 and I didn't manage to 
compile it... Could this be the reason?

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


Re: date diff calc

2004-12-02 Thread David Fraser
Peter Hansen wrote:
Tim Peters wrote:
[Peter Hansen]
I think Skip was intending that the format string be mandatory,
to avoid such ambiguity.  

It's still a bottomless pit -- ask Brett, who implemented the Python
strptime .  

True, I did overlook timezones at the time.
On the other hand, that's because *my* use cases for "simple"
fromstring() behaviour are all involving local time.  When
I'm interested in non-local time, I would be happy having
to specify that behaviour in a more complex manner.
OTOH, is that what people really want?  For all I know,
rfc822.getdate() or rfc822.getdate_tz() are what's really wanted, or
maybe some DWIM thing like Zope's date guessers.

To each his own, although I think there's a hope here that
for those who might need/want a really simple solution,
95% of people have this in mind (pseudo-code):
class datetime.date:
def fromstring(format, string):
ts = time.mktime(time.strptime(string, format))
return datetime.date.fromtimestamp(ts)
Hear, hear, the above would be great!
--
http://mail.python.org/mailman/listinfo/python-list


Re: A little threading problem

2004-12-02 Thread Alban Hertroys
Jeremy Jones wrote:
Alban Hertroys wrote:

Notify is called before thread B (in this case) hits the 
condAllowed.wait() piece of code.  So, it sits at that wait() for 
forever (because it doesn't get notified, because the notification 
already happened), waiting to be notified from the main thread, and the 
main thread is waiting on thread B (again, in this case) to call 
mainCond.notify().  This approach is a deadlock just wanting to happen 
(not waiting, because it already did happen).  What is it exactly that 
you are trying to accomplish?  I'm sure there is a better approach.
Hmm, I already learned something I didn't know by reading through my own 
version of the output.
I added an extra counter, printed before waiting in the for-loop in 
Main. My wrong assumption was that acquire() would block other threads 
from acquiring until release() was called. In that case the for-loop 
would wait 3 times (once for each thread), which is what I want. 
Unfortunately, in my output I see this:

T-A: acquire mainCond
...
T-B: acquire mainCond
...
T-B: released mainCond
...
T-A: released mainCond
Which is exactly what I was trying to prevent...
But even then, as you pointed out, there is still the possibility that 
one of the threads sends a notify() while the main loop isn't yet 
waiting, no matter how short the timespan is that it's not waiting...

As for what I'm trying to do; I'm trying to merge three huge XML files 
into single seperate database records. Every database record contains 
related data from each of the XML files.
For practical purposes this is a two-stage process, where I first store 
an uncombined "record" from each XML file into the DB (marked as 
'partial'), and then periodicaly merge the related records into one 
final record.

I could first store all data as 'partial' and then merge everything, but 
I consider it better to do this with relatively small batches at a time 
(queries are faster with smaller amounts of data, and the DB stays 
smaller too).
The reason I use threads for this is that (to my knowledge) it is not 
possible to pause an xml.parsers.xmlproc.xmlproc.Application object once 
it starts parsing XML, but I can pause a thread.

This is a timeline of what I'm trying to do:
Mainstart   |combine XML|comb.
|next batch |next
Application A run>..*|  |   >...*|  | etc.
Application B  run>.*|  |   >..*|
Application C  run>*|   >..*|
Legend:
> = thread is active
* = batch ready, wait()
| = timeline delimiter
--
http://mail.python.org/mailman/listinfo/python-list


Re: subclassing extension type and assignment to __class__

2004-12-02 Thread Gregory Lielens

> Unless I'm misunderstanding, couldn't one of __getattr__ or
> __getattribute__ make mapping other methods you don't override very
> simple and practical, not to mention fully automated with 2-3 lines of
> code?  In particular, __getattr__ would seem good for your use since
> it is only called for attributes that couldn't already be located.
> 
> I've had code that wrapped underlying objects in a number of cases, and
> always found that to be a pretty robust mechanism.

Thanks for mentioning this, after more research I came up with something
usable, using delegating technique from python cookbook:


#wrapper
 
def wrap_class(base):
class wrapper:
__base__=base
def __init__(self,*args,**kwargs):
if len(args)==1 and type(args[0])==self.__base__ and kwargs=={}:
self._base = args[0]
else:

self._base=self.__class__.__base__.__new__(self.__class__.__base__,*args,**kwargs)
def __getattr__(self,s):
return self._base.__getattribute__(s)
return wrapper
 
 
 
#wrap class
complex2=wrap_class(complex)
#extend wrapper class
def supaprint(self):
print "printed with supaprint(tm):"
print self
complex2.supaprint=supaprint
 
#define wrapper class from base class
c1=1+1j
c2=complex2(c1)
#test old functionalities
print c1==c2
print "c1=",c1
print "c2=",c1
#test extension
c2.supaprint()
c1.supaprint()

So this basically fit the bill, it even delegates special methods it
seems, although I am not sure why...It is like writting heritage ourself,
in a way :-)

Remaning problem is that if we use the class generating
wrapper function (simple), we loose the classic class definition syntax
and rely on explicitely adding methods.
The alternative is to include the wrapper
machinery in every "home-derived" class, but you are right, it is not as bad as 
I
though :-)

The biggest point I am not sure now is performance: Isn't a big penalty
associated to this embedding, compared to derivation? Python performance
is not so critical in our application, but I would be uncomfortable having
a factor 10 penalty in methd calling associated to this approach...For now, 
this will be used for
testing new implementations/extensions, that will be added to the C++
written binding afterwards.

I'd like to thanks the list for the hints, I will post the results of my
experimatations relaxing the assigment to __class__ test if they are
interesting.

Greg.

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


MySQLdb binaries for Python 2.4 on Windows?

2004-12-02 Thread Martin Bless
I'd be happy and thankful if somebody could provide the MySQLdb
binaries for Windows and Python 2.4.

Have a nice day - 

mb - Martin Bless

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


Re: Python 3000 and "Python Regrets"

2004-12-02 Thread Peter Maas
Dave Benjamin schrieb:
LOL! Better yet:
import __past__
del __past__.__mistakes__
Boy, what a load off!
Merry Christmas in advance,
from __future__ import NewYear
A Happy New Year to everybody!
;)
--
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
--
http://mail.python.org/mailman/listinfo/python-list


Re: non blocking read()

2004-12-02 Thread Pierre Barbier de Reuille
Steve Holden a écrit :
Donn Cave wrote:
In article <[EMAIL PROTECTED]>,
 Gustavo Córdova Avila <[EMAIL PROTECTED]> wrote:

David Bolen wrote:

Jp Calderone <[EMAIL PROTECTED]> writes:

  def nonBlockingReadAll(fileObj):
  bytes = []
  while True:
  b = fileObj.read(1024)
  bytes.append(b)
  if len(b) < 1024:
  break
  return ''.join(bytes)
Wouldn't this still block if the input just happened to end at a
multiple of the read size (1024)?
-- David
No, it'll read up to 1024 bytes or as much as it can, and
then return an apropriatly sized string.

Depends.  I don't believe the original post mentioned
that the file is a pipe, socket or similar, but it's

It did actually specifically mention files.
Read more carrefully and you'll see that it mentionned "file object" and 
, on UNIX systems, that's very different than "file". It even mentions 
"stdin", and stdin (though not always a pipe) always bahaves like a pipe 
when it comes to non-blocking reading.

For an answer, you can modify stdin (or whatever file desciptor you 
have) to have non-blocking reading operations. It can be done using :

*
import fcntl, os
fcntl.fcntl(0, fcntl.F_SETFL, os.O_NONBLOCK)
*
You can replace the "0" by whatever file descriptor you want of course !
After that call stdin is non-blocking.
Pierre
--
http://mail.python.org/mailman/listinfo/python-list


pyOpenSSL and Python 2.4? or alternatives...

2004-12-02 Thread Ola Natvig
Anyone that knows anyone knows a win32 Py2.4 build of pyOpenSSL?
Or perhaps has a outstanding alternative to this SSL package. It's 
imperative the package is as simmilar to the standard socket library of 
python.

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


PIL and antialiasing problem

2004-12-02 Thread Laszlo Zsolt Nagy
Hi all,

I have a little problem with PIL. I need to display images in a
browser (thumbnails) (this is the selector window).
I also need the original version of the image to be displayed in a
Java applet.

One example:

thumbnail:  http://designasign.biz/applet/GIF_Small/AIRCRAFT/a10per.png
original:   http://designasign.biz/applet/GIF/AIRCRAFT/a10per.png

I made the thumbnail from the original image using PIL this way:


im = Image.open(fullpath)
try:
im.thumbnail(THUMBSIZE,Image.ANTIALIAS)
im.save(thumbpath)
finally:
del im


If I do not use ANTIALIAS, then I get this:

http://designasign.biz/tmp/a10per.png

With the ANTIALIAS-ed version, the problem is that you cannot see the
lines - they are very light gray, almost invisible. I have many cliparts
with thin lines. However, I also have many cliparts like this:

http://designasign.biz/applet/GIF/AFRICA/angel03.png

I tried to posterize or darken the images but I could not find a good
solution. (I also tried to count the number of colors in the image and
use this info.) Can you suggest an image filter and/or method that creates
darker black lines from the original thin lines? Also it would be
great to have it working with those colorful smudged images. It will
be terribly slow to separate them by hand. There are almost 15000 of
them...

-- 
Thanks,
 Laszlo

mailto:[EMAIL PROTECTED]
web: http://designasign.biz

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


Re: pre-PEP generic objects

2004-12-02 Thread Peter Otten
Nick Craig-Wood wrote:

> Scott David Daniels <[EMAIL PROTECTED]> wrote:
>>  Nick Craig-Wood wrote:
>> > class Hash:
>> > def __init__(self, **kwargs):
>> > for key,value in kwargs.items():
>> > setattr(self, key, value)
>> > def __getitem__(self, x):
>> > return getattr(self, x)
>> > def __setitem__(self, x, y):
>> > setattr(self, x, y)
>> 
>>  You can simplify this:
>>  class Hash(object):
>>   def __init__(self, **kwargs):
>>   for key,value in kwargs.items():
>>   setattr(self, key, value)
>>   __getitem__ = getattr
>>   __setitem__ = setattr
> 
> That doesn't work unfortunately...
> 
 class Hash(object):
> ... def __init__(self, **kwargs):
> ... for key,value in kwargs.items():
> ... setattr(self, key, value)
> ... __getitem__ = getattr
> ... __setitem__ = setattr
> ...
 h=Hash(a=1,b=2)
 h.a
> 1
 h['a']
> Traceback (most recent call last):
>   File "", line 1, in ?
> TypeError: getattr expected at least 2 arguments, got 1

> 
> I'm not exactly sure why though!

Functions written in Python have a __get__ attribute while builtin functions
(implemented in C) don't. Python-coded functions therefore automatically
act as descriptors while builtins are just another attribute. See

http://mail.python.org/pipermail/python-list/2004-May/219424.html

for a strange example.

Peter


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


Re: Semaphore or what should I use?

2004-12-02 Thread Pierre Barbier de Reuille
Ville Vainio a écrit :
"Bastian" == Bastian Hammer <[EMAIL PROTECTED]> writes:

Bastian> Now I have to make sure, that both threads are
Bastian> synchronal, 1 thread edits something and the other is
Bastian> blocked until the first thread is ready.
Bastian> Isn´t it a good idea to do this with a semaphore?
Semaphore will do, but this is a classical use case for
threading.Lock.
There should be lots of stuff regarding locks (or more googleably,
"mutexes") on the net.
I don't agree. Mutexes (or locks) are best suited for critical sections 
(ie. sections that cannot be run by many thread at the same time). The 
kind of synchonisation Bastian want is not really semaphore either but 
more event. This python "Event" object is described in the section 7.5.5 
of the documentation of Python 2.3. There is no example, but I think 
Event are quite strait forward : you creates it, then some thread block, 
waiting the event to occure while some other thread execute until it set 
the event, allowing the blocked thread to go on its own execution :)

Here a small working example :
***8<8<***8<**
import threading, time
class MyThread(threading.Thread):
  def __init__(self):
threading.Thread.__init__(self)
self._event = threading.Event()
self._exit = False
  def run(self):
while 1:
  print "Waiting for an event to continue"
  self._event.wait()
  print "Ok, the thread is unblocked now :)"
  if self._exit:
return
  self._event.clear()
  def unblock(self):
self._event.set()
  def exit(self):
self._exit = True
self.unblock()
t = MyThread()
t.start()
time.sleep(1)
t.unblock()
time.sleep(1)
t.unblock()
time.sleep(1)
t.exit()
***8<8<***8<**
Pierre
--
http://mail.python.org/mailman/listinfo/python-list


Re: installing wxPython on Linux and Windows

2004-12-02 Thread Diez B. Roggisch
> Same task on Win2k: download wxPython-setup.exe, double-click, done.
> Took me approx. 1 minute. This strikes me. Why are some tasks so hard
> on Linux and so easy on Windows? After all wxPython/Win and wxPython/Lin
> are made by the same developers. My guess: the software deployment
> infrastructure on Linux needs to be improved.

On debian, it 

apt-get install wxPython2.5.3

So it clearly depends on you distribution. That this is unfortunate is of
course true...

I think there are several reasons for windows having easier installation:

 - on unix, progams usually are linked to libraries available on the
machine, so missing dependencies make the installation fail. On windows,
the installer installs all the dependencies - and possibly overwrites
system dlls (CorelDraw 7 killed Exchange by that, back in 1998)

 - there is more commercially available installers for windows - maybe
because free software developers on UNIXes are less keen to pay for such
tools, or the admins of such systems can be trusted to be more apt dealing
with configure and the like.

 - the variety of hardware _and_ software unix systems run on is much
larger, so compiling is the only way to go if you don't want to support a
plethorea of binaries (and have hardware available for these). On windows,
you can compile at home and install it on the big iron at work.

All the points are of course only an explanation, no excuse - there _could_
be better installers. As I showed, in  parts that's already available, e.g.
for debian which handles dependencies usually much better and is easier to
use for online updates. I think we have to wait until consistent dependency
checking and so on are established - maybe LSB helps us there.



-- 
Regards,

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


Re: database questions ala newbie pythonist

2004-12-02 Thread Uwe Grauer
Weinhandl Herbert wrote:
chris wrote:
...

This works fine using the literals 0 (For Delstatus) and 1190 (for
ProductID)
But when I try to use a variable such as:
###
...
varA = '0'
varB = '1190'
mycursor.execute('Update Categories Set DelStatus = ' varA 'Where 
ProductID
= ' varB)

use string formatting expressions
(which are easier to handle than string concatenation) :
'UPDATE Categories SET DelStatus=%d WHERE ProductID=%s;' % (varA,'1190')
or maybe
"UPDATE Categories SET DelStatus='%d' WHERE ProductID='%d';" % (0,varB)
if your DB wants your int's as string

You could also use:
curs.execute('UPDATE Categories SET DelStatus=? WHERE ProductID=?;', 
(varA, 1190))

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


Re: database questions ala newbie pythonist

2004-12-02 Thread Dan Sommers
On Wed, 1 Dec 2004 20:45:13 -0500,
"chris" <[EMAIL PROTECTED]> wrote:

> But when I try to use a variable such as:

> ###
> ...
> varA = '0'
> varB = '1190'
> mycursor.execute('Update Categories Set DelStatus = ' varA 'Where ProductID
> = ' varB)
> ...
> ###

Let the database module (looks like odbc) do that for you:

sql = 'UPDATE categories SET delstatus = %s WHERE productid = %s'
values = (varA, varB)
mycursor.execute( sql, values )

The database module will know exactly how to quote and escape and
whatever else is necessary to build a valid SQL statement.  Your
particular module may support other options, too, but it knows more than
you do (and has, in theory, already been debugged).

See also PEP 249, .

HTH,
Dan

-- 
Dan Sommers

Never play leapfrog with a unicorn.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL and antialiasing problem

2004-12-02 Thread Will McGugan
Laszlo Zsolt Nagy wrote:
I tried to posterize or darken the images but I could not find a good
solution. (I also tried to count the number of colors in the image and
use this info.) Can you suggest an image filter and/or method that creates
darker black lines from the original thin lines? Also it would be
great to have it working with those colorful smudged images. It will
be terribly slow to separate them by hand. There are almost 15000 of
them...
Try running ImageFilter.MinFilter on the image before you thumbnail it. 
This should make dark lines thicker.

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


Re: PIL and antialiasing problem

2004-12-02 Thread Belyh G.P.
Laszlo Zsolt Nagy wrote:
Hi all,
I have a little problem with PIL. I need to display images in a
browser (thumbnails) (this is the selector window).
I also need the original version of the image to be displayed in a
Java applet.
One example:
thumbnail:  http://designasign.biz/applet/GIF_Small/AIRCRAFT/a10per.png
original:   http://designasign.biz/applet/GIF/AIRCRAFT/a10per.png
I made the thumbnail from the original image using PIL this way:
   im = Image.open(fullpath)
   try:
   im.thumbnail(THUMBSIZE,Image.ANTIALIAS)
   im.save(thumbpath)
   finally:
   del im
If I do not use ANTIALIAS, then I get this:
http://designasign.biz/tmp/a10per.png
With the ANTIALIAS-ed version, the problem is that you cannot see the
lines - they are very light gray, almost invisible. I have many cliparts
with thin lines. However, I also have many cliparts like this:
http://designasign.biz/applet/GIF/AFRICA/angel03.png
I tried to posterize or darken the images but I could not find a good
solution. (I also tried to count the number of colors in the image and
use this info.) Can you suggest an image filter and/or method that creates
darker black lines from the original thin lines? Also it would be
great to have it working with those colorful smudged images. It will
be terribly slow to separate them by hand. There are almost 15000 of
them...
Photoshop cann't normaly resize
http://designasign.biz/applet/GIF/AIRCRAFT/a10per.png 
too.
But  when I resize this image with bgcolor=white  all done well.
Maybe PIL needed  image with bgcolor  for normal resize.

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


Re: Video Catalogue

2004-12-02 Thread Harlin Seritt
Tom B.:

If you're not having trouble saving with dict then use that. You only need
pickle if using lists or dicts are not doing the job when the data in them
are integers or long.


"Tom B." <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> "Rodney Dangerfield" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Greetz!
> >
> > Recently I started creating a CGI application for my gf that
> > she would use for indexing and keeping track of her video
> > collection.
> >
> > I am relatively new to python so I started with the basics.
> > I figured out how to extract the form field values in a
> > script and how to save to a file.
> >
> > My question is which data type should I use to store the information
> > about the videos? I was thinking of using a dictionary variable,
> > I saw something about the pickle module too, could I use it to
> > save the state of my dictionary to a file and than later read it
> > and feed values from it to the form fields via CGI?
> >
> > All help is greatly appreciated.
>
> I think a dictionary might work well, I might use a dictionary within a
> dictionary.
>
> vidiodict =
>
{'Title':{'description':'','date':'','cast':'','length':'130.99','comments':
''}}
>
> that way you could look at vidiodict['Title']['length'] it returns
'130.99'.
>
> Tom
>
>


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


debian python2.4

2004-12-02 Thread km

Hi all,
is there a debian binary of python2.4 ? 

tia,
KM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A little threading problem

2004-12-02 Thread Alban Hertroys
Jeremy Jones wrote:
(not waiting, because it already did happen).  What is it exactly that 
you are trying to accomplish?  I'm sure there is a better approach.
I think I saw at least a bit of the light, reading up on readers and 
writers (A colleague showed up with a book called "Operating system 
concepts" that has a chapter on process synchronization).
It looks like I should be writing and reading 3 Queues instead of trying 
to halt and pause the threads explicitly. That looks a lot easier...

Thanks for pointing out the problem area.
--
http://mail.python.org/mailman/listinfo/python-list


Re[2]: PIL and antialiasing problem

2004-12-02 Thread Laszlo Zsolt Nagy
> Try running ImageFilter.MinFilter on the image before you thumbnail it.
> This should make dark lines thicker.
> HTH,
> Will McGugan

You are my man! It worked perfectly!

Statement: Sometimes PIL is better than Adobe Photoshop. :-)

I also found these with the aid of the wonderful dir() function:

MinFilter, MaxFilter, MedianFilter, ModeFilter, RankFilter, BuiltInFilter

They do not have a docstring and they are not documented in the
handbook. I'm curious what they do exactly. The others (like BLUR, EMBOSS,
CONTOUR etc.) are documented very well. I wonder why is that.


Python forever,

   Laszlo

mailto:[EMAIL PROTECTED]
web:http://designasign.biz

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


"readline()" omitted '\r' in win32 for dos format text file

2004-12-02 Thread Newgene
Hi, group,
I have python2.3 installed on win2k. I noticed that when I open a
dos format text file (eol is '\r\n'), readline() always returns a line
ending with '\n' only, not '\r\n'. While I read the same file on unix,
it returns a line ending with '\r\n' correctly.
This makes me difficult to determine the format of a text file, dos or
unix.

Is this a bug or intended behavior? If not a bug, then how to
determine the format of a text file?

Thanks.

C

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


Re: "readline()" omitted '\r' in win32 for dos format text file

2004-12-02 Thread Peter Otten
Newgene wrote:

> I have python2.3 installed on win2k. I noticed that when I open a
> dos format text file (eol is '\r\n'), readline() always returns a line
> ending with '\n' only, not '\r\n'. While I read the same file on unix,
> it returns a line ending with '\r\n' correctly.
> This makes me difficult to determine the format of a text file, dos or
> unix.
> 
> Is this a bug or intended behavior? If not a bug, then how to
> determine the format of a text file?

It's not a bug. On windows, files are opened in text mode by default.

Opening a file in binary mode 

file(name, "rb") 

will preserve the line endings regardless of platform while opening it in
"universal" mode 

file(name, "rU") 

will normalize all line endings to "\n". 

Peter


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


Re: PIL and antialiasing problem

2004-12-02 Thread Will McGugan
Laszlo Zsolt Nagy wrote:
Try running ImageFilter.MinFilter on the image before you thumbnail it.
This should make dark lines thicker.
HTH,
Will McGugan

You are my man! It worked perfectly!
Statement: Sometimes PIL is better than Adobe Photoshop. :-)
Happy to help :)
I also found these with the aid of the wonderful dir() function:
MinFilter, MaxFilter, MedianFilter, ModeFilter, RankFilter, BuiltInFilter
MinFilter replaces each pixel with the darkest pixel within the filter 
area. MaxFilter replaces each pixel with the brightest of the 
surrounding pixels. MedianFilter sorts the surrounding pixels by 
brightness and selects the middle value. I think ModeFilter selects the 
most common pixel if occurs more than a certain threshhold. RankFilter 
is like Median, but it selects the colour at a specific point within the 
ordered list. Not sure about BuiltInFilter, my guess is its an 
implementation detail of some kind..

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


Re: XUL Parser?

2004-12-02 Thread Alberto Berti
Hi,
I'm slowly developing a "thin client environment" that will use xul, or a part
of it as gui language, all done in python and that uses python instead of js as
scripting language and "event binding". It builds the gui using pyGTK.

Who is interested can find more info here:

http://artiemestieri.tn.it/~azazel/darcs/snakegtk

The project is currently halted due to time constraints. On the repository there
is a tag "0.1" from wich the demo was generated, the "HEAD" is not functional
yet and it's current 0.2 code, a release  that will add:
 
  - a test suite;

  - remote loading of xul files and python libraries with support for
"file", "http", "https", "ftp" url schemes, with remote import of python
modules too;

  - importing of external module via 

  - refactoring of the overall environment;

If you are interested, please download the code and contribute, it's GPL.

bye, Alberto

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


Re: A little threading problem

2004-12-02 Thread Jeremy Jones
Alban Hertroys wrote:
Jeremy Jones wrote:
(not waiting, because it already did happen).  What is it exactly 
that you are trying to accomplish?  I'm sure there is a better approach.

I think I saw at least a bit of the light, reading up on readers and 
writers (A colleague showed up with a book called "Operating system 
concepts" that has a chapter on process synchronization).
It looks like I should be writing and reading 3 Queues instead of 
trying to halt and pause the threads explicitly. That looks a lot 
easier...

Thanks for pointing out the problem area.
That's actually along the lines of what I was going to recommend after 
getting more detail on what you are doing.  A couple of things that may 
(or may not) help you are:

* the Queue class in the Python standard library has a "maxsize" 
parameter.  When you create a queue, you can specify how large you want 
it to grow.  You can have your three threads busily parsing XML and 
extracting data from it and putting it into a queue and when there are a 
total of "maxsize" items in the queue, the next put() call (to put data 
into the queue) will block until the consumer thread has reduced the 
number of items in the queue.  I've never used 
xml.parsers.xmlproc.xmlproc.Application, but looking at the data, it 
seems to resemble a SAX parser, so you should have no problem putting 
(potentially blocking) calls to the queue into your handler.  The only 
thing this really buys you won't have read the whole XML file into memory.
* the get method on a queue object has a "block" flag.  You can 
effectively poll your queues something like this:

#untested code
#a_done, b_done and c_done are just checks to see if that particular 
document is done
while not (a_done and b_done and c_done):
   got_a, got_b, got_c = False, False, False
   item_a, item_b, item_c = None, None, None
   while (not a_done) and (not got_a):
  try:
 item_a = queue_a.get(0) #the 0 says don't block and raise an 
Empty exception if there's nothing there
 got_a = True
  except Queue.Empty:
 time.sleep(.3)
   while (not b_done) and (not got_b):
  try:
 item_b = queue_b.get(0)
 got_a = True
  except Queue.Empty:
 time.sleep(.3)
   while (not c_done) and (not got_c):
  try:
 item_c = queue_c.get(0)
 got_c = True
  except Queue.Empty:
 time.sleep(.3)
   put_into_database_or_whatever(item_a, item_b, item_c)

This will allow you to deal with one item at a time and if the xml files 
are different sizes, it should still work - you'll just pass None to 
put_into_database_or_whaver for that particular file.

HTH.
Jeremy Jones
--
http://mail.python.org/mailman/listinfo/python-list


exec size

2004-12-02 Thread km
Hi all,
just curious to know why /usr/bin/python2.3  is 890K and /usr/bin/python2.4 is 
3.5M  in linux ? 

tia,
KM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exec size

2004-12-02 Thread Gerhard Haering
On Fri, Dec 03, 2004 at 10:14:48PM +0530, km wrote:
> Hi all,
> just curious to know why /usr/bin/python2.3  is 890K and
> /usr/bin/python2.4 is 3.5M  in linux ? 

Did you try already removing the debug symbols with strip(1)?

-- Gerhard


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

Re: database questions ala newbie pythonist

2004-12-02 Thread Steve Holden
Dan Sommers wrote:
On Wed, 1 Dec 2004 20:45:13 -0500,
"chris" <[EMAIL PROTECTED]> wrote:

But when I try to use a variable such as:

###
...
varA = '0'
varB = '1190'
mycursor.execute('Update Categories Set DelStatus = ' varA 'Where ProductID
= ' varB)
...
###

Let the database module (looks like odbc) do that for you:
Well, by now chris is probably wondering why you suggest
sql = 'UPDATE categories SET delstatus = %s WHERE productid = %s'
values = (varA, varB)
mycursor.execute( sql, values )
when Uwe Grauer thinks that
You could also use:
curs.execute('UPDATE Categories SET DelStatus=? WHERE ProductID=?;', (varA, 
1190))
is more appropriate, and Weinhandl Herbert suggested
use string formatting expressions
(which are easier to handle than string concatenation) :
'UPDATE Categories SET DelStatus=%d WHERE ProductID=%s;' % (varA,'1190')
or maybe
"UPDATE Categories SET DelStatus='%d' WHERE ProductID='%d';" % (0,varB)
if your DB wants your int's as string
So, having gone through these newbie questions myself several decades 
ago (I exaggerate for effect) I thought I might try to resolve the 
differences. Although this is addressed to you out of politeness (since 
it's your post I'm replying to), please don't think I believe you need 
the lecture, since your reply seems to do what's needed.

You are, of course, correct in saying
The database module will know exactly how to quote and escape and
whatever else is necessary to build a valid SQL statement.  Your
particular module may support other options, too, but it knows more than
you do (and has, in theory, already been debugged).
See also PEP 249, .
and your reference to the DB API sepcification gives chris the chance to 
RTFM should he so desire.

The plain fact of the matter, however, is that the DB API specification 
is less than satisfactory in certain respects, and the odbc module 
that's a part of the win32all extensions isn't in any case fully 
compatible with DB API 2.0.

Firstly, the suggestion that one generates one's own well-formed SQL 
statement is valid, but sub-optimal. Following Herbert's suggestion, one 
might expect to be able to use

>>> 'UPDATE Categories SET DelStatus=%d WHERE ProductID=%s;' % 
(1234,'1190')
'UPDATE Categories SET DelStatus=1234 WHERE ProductID=1190;'

I'm not quite sure why string substitution was used for the ProductID 
when decimal was used for the DelStatus value, but that's beside the 
point - both values were presented as strings in the OP's question.

This does indeed generate a well-formed SQL statement, but doing so 
isn't as easy as you might think in the general case. To insert a string 
value into the database. one might expect

>>> "UPDATE MyTable SET charcol='%s' WHERE ProductID=%d" % ('a string', 
1234)
"UPDATE MyTable SET charcol='a string' WHERE ProductID=1234"

to work, and for much of the time it does. Unfortunately in the case 
where the string value contains single quotes it will break:

>>> "UPDATE MyTable SET charcol='%s' WHERE ProductID=%d" % ("it's a
string", 12
34)
"UPDATE MyTable SET charcol='it's a string' WHERE ProductID=1234"
yields something that clearly isn't valid SQL. One answer is to take all 
string values and replace any single quotes that are found with two 
single quotes - this is the accepted SQL escaping mechanism, though some 
 "rogue" database will also accept variations such as backslash 
stropping. So

>>> "UPDATE MyTable SET charcol='%s' WHERE ProductID=%d" % ("it's a 
string".replace("'", "''"), 1234)
"UPDATE MyTable SET charcol='it''s a string' WHERE ProductID=1234"

does give correct SQL, but at the expense of some additional complexity, 
plus the extra burden of having to treat string values differently from 
other types of values. Personally I try to write my code so it works no 
matter what type of value I'm deadling with, and while this is an ideal 
it's surprisingly easy to stay close to the ideal.

The real answer is in your and Uwe's suggestion that the OP provides a 
"parameterized" SQL statement, providing the actual values to be 
substituted for the parameter marks. This has the further advantage that 
 the SQL engine will see the same stateme nt every time, which means 
that it can go through the optimization stages just once, and use the 
same execution plan with repeated uses of the same parameterized 
statement. If we try to write the whole SQL statement ourselves not only 
is it more complex to program, it throws away this potential optimization.

So why did you use "... SET delstatus = %s WHERE productid = %s" when 
Uwe used "... SET DelStatus=? WHERE ProductID=?"?

The answer here is the DB API's additional obstacle to database 
portability: authors of interface modules can choose from one of a 
number of different styles for paraeterization, indicating their choice 
by setting the

Re: installing wxPython on Linux and Windows

2004-12-02 Thread Cousin Stanley
| On debian, it
|
| apt-get install wxPython2.5.3
|
| So it clearly depends on you distribution.
|
| That this is unfortunate is of course true...
| 
Diez 
  The package for wxPython2.5.3 currently is available
  for Debian Sid/unstable but not for Sarge/testing 

--
Cousin Stanley
Human Being
Phoenix, Arizona
--
http://mail.python.org/mailman/listinfo/python-list


Re: Semaphore or what should I use?

2004-12-02 Thread Sergei Organov
Pierre Barbier de Reuille <[EMAIL PROTECTED]> writes:

> Ville Vainio a Иcrit :
> >>"Bastian" == Bastian Hammer <[EMAIL PROTECTED]> writes:
> > Bastian> Now I have to make sure, that both threads are
> 
> > Bastian> synchronal, 1 thread edits something and the other is
> > Bastian> blocked until the first thread is ready.
> > Bastian> Isn╢t it a good idea to do this with a semaphore?
> 
> > Semaphore will do, but this is a classical use case for
> > threading.Lock.
> >
> > There should be lots of stuff regarding locks (or more googleably,
> > "mutexes") on the net.
> >
> 
> 
> I don't agree. Mutexes (or locks) are best suited for critical sections (ie.
> sections that cannot be run by many thread at the same time).

Please don't add even more confusion to the issue. Mutex conceptually is
designed to be used for MUTual EXclusion of access to a resource (e.g.,
a peace of data). While critical section could be implemented using
mutex, the mutex itself is more general concept. Besides, the rule of
thumb using mutexes is: "protect data, not program code."

My answer to OP's question is: use either lock (mutex) or semaphore.
I'd probably use semaphore as mutexes are usually optimized for the case
when contention probability is low (i.e., they usually shouldn't be locked
for a long time).

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


Re: exec size

2004-12-02 Thread km
Hi Gerhard,
ya have tried stripping python2.4 it came to 952K.
now does the size diference before and after strip affect the runtime of a 
python program ? 
KM
-
On Thu, Dec 02, 2004 at 02:23:34PM +0100, Gerhard Haering wrote:
> On Fri, Dec 03, 2004 at 10:14:48PM +0530, km wrote:
> > Hi all,
> > just curious to know why /usr/bin/python2.3  is 890K and
> > /usr/bin/python2.4 is 3.5M  in linux ? 
> 
> Did you try already removing the debug symbols with strip(1)?
> 
> -- Gerhard



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

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


Re: Semaphore or what should I use?

2004-12-02 Thread Ville Vainio
> "Sergei" == Sergei Organov <[EMAIL PROTECTED]> writes:

Sergei> My answer to OP's question is: use either lock (mutex) or
Sergei> semaphore.  I'd probably use semaphore as mutexes are
Sergei> usually optimized for the case when contention probability
Sergei> is low (i.e., they usually shouldn't be locked for a long
Sergei> time).

Both Mutexes and Semaphores put the thread to sleep, so I don't think
there will be a big difference.

The OP might also want to check out read/write lock. The first thing
google finds is

http://www.majid.info/mylos/weblog/2004/11/04-1.html

-- 
Ville Vainio   http://tinyurl.com/2prnb
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exec size

2004-12-02 Thread Gerhard Haering
On Fri, Dec 03, 2004 at 10:53:30PM +0530, km wrote:
> Hi Gerhard,
> ya have tried stripping python2.4 it came to 952K.  now does the size
> diference before and after strip affect the runtime of a python program ? 

No, it only saves some space on disk. The interpreter doesn't need any less
memory at runtime just because the executable size is less now. The OS wouldn't
load the symbols into memory, unless they're used for debugging, anyway.

-- Gerhard


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

Re: MySQLdb binaries for Python 2.4 on Windows?

2004-12-02 Thread Sibylle Koczian
Martin Bless schrieb:
I'd be happy and thankful if somebody could provide the MySQLdb
binaries for Windows and Python 2.4.
So would I. Preferably version 1.1.7 and up which works with MySQL 4.1.
--
Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg
Tel.: (0821) 598-2400, Fax : (0821) 598-2410
e-mail : [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: A little threading problem

2004-12-02 Thread Alban Hertroys
Jeremy Jones wrote:
* the get method on a queue object has a "block" flag.  You can 
effectively poll your queues something like this:

#untested code
#a_done, b_done and c_done are just checks to see if that particular 
document is done
while not (a_done and b_done and c_done):
   got_a, got_b, got_c = False, False, False
   item_a, item_b, item_c = None, None, None
   while (not a_done) and (not got_a):
  try:
 item_a = queue_a.get(0) #the 0 says don't block and raise an 
Empty exception if there's nothing there
Actually, it is just fine to let get() block, as long as I put(None) on 
the queue when I reach document_end and test for it (removing it from 
the "list of queues to read" when get() returns 'None').

I rewrote my test script (the one I sent to the NG) to use Queues this 
way, and it works well. It's also a lot easier to read/follow. Currently 
I'm implementing it in my application.
I'm glad I don't get paid by the number of lines I write, there are 
going to be less lines at the end of today ;)

Thanks a lot for the pointers.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Semaphore or what should I use?

2004-12-02 Thread Sergei Organov
Ville Vainio <[EMAIL PROTECTED]> writes:
> > "Sergei" == Sergei Organov <[EMAIL PROTECTED]> writes:
> 
> Sergei> My answer to OP's question is: use either lock (mutex) or
> Sergei> semaphore.  I'd probably use semaphore as mutexes are
> Sergei> usually optimized for the case when contention probability
> Sergei> is low (i.e., they usually shouldn't be locked for a long
> Sergei> time).
> 
> Both Mutexes and Semaphores put the thread to sleep, so I don't think
> there will be a big difference.

Yeah, most probably from this point of view there is no difference
(mutexes could be implemented using busy-waiting, but I don't think it's
the case). However, though I don't think it's a real issue in this
particular case either, mutexes can do fancy things with the thread that
has locked the mutex (mutex owner thread), like raising its priority to
the highest one of the threads waiting for the mutex to prevent so
called priority inversion.

There could be other subtle differences between mutex and semaphore
behavior resulting in different performance of the application. The
application correctness shouldn't be affected though.

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


Re: non blocking read()

2004-12-02 Thread Gustavo Córdova Avila
Donn Cave wrote:
Depends.  I don't believe the original post mentioned
that the file is a pipe, socket or similar, but it's
kind of implied by the use of select() also mentioned.
It's also kind of implied by use of the term "block" -
disk files don't block.
If we are indeed talking about a pipe or something that
really can block, and you call fileobject.read(1024),
it will block until it gets 1024 bytes.
  Donn Cave, [EMAIL PROTECTED]
Actually the op did mention that he wanted to monitor files.
--
Gustavo Córdova Avila <[EMAIL PROTECTED]> 

*Tel:* +52 (81) 8130-1919 ext. 127
Integraciones del Norte, S.A. de C.V.
Padua #6047, Colonia Satélite Acueducto
Monterrey, Nuevo León, México.
--
http://mail.python.org/mailman/listinfo/python-list


Re: installing wxPython on Linux and Windows

2004-12-02 Thread Peter Maas
Diez B. Roggisch schrieb:
Same task on Win2k: download wxPython-setup.exe, double-click, done.
Took me approx. 1 minute. This strikes me. Why are some tasks so hard
on Linux and so easy on Windows? After all wxPython/Win and wxPython/Lin
are made by the same developers. My guess: the software deployment
infrastructure on Linux needs to be improved.

On debian, it 

apt-get install wxPython2.5.3
I have heard praises of Debian's install system but Debian is quite
conservative with latest versions. There are some packages (e.g. Python,
PostgreSQL, Subversion) where I'd like to have the latest versions.
I don't want to be too tightly bound to the update cycles of the
Linux distribution.
All the points are of course only an explanation, no excuse - there _could_
be better installers. As I showed, in  parts that's already available, e.g.
for debian which handles dependencies usually much better and is easier to
use for online updates. I think we have to wait until consistent dependency
checking and so on are established - maybe LSB helps us there.
If there would be a common specification how to query and change
configuration data of the system and applications this would be
really helpful.
--
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
--
http://mail.python.org/mailman/listinfo/python-list


disk based dictionaries

2004-12-02 Thread Shivram U

Hi,

  I want to store dictionaries on disk. I had a look at a few modules
like bsddb, shelve etc. However would it be possible for me to do the
following

hash[1] = [1, 2, 3] where the key is an int and not a string

bsddb requires that both the key,value are string. 
shelve does support values being object but not the keys. Is there any
module which support keys which are not strings

Also how do i use disk based hashes for multidimensional hashes such as
below

#!/usr/bin/python

dict={}
dict['key1'] = {}
dict[('key1')][('key2')] = 'value'

key1=dict['key1']
print key1['key2']

I have read of mxBeeDict but was unable to get it work properly. I am
not sure if it supports what i need as i was unable to get any
documentation about it. Is the module used widely ?

Below is how i am using the module

bdict = BeeDict('/tmp/beedict')

bdict[1] = 1
print bdict.keys()

bdict.commit()
bdict.close()

bdict1 = BeeDict('/tmp/beedict')
print bdict1.keys()
print bdict1.values()


Would it be that using disk based dictionaries once opened are as fast
as in memory dictionaries ?

Thanks in advance,

Best Regards,
Shivram U




Confidentiality Notice 

The information contained in this electronic message and any attachments to 
this message are intended
for the exclusive use of the addressee(s) and may contain confidential or 
privileged information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL 
PROTECTED] immediately
and destroy all copies of this message and any attachments.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing wxPython on Linux and Windows

2004-12-02 Thread Diez B. Roggisch
>The package for wxPython2.5.3 currently is available
>for Debian Sid/unstable but not for Sarge/testing 

Nevertheless, the point remains valid: _If_ you have proper
dependency-management, installation of packages is easy. Of course tracking
dependencies takes effort, and so unless a general scheme is adopted, no
software project will  burden itself with the task of doing this. So you
have to wait for your distribution to do that for them - which may result
in not-so-latest verisons. Or even none at all

-- 
Regards,

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


Re: installing wxPython on Linux and Windows

2004-12-02 Thread Jp Calderone
On Thu, 02 Dec 2004 15:29:53 +0100, Peter Maas <[EMAIL PROTECTED]> wrote:
>Diez B. Roggisch schrieb:
> >>Same task on Win2k: download wxPython-setup.exe, double-click, done.
> >>Took me approx. 1 minute. This strikes me. Why are some tasks so hard
> >>on Linux and so easy on Windows? After all wxPython/Win and wxPython/Lin
> >>are made by the same developers. My guess: the software deployment
> >>infrastructure on Linux needs to be improved.
> > 
> > 
> > On debian, it 
> > 
> > apt-get install wxPython2.5.3
> > 
> 
> I have heard praises of Debian's install system but Debian is quite
> conservative with latest versions. There are some packages (e.g. Python,
> PostgreSQL, Subversion) where I'd like to have the latest versions.
> I don't want to be too tightly bound to the update cycles of the
> Linux distribution.
> 

[EMAIL PROTECTED]:~$ apt-cache show python2.4
Package: python2.4
Priority: optional
Section: python
Installed-Size: 10972
Maintainer: Matthias Klose <[EMAIL PROTECTED]>
Architecture: i386
Version: 2.3.97-2
Provides: python2.4-cjkcodecs
Depends: libbz2-1.0, libc6 (>= 2.3.2.ds1-4), libdb4.2, libncurses5 (>= 5.4-1), 
libreadline4 (>= 4.3-1), libssl0.9.7, zlib1g (>= 1:1.2.1)
Suggests: python2.4-iconvcodec | python2.4-japanese-codecs, 
python2.4-iconvcodec | python2.4-korean-codecs, python2.4-doc
Conflicts: python2.4-dev (<< 2.3.95-2)
Filename: pool/main/p/python2.4/python2.4_2.3.97-2_i386.deb
Size: 3503764
MD5sum: 519ed28c52bff645b311b8d5d27b2318
Description: An interactive high-level object-oriented language (version 2.4)
 Version 2.4 of the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.

Package: python2.4
Status: install ok installed
Priority: optional
Section: python
Installed-Size: 9764
Maintainer: Matthias Klose <[EMAIL PROTECTED]>
Version: 2.3.90-1
Replaces: python2.4-xmlbase
Provides: python2.4-xmlbase
Depends: libbz2-1.0, libc6 (>= 2.3.2.ds1-4), libdb4.2, libncurses5 (>= 5.4-1), 
libreadline4 (>= 4.3-1), libssl0.9.7, zlib1g (>= 1:1.2.1)
Recommends: python2.4-iconvcodec | python2.4-cjkcodecs | 
python2.4-japanese-codecs, python2.4-iconvcodec | python2.4-cjkcodecs | 
python2.4-korean-codecs
Suggests: python2.4-doc
Conflicts: python2.4-xmlbase, python2.4-csv
Conffiles:
 /etc/python2.4/site.py b448b0f87294e041b8276ea3459df4a8
Description: An interactive high-level object-oriented language (version 2.4)
 Version 2.4 of the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.

  This is a long and obnoxious way of pointing out that Python 2.4 is already 
available as a Python package :)  How much more up to date software can you ask 
for?

  And even if there are packages that aren't available, don't you think effort 
put into a packaging system would better be put into apt than an entirely new 
system that is guaranteed to be less useful than apt for many years?

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


Re: installing wxPython on Linux and Windows

2004-12-02 Thread Diez B. Roggisch
> I have heard praises of Debian's install system but Debian is quite
> conservative with latest versions. There are some packages (e.g. Python,
> PostgreSQL, Subversion) where I'd like to have the latest versions.
> I don't want to be too tightly bound to the update cycles of the
> Linux distribution.

Then you can go for debian testing or (as I do) unstable. They usually have
the latest stuff in, and for a desktop-system that doesn't need uptimes
measured in years its really good. Occasionally, some dependency matters
occur in these releases, and I have to force installation of packages. But
usually, things are smooth, and apart from a hd-crash in January, I never
had to reinstall my system for now 2-3 years. Before that, I used Suse, and
switching between releases did give me quite a few headaches - usually I
reinstalled the system, as my home was on its own partition.

However, a warning has to be voiced: Commercial distributions do a better
job on the hardware detection/integration side of linux-life. Debian can do
what can be done on linux in general, but it might require some
config-file-fiddling and the occasional kernel build. Still worth the
effort for me, though.


> If there would be a common specification how to query and change
> configuration data of the system and applications this would be
> really helpful.

Yup. And above that, tool support for configure or the like that will
integrate this - for example, on debian nearly all libs come with an extra
dev-package you need when compiling against them. No big deal, but
compiling software yourself usually means to downtrack these packages by
making multiple configure runs, until all missing headerfiles are there. 

-- 
Regards,

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


installer

2004-12-02 Thread km
Hi all,

does python have a default module installer inbuilt as for perl in windows ? 

tia ,
KM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing wxPython on Linux and Windows

2004-12-02 Thread Antoon Pardon
Op 2004-12-02, Peter Maas schreef <[EMAIL PROTECTED]>:
> Diez B. Roggisch schrieb:
>>>Same task on Win2k: download wxPython-setup.exe, double-click, done.
>>>Took me approx. 1 minute. This strikes me. Why are some tasks so hard
>>>on Linux and so easy on Windows? After all wxPython/Win and wxPython/Lin
>>>are made by the same developers. My guess: the software deployment
>>>infrastructure on Linux needs to be improved.
>> 
>> 
>> On debian, it 
>> 
>> apt-get install wxPython2.5.3
>> 
>
> I have heard praises of Debian's install system but Debian is quite
> conservative with latest versions. There are some packages (e.g. Python,
> PostgreSQL, Subversion) where I'd like to have the latest versions.
> I don't want to be too tightly bound to the update cycles of the
> Linux distribution.

Debian has muliple distributions. Only the stable distribution is
really conservative. The PostgreSQL version in the testing distribution
is 7.4.6-4, the download page of PostgreSQL gives 7.4.6 as the latest
version. That seems to be in order.

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


Re: installer

2004-12-02 Thread Gerhard Haering
On Sat, Dec 04, 2004 at 12:15:04AM +0530, km wrote:
> Hi all,
> 
> does python have a default module installer inbuilt as for perl in
> windows ? 

No, there is no CPAN-like system for Python. You will have to search,
download and install your third-party Python libraries yourself.

OTOH, there are some good places to look for these, like
http://www.python.org/pypi?:action=browse and the libraries are
usually packaged with distutils into win32 installers that you can
then easily install/uninstall.

-- Gerhard


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

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 2)

2004-12-02 Thread David Fraser
Robin Becker wrote:
Cameron Laird wrote:
QOTW:  "... why does Microsoft try so hard to protect its sources?"
.
2.4 is final, buildable under Windows in at least a couple of 
ways, improved, ...
http://www.brunningonline.net/simon/blog/archives/001657.html

asyncore, Twisted, the Python core...--do you understand how
they relate to TLS, serial-port usage, GUI-oriented event
processing, and so on?
http://groups.google.com/groups?th=752ebdb8b57fa3f3
Ian Bicking and others describe the meaning of "Python 3000".
http://groups.google.com/groups?frame=left&th=8f9b6a3959888f2b
Reading without blocking is possible--with care.
http://groups.google.com/groups?frame=left&th=78654cfc06d2fbbe
Josiah Carlson and Paul McGuire explain decorators.
http://groups.google.com/groups?th=5bfb80b43887bc1f
Nick Coghlan knows sick ways to spell "file".
http://groups.google.com/groups?frame=right&th=e562a771d1c827c9
Python works in Frontier.
http://radio.weblogs.com/0100039/2004/11/30.html#a626

...
For some reason I can't seem to make use of the google links. When I use 
the above eg

http://groups.google.com/groups?frame=right&th=e562a771d1c827c9
I get a not found google page with url
http://groups-beta.google.com/groups?frame=right&th=e562a771d1c827c9
really wanted to spell file in a sickly manner :)
Apparently this is due to a Google "upgrade"
See the slashdot story:
http://slashdot.org/article.pl?sid=04/12/02/149210&tid=217&tid=95
The important thing is that you (or I) can still access them at 
groups.google.co.uk:

http://groups.google.co.uk/groups?frame=right&th=e562a771d1c827c9
etc
Maybe the URLs on the web page could be adjusted?
David
--
http://mail.python.org/mailman/listinfo/python-list


Re: non blocking read()

2004-12-02 Thread Steve Holden
Gustavo Córdova Avila wrote:
Donn Cave wrote:
Depends.  I don't believe the original post mentioned
that the file is a pipe, socket or similar, but it's
kind of implied by the use of select() also mentioned.
It's also kind of implied by use of the term "block" -
disk files don't block.
If we are indeed talking about a pipe or something that
really can block, and you call fileobject.read(1024),
it will block until it gets 1024 bytes.
  Donn Cave, [EMAIL PROTECTED]
Actually the op did mention that he wanted to monitor files.
As was pointed out to me when I made the same assertion, he actually 
said "file object which is stdin" or something like that, which means 
the object could be a socket, a pipe, a file, a named pipe ...

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


Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 2)

2004-12-02 Thread Rocco Moretti

For some reason I can't seem to make use of the google links. When I use 
the above eg

http://groups.google.com/groups?frame=right&th=e562a771d1c827c9
I get a not found google page with url
http://groups-beta.google.com/groups?frame=right&th=e562a771d1c827c9
really wanted to spell file in a sickly manner :)
It seems Google recently redid their groups interface. By searching for 
"group:comp.lang.python Coghlan" on http://groups.google.com, I was able 
to find the probable post (Sort by Date, titled "Restricted Execution on 
the cheap", about four down)

I'm sorry I'm not able to give a direct URL, but it seems they've 
switched over to a horrendously long, stateful URL system which doesn't 
lend itself to direct linkage.
--
http://mail.python.org/mailman/listinfo/python-list


Re: non blocking read()

2004-12-02 Thread Gustavo Córdova Avila
Steve Holden wrote:
Gustavo Córdova Avila wrote:
Actually the op did mention that he wanted to monitor files.
As was pointed out to me when I made the same assertion, he actually 
said "file object which is stdin" or something like that, which means 
the object could be a socket, a pipe, a file, a named pipe ...

regards
 Steve
Yup, read the post you're talking about *after* I sent mine. :-P
--
Gustavo Córdova Avila <[EMAIL PROTECTED]> 

*Tel:* +52 (81) 8130-1919 ext. 127
Integraciones del Norte, S.A. de C.V.
Padua #6047, Colonia Satélite Acueducto
Monterrey, Nuevo León, México.
--
http://mail.python.org/mailman/listinfo/python-list


Re: non blocking read()

2004-12-02 Thread Steve Holden
Gustavo Córdova Avila wrote:
Steve Holden wrote:
Gustavo Córdova Avila wrote:
Actually the op did mention that he wanted to monitor files.

As was pointed out to me when I made the same assertion, he actually 
said "file object which is stdin" or something like that, which means 
the object could be a socket, a pipe, a file, a named pipe ...

regards
 Steve

Yup, read the post you're talking about *after* I sent mine. :-P
Please try to keep up :-P
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Dr. Dobb's Python-URL! - weekly Python news and links (Dec 2)

2004-12-02 Thread Cameron Laird
QOTW:  "... why does Microsoft try so hard to protect its sources?"
"To avoid embarrassment." -- Peter Maas and Grant Edwards
http://groups.google.com/groups?frame=left&th=9a599152d8b23b54

"Sufficiently advanced cluelessness is indistinguishable from
malice." -- Alex Martelli


2.4 is final, buildable under Windows in at least a couple 
of ways, improved, ...
http://www.brunningonline.net/simon/blog/archives/001657.html

asyncore, Twisted, the Python core...--do you understand how
they relate to TLS, serial-port usage, GUI-oriented event
processing, and so on?
http://groups.google.com/groups?th=752ebdb8b57fa3f3

Ian Bicking and others describe the meaning of "Python 3000".
http://groups.google.com/groups?frame=left&th=8f9b6a3959888f2b

Reading without blocking is possible--with care.
http://groups.google.com/groups?frame=left&th=78654cfc06d2fbbe

Josiah Carlson and Paul McGuire explain decorators.
http://groups.google.com/groups?th=5bfb80b43887bc1f

Nick Coghlan knows sick ways to spell "file".
http://groups.google.com/groups?frame=right&th=e562a771d1c827c9

Python works in Frontier.
http://radio.weblogs.com/0100039/2004/11/30.html#a626



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily  
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html 
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

Brett Cannon continues the marvelous tradition established by 
Andrew Kuchling and Michael Hudson of intelligently summarizing
action on the python-dev mailing list once every other week.
http://www.python.org/dev/summary/

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/   

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

The Python Business Forum "further[s] the interests of companies
that base their business on ... Python."
http://www.python-in-business.org

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance. 
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donate.html

Kurt B. Kaiser publishes a weekly report on faults and patches.
http://www.google.com/groups?as_usubject=weekly%20python%20patch
   
Cetus collects Python hyperlinks.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes.
http://aspn.activestate.com/ASPN/Cookbook/Python

Among several Python-oriented RSS/RDF feeds available are
http://www.python.org/channews.rdf
http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi
http://python.de/backend.php
For more, see
http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all
The old Python "To-Do List" now lives principally in a
SourceForge reincarnation.
http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse
http://python.sourceforge.net/peps/pep-0042.html
 
The online Python Journal is posted at pythonjournal.cognizor.com.
[EMAIL PROTECTED] and [EMAIL PROTECTED]
welcome submission of material that helps people's understanding
of Python use, and offer Web presentation of your work.

*Py: the Journal of the Python Language*
http://www.pyzine.com

Archive probing tricks of the trade:

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.

Re: installing wxPython on Linux and Windows

2004-12-02 Thread Colin J. Williams
Jp Calderone wrote:
On Thu, 02 Dec 2004 15:29:53 +0100, Peter Maas <[EMAIL PROTECTED]> wrote:
Diez B. Roggisch schrieb:
Same task on Win2k: download wxPython-setup.exe, double-click, done.
Took me approx. 1 minute. This strikes me. Why are some tasks so hard
on Linux and so easy on Windows? After all wxPython/Win and wxPython/Lin
are made by the same developers. My guess: the software deployment
infrastructure on Linux needs to be improved.

On debian, it 

apt-get install wxPython2.5.3
I have heard praises of Debian's install system but Debian is quite
conservative with latest versions. There are some packages (e.g. Python,
PostgreSQL, Subversion) where I'd like to have the latest versions.
I don't want to be too tightly bound to the update cycles of the
Linux distribution.

[EMAIL PROTECTED]:~$ apt-cache show python2.4
Package: python2.4
Priority: optional
Section: python
Installed-Size: 10972
Maintainer: Matthias Klose <[EMAIL PROTECTED]>
Architecture: i386
Version: 2.3.97-2
Provides: python2.4-cjkcodecs
Depends: libbz2-1.0, libc6 (>= 2.3.2.ds1-4), libdb4.2, libncurses5 (>= 5.4-1), 
libreadline4 (>= 4.3-1), libssl0.9.7, zlib1g (>= 1:1.2.1)
Suggests: python2.4-iconvcodec | python2.4-japanese-codecs, 
python2.4-iconvcodec | python2.4-korean-codecs, python2.4-doc
Conflicts: python2.4-dev (<< 2.3.95-2)
Filename: pool/main/p/python2.4/python2.4_2.3.97-2_i386.deb
Size: 3503764
MD5sum: 519ed28c52bff645b311b8d5d27b2318
Description: An interactive high-level object-oriented language (version 2.4)
 Version 2.4 of the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
Package: python2.4
Status: install ok installed
Priority: optional
Section: python
Installed-Size: 9764
Maintainer: Matthias Klose <[EMAIL PROTECTED]>
Version: 2.3.90-1
Replaces: python2.4-xmlbase
Provides: python2.4-xmlbase
Depends: libbz2-1.0, libc6 (>= 2.3.2.ds1-4), libdb4.2, libncurses5 (>= 5.4-1), 
libreadline4 (>= 4.3-1), libssl0.9.7, zlib1g (>= 1:1.2.1)
Recommends: python2.4-iconvcodec | python2.4-cjkcodecs | 
python2.4-japanese-codecs, python2.4-iconvcodec | python2.4-cjkcodecs | 
python2.4-korean-codecs
Suggests: python2.4-doc
Conflicts: python2.4-xmlbase, python2.4-csv
Conffiles:
 /etc/python2.4/site.py b448b0f87294e041b8276ea3459df4a8
Description: An interactive high-level object-oriented language (version 2.4)
 Version 2.4 of the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
  This is a long and obnoxious way of pointing out that Python 2.4 is already 
available as a Python package :)  How much more up to date software can you ask 
for?
  And even if there are packages that aren't available, don't you think effort 
put into a packaging system would better be put into apt than an entirely new 
system that is guaranteed to be less useful than apt for many years?
  Jp
Or synaptic, which puts a GUI layer on top of apt.
Colin W.
--
http://mail.python.org/mailman/listinfo/python-list


Re: debian python2.4

2004-12-02 Thread Nick Vargish
km <[EMAIL PROTECTED]> writes:

> is there a debian binary of python2.4 ? 

root# apt-get update
root# apt-cache search python2.4

idle-python2.4 - An IDE for Python (v2.4) using Tkinter
python2.4 - An interactive high-level object-oriented language (version 2.4)
python2.4-dev - Header files and a static library for Python (v2.4)
python2.4-doc - Documentation for the high-level object-oriented language 
Python (v2.4)
python2.4-examples - Examples for the Python language (v2.4)
python2.4-gdbm - GNU dbm database support for Python (v2.4)
python2.4-tk - Tkinter - Writing Tk applications with Python (v2.4)

It sure looks like it's there.

Nick

-- 
#  sigmask  ||  0.2  ||  20030107  ||  public domain  ||  feed this to a python
print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?')
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: decorators ?

2004-12-02 Thread Michael Hudson
Skip Montanaro <[EMAIL PROTECTED]> writes:

> Jacek> Anything you can do with decorators, you could do before (with
> Jacek> the exception of rebinding the __name__ of functions).
> 
> And while that feature was added because we realized it would be nice if the
> decorated function could have the same name as the original function, it
> seems like that change could stand on its own merits.

Indeed.  I'd been meaning to do it for at least a year...

Cheers,
mwh

-- 
  Never meddle in the affairs of NT. It is slow to boot and quick to
  crash. -- Stephen Harris
   -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html
-- 
http://mail.python.org/mailman/listinfo/python-list


app with support for multiple Python versions

2004-12-02 Thread Steven Bethard
I have a friend developing an app that has bindings for a variety of
languages (e.g. Python, Perl, Tcl, Java, etc.).  In order to provide
the Python support, he uses tclpython
(http://jfontain.free.fr/tclpython.htm).  If he builds tclpython with,
say, Python 2.3, I have to download a source version of his app and
rebuild the Python support if I'm using Python 2.4.  This works fine
for me because I have no problem rebuilding the library, but for those
that don't want to rebuild libraries, it could be inconvenient.

Are there any options other than compiling a separate version of the
app for each Python version?

Thanks for your suggestions,

STeve
-- 
You can wordify anything if you just verb it.
--- Bucky Katt, Get Fuzzy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: disk based dictionaries

2004-12-02 Thread Steve
Hi Shivam,

If storing and retrieving is all that you are interested in, you
should consider 'pickling' your dicts, using python's pickle module.
It's part of the standard library.
Learn more about it here:
http://docs.python.org/lib/module-pickle.html

Here's an example usage:

[EMAIL PROTECTED] ~]$ python
Python 2.3.4 (#2, Aug 19 2004, 15:49:40) 
[GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> d = {'foo':'bar', 1:'ham', 'eggs':10}
>>> fl = open('mydict', 'wb')
>>> pickle.dump(d, fl)
>>> del(d)
>>> dir()
['__builtins__', '__doc__', '__file__', '__name__', 'fl', 'pickle']
>>> fl.close()
>>> fl = open('mydict')
>>> d = pickle.load(fl)
>>> d
{1: 'ham', 'eggs': 10, 'foo': 'bar'}
>>>

HTH
Regards
steve


On 02 Dec 2004 20:33:22 +0600, Shivram U <[EMAIL PROTECTED]> wrote:
> 
> Hi,
> 
>   I want to store dictionaries on disk. I had a look at a few modules
> like bsddb, shelve etc. However would it be possible for me to do the
> following
> 
> hash[1] = [1, 2, 3] where the key is an int and not a string
> 
> bsddb requires that both the key,value are string.
> shelve does support values being object but not the keys. Is there any
> module which support keys which are not strings
> 
> Also how do i use disk based hashes for multidimensional hashes such as
> below
> 
> #!/usr/bin/python
> 
> dict={}
> dict['key1'] = {}
> dict[('key1')][('key2')] = 'value'
> 
> key1=dict['key1']
> print key1['key2']
> 
> I have read of mxBeeDict but was unable to get it work properly. I am
> not sure if it supports what i need as i was unable to get any
> documentation about it. Is the module used widely ?
> 
> Below is how i am using the module
> 
> bdict = BeeDict('/tmp/beedict')
> 
> bdict[1] = 1
> print bdict.keys()
> 
> bdict.commit()
> bdict.close()
> 
> bdict1 = BeeDict('/tmp/beedict')
> print bdict1.keys()
> print bdict1.values()
> 
> Would it be that using disk based dictionaries once opened are as fast
> as in memory dictionaries ?
> 
> Thanks in advance,
> 
> Best Regards,
> Shivram U
> 
> Confidentiality Notice
> 
> The information contained in this electronic message and any attachments to 
> this message are intended
> for the exclusive use of the addressee(s) and may contain confidential or 
> privileged information. If
> you are not the intended recipient, please notify the sender at Wipro or 
> [EMAIL PROTECTED] immediately
> and destroy all copies of this message and any attachments.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


access to generator state

2004-12-02 Thread Neal D. Becker
I am converting optimization code from legacy C to python.  Generators are a
HUGE convenience, because the original code structures have the optimizer
as the main code calling your function, while I want to invert these roles. 
I want to call the optimizer to perform just one step at a time.

So, the optimizer must preserve it's state.  The classic way to do this is
with classes.  Problem is, I need to figure out just what variables need to
be preserved across calls.

Using yield, this is trivial to achieve.  All state is automatically saved.

Only one problem.  Is there any way to access the state of a generator
externally?  In other words, the generator saves all it's local variables. 
Can an unrelated object then query the values of those variables?  (In this
case, to get at intermediate results)

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


Why I can NOT use Python but PHP

2004-12-02 Thread Lad
I would like to set up my website and allow customers to choose
products there, including shopping carts. I would like to use Python
but it would be very complicated to start from nothing.
Why is there not any(?) framework or complete e-commerce solution
written in Python?
There are lots in PHP.One, very nice is http://www.oscommerce.org
Lad
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why I can NOT use Python but PHP

2004-12-02 Thread Steve Holden
Lad wrote:
I would like to set up my website and allow customers to choose
products there, including shopping carts. I would like to use Python
but it would be very complicated to start from nothing.
Why is there not any(?) framework or complete e-commerce solution
written in Python?
There are lots in PHP.One, very nice is http://www.oscommerce.org
Lad
I fail to see the point of asking for a finished product in Python 
that's already available in another language. Am I being dense? The 
obvious answer seems to be "If you like the oscommerce.org software then 
use it".

"I would like to use Python" implies this is a hobby, not a commercial 
enterprise, in which case it's easier to understand what's going on, and 
then the advice might be "Pick the PHP apart and use that as a quide for 
building similar functionality".

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


Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 2)

2004-12-02 Thread Gerrit
Cameron Laird wrote:
> Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Dec  2)

What is the frequency of the weekly Python-URL? (-;

regards,
Gerrit Holl.

-- 
Weather in Lulea / Kallax, Sweden 02/12 19:20:
-8.0ÂC Scattered clouds mostly cloudy wind 0.9 m/s None (34 m above 
NAP)
-- 
In the councils of government, we must guard against the acquisition of
unwarranted influence, whether sought or unsought, by the
military-industrial complex. The potential for the disastrous rise of
misplaced power exists and will persist.
-Dwight David Eisenhower, January 17, 1961
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: access to generator state

2004-12-02 Thread Kent Johnson
Neal D. Becker wrote:
Only one problem.  Is there any way to access the state of a generator
externally?  In other words, the generator saves all it's local variables. 
Can an unrelated object then query the values of those variables?  (In this
case, to get at intermediate results)

You could make the generator a method of a class and store the generator state in instance variables 
instead of local variables:

>>> class Gen:
...   def __init__(self):
... self.i = 0
...   def __call__(self):
... while True:
...   yield self.i
...   self.i += 1
...
>>> g=Gen()
>>> g.i
0
>>> iter=g()
>>> iter.next()
0
>>> g.i
0
>>> iter.next()
1
>>> g.i
1
HTH
Kent
--
http://mail.python.org/mailman/listinfo/python-list


Galois field

2004-12-02 Thread Roie Kerstein
I am looking for a python package that deals with galois fields.

Does anybody know where can I find it?

Thank in advance
-- 
Best regards
Roie Kerstein

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


Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 2)

2004-12-02 Thread Thomas Heller
Gerrit <[EMAIL PROTECTED]> writes:

> Cameron Laird wrote:
>> Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Dec  2)
>
> What is the frequency of the weekly Python-URL? (-;

According to the name, about 1.6 µHz.

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


Re: debian python2.4

2004-12-02 Thread Jordi Romero (qiz/jrom)
Just remove /usr/bin/python and make a new soft link to the 
/usr/bin/python2.4 (ln -s /usr/bin/python2.4 /usr/bin/python)

Jonas Galvez wrote:
km wrote:
 

Only
downside is that /usr/bin/python still points to 2.3.4. Haven't
figured out how to change that, but I am also afraid it would break
mod_python so I decided to keep it unchanged for now.
--
http://jonasgalvez.com
http://codeazur.com.br
 

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


Re: access to generator state

2004-12-02 Thread Peter Otten
Neal D. Becker wrote:

> Only one problem.  Is there any way to access the state of a generator
> externally?  In other words, the generator saves all it's local variables.
> Can an unrelated object then query the values of those variables?  (In

You get read access with generator.gi_frame.f_locals and can mess (as
always) with mutable variables, but not rebind the local variables:

>>> def gen():
... a = 2
... b = [3]
... yield a*b[0]
... yield a*b[0]
...
>>> g = gen()
>>> g.gi_frame.f_locals
{}
>>> g.next()
6
>>> g.gi_frame.f_locals
{'a': 2, 'b': [3]}
>>> g.gi_frame.f_locals["a"] = 137 # has no effect
>>> g.gi_frame.f_locals["b"][0] = 42
>>> g.next()
84
>>> g.gi_frame.f_locals
{'a': 2, 'b': [42]}

Peter

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


Re: access to generator state

2004-12-02 Thread Sean Ross

"Neal D. Becker" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am converting optimization code from legacy C to python.  Generators are
a
> HUGE convenience, because the original code structures have the optimizer
> as the main code calling your function, while I want to invert these
roles.
> I want to call the optimizer to perform just one step at a time.
>
> So, the optimizer must preserve it's state.  The classic way to do this is
> with classes.  Problem is, I need to figure out just what variables need
to
> be preserved across calls.
>
> Using yield, this is trivial to achieve.  All state is automatically
saved.
>
> Only one problem.  Is there any way to access the state of a generator
> externally?  In other words, the generator saves all it's local variables.
> Can an unrelated object then query the values of those variables?  (In
this
> case, to get at intermediate results)
>


>>> def twice():
...  for i in range(0,2):
...   yield i
...
>>> gen = twice()
>>> gen.gi_frame.f_locals
{}
>>> gen.next()
0
>>> gen.gi_frame.f_locals
{'i': 0}
>>> gen.next()
1
>>> gen.gi_frame.f_locals
{'i': 1}
>>> gen.next()
Traceback (most recent call last):
  File "", line 1, in ?
StopIteration
>>>

HTH,
Sean


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


Re: debian python2.4

2004-12-02 Thread Jonas Galvez
km wrote:
> is there a debian binary of python2.4 ?

Not yet, I guess, but I could easily compile it from the source (I'm
no Linux expert, I simply followed the instructions: ./configure,
make, make install, and voilà). No error messages, no nothing. Only
downside is that /usr/bin/python still points to 2.3.4. Haven't
figured out how to change that, but I am also afraid it would break
mod_python so I decided to keep it unchanged for now.


--
http://jonasgalvez.com
http://codeazur.com.br
--
http://mail.python.org/mailman/listinfo/python-list


Re: access to generator state

2004-12-02 Thread Tim Peters
[Neal D. Becker]
> ... 
> Only one problem.  Is there any way to access the state of a
> generator externally?  In other words, the generator saves all it's
> local variables.  Can an unrelated object then query the values of
> those variables?  (In this case, to get at intermediate results)

It's the same as asking whether you can peek at the internal state of
any function -- "a generator" in CPython is really just a Python
function stack frame, essentially the same as a non-generator's stack
frame.  The primary difference is that when a function returns, its
frame is decref'ed and typically gets garbage-collected then; when a
generator yields, its frame isn't decref'ed, and the
generator-iterator holds on to the frame for resumption.  In this
sense, Python's generators are quite literally "resumable functions".

Python-the-language doesn't define any way to peek inside one function
from another.  CPython-the-implementation can be exploited, as a
generator-iterator in CPython has a gi_frame attribute referencing the
frame.  You can pick that apart in Python like any other CPython stack
frame.  For example, here's a toy program:

"""
def fib(a, b):
i = 0
yield a
i = 1
yield b
while True:
started_loop = True
i, a, b = i+1, b, a+b
yield b
if b > 12:
break

f = fib(0, 1)
for val in f:
print val, f.gi_frame.f_locals
"""

and here's its output:

0 {'i': 0, 'a': 0, 'b': 1}
1 {'i': 1, 'a': 0, 'b': 1}
1 {'i': 2, 'a': 1, 'b': 1, 'started_loop': True}
2 {'i': 3, 'a': 1, 'b': 2, 'started_loop': True}
3 {'i': 4, 'a': 2, 'b': 3, 'started_loop': True}
5 {'i': 5, 'a': 3, 'b': 5, 'started_loop': True}
8 {'i': 6, 'a': 5, 'b': 8, 'started_loop': True}
13 {'i': 7, 'a': 8, 'b': 13, 'started_loop': True}

Note some subtleties:  despite possible appearance, it's *not* the
case that the local vrbl 'started_loop' doesn't exist before it's
assigned to.  Local variables are wholly determined at compile time,
and all exist as soon as a function is entered.  Locals aren't
normally represented internally in a dict, either.  That you see a
dict at all here, and that it suppresses entries for unbound locals,
is all the result of fancy code executed as a side effect of
referencing the "f_locals" attribute of a frame (f_locals is akin to a
Python property with a "getter" function).

Note too that, as when getting a dict via the locals() builtin inside
a function, mutating the dict has no defined effect (it may or may not
have any visible effect, depending on accidents that aren't, and never
will be, documented or guaranteed).
-- 
http://mail.python.org/mailman/listinfo/python-list


RotatingFileHandler

2004-12-02 Thread Kamus of Kadizhar
I'm having a problem with logging.  I have an older app that used the
RotatingFileHandler before it became part of the main distribution (I
guess in 2.3).

It worked fine then.  Now I get:

[EMAIL PROTECTED] bin]# ./mplayer.py file://test.avi
//test.avi
Traceback (most recent call last):
  File "./mplayer.py", line 40, in ?
logFile.emit(movieName)
  File 
"/usr/src/build/394694-i386/install/usr/lib/python2.3/logging/handlers.py", 
line 102, in emit
  File 
"/usr/src/build/394694-i386/install/usr/lib/python2.3/logging/__init__.py", 
line 567, in format
  File 
"/usr/src/build/394694-i386/install/usr/lib/python2.3/logging/__init__.py", 
line 362, in format
AttributeError: 'str' object has no attribute 'getMessage'

The offending snippet of code is:

   logFile = 
logging.handlers.RotatingFileHandler('/var/log/user/movies2.log','a',2000,4)
   logFile.emit(movieName)

I don't see anything wrong with this, but I'm a relative python bonehead.

movieName contains the string 'test.avi' at the time of the crash.

What's going on?  Anything I need to look at?

--Kamus

-- 
   o   |
 o__  >[]  | A roadie who doesn't ride a mountain bike has no soul.
 ,>/'_/\   | But then a mountain biker who doesn't ride a road bike has no 
legs...
(_)\(_)   \ \  | -Doug Taylor, alt.mountain-bike

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


Re: recombination variations

2004-12-02 Thread Scott David Daniels
Hung Jung Lu wrote:
... expand = lambda t: reduce(lambda r, s: [x+y for x in r 
>for y in alphabet[s]], t, [''])
print expand('ATSGS')
Or, for a more verbose version:
multis = dict(W='AT', M='AC', R='AG', Y='TC', K='TG', S='CG',
  H='ATC', D='ATG', V='AGC', B='CTG', N='ATCG')
def expanded(string, expansions=multis):
result = ''
for pos, char in enumerate(string):
if char in multis:
break
else:
yield string
raise StopIteration
parts = multis[char]
prelude, string = string[:pos], string[pos+1:]
for expansion in expanded(string, multis):
for middle in parts:
yield prelude + middle + expansion
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why I can NOT use Python but PHP

2004-12-02 Thread Roie Kerstein
Lad wrote:

> Why is there not any(?) framework or complete e-commerce solution
> written in Python?

There is a framework written in python.
It is called zope.
www.zope.org

If you will search well, I am quite sure you will also find a complete
e-commerce solution.

-- 
Best regards
Roie Kerstein

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


Re: non blocking read()

2004-12-02 Thread Donn Cave
In article <[EMAIL PROTECTED]>,
 Greg Ewing <[EMAIL PROTECTED]> wrote:

> Donn Cave wrote:
> > If we are indeed talking about a pipe or something that
> > really can block, and you call fileobject.read(1024),
> > it will block until it gets 1024 bytes.
> 
> No, it won't, it will block until *some* data is
> available, and then return that (up to a maximum of
> 1024).

You can test this on your platform, I will append
a 9 line program.   For me, fileobject.read blocks
until all the requested data can be returned.

> If the fd has just been reported by select() as ready
> for reading, then something is there, so the first
> read() call won't block. But if there was exactly
> 1024 bytes there, the second read() call *will* block,
> because there are now 0 bytes available (which I think
> is what an earlier poster was hinting at).
> 
> For this reason, if you have no way of knowing how
> much data to expect in advance, it's better to avoid
> making more than one read() call on a fd per select().
> If you don't get a whole line (or whatever chunk you're
> looking for), put what you've got into a buffer, and
> go back to select(). When you've built up a complete
> chunk in the buffer, process it. Keep in mind that
> part of the next chunk may be in the tail of the
> buffer, so be prepared to chop a chunk off the
> beginning of the buffer and leave the rest for later.

Yes, this looks right to me, but I think we're talking
about os.read(), not fileobject.read().

> Another possibility that's been suggested is putting
> the fd into non-blocking mode. I wouldn't recommend
> that; the last time I tried it (which was quite a long
> time ago) select() and non-blocking I/O didn't mix
> well. While it may be possible to get it to work, I
> don't think you'd gain much. You need to understand
> that there's no guaranteed relationship between the
> chunks of data written to one end of a pipe or socket
> and those returned by reading the other end. So you'd
> still need to be prepared to buffer and re-chunk the
> data. You'd end up doing all of what I outlined above,
> with the extra complication of non-blocking I/O thrown
> in. I don't see any advantage in it.

Exactly.

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


Re: pre-PEP generic objects

2004-12-02 Thread Scott David Daniels
Nick Craig-Wood wrote:
Scott David Daniels <[EMAIL PROTECTED]> wrote:
You can simplify this:
class Hash(object):
 def __init__(self, **kwargs):
 for key,value in kwargs.items():
 setattr(self, key, value)
 __getitem__ = getattr
 __setitem__ = setattr
That doesn't work unfortunately...
h['a']
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: getattr expected at least 2 arguments, got 1
I'm not exactly sure why though!
I could have sworn I tested this, but I must have accidentally
tested h.a rather than h['a'].  I don't know why it doesn't work either.
For example:
def gattr(*args): return getattr(*args)
def sattr(*args): return setattr(*args)
class Hash(object):
 def __init__(self, **kwargs):
 for key,value in kwargs.items():
 setattr(self, key, value)
 __getitem__ = gattr
 __setitem__ = sattr
does work.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


help running python in a limited interpreted environment

2004-12-02 Thread Mike
We have a large c++ program that runs under Windows NT Embedded to
control an instrument.  That program has been written to run external
python scripts.  The computer where this code runs does not and cannot
have a full python installation.  It ONLY has the pythonNN.dll file
that comes with a full python installation.

For simple scripts that do not import external modules, this works just
fine.

For more complex scripts that require imported external modules, the
called modules (.py) have been placed on the computer in the same
folder as the calling script.  However, when the calling scripts run,
we get the error message:

AttributeError: 'module' object has no attribute 'xxx'

We know the calling script finds the necessary modules, and the
attribute clearly appears in the module's .py file.

Can anyone tell me what the problem is or if what we're trying to do is
not possible?  Is there something in addition to the .dll that needs to
be present?

Thanks.

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


How is Python designed?

2004-12-02 Thread Limin Fu
Hello,
Is there any technical description on internet of how
python is designed? Or can somebody give a short
description about this? I'm just curious.
Thanks in advance,
Limin




__ 
Do you Yahoo!? 
Yahoo! Mail - You care about security. So do we. 
http://promotions.yahoo.com/new_mail
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pre-PEP generic objects

2004-12-02 Thread Jp Calderone
On Thu, 02 Dec 2004 12:26:31 -0800, Scott David Daniels <[EMAIL PROTECTED]> 
wrote:
>Nick Craig-Wood wrote:
> > Scott David Daniels <[EMAIL PROTECTED]> wrote:
> >> You can simplify this:
> >> class Hash(object):
> >>  def __init__(self, **kwargs):
> >>  for key,value in kwargs.items():
> >>  setattr(self, key, value)
> >>  __getitem__ = getattr
> >>  __setitem__ = setattr
> > That doesn't work unfortunately...
> h['a']
> > 
> > Traceback (most recent call last):
> >   File "", line 1, in ?
> > TypeError: getattr expected at least 2 arguments, got 1
> > 
> > I'm not exactly sure why though!
> 
> I could have sworn I tested this, but I must have accidentally
> tested h.a rather than h['a'].  I don't know why it doesn't work either.
> For example:
> 
>  def gattr(*args): return getattr(*args)
>  def sattr(*args): return setattr(*args)
>  class Hash(object):
>   def __init__(self, **kwargs):
>   for key,value in kwargs.items():
>   setattr(self, key, value)
>   __getitem__ = gattr
>   __setitem__ = sattr
> 
> does work.

>>> def getattr2(obj, name, value):
... return getattr(obj, name, value)
... 
>>> class X:
... a = getattr
... b = getattr2
... 
>>> X.a

>>> X.b

>>> type(getattr)

>>> type(getattr2)

>>> 

  When the class object is created, the namespace is scanned for instances of 
.  For those and only those, a descriptor is created which 
will produce bound and unbound methods.  Instances of other types, such as 
 or , are ignored, leading to 
the critical difference in this case:

>>> X().a

>>> X().b
>
>>> 

  No bound method for getattr, hence trying to call it with two arguments 
fails, as it has no self on which to operate.

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


Any affordable Python-based CRM & ERP solutions?

2004-12-02 Thread Will
Hi all,

Please excuse the longish post. I'm new to Python (and programming),
but love what I see and believe it to be an important language.

I have (at least) one retail client (with single outlet at present)
that requires a total business solution for their operation,
preferably open source. They need:

- an ecommerce website providing sales, customer service, order
tracking and an opt-in newsletter
- system for tracking inventory
- full accounting system, tied-into the ecommerce website-- so full
front-end and back-end system integration
- possibly even point of sale tied-into the above.

They've been using Windows up until now, but are happy to consider
Linux, BSD, Mac, etc, as long as there's not a huge learning curve
(they merely want a solution that works and is cost-effective). Other
than standard accounting reporting requirements, they need the ability
to add tax to local transactions.

I have Googled with not a lot of contenders (Compiere--
http://www.compiere.org/index.html -- not Python and an Oracle license
is required to run it; and I've just started reading about Bizar
Shop-- http://www.bizarshop.com.au/). Anything else I've seen is
either really expensive, doesn't fit the bill, or are not Python-based
(which I'd ultimately like to promote).

Because of the above requirements I was thinking something quite
modular (that could be added to in future) would be the way to go. I
like what I have seen with Plone and Zope but am unsure at present
(given limited experience with these products) how one would integrate
something into those solutions (if package didn't come from one
'vendor'), so that at least on the surface, everything appeared pretty
seamless.

Is this wishful thinking in Python at present? If so, have you
encountered any other open source solutions that cover part of the
above with Python handling the rest (and being easily integrated)?

I look forward to any feedback. Thanks very much in advance.

Cheers,

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


inheritance problem with 2 cooperative methods

2004-12-02 Thread Dan Perl
Here is a problem I am having trouble with and I hope someone in this group 
will suggest a solution.  First, some code that works.  3 classes that are 
derived from each other (A->B->C), each one implementing only 2 methods, 
__init__ and setConfig.
---
#!/usr/bin/python
class A (object):
   def __init__(self):
  super(A, self).__init__()
  self.x = 0
   def setConfig(self, config):
  self.x += config['x']

class B (A):
   def __init__(self):
  super(B, self).__init__()
  self.y = 0
   def setConfig(self, config):
  super(B, self).setConfig(config)
  self.y += config['y']

class C (B):
   def __init__(self):
  super(C, self).__init__()
  self.z = 0
   def setConfig(self, config):
  super(C, self).setConfig(config)
  self.z += config['z']

config = {'x':1, 'y':2, 'z':3}
alpha = A()
alpha.setConfig(config)
print alpha.x
beta = B()
beta.setConfig(config)
print beta.x, beta.y
beta.setConfig(config)
print beta.x, beta.y
gamma = C()
gamma.setConfig(config)
print gamma.x, gamma.y, gamma.z
gamma.setConfig(config)
print gamma.x, gamma.y, gamma.z
--

The output from that code is:
1
1 2
2 4
1 2 3
2 4 6

So far, so good!  But let's assume that I want to change the __init__ 
methods so that they take a configuration as an argument so the objects are 
created and configured in one step, like this:
alpha = A(config)

How can the code be changed to implement this?  It is tempting to modify the 
__init__ methods like this:
class A (object):
   def __init__(self, config):
  super(A, self).__init__(config)
  self.x = 0
  A.setConfig(self, config)

However, if implemented this way, the output is:
1
2 2
3 4
3 4 3
4 6 6

This shows that setConfig gets called more than once because both __init__ 
and setConfig are cooperative methods.

I have been thinking about this for a day now and I cannot find a good 
solution.  I imagine this would be a common problem and that there would be 
a recipe somewhere, but I couldn't find one (I looked in the Python 
Cookbook).  I've thought of creating 2 separate methods instead of 
setConfig, one that does the "local" configuration and another one that 
takes care of invoking super.  But I don't like the idea of creating 2 
methods in each class and I haven't been able to think of a way to solve the 
problem with just one change in the base class that would be inherited by 
all the subclasses.

Anyone has any ideas?  Thanks.

Dan 


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


Re: "encoding specified in XML declaration is incorrect"

2004-12-02 Thread "Martin v. Löwis"
Gustaf Liljegren wrote:
f.write(header + self.all + footer)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 
745-751: ordinal not in range(128)

The XML declaration should be enough to tell the encoding. 
Sure, but that does not help at all. self.all is a Unicode string;
information about its original encoding is not available anymore.
If you want to write self.all to f, you need to encode it explicitly,
e.g.
  f.write(header + self.all.encode("koi8-r") + footer)
Instead of koi8-r, you should use the enccoding of f, of course.
u = unicode(s, "utf-8")
xml.sax.parseString(u, MyParser())
This is not really supposed to work (yet). You need to pass
byte strings to xml.sax.parseString, not Unicode strings.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: pickle and py2exe

2004-12-02 Thread Justin Straube
On Tue, 30 Nov 2004 22:48:39 -0600, "Catfish" <[EMAIL PROTECTED]> wrote:

>I did this a while back, and I can't remember exactly. Therefore, I may only 
>be able to give you a push in the right direction until someone else can 
>answer it fully.
>
>However, I think you have to force the db into the py2exe compile. I think 
>it's something like this:
>
>--force-imports dbhash
>
>Try this and see if it works.

Thanks Catfish, 

This brought up an error, option: --force-import not recognized. 

While looking into this, I had seen some mention of protocol option in pickle. I
hadnt specified anything for protocol, so it defaults to 0 though I dont know
what that is. Its my first time using pickle and second with py2exe. 

Thanks for the suggestion, Ill keep trying at this and another idea without
pickle.

Justin

>"Justin Straube" <[EMAIL PROTECTED]> wrote in message 
>news:[EMAIL PROTECTED]
>> Hello,
>>
>> Im trying to compile a script with py2exe. The pickle module is causing 
>> the
>> program to give an error.
>>
>> Traceback (most recent call last):
>>  File "SETIstat.pyw", line 330, in ?
>>  File "SETIstat.pyw", line 84, in start_up
>>  File "SETIstat.pyw", line 79, in config_load
>>  File "pickle.pyc", line 1390, in load
>>  File "pickle.pyc", line 872, in load
>>  File "pickle.pyc", line 985, in load_string
>> LookupError: unknown encoding: string-escape
>>
>> the data in the pickled file is a dictionary containing a couple strings. 
>> The
>> strings do contain \n and \t charaters but no other special characters or
>> anything.
>>
>> Does anyone have any suggestions to what I can try to get around this? The
>> pickle module works fine when the .pyw file is run. Its only when I 
>> compile this
>> is there an issue.
>>
>> Thanks for any help,
>>
>> Justin 
>

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


RE: RotatingFileHandler

2004-12-02 Thread Robert Brewer
Kamus of Kadizhar wrote:
> I'm having a problem with logging.  I have an older app that used the
> RotatingFileHandler before it became part of the main distribution (I
> guess in 2.3).
> 
> It worked fine then.  Now I get:
> 
> [EMAIL PROTECTED] bin]# ./mplayer.py file://test.avi
> //test.avi
> Traceback (most recent call last):
>   File "./mplayer.py", line 40, in ?
> logFile.emit(movieName)
>   File 
> "/usr/src/build/394694-i386/install/usr/lib/python2.3/logging/
> handlers.py", line 102, in emit
>   File 
> "/usr/src/build/394694-i386/install/usr/lib/python2.3/logging/
> __init__.py", line 567, in format
>   File 
> "/usr/src/build/394694-i386/install/usr/lib/python2.3/logging/
> __init__.py", line 362, in format
> AttributeError: 'str' object has no attribute 'getMessage'
> 
> The offending snippet of code is:
> 
>logFile = 
> logging.handlers.RotatingFileHandler('/var/log/user/movies2.lo
> g','a',2000,4)
>logFile.emit(movieName)

Making a quick run-through of the logging module, it looks like you need
to have a Formatter object added to your Handler:

filename = '/var/log/user/movies2.log'
logFile = logging.handlers.RotatingFileHandler(filename,'a',2000,4)
formatter = logging.Formatter()
logFile.setFormatter(formatter)

...then you can call emit.



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


What to use for installation?

2004-12-02 Thread Eugene Morozov
Hello!
I wrote a crossplatform Glade/GTK+ application for learning foreign 
languages (it is called Snakememory but doesn't have site in English yet).

Currently it works from the directory where it was unpacked. But I need 
installation script that will compile and install translations, install 
application on Unix or create installation bundle for Windows.

I have a three choices: distutils, make and scons. I think that 
distutils can't handle many tasks and make will require installing the 
whole cygwin for packaging on Windows, so the only remaining choice is 
scons.

But I want to know other opinions before going with scons. What is the 
best tool for installing python applications?
Eugene
--
http://mail.python.org/mailman/listinfo/python-list


RE: decorators ?

2004-12-02 Thread Delaney, Timothy C (Timothy)
Michael Hudson wrote:

> Skip Montanaro <[EMAIL PROTECTED]> writes:
> 
>> Jacek> Anything you can do with decorators, you could do before
>> (with Jacek> the exception of rebinding the __name__ of
>> functions). 
>> 
>> And while that feature was added because we realized it would be
>> nice if the decorated function could have the same name as the
>> original function, it seems like that change could stand on its own
>> merits. 
> 
> Indeed.  I'd been meaning to do it for at least a year...

Ah - looking for any old excuse to get it in huh? 

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


efficient intersection of lists with rounding

2004-12-02 Thread Gordon Williams
Hi,

I have to lists that I need to find the common numbers (2nd rounded to
nearest integral) and I am wondering if there is a more efficient way of
doing it.

>>> a= [(123,1.3),(123,2.4),(123,7.8),(123,10.2)]
>>> b= [(123, 0.9), (123, 1.9), (123, 8.0)]
>>> [ (i,round(j)) for i,j in a for l,m in b if (i,round(j)) ==
(l,round(m))]
[(123, 1.0), (123, 2.0), (123, 8.0)]
>>>
This works but a and b can be in the order of 30K long.

A couple of other bits of info.
- a and b are ordered smallest to largest (could bisect module be used?)
- in the future I will want to round the second number of closest 0.25
rather than whole number.

Would the sets module be more efficient?

I'm using python 2.3.

Thanks for any ideas.

Regards,

Gordon Williams

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


PySQLite Table indexing inside a functions

2004-12-02 Thread Kevin
Hello Everyone,

I'm using PySQLite and would like to index this insert
statement with the 'tablename'.  Can anyone offer a
suggestion?

Also, this is a shot in the dark.  Has anyone done
anything with nested fields.  I would like each vertex
to have 3 points.  currently, I'm just making 3
fields.

Regards,
   Kevin



def PARSE2DB(data,tablename):
i = j = k = 0
cadu = GETdb().cursor()
FacetNum = len(data [1])
while i < FacetNum:
cadu.execute("""
insert into table = 'tablename'( V1_x, V1_y, V1_z,
V2_x, V2_y, V2_z,
 V3_x, V3_y, V3_z, N_x, 
N_y, N_z)
values(%f, %f, %f, %f, %f, %f, %f, %f, 
%f, %f,
%f, %f)
""",
(data [1][i][1][0][0], data [1][i][1][0][1],data
[1][i][1][0][2],
data [1][i][1][1][0], data [1][i][1][1][1],data
[1][i][1][1][2],
data [1][i][1][2][0], data
[1][i][1][2][1],data [1][i][1][2][2],
data [1][i][0][0], data
[1][i][0][1], data [1][i][0][2])
)
i = i + 1

return 




__ 
Do you Yahoo!? 
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle and py2exe

2004-12-02 Thread Justin Straube
On 1 Dec 2004 11:45:59 -0800, [EMAIL PROTECTED] (Johan Lindberg) wrote:


>Have you included string-escape encoding in your setup.py?
>My guess is that you can fix the problem with something similar to:
>
> from distutils.core import setup
> import py2exe
> opts = { "py2exe": { "packages": ["encodings"], } }
> setup(windows= ["spam.py"], options= opts)
>
>in your setup.py.
>
>Hope it helps
>/Johan Lindberg

Thanks Johan,  but unfortunately the same traceback is given in the log. 
I should have mentioned in my previous post that Im using win2000, if it matters
any. 

Thanks,

Justin
>> Im trying to compile a script with py2exe. The pickle module is causing the
>> program to give an error.
>> 
>> Traceback (most recent call last):
>>   File "SETIstat.pyw", line 330, in ?
>>   File "SETIstat.pyw", line 84, in start_up
>>   File "SETIstat.pyw", line 79, in config_load
>>   File "pickle.pyc", line 1390, in load
>>   File "pickle.pyc", line 872, in load
>>   File "pickle.pyc", line 985, in load_string
>> LookupError: unknown encoding: string-escape
>> 
>> the data in the pickled file is a dictionary containing a couple strings. The
>> strings do contain \n and \t charaters but no other special characters or
>> anything. 
>> 
>> Does anyone have any suggestions to what I can try to get around this? The
>> pickle module works fine when the .pyw file is run. Its only when I compile
>> this is there an issue. 
>> 
>> Thanks for any help,
>> 
>> Justin
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How is Python designed?

2004-12-02 Thread Timo Virkkala
Limin Fu wrote:
Hello,
Is there any technical description on internet of how
python is designed? Or can somebody give a short
description about this? I'm just curious.
Do you mean the structure and design of the language, or the process of 
designing the language?

Well, in either case, you'll probably find your answer at http://www.python.org
Take a look at the Docs -> Language Reference and PEP sections.
--
Timo Virkkala
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 and Tkinter

2004-12-02 Thread Jeffrey Barish
Jean Brouwers wrote:

> 
> Here is how we understand this (which may be incomplete and/or
> incorrect).
> 
> The _tkinter module is a shared library _tkinter.o and that is built
> from C source file _tkinter.c.  That C file and a few other tk related
> C files are included in the Python distribution.
> 
> But the Tcl/Tk libraries to build the _tkinter module are coming from
> /usr/local/lib in our case.  And those happens to be tcl83 and tk83 in
> our case.
> 
> If the Tcl/Tk libraries (and include files) are missing, you will have
> to get and install those.  But they are not part of the Python
> distribution, as far as we know.
> 
> /Jean Brouwers
> 
> 
> 
> In article <[EMAIL PROTECTED]>,
> Jeffrey Barish <[EMAIL PROTECTED]> wrote:
> 
>> Jean Brouwers wrote:
>> 
>> > 
>> > FWIW, we just installed Python 2.4 (on RH Linx 8), rebuilt it from
>> > scratch and everything is fine.  Tkinter is there, _tkinter as well
>> > and idle comes up as expected.
>> > 
>> > /Jean Brouwers
>> > 
>> > 
>> > 
>> > In article <[EMAIL PROTECTED]>,
>> > Jeffrey Barish <[EMAIL PROTECTED]> wrote:
>> > 
>> >> http://www.python.org/moin/TkInter
>> 
>> Here's what I get when I import Tkinter at a python prompt:
>> 
>> [EMAIL PROTECTED]:~$ python
>> Python 2.4 (#1, Nov 30 2004, 08:58:13)
>> [GCC 3.2.3 20030316 (Debian prerelease)] on linux2
>> Type "help", "copyright", "credits" or "license" for more
>> information.
>> >>> import Tkinter
>> Traceback (most recent call last):
>>   File "", line 1, in ?
>>   File "/usr/local/lib/python2.4/lib-tk/Tkinter.py", line 38, in ?
>> import _tkinter # If this fails your Python may not be configured
>> for Tk
>> ImportError: No module named _tkinter
>> 
>> I tried make clean and make.  Same result.  Ah, now I see that the
>> output from make includes:
>> 
>> INFO: Can't locate Tcl/Tk libs and/or headers
>> 
>> Aren't the libs and headers included in Python-2.4.tgz?

OK, I downloaded tcl8.4.8 and tk8.4.8.  They are now installed.  Back to
python2.4 make.  It now bombs at:

gcc -pthread -shared build/temp.linux-i686-2.4/_tkinter.o
build/temp.linux-i686-2.4/tkappinit.o -L/usr/X11R6/lib64
-L/usr/X11R6/lib -L/usr/local/lib -ltk8.4 -ltcl8.4 -lX11 -o
build/lib.linux-i686-2.4/_tkinter.so
*** WARNING: renaming "_tkinter" since importing it failed: libtk8.4.so:
cannot open shared object file: No such file or directory
running build_scripts

Here's what I don't get:

[EMAIL PROTECTED]:/tmp/Python-2.4# ls -l /usr/local/lib/libtk8.4.so
-rwxr-xr-x1 root staff  893866 2004-12-02
15:28 /usr/local/lib/libtk8.4.so

The library is there but gcc claims that it isn't.  Any suggestions?
-- 
Jeffrey Barish

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


Re: What to use for installation?

2004-12-02 Thread Roger Binns
"Eugene Morozov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> But I want to know other opinions before going with scons. What is the best 
> tool for installing python applications?

The tools you mention are actually more applicable to Python packages
in that they install the code into an existing Python install on
the machine.

For applications most people want standalone programs that the user
doesn't know or care is written in Python and doesn't have any
dependencies on things already installed on their system.

In that case you can use a Freezing tool which will package up
an executable stub, your code, the interpretter dll/so and other
binary/source modules you may use (eg GTK in your case).  This
will give you a single directory with no dependcies that will
run your program.

Then you can use an installer that is platform specific.  For
example on Windows you'll want the program to install from a
setup.exe and be in the Add/Remove programs list in the Contol
Panel.  On Linux you'll want it added to KDE/Gnome user menus.

For freezing tools, there are:

  - cx-Freeze (Windows, Linux, Mac?)
  - py2exe (Windows)
  - McMillan Installer (Windows, Linux, Mac?)
  - py2app (Mac)
  - bundlebuilder (Mac)

For installers, there are:

  - InnoSetup (Windows)
  - NSIS  (Windows)
  - rpm/dpkg (Linux)
  - dimg tools (Mac)
  - EPM (Linux/Unix)

IMHO the best of breed are

Windows:  py2exe/InnoSetup
Linux:cx-Freeze/rpm
Mac:  py2app/dimg

Other people use other combinations and have their favourites.

You can see some slides from a talk I did a while back that
goes into a little more detail, as well as giving an idea
of how much "code"/templates were written for the bitpim
project to use a freezer/installer on Windows, Linux and Mac.

http://bitpim.org/papers/baypiggies/

(See slides 18 thru 22).

Roger 


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


Pythonic use of CSV module to skip headers?

2004-12-02 Thread Ramon Felciano
Hi --

I'm using the csv module to parse a tab-delimited file and wondered
whether there was a more elegant way to skip an possible header line.
I'm doing

line = 0
reader = csv.reader(file(filename))
for row in reader:
if (ignoreFirstLine & line == 0):
continue
line = line+1
# do something with row

The only thing I could think of was to specialize the default reader
class with an extra skipHeaderLine constructor parameter so that its
next() method can skip the first line appropriate. Is there any other
cleaner way to do it w/out subclassing the stdlib?

Thanks!

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


  1   2   >