Hi,  
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> KeyError: 'a'
>  
> And it's just as annoying as in PHP. Actually, probably more annoying
> :). But it has .get() which solves the problem usually, albeit in a bit
> more verbose way. Also, Python has defaultdict which I would usually use
> when I need keys to be created automatically.



Ah, ok sorry about that…

This means then, that Go is less strict about this than Python.

Consider this:
http://play.golang.org/p/Qbc0bEBsKa
--  
Christoph Hochstrasser
http://twitter.com/hochchristoph | http://christophh.net | 
https://github.com/CHH



Am Mittwoch, 01. August 2012 um 19:54 schrieb Stas Malyshev:

> Hi!
>  
> > I've looked a bit into other languages (Ruby, Python, Go) and
> > all of them do not generate an error when an undefined dict/hash/map key is 
> > accessed.
>  
>  
>  
> Python would definitely throw an exception:
>  
> > > > a = {}
> > > > a
> > >  
> >  
>  
>  
> {}
> > > > print a['a']
> > >  
> >  
>  
>  
>  
> --  
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227




--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to