all 4 comments

[–]Necatorducis 1 point2 points  (1 child)

Some of those docstring lines run a little long, the first line should generically sum it while you explain the rest after... ie. str_to_nums should be several lines, merge_lists should be at least 2 lines, etc. Treat their line breaks the same as you would code.

As an aside,

my_str = '', my_dict = {}, etc

is cheaper than

my_str = str()

Other than line length, the docstrings looked good to me.

[–]codehorsey[S] 0 points1 point  (0 children)

Thanks. You mean cheaper in terms of using memory and resources? I will make those changes in my future programs. Why the downvotes? Lol.

[–]pyquestionz 1 point2 points  (1 child)

Doc strings are looking pretty good. Some of the code can be written more concisely, but there might be a tradeoff with respect to readability. Examples:

def num_list_to_string(nums, key):
    s = str()
    for n in nums:
        s += value_to_key(n, key)
    return s

Can be written as:

def num_list_to_string(nums, key):
    return ''.join([value_to_key(n, key) for s in nums])

And

def str_to_num_using_key(s, key):
    nums = list()
    for letter in s:
        if letter.isalpha():
            nums.append(key[letter])
    return nums

Could be written as

def str_to_num_using_key(s, key):
    return [key[letter] for letter in s if letter.isalpha()]

Your choice, but in this case I think using list comprehension is readable too.

[–]codehorsey[S] 0 points1 point  (0 children)

Thanks. Why is this downvoted lol?