You can just use `isalnum`.