Re: [Tutor] Alternatives to append() for "growing" a list

2013-11-30 Thread Steven D'Aprano
On Sun, Dec 01, 2013 at 02:32:38PM +1000, Amit Saha wrote: > Hello, > > I was told by someone (as a comment) that a code snippet such as this > "would make Pythonistas talk my ear off about how evil the append()" > function is: There is absolutely nothing wrong with append. Either you have misun

Re: [Tutor] Alternatives to append() for "growing" a list

2013-11-30 Thread Dave Angel
On Sun, 1 Dec 2013 14:32:38 +1000, Amit Saha wrote: I was told by someone (as a comment) that a code snippet such as this "would make Pythonistas talk my ear off about how evil the append()" function is: >>> mylist = [] >>> mylist.append(1) Nothing evil about append. Many times the list

[Tutor] Alternatives to append() for "growing" a list

2013-11-30 Thread Amit Saha
Hello, I was told by someone (as a comment) that a code snippet such as this "would make Pythonistas talk my ear off about how evil the append()" function is: >>> mylist = [] >>> mylist.append(1) # a number of times over I have some ideas that on an append() the list's internal size increases (d

Re: [Tutor] Output not legible when debugging with ipdb

2013-11-30 Thread Peter Zorn
PyReadline is installed with the Anaconda distribution, and Powershell displays colored IPython output, but not when I use ipdb for whatever reason. I figured out that from IPython.core.debugger import Tracer; debug_here = Tracer() debug_here() seems to yield the desired result: a debugger wi

[Tutor] empty delimiters, and None

2013-11-30 Thread ugajin
Thanks for the helpful comments Eryksun/Steve Mis-configured environment (see below)? I rather felt that setting the 2nd parameter to None, was side stepping an underlying issue. However I experimented further and find; locale.setlocale(locale.LC_ALL, 'en_GB') also works OK. Perhaps this is a be

Re: [Tutor] empty delimiters, and None

2013-11-30 Thread spir
On 11/29/2013 02:19 PM, uga...@talktalk.net wrote: I have also looked at locale.py Line 494 of which is the last line of a def (def function?) I include this below, hopefully this may save you searching for locale.py (Pyhon 2.6) should you need it and wish to answer the above questions, it may

Re: [Tutor] empty delimiters, and None

2013-11-30 Thread eryksun
On Sat, Nov 30, 2013 at 7:04 AM, wrote: > believe the system locale is set correctly: > > Apples-iMac-4:~ apple$ locale > LANG="en_GB.UTF-8" Does `locale -a` report that en_US is available? > 127
6) Insert a new line before line 127 with this content: > export LANG="en_US.UTF-8" Did you try en

Re: [Tutor] strip and split?

2013-11-30 Thread eryksun
On Sat, Nov 30, 2013 at 1:40 PM, richard kappler wrote: > > > disk usage(total=302264549376, used=73844322304, free=213066088448, > percent=24.4) > > So if I want only the number following percent, I get that I need to convert > this to a built in type and do some split and strip, but that's where

Re: [Tutor] strip and split?

2013-11-30 Thread Don Jennings
On Nov 30, 2013, at 4:32 PM, Wolfgang Maier wrote: > richard kappler gmail.com> writes: > >> >> I'm using psutil to generate some somatic data with the following script: >> >> import psutil as ps >> >> cpu = ps.cpu_percent() >> mem = ps.virtual_memory() >> disk = ps.disk_usage('/') >> >> Al

Re: [Tutor] strip and split?

2013-11-30 Thread Don Jennings
On Nov 30, 2013, at 1:40 PM, richard kappler wrote: > I'm using psutil to generate some somatic data with the following script: > > import psutil as ps > > cpu = ps.cpu_percent() > mem = ps.virtual_memory() > disk = ps.disk_usage('/') > > All works well, but except for cpu I am struggling to l

Re: [Tutor] strip and split?

2013-11-30 Thread Wolfgang Maier
richard kappler gmail.com> writes: > > I'm using psutil to generate some somatic data with the following script: > > import psutil as ps > > cpu = ps.cpu_percent() > mem = ps.virtual_memory() > disk = ps.disk_usage('/') > > All works well, but except for cpu I am struggling to learn how to st

[Tutor] strip and split?

2013-11-30 Thread richard kappler
I'm using psutil to generate some somatic data with the following script: import psutil as ps cpu = ps.cpu_percent() mem = ps.virtual_memory() disk = ps.disk_usage('/') All works well, but except for cpu I am struggling to learn how to strip out what I don't need. For example, once I do the abo

Re: [Tutor] Pretty printing XML using LXML on Python3

2013-11-30 Thread Stefan Behnel
SM, 29.11.2013 22:21: > On Thu, Nov 28, 2013 at 2:45 PM, eryksun wrote: >> On Thu, Nov 28, 2013 at 2:12 PM, SM wrote: >>> Run with Python3: >>> >>> $ python3 testx.py >>> b'\n \n some text\n\n' >> >> print() first gets the object as a string. tostring() returns bytes, >> and bytes.__str__ returns