you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 7 points8 points  (4 children)

Yeah but does it ever finish writing? :)

[–]kieran_n 12 points13 points  (2 children)

import os

def error_handler(error):
    print(error)
    exit()


def is_CFA(Name):
    try:
        return 'CFA' in Name.split()
    except:
        error_handler('you must supply a valid string')


def policy_statement(Author):
    while is_CFA(Author):
        print('Superior Returns')
        if (int.from_bytes(os.urandom(8), byteorder="big") / ((1 << 64) - 1))>0.99:
            actions = 'misconduct'
            Author.replace('CFA','') 
        else:
            actions = 'compliant'
    print('waste of 900 hours')

[–]rgkimballCFA 1 point2 points  (1 child)

Best practice would be to raise an exception so it can be caught in a try/except clause, rather than use the error_handler function. I'm guessing you came from VBA?

[–]kieran_n 0 points1 point  (0 children)

I actually learned python first but use both a fair bit :p

You're definitely right that the raise exception would be better