Question: Here's the pattern I'm thinking of using: 

```
class Dicty(dict): 
    def __init__(self): 
         self.__dict__ = self 

d = Dicty()
d.foo = 'bar' 
print d['foo']
>>> bar 
d['foo'] = 'baz'
print d.foo
>>> 'baz'

```

Generally, I prefer the semantics of object attribute access over dict get/set access, but there are some circumstances where dict-like access is required (for example, `d['foo-bar'] = 'baz'`) and I'd prefer not to have special getter setter methods for these cases, so thus, the dual behavior of dict & object at the same time with shared attributes. 

Are there any gotchas with the above pattern?

Answer: 
Here's a less "hacky" way to achieve the same effect:

```
class Dicty(dict):
    def __getattr__(self, key):
        return self[key]

    def __setattr__(self, key, value):
        self[key] = value
```

I *think* that your way may work fine as well, but setting the `__dict__` attribute like that seems a bit iffy style-wise, and is bound to raise some questions if anyone else ends up reading your code.
A couple of things. One is if you try and use a dictionary method, such as `keys`, you won't be able to get it now. There were some other issues I ran into, such as being pickle-able and copy-able. 

But I have implemented something that does this without those problems. You can see it here, it's the AttrDict class in the [dictlib.py module](http://code.google.com/p/pycopia/source/browse/trunk/aid/pycopia/dictlib.py). That module also contains a class that can wrap another mapping style object, in cases where it can't be subclassed.