Rationales behind some changes:
- Change package names like 'naive-bayes' to valid Python identifiers. The package with invalid name can be imported only with special code like:
naive_bayes = __import__('naive-bayes')
instead of
import naive_bayes
when package name is a valid Python identifier.
-
Pre-2.1 Python classes are not used, because they are not properly integrated into type system.
-
EmailObject.file is removed, because it creates useless entanglement
-
The variable name 'file' is not used because overrides the built-in function 'file'.
-
'file' is not closed by EmailObject, because it violates SRP (the 'file' object is owned and opened by caller).
-
The standard Python idiom
with open('name') as fp:
used because it provides exceptional stability (it closes file if any exception occurs inside the block).
This
with open('name') as fp:
do_something(fp)
is short equivalent (approximately) of:
try:
fp = open('name')
do_something(fp)
finally:
fp.close()