How to read the Python tutorial?

rantingrick rantingrick at gmail.com
Wed Nov 10 11:19:19 EST 2010


On Nov 10, 10:05 am, Zeynel <azeyn... at gmail.com> wrote:

> AttributeError: 'datetime.datetime' object has no attribute 'seconds'

First of all put some scaffolding in this code. What is scaffolding.
Basically some debug print statements so you can follow the trail of
errors. You need to learn how to debug code and be self reliant. A few
very important functions are.

>>> a = 's'
>>> b = 1
>>> a * b
's'
>>> a + b

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    a + b
TypeError: cannot concatenate 'str' and 'int' objects

>>> type(a), type(b)
(<type 'str'>, <type 'int'>)

>>> id(a), id(b)
(26864768, 12844616)

>>> print a, b
s 1

>>> repr(a), repr(b)
("'s'", '1')

>>> isinstance(a, str)
True

I would start at the loop and figure out what is going on from there
with some print statements and the functions i showed you. Debugging
is a large part of any programming project. We all do it everyday. So
the sooner you learn the better. If you have a specific question feel
free to ask, but general debug issues are better solved yourself.

A few more indispensable functions are dir() and help()




More information about the Python-list mailing list