I&C SCI 32 Lecture Notes - Lecture 8: Init, Software Engineering
Document Summary
You"ve seen previously how to use namedtuples, which is one way in python to collect heterogeneous data into a single object. Each piece of data is called a fieldand the fields are identified by their names. Beyond that, namedtuples don"t really know how to do much of anything; they"re useful, but limited to the problem of bringing a few pieces of data together into the same object. For example, consider this interaction with a python interpreter. >>> s = "this is a string object" After creating a string and storing it in the variable s, we then ask that string to do a couple of things for us: Hey, s, split yourself into a list of words, by using spaces to delineate where one word ends and another begins, and give me back the resulting list. The syntax s. upper() is called a method call on the object s; in this case, upper() is called a method.