# Demonstration code for Scientific Computing class, # http://www.math.nyu.edu/faculty/goodman/teaching/SciComp2022/ # Helpers.py # uses Python 3 and Numpy # Python Classes Demo # Some functions used in the demo of Python Classes def myNames(nameList): """The input nameList is a list of strings (names). The output is a list of all the strings that do not have "__" twice, as __init__ In a namelist for a class, the __***__ names are put there by the system, not by the user defining the class. """ # I really should have used Python string matching to look for strings # that don't match __***__, but I could not figure out the string # matching system -- the documentation is terrible (or I'm an idiot?)! # This should work most of the time, unless a user creates a name like # "best__burger__in__town" instead of "best_burger_in_town". myNameList = [] for name in nameList: if ( name.count("__") < 2 ): myNameList.append(name) return myNameList def printHello(): """A function that prints: Hello, classy world""" print(" Hello, classy world.")