mac install

2010-02-09 Thread Thomas Nelson
I downloaded the 3.1.1 dmg from http://www.python.org/download/releases/3.1.1/ but when I run it I get the error "The folowing install step failed: run postflight script for python documentation." The bugs list has this bug at http://bugs.python.org/issue6934 but it's described as fixed. Is it on

Re: Looping through File Question

2007-09-05 Thread Thomas Nelson
> > > On Sep 5, 8:58 pm, planetmatt <[EMAIL PROTECTED]> wrote: > > > > > I am a Python beginner. I am trying to loop through a CSV file which > > > > I can do. What I want to change though is for the loop to start at > > > > row 2 in the file thus excluding column headers. The DictReader object

Re: Combinatorial of elements in Python?

2007-08-15 Thread Thomas Nelson
On Aug 15, 8:39 am, "Sebastian Bassi" <[EMAIL PROTECTED]> wrote: > That was easy :) > What about extending it for N elements inside the dictionary? Sounds > like a work for a recursive function. Here's my attempt: [code] def backtrack(groups,position=0, answer=''): if position==len(groups)

condor_compiled python interpreter

2007-07-11 Thread Thomas Nelson
Does anyone know where I could find help on condor_compiling a python interpreter? My own attempts have failed, and I can't find anything on google. Here's the condor page: http://www.cs.wisc.edu/condor/ Thanks, Tom -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble killing a process on windows

2007-06-02 Thread Thomas Nelson
On Jun 2, 11:43 am, Tim Golden <[EMAIL PROTECTED]> wrote: > Thomas Nelson wrote: > > from subprocess import Popen > > from time import sleep > > import win32api > > war3game = Popen(["C:\Program Files\Warcraft III\Frozen Throne.exe"]) >

Trouble killing a process on windows

2007-06-02 Thread Thomas Nelson
Hi, I'd like to start a program, run it for a while, then terminate it. I can do this on linux, but I'm new to working with windows. Here's my script: from subprocess import Popen from time import sleep import win32api war3game = Popen(["C:\Program Files\Warcraft III\Frozen Throne.exe"]) sleep(30

Re: Sorting troubles

2007-05-14 Thread Thomas Nelson
On May 14, 11:05 am, [EMAIL PROTECTED] wrote: > I have the following implementations of quicksort and insertion sort: > > def qSort(List): > if List == []: return [] > return qSort([x for x in List[1:] if x< List[0]]) + List[0:1] + \ >qSort([x for x in List[1:] if x>=List[0]]) >

Re: How do I get type methods?

2007-05-04 Thread Thomas Nelson
On May 4, 7:59 am, [EMAIL PROTECTED] wrote: > On 4 ÍÁÊ, 09:08, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > > En Fri, 04 May 2007 01:34:20 -0300, <[EMAIL PROTECTED]> escribio: > > > I'm not against 'dir(MyClass)'; the question is, what should I 'dir()' > > > to get methods of 'pyuno' type ins

How safe is a set of floats?

2007-05-04 Thread Thomas Nelson
I want to generate all the fractions between 1 and limit (with limit>1) in an orderly fashion, without duplicates. def all_ratios(limit): s = set() hi = 1.0 lo = 1.0 while True: if hi/lo not in s: s.add(hi/lo) yield (hi,lo) hi += 1 if

Re: editing scripts on a mac

2007-04-27 Thread Thomas Nelson
On Apr 27, 11:37 am, Tommy Grav <[EMAIL PROTECTED]> wrote: > > him> I do not have a text editor, but here are the answers to > > him> questions 1-5. > > > Now, frankly, I don't think this answer is correct, since I know OS > > X is > > a UNIX derivative, but I am loathe to involve a programming n

Re: When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?

2007-04-24 Thread Thomas Nelson
On Apr 23, 10:38 pm, Mel Wilson <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: > > The interpreter explains it: "A list is not a hashable object." > > Choosing a hash table instead of some kind of balanced tree seems > > to be just an optimization. ;) > > Even with a balanced tree, if a key in a

feedback on Until recipe

2007-04-24 Thread Thomas Nelson
Occasionally people post complaining about the lack of a "repeat...until" structure in python. I thought about it and came up with this recipe that I like. The only ugly thing is having to use lambdas, otherwise it's very terse and readable. Tell me what you think, and if anyone besides me think

Feedback on Until recipe

2007-04-24 Thread Thomas Nelson
Occasionally someone posts to this group complaining about the lack of "repeat ... until" in python. I too have occasionally wished for such a construct, and after some thinking, I came up with the class below. I'm hoping to get some feedback here, and if people besides me think they might use it

Re: how to remove multiple occurrences of a string within a list?

2007-04-03 Thread Thomas Nelson
On Apr 3, 1:49 pm, [EMAIL PROTECTED] wrote: > On Apr 3, 1:31 pm, "Matimus" <[EMAIL PROTECTED]> wrote: > > > It depends on your application, but a 'set' might really be what you > > want, as opposed to a list. > > > >>> s = set(["0024","haha","0024"]) > > >>> s > > > set(["0024","haha"])>>> s.remove

Re: how to remove multiple occurrences of a string within a list?

2007-04-03 Thread Thomas Nelson
bahoo wrote: > Hi, > > I have a list like ['0024', 'haha', '0024'] > and as output I want ['haha'] > > If I > myList.remove('0024') > > then only the first instance of '0024' is removed. > > It seems like regular expressions is the rescue, but I couldn't find > the right tool. > > Thanks! > bahoo

Re: list/get methods/attributes of a class?

2007-02-22 Thread Thomas Nelson
Check out the dir() function. It does what you want, I think. Tom On Feb 22, 9:27 am, [EMAIL PROTECTED] wrote: > Hello, > Sorry guys for this newbie questions. But I wonder if there is a > standard or build-in method to know the methods of a class? > > I'm not originally a progrommer and I have

Re: c++ for python programmers

2007-02-12 Thread Thomas Nelson
On Feb 12, 1:35 pm, andrew clarke <[EMAIL PROTECTED]> wrote: > Thomas, I sent you a message off-list but it bounced due to your mailbox > being full. > > Short answer: Subscribe to the c-prog@yahoogroups.com mailing list and > ask your C/C++ questions there. > > Regards > Andrew I have to edit a

c++ for python programmers

2007-02-12 Thread Thomas Nelson
I realize I'm approaching this backwards from the direction most people go, but does anyone know of a good c/c++ introduction for python programmers? Thanks, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting a List of Lists

2007-01-30 Thread Thomas Nelson
On Jan 30, 5:55 pm, [EMAIL PROTECTED] wrote: > I can't seem to get this nailed down and I thought I'd toss it out > there as, by gosh, its got to be something simple I'm missing. > > I have two different database tables of events that use different > schemas. I am using python to collate these reco

Re: Trouble with max() and __cmp__()

2007-01-28 Thread Thomas Nelson
On Jan 28, 3:13 pm, Wojciech Muła <[EMAIL PROTECTED]> wrote: >Define method __gt__. This works, thanks. I was a little surprised though. is __cmp__ used by any builtin functions? Thanks, THN -- http://mail.python.org/mailman/listinfo/python-list

Trouble with max() and __cmp__()

2007-01-28 Thread Thomas Nelson
My code: class Policy(list): def __cmp__(self,other): return cmp(self.fitness,other.fitness) j = Policy() j.fitness = 3 k = Policy() k.fitness = 1 l = Policy() l.fitness = 5 print max([j,k,l]).fitness prints 3, when I was expecting it to print 5. What have I done wrong? Thanks for

Re: newbieee

2007-01-08 Thread Thomas Nelson
lee wrote: > I getting familiarised with python...can any one suggest me a good > editor available for python which runs on windows xpone more > request guys...can nyone tell me a good reference manual for python.. I think vim is a very good editor for python, and it's certainly available for

Re: Non greedy regex

2006-12-14 Thread Thomas Nelson
There's an optional count argument that will give what you want. Try re.sub('a.*b','','ababc',count=1) Carsten Haese wrote: > On Thu, 2006-12-14 at 06:45 -0800, [EMAIL PROTECTED] wrote: > > Can someone please explain why these expressions both produce the same > > result? Surely this means that

Re: Python in sci/tech applications

2006-11-03 Thread Thomas Nelson
How hard would it be to have numpy/ scipy part of the python standard library? Tom mattf wrote: > I've discovered Python and have been trying it out lately as a possible > replacement for computations that would ordinarily be done with a > commercial package like Matlab or IDL. I'd like to mentio

Re: can I import the module twice (under differnet names)

2006-11-01 Thread Thomas Nelson
alf wrote: > Hi, > > wonder if in the python I could treat modules imorts like classes > instances. It means I could import it twice or more times under > different names. > > -- > alfz1 You can always give any object as many names as you want: >>> import sys >>> s1 = sys >>> s2 = sys >>> s1.path

Re: Memory problem

2006-08-14 Thread Thomas Nelson
Yi Xing wrote: > On a related question: how do I initialize a list or an array with a > pre-specified number of elements, something like > int p[100] in C? I can do append() for 100 times but this looks silly... > > Thanks. > > Yi Xing Use [0]*100 for a list. THN -- http://mail.python.org/ma

Re: Two Classes In Two Files

2006-08-10 Thread Thomas Nelson
Perhaps __init__.py has what you're looking for? THN [EMAIL PROTECTED] wrote: > I just started working with Python and ran into an annoyance. Is there > a way to avoid having to use the "from xxx import yyy" syntax from > files in the same directory? I'm sure it's been asked a million times, > b

Re: Programming newbie coming from Ruby: a few Python questions

2006-08-03 Thread Thomas Nelson
I strongly recommend trying to come up with your own projects. Just pick small things that reflect something you actually want to do: maybe make a simple board game, or a few scripts to help you keep all your files organized, etc. Generally speaking I think it's easier to teach yourself a languag

Re: looking for a regular expression

2006-08-01 Thread Thomas Nelson
How about my_string = "We the people of the United States, in order to form a more perfect union, establish justice, insure domestic tranquility,.." print (x for x in my_string.split(",") if "justice" in x).next() This isn't a regular expression, but it gives what you're looking for. THN --

Re: statistical analysis tools in python?

2006-07-18 Thread Thomas Nelson
Actually, after a little looking, the simple stats.py module at http://www.nmr.mgh.harvard.edu/Neural_Systems_Group/gary/python.html is exactly what I needed. It may not be as fast or as comprehensive as scipy or R, but installation simply involves downloading the module and importing into the cod

Re: execute a shell script from a python script

2006-07-18 Thread Thomas Nelson
As described in the docs I pointed to before: subprocess.call("foo.sh",shell=True) Is the way to do it without args. I think it is simplest to learn the subprocess module because (quoting from the docs) this module intends to replace several other, older modules and functions, such as: os.system o

Re: execute a shell script from a python script

2006-07-17 Thread Thomas Nelson
If your script is foo.sh and takes args: import subprocess subprocess.call(["foo.sh","args"],shell=True) Should work fine. check out http://www.python.org/dev/doc/maint24/lib/module-subprocess.html Enjoy, THN spec wrote: > Hi all, I know nothing about Python. What I need to do is to get a > Pyth

statistical analysis tools in python?

2006-07-12 Thread Thomas Nelson
Sorry if this is a FAQ, but I couldn't find a good summary through google. What kinds of statistical analysis tools exist in python? I really just need t-tests, chi-squared test, and other such tests of statistical significance. A few things point to numpy and scipy, but I was surprised to find

Re: Best command for running shell command

2006-07-11 Thread Thomas Nelson
Yes, I highly recommend the subprocess module. subprocess.call() can do almost anything you want to do, and the options are all pretty intuitive Whenever I need to write quick scripts for myself, it's what I use. THN Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > Donald Duck <[EMAIL PRO

Re: how can I avoid abusing lists?

2006-07-07 Thread Thomas Nelson
Thanks to everyone who posted. First, I don't think my question was clear enough: Rob Cowie, Ant, Simon Forman, [EMAIL PROTECTED], and Jon Ribbens offered solutions that don't quite work as-is, because I need multiple values to map to a single type. Tim Chase and Bruno Destuilliers both offer ver

how can I avoid abusing lists?

2006-07-07 Thread Thomas Nelson
I have this code: type1 = [0] type2 = [0] type3 = [0] map = {0:type1, 1:type1, 2:type3, 3:type1, 4:type2} # the real map is longer than this def increment(value): map[value][0] += 1 increment(1) increment(1) increment(0) increment(4) #increment will actually be called many times through

Re: calling functions style question

2006-06-06 Thread Thomas Nelson
The difference becomes clear when you import your program into another program (or the command line python editor). __name__!='__main__' when you import, so the functions will not be called if they're inside the block. This is why you see this block so often at the end of scripts; so that the scr

Re: print names of dictionaries

2006-04-26 Thread Thomas Nelson
I meant something like def printdict(dictionaries=[(apps,'apps'), (dirs,'dirs'), (sites,'sites')]): for dictionary,name in dictionaries: print name keys = dictionary.keys() keys.sort() for key in keys: print key, ":

Re: print names of dictionaries

2006-04-26 Thread Thomas Nelson
Here's an OO way that may do what you want: >>> class MyD(dict): ... def __init__(self,dic,rep): ... dict.__init__(self,dic) ... self.rep = rep ... def __repr__(self): ... return self.rep ... >>> apps = MyD({'alpha':1,'beta':2},'apps') >>> apps apps >>> a

Re: do while loop

2006-04-26 Thread Thomas Nelson
My usual way of emulating do-while is: started = False while (someBoolean or not started): started = True #whatever else This simply assures "whatever else" happens at least once. Is this Pythonic? THN -- http://mail.python.org/mailman/listinfo/python-list

Re: print names of dictionaries

2006-04-26 Thread Thomas Nelson
Here's an OO way that may do what you want: >>> class MyD(dict): ... def __init__(self,dic,rep): ... dict.__init__(self,dic) ... self.rep = rep ... def __repr__(self): ... return self.rep ... >>> apps = MyD({'alpha':1,'beta':2},'apps') >>> apps apps >>> a

Re: modifying iterator value.

2006-04-26 Thread Thomas Nelson
There is also this way: for index in range(len(someList)): someList[index] = 1 This is not as pretty or concise as enumerate(), but if you've never seen that function before this may be more clear. I assume you're familiar with the way range and len work. THN -- http://mail.python.org/mai

Re: python about mobile game?

2006-04-20 Thread Thomas Nelson
What is a mobile game? Is it a game that can be played on a mobile phone? THN -- http://mail.python.org/mailman/listinfo/python-list

Re: "The World's Most Maintainable Programming Language"

2006-04-09 Thread Thomas Nelson
I thought the paragraph about provability was interesting. Presumably the author refers to proofs in the spirit of "A Discipline of Programming" from Djikstra, 1976. Unfortunately, I don't think anyone has writting much about this since the 70s. I'd be interested to learn if anyone's tried to wr

Re: python on Mac

2006-04-06 Thread Thomas Nelson
Ok, I fixed my /usr/bin/python and added /usr/public/bin/ to my PATH in .profile. Everything seems ok now. Thanks again to everyone for their help. THN -- http://mail.python.org/mailman/listinfo/python-list

Re: python on Mac

2006-04-06 Thread Thomas Nelson
Well, as I stated in post, I've already replaced the link at /usr/bin/python. I'm not clear why that's unhealthy. Should I change it back to whatever it was before? I guess maybe it was /System/Library/Frameworks/Python.framework/Versions/Current/bin/python ? Thanks, THN -- http://mail.python.

Re: python on Mac

2006-04-05 Thread Thomas Nelson
Thanks to you both. I downloaded the dmg suggested, and trustingly typed: sudo rm /usr/bin/python sudo ln -s /usr/local/bin/python2.4 /usr/bin/python And now my command line and scripts behave the way I expect. Thanks again. THN -- http://mail.python.org/mailman/listinfo/python-list

Re: python on Mac

2006-04-05 Thread Thomas Nelson
There is no 2.4 in my Versions folder, only 2.3 and current. Should one of the installers have created this directory? Which one? THN -- http://mail.python.org/mailman/listinfo/python-list

python on Mac

2006-04-05 Thread Thomas Nelson
I just purchased a new macbook (os 10.4.6), and I'm trying to install python 2.4 on it. I downloaded and ran the two installers recommended at http://www.python.org/download/mac/. Now I have IDLE, which runs 2.4.1, but typing "python" at a terminal still opens 2.3.5, because it points to /usr/bin

Re: new to mac OS10

2005-04-15 Thread Thomas Nelson
The main thing I would like is to be able to use tkinter with python on my mac. will the command-line-style source allow this? Does it come with IDLE? How is the fink version different from the source i can download at python.org? Here's the result of the requested commands on my Terminal.

Re: new to mac OS10

2005-04-14 Thread Thomas Nelson
Maurice LING wrote: I'm using OSX 10.3.8 as well. Just wondering, how did you "destroy" it? What I am thinking is, it may not be as destroyed as you think it might have... cheers maurice I was actually trying to update to the newest python version, and I had read something saying it would confl

new to mac OS10

2005-04-14 Thread Thomas Nelson
I'm on a mac OS X (10.3.8), and I seem to have accidentally destroyed the default python installation. How should I put it on? Do I need to use the unix version? any help would be greatly appreciated. THN -- http://mail.python.org/mailman/listinfo/python-list