names

Filling a 2D list with name and family name

Filling a 2D list with name and family name Question: Trying to put a string with full names into a 2D list, I get an error list out of range, how can I fix it? Example y[0][0] should contain "Charbel", and y[0][1] should contain "Daoud"… string1 = "Charbel Daoud, Manuella Germanos, Anis Ismael" x= string1.split(",") …

Total answers: 1

Get the column names of a python numpy ndarray

Get the column names of a python numpy ndarray Question: Let’s say I have a data file called data.txt that looks like: TIME FX FY FZ 0 10 5 6 1 2 4 7 2 5 2 6 … In Python run: import numpy as np myData = np.genfromtxt("data.txt", names=True) >>> print myData["TIME"] [0, 1, …

Total answers: 1

Why the "mutable default argument fix" syntax is so ugly, asks python newbie

Why the "mutable default argument fix" syntax is so ugly, asks python newbie Question: Now following my series of “python newbie questions” and based on another question. Prerogative Go to http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#other-languages-have-variables and scroll down to “Default Parameter Values”. There you can find the following: def bad_append(new_item, a_list=[]): a_list.append(new_item) return a_list def good_append(new_item, a_list=None): if a_list …

Total answers: 8