Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it OK to inspect properties beginning with underscore?

I've been working on a very simple crud generator for pylons. I came up with something that inspects

SomeClass._sa_class_manager.mapper.c

Is it ok to inspect this (or to call methods begining with underscore)? I always kind of assumed this is legal though frowned upon as it relies heavily on the internal structure of a class/object. But hey, since python does not really have interfaces in the Java sense maybe it is OK.

like image 565
Bartosz Radaczyński Avatar asked Dec 06 '22 07:12

Bartosz Radaczyński


1 Answers

It is intentional (in Python) that there are no "private" scopes. It is a convention that anything that starts with an underscore should not ideally be used, and hence you may not complain if its behavior or definition changes in a next version.

like image 124
Swaroop C H Avatar answered Dec 10 '22 10:12

Swaroop C H