Re: Derived class and deepcopy

2005-02-17 Thread Fredrik Lundh
Philip Smith wrote:

 In the given example I want to apply deepcopy() to the Matrix instance (on 
 initialisation) to 
 ensure that the list part is not affected by subsequent changes to the 
 initialising list or Matrix 
 but this gives me a string of errors (some of which imply I'm trying to copy 
 the class rather than 
 the instance).

 Anyone got any thoughts on this

where's the example?  what errors do you get?

/F 



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


Re: Problem using/installing numarray

2005-02-17 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

   ImportError: No module named _conv
 The file _conf.pyd exists, but my guess is that the .pyd suffix is not
 recognized under the CygWin version of Python.  (But that doesn't make
 sense...)

you can use imp.get_suffixes() to get a list of supported extensions.
here's the output from a stock python.org stock interpreter on WinXP:

 import imp
 imp.get_suffixes()
[('.pyd', 'rb', 3), ('.dll', 'rb', 3), ('.py', 'U', 1), ('.pyw', 'U', 1), 
('.pyc', 'rb', 2)]

/F 



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


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread news.sydney.pipenetworks.com
Nick Vargish wrote:
Leo Breebaart [EMAIL PROTECTED] writes:

That suggests
to me an obvious default of the kind that exists elsewhere in
Python as well.

I feel pretty much the opposite... If a non-string-type has managed to
get into my list-of-strings, then something has gone wrong and I would
like to know about this potential problem.
If you want to do force a conversion before the join, you can use a 
list comp:

', '.join([str(x) for x in l])
Nick Explicit is better than Implicit
Really ? Then why are you using python. Python or most dynamic languages 
are are so great because of their common sense towards the implicit. 
You must have heard of never say never but never say always (as in 
always better) is more appropriate here. There are many cases of 
python's implicitness.

What about
a = string
b = 2
c = %s%s % (a, b)
There is an implicit str(b) here.
''.join([string, 2]) to me is no different then the example above.
Huy
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Fredrik Lundh
news.sydney.pipenetworks.com wrote:

 Nick Explicit is better than Implicit

 Really ? Then why are you using python. Python or most dynamic languages are 
 are so great because 
 of their common sense towards the implicit. You must have heard of never 
 say never but never 
 say always (as in always better) is more appropriate here. There are many 
 cases of python's 
 implicitness.

a certain princess bride quote would fit here, I think.

 What about

 a = string
 b = 2
 c = %s%s % (a, b)

 There is an implicit str(b) here.

nope.   it's explicit: %s means convert using str().

from the documentation:

  %s String (converts any python object using str()).


 ''.join([string, 2]) to me is no different then the example above.

so where's the %s in your second example?

/F 



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


RE: huge help for interactive python

2005-02-17 Thread Tim Golden
[David S.]

[... snip recommendation of Gary Bishop's readline ...]

| 
| I could not find a list of the keyboard commands 
| that readline supports, so I generated:
| 
| http://fsinnovations.net/share/keymap.pdf

Brilliant! Thanks very much. I've half-used ipython
for several months, but I'm so keyboard-aware in
the normal Windows cmd shell that I found it a hard 
switch, no matter how well- motivated I was. Now I 
hope to make the best of both worlds.

TJG


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

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


Re: low-end persistence strategies?

2005-02-17 Thread John Lenton
On Wed, Feb 16, 2005 at 10:43:42PM -0800, Michele Simionato wrote:
 snip simple example with flock
 
 What happens if for any reason the application crashes?
 Locked files will stay locked or not? And if yes, how do I
 unlock them?

the operating system cleans up the lock.

-- 
John Lenton ([EMAIL PROTECTED]) -- Random fortune:
Linux ext2fs has been stable for a long time, now it's time to break it
-- Linuxkongreß '95 in Berlin


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

:-)

2005-02-17 Thread Bart van Deenen
Jack Diederich [EMAIL PROTECTED] wrote:

 /tmp/ python
 Python 2.3.4 (#2, Jan  5 2005, 08:24:51) 
 Type help, copyright, credits or license for more information.
  ^D


 :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-)

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


Re: Help with C extensions under VC6 / WinXP and Python 2.4

2005-02-17 Thread Fredrik Lundh
Simon John wrote:

 What's the difference between ctypes, SWIG and SIP?

 I've used SWIG to convert C source to Python (as I believe SIP
 does?), so does ctypes wrap functions from binaries (e.g. DLL's)?

ctypes is a runtime linker.  it generates bindings on the fly, at runtime,
and doesn't require a separate compilation step.

/F 



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


Re: low-end persistence strategies?

2005-02-17 Thread Michele Simionato
John Lenton:
 the operating system cleans up the lock.

So, are you effectively saying than a custom made solution based on
flock
can be quite reliable and it could be a reasonable choice to use
shelve+flock
for small/hobbysts sites? I always thought locking was a bad beast and
feared
to implement it myself, but maybe I was wrong afterall ...

 Michele Simionato

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


Re: Help with C extensions under VC6 / WinXP and Python 2.4

2005-02-17 Thread Miki Tebeka
Hello Simon,

 What's the difference between ctypes, SWIG and SIP?
SIG and SIP take C/C++ *sources* and create Python modules. ctypes works
directly with the binary dll.

Bye.
--

Miki Tebeka [EMAIL PROTECTED]
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys
-- 
http://mail.python.org/mailman/listinfo/python-list


Best way to SIGHUP spamd from web page?

2005-02-17 Thread Robert Brewer
I'd like to be able to restart spamd (the SpamAssassin daemon) from a
web page, so that it will reload its system config files. Currently, I'm
only worried about Debian; my SA is from the testing (Sarge) distro, and
I'm running Apache 1.3. I don't have any other signals to send, or
commands, and no dynamic values other than the pid (which I can read
just fine from /var/run/spamd.pid).

Basically, there are half-a-dozen different ways to get this to happen,
but all of them spend 3/4 of their documentation saying DON'T EVER DO
THIS. I'm just wondering if anyone has recommendations for whose advice
to ignore first. ;) Detailed explanations of your choice would be much
appreciated, of course.


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


performance increase rpm v compile

2005-02-17 Thread tony barratt
Hello,
I am working on a python app which does quite a lot of database manipulation 
via berkeley db.
An increase in performance would be welcome, although ait is pretty quick it 
just has a lot to do.
Currently it runs on RH 8.0, FC2 or 3 coming. And it is installed from an 
(rpm python-2.2.1-17).
It runs on a dual processor xeon. My experience with X leads me to believe 
you can get a performance increase of 10-20% from compiling it.
Is this likely to be true for python?

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


Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread Leif B. Kristensen
john san skrev:

 pure DOS, old pc, used for teaching . want show some windows under
 DOS (under Python).

curses is a text-based interface that will let you build windowed
applications like you could with the crt unit in Turbo Pascal of those
golden days. I've no idea if anyone's compiled it for the 16-bits DOS
platform, though.
-- 
Leif Biberg Kristensen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread Leif B. Kristensen
john san skrev:

 Actually the windows running very good under the xbox-NTOS via
 xboxmediacenter. its just limited functions(not easy to programming
 the windows prog.), if we can find WxPython-like can be ported (I
 can import *
 from it  to my xboxPython) )it will be a great great . You
 will have HD screen and web surfing on HDTV and computing on HDTV.
 think about it! That is a real thing the python-like lang. should to
 do otherwise just a garbage(toy).

You can run Linux with MythTV on an XBox. Does all the things you want,
and of course it will run WxPython.
-- 
Leif Biberg Kristensen

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


RE: keeping a COM server alive

2005-02-17 Thread Stefan Schukat
Hi, 

there is no real solution if you are using a standard local server.
The server is as a COM object reference counted. So if the
reference count reaches 0 (no client) it will shutdown itself which
is done by design. If you want a different behavior you should write
either a service which exports COM objects and is started by the
operating system or a Python script which you start by hand, 
registers the class factories and then does not shut down.

Stefan

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of
 [EMAIL PROTECTED]
 Sent: Monday, February 14, 2005 12:53 PM
 To: python-list@python.org
 Subject: keeping a COM server alive
 
 
 I have implemented a local COM Server with win32com framework 
 where all
 clients
 use the same global object (test_obj). So far it works, but when the
 last client
 is closed the gobal object is deleted because the pythonw.exe is
 closed. When I
 create a new client a new pythonw process is started. I need that the
 new client
 gets the same global object. How can I prevent the Python COM
 enviornment
 (pythonw.exe) to close when no client exist. I figured out a
 workaround, but
 there must be real solution to the problem.
 
 
 
 The code looks like:
 
 class test:
 ...
 
 test_obj=test()
 
 
 class test_F:
 
 _reg_clsid_ = ...
 _reg_progid_ = test.cl
 _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
 _public_methods_ = ...
 
 
 def __init__(self):
 self.delegate=test_obj
 
 ...
 
 
 Workaround to keep the local server alive
 if not __name__=='__main__':
 import win32com.client
 dummy=win32com.client.Dispatch(test.cl)
 ##
 
 
 if __name__=='__main__':
 import win32com.server.register
 win32com.server.register.UseCommandLine(test_F, debug=0)
 
 -- 
 http://mail.python.org/mailman/listinfo/python-list
 
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pmw.Balloon under Windows

2005-02-17 Thread Eric Brunel
On 16 Feb 2005 10:51:27 -0800, Aki Niimura [EMAIL PROTECTED] wrote:
[snip]
The software is working fine under Solaris 9.
However, when I tried it under Windows, it worked also fine but it spit
out
the following error message when exiting.
(from cygwin terminal)
% c:/Python23/python my_app.py
This application has requested the Runtime to terminate it in an
unusual way.
Please contact the application's support team for more information.
(the same error message is observed when I run the program directly in
Windows XP environment.)
//
[snip]
After painful investigation, I found Pmw.Balloon was causing this
problem
(because the problem went away if I commented out all balloon
statements).
Then I compared my usages and Pmw Balloon example because the example
didn't
cause this. (http://pmw.sourceforge.net/doc/Balloon.html)
I used the Pmw.Balloon quite a lot and never see any problem.
One question: what Python do you use? Is it a regular Windows Python distribution or the 
Python delivered with Cygwin? I know by experience that the Python in Cygwin has quite a 
lot of problems (mine crashes *very* often). If you don't already use a 
regular Windows distro, I think using one may solve your problem.
My questions are:
(1) Why my program is complaining and is there any workaround?
(2) What is the difference between using widget quit() method
and using Windows 'X' button.
- I know clicking Windows 'X' button generates an event but I thought
- ultimately it reached to the same routine to terminate the program.
I think the default binding for the 'X' button is to call destroy, not 
quit. Calling destroy on the main window is almost equivalent to calling quit, 
so maybe it can be a solution?
(3) Is it possible to fake clicking 'X' button?
I see a widget has event_generate() method.
Not that I know of. The event_generate method won't help here, because the 'X' button is 
handled by the window manager, and not by the application. It's a bit more complicated on Windows 
(as usual...) since there is no real window manager, but from the tk/Tkinter point of 
view, the result is the same: you can't fake a window manager event using 
event_generate.
BTW, what are the versions of Python, tk and Pmw you're using?
HTH a little...
 - Eric Brunel -
--
http://mail.python.org/mailman/listinfo/python-list


Re: Stable GUI

2005-02-17 Thread Lars
I've used Tkinter quite extensively for various tools, but never for
anything big. I believe it will work nicely for a data input type of
application. I don't  know if you'll experience significant lag when
updating app-windows on old pentiums, but it shouldn't be a problem.
Mind you, the machines should have a decent amount of ram (I guess
around 128 mb and upwards is reasonable).
The only problem I've ever encountered was with updating Tk widgets
from threads in a threaded app - it won't work. The solution was
nothing worse than using an output queue, and having an event check the
output buffer every second or so.

The Tcl/TK crowd probably have more extensive experience with using Tk
and Tix for bigger long running apps, maybe you can ask them for more
info?

Good luck with your app!
Lars

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


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Nick Craig-Wood
Nick Vargish [EMAIL PROTECTED] wrote:
  I feel pretty much the opposite... If a non-string-type has managed to
  get into my list-of-strings, then something has gone wrong and I would
  like to know about this potential problem.

This is a good argument.

Why not have another method to do this?  I propose joinany which will
join any type of object together, not just strings

That way it becomes less of a poke in the eye to backwards
compatibility too.

  Nick Explicit is better than Implicit

Aye!

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


Re: Help with C extensions under VC6 / WinXP and Python 2.4

2005-02-17 Thread Martin v. Löwis
Scott wrote:
I'm specifically trying to perform step 6. Creating a brand
new project using VC6.
The instructions are outdated. Don't use VC6 to build
extension modules for Python 2.4.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Max M
Nick Craig-Wood wrote:
Nick Vargish [EMAIL PROTECTED] wrote:

Why not have another method to do this?  I propose joinany which will
join any type of object together, not just strings
 l = [1,2,3,'four']
 ','.join(map(str, l))
'1,2,3,four'
Is this really that hard to do, that you want it in the library?
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Michael Hoffman
Nick Craig-Wood wrote:
Why not have another method to do this?  I propose joinany which will
join any type of object together, not just strings
I think that's what Frederik was proposing. Except that it would be
called join and be a built-in (not a str method).
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Michael Hoffman
Max M wrote:
  ','.join(map(str, l))
'1,2,3,four'
Is this really that hard to do, that you want it in the library?
I think it's a sufficiently common use case that having to do that
is a wart.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list


Re: Stable GUI

2005-02-17 Thread Jarek Zgoda
Lars napisa(a):
The only problem I've ever encountered was with updating Tk widgets
from threads in a threaded app - it won't work. The solution was
nothing worse than using an output queue, and having an event check the
output buffer every second or so.
I know literally no GUI toolkit, that allows direct updating of GUI 
objects from any other thread that the one which created them. Some even 
do not allow updating from any other thread than main application thread 
and this may be really painful.

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


Re: MYSQL - how to install ?

2005-02-17 Thread export

Daniel Bowett wrote:
 Lad wrote:
  I am sorry it was my fault I did not say that clearly.
   I do not have a problem to install MySQL  server but I do not know
how
  to install MySQLdb module on my windowsXP so that I can work  with
  MySQL server via Python 2.3.
  Thanks for help
  Lad
 

 Try this installer, if you want a newer version you will need to
compile
 it yourself.


http://prdownloads.sourceforge.net/mysql-python/MySQL-python.exe-1.0.0.win32-my4.1-py2.3.exe?download

Thank you I will try. As far as I understand I can install the latest
MySQL server and then MySQLdb module on my windowsXP with the
installer( the link you provided above).
Is it so?
Lad.

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


Re: difference between class methods and instance methods

2005-02-17 Thread Duncan Booth
John M. Gabriele wrote:

 I've done some C++ and Java in the past, and have recently learned
 a fair amount of Python. One thing I still really don't get though
 is the difference between class methods and instance methods. I
 guess I'll try to narrow it down to a few specific questions, but
 any further input offered on the subject is greatly appreciated:

I'll try not to cover the same ground as Steven did in his reply.

 
 1. Are all of my class's methods supposed to take 'self' as their
 first arg?
consider this:
 class Demo(object):
def foo(self, x):
print self, x
@classmethod
def clsmethod(cls, x):
print cls, x
@staticmethod
def stmethod(x):
print x


 instance = Demo()

Calling a bound method, you don't pass an explicit self parameter, but the 
method receives a self parameter:

 bound = instance.foo
 bound(2)
__main__.Demo object at 0x00B436B0 2

Note that it doesn't matter whether you call instance.foo(2) directly, or 
bind instance.foo to a variable first. Either will create a *new* bound 
method object, and the correct instance is used for the call. This is 
significantly different from languages such as C++ and Javascript which are 
a real pain if you want to use a method as a callback.

Calling an unbound method, you pass a self parameter explicitly (and it 
must be an instance of the class, *or an instance of a subclass*:

 unbound = Demo.foo
 unbound(instance, 2)
__main__.Demo object at 0x00B436B0 2

Again is doesn't matter whether you do this in one step or two. The usual 
case for using an unbound method is when you have overridden a method in a 
derived class and want to pass the call on to a base class. e.g.

 class Derived(Demo):
def foo(self, x):
 Demo.foo(self, x)

A class method is usually called through the class rather than an instance, 
and it gets as its first parameter the actual class involved in the call:

 Demo.clsmethod(2)
class '__main__.Demo' 2
 Derived.clsmethod(2)
class '__main__.Derived' 2

You can call a class method using an instance of the class, or of a 
subclass, but you still the get class passed as the first parameter rather 
than the instance:

 d = Derived
 d.clsmethod(2)
class '__main__.Derived' 2

A common use for class methods is to write factory functions. This is 
because you can ensure that the object created has the same class as the 
parameter passed in the first argument. Alternatively you can use class 
methods to control state related to a specific class (e.g. to count the 
number of instances of that exact class which have been created.)

There is no equivalent to a class method in C++.

Static methods are like static methods in C++. You can call them through 
the class or a subclass, or through an instance, but the object used in the 
call is not passed through to the method:

 Demo.stmethod(2)
2
 instance.stmethod(2)
2
 Derived.stmethod(2)
2
 d.stmethod(2)
2
 

 
 2. Am I then supposed to call them with MyClass.foo() or instead:
 
 bar = MyClass()
 bar.foo()
 ?

If you have an instance then use it. If the class method is a factory then 
you might want to create a new object of the same type as some existing 
object (but not a simple copy since you won't get any of the original 
object's state). Mostly though you know the type of the object you want to 
create rather than having an existing instance lying around.

 
 3. Is bound method a synonym for instance method?

Close but not quite. It is a (usually transient) object created from an 
unbound instance method for the purposes of calling the method.
 
 4. Is unbound method a synonym for class method?

Definitely not.

 
 And if anyone's *really* daring:
 Where do the so-called static methods fit into all this?
 By the name of them, it sounds like the same thing as class
 methods...

See above.

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


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Nick Coghlan
Leo Breebaart wrote:
All I've been able to find is a 1999 python-dev post by Tim
Peters which would seem to indicate he doesn't understand it
either:
string.join(seq) doesn't currently convert seq elements to
 string type, and in my vision it would. At least three of us
 admit to mapping str across seq anyway before calling
 string.join, and I think it would be a nice convenience
 [...]
But now it's 2005, and both string.join() and str.join() still
explicitly expect a sequence of strings rather than a sequence of
stringifiable objects.
There's a more recent discussion than that, because I tried to change it shortly 
after I offered a patch to fix a corner case for string subclasses.

This seems to be the last relevant message in the thread:
http://mail.python.org/pipermail/python-dev/2004-August/048516.html
So it was tried, but we found too many weird corner cases we weren't quite sure 
what to do with. At that point, explicit is better than implicit kicked in :)

A shame, since it was both faster and more convenient than using a list comp. 
But the convenience wasn't worth the ambiguity of the semantics.

Cheers,
Nick.
P.S. For anyone else that uses Firefox:
Linking the pydev keyword to
http://www.google.com/search?q=site:mail.python.org+inurl:python-dev+%s;
and the pylist keyword to
http://www.google.com/search?q=site:mail.python.org+inurl:python-list+%s;
makes searching the archives on python.org really easy. Of course, knowing what 
you're looking for because you were a participant in the discussion helps, too ;)

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


Re: MYSQL - how to install ?

2005-02-17 Thread Daniel Bowett
[EMAIL PROTECTED] wrote:
Daniel Bowett wrote:
Lad wrote:
I am sorry it was my fault I did not say that clearly.
I do not have a problem to install MySQL  server but I do not know
how
to install MySQLdb module on my windowsXP so that I can work  with
MySQL server via Python 2.3.
Thanks for help
Lad
Try this installer, if you want a newer version you will need to
compile
it yourself.

http://prdownloads.sourceforge.net/mysql-python/MySQL-python.exe-1.0.0.win32-my4.1-py2.3.exe?download
Thank you I will try. As far as I understand I can install the latest
MySQL server and then MySQLdb module on my windowsXP with the
installer( the link you provided above).
Is it so?
Lad.
Thats correct.
--
http://mail.python.org/mailman/listinfo/python-list


need of help

2005-02-17 Thread Tarik Messaoudi
Hello,
Please I need of  help about :
  * how to display an browser  window
  * how to display a window in the midle of the screen
   and finaly how to insert an image in a canvas within a program
--
http://mail.python.org/mailman/listinfo/python-list


Re: MYSQL - how to install ?

2005-02-17 Thread Harlin
Sorry about the mis-read. Keep in mind that if you're doing this on
win32 (and it looks like you are), you can use ODBC a bit easier. :)

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


Re: need of help

2005-02-17 Thread Harlin
Need more info on this. Are you:

1. Trying to create a GUI window of your own making? If so, what
toolkit are you using?

2. Trying to open a web browser? If so, you can do the following:

import os

os.system('path/to/executable options')

or

os.startfile('pagename.html')

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


Re: Pausing a program - poll/sleep/threads?

2005-02-17 Thread Harlin
import time

play_something()

time.sleep(LengthOfSongInSeconds)

do_something()


Have you tried that? I'd be interesting in seeing this app you have. !

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


Re: keeping a COM server alive

2005-02-17 Thread [EMAIL PROTECTED]
Hi,

thanks, I 'll post the problem in python-win32@python.org ...

   Frank

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


Re: PythonCard and Py2Exe

2005-02-17 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
(Most recent call last):
C:\Documents and Settings\Gateway User\ Desktop\custdb\setup.py, 
 line 1, name = custdb, 'setup' is not defined
There may be a single word infront of 'setup' on the fourth line, it
scramble on my screen because I have to use a screen capture to read
the error (it pops up for just a second before the window shuts down.
That's because you're not running it from a command prompt.
Please open a command prompt (Start Menu, select Run,
type cmd.exe and ENTER, then type the following line
to get to the folder with the script:
cd c:\documents and settings\gateway user\desktop\custdb
(If that doesn't work, perhaps there is really a space in
front of desktop as you show above...)
Once you're there, you should be able to run the script
directly just by typing its name plus the arguments
required: setup.py py2exe (without the quotes).  If
you can get that far, you should have the full error
message in a form you can directly cut and paste.  If
it adds nothing over what you show above, however, then
I'm at a loss because I can't see how your script could
possibly have generated that error...
Here's the full setup.py script I ran to get the error:
from distutils.core import setup
import py2exe
setup( name = custdb,
   console = [custdb.py],
   data_files = [ (., [custdb.ini, custdb.de.rsrc.py
custdb.rsrc.py, customerdata.csv]) ]
This makes no sense to me, given the error message.  The error
reports that it fails on line 1, yet line 1 in the above
is the import statement, and doesn't have name = custdb on
it as the error reports.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Leif K-Brooks
Leo Breebaart wrote:
What I can't find an explanation for is why str.join() doesn't
automatically call str() on its arguments
I don't really like that idea for the reasons others have stated. But a 
related and (IMHO) more Pythonic idea would be to allow arbitrary 
objects to be str.join()ed if they use __radd__ to allow concatenation 
with strings. This would be consistent with how the + operator behaves:

Python 2.4 (#2, Jan  8 2005, 20:18:03)
[GCC 3.3.5 (Debian 1:3.3.5-5)] on linux2
Type help, copyright, credits or license for more information.
 class Foo(object):
... def __radd__(self, other):
... if isinstance(other, basestring):
... return other + str(self)
... def __str__(self):
... return 'Foo()'
...
 'foo:' + Foo()
'foo:Foo()'
 ''.join(['foo', Foo()])
Traceback (most recent call last):
  File stdin, line 1, in ?
TypeError: sequence item 1: expected string, Foo found
--
http://mail.python.org/mailman/listinfo/python-list


Help needed for to build a CGI shell interface.

2005-02-17 Thread Slalomsk8er
I don't get it with the popen (popen3 or subprocess).
1. How do I establish my pipes?
2. And how do I interact with the pipes (interactive CGI-page)?
Thanks, Dominik
--
http://mail.python.org/mailman/listinfo/python-list


Re: gui scripting

2005-02-17 Thread Tonino
hi,

thanks - am already involved in a process to modify winguiauto.py  -
this is a GREAT start but we need more control and better handleing ;)

Thanks for the WATSUP site - will check on this as well ;)

Thanks
T

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


Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread Lucas Raab
Leif B. Kristensen wrote:
john san skrev:

Actually the windows running very good under the xbox-NTOS via
xboxmediacenter. its just limited functions(not easy to programming
the windows prog.), if we can find WxPython-like can be ported (I
can import *
from it  to my xboxPython) )it will be a great great . You
will have HD screen and web surfing on HDTV and computing on HDTV.
think about it! That is a real thing the python-like lang. should to
do otherwise just a garbage(toy).

You can run Linux with MythTV on an XBox. Does all the things you want,
and of course it will run WxPython.
But does that involve modding the Xbox?? As in messing with the hardware??
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Nick Vargish
news.sydney.pipenetworks.com [EMAIL PROTECTED] writes:

 Really ? Then why are you using python.

Try import this at a Python prompt. I didn't invent Explicit is
better than implicit.

 Python or most dynamic languages are are so great because of their
 common sense towards the implicit.

Python is not most dynamic languages, and does not seem to
implicitly cast objects into other types. Python may be dynamic,
but it's also strongly typed, a feature I consider a benefit, though
you are of course free to disagree.

 c = %s%s % (a, b)
 There is an implicit str(b) here.

Not if you read the docs, as another poster has pointed out.

 ''.join([string, 2]) to me is no different then the example above.

TypeError: sequence item 1: expected string, int found

Which pretty much supports my initial argument -- if a non-string got
into the list, something needs to be fixed, and it isn't the behavior
of the join() method!

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: Stable GUI + wxPython memory leak

2005-02-17 Thread Viktor
Peter Hansen wrote:
 On which platform?

On Linux, and I'm watching the percentage of used memory with *top* or
*ps v* (I have 256 MB). The aplication started with 19% used and after
45 minutes playing I saw i eat up almost 70%.

I also noticed that:

 from Tkinter import *
 l = Listbox()
 l.pack()
 for i in range(20):
... l.insert('end', str(i)) # Occupy memory
...
 l.delete(0, 'end')  # Free the memory

Doesn't free the memory. The memory stays occupied. OK, when I do the
same thing again, no additional memory is occupied. He uses the same
memory allocated first time, but why doesn't he free it and why memory
isn't fread up even if I explicitly call

 l.distroy()
 del l
?!

Thank You.

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


Re: Help needed for to build a CGI shell interface.

2005-02-17 Thread Diez B. Roggisch
Slalomsk8er wrote:

 I don't get it with the popen (popen3 or subprocess).
 
 1. How do I establish my pipes?
 
 2. And how do I interact with the pipes (interactive CGI-page)?

There are plenty of python + http frameworks out there - from simple
cgi-like ones like mod_python to full fledged app servers like zope. As
usual, google is your friend. No need to dig into the things you mentioned
above - at least not for what you want to do right now.
-- 
Regards,

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


tiff via email-module

2005-02-17 Thread Arenz, Ralph
hi all,

my problem is to get a tiff-file-attachment out of an email sent by a
fax-server.
When i try this with get_payload(decode='True') i get additional 
informations, looks like binary-mixed header-information, enveloping the 
tiff-data. 

I tried the following: Sending the email from outlook to a postfix-user and
a file on the postfix-host as well. The file shows the stucture mentioned
above. The mail for the postfix-user is deliverd correctly. So postfix must
fetch the raw tiff-data too!?.

Is there a way to get the raw tiff-data using the email-module?


Any ideas?

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


Re: Stable GUI + wxPython memory leak

2005-02-17 Thread Fredrik Lundh
Viktor wrote:

 Doesn't free the memory. The memory stays occupied. OK, when I do the
 same thing again, no additional memory is occupied. He uses the same
 memory allocated first time, but why doesn't he free it and why memory
 isn't fread up even if I explicitly call

the memory is released, but it's still assigned to the process.  if, how and 
when it's
returned to the operating system depends on a lot of things, most of which are 
out-
side Python's control.

(fwiw, this is how dynamic memory management works on most platforms).

/F 



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


Is it possible to use the logging-module in a threadless environment?

2005-02-17 Thread Roger
I'd like to use a program (roundup) that imports the logging.config
module on a machine where I could not get the thread and threading
modules to compile.

How dangerous is it to changing /lib/python2.4/logging/config.py to
something like:

import dummy_thread as thread, dummy_threading as threading


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


Re: check if object is number

2005-02-17 Thread TZOTZIOY
On Sat, 12 Feb 2005 16:01:26 -0800, rumours say that Michael Spencer
[EMAIL PROTECTED] might have written:

 Yup, that's basically what I'm doing right now.  The question was really 
 how to define that adapter function. =)
 
 Steve
OK - then my entry is:
   assert obj+1 = 1
:-)

So -1 is not a number.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why Tk treat F10, F11, F12 diferently from F1...F9?

2005-02-17 Thread TZOTZIOY
On Sun, 13 Feb 2005 00:10:35 -0200, rumours say that Gabriel B.
[EMAIL PROTECTED] might have written:

[snip: F10 in Motif activates the menu bar]

i'm on windowsXP (what makes the F10 biding by default even more
weird). Well, for now using the keysym_num will be more safe since i'm
still getting they correct.

It's not weird, it's the same in Windows as far as I remember (windows 3.0).
F10 is the same as depressing Alt.
-- 
TZOTZIOY, I speak England very best.
Be strict when sending and tolerant when receiving. (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread news.sydney.pipenetworks.com
Fredrik Lundh wrote:
news.sydney.pipenetworks.com wrote:

Nick Explicit is better than Implicit
Really ? Then why are you using python. Python or most dynamic languages are are so great because 
of their common sense towards the implicit. You must have heard of never say never but never 
say always (as in always better) is more appropriate here. There are many cases of python's 
implicitness.

a certain princess bride quote would fit here, I think.
I'm not really familiar with it, can you enlighten please.
What about
a = string
b = 2
c = %s%s % (a, b)
There is an implicit str(b) here.

nope.   it's explicit: %s means convert using str().
ok you got me there, although it must be bad practice compared to
c = %s%d % (a, b)
because this is much more explicit and will tell you if b is ever 
anything other then an integer even though you may not care.

from the documentation:
  %s String (converts any python object using str()).

''.join([string, 2]) to me is no different then the example above.

so where's the %s in your second example?
/F 
I'm not sure if this has been raised in the thread but I sure as heck 
always convert my join arguments using str(). When does someone use 
.join() and not want all arguments to be strings ? Any examples ?

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


Re: Stable GUI + wxPython memory leak

2005-02-17 Thread Sion Arrowsmith
Peter Hansen  [EMAIL PROTECTED] wrote:
Viktor wrote:
 I just noticed that wxPython is leaking memory?! Playing with
 wxPython-demo, I started with 19MB used, and ended whith almost 150MB
 used?!
 It's wxPython 2.5.3.1 running on Python 2.4.
On which platform?

And how are you measuring this apparent memory consumption?

And what are you doing to the demo to provoke it? (I've had a
wxPython application significantly increase its memory footprint
on Windows just from opening a file dialog.)

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  Frankly I have no feelings towards penguins one way or the other
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list


Convert a raw pointer to IDispatch

2005-02-17 Thread Roger That
Hi,
I am trying to use the function CreateStreamOnHGlobal from python code 
(I need to pass an IStream object to MSXML, like I do in C++ code).

I was able to retrieve a pointer on the IStream object in this way:
from ctypes import *
stream = c_int()
windll.ole32.CreateStreamOnHGlobal(c_long(0), c_long(1), byref(stream))
print %x%stream.value
The problem is that I would like to attach this pointer to a python 
IDispatch object (in Python only, not using a C++ DLL to do the stuff). 
Do you know a way to do it ?

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


Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread Fuzzyman

john san wrote:
 Actually the windows running very good under the xbox-NTOS via
 xboxmediacenter. its just limited functions(not easy to programming
the
 windows prog.), if we can find WxPython-like can be ported (I can
import *
 from it  to my xboxPython) )it will be a great great . You
will have
 HD screen and web surfing on HDTV and computing on HDTV. think about
it!
 That is a real thing the python-like lang. should to do otherwise
just a
 garbage(toy).




I assume you mean that without python the Xbox is just a toy..

Regards,

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

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


Re: pyFMOD writing a callback function in Python

2005-02-17 Thread kdahlhaus
Any opinion on pyFMOD vs. pySonic?

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


Re: Stable GUI

2005-02-17 Thread Thomas Guettler
Am Wed, 16 Feb 2005 06:19:27 -0800 schrieb Viktor:

 Which GUI is the most stable one? I don't need any fancy looking
 widgets (look and feel doesn't realy matter to me), I just need it
 to be rock stable and fast...

Hi,

For me pygtk is enough stable and fast.

The reference is good:
http://www.pygtk.org/pygtk2reference/index.html


 Thomas

-- 
Thomas Güttler, http://www.thomas-guettler.de/


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


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread news.sydney.pipenetworks.com
Nick Vargish wrote:
news.sydney.pipenetworks.com [EMAIL PROTECTED] writes:

Really ? Then why are you using python.

Try import this at a Python prompt. I didn't invent Explicit is
better than implicit.
Thanks for the pointer. Let's see how many zen points are for the OP's 
idea vs against

Against
Explicit is better than implicit.
Special cases aren't special enough to break the rules.
On the wall
Errors should never pass silently.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
Namespaces are one honking great idea -- let's do more of those!
For
Beautiful is better than ugly.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Although practicality beats purity. Unless explicitly silenced.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Well this is clearly a goer ;-)
Python or most dynamic languages are are so great because of their
common sense towards the implicit.

Python is not most dynamic languages, and does not seem to
implicitly cast objects into other types. Python may be dynamic,
but it's also strongly typed, a feature I consider a benefit, though
you are of course free to disagree.

c = %s%s % (a, b)
There is an implicit str(b) here.

Not if you read the docs, as another poster has pointed out.
''.join([string, 2]) to me is no different then the example above.

TypeError: sequence item 1: expected string, int found
Which pretty much supports my initial argument -- if a non-string got
into the list, something needs to be fixed, and it isn't the behavior
of the join() method!
Nick

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


os.walk()

2005-02-17 Thread rbt
Could someone demonstrate the correct/proper way to use os.walk() to skip certain 
files and folders while walking a specified path? I've read the module docs and 
googled to no avail and posted here about other os.walk issues, but I think I need to 
back up to the basics or find another tool as this isn't going anywhere fast... I've 
tried this:

for root, dirs, files in os.walk(path, topdown=True):
file_skip_list = ['file1', 'file2']
dir_skip_list = ['dir1', 'dir2']
for f in files:
if f in file_skip_list
files.remove(f)
for d in dirs:
if d in dir_skip_list:
dirs.remove(d)
NOW, ANALYZE THE FILES
And This:
files = [f for f in files if f not in file_skip_list]
dirs = [d for d in dirs if dir not in dir_skip_list]
NOW, ANAYLZE THE FILES
The problem I run into is that some of the files and dirs are not removed while others 
are. I can be more specific and give exact examples if needed. On WinXP, 
'pagefile.sys' is always removed, while 'UsrClass.dat' is *never* removed, etc.
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.walk()

2005-02-17 Thread Dan Perl

rbt [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Could someone demonstrate the correct/proper way to use os.walk() to skip 
 certain files and folders while walking a specified path? I've read the 
 module docs and googled to no avail and posted here about other os.walk 
 issues, but I think I need to back up to the basics or find another tool 
 as this isn't going anywhere fast... I've tried this:

 for root, dirs, files in os.walk(path, topdown=True):

 file_skip_list = ['file1', 'file2']
 dir_skip_list = ['dir1', 'dir2']

 for f in files:
 if f in file_skip_list
 files.remove(f)

 for d in dirs:
 if d in dir_skip_list:
 dirs.remove(d)

I think the problem here is that you are removing elements from a list while 
traversing it.  Try to use a copy for the traversal, like this:
 for f in files[:]:
 if f in file_skip_list
 files.remove(f)

 for d in dirs[:]:
 if d in dir_skip_list:
 dirs.remove(d)

 And This:

 files = [f for f in files if f not in file_skip_list]
 dirs = [d for d in dirs if dir not in dir_skip_list]

This is not doing what you want because it just creates new lists and it 
doesn't modify the existing lists that the os.walk generator is using. 


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


Re: Is it possible to use the logging-module in a threadless environment?

2005-02-17 Thread Denis S. Otkidach
On 17 Feb 2005 05:41:12 -0800
[EMAIL PROTECTED] (Roger) wrote:

 I'd like to use a program (roundup) that imports the logging.config
 module on a machine where I could not get the thread and threading
 modules to compile.
 
 How dangerous is it to changing /lib/python2.4/logging/config.py to
 something like:
 
 import dummy_thread as thread, dummy_threading as threading

I believe it's a bug and logging/config.py should use the same approach
as logging/__init__.py do:

try:
import thread
import threading
except ImportError:
thread = None

-- 
Denis S. Otkidach
http://www.python.ru/  [ru]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Nick Coghlan
news.sydney.pipenetworks.com wrote:
Nick Vargish wrote:
news.sydney.pipenetworks.com [EMAIL PROTECTED] writes:

Really ? Then why are you using python.

Try import this at a Python prompt. I didn't invent Explicit is
better than implicit.
Thanks for the pointer. Let's see how many zen points are for the OP's 
idea vs against

Against
Explicit is better than implicit.
Special cases aren't special enough to break the rules.
On the wall
Errors should never pass silently.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
Namespaces are one honking great idea -- let's do more of those!
For
Beautiful is better than ugly.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Although practicality beats purity. Unless explicitly silenced.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
From the point of view of someone who actually *tried* doing this to the 
relevant method, while maintaining backward compatibility. . .

Against:
Explicit is better than implicit
Special cases aren't special enough to break the rules
In the face of ambiguity, refuse the temptation to guess
  - there are plenty of ambiguious cases to handle
Simple is better than complex (Semantics  C code)
  - and much complexity in dealing with the ambiguities
Errors should never pass silently. Unless explicitly silenced.
  - and a bunch of them are likely to indicate errors. Maybe.
Readability counts (C code)
  - This makes the implemenation hard to read
If the implementation is hard to explain, it's a bad idea.
  - or explain to anyone, too
For:
Beautiful is better than ugly.
  - the explicit calls to str() aren't that clean.
There should be one-- and preferably only one --obvious way to do it.
  - Currently listcomp, genexp, map, string interpolation, etc
IMO, the rest can be used to argue either side, or simply don't weigh heavily 
either way.

The things that make it a real cow are the current behaviour of auto-promotion 
to the Unicode version when there are any Unicode strings in the list, and the 
existence of __str__ and __repr__ methods which actually return instances of 
unicode rather than str.

Calling str() explicitly makes the different behaviours unsurprising. Trying to 
do the same thing behind the scenes has the potential to make the method behave 
*very* suprisingly depending on the objects involved.

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


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Sion Arrowsmith
In article [EMAIL PROTECTED],

!

Nick Vargish  [EMAIL PROTECTED] wrote:
 If a non-string-type has managed to
get into my list-of-strings, then something has gone wrong and I would
like to know about this potential problem.

Thinking about where I use join(), I agree. If there's something
other than a string in my list, either I know about it and can
explicitly convert it (Explicit is better than implicit.) or
it's an error, and Errors should never pass silently.

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  Frankly I have no feelings towards penguins one way or the other
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.walk()

2005-02-17 Thread rbt
Roel Schroeven wrote:
rbt wrote:
The problem I run into is that some of the files and dirs are not
removed while others are. I can be more specific and give exact examples
if needed. On WinXP, 'pagefile.sys' is always removed, while
'UsrClass.dat' is *never* removed, etc.

Keep in mind that the comparisons are done case sensitive; are you sure
that there's no problem regarding uppercase/lowercase?
I've noticed that. I've tried most all combinations possible with the same 
results.
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.walk()

2005-02-17 Thread Max Erickson
snip

os.walk() is a generator. When you iterate over it, like in a for loop,
as
for r,ds,fs in os.walk(...):
r, ds and fs are set to new values at the beginning of each iteration.
If you want to end up with a list of files or dirs, rather than
processing them in the bodies of the file and dir for loops, you need
to keep a list of the files and dirs that os.walk gives you:

 import os
 dir_skip_list = ['sub2']
 file_skip_list = []
 keptfiles = list()
 keptdirs = list()
 for root, ds, fs in os.walk('c:\\bin\\gtest\\'):
for f in fs:
if f not in file_skip_list:
keptfiles.append(f)
for d in ds:
if d in dir_skip_list:
ds.remove(d)
else:
keptdirs.append(d)


 keptfiles
['P4064013.JPG', 'P4064015.JPG', 'Thumbs.db', 'P4064060.JPG',
'P4064061.JPG', 'Thumbs.db', 'PC030088.JPG', 'P4224133.JPG',
'Thumbs.db']
 keptdirs
['sub1', 'sub5', 'sub6']

There is something going on above that I don't quite understand, there
should be more directories, so if you can't get something working with
that, this gives you lists of files and dirs that you can then filter:

 keptfiles = list()
 keptdirs = list()
 for r, ds, fs in os.walk('c:\\bin\\gtest'):
keptfiles.extend(fs)
keptdirs.extend(ds)

 keptfiles
['P4064013.JPG', 'P4064015.JPG', 'Thumbs.db', 'P4064026.JPG',
'Thumbs.db', 'Thumbs.db', 'Thumbs.db', 'P4064034.JPG', 'Thumbs.db',
'P3123878.JPG', 'P4064065.JPG', 'Thumbs.db', 'P4064060.JPG',
'P4064061.JPG', 'Thumbs.db', 'PC030088.JPG', 'P4224133.JPG',
'Thumbs.db']
 keptdirs
['sub1', 'sub2', 'sub3', 'sub5', 'sub6', 'sub8', 'SubA', 'sub9',
'sub6']
 #filter away...

Hope this helps, 
max

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


Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread john san

oh, ya.

Fuzzyman [EMAIL PROTECTED] 
news:[EMAIL PROTECTED]

 john san wrote:
  Actually the windows running very good under the xbox-NTOS via
  xboxmediacenter. its just limited functions(not easy to programming
 the
  windows prog.), if we can find WxPython-like can be ported (I can
 import *
  from it  to my xboxPython) )it will be a great great . You
 will have
  HD screen and web surfing on HDTV and computing on HDTV. think about
 it!
  That is a real thing the python-like lang. should to do otherwise
 just a
  garbage(toy).
 
 
 

 I assume you mean that without python the Xbox is just a toy..

 Regards,

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



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


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Duncan Booth
news.sydney.pipenetworks.com wrote:

 I'm not sure if this has been raised in the thread but I sure as heck 
 always convert my join arguments using str(). When does someone use 
 .join() and not want all arguments to be strings ? Any examples ?

This has already been raised, but maybe not in exactly this context. You 
don't want to convert your arguments to be strings if some of them are 
unicode.

If I do:

  res = str.join(', ', [a, b, c])

then res is of type str if, and only if, a, b, and c are of type str.
If any of a, b, or c are of type unicode, then res is unicode.

In effect, this means you don't have to worry about whether you are 
manipulating str or unicode at this point in your program (kind of 
comparable to not caring whether the integer you are using is int or long).

When you come to output the string you do need to care, as when it is 
unicode you may have to encode it, but at least the internal manipulations 
can ignore this possibility.

Of course you could just call unicode on everything but for simple 
applications you might not want to handle unicode at all. That's not a 
decision Python can make for you so it shouldn't guess.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting milliseconds in Python

2005-02-17 Thread Curt
On 2005-02-16, Brian Beck [EMAIL PROTECTED] wrote:

seconds * 100 = milliseconds
 
 
 are you sure you know what a millisecond is?
 
 (duck) 

 Touché.

 But it was a typo.

Oh, you meant 'seconds / 100 = milliseconds'?

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


Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread john san
yes. u need mod-xbox. since its be easy done and we already have OS,
Python support what we need now is only that Python can easy to coding
and show window program just like wt we can do under Windows.


Lucas Raab [EMAIL PROTECTED] 
news:[EMAIL PROTECTED]
 Leif B. Kristensen wrote:
  john san skrev:
 
 
 Actually the windows running very good under the xbox-NTOS via
 xboxmediacenter. its just limited functions(not easy to programming
 the windows prog.), if we can find WxPython-like can be ported (I
 can import *
 from it  to my xboxPython) )it will be a great great . You
 will have HD screen and web surfing on HDTV and computing on HDTV.
 think about it! That is a real thing the python-like lang. should to
 do otherwise just a garbage(toy).
 
 
  You can run Linux with MythTV on an XBox. Does all the things you want,
  and of course it will run WxPython.

 But does that involve modding the Xbox?? As in messing with the hardware??


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


Re: Getting milliseconds in Python

2005-02-17 Thread Brian Beck
Curt wrote:
Oh, you meant 'seconds / 100 = milliseconds'?
(canard)
I assume you're suggesting that there are two typos in my original post 
(the * and the 100)...

Despite a millisecond being a thousandth of a second, given the number 
of seconds provided by the time module, he does have to *multiply* by a 
thousand to get the number of milliseconds.

2 seconds * 1000 = 2000 milliseconds
So, aside from the 100 in the original post, it may look misleading, but 
that is what he would need to do...

--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread Diez B. Roggisch
john san wrote:

 yes. u need mod-xbox. since its be easy done and we already have OS,
 Python support what we need now is only that Python can easy to coding
 and show window program just like wt we can do under Windows.

You can't. DOS does not allow for graphical output - at least not in a way
python supports it by standard toolkits like wxPython. That has nothing to
do with python, btw. You won't find anything else that can do that - apart
from some really old legacy toolkits that certainly aren't available today. 

Use either Linux with frambuffer output (see freevo) or a real Windows
that is capable of showing a graphical ui. 

Maybe somehow the pygame sdl wrapper can be used for gui-stuff. SDL has had
a DOS mode. But it is discontinued.
-- 
Regards,

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


Re: tiff via email-module

2005-02-17 Thread Max M
Arenz, Ralph wrote:
hi all,
my problem is to get a tiff-file-attachment out of an email sent by a
fax-server.
When i try this with get_payload(decode='True') i get additional 
informations, looks like binary-mixed header-information, enveloping the 
tiff-data. 
get_payload(decode=1) returns the decoded data. eg. the binary value 
of a file attachement.

If you get additional information there is most likely something wrong 
with your message, or you are not traversing it correctly.

You should do something like::
# untested
def getAttachments(message):
Returns attachments from message
maintype = message.get_type()
if maintype == 'application/octet-stream' :
return [message.get_payload(decode=1)]
if message.is_multipart():
attachments = []
for part in message.walk():
attachments.append(part.get_payload(decode=1))
return attachments
return []
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem using/installing numarray

2005-02-17 Thread maxwell
Thanks, that explains why the CygWin Python will not import the .pyd
files:

 imp.get_suffixes()
[('.dll', 'rb', 3), ('module.dll', 'rb', 3), ('.py', 'U', 1), ('.pyc',
'rb', 2)]

Doesn't look like there's a way to get the CygWin Python to load .pyd
files.  So I guess I have to figure out why the build isn't working...

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


Re: difference between class methods and instance methods

2005-02-17 Thread John
Duncan Booth wrote:
John M. Gabriele wrote:

I've done some C++ and Java in the past, and have recently learned
a fair amount of Python. One thing I still really don't get though
is the difference between class methods and instance methods. I
guess I'll try to narrow it down to a few specific questions, but
any further input offered on the subject is greatly appreciated:

I'll try not to cover the same ground as Steven did in his reply.
Thanks for taking the time to reply Duncan.

1. Are all of my class's methods supposed to take 'self' as their
first arg?
consider this:
  class Demo(object):
def foo(self, x):
print self, x
@classmethod
def clsmethod(cls, x):
print cls, x
@staticmethod
def stmethod(x):
print x

instance = Demo()
Calling a bound method, you don't pass an explicit self parameter, but the 
method receives a self parameter:

bound = instance.foo
bound(2)
__main__.Demo object at 0x00B436B0 2

Note that it doesn't matter whether you call instance.foo(2) directly, or 
bind instance.foo to a variable first. Either will create a *new* bound 
method object, and the correct instance is used for the call.
Za! What do you mean, create a new bound method object? I *already*
created that method when I def'd it inside the 'class Demo' statement,
no?
This is 
significantly different from languages such as C++ and Javascript which are 
a real pain if you want to use a method as a callback.

Calling an unbound method, you pass a self parameter explicitly (and it 
must be an instance of the class, *or an instance of a subclass*:

unbound = Demo.foo
unbound(instance, 2)
__main__.Demo object at 0x00B436B0 2
A! See, coming from C++, the first thing I thought
when I saw what you just wrote was, whoops, he shouldn't be
calling that instance method via the class name -- it's a bad
habit. Now I think I see what you mean: you may call an
instance method in two ways: via an instance where you don't
pass in anything for 'self', and via the class name, where
you must supply a 'self'.
Again is doesn't matter whether you do this in one step or two. The usual 
case for using an unbound method is when you have overridden a method in a 
derived class and want to pass the call on to a base class. e.g.
Ok. Interesting.
class Derived(Demo):
def foo(self, x):
 Demo.foo(self, x)
A class method is usually called through the class rather than an instance, 
and it gets as its first parameter the actual class involved in the call:

Demo.clsmethod(2)
class '__main__.Demo' 2
Derived.clsmethod(2)
class '__main__.Derived' 2
Check.
You can call a class method using an instance of the class, or of a 
subclass, but you still the get class passed as the first parameter rather 
than the instance:

d = Derived
d.clsmethod(2)
class '__main__.Derived' 2
Ok, so it looks like it may lead to confusion if you do that.
I wonder why the language allows it...

A common use for class methods is to write factory functions. This is 
because you can ensure that the object created has the same class as the 
parameter passed in the first argument. Alternatively you can use class 
methods to control state related to a specific class (e.g. to count the 
number of instances of that exact class which have been created.)

There is no equivalent to a class method in C++.
Right. I see -- because in Python, a reference the actual class
object is implicitly passed along with the method call. Whereas,
C++ doesn't even have class objects to begin with.
Static methods are like static methods in C++. You can call them through 
the class or a subclass, or through an instance, but the object used in the 
call is not passed through to the method:

Demo.stmethod(2)
2
instance.stmethod(2)
2
Derived.stmethod(2)
2
d.stmethod(2)
2

2. Am I then supposed to call them with MyClass.foo() or instead:
   bar = MyClass()
   bar.foo()
?

If you have an instance then use it. If the class method is a factory then 
you might want to create a new object of the same type as some existing 
object (but not a simple copy since you won't get any of the original 
object's state). Mostly though you know the type of the object you want to 
create rather than having an existing instance lying around.


3. Is bound method a synonym for instance method?

Close but not quite. It is a (usually transient) object created from an 
unbound instance method for the purposes of calling the method.
... hmm... bound methods get created each time you make
a call to an instance method via an instance of the given class?

4. Is unbound method a synonym for class method?

Definitely not.
Right. :)

And if anyone's *really* daring:
Where do the so-called static methods fit into all this?
By the name of them, it sounds like the same thing as class
methods...

See above.

--
--- remove zees if replying via email ---
--
http://mail.python.org/mailman/listinfo/python-list


Re: difference between class methods and instance methods

2005-02-17 Thread Diez B. Roggisch
John wrote:
 ... hmm... bound methods get created each time you make
 a call to an instance method via an instance of the given class?

No, they get created when you create an actual instance of an object. So
only at construction time. Creating them means taking the unbound method
and binding the created object as first argument to the method. Thus each
instance of a class Foo with a method bar has its own instance of bar - the
bound method bar. But only one per object. 


-- 
Regards,

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


Re: Getting milliseconds in Python

2005-02-17 Thread Brian Beck
Martin Christensen wrote:
A math teacher! A math teacher! My kingdom for a math teacher!
Martin
Man, this is the hottest topic on c.l.py since that Lazaridis guy...
--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list


site indexer and search script

2005-02-17 Thread flupke
Hi,
for an old intranet that is still used here, i would like to add a 
search function.

I think there migth already be an indexer/search script available in 
python. I've googled and come across a few scripts but i'm not sure 
which one is really easy and good at the task.
Any good scripts (and easy to configure) around?

I would like to use python to generate the corresponding results page, 
what would i use for that, again bearing in mind that it needs to be 
done quite quickly so i cannot afford to waste to much time ?

Is mod_python usable for such a simple page generation or would i better 
focus on Twisted or CherryPie?

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


Re: difference between class methods and instance methods

2005-02-17 Thread John
Diez B. Roggisch wrote:
John wrote:
... hmm... bound methods get created each time you make
a call to an instance method via an instance of the given class?

No, they get created when you create an actual instance of an object. So
only at construction time. Creating them means taking the unbound method
and binding the created object as first argument to the method. Thus each
instance of a class Foo with a method bar has its own instance of bar - the
bound method bar. But only one per object. 


O. Unlike C++, where methods are not first class objects
and you only have *one* that gets shared by all instances.
I'm getting it. Thanks for the reply. :)
---J
--
--- remove zees if replying via email ---
--
http://mail.python.org/mailman/listinfo/python-list


Re: difference between class methods and instance methods

2005-02-17 Thread Diez B. Roggisch
 O. Unlike C++, where methods are not first class objects
 and you only have *one* that gets shared by all instances.

Exactly - so unlike in c++, where you have to do ugly hacks if e.g. a C-lib
takes a callback and you want to pass an instance method, you can do that
in python. It's really great.

-- 
Regards,

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


Re: newbie question - iterating through dictionary object

2005-02-17 Thread Martin Christensen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 Miranda == mirandacascade  [EMAIL PROTECTED] writes:
Miranda 1) Is there any advantage to use the
Miranda y = a.keys()
Miranda for z in y:

While you're at it, you could save y altogether and just use

for z in a.keys():
...

Miranda looping technique rather than the
Miranda for x in a:
Miranda looping technique?

I certainly don't see any advatages.

Miranda 2) What are the tradeoffs for using each of the techniques?

'for x in a:' is prettier to look at. :-) As you can see, it's also
slightly faster (at least for very small dictionaries), but unless
you're doing a _lot_ of them, it won't matter.

% python2.4 -m timeit -c a = {1:1, 2:2, 3:3, 4:4, 5:5} for x in a: pass
100 loops, best of 3: 1.63 usec per loop
% python2.4 -m timeit -c a = {1:1, 2:2, 3:3, 4:4, 5:5} for x in a.keys(): 
pass
10 loops, best of 3: 2.1 usec per loop


Martin

- -- 
Homepage:   http://www.cs.auc.dk/~factotum/
GPG public key: http://www.cs.auc.dk/~factotum/gpgkey.txt
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using Mailcrypt+GnuPG http://www.gnupg.org

iEYEARECAAYFAkIUyPwACgkQYu1fMmOQldWV8ACdEZOgwwtOyp7c+hDVtQe+0LX1
yRoAoITJGZA6zA0iE9G4lp2cP/GinlZC
=njlP
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting milliseconds in Python

2005-02-17 Thread Martin Christensen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 Brian == Brian Beck [EMAIL PROTECTED] writes:
Brian Man, this is the hottest topic on c.l.py since that Lazaridis
Brian guy...

... which was really the point of my joke, even if it did belly flop
somewhat. This whole discussions brought to mind a cartoon where a
group of doctors were performing open heart surgery. One of them says,
Okay, how many of us believe that the heart has _four_ chambers?,
and a few of the others raise their hands. I intended it as a 'let's
call in the professors to determine if 2+2=4', but, well... :-)

Martin

- -- 
Homepage:   http://www.cs.auc.dk/~factotum/
GPG public key: http://www.cs.auc.dk/~factotum/gpgkey.txt
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using Mailcrypt+GnuPG http://www.gnupg.org

iEYEARECAAYFAkIUyzAACgkQYu1fMmOQldWVdACdHLxtUi4TtFCl0ZW6wf65Hu9M
ioMAoMWAHrkS5lhQw5V0cJXVO1nk76MO
=6MXl
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: difference between class methods and instance methods

2005-02-17 Thread Steven Bethard
John wrote:
Steven Bethard wrote:
John M. Gabriele wrote:
class C(object):
@classmethod
def f(cls, *args):
# do stuff
Sorry -- I'm not as far along as you suspect. :) I've
never yet seen this @classmethod syntax. I'm supposing that
it's part of this so-called new-style class syntax.
This is syntactic sugar in Python 2.4 for:
class C(object):
def f(cls, *args):
# do stuff
f = classmethod(f)
So if you'd like to check the docs, look in the builtins for classmethod 
(and staticmethod):

http://docs.python.org/lib/built-in-funcs.html

 From your reply, I gather that, unless I'm using this special
syntax (@classmethod or @staticmethod), all my def's are supposed
to take 'self' as their first arg.
Yup.  You're of course welcome to name it whatever you like, but the 
methods defined in your class (when not wrapped with classmethod, 
staticmethod, etc.) will all be called with an instance of the class as 
their first argument.  So you need to make sure 'self' or something like 
it is the first parameter to the function.

So then, are all def's -- that take 'self' as their first --
argument -- in a class statement, instance methods?
Basically, yes.  (Again, assuming they're not wrapped with anything.)
Consider the difference between str.join and ''.join:
py str.join
method 'join' of 'str' objects
 
py ', '.join
built-in method join of str object at 0x01233620
 
Hmm... weird.
Ok, the point here is that str.join and ', '.join are not the same 
object.  The reason is that, when the ', ' instance of str is created, 
new bound method objects are created for each of the instance methods 
in str.  These bound methods all know that the first argument to their 
functions is ', '.

py ', '.join(['a', 'b', 'c'])
'a, b, c'
Check.
py str.join(', ', ['a', 'b', 'c'])
'a, b, c'

[snip]
What's happening here?
str.join is the unbound method of the str object.  So just like you 
have to declare 'self' as the first argument of all your instance 
methods, the writer of the str object methods also declared 'self' as 
the first argumetn to str.join.  So str.join looks something like:

class str(object):
...
def join(self, sequence):
...
So when you access it like str.join(...) you should be passing it an 
instance and a sequence.  On the other hand, the bound method created 
for ', ' has already bound the instance, so it no longer expects the 
'self' argument to be passed in.

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


Re: newbie question - iterating through dictionary object

2005-02-17 Thread Grant Edwards
On 2005-02-17, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 1) Is there any advantage to use the

 y = a.keys()
 for z in y:

 looping technique rather than the

 for x in a:

 looping technique?

Not really.

 2) What are the tradeoffs for using each of the techniques?

for x in a can be more efficient since it allows the
dictionary to return key values one at a time instead of
creating a list containing all of them.  For small dictionaries
it won't matter.

Here's another choice, that's sometimes handy:

 d = {1:'one',2:'two',3:'three'}
 for k,v in d.items():
  print k,v
 
1 one
2 two
3 three
 

I wouldn't recommend this for large dictionaries.

-- 
Grant Edwards   grante Yow!  RELATIVES!!
  at   
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loading functions from a file during run-time

2005-02-17 Thread Wensheng
f=open(bar.txt)
import imp
fs=imp.new_module(fs)
exec f in fs.__dict__
 rests are the same

althought why use anything other than .py, when you import .py, it get
compiled into .pyc and it load faster next time

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


Re: newbie question - iterating through dictionary object

2005-02-17 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
1) Is there any advantage to use the
y = a.keys()
for z in y:
looping technique rather than the
for x in a:
looping technique?
2) What are the tradeoffs for using each of the techniques?
Calling dict.keys creates a list in memory of the keys to the dict. 
Using the dict directly in the for-loop (which implicitly calls 
__iter__) will only load one key into memory at a time.  The only time 
you should call keys is if you *really* need a list.  If you're just 
going to iterate over them in a for-loop, you should definitely use the 
latter technique.

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


Re: newbie question - iterating through dictionary object

2005-02-17 Thread Steven Bethard
Grant Edwards wrote:
Here's another choice, that's sometimes handy:
d = {1:'one',2:'two',3:'three'}
for k,v in d.items():
  print k,v
 
1 one
2 two
3 three

I wouldn't recommend this for large dictionaries.
Yes, for large dictionaries, you should use:
for k, v in d.iteritems():
print k, v
STeVe
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pausing a program - poll/sleep/threads?

2005-02-17 Thread Simon John
I don't think time.sleep() will work too well, I think it will cause
the program to hang around in the foreground, and prevent the GUI
updating.

I'll give it a try just to make sure, as I can't figure out the
signal/alarm thing (the alarm only seems to trigger when I click a
button, not after n-seconds

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


Creating properties with decorator like syntax

2005-02-17 Thread Will McGugan
Hi,
Is there any way of making properties using a decorator? The current way 
of creating a property seems inelegant.

Something like this imaginary snippit would be nice, IMHO.
class C(object):
@make_property
def x(self):
def getx(self): return self.__x
def setx(self, value): self.__x = value
def delx(self): del self.__x
Regards,
Will McGugan

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


Re: difference between class methods and instance methods

2005-02-17 Thread Duncan Booth
Diez B. Roggisch wrote:

 John wrote:
 ... hmm... bound methods get created each time you make
 a call to an instance method via an instance of the given class?
 
 No, they get created when you create an actual instance of an object.
 So only at construction time. Creating them means taking the unbound
 method and binding the created object as first argument to the method.
 Thus each instance of a class Foo with a method bar has its own
 instance of bar - the bound method bar. But only one per object. 
 
 
This is badly wrong. John was correct.

Bound methods get created whenever you reference a method of an instance. 
If you are calling the method then the bound method is destroyed as soon as 
the call returns. You can have as many different bound methods created from 
the same unbound method and the same instance as you want:

 inst = C()
 f1 = inst.foo
 f2 = inst.foo
 f1, f2
(bound method C.foo of __main__.C instance at 0x00B03F58, bound method 
C.foo of __main__.C instance at 0x00B03F58)
 f1 is f2
False
 f1 is inst.foo
False
 

Every reference to inst.foo is a new bound method.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help needed for to build a CGI shell interface.

2005-02-17 Thread Slalomsk8er
Diez B. Roggisch wrote:
Slalomsk8er wrote:

I don't get it with the popen (popen3 or subprocess).
1. How do I establish my pipes?
2. And how do I interact with the pipes (interactive CGI-page)?

There are plenty of python + http frameworks out there - from simple
cgi-like ones like mod_python to full fledged app servers like zope. As
usual, google is your friend. No need to dig into the things you mentioned
above - at least not for what you want to do right now.
What do I want to do? I am building an admintool (deamon and client) and 
for this I need to script a interface to the shell, with the console 
ansi escape sequences, whitch is fully transparent for the user.

I do not want Zope or Plone. I want Python and XUL.
Google is my friend but I did not found the answers I need to understand 
the concepts behind the parts (python internals and shell/terminal things).

Please point me to the info, I can not find it (tryed for some days) or 
post code so I can reverse engenieer ;) and adapt it.

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


Re: Pausing a program - poll/sleep/threads?

2005-02-17 Thread Simon John
Damn! signal is not supported on Windows.

time.sleep() doesn't work, as I suspected::

def info(self):
   sleep(5)
   self.info()

Basically causes the function to pause, then call itself again, all in
the foreground :-(

I'm thinking some sort of thread timer is the way to go, but really
don't understand threads

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


Re: Why doesn't join() call str() on its arguments?

2005-02-17 Thread Jeff Shannon
news.sydney.pipenetworks.com wrote:
Fredrik Lundh wrote:
a certain princess bride quote would fit here, I think.
I'm not really familiar with it, can you enlighten please.
(Taking a guess at which quote /F had in mind...)
Vezzini:  Inconceivable!
Inigo:You keep using that word.  I do not think that it means 
what you think it means.

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


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-17 Thread Ilias Lazaridis
Stephen Kellett wrote:
[...]
closing thread
http://groups-beta.google.com/group/comp.lang.python/msg/f2ae9cdbe16676d1
.
--
http://lazaridis.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-17 Thread Ilias Lazaridis
Mike Meyer wrote:
[...]
closing thread
http://groups-beta.google.com/group/comp.lang.python/msg/f2ae9cdbe16676d1
.
--
http://lazaridis.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-17 Thread Ilias Lazaridis
Bruno Desthuilliers wrote:
[...]
closing thread
http://groups-beta.google.com/group/comp.lang.python/msg/f2ae9cdbe16676d1
.
--
http://lazaridis.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: multimethod (or rather overloading) in Python

2005-02-17 Thread anton muhin
anton muhin wrote:
Correction:
Of course, I can imagine some metaclasses magic that would allow to code:
class MyClass(WithOverloading):
  @overloadMethod(A)
  def someMetod(self, _): ...
But it would rather convoluted: the best idea I have so far is to mangle 
 methods name in the manner most of C++ compilers do.
Stupid me. Of course, name magling is impossible and unnecessary. Sorry.
Still the question remains.
with the best regards,
anton.
--
http://mail.python.org/mailman/listinfo/python-list


Re: [EVALUATION] - E02 - ULTIMATE RECIPE TO RESOLVE ALL ISSUES

2005-02-17 Thread Ilias Lazaridis
Peter Maas wrote:
Ilias Lazaridis schrieb:
I'm a newcomer to python:

Sorry, I'm breaking my promise to post only once to this thread.
I'm breaking my 'promise' to close this thread.
But I've found the ultimate recipe to resolve all issues of this and 
other similar threads:

Please read
http://nobelprize.org/medicine/educational/pavlov/
and then do something useful :)
I don't think that this would change the disastrous communication 
behaviour of the python community [1]. For sure it has not changed yours.

And I don't think that this would change anything on the huge amounts of 
off-topic posts [including yours, and of course my reply to yours].

This thread proofs simply the inability of this community [1] to focus 
on a simple essence.

-
[1] community: the publically writing, within c.l.python
.
--
http://lazaridis.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pausing a program - poll/sleep/threads?

2005-02-17 Thread Jeff Shannon
Simon John wrote:
I'm writing a PyQt network client for XMMS, using the InetCtrl plugin,
that on connection receives a track length.
[...]
So, how would I make a Python program automatically call a function
after a preset period of time, without the Python process running in
the foreground (effectively single-tasking)?
I'm not familiar with Qt/PyQt myself, but the GUI toolkits I *am* 
familiar with all have a concept of a timer.  Basically, you create a 
timer that, when the specified amount of time has elapsed, will either 
deliver an event/message to your application's event queue or will 
directly call the callback function you provide.

However, I'd suggest that you may not want to wait for the entire 
length of the current track, especially if some other process or user 
(on any machine) may have access to the same XMMS application.  What 
happens when, after the song's been playing for a few seconds, someone 
skips to the next track?  Presumably, you'll want your network client 
to detect that and update appropriately.  This implies that you should 
check back in with the XMMS server every few seconds at least.  (You 
can still use a timer to do this; just have it fire periodically every 
second or so, rather than only after several minutes.)

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


Re: Calling a function from module question.

2005-02-17 Thread JRCondon
Sean, if you are asking what I think you are asking (I don't think name
hiding is the issue), you can use

from module_name import *

and you will end up with all of the functions at session scope.  You can
use the 'as' to alias the function names if you wish

from module_name import fn1 as myfn1, fn2 as myfn2

but, um, that gets confusing.

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


Re: Alternative to standard C for

2005-02-17 Thread James Stroud
On Sat, 2005-02-05 at 10:49, BJörn Lindqvist wrote:
  I am quite new to Python, and have a straight  simple question.
  In C, there is for (init; cond; advance). We all know that.
  In Python there are two ways to loop over i=A..B (numerical.):
  1) i = A
 while iB:
...do something...
i+=STEP
 
 This is indeed quite ugly. You rarely need such loops in Python and
 with some thinking you can often translate the C-equivalent to
 something more pythonic. As you guessed, your second problem is best
 solved with a generator function - xrange(). It is completely equal to
 range() except that it returns a generator instead of a list.

It seems I need constructs like this all of the time

i = 0
while i  len(somelist):
  if oughta_pop_it(somelist[i]):
somelist.pop(i)
  else:
i += 1

There has to be a better way...

Any thoughts?

James

-
7. Obsession with National Security
Fear is used as a motivational tool by the government over the masses.

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


Re: Convert a raw pointer to IDispatch

2005-02-17 Thread Thomas Heller
Roger That [EMAIL PROTECTED] writes:

 Hi,

 I am trying to use the function CreateStreamOnHGlobal from python
 code (I need to pass an IStream object to MSXML, like I do in C++
 code).

 I was able to retrieve a pointer on the IStream object in this way:

 from ctypes import *

 stream = c_int()
 windll.ole32.CreateStreamOnHGlobal(c_long(0), c_long(1), byref(stream))
 print %x%stream.value

 The problem is that I would like to attach this pointer to a python
 IDispatch object (in Python only, not using a C++ DLL to do the
 stuff). Do you know a way to do it ?

What do you want to do with this pointer? Pass it to a function called
via ctypes?

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


namespace collisions

2005-02-17 Thread Will McGugan
Hi,
I'm accumulating a number of small functions, which I have sensibly put 
in a single file called 'util.py'. But it occurs to me that with such a 
generic name it could cause problems with other modules not written by 
myself. Whats the best way of handling this? If I put it in a common 
location in my Python path, should I call it willsutil.py?

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


Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread Thomas Heller
Diez B. Roggisch [EMAIL PROTECTED] writes:

 Maybe somehow the pygame sdl wrapper can be used for gui-stuff. SDL has had
 a DOS mode. But it is discontinued.

What exactly is discontinued?  pygame? SDL?

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


Re: check if object is number

2005-02-17 Thread Michael Spencer
Christos TZOTZIOY Georgiou wrote:
On Sat, 12 Feb 2005 16:01:26 -0800, rumours say that Michael Spencer
[EMAIL PROTECTED] might have written:

Yup, that's basically what I'm doing right now.  The question was really 
how to define that adapter function. =)

Steve
OK - then my entry is:
assert obj+1 = 1
:-)

So -1 is not a number.
At least not a legal one for Steven's function as I understood it
Michael
--
http://mail.python.org/mailman/listinfo/python-list


msnp, friends list

2005-02-17 Thread jr
I'm currently using the msnp.py code from Manish Jethani's project. I
havn't been able to get the friends list to update like it should. it
works once out of about every 25 times the program loads.

Has anyone been able to implement his code and get the friends list to
actively update? Or have any suggestions?

Any info would be great.
Thanks.

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


Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread Jeff Shannon
Leif B. Kristensen wrote:
john san skrev:
pure DOS, old pc, used for teaching . want show some windows under
DOS (under Python).
curses is a text-based interface that will let you build windowed
applications like you could with the crt unit in Turbo Pascal of those
golden days. I've no idea if anyone's compiled it for the 16-bits DOS
platform, though.
Curses is a *nix interface.  There are attempts at a work-alike 
package for Windows, which by all reports are not very successful. 
Whether any of those would maintain their already-limited 
functionality under DOS is questionable.

There *are* similar-but-not-compatible libraries for DOS... or perhaps 
I should say *were*, because I have no idea where one might find such 
a thing now.  (Though I presume that Google would be the best starting 
place.)  One would then need to find/create a Python wrapper for that 
library...

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


  1   2   >