Question: I have a WordNet synset offset (for example `id="n#05576222"`). Given this offset, how can I get the synset using Python?

Answer: 
**For NTLK 3.2.3 or newer, please see donners45's answer.**

**For older versions of NLTK:**

There is no built-in method in the NLTK but you could use this:

```
from nltk.corpus import wordnet

syns = list(wordnet.all_synsets())
offsets_list = [(s.offset(), s) for s in syns]
offsets_dict = dict(offsets_list)

offsets_dict[14204095]
>>> Synset('heatstroke.n.01')

```

You can then pickle the dictionary and load it whenever you need it.

For NLTK versions prior to 3.0, replace the line

```
offsets_list = [(s.offset(), s) for s in syns]

```

with

```
offsets_list = [(s.offset, s) for s in syns]

```

since prior to NLTK 3.0 `offset` was an attribute instead of a method.
You can use [`of2ss()`](http://www.nltk.org/_modules/nltk/corpus/reader/wordnet.html), For example:

```
from nltk.corpus import wordnet as wn
syn = wn.of2ss('01580050a')

```

will return 
`Synset('necessary.a.01')`