Path: csiph.com!usenet.pasdenom.info!news.albasani.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'output': 0.04; 'subject:Python': 0.05; 'float': 0.05; 'means,': 0.07; 'python': 0.09; 'cc:addr:googlegroups.com': 0.09; 'input,': 0.09; 'cc:addr:python-list': 0.10; 'input.': 0.16; 'quadratic': 0.16; 'solver.': 0.16; 'variable.': 0.16; 'wrote:': 0.17; 'integer': 0.17; 'input': 0.18; 'code.': 0.20; 'variable': 0.20; 'email addr:gmail.com>': 0.20; 'example': 0.23; '>': 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '3.0': 0.27; 'message- id:@mail.gmail.com': 0.27; 'types.': 0.29; 'skip:& 10': 0.29; 'probably': 0.29; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'but': 0.36; 'possible': 0.37; 'bad': 0.37; 'supporting': 0.37; 'does': 0.37; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'supports': 0.38; 'some': 0.38; 'think': 0.40; "you'll": 0.62; 'different': 0.63; 'ever': 0.63; 'skip:n 10': 0.63; 'believe': 0.69; 'benefit': 0.70; '2013': 0.84; 'careful': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=4CXkWrztp1kAB54xXyyLaFakDx42tPA0IeVfUJf3RxQ=; b=sxSbiLq7d24EexjhXvLkwOwAQpabeaznTvqAYQXQnjHSSPEw2WPCVInDzZcjof66oB p9/lg5nesu1RHewxCPf7QOBoQHRobeAeuWC/zII/gealCyXyk6p06+XKonfap7DmqskR jwOuJ/QtAldVoTCL6EBpRITyDILeK3HddVwDdbn0xVkefpotfZBcJ2C4yYpcHS5+5c9D e3jExxb7rsLtWADqg1YpM0411XBM1TgE/EU1R/GR/UwEuT1nrBXkHmeCLoHeXD89bIbQ WDFHb7ghJZTb81lmegbT0+EP7PEq1+Da6N0S1zjcBOnYiX2g/Aaqo39w3MrJahjrB/nA qvxQ== X-Received: by 10.112.28.169 with SMTP id c9mr3786016lbh.84.1361752160645; Sun, 24 Feb 2013 16:29:20 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <8eadd52c-d533-4333-8c7f-7bf3a6d7b046@googlegroups.com> <9p1ii899tkalvfd1cl7sneoqa9t1cqh4oj@invalid.netcom.com> <5129482F.3080402@gmail.com> <512a5199$0$29998$c3e8da3$5496439d@news.astraweb.com> <5a3bf25b-a08b-4084-a940-e1fd05a1045d@googlegroups.com> <2e9471ad-8320-4f7f-80ba-cd5a7f8f013d@googlegroups.com> From: Joshua Landau Date: Mon, 25 Feb 2013 00:28:40 +0000 Subject: Re: Python Newbie To: piterrr.dolinski@gmail.com Content-Type: multipart/alternative; boundary=bcaec554d832ceb21404d681a119 Cc: Python , comp.lang.python@googlegroups.com 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: 88 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361752168 news.xs4all.nl 6931 [2001:888:2000:d::a6]:42864 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39829 --bcaec554d832ceb21404d681a119 Content-Type: text/plain; charset=ISO-8859-1 On 25 February 2013 00:08, wrote: > > For example (I believe it's already been mentioned) "declaring" intX > with some integer value does *nothing* to maintain > > > > X as an integer: > > > > --> intX = 32 > > > > --> intX = intX / 3.0 > > > > --> intX > > > > 10.6666666666 > > > > Yes I did see that it is possible to redefine the type of a variable. But > I don't think I would ever do this intentionally; need to be really careful > with Python. Not necessarily. Python duck types. If you don't know what that means, Google's got a ton on it. Take a look at my really bad quadratic equation solver. It supports integer input, float input and complex input. It will output a list of two floats or complex numbers. That's a use for having one variable have different types. You'll find thousands of parallels in real, working code. Hence, you don't really need to be careful. You'd probably benefit if you stopped thinking of supporting type-changing as "dangerous" and started thinking of it as "useful". --bcaec554d832ceb21404d681a119 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On 25 February 2013 00:08, <piterrr.dolinski@g= mail.com> wrote:
> For example (I believ= e it's already been mentioned) "declaring" intX with some int= eger value does *nothing* to maintain
>
> X as an integer:
>
> --> intX =3D 32
>
> --> intX =3D intX / 3.0
>
> --> intX
>
> 10.6666666666
>

Yes I did see that it is possible to redefine the type of a variable.= But I don't think I would ever do this intentionally; need to be reall= y careful with Python.

Not=A0necessar= ily.

Python duck types. If you don't know wh= at that means, Google's got a ton on it.

Take a look at my really bad quadratic equation solver. It supports = integer input, float input and complex input. It will output a list of two = floats or complex numbers.

That's a use for having one variable ha= ve different types. You'll find thousands of parallels in real, working= code.

Hence, you don't really nee= d to be careful. You'd probably=A0benefit=A0if you stopped thinking of = supporting type-changing as "dangerous" and started thinking of i= t as "useful".
--bcaec554d832ceb21404d681a119--