-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpected.py
More file actions
executable file
·78 lines (78 loc) · 2.42 KB
/
Copy pathexpected.py
File metadata and controls
executable file
·78 lines (78 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/python
def test1(strObject,strS1,strS2):
return strObject + strS1 + strS2
def testDottedQuad(strObject):
if not isinstance(strObject, basestring): return False
listStrings = strObject.split('.')
if len(listStrings) != 4: return False
for strNum in listStrings:
try: val = int(strNum)
except: return False
if val < 0: return False
if val > 255: return False
return True
def shorty(strObject):
if len(strObject) < 8: return True
return False
def test2(strObject):
return '"'+strObject+'"' + ' is ' + str(len(strObject)) + ' characters long'
def meth():
return 'blue'
def zombie():
return 'white'
def upup(strObject):
return strObject.upper()
def test():
print 'bah:'
# print 'foo:'.test1(" there's a method",' to my madness')
print test1('foo:'," there's a method",' to my madness')
# print 'bing:'.test2()
print test2('bing:')
test()
if 1:
x = 'a'
# print x.test1('b','c')
print test1(x,'b','c')
fruit = 'cherries'
# print fruit.test1(' ripe',' and luscious')
print test1(fruit,' ripe',' and luscious')
# print meth().test2();print zombie().test2()
print test2(meth());print test2(zombie())
# print upup(meth()).test2()
print test2(upup(meth()))
# print upup(meth()).test1(' red',' green')
print test1(upup(meth()),' red',' green')
# print upup(str(['1','2','3'])).test2()
print test2(upup(str(['1','2','3'])))
# print upup(str({1:'a',2:'b',3:'c'})).test2()
print test2(upup(str({1:'a',2:'b',3:'c'})))
z = {1:'ab',2:'bc',3:'cd'}
# print upup(str(z[2])).test2()
print test2(upup(str(z[2])))
y = {'a':1,'b':2,'c':3}
# print upup(str(z[y['c']])).test2()
print test2(upup(str(z[y['c']])))
# print meth().test2()
print test2(meth())
# print upup('foo').test2();print upup('bar').test2()
print test2(upup('foo'));print test2(upup('bar'))
# print upup('foo').test2();print upup('bar').test1(' twice',' two')
print test2(upup('foo'));print test1(upup('bar'),' twice',' two')
# if upup('boink').shorty():
if shorty(upup('boink')):
print 'Short!'
else:
print 'not Short'
# if not upup('boink').shorty():
if not shorty(upup('boink')):
print 'Long'
else:
print 'not Long'
# print str('127.0.0.1'.testDottedQuad())
print str(testDottedQuad('127.0.0.1'))
# print str('password'.testDottedQuad())
print str(testDottedQuad('password'))
# print str('4'.testDottedQuad())
print str(testDottedQuad('4'))
# print "bar:".test1(' but',' no dir() and no help()')
print test1("bar:",' but',' no dir() and no help()')