Re: xml-rpc

2010-03-16 Thread Gabriel Genellina
En Sun, 14 Mar 2010 05:14:49 -0300, ahmet erdinc yilmaz escribió: Recenetly we are developing a senior project and decide to use xmlrpclib. However I have some questions. In the documentation I could not find any clue about handling requests? Does the server handles each request in a separa

import antigravity

2010-03-16 Thread Lawrence D'Oliveiro
Subtle... -- http://mail.python.org/mailman/listinfo/python-list

affectation in if statement

2010-03-16 Thread samb
Hi, I'm trying to do something like : if m = re.match(r'define\s+(\S+)\s*{$', line): thing = m.group(1) elif m = re.match(r'include\s+(\S+)$', line): thing = m.group(1) else thing = "" But in fact I'm not allowed to affect a variable in "if" statement. My code should then look like :

Re: subtraction is giving me a syntax error

2010-03-16 Thread Steven D'Aprano
On Mon, 15 Mar 2010 22:56:19 +, Grant Edwards wrote: > On 2010-03-15, Steven D'Aprano > wrote: >> On Mon, 15 Mar 2010 18:09:29 +, Grant Edwards wrote: >> Delete the character between "y_diff" and "H" and replace it with a plain ASCII subtraction sign. >>> >>> I think somebody n

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

2010-03-16 Thread Stefan Behnel
Martin Schmidt, 15.03.2010 18:16: I have just started to use Python a few weeks ago and until last week I had no knowledge of XML. Obviously my programming knowledge is pretty basic. Now I would like to use Python in combination with ca. 2000 XML documents (about 30 kb each) to search for certain

Re: import antigravity

2010-03-16 Thread Chris Rebert
On Tue, Mar 16, 2010 at 12:40 AM, Lawrence D'Oliveiro wrote: > Subtle... You're a bit behind the times. If my calculations are right, that comic is over 2 years old. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: import antigravity

2010-03-16 Thread Stefan Behnel
Lawrence D'Oliveiro, 16.03.2010 08:40: Subtle... Absolutely. Python 2.4.6 (#2, Jan 21 2010, 23:45:25) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import antigravity Traceback (most recent call last): File "", line 1, in ? Imp

Re: affectation in if statement

2010-03-16 Thread Chris Rebert
On Tue, Mar 16, 2010 at 12:45 AM, samb wrote: > Hi, > > I'm trying to do something like : > > if m = re.match(r'define\s+(\S+)\s*{$', line): >    thing = m.group(1) > elif m = re.match(r'include\s+(\S+)$', line): >    thing = m.group(1) > else >    thing = "" > > But in fact I'm not allowed to aff

Re: affectation in if statement

2010-03-16 Thread Paul Rubin
samb writes: > or like : > > m = re.match(r'define\s+(\S+)\s*{$', line) > if m: > thing = m.group(1) > else: > m = re.match(r'include\s+(\S+)$', line) > if m: > thing = m.group(1) > else > thing = "" > > Which isn't nice neither because I'm going to have maybe 20 ma

Re: affectation in if statement

2010-03-16 Thread Gary Herron
samb wrote: Hi, I'm trying to do something like : if m = re.match(r'define\s+(\S+)\s*{$', line): thing = m.group(1) elif m = re.match(r'include\s+(\S+)$', line): thing = m.group(1) else thing = "" But in fact I'm not allowed to affect a variable in "if" statement. My code should th

Re: import antigravity

2010-03-16 Thread Chris Rebert
On Tue, Mar 16, 2010 at 12:51 AM, Stefan Behnel wrote: > Lawrence D'Oliveiro, 16.03.2010 08:40: >> >> Subtle... > > Absolutely. > >  Python 2.4.6 (#2, Jan 21 2010, 23:45:25) >  [GCC 4.4.1] on linux2 >  Type "help", "copyright", "credits" or "license" for more information. >  >>> import antigravity

Re: affectation in if statement

2010-03-16 Thread samb
Thanks for all those suggestions. They are good! 1) Let's suppose now that instead of just affecting "thing = m.group(1)", I need to do a piece of logic depending on which match I entered... 2) Concerning the suggestion : m = re.match(r'define\s+(\S+)\s*{$', line) if m: thing = m.group(1) m

Re: affectation in if statement

2010-03-16 Thread Chris Rebert
On Tue, Mar 16, 2010 at 1:37 AM, samb wrote: > Thanks for all those suggestions. > They are good! > 2) Concerning the suggestion : > m = re.match(r'define\s+(\S+)\s*{$', line) > if m: >    thing = m.group(1) > > m = re.match(r'include\s+(\S+)$', line) > if m: >    thing = m.group(1) > > #etc... >

Re: affectation in if statement

2010-03-16 Thread Rob Williscroft
samb wrote in news:5c361012-1f7b-487f-915b-0f564b238be3 @e1g2000yqh.googlegroups.com in comp.lang.python: > Thanks for all those suggestions. > They are good! > > 1) Let's suppose now that instead of just affecting "thing = > m.group(1)", I need to do a piece of logic depending on which match I >

Re: to pass self or not to pass self

2010-03-16 Thread Bruno Desthuilliers
lallous a écrit : Hello, Learning Python from the help file and online resources can leave one with many gaps. Can someone comment on the following: (snip code) Why in test1() when it uses the class variable func_tbl we still need to pass self, but in test2() we don't ? What is the differen

Re: affectation in if statement

2010-03-16 Thread samb
On Mar 16, 9:53 am, Chris Rebert wrote: > On Tue, Mar 16, 2010 at 1:37 AM, samb wrote: > > Thanks for all those suggestions. > > They are good! > > > 2) Concerning the suggestion : > > m = re.match(r'define\s+(\S+)\s*{$', line) > > if m: > >    thing = m.group(1) > > > m = re.match(r'include\s+(

Re: affectation in if statement

2010-03-16 Thread samb
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) 2nd time : return the previous result (args: prev) """ def __call__(self, rege

Re: affectation in if statement

2010-03-16 Thread Peter Otten
samb wrote: > 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) > 2nd time : return the previous result (args: prev) > """ >

Re: A tool for find dependencies relationships behind Python projects

2010-03-16 Thread Hellmut Weber
Am 24.02.2010 18:49, schrieb Victor Lin: On 2月23日, 上午12時32分, Hellmut Weber wrote: Hi Victor, I would be intereseted to use your tool ;-) My system is Sabayon-5.1 on Lenovo T61. Trying for the first time easy_install I get the following error: r...@sylvester ~ # easy_inst

Re: affectation in if statement

2010-03-16 Thread Bruno Desthuilliers
samb a écrit : 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) 2nd time : return the previous result (args: prev) """ def __

Re: affectation in if statement

2010-03-16 Thread Jean-Michel Pichavant
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) 2nd time : return the previous result (args: prev) """ def __cal

any python libraries for rendering open office spreadsheet to html

2010-03-16 Thread hackingKK
Hello, Is there a python library which can render ods to html. (I would even prefer javascript library to do this). The reason I am more interested in a python library is because, I am developing a web application in pylons. It is a financial software and initially on the desktop based client, I

Re: Understanding the CPython dict implementation

2010-03-16 Thread Steven D'Aprano
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 seems to be unwatchable, at least for me. It crashed the Netscape pl

C-API PyObject_Call

2010-03-16 Thread moerchendiser2k3
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/file the return value of PyObject_Call

Re: import antigravity

2010-03-16 Thread 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 Uli -- http://mail.python.org/mailman/listinfo/python-list

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

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

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 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

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: 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.

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

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

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

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: 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

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: 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

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: 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: 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: 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: 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: 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 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

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 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

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: 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: 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 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: 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: 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: 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: 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 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: 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: 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

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: 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

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: 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: 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: 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 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: 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: 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: 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: 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: 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

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

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

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

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: 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

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: 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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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

  1   2   >