using os.walk to generate objects

2008-12-03 Thread Joe Hrbek
The code below works (in linux), but I'm wondering if there is a better/easier/cleaner way? It works on directory trees that don't have a lot of "."s in them or other special characters. I haven't implemented a good handler for that yet, so if you run this in your system, choose/make a simple dire

Re: Running a Python script from crontab

2008-12-03 Thread Astley Le Jasper
On 3 Dec, 16:41, Philip Semanchuk <[EMAIL PROTECTED]> wrote: > On Dec 3, 2008, at 10:29 AM, Astley Le Jasper wrote: > > > I've included a switch to include or exclude theloggingto console. > > Whenloggingonly to file, the script runs fine. > > > Of course, I still don't understand whyduallogging, a

python to parse excel file csv format

2008-12-03 Thread Jay Jesus Amorin
Hi all, Can anyone please help me. i need to parse the content of my csv excel file and run the unix command chown. test.csv: "/dev/trunk/admin/sql/ADBPOS_CMSI_NATIONALITY.syn",814 "/dev/trunk/bin/ADBPOSCMSDICED.ctl",405 "/dev/trunk/discoverer/ADBPOS_BUSINESS_AREA.eex",215 Please help me parse

Python calling COM compliant .dll

2008-12-03 Thread David Shi
Hello, there.   I am looking for a concise working example of Python script calling COM compliant .dll.   Regards.   David -- http://mail.python.org/mailman/listinfo/python-list

Re: Jython: Packing several .py on .jar, problem importing .py modules within the .jar

2008-12-03 Thread Gubatron
cont... Take in consideration /** Hashtable of URLClassLoaders for each of the jars loaded */ private Hashtable classLoaders; Here's an example: org.python.core.PySystemState pySys = new org.python.core.PySystemState(); //classLoad

Re: Jython: Packing several .py on .jar, problem importing .py modules within the .jar

2008-12-03 Thread Gubatron
I've managed to solve this problem. I can now run a python script that lives inside a Jar. The python script is now able to import other scripts within the same jar, and it's also able to import java classes that live within the jar. The problem was solved by giving the Jython Interpreter the pro

Re: python an sqlite objects

2008-12-03 Thread Gerhard Häring
[EMAIL PROTECTED] wrote: > azrael> is it possible to save a python object into a sqlite database as > azrael> an atribute of type BLOB > > Sure. Just pickle the object and save the resulting string. Be sure to save it as BLOB, not TEXT. Suppose you have serialized your object as Python

Re: python an sqlite objects

2008-12-03 Thread skip
Bruno> Or if you want something more portable, serialize the object to Bruno> json. At least you'll have a chance to deserialize it with some Bruno> other language. Assuming json can serialize more-or-less arbitrary Python objects. Can it serialize class instances? Skip -- http://ma

Re: python an sqlite objects

2008-12-03 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : azrael> is it possible to save a python object into a sqlite database as azrael> an atribute of type BLOB Sure. Just pickle the object and save the resulting string. Or if you want something more portable, serialize the object to json. At least you'll have

Re: Multiple Versions of Python on Windows XP

2008-12-03 Thread Colin J. Williams
Martin v. Löwis wrote: What changes are made to the registry? For a complete list, see Tools/msi/msi.py in the source tree. I have scanned the file: http://svn.python.org/projects/python/branches/py3k/Tools/msi/msi.py I don't find anything that addresses this issue. Read the add_registry fu

Re: python an sqlite objects

2008-12-03 Thread skip
azrael> is it possible to save a python object into a sqlite database as azrael> an atribute of type BLOB Sure. Just pickle the object and save the resulting string. -- Skip Montanaro - [EMAIL PROTECTED] - http://smontanaro.dyndns.org/ -- http://mail.python.org/mailman/listinfo/python-

Re: porting modules to Python 3.0

2008-12-03 Thread Terry Reedy
Martin v. Löwis wrote: In one has both 2.x and 3.0 installed, would it easy to install 'lib.py' for both? It's currently not possible to install something for 2.x; you have to specifically install it for every value of x (e.g. 2.5 or 2.6). That is what I meant. It's the same for 3.0: you ha

python an sqlite objects

2008-12-03 Thread azrael
is it possible to save a python object into a sqlite database as an atribute of type BLOB -- http://mail.python.org/mailman/listinfo/python-list

Re: Mathematica 7 compares to other languages

2008-12-03 Thread Jon Harrop
Xah Lee wrote: > On Dec 2, 5:13 pm, Jon Harrop <[EMAIL PROTECTED]> wrote: >> The Mathematica code is 700,000x slower so a 50% improvement will be >> uninteresting. Can you make my Mathematica code five orders of magnitude >> faster or not? > > Pay me $10 thru paypal, i'll can increase the speed so

Re: Reverse zip() ?

2008-12-03 Thread Andreas Waldenburger
On Wed, 3 Dec 2008 07:08:52 -0800 (PST) Janto Dreijer <[EMAIL PROTECTED]> wrote: > I'd like to point out that since your where thinking in terms of > matplotlib, you might actually find numpy's own transpose useful, > instead of using zip(*seq) :) > This was, of course, to be expected. :) Whenev

Re: Multiple equates

2008-12-03 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: >In message <[EMAIL PROTECTED]>, Cameron Laird wrote: > >>def shell_escape(Arg) : >>"""returns Arg suitably escaped for use as a command-line argument >>to Bash.""" >> >>pattern = r"[\<\>\"\

Re: Debugging a Python Program that Hangs

2008-12-03 Thread Stef Mientki
check winpdb / rpdb2, cheers, Stef On 12/3/08, alex23 <[EMAIL PROTECTED]> wrote: > On Dec 3, 2:19 am, Kevin D. Smith <[EMAIL PROTECTED]> wrote: >> I have a fairly large python program that, when a certain combination >> of options is used, hangs. I have no idea where it is hanging, so >> simply p

Re: Running a Python script from crontab

2008-12-03 Thread Philip Semanchuk
On Dec 3, 2008, at 10:29 AM, Astley Le Jasper wrote: I've included a switch to include or exclude the logging to console. When logging only to file, the script runs fine. Of course, I still don't understand why dual logging, and specifically to the console, causes a problem and if anyone has a

Re: Running a Python script from crontab

2008-12-03 Thread Astley Le Jasper
I've included a switch to include or exclude the logging to console. When logging only to file, the script runs fine. Of course, I still don't understand why dual logging, and specifically to the console, causes a problem and if anyone has any comments about the dual output logging code above then

Re: Thread Tkinter problem

2008-12-03 Thread Hendrik van Rooyen
"Davy" <[EMAIL PROTECTED]> wrote: > while(data_queue.full() == False): This will fill the queue and stop. Use while true and if queue not full... - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

Profiling Python

2008-12-03 Thread esgameserver
Hi, Simply put, we want to see the profile info dynamically. Is that possible? To clarify again, Is there some function like profile.PrintStats() which dynamically shows the stats before stopping the Profiler? Regards, -- http://mail.python.org/mailman/listinfo/python-list

Re: Reverse zip() ?

2008-12-03 Thread Janto Dreijer
I'd like to point out that since your where thinking in terms of matplotlib, you might actually find numpy's own transpose useful, instead of using zip(*seq) :) untested: t = linspace(0,2*pi*3) seq = asarray(zip(t, sin(t))) t, y = seq.T # or seq.transpose() or numpy.transpose(seq) pylab.plot(t,y

Re: Obama's Birth Certificate - Demand that US presidential electors investigate Obama's eligibility

2008-12-03 Thread Albert Hopkins
This has nothing to do with Python. Please take this thread to cares.who.someone. -- http://mail.python.org/mailman/listinfo/python-list

Re: generating a liste of characters

2008-12-03 Thread Vlastimil Brom
2008/12/3 Yves Dorfsman <[EMAIL PROTECTED]>: > Is there any built in way to generate a list of characters, something > along the line of range('a'-'z') ? > > Right now I am using: > > chars = [ chr(l) for l in range(0x30, 0x3a) ] # 0 - 9 > chars += [ chr(l) for l in range(0x41, 0x5b) ] # A - Z

Re: How to instantiate in a lazy way?

2008-12-03 Thread Nick Craig-Wood
Slaunger <[EMAIL PROTECTED]> wrote: > On 3 Dec., 11:30, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > > ? ? ? ? ?cls = self.__class__ > > > ? ? ? ? ?if attr_name in cls.data_attr_names: > > > > self.data_attr_names should do instead of cls.data_attr_names unless > > you are overriding it in the i

Re: generating a liste of characters

2008-12-03 Thread Shane Geiger
import string alphabet=list(string.letters[0:26]) print alphabet Yves Dorfsman wrote: Is there any built in way to generate a list of characters, something along the line of range('a'-'z') ? Right now I am using: chars = [ chr(l) for l in range(0x30, 0x3a) ] # 0 - 9 chars += [ chr(l)

Re: generating a liste of characters

2008-12-03 Thread James Mills
On Thu, Dec 4, 2008 at 12:18 AM, Yves Dorfsman <[EMAIL PROTECTED]> wrote: > Is there any built in way to generate a list of characters, something > along the line of range('a'-'z') ? > > Right now I am using: > > chars = [ chr(l) for l in range(0x30, 0x3a) ] # 0 - 9 > chars += [ chr(l) for l i

generating a liste of characters

2008-12-03 Thread Yves Dorfsman
Is there any built in way to generate a list of characters, something along the line of range('a'-'z') ? Right now I am using: chars = [ chr(l) for l in range(0x30, 0x3a) ] # 0 - 9 chars += [ chr(l) for l in range(0x41, 0x5b) ] # A - Z chars += [ chr(l) for l in range(0x61, 0x7b) ] # a

Python3: sorting image objects according to a cmp function

2008-12-03 Thread Poor Yorick
I'm looking for a Python3-compatible way to sort a list of PIL image objects based on a computed difference between the two images. In 2.x, this would work: imagelist.sort(cmp=image_diff(a,b)) Maybe this could be done by creating a new class with the appropriate __lt__, gt__, __eq__ metho

Re: Converting a .xls file to .html

2008-12-03 Thread Tino Wildenhain
Hi, tarun wrote: Hello All, I've a .xml file (saved as .xls) that can be opened in Microsoft excel. Well if its an xml file then just attach a style to it and you can just view it in a browser w/o involving excel in the first place. Also there are lots of xml libraries coming with python

Thread Tkinter problem

2008-12-03 Thread Davy
Hi all, I am using thread and tkinter to write some simple programs and solidify my understanding of Python thread/GUI programing. The scheme is thread + queue + GUI. One child thread (gen_board_thread) generate board and insert data into queue infinitely. Meanwhile, the main thread canvas widget

Re: Converting a .xls file to .html

2008-12-03 Thread Linda Octalina
Do you have styles attached to the text of the document in the xls? (bold, italic, etc) if not, then you can just do the mapping by creating table and cells by yourself... (or xslt) {^(00)^} LiNdA OcTaLiNa ---GeEeEee--- From: Jeremiah Dodds <[EMAIL PROTECTED

Re: Multiple equates

2008-12-03 Thread Almar Klein
Hi, what about numpy? import numpy a = numpy.ones((10,),dtype=numpy.bool) I = [1,3,8] a[I]=False print a gives: [ True False True False True True True True False True] Almar -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a .xls file to .html

2008-12-03 Thread Jeremiah Dodds
On Wed, Dec 3, 2008 at 5:54 AM, tarun <[EMAIL PROTECTED]> wrote: > Hello All, > > I've a .xml file (saved as .xls) that can be opened in Microsoft excel. I > want to write python code that converts this excel file into .html (so that > it can be viewed as is in an explorer). > > Can any one help?

Re: Multiple equates

2008-12-03 Thread Jeremiah Dodds
On Wed, Dec 3, 2008 at 6:23 AM, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > > So why is that better? > -- > http://mail.python.org/mailman/listinfo/python-list > I personally think that it looks marginally cleaner (indentation issues aside). Do you think it's substantially worse? If so, why

Jython: Packing several .py on .jar, problem importing .py modules within the .jar

2008-12-03 Thread Gubatron
Hello all, I've a problem with Jython and importing .py inside a jar. I'm putting .class and .py files inside .jar files. myjar.jar MyJar\SomeClass.class MyJar\main.py MyJar\otherModule.py So I add the myjar.jar to Jython's sys.path org.python.core.PySystemState p

Re: How to instantiate in a lazy way?

2008-12-03 Thread Slaunger
On 3 Dec., 11:30, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > >          cls = self.__class__ > >          if attr_name in cls.data_attr_names: > > self.data_attr_names should do instead of cls.data_attr_names unless > you are overriding it in the instance (which you don't appear to be). Yeah, I

Re: Multiple equates

2008-12-03 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Cameron Laird wrote: >def shell_escape(Arg) : >"""returns Arg suitably escaped for use as a command-line argument >to Bash.""" > >pattern = r"[\<\>\"\'\|\&\$\#\;\(\)\[\]\{\}\`\!\~\ \\]" >def f1(Match): > return "\\" + Match.group

Re: Simple ini Config parser examples needed

2008-12-03 Thread Tim Chase
Tim provided a correct-looking answer, albeit somewhat complex, as it doesn't reuse the logic in the ConfigParser. It didn't start out very complex, but it was so easy to make it a bit more robust with such a scant few lines of code that I went ahead. The original just looked like options

Re: Running a Python script from crontab

2008-12-03 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Astley Le Jasper wrote: > The trouble is that obviously I get no console when using crontab so > can't see any traceback. Cron normally sends you mail if a cron task generated any output (this should include error messages). -- http://mail.python.org/mailman/listin

Re: Multiple equates

2008-12-03 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: >Cameron Laird wrote: > >>def f1(Match): >>return > >Something missing here? Ugh; yes, sorry: def shell_escape(Arg) : """returns Arg suitably escaped for use as a command-line argument

Re: Obama's Birth Certificate - Demand that US presidential electors investigate Obama's eligibility

2008-12-03 Thread Iain King
On Dec 3, 10:16 am, [EMAIL PROTECTED] wrote: > On Dec 3, 12:53 am, Bryan Olson <[EMAIL PROTECTED]> wrote: > > > > > [EMAIL PROTECTED] wrote: > > > This message is not about the meaningless computer printout called > > > More importantly, it's not about Python. I'm setting follow-ups to > > talk.pol

Re: Is it safe to modify the dict returned by vars() or locals()

2008-12-03 Thread Helmut Jarausch
Duncan Booth wrote: Helmut Jarausch <[EMAIL PROTECTED]> wrote: Chris Rebert wrote: On Mon, Dec 1, 2008 at 1:01 PM, Helmut Jarausch <[EMAIL PROTECTED]> wrote: Hi, I am looking for an elegant way to solve the following problem: Within a function def Foo(**parms) I have a list of names, say

Converting a .xls file to .html

2008-12-03 Thread tarun
Hello All, I've a .xml file (saved as .xls) that can be opened in Microsoft excel. I want to write python code that converts this excel file into .html (so that it can be viewed as is in an explorer). Can any one help? Regards, Tarun -- http://mail.python.org/mailman/listinfo/python-list

Re: How to send body and attachements in an email message?

2008-12-03 Thread Aspersieman
On Wed, 03 Dec 2008 12:40:30 +0200, srinivasan srinivas <[EMAIL PROTECTED]> wrote: HI, I would like to send an email message with body-content 'test' and an attachment. The snippet i used is: outer = email.mime.multipart.MIMEMultipart() msg1 = email.mime.text.MIMEText(, _subtype = 'text')

Re: Reverse zip() ?

2008-12-03 Thread Andreas Waldenburger
On Wed, 3 Dec 2008 02:11:51 -0800 (PST) alex23 <[EMAIL PROTECTED]> wrote: > On Dec 3, 6:51 pm, Andreas Waldenburger <[EMAIL PROTECTED]> wrote: > > On Tue, 02 Dec 2008 18:16:13 -0800 Bryan Olson > > > zip as its own inverse might be even easier to comprehend if we > > > call zip by its more traditi

How to send body and attachements in an email message?

2008-12-03 Thread srinivasan srinivas
HI, I would like to send an email message with body-content 'test' and an attachment. The snippet i used is: outer = email.mime.multipart.MIMEMultipart() msg1 = email.mime.text.MIMEText(, _subtype = 'text') msg1.add_header('Content-Disposition', 'attachment') outer.attach(msg1) body = email.mime.

Re: How to instantiate in a lazy way?

2008-12-03 Thread Nick Craig-Wood
Slaunger <[EMAIL PROTECTED]> wrote: > Just wanted to show the end result in its actual implementation! > > I ended up *not* making a decorator, as I already had a good idea > about how to do it > using __getattr__ > > class PayloadDualFrqIQOnDemand(PayloadDualFrqIQ): > """ > This c

Re: Running a Python script from crontab

2008-12-03 Thread Astley Le Jasper
Ok ... this is odd. I tried gregory's suggestion of redirecting the stdout & stderr to a text file. This worked. I could see all the logging information. However, there was no error to see this time ... the application worked completely without any problems. I also then tried Jon's suggestion of

Re: Obama's Birth Certificate - Demand that US presidential electors investigate Obama's eligibility

2008-12-03 Thread MM456Z
On Dec 3, 12:53 am, Bryan Olson <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > This message is not about the meaningless computer printout called > > More importantly, it's not about Python. I'm setting follow-ups to > talk.politics. > > > "Certification of Live Birth" that Obama propaga

Re: Reverse zip() ?

2008-12-03 Thread alex23
On Dec 3, 6:51 pm, Andreas Waldenburger <[EMAIL PROTECTED]> wrote: > On Tue, 02 Dec 2008 18:16:13 -0800 Bryan Olson > > zip as its own inverse might be even easier to comprehend if we call > > zip by its more traditional name, "transpose". > > Sounds like a Py4k change to me. Nah, just add the fol

Re: [ANN] Pyjamas 0.4: Python Web Toolkit Release

2008-12-03 Thread Luke Kenneth Casson Leighton
On Wed, Dec 3, 2008 at 4:54 AM, Banibrata Dutta <[EMAIL PROTECTED]> wrote: > Amazing concept, and glad that someone thought of this and implemented this. > The book's formatting on IE and Chrome looked a bit unusual. Content wise it > is already firly decent (i.e. enough to get a programmer started

Re: Do more imported objects affect performance

2008-12-03 Thread Nick Craig-Wood
On Tue, Dec 02, 2008 at 10:53:47PM -0500, Steve Holden wrote: > Pardon me for intruding, but timings here are entirely the wrong focus > for a Python newcomer. Given that imports are super-optimized (i.e. the > code in the module is only performed once) such a small difference in > timing is incons

Re: How to use a Python function that returns a double array in C++.

2008-12-03 Thread Hrvoje Niksic
pieter <[EMAIL PROTECTED]> writes: > I want to use a Python function that returns a double array in C++. Return an array.array('d') object, and use the buffer protocol (for example PyObject_AsReadBuffer()) to get the address of the underlying array of native doubles. -- http://mail.python.org/mai

Re: Reverse zip() ?

2008-12-03 Thread Andreas Waldenburger
On Tue, 02 Dec 2008 18:16:13 -0800 Bryan Olson <[EMAIL PROTECTED]> wrote: > zip as its own inverse might be even easier to comprehend if we call > zip by its more traditional name, "transpose". > Sounds like a Py4k change to me. /W -- My real email address is constructed by swapping the domain

How to use a Python function that returns a double array in C++.

2008-12-03 Thread pieter
I want to use a Python function that returns a double array in C++. I don’t have a problem if the Python function returns a single variable of type double, using the following lines in my C++ code: myPythonObjectPointer = PyObject_CallObject(pFunc, pArgs); myCppDoubleVariable = PyF

Re: noob needs help

2008-12-03 Thread Jeremiah Dodds
On Wed, Dec 3, 2008 at 1:01 AM, Sambo <[EMAIL PROTECTED]> wrote: > Peter Pearson wrote: > > > In slackware one needs "./" before the filename if you executing > files in current dir. > -- > http://mail.python.org/mailman/listinfo/python-list > Umm, only if you're running files marked as executabl

Re: Multiple equates

2008-12-03 Thread Lawrence D'Oliveiro
Cameron Laird wrote: >def f1(Match): >return Something missing here? -- http://mail.python.org/mailman/listinfo/python-list

Re: porting modules to Python 3.0

2008-12-03 Thread Martin v. Löwis
> In one has both 2.x and 3.0 installed, would it easy to install 'lib.py' > for both? It's currently not possible to install something for 2.x; you have to specifically install it for every value of x (e.g. 2.5 or 2.6). It's the same for 3.0: you have to install it separately. Doing so is fairl

<    1   2