Re: [Tutor] adding dictionary values

2009-03-21 Thread عماد نوفل
2009/3/20 Kent Johnson ken...@tds.net

 2009/3/20 Emad Nawfal (عماد نوفل) emadnaw...@gmail.com:

  if I want to do this with more than two dictionaries, the obvious
 solution
  for me is to use something like the reduce functions with a list of
  dictionary names like:
  dictList = [dict1, dict2, dict3]
  newDict = reduce(addDicts, dictList)
 
  Is this a satisfactory solution?

 This will do some extra copying, as addDicts() always copies the first
 argument. You would do better with something like
 def addToDict(a, b):
for k,v in b.iteritems():
a[k] += v
   return a

 newDict = reduce(addDictTo, dictList[1:], defaultdict(int, dictList[0]))

 or rewrite addDicts() to take a variable number of arguments and loop
 over the args.

 Kent

Thanks Kent and All. I appreciate your helpfulness


-- 
لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.محمد
الغزالي
No victim has ever been more repressed and alienated than the truth

Emad Soliman Nawfal
Indiana University, Bloomington

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Distributing MySQL with my application

2009-03-21 Thread Lauren Snyder
Hello!

 

I have written an application in python that uses a MySQL database. I want
to distribute this application to many users so I created an executable
using GUI2exe. My executable works marvelously. However, when attempting to
run the app on a computer that doesn't have the MySQL server running, I
obviously get the error: Can't connect MySQL server on localhost.  

 

So I have some questions around this problem:

 

1.  Is it possible to bundle the database into my application?
2.  Do I have to write a script that installs the database server
locally?
3.  Do I have to make Users must have MySQL server running as a
pre-requisite for using my software?
4.  Did I miss an option in GUI2exe that allows me to set up my exe to
use MySQL?

 

Thank you,

Lauren

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Distributing MySQL with my application

2009-03-21 Thread Alan Gauld


Lauren Snyder lau...@protopc.com wrote

I have written an application in python that uses a MySQL database. 
I want
to distribute this application to many users so I created an 
executable


1. Is it possible to bundle the database into my application?


It may be possible but it is unusual.
Normally the database woyuld come as a sseparate installer so that
those who already have MySql can simply create a new database
on their existing server. It is much easier to administer multiple 
databases

on a single server than to have multiple servers ruinning!


2. Do I have to write a script that installs the database server
locally?


If it needs to be local. Do you not use an environment variable or 
config

file to allow the user to select where the database server runs?


3. Do I have to make Users must have MySQL server running as a
pre-requisite for using my software?


Usually yes, then provide a loader for MySql for those who need it.

HTH,


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor