Question: I have a list of Account objects in `self.accounts`, and I know that only one of them will have a `type` attribute equal to 'equity'. What is the best (most pythonic) way to get only that object from the list?

Currently I have the following, but I'm wondering if the `[0]` at the end is superfluous. Is there a more succinct way to do this?

`return [account for account in self.accounts if account.type == 'equity'][0]`

Answer: 
```
return next(account for account in self.accounts if account.type == 'equity')

```

or

```
return (account for account in self.accounts if account.type == 'equity').next()

```
It's such a common need in Python but afaik there is no built in way to do it. You could also do:

```
return next(filter(lambda x: x.type == 'equity', self.accounts))

```