DISQUS

DISQUS Hello!  The comments on this profile are unclaimed and thus are unverified.

Do they belong to you? Claim these comments.

Ben Finney's picture

Unregistered

Feeds

aliases

  • Ben Finney
  • bignose

Ben Finney

2 weeks ago

in Python Exception Handling Techniques - Doug Hellmann on Doug Hellmann
For the “second exception raised while still cleaning up from first exception” case, it's worth noting that PEP 3134 introduced “chained exceptions” via ‘raise barexception from fooexception’.
1 reply
dhellmann's picture
dhellmann I wasn't aware of that PEP, is it only in 3.x or has it been backported to 2.6 or 2.7?

2 weeks ago

in Is this pylint error message valid or bogus? on t+1
> The vast majority of pythoners use None, but I prefer descriptive strings for default values

If you do that, you're communicating badly.

Python's default arguments mean something very specific, and readers will expect it: “this argument can be omitted, and if so, *this value will be used instead*”. By putting a value there that you never intend on using, you subvert that communication.

Please, if you don't have a good static value to use, just stick with the conventional sentinel value: None.

If you need None for some other purpose (e.g. you need to tell the difference between the default and a user-supplied None), use a clearly-for-no-other-purpose object, such as a module-local name bound to a unique object() instance.

3 weeks ago

in Don’t negotiate on your estimates on t+1
The point, that estimates are not an appropriate target for negotiation, is good and needs to be spread widely. Estimates are like weather forecasts: they're an expression of one's understanding of truth, not a promise or a commitment.

The flip side of that, though, is that we need to be true to that by *revising* an estimate as requirements change, and more importantly as we get a better understanding of the facts that affect our estimate.

We also need to treat estimates more like forecasting: as testable predictions, that can be improved by examining the track record and learning how to estimate better. If we want the recipients of these estimates to trust us, we need to commit to improving our skill at estimating.

3 weeks ago

in When to use globals on t+1
The entrenched aversion to globals is usually specifically about *program*-level globals; i.e. identifiers that cross module boundaries and are almost impossible to track down reliably.

There's nothing wrong with *module*-level globals, which is the largest scope in Python.

3 months ago

in Instead of setting instance attributes within __init__ on t+1
One problem is it's more verbose, and rather unusual. The reader isn't going to expect what you're doing, which is always a negative when deciding whether to be clever in code :-)

Another problem is you've defined only a read-only property: the decorator wraps the getter, but the property has no setter (or deleter or docstring).
1 reply
saluk I have the opposite opinion - __init__ should not be doing anything OTHER than setting the default attributes. When I type a = Object(), I want a to be valid. Putting too much stuff inside of __init__ can make it harder to see why something is actually failing. Sometimes though, I do delegate out to other functions from __init__ which do more work if necessary.

The above just looks like a mess!

9 months ago

in I just wrote another mock object framework. on t+1
Doesn't seem too useful; when the code under test attempts to call expected methods on an instance it'll fail with 'AttributeError'. A mock object should pretend it's the object being mocked, surely?
1 reply
Matt Wilson's picture
Matt Wilson Hi Ben,

I probably should have included a few example uses. Pretend I want to mock an object that has an attribute named ivr_sends which is a list of strings. I'd do this:

mm = BazMock(ivr_sends=['abc', 'def'])

Now my test code can access mm.ivr_sends just fine.

And now pretend you need to mock attributes on attributes:

mm = BazMock(x=BazMock(y=[BazMock(a=1, b=2), BazMock(a=3, b=4)]))

And now I can access mm.x.y[0].a.

For methods, you'd need to graft on definitions like this:

def fake_foo(x):
return "99"

mm.foo = fake_foo

I've been told that there are better mock objects out there, that do stuff like inspect a module or a class and create mocks automatically.

I'm dragging my feet about learning them. Let me know if you find one you like.

9 months ago

in Why Google won’t do evil on The Technology Liberation Front
> There’s no denying that Google has the capacity to do some pretty heinous things with all the sensitive data stored on its servers.

Okay, so we agree that all Google now needs is motivation to do evil; or, phrased differently, lack of motivation to behave virtuously.

> But the relevant question isn’t whether Google could do evil, but whether it realistically will.

Since the information they gather is theirs forever — the users certainly have no practical control over it once it's granted to Google — that “will” becomes “will, ever, at any point in the future”.

> What incentive is there for Google to do anything but keep private data as secure as humanly possible?

Here you make the fallacy of assuming that Google's *current* model is sufficient guarantee that they will *forever* have incentive to be virtuous with the data we give them every day over time.

The correct question is: How likely is it that Google's model, leadership, or shareholder pressures, forever into the future, will always be sufficient to constrain Google to act virtuously with the data gathered on all parties that interact with them over their entire history?
1 reply
Ryan Radia's picture
Ryan Radia Google doesn't keep its users' data forever. It anonymizes search logs after 9 months, and if you have a Gmail account, when you hit "Delete" that data will be completely wiped off Google's servers and its backups within a matter of months.

And it's not even necessary for Google to care about behaving "virtuously." To do anything but safeguard privacy would be suicidal, even if Google's business model were to change down the line. Google can't change it privacy policies to the detriment of its users without their explicit permission.

There are privacy risks to using Google's services, as there are with using any company's services where that company will have possession of personal info. With respect to Google, I think these risks are fairly trivial, but different people have different levels of risk aversion. Fortunately, nobody has to use Google--you don't even have to give Google your IP address to use it search engine (A topic I will be discussing in greater detail soon).

11 months ago

in Google Search Won’t Return Links to cato-at-liberty.org on The Technology Liberation Front
"Dissatisfied? Help us improve" http://www.google.com.au/quality_form has just received this report from me:

=====
I was looking for Cato-at Liberty articles around the same time as a specific article by David Boaz, that I know contains the text "remains a temptation to our current candidates".

The Google result shows the article at David Boaz's own site, but *not* the same article at the URL http://www.cato-at-liberty.org/2008/06/30/our-c...

The cato-at-liberty site should be prominent in the results, as it is linked to by many other sites, and the very same article at a different site appears in the search results.

Specifying "site:cato-at-liberty.org" in the search criteria returns *no* results. The expected behaviour is that the site should have its results along with any others that qualify according to the criteria.

1 year ago

in Pep Turds on jessenoller.com comments
Bah. Two problems with that turd: it should read "filetype=rst", and indentation was not preserved by the comment mechanism.
1 reply
jnoller's picture
jnoller It's ok - my kid has taught me that every turd is special!

1 year ago

in Pep Turds on jessenoller.com comments
Vim is definitely turd-friendly. You've likely seen them: they look like "vim: foo bar=baz :".

I usually include the following Emacs-and-Vim turd in my reStructuredText documents:

..
Local Variables:
mode: rst
coding: utf-8
End:
vim: filetype-rst :
2 replies
Ben Finney Bah. Two problems with that turd: it should read "filetype=rst", and indentation was not preserved by the comment mechanism.
jnoller's picture
jnoller Huh, I didn't know you could embed vim turds into documents.

In seriousness, I sort of dislike embedding editor-specific "nuggets of joy" into documents - I can see why you might do it, but still.

2 years ago

in Microsoft and Novell - Exacerbating an Ideological Divide? on The Technology Liberation Front
The recent Samba team response is clear: the GPL is a zero-sum game -- you exploit open source software for your gain to the detriment of others

That's not how I read the Samba team response at all. In fact they're saying quite the contrary:


One of the fundamental differences between the proprietary software world and the free software world is that the proprietary software world divides users by forcing them to agree to coercive licensing agreements which restrict their rights to share with each other, whereas the free software world encourages users to unite and share the benefits of the software.


The patent agreement struck between Novell and Microsoft is a divisive agreement. It deals with users and creators of free software differently depending on their "commercial" versus "non-commercial" status, and deals with them differently depending on whether they obtained their free software directly from Novell or from someone else.


The GPL sets up a non-zero-sum game, by ensuring that a work can be shared freely by all recipients. Software idea patents attempt to revert to a zero-sum game, by dividing each recipient against the others.

2 years ago

in Samba Blasts Novell on The Technology Liberation Front

Crosbie: The GPL, at its heart, is about ensuring that *all* recipients of the software have the same guaranteed freedoms. Patent extortion payments for *some* of those recipients is divisive and makes the other recipients less free. That's why the GPL speaks explicitly about software patents, and in particular about ensuring patents can't be used against *any* recipient of the software. Novell's deal violates this in spirit; we have yet to see whether it violates it in law.


Noel: Making a payment for a software patent license is very similar to paying an extortion fee to a mob. The patent holder provides nothing of value, except a limited promise not to harm the one who makes the payment. The one who pays the fee gains nothing that they would have had in the absence of this extortion. The fact that someone pays the fee only serves to legitimise this extortion, and encourage the patent holder to attempt further extraction of fees from others.

Returning? Login