[Tutor] automatic output file naming scheme

2010-03-28 Thread kevin parks
okay. I got the subprocess bit to work and i have os walk doing its walk. But now for something i did not think about until i started to think about how to fit these two bits to work together. os walk is going to traverse my dirs from some given starting point and process files that it finds th

Re: [Tutor] subprocess

2010-03-27 Thread kevin parks
Thanks David. Those are excellent short clear examples. I will look those over. Super! Thanks for that. -kp On Mar 27, 2010, at 5:30 PM, David Abbott wrote: > On Sat, 2010-03-27 at 16:55 +0900, kevin parks wrote: > > Here is an example using subprocess.call > http://dwabbott.com

[Tutor] subprocess

2010-03-27 Thread kevin parks
I tried readings some toots and tried reading alan's thing. I just still can't grok how to use subprocess. I am trying to call sox (fun fact: an early contributer to sox was none other than Guido van Rossum) In the old days you would just use os i guess, like: import os os.system('sox -V3 -D -

Re: [Tutor] Bowing out

2010-03-03 Thread kevin parks
Dang! I wish you were not going. But really, I have to say a HUGE thank you to you for all the fine teaching you have done on this list. I learned so much from reading your posts. Thanks for all the time and effort (and code) you put into this! I wish you were staying. Hats off to you. Wi

[Tutor] batch file processing w/ python using cmd line executable?

2010-02-12 Thread kevin parks
hi I am new territory here and not even sure where to start poking around other than the os module some. Essentially i need to do something like a shell script for batch processing gobs of files. I am trying to use a command line tool (sox, an open source sound file converter that runs fr

Re: [Tutor] Automaton/transitional grammar query

2009-10-12 Thread kevin parks
On Oct 12, 2009, at 8:02 PM, Dave Angel wrote: Often, when a combination of existing stdlib collection types gets too confusing, it's time to consider classes and objects. Not necessarily to make the program "object oriented," but to make the program data structure understandable. That

Re: [Tutor] Automaton/transitional grammar query

2009-10-12 Thread kevin parks
> You might be interested in Steven Wolfram's book, "A New Kind of > Science" and the many examples on his web site: > http://www.wolframscience.com/ See Wikipedia as well. This is a very > rich area. Thanks. That was just the kind of reference I was looking for. Fantastic. I am sure i wont

[Tutor] Automaton/transitional grammar query

2009-10-12 Thread kevin parks
I posted about this a couple weeks back, but then got horribly ill and dropped the ball so i was hoping to revisit. I am not sure if this is and example of Finite Automaton or a Finite State Machine or perhaps it is related to a transition table or markov process. I think some one here told

Re: [Tutor] need help with conditionals

2009-09-26 Thread kevin parks
On Sep 26, 2009, at 11:42 PM, Alan Gauld wrote: "Kent Johnson" wrote It appears to be http://openbookproject.net/thinkCSpy/ch04.html So it is, Thats a shame CSpy is one of my favourite "competitors" :-) Pity it's apparently encouraging the use of eval like this with no caveat. But to

Re: [Tutor] What is this an example of (and how can i use it?)

2009-09-22 Thread kevin parks
On Sep 21, 2009, at 9:52 AM, Kent Johnson wrote: Calling a generator function gives you something that can be iterated. You can create a list out of it (by passing it to the list() function) or you can iterate the items in it directly with a for loop. Using the example above, you could say fo

Re: [Tutor] What is this an example of (and how can i use it?)

2009-09-20 Thread kevin parks
On Sep 21, 2009, at 1:32 AM, Alan Gauld wrote: kevin parks wrote: called, and what it is an example of. I guess there are generators and iterators now and it seems this might be an example of one of those new This is a generator expression. That's unfortunate news for me. It is

[Tutor] What is this an example of (and how can i use it?)

2009-09-20 Thread kevin parks
I am afraid that in the long layoff in python has meant some new constructs have passed me by. In googling around I found some nice little code I want to use, but i don't quite understand it, how it is called, and what it is an example of. I guess there are generators and iterators now and

Re: [Tutor] working with multiple sets

2009-09-09 Thread kevin parks
Are any of these methods better than another for some reason? On Sep 9, 2009, at 10:12 PM, Lie Ryan wrote: kevin parks wrote: This discussion is making my brain melt. It is also showing how clever Bob was to do it the way he did... I found a solution that i think works, and think has not

Re: [Tutor] mapping/filtering a sequence

2009-09-09 Thread kevin parks
Prolly good to post final solutions for future goog'lerz (like when i forget) or anyone who was following along. Here's where i ended up with this... shows both ways. -- #!/usr/bin/env python my_map = { 38:34, 40:39, 45:44, 47:46, 52:51, 59:58, 55:56 } def filter_item(item): retu

Re: [Tutor] working with multiple sets

2009-09-09 Thread kevin parks
This discussion is making my brain melt. It is also showing how clever Bob was to do it the way he did... I found a solution that i think works, and think has not yet been suggested. I quarantined Bob's code into a black box ... and then cast the output as a plain old fashioned python built

Re: [Tutor] working with multiple sets

2009-09-08 Thread kevin parks
I guess what i honestly want to asks, but am hesitant to since it makes me look like a dork is: What would this look like if i want to use a straight up built-in dictionary type and not the collections.defaultdict. import collections def foo(): lookup = collections.defaultdict(l

Re: [Tutor] working with multiple sets

2009-09-08 Thread kevin parks
or educational purposes. I am somewhat nervous about using something other than a built in type as i am not familiar with collections and it isn't well covered in beginner books or the docs. On Sep 9, 2009, at 12:44 AM, Kent Johnson wrote: On Tue, Sep 8, 2009 at 10:07 AM, kevin parks

Re: [Tutor] working with multiple sets

2009-09-08 Thread kevin parks
d it in all the wrong places. 0 ['x'] 1 ['x'] 2 ['x'] 3 ['x'] 4 ['x'] 5 ['y', 'x'] 6 ['y', 'x'] 7 ['y', 'x'] 8 ['y', 'x', 'z'] 9 ['y',

Re: [Tutor] working with multiple sets

2009-09-08 Thread kevin parks
I am looking at this and wondering: Why does this use collections.defaultdict ? In fact i guess since collections.defaultdict is new to me i am not even sure why it exists and why someone would use this as opposed to using Python's built-in dictionary? and why was it used in this instance

Re: [Tutor] mapping/filtering a sequence

2009-09-06 Thread kevin parks
I actually find the map biz easier to get my head around than the list comp. I guess this makes it another good reason for me to be happy that map is apparently staying in after nearly being depreciated. I generally prefer list comp in every instance, but the idea of an if else construct wi

Re: [Tutor] Help deciding between python and ruby

2009-09-06 Thread kevin parks
ore than one way of doing something). You mean people actually like ruby's syntax? I think Python's the prettiest language I've worked with syntactically. I wouldn't call having multiple ways to do something "flexible". I agree more with Python's philosophy,

Re: [Tutor] mapping/filtering a sequence

2009-09-05 Thread kevin parks
Yeah the list seems flaky at the moment. Additionally, my query is an incredibly stupid one. But what you have works and represents an improvement over the unreadable kludge I was doing. Thanks to all who responded. cheers, k On Sep 6, 2009, at 12:26 AM, Douglas Philips wrote: On or ab

Re: [Tutor] mapping/filtering a sequence

2009-09-05 Thread kevin parks
list just now. On Sep 5, 2009, at 11:47 PM, Wayne wrote: On Fri, Sep 4, 2009 at 12:31 PM, kevin parks wrote: I am doing some data massage, minor mapping and filtering really and i find that i have a lot of this kind of kludgy code: To do some basic jiggering of some out of range off gri

Re: [Tutor] Help deciding between python and ruby

2009-09-05 Thread kevin parks
1. go to the book store 2. pull a copy of learning ruby by Michael Fitzgerald (ora.com) 3. pull a copy of learning python by Mark Lutz (ora.com) 4. read chapter 1 of each 5. make a decision 6. get to work Alternately check comp.lang.python where this question comes up over and over and over a

[Tutor] working with multiple sets

2009-09-05 Thread kevin parks
I am doing some simple things with sets and so far have had a lot of success with python's built-in sets, which is such a great new(ish) "batteries included" type python data type. [snip] [snip] -- [snip] [snip] -- #!/usr/bin/env python def test(

[Tutor] mapping/filtering a sequence

2009-09-05 Thread kevin parks
I am doing some data massage, minor mapping and filtering really and i find that i have a lot of this kind of kludgy code: # -- - def filt_seq(inseq): out_list = [] for item in inseq: # 38 needs to be mapped on to 34 as we don't have a 38

Re: [Tutor] packing a list of lists

2009-08-28 Thread kevin parks
On Aug 29, 2009, at 12:23 AM, Michael M Mason wrote: i wrote: def pack(in_seq): out_list=[] x = 1 ll=[1, 1] for each in in_seq: ll[0] = x ll[1] = each out_list.append(ll) #print ll x

Re: [Tutor] packing a list of lists

2009-08-28 Thread kevin parks
Interestingly changing: out_list.append(ll) to out_list.append(list(ll)) seems to work. The part of my brain that understood why that is must have sleeping. -k On Aug 28, 2009, at 11:05 PM, i wrote: Back to python after a long long layoff. So i am running

Re: [Tutor] packing a list of lists

2009-08-28 Thread kevin parks
I think this is b/c I am running 2.5. I also have 2.6 but i am using 2.5 for gnupoly and an older audio lib i have. I ran the listcom below on 2.6 and it worked, so i just have to figure out how that can be written for 2.5. I guess 2.6 has an update to enumerate. -k On Aug 29, 2009, at 2:2

Re: [Tutor] packing a list of lists

2009-08-28 Thread kevin parks
Thanks for the replies. Though the list comprehension does not work: TypeError: enumerate() takes exactly 1 argument (2 given) On Aug 29, 2009, at 12:20 AM, vince spicer wrote: #print foohough I didn't test your code, I think what you are trying to accomplish can be done using enu

[Tutor] packing a list of lists

2009-08-28 Thread kevin parks
Back to python after a long long layoff. So i am running into some beginner's confusion... I am trying to plot a list of numbers in gnuplot.py. To do that I am trying to pack the list with an index by iterating over the list so i can get something like: foo = [12, 11, 9, 6, 2, 9, 3, 8, 12

[Tutor] Module imports

2007-07-11 Thread kevin parks
With sincere apologies for such a basic question, and one i will admit that i asked once before, moons ago. But even after googling around a bit i don't understand what the right answer is, or if i once did, can't recall it now.. I have a script, let's call it foo.py This script loads sever

[Tutor] time(duration) formats & basic time math query

2006-07-05 Thread kevin parks
I have been handed a huge number of documents which have hundreds of pages of times and durations, all calculated and notated by several different people over the course of many years. Sadly, no made any guidelines at all about how this work would proceed and all the documenters had their o

Re: [Tutor] how to *really* copy a list

2006-04-29 Thread kevin parks
Ed, I should have realized that the nesting would create the problem, but i didn't have that in mind... i always thought that the difference between extend and append was that extend did not yield a nested list. I really need to revisit this issue and get it right in my mind. It is a 'gotcha'

Re: [Tutor] how to *really* copy a list

2006-04-29 Thread kevin parks
John, Thanks. Your message was very helpful. I will tattoo it to my forehead. hehe... i notice that the "learning python" book also explains so of this and i shall study that as well cheers, kevin On Apr 27, 2006, at 10:14 PM, [EMAIL PROTECTED] wrote: > > On 28/04/06, kev

Re: [Tutor] cycle w/ shuffle

2006-04-29 Thread kevin parks
kevin-- On Apr 27, 2006, at 6:00 AM, [EMAIL PROTECTED] wrote: > kevin parks wrote: >> it seems to me that i need something like itertools cycle, except that >> i need to keep track of when i have exhausted my list and then call >> random.shuffle() on my sequence. >

Re: [Tutor] how to *really* copy a list

2006-04-27 Thread kevin parks
I know there is an answer to this somewhere. it is prolly the biggest stumbling block to all python n00bs, but it hasn't been an issue for me in a while. Suddenly i am getting bit by it and can't for the life of me keep straight the two way of opperating on lists. In most case you are fine

[Tutor] cycle w/ shuffle

2006-04-26 Thread kevin parks
I am trying to write a loop that iterates over a sequence and do something x number of times. But sometimes i will need more events (larger number x) than i have have items in the sequence, so if i need more events that i have stuff in my sequence i would like to have the loop reload and shuffl

Re: [Tutor] cycle w/ shuffle

2006-04-26 Thread kevin parks
I am trying to write a loop that iterates over a sequence and do something x number of times. But sometimes i will need more events (larger number x) than i have have items in the sequence, so if i need more events that i have stuff in my sequence i would like to have the loop reload and shuffl

Re: [Tutor] seq looping

2006-04-26 Thread kevin parks
Bob ... i used my kludge which defines some bounds and tests for it... but your idea of stuffing that into a seperate black box as golden in that it made me think of the problem as input --> doit --> result. and made my loops simpler and easier to read... and i use that same gap making typing

[Tutor] seq looping

2006-04-25 Thread kevin parks
I have a loop that process each item in a sequence and after each item some updating is done to some variables. However i don't what these variable updated if we are processing the last item in the list. i could put in a conditional and test if the list is now empty after popping items from the

Re: [Tutor] Alternating patterns

2006-03-28 Thread kevin parks
e: text/plain; charset=ISO-8859-1; format=flowed > > kevin parks wrote: >> I have a set that i iterate over... but each time through it i would >> like to alternate between the original set and a variation of the set >> that has one of the members of the set altered (

[Tutor] Alternating patterns

2006-03-28 Thread kevin parks
I have a set that i iterate over... but each time through it i would like to alternate between the original set and a variation of the set that has one of the members of the set altered (by + or - 1) So if my original set is: [0, 2, 4, 5, 7, 9, 11] I would use that the first pass but on the se

Re: [Tutor] scaling values

2006-03-14 Thread kevin parks
Thanks to Kent Johnson, & David Heiser and everyone else. Looks like i was most of the way there...hehe... David Heiser gets special bonus points for actually understanding my initial mysterious query. ___ Tutor maillist - Tutor@python.org http://mai

Re: [Tutor] scaling values

2006-03-14 Thread kevin parks
hi, Seems my post added much confusion. Sorry... I was hoping not to have to post my code since it is really wrong and slightly embarrassing.. what i am trying to do is map an input range of values to output range. I was hoping to make it a bit of an all purpose utility that would map pretty m

[Tutor] scaling values

2006-03-14 Thread kevin parks
i have various functions (that i didn't write) that put out data in lists of various types. But some functions (which i didn't write) that expect the data to be scaled, sometimes 0-1 sometimes 1-2, sometimes 0-127..., sometimes 0 - 32768... gosh you name it. In other words i have a bunch of bla

Re: [Tutor] weighted choices from among many lists

2006-03-11 Thread kevin parks
> Yes, you need to unpack the result of calling windex(). You so ably > demonstrated unpacking the list in your for loop I thought you would > figure it out :-) > > Try >lst_name, lst = windex(x) > > then random.choice() and print. > Thanks Kent i got it, just another brain-fart on my side...

Re: [Tutor] weighted choices from among many lists

2006-03-11 Thread kevin parks
D]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > kevin parks wrote: >> I have several lists... and i would like to some times chose from one >> list and for a while choose from a different list, etc. > > You don't say what isn't workin

[Tutor] activestate

2006-03-10 Thread kevin parks
I noticed a couple days ago that the active state archive seems to have ceased. Is it going away? cheers, kevin ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] weighted choices from among many lists

2006-03-10 Thread kevin parks
I have several lists... and i would like to some times chose from one list and for a while choose from a different list, etc... so i cooked this up and it almost works so that i can get colors 50% of the time, doggies 25%, beer 10%, and guitars 100% (if i was real smart i would make my index th

Re: [Tutor] module imports

2006-03-08 Thread kevin parks
On Mar 8, 2006, at 7:09 PM, Bob Gailer wrote: > kevin parks wrote: >> i have a module called foo.py >> >> foo.py imports random >> >> kp.py imports foo.py ... but in kp.py i also need to use stuff from >> random... >> >> so kp.py also impo

[Tutor] module imports

2006-03-08 Thread kevin parks
i have a module called foo.py foo.py imports random kp.py imports foo.py ... but in kp.py i also need to use stuff from random... so kp.py also imports random but i prolly shouldn't do that right? Cause now, haven't i needlessly copied the same names/attributes/methods/functions to 2 nam

Re: [Tutor] list packing

2006-02-27 Thread kevin parks
John, Thanks... i am liking this variation a tad more since it means i only have to type the path in one place but it is akin to your second one... i was (still am really) having a hard time understanding how to apply path.join _and_ listdir sometimes list comprehensions twist my brain b

[Tutor] list packing

2006-02-26 Thread kevin parks
howdy, I am using the os module to do some of my heavy lifting for me. I am tried of building lists by hand so i decided that i would get python to look in a bunch of directories and stuff all the things it find there into a list depending on it's extension. Works great ... one problem sometime

[Tutor] soundfile picker & rating system

2006-02-08 Thread kevin parks
I am a little bit stuck I want to play a bunch of soundfiles randomly, but i want to give each soundfile a rating (say 0-100) and have the likelihood that the file be chosen be tied to its rating so that the higher the rating the more likely a file is to be chosen. Then i need some addit

[Tutor] Gaussian integer values

2006-02-08 Thread kevin parks
hi all. I am working with a list and would like to choose from the list randomly but not uniformly. I am interested in several distributions but the first one i looked at is Gaussian. which you call like so: random.gauss(mean, dev) You can try this code courtesy of effbot (http://effbot.org

Re: [Tutor] printing the random seed?

2006-02-01 Thread kevin parks
Danny (hope you are good!) & co, I see that biz about random.seed()... but in the absence of setting that ... does it just grab a value from the system clock? Is there a way to just let it generate it's usual, known seed... but then observe what that is in case you get an especially good run of

[Tutor] printing the random seed?

2006-02-01 Thread kevin parks
hi. I am having some fun with python and making multiple runs on an algorhythm and sometimes getting some fun stuff that i would like to be able to reproduce, but there are some random elements in it. I wonder is there a way to see the random seed, and make note of it so that you could then se

[Tutor] cyclically rotate a seq

2005-03-10 Thread kevin parks
Hi folks, I am trying to cyclically rotate a seq until it reached the beginning stage again. I would like to be able to rotate in both directions and using any arbitrary interval. I think that I have this correct, but would be happy for someone to check it and also i am interested in any improve

Re: [Tutor] permutations, patterns, and probability

2005-02-01 Thread kevin parks
Tremendously helpful One question though. How can i pluck a unique item from my exhaustive list of permutations without repeats making sure that each one is used once? Like filling a bag, shaking it, and then picking from the bag and removing that item from the bag so it isn't used again...

[Tutor] permutations, patterns, and probability

2005-02-01 Thread kevin parks
Greetings, I am working on a program to produce patterns. What would like is for it to exhaustively produce all possible permutations of a sequence of items but for each permutation produce variations, and also a sort of stutter based on probability / weighted randomess. Let us say we have til

[Tutor] spaces in print

2005-01-12 Thread kevin parks
when i print: print '\n','siday_q', key, '.wav'# event i get: siday_q 515 .wav how can you eliminate the spaces to get: siday_q515.wav ? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Time script help sought!

2005-01-12 Thread kevin parks
thanks everyone... I will look at all the various appraoches folks came up with and see what i can learnn from them. I ended doing something lame -- a brute force method. I formmatted and reformatted my input data and stuffed it in a HUGE dictionary it was stupid and kludgy i hope to st

Re: [Tutor] Time script help sought!

2005-01-11 Thread kevin parks
I also notice that there is the is the 'datetime' module, which is new to version 2.3, which i now have access to. My feeling is that this will do much of what i want, but i can't get my head round the standard library reference stuff http://www.python.org/doc/lib/module-datetime.html I don't h

Re: [Tutor] Time script help sought!

2005-01-11 Thread kevin parks
I am still working on it and also fixing the input data. I think for simplicity and consistency's sake i will have *all* time values input and output as hh:mm:ss maybe that would be easier for now.. so i am editing the input stuff now... so it should all look like: Item_1, DAT_1, 1, 00:00:23, 0

Re: [Tutor] Time script help sought!

2005-01-11 Thread kevin parks
Thanks for this Everyone! Trying to work with all the stuff folks are giving me on this i a have come across a problem... down the line i notice that some of the times will also have an hour as well as in H:M:S (e.g. 1:22:40) so in some cases i would need to convert H:M:S to sec and some just M:

[Tutor] Time script help sought!

2005-01-11 Thread kevin parks
I am kind of in a bit of a jam (okay a big jam) and i was hoping that someone here could give me a quick hand. I had a few pages of time calculations to do. So, i just started in on them typing them in my time calculator and writing them in by hand. Now i realize, that i really need a script t