pyMpCCI v0.1

2005-06-22 Thread Marc Poinot

---
pyMpCCI v0.1

This package is a Python wrapper for MpCCI code-coupling product
(see http://www.scai.fraunhofer.de/mpcci.html)

MpCCI is a code-coupling system built on top of MPI. It insures data
translation between structured meshes and unstructured meshes codes.
For example when you build an application involving a structured 
mesh fluid solver (CFD) and an unstructured mesh structure solver (CSM).
With this pyMpCCI module, your target application can be written in Python.

It is useful for people using MpCCI and Python ;)

---
Package pyMpCCI uses Numeric Python.
The package is still incomplete and the doc is limited to the cover pages.
If you want more info, including the package download, please go to:

  http://cgns-python.berlios.de/index.html

-MP- 
---
 Marc POINOT Alias: marcvsEmail: [EMAIL PROTECTED]
 ONERA -MFE/DSNA/ELSATel: 01.46.73.42.84  Info: [EMAIL PROTECTED]
 29, Div. LeclercFax: 01.46.73.41.66  Site: 
 92322 Chatillon FRANCE  Project: elsAWeb: http://www.onera.fr
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: *Python* Power Tools

2005-06-22 Thread Terry Hancock
On Tuesday 21 June 2005 06:53 pm, John Machin wrote:
 Micah wrote:
  Anyone know if there is any organized effort underway to implement the
  Python equivalent of Perl Power Tools http://ppt.perl.org/?
  
  If not, would starting this be a waste of effort since:
 
 +1 WOFTAM-of-the-year
[...]
  Or would people really like to claim a pure Python set of UNIX
  utilities?
 
 Sorry, can't parse that last sentence.

In other words, it'd be a purely aesthetic goal.  Which is only a waste
if art is.

But then, I know *I'm* not going to spend time on it. ;-)
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: tree functions daily exercise: Table

2005-06-22 Thread gene tani
Dear Mr. Jones:

Our team of 3,972 expert testers judged the output of your
troll-spewing neural net virtually indistinguishable from the original.
 Given this, I am please to announce that our firm is willing to
discuss arrangements for an exclusive license that you would likely
find financially compelling.  Please do not post the code on
sourcefurge or whatever you call that open source thing until you speak
with us.

S. Ballmer

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


Re: getting an object name

2005-06-22 Thread Irmen de Jong
David Bear wrote:
 Let's say I have a list called, alist. If I pass alist to a function,
 how can I get the name of it?
 
 alist = range(10)
 
 def afunction(list):
 listName = list.__name__ (fails for a list object)
 

You don't, see the other reply.

You didn't say why you think you need this for, but I suspect
that you can solve your case by using a dict in one way or another:

{ somename: [1,2,3,4,5] }


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


Re: getting an object name

2005-06-22 Thread Simon Brunning
On 6/22/05, David Bear [EMAIL PROTECTED] wrote:
 Let's say I have a list called, alist. If I pass alist to a function,
 how can I get the name of it?

The effbot put it beautifully:

The same way as you get the name of that cat you found on your porch:
the cat (object) itself cannot tell you its name, and it doesn't
really care -- so the only way to find out what it's called is to ask
all your neighbours (namespaces) if it's their cat (object) ... and
don't be surprised if you'll find that it's known by many names, or no
name at all!

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


Re: Using code objects?

2005-06-22 Thread Fredrik Lundh
Chinook wrote:

 When I create the code objects though, it seems a couple different ways
 work and I'm wondering which is better and why (or is there a more correct
 technique in this situation)?

from where are you getting the source code for those code objects?

from the example below, it sure looks like using callable objects and
argument binding is a better way to do it.  for the simplest cases,
you can use a plain lambda to delay evaluation:


 The two different ways are illustrated below:

 Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
 [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)]
 Type help, copyright, credits or license for more information.
  def foo(st):
 ...   print st
 ...

 obj1 = lambda: foo(#expression1#)
 obj1()
#expression1#
 obj2 = lambda: foo(#expression2#)
 obj2()
#expression2#

/F



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


Re: utf8 and ftplib

2005-06-22 Thread Fredrik Lundh
Fredrik Lundh wrote:

 character references refer to code points in the Unicode code
 space, so you just convert the bytes you get after converting
 to UTF-8.

so you cannot just, of course.

/F



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


C++ ActiveX python javascript communication trouble.

2005-06-22 Thread whimsica
I'm investingating a c++ api, Panda3d.com, that has a python binding.
I want to convert this api into an ACtiveX control so it will run on
the web.  When I do so I want to use Microsoft Script Control to call
api routines from Javascript in the browser.


Let's say I write up a game in python with my own functions. Then I
embed it in a web page and I want to call my functions from javascript?
How can I do it. Script control allows you to bind api functions to
javascript, but not the functions in my python file.

Adobe Atmoshere a 3D application that ran in a web page, had a
javascript binding. You could write code in a javascript file, and it
would be interpreted during start-up. After that, I could send function
calls in the form of a string from the browser to atmosphere. How did
this work?  Is the api aware of the python functions and variables
after it is loaded up?

Confused,
Dan

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


C++ ActiveX python javascript communication trouble.

2005-06-22 Thread whimsica
I'm investingating a c++ api, Panda3d.com, that has a python binding.
I want to convert this api into an ACtiveX control so it will run on
the web.  When I do so I want to use Microsoft Script Control to call
api routines from Javascript in the browser.


Let's say I write up a game in python with my own functions. Then I
embed it in a web page and I want to call my functions from javascript?
How can I do it. Script control allows you to bind api functions to
javascript, but not the functions in my python file.

Adobe Atmoshere a 3D application that ran in a web page, had a
javascript binding. You could write code in a javascript file, and it
would be interpreted during start-up. After that, I could send function
calls in the form of a string from the browser to atmosphere. How did
this work?  Is the api aware of the python functions and variables
after it is loaded up?

Confused,
Dan

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


Reading registry export files

2005-06-22 Thread George
Hi,

I have exported some registry-keys using Regedit to a number of 
.reg-files. I can open these files using any text editor. Now I wanted 
to write a simple Python script to concatenate all these files to one 
output file. (Please note that I'm a newbie).

However, if I do something like:

  f=open('c:/documents and settings/myname/desktop/test.reg','r')
  r=f.read()
  print r

I get a lot of garbage with a lot characters which the Python shell 
cannot display (it display a square instead). The above code does work 
with ordinary text files.

Should I open these reg-files in a different way, or treat them 
differently once read in Python?

Thanks for any help.

Kind regards, George
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tree functions daily exercise: Table

2005-06-22 Thread Duncan Booth
Xah Lee wrote:

 oops, another error. The example should be:
 
 Table(f,[1,2,1],[2,6,2]) returns
 [[f(1,2),f(1,4),f(1,6)],[f(2,2),f(2,4),f(2,6)]]
 
 Wouldn't it be more sensible just to take the iterators directly as
 arguments, so for this example you would do:

 Table(f, range(1,3), range(2,7,2))
 
 well yes... but this was emulation of Mathematica functions.
 (Disclaimer: Mathematica is a trademark of Wolfram Research Inc, who is
 not affliated with this project)
 
 What you suggested is a function called Outer in Mathematica. The Table
 function is in a sense multi-dimentional version of Range, so they
 share syntax form.
 
Ok, so, if I understand you, the definition of Table is just:

def Table(f, *lists):
return Outer(f,
*[range(start,end+1,step) for (start,end,step) in lists])

Is that about right?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running WMI within a Windows service

2005-06-22 Thread cameron . mccloud
Tim,

Changing the path didn't do anything, but changing the name of the
module to my_wmi did the trick.

Thanks very much,

Cam.

Tim Golden wrote:
 [EMAIL PROTECTED]
 | Hi,
 |
 | When trying to import the WMI module in a Python Windows
 | Service, I get
 | the following:
 |
 | dynamic module does not define init function (initwmi)
 |
 | The WMI version is 0.6. Python 2.4 on Win32, Python Win32 extensions
 | version 203

 This is almost certainly caused by a problem which
 I consistently fail to mention on my site every time
 it comes up. In essence, the service you've defined
 will run in c:\winnt\system32, where there is an
 file called wmi.dll (which presumably implements
 the core WMI functionality). Python, looking for
 a wmi to import, finds this -- which could be
 a Python module -- and tries to import it. And fails.

 Possible solutions:

 1) Within the service code, switch directories to
some other directory before importing wmi.

 2) Rename wmi.py to something else (pywmi.py?)
and import that.

 3) Run the service as a named user, which will run
within that user's home directory. (Not at all
sure about this one; haven't tried it).

 HTH
 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: *Python* Power Tools

2005-06-22 Thread Daniel Dittmar
Micah wrote:
 Anyone know if there is any organized effort underway to implement the
 Python equivalent of Perl Power Tools http://ppt.perl.org/?
 
 If not, would starting this be a waste of effort since:
 
 - it's already being done in Perl?
 - cygwin thrives?
 - UNIX is already pervasive :-) ?
 
 Or would people really like to claim a pure Python set of UNIX
 utilities?

There would be some use for a Python library that implements the 
functionality of these tools. Some of it already exists (difflib, 
shutil). Some is probably more difficult and less flexible to use from a 
lib that from straight python (cut).

Perhaps that could be started either in the Python Cookbook 
(http://aspn.activestate.com/ASPN/Python/Cookbook/) or the Python Wiki 
(http://wiki.python.org/moin/). Just short explanations of how you would 
implement the functionality of various Unix utilities in Python.

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


Re: tree functions daily exercise: Table

2005-06-22 Thread Duncan Booth
Duncan Booth wrote:
 Ok, so, if I understand you, the definition of Table is just:
 
 def Table(f, *lists):
 return Outer(f,
 *[range(start,end+1,step) for (start,end,step) in lists])
 
 Is that about right?
 

And lest you think I left a bit too much as an exercise for the
reader: 

-- xah.py 
def Table(f, *lists):
Xah Lee's Table function
 Table(f,[3,10,2])
[f(3), f(5), f(7), f(9)]
 Table(f,[1,2,1],[2,6,2])
[[f(1, 2), f(1, 4), f(1, 6)], [f(2, 2), f(2, 4), f(2, 6)]]

return Outer(f, *[range(start,end+1,step) for (start,end,step) in lists])

def explode(lists):
Form all combinations of 1 element from each list.
 explode([[1,2], [3]])
[(1, 3), (2, 3)]
 explode([[1,2], [3,4]])
[(1, 3), (1, 4), (2, 3), (2, 4)]
 explode([[1,2], [3,4], [5]])
[(1, 3, 5), (1, 4, 5), (2, 3, 5), (2, 4, 5)]

result = [()]
for l in lists[::-1]:
result = [ (val,) + tail for val in l for tail in result ]

return result

def groupsOfN(it, n):
Returns tuples of length n taken from it.
 groupsOfN(range(12), 3)
[(0, 1, 2), (3, 4, 5), (6, 7, 8), (9, 10, 11)]
 groupsOfN(range(12), 1)
[(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (11,)]

it = iter(it)
return zip(*([it]*n))

def Outer(f, *lists):

 Outer(f, range(1,3), range(2,7,2))
[[f(1, 2), f(1, 4), f(1, 6)], [f(2, 2), f(2, 4), f(2, 6)]]

result = [f(*args) for args in  explode(lists)]
for l in lists[:0:-1]:
result = [list(v) for v in groupsOfN(result, len(l))]
return result

def _test():
global f
class f:
def __init__(self, *args):
self.args = args
def __repr__(self):
if len(self.args) == 1:
return %s(%r) % (self.__class__.__name__.split('.')[-1], 
self.args[0])
else:
return %s%r % (self.__class__.__name__.split('.')[-1], 
self.args)

import doctest
doctest.testmod()

if __name__ == __main__:
_test()
--
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Running WMI within a Windows service

2005-06-22 Thread Tim Golden
[EMAIL PROTECTED]
| 

[.. re problems running WMI in a service ...]

| Changing the path didn't do anything, but changing the name of the
| module to my_wmi did the trick.
| 
| Thanks very much,
| 
| Cam.
| 

Thanks for the feedback; I'll try to find the time to
experiment a bit but I know I've used the change-the-name
trick in the past. It has been suggested that I permanently
change the module name, but I'm a bit loth to do that. Mark
(Hammond) was talking about a patch which would prevent 
imports from picking up the false .dll, but I don't know
if it's gone anywhere.

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: Loop until condition is true

2005-06-22 Thread Ville Vainio
 Stelios == Stelios Xanthakis [EMAIL PROTECTED] writes:

Stelios Anyway, if you can't wait for 2.5 either use 'while 1:',
Stelios or pyc[1]

... and I can't see why people don't want to use 'while 1:' in the
first place, given that everyone can identify the idiom
immediately. It's 4 keystrokes less.

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


Re: Embedding Python - Deleting a class instance

2005-06-22 Thread Andreas Kostyrka
On Tue, Jun 21, 2005 at 12:06:47PM +, Bue Krogh Vedel-Larsen wrote:
 How do I delete a class instance created using PyInstance_New? I've tried 
 calling Py_CLEAR on the instance, but __del__ isn't called. I've also tried 
 calling PyObject_Del, but this gives an access violation in 
 _PyObject_DebugDumpAddress so I guess that ain't a good idea :)
 
 I've noticed that the PyObject returned by PyInstance_New has refcount = 2, 
 does this have any significance?
Well, the only way to do that is to call PyDECREF. And this is only legal 
when you really remove the reference, or else you get dangling pointers
which will lead to a corrupted heap and/or segfault somewhere in the future of
your program.

Andreas

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


Re: asynchronous comunication, wxPython and threads.

2005-06-22 Thread Zunbeltz Izaola
On Tue, 21 Jun 2005 11:07:35 -0400, Peter Hansen wrote:

 
 Please clarify: what does this mean?  Sending a socket is not a usual 
 way to describe TCP communications.  Do you mean your program _opens_ a 
 socket (like a phone connection) and _sends_ some data, then waits for 
 data to be received from the other end?  Or are you (as it almost 
 sounds) opening and closing sockets repeatedly for each part of the 
 conversation?


Sorry for the lack of clarity. I opened the socket once (i don't know if
itit is important to open inside or outside the comunication thread). And
them send packages and wait for data.

 
 
 I think you are using the term socket where you should be using 
 packet.  A socket is the virtual connection created by TCP.  A packet 
 is either a single blob of data sent by the TCP code in the operating 
 system, or perhaps a single chunk of your own data.
 

Thanks for the vocabulary correction.

 If you are using a single TCP socket to send multiple packets, and you 
 are talking about those packets being sent out of order, it's very 
 unlikely and there must be another explanation.  TCP _is_ reliable, and 
 you will not get data out of order unless you do something to screw 
 things up, for example by creating a race condition by doing 
 multithreaded code incorrectly.
 

I think this is the case (see the post of Toby). I didn't try it out but I
think the problem is that i *do* comunication in both threads.

 
 Some people advise that, but there's really nothing *wrong* with doing 
 this in a second thread, and in fact I do similar things all the time 
 with no ill effects.  While async frameworks _can_ make this easier, 
 they could also make it harder (at least for a while) as you adjust your 
 brain to the new approach.  Furthermore, at least in the case of 
 wxPython and Twisted (on Windows) there can be problems integrating the 
 two loops.  I don't believe the latest Twisted claims to have fully 
 solved the problems involved yet, so you might still be required to have 
 a second thread for the TCP stuff.
 

Yes, i have read that there is problems yet.

 
 I use a non-blocking socket and select() calls in my thread, and 
 communicate with the GUI thread using appropriate Queue objects and 
 calls to PostEvent() (or CallAfter()) on the wx side of things.  It's 
 pretty straightforward, so if you post a small piece of your application 
 which reproduces the problem it shouldn't be hard for someone here to 
 help you fix it.
 

Thanks. First i would check if the problem is what Toby says.

 
 No more so than using threads, unless your problem is caused by the
 threads themselves (as I suggested above) in which case it might be
 easier to just fix the problem.
 
 -Peter

Thank you very much

Zunbeltz

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


Re: *Python* Power Tools

2005-06-22 Thread Ville Vainio
 John == John Machin [EMAIL PROTECTED] writes:

John For windows users, apart from cygwin, there are a couple of
John sources of binaries for *x command-line utilities (unxutils,
John gnuwin32).

unxutils is my personal favourite - cygwin is way too much an
environment, and gets broken too easily.

I for one would like to see various shell tools implemented in pure
python, if only to be able to import them as a module and use cross
platform tools that have more power than e.g. 'shutil' or 'os'
functions. The API exposed through the module (as opposed to normal
execution from shell) could also be much richer, providing hooks for
calling own stuff for just-in-time error handling, progress
notification etc.

So no, it doesn't seem like bad idea at all. It's also something that
could evolve gradually, and reach a useful stage (i.e. have several
handy tools) quickly.

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


Re: need to strip stuff off email

2005-06-22 Thread Tim Williams


 nephish [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  hey there,
  i have a script that retrieves my email, but i need it to
  be able to strip all the stuff off except the body (the message itself)
  so i can later write it to a text file.
 
  anyone know how to accomplish this?
  thanks

The body is:   The rest of the email after the first blank line after the
subject header.   In practice it is the first blank line.

If you get the message into a string it can sometimes be easier to just
RSPLIT the string at '\r\n\r\n',  if the message is in a list then the body
= '\r\n'.join(msg[x:]) where x = that blank line +1  ,  that way if you
don't need any of the header info,  you don't have to decode the message and
rebuild it in a file.

if you *are* using the email module, eg

msg = email.message_from_file(a_file)

then rsplit the msg to get the same result.

As someone will no doubt point out,   some emails are broken and parts of
the headers will end up in the body (even when you view the email it in a
client),  this is very rare though.




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


suggestions invited

2005-06-22 Thread Aditi
hi all...i m a software engg. student completed my 2nd yr...i have been
asked to make a project during these summer vacations...and hereby i
would like to invite some ideas bout the design and implementation of
an APPLICATION MONITORING SYSTEMi have to start from scrach so
please tell me how to go bout it rite from the beggining this is the
first time i m making a project of this complexity...
i have to make a system used by the IT department of a company which
contains 31 applications and their details which are being used in a
company ...the details are...
Application sub application catagoryplatform
languageversion IT
owner   functional ownerremarks source code documentation   
last updated
dates
i want to design a system such that it lets the it employee enter the
name of the application and gives him all the details about it...please
suggest an appropriate design and the language which you think would be
best to use...as i have enouf time with me and i can learn a new
language as well...i currently know c and c++...your advise is welcomed
Aditi

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


Re: Want to learn a language - is Python right?

2005-06-22 Thread Aziz McTang
Hi Everyone,
Thanks for all the helpful advice. Downloaded 2.4.1 and already have an
inkling of some of the things it can do. Time to start learning!
ATB
Aziz

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


Re: Loop until condition is true

2005-06-22 Thread Steven D'Aprano
On Wed, 22 Jun 2005 09:54:44 +0200, Fredrik Lundh wrote:

 [CENSORED] I keep for myself how stupid I found your post.
 
 so let's see if everyone who understands how embarrassingly stupid
 your post is will keep that to themselves...

Damn, did I fail some test?

wink



-- 
Steven.

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


Urgent: Embedding Python question please

2005-06-22 Thread adsheehan
Hi,

I am embedding Python into a multi-threaded C++ application runnig on
Solaris and need urgent clarification on the embedding architecture and
its correct usage (as I am experience weird behaviors).

Can anyone clarify:

- if Python correctly supports multiple sub-interpreters
(Py_NewInterpreter) ?

- if Python correctly supports multiple thread states per
sub-interpreter (PyThreadState_New) ?

and the real question:

- what is the rationale for choosing one of:

[a] one sub-interpreter with many thread states
[b] many sub-interpreters with one thread state each
[c] many sub-interpreters with many threas states each

Thanks for helping
Alan

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


Re: Installing MySQL-Python

2005-06-22 Thread kai festersen
Cathy Hui wrote:
 Do u know why do i get the following message
error: command 'gcc' failed with exit status 1

yes:
error: command 'gcc' failed with exit status 1

means: there's no compiler gcc ...

kai

  when trying to build the
 MySql-Python (1.2.0) on my Solaris 8 system?  (with mysql 4.0.21 and
 python 2.4).  thanks!
 
 error mesg:
 ld: fatal: relocations remain against allocatable but non-writable
 sections
 collect2: ld returned 1 exit status
 error: command 'gcc' failed with exit status 1
 
 
 see below for the log
 =
 
 
 # python setup.py build
 
 unknown   0x5c8
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 unknown   0x840
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 unknown   0x84c
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 unknown   0x9b4
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 unknown   0x9bc
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 unknown   0x9f8
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 unknown   0xa04
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 unknown   0xa98
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 unknown   0xaac
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 unknown   0xad0
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 unknown   0xae0
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 unknown   0xb0c
 /usr/local/mysql/lib/mysql/libmysqlclient_r.a(default.o)
 .
 .
 .
 
 ld: fatal: relocations remain against allocatable but non-writable
 sections
 collect2: ld returned 1 exit status
 error: command 'gcc' failed with exit status 1
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: need to strip stuff off email

2005-06-22 Thread Tim Williams
- Original Message - 
From: Tim Williams [EMAIL PROTECTED]
To: python-list@python.org
Sent: Wednesday, June 22, 2005 10:48 AM
Subject: Re: need to strip stuff off email




  nephish [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   hey there,
   i have a script that retrieves my email, but i need it to
   be able to strip all the stuff off except the body (the message
itself)
   so i can later write it to a text file.
  
   anyone know how to accomplish this?
   thanks

 The body is:   The rest of the email after the first blank line after the
 subject header.   In practice it is the first blank line.

 If you get the message into a string it can sometimes be easier to just
 RSPLIT the string at '\r\n\r\n',  if the message is in a list then the
body
 = '\r\n'.join(msg[x:]) where x = that blank line +1  ,  that way if you
 don't need any of the header info,  you don't have to decode the message
and
 rebuild it in a file.

 if you *are* using the email module, eg

 msg = email.message_from_file(a_file)

 then rsplit the msg to get the same result.

 As someone will no doubt point out,   some emails are broken and parts of
 the headers will end up in the body (even when you view the email it in a
 client),  this is very rare though.

Ah,  trying to do anything before my first cup of coffee in the morning is
always a mistake - substitute RSPLIT with LSPLIT  for both occurrences above
!!!  :(

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


importing a package

2005-06-22 Thread flupke
Hi,

I developed a package with a structure like this
src/
tesfile.py
dir1/
__init__.py
file1.py
dir2/
__init__.py
file2.py

The testfile is meant to try the code out that is specified in file1.py 
and file2.py

Now i have another project where i want to use the code from that package.
The structure of that project:

src/
 file3.py
 dir3/
 __init__.py
 file4.py

To use it, i copied the package in the root of the project:
src/
 file3.py
 dir3/
 __init__.py
 file4.py
 package/
__init__.py
dir1/
__init__.py
file1.py
dir2/
__init__.py
file2.py

In my code (file3.py) i then do an import package.dir1.file1 as myobj 
and access a class like this:
myobj.LMyClass()

(where myobj and LMyClass are decent names. Used these as example)

That works but i get an error in the package files.
I then get an error in package/dir1/file1.py on an import statement 
specified in that file1.py that says import dir2.file2

How come this works as standalone project and not when i try to use it 
as in situation 2 it doesn't seem to find module file2.py ?
How can i solve that?

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


Re: suggestions invited

2005-06-22 Thread Konstantin Veretennicov
On 22 Jun 2005 02:47:06 -0700, Aditi [EMAIL PROTECTED] wrote:
 i have to make a system used by the IT department of a company which
 contains 31 applications and their details which are being used in a
 company ...the details are...
 Application sub application catagoryplatform
 languageversion IT
 owner   functional ownerremarks source code documentation 
   last updated
 dates
 i want to design a system such that it lets the it employee enter the
 name of the application and gives him all the details about it...please
 suggest an appropriate design

Ahem...

Create a directory appmon. In this directory create a text file for
each application. Put application details in file and name it after
application name. Users will be able to view details of a particular
application by using cat appname on unix or type appname on
windows, thus it is a portable solution. I believe this design fits
your requirements :)

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


Re: Getting/Saving email attachments w/ poplib and email modules

2005-06-22 Thread Tim Williams

- Original Message - 
From: [EMAIL PROTECTED]
 
 Here's what I'm trying to do:
 
 I need to connect to a pop3 server, download all messages, and copy all
 of the attachments into a specific directory.  The actual email message

##
import email
import poplib

mimes = [image/tif,image/tiff,images/x-tif,image/x-tiff,
   application/tif,application/tiff,application/x-tif,
   application/x-tiff]

def WriteAttachment(msg):
for part in msg.walk():
if part.get_type() in mimes:
name = part.get_filename()
data = part.get_payload(decode=True)
f = file(name,'wb')
f.write(data)
f.close()

ms = poplib.POP3(server)
ms.user(user)
ms.pass_(passw)

msgcount = len(ms.list()[1])
for i in range(msgcount):
response, msg_as_list, size = ms.retr(i+1)
msg = email.message_from_string('\r\n'.join(msg_as_list))
WriteAttachment(msg)

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


Re: Compiling C++ extensions with distutils on Cygwin

2005-06-22 Thread George Sakkis
George Sakkis wrote:

 I'm trying to build a C++ extension on Cygwin, but it fails because
 distutils invokes gcc instead of g++. Looking into distutils internals,
 it turns out that compilation is assumed to be independent of the
 target language, while linking is not (CCompiler.compile() doesn't take
 a target_lang argument but CCompiler.link() does). Is there a good
 reason for this ?

Is this a coincidence or what ? A patch for exactly this issue was
posted just five days ago (http://python.org/sf/1222585), so it should
be fixed in 2.5.

George

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


Re: getting an object name

2005-06-22 Thread TZOTZIOY
On Wed, 22 Jun 2005 09:00:23 +0100, rumours say that Simon Brunning
[EMAIL PROTECTED] might have written:

 Let's say I have a list called, alist. If I pass alist to a function,
 how can I get the name of it?

The effbot put it beautifully:

And IMO it should be in the FAQ:
(http://www.python.org/doc/faq/general.html)

How do I get the name of an object?

The same way as you get the name of that cat you found on your porch:
the cat (object) itself cannot tell you its name, and it doesn't
really care -- so the only way to find out what it's called is to ask
all your neighbours (namespaces) if it's their cat (object) ... and
don't be surprised if you'll find that it's known by many names, or no
name at all!

Whom should we bug to add it?
-- 
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: A World Beyond Capitalism 2005, An Annual International Multiracial Alliance Building Peace Conference Is Accepting Proposals...

2005-06-22 Thread Drazen Gemic
Take your political propaganda somewhere else.

DG

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


Re: python create WMI instances

2005-06-22 Thread future_retro
Create isn't a method of Win32_Printer so I couldn't get that to work.
.Create is a method of Win32_Process which (wait for it..) creates a
new process.  Unfortunatly there is no method to add a printer.  the
method .AddPrinterConnection will allow me to add a connection to an
existing print share but I want to create a printer with the option of
sharing it.

I think I'll have to do this with spawninstance.





Tim Golden wrote:
 [Marc Wyburn]
 |
 | Hi all, I am struggling with a vb - python code conversion.  I'm using
 | WMI to create printers on remote machines using (in VB);
 |
 | set oPrinter = oService.Get(Win32_Printer).SpawnInstance_
 |
 | oPrinter.DriverName = strDriver
 | oPrinter.PortName   = strPort
 | oPrinter.DeviceID   = strPrinter
 | oPrinter.Put_(kFlagCreateOnly)
 |
 | In python I have logged onto the WMI service on the remote machine and
 | I can run things like c.new.AddPrinterConnection so I know that I am
 | connected and working OK.  I don't get any errors when I create a new
 | object with SpawnInstance_ but when I try to set the value of
 | oPrinter.Drivername I get an error saying that the Drivername object
 | doesn't exist.  Does anyone know how to set the values of the object
 | using either the method above or with the WMI module?  I think the WMI
 | module only allows access to modify methods such ADDPrinterConnection
 | or Create (from Win32_Service).

 Not sure if I can help here or not, but just in case...

 As far as I understand you, the fact that you're creating
 on a remote machine is just an incidental, ie you'd have
 the same problem doing this locally.

 Part of the problem is that when VB does something
 like:

 oPrinter.DriverName = strDriver

 what's really happening behind the scenes is something
 like:

 oPrinter.Properties_ (DriverName).Value = strDriver

 Now you can do that in Python. (In fact, that's what
 the wmi module does when it overrides __setattr__, followed
 by a Put_). So if you want to translate code fairly literally,
 then carry on as you were, but substitute the latter code for
 the former.

 Having said that, the wmi module *can* create new instances
 of classes. The problem is that I had/have little knowledge
 of how WMI works in this area, so what I've done may not
 be right. The method you're looking for is .new (aliased
 as .new_instance_of) and if you use help on that method,
 you'll get this:

 new(self, wmi_class) unbound wmi.WMI method
 Create a new whatever, typically something like
 Win32_Process, eg:

 c = wmi.WMI (remote_machine)
 for p in c.Win32_Process (name=notepad.exe): print p
 c.new (Win32_Process).Create (CommandLine=notepad.exe)
 for p in c.Win32_Process (name=notepad.exe): print p
 p.Terminate ()
 for p in c.Win32_Process (name=notepad.exe): print p

 Now this example works, but I notice from the code
 that what I did to make it work was to remove the
 SpawnInstance_ which I had, and replace it by an
 instance retrieval. ie I just do a Get on the class.

 I'll try to find some examples around of what you're
 doing which, up till now, I've not really needed to
 do. Meanwhile, I hope the above info is of some use.

 Feel free to respond with questions or comments. This
 can only get clearer!

 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: Getting/Saving email attachments w/ poplib and email modules

2005-06-22 Thread Mike Meyer
[EMAIL PROTECTED] writes:

 Hello All,
 
 Here's what I'm trying to do:
 
 I need to connect to a pop3 server, download all messages, and copy all
 of the attachments into a specific directory.  The actual email message
 is unimportant.  Now, I've found plenty of examples that strip the
 attachments from an email message, but most (if not all) of them take a
 file parameter.  My question is this:
 
 How can i retrieve an email message via poplib and pass it to
 email.message_from_string()?

A quick look at the poplib documentation shows the retr method, which gets
a message by number, and returns a list: ['response', ['line', ...], octets].

So to get a string, you'd do:

from poplib import POP3
from sys import exit

p = POP3('example.com')
# authentication, etc.
msg_list = p.list()
if not msg_list.startswith('+OK'):
# Handle error in listings
exit(1)

for msg in msg_list[1]:
msg_num, _ = msg.split()
resp = p.retr(msg_num)
if resp.startswith('+OK'):
email.message_from_string('\n'.join(resp[1]))
else:
# Deal with error retrieving message.

This is untested code, but the details of dealing with poplib should
be right.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: python-ldap-2.0.8

2005-06-22 Thread Michael Ströder
Find a new release of python-ldap:

  http://python-ldap.sourceforge.net/

python-ldap provides an object-oriented API to access LDAP directory
servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for
that purpose. Additionally it contains modules for other LDAP-related
stuff (e.g. processing LDIF, LDAPURLs and LDAPv3 schema).


Released 2.0.8 2005-06-22 at Linuxtag 2005, Karlsruhe, Germany

Changes since 2.0.7:

* Preliminary support for receiving LDAP controls added.
  Contributor:
  - Andreas Ames

Lib:/
- Added classes in module ldif to ldif.__all__ to fix
  from ldif import *
- Removed BitString syntax from
  ldap.schema.models.NOT_HUMAN_READABLE_LDAP_SYNTAXES
  since the LDAP encoding is in fact human-readable
- ldapurl.LDAPUrlExtension.unparse() outputs empty string
  if LDAPUrlExtension.exvalue is None
- Added ldap.controls.SimplePagedResultsControl


Released 2.0.7 2005-04-29

Changes since 2.0.6:

* Added preliminary support for sending LDAP controls
  with a request.
  Contributors:
  - Deepak Giridharagopal
  - Ingo Steuwer
  (Receiving controls in LDAP results still not supported.)

Modules:
* LDAPObject.c: removed l_ldap_manage_dsa_it()
* LDAPObject.c: Added missing #ifdef around l_ldap_passwd()
  for compability with older OpenLDAP libs.

Lib:/
* New algorithm in ldap.schema.tokenizer.split_tokens()
  contributed by Wido Depping which is more robust
  when parsing very broken schema elements
  (e.g. Oracle's OID).
* Fixed argument list (position of timeout) when calling
  LDAPObject.search_ext_s() from search_st() and search_s().
* LDAPObject.search_ext_s() correctly calls search_ext_s() now.
* Re-implemented LDAPObject.manage_dsa_it() without calling _ldap.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loop until condition is true

2005-06-22 Thread Greg Lindstrom
A bit off topic, but what does the expression Don't try to teach your
grandfather how to suck eggs. mean?  I've never heard it before and am
curious to the story behind it.

Thanks,
--greg

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


Re: Reading registry export files

2005-06-22 Thread [EMAIL PROTECTED]
It works fine for me on NT. I think it has nothing to do with Python
but with the way the file is created - what windows version are you on?
Also note the possibility the '/' - I prefer a noatation like below to
avoid ambiguity.

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]
on win32
Type help, copyright, credits or license for more information.
py f = open(rd:\test.reg)
py r = f.read()
py print r
REGEDIT4

I would do it like this however, then join all lists from various .reg
files:
py f = open(r'd:\test.reg')
py r = f.readlines()
py print r
['REGEDIT4\n', '\n',
'[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Ole]\n', 'Enabl
eDCOM=Y\n',
'DefaultLaunchPermission=hex:01,00,04,80,64,00,00,00,80,00,00,0
0,00,00,00,00,\\\n', '
14,00,00,00,02,00,50,00,03,00,00,00,00,00,18,00,01,00,00
,00,01,01,00,00,00,\\\n', '
00,00,05,12,00,00,00,00,00,00,00,00,00,18,00,01,00,
00,00,01,01,00,00,00,00,\\\n', '
00,05,04,00,00,00,00,00,00,00,00,00,18,00,01,0
0,00,00,01,02,00,00,00,00,00,\\\n', '
05,20,00,00,00,20,02,00,00,01,05,00,00,00
,00,00,05,15,00,00,00,a0,5f,84,1f,\\\n', '
5e,2e,6b,49,ce,12,03,03,f4,01,00,00,
01,05,00,00,00,00,00,05,15,00,00,00,a0,\\\n', '
5f,84,1f,5e,2e,6b,49,ce,12,03,0
3,f4,01,00,00\n', '\n']


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Ole]
EnableDCOM=Y
DefaultLaunchPermission=hex:01,00,04,80,64,00,00,00,80,00,00,00,00,00,00,00,

14,00,00,00,02,00,50,00,03,00,00,00,00,00,18,00,01,00,00,00,01,01,00,00,00,\

00,00,05,12,00,00,00,00,00,00,00,00,00,18,00,01,00,00,00,01,01,00,00,00,00,\

00,05,04,00,00,00,00,00,00,00,00,00,18,00,01,00,00,00,01,02,00,00,00,00,00,\

05,20,00,00,00,20,02,00,00,01,05,00,00,00,00,00,05,15,00,00,00,a0,5f,84,1f,\

5e,2e,6b,49,ce,12,03,03,f4,01,00,00,01,05,00,00,00,00,00,05,15,00,00,00,a0,\
  5f,84,1f,5e,2e,6b,49,ce,12,03,03,f4,01,00,00

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


Re: Loop until condition is true

2005-06-22 Thread Tim Williams
- Original Message - 
From: Greg Lindstrom [EMAIL PROTECTED]


 A bit off topic, but what does the expression Don't try to teach your
 grandfather how to suck eggs. mean?  I've never heard it before and am
 curious to the story behind it.

A relatively well know phrase, however  as quoted it is incorrect,  it
should have referred to grandmother

http://www.phrases.org.uk/bulletin_board/18/messages/50.html
http://www.worldwidewords.org/qa/qa-tea1.htm

:)

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


Re: A World Beyond Capitalism 2005, An Annual International Multiracial Alliance Building Peace Conference Is Accepting Proposals...

2005-06-22 Thread Peter Hansen
Jack Diederich wrote:
 The '.info' domain also defeats
 the linux 'whois' command to dig for registrar info.

Maybe so, but it's always pretty easy to Google for whois plus the 
domain to find a way of doing it via the web, in this case with 
http://www.afilias.info/cgi-bin/whois.cgi .

(It's registered to something called the Institute of Pamela, which 
seems to stand for Peaceful Alliances facilitated by Multilingual, 
multiracial Education, handicapable outreach and native Language 
Accessibility.  I think this thing really exists, making this spam and 
not just a farce.)

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


Python API to manipulate CAB files.

2005-06-22 Thread Isaac Rodriguez
Does anyone know of a Python API to manipulate CAB files?

Thanks,

-- 
Isaac Rodriguez
SWE Autodesk.

There are 10 types of people.
Those who undertand binary, and those who don't 


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


Re: Reading registry export files

2005-06-22 Thread Thorsten Kampe
* [EMAIL PROTECTED] (2005-06-22 13:59 +0100)
 It works fine for me on NT. I think it has nothing to do with Python
 but with the way the file is created - what windows version are you on?

Windows uses UTF-16 since Windows 2000. Regedit offers the possibility
to export in the old Win9x/NT4 format.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C++ ActiveX python javascript communication trouble.

2005-06-22 Thread BigBrian
 I'm investingating a c++ api, Panda3d.com, that has a python binding.
 I want to convert this api into an ACtiveX control so it will run on
 the web.  When I do so I want to use Microsoft Script Control to call
 api routines from Javascript in the browser.


 Let's say I write up a game in python with my own functions. Then I
 embed it in a web page and I want to call my functions from javascript?
 How can I do it. Script control allows you to bind api functions to
 javascript, but not the functions in my python file.

 Adobe Atmoshere a 3D application that ran in a web page, had a
 javascript binding. You could write code in a javascript file, and it
 would be interpreted during start-up. After that, I could send function
 calls in the form of a string from the browser to atmosphere. How did
 this work?  Is the api aware of the python functions and variables
 after it is loaded up?

 Confused,
 Dan

So what's your question about the C++ language.  ActiveX, Javascript,
phython, web stuff are off topic.

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


Re: sudoku dictionary attack

2005-06-22 Thread Nigel Greenwood


Nick Atty wrote:

 On-line canal route planner: http://www.canalplan.org.uk

So the Travelling Salesman goes by narrow boat these days, does he?

Nigel

--
ScriptMaster language resources (Chinese/Modern  Classical
Greek/IPA/Persian/Russian/Turkish):
http://www.elgin.free-online.co.uk

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


Database recommendations for Windows app

2005-06-22 Thread Will McGugan
Hi,

I'd like to write a windows app that accesses a locally stored database. 
There are a number of tables, the largest of which has 455,905 records.

Can anyone recommend a database that runs on Windows, is fast / 
efficient and can be shipped without restrictions or extra downloads?

I have googled and found plenty of information on databases, its just 
that I dont have enough experience with databases to know which one is 
best for my task!


Thanks in advance,

Will McGugan
-- 
http://www.willmcgugan.com
.join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in 
jvyy*jvyyzpthtna^pbz)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: getting an object name

2005-06-22 Thread Ron Adam
David Bear wrote:
 Let's say I have a list called, alist. If I pass alist to a function,
 how can I get the name of it?
 
 alist = range(10)
 
 def afunction(list):
 listName = list.__name__ (fails for a list object)
 

Using an object's name as data isn't a good idea because it will 
generally cause more problems than it solves.


If you have several different types of lists and need to handle them 
differently, then you might consider using class's that knows how to 
handle each type of list.

Also, if the name is really part of the data, then you should store the 
name as a string with the list.


class data1(object):
 def __init__(self, alist, name):
 self.list = alist
 self.name = name
 def data_type(self):
 print This is a data1 object

class data2(object):
 def __init__(self, alist, name):
 self.list = alist
 self.name = name
 def data_type(self):
 print This is a data2 object

list_a = data1( range(10), small list)
print list_a.list
print list_a.name

list_b = data2( range(100), large list)

def data_type(data):
 data.data_type()  # don't need the name here

data_type(list_a) # prints 'This is a data1 object'
data_type(list_b) # prints 'This is a data2 object'



You can also store a name with the list in a list if you don't want to 
use class's.

alist = ['mylist',range[10]]
print alist[0] # name
print alist[1] # list


Regards,
Ron

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


[no subject]

2005-06-22 Thread Doug Ly








Is there a good IDE for Python? I have heard that Eclipse
has a plugin for Jython only.

Thanks



--Doug








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

Re: Loop until condition is true

2005-06-22 Thread Magnus Lycka
Remi Villatel wrote:
 Erm... You totally missed the point. I wrote it this way because, first, 
 it's perfectly valid Python code and, second and most important, it's 
 also a valid english sentence.

Remi, I think you have failed to understand what Fredrik was
telling you. I can understand that, because he didn't actually
explain the problem. He probably thought it was obvious, but
it seems it wasn't.

if a is b: is equivalent to if id(a) == id(b). It doesn't
test whether two values are the equal, it tests whether a and b
are the same object. None is a singleton object in Python, but
True is not. (At least not in the Python versions I use.)

That means that you are relying on Python to use a performance
optimization (interning of some common values, in this case
the integer 1, which is what True is in practice).

In some cases, == and is happens to give the same result.
  a = 1
  b = 1
  a == b
1
  a is b
1

But often not.

  c = 123456789
  d = 123456789
  c == d
1
  c is d
0

Or, for an example of the opposite:

  class Smaller:
... def __cmp__(self, other):
... return -1
...
  s = Smaller()
  b = a
  a  b
1
  b  a
1
  a == b
0
  a is b
1

In other words, a test like if x is None: makes sense,
since None is a singleton, but if x is True: certainly
seems like buggy code that just happens to work. You could
write if x == True: without risking a failure in some
Python implementation that doesn't intern True (i.e. 1)
if you are certain that x is 0 or 1, but it's completely
redundant. Why stop there? Why not write
if x == True == True: or if x == True == True == True:?
These are all logically equivalent. You could also write
if x and True:, or if x or not True :)

I understand what your intentions are: You feel that your
code is easier to understand written the way you did it, but
it stops feeling like that once you have gotten fully into
your head that the expressions (a) and (a == True) are
logically equivalent if a is either True or False.

If you manage to get away from this x == True mind-set
you are likely to write better Python code.

First of all, a lot of Python values except 1 (a.k.a. True)
are logically true in a Python expression. It's considered
good form to exploit that. E.g.

if y: z = x / y
if text: print text
if l: cols = len(l[0])

In these cases, adding a ==True, would break the code, and
adding more correct comparisions would just clutter the code,
which hides the intent and raises the risk for bugs, and make
it more difficult to keep the code as flexible as Python code
can be. E.g. if you change the last statement to
if l != []: cols = len(l[0]), you'll get in trouble if it
turns out that l = (). The uncluttered code will still work.

Secondly, if you ever write logical expressions that are more
complex, you will make them much more difficult to read unless
you drop that == True baggage.

I'm convinced that it's easier to understand

if past_six or past_three and saturday or sunday:

than to understand

if (past_six==True or
past_three==True and saturday==True or
sunday==True):

I'm also pretty sure it's easier to write the first without
making any mistake.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: asynchronous comunication, wxPython and threads.

2005-06-22 Thread Zunbeltz Izaola
On Wed, 22 Jun 2005 09:28:31 -0400, Peter Hansen wrote:


 Almost certainly it is.  It would be simplest to set up a worker thread 
 once, when the GUI thread begins, and simply send requests to it via a 
 Queue.  It can create the socket, connect to the server, communicate, 
 close it down, and go back to waiting all in one place (so to speak... 
 of course this would be several methods all called from a top-level loop 
 in that thread).  No chance of mis-steps.

I corrected the problem. A bit of the comunication was done in the
GUI thread. 

Thanks again for your help.

Zunbeltz


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


Re: Database recommendations for Windows app

2005-06-22 Thread Thomas Bartkus
Will McGugan [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 I'd like to write a windows app that accesses a locally stored database.
 There are a number of tables, the largest of which has 455,905 records.

 Can anyone recommend a database that runs on Windows, is fast /
 efficient and can be shipped without restrictions or extra downloads?

 I have googled and found plenty of information on databases, its just
 that I dont have enough experience with databases to know which one is
 best for my task!

If you are writing strictly for the MS Windows platform
   And
If the database is running single user with a locally stored database on a
Windows workstation.
   Then
The MS Access file based (.mdb) system is hard to argue with.
You wouldn't have to distribute the (rather expensive) Access application
since this is little more than a front for the underlying DAO/ADO database
libraries that are built into the warp and woof of MS Windows.  Your Python
application can address the DAO or ADO directly as these will libraries will
be pre-installed and/or freely available for MS Windows.  Fast, freely
available, no license restrictions, and no need for extra downloads for a
reasonably recent (Win2000, XP) operating system.

On the other hand, if operating system portability were a concern (as it
should be!), I might suggest MySQL.
A Python/MySQL application can jump between Windows to Linux (all flavors!)
to Unix to BSD without need to alter a single line of code.

You were writing a Python app, weren't you :-)
Thomas Bartkus


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


Re: importing a package

2005-06-22 Thread flupke
Damjan wrote:
I developed a package with a structure like this
src/
tesfile.py
dir1/
__init__.py
file1.py
dir2/
__init__.py
file2.py
 
 
 Importing dir2/file2 from dir1/file1.py works here, because when yuo started
 the testfile script the src/ directory was added to the sys.path list.
 
 If you relocate dir1/ and dir2/ in a package directory here it will not
 work.
 
 

Indeed, when i do this, then it works
import sys
sys.path.append('package')

However, why is it that package isn't added automatically to the pad?

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


Re: Database recommendations for Windows app

2005-06-22 Thread Gregory Piñero
I always figured a problem with using MySQL was distribution.  Would
you have to tell your users to install MySQL and then to leave the
service running?  I've never found an easy way to embed MySQL into a
python app, and even if you could, would you then have to pay for it?

-Greg


On 6/22/05, Thomas Bartkus [EMAIL PROTECTED] wrote:
 Will McGugan [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Hi,
 
  I'd like to write a windows app that accesses a locally stored database.
  There are a number of tables, the largest of which has 455,905 records.
 
  Can anyone recommend a database that runs on Windows, is fast /
  efficient and can be shipped without restrictions or extra downloads?
 
  I have googled and found plenty of information on databases, its just
  that I dont have enough experience with databases to know which one is
  best for my task!
 
 If you are writing strictly for the MS Windows platform
   And
 If the database is running single user with a locally stored database on a
 Windows workstation.
   Then
 The MS Access file based (.mdb) system is hard to argue with.
 You wouldn't have to distribute the (rather expensive) Access application
 since this is little more than a front for the underlying DAO/ADO database
 libraries that are built into the warp and woof of MS Windows.  Your Python
 application can address the DAO or ADO directly as these will libraries will
 be pre-installed and/or freely available for MS Windows.  Fast, freely
 available, no license restrictions, and no need for extra downloads for a
 reasonably recent (Win2000, XP) operating system.
 
 On the other hand, if operating system portability were a concern (as it
 should be!), I might suggest MySQL.
 A Python/MySQL application can jump between Windows to Linux (all flavors!)
 to Unix to BSD without need to alter a single line of code.
 
 You were writing a Python app, weren't you :-)
 Thomas Bartkus
 
 
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: python create WMI instances

2005-06-22 Thread future_retro
Win32_Printer doesn't work with the Create method and
AddPrinterConnection only lets me add a connection to a share.  I'll
try and work out how to set the printer object properties in the format
suggested;

oPrinter.Properties_ (DriverName).Value = strDriver 

Cheers, MW.

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


RE: python create WMI instances

2005-06-22 Thread Tim Golden
[EMAIL PROTECTED]
| Win32_Printer doesn't work with the Create method and
| AddPrinterConnection only lets me add a connection to a share.  I'll
| try and work out how to set the printer object properties in 
| the format
| suggested;
| 
| oPrinter.Properties_ (DriverName).Value = strDriver 
| 
| Cheers, MW.

I'm sorry my module won't have been much use to you
in this, but it would be *really* helpful if you
could post [a fragment of] the code you come up with
so I can see what changes I need to make to help our
future instance-spawners. It's just that I've never
had the need to do this, and don't have any time to
experiment at present.

Thanks
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: Database recommendations for Windows app

2005-06-22 Thread Dan
Take a look at Firebird.  It can be run in embedded mode.  It might be 
overkill for your needs though...

On 6/22/2005 10:37 AM, Gregory Piñero wrote:
 I always figured a problem with using MySQL was distribution.  Would
 you have to tell your users to install MySQL and then to leave the
 service running?  I've never found an easy way to embed MySQL into a
 python app, and even if you could, would you then have to pay for it?
 
 -Greg
 
 
 On 6/22/05, Thomas Bartkus [EMAIL PROTECTED] wrote:
 
Will McGugan [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

Hi,

I'd like to write a windows app that accesses a locally stored database.
There are a number of tables, the largest of which has 455,905 records.

Can anyone recommend a database that runs on Windows, is fast /
efficient and can be shipped without restrictions or extra downloads?

I have googled and found plenty of information on databases, its just
that I dont have enough experience with databases to know which one is
best for my task!

If you are writing strictly for the MS Windows platform
  And
If the database is running single user with a locally stored database on a
Windows workstation.
  Then
The MS Access file based (.mdb) system is hard to argue with.
You wouldn't have to distribute the (rather expensive) Access application
since this is little more than a front for the underlying DAO/ADO database
libraries that are built into the warp and woof of MS Windows.  Your Python
application can address the DAO or ADO directly as these will libraries will
be pre-installed and/or freely available for MS Windows.  Fast, freely
available, no license restrictions, and no need for extra downloads for a
reasonably recent (Win2000, XP) operating system.

On the other hand, if operating system portability were a concern (as it
should be!), I might suggest MySQL.
A Python/MySQL application can jump between Windows to Linux (all flavors!)
to Unix to BSD without need to alter a single line of code.

You were writing a Python app, weren't you :-)
Thomas Bartkus


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

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


Re: Database recommendations for Windows app

2005-06-22 Thread Dave Cook
On 2005-06-22, Will McGugan [EMAIL PROTECTED] wrote:

 I'd like to write a windows app that accesses a locally stored database. 
 There are a number of tables, the largest of which has 455,905 records.

 Can anyone recommend a database that runs on Windows, is fast / 
 efficient and can be shipped without restrictions or extra downloads?

http://pysqlite.org

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


PEP ? os.listdir enhancement

2005-06-22 Thread Riccardo Galli
Hi,
I noticed that when I use os.listdir I need to work with absolute paths
90% of times.
While I can use a for cycle, I'd prefere to use a list comprehension,
 but it becomes too long.

I propose to add an 'abs' keyword which would make os.listdir return the
absolute path of files instead of a relative path.
This would bring only advantages, I think.

I show two examples

from os import listdir
from os.path import isdir,join,getsize,isfile

### e.g. 1 part 1 - getting a list of directories ### 
dirs=[]
for i in os.listdir(path):
tmp_path=os.path.join(path,i)
if os.path.isdir(tmp_path):
dirs.append(tmp_path)

### e.g. 1 part 2 ###
dirs=[join(path,x) for x in listdir(path) if isdir(join(path,x))]

here the list comprehension is still clear, but only because we have
direct references to join and friends. moreover whe need to use join twice
for each directory.

### e.g. 2 part 1 - getting a list of (file,size) tuples ### 
path_size=[]
for i in os.listdir(path):
tmp_path=os.path.join(path,i)
if os.path.isfile(tmp_path):
path_size.append((tmp_path,getsize(tmp_path))

### e.g. 2 part 2 ###
dirs=[(join(path,x),getsize(join(path,x)) for x in listdir(path) if
isfile(join(path,x))]


now list comprehension is way too long, and in the worst case we must use
join 3 times for each iteration.

adding an 'abs' keyword to os.listdir would give benefits both to for
cycle and list comprehensions.
for cycle would lose the tmp_path assignment and list comprehensions ...


### e.g. 1 part 2 bis ###
dirs=[x for x in listdir(path,abs=True) if isdir(x)]

here we gain clearness and speed.

### e.g. 2 part 2 bis ### 
dirs=[(x,getsize(x)) for x in listdir(path,abs=True) if isfile(x)]

and here we gain clearness, speed and a truely _usable_ list comprehension

What do you think about this ?

Thanks for reading,
Riccardo

-- 
Riccardo Galli
Sideralis Programs
http://www.sideralis.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loop until condition is true

2005-06-22 Thread Michael Hoffman
Remi Villatel wrote:
 Fredrik Lundh wrote:
 checking if a logical expression is true by comparing it to True is bad
 style, and comparing values using is is also bad style.
 
 I wrote it this way because, first, it's perfectly valid Python code and,
  second and most important, it's also a valid english sentence.

As others have pointed out, it's not perfectly valid code. In fact it is 
frequently incorrect.

 [CENSORED] I keep for myself how stupid I found your post...
 Don't try to teach your grandfather how to suck eggs.

You apparently don't know how to do it without getting egg on your face.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Looking for a web-based messaging system

2005-06-22 Thread Mike Meyer
One of my clients has a need for a web-based messaging
system. Something python-based is preferred, as that's where our
expertise is, but web frameworks built in Python are perfectly
acceptable. If you know of something really good that isn't in Python,
I wouldn't mind hearing about it - but I do have a long list of
non-python solutions.

I've got a pretty full set of requirements. Basically, the user should
log in to the web site and get a list of outstanding messages.  It
*has* to support multiple browser windows with different views of the
list.

Capabilities wanted include sorting in both directions and on multiple
fields. Filtering based on arbitrary fields - including both ANDing
and ORing together filtering criteria. It should be possible to group
related messages together, with a single line display summarizing the
group. Likewise, it should be possible to fold related messages into
a single line, and unfold specific instances.

We'd like the messages to be stored in an SQL database - we're using 
postgres - so we can use our existing report generation tools.

The only licensing requirement is that we get source so we can tailor
the product to our needs. Commercial is perfectly fine. GPL is
acceptable, but not preferred.

So far, the only thing I've found that comes remotely close to this is
BoBoMail.

Thanks,
mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Database recommendations for Windows app

2005-06-22 Thread Magnus Lycka
Will McGugan wrote:
 Hi,
 
 I'd like to write a windows app that accesses a locally stored database. 
 There are a number of tables, the largest of which has 455,905 records.
 
 Can anyone recommend a database that runs on Windows, is fast / 
 efficient and can be shipped without restrictions or extra downloads?
 
 I have googled and found plenty of information on databases, its just 
 that I dont have enough experience with databases to know which one is 
 best for my task!

Neither do we, considering that brief description.

Will there be multiple simultaneous users?
Multiple simultaneous writers?
Do you require proper transaction management?
   (Or is it a pure read-only database, since you know
exactly how many records the largest table has?)
Do you need to make ad-hoc queries?
What will your code look like?
* Is it object-oriented?
* Are there a lot of fixed relations between objects?
Are there other requirements such as need for undo or
   change history management?
Does the application work with small chunks of data at a time
   (such as in a ticket ordering system) or with larger chunks
   (such as in a web site CMS)?
What size is it? It's a big difference between 455,905 integers
   and 455,905 mp3 files for instance...
A number of tables tells us very little, more than suggesting
   that it's more than one... Ten and 200 makes a big difference.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Database recommendations for Windows app

2005-06-22 Thread Magnus Lycka
Thomas Bartkus wrote:
 If you are writing strictly for the MS Windows platform
And
 If the database is running single user with a locally stored database on a
 Windows workstation.
Then
 The MS Access file based (.mdb) system is hard to argue with.

I disagree. What does .mdb/jet without Access offer you that you
don't get from e.g. SQLite except vendor lock-in and horrible
deviations from the SQL standard? Ok, it does give you somewhat
stronger typing, which you might possibly want, but if that's
an issue, I'd suggest embedded firebird (if we want serverless).

I'm not entirely sure something SQLish is the way to go though.

Also, the best ODBC adaper for Python, mxODBC, isn't free. Last
time I used adodbapi, it was a bit buggy, and pure ADO or DAO
solutions don't follow the Python standard DB-API 2.
-- 
http://mail.python.org/mailman/listinfo/python-list


Dr. Dobb's Python-URL! - weekly Python news and links (Jun 22)

2005-06-22 Thread Simon Brunning
QOTW: Python is more concerned with making it easy to write good programs
than difficult to write bad ones. - Steve Holden

Scientists build so that they can learn. Programmers and engineers learn
so that they can build. - Magnus Lycka

It happens that old Java programmers make one module per class when they
start using Python. That's more or less equivalent of never using more
than 8.3 characters in filenames in modern operating systems, or to make
a detour on your way to work because there used to be a fence blocking the
shortest way a long time ago. - Magnus Lycka


Python doesn't currently have a case or switch statement. Case blocks
are easily simulated with if, elif, and else, but would Python's
readability benefit from having it built in?:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/29e45afc78adcd15

A Podcast worth listening to at last. Guido speaks on Python's history
and community:
http://www.itconversations.com/shows/detail545.html
http://www.itconversations.com/shows/detail559.html

If your class implements __eq__ but not __ne__, (a = b) does not imply
!(a != b). If this something that should be fixed, or just a gotcha?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/f6e0986b2c0f01c0

John Machin instructively analyzes several of Excel's defects as a
data-management vehicle, obliquely highlighting Python's Zen.  Tim
Roberts follows up with a small but potentially crucial addendum
pertinent, among others, to those who deal with USA zip codes:

http://groups-beta.google.com/group/comp.lang.python/index/browse_frm/thread/d14b13c8bc6e8515/

Recent (unreleased) work on distutils allows you to automatically
upload packages to PyPI:
http://www.amk.ca/diary/archives/003937.html

Text files and line endings; Python helps you out on Windows, which can
be a little confusing:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/2d3f61b949bca0e9

Kalle wants to protect his instance attributes. He's warned off the
idea, but at the same time, alex23 demonstrates an interesting way of
doing it using properties():

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/9f7c29fed95d7586

Creating a Python iterator by wrapping any callable:

http://bob.pythonmac.org/archives/2005/06/14/python-iterators-and-sentinel-values/

Richard Lewis wants resumable exceptions. Python doesn't have them,
but Peter Hansen shows him how to achieve what he wants, and Willem
shows us how resumable exceptions work in Lisp:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/e3dafce228dd4258

Jan Danielsson is confused about the difference between __str__ and
__repr__, and what they are both for:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b37f1e3fae1154d6

The Kamaelia Framework; communicating with and linking Python generators:
http://www.bbc.co.uk/rd/pubs/whp/whp113.shtml

Ron Adams proposes an also block to be executed if a for loop's
else block isn't, and more controversially, that the else block's
meaning be switched:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b15de260c5ca02e0

How you convince your marketing drones that switching from Python to
Java would be A Bad Thing?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/5b6d1ff54640e9b1

Why should an ambitious 14-year-old look at Python? (And why source-code
hiding is a waste of time.)

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/107a4da1dd45b915



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

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

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

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/

Dr. Dobb's Python-URL! - weekly Python news and links (Jun 22)

2005-06-22 Thread Simon Brunning
QOTW: Python is more concerned with making it easy to write good programs
than difficult to write bad ones. - Steve Holden

Scientists build so that they can learn. Programmers and engineers learn
so that they can build. - Magnus Lycka

It happens that old Java programmers make one module per class when they
start using Python. That's more or less equivalent of never using more
than 8.3 characters in filenames in modern operating systems, or to make
a detour on your way to work because there used to be a fence blocking the
shortest way a long time ago. - Magnus Lycka


Python doesn't currently have a case or switch statement. Case blocks
are easily simulated with if, elif, and else, but would Python's
readability benefit from having it built in?:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/29e45afc78adcd15

A Podcast worth listening to at last. Guido speaks on Python's history
and community:
http://www.itconversations.com/shows/detail545.html
http://www.itconversations.com/shows/detail559.html

If your class implements __eq__ but not __ne__, (a = b) does not imply
!(a != b). If this something that should be fixed, or just a gotcha?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/f6e0986b2c0f01c0

John Machin instructively analyzes several of Excel's defects as a
data-management vehicle, obliquely highlighting Python's Zen.  Tim
Roberts follows up with a small but potentially crucial addendum
pertinent, among others, to those who deal with USA zip codes:

http://groups-beta.google.com/group/comp.lang.python/index/browse_frm/thread/d14b13c8bc6e8515/

Recent (unreleased) work on distutils allows you to automatically
upload packages to PyPI:
http://www.amk.ca/diary/archives/003937.html

Text files and line endings; Python helps you out on Windows, which can
be a little confusing:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/2d3f61b949bca0e9

Kalle wants to protect his instance attributes. He's warned off the
idea, but at the same time, alex23 demonstrates an interesting way of
doing it using properties():

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/9f7c29fed95d7586

Creating a Python iterator by wrapping any callable:

http://bob.pythonmac.org/archives/2005/06/14/python-iterators-and-sentinel-values/

Richard Lewis wants resumable exceptions. Python doesn't have them,
but Peter Hansen shows him how to achieve what he wants, and Willem
shows us how resumable exceptions work in Lisp:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/e3dafce228dd4258

Jan Danielsson is confused about the difference between __str__ and
__repr__, and what they are both for:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b37f1e3fae1154d6

The Kamaelia Framework; communicating with and linking Python generators:
http://www.bbc.co.uk/rd/pubs/whp/whp113.shtml

Ron Adams proposes an also block to be executed if a for loop's
else block isn't, and more controversially, that the else block's
meaning be switched:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/b15de260c5ca02e0

How you convince your marketing drones that switching from Python to
Java would be A Bad Thing?

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/5b6d1ff54640e9b1

Why should an ambitious 14-year-old look at Python? (And why source-code
hiding is a waste of time.)

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/107a4da1dd45b915



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

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

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

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/

Re: Python API to manipulate CAB files.

2005-06-22 Thread Peter Maas
Isaac Rodriguez schrieb:
 Does anyone know of a Python API to manipulate CAB files?

If there is a Windows API you can probybly call it from Python
using Mark Hammond's Win32 extensions.

-- 
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP ? os.listdir enhancement

2005-06-22 Thread Jeff Epler
Why not just define the function yourself?  Not every 3-line function
needs to be built in.

def listdir_joined(path):
return [os.path.join(path, entry) for entry in os.listdir(path)]

dirs = [x for x in listdir_joined(path) if os.path.isdir(x)]

path_size = [(x, getsize(x)) for x in listdir_joined(path) if os.path.isfile(x)]


Jeff


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

Re: a comprehensive Tkinter document?

2005-06-22 Thread William Gill
Kent Johnson wrote:
 William Gill wrote:
 
 I know a major problem I am having is that I am finding lots of 
 Tkinter information in 'fragments' of various , sometimes conflicting 
 vintages.  For example the python reference I was using didn't show 
 the '%%' as an escape sequence, I posted asking how to escape the '%' 
 and after several helpful responses voila I found a more complete 
 table of escape sequences.  Is there a comprehensive document or book 
 that I can get that is relatively current?  
 
 
 Maybe not comprehensive but I think reasonably current:
 http://www.pythonware.com/library/tkinter/introduction/index.htm
 http://infohost.nmt.edu/tcc/help/pubs/tkinter/
 
 Kent

Yes, these are two of my staples, though I have occasionally slipped 
into 'copies' elsewhere that aren't kept up.

Thanks,

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


Re: Database recommendations for Windows app

2005-06-22 Thread Thomas Bartkus
Will McGugan [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 I'd like to write a windows app that accesses a locally stored database.
 There are a number of tables, the largest of which has 455,905 records.

 Can anyone recommend a database that runs on Windows, is fast /
 efficient and can be shipped without restrictions or extra downloads?

 I have googled and found plenty of information on databases, its just
 that I dont have enough experience with databases to know which one is
 best for my task!

If you are writing strictly for the MS Windows platform
   And
If the database is running single user with a locally stored database on a
Windows workstation.
   Then
The MS Access file based (.mdb) system is hard to argue with.
You wouldn't have to distribute the (rather expensive) Access application
since this is little more than a front for the underlying DAO/ADO database
libraries that are built into the warp and woof of MS Windows.  Your Python
application can address the DAO or ADO directly as these will libraries will
be pre-installed and/or freely available for MS Windows.  Fast, freely
available, no license restrictions, and no need for extra downloads for a
reasonably recent (Win2000, XP) operating system.

On the other hand, if operating system portability were a concern (as it
should be!), I might suggest MySQL.
A Python/MySQL application can jump between Windows to Linux (all flavors!)
to Unix to BSD without need to alter a single line of code.

You were writing a Python app, weren't you :-)
Thomas Bartkus



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


Re: Loop until condition is true

2005-06-22 Thread Jeff Epler
def until(pred):
yield None
while True:
if pred(): break
yield None

def example():
i = 0
for _ in until(lambda: x==0):
x = 10 - i
i += 1
print x, i

example()


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

Re: Database recommendations for Windows app

2005-06-22 Thread Dan
On 6/22/2005 11:38 AM, Thomas Bartkus wrote:
 Will McGugan [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
Hi,

I'd like to write a windows app that accesses a locally stored database.
There are a number of tables, the largest of which has 455,905 records.

Can anyone recommend a database that runs on Windows, is fast /
efficient and can be shipped without restrictions or extra downloads?

I have googled and found plenty of information on databases, its just
that I dont have enough experience with databases to know which one is
best for my task!
 
 
 If you are writing strictly for the MS Windows platform
And
 If the database is running single user with a locally stored database on a
 Windows workstation.
Then
 The MS Access file based (.mdb) system is hard to argue with.
 You wouldn't have to distribute the (rather expensive) Access application
 since this is little more than a front for the underlying DAO/ADO database
 libraries that are built into the warp and woof of MS Windows.  Your Python
 application can address the DAO or ADO directly as these will libraries will
 be pre-installed and/or freely available for MS Windows.  Fast, freely
 available, no license restrictions, and no need for extra downloads for a
 reasonably recent (Win2000, XP) operating system.
 

And then XP Autoupdate executes, some of those Access/MSDE libraries are 
updated, and you app is broken.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP ? os.listdir enhancement

2005-06-22 Thread Peter Hansen
Riccardo Galli wrote:
 I noticed that when I use os.listdir I need to work with absolute paths
 90% of times.
 While I can use a for cycle, I'd prefere to use a list comprehension,
  but it becomes too long.
 
 ### e.g. 1 part 1 - getting a list of directories ### 
 dirs=[]
 for i in os.listdir(path):
 tmp_path=os.path.join(path,i)
 if os.path.isdir(tmp_path):
 dirs.append(tmp_path)
 
 ### e.g. 1 part 2 ###
 dirs=[join(path,x) for x in listdir(path) if isdir(join(path,x))]

Using Jason Orendorff's path module, all this code basically collapses 
down to this beauty (with your variable path renamed to myPath to 
avoid a name collision):

from path import path
dirs = path(myPath).abspath().dirs()

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


Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Grant Edwards
On 2005-06-22, Scott David Daniels [EMAIL PROTECTED] wrote:

 I finally figured out why one of my apps sometimes fails under
 Win32 when it always works fine under Linux: Under Win32, the
 pickle module only works with a subset of floating point
 values.  In particular the if you try to dump/load an infinity
 or nan value, the load operation chokes:

 There is no completely portable way to do this.

Python deals with all sorts of problems for which there is no
completely portable solution.  Remember: practicality beats purity.

 Any single platform can have a solution, but (since the C
 standards don't address how NaNs and Infs are represented)
 there is not a good portable way to do the pickle / unpickle.

Likewise, there is no completely portable python
implimentation.  Any single platform can have a Python
implimentation, but since the C standards don't address a
universal standard for a computer there is not a good
portable way to do Python.  I guess we'd better give up on
Python.  :)

 It is nice the exception is raised, since at one point it was
 not (and a simple 1.0 was returned).

That would be even worse.

 [NaN and Infinity are prefectly valid (and extremely useful)
 floating point values, and not using them would require huge
 complexity increases in my apps (not using them would probably
 at least triple the amount of code required in some cases).]

 You could check to see if the Python 2.5 pickling does a better
 job.  Otherwise, you've got your work cut out for you.

Fixing it is really quite trivial.  It takes less than a dozen
lines of code.  Just catch the exception and handle it.

def load_float(self):
s = self.readline()[:-1]
try:
f = float(s)
except ValueError:
s = s.upper()
if s in [1.#INF, INF]:
f = 1e300*1e300
elif s in [-1.#INF, -INF]:
f = -1e300*1e300
elif s in [NAN,1.#QNAN,QNAN,1.#IND,IND,-1.#IND]:
f = -((1e300*1e300)/(1e300*1e300))
else:
raise ValueError, Don't know what to do with +`s`
self.append(f)

Obviously the list of accepted string values should be expanded
to include other platforms as needed.  The above example
handles Win32 and glibc (e.g. Linux).

Even better, add that code to float().

-- 
Grant Edwards   grante Yow!  Is the EIGHTIES
  at   when they had ART DECO
   visi.comand GERALD McBOING-BOING
   lunch boxes??
-- 
http://mail.python.org/mailman/listinfo/python-list


how to use more than 1 __init__ constructor in a class ?

2005-06-22 Thread scott
hi people,

can someone tell me, how to use a class like that* (or simulate more 
than 1 constructor) :
#--
class myPointClass:
   def __init__(self, x=0, y=0):
 self.x = x
 self.y = y
   def __init__(self, x=0, y=0, z=0):
 self.__init__(self, x, y)
 self.z = z
#--

tia people
scott

*this is not homework
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Database recommendations for Windows app

2005-06-22 Thread Hughes, Chad O
Firebird is cross platform (you would need the classic server version)
look at the following post:

http://mail.python.org/pipermail/python-list/2005-June/286366.html

Chad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Will McGugan
Sent: Wednesday, June 22, 2005 7:14 AM
To: python-list@python.org
Subject: Database recommendations for Windows app


Hi,

I'd like to write a windows app that accesses a locally stored database.

There are a number of tables, the largest of which has 455,905 records.

Can anyone recommend a database that runs on Windows, is fast / 
efficient and can be shipped without restrictions or extra downloads?

I have googled and found plenty of information on databases, its just 
that I dont have enough experience with databases to know which one is 
best for my task!


Thanks in advance,

Will McGugan
-- 
http://www.willmcgugan.com
.join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in 
jvyy*jvyyzpthtna^pbz)
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to use more than 1 __init__ constructor in a class ?

2005-06-22 Thread Steve
Hi Scott,
 can someone tell me, how to use a class like that* (or simulate more
 than 1 constructor) :

One approach could be:

class myPointClass:
def __init__(self, **args):
for k, v in args.items():
setattr(self, k, v)

 *this is not homework
Just to be safe, I'll leave out the explanation :)

Regards
Steve

On 6/22/05, scott [EMAIL PROTECTED] wrote:
 hi people,
 
 can someone tell me, how to use a class like that* (or simulate more
 than 1 constructor) :
 #--
 class myPointClass:
def __init__(self, x=0, y=0):
  self.x = x
  self.y = y
def __init__(self, x=0, y=0, z=0):
  self.__init__(self, x, y)
  self.z = z
 #--
 
 tia people
 scott
 
 *this is not homework
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: how to use more than 1 __init__ constructor in a class ?

2005-06-22 Thread Michael Hoffman
scott wrote:

 can someone tell me, how to use a class like that* (or simulate more 
 than 1 constructor) :
 #--
 class myPointClass:
   def __init__(self, x=0, y=0):
 self.x = x
 self.y = y
   def __init__(self, x=0, y=0, z=0):
 self.__init__(self, x, y)
 self.z = z
 #--

Well for the example you used, multiple constructors are not needed. 
This will get you the same result as what I imagine you wanted the
first example to do:

class myPointClass:
 def __init__(self, x=0, y=0, z=0):
  self.x = x
  self.y = y
  self.z = z
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Database recommendations for Windows app

2005-06-22 Thread Thomas Bartkus
Dan [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On 6/22/2005 11:38 AM, Thomas Bartkus wrote:
  Will McGugan [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
 

 And then XP Autoupdate executes, some of those Access/MSDE libraries are
 updated, and you app is broken.

Hasn't happened yet!

For the record - I wouldn't recommend automatic updates of any kind for a
Linux/MySQL system either.  For precisely the same reasons.

Thomas Bartkus



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


Re: PEP ? os.listdir enhancement

2005-06-22 Thread Michael Hoffman
Peter Hansen wrote:

 Using Jason Orendorff's path module, all this code basically collapses 
 down to this beauty (with your variable path renamed to myPath to 
 avoid a name collision):

This has to be the non-stdlib library I use the most. It's a great module.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: JEP and JPype in a single process

2005-06-22 Thread Steve Menard
Steve Menard wrote:
 skn wrote:
 
 Hello,

 I have written a very simple java class file, which invokes a Python 
 script
 using JEP.

 Code snippet:-
 ---
 Jep jep = new Jep(false);
 jep.runScript(C:\\temp\\testscript.py);
 jep.close();

 Now inside this Python script I want to make Java calls using JPype.
 If I use startjvm() inside this Python script, a Runtime Error 
 (exception)
 is thrown.
 Also tried attachThreadToJVM(), but doesn't work, again Runtime Error.

 Any clues as to how I could achieve my goal??
 The interaction shown below should happen in a single process.

 JAVA == jep == PYTHON == jpype == JAVA

 Regards,
 skn


 
 You're trying to do something I hope to make possible somewhere down the 
 road ...
 
 As of today, I do not think it is possible. JPype does not provide a way 
 to initialize the JVM-bridge system except for startJvm .. which seems 
 to be prohibited when a JVM is already running.
 
 AttachThreadToJVM will only work once the JVM-bridge system has been 
 initialize.
 
 I will look into providing a sister method to startJVM to attach to the 
 currently running JVM instead of starting a new one. IF it does not 
 require major changes I will release it as 0.5.1. If you'd like you can 
 submit an enhancement request on the JPype sourceforge page, so this 
 doesn't get lost.
 
 
 

OK .. it now works. There are a few caveats that cannot be resolved 
until either JEP and JPype can somehow cooperate or I finish what I 
started and basically fold the JEP functionality in JPype.

I will release the new functionality in as version 0.5.1. The gotchas 
are going to be in a readme-jep.txt file.

-- 
Steve Menard

Maintainer of http://jpype.sourceforge.net
-- 
http://mail.python.org/mailman/listinfo/python-list


MySQLdb reconnect

2005-06-22 Thread Damjan
Does MySQLdb automatically reconnect if the connection to the database is
broken?

I'm asking this since I have a longrunning Python precess that is connected
to Mysql-4.1.11, and I execute set names utf8 when I connect to it.

But after running a day the results from the python program were displayed
as if the set names utf8 was not executed i.e. I got question marks where
utf-8 cyrillics should've appeared. After restarting the Python program
everything was ok, just as when I first started it.

The long running Python process is actually a scgi quixote web application.


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


Re: how to use more than 1 __init__ constructor in a class ?

2005-06-22 Thread Paul McGuire
This recipe that I submitted to the Python Cookbook
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/223611)
describes a technique for doing this.  I use the example of creating
Color objects for plotting to a bitmap, using either R,G,andB values,
or a single integer representing the RGB encoded value.

This style you describe is a Java language artifact.  If you have
optional params, then these really don't represent different method
signatures.  In my color example, you truly have different signatures,
either 3 integers representing color components, or a single encoded
integer.

-- Paul

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


Re: how to use more than 1 __init__ constructor in a class ?

2005-06-22 Thread Rocco Moretti
scott wrote:
 hi people,
 
 can someone tell me, how to use a class like that* (or simulate more 
 than 1 constructor) :
 #--
 class myPointClass:
   def __init__(self, x=0, y=0):
 self.x = x
 self.y = y
   def __init__(self, x=0, y=0, z=0):
 self.__init__(self, x, y)
 self.z = z
 #--
 

You might try:

#--
class myPointClass:
   def __init__(self, x=0, y=0, z=None):
 self.x = x
 self.y = y
 if z is not None:
self.z = z
#--

You could also turn __init__ into a dispatch fuction:

#--
class myPointClass:
   def __init__(self, *args):
 if len(args) = 2:
   self.__init_two(*args)
 if len(args) == 3:
   self.__init_three(*args)
   def __init_two(self, x=0, y=0):
 self.x = x
 self.y = y
   def __init_three(self, x=0, y=0, z=0):
 self.__init_two(x, y)
 self.z = z
#--

But I would definitely recommend looking at your algorithm to determine 
if there is a better way to do what you want, that doesn't require an 
initilizer with two different signatures.
-- 
http://mail.python.org/mailman/listinfo/python-list


timedelta comparision with gmtime()

2005-06-22 Thread Florian Lindner
Hello,
I want to know if a certain duration is over.
I try it like this with timedelta objects:

d = datetime.timedelta(minutes = 2)
t = time.gmtime()
print (t + d  time.gmtime())

gives:

TypeError: unsupported operand type(s) for +: 'datetime.timedelta' and
'time.struct_time'

How to do that right?

Thanks,

Florian


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


Re: Loop until condition is true

2005-06-22 Thread Scott David Daniels
Magnus Lycka wrote:
 In some cases, == and is happens to give the same result.
   a = 1
   b = 1
   a == b
 1
   a is b
 1
 
 But often not.
 
   c = 123456789
   d = 123456789
   c == d
 1
   c is d
 0
 
...
 First of all, a lot of Python values except 1 (a.k.a. True)
 are logically true in a Python expression

Actually, True and 1 are interesting examples.

  a, b = 1, True
  a == b
True

  a is b
False


I suspect you simply forgot this fact.

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


Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Scott David Daniels
Grant Edwards wrote:
 On 2005-06-22, Scott David Daniels [EMAIL PROTECTED] wrote:
...Under Win32, the pickle module only works with a subset of
 floating point values.  In particular ... infinity or nan ...

There is no completely portable way to do this.
 
 Python deals with all sorts of problems for which there is no
 completely portable solution.  Remember: practicality beats purity.
 
Any single platform can have a solution, but (since the C
standards don't address how NaNs and Infs are represented)
there is not a good portable way to do the pickle / unpickle.
 ... 
 Fixing it is really quite trivial.  It takes less than a dozen
 lines of code.  Just catch the exception and handle it.
Since you know it is quite trivial, and I don't, why not submit a
patch resolving this issue.  Be sure to include tests for all
supported Python platforms.

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


Re: Database recommendations for Windows app

2005-06-22 Thread Magnus Lycka
Gregory Piñero wrote:
 I always figured a problem with using MySQL was distribution.  Would
 you have to tell your users to install MySQL and then to leave the
 service running?  I've never found an easy way to embed MySQL into a
 python app, and even if you could, would you then have to pay for it?

There are more reasons than that not to use MySQL...
See e.g. http://sql-info.de/mysql/gotchas.html

It seems a lot of the most badly missed features are
appearing in MySQL 5.0, but as features are added, I
suppose the claimed advantages in performance and
simplicity withers away, and these features can hardly
be considered very mature yet. (One should also note
that MySQL manuals have often claimed that features
it lacked were useless, or even dangerous, until
MySQL AB decided to implement them themselves... :)


Also, the GPL/Commercial licence is not a good thing
for commercial apps, particularly since this licence
applies even to client libs.

Recent PostgreSQL versions are stable, fast, and have
native Windows versions.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Grant Edwards
On 2005-06-22, Scott David Daniels [EMAIL PROTECTED] wrote:

 Fixing it is really quite trivial.  It takes less than a dozen
 lines of code.  Just catch the exception and handle it.

 Since you know it is quite trivial, and I don't, why not
 submit a patch resolving this issue.  Be sure to include tests
 for all supported Python platforms.

I'm working on it.  I should have said it's trivial if you have
access to the platforms to be supported.  I've tested a fix
that supports pickle streams generated under Win32 and glibc.
That's using the native string representation of a NaN or
Inf.

A perhaps simpler approach would be to define a string
representation for Python to use for NaN and Inf.  Just because
something isn't defined by the C standard doesn't mean it can't
be defined by Python.

-- 
Grant Edwards   grante Yow!  I'm shaving!! I'M
  at   SHAVING!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Database recommendations for Windows app

2005-06-22 Thread Cameron Laird
In article [EMAIL PROTECTED], Dan  [EMAIL PROTECTED] wrote:
.
.
.
 You wouldn't have to distribute the (rather expensive) Access application
 since this is little more than a front for the underlying DAO/ADO database
 libraries that are built into the warp and woof of MS Windows.  Your Python
 application can address the DAO or ADO directly as these will libraries will
 be pre-installed and/or freely available for MS Windows.  Fast, freely
 available, no license restrictions, and no need for extra downloads for a
 reasonably recent (Win2000, XP) operating system.
 

And then XP Autoupdate executes, some of those Access/MSDE libraries are 
updated, and you app is broken.

Are you saying that Python-based applications are particularly
vulnerable in this all-too-common scenario?  If so, I'm not
getting it; why is the architecture described more fragile than
more traditional Windows-oriented development patterns?  If not,
then, ... well then I truly don't get your point.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: importing a package

2005-06-22 Thread Damjan
 Indeed, when i do this, then it works
 import sys
 sys.path.append('package')
 
 However, why is it that package isn't added automatically to the pad?

When you execute a python program the directory where the program is is
automatically added to sys.path. No other directory is added to the default
builtin sys.path.

In you case (the second case), you can import package.dir2.file2.


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


Re: Database recommendations for Windows app

2005-06-22 Thread Dave Cook
On 2005-06-22, Cameron Laird [EMAIL PROTECTED] wrote:

 Are you saying that Python-based applications are particularly
 vulnerable in this all-too-common scenario?  If so, I'm not
 getting it; why is the architecture described more fragile than
 more traditional Windows-oriented development patterns?  If not,
 then, ... well then I truly don't get your point.

Maybe the point is the downside of depending on installed DLLs rather than
shipping your own.

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


Re: timedelta comparision with gmtime()

2005-06-22 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED]:~ $ python
Use now() from datetime class of datetime module instead of time
module.

Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type help, copyright, credits or license for more information.
py import datetime
py t = datetime.datetime.now()
py print t
2005-06-22 20:22:36.212142
py d = datetime.timedelta(minutes = 2)
py print t + d
2005-06-22 20:24:36.212142

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


Package organization

2005-06-22 Thread Thomas Lotze
Hi,

I've two questions concerning organizing and naming things when writing
a Python package.

- Naming of classes: I'm writing a library that reads PDF files. I have
  a data structure that represents the large-scale structure of a PDF
  file (header, trailer, incremental updates etc), and I'll have others,
  e.g. one that represents the document as a collection of logical
  objects (page descriptions, images etc).

  Assume I have a package called PDF. Should the classes then be called
  simply File and Objects, as it is clear what they do as they are
  imported from PDF? Or should they be called PDFFile and PDFObjects, as
  the names would be too undescriptive otherwise?

- Organizing subpackages and interfaces: I'm using the zope.interface
  package in order to define interface classes. In a small package
  called foo, one might define interfaces IReadableFoo and IWritableFoo
  in foo.interfaces.

  However, in a large package foo with subpackages bar and baz,
  interface definitions might either sit in foo.bar.interfaces and
  foo.baz.interfaces, or in foo.interfaces.bar and foo.interfaces.baz.
  Which is preferable?

Thanks for any thought on this.

-- 
Thomas

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


Re: how to use more than 1 __init__ constructor in a class ?

2005-06-22 Thread [EMAIL PROTECTED]
You also could use a list to represent your data, then you get more
dimensions supported, e.g:
import math
class Point:
def __init__(self, *args):
self.points = list(args)

def dist(x, y):
if len(x.points) != len(y.points):
raise RuntimeError('dimensions not the same')
d = 0
for i in range(len(x.points)):
d += (x.points[i] - y.points[i])**2
return math.sqrt(d)

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


Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Scott David Daniels
Grant Edwards wrote:
 I'm working on it.  I should have said it's trivial if you have
 access to the platforms to be supported.  I've tested a fix
 that supports pickle streams generated under Win32 and glibc.
 That's using the native string representation of a NaN or
 Inf.
Several issues:
(1) The number of distinct NaNs varies among platforms.  There are
 quiet and signaling NaNs, negative 0, the NaN that Windows VC++
 calls Indeterminate, and so on.
(2) There is no standard-conforming way to create these values.
(3) There is no standard-conforming way to detect these values.

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


debugging - converting PyObject back to a variable name

2005-06-22 Thread adamc
hi,

I'm currently debugging a crash occurring in the Python interpreter.
I've got a Dictionary object in the form of a (PyObject *)

I can cast it to (dictobject *) in the debugger watch window, and I can
also use PyString_AsString(PyObject_Repr()) to get the debugger to
print out a string representation of the dictionary (actually I can't -
this also crashes, because one of the values in the dictionary has
become corrupted)

What I'm trying to do is relate this dictionary object back to a
variable name in my application source code (i.e. written in Python) -
I've been searching round the web for an easy way of doing this -
hopefully some function I can type into the debugger's watch window.

thanks alot for the help

adam

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


create a pdf file

2005-06-22 Thread Alberto Vera
Hello:

I found a script that convert a file to PDF format , but it was made in PHP

Do you know any script using Python?

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


Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Terry Reedy

Grant Edwards [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 I'm working on it.  I should have said it's trivial if you have
 access to the platforms to be supported.  I've tested a fix
 that supports pickle streams generated under Win32 and glibc.
 That's using the native string representation of a NaN or
 Inf.

 A perhaps simpler approach would be to define a string
 representation for Python to use for NaN and Inf.  Just because
 something isn't defined by the C standard doesn't mean it can't
 be defined by Python.

I believe that changes have been made to marshal/unmarshal in 2.5 CVS with 
respect to NAN/INF to eliminate annoying/surprising behavior differences 
between corresponding .py and .pyc files.  Perhaps these revisions would be 
relevant to pickle changes.

TJR



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


Re: create a pdf file

2005-06-22 Thread Dan
On 6/22/2005 1:58 PM, Alberto Vera wrote:
 Hello:
 
 I found a script that convert a file to PDF format , but it was made in PHP
 
 Do you know any script using Python?
 
 Regards

See http://www.reportlab.org/rl_toolkit.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to use more than 1 __init__ constructor in a class ?

2005-06-22 Thread F. Petitjean
Le 22 Jun 2005 11:44:09 -0700, [EMAIL PROTECTED] a écrit :
 You also could use a list to represent your data, then you get more
 dimensions supported, e.g:
 import math
 class Point:
   def __init__(self, *args):
   self.points = list(args)

 def dist(x, y):
   if len(x.points) != len(y.points):
   raise RuntimeError('dimensions not the same')
   d = 0
   for i in range(len(x.points)):
   d += (x.points[i] - y.points[i])**2
   return math.sqrt(d)


My rewrite (same idea) :-)
class Point(object):
def __init__(self, *args):
self.coords = list(args)  # or even args ?

def dist(self, other):
d2 = sum([ (c1-c2)*(c1-c2) for c1, c2 in zip(self.coords,
other.coords)])
return math.sqrt(d2)


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


Re: Package organization

2005-06-22 Thread F. Petitjean
Le Wed, 22 Jun 2005 20:42:24 +0200, Thomas Lotze a écrit :
 Hi,

 I've two questions concerning organizing and naming things when writing
 a Python package.

   Assume I have a package called PDF. Should the classes then be called
   simply File and Objects, as it is clear what they do as they are
   imported from PDF? Or should they be called PDFFile and PDFObjects, as
   the names would be too undescriptive otherwise?

As you whish :-)
if in the package ie in the __init__.py (not the best idea)
from PDF import File as PDFFile  # always possible

if File is defined in a module Objects
from PDF.Objects import File  # as PDFFile is always possible.

Have you installed the reportlab package ? It is full of from ... import
..  and it generates PDF.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Grant Edwards
On 2005-06-22, Scott David Daniels [EMAIL PROTECTED] wrote:

 I'm working on it.  I should have said it's trivial if you have
 access to the platforms to be supported.  I've tested a fix
 that supports pickle streams generated under Win32 and glibc.
 That's using the native string representation of a NaN or
 Inf.
 Several issues:

 (1) The number of distinct NaNs varies among platforms.

According to the IEEE standard, there are exactly two:
signalling and quiet, and on platforms that don't impliment
floating point exceptions (probably in excess of 99.9% of
python installations), the difference between the two is moot.

 There are quiet and signaling NaNs, negative 0,

Negative 0 isn't a NaN, it's just negative 0.
 
 the NaN that Windows VC++ calls Indeterminate, and so
 on.

That's just Microsoft's way of spelling signalling NaN.

 (2) There is no standard-conforming way to create these values.

What standard are you looking at?  My copy of the IEEE 754
standard is pretty clear.

 (3) There is no standard-conforming way to detect these
 values.

The bit patterns are defined by the IEEE 754 standard.  If
there are Python-hosting platoforms that don't use IEEE 754 as
the floating point representation, then that can be dealt with.

Python has _tons_ of platform-specific code in it.  

Why all of a sudden is it taboo for Python to impliment
something that's not universally portable and defined in a
standard?  Where's the standard defining Python?

-- 
Grant Edwards   grante Yow!  ... A housewife
  at   is wearing a polypyrene
   visi.comjumpsuit!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: oddness in shelve module

2005-06-22 Thread John Machin
Michael P. Soulier wrote:

On 22/06/05 John Machin said:

  

AFAICT, wrong it. The item assignment which is alleged not to be 
supported is of this form: an_object[some_key] = a_value

I.e. self.db is the suspect, not sample



Ah. Let me test that it is in fact being created properly then. I
expected an error more like, object has no property db in that case. 

Mike

  

sorry, perhaps I wasn't clear enough -- you seem to think I meant self 
has no attribute called db. No, self.db exists, but it doesn't 
support the activity of assigning to an indexed item, like a dictionary.

The interactive interpreter is your friend:

  adict = {}
  adict[3] = 4
  notlikeadict = 666
  notlikeadict[3] = 4
Traceback (most recent call last):
  File stdin, line 1, in ?
TypeError: object does not support item assignment
 

This is the message that you are thinking about, the word is 
attribute, not property.

  class Dummy:
...pass
...
  x = Dummy()
  x.dc
Traceback (most recent call last):
  File stdin, line 1, in ?
AttributeError: Dummy instance has no attribute 'dc'

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


  1   2   >