diff options
author | 2007-01-13 19:25:20 +0000 | |
---|---|---|
committer | 2007-01-13 19:25:20 +0000 | |
commit | 3e8a638793af3b001843055e8928cdb79e8afb79 (patch) | |
tree | e70a10ae0a11bc094db9abf2b66d797f9af41429 /DEVELOPING | |
parent | make sure people call addread/addwrite/adddeny/addpredict correctly (diff) | |
download | portage-idfetch-3e8a638793af3b001843055e8928cdb79e8afb79.tar.gz portage-idfetch-3e8a638793af3b001843055e8928cdb79e8afb79.tar.bz2 portage-idfetch-3e8a638793af3b001843055e8928cdb79e8afb79.zip |
fix tabs with patch from Grobian and bug # 161911, fix developing a bit
svn path=/main/trunk/; revision=5633
Diffstat (limited to 'DEVELOPING')
-rw-r--r-- | DEVELOPING | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -56,16 +56,12 @@ Generally you can do two things here, if you are messing with defaults.. dict.get(foo, some_default) will try to retrieve foo from dict, if there is a KeyError, will insert foo -into dict with the value of some_default. This method is preferred in most cases. - -You can also do something like: +into dict with the value of some_default. This method is preferred in cases where +you are messing with defaults: try: dict[foo] - ...stuff here.. except KeyError: - print "holy cow we totally expected a keyerror here" + dict[foo] = default_value -in most instances however you are only catching the KeyError to set a default, -in which case you should be using dict.get() or telling the user they are missing -a required dict key. +The get call is nicer (compact) and faster (try,except are slow). |