Newbie look at Python and OO

Carsten Haese carsten at uniqsys.com
Thu May 10 12:25:47 EDT 2007


On Thu, 2007-05-10 at 08:58 -0700, walterbyrd wrote:
> I learned to program with Pascal, way back when. Went into software
> development for a while, then went into systems admin. Have programmed
> in several languages, just learning Python.
> 
> Some things I find odd:
> 
> 1) 5/-2 == -3?

Division of integers performs a "floor division" that rounds the result
down to a whole number. If you want a floating point result, you'll need
to specify that you're working with floats: 5.0/-2 or float(5)/-2

> 2) list assignment handling, pointing two vars to the same list:

See http://effbot.org/zone/python-objects.htm .

> 3) ambiguous use of the form: this.that()

The form "this.that" *always* means the same: It refers to the attribute
called "that" of the object called "this". This may yield seemingly
different meanings depending on what type of object "this" is, but the
basic mechanism is always the same.

The main source of your confusion seems to stem from the fact that
join() was decided somewhat non-intuitively to be a method of string
instances.

By the way, the next time you have a number of unrelated questions,
please consider posting them in separate messages. That allows you to
pick a more descriptive subject line for each message, and it makes the
ensuing conversations easier to follow.

Best regards,

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list