can someone explain?

Rene Pijlman reageer.in at de.nieuwsgroep
Mon Feb 17 11:48:41 EST 2003


Pablo:
>I'm interested in Python and I've been reading some tutorials,
>documents, etc. but could't find an answer for a few questions.

I think you should evaluate your search strategies :-)

>How can I pass an address (reference) of a variable to a function?

This is a FAQ.
http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.035.htp

>Why doesn't python let encapsulate attributes in classes? 

It does, to an extent. This is explained in the tutorial.
http://www.python.org/doc/current/tut/node11.html#SECTION0011600000000000000000

>def f(a,L=[]):
>  L.append(a)
>  return L
[...]
>L is a default argument so every time when a function f is invoked, L
>should be created and as a result f should return a list with only one
>value.
>Why doesn't it work that way?

This is a FAQ.
http://www.python.org/cgi-bin/faqw.py?req=show&file=faq06.025.htp

>I'm really disapointed that the same logic from C++ or Java doesn't 
>exist in Python.

If Python would be the same as C++ or Java, it would be C++ or
Java, instead of Python.

-- 
René Pijlman

Wat wil jij leren?  http://www.leren.nl




More information about the Python-list mailing list