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


Groups > comp.lang.python > #28953

avoid the redefinition of a function

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jabba.laci@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'function,': 0.07; 'python': 0.09; 'called.': 0.09; 'received:mail- lpp01m010-f46.google.com': 0.09; 'url:github': 0.09; 'def': 0.10; '(like': 0.15; 'redefinition': 0.16; 'ubuntu.': 0.16; 'thanks,': 0.18; 'script': 0.24; 'allows': 0.25; 'skip:# 10': 0.27; 'functions.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.215.46': 0.30; 'function': 0.30; 'print': 0.32; 'function.': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'add': 0.36; 'but': 0.36; 'should': 0.36; 'received:209': 0.37; 'interested.': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'little': 0.39; 'header:Received:5': 0.40; 'here': 0.65; 'p.s.:': 0.84; 'grew': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=lX8+zqUhi5ThqoofuFO4VgpfEy6iAroPC8RQxFgU20g=; b=Rab+t8TBeWvwvagplwjLc0ULTd4DNl9s/Q6LoTp5uN1C41IPCHnv7fWGrZp5S4sr1c 9i25ikZ9ODjUttrtbTYzaLaxPa4gDKkOcA3Jlk9HQaL2Bg1b6nY7TnNCceaH+QiDfuWR dWdgcS5uJcnH2reTiqoiaCN49ShMbtONr7waCPnMcCFkkfUeOE9Bn/AXKktBCTSe07an LgcMUKd2H3MJ4AHNaaNgbyRepoTtxanliLMJn+FBuxgTsMNkdJi1jRQaenskn2nl6ps1 kjtt6Tt/Lq5C+FduUUcOnjG5S5PTTfqZQSqDRu1Rwd7L5TNhbaDONoul2xZjB7cFeMtH m3eg==
MIME-Version 1.0
From Jabba Laci <jabba.laci@gmail.com>
Date Wed, 12 Sep 2012 14:56:12 +0200
Subject avoid the redefinition of a function
To Python mailing list <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 <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.554.1347454594.27098.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1347454594 news.xs4all.nl 6974 [2001:888:2000:d::a6]:52462
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28953

Show key headers only | View raw


Hi,

I have an installer script that contains lots of little functions. It
has an interactive menu and the corresponding function is called. Over
time it grew long and when I want to add a new function, I should give
a unique name to that function. However, Python allows the
redefinition of functions:

#!/usr/bin/env python

def step_1():
    print 1

def step_1():
    print 2

step_1()

This will call the 2nd function. Now my functions are called step_ID
(like step_27(), step_28(), etc.). How to avoid the danger of
redefinition? Now, when I write a new function, I search for its name
to see if it's unique but there must be a better way.

Thanks,

Laszlo
P.S.: the script is here ( https://github.com/jabbalaci/jabbatron ) if
you are interested. It's made for Ubuntu.

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


Thread

avoid the redefinition of a function Jabba Laci <jabba.laci@gmail.com> - 2012-09-12 14:56 +0200
  Re: avoid the redefinition of a function Ramchandra Apte <maniandram01@gmail.com> - 2012-09-12 06:15 -0700
    Re: avoid the redefinition of a function Alister <alister.ware@ntlworld.com> - 2012-09-12 14:04 +0000
  Re: avoid the redefinition of a function Ramchandra Apte <maniandram01@gmail.com> - 2012-09-12 06:15 -0700

csiph-web