Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.135 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.74; '*S*': 0.01; 'received:66.35': 0.09; 'am,': 0.13; 'wrote:': 0.15; 'operators,': 0.16; 'def': 0.16; 'math': 0.21; 'header:In-Reply-To:1': 0.22; 'stuff': 0.22; 'missed': 0.24; 'import': 0.29; 'skip:- 30': 0.30; 'object': 0.30; 'subject:?': 0.31; 'usual': 0.32; 'named': 0.32; 'to:addr:python- list': 0.34; 'header:User-Agent:1': 0.34; 'there': 0.34; 'file': 0.36; 'addition,': 0.36; 'but': 0.37; 'received:192': 0.38; 'subject:: ': 0.38; 'steven': 0.38; 'think': 0.38; 'received:192.168.1': 0.39; 'to:addr:python.org': 0.39; 'your': 0.60; 'customized': 0.76; '01:35': 0.84; 'can:': 0.91; 'something.': 0.91; 'subject:there': 0.91 Date: Sat, 16 Jul 2011 08:56:44 -0700 From: Gary Herron User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Is there a way to customise math.sqrt(x) for some x? References: <4e214d5a$0$29975$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <4e214d5a$0$29975$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310832355 news.xs4all.nl 23979 [2001:888:2000:d::a6]:45605 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9626 On 07/16/2011 01:35 AM, Steven D'Aprano wrote: > I have a custom object that customises the usual maths functions and > operators, such as addition, multiplication, math.ceil etc. > > Is there a way to also customise math.sqrt? I don't think there is, but I > may have missed something. > > Create a file named myMath.py containing: -------------------------------------- from math import * def sqrt(x): ...whatever you want... --------------------------------------- Then you can: import math #to get normal stuff and import myMath # to get your customized stuff or import myMath as math # to get your stuff but named math. Gary Herron