Python 3.0 - is this true?
cs at zip.com.au
Sun Nov 9 04:32:35 CET 2008
On 08Nov2008 19:17, walterbyrd <walterbyrd at iname.com> wrote:
| On Nov 8, 12:02 pm, Arnaud Delobelle <arno... at googlemail.com> wrote:
| > It goes well with duck typing. It lets you know when you things happen
| > that you don't mean to happen.
| But doesn't that also make the language less flexible?
No. All you need to do is define the comparison criterion so Python
doesn't make an arbitrary guess.
| For example, if I used C, I would never have to worry about assigning
| a float to an integer variable. The language will not allow it.
Hmm. I presume you've never used unions in C then?
Or cast to void* then back to another pointer?
C code can be written to pay a fair amount of attention to types
and protect (or warn, depending) about a lot of typing issues.
But you can also, either deliberately or through sloppiness,
do all sorts of nasty type mangling, including assigning a float
into space used elsewhere as an integer variable.
| thought that python's flexibility, in regard to that sort of thing,
| was supposed to be one of python's great strengths.
| Would it be better if python lists only accepted one type of data?
No. That would be less flexible.
| Wouldn't that even go further to let you know when things happen, that
| you don't mean to happen?
If I meant to put different types in a list, then this would be a
Cameron Simpson <cs at zip.com.au> DoD#743
More information about the Python-list