GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — example-code/08-obj-ref/bus.py at master · dreamsql/example-code Expand file tree/ Copy pathbus.pyMore file actions 29 lines (23 loc) · 606 Bytes / Copy pathbus.pyFile metadata and controls29 lines (23 loc) · 606 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 """ >>> import copy >>> bus1 = Bus(['Alice', 'Bill', 'Claire', 'David']) >>> bus2 = copy.copy(bus1) >>> bus3 = copy.deepcopy(bus1) >>> bus1.drop('Bill') >>> bus2.passengers ['Alice', 'Claire', 'David'] >>> bus3.passengers ['Alice', 'Bill', 'Claire', 'David'] """ # BEGIN BUS_CLASS class Bus: def __init__(self, passengers=None): if passengers is None: self.passengers = [] else: self.passengers = list(passengers) def pick(self, name): self.passengers.append(name) def drop(self, name): self.passengers.remove(name) # END BUS_CLASS |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |