def testSub(x, y): #get Directory for functions currentworkingdirectory = os.getcwd() currentworkingdirectory = currentworkingdirectory.replace('/testCasesExecutables', '') currentworkingdirectory = (currentworkingdirectory + '/project/src') sys.path.insert(0, currentworkingdirectory) from functions import sub try: output = sub(int(x),int(y)) except: output = "ERROR" return output
def testSub(x, y): #get Directory for functions currentworkingdirectory = os.getcwd() currentworkingdirectory = currentworkingdirectory.replace( '/testCasesExecutables', '') currentworkingdirectory = (currentworkingdirectory + '/project/src') sys.path.insert(0, currentworkingdirectory) from functions import sub try: output = sub(int(x), int(y)) except: output = "ERROR" return output
# absolute import import functions # relative import # from functions import add # relative import with dot syntax, requires __init__.py file from . import functions x = 5 y = 6 z = functions.add(x, y) print("5 + 6 =", z) z = functions.sub(x, y) print(z)
from functions import add, sub, mult, div x = add(8, 9) print(x) x = sub(x, 3) print(x) x = mult(x, 4) print(x) x = div(x, 2) print(x)
from functions.add import * from functions.sub import * a = add(1, 2) b = sub(2, 1) print(a) print(b)
def crea_bridge(self,tipo): if tipo=="lb": sub("sudo brctl addbr %s" %self.nombre).stdout elif tipo=="ovs": sub("sudo ovs-vsctl add-br %s" %self.nombre).stdout
def crea_ns(self): sub("sudo ip netns add %s" %self.nombre)
def crea_veth(ext_a,ext_b): sub("sudo ip link add %s type veth peer name %s" %(ext_a,ext_b)).stdout
def equation(x, y): return exponent(sub(x, y), 3)
if '\n' in word: # removes '\n' from word count -= 1 print('Welcome to the Hangman Game!') print('\nThe word is {0} letters long, and you have {1} tries.\n'.format(count, num)) print('Word: {0}'.format(functions.word(assemble, word))) # prints word as it gets assembled while count > 0: # while not fully assembled guess = input('\nWhat is your guess? ').lower() # asks user for guess if guess in word and guess not in assemble and len(guess) == 1: # if guess is correct assemble.append(guess) count -= functions.sub(guess, word) # number of letters in word left print('You are correct, now there are: {0} letters left, and you have {1} tries left.\n'.format(count, num)) print('Word: {0}'.format(functions.word(assemble, word))) # prints word as it gets assembled print('Wrong: {0}'.format(functions.wrong(guess, word, wrong))) # prints incorrect letters elif len(guess) == 0: # if guess is null pass elif guess in assemble or guess in wrong: # if guess is already logged print('You already guessed that.\n') print('Word: {0}'.format(functions.word(assemble, word))) # prints word as it gets assembled print('Wrong: {0}'.format(functions.wrong(guess, word, wrong))) # prints incorrect letters elif len(guess) > 1: # if guess is too long print('That\'s too long')
def __rsub__(self, other): return F.sub(other, self)
def __sub__(self, other): return F.sub(self, other)
def get(self): username = self.request.get('username') self.response.out.write(sub(username))