At Wednesday 17/1/2007 19:46, Stef Mientki wrote:

>      for key,value in count:
>         line += ' %s=%d' % (key, value)
>
I didn't succeed to use value as a enumerator, and I had to typecast key into a string (and skipping
some redundant information, but then it works great, thanks !!

Ouch, my fault! I didn't test it when I wrote it :(

here the complete listing:
     count = {}
     for item in V:
       t = type(item)
       try: count[t] += 1
       except KeyError: count[t] = 1
     if type(V)==list: line = 'list:'
     else: line = 'tuple:'
     for key in count: line += '  %s=%d' %('N_'+str(key)[7:-2],count[key])
     print line

str(key)[7:-2] => key.__name__

Nice to see you built a useful tool! It's a great way to learn a language.


--
Gabriel Genellina
Softlab SRL

        

        
                
__________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to