main()   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 9
Bugs 6 Features 3
Metric Value
cc 4
c 9
b 6
f 3
dl 0
loc 13
rs 9.2
1
#!/usr/bin/python
2
3
import sys
4
import re
5
def read_input(input_file):
6
    '''
7
    This function read input file line by line change it to lowercase and split words of this line and yield
8
    (return in each iteration) as list
9
    :param file: input file
10
    :type file : file object
11
    :return: yield in each iteration
12
    '''
13
    for line in input_file:
14
        line = re.split('[^a-z]+', line.lower())
15
        yield line
16
def main(separator='\t'):
17
    '''
18
    This function get input file from sys.stdin (argument passing in terminal) and pass this file to read_input function
19
    in each output of read_input function check list items if char number of each word larger than 0 (word validation)
20
    sort letter of word and print sorted word and first word with a separator(default value ="\t") to terminal
21
    :param separator: separator for sorted word and first word
22
    :type separator:str
23
    :return: None
24
    '''
25
    for words in read_input(sys.stdin):
26
        for word in words:
27
            if len(word) > 0:
28
                print '%s%s%s' % (''.join(sorted(word)), separator, word)
29
if __name__ == "__main__":
30
    main()
31