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


Groups > comp.lang.python > #18499

Re: python philosophical question - strong vs duck typing

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ether.joe@gmail.com>
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.01; 'python.': 0.04; 'everybody,': 0.07; 'method,': 0.07; 'variable,': 0.07; 'python': 0.08; 'integer,': 0.09; 'php,': 0.09; 'subject:python': 0.10; 'thanks!': 0.14; 'typing': 0.15; 'bit.': 0.16; 'confuses': 0.16; 'cpp': 0.16; 'finney': 0.16; 'type),': 0.16; 'versus': 0.16; 'wording': 0.16; 'cc:addr:python-list': 0.16; 'subject:question': 0.17; 'wrote:': 0.18; 'jan': 0.19; 'cc:no real name:2**0': 0.20; 'so.': 0.22; 'header:In-Reply-To:1': 0.22; 'reference.': 0.23; 'string': 0.24; 'cc:2**0': 0.24; 'object,': 0.24; 'writes:': 0.25; 'code.': 0.26; "i'm": 0.26; 'code,': 0.27; 'variable': 0.28; 'all,': 0.28; 'needed,': 0.28; 'bit': 0.28; 'message- id:@mail.gmail.com': 0.28; 'pass': 0.29; 'compile': 0.29; 'sean': 0.29; 'theoretical': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'closer': 0.30; 'compromise': 0.30; 'object.': 0.30; 'objects.': 0.30; 'throwing': 0.30; 'translator': 0.30; '(e.g.': 0.31; 'ok,': 0.31; 'thanks': 0.31; "i've": 0.31; "didn't": 0.31; 'does': 0.32; 'list': 0.32; 'objects': 0.32; 'tue,': 0.32; "won't": 0.33; 'there': 0.33; 'object': 0.33; 'realize': 0.34; 'duplicate': 0.34; 'integer': 0.34; 'languages': 0.35; '...': 0.36; 'question': 0.36; 'example,': 0.37; 'bound': 0.37; 'subject:skip:p 10': 0.37; 'variables': 0.37; 'but': 0.37; 'reference': 0.37; 'received:google.com': 0.37; 'another': 0.37; 'think': 0.37; 'doing': 0.38; 'using': 0.38; 'references': 0.38; 'some': 0.38; 'screen': 0.38; 'received:209.85': 0.38; 'put': 0.38; 'e.g.': 0.39; 'etc.)': 0.39; 'being': 0.39; 'strong': 0.39; 'received:209': 0.40; 'type': 0.61; 'types': 0.61; 'custom': 0.61; 'your': 0.61; '2012': 0.67; 'gain': 0.75; 'game,': 0.84; 'ignorant': 0.84; 'terminology': 0.84; '-->': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=VgNl54Xsg1vHao9EmbcDLEsicbFc33+e9kaszrOaWcg=; b=RvMmxgx2oprYum7EGJ4zAXKiTP+FGgDciguAPf670VQijsQW9lfX9UTtkPMoFOIaFI ujL7RzV6LPRTK0BbZMG9bLoyrXv/+V5eBPULvg8OAUTmpRs/+U6rgIpkaej2EttCOYrT asEqtvk/FQLU2ucbIYvcXrUetufHxtyYfElDk=
MIME-Version 1.0
In-Reply-To <87wr98zaiy.fsf@benfinney.id.au>
References <mailman.4361.1325614408.27778.python-list@python.org> <87wr98zaiy.fsf@benfinney.id.au>
Date Wed, 4 Jan 2012 11:30:39 -0300
Subject Re: python philosophical question - strong vs duck typing
From Sean Wolfe <ether.joe@gmail.com>
To Ben Finney <ben+python@benfinney.id.au>
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.4409.1325687441.27778.python-list@python.org> (permalink)
Lines 59
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1325687441 news.xs4all.nl 6898 [2001:888:2000:d::a6]:43335
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18499

Show key headers only | View raw


On Tue, Jan 3, 2012 at 7:28 PM, Ben Finney <ben+python@benfinney.id.au> wrote:
> Sean Wolfe <ether.joe@gmail.com> writes:
>
>> Hello everybody, I'm a happy pythonista newly subscribed to the group.
>
> Welcome!

Thanks! and thanks to all, hjaha.

>
>> I have a theoretical / philosophical question regarding strong vs duck
>> typing in Python. Let's say we wanted to type strongly in Python
>
> There may be an unstated assumption there, and your wording confuses me.
>

yep, probably. I am throwing around terminology a bit. Here's another
attempt -->

If I am willing to create some python code, when needed, where when I
create a variable, let's say an integer, that it will be for all time
an integer, and also that a method that returns say a Sprite custom
object, and will for all time return only a Sprite object ... , does
this get me significantly closer to being able to compile to C++?

I am just thinking in my brain about the differences between cpp and
python, and if there is a way to compromise a bit on the python-ness
to get closer to cpp, but still be able to keep a lot of the goodness,
then put in a translator or converter to cpp and gain performance by
using cpp code. Sounds like Rpython, cython, shedskin are doing a lot
or all of this, so lots to study up on.

>
> “Strongly-typed” is one end of a spectrum whose opposite end is
> “weakly-typed”. Weakly-typed objects are in languages like e.g. PHP,
> where an integer object can be added to a string object.

Ah ok, I didn't realize this distinction. Now I grok it a bit better.

> Python does not have variables in the sense of languages like C; rather,
> Python has references bound to objects. A reference (e.g. a name, or a
> list index, etc.) never has a type. An object always has a type.

yeah I've been learning a lot about this ... at times I have to
're-create' a variable to avoid modifying the original value as well.
For example, when I pass a 'screen' object in my game, at times I have
to duplicate the screen in the new method, then work on the duplicate,
otherwise I will be using the original screen by reference.

> You may be thinking of “static typing” (identifiers have types, and
> won't allow themselves to refer to an object of a different type),
> versus “dynamic typing” (identifiers are ignorant of types – this is
> what you have in Python).

Yep I think so.

Thanks for the info all!

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


Thread

python philosophical question - strong vs duck typing Sean Wolfe <ether.joe@gmail.com> - 2012-01-03 15:13 -0300
  Re: python philosophical question - strong vs duck typing Ben Finney <ben+python@benfinney.id.au> - 2012-01-04 09:28 +1100
    Re: python philosophical question - strong vs duck typing Sean Wolfe <ether.joe@gmail.com> - 2012-01-04 11:30 -0300
    Re: python philosophical question - strong vs duck typing Tim Wintle <tim.wintle@teamrubber.com> - 2012-01-04 17:01 +0000

csiph-web