Re: config files in python

2008-05-05 Thread sandipm
Thanks for various useful suggestions. actually right now I am using conf files only in psp handler of mod_python/apache but I have other processes which might use same config files. One way is I can put conf related data directly in database and database handling module can directly pickup values

config files in python

2008-05-04 Thread sandipm
Hi, In my application, I have some configurable information which is used by different processes. currently I have stored configration in a conf.py file as name=value pairs, and I am importing conf.py file to use this variable. it works well import conf print conf.SomeVariable but if I need to c

Re: python script as executable

2008-04-28 Thread sandipm
bin/env doesn't > exist... not likely though. > > On Tue, Apr 29, 2008 at 1:36 AM, sandipm <[EMAIL PROTECTED]> wrote: > > Hi, > > I have written a python script to run from cron. > > I have put #!/usr/bin/env python at top. file executes correctly when >

python script as executable

2008-04-28 Thread sandipm
Hi, I have written a python script to run from cron. I have put #!/usr/bin/env python at top. file executes correctly when I run using python filename.py but it fails to execute when try to run it like script/command. it throws error: :No such file or directory I am editing file from eclipse for

Re: Problem with parsing email message with extraneous MIME information

2007-12-27 Thread sandipm
I think I faced same problem quite sometime back... but in our case, due to some settings in Microsoft outlook , forwarded emails were also coming as an attachment to email. so That attachement itself has same format as email's format, so to get information from attachment we needed to treat atta

Re: reading/writing files

2007-11-27 Thread sandipm
f1= open("file1.pdf", "rb") x = f1.read() open("file2.pdf", "wb").write(x) works... thanks sandip On Nov 27, 5:43 pm, sandipm <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to read a file and write into other file. if I do it for &g

reading/writing files

2007-11-27 Thread sandipm
Hi, I am trying to read a file and write into other file. if I do it for simple text file, it works well. but for pdfs or some other mime types, its failing. actually main problem is i am uploading file using cgi, in this process I am getting content of file, and I am trying to save the file. I

Re: __file__ vs __FILE__

2007-11-05 Thread sandipm
interestingly... I wanted to reuse this code so i wrote function in a file def getParentDir(): import os return os.path.dirname(os.path.abspath(__file__)) and called this function, in another file, its giving me parent directory of file where this function is defined.? how to reuse this

achieving performance using C/C++

2007-11-04 Thread sandipm
I did fair amount of programming in python but never used c/c++ as mentioned below. any good tutorials for using C/C++ to optimize python codebase for performance? how widely do they use such kind of mixed coding practices? sandip -- Forwarded message -- From: "D.Hering" . . . . P

Re: choose from a list

2007-11-01 Thread sandipm
one more way of connecting to sql. MySQLdb.connect(client_flag=65536131072,cursorclass=cursors.DictCursor,host=HOST,port=3306,user=USER,passwd=PASSWD,db=DbName) cursor = conn.cursor() in your case, only list of dictiories will be returned but when query/stored procedure returns more than one

Re: How to find if a string contains another string

2007-10-29 Thread sandipm
you can use "find" function...which gives index of occurrence of smaller one in bigger one and return -1 if does not exists.. if bigstring.find(smallone) > -1: return true else: return false sandip On Oct 30, 9:15 am, "Borse, Ganesh" <[EMAIL PROTECTED]> wrote: > Sorry, am getting t

python in academics?

2007-10-29 Thread sandipm
seeing posts from students on group. I am curious to know, Do they teach python in academic courses in universities? in undergrad comp science courses, We had scheme language as scheme is neat and beautiful language to learn programming. We learnt other languages ourselve with basics set right by

Re: Anagrams

2007-10-24 Thread sandipm
thanks..I am using python 2.4.4. so i couldnt find "all" either as inbuilt module or by doing "from itertools import *", "all" is not available. I think I need to move to 2.5 then but what are the pros/cons of moving to 2.5? as we are using 2.4.4 on production server which is quite stable. a

Re: Anagrams

2007-10-24 Thread sandipm
hi, Is "all" inbuilt function in python? what it does? > from itertools import ifilter, count > > def anagram_finder(): > primes = ifilter(lambda p: all(p % k for k in xrange(2, p)), count(2)) > primeAlpha = dict(zip(string.lowercase, primes)) >

Re: transforming list

2007-10-23 Thread sandipm
hi james, this is one implementation using python dictionaries. report ={} for row in data: if not row[0] in report: report[row[0]] = [row[0], row[1], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] if row[2]: report[row[0]][row[2]+1] = row[3] reports = report.values() regards, Sa