Re: How to install libxml2-devel and libxslt-devel in Windows ?

2012-11-10 Thread Stefan Behnel
goldtech, 10.11.2012 18:12: > I have Windows XP and Python 2.7.x > > I download and install libxml2-python-2.7.7.win32-py2.7.exe, From > here: http://users.skynet.be/sbi/libxml-python/ > > This file has both libxml2 AND libxslt. > > But, I also need libxml2-devel and libxslt-devel for python 2.7

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Ian Kelly
On Sat, Nov 10, 2012 at 11:43 PM, Ian Kelly wrote: > Where I wrote "(0,0) is the origin" above I was not referring to a > point, not a tuple, but I can see how that was confusing. What I meant to say is I *was* referring to a point. Gah! -- http://mail.python.org/mailman/listinfo/python-list

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Ian Kelly
On Sat, Nov 10, 2012 at 7:53 PM, Roy Smith wrote: > In article , > Ian Kelly wrote: > >> On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote: >> > I would not assume that. The origin is a point, just like any other. >> > With a Line class, you could deem a zero-length line to be like a >> > z

Re: A gnarly little python loop

2012-11-10 Thread Steve Howell
On Nov 10, 2:58 pm, Roy Smith wrote: > I'm trying to pull down tweets with one of the many twitter APIs.  The > particular one I'm using (python-twitter), has a call: > > data = api.GetSearch(term="foo", page=page) > > The way it works, you start with page=1.  It returns a list of tweets. > If the

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Roy Smith
In article , Ian Kelly wrote: > On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote: > > I would not assume that. The origin is a point, just like any other. > > With a Line class, you could deem a zero-length line to be like a > > zero-element list, but Point(0,0) is more like the tuple (0,0

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 1:43 PM, Ian Kelly wrote: > On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote: >> I would not assume that. The origin is a point, just like any other. >> With a Line class, you could deem a zero-length line to be like a >> zero-element list, but Point(0,0) is more like

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Ian Kelly
On Sat, Nov 10, 2012 at 7:13 PM, Chris Angelico wrote: > I would not assume that. The origin is a point, just like any other. > With a Line class, you could deem a zero-length line to be like a > zero-element list, but Point(0,0) is more like the tuple (0,0) which > is definitely True. It's more

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 12:13 PM, Steven D'Aprano wrote: > Almost but not quite. I assume that, in a full Point class, you would > want Point(0, 0) to count as false in a boolean context. (A "falsey" > value, like None, [], 0.0, etc.) I would not assume that. The origin is a point, just like any

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Oscar Benjamin
On 10 November 2012 19:33, Jennie wrote: > What is the best solution to solve the following problem in Python 3.3? > > import math class Point: > ... def __init__(self, x=0, y=0): > ... self.x = x > ... self.y = y > ... def __sub__(self, other): > ... return Po

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Steven D'Aprano
On Sat, 10 Nov 2012 20:33:05 +0100, Jennie wrote: [...] > I propose three solutions. The first one: > > >>> class Point: > ... def __init__(self, x=0, y=0): > ... self.x = x > ... self.y = y > ... def __sub__(self, other): > ... return Point(self.x - other.x, self

Re: A gnarly little python loop

2012-11-10 Thread Steven D'Aprano
On Sat, 10 Nov 2012 17:58:14 -0500, Roy Smith wrote: > The way it works, you start with page=1. It returns a list of tweets. > If the list is empty, there are no more tweets. If the list is not > empty, you can try to get more tweets by asking for page=2, page=3, etc. > I've got: > > page =

Re: A gnarly little python loop

2012-11-10 Thread Ian Kelly
On Sat, Nov 10, 2012 at 3:58 PM, Roy Smith wrote: > I'm trying to pull down tweets with one of the many twitter APIs. The > particular one I'm using (python-twitter), has a call: > > data = api.GetSearch(term="foo", page=page) > > The way it works, you start with page=1. It returns a list of twe

A gnarly little python loop

2012-11-10 Thread Roy Smith
I'm trying to pull down tweets with one of the many twitter APIs. The particular one I'm using (python-twitter), has a call: data = api.GetSearch(term="foo", page=page) The way it works, you start with page=1. It returns a list of tweets. If the list is empty, there are no more tweets. If t

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Dave Angel
On 11/10/2012 03:51 PM, Jennie wrote: > On 11/10/2012 09:29 PM, Terry Reedy wrote: > >> On 11/10/2012 2:33 PM, Jennie wrote: >>> >>> I propose three solutions. The first one: >>> >>> >>> class Point: >>> ... def __init__(self, x=0, y=0): >>> ... self.x = x >>> ... self.y = y >>

Re: Py3k Signal Handling

2012-11-10 Thread Antoine Pitrou
Jonathan Hayward pobox.com> writes: > > What needs changing here and how should I change it so that handle_signal() > is called and then things keep on ticking? So that it is called when exactly? Your message isn't clear as to what isn't working for you. Regards Antoine. -- http://mail.pyt

Re: Format specification mini-language for list joining

2012-11-10 Thread Tobia Conforto
Kwpolska wrote: > > out = 'Temperatures: {0:", ":.1f} Celsius'.format(temps) > > [...] your format is cryptic. Thank you for your criticism, I'll think it over. The reason I find it readable (-enough) is because even without knowing what format language is supported by the temps object, you can

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Jennie
On 11/10/2012 09:29 PM, Terry Reedy wrote: On 11/10/2012 2:33 PM, Jennie wrote: I propose three solutions. The first one: >>> class Point: ... def __init__(self, x=0, y=0): ... self.x = x ... self.y = y ... def __sub__(self, other): ... return Point(self.x - o

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Terry Reedy
On 11/10/2012 2:33 PM, Jennie wrote: What is the best solution to solve the following problem in Python 3.3? import math >>> class Point: ... def __init__(self, x=0, y=0): ... self.x = x ... self.y = y ... def __sub__(self, other): ... return Point(self.x - other

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 6:33 AM, Jennie wrote: > ... def distance(self, point=None): > ... p = point if point else Point() I'd go with this one. Definitely not the third one, which mutates the class according to a current global every time a Point is instantiated - could be *extremely

Method default argument whose type is the class not yet defined

2012-11-10 Thread Jennie
What is the best solution to solve the following problem in Python 3.3? import math >>> class Point: ... def __init__(self, x=0, y=0): ... self.x = x ... self.y = y ... def __sub__(self, other): ... return Point(self.x - other.x, self.y - other.y) ... def dista

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 12:15 AM, wrote: > Thanks to all. > Steve's example is the one I will try next week. > Passing in lists, will work but it requires extra coding from the calling > routines to build the list. Not necessarily! Watch: def foo(*args): print(repr(args)) foo("Hello","wor

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread bruceg113355
All, I never used decorators before. I saw Miki Tebeka's sample code and your rationale (Aahz) and I like it. For my application problem, decorators seem like a good solution. Thanks to all, Bruce On Saturday, November 10, 2012 10:35:12 AM UTC-5, Aahz wrote: > In article , > > Peter Otten

How to install libxml2-devel and libxslt-devel in Windows ?

2012-11-10 Thread goldtech
Hi, I have Windows XP and Python 2.7.x I download and install libxml2-python-2.7.7.win32-py2.7.exe, From here: http://users.skynet.be/sbi/libxml-python/ This file has both libxml2 AND libxslt. But, I also need libxml2-devel and libxslt-devel for python 2.7. Are binaries for win32 available for

Re: Format specification mini-language for list joining

2012-11-10 Thread Kwpolska
On Sat, Nov 10, 2012 at 5:51 PM, Paul Rubin wrote: > […] Python's format strings are pretty much the same as C's format strings […] You’re thinking about the old % syntax, 'Hello %s!' % 'world'. The OP meant the new str.format syntax ('Hello {}!'.format('world')). --- IMO, the idea is useless.

Re: Format specification mini-language for list joining

2012-11-10 Thread Steven D'Aprano
On Sat, 10 Nov 2012 02:26:28 -0800, Tobia Conforto wrote: > Hello > > Lately I have been writing a lot of list join() operations variously > including (and included in) string format() operations. > > For example: > > temps = [24.369, 24.550, 26.807, 27.531, 28.752] > > out = 'Temperatures

Re: Format specification mini-language for list joining

2012-11-10 Thread Paul Rubin
Tobia Conforto writes: > Now, as much as I appreciate the heritage of Lisp, I won't deny than > its format string mini-language is EVIL. ... Still, this is the > grand^n-father of Python's format strings... Without having yet read the rest of your post carefully, I wonder the particular historica

Re: Python3.3 str() bug?

2012-11-10 Thread Oscar Benjamin
On 9 November 2012 11:08, Helmut Jarausch wrote: > On Fri, 09 Nov 2012 10:37:11 +0100, Stefan Behnel wrote: > >> Helmut Jarausch, 09.11.2012 10:18: >>> probably I'm missing something. >>> >>> Using str(Arg) works just fine if Arg is a list. >>> But >>> str([],encoding='latin-1') >>> >>> gives

Re: Single leading dash in member variable names?

2012-11-10 Thread Aahz
In article , Ian Kelly wrote: >On Tue, Sep 11, 2012 at 12:45 PM, wrote: >> >> Python noob here. Trying to understand a particular syntax: >> >> class stuff: >> def __init__(self): >> self._bongo = "BongoWorld" >> >> What is the significance of the leading underscore in "self._bong

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread Aahz
In article , Peter Otten <__pete...@web.de> wrote: >Miki Tebeka wrote: > >>> Is there a simpler way to modify all arguments in a function before using >>> the arguments? >> >> You can use a decorator: >> >> from functools import wraps >> >> def fix_args(fn): >> @wraps(fn) >> def wrapper(

Re: How to print python commands automatically?

2012-11-10 Thread rusi
On Nov 9, 10:41 pm, Peng Yu wrote: > I have to explicitly specify the modules I want to ignore. Is there a > way to ignore all the modules by default? Is this your problem? http://bugs.python.org/issue10685 -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread bruceg113355
On Friday, November 9, 2012 8:16:12 PM UTC-5, Steven D'Aprano wrote: > On Fri, 09 Nov 2012 20:05:26 -0500, Roy Smith wrote: > > > > > In article <18134e77-9b02-4aec-afb0-794ed900d...@googlegroups.com>, > > > bruceg113...@gmail.com wrote: > > > > > >> Is there a simpler way to modify all arg

Re: Numpy combine channels

2012-11-10 Thread Dave Angel
On 11/09/2012 11:30 PM, Aahz wrote: > In article , > MRAB wrote: >> >> >> But should they be added together to make mono? >> >> Suppose, for example, that both channels have a maximum value. Their >> sum would be _twice_ the maximum. >> >> Therefore, I think that it should probably be the averag

Format specification mini-language for list joining

2012-11-10 Thread Tobia Conforto
Hello Lately I have been writing a lot of list join() operations variously including (and included in) string format() operations. For example: temps = [24.369, 24.550, 26.807, 27.531, 28.752] out = 'Temperatures: {0} Celsius'.format( ', '.join('{0:.1f}'.format(t) for t in temp

Re: Printing characters outside of the ASCII range

2012-11-10 Thread wxjmfauth
Le vendredi 9 novembre 2012 18:17:54 UTC+1, danielk a écrit : > I'm converting an application to Python 3. The app works fine on Python 2. > > > > Simply put, this simple one-liner: > > > > print(chr(254)) > > > > errors out with: > > > > Traceback (most recent call last): > > File "

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread Chris Angelico
On Sat, Nov 10, 2012 at 3:05 PM, Paul Rubin wrote: > Chris Angelico writes: >> Contrived example: >> def send_email(from, to, subj, body, whatever, other, headers, you, like): > > That should be a dictionary with the header names as indexes. In fact > there are already some email handling module

Re: Want to add dictionary keys to namespace?

2012-11-10 Thread Peter Otten
Jeff Jeffries wrote: > Smart people, Is there a way I can add a dictionaries keys to the python > namespace? It would just be temporary as I am working with a large > dictionary, and it would speed up work using an IDE. I look and find > nothing... none of the keys have spaces and none are common

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread Peter Otten
Miki Tebeka wrote: >> Is there a simpler way to modify all arguments in a function before using >> the arguments? > You can use a decorator: > > from functools import wraps > > def fix_args(fn): > @wraps(fn) > def wrapper(*args): > args = (arg.replace('_', '') for arg in args) >