PyWart: NameError trackbacks are superfluous

Tim Chase python.list at tim.thechases.com
Sat Mar 16 19:36:15 EDT 2013


On 2013-03-16 15:39, Rick Johnson wrote:
> On Saturday, March 16, 2013 4:19:34 PM UTC-5, Oscar Benjamin wrote:
> >   # tmp.py
> >   def broken(x):
> >       if x > 2:
> >           print(x)
> >       else:
> >           print(undefined_name)
> > 
> >   broken(1)
> 
> Why would anyone write code like that?

Because, in the real world, that example looks something like

  def broken(intelligence_level):
    if intelligence_level < 100:
      return dumb_down(intellegence_level)
    else:
      return make_harder(intelligence_level)
  broken(op.iq)

Pylint, pyflakes or some other such linter should catch it, but this
happens ALL THE TIME in actual development, occasionally leaking into
production. 

-tkc






More information about the Python-list mailing list