Best Open Source Project?
Look at a poll in this site: http://www.grupthink.com/topic/index.php5?id=821page=1 regards. -- http://mail.python.org/mailman/listinfo/python-list
Re: Want to reduce steps of an operation with dictionaries
James: Your solution works for me, many, many thanks for your help and many thanks for the time, teaching and reflections I received from all the guys that participated in this thread. James Stroud wrote: [EMAIL PROTECTED] wrote: Hello: I have next dictionaries: a={'a':0, 'b':1, 'c':2, 'd':3} b={'a':0, 'c':1, 'd':2, 'e':3} I want to put in a new dictionary named c all the keys that are in b and re-sequence the values. The result I want is: c={'a':0, 'c':1, 'd':2} How can I do this with one line of instruction? I attempted the next but the output is not the expected: c=dict([(k,v) for v,k in enumerate(a) if b.has_key(k)]) erroneously (for me) gets: {'a': 0, 'c': 2, 'd': 3} Thanks for your help. I think you have the right idea if I understand what you want: c = dict(((k,v) for (v,k) in enumerate(x for x in a if b.has_key(x -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Want to reduce steps of an operation with dictionaries
Mike: Many thanks for your solution. It looks really nice. Mike Erickson wrote: * [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: Hello: I have next dictionaries: a={'a':0, 'b':1, 'c':2, 'd':3} b={'a':0, 'c':1, 'd':2, 'e':3} I want to put in a new dictionary named c all the keys that are in b and re-sequence the values. The result I want is: c={'a':0, 'c':1, 'd':2} How can I do this with one line of instruction? I attempted the next but the output is not the expected: c=dict([(k,v) for v,k in enumerate(a) if b.has_key(k)]) erroneously (for me) gets: {'a': 0, 'c': 2, 'd': 3} I am not 100% I understand your questions, but k,v are being pulled from a, try: c=dict([(k,b[k]) for v,k in enumerate(a) if b.has_key(k)]) mike -- http://mail.python.org/mailman/listinfo/python-list
Want to reduce steps of an operation with dictionaries
Hello: I have next dictionaries: a={'a':0, 'b':1, 'c':2, 'd':3} b={'a':0, 'c':1, 'd':2, 'e':3} I want to put in a new dictionary named c all the keys that are in b and re-sequence the values. The result I want is: c={'a':0, 'c':1, 'd':2} How can I do this with one line of instruction? I attempted the next but the output is not the expected: c=dict([(k,v) for v,k in enumerate(a) if b.has_key(k)]) erroneously (for me) gets: {'a': 0, 'c': 2, 'd': 3} Thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list
A question about list
Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? Thanks!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Encode differences between idle python and python
Gabriel, Peter: Many thanks for your clear answers!! Best regards. Vizcayno -- http://mail.python.org/mailman/listinfo/python-list
Encode differences between idle python and python
Hello: Under win32 XP y select python command line and execute next code with results indicated: Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on Type help, copyright, credits or license for more information. u=u'áéíóú' u u'\xe1\xe9\xed\xf3\xfa' print u áéíóú a=u.encode('latin-1') a '\xe1\xe9\xed\xf3\xfa' print a ßÚݾ· type(a) type 'str' type(u) type 'unicode' using python IDLE I repeat the code, but get next differen result: IDLE 1.2 u=u'áéíóú' u u'\xe1\xe9\xed\xf3\xfa' print u áéíóú a=u.encode('latin-1') a '\xe1\xe9\xed\xf3\xfa' print a áéíóú type(a) type 'str' type(u) type 'unicode' What do you think is happending and how can I solve this ? The IDLE looks fine but command line has problems. -- http://mail.python.org/mailman/listinfo/python-list
.dll and .pyd
Please, confirm me one thing. According to Python documentation for Windows the objects .pyd and .dll have the same characteristics. I observed that in Python24 it does not produce errors when importing xx.dll or xx.pyd, however in python25b2, it only accepts nto import xx.pyd. Best regards. -- http://mail.python.org/mailman/listinfo/python-list
Compiler for external modules for python
Hello: I have interesting external modules that I want to incorporate to python 2.4.3 and python 2.5b2 also. Some of them requires C/C++ compiler. I work with Win XP Sp2 and have installed VC2005 express (I do not know if the compiler is the one with optimizing characterisitics), when trying to install some module using distutils program, it asks for C/C++ VC7 that is part of VS2003, it seems distutils is not configured for VC8 that is part of VC2005. Under this circumstances I tried to find the VC7 compiler from microsoft sites, however it deflect to the new version of VS2005, so I lost the cord and the goat . I do not know what to do. Does anybody has some guidelines about this matter? Thanks!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Which Pyton Book For Newbies?
W. D. Allen wrote: I want to write a retirement financial estimating program. Python was suggested as the easiest language to use on Linux. I have some experience programming in Basic but not in Python. I have two questions: 1. What do I need to be able to make user GUIs for the program, and Try in: www.wxpython.org or in http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPythontitle=More%20Information 2. Which book would be easiest to use to learn Python programming? Try in: http://docs.python.org/tut/tut.html I nice Book I has is in: http://www.amazon.com/gp/product/159059519X/sr=8-1/qid=1153612000/ref=pd_bbs_1/104-182-3979942?ie=UTF8 -- http://mail.python.org/mailman/listinfo/python-list
Re: Which Pyton Book For Newbies?
W. D. Allen wrote: I want to write a retirement financial estimating program. Python was suggested as the easiest language to use on Linux. I have some experience programming in Basic but not in Python. I have two questions: 1. What do I need to be able to make user GUIs for the program, and Try in: www.wxpython.org or in http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPythontitle=More%20Information 2. Which book would be easiest to use to learn Python programming? Try in: http://docs.python.org/tut/tut.html I nice Book I has is in: http://www.amazon.com/gp/product/159059519X/sr=8-1/qid=1153612000/ref=pd_bbs_1/104-182-3979942?ie=UTF8 -- http://mail.python.org/mailman/listinfo/python-list