Re: Listen for changes in variable (alsaaudio.Mixer(x, x).getvolume(x)

2012-10-24 Thread Tim Roberts
Muffinman wrote: > >I'm new to Python (running 2.6.6 but if necessary 3.x should also be >fine). I have a little idea I hope to accomplish with Python. I want to >listen for changes in Alsa sound volume level and base some actions on >that. With the few lines below I can check the current volume l

[OT] Re: turn list of letters into an array of integers

2012-10-24 Thread Peter Otten
Dennis Lee Bieber wrote: > On Wed, 24 Oct 2012 11:04:38 +0200, Peter Otten <__pete...@web.de> > declaimed the following in gmane.comp.python.general: > >> Peter Otten wrote: >> >> Brave new words: >> >> > immortable >> >> should be "immortal" > > Readlines() isn't immortal... It's a lich > ht

Re: turn list of letters into an array of integers

2012-10-24 Thread Chris Rebert
On Wed, Oct 24, 2012 at 9:27 PM, seektime wrote: > On Tuesday, October 23, 2012 11:07:29 PM UTC-7, Chris Rebert wrote: >> P.S.: I'm guessing you obtained `L` from file.readlines() or similar; >> it is worth noting for future reference that the readlines() method is >> considered somewhat deprecat

Re: while expression feature proposal

2012-10-24 Thread Terry Reedy
On 10/24/2012 7:19 PM, Evan Driscoll wrote: On 10/24/2012 05:26 PM, Cameron Simpson wrote: But I'm still -0 on it, because it supplants the glaringly obvious: m = ... assignment with the far less in your face: possibly-long-expr as m and I think it would get quite heavily used, to the

Re: turn list of letters into an array of integers

2012-10-24 Thread seektime
On Tuesday, October 23, 2012 11:07:29 PM UTC-7, Chris Rebert wrote: > On Tue, Oct 23, 2012 at 10:23 PM, seektime wrote: > > > Here's some example code. The input is a list which is a "matrix" of > > letters: > > >a b a > > >b b a > > > > > > and I'd like to turn this into a Pytho

Re: simple string format question

2012-10-24 Thread Piet van Oostrum
Adrien writes: > print "{:.3g}".format(2.356) # this rounds up But: >>> print "{:.3g}".format(12.356) 12.4 >>> print "{:.3g}".format(123.356) 123 -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list

Re: Listen for changes in variable (alsaaudio.Mixer(x, x).getvolume(x)

2012-10-24 Thread David Hutto
On Wed, Oct 24, 2012 at 2:55 PM, Muffinman wrote: > Hello all, > > I'm new to Python (running 2.6.6 but if necessary 3.x should also be > fine). I have a little idea I hope to accomplish with Python. I want to > listen for changes in Alsa sound volume level and base some actions on > that. With th

Re: Listen for changes in variable (alsaaudio.Mixer(x, x).getvolume(x)

2012-10-24 Thread David Hutto
On Wed, Oct 24, 2012 at 2:55 PM, Muffinman wrote: > Hello all, > > I'm new to Python (running 2.6.6 but if necessary 3.x should also be > fine). I have a little idea I hope to accomplish with Python. I want to > listen for changes in Alsa sound volume level and base some actions on > that. With t

Re: resume execution after catching with an excepthook?

2012-10-24 Thread Steven D'Aprano
On Wed, 24 Oct 2012 13:51:30 +0100, andrea crotti wrote: > So I would like to be able to ask for confirmation when I receive a C-c, > and continue if the answer is "N/n". I don't think there is any way to do this directly. Without a try...except block, execution will cease after an exception is

Re: while expression feature proposal

2012-10-24 Thread Ian Kelly
On Wed, Oct 24, 2012 at 5:08 PM, Paul Rubin wrote: > from itertools import dropwhile > > j = dropwhile(lambda j: j in selected, > iter(lambda: int(random() * n), object())) > .next() > > kind of ugly, makes me wish for a few more itertools primitives, but I > think it

Re: Re: while expression feature proposal

2012-10-24 Thread Evan Driscoll
On 10/24/2012 05:26 PM, Cameron Simpson wrote: > But I'm still -0 on it, because it supplants the glaringly obvious: > > m = ... > > assignment with the far less in your face: > > possibly-long-expr as m > > and I think it would get quite heavily used, to the detriment of > assignment reada

Re: while expression feature proposal

2012-10-24 Thread Paul Rubin
Ian Kelly writes: > j = int(random() * n) > while j in selected: > j = int(random() * n) from itertools import dropwhile j = dropwhile(lambda j: j in selected, iter(lambda: int(random() * n), object())) .next() kind of ugly, makes me wish for a few more itertoo

Re: Listen for changes in variable (alsaaudio.Mixer(x,x).getvolume(x)

2012-10-24 Thread Steven D'Aprano
On Wed, 24 Oct 2012 20:55:35 +0200, Muffinman wrote: > Hello all, > > I'm new to Python (running 2.6.6 but if necessary 3.x should also be > fine). I have a little idea I hope to accomplish with Python. I want to > listen for changes in Alsa sound volume level and base some actions on > that. Wit

Re: while expression feature proposal

2012-10-24 Thread Cameron Simpson
On 24Oct2012 15:37, Paul Rubin wrote: | Cameron Simpson writes: | > if re_FUNKYPATTERN.match(test_string) as m: | > do stuff with the results of the match, using "m" | | class memo: | def __call__(f, *args, **kw): | self.result = f(*args, **kw) | | m = memo() | if resul

Re: while expression feature proposal

2012-10-24 Thread Cameron Simpson
On 25Oct2012 09:40, Chris Angelico wrote: | On Thu, Oct 25, 2012 at 9:26 AM, Cameron Simpson wrote: | > If I could write this as: | > | > if re_FUNKYPATTERN.match(test_string) as m: | > do stuff with the results of the match, using "m" | | Then you'd be right there with C-like languages wh

Re: while expression feature proposal

2012-10-24 Thread Ian Kelly
On Wed, Oct 24, 2012 at 3:54 PM, Tim Chase wrote: > It may be idiomatic, but that doesn't stop it from being pretty > ugly. I must say I really like the parity of Dan's > > while EXPR as VAR: > BLOCK > > proposal with the "with" statement. It also doesn't fall prey to > the "mistaken-assi

Re: while expression feature proposal

2012-10-24 Thread Tim Chase
On 10/24/12 17:26, Cameron Simpson wrote: > On 24Oct2012 16:54, Tim Chase wrote: > | On 10/24/12 16:34, Ian Kelly wrote: > | > The idiomatic way to do this is: > | > > | > while True: > | > VAR = EXPR > | > if not VAR: > | > break > | > BLOCK > | > | It may be idiomatic, but

Re: while expression feature proposal

2012-10-24 Thread Paul Rubin
Paul Rubin writes: > class memo: > def __call__(f, *args, **kw): > self.result = f(*args, **kw) obviously add return self.result -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-24 Thread Chris Angelico
On Thu, Oct 25, 2012 at 9:26 AM, Cameron Simpson wrote: > If I could write this as: > > if re_FUNKYPATTERN.match(test_string) as m: > do stuff with the results of the match, using "m" Then you'd be right there with C-like languages where assignment is an expression :) while (tok = strtok(b

Re: while expression feature proposal

2012-10-24 Thread Paul Rubin
Cameron Simpson writes: > if re_FUNKYPATTERN.match(test_string) as m: > do stuff with the results of the match, using "m" class memo: def __call__(f, *args, **kw): self.result = f(*args, **kw) m = memo() if result(re_FUNKYPATTERN.match, test_string): do stuff wit

Re: while expression feature proposal

2012-10-24 Thread Cameron Simpson
On 24Oct2012 16:54, Tim Chase wrote: | On 10/24/12 16:34, Ian Kelly wrote: | > On Wed, Oct 24, 2012 at 2:40 PM, Dan Loewenherz wrote: | >> So I'm sure a lot of you have run into the following pattern. I use it | >> all the time and it always has felt a bit awkward due to the duplicate | >> varia

Re: while expression feature proposal

2012-10-24 Thread Paul Rubin
Dan Loewenherz writes: > VAR = EXPR > while VAR: > BLOCK > VAR = EXPR for VAR in iter(lambda: EXPR, None): BLOCK where the termination sentinel might be False or '' or whatever instead of None. Of course if EXPR is a callable, there's no lambda. > while EXPR as VAR: > BLOCK Thi

Re: A lock that prioritizes acquire()s?

2012-10-24 Thread David M Chess
Lovely, thanks for the ideas! I remember considering having release() pick the next thread to notify, where all the waiters were sitting on separate Conditions or whatever; not sure why I didn't pursue it to the end. Probably distracted by something shiny; or insufficient brainpower. :) D

Re: while expression feature proposal

2012-10-24 Thread Tim Chase
On 10/24/12 16:34, Ian Kelly wrote: > On Wed, Oct 24, 2012 at 2:40 PM, Dan Loewenherz wrote: >> So I'm sure a lot of you have run into the following pattern. I use it >> all the time and it always has felt a bit awkward due to the duplicate >> variable assignment. >> >> VAR = EXPR >> while VAR: >>

Re: while expression feature proposal

2012-10-24 Thread Ian Kelly
On Wed, Oct 24, 2012 at 2:40 PM, Dan Loewenherz wrote: > So I'm sure a lot of you have run into the following pattern. I use it > all the time and it always has felt a bit awkward due to the duplicate > variable assignment. > > VAR = EXPR > while VAR: > BLOCK > VAR = EXPR The idiomatic wa

Re: A lock that prioritizes acquire()s?

2012-10-24 Thread Ian Kelly
On Wed, Oct 24, 2012 at 2:19 PM, Ian Kelly wrote: > I used a PriorityQueue and Conditions to get rid of the ugly while True loop. Same things, but with Events instead of Conditions. This is just a bit more readable. The PriorityQueue is also probably unnecessary, since it's always accessed with

while expression feature proposal

2012-10-24 Thread Dan Loewenherz
Hi all, This is my first post to this group--I'm not subscribed, so please CC me in responses. So I'm sure a lot of you have run into the following pattern. I use it all the time and it always has felt a bit awkward due to the duplicate variable assignment. VAR = EXPR while VAR: BLOCK VA

Re: A lock that prioritizes acquire()s?

2012-10-24 Thread Ian Kelly
On Wed, Oct 24, 2012 at 12:54 PM, David M Chess wrote: > Seeking any thoughts on other/better ways to do this, or whether the > inefficiency will be too eyerolling if we get say one request per second > with an average service time a bit under a second but maximum service time > well over a second

Re: A lock that prioritizes acquire()s?

2012-10-24 Thread MRAB
On 2012-10-24 19:54, David M Chess wrote: Okay, next silly question. :) We have a very simple multi-threaded system where a request comes in, starts running in a thread, and then (zero, one, or two times per request) gets to a serialization point, where the code does: with lock: do_critical

[ANN] The Python Papers Anthology IndexCopernicus Value for 2011

2012-10-24 Thread mauricel...@acm.org
Dear all On behalf of the editorial committee of The Python Papers (overseeing The Python Papers, The Python Papers Monograph, and The Python Papers Source Codes), it is my pleasure to announce our first IndexCopernicus Value. Title ISSNINDEX COPERNICUS 2011 Th

Listen for changes in variable (alsaaudio.Mixer(x,x).getvolume(x)

2012-10-24 Thread Muffinman
Hello all, I'm new to Python (running 2.6.6 but if necessary 3.x should also be fine). I have a little idea I hope to accomplish with Python. I want to listen for changes in Alsa sound volume level and base some actions on that. With the few lines below I can check the current volume level. Can I

A lock that prioritizes acquire()s?

2012-10-24 Thread David M Chess
Okay, next silly question. :) We have a very simple multi-threaded system where a request comes in, starts running in a thread, and then (zero, one, or two times per request) gets to a serialization point, where the code does: with lock: do_critical_section_stuff_that_might_take_awhile()

Re: turn list of letters into an array of integers

2012-10-24 Thread Demian Brecht
On 2012-10-24, at 10:27 AM, wxjmfa...@gmail.com wrote: > Not so sure what you mean by an "array of integers". I wasn't entirely sure about that either. I assumed given the subject that it was just a 1-D array and could then be accessed by arr[(y * width) + x]. Demian Brecht @demianbrecht http:

Re: turn list of letters into an array of integers

2012-10-24 Thread wxjmfauth
Le mercredi 24 octobre 2012 07:23:11 UTC+2, seektime a écrit : > Here's some example code. The input is a list which is a "matrix" of letters: > >a b a > >b b a > > > > and I'd like to turn this into a Python array: > > > > 1 2 1 > > 2 2 1 > > > > so 1 replaces a, and 2

Re: turn list of letters into an array of integers

2012-10-24 Thread MRAB
On 2012-10-24 07:07, Chris Rebert wrote: On Tue, Oct 23, 2012 at 10:23 PM, seektime wrote: Here's some example code. The input is a list which is a "matrix" of letters: a b a b b a and I'd like to turn this into a Python array: You mean a Python list. The datatype Python calls an `

Re: Getting a TimedRotatingFileHandler not to put two dates in the same file?

2012-10-24 Thread David M Chess
> w...@mac.com > Something like: > Does a log file exist? -> No -> First run; create log file & continue > | > Yes > | > Read backwards looking for date change, copy lines after change > to new file, delete from old file. Yep, I'm concluding that also. It just wasn

Re: Getting a TimedRotatingFileHandler not to put two dates in the same file?

2012-10-24 Thread wrw
On Oct 24, 2012, at 10:22 AM, David M Chess wrote: > >> This works great, splitting the log information across files by date, as > >> long as the process is actually up at midnight. > >> > >> But now the users have noticed that if the process isn't up at midnight, > >> they can end up with lin

Re: classes

2012-10-24 Thread Chris Angelico
On Thu, Oct 25, 2012 at 3:10 AM, Zero Piraeus wrote: > On 24 October 2012 11:18, Chris Angelico wrote: >> On Thu, Oct 25, 2012 at 2:14 AM, Zero Piraeus wrote: >>> [... on return values and side effects ...] >> >> Side point: It's not that it's *bad* code or even bad style; > > It's a matter of t

Re: classes

2012-10-24 Thread Zero Piraeus
: On 24 October 2012 11:18, Chris Angelico wrote: > On Thu, Oct 25, 2012 at 2:14 AM, Zero Piraeus wrote: >> [... on return values and side effects ...] > > Side point: It's not that it's *bad* code or even bad style; It's a matter of taste, sure, but especially for a beginner, it's easy to find

Re: classes

2012-10-24 Thread Terry Reedy
On 10/24/2012 8:11 AM, inshu chauhan wrote: I was just trying out a program for learning classes in python I think you should work through or reread the Tutorial, especially the chapters on functions and classes. You will also be slightly better off with Python 3, which only has one categor

Re: turn list of letters into an array of integers

2012-10-24 Thread Terry Reedy
On 10/24/2012 1:23 AM, seektime wrote: Here's some example code. The input is a list which is a "matrix" of letters: a b a b b a and I'd like to turn this into a Python array: 1 2 1 2 2 1 so 1 replaces a, and 2 replaces b. If you are going to replace single characters (lett

Re: Getting a TimedRotatingFileHandler not to put two dates in the same file?

2012-10-24 Thread Vinay Sajip
David M Chess us.ibm.com> writes: > >> But now the users have noticed that if the process isn't up at > midnight, > >> they can end up with lines from two (or I guess potentially more) > dates in > >> the same log file. > >> > >> Is there some way to fix this, either with cleverer arguments > i

Re: classes

2012-10-24 Thread Chris Angelico
On Thu, Oct 25, 2012 at 2:14 AM, Zero Piraeus wrote: > By the way ... while Bag.addtwice() is legal Python [and I understand > that you're just playing around here], a method that both "does > something" [changes the object] and "gives something" [returns a > useful value] when that's not strictly

Re: Fast forward-backward (write-read)

2012-10-24 Thread rusi
On Oct 23, 7:52 pm, Virgil Stokes wrote: > I am working with some rather large data files (>100GB) that contain time > series > data. The data (t_k,y(t_k)), k = 0,1,...,N are stored in ASCII format. I > perform > various types of processing on these data (e.g. moving median, moving average, > an

Re: classes

2012-10-24 Thread Zero Piraeus
: On 24 October 2012 09:02, inshu chauhan wrote: > I changed the programme to this : > class Bag: > def __init__(self): > > self.data = [] > > def add(self, x): > self.data.append(x) > def addtwice(self, x): > self.add(x) > self.add(x) > retu

Re: Fast forward-backward (write-read)

2012-10-24 Thread Paul Rubin
Emile van Sebille writes: >> probably somewhere close to 400-500Gb in memory > I went looking for a machine capable of this and got about halfway > there with http://www.tech-news.com/publib/pl2818.html which allows up > to 248Gb memory -- near as I can tell the price for the maxed out > syste

Re: Appending a list using list obtained from a class

2012-10-24 Thread Demian Brecht
On 2012-10-24, at 8:00 AM, inshu chauhan wrote: > Yes, a Class method returns a list. I am trying to append this in main() to > make another list. > But the list i am getting after appending i showing addresses like this > '<__main__.Point object at 0x0254FAB0>' but if i print the same in the

Re: Appending a list using list obtained from a class

2012-10-24 Thread inshu chauhan
> the class is returning the list , and i want to append the list outside the class... main problem is this > > What do you mean "the class is returning the list"? Do you mean that a > class stores a list internally and you want to be able to mutate that list? > Do you mean that you have a class m

Re: Appending a list using list obtained from a class

2012-10-24 Thread Demian Brecht
On 2012-10-24, at 7:45 AM, inshu chauhan wrote: > the class is returning the list , and i want to append the list outside the > class... main problem is this What do you mean "the class is returning the list"? Do you mean that a class stores a list internally and you want to be able to mutate

Re: Appending a list using list obtained from a class

2012-10-24 Thread inshu chauhan
yes this i know very well.. but the problem is not so simple... the class is returning the list , and i want to append the list outside the class... main problem is this I know how to append a list with a list nd stuff.. On Wed, Oct 24, 2012 at 4:41 PM, Demian Brecht wrote: > > On 2012-10-24, a

Re: Appending a list using list obtained from a class

2012-10-24 Thread Demian Brecht
On 2012-10-24, at 7:37 AM, inshu chauhan wrote: > I am having a problem, > > I have a class which return me a list. I want to append another list using > this list outside the Class. > can i do it ? if yes how ? > And can i use Userlist function for this ?? > -- > http://mail.python.org/mai

Appending a list using list obtained from a class

2012-10-24 Thread inshu chauhan
I am having a problem, I have a class which return me a list. I want to append another list using this list outside the Class. can i do it ? if yes how ? And can i use Userlist function for this ?? -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting a TimedRotatingFileHandler not to put two dates in the same file?

2012-10-24 Thread David M Chess
> d...@davea.name > > On 10/23/2012 11:23 AM, David M Chess wrote: > > We have a TimedRotatingFileHandler with when='midnight' > > You give us no clue what's in this class, or how it comes up with the > filenames used. Sorry if I was unclear. This isn't my own subclass of TimedRotatingFileHandle

Re: Is there a way to programmatically turn on remote registry?

2012-10-24 Thread Tim Golden
On 24/10/2012 14:26, Kevin Holleran wrote: > On Wed, Oct 24, 2012 at 9:11 AM, Tim Golden Ok, try specifying the parameter names. (I remember someone having > problems before caused by mismatched param order): > > > > OK, tried that as well as specifying the parameters directly instead o

Re: classes

2012-10-24 Thread inshu chauhan
ok.. This was an example i was trying to run from http://docs.python.org/tutorial/classes.html ... On Wed, Oct 24, 2012 at 3:48 PM, Chris Angelico wrote: > On Thu, Oct 25, 2012 at 12:02 AM, inshu chauhan > wrote: > > I changed the programme to this : > > def addtwice(self, x): > >

Re: classes

2012-10-24 Thread Chris Angelico
On Thu, Oct 25, 2012 at 1:02 AM, inshu chauhan wrote: > ok.. This was an example i was trying to run from > http://docs.python.org/tutorial/classes.html ... I would strongly recommend going back a bit in the tutorial and reading about functions: http://docs.python.org/tutorial/controlflow.html

Re: Fast forward-backward (write-read)

2012-10-24 Thread Grant Edwards
On 2012-10-23, Steven D'Aprano wrote: > I would be very surprised if the poster will be able to fit 100 > gigabytes of data into even a single list comprehension, let alone > two. > > This is a classic example of why the old external processing > algorithms of the 1960s and 70s will never be obso

Re: classes

2012-10-24 Thread Chris Angelico
On Thu, Oct 25, 2012 at 12:02 AM, inshu chauhan wrote: > I changed the programme to this : > def addtwice(self, x): > self.add(x) > self.add(x) > return x > y = Bag() > print y.addtwice(4) > > Now its not showing any error but result is same as the number passed for

Re: Fast forward-backward (write-read)

2012-10-24 Thread Emile van Sebille
On 10/23/2012 4:35 PM, emile wrote: So, let's see, at that point in time (building backward) you've got probably somewhere close to 400-500Gb in memory. My guess -- probably not so fast. Thrashing is sure to be a factor on all but machines I'll never have a chance to work on. I went looking

Re: PIL and requests don't get along

2012-10-24 Thread Roy Smith
In article , Kushal Kumaran wrote: > On 23 Oct 2012 14:06:59 -0400, r...@panix.com (Roy Smith) wrote: > > I have a url from which I can get an image. I want to use PIL to > > manipulate that image. Getting the image is easy: > > > > >>> import requests > > >>> r = requests.get(url) > > > > T

Re: Is there a way to programmatically turn on remote registry?

2012-10-24 Thread Kevin Holleran
On Wed, Oct 24, 2012 at 9:11 AM, Tim Golden wrote: > On 24/10/2012 13:36, Kevin Holleran wrote: > > Here is the output as you requested. Again thanks for your time & help. > > I hate monopolizing one person's time so much > > Heh. Everyone else is welcome to chip in :) > > Ok, try specifyin

Re: Is there a way to programmatically turn on remote registry?

2012-10-24 Thread Tim Golden
On 24/10/2012 13:36, Kevin Holleran wrote: > Here is the output as you requested. Again thanks for your time & help. > I hate monopolizing one person's time so much Heh. Everyone else is welcome to chip in :) Ok, try specifying the parameter names. (I remember someone having problems before

Re: classes

2012-10-24 Thread Mark Lawrence
On 24/10/2012 13:48, inshu chauhan wrote: I was just trying out a programme for learning classes in python The prog below is showing an error which it should not show : class Bag: def __init__(self, x): self.data = [] You do nothing with x here. Right so x shouldnot be in th

Re: classes

2012-10-24 Thread inshu chauhan
I changed the programme to this : class Bag: def __init__(self): self.data = [] def add(self, x): self.data.append(x) def addtwice(self, x): self.add(x) self.add(x) return x y = Bag() print y.addtwice(4) Now its not showing any error but resu

resume execution after catching with an excepthook?

2012-10-24 Thread andrea crotti
So I would like to be able to ask for confirmation when I receive a C-c, and continue if the answer is "N/n". I'm already using an exception handler set with sys.excepthook, but I can't make it work with the confirm_exit, because it's going to quit in any case.. A possible solution would be to do

Re: classes

2012-10-24 Thread Dave Angel
On 10/24/2012 08:11 AM, inshu chauhan wrote: > I was just trying out a programme for learning classes in python > > The prog below is showing an error which it should not show : > > class Bag: > def __init__(self, x): > self.data = [] > > def add(self, x): > self.data.append

Re: classes

2012-10-24 Thread inshu chauhan
I was just trying out a programme for learning classes in python >> >> The prog below is showing an error which it should not show : >> >> class Bag: >> def __init__(self, x): >> self.data = [] >> > > You do nothing with x here. Right so x shouldnot be in the argument. > Fine *class

Re: classes

2012-10-24 Thread Chris Angelico
On Wed, Oct 24, 2012 at 11:11 PM, inshu chauhan wrote: > print " Adding twice of %4.2f gives " % (y.addtwice()) > > > Error is : > > Traceback (most recent call last): > File "Z:\learning Python\learn5.py", line 35, in > print " Adding twice of %4.2f gives " % (y.addtwice()) > TypeError: ad

Re: classes

2012-10-24 Thread Mark Lawrence
On 24/10/2012 13:11, inshu chauhan wrote: I was just trying out a programme for learning classes in python The prog below is showing an error which it should not show : class Bag: def __init__(self, x): self.data = [] You do nothing with x here. def add(self, x):

Re: Is there a way to programmatically turn on remote registry?

2012-10-24 Thread Kevin Holleran
On Wed, Oct 24, 2012 at 7:51 AM, Tim Golden wrote: > On 24/10/2012 12:40, Kevin Holleran wrote:> Here is the full traceback: > > > Could you confirm what version of Windows is running on the remote > machine? Also, could you show the output of the following, please: > > > import wmi > > host = "

Re: turn list of letters into an array of integers

2012-10-24 Thread Robert Kern
On 10/24/12 1:03 PM, 8 Dihedral wrote: The list in python is a list of valid python objects. For the number crunching part, please use arrays in numarray and scipy. Your bot's database is laughably out of date. -- Robert Kern "I have come to believe that the whole world is an enigma, a

Re: get each pair from a string.

2012-10-24 Thread Mark Lawrence
On 24/10/2012 10:32, wxjmfa...@gmail.com wrote: Le mardi 23 octobre 2012 18:41:45 UTC+2, Ian a écrit : On Tue, Oct 23, 2012 at 12:47 AM, wrote: In any case, have you been following the progress of issue 16061? There is a patch for the str.replace regression that you identified, which resu

classes

2012-10-24 Thread inshu chauhan
I was just trying out a programme for learning classes in python The prog below is showing an error which it should not show : class Bag: def __init__(self, x): self.data = [] def add(self, x): self.data.append(x) def addtwice(self, x): self.add(x) s

Re: turn list of letters into an array of integers

2012-10-24 Thread 88888 Dihedral
Chris Rebert於 2012年10月24日星期三UTC+8下午2時07分29秒寫道: > On Tue, Oct 23, 2012 at 10:23 PM, seektime wrote: > > > Here's some example code. The input is a list which is a "matrix" of > > letters: > > >a b a > > >b b a > > > > > > and I'd like to turn this into a Python array: > > > > Y

Re: Is there a way to programmatically turn on remote registry?

2012-10-24 Thread Tim Golden
On 24/10/2012 12:40, Kevin Holleran wrote:> Here is the full traceback: > > [output] > Scan_NIC_Driver_Info_1.2.py -i > testing_MSK_Server.csv -o MSK_Test_output.csv -u unreachable.csv > Parsing input file... > > Connecting to IP... > > Traceback (most recent ca

Re: Is there a way to programmatically turn on remote registry?

2012-10-24 Thread Kevin Holleran
On Tue, Oct 23, 2012 at 11:44 AM, Kevin Holleran wrote: > On Tue, Oct 23, 2012 at 11:39 AM, Tim Golden wrote: > >> On 23/10/2012 16:17, Kevin Holleran wrote: >> > I am still having a small implementation problem >> > >> > [code] >> > HKLM = winreg.HKEY_LOCAL_MACHINE >> > NICs = >> > >> "SYST

Re: Python input function not working in 2.7 version

2012-10-24 Thread Chris Angelico
On Wed, Oct 24, 2012 at 9:37 PM, Morten Engvoldsen wrote: > I am facing issue with input() of Python 2.7. When i run the program it > doesn't display any line to take user input . Below is the code: > > But the above print function doesn't display the out put in same way. I am > new to Python and

Python input function not working in 2.7 version

2012-10-24 Thread Morten Engvoldsen
Hi, I am facing issue with input() of Python 2.7. When i run the program it doesn't display any line to take user input . Below is the code: def user_input() fat_grams = input("How many grams of fat are in one serving? ") total_calories = input("How many total calories are in one serving? ")

[SOLVED] Re: Making `logging.basicConfig` log to *both* `sys.stderr` and `sys.stdout`?

2012-10-24 Thread Daniel Dehennin
Daniel Dehennin writes: > Hello, Hi [...] > I tried to setup the same for my scripts with > "logging.config.dictConfig()" without much success, I want to limit > output to stdout to INFO, everything bellow INFO should be sent to > stderr instead. > > Any hints? I finally find a solution for

Re: get each pair from a string.

2012-10-24 Thread wxjmfauth
Le mardi 23 octobre 2012 18:41:45 UTC+2, Ian a écrit : > On Tue, Oct 23, 2012 at 12:47 AM, wrote: > > > > In any case, have you been following the progress of issue 16061? > > There is a patch for the str.replace regression that you identified, > > which results in better performance across

Re: turn list of letters into an array of integers

2012-10-24 Thread Peter Otten
Peter Otten wrote: Brave new words: > immortable should be "immortal" -- http://mail.python.org/mailman/listinfo/python-list

Re: Split single file into multiple files based on patterns

2012-10-24 Thread Peter Otten
satyam wrote: > I have a text file like this > > A1980JE3937 2732 4195 12.527000 > A1980JE3937 3465 9720 22.00 > A1980JE3937 1853 3278 12.50 > A1980JE3937 2732 2732 187.50 > A1980JE3937 19 4688 3.619000 > A1980JE3937 2995 9720 6.667000 > A1980JE3937 1603 97

Re: Fast forward-backward (write-read)

2012-10-24 Thread Tim Golden
On 24/10/2012 08:07, Virgil Stokes wrote: > On 23-Oct-2012 22:03, Cousin Stanley wrote: >> Virgil Stokes wrote: >> >>> Not sure about "tac" --- could you provide more details on this >>> and/or a simple example of how it could be used for fast reversed >>> "reading" of a data file ? >>tac is av

Re: Fast forward-backward (write-read)

2012-10-24 Thread Steven D'Aprano
On Wed, 24 Oct 2012 01:23:58 -0400, Dennis Lee Bieber wrote: > On Tue, 23 Oct 2012 16:35:40 -0700, emile declaimed the > following in gmane.comp.python.general: > >> On 10/23/2012 04:19 PM, David Hutto wrote: >> > forward = [line.rstrip('\n') for line in f.readlines()] >> >> f.readlines() will

Re: Split single file into multiple files based on patterns

2012-10-24 Thread David Hutto
On Wed, Oct 24, 2012 at 3:52 AM, Steven D'Aprano wrote: > On Tue, 23 Oct 2012 20:01:03 -0700, satyam wrote: > >> I have a text file like this >> >> A1980JE3937 2732 4195 12.527000 > [...] > >> I want to split the file and get multiple files like A1980JE3937.txt >> and A1980KK18700010.txt,

Re: Split single file into multiple files based on patterns

2012-10-24 Thread Steven D'Aprano
On Tue, 23 Oct 2012 20:01:03 -0700, satyam wrote: > I have a text file like this > > A1980JE3937 2732 4195 12.527000 [...] > I want to split the file and get multiple files like A1980JE3937.txt > and A1980KK18700010.txt, where each file will contain column2, 3 and 4. Are you just excite

Re: turn list of letters into an array of integers

2012-10-24 Thread Peter Otten
Chris Rebert wrote: > line.strip().split() No need to strip() if you are going to split on whitespace: >>> line = " a b c \n" >>> line.split() == line.strip().split() True Lest the new idiom takes on while you are bravely fighting the immortable readlines() ;) -- http://mail.python.org/mailm

Re: Fast forward-backward (write-read)

2012-10-24 Thread Virgil Stokes
On 23-Oct-2012 22:03, Cousin Stanley wrote: Virgil Stokes wrote: Not sure about "tac" --- could you provide more details on this and/or a simple example of how it could be used for fast reversed "reading" of a data file ? tac is available as a command under linux $ whatis tac ta

Re: Fast forward-backward (write-read)

2012-10-24 Thread David Hutto
On Wed, Oct 24, 2012 at 3:17 AM, Virgil Stokes wrote: > On 24-Oct-2012 00:57, Demian Brecht wrote: >>> >>> This is a classic example of why the old external processing algorithms >>> of the 1960s and 70s will never be obsolete. No matter how much memory >>> you have, there will always be times whe

Re: Fast forward-backward (write-read)

2012-10-24 Thread David Hutto
On Wed, Oct 24, 2012 at 3:05 AM, Virgil Stokes wrote: > On 24-Oct-2012 00:36, David Hutto wrote: >>> >>> Don't forget to use timeit for an average OS utilization. >>> >>> I'd suggest two list comprehensions for now, until I've reviewed it some >>> more: >>> >>> forward = ["%i = %s" % (i,chr(i)) f

Re: Fast forward-backward (write-read)

2012-10-24 Thread Virgil Stokes
On 24-Oct-2012 00:53, Steven D'Aprano wrote: On Tue, 23 Oct 2012 17:50:55 -0400, David Hutto wrote: On Tue, Oct 23, 2012 at 10:31 AM, Virgil Stokes wrote: I am working with some rather large data files (>100GB) [...] Finally, to my question --- What is a fast way to write these variables to

Re: Fast forward-backward (write-read)

2012-10-24 Thread Virgil Stokes
On 24-Oct-2012 00:57, Demian Brecht wrote: This is a classic example of why the old external processing algorithms of the 1960s and 70s will never be obsolete. No matter how much memory you have, there will always be times when you want to process more data than you can fit into memory. But sur

Re: Fast forward-backward (write-read)

2012-10-24 Thread Virgil Stokes
On 24-Oct-2012 02:06, Oscar Benjamin wrote: On 23 October 2012 15:31, Virgil Stokes wrote: I am working with some rather large data files (>100GB) that contain time series data. The data (t_k,y(t_k)), k = 0,1,...,N are stored in ASCII format. I perform various types of processing on these data

Re: Fast forward-backward (write-read)

2012-10-24 Thread Virgil Stokes
On 24-Oct-2012 00:36, David Hutto wrote: Don't forget to use timeit for an average OS utilization. I'd suggest two list comprehensions for now, until I've reviewed it some more: forward = ["%i = %s" % (i,chr(i)) for i in range(33,126)] backward = ["%i = %s" % (i,chr(i)) for i in range(126,32,-