Re: String concatenation vs. string formatting

2011-07-08 Thread Ian Kelly
On Sat, Jul 9, 2011 at 12:16 AM, Chris Angelico wrote: > Has the same optimization been implemented for Unicode? The page > doesn't mention Python 3 at all, and I would guess that the realloc > optimization would work fine for both types of string. Seems to be implemented for strs in 3.2, but not

Re: String concatenation vs. string formatting

2011-07-08 Thread Chris Angelico
On Sat, Jul 9, 2011 at 3:30 PM, Steven D'Aprano wrote: > It also doesn't generalise: only appends are optimized, not prepends. > > If you're interested in learning about the optimization: > > http://utcc.utoronto.ca/~cks/space/blog/python/ExaminingStringConcatOpt >From that page: "Also, this is o

Re: String concatenation vs. string formatting

2011-07-08 Thread Ian Kelly
On Fri, Jul 8, 2011 at 11:30 PM, Steven D'Aprano wrote: > Billy Mays wrote: > >> If it means anything, I think concatenation is faster. > > You are measuring the speed of an implementation-specific optimization. > You'll likely get *very* different results with Jython or IronPython, or > old versi

Re: String concatenation vs. string formatting

2011-07-08 Thread Steven D'Aprano
Billy Mays wrote: > If it means anything, I think concatenation is faster. You are measuring the speed of an implementation-specific optimization. You'll likely get *very* different results with Jython or IronPython, or old versions of CPython, or even if you use instance attributes instead of lo

Re: String concatenation vs. string formatting

2011-07-08 Thread Steven D'Aprano
Andrew Berg wrote: > Is it bad practice to use this >> logger.error(self.preset_file + ' could not be stored - ' + >> sys.exc_info()[1]) > Instead of this? >> logger.error('{file} could not be stored - >> {error}'.format(file=self.preset_file, error=sys.exc_info()[1])) > > > Other than the case

Re: Does hashlib support a file mode?

2011-07-08 Thread Steven D'Aprano
Phlip wrote: > On Jul 8, 12:42 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> Phlip wrote: >> >> I worded that poorly. None is (AFAIK) the only instance of NoneType, >> >> but I should've clarified the difference.> The is operator does not >> >> compare types, it compares instance

Re: Implicit initialization is EVIL!

2011-07-08 Thread Steven D'Aprano
rantingrick wrote: > On Jul 7, 8:25 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> rantingrick wrote: >> > On Jul 7, 12:34 am, Gregory Ewing wrote: >> >> The important thing is that it's okay for an app to stay >> >> alive until its *last* top level window is closed. >> >> I part

Re: CI and BDD with Python

2011-07-08 Thread Stefan Behnel
mark curphey, 09.07.2011 01:41: And for CI having been using Hudson for a while, any real advantages in a Python / Django world for adopting something native like Trac and one of the CI plugins like Bitten? I warmly recommend Jenkins (i.e. Hudson) for anything CI. It gives you tons of plugin

Re: String concatenation vs. string formatting

2011-07-08 Thread Thorsten Kampe
* John Gordon (Fri, 8 Jul 2011 20:23:52 + (UTC)) > I prefer this usage: > > logger.error('%s could not be stored - %s' % \ > (self.preset_file, sys.exc_info()[1])) The syntax for formatting logging messages according to the documentation is: Logger.error(msg, *args) NOT Logger.erro

Re: meaning of numpy.fft coefficients

2011-07-08 Thread Corey Richardson
Excerpts from Joey's message of Fri Jul 08 20:14:29 -0400 2011: > the list generated by numpy is of form [ a+bi, c+di, ...] > > could anybody tell me the meaning of the coefficients a and b? I am > very confused about fourier transform! > a+bi is a typical complex number. a is the real part, b i

meaning of numpy.fft coefficients

2011-07-08 Thread Joey
the list generated by numpy is of form [ a+bi, c+di, ...] could anybody tell me the meaning of the coefficients a and b? I am very confused about fourier transform! information provided by numpy reference says Ak = Sum of a[m] * exp{-2*pi * i * m * k / n} for m from 0 to n-1 Which part is a and

CI and BDD with Python

2011-07-08 Thread mark curphey
Moving to Python from Ruby, first time poster. Anyone any opinions (non-religious) on investing time in Lettuce (www.lettuce.it) or Freshen (https://github.com/rlisagor/freshen#readme) for their BDD ? And for CI having been using Hudson for a while, any real advantages in a Python / Django wo

Re: String concatenation vs. string formatting

2011-07-08 Thread Andrew Berg
On 2011.07.08 05:59 PM, Ben Finney wrote: > With the caveat that the formatting of that line should be using PEP 8 > indentation for clarity: PEP 8 isn't bad, but I don't agree with everything in it. Certain lines look good in chunks, some don't, at least to me. It's quite likely I'm going to be wr

Re: String concatenation vs. string formatting

2011-07-08 Thread Ben Finney
Ben Finney writes: > logger.error( > '{0} could not be stored - {1}'.format( > (self.preset_file, sys.exc_info()[1])) > > I usually prefer to use named placeholders instead of positional, but > this duplicates your original. Ah, I see that the OP *did* use named placeholders.

Re: String concatenation vs. string formatting

2011-07-08 Thread Dan Stromberg
On Fri, Jul 8, 2011 at 3:50 PM, Ben Finney wrote: > * The ‘%’ string formatting operator is superseded in current Python > versions by the more flexible ‘format’ method of string objects. > AFAIK, % formatting is the only kind of formatting that works portably across all of CPythons 2.5, 2.6, 2.

Re: String concatenation vs. string formatting

2011-07-08 Thread Ben Finney
Andrew Berg writes: > Is it bad practice to use this > > logger.error(self.preset_file + ' could not be stored - ' + > > sys.exc_info()[1]) This is not necessarily bad practice, but there are not many points in its favour. It's inflexible and makes the eventual formatting harder to discern. > I

Re: String concatenation vs. string formatting

2011-07-08 Thread Ben Finney
John Gordon writes: > I prefer this usage: > > logger.error('%s could not be stored - %s' % \ > (self.preset_file, sys.exc_info()[1])) That can be improved by learning two things: * The backslash-linebreak is ugly and fragile, and almost never needed, since Python knows to continue a st

Re: String concatenation vs. string formatting

2011-07-08 Thread Ian Kelly
On Fri, Jul 8, 2011 at 3:23 PM, Benjamin Kaplan wrote: > String formatting is the One Right Way here. It's fine to use string > concatenation for a few things, but the operation is O(n^2) because each > concat occurs one at a time: Python allocates space for a string the size of > the first 2 thin

Re: String concatenation vs. string formatting

2011-07-08 Thread Benjamin Kaplan
On Fri, Jul 8, 2011 at 1:18 PM, Andrew Berg wrote: > Is it bad practice to use this > > logger.error(self.preset_file + ' could not be stored - ' + > > sys.exc_info()[1]) > Instead of this? > > logger.error('{file} could not be stored - > > {error}'.format(file=self.preset_file, error=sys.exc_info

Re: String concatenation vs. string formatting

2011-07-08 Thread Billy Mays
On 07/08/2011 04:18 PM, Andrew Berg wrote: Is it bad practice to use this logger.error(self.preset_file + ' could not be stored - ' + sys.exc_info()[1]) Instead of this? logger.error('{file} could not be stored - {error}'.format(file=self.preset_file, error=sys.exc_info()[1])) Other than th

Re: String concatenation vs. string formatting

2011-07-08 Thread John Gordon
In Andrew Berg writes: > Is it bad practice to use this > > logger.error(self.preset_file + ' could not be stored - ' + > > sys.exc_info()[1]) > Instead of this? > > logger.error('{file} could not be stored - > > {error}'.format(file=self.preset_file, error=sys.exc_info()[1])) > Other than the

String concatenation vs. string formatting

2011-07-08 Thread Andrew Berg
Is it bad practice to use this > logger.error(self.preset_file + ' could not be stored - ' + > sys.exc_info()[1]) Instead of this? > logger.error('{file} could not be stored - > {error}'.format(file=self.preset_file, error=sys.exc_info()[1])) Other than the case where a variable isn't a string (f

ANN: psutil 0.3.0 released

2011-07-08 Thread Giampaolo Rodolà
Hi folks, I'm pleased to announce the 0.3.0 release of psutil: http://code.google.com/p/psutil === Major enhancements === * disk usage * mounted disk partitions * system per-cpu percentage utilization and times * per-process terminal * physical and virtual memory usage including percentage === N

Re: The end to all language wars and the great unity API to come!

2011-07-08 Thread Ian Kelly
On Fri, Jul 8, 2011 at 1:05 PM, sal migondis wrote: >> I believe... > > Shifting from 'belief' to 'believe', the latter having a considerably > wider semantic scope. Wider how? Would you care to give an example of something that is believed but is not a belief? -- http://mail.python.org/mailman

Re: The end to all language wars and the great unity API to come!

2011-07-08 Thread sal migondis
On Jul 6, 7:45 am, Steven D'Aprano wrote: > sal migondis wrote: > > How could a belief be wrong? > I believe... Shifting from 'belief' to 'believe', the latter having a considerably wider semantic scope. After that, anything goes.. naturally. > you are a small glass of beer. Are you *actually

Re: Implicit initialization is EVIL!

2011-07-08 Thread rantingrick
On Jul 7, 8:25 pm, Steven D'Aprano wrote: > rantingrick wrote: > > On Jul 7, 12:34 am, Gregory Ewing wrote: > >> The important thing is that it's okay for an app to stay > >> alive until its *last* top level window is closed. > > I partially disagree with Greg on this. This is not the only model:

ANN: ActivePython 2.5.6.10 is now available

2011-07-08 Thread Sridhar Ratnakumar
ActiveState is pleased to announce ActivePython 2.5.6.10, a complete, ready-to-install binary distribution of Python 2.5. http://www.activestate.com/activepython/downloads What's New in ActivePython-2.5.6.10 === New Features & Upgrades ---

ANN: ActivePython 2.6.7.20 is now available

2011-07-08 Thread Sridhar Ratnakumar
ActiveState is pleased to announce ActivePython 2.6.7.20, a complete, ready-to-install binary distribution of Python 2.6. http://www.activestate.com/activepython/downloads What's New in ActivePythonEE-2.6.7.20 = New Features & Upgrades

ANN: ActivePython 2.7.2.5 is now available

2011-07-08 Thread Sridhar Ratnakumar
ActiveState is pleased to announce ActivePython 2.7.2.5, a complete, ready-to-install binary distribution of Python 2.7. http://www.activestate.com/activepython/downloads What's New in ActivePython-2.7.2.5 == New Features & Upgrades --- -

Re: Finding duplicated photo

2011-07-08 Thread Dave Angel
On 01/-10/-28163 02:59 PM, TheSaint wrote: Hello, I came across the problem that Gwenview moves the photo from the camera memory by renaming them, but later I forgot which where moved. Then I tought about a small script in python, but I stumbled upon my ignorance on the way to do that. PIL can

Re: Finding duplicated photo

2011-07-08 Thread Dan Stromberg
On Fri, Jul 8, 2011 at 8:16 AM, Thomas Jollans wrote: > On 07/08/2011 01:29 PM, TheSaint wrote: > > Hello, > > > > I came across the problem that Gwenview moves the photo from the camera > > memory by renaming them, but later I forgot which where moved. > > Then I tought about a small script in p

Re: Finding duplicated photo

2011-07-08 Thread Thomas Jollans
On 07/08/2011 01:29 PM, TheSaint wrote: > Hello, > > I came across the problem that Gwenview moves the photo from the camera > memory by renaming them, but later I forgot which where moved. > Then I tought about a small script in python, but I stumbled upon my > ignorance on the way to do that.

Re: Python-list Digest, Vol 94, Issue 52

2011-07-08 Thread Thomas Jollans
On 07/08/2011 04:45 PM, Mapere Ali wrote: > Hi, > > I need help with a python script to monitor my wireless router > internet usage using a Mac address and then backup the report files on > the server. i would also like to create login access on the website to > have users checkout their bandwidth

Re: Python-list Digest, Vol 94, Issue 52

2011-07-08 Thread Mapere Ali
Hi, I need help with a python script to monitor my wireless router internet usage using a Mac address and then backup the report files on the server. i would also like to create login access on the website to have users checkout their bandwidth usage...Please help anyone I'm a newbie in Python..

Re: making socket.getaddrinfo use cached dns

2011-07-08 Thread high bandwidth
my /etc/resolv.conf says: # Dynamic resolv.conf(5) file for glibc resolver(3) generated by > resolvconf(8) > # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN > nameserver 127.0.0.1 > search Dynex > But getaddrinfo still takes a lot of time for repeated queries. After instal

Re: Finding duplicated photo

2011-07-08 Thread Billy Mays
On 07/08/2011 10:14 AM, TheSaint wrote: Billy Mays wrote: It worked surprisingly well even with just the 64bit hash it produces. I'd say that comparing 2 images reduced upto 32x32 bit seems too little to find if one of the 2 portrait has a smile referred to the other. I think it's about that

Re: Finding duplicated photo

2011-07-08 Thread TheSaint
Billy Mays wrote: > It worked surprisingly well even > with just the 64bit hash it produces. > I'd say that comparing 2 images reduced upto 32x32 bit seems too little to find if one of the 2 portrait has a smile referred to the other. I think it's about that mine and your suggestion are similar,

Re: Serial & reset of the device

2011-07-08 Thread Grant Edwards
On 2011-07-08, Tim Chase wrote: > On 07/08/2011 02:45 AM, Tim Roberts wrote: >> yorick wrote: >>> I'm trying to access a hardware board of my company through a serial >>> connection using a Python script and the pyserial module. >>> >>> The board to which I'm trying to connect works correctly wit

Re: Does hashlib support a file mode?

2011-07-08 Thread Phlip
On Jul 8, 12:42 am, Steven D'Aprano wrote: > Phlip wrote: > >> I worded that poorly. None is (AFAIK) the only instance of NoneType, but > >> I should've clarified the difference.> The is operator does not compare > >> types, it compares instances for identity. > > > None is typesafe, because it's

Re: Serial & reset of the device

2011-07-08 Thread Tim Chase
On 07/08/2011 02:45 AM, Tim Roberts wrote: yorick wrote: I'm trying to access a hardware board of my company through a serial connection using a Python script and the pyserial module. The board to which I'm trying to connect works correctly with serial as some other guys did some TCL scripts t

Re: Finding duplicated photo

2011-07-08 Thread Billy Mays
On 07/08/2011 07:29 AM, TheSaint wrote: Hello, I came across the problem that Gwenview moves the photo from the camera memory by renaming them, but later I forgot which where moved. Then I tought about a small script in python, but I stumbled upon my ignorance on the way to do that. PIL can fin

Finding duplicated photo

2011-07-08 Thread TheSaint
Hello, I came across the problem that Gwenview moves the photo from the camera memory by renaming them, but later I forgot which where moved. Then I tought about a small script in python, but I stumbled upon my ignorance on the way to do that. PIL can find similar pictures. I was thinking to re

Re: Implicit initialization is EVIL!

2011-07-08 Thread Andrew Berg
On 2011.07.07 12:29 PM, rantingrick wrote: > So you prefer to close a gazillion windows one by one? If so, why not > just code the GUI correctly from the start; by creating separate > transactions? Thereby reducing the number of windows a user must > juggle? FYI: You know the user complexity of a G

Python for science experiments

2011-07-08 Thread Ajith Kumar
Hello, Just posting a link of a project using Python for doing science experiments. with regards ajith -- Dr. Ajith Kumar B.P. Scientist SG Inter-University Accelerator Centre Aruna Asaf Ali Marg New Delhi 110067 www.iuac.res.in Ph: (off) 91 11 26893955 (Ext.230)

Re: Serial & reset of the device

2011-07-08 Thread Tim Roberts
yorick wrote: > >I'm trying to access a hardware board of my company through a serial >connection using a Python script and the pyserial module. > >I use Python 2.7.1 with Ubuntu 11.04 (pyserial is the package python- >serial with version 2.5.2, http://pyserial.sourceforge.net/pyserial_api.html).

Re: Does hashlib support a file mode?

2011-07-08 Thread Steven D'Aprano
Phlip wrote: >> I worded that poorly. None is (AFAIK) the only instance of NoneType, but >> I should've clarified the difference.> The is operator does not compare >> types, it compares instances for identity. > > None is typesafe, because it's strongly typed. Everything in Python is strongly ty

Re: Large number multiplication

2011-07-08 Thread Mark Dickinson
On Jul 7, 9:30 am, Ulrich Eckhardt wrote: > That said, I'm sure that the developers would accept a patch that switches > to a different algorithm if the numbers get large enough. I believe it > already doesn't use Karatsuba for small numbers that fit into registers, > too. I'm far from sure that