[Python-Dev] PEP 8 and optional underscores

Barry Warsaw barry at python.org
Thu Jun 12 17:40:26 CEST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Jun 12, 2008, at 11:21 AM, skip at pobox.com wrote:

>
>>> Should it be...
>>>
>>> 2.n : .is_alive()
>>> 2.n+1 : .is_alive() (deprecated), .alive (recommended)
>>> 2.n+2 : .alive
>
>    Barry> Personally, I'd go with a property .is_alive
>
> I'm not fond of using a property for this since it can lull you into  
> the
> false belief that what you are doing is less expensive than it  
> really is
> (attribute access vs method call).  I think this is a case where  
> explicit is
> better than implicit.

I've heard this argument before, and it's one I'm not unsympathetic  
to.  Usually I've heard it in the context of remote network access,  
e.g. let's say .alive had to make a REST call over the net each time.   
Well, maybe there's caching involved which amortizes the costs, so the  
argument gets trickier.

Ideally, I would like for those considerations to not enter into the  
API design.  I'd rather keep it clean, with sufficient documentation  
to give hints about any additional costs involved.  Logically .alive  
is a property, so I'd like to write it that way.

Perhaps function annotations help out here.

- -Barry

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iQCVAwUBSFFDanEjvBPtnXfVAQJxbAQAq2BDNE7m+J+5Jy3E4XlHaw8JXsEaukEA
YvZ1M1R1mREGCstIf4tlScKko1eu9PfJIk7+kCmFYezighJ1tPZunyu5zLemlgQe
9rJ9keFIJBLtao8yv+FPkn56idixtkTGq+14Ef+EhjIhOnbonp+eDuhScbE2tdzM
5tuFO/hsrqw=
=66R7
-----END PGP SIGNATURE-----


More information about the Python-Dev mailing list