Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #50526

Re: Understanding other people's code

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'scripts': 0.03; 'interpreter': 0.05; '(so': 0.07; 'interpreter.': 0.07; 'subject:code': 0.07; 'tkinter': 0.07; 'tackle': 0.09; 'unrecognized': 0.09; 'project,': 0.12; 'up-to-date': 0.14; 'code),': 0.16; 'command-line': 0.16; 'definition.': 0.16; 'docstring': 0.16; 'dumps': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'guessing': 0.16; 'itertools': 0.16; 'itself,': 0.16; 'namespace.': 0.16; 'say.': 0.16; 'statements,': 0.16; 'sat,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'file,': 0.19; 'import': 0.22; 'source': 0.25; 'possibly': 0.26; 'references': 0.26; 'this:': 0.26; 'second': 0.26; 'least': 0.26; 'skip:" 20': 0.27; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'strongly': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'getting': 0.31; 'that.': 0.31; '13,': 0.31; 'subject:other': 0.31; 'anyone': 0.31; 'file': 0.32; 'stuff': 0.32; 'third': 0.33; 'comment': 0.34; "i'd": 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'idle': 0.36; 'library.': 0.36; 'starting': 0.37; 'to:addr:python- list': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'skip:u 10': 0.60; 'tips': 0.61; 'entire': 0.61; "you're": 0.61; 'first': 0.61; "you'll": 0.62; 'different': 0.65; 'techniques': 0.66; 'lose': 0.68; 'overall': 0.69; 'jul': 0.74; 'lack': 0.78; 'yourself': 0.78; 'gain': 0.79; 'actually,': 0.84; 'grabbing': 0.84; 'nice,': 0.84; 'seriously,': 0.84; 'subject:people': 0.84; 'understand,': 0.84; 'wipe': 0.84; '2013': 0.98
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:content-transfer-encoding; bh=n4ADwX/jBJOg3y+myGfIFA2ux5Yc44/gFvWkXvo6hvs=; b=vjeH4KxdseDfYMEAmb3JdcBJMxomEpNAbHAxPeNxvoprzXHY4rA+dBzr3YiB/68gVi rG0GQ4ccL9Vgamd80s0BfYYKDYUAb683Z2YGf5FpG/9OQOv7Y7sHXlDQEXLboETIu6wg apQDOnW4m431wfUVFl3yN/+mMmBAqXDYyn4DWKhx8GoQbrmeKlU8++9gSLq3cU4FHFG8 n8ndQntO+QrGn9U9lXF09F8opBuZFH0Hg5hK7OjO7BEDGdS997Ofmp6AQ87JZkc3cdVP WMuzQhEOU09shG9DCK2c0o1W5p2Oib9N4DNLNgIdnrdiEn2uCgLnAMfmmhBUDDC55k/F D+KA==
MIME-Version 1.0
X-Received by 10.58.187.4 with SMTP id fo4mr24657459vec.55.1373640375853; Fri, 12 Jul 2013 07:46:15 -0700 (PDT)
In-Reply-To <66c25416-eaa5-4ac1-a71d-2b2948dec2fb@googlegroups.com>
References <66c25416-eaa5-4ac1-a71d-2b2948dec2fb@googlegroups.com>
Date Sat, 13 Jul 2013 00:46:15 +1000
Subject Re: Understanding other people's code
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4633.1373640379.3114.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1373640379 news.xs4all.nl 15966 [2001:888:2000:d::a6]:37459
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50526

Show key headers only | View raw


On Sat, Jul 13, 2013 at 12:22 AM, L O'Shea <lo0446@my.bristol.ac.uk> wrote:
> I'm starting to get pretty worried about my lack of overall progress and so I wondered if anyone out there had some tips and techniques for understanding other peoples code. There has to be 10/15 different scripts with at least 10 functions in each file I would say.


The first thing I'd recommend is getting yourself familiar with the
language itself, and (to some extent) the standard library. Then
you'll know that any unrecognized wotzit must have come from your own
project, so you'll be able to search up its definition. Then I'd
tackle source files one at a time, and look at the very beginning. If
the original coder was at all courteous, each file will start off with
a block of 'import' statements, looking something like this:

import re
import itertools

Or possibly like this:

from itertools import cycle, islice

Or, if you're unlucky, like this:

from tkinter import *

The first form is easy. You'll find references to "re.sub" or
"itertools.takewhile"; the second form at least names what it's
grabbing (so you'll find "cycle" or "islice" in the code), and the
third just dumps a whole lot of stuff into your namespace.

Actually, if the programmer's been really nice, there'll be a block
comment or a docstring at the top of the file, which might even be
up-to-date and accurate. But I'm guessing you already know to look for
that. :)

The other thing I would STRONGLY recommend: Keep the interactive
interpreter handy. Any line of code you don't understand, paste it
into the interpreter. Chances are it won't wipe out your entire hard
drive :) But seriously, there is much to gain and nothing to lose by
keeping IDLE or the command-line interpreter handy.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Understanding other people's code "L O'Shea" <lo0446@my.bristol.ac.uk> - 2013-07-12 07:22 -0700
  Re: Understanding other people's code Chris Angelico <rosuav@gmail.com> - 2013-07-13 00:46 +1000
  Re: Understanding other people's code Peter Otten <__peter__@web.de> - 2013-07-12 17:21 +0200
  Re: Understanding other people's code "Eric S. Johansson" <esj@harvee.org> - 2013-07-12 12:04 -0400
  Re: Understanding other people's code Terry Reedy <tjreedy@udel.edu> - 2013-07-12 18:11 -0400
  Re: Understanding other people's code Joel Goldstick <joel.goldstick@gmail.com> - 2013-07-12 19:49 -0400
  Re: Understanding other people's code CM <cmpython@gmail.com> - 2013-07-13 23:58 -0700
  Re: Understanding other people's code Azureaus <lo0446@my.bristol.ac.uk> - 2013-07-15 03:02 -0700
    Re: Understanding other people's code CM <cmpython@gmail.com> - 2013-07-15 12:13 -0700
    Re: Understanding other people's code albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-27 13:13 +0000
      Re: Understanding other people's code Chris Angelico <rosuav@gmail.com> - 2013-07-27 14:41 +0100
  Re: Understanding other people's code asimjalis@gmail.com - 2013-07-15 19:10 -0700
  Re: Understanding other people's code David M Chess <chess@us.ibm.com> - 2013-07-16 14:38 -0400
  Re: Understanding other people's code David Hutto <dwightdhutto@gmail.com> - 2013-07-16 20:05 -0400
  Re: Understanding other people's code David Hutto <dwightdhutto@gmail.com> - 2013-07-19 22:57 -0400
  Re: Understanding other people's code Azureaus <lo0446@my.bristol.ac.uk> - 2013-07-25 09:26 -0700

csiph-web