CodeSOD: Convenience

Casey works with some pretty courteous and forward thinking Python developers. They want to make sure that using their APIs are as convenient as possible, and make sure to provide all sorts of useful convenience methods. Like this one:

@property def request(self): """ just for convenience """ return self

For the non-Python folks, self is the Python equivalent of this in other languages, and it has to be passed as a parameter because Python is weird. So this method allows you to call request on an object to get the object you just called request on.

As Casey describes it: "That's pretty convenient!"

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!

This post originally appeared on The Daily WTF.

Leave a Reply

Your email address will not be published.