-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraising.py
More file actions
34 lines (30 loc) · 845 Bytes
/
Copy pathraising.py
File metadata and controls
34 lines (30 loc) · 845 Bytes
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
**Project Name:**
**Product Home Page:**
**Code Home Page:**
**Authors:** Pengfei Cui
**Copyright(c):** Pengfei Cui
**Licensing:** GPL3
**Coding Standards:**
Description
--------
"""
class ShortInputException(Exception):
'''A user-defined exception class.'''
def __init__(self,length,atleast):
Exception.__init__(self)
self.length =length
self.atleast=atleast
try:
s=raw_input('Enter something -->')
if len(s) <3:
raise ShortInputException(len(s),3)
except EOFError:
print '\nWhy did you do an EOF on me?'
except ShortInputException,x:
print 'ShortInputException: The input was of length %d, \
was expecting at least %d' % (x.length, x.atleast)
else:
print 'No exception was raised.'