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
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))
>
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
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
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
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
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
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
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
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
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
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
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
>
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
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
15 matches
Mail list logo