Python Interview Questions

Chris Angelico rosuav at gmail.com
Wed Sep 5 10:34:42 EDT 2012


On Thu, Sep 6, 2012 at 12:21 AM, Peter Otten <__peter__ at web.de> wrote:
> charvigroups at gmail.com wrote:
>
>> Finally I have decided to put best interview question and answers.
>>
>> Please visit http://***/web/CorePython/ for core python
>> and http://***/web/PythonAdvanced/ for advanced python
>
> Hm, are you a reformed PHP programmer who has never heard of sql injection
> attacks? The first "advanced" answer (and probably all the database-related
> stuff) should definitely be withdrawn.

I wouldn't go that far. The 'name' parameter, I would expect, would be
a constant. However, this strikes me as encouraging some really
inefficient code, like iterating over all the rows in a table with N+1
queries (one to get the length, then a separate query for each row).
Plus, use of limit without order by is not guaranteed (although since
this is specific to MySQL, it's unlikely you'll run into trouble - but
PostgreSQL, with its MVCC storage system, frequently reorders rows in
a table).

As a general rule, I don't like SQL builders. I'd prefer to directly
embed SQL statements in my code. Although sometimes a class can
helpfully manage some things, it's seldom worth having something that
tries to pretend a table is iterable in that sort of way.

ChrisA



More information about the Python-list mailing list