Question: Recently, I find myself writing code like this:

```

for name in dir( object ):
    if name.startswith( '__' ) : continue
    ...

```

Is there a more pythonic way to access the object's "public" namespace?

Answer: 
You can prepare list of "public" attributes (as list or as generator) before:

```
>>> public_props = (name for name in dir(object) if not name.startswith('_'))
>>> for name in public_props:
    print name

```

But please read a note about `dir()` function in the documentation:

> 
> **Note** Because `dir()` is supplied primarily as a convenience for use at an interactive prompt, it tries to supply an interesting set of names more than it tries to supply a rigorously or consistently defined set of names, and its detailed behavior may change across releases. For example, metaclass attributes are not in the result list when the argument is a class.
> 
> 
> 

You should also be aware, that any class can implement `__dir__()` method that may return a list of names that do not necessarily correspond to the names of the attributes. In other words, `dir(something)` does not guarantee that the result will return attributes of `something`.
Rather than an exclusion branch using the `continue` keyword, iterating over a comprehension of public names directly seems more Pythonic. But it could just be a matter of taste, it's admittedly not much better than what you already have.

```
public_names = (n for n in dir(object) if not n.startswith('_'))
for attr in public_names:
    ...

```

*Note:* Single underscore attributes are also not "public".