```python
node_u = G.node[u]
try:
    return node_u[community]
except KeyError:
    raise nx.NetworkXAlgorithmError('No community information')
```

This avoids punishing the common case where community information is present.