Newbie look at Python and OO

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Fri May 11 23:56:35 EDT 2007


On Fri, 11 May 2007 20:07:36 -0700, walterbyrd wrote:

>> He's thinking in Pascal, not C.
>>
> 
> Actually, I have programmed in many languages. I just first learned in
> Pascal.
> 
> For me, going from Pascal, to basic,c,cobol,fortran  . . was not that
> difficult. Python, however, feels strange.

Sounds to me like it is the object-oriented stuff that causes the
confusion, not Python per se.

 
> As crazy as this may sound: Python, in some ways, reminds me of
> assembly language. I haven' t programmed in assembly in a *long* time.
> But I vaugly remember doing a lot of stuff where  I used memory
> addresses as pointers to data, and also as pointers to pointers.
> Although, when I first started assembly language, I think it took me a
> week to write a program to print "hello world."


You shouldn't need to think about memory addresses in Python. The only
exceptions are that the id() function returns the memory address
(although that's just an implementation detail, it could be any old number
for all the difference it makes), and that some objects expose the memory
address as part of their default string representation:

>>> print object()
<object object at 0xb7fb0460>

I too learnt to program in Pascal, and I also found the OO side of things
confusing at first. With the exception of a few "gotchas" like
string.join() which feels like it is written backwards, it is usually
quite natural.

You started this thread with a list of conceptual problems you were
having. Are they now cleared up?



-- 
Steven.




More information about the Python-list mailing list