Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31290

Re: What's the tidy/elegant way to protect this against null/empty parameters?

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.python
Subject Re: What's the tidy/elegant way to protect this against null/empty parameters?
References <1b8tk9-un9.ln1@chris.zbmc.eu>
Date 2012-10-15 04:49 -0700
Message-ID <7xhapwc5uy.fsf@ruckus.brouhaha.com> (permalink)
Organization Nightsong/Fort GNOX

Show all headers | View raw


tinnews@isbd.co.uk writes:
> I want to fix an error in some code I have installed, however I don't
> really want to just bodge it. ...
> Now its *probably* something higher up the tree causing the problem
> (it's only one particular image in 20 thousand or so that breaks
> things) but I really want to just get things working.  

That means you do really want to just bodge it, doesn't it?  (I'm
reading "bodge" as something like "kludge" but maybe it means something
different.)

> So, what's the neatest way to protect the get_text() method from empty
> data?

I'd say the use of None as a picture is already a code smell: figure out
where it is coming from, and fix it.  Or, if you want to just bodge it
(by checking for None and returning the empty string or something)),
then try it and see if it helps.  I'm assuming this is something
noncritical that you're running on your own computer for convenience.  I
wouldn't ship code to a customer without a more careful fix.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

What's the tidy/elegant way to protect this against null/empty parameters? tinnews@isbd.co.uk - 2012-10-15 12:23 +0100
  Re: What's the tidy/elegant way to protect this against null/empty parameters? Paul Rubin <no.email@nospam.invalid> - 2012-10-15 04:49 -0700
  Re: What's the tidy/elegant way to protect this against null/empty parameters? Chris Rebert <clp2@rebertia.com> - 2012-10-15 04:58 -0700
  Re: What's the tidy/elegant way to protect this against null/empty parameters? Roy Smith <roy@panix.com> - 2012-10-15 08:00 -0400
  Re: What's the tidy/elegant way to protect this against null/empty parameters? Miki Tebeka <miki.tebeka@gmail.com> - 2012-10-15 06:33 -0700
  Re: What's the tidy/elegant way to protect this against null/empty parameters? Terry Reedy <tjreedy@udel.edu> - 2012-10-15 11:45 -0400
  Re: What's the tidy/elegant way to protect this against null/empty parameters? Marco Nawijn <nawijn@gmail.com> - 2012-10-16 03:07 -0700
    Re: What's the tidy/elegant way to protect this against null/empty parameters? tinnews@isbd.co.uk - 2012-10-16 14:44 +0100

csiph-web