Re: Get keys from a dicionary

2011-11-11 Thread macm
On Nov 11, 2:25 pm, John Gordon wrote: > In <8f5215a8-d08f-4355-a5a2-77fcaa32c...@j10g2000vbe.googlegroups.com> macm > writes: > > > I pass a nested dictionary to a function. > > def Dicty( dict[k1][k2] ): > > That's not valid syntax. > > >    p

Re: Get keys from a dicionary

2011-11-11 Thread macm
Ok Sorry!! Sorry the noise!! def func(object): print "%s" % object Regards On Nov 11, 2:33 pm, macm wrote: > Hi > > Sorry ! My mistake. > > >>> myDict = {} > >>> myDict['foo'] = {} > >>> myDict['foo']['

Re: Get keys from a dicionary

2011-11-11 Thread macm
'bar']) ... # I want inspect this MyObj ... # what keys was pass ... print MyObj.keys() ## WRONG ... # So What I want is : ... # return foo bar >>> result = myFunction( myDict['foo']['bar'] ) >>> result Should

Re: side by side python

2011-03-21 Thread macm
On Mar 21, 9:31 am, Robert wrote: > Can I install Python 2.7 and 3.2 (from python.org) side by side on OSX > without them stepping all over each other? Yes, sure! Look for "python environment" http://pypi.python.org/pypi/virtualenv Regards -- http://mail.python.org/mailman/listinfo/python-list

Re: Partition Recursive

2010-12-24 Thread macm
Thanks all In [11]: reps = 5 In [12]: t = Timer("url = 'http://docs.python.org/dev/library/ stdtypes.html? highlight=partition#str.partition' ;sp = re.compile('(//?|[;?:@=&#.])'); filter(len, sp.split(url))", 'import re') In [13]: print sum(t.repeat(repeat=reps, number=1)) / reps 4.94003295898e-0

Re: round in 2.6 and 2.7

2010-12-23 Thread macm
On Dec 23, 4:57 pm, Hrvoje Niksic wrote: > I stumbled upon this.  Python 2.6: > > Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) > [GCC 4.4.5] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> 9.95 > 9.9493 > >>> "%.16g" % 9.95 > '9.949

Re: Partition Recursive

2010-12-23 Thread macm
#x27;.','html','?','highlight','=','partition','#','str','.','partition'] re module is slow. Even I make a loop in urlparse.urlsplit I can lost specialMeaning order. Seen easy but best aproach will be rec

Partition Recursive

2010-12-23 Thread macm
Hi Folks I have this: url = 'http://docs.python.org/dev/library/stdtypes.html? highlight=partition#str.partition' So I want convert to myList = ['http',':','//','docs','.','python','.','org','/','dev','/','library','/','stdtypes','.','html','?','highlight','=','partition','#','str','.','partiti

Automatic Distutils generator

2010-11-25 Thread macm
Hi Folks I am trying run Distutils setup inside a script. The Docs dont tell me much and I cant find any examples. This script will generate shared libraries recursive to all files in a dir. - import os import sys from distutils.core import setup as d from distutil

Open Multiples Files at same time with multiprocessing - How "declare" dynamically the var?

2010-11-11 Thread macm
m{z}.start() for x in L: z=L.index(x) d1.append(q{z}.get()) # <= So now I am sure that q{z}.get() isn't lock print list(d1) return I tried use list but didn't work look below one shot. Best Regards macm I tried : d

Re: Learning Pyhton - Functional Programming - How intersect/difference two dict with dict/values? fast!

2010-11-10 Thread macm
sult [[], [1, 3, '79b'], [2]] >>> but should be {'ac': [1, 3, '79b'], 'ab': [2]} Best Regards Mario On 10 nov, 18:14, macm wrote: > Hi Folks > > I am studing yet (with fever, grasp and headache). > > I know I can do better, but first

Re: Learning Pyhton - Functional Programming - How intersect/difference two dict with dict/values? fast!

2010-11-10 Thread macm
Hi Folks I am studing yet (with fever, grasp and headache). I know I can do better, but first I should learn more about "dictionary comprehension syntax" in python 2.65 >>> dict1 = {'ab':[[1,2,3,'d3','d4',5],12],'ac':[[1,3,'78a','79b'],54],'ad': >>> [[56,57,58,59],34], 'ax': [[56,57,58,59],34]

Re: Learning Pyhton - Functional Programming - How intersect/difference two dict with dict/values? fast!

2010-11-09 Thread macm
Sorry Mr. Nagle and Folks I had a bad day today. I need forward but with fever, a grasp and headache is hard. You are absolute right, I was rude and I ask your pardon. About my code, sorry I thought was the best way to copy and paste in python console. Best Regards macm On Nov 9, 7:03 pm

Learning Pyhton - Functional Programming - How intersect/difference two dict with dict/values? fast!

2010-11-09 Thread macm
:[2,'d3']} # look last key/value 'ax' (dict1, dict2) even intersec a key but not values from list so not valid and difference from dict3 dict3 = {'ac':[[1,3,67,'gf'],12],'at':[[2,4,50,42,'c4'],12],'as': [[1,3,'79b',45,65,'er4'],54],'ae': [[56,57,58,59],34]} result from (intersect - dict3) {'ac':['79b'], 'ab':[2,'d3']} Thanks in advance! Before someone blame me. Yes I am trying learn python Functional Programming! ; ) Best Regards macm -- http://mail.python.org/mailman/listinfo/python-list

Re: How convert list to nested dictionary?

2010-11-05 Thread macm
#x27;k5'] >>> ndict = reduce(lambda x,y: {y:x}, reversed(l), {'/':[1,2,3]}) >>> x = l + list('/') >>> print appendNested(ndict, x, 5) {'k1': {'k2': {'k3': {'k4': {'k5': {'/': [1, 2, 3, 5]}

Re: How convert list to nested dictionary?

2010-11-05 Thread macm
Hi Peter Thanks a lot for your tips and codes, Cake Recipes are good to learn! So I post just basic issues. Hopping a good soul like you can help me! But I am still learning... : ) Best Regards macm On 5 nov, 15:40, Peter Otten <__pete...@web.de> wrote: > macm wrote: > > t

Re: How convert list to nested dictionary?

2010-11-05 Thread macm
: [1, 2, 3]} >>> d['k1']['k2']['k3']['k4']['k5']['/'] [1, 2, 3] >>> now I want generate the "index" to access the element. ==> d['k1']['k2']['k3']['k4']['k5'][&

Re: How convert list to nested dictionary?

2010-11-04 Thread macm
vance. Best regards macm On 4 nov, 16:53, Chris Rebert wrote: > On Thu, Nov 4, 2010 at 11:48 AM, macm wrote: > > Hi Folks > > > How convert list to nested dictionary? > > >>>> l > > ['k1', 'k2', 'k3', 'k4', '

How convert list to nested dictionary?

2010-11-04 Thread macm
Hi Folks How convert list to nested dictionary? >>> l ['k1', 'k2', 'k3', 'k4', 'k5'] >>> result {'k1': {'k2': {'k3': {'k4': {'k5': {}} Regards macm -- http://mail.python.org/mailman/listinfo/python-list

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread macm
Peter Ok! Both works fine! Thanks a lot! >>> for v in f(a['a']['b']): ... b.extend(v) b Now I will try find which script is the fast! Regards macm On 4 nov, 15:56, macm wrote: > Hi Folks > > Thanks a lot > > Script from Diez works: >

Re: How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread macm
all last): File "", line 2, in TypeError: 'int' object is not iterable I am trying understand this error. Best Regards and thanks a lot again! Mario macm On 4 nov, 15:26, Peter Otten <__pete...@web.de> wrote: > macm wrote: > > How find all childrens

How find all childrens values of a nested dictionary, fast!

2010-11-04 Thread macm
;/': [1, 2, 3, 4], 'bc': {'bcd': {'/': [68, 69, 66]}, '/': [51, 52, 54]}}} >>> a['a']['b'] {'ba': {'/': [41, 42, 44]}, '/': [1, 2, 3, 4], 'bc': {'bcd': {'/': [68, 69, 66]}, '/': [51, 52, 54]}} >>> a['a']['b'].values() [{'/': [41, 42, 44]}, [1, 2, 3, 4], {'bcd': {'/': [68, 69, 66]}, '/': [51, 52, 54]}] Now I want find all values of key "/" Desire result is [41, 42, 44, 1, 2, 3, 4, 68, 69, 66, 51, 52, 54] I am trying map, reduce, lambda. Regards macm -- http://mail.python.org/mailman/listinfo/python-list

[python] pass the name of args

2010-06-04 Thread macm
again : IhaveOtherName = ('some','thing') myDef(IhaveOtherName) so what I am looking for in myDef result = IhaveOtherName -- Is it possible with python? Regards macm -- http://mail.python.org/mailman/listinfo/python-list