Re: Displaying formatted - data with TKinter

2005-05-02 Thread dimitri pater
hello,
take a look at the multilistbox:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52266
http://www.haucks.org/download/MultiListbox.py.gz

I use it for this purpose, it looks quite nice

regards,
DimitriOn 1 May 2005 19:10:19 -0700, custard_pie <[EMAIL PROTECTED]> wrote:
Hi,..I found it difficult to display data from a dictionary using GUI.What widget should I use? I tried using text widget, but I couldn't getthe display I want. I need the display to look like thisfile
name  
size  
agelocationfdssfdfsa
3034safasfafsfdsaasdfafdsafs  
4556asdffdsafsdAnd I'm getting the display from inside a dictionary that holds list asits value. Any suggestion on what I should use to display the data inthat format??--
http://mail.python.org/mailman/listinfo/python-list-- Please visit dimitri's website: www.serpia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

What's this error then?

2005-05-02 Thread Sara Khalatbari
You remember me asking about running a program in my
code...I got a problem here

I copied the msgfmt here :

[EMAIL PROTECTED] HEADER]$ ls
allsamples  
Backup   
file-roller.HEAD.fa.po  
msgfmt.py
header.py  


& my code is:
#! /usr/bin/env python

import os
from os import execl

os.execl ('/home/sara/PYTHON/HEADER/msgfmt.py',
'file-roller.HEAD.fa.po')


But when I run it, this Error raises:
[EMAIL PROTECTED] HEADER]$ python run.py
/usr/bin/env: python2.2: No such file or directory

Do you have any solutions?

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MRO problems with diamond inheritance?

2005-05-02 Thread Michele Simionato
John & Sarah:
> Incidentally, is it safe to have an mro() method in a class, > or is
this
> as reserved as the usual __reserved_words__? Does Python > use mro()
(as
> opposed to __mro__) internally or anything?

.mro() is a metamethod, it is a method of the metaclass, not of the
class. So you can override it without problems, and still access it as
type.mro(cls).

For more about metamethods see
http://www-128.ibm.com/developerworks/linux/library/l-pymeta2/index.html

   Michele Simionato

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


Re: Design advice for unit test asserters

2005-05-02 Thread Edvard Majakari
"Gary" <[EMAIL PROTECTED]> writes:

Hi again,

> First, thanks to both Kent and Edvard for useful comments.  
> I certainly need to consider whether it make sense to switch to py.test at
> this time; its simplicity is attractive.

For what it's worth, I've also coded a simple py.test skeleton generator,
which does have some funky features like creating working tests using existing
doctest strings in the module. For simple cases, tests work out of the box,
but mostly I use it to save typing. Of course, you'd be better off using TDD,
but the program can help you there too; it is able to create a module skeleton
out of py.test suite, though it is not very mature yet. You can grab it from
http://majakari.net/dl/pytestgen/ if you wish to try it.

-- 
# Edvard Majakari   Software Engineer
# PGP PUBLIC KEY available  Soli Deo Gloria!
One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer
Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however, was 
not full of lettuces. This did not seem fair.  --Mr Bunnsy has an adventure 
-- 
http://mail.python.org/mailman/listinfo/python-list


[no subject]

2005-05-02 Thread rijish valoorthodi rajan

  
hello all
I am a member of a team dedicated to make a client server database application and our main concern is the speed with which the system performs. we are very new to python. but after reading a lot of documents and consulting some experts we decided to work it out using PYTHON. we plan to make 2 programs one running in the client systems and one that run in server. can any one please help me by telling the thins that i should take care of while designing the project and what tools and what style we should adopt to make the program optimised.

regards



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

Re: What's this error then?

2005-05-02 Thread Wolfram Kraus
Sara Khalatbari wrote:
> You remember me asking about running a program in my
> code...I got a problem here
> 
[...]

> & my code is:
> #! /usr/bin/env python
 ^
Remove this space, the line should be:
#!/usr/bin/env python


> 
> import os
> from os import execl
> 
> os.execl ('/home/sara/PYTHON/HEADER/msgfmt.py',
> 'file-roller.HEAD.fa.po')
> 
> 
> But when I run it, this Error raises:
> [EMAIL PROTECTED] HEADER]$ python run.py
> /usr/bin/env: python2.2: No such file or directory
> 
> Do you have any solutions?


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


Re: MRO problems with diamond inheritance?

2005-05-02 Thread Michele Simionato
M.E. Farmer:

>You would be surprised how many answers you can squeeze out of that
one
>URL.
>That whole page is worth a month of study( for me anyway ).

One month only? You must be pretty smart, one could easily extract
a book from that page ;)

>I am still trying to grasp the 'purpose' of classmethods.

In my personal opinion classmethods and staticmethods could (and
possibly
should) be removed from the language; a part for that consideration,
the typical
use for classmethods is as object factories, to provide alternative
constructors.

   Michele Simionato

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


Re: gtk/qt scintilla help !

2005-05-02 Thread fabien
Neil Hodgson wrote:
> Fabien:
> 
> 
>>There is a lexPOV.cxx file in the package, but I can not find any POV 
>>keywords in any file ( there are about 150 POV keywords). Did i miss it, 
>>and if not, how do I create one and include it for the library building ?
> 
> 
>The Scintilla web site, documentation and mailing list are:
> http://www.scintilla.org/
> http://scintilla.sourceforge.net/ScintillaDoc.html
> http://mailman.lyra.org/mailman/listinfo/scintilla-interest
> 
>Keyword lists are often very large as it is frequently desired to 
> highlight all the identifiers in an API. The Win32 API is around 10 
> megabytes in SciTE .api format. 
> 
>The SciTE editor is shipped with some keyword lists, including some 
> for POV in the pov.properties file.
Yes I saw that  file, but as far as I know, it is used by and only by 
SciTE. I thought at first that I could use it for pygtkScintilla.

> 
>To set keywords, call SCI_SETKEYWORDS as described on the 
> documentation page.
That is going to be tough, I do not know anything about C. It is going 
to be easier if I could find a file with a syntax close to that of POV 
and replace of the keywords found in it with POV keywords ,and the compile.

> 
>I do not personally use the Qt or PygtkScintilla wrappers for 
> Scintilla.

Thanks for the reply and the links

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


Re: MRO problems with diamond inheritance?

2005-05-02 Thread Michele Simionato
BTW, what it your use case? I have yet to see a single compelling use
case for multiple inheritance, so I am
curious of what your design is.

 Michele Simionato

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


pyFLTK

2005-05-02 Thread Jason Manley
Hello
I am very interested in the pyFLTK GUI widget set. Unfortunately the webpage 
and mailing lists are very quiet, does anyone here use it or know of a 
resource I can access to help me with some examples?

Cheers
JM 


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


Re: BitKeeper for Python?

2005-05-02 Thread Nick Craig-Wood
John Smith <[EMAIL PROTECTED]> wrote:
>  I am going to be working with some people on a project that is going to be
>  done over the internet. I am looking for a good method of keeping everyone's
>  code up to date and have everyone be able to access all the code including
>  all the changes and be able to determine what parts of the code were
>  changed.
> 
>  If it were opensource that would be even better.

You could try Mercurial

  http://www.selenic.com/mercurial/

which aims at being a true bk replacement.  Its also written in
python.  Its being developed at the moment...

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tripoli: a Python-based triplespace implementation

2005-05-02 Thread Dominic Fox
karouri wrote:

> Interesting, but I wonder if you are aware of pylinda
> (http://www-users.cs.york.ac.uk/~aw/pylinda/) and if so, what's the
> difference?

Tripoli trades off some of the generality of PyLinda in order to
support some performance tweaks and some additional graph-related
operations.

Tripoli restricts the tuple space model implemented by PyLinda to
3-tuples, and extends it by adding copy_graph and copy_collect_graph
operations to copy and move graphs of triples from one triple space to
another.

PyLinda allows you to pattern match on types, which is really neat but
makes index-based tuple lookups impractical. Tripoli matches literals
or wildcards only, but it indexes every triple on all three components
so in theory it should be quicker at finding triples, matching blocked
requests to incoming triples and so on. Performance is fairly good
even with large-ish (1+). triple sets.

Some other respects in which I think Tripoli is different, but aren't
familiar enough with PyLinda to say for certain:

Tripoli uses callbacks to notify waiting requestors that a matching
triple has arrived. Requestors can block waiting for a callback, or
continue about their business and handle the callback only when it
occurs. Communication between the Tripoli client and server is
asynchronous: the client sends a triple request, and at some point in
the future the server may contact the client to send a response back.
The REST-ful version will also support client polling of a temporary
resource representing a pending request.

Tripoli will eventually support RDF/XML as a format for importing and
exporting triples.

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


Re: __del__ and logging

2005-05-02 Thread flupke
Vinay Sajip wrote:
> flupke  nonexistingdomain.com> writes:
> 
> 
>>Hi,
>>
>>i have a class and a class attribute log which is a logger object. In 
>>the __del__() function i want to log a message but it fails even if i 
>>use self.__class__.log.
>>
>>The error i get is this:
>>Traceback (most recent call last):
>>   File "C:\Python24\lib\logging\__init__.py", line 712, in emit
>> self.stream.write(fs % msg)
>>ValueError: I/O operation on closed file
>>
>>So is there no way to use the logger object in a __del__
>>I wanted to use the message to clearly indicate in the logger file that 
>>the instance had closed ok.
>>
> 
> 
> It all depends. If your __del__ is being called via atexit() for application
> cleanup, for example, logging may not be available to you because it has been
> cleaned up beforehand.
> 
> The logging module registers an atexit() handler to flush and close handlers
> before script termination.
> 
> Vinay Sajip
> 
> 

Thanks i was able to solve it using a function registered in both the 
classes i used in that project.
Why would one use __del__ instead of atexit then especially if the calls 
  you make in __del__ are so unrelieable?

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


Re: Best way to create temporary file?

2005-05-02 Thread Frank Millman
Ok, thanks for the advice.

Frank

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


Is python support jxta now?

2005-05-02 Thread monkey
Hi all, just read from the jxta.org that a python implemention of jxta
framework is being developed. But its project page doesn't state whether it
can be use now..

I am interested to learn to develop p2p app, that's why I am studying python
now. Or there is any lib in python that already implement a p2p protocol?
Please insight me, thanks a lot ( :


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


Re: gtk/qt scintilla help !

2005-05-02 Thread fabien
John Ridley wrote:
> fabien wrote on Sun, 01 May 2005 05:40:05 -0700:
> 
Hello John,
> 
>>Hi,
> 
> 
> Hello Fabien
> 
> 
>>I am writing a POV-RAY editor with Python using
>>either QT or GTK as GUI 'wrapper'. ( I am still trying both )
>>
>>[snip]
>>
>>I have also downloaded qscintilla-1.62-gpl-1.5.1.
>>As for GTK, I also found the LexPOV.cpp file, with
>>no POV keywords in it and with no POV keywords in
>>any of the file in the package.
>>The compilation builds then move the library
>>libqscintilla.so to /usr/lib/qt3/lib.
>>
>>How do I link the newly built library to the folling qt script :
>>
>>[snip]
> 
> 
> QScintilla is a port to Qt of the Scintilla editor control, and PyQt
> provides the python bindings for it. Scintilla has several dozen lexers
> (including one for POV), and QScintilla currently provides class
> wrappers for a small selection of them - but not POV, as you will see
> from the documentation:
> 
> http://www.river-bank.demon.co.uk/docs/qscintilla/hierarchy.html
> 
> Given this, there are two routes you can go down. You could ask the
> developer of QScintilla to provide support for POV by making a request
> via the mailing list:
> 
> http://www.riverbankcomputing.co.uk/pyqt/mailinglist.php
> 
> Or you could write your own POV lexer class in python using the
> existing QScintilla APIs. This is not particularly difficult, but it
> does take some working out. As you already know, a list of POV keywords
> is required. You will then need to look at the source (LexPOV.cpp and
> SciLexer.h) to see how the keywords are used and how the lexical states
> tie up with the SCE_POV enum. QScintilla's lexer classes are mainly
> wrappers around this information, so once you've worked it out, writing
> a python class based on QextScintillaLexer is fairly straightforward:

Well I have tried to use two files called "qextscintillalexerlua.cpp" 
and "qextsinctillalexerlua.h". I noticed that the LUA language used the 
same type of syntax as for POV. I copied them both to 
qextscintillalexerpov and replaced all the keywords found in them with 
POV-keywords.
I compiled and it worked : I got a libqscintilla.so that was modified in 
/usr/lib/qt3/lib.

The hitch is that a scintilla PYQT script also needs a file called
/usr/share/sip/qextscintillalexerperl.sip ( here for perl ).

I do not have a clue how to build a qextscintillalexerpov.sip file.

I looked at: http://www.river-bank.demon.co.uk/docs/sip/sipref.html
but it is all chinese to me. A do not  know C.


-> This is where I am going to contact river-bank for information.



> 
> 
class LexerPOV(QextScintillaLexer):
def __init__(self, parent, name):
QextScintillaLexer.__init__(self, parent, name)
def lexer(self):
return "pov"
def color(self, style):
# styles map to (SCE_POV enum)
# return your own QColor
# or return the base class default
return QextScintillaLexer.color(self, style)
def keywords(self, set):
# if set == 0:
# return 
# elif ...
return 0
def description(self, style):
# if style == 0:
# return self.tr("Default")
# elif ...
return QString.null
> 
> 
Thanks for the example and for the information

Fabien

to reply, remove '_nospam_'

> Of course, this is a minimal lexer class - it is possible to be a lot
> more sophisticated than what is suggested here.
> 
> 
> John Ridley
> 
> Send instant messages to your online friends http://uk.messenger.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


PyAuthD Beta 2a

2005-05-02 Thread Heiko Wundram
PyAuthD - Python Authentication Daemon
--

PyAuthD is a project to create PAM, NSS and PPPd modules which communicate 
with a running Python authentication daemon using a Unix Domain socket. The 
project focusses so far on creating the necessary modules for PAM, NSS and 
PPPd.

As the authentication is done using a single backend daemon, authentication on 
a Unix system can now be done safely and securely through a single process 
which need not even run as root as the metalanguage Python offers shields the 
programmer from handling common mistakes such as buffer-overflows. Choosing 
Python as the language to implement the daemon has other security 
implications which I am working on resolving.

Current Release
---

I've released PyAuthD, beta 2a. The project is now available via subversion 
from the following URL:

http://193.174.104.108/svn/repos/tags/PyAuthD-beta2a

or through ViewCVS:

http://193.174.104.108/viewcvs

Beta 2a does not yet implement a single daemon infrastructure, but contains 
(rather) incomplete samples of how to interact with the modules in question. 
These daemons were written with the single purpose to test the modules, and 
may not work with the current state of the modules anymore.

License
---

PyAuthD and the modules are released under a "New BSD"-style license. You are 
required to keep the copyright intact if you plan on using this code, but 
otherwise are not encumbered in using it except by the common advertising 
clause.

Plans/Bugfixes
--

- Create autoconf/automake infrastructure for PyAuthD (looking for volunteers)
- Implement the single signon daemon in a proper way.
- Create Patches for the Python interpreter which cause types to overwrite the 
memory used by an object with zeros after freeing it.
- Security-check the module implementations.
- Implement proper error handling in the NSS get*ent functions when memory 
runs out.
- and much, much more...

Help


I'm working on this project with two other people. If you are interested in 
joining us, feel free to mail me, and I can arrange commit priviledges to the 
SVN repository.

Otherwise, I'm looking forward to this thursday, where I'll present the 
project at this years German Linux-User-Groups meeting. Hope to see you 
there!

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


Using wildcards...

2005-05-02 Thread Harlin Seritt
I looked all over the net but could not find if it is possible to
insert wildcards into strings. What I am trying to do is this: I am
trying to parse text from a Bible file. In case you're not familiar
with the way the Bible organizes itself, it is broken down into Books >
Chapters > Verses. The particular text I am working with are organized
into Book files (*.txt -- flat text file). Here is what the file looks
like:

{1:1} Random text here. {1:2} More text here. and so on.

Of course the {*} can be of any length, so I can't just do .split()
based on the length of the bracket text. What I would like to do is to
.split() using something akin to this:

textdata.split('{*}') # The '*' being a wildcard

Is this possible to do? If so, how is it done?

Thanks,

Harlin Seritt

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


Re: Displaying formatted - data with TKinter

2005-05-02 Thread Harlin Seritt
I've used multiple listboxes in the past. Also, you can build a widget
that contains multiple listboxes as well. As far as there being one
ready to go, I don't know of one.

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


Re: Is python support jxta now?

2005-05-02 Thread Diez B. Roggisch
monkey wrote:

> Hi all, just read from the jxta.org that a python implemention of jxta
> framework is being developed. But its project page doesn't state whether
> it can be use now..
> 
> I am interested to learn to develop p2p app, that's why I am studying
> python now. Or there is any lib in python that already implement a p2p
> protocol? Please insight me, thanks a lot ( :

Bittorrent, one of the most actively used p2p protocols is _written_ in
python.

-- 
Regards,

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


Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread Reinhold Birkenfeld
Dan Christensen wrote:
> Roel Schroeven <[EMAIL PROTECTED]> writes:
> 
>> There's no level 12 yet though.
> 
> Now there's a 12 and a 13 (at least!).

Anyone solved 12? Hints?

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


Re: Which IDE is recommended?

2005-05-02 Thread Dave Cook
On 2005-04-29, John J. Lee <[EMAIL PROTECTED]> wrote:

> Dave Cook <[EMAIL PROTECTED]> writes:
>> Pydev has some compelling features, but I wish I didn't have to run eclipse

>> On 2005-04-27, monkey <[EMAIL PROTECTED]> wrote:
> What are those compelling features of Pydev, for an emacs user?

For me, the code completion feature.  Also, modern anti-aliased font
rendering under Linux doesn't hurt.

Emacs python-mode is still ahead on code formatting.  For example, the way
you can line up code by hitting tab once anywhere on the line.  And I miss
emacs things like M-^ (delete-indentation; joins the line to the previous
line and removes whitespace).  

Eclipse has an emacs keybinding mode, but it's not very comprehensive.

I'm not ready to switch, but I played around enough to know I could get
fairly comfortable if I wanted to.

I exaggerated memory usage a bit.  Eclipse only uses about twice as much RAM
as XEmacs on my Linux box.  Still, I probably wouldn't find it as usable if
this wasn't an AMD64 3200 with 1G RAM.

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


Re: doctest's ELLIPSIS

2005-05-02 Thread Sébastien Boisgérault
(Forwarded from Python bug tracker)

[ 1192554 ] doctest's ELLIPSIS and multiline statements

Tim Peters:
[...]
doctest has few syntax requirements, but the
inability to start an expected output block with "..." has
always been one of them, and is independent of the
ELLIPSIS gimmick.  I doubt this will change, in part because
the complications needed to "do something about it" are
probably pig ugly, in part because it's so rare a desire, and
in part because there are easy ways to work around it (like
arranging for the expected output to start with something
other than '...').

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


Re: Using wildcards...

2005-05-02 Thread Roel Schroeven
Harlin Seritt wrote:

> I looked all over the net but could not find if it is possible to
> insert wildcards into strings. What I am trying to do is this: I am
> trying to parse text from a Bible file. In case you're not familiar
> with the way the Bible organizes itself, it is broken down into Books >
> Chapters > Verses. The particular text I am working with are organized
> into Book files (*.txt -- flat text file). Here is what the file looks
> like:
> 
> {1:1} Random text here. {1:2} More text here. and so on.
> 
> Of course the {*} can be of any length, so I can't just do .split()
> based on the length of the bracket text. What I would like to do is to
> .split() using something akin to this:
> 
> textdata.split('{*}') # The '*' being a wildcard
> 
> Is this possible to do? If so, how is it done?

You can use the split function in the re module with a suitable regular 
expression:

  >>> re.split('{\d+:\d+}', textdata)
['', ' Random text here. ', ' More text here. and so on.']

{\d+:\d+} means 'match {, then one or more digits, then :, then one or 
more digits, then }'.

re.split('{.*}', textdata) would be a more direct translation of your 
wildcard, but that doesn't work: .* matches as much as possible, so in 
your example it would match '{1:1} Random text here. {1:2}' instead of 
just '{1:1}' and '{1:2}'.

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

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


Comparision of GUI framworks

2005-05-02 Thread Florian Lindner
Hello,
I've read the chapter in the Python documentation, but I'm interested in a a
more in-depth comparision. Especially regarding how pythonic it is and how
well it performs and looks under Windows.
I've some C++ experiences with Qt, so I'm very interested to have PyQt
compared to wxWindows and Tk. How fast does PyQt catches up with the
versiones released from Trolltech? etc..

Thx,
Florian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MRO problems with diamond inheritance?

2005-05-02 Thread M.E.Farmer
Michele Simionato wrote:
> M.E. Farmer:
>
> >You would be surprised how many answers you can squeeze out of that
> one
> >URL.
> >That whole page is worth a month of study( for me anyway ).
>
> One month only? You must be pretty smart, one could easily extract
> a book from that page ;)
No, I was being 'conservative'.
I am not as smart as the fellow that wrote that MRO paper ;)
Honestly, I have had that bookmarked for years...
There are some deep conceps on that page and I have not had a 'use
case' for most of them.
I would gladly welcome the book, you gonna write it!?
Something that covers ( with lots of 'real-life' examples ):
 classes ( I see a lot of questions on c.l.py about basic class use )
 special methods and class customization ( putting classes to work )
 metaclasses ( what they are and when you might need them )
 inheritance ( covering all flavors subclassing,mixin,etc.. )
 descriptors ( what are they and why you should care )
 types ( creating new ones, subclassing old ones, etc... )
 old style / newstyle gotchas for classes / metaclasses
 and maybe a few pages on decorators.

It is all well and good to have advanced OO in the language,
but it would be better if there was a 'reason' for it all.

> >I am still trying to grasp the 'purpose' of classmethods.
>
> In my personal opinion classmethods and staticmethods could (and
> possibly
> should) be removed from the language; a part for that consideration,
> the typical
> use for classmethods is as object factories, to provide alternative
> constructors.
>
>Michele Simionato

Thank you, I had a feeling that it was just extra fluff.
But I felt/feel that way about list comprehensions and decorators too
;)  
M.E.Farmer

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


Re: Using wildcards...

2005-05-02 Thread Kent Johnson
Harlin Seritt wrote:
> I looked all over the net but could not find if it is possible to
> insert wildcards into strings. What I am trying to do is this: I am
> trying to parse text from a Bible file. In case you're not familiar
> with the way the Bible organizes itself, it is broken down into Books >
> Chapters > Verses. The particular text I am working with are organized
> into Book files (*.txt -- flat text file). Here is what the file looks
> like:
> 
> {1:1} Random text here. {1:2} More text here. and so on.
> 
> Of course the {*} can be of any length, so I can't just do .split()
> based on the length of the bracket text. What I would like to do is to
> .split() using something akin to this:
> 
> textdata.split('{*}') # The '*' being a wildcard

You can do this with the re module. For example

  >>> import re
  >>> s = '{1:1} Random text here. {1:2} More text here. and so on.'
  >>> re.split(r'\{[^}]+\}', s)
['', ' Random text here. ', ' More text here. and so on.']

If you want to be a little stricter in what you accept for the split you could 
look explicitly for 
digits:
  >>> re.split(r'\{\d+:\d+\}', s)
['', ' Random text here. ', ' More text here. and so on.']

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


Re: MRO problems with diamond inheritance?

2005-05-02 Thread Michele Simionato
Well, writing that book would be a major undertaking that I am not
willing
to take any soon ;)

However, all you are asking for is already in my lectures at ACCU:
http://www.reportlab.org/~andy/accu2005/pyuk2005_simionato_wondersofpython.zip

>From the README:

"""

Generally speaking these lectures are unpolished, too concise, with
more code than words, and with cutting edge/experimental code.
Read them at your risk and peril. Take in account the fact that they
were prepared as a last minute replacement for Alex Martelli's
tutorial,
with a limited amount of time and a very advanced program to follow.

My main concern in preparing these notes was to give the readers a few
*ideas*, not polished solutions. If you are reading these notes, you
will be more than capable to customize these ideas to your own
situation
and to fix the unavoidable little bugs, imperfections, annoyances.

Whereas I recommend the first lecture about iterators and generators
to everybody, take in account than the second and especially the
third lecture may cause your head to explode. I do not take any
responsability in that case.
"""
  Michele Simionato

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


Re: Using wildcards...

2005-05-02 Thread George Yoshida
Harlin Seritt wrote:
> {1:1} Random text here. {1:2} More text here. and so on.
> 
> Of course the {*} can be of any length, so I can't just do .split()
> based on the length of the bracket text. What I would like to do is to
> .split() using something akin to this:
> 
> textdata.split('{*}') # The '*' being a wildcard
> 
> Is this possible to do? If so, how is it done?
> 

You should look into re module.
regex has more flexible features for text processing than string
  module or methods.

- Regular expression operations
   http://docs.python.org/lib/module-re.html
- HOWTO
   http://www.amk.ca/python/howto/regex/

In your case, the code would go like this:

   >>> text = '{1:1} Random text here. {1:2} More text here. and so on.'
   >>> import re
   >>> pattern = re.compile('{\d+:\d+}')
   >>> pattern.split(text)
   ['', ' Random text here. ', ' More text here. and so on.']

--
george

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


ICQ module ?

2005-05-02 Thread Lad
Hello ,
Is there an ICQ module? I would like to send a message to users in my
contact list, check if a user is online etc.
Is there a support in Python?
Thanks
L.B

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


Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread [EMAIL PROTECTED]
Any hints on level 6 ?
There is "zip" in the page source, "ZIp" in the
image data, but have no clue what to do with them
- tried many things :). 

Thanks, 
Maciek

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


Locale and cookies

2005-05-02 Thread dagurp
I'm doing a small mod_python project and I'm using a locale for my own
language. This is not a problem until I start using cookies because the
cookie module in mod_python uses time.strftime() to write the
expiration times and therefore makes invalid cookies.
I tried to fix this by changing the locale back to "English" before
creating cookies and that works on Windows but not for Linux. If I use
"en_EN.ISO8859-1" it works on Linux but not on Windows.

I'm sure there's an easy way to fix this.

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


Python sockets and recvmsg

2005-05-02 Thread Heiko Wundram
Hi all!

I've read up on unix domain sockets, and I've seen that you can send out of 
bound messages such as sending the processes credentials over the socket. 
Receiving this requires to call recvmsg, which seems to be unavailable on the 
standard Python socket type.

How would you go about implementing this functionality? I don't think that a 
standard recv() does what I want...

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


Re: Python sockets and recvmsg

2005-05-02 Thread Heiko Wundram
On Monday 02 May 2005 14:50, Heiko Wundram wrote:
> How would you go about implementing this functionality? I don't think that
> a standard recv() does what I want...

Okay, looking at google would've been appropriate... There's Python Eunuchs... 
I wonder why this hasn't made it into the standard Python distribution, 
nevertheless...

Would there be interest in a patch?

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


Re: BitKeeper for Python?

2005-05-02 Thread Bruce Stephens
Nick Craig-Wood <[EMAIL PROTECTED]> writes:

[...]

> You could try Mercurial
>
>   http://www.selenic.com/mercurial/

Or Codeville, also written in Python.

> which aims at being a true bk replacement.  Its also written in
> python.  Its being developed at the moment...

Codeville's said to be pretty usable.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MRO problems with diamond inheritance?

2005-05-02 Thread M.E.Farmer
>Well, writing that book would be a major undertaking that I am not
>willing to take any soon ;)
Well at least you didn't say NO, so when you DO write the book I will
buy a copy.

>However, all you are asking for is already in my lectures at ACCU
How many people can say ' No book just these lectures that cover
everything you want '
I knew I was asking the right person ;)
Now I just need to read your lectures...but first I am going to wrap my
head in duct tape.
( prevents/contains explosions )
Thanks for your time,
M.E.Farmer

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


Re: Supercomputer and encryption and compression @ rate of 96%

2005-05-02 Thread km
Hi all,

This was posted long ago.
I tried to compress a  mp3 file but i couldnt get the keycode+".out" file which 
is of size 1 bit. instead it is printed to STDOUT. i am usng python 2.4 . i 
understand that the keycode is embedded in the filename itself. Is it a problem 
with python not able to create a file with such a big filename ? 
any workarounds ? 

regards,
KM

On Thu, Apr 14, 2005 at 01:49:22PM +0200, Fredrik Lundh wrote:
> Will McGugan wrote:
> 
> > Please implement this as a Python module. I would like to compress my mp3 
> > collection to single 
> > bits.
> 
> here's the magic algorithm (somewhat simplified):
> 
> def algorithm(data):
> m = 102021 # magic constant
> d = [int(c) for c in str(1*2*3*4*5*m+5+4+2+1)]
> x = [ord(c) for c in hex(1+2+4+5+m*5*4*3*2*1)]
> x[d[0]*d[1]*d[2]] = x[d[-1]] + sum(d) - d[d[-d[-1]-1]] + d[0]
> x = __import__("".join(chr(c) for c in x[d[0]*d[1]:])).encodestring
> return "".join(x(data).split("\n")).rstrip("="), sum(d)-sum(reversed(d))
> 
> and here's a driver for your MP3 collection:
> 
> import glob
> 
> def compress(filename):
> data = open(filename, "rb").read()
> keycode, bit = algorithm(data)
> file = open(keycode + ".out", "wb")
> file.write(chr(bit))
> file.close()
> print "compressed", filename,
> print len(data), "=>", 1, round(100.0/len(data), 3), "%"
> 
> for file in glob.glob("*.mp3"):
> compress(file)
> 
>  
> 
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

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


Re: Locale and cookies

2005-05-02 Thread Klaus Alexander Seistrup
[EMAIL PROTECTED] wrote:

> I tried to fix this by changing the locale back to "English"
> before creating cookies and that works on Windows but not for
> Linux. If I use "en_EN.ISO8859-1" it works on Linux but not
> on Windows.

How about setting locale to "C" or "POSIX"?

-- 
Klaus Alexander Seistrup
Magnetic Ink, Copenhagen, Denmark
http://magnetic-ink.dk/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which IDE is recommended?

2005-05-02 Thread dcrespo
> But I personally recommend DrPython. (Not only, I'm a member of the
> project).

I saw this message and downloaded DrPython. It's very good: I like the
class/functions browser while I'm coding... but I can't find the
autocompletion feature you talk, and I think this feature is very
important. Where it is?

Daniel

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


Re: PyAuthD Beta 2a

2005-05-02 Thread Heiko Wundram
On Monday 02 May 2005 12:58, Heiko Wundram wrote:
> Current Release
> ---

Sorry for all the posting, but I'm having trouble setting up Subversion 
properly... Anyway, the release has moved to its final destination:

http://193.174.104.108/svn/repos/PyAuthD/tags/beta-2a

and of course is still accessible through ViewCVS:

http://193.174.104.108/viewcvs

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


Re: Is python support jxta now?

2005-05-02 Thread monkey
> Bittorrent, one of the most actively used p2p protocols is _written_ in
> python.
>
> Diez B. Roggisch

Hey man, no, the jxta p2p protocols is not mean the bittorrent stuff. It is
a fully decentralized network protocol, not confine to file transfer.


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


Re: Comparision of GUI framworks

2005-05-02 Thread monkey
wxPython rules ( ;
Go to http://wxpython.org for details...


"Florian Lindner" <[EMAIL PROTECTED]> ???
news:[EMAIL PROTECTED] ???...
> Hello,
> I've read the chapter in the Python documentation, but I'm interested in a
a
> more in-depth comparision. Especially regarding how pythonic it is and how
> well it performs and looks under Windows.
> I've some C++ experiences with Qt, so I'm very interested to have PyQt
> compared to wxWindows and Tk. How fast does PyQt catches up with the
> versiones released from Trolltech? etc..
>
> Thx,
> Florian


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


Reading output from standard out

2005-05-02 Thread Thierry Lam








Let’s say I have a python program which prints output
to standard out, let’s call it HelloApp.  How do I capture these outputs
from the python GUI tkinter? For example, I want to call HelloApp from my GUI
program and I want to send the output live to a tkinter text area.

 

Thanks

Thierry






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

Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread John Hazen
* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [2005-05-02 05:10]:
> Any hints on level 6 ?
> There is "zip" in the page source, "ZIp" in the
> image data, but have no clue what to do with them
> - tried many things :). 

Have you found the zip file yet?

(I did, and I still can't figure it out.  I'm wondering if there are
comments embedded in the jpg that none of my viewers will show me.
Hmm, maybe there's a python module that does that...  I'll play with it
more after I sleep on it.)

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


Re: Which IDE is recommended?

2005-05-02 Thread Franz Steinhaeusler
On 2 May 2005 06:08:02 -0700, "dcrespo" <[EMAIL PROTECTED]> wrote:

>> But I personally recommend DrPython. (Not only, I'm a member of the
>> project).
>
>I saw this message and downloaded DrPython. It's very good: 

Hello Daniel,

thank you,

>I like the
>class/functions browser while I'm coding... but I can't find the
>autocompletion feature you talk, and I think this feature is very
>important. Where it is?
>
>Daniel


For clarification:

1) There is the "normal" Autocomplete: It looks for already available
Words in the text file, and suggest possible completition. Edit => Find
and complete.

2) A plugin: Abbreviations: You can edit a list of words with
abbreviation keys (like in SciTE).

3) I think, you meant "Code Completition":
for example you type: os. and with the "." os.chmod, os.chdir, ...
appear in a completition list box.
You have to download it or install via plugin manager this plugin.
Best overview, you get if you choose "Show ALL Project Files" in the 
Project:DrPython: Summary.
Or you look at the homepage: http://drpython.sourceforge.net/
and select Plugins.

HTH,

-- 
Franz Steinhäusler
http://drpython.sourceforge.net/
http://mitglied.lycos.de/drpython/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread Reinhold Birkenfeld
John Hazen wrote:
> * [EMAIL PROTECTED] <[EMAIL PROTECTED]> [2005-05-02 05:10]:
>> Any hints on level 6 ?
>> There is "zip" in the page source, "ZIp" in the
>> image data, but have no clue what to do with them
>> - tried many things :). 
> 
> Have you found the zip file yet?
> 
> (I did, and I still can't figure it out.  I'm wondering if there are
> comments embedded in the jpg that none of my viewers will show me.
> Hmm, maybe there's a python module that does that...  I'll play with it
> more after I sleep on it.)

It's best when you use the zipfile module.

*** SPOILER ***




























































Look carefully at the ZipInfo class for every file in the archive.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which IDE is recommended?

2005-05-02 Thread Franz Steinhaeusler
On Mon, 02 May 2005 15:29:58 +0200, Franz Steinhaeusler
<[EMAIL PROTECTED]> wrote:

>3) I think, you meant "Code Completition":
>for example you type: os. and with the "." os.chmod, os.chdir, ...
>appear in a completition list box.

BTW: If it doesn't seem to work: Make sure, to enable it
in Options=>Enable Autocompletition.
You can also select under Plugin Preferences "Code Completition Enabled
by default".

For other questions, you are welcome to ask in the tracker or
Public Forums.

-- 
Franz Steinhäusler
http://drpython.sourceforge.net/
http://mitglied.lycos.de/drpython/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: BitKeeper for Python?

2005-05-02 Thread Ville Vainio
> "Bruce" == Bruce Stephens <[EMAIL PROTECTED]> writes:

Bruce> Nick Craig-Wood <[EMAIL PROTECTED]> writes:
Bruce> [...]

>> You could try Mercurial
>> 
>> http://www.selenic.com/mercurial/

Bruce> Or Codeville, also written in Python.

Or bazaar-ng, also written in python.

Bruce> Codeville's said to be pretty usable.

Ditto, through the repo format has not been stabilized yet.

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


Can't get compression in Python zip script.

2005-05-02 Thread [EMAIL PROTECTED]
Hello,
I following an example on how to zip files from the www.devshed.com 
site.
I can create a zip package, however I am not getting any compression.
120M file stays 120M within the zip package.
I need to know how to set or activate the compression values.
here is the code I'm using:

>import zipfile
>zip = zipfile.ZipFile('', 'w')
>zip.write('')
>zip.close()

Any help would be gratly appreciated

deej



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


Re: Python interpreter in Basic or a Python-2-Basic translator.

2005-05-02 Thread rrr

On 1 May 2005 at 6:18, Engineer wrote:

> The security 'droids have decided that since the MS Office Suite is a
> "standard" application then software written in MS Office VBA must be
> "safe."  Any other development environments (such as Java, Perl,
> Cygwin) are "unsafe" and can't be installed.

This has more to do with engineers not risking their own jobs than 
being safe from virus's. 


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


Reading output from standard out

2005-05-02 Thread Thierry Lam








Let’s say I have a python program which prints output
to standard out, let’s call it HelloApp.  How do I capture these
outputs from the python GUI tkinter? For example, I want to call HelloApp from
my GUI program and I want to send the output live to a tkinter text area.

 

Thanks

Thierry






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

Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread Ganesan Rajagopal

I am stuck on level 3. I've tried every re that I can think of. Some body
give me a clue. 

Ganesan

-- 
Ganesan Rajagopal


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


Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread Maciek Starzyk
On 5/2/05, John Hazen <[EMAIL PROTECTED]> wrote:
> * [EMAIL PROTECTED] <[EMAIL PROTECTED]> [2005-05-02 05:10]:
> > Any hints on level 6 ?
> > There is "zip" in the page source, "ZIp" in the
> > image data, but have no clue what to do with them
> > - tried many things :).
> 
> Have you found the zip file yet?

Now I have it. Thanks :)

> (I did, and I still can't figure it out.  I'm wondering if there are
> comments embedded in the jpg that none of my viewers will show me.
> Hmm, maybe there's a python module that does that...  I'll play with it
> more after I sleep on it.)

Hint: Use Python module 'zipfile' :)

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


Re: Which IDE is recommended?

2005-05-02 Thread vkeyboard
Also take a look at Stani's Python Editor http://spe.pycs.net

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


Re: Tripoli: a Python-based triplespace implementation

2005-05-02 Thread Skip Montanaro

Dominic> Tripoli will eventually support RDF/XML as a format for
Dominic> importing and exporting triples.

Is there some interoperability requirement with non-Python apps?  If not,
why not just use pickle or marshal?

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


pop3proxy

2005-05-02 Thread BrokenClock
Hello every body,

Here is a python newbie! I've choose it to make a pop3 proxy - I want to 
filter content between a pop3 client and a pop3 server, and I have no 
control on the server...
First, I wanted to do an non-filtering, just logging, mono-thread proxy 
to make some test..
Based on the RFC 1939 (http://www.faqs.org/rfcs/rfc1939.html) (in 
particular the item 5), I was expecting some output, but did not get it...
In fact, I expected to see the message, but I did not see it... only the 
  command to retrieve it. On the other hand, the message is well receipt 
in my mail client.
An other point is that all this seems to work well with short messages, 
but difficulties appear when messages go bigger. I think it is due to 
the parameter of recv, but I don't know how to set it.
So here are my two questions:
1-why do not I see the message in my output, and how could I do to see 
and handle it?
2-how should I set the parameter of recv to handle big messages?

Any help would we very appreciate.

Cheers,

Brokenclock

Here is the code:
 >
import socket

LOCALHOST = '192.168.31.202'# This is me
REMOTEHOST = 'pop.fr.oleane.com'# The remote host
PORT = 110  # pop3 port
while 1:
SocketServer = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
SocketServer.bind((LOCALHOST, PORT))
SocketServer.listen(1)
Connexion2Client, ClientAddress = SocketServer.accept()
print '#', ClientAddress,' connected'
ClientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ClientSocket.connect((REMOTEHOST, PORT))
print '#', REMOTEHOST, ' connected'
while 1:
DataFromServer = ClientSocket.recv(5896230)
print REMOTEHOST,'> ',DataFromServer
Connexion2Client.send(DataFromServer)
DataFromClient = Connexion2Client.recv(5896230)
print ClientAddress,'> ',DataFromClient
if DataFromClient==" QUIT": print 'QUIT received from client'
ClientSocket.send(DataFromClient)
if not DataFromClient: break
ClientSocket.close()
Connexion2Client.close()
 >eof


Here the output:
 >
C:/Python24/pythonw.exe -u  "C:/Python24/Scripts/pop3proxy3.py"
# ('192.168.31.202', 2345)  connected
# pop.fr.oleane.com  connected
pop.fr.oleane.com >  +OK pop1.clb.oleane.net POP3 Oleane Mail Server Ready

('192.168.31.202', 2345) >  CAPA

pop.fr.oleane.com >  +OK Capability list follows
TOP
USER
RESP-CODES
AUTH-RESP-CODE
PIPELINING
UIDL
IMPLEMENTATION omail-1.3.1
.

('192.168.31.202', 2345) >  USER [EMAIL PROTECTED]

pop.fr.oleane.com >  +OK User name accepted, password please
Username

('192.168.31.202', 2345) >  PASS password

pop.fr.oleane.com >  +OK 1 messages (1631 octets)

('192.168.31.202', 2345) >  STAT

pop.fr.oleane.com >  +OK 1 1631

('192.168.31.202', 2345) >  LIST

pop.fr.oleane.com >  +OK 1 messages (1631 octets)
1 1631
.

('192.168.31.202', 2345) >  UIDL

pop.fr.oleane.com >  +OK Unique-ID listing follows
1 42762947a4801810065f
.

('192.168.31.202', 2345) >  RETR 1

pop.fr.oleane.com >  +OK pop1.clb.oleane.net chpounz the connection. 
Have a nice day!

('192.168.31.202', 2345) >
 >eof
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: BitKeeper for Python?

2005-05-02 Thread Bruce Stephens
Ville Vainio <[EMAIL PROTECTED]> writes:

[...]

> Bruce> Or Codeville, also written in Python.
>
> Or bazaar-ng, also written in python.
>
> Bruce> Codeville's said to be pretty usable.
>
> Ditto, through the repo format has not been stabilized yet.

The impression I get is that bazaar-ng probably isn't ready for real
use yet:

Warning: bzr is at an early stage of development, and the design
is still changing from week to week. The documents here may be
inconsistent with themselves or with the code, and sometimes refer
to features that are planned but not yet written.

I think I'd give it a while.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: BitKeeper for Python?

2005-05-02 Thread Jp Calderone
On 02 May 2005 09:30:05 GMT, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
>John Smith <[EMAIL PROTECTED]> wrote:
>>  I am going to be working with some people on a project that is going to be
>>  done over the internet. I am looking for a good method of keeping everyone's
>>  code up to date and have everyone be able to access all the code including
>>  all the changes and be able to determine what parts of the code were
>>  changed.
>>
>>  If it were opensource that would be even better.
>
>You could try Mercurial
>
>  http://www.selenic.com/mercurial/
>
>which aims at being a true bk replacement.  Its also written in
>python.  Its being developed at the moment...
>

  "Being developed at the moment" is something of an understatement.  It's less 
than a month old.  Less than a month old.  Compare this to such systems as CVS 
(more than 16 years old) and I think everyone can agree that Mercurial may need 
a teensy bit more work before it is interesting to people looking for an RCS.

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


Re: pop3proxy

2005-05-02 Thread Just
In article <[EMAIL PROTECTED]>,
 BrokenClock <[EMAIL PROTECTED]> wrote:

> Here is a python newbie! I've choose it to make a pop3 proxy - I want to 
> filter content between a pop3 client and a pop3 server, and I have no 
> control on the server...
> First, I wanted to do an non-filtering, just logging, mono-thread proxy 
> to make some test..

Not directly helpong with your problem, but perhaps some example code 
helps: the spambayes project contains a working pop3 proxy.

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


Re: BitKeeper for Python?

2005-05-02 Thread John P. Speno
In <[EMAIL PROTECTED]> Ville Vainio <[EMAIL PROTECTED]> writes:
>> "Bruce" == Bruce Stephens <[EMAIL PROTECTED]> writes:
>Bruce> Nick Craig-Wood <[EMAIL PROTECTED]> writes:
>Bruce> [...]

>>> You could try Mercurial
>>> 
>>> http://www.selenic.com/mercurial/

>Bruce> Or Codeville, also written in Python.

>Or bazaar-ng, also written in python.

Too many choices here. Is anyone planning a PySCMOff blog yet ?

Python, the language that makes reinventing the wheel a little too easy
sometimes.

I kid because I love.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pop3proxy

2005-05-02 Thread BrokenClock
Thank you! At a first glance, it seems to be very similar to what I 
need. More to come when I go deeper...

Just a écrit :
> In article <[EMAIL PROTECTED]>,
>  BrokenClock <[EMAIL PROTECTED]> wrote:
> 
> 
>>Here is a python newbie! I've choose it to make a pop3 proxy - I want to 
>>filter content between a pop3 client and a pop3 server, and I have no 
>>control on the server...
>>First, I wanted to do an non-filtering, just logging, mono-thread proxy 
>>to make some test..
> 
> 
> Not directly helpong with your problem, but perhaps some example code 
> helps: the spambayes project contains a working pop3 proxy.
> 
> Just
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pop3proxy

2005-05-02 Thread Jp Calderone
On Mon, 02 May 2005 16:05:13 +0200, BrokenClock <[EMAIL PROTECTED]> wrote:
>Hello every body,
>
>Here is a python newbie! I've choose it to make a pop3 proxy - I want to
>filter content between a pop3 client and a pop3 server, and I have no
>control on the server...
>First, I wanted to do an non-filtering, just logging, mono-thread proxy
>to make some test..
>Based on the RFC 1939 (http://www.faqs.org/rfcs/rfc1939.html) (in
>particular the item 5), I was expecting some output, but did not get it...
>In fact, I expected to see the message, but I did not see it... only the
>  command to retrieve it. On the other hand, the message is well receipt
>in my mail client.
>An other point is that all this seems to work well with short messages,
>but difficulties appear when messages go bigger. I think it is due to
>the parameter of recv, but I don't know how to set it.
>So here are my two questions:
>1-why do not I see the message in my output, and how could I do to see
>and handle it?
>2-how should I set the parameter of recv to handle big messages?

  Regardless of how large you set the parameter, you will still have to issue 
multiple recv() calls.  TCP is stream oriented, not packet oriented.  There are 
no guarantees about how many bytes recv() will return.  You may get the entire 
chunk of bytes written by your peer, or you may get a small fraction of them, 
or you may get two byte chunks written separately merged together.

  The only way to be sure you've received everything is to include logic in 
your application which can examine the bytes and determine based on the 
protocol whether or not more bytes should be coming.

  For this reason, you cannot simply recv() on one socket and then send() on 
the next, alternating.  You need some actual POP3 logic to determine whether a 
recv() returned all the expected bytes, or whether you need to recv() on the 
same socket again.

  Another approach is to use non-blocking sockets, select(), and issue a recv() 
on either socket whenever select() indicates there are bytes to be read.  This 
is the approach taken by various libraries, including asyncore in the stdlib, 
as well as by Twisted.  As a bonus, Twisted () 
also includes client and server POP3 protocol implementations.

>
>Any help would we very appreciate.
>
>Cheers,
>
>Brokenclock
>
>Here is the code:
> >
>import socket
>
>LOCALHOST = '192.168.31.202'   # This is me
>REMOTEHOST = 'pop.fr.oleane.com'   # The remote host
>PORT = 110 # pop3 port
>while 1:
>   SocketServer = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>   SocketServer.bind((LOCALHOST, PORT))
>   SocketServer.listen(1)
>   Connexion2Client, ClientAddress = SocketServer.accept()
>   print '#', ClientAddress,' connected'
>   ClientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>   ClientSocket.connect((REMOTEHOST, PORT))
>   print '#', REMOTEHOST, ' connected'
>   while 1:
>   DataFromServer = ClientSocket.recv(5896230)
>   print REMOTEHOST,'> ',DataFromServer

>   Connexion2Client.send(DataFromServer)

  You can't just call send() like this.  It may not write all the bytes you 
pass it.  It will return the number of bytes written, and you must then call 
send again with the remaining bytes (and again test the return value, etc).

>   DataFromClient = Connexion2Client.recv(5896230)
>   print ClientAddress,'> ',DataFromClient
>   if DataFromClient==" QUIT": print 'QUIT received from client'

  Since you may receive "Q", "U", "I", and "T" in separate recv() results, the 
above will not work reliably.  You will need to buffer bytes and test for the 
presence of QUIT in the buffer.  Additionally, you need to maintain information 
about the state of connection, since "QUIT" is perfectly legitimate as part of 
a message body and should not be interpreted the same as a QUIT outside a 
message body.

>   ClientSocket.send(DataFromClient)

  Same comments about send() as above.

>   if not DataFromClient: break
>   ClientSocket.close()
>   Connexion2Client.close()
> >eof
>
>
> [snip output]

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


Re: Can't get compression in Python zip script.

2005-05-02 Thread M.E.Farmer
zipfile.ZipFile.__init__(self, filename, mode='r', compression=0)
Open the ZIP file with mode read "r", write "w" or append "a".

>import zipfile
>zip = zipfile.ZipFile('', 'w', compression=1)
>zip.write('')
>zip.close()

Warning about zipfile module:
In Python2.2 this is true, maybe 2.3 and 2.4 also have some problems.
You cannot remove/delete an entry from a zipfile with Python but you
can read and write it!
To do it you will have to make a new zip file that contains all the
files you want to keep and then overwrite the original.
You can have mulitple files with the same name!
Obviusly that can cause problems.
This can be very confusing.
hth,
M.E.Farmer

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


Re: BitKeeper for Python?

2005-05-02 Thread Bruce Stephens
"John P. Speno" <[EMAIL PROTECTED]> writes:

[...]

> Too many choices here. Is anyone planning a PySCMOff blog yet ?
>
> Python, the language that makes reinventing the wheel a little too
> easy sometimes.

Why stick to Python?  There seem to be about a dozen newish SCM's
around at the moment, in at least C, C++, Haskell, Java, Python, Ruby,
Smalltalk (Squeak) (although I think that last one is only for the
Squeak environment).  Typical, you wait years for a decent replacement
for CVS, and then...
-- 
http://mail.python.org/mailman/listinfo/python-list


problem in the compiler ?

2005-05-02 Thread Glauco Silva



when i creat a RadioButton and put a command = 
self.Function , this function is called in the creation of 
RadioButton.
It´s right this or it´s wrong ? 
Thank you
Glauco 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.1 - Release Date: 2/5/2005
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Can't get compression in Python zip script.

2005-05-02 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> Hello,
> I following an example on how to zip files from the www.devshed.com 
> site.
> I can create a zip package, however I am not getting any compression.
> 120M file stays 120M within the zip package.
> I need to know how to set or activate the compression values.
> here is the code I'm using:
> 
> 
>>import zipfile
>>zip = zipfile.ZipFile('', 'w')
>>zip.write('')
>>zip.close()
> 
> 
> Any help would be gratly appreciated
> 
It's not that difficult. The zipfile module uses null compression by 
deafult, so you need to change the second line to read

zip = zipfile.ZipFile('', 'w', zipfile.ZIP_DEFLATED)

That will create a comrpessed zip file.

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

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


SWIG -- Passing python proxy class instance to python callback

2005-05-02 Thread Jeff
I'm trying to pass a proxy class instance (SWIG generated) of CClass,
to a python callback function from C++.  The proxy class instance of
CClass is created from a pointer to the C++ class CClass.

Using the code below, I receive the error message:

"AttributeError: 'PySwigObject' object has no attribute 'GetName'"


The python callback function is being passed in through the clientdata
pointer, and the CClass *class pointer is what's being converted to an
instance of the SWIG proxy class and passed to the python callback
function as an argument.

static void PythonCallBack(CClass *class,void *clientdata)
{
   PyObject *func, *arglist,*obj;
   PyObject *result;

   func = (PyObject *) clientdata;   // Get Python function
   obj = SWIG_NewPointerObj((void*) cmd, SWIGTYPE_p_CSCSICommand,  1);
//create instance of python proxy class from c++ pointer

   arglist=Py_BuildValue("(O)",*obj); //convert to tuple
   result = PyEval_CallObject(func,arglist); // Call Python

   Py_XDECREF(result);
   return;
}

Any input would greatly appreciated.  Thanks,
Jeff

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


Re: How to kill a SocketServer?

2005-05-02 Thread [EMAIL PROTECTED]
[Skip Montanaro]
> > def serve_forever(self):
> > while self.serving:
> > r,w,e = select.select([self.socket], [], [],
self.pause)
> > if r:
> > self.handle_request()
> >
> > and set self.pause to something short-ish.  The select call times
out and
> > the server exits.

[Paul Rubin]
> Ah, good point.  Something like this should probably be added to
> SocketServer.py (optional timeout parameter to serve_forever), or at
> least the trick should be mentioned in the docs.

I like this idea, and perhaps you all could come up with some more
useful APIs in this area; I know that I often struggle a bit with
getting these servers to stop.

(I also like the idea of having the worker thread mixin part of the
standard library -- it seems generally useful.)

--Guido van Rossum (home page: http://www.python.org/~guido/)

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


Re: How to kill a SocketServer?

2005-05-02 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> > Ah, good point.  Something like this should probably be added to
> > SocketServer.py (optional timeout parameter to serve_forever), or at
> > least the trick should be mentioned in the docs.
> 
> I like this idea, and perhaps you all could come up with some more
> useful APIs in this area; I know that I often struggle a bit with
> getting these servers to stop.

I put an RFE in sourceforge last night, suggesting adding a shutdown()
method to socket servers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Setting win32 console title from Python

2005-05-02 Thread Duncan Booth
runes wrote:

> Hi Duncan, sorry, I was unprecise.  I'm thinking of a script, called
> t.py  that can be used in the console  like an ordinary command. Som if
> I change directory from S:\scripts to d:\projects and execute the
> script  the title changes to "projects" etc.
> 
> I have that functionality today with a combination of a python script
> and a batch file. I just wondered if I could use python all the way.
> Apparently I cannot.
> 
I think not, although you probably can do it with only the batch file. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which IDE is recommended?

2005-05-02 Thread dcrespo
Hi. You were right: I meant "Code Completition". I did what you told me
to do. I get now auto completition of code.
For example:

import wx
wx.(here appear a list with the possibilities)

But (there's always a "but") with:

button = wx.Button(...)

when I write "button." there's a flick of the list of the possible
parameters, resulting in no showing it. Is there a way to correct it?

Daniel

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


Re: lists in cx_Oracle

2005-05-02 Thread infidel
Something like this might work for you:

>>> ids= ['D102', 'D103', 'D107', 'D108']
>>> in_clause = ', '.join([':id%d' % x for x in xrange(len(ids))])
>>> sql = "select * from tablename where id in (%s)" % in_clause
>>> import cx_Oracle as ora
>>> con = ora.connect('foo/[EMAIL PROTECTED]')
>>> cur = con.cursor()
>>> cur.execute(sql, ids)

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


Re: Webbrowser On Windows

2005-05-02 Thread J Correia

"M.E.Farmer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I played around with it.
>

> import pythoncom
> from win32com.client import Dispatch
>

> def webbrowser(url=None):
> ie = pythoncom.CoCreateInstance("InternetExplorer.Application",
> None,
>  pythoncom.CLSCTX_SERVER,
>  pythoncom.IID_IDispatch)
> ie = Dispatch(ie)
> ie.Navigate
> if url:
> ie.Navigate(url)
> ie.Visible = 1
> return ie
>

#
> import time
> w = webbrowser()
> w.Navigate('http://www.google.com')
> time.sleep(2)
> w.Navigate('http://dir.gmane.org/gmane.comp.python.general')
> time.sleep(2)
>
webbrowser('http://groups-beta.google.com/group/comp.lang.python?hl=en&lr=')
> webbrowser('http://python.org')
>

#
> M.E.Farmer
>

Noticed your sleep statements... because the response times vary from site
to site you might want to use this code:

while w.ReadyState != 4:   # 4 signals browser has finished loading and
is ready... 0=uninitialised; 1=loading; 2=loaded; 3=interactive; 4=complete
time.sleep(1)

While we're on that subject... if you go further and expose the Document
object to work with the contents of the browser, for example...

doc = w.Document

then you also need to check for document readiness before continuing
processing as follows...

while w.ReadyState != 4 and doc.readyState != "complete":
time.sleep(1)

Useful links:
http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/IWebBrowser2/IWebBrowser2.asp

http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_document.asp

HTH,


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


Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread Roel Schroeven
John Hazen wrote:

> * [EMAIL PROTECTED] <[EMAIL PROTECTED]> [2005-05-02 05:10]:
> 
>>Any hints on level 6 ?
>>There is "zip" in the page source, "ZIp" in the
>>image data, but have no clue what to do with them
>>- tried many things :). 
> 
> 
> Have you found the zip file yet?
> 
> (I did, and I still can't figure it out.  I'm wondering if there are
> comments embedded in the jpg that none of my viewers will show me.
> Hmm, maybe there's a python module that does that...  I'll play with it
> more after I sleep on it.)
> 
> -John

Possible spoiler, so ROT13'ed:

Qvq lbh frr naq ernq gur ernqzr.gkg va gur mvc svyr?

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

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


Re: Which IDE is recommended?

2005-05-02 Thread Steffen Glückselig
> I'm a fan of PSPad.  It's free, light weight, and works with
> everything.
I want to second that. For small scripts PSPad is definitely very
useful and comfortable.

For larger scripts I'd consider something with code-completion. Maybe
PyDev.


best regards
Steffen

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


Re: Forgot my wrapup of example! Sorry!

2005-05-02 Thread GMane Python
So, I forgot the last part of my example that might gel in your mind why
Objects are useful in certain situations.  Ok so you maybe followed my
example of the shopping cart.  Let's just forget for a moment the use for
shopping carts is for  websites.  Let's just say you were going to write the
lines directly into Python, like maybe at the IDLE interpreter.  Like maybe
you're testing the functionality of the routine for correctness, not actual
implementation.



You have a ShoppingCartClass(), and three users-> Dave, Tommy, Bryan.

ShoppngCartClass() has 3 methods:

.AddItem()

.RemoveItem()

.CheckOut()



These are really just def routintes you write in the class to do some action
or calculation.  Here, we want to either add an item to 'the cart', remove
one, or finalize the order.



In the interpreter,  you could do this. Define 3 users of the
ShoppingCartClass.



Dave = ShoppingCartClass()

Tommy = ShoppingCartClass()

Bryan = ShoppingCartClass()





Ok.  Now you could do different things to each:



Dave.AddItem(sku=5)

Tommy.AddItem(sku=77)

Tommy.AddItem(sku=12)

Tommy.RemoveItem(sku=12)

Dave.CheckOut(state=CT, ccard='visa', ccardnum='1234-5678-8765-431')

Tommy.CheckOut(stsate=RI, ccard='mastercard', ccardnum='431-123-4321-1234')

Bryan.CancelOrder()



so, if you were then to take account of what you had, you'd know:

Dave has item SKU=5

Tommy has item SKU=77

Bryan has his order cancelled.



This is still very hard-coded.  You could abstract, or maybe variablize,
things more. Let's try:



You can mix classes with say dictionaries, to make their use in routines
more beneficial.



So, you could have:



user = "Dave"

ShoppingCart={}

ShoppingCart[user] = ShoppingCartClass()

user = "Tommy"

ShoppingCart[user] = ShoppingCartClass()

user = "Dave"

ShoppingCart[user].AddItem(sku=55)

user = "Tommy"

ShoppingCart[user].CheckOut( ... )

ShoppingCart["Dave"].CheckOut( ... )



Putting the classes in the dictionary allow you to use names from things
like fields, config files, text files, TextControls in my favorite program
wxPython, etc.



In a class, you can have a variable 'total' and you can have a variable
'self.total'.  The first is just accessible from within the structure of the
class.  The latter is accessible from outside the class.  So, using a class
with the variable self.total, you can from outside the class say:



print ShoppingCart["Dave"].total



to get the value of the variable self.total.  (That had me buggered for a
while . )



If you can wrap your mind around this, you're well on your way to using OOP
I believe.  If not, , don't give up. I'm just a python/programming newbie
and maybe missed the boat completely with my posting.



Another quite important part I didn't even mention was sub-classing.  That's
taking a class, and 'inheriting' it's code to your class as a base, then you
can re-write or adddifferent methods.  But, first I think it's important to
understand how to have several instances of a single class running in
memory, each with different values for the defined variables.  I'll let
someone else talk about that.



-Dave



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


Re: How to kill a SocketServer?

2005-05-02 Thread Skip Montanaro
>> > set self.pause to something short-ish.  The select call times out
>> > and the server exits.

Guido> [Paul Rubin]
>> Ah, good point.  Something like this should probably be added to
>> SocketServer.py (optional timeout parameter to serve_forever), or at
>> least the trick should be mentioned in the docs.

Guido> I like this idea, and perhaps you all could come up with some
Guido> more useful APIs in this area...

I stumbled on a somewhat cleaner way to do this using socket timeouts:

class Server(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
pause = 0.25
allow_reuse_address = True

def __init__(self, server_address, RequestHandlerClass):
SocketServer.TCPServer.__init__(self, server_address,
RequestHandlerClass)
self.socket.settimeout(self.pause)
self.serving = 1
...

def serve_forever(self):
while self.serving:
self.handle_request()

As far as my simple testing went (a trivial little xmlrpc server exposing
only "noop" and "exit" methods), the above worked fine.  I was mildly
surprised that I didn't have to catch socket.timeout exceptions.

Skip

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


popen2 psql

2005-05-02 Thread Mage
  Hello,

maybe my question is about linux and not about python.

I tried to write a proxy script for "psql" command. I need some query
log. I failed to read from the file object.

I have tested:

a,b = os.popen2('ls')
for s in b.readlines(): print s,

and:

a,b = os.popen2('./pto.py')
for s in b.readlines(): print s,

popen2 works with 'ls' but it doesn't output anything with the './pto.py'.
The 'pto.py' is an existing python script and contains some print.

Likely I have the same problem with popening the python script and the
psql binary. I can simple popen('psql').write(), but I would like to log
everything, so I need stdin and stdout files.

Please help.

   Mage


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


Re: lists in cx_Oracle

2005-05-02 Thread Andrew Dalke
infidel wrote:

> Something like this might work for you:
> 
 ids= ['D102', 'D103', 'D107', 'D108']
 in_clause = ', '.join([':id%d' % x for x in xrange(len(ids))])
 sql = "select * from tablename where id in (%s)" % in_clause
 import cx_Oracle as ora
 con = ora.connect('foo/[EMAIL PROTECTED]')
 cur = con.cursor()
 cur.execute(sql, ids)

That's pretty much what I did but it seems inelegant.
I would rather do

  ids = ['D102', 'D103', 'D107', 'D108']
   .. connect and set up the cursor ..
  cursor.execute("select * from tablename where id in :ids", ids)

and if 'ids' is seen to be a list or tuple then it does
the appropriate conversion.  (I'm also fine with having
to use ()s in the SQL query, as in "id in (:ids)".)

The lack of a simple way to do this is error prone. I've seen
people do

  cursor.execute("select * from tablename where id in (%s)" % repr(ids))

because the repr of a string is close enough that it works
for expected string values.  But it opens up the possibility
of SQL injection problems.

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


Re: popen2 psql

2005-05-02 Thread Klaus Alexander Seistrup
Mage wrote:

> I tried to write a proxy script for "psql" command. I need some
> query log. I failed to read from the file object.

The psql command is probably linked against readline; did you look
in the ~/.psql_history file?

Cheers,

-- 
Klaus Alexander Seistrup
Magnetic Ink, Copenhagen, Denmark
http://magnetic-ink.dk/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: anybody have a CGIXMLRPCRequestHandler example?

2005-05-02 Thread Chris Curvey
here's the simple example, for posterity

import os
import SimpleXMLRPCServer

class Foo:
def settings(self):
return os.environ
def echo(self, something):
return something
def greeting(self, name):
return "hello, " + name

handler = SimpleXMLRPCServer.CGIXMLRPCRequestHandler()
handler.register_instance(Foo())
handler.handle_request()


and here's an example of the client that has to speak with it.  My
mistake was trying to call the server thru a web browser.  The
"textcall" shows you the format of the incoming request (which I
suppose I could have built by hand by reading the spec).

import xmlrpclib

server = xmlrpclib.ServerProxy("http://127.0.0.1/cms/Foo.py";)

yoonikode = u'Sacr\xe9 Bleu'
tup = tuple([yoonikode])
print tup
textcall = xmlrpclib.dumps(tup,("server.echo"))
print textcall
print server.echo("hi")
print server.greeting("dilbert")
print server.greeting(yoonikode)

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


Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread Roel Schroeven
Dan Bishop wrote:

> Roel Schroeven wrote:
> 
>>Dan Bishop wrote:
>>
>>
>>>Dan Bishop wrote:
>>>
>>>Correction: Now I'm stuck on Level 11.  I think I'm supposed to do
>>>something with the pixels in the image, but what?
>>
>>Me too. I've tried making different images out of the even and the
> 
> odd
> 
>>pixels, but nothing interesting happened. I tried to combine both
> 
> images
> 
>>in various ways (using the Gimp), but that also seemed to be a dead
> 
> end.
> 
> You only got 2 images?
> 
> *** SPOILER ALERT ***
[...]

Is that on the original image, or the new one? I solved it with the new 
one, but I'm still unable to do find the solution using the original one.

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

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


xmlrpc server running behind IIS as a CGI

2005-05-02 Thread Chris Curvey
Here's my server:

import os
import SimpleXMLRPCServer

class Foo:
def settings(self):
return os.environ
def echo(self, something):
return something
def greeting(self, name):
return "hello, " + name

handler = SimpleXMLRPCServer.CGIXMLRPCRequestHandler()
handler.register_instance(Foo())
handler.handle_request()

If I run this behind Apache/CGI, everything works fine.  If I run this
behind IIS/CGI, everything hangs when I call the server  (I have
confirmed that a "hello world" program runs fine thru CGI when called
via a web browser).

Here's the client program:

import xmlrpclib
server = xmlrpclib.ServerProxy("http://127.0.0.1:81/cms/Foo.py";)
print server.settings()

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


Re: How to kill a SocketServer?

2005-05-02 Thread Guido van Rossum
[Skip Montanaro]

> I stumbled on a somewhat cleaner way to do this using socket timeouts:
> 
> class Server(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
> pause = 0.25
> allow_reuse_address = True
> 
> def __init__(self, server_address, RequestHandlerClass):
> SocketServer.TCPServer.__init__(self, server_address,
> RequestHandlerClass)
> self.socket.settimeout(self.pause)
> self.serving = 1
> ...
> 
> def serve_forever(self):
> while self.serving:
> self.handle_request()
> 
> As far as my simple testing went (a trivial little xmlrpc server exposing
> only "noop" and "exit" methods), the above worked fine.  I was mildly
> surprised that I didn't have to catch socket.timeout exceptions.

I think this would cause timeouts in the middle of handling request
whenever a client is slow.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
-- 
http://mail.python.org/mailman/listinfo/python-list


Bhavaya-like ORM for Python?

2005-05-02 Thread Wolfgang Keller
Hello,

does anyone know of a Python ORM module that works like Bhavaya does
for J***? In case Bhavaya isn't known, an introduction can be found at:
http://bhavaya.openadaptor.org/intro.html.

TIA,

Best regards

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


Use case for multiple inheritance (was Re: MRO problems with diamond inheritance?)

2005-05-02 Thread Aahz
In article <[EMAIL PROTECTED]>,
Michele Simionato <[EMAIL PROTECTED]> wrote:
>
>BTW, what it your use case? I have yet to see a single compelling use
>case for multiple inheritance, so I am curious of what your design is.

Dunno whether you'd call it compelling, but my current company uses
multiple inheritance to compose a mega-class with different methods
depending on what the mega-class's capabilities are.  It's a pretty
baroque design, admittedly, but I'm not sure how I'd do it differently
from scratch.  We've even implemented our own super() for cooperative
method calls with classic classes.

(This application was started in Python 1.4; we're slowly refactoring
it, but we're still using Python 2.2/2.3 -- we didn't get rid of 1.5.2
until last July.  Now you know why I've gotten even more conservative
since I started this job last June...)
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"It's 106 miles to Chicago.  We have a full tank of gas, a half-pack of
cigarettes, it's dark, and we're wearing sunglasses."  "Hit it."
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-02 Thread darren kirby
quoth the Ganesan Rajagopal:
> I am stuck on level 3. I've tried every re that I can think of. Some body
> give me a clue.
>
> Ganesan
>
> --
> Ganesan Rajagopal

>>> t = /text of page source.../
>>> re.findall('[a-z][A-Z]{3}[a-z]{1}[A-Z]{3}[a-z]', t)

You should get ten results. Consider all ten together to get your solution...

-d
-- 
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972


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

Canvas drawing slow

2005-05-02 Thread phil
I'm mapping quadratic equations on a Canvas.
But that's irrelevant, the point is I am drawing
a lot of points in a loop without returning to
mainloop until the end.  I want my students to see the
drawing progress, so I call update_idletasks() after
each tiny rectangle. ( I use to call update() and it
seems to make no difference)

This is so fast at first I am tempted to put a sleep(.01) in the
loop.  But after a few thousand points it starts to slow down
dramatically.  WHy?  I thought udate_idletasks would only redraw
the 'damaged' portion.
Maybe my approach is wrong.

I was hoping to use Canvas to do some simple instructional
animation, but not if I can't solve this mystery.

Any help appreciated.


BTW: I posted a couple days ago about rotating objects making
the item stack grow.  My bad, debugging bug, fixed it.

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


Re: lists in cx_Oracle

2005-05-02 Thread infidel
I think perhaps you are asking for something that the OCI doesn't
provide.  At least I'd be rather surprised if it did.  I know that the
SQL syntax doesn't provide for such a mechanism.

And really, it all boils down to the list comprehension:

in_clause = ', '.join([':id%d' % x for x in xrange(len(ids))])

... elegance is certainly subjective, and the above statement isn't the
cleanest ever, but it solves your main problem while avoiding the other
problem you mentiong (sql injection).  Seems "elegant enough" to me.

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


How close program in the wxPython?

2005-05-02 Thread Tian
I have made a program in wxpython, but how could i exit the program? I
am using wxFrame for my window, what is the function to close the
program?

Thanks!!

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


Re: odeint function in SciPy

2005-05-02 Thread Ben Champion
Thanks for the link! I think it has the information I want in it (the
numerical method eg Runge-Kutta). However I am not sure which of the
solvers listed within that file is used by odeint.

All I want to achieve is to write a few lines on the mathematical
method used by odeint for my college project.

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


Mouseclick

2005-05-02 Thread Terje Johan Abrahamsen
Hello.

I have been trying desperately for a while to make Python push the
left mousebutton. I have been able to let Python push a button in a
box:

def click(hwnd):
win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, 0, 0)
win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, 0)

optDialog = findTopWindow(wantedText="Options")

def findAButtonCalledOK(hwnd, windowText, windowClass):
return windowClass == "Button" and windowText == "OK"
okButton = findControl(optDialog, findAButtonCalledOK)

click(okButton)

As described here, http://tinyurl.com/cwjls. But, that is not what I
am looking for. I would like to specify some coordinates such as
windll.user32.SetCursorPos(450, 370) and thereafter click the left
mousebutton at that place.

I know that the sollution lies somewhere with Microsoft
(http://www.6URL.com/FED), but cannot understand how to make Python
click the button regardless of how much I try.

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


How to tell if invoked through IDLE or command line?

2005-05-02 Thread Robert D. Young
I've probably asked this before, but how can I tell within the program I'm
running if the .py files was involved by "run module" in IDLE or by using
the .py assoication with the python.exe program? I'd like to prevent running
under certain circumstances, or pop-up warnings, or change character
displays (some look different when run under IDLE).

- Robert


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


Re: Important please read this Thank you `°º·...·º°`°º·...·º°`°º·.†..·º°`°º·...·º°`°º·..·º°` `°º·...·º°`°º·...·º°`°º·.†..·º°`°º·...·º°`°º·..·º°` `°º·...·º°`°º·...·º°`°º·.†..·º°`°º·...·º°`°º·..·º°` `°º·...·º°`°º·...·º°`°º·.†..·º°`°º·...·º°`°º·..·º°` `°º·...·º°`°º·...·º°`°º·.†..·º°`°º·...·º°`°º·..·º°` `°º·...·º°`°º·...·º°`°º·.†..·º°`°º·...·º°`°º·..·º°` `°º·...·º°`°º·...·º°`°º·.†..·º°`°º·...·º°`°º·..·º°` `°º·...·º°`°º·...·º°`°º·.†..·º°`°º·...·º°`°º·..·º°` GOOGLE·NEWSGROUP·POST·155

2005-05-02 Thread Please
Reports to [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED],
[EMAIL PROTECTED], [EMAIL PROTECTED]

And do not feed the troll!
-- 
http://mail.python.org/mailman/listinfo/python-list


Quick and dirty dialogs?

2005-05-02 Thread andy
What's the easiest way for a script to throw up simple dialogs such as
file select and alerts?

I thought there was something in the standard library that didn't need
TK and was cross-platform but I can't seem to get my Google-fu working
well enough to find it.

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


Re: Mouseclick

2005-05-02 Thread Benji York
Terje Johan Abrahamsen wrote:
> I have been trying desperately for a while to make Python push the
> left mousebutton.

Here's some code I've used to simulate a *right* click, but it should 
be obvious how to make it do what you want:

void sendRightClick(void)
{
 PostMessage(GetForegroundWindow(), WM_RBUTTONDOWN, MK_RBUTTON, 0);
 PostMessage(GetForegroundWindow(), WM_RBUTTONUP, 0, 0);
}

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


RE: Quick and dirty dialogs?

2005-05-02 Thread Robert Brewer
[EMAIL PROTECTED] wrote:
> What's the easiest way for a script to throw up simple dialogs such as
> file select and alerts?
> 
> I thought there was something in the standard library that didn't need
> TK and was cross-platform but I can't seem to get my Google-fu working
> well enough to find it.

If by "didn't need TK" you mean "I don't want to have to learn Tk", try
Steve Ferg's EasyGUI:

http://www.ferg.org/easygui/


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


SQLRelay Problem

2005-05-02 Thread Evrim Ozcelik
Hi,
My zope server is running on fedore core3. I want to connect to ms sql 
server running on windows xp platform using FreeTDS, SQLRelay and 
ZSqlRelayDA. My sqlrelay.conf can be seen below:





   
  
 
  
  
 
  
   


As you seen there is only 1 listener socket created. I can execute the 
first sql command successfully but i can't execute the second command. 
The sqlrelay error shown in the log file:

Client Library error:
severity(78)
layer(0)
origin(0)
number(51)
Error:  Attempt to initiate a new SQL Server operation with results pending.

I think the connection does not end after the execution. When all the 
listener sockets used the system becomes useless. Then i restart the 
sqlrelay service in order to clear the sockets.

What must i do ? The listener socket must be empty after the execution.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Quick and dirty dialogs?

2005-05-02 Thread Robert D. Young
I use quick-and-dirty code like this:


# Get source directory and text file

Root = Tkinter.Tk()
Root.title(programname)
srcdir = tkFileDialog.askdirectory(title='Choose the source directory',
initialdir='C:\\')
srcfile = tkFileDialog.askopenfilename(title='Choose the text file',
initialdir=srcdir)
Root.destroy()



- Robert


<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> What's the easiest way for a script to throw up simple dialogs such as
> file select and alerts?
>
> I thought there was something in the standard library that didn't need
> TK and was cross-platform but I can't seem to get my Google-fu working
> well enough to find it.
>


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


compare two voices

2005-05-02 Thread phil
You didn't indicate how deep you want to get into
the code yourself.

I am gonna step way out of my mathematical depth here
and say this should not be too difficult in python.
1. you need to know the format of .wav
surely it is a set of frequency amplitude pairs.
2. you need to know the sampling rate is the same,
 say its a hundred points per second, a five second
  speech is only a 500 hundred point pair of curves.
3. then perhaps a package like MatLAb would give you the
  curve fitting algorithms to obtain a score.
 It might even compensate for an average frequency
  diff between the two samples.

The difference in tonal quality between native Germans
and native Thais I would think would not enter into
it, because that is part of what you are testing for.

The math for comparing two waves which are different at
every point, have different base frequencies and different
rates is hellacious, but its been done.
Python would just be the wrapper, and a good one.

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


  1   2   3   >