From 3e8a638793af3b001843055e8928cdb79e8afb79 Mon Sep 17 00:00:00 2001 From: Alec Warner Date: Sat, 13 Jan 2007 19:25:20 +0000 Subject: fix tabs with patch from Grobian and bug # 161911, fix developing a bit svn path=/main/trunk/; revision=5633 --- DEVELOPING | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'DEVELOPING') diff --git a/DEVELOPING b/DEVELOPING index 0530d99cf..01eb9bd42 100644 --- a/DEVELOPING +++ b/DEVELOPING @@ -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). -- cgit v1.2.3-1-g7c22