Re: [Tutor] get_python_lib()

2008-01-15 Thread Vishnu Mohan
Kakada wrote: > Hi list, > > I was just wondering why the below function return different location on > different machine? > > import distutils.sysconfig > distutils.sysconfig.get_python_lib() > On my computer: > '/usr/lib/python2.5/site-packages' > On my friend's computer: > '/usr/local/lib/pytho

Re: [Tutor] Problem with while loop

2007-09-10 Thread Vishnu Mohan
> Now I just need to figure out how to only get 4 digit pin numbers :) > Use regular expressions The following is the code with re. from random import randint import re counter = 0 pinPattern = re.compile(r'^\d{4}$') howmany = raw_input( "How many: " ) if pinPattern.match(howmany): whil

Re: [Tutor] Automatic generation of an "all possible combinations" array

2007-06-14 Thread Vishnu Mohan
Another simplest way of doing it is >>> from random import * from sys import * def bin_list(n): bin_val = 0 if n >= 0: bin_val = 2**n - 1 list = [] while bin_val >= 0: list.append([((bin_val >> y) & 1) for y in range(n-1,-1,-1)]) bin_val -= 1 shuffle(

Re: [Tutor] locking files

2007-06-14 Thread Vishnu Mohan
You can look into the flock or lockf methods in fcntl module (or) the following link will help you http://www.python.org/doc/2.4/lib/module-fcntl.html VishnuMohan Alan Gauld wrote: "Jeff Peery" <[EMAIL PROTECTED]> wrote does anyone know if there is a way in python to lock a file so othe

Re: [Tutor] Tutor Digest, Vol 40, Issue 25

2007-06-12 Thread Vishnu Mohan
> > Message: 2 > Date: Sun, 10 Jun 2007 09:20:28 -0500 > From: David Hamilton <[EMAIL PROTECTED]> > Subject: [Tutor] Correct use of range function.. > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > I just finished doing an e