Re: simple question about dictionaries

2008-07-22 Thread Bruno Desthuilliers
skazhy a écrit : hi, i am new to python, so i've a really simple question about dictionaries. if i have a dictionary and I make have an input after it (to input numbers) can i get the key of value that was in input? What if many keys are associated with a same value, ie: d = {'a

Re: simple question about dictionaries

2008-07-22 Thread Jeff
On Jul 21, 8:14 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Jeff wrote: > >   throw KeyError('%s not found' % str(val)) > > "throw"?  and shouldn't that be a ValueError? ;-) > > Whoops. Been working in too many different languages at the same time :). -- http://mail.python.org/mailman/listinf

Re: simple question about dictionaries

2008-07-22 Thread Jeff
On Jul 21, 8:14 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Jeff wrote: > >   throw KeyError('%s not found' % str(val)) > > "throw"?  and shouldn't that be a ValueError? ;-) > > Whoops. Been working in too many different languages at the same time :). -- http://mail.python.org/mailman/listinf

Re: simple question about dictionaries

2008-07-21 Thread Fredrik Lundh
Jeff wrote: throw KeyError('%s not found' % str(val)) "throw"? and shouldn't that be a ValueError? ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: simple question about dictionaries

2008-07-21 Thread Jeff
On Jul 21, 7:35 am, skazhy <[EMAIL PROTECTED]> wrote: > hi, i am new to python, so i've a really simple question about > dictionaries. > if i have a dictionary and I make have an input after it (to input > numbers) can i get the key of value that was in input? > >

Re: simple question about dictionaries

2008-07-21 Thread Fredrik Lundh
skazhy wrote: hi, i am new to python, so i've a really simple question about dictionaries. if i have a dictionary and I make have an input after it (to input numbers) can i get the key of value that was in input? A dictionary contains (key, value) pairs, and is optimized for quickly fi

Re: simple question about dictionaries

2008-07-21 Thread Berco Beute
Sounds like a school assignment. Find the answer yourself here: http://diveintopython.org/toc/index.html You'll learn a lot more in the process. 2B -- http://mail.python.org/mailman/listinfo/python-list

simple question about dictionaries

2008-07-21 Thread skazhy
hi, i am new to python, so i've a really simple question about dictionaries. if i have a dictionary and I make have an input after it (to input numbers) can i get the key of value that was in input? somehting like this: dict = { "key1"=100,"key2"=200,"key3"

Re: question about dictionaries

2006-01-19 Thread Brett Hoerner
Chris wrote: > Is there a way to stop this behavior? I want to process this dictionary > in the order it's in, element by element. I'm running Python 2.3, if > that helps. As said previously, you either want a list (which are ordered), or an ordered-dictionary (not a Python native type, see http:/

Re: question about dictionaries

2006-01-19 Thread Paul Rubin
"Chris" <[EMAIL PROTECTED]> writes: > Is there a way to stop this behavior? I want to process this dictionary > in the order it's in, element by element. I'm running Python 2.3, if > that helps. You want a list not a dictionary. -- http://mail.python.org/mailman/listinfo/python-list

question about dictionaries

2006-01-19 Thread Chris
When you declare a dictionary, Python puts it in a different order than the way you declare it: >>> stuff = {'\n':'', ':'\n'} >>> print stuff {'':'\n', '\n':''} Is there a way to stop this behavior? I want to process this dictionary in the order it's in, element by element. I'm running Python 2.3