Skip to content

Commit 59d7e74

Browse files
committed
-
1 parent 79d9945 commit 59d7e74

File tree

9 files changed

+22
-48
lines changed

9 files changed

+22
-48
lines changed

python_toolbox/cute_testing.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
'''This module defines tools for testing.'''
55

6-
import re
7-
86
from python_toolbox.third_party import unittest2
97

108
from python_toolbox import cute_inspect

python_toolbox/dict_tools.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ def reverse_with_set_values(d):
8282

8383

8484
def devour_items(d):
85+
'''Iterator that pops (key, value) pairs from `d` until it's empty.'''
8586
while d:
8687
yield d.popitem()
8788

8889

8990
def devour(d):
91+
'''Iterator that pops keys from `d` until it's exhaused (i.e. empty).'''
9092
while d:
9193
yield d.pop()

python_toolbox/function_anchoring_type.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import types
1212

1313
from python_toolbox import misc_tools
14-
from python_toolbox import import_tools
15-
from python_toolbox import address_tools
1614

1715

1816
class FunctionAnchoringType(type):

python_toolbox/gc_tools.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
# Copyright 2009-2012 Ram Rachum.
22
# This program is distributed under the LGPL2.1 license.
33

4-
'''
5-
This module defines the `` class.
6-
7-
See its documentation for more information.
8-
'''
4+
'''Defines various tools for working with garbage-collection.'''
95

106
import gc
117

128
from python_toolbox import sys_tools
139

1410
def collect():
1511
if sys_tools.is_pypy:
16-
for i in range(3):
12+
for _ in range(3):
1713
gc.collect()
1814
else:
1915
gc.collect()

python_toolbox/import_tools.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import os.path
88
import imp
99
import zipimport
10-
import zipfile
1110

1211
from python_toolbox import package_finder
1312
from python_toolbox import caching
@@ -134,17 +133,8 @@ def exists(module_name, path=None):
134133
module_file.close()
135134

136135

137-
def _import_by_path_from_zip(path, name=None):
138-
'''
139-
Import module/package by path. blocktododoc, psudopath inside zip? no file
140-
extensions?
141-
142-
You may specify a name: This is helpful only if it's an hierarchical name,
143-
i.e. a name with dots like "orange.claw.hammer". This will become the
144-
imported module's __name__ attribute. Otherwise only the short name,
145-
"hammer", will be used, which might cause problems in some cases. (Like
146-
when using multiprocessing.)
147-
'''
136+
def _import_by_path_from_zip(path):
137+
'''Import a module from a path inside a zip file.'''
148138
assert '.zip' in path
149139

150140
parent_path, child_name = path.rsplit(os.path.sep, 1)

python_toolbox/infinity.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616

1717
def is_floatable(x):
18+
'''Can `x` be made into a `float`?'''
1819
try:
1920
float(x)
2021
return True
@@ -23,6 +24,7 @@ def is_floatable(x):
2324

2425

2526
def is_nonfractional(x):
27+
'''Is `x` a whole number?'''
2628
try:
2729
int(x)
2830
return int(x) == x
@@ -89,7 +91,7 @@ def __div__(self, other):
8991
raise InfinityRaceError
9092
elif is_floatable(other):
9193
s = math_tools.sign(other)
92-
if s==0:
94+
if s == 0:
9395
raise InfinityRaceError
9496
else:
9597
return Infinity(direction=self.direction * s)
@@ -102,7 +104,7 @@ def __mul__(self, other):
102104
return Infinity(self.direction * other.direction)
103105
elif is_floatable(other):
104106
s = math_tools.sign(other)
105-
if s==0:
107+
if s == 0:
106108
raise InfinityRaceError
107109
else:
108110
return Infinity(direction=self.direction * s)
@@ -121,19 +123,19 @@ def __pow__(self, other):
121123
raise object # todo
122124
elif is_floatable(other):
123125
s = math_tools.sign(other)
124-
if s==0:
126+
if s == 0:
125127
raise InfinityRaceError
126128
else:
127-
if self.direction==1:
128-
if s==1:
129+
if self.direction == 1:
130+
if s == 1:
129131
return self
130-
if s==-1:
132+
if s == -1:
131133
return 0
132134
else: #self.direction == -1
133135
if is_nonfractional(other):
134-
if s==-1:
136+
if s == -1:
135137
return 0
136-
if s==1:
138+
if s == 1:
137139
if s % 2 == 0:
138140
return Infinity()
139141
else:
@@ -194,10 +196,10 @@ def __neq__(self, other):
194196
return not self.__eq__(other)
195197

196198
def __repr__(self):
197-
if self.direction==1:
198-
suffix=''
199+
if self.direction == 1:
200+
suffix = ''
199201
else: # self.direction == -1
200-
suffix='-'
202+
suffix = '-'
201203
return suffix + 'infinity'
202204

203205

python_toolbox/misc_tools/name_mangling.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Copyright 2009-2012 Ram Rachum.
22
# This program is distributed under the LGPL2.1 license.
33

4-
'''
5-
This module defines the `` class.
6-
7-
See its documentation for more information.
8-
'''
4+
'''Defines tools for name-mangling.'''
95

106
from python_toolbox import string_tools
117

python_toolbox/module_tasting/tasted_resources.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Copyright 2009-2012 Ram Rachum.
22
# This program is distributed under the LGPL2.1 license.
33

4-
'''
5-
This module defines the `` class.
6-
7-
See its documentation for more information.
8-
'''
4+
'''Defines `pkg_resources`-like tools for tasted modules.'''
95

106
import types
117
import sys
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Copyright 2009-2012 Ram Rachum.
22
# This program is distributed under the LGPL2.1 license.
33

4-
'''
5-
This module defines the `` class.
6-
7-
See its documentation for more information.
8-
'''
4+
'''Defines tools for drawing with wxPython.'''
95

106
from . import pens

0 commit comments

Comments
 (0)