# Check if a rectangle is empty.
#
-def is_empty((left, top), (right, bottom)):
+def is_empty(r):
+ (left, top), (right, bottom) = r
return left >= right or top >= bottom
if top < t: top = t
if right > r: right = r
if bottom > b: bottom = b
- if is_empty((left, top), (right, bottom)):
+ if is_empty(((left, top), (right, bottom))):
return empty
return (left, top), (right, bottom)
def union(list):
(left, top), (right, bottom) = empty
for (l, t), (r, b) in list[1:]:
- if not is_empty((l, t), (r, b)):
+ if not is_empty(((l, t), (r, b))):
if l < left: left = l
if t < top: top = t
if r > right: right = r
# Check if a rectangle is empty.
#
-def is_empty((left, top), (right, bottom)):
+def is_empty(r):
+ (left, top), (right, bottom) = r
return left >= right or top >= bottom
if top < t: top = t
if right > r: right = r
if bottom > b: bottom = b
- if is_empty((left, top), (right, bottom)):
+ if is_empty(((left, top), (right, bottom))):
return empty
return (left, top), (right, bottom)
def union(list):
(left, top), (right, bottom) = empty
for (l, t), (r, b) in list[1:]:
- if not is_empty((l, t), (r, b)):
+ if not is_empty(((l, t), (r, b))):
if l < left: left = l
if t < top: top = t
if r > right: right = r
# module 'string' -- A collection of string operations
-# XXX Some of these operations are incredibly slow and should be built in
+# Warning: most of the code you see here isn't normally used nowadays.
+# At the end of this file most functions are replaced by built-in
+# functions imported from built-in module "strop".
# Some strings for ctype-style character classification
whitespace = ' \t\n'
# module 'string' -- A collection of string operations
-# XXX Some of these operations are incredibly slow and should be built in
+# Warning: most of the code you see here isn't normally used nowadays.
+# At the end of this file most functions are replaced by built-in
+# functions imported from built-in module "strop".
# Some strings for ctype-style character classification
whitespace = ' \t\n'
if repr([]) <> '[]': raise TestFailed, 'repr([])'
if repr({}) <> '{}': raise TestFailed, 'repr({})'
+print 'round'
+if round(0.0) <> 0.0: raise TestFailed, 'round(0.0)'
+if round(1.0) <> 1.0: raise TestFailed, 'round(1.0)'
+if round(10.0) <> 10.0: raise TestFailed, 'round(10.0)'
+if round(1000000000.0) <> 1000000000.0:
+ raise TestFailed, 'round(1000000000.0)'
+if round(1e20) <> 1e20: raise TestFailed, 'round(1e20)'
+
+if round(-1.0) <> -1.0: raise TestFailed, 'round(-1.0)'
+if round(-10.0) <> -10.0: raise TestFailed, 'round(-10.0)'
+if round(-1000000000.0) <> -1000000000.0:
+ raise TestFailed, 'round(-1000000000.0)'
+if round(-1e20) <> -1e20: raise TestFailed, 'round(-1e20)'
+
+if round(0.1) <> 0.0: raise TestFailed, 'round(0.0)'
+if round(1.1) <> 1.0: raise TestFailed, 'round(1.0)'
+if round(10.1) <> 10.0: raise TestFailed, 'round(10.0)'
+if round(1000000000.1) <> 1000000000.0:
+ raise TestFailed, 'round(1000000000.0)'
+
+if round(-1.1) <> -1.0: raise TestFailed, 'round(-1.0)'
+if round(-10.1) <> -10.0: raise TestFailed, 'round(-10.0)'
+if round(-1000000000.1) <> -1000000000.0:
+ raise TestFailed, 'round(-1000000000.0)'
+
+if round(0.9) <> 1.0: raise TestFailed, 'round(0.9)'
+if round(9.9) <> 10.0: raise TestFailed, 'round(9.9)'
+if round(999999999.9) <> 1000000000.0:
+ raise TestFailed, 'round(999999999.9)'
+
+if round(-0.9) <> -1.0: raise TestFailed, 'round(-0.9)'
+if round(-9.9) <> -10.0: raise TestFailed, 'round(-9.9)'
+if round(-999999999.9) <> -1000000000.0:
+ raise TestFailed, 'round(-999999999.9)'
+
print 'setattr'
import sys
setattr(sys, 'foobar', 1)
testing
reload
repr
+round
setattr
str
type
tzstr = os.environ['TZ']
tzparams = tzparse(tzstr)
timezone = tzparams[1] * 3600
- altzone = timezone + 3600
+ altzone = timezone - 3600
daylight = 1
tzname = tzparams[0], tzparams[2]