Category : return

I am trying to execute a C file from a python code by running the C executable. Below is my code: import subprocess import sys dataset = sys.argv[1] def func(): subprocess.run([‘/home/dev/exec_file’, dataset, ‘outfile’]) f_result = [] f = open(‘outfile’, "r") content = f. read() f_result.append(content) print(f_result) #print(content.rstrip(‘n’)) return f_result Here if I simply write print(content.rstrip(‘n’)) ..

Read more

While using the interactive brokers api python library, I try to return a dict object from specific functions in my program that supported by the ibapi module itself. from ibapi.client import EClient from ibapi.wrapper import EWrapper from ibapi.contract import Contract from ibapi.ticktype import TickTypeEnum from threading import Timer from threading import * import csv import ..

Read more

My method looks like below. I am trying to return a string and a list. But it does not return anything. I put a print statement to check but the program doesnot enter the print statement, let alone execute the return statement below it. def frame_array(self, text_file_path): text_file = os.path.join(text_file_path, os.listdir(text_file_path)[0]) with open(text_file, "r", encoding="utf8") ..

Read more

while True: print("Welcome to this BMI calculator") x = str(input("Are you using Pounds or Kg, if you are using Kg press K if you are using Pounds press P:")) if x in [‘P’, ‘p’]: h = float(input("Key in your weight:")) elif x in [‘K’, ‘k’]: h = float(input("Key in your weight:")) else: **return(x)** print(x) Bold ..

Read more

function looks like: def mutate_color(tri): out = tri.copy() out[3][np.random.randint(3)] = np.random.randint(256) return out one object looks like: TRI_A = array([array([181, 75]), array([99, 9]), array([53, 15]), array([18, 5, 19], dtype=uint8)], dtype=object) <== this is a colored triangle, frist three are coordinates, the last one are RGB value. But when I pass this (or some object like ..

Read more