More pythonic way to find the longest sequence (#512)

* More pythonic way to find the longest sequence

* pep8 fix
This commit is contained in:
Sebastian Raschka
2025-02-01 10:22:47 -06:00
committed by GitHub
parent 0e14c76dee
commit 8cfa52bf1d
5 changed files with 16 additions and 1 deletions

View File

@@ -94,6 +94,9 @@ class SpamDataset(Dataset):
if encoded_length > max_length:
max_length = encoded_length
return max_length
# Note: A more pythonic version to implement this method
# is the following, which is also used in the next chapter:
# return max(len(encoded_text) for encoded_text in self.encoded_texts)
def download_and_unzip(url, zip_path, extract_to, new_file_path):