Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'encouraging': 0.07; 'mysql,': 0.07; 'pretend': 0.07; 'python': 0.09; '(although': 0.09; 'postgresql,': 0.09; 'rows': 0.09; 'sep': 0.09; 'programmer': 0.11; "wouldn't": 0.11; 'expect,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterable': 0.16; 'iterating': 0.16; 'length,': 0.16; 'parameter,': 0.16; 'plus,': 0.16; 'stuff)': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'tries': 0.17; 'code,': 0.18; 'code.': 0.20; 'sort': 0.21; 'received:209.85.214.174': 0.21; 'subject:Questions': 0.22; "i'd": 0.22; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'separate': 0.27; 'question': 0.27; 'core': 0.27; 'message- id:@mail.gmail.com': 0.27; 'trouble': 0.28; 'run': 0.28; 'embed': 0.29; 'far.': 0.29; 'statements': 0.29; 'things,': 0.29; 'unlikely': 0.29; 'probably': 0.29; 'class': 0.29; 'query': 0.30; '(and': 0.32; 'system,': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'sometimes': 0.35; 'table': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'really': 0.36; 'but': 0.36; 'should': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'first': 0.61; "you'll": 0.62; 'worth': 0.63; 'email addr:gmail.com': 0.63; 'visit': 0.64; 'decided': 0.65; 'limit': 0.65; 'frequently': 0.65; 'finally': 0.66; 'guaranteed': 0.76; 'otten': 0.84; 'seldom': 0.84; 'subject:Interview': 0.84; 'inefficient': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=o+pNnfcAQI+/oso82H5pGAQZlKYKSKuxAxELB3JQHqY=; b=wQaP3Ze1fyAIwR9sUwcIxL8qftAPUNfSOQK4dtQUjvqWm392QpXa2aSxTFErRFuYb+ Tovv4Y49gMVNfrwj5fQNbTyztjJss8iClOVYOpCYz0E2BnqSE6RtPDA0RD7wcrfflTtE s2EVW8AejBtDMHq0X/x1wS/Wv11NQ/MO47nd5yDgNK4DUAlXdpKFeBjJdFErnBaL35jB Z7M2I0Lga+dBg3/bdq2un0pu/9veuXf0Wsa+y+BfHCaTSrktO/87isTSALbcj8AB0DVv WitbBdtTRbnjA/f/RAPW/mA56CiMqHZ2SO0FBmSKzlGl+uPOR2j4bflDDlYO1IJg8hIt qojA== MIME-Version: 1.0 In-Reply-To: References: <1193768041.349129.26350@v3g2000hsg.googlegroups.com> Date: Thu, 6 Sep 2012 00:34:42 +1000 Subject: Re: Python Interview Questions From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346855687 news.xs4all.nl 6903 [2001:888:2000:d::a6]:56126 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28502 On Thu, Sep 6, 2012 at 12:21 AM, Peter Otten <__peter__@web.de> wrote: > charvigroups@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