Re: C++ code generation

2010-03-16 Thread Stefan Behnel
CHEN Guang, 17.03.2010 02:54: - Original Message - From: "Dan Goodman" I'm doing some C++ code generation using Python, and would be interested in any comments on the approach I'm taking. PythoidC ( http://pythoidc.googlecode.com ) is a C code generator (not C++) It would be nice if

Re: import antigravity

2010-03-16 Thread Stefan Behnel
Michael Rudolf, 17.03.2010 00:48: Am 16.03.2010 21:44, schrieb Mark Lawrence: Who actually *IS* running the time machine? Are there any bugs?? My is. And as I'm a lazy hacker: sure. there are bugs. lets just call them features and move on. nothing to see here ;) I'll know it, I'll just know

Re: C-API PyObject_Call

2010-03-16 Thread Stefan Behnel
moerchendiser2k3, 16.03.2010 19:25: Hi, currently I am not at home, I will post some stuff when I am back. Just the note: I throw an exception with the C API. Looks like that PyObject *result = PyObject_Call(my_isntance, "", NULL); if(result==NULL) { PyErr_Print(); //when this happens, th

Re: Converting Python CGI to WSGI scripts

2010-03-16 Thread John Nagle
Sebastian Bassi wrote: On Tue, Mar 16, 2010 at 2:18 PM, wrote: I have a few dozen simple Python CGI scripts. Are there any advantages or disadvantages to rewriting these CGI scripts as WSGI scripts? It depends of the script. WSGI should be faster since you don't start a Python instance for e

Re: Dynamic Class Creation

2010-03-16 Thread Josh English
Chris, Thanks. This worked for the attributes, but I think the tactic is still misleading. There are child elements I can't quite determine how to deal with: Analog Science Fiction and Fact Analog Science Fiction First Contact Hard Science Fiction Stanley Schmidt

Re: to pass self or not to pass self

2010-03-16 Thread Patrick Maupin
On Mar 16, 1:59 pm, Jason Tackaberry wrote: > Why not create the bound methods at instantiation time, rather than > using the descriptor protocol which has the overhead of creating a new > bound method each time the method attribute is accessed? Well, for one thing, Python classes are open. They

Re: to pass self or not to pass self

2010-03-16 Thread Steven D'Aprano
On Wed, 17 Mar 2010 15:57:17 +1100, Lie Ryan wrote: > Most people probably would never need to use > descriptor protocol directly, since the immediate benefit of descriptor > protocol are property(), classmethod(), and instancemethod() decorators > which, without descriptor protocol, would never b

Re: Converting Python CGI to WSGI scripts

2010-03-16 Thread Sebastian Bassi
On Tue, Mar 16, 2010 at 2:18 PM, wrote: > I have a few dozen simple Python CGI scripts. > Are there any advantages or disadvantages to rewriting these CGI scripts as > WSGI scripts? It depends of the script. WSGI should be faster since you don't start a Python instance for each call (as in CGI).

Re: to pass self or not to pass self

2010-03-16 Thread Lie Ryan
On 03/17/2010 05:59 AM, Jason Tackaberry wrote: > On Tue, 2010-03-16 at 10:04 +0100, Bruno Desthuilliers wrote: >> Answer here: >> >> http://wiki.python.org/moin/FromFunctionToMethod > > I have a sense I used to know this once upon a time, but the question > came to my mind (possibly again) and I

Data entry Work available

2010-03-16 Thread pothuri ramesh
Data entry works Available At No need to pay DEposite http://trading7000.blogspot.com/ Adposting Jobs Availble http://trading7000.blogspot.com/ No need to work Hard Earn Money From Home 7000 in Minutes http://trading7000.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-lis

Re: highlight words by regex in pdf files using python

2010-03-16 Thread Patrick Maupin
On Mar 4, 6:57 pm, Peng Yu wrote: > I don't find a general pdf library in python that can do any > operations on pdfs. > > I want to automatically highlight certain words (using regex) in a > pdf. Could somebody let me know if there is a tool to do so in python? The problem with PDFs is that they

Web Hosting Python 3

2010-03-16 Thread hidura
Hello list, i am in a project what need hosting, who give hosting to python3? -- http://mail.python.org/mailman/listinfo/python-list

Re: C-API PyObject_Call

2010-03-16 Thread moerchendiser2k3
At first thanks for your answers!!! On 16 Mrz., 21:16, Carl Banks wrote: > Here you raise an exception with a C statement, > and catch and print it in the very next line.  The exception doesn't > exit from Python code so there are no lines to print. Exactly, I dont expect any line/file informati

Re: datetime string conversion error

2010-03-16 Thread Gabriel Genellina
En Tue, 16 Mar 2010 20:31:11 -0300, Josh English escribió: On Mar 16, 11:56 am, Jordan Apgar wrote: here's what I'm doing: date = "2010-03-16 14:46:38.409137" olddate = datetime.strptime(date,"%Y-%m-%j %H:%M:%S.%f") Due to circumstances, I'm using Python 2.5.4 on one machine (2.6 on th

Re: Exiting gracefully from ThreadingTCPServer

2010-03-16 Thread Gabriel Genellina
En Fri, 12 Mar 2010 12:15:16 -0300, Pete Emerson escribió: I'm trying to get threading going for the first time in python, and I'm trying to modify code I found so that I can have the server close the TCP connections and exit gracefully. Two problems: Which Python version? 1) While the Ke

Re: How to handle file uploads with http.server

2010-03-16 Thread Gabriel Genellina
En Thu, 11 Mar 2010 07:30:24 -0300, Neil Blue escribió: I have a basic http.server instance running (class HTTPHandler(http.server.BaseHTTPRequestHandler), with python 3.1, and I would like to upload files with multipart forms. def do_POST(self): ctype, pdict = cgi.parse_header(self.

Re: C++ code generation

2010-03-16 Thread CHEN Guang
PythoidC ( http://pythoidc.googlecode.com ) is a C code generator (not C++) - Original Message - From: "Dan Goodman" To: Sent: Wednesday, March 17, 2010 9:00 AM Subject: C++ code generation > Hi all, > > I'm doing some C++ code generation using Python, and would be interested > in

Re: Python bindings tutorial

2010-03-16 Thread CHEN Guang
> Is there any tutorial how to write a bindings for a exe ( dos) > program? > I would like to run it from a Python directly > ( using import command and a particular function from the binding) > not using os.system command. An example: PythoidC ( http://pythoidc.googlecode.com ), look at import

C++ code generation

2010-03-16 Thread Dan Goodman
Hi all, I'm doing some C++ code generation using Python, and would be interested in any comments on the approach I'm taking. Basically, the problem involves doing some nested loops and executing relatively simple arithmetic code snippets, like: for i in xrange(len(X)): X[i] += 5 Actually

Re: How to add a library path to pythonpath ?

2010-03-16 Thread Mark Hammond
On 17/03/2010 1:26 AM, Barak, Ron wrote: Thanks for the suggestion Pable. However, I really need the $PYTHONPATH to include this additional library, so all Python scripts could use it. In Windows I have defined PYTHONPATH as c:\views\cc_view\TS_svm_ts_tool\SVMInspector\lib\, and also in the Windo

Re: import antigravity

2010-03-16 Thread Michael Rudolf
Am 16.03.2010 21:44, schrieb Mark Lawrence: Who actually *IS* running the time machine? Are there any bugs?? My is. And as I'm a lazy hacker: sure. there are bugs. lets just call them features and move on. nothing to see here ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: cycling through options

2010-03-16 Thread Gabriel Genellina
En Tue, 16 Mar 2010 11:30:51 -0300, Dieter Faulbaum escribió: is there a better way for cycling through all options than this: (options, args) = parser.parse_args() for opt in options.__dict__.keys(): print opt, ":", options.__dict__[opt] (I assume parser is an optparse.OptionParser

Re: Conditional based on whether or not a module is being used

2010-03-16 Thread Aahz
In article <42062deb-785a-4955-9ce0-d9fb7a264...@j27g2000yqn.googlegroups.com>, Vinay Sajip wrote: > >I'm reviewing the documentation at the moment, as it happens, and it >still seems hard to be able to put together a structure which is good >for everyone. A full treatment, it seems to me, would

Re: Conditional based on whether or not a module is being used

2010-03-16 Thread Aahz
In article , Pete Emerson wrote: > >Excellent, this is what I finally discovered, although I was looking >for 'foo' in sys.modules.keys(), which apparently isn't necessary. Actually, `foo in sys.modules.keys()` is double-slow, because first the dict must be scanned to create a list, and then the

Re: highlight words by regex in pdf files using python

2010-03-16 Thread Aahz
In article , Peng Yu wrote: > >I don't find a general pdf library in python that can do any >operations on pdfs. > >I want to automatically highlight certain words (using regex) in a >pdf. Could somebody let me know if there is a tool to do so in python? Did you Google at all? "python pdf" find

Re: Function that knows its argument's variable name

2010-03-16 Thread Phlip
> Yet, the answer to your question is not quite absolutely "no".  Python > has lots of introspection capabilities, including, perhaps, getting at > and parsing the original code to find the call.    But there's nothing > direct for what you want. > > Gary Herron Below my sig is one shot at it; whi

Re: datetime string conversion error

2010-03-16 Thread Josh English
On Mar 16, 11:56 am, Jordan Apgar wrote: > here's what I'm doing: > date = "2010-03-16 14:46:38.409137" >  olddate = datetime.strptime(date,"%Y-%m-%j %H:%M:%S.%f") > Due to circumstances, I'm using Python 2.5.4 on one machine (2.6 on the other). When I have a script as simple as this: import d

Re: class inheritance

2010-03-16 Thread Robert Kern
On 2010-03-16 17:55 PM, JLundell wrote: On Mar 16, 8:06 am, Robert Kern wrote: On 2010-03-16 07:35 AM, Dave Angel wrote: Carl Banks wrote: On Mar 15, 4:34 pm, JLundell wrote: It's also unfortunate that Python doesn't have an approximately-equal operator; it'd come in handy for floating-poi

Re: Function that knows its argument's variable name

2010-03-16 Thread Gregory Ewing
Helge Stenström wrote: I want to write function that prints a value of a variable, for debugging. Like: myVariable = "parrot" otherVariable = "dead" > probe(myVariable) probe(otherVariable) Not exactly, but you can come close with a little hackery. import sys def print_var(name): print

Re: class inheritance

2010-03-16 Thread JLundell
On Mar 16, 8:06 am, Robert Kern wrote: > On 2010-03-16 07:35 AM, Dave Angel wrote: > > > > > > > > > Carl Banks wrote: > >> On Mar 15, 4:34 pm, JLundell wrote: > >>> It's also unfortunate that Python doesn't have an approximately-equal > >>> operator; it'd come in handy for floating-point applica

Re: passing a socket to a subprocess in windows

2010-03-16 Thread Gabriel Genellina
En Tue, 16 Mar 2010 14:10:16 -0300, Daniel Platz escribió: I have a problem with passing a socket to a subprocess in windows. It works in Linux and for windows there is a workaround in the Python doc. However, this workaround does not work. It was already noted by other people and they Python

Re: import antigravity

2010-03-16 Thread Mark Lawrence
Hans Mulder wrote: Ulrich Eckhardt wrote: Chris Rebert wrote: You're a bit behind the times. If my calculations are right, that comic is over 2 years old. import timetravel I think you mean: from __future__ import timetravel -- HansM Taking 1984 into account surely it should be fr

Re: subtraction is giving me a syntax error

2010-03-16 Thread Benjamin Kaplan
On Tue, Mar 16, 2010 at 4:12 PM, Grant Edwards wrote: > On 2010-03-16, Vito 'ZeD' De Tullio wrote: > > Grant Edwards wrote: > > > >>> As for not being able to see the difference between a hyphen and an > >>> EN- dash, or minus sign, or whatever it is, yes but they are very > >>> similar looking g

Re: The first ASIC designed with MyHDL

2010-03-16 Thread Aahz
In article <4b9f7414$0$2887$ba620...@news.skynet.be>, Jan Decaluwe wrote: > >I am proud to report on the first ASIC product designed with MyHDL >(afaik). > >http://www.jandecaluwe.com/hdldesign/digmac.html Congrats! -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-16 Thread david jensen
>If Gerard's code works, I would consider it far superior to your code >here. Pythonic does not necessarily mean short and ugly yes, I agree... and in my script i'm using something very like Gerard's (thanks again, Gerard). I just posted the corrected version of nn's because the original solved o

Re: C-API PyObject_Call

2010-03-16 Thread Carl Banks
On Mar 16, 11:25 am, moerchendiser2k3 wrote: > Hi, currently I am not at home, I will post some stuff when I am back. > Just the note: I throw an exception with the C API. > > Looks like that > > PyObject *result = PyObject_Call(my_isntance, "", NULL); > if(result==NULL) > { >     PyErr_Print(); /

Re: to pass self or not to pass self

2010-03-16 Thread Jonathan Gardner
On Tue, Mar 16, 2010 at 2:04 AM, Bruno Desthuilliers wrote: > lallous a écrit : >> >> What is the difference between the reference in 'F' and 'func_tbl' ? > > Answer here: > > http://wiki.python.org/moin/FromFunctionToMethod > Among all the things in the Python language proper, this is probably t

Re: subtraction is giving me a syntax error

2010-03-16 Thread Grant Edwards
On 2010-03-16, Vito 'ZeD' De Tullio wrote: > Grant Edwards wrote: > >>> As for not being able to see the difference between a hyphen and an >>> EN- dash, or minus sign, or whatever it is, yes but they are very >>> similar looking glyphs in virtually ever modern font. It would take a >>> good eye t

Re: Python bindings tutorial

2010-03-16 Thread Terry Reedy
On 3/16/2010 3:12 PM, Gabriel Genellina wrote: En Tue, 16 Mar 2010 13:20:40 -0300, Johny escribió: Is there any tutorial how to write a bindings for a exe ( dos) program? I would like to run it from a Python directly ( using import command and a particular function from the binding) not using

Re: Understanding the CPython dict implementation

2010-03-16 Thread Terry Reedy
On 3/16/2010 7:46 AM, Steven D'Aprano wrote: On Sun, 14 Mar 2010 19:39:46 -0400, Terry Reedy wrote: I found this PyCon2010 presentation to be excellent: The Mighty Dictionary, Branden Craig Rhodes, 30 min. Sorry, http://pycon.blip.tv/file/3332763/ which plays fine in FF3.6 on windows http

Re: datetime string conversion error

2010-03-16 Thread MRAB
Jordan Apgar wrote: Hey all, I'm trying to convert a string to a date time object and all my fields convert except for month which seems to default to january. here's what I'm doing: date = "2010-03-16 14:46:38.409137" olddate = datetime.strptime(date,"%Y-%m-%j %H:%M:%S.%f") print date print o

Re: import antigravity

2010-03-16 Thread Martin P. Hellwig
On 03/16/10 19:30, Hans Mulder wrote: Ulrich Eckhardt wrote: Chris Rebert wrote: You're a bit behind the times. If my calculations are right, that comic is over 2 years old. import timetravel I think you mean: from __future__ import timetravel -- HansM Well according to Marty it is: fr

Re: import antigravity

2010-03-16 Thread Hans Mulder
Ulrich Eckhardt wrote: Chris Rebert wrote: You're a bit behind the times. If my calculations are right, that comic is over 2 years old. import timetravel I think you mean: from __future__ import timetravel -- HansM -- http://mail.python.org/mailman/listinfo/python-list

Re: subtraction is giving me a syntax error

2010-03-16 Thread Vito 'ZeD' De Tullio
Grant Edwards wrote: >> As for not being able to see the difference between a hyphen and an >> EN- dash, or minus sign, or whatever it is, yes but they are very >> similar looking glyphs in virtually ever modern font. It would take a >> good eye to see the difference between (say) ??? ??? and -. >

Re: datetime string conversion error

2010-03-16 Thread Jordan Apgar
On Mar 16, 3:07 pm, Christian Heimes wrote: > Jordan Apgar wrote: > > Hey all, > > I'm trying to convert a string to a date time object and all my fields > > convert except for month which seems to default to january. > > > here's what I'm doing: > > date = "2010-03-16 14:46:38.409137" > >  olddat

Re: Python bindings tutorial

2010-03-16 Thread Gabriel Genellina
En Tue, 16 Mar 2010 13:20:40 -0300, Johny escribió: Is there any tutorial how to write a bindings for a exe ( dos) program? I would like to run it from a Python directly ( using import command and a particular function from the binding) not using os.system command. Do you mean that you want

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-16 Thread Michael Torrie
david jensen wrote: > of course, changing nn's to: > def getOutcomes(myList=[2,5,8,3,5]): >low_id = int(myList[0]>myList[1]) >amountToShare = 2*myList[low_id] >remainder = myList[not low_id]-myList[low_id] >tail=list(myList[2:]) >outcomes = [[amountToShare*perc, remainder+amount

Re: datetime string conversion error

2010-03-16 Thread Christian Heimes
Jordan Apgar wrote: > Hey all, > I'm trying to convert a string to a date time object and all my fields > convert except for month which seems to default to january. > > here's what I'm doing: > date = "2010-03-16 14:46:38.409137" > olddate = datetime.strptime(date,"%Y-%m-%j %H:%M:%S.%f") > > pr

datetime string conversion error

2010-03-16 Thread Jordan Apgar
Hey all, I'm trying to convert a string to a date time object and all my fields convert except for month which seems to default to january. here's what I'm doing: date = "2010-03-16 14:46:38.409137" olddate = datetime.strptime(date,"%Y-%m-%j %H:%M:%S.%f") print date print olddate I get: 2010-03

Re: to pass self or not to pass self

2010-03-16 Thread Jason Tackaberry
On Tue, 2010-03-16 at 10:04 +0100, Bruno Desthuilliers wrote: > Answer here: > > http://wiki.python.org/moin/FromFunctionToMethod I have a sense I used to know this once upon a time, but the question came to my mind (possibly again) and I couldn't think of an answer: Why not create the bound met

Re: C-API PyObject_Call

2010-03-16 Thread moerchendiser2k3
Hi, currently I am not at home, I will post some stuff when I am back. Just the note: I throw an exception with the C API. Looks like that PyObject *result = PyObject_Call(my_isntance, "", NULL); if(result==NULL) { PyErr_Print(); //when this happens, the traceback is correct with information

Re: Python bindings tutorial

2010-03-16 Thread Joaquin Abian
On Mar 16, 5:20 pm, Johny wrote: > Is there any tutorial how to write a bindings for a exe ( dos) > program? > I would like to run it from a Python directly > ( using import command and a particular function from the binding) >  not using os.system command. > Thanks > L. subprocess ? -- http://m

Re: Python bindings tutorial

2010-03-16 Thread Joaquin Abian
On Mar 16, 5:20 pm, Johny wrote: > Is there any tutorial how to write a bindings for a exe ( dos) > program? > I would like to run it from a Python directly > ( using import command and a particular function from the binding) >  not using os.system command. > Thanks > L. subprocess ? -- http://m

Converting Python CGI to WSGI scripts

2010-03-16 Thread python
I have a few dozen simple Python CGI scripts. Are there any advantages or disadvantages to rewriting these CGI scripts as WSGI scripts? Apologies if my terminology is not correct ... when I say WSGI scripts I mean standalone scripts like the following simplified (as an example) template: import

passing a socket to a subprocess in windows

2010-03-16 Thread Daniel Platz
Hello! I have a problem with passing a socket to a subprocess in windows. It works in Linux and for windows there is a workaround in the Python doc. However, this workaround does not work. It was already noted by other people and they Python issue tracker http://bugs.python.org/issue5879

Re: C-API PyObject_Call

2010-03-16 Thread Steve Holden
moerchendiser2k3 wrote: > In one case I have to check the return value of PyObject_Call, and if > its not of the correct return value, > I throw an exception, but I just get a simple output: > > TypeError: Expected an instance of XYZ, no int. > > instead of > > Traceback (most called...) > TypeE

Re: equivalent of Ruby's Pathname?

2010-03-16 Thread Steve Holden
Phlip wrote: > Chris Rebert wrote: > >> The next closest thing would probably be the Python >> Cookbook:http://code.activestate.com/recipes/langs/python/ > > One thing I really like about ... my hacked version of path.py ... is > path.cd( lambda: ... ). It works great inside fabfile.py to > temp

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-16 Thread david jensen
of course, changing nn's to: def getOutcomes(myList=[2,5,8,3,5]): low_id = int(myList[0]>myList[1]) amountToShare = 2*myList[low_id] remainder = myList[not low_id]-myList[low_id] tail=list(myList[2:]) outcomes = [[amountToShare*perc, remainder+amountToShare*(1-perc)]+ tail for perc i

Re: extract occurrence of regular expression from elements of XML documents

2010-03-16 Thread Martin Schmidt
On Tue, Mar 16, 2010 at 11:56 AM, Martin Schmidt wrote: > Thanks, Stefan. > Actually I will have to run the searches I am interested in only a few > times and therefore will drop performance concerns. > > Thanks for len(text.split()) . > I will try it later. > > The text I am interested in is alwa

Re: How to add a library path to pythonpath ?

2010-03-16 Thread Steve Holden
Dave Angel wrote: > Barak, Ron wrote: >> >>> -Original Message- >>> From: Dave Angel [mailto:da...@ieee.org] >>> Sent: Tuesday, March 16, 2010 5:04 PM >>> To: Barak, Ron >>> Cc: Pablo Recio Quijano; python-list@python.org >>> Subject: RE: How to add a library path to pythonpath ? >>> >>>

Re: Dynamic Class Creation

2010-03-16 Thread Chris Rebert
On Tue, Mar 16, 2010 at 9:49 AM, Jack Diederich wrote: > On Tue, Mar 16, 2010 at 2:18 AM, Chris Rebert wrote: >> On Mon, Mar 15, 2010 at 11:01 PM, Josh English >> wrote: >>> What's the best way to create these helper methods? > > You can either define a catch-all __getattr__ method to look them

Re: Python-list Digest, Vol 78, Issue 161

2010-03-16 Thread Martin Schmidt
Thanks, Stefan. Actually I will have to run the searches I am interested in only a few times and therefore will drop performance concerns. Thanks for len(text.split()) . I will try it later. The text I am interested in is always in leaf elements. I have posted a concrete example incl. a represen

Re: Dynamic Class Creation

2010-03-16 Thread Jack Diederich
On Tue, Mar 16, 2010 at 2:18 AM, Chris Rebert wrote: > On Mon, Mar 15, 2010 at 11:01 PM, Josh English > wrote: >> I have a large program with lots of data stored in XML. I'm upgrading >> my GUI to use ObjectListView, but with my data in XML, I don't have >> regular objects to interact with the OL

Re: C-API PyObject_Call

2010-03-16 Thread moerchendiser2k3
In one case I have to check the return value of PyObject_Call, and if its not of the correct return value, I throw an exception, but I just get a simple output: TypeError: Expected an instance of XYZ, no int. instead of Traceback (most called...) TypeError: in line 3, file test.py: expected an i

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-16 Thread david jensen
Thanks Paul, but i don't immediately see how that helps (maybe I'm just being dense)... nn's solution, though i initially thought it worked, actually has a similar problem: intended: >>> print getOutcomes([3,4,5,5]) [[6, 1, 5, 5], [4.5, 2.5, 5, 5], [3, 4, 5, 5], [1.5, 5.5, 5, 5], [0, 7, 5, 5]] >>>

Re: web sound recording with python

2010-03-16 Thread S.Selvam
On Fri, Oct 9, 2009 at 1:10 PM, Michel Claveau - MVP wrote: > Hi! > > On windows, you can record sound who play on the local sound-card. > It is not really Python scripting, but Python can launch it. > Does python do not have support for voice recording ? -- Regards, S.Selvam " I am becaus

Python bindings tutorial

2010-03-16 Thread Johny
Is there any tutorial how to write a bindings for a exe ( dos) program? I would like to run it from a Python directly ( using import command and a particular function from the binding) not using os.system command. Thanks L. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to add a library path to pythonpath ?

2010-03-16 Thread Dave Angel
Barak, Ron wrote: -Original Message- From: Dave Angel [mailto:da...@ieee.org] Sent: Tuesday, March 16, 2010 5:04 PM To: Barak, Ron Cc: Pablo Recio Quijano; python-list@python.org Subject: RE: How to add a library path to pythonpath ? Barak, Ron wrote: Thanks for the suggestion

Re: C-API PyObject_Call

2010-03-16 Thread Stefan Behnel
moerchendiser2k3, 16.03.2010 12:52: i have a serious problem and I am looking for a solution. I pass an instance of a class from a file to PyObject_Call. When something fails, I get a full traceback. If it succeeds, I get the return value. Is it possible to get information from which line/file t

Re: C-API PyObject_Call

2010-03-16 Thread Stefan Behnel
moerchendiser2k3, 16.03.2010 17:08: But the stack is empty after PyObject_Call, isnt it? I think Steve was expecting that you wanted to debug into your program, step into the call, and find the line yourself. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: equivalent of Ruby's Pathname?

2010-03-16 Thread Phlip
Chris Rebert wrote: > The next closest thing would probably be the Python > Cookbook:http://code.activestate.com/recipes/langs/python/ One thing I really like about ... my hacked version of path.py ... is path.cd( lambda: ... ). It works great inside fabfile.py to temporarily switch to a differe

Re: C-API PyObject_Call

2010-03-16 Thread moerchendiser2k3
But the stack is empty after PyObject_Call, isnt it? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to add a library path to pythonpath ?

2010-03-16 Thread Christian Heimes
Steve Holden schrieb: > Barak, Ron wrote: >> Hi, >> >> I'm trying to add a library path to my pythonpath, but seems it is not >> accepted - >> >> On Windows DOS window: >> >> C:\>echo %PYTHONPATH% >> c:\views\cc_view\TS_svm_ts_tool\SVMInspector\lib\ >> > That looks like it should work. The only t

Re: affectation in if statement

2010-03-16 Thread samb
On Mar 16, 11:56 am, Jean-Michel Pichavant wrote: > samb wrote: > > Hi, > > > I've found a work around, inspired from Rob Williscroft : > > > class ReMatch(object): > >     """ > >         Object to be called : > >         1st time : do a regexp.match and return the answer (args: > > regexp, line)

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-16 Thread Paul Rubin
david jensen writes: > Obviously, i can just write the code again, in an else, switching > indices 0 and 1. Or, I could just have a test at the beginning, switch > them if they are in the order "big, small", and then switch them again > at the end in a list comprehension. Both ideas seem terribly

RE: How to add a library path to pythonpath ?

2010-03-16 Thread Barak, Ron
> -Original Message- > From: Dave Angel [mailto:da...@ieee.org] > Sent: Tuesday, March 16, 2010 5:04 PM > To: Barak, Ron > Cc: Pablo Recio Quijano; python-list@python.org > Subject: RE: How to add a library path to pythonpath ? > > > > Barak, Ron wrote: > > Thanks for the suggestion Pable

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-16 Thread david jensen
Thank you both very much! Yeah: it was a total brainfart on my part: nn's solution should have been obvious. As the general solution, i like your approach, Gerard, but I think I'll stick to nn's, the one i should have written. Again, thank you both! dmj -- http://mail.python.org/mailman/listin

Re: class inheritance

2010-03-16 Thread Robert Kern
On 2010-03-16 07:35 AM, Dave Angel wrote: Carl Banks wrote: On Mar 15, 4:34 pm, JLundell wrote: It's also unfortunate that Python doesn't have an approximately-equal operator; it'd come in handy for floating-point applications while preserving hash. If only there were a ~=r ≈ operator I coul

RE: How to add a library path to pythonpath ?

2010-03-16 Thread Dave Angel
Barak, Ron wrote: Thanks for the suggestion Pable. However, I really need the $PYTHONPATH to include this additional library, so all Python scripts could use it. In Windows I have defined PYTHONPATH as c:\views\cc_view\TS_svm_ts_tool\SVMInspector\lib\, and also in the Windows registry I ha

cycling through options

2010-03-16 Thread Dieter Faulbaum
Hello, is there a better way for cycling through all options than this: (options, args) = parser.parse_args() for opt in options.__dict__.keys(): print opt, ":", options.__dict__[opt] Thanks for any nicer solution -- Dieter Faulbaum -- http://mail.python.org/mailman/listinfo/python-li

Re: How to add a library path to pythonpath ?

2010-03-16 Thread Steve Holden
Barak, Ron wrote: > Hi, > > I'm trying to add a library path to my pythonpath, but seems it is not > accepted - > > On Windows DOS window: > > C:\>echo %PYTHONPATH% > c:\views\cc_view\TS_svm_ts_tool\SVMInspector\lib\ > That looks like it should work. The only thing I notice is that I don't hav

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-16 Thread Gerard Flanagan
david jensen wrote: ... and of course i screwed up my outcomes... that should read outcomes=[[4,3,8,3,5],[3,4,8,3,5],[2,5,8,3,5],[1,6,8,3,5],[0,7,8,3,5]] abstracting the given algorithm: def iterweights(N): d = 1.0/(N-1) for i in xrange(N): yield i*d, (N-1-i)*d def iterpart

RE: How to add a library path to pythonpath ?

2010-03-16 Thread Barak, Ron
Thanks for the suggestion Pable. However, I really need the $PYTHONPATH to include this additional library, so all Python scripts could use it. In Windows I have defined PYTHONPATH as c:\views\cc_view\TS_svm_ts_tool\SVMInspector\lib\, and also in the Windows registry I have HKEY_LOCAL_MACHINE

Re: C-API PyObject_Call

2010-03-16 Thread Steve Holden
moerchendiser2k3 wrote: > Hi, > > i have a serious problem and I am looking for a solution. I pass an > instance of a class from a file to PyObject_Call. When something > fails, I get a full traceback. If it succeeds, I get the return value. > > Is it possible to get information from which line/f

Re: subtraction is giving me a syntax error

2010-03-16 Thread Grant Edwards
On 2010-03-16, Steven D'Aprano wrote: >> Though it may not be Microsoft Word, I think I'd still maintain that >> an editor where you can't see a ctrl-Z or tell the difference between >> an ASCII minus and a windows-codepage-whatever isn't a very good >> programmer's editor. > > Regarding ctrl-Z (

Re: converting a timezone-less datetime to seconds since the epoch

2010-03-16 Thread Chris Rebert
On Tue, Mar 16, 2010 at 6:47 AM, Chris Withers wrote: > Hi All, > > We have a bunch of datetime objects that have tzinfo=None. > We want to turn them into float timestamps in seconds since the epoch. > > Here's the first attempt: > > import time > from datetime import datetime > from unittest impo

Re: what's the diffence between "RECENT" and "UNSEEN" in imaplib?

2010-03-16 Thread Chris Rebert
On Tue, Mar 16, 2010 at 5:53 AM, freakrobot wrote: > When I work with the imaplib, > there is a imap4.status(mailboxname, '(MESSAGES RECENT UNSEEN)') > function. > > So I really wonder what's the difference between RECENT and UNSEEN > conditions. > And what kind of messages belong to RECENT condit

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-16 Thread nn
david jensen wrote: > ... and of course i screwed up my outcomes... that should read > outcomes=[[4,3,8,3,5],[3,4,8,3,5],[2,5,8,3,5],[1,6,8,3,5],[0,7,8,3,5]] For starters: def getOutcomes(myList=[2,5,8,3,5]): low_id = int(myList[0]>myList[1]) amountToShare = 2*myList[low_id] remainder

converting a timezone-less datetime to seconds since the epoch

2010-03-16 Thread Chris Withers
Hi All, We have a bunch of datetime objects that have tzinfo=None. We want to turn them into float timestamps in seconds since the epoch. Here's the first attempt: import time from datetime import datetime from unittest import TestCase def timestamp(dttm): return time.mktime(dttm.timetuple

Re: Build Python with XCode

2010-03-16 Thread Kevin Walzer
On 3/15/10 11:15 PM, moerchendiser2k3 wrote: Hi, I would like to build Python with Xcode (but without the makefile). Does anyone know a link where I can get a real xcodeproj with the current Py2.x sources? Thanks in advance!! Bye, donnerCobra I don't think one exists--I build my Python on OS

Re: Searching for most pythonic/least stupid way to do something simple

2010-03-16 Thread david jensen
... and of course i screwed up my outcomes... that should read outcomes=[[4,3,8,3,5],[3,4,8,3,5],[2,5,8,3,5],[1,6,8,3,5],[0,7,8,3,5]] -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding the CPython dict implementation

2010-03-16 Thread Michiel Overtoom
On 16 Mar 2010, at 12:46 , Steven D'Aprano wrote: > On Sun, 14 Mar 2010 19:39:46 -0400, Terry Reedy wrote: > >> I found this PyCon2010 presentation to be excellent: The Mighty >> Dictionary, Branden Craig Rhodes, 30 min. >> http://pycon.blip.tv/file/3264041/ > > > Unfortunately, that clip seem

Searching for most pythonic/least stupid way to do something simple

2010-03-16 Thread david jensen
Hi all, This may be a complete brainfart, but it's been puzzling me for a day or two (!). Sorry for not describing "something" in the subject, but it's hard to describe succinctly: I have a short list of non-zero positive integers (say myList=[2,5,8,3,5]). I need to return five lists of non-negat

what's the diffence between "RECENT" and "UNSEEN" in imaplib?

2010-03-16 Thread freakrobot
When I work with the imaplib, there is a imap4.status(mailboxname, '(MESSAGES RECENT UNSEEN)') function. So I really wonder what's the difference between RECENT and UNSEEN conditions. And what kind of messages belong to RECENT condition? Thank you~ -- http://mail.python.org/mailman/listinfo/pytho

Re: class inheritance

2010-03-16 Thread Dave Angel
Carl Banks wrote: On Mar 15, 4:34 pm, JLundell wrote: It's also unfortunate that Python doesn't have an approximately-equal operator; it'd come in handy for floating-point applications while preserving hash. If only there were a ~=r ≈ operator I could overload. And ~ is unary, so no joy.

Re: How to add a library path to pythonpath ?

2010-03-16 Thread Pablo Recio Quijano
You have to add yout path to the list: import sys sys.path.append(your_path) Jus simple to add the element on the list :) 2010/3/16 Barak, Ron > Hi, > > I'm trying to add a library path to my pythonpath, but seems it is not > accepted - > > On Windows DOS window: > > C:\>echo %PYTHONPATH% > c

Re: import antigravity

2010-03-16 Thread Alf P. Steinbach
* Ulrich Eckhardt: Chris Rebert wrote: You're a bit behind the times. If my calculations are right, that comic is over 2 years old. import timetravel C:\test> python Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credi

How to add a library path to pythonpath ?

2010-03-16 Thread Barak, Ron
Hi, I'm trying to add a library path to my pythonpath, but seems it is not accepted - On Windows DOS window: C:\>echo %PYTHONPATH% c:\views\cc_view\TS_svm_ts_tool\SVMInspector\lib\ C:\>python -c "import sys ; print sys.path" ['', 'c:\\views\\cc_view\\TS_svm_ts_tool\\SVMInspector\\lib', 'C:\\WI

Re: import antigravity

2010-03-16 Thread Chris Rebert
On Tue, Mar 16, 2010 at 4:56 AM, Ulrich Eckhardt wrote: > Chris Rebert wrote: >> You're a bit behind the times. >> If my calculations are right, that comic is over 2 years old. > > import timetravel > > Uli So that's where Guido's been hiding his infamous time machine! Right in plain sight! It's

The first ASIC designed with MyHDL

2010-03-16 Thread Jan Decaluwe
I am proud to report on the first ASIC product designed with MyHDL (afaik). http://www.jandecaluwe.com/hdldesign/digmac.html -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com Analog design a

  1   2   >