[Tutor] (no subject)

Kai Bojens kb at kbojens.de
Wed Apr 25 14:50:21 EDT 2018


On 25/04/2018 –– 12:19:28PM -0600, Mats Wichmann wrote:
> I presume that's pseudo-code, since it's missing punctuation (commas
> between elements) and the country codes are not quoted....

Yes, that was just a short pseudo code example of what I wanted to achieve. 
 
> you don't actually need to check (there's a Python aphorism that goes
> something like "It's better to ask forgiveness than permission").
 
> You can do:
 
> try:
>     result[login_auth]['Countries'].append(login_country)
> except KeyError:
>     # means there was no entry for login_auth
>     # so add one here

I see. That'd be better indeed. The try/except concept is still rather new to me
and I still have to get used to it. 

Thanks for your hints! I'm sure that I can work with these suggestions ;)


More information about the Tutor mailing list