On Sun, 31 Dec 2006 21:23:03 -0800, Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> > At the same time, you should ponder very
>> > carefully the reasons why the original author deemed it important to
>> > make those attributes private in the first place.
>>
>> In my experience
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> > At the same time, you should ponder very
> > carefully the reasons why the original author deemed it important to
> > make those attributes private in the first place.
>
> In my experience, it is mostly because they come from
> bondage-and-domination
On Sun, 31 Dec 2006 19:48:55 -0800, Tom Plunket wrote:
> Steven D'Aprano wrote:
>
>> What does the author of the original class know about *my* needs and
>> requirements?
>
> The only thing that the original class author might know is that mucking
> with data marked private may well cause proble
Steven D'Aprano wrote:
> What does the author of the original class know about *my* needs and
> requirements?
The only thing that the original class author might know is that mucking
with data marked private may well cause problems, and hiding it
therefore prevents those problems.
> It may turn
On Sun, 31 Dec 2006 03:39:52 +0100, Rene Fleschenberg wrote:
> johnf wrote:
>> Very detailed. But I was attempting to debug some code which subclassed
>> other code. I got a traceback that something like "no
>> mySubClass.__source.query() did not exist".
>
> By (strong) convention, "__" means
On Sat, 30 Dec 2006 11:08:10 -0800, johnf wrote:
> Very detailed. But I was attempting to debug some code which subclassed
> other code. I got a traceback that something like "no
> mySubClass.__source.query() did not exist". The superclass had something
> like "myClass.__source.query(sql)" which
johnf wrote:
> Very detailed. But I was attempting to debug some code which subclassed
> other code. I got a traceback that something like "no
> mySubClass.__source.query() did not exist".
By (strong) convention, "__" means "not to be accessed from outside the
class, not even from subclasses".
Steven D'Aprano wrote:
>
> There are three other underscore conventions in use:
>
> (1) Objects with a single leading underscore like _attribute are private
> by convention, but Python doesn't enforce it. Starting an object with a
> single underscore is like writing "# Private! Don't touch!" af
At Friday 29/12/2006 13:17, Steven D'Aprano wrote:
>>> X.__dict__
{'__module__': '__main__', '__doc__': None}
>>> X.__name__
'X'
>>> X.__bases__
()
Now that's interesting... if __name__ and __bases__ don't live in the
class __dict__, where do they live? What other methods and attributes are
inv
On Fri, 29 Dec 2006 12:04:11 -0800, johnf wrote:
> Ok then how do debug when I have something like "__source" and I need to
> know what is available for the object?
Outside of a class, objects with two leading underscores are just ordinary
objects with no special behaviour:
>>> __source = 2
>>>
Steven D'Aprano wrote:
> On Fri, 29 Dec 2006 08:20:22 -0600, Larry Bates wrote:
>
>> johnf wrote:
>>> Hi,
>>> When I use dir() I don't see the __ underscore items. Is there anything
>>> that will show all the private vars and functions?
>>>
>>> johnf
>>
>> The idea of the underscore items is t
On Dec 29, 5:17 pm, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Fri, 29 Dec 2006 07:57:30 -0800, [EMAIL PROTECTED] wrote:
> > What do you mean? Can you specify which special functions you don't
> > see?
> > I get:
> > py> class X:
> >pass
> > py> dir(X)
> > ['__doc__', '__module__']How ab
On Fri, 29 Dec 2006 08:20:22 -0600, Larry Bates wrote:
> johnf wrote:
>> Hi,
>> When I use dir() I don't see the __ underscore items. Is there anything
>> that will show all the private vars and functions?
>>
>> johnf
>
> The idea of the underscore items is that they aren't to be used by
> you.
On Fri, 29 Dec 2006 07:57:30 -0800, [EMAIL PROTECTED] wrote:
> What do you mean? Can you specify which special functions you don't
> see?
> I get:
> py> class X:
> pass
> py> dir(X)
> ['__doc__', '__module__']
How about these?
>>> X.__dict__
{'__module__': '__main__', '__doc__': None}
>>>
What do you mean? Can you specify which special functions you don't
see?
I get:
py> class X:
pass
py> dir(X)
['__doc__', '__module__']
py> class X:
def __getitem__(self, x):
pass
py> dir(X)
['__doc__', '__getitem__', '__module__']
On Dec 29, 12:35 pm, johnf <[EMAI
johnf wrote:
> Hi,
> When I use dir() I don't see the __ underscore items. Is there anything
> that will show all the private vars and functions?
>
> johnf
The idea of the underscore items is that they aren't to be used by
you. If you wish to access private variables and functions you will
almo
16 matches
Mail list logo