Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18499
| References | <mailman.4361.1325614408.27778.python-list@python.org> <87wr98zaiy.fsf@benfinney.id.au> |
|---|---|
| Date | 2012-01-04 11:30 -0300 |
| Subject | Re: python philosophical question - strong vs duck typing |
| From | Sean Wolfe <ether.joe@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4409.1325687441.27778.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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