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


Groups > comp.lang.python > #55247

python function parameters, debugging, comments, etc.

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cbf123@mail.usask.ca>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; '(especially': 0.07; 'debug': 0.07; 'nested': 0.07; 'advice.': 0.09; 'image,': 0.09; 'instance.': 0.09; 'parameter': 0.09; 'python': 0.11; 'def': 0.12; 'dictionary.': 0.16; 'expecting': 0.16; 'instances,': 0.16; 'subject:etc.': 0.16; 'subject:parameters': 0.16; 'to:name:python list': 0.16; 'types,': 0.16; 'subject:python': 0.16; 'thanks,': 0.17; 'code.': 0.18; 'bit': 0.19; 'trying': 0.19; 'passing': 0.19; 'programming': 0.22; 'header:User-Agent:1': 0.23; 'instance,': 0.24; 'specify': 0.24; 'fairly': 0.24; 'looks': 0.24; "i've": 0.25; 'this:': 0.26; 'function': 0.29; 'fixed': 0.29; 'chris': 0.29; "i'm": 0.30; 'code': 0.31; 'comments': 0.31; 'context,': 0.31; 'stuff': 0.32; 'actual': 0.34; 'problem': 0.35; 'but': 0.35; 'list': 0.37; 'being': 0.38; 'expected': 0.38; 'skip:o 20': 0.38; 'to:addr :python-list': 0.38; 'fact': 0.38; 'realize': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'received:unknown': 0.61; 'new': 0.61; 'took': 0.61; "you're": 0.61; 'hoping': 0.75; "else's": 0.84; 'id,': 0.84
X-Cloudmark-SP-Filtered true
X-Cloudmark-SP-Result v=1.1 cv=BkBxTXsSVzyY7C2joSQK+JNK4mJr1It1Skr7Xe8+Jh8= c=1 sm=2 a=7E2d2x4H2BEA:10 a=oTNS_HmmxIcA:10 a=BLceEmwcHowA:10 a=8nJEP1OIZ-IA:10 a=3tzgUIiB9LSlwt-V3iQA:9 a=wPNLvfGTeEIA:10
Date Tue, 01 Oct 2013 16:54:00 -0600
From Chris Friesen <cbf123@mail.usask.ca>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8
MIME-Version 1.0
To python list <python-list@python.org>
Subject python function parameters, debugging, comments, etc.
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.576.1380668112.18130.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1380668112 news.xs4all.nl 15868 [2001:888:2000:d::a6]:51636
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:55247

Show key headers only | View raw


I've got a fair bit of programming experience (mostly kernel/POSIX stuff in C).  I'm fairly new to python though, and was hoping for some advice.

Given the fact that function parameters do not specify types, when you're looking at someone else's code how the heck do you know what is expected for a given argument?  (Especially in a nontrivial system where the parameter is just passed on to some other function and may not be evaluated for several nested function calls.)

Is the recommendation to have comments for each function describing the expected args?

I was trying to debug some stuff that someone else wrote.  It turned out that the problem was in code like this:



def rebuild_instance(self, context, instance, image, ...)
	request_spec = scheduler_utils.build_request_spec(context, image, [instance])
	...stuff...
	other_function(...,image,...)


where build_request_spec looks like:

def build_request_spec(ctxt, image, instances):
    ...etc...


and it took me a while to realize that rebuild_instance() was being passed the image ID (basically just a string), and other_function() was expecting the image ID, but build_request_spec() was expecting the actual image dictionary.

It also took me a while to realize that that build_request_spec() was expecting a list of instances, while rebuild_instance() was passing in a single instance.  That one is already fixed in the above code.


So what's the recommended way of dealing with stuff like this in larger projects with many developers?

Thanks,
Chris

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


Thread

python function parameters, debugging, comments, etc. Chris Friesen <cbf123@mail.usask.ca> - 2013-10-01 16:54 -0600
  Re: python function parameters, debugging, comments, etc. Rotwang <sg552@hotmail.co.uk> - 2013-10-02 00:45 +0100
    Re: python function parameters, debugging, comments, etc. Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-02 11:15 +0100
      Re: python function parameters, debugging, comments, etc. Rotwang <sg552@hotmail.co.uk> - 2013-10-02 14:52 +0100

csiph-web