On Fri, Jul 29, 2016 at 6:01 AM, Rob Gaddi <rgaddi@highlandtechnology.invalid> wrote: > Chris Angelico wrote: > >> On Sat, Jul 23, 2016 at 9:13 PM, Marko Rauhamaa <ma...@pacujo.net> wrote: >>>> One less thing to be programmed, one less thing for the user to >>>> remember. Just require pass any time you have an empty block, rather >>>> than try to remember where it is required and were it is optional. >>> >>> Actually, the requirement of a dummy statement is a slight annoyance for >>> the programmer. After deleting a statement, you must see if you have to >>> put in a pass statement. And after adding a statement, you may feel the >>> urge to remove the redundant pass statement. >> >> How often do you actually need empty statements, adding stuff, >> removing stuff, like that? Possibly there's a code smell here. >> >> ChrisA > > Yeah, all the time. > > try: > return self.cache[key] > except KeyError: > pass > > lots... of... code... > self.cache[key] = newval > return newval
It's common to *use* empty statements. What I'm saying is, do you often have the situation Marko raises, where you need an empty statement to which you add stuff and remove stuff, thus needing the insertion/removal of 'pass'? Normally, you use 'pass' in a situation where it's always going to remain an empty block. ChrisA -- https://mail.python.org/mailman/listinfo/python-list