Q:

Removing punctuation and creating a set from words from user input

I was wondering how I might go about removing punctuation from user input and creating a set from the words in the input. So far I have this.
input_set = set(self.entry.get().lower().split(' '))

A:

Use str.translate:
Python2:
>>> from string import punctuation
>>> s = 'sfda%$$sdafd dasf564%^%^, hgghg%#56'
>>> set(s.translate(None, punctuation).split())
set(['hgghg56', 'dasf564', 'sfdasdafd'])

Python3:
from string import punctuation
s = 'sfda%$$sdafd dasf564%^%^, hgghg%#56'
tab = dict.fromkeys(map(ord, punctuation))
print (set(s.translate(tab).split()))

A:

This is an excellent place to use regular expressions:
import re
re.split(r'\W+',str)

depending on what you consider punctuation you may want to change '\W' to a different character class or character group.

