Reply to comment

Errata

Python is not "weakly typed". It is strongly, dynamically, implicitly typed.

"Equality testing", not "truth testing", is done with the == sign. The == operator tells you if its arguments are equal, not if they are true.

Dictionaries are not "one-dimensional named arrays". They are associative arrays, sometimes known as hash tables, although "hash table" is really the name of one implementation of associative arrays.

A useful use of the array range colon is to copy an array:

newary = oldary[:]

Multiline strings can be enclosed in '''triple single quotes''' as well as """triple double quotes""".

"Flow control statements are while, if@, and @for" contains unnecessary @ signs.

Functions returning a tuple is not the same as functions returning multiple values. You're thinking of tuple unpacking of a returned tuple, which is indeed useful ... but multiple values are something different. (Languages which support that include Common Lisp.) Multiple values has been proposed for Python, but never implemented.

Arguments are not passed "by value". They are passed "by reference". If arguments were passed by value, a function passed an array as an argument would not be able to modify it and have that modification affect the calling context, e.g.:

>>> def foo(ary):
... ary.append("yermom")
...
>>> a = ["monkey"]
>>> foo(a)
>>> a
['monkey', 'yermom']

Submitted by Fubar Obfusco (not verified) on Thu, 12/01/2006 - 08:47.

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Google ads

(You can disable these if you log in)