[Python-Dev] annoying dictionary problem, non-existing keys
i use dictionaries to hold some config data, such as: conf={'key1':'value1','key2':'value2'} and so on... when i try to process conf, i have to code every time like: if conf.has_key('key1'): if conf['key1']<>'': other commands this is very annoying. in php, i was able to code only like: if conf['key1']=='someth' in python, this fails, because, if key1 does not exists, it raises an exception. MY question: is there a way to directly get value of an array/tuple/dict item by key, as in php above, even if key may not exist, i should not check if key exist, i should only use it, if it does not exist, it may return only empty, just as in php i hope you understand my question... -- İ.Bahattin Vidinli Elk-Elektronik Müh. --- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: [EMAIL PROTECTED] yahoo: bvidinli +90.532.7990607 +90.505.5667711 ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] annoying dictionary problem, non-existing keys
Python-dev is for discussion of development of future Python. Use python-list / comp.lang.python / gmane.comp.python.general for usage questions. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] annoying dictionary problem, non-existing keys
> this is very annoying. Posting to so many lists is even more annoying. You might not get a single helpful answer just because people are so frustrated by this behavior. Regards, Martin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] annoying dictionary problem, non-existing keys
I posted to so many lists because, this issue is related to all lists, this is an idea for python, this is related to development of python... why are you so much defensive ? i think ideas all important for development of python, software i am sory anyway hope will be helpful. 2008/4/24, Terry Reedy <[EMAIL PROTECTED]>: > Python-dev is for discussion of development of future Python. Use > python-list / comp.lang.python / gmane.comp.python.general for usage > questions. > > > > ___ > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/bvidinli%40gmail.com > -- İ.Bahattin Vidinli Elk-Elektronik Müh. --- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: [EMAIL PROTECTED] yahoo: bvidinli +90.532.7990607 +90.505.5667711 ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] annoying dictionary problem, non-existing keys
2008/4/24 bvidinli <[EMAIL PROTECTED]>: > I posted to so many lists because, > > this issue is related to all lists, > this is an idea for python, > this is related to development of python... > > why are you so much defensive ? > > i think ideas all important for development of python, software > i am sory anyway hope will be helpful. Please consult the documentation first: http://docs.python.org/lib/typesmapping.html . You're looking for the get() method. This attribute of PHP is hardly considered a feature, and is not something Python wishes to emulate. Collin Winter > 2008/4/24, Terry Reedy <[EMAIL PROTECTED]>: > > > > Python-dev is for discussion of development of future Python. Use > > python-list / comp.lang.python / gmane.comp.python.general for usage > > questions. > > > > > > > > ___ > > Python-Dev mailing list > > Python-Dev@python.org > > http://mail.python.org/mailman/listinfo/python-dev > > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/bvidinli%40gmail.com > > > > > > -- > İ.Bahattin Vidinli > Elk-Elektronik Müh. > --- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin, www.skype.com) > msn: [EMAIL PROTECTED] > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 > ___ > > > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/collinw%40gmail.com > ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com