<html style="direction: ltr;">
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;"
bidimailui-detected-decoding-type="latin-charset" text="#000000"
bgcolor="#FFFFFF">
Here's one important difference in behavior:<br>
<br>
To call db.cursor, db cannot be null, and moreover has to have a
"cursor" method that does something useful. To call get_cursor(db),
db can be null or anything. It might be important for you to support
a null case, for example if you're returning a mock cursor, or if
you want to automatically create the DB, or use a global DB
singleton, or whatever.<br>
<br>
OK, so we're "playing with text" but differences are differences and
they have consequences. They might be small and subtle, but in huge
programs with thousands of lines of code these become important. I
know Garret's main point in his blog is that this adds clarity, and
I don't deny that. There is a relationship between clarity and power
in coding.<br>
<br>
I find that making such decisions early on is far more important in
dynamic languages, because you have no automatic "text" refactoring
tool that static languages have, like Eclipse's Java refactoring,
where you can change a signature for a method on the fly for your
entire codebase. In Python, you are really really stuck with the
"text" and your best tool is search-and-replace-with-regex, but
surely that won't catch the weird dynamic things that your program
does with the "text." So many times in my life I had to deal with
SQL code that doesn't perform well under load, and requires us to
switch to a connection pool, but then you need to find all the
places in the code where you get a connection and change them, but
it takes 3 days, and you missed a few spots, and the fun
continues...<br>
<br>
<div class="moz-cite-prefix">On 11/16/2012 10:20 AM, Carl Karsten
wrote:<br>
</div>
<blockquote
cite="mid:CADmzSShL+rRTjr953DxdVdSooomMZBp++r30w-0xGNWmqmBw_w@mail.gmail.com"
type="cite">
<pre wrap="">
wat?
In the calling code, db.cursor() and get_cursor(db) are the same.
What they do/return/affect can be the same, and there is no reason one
syntax/notation should imply some different behavior.</pre>
</blockquote>
<br>
</body>
</html>