304 Posted Topics

Member Avatar for mruane

You mean something like that?: [CODE=python] functs=['blue','red','yellow'] def explain(): print("just type in the function name like %s"%" or ".join(functs)) def funct_blue(): print("blue called") while True: inp=raw_input("function name: ") try: eval("funct_"+inp)() except NameError: explain() [/CODE]

Member Avatar for slate
0
299
Member Avatar for turnerca902

First build a dictionary with keys of mapsheet nrs and values of mapsheet names. [U]High hack value, instable code:[/U] Filter the xml line by line with a regular expression like: pattern=re.compile(r'<title Sync="TRUE">(([0-9]+)\.tif).*?') Replace line.match.group(X) whith the appripirate value from the dictionary [U]More reading, more learning, elegant code, maybe overkill:[/U] Parse …

Member Avatar for woooee
0
154
Member Avatar for jimbox123

[CODE=python] def choose_pizza(pizza,menu): print("Let me help you order a pizza. Here are the choices:") for (pizzaname,prize),menuitem in zip(pizza.iteritems(),menu.keys()): print("(%s) %s $%.2f" % (menuitem,pizzaname,prize)) choice=raw_input("Please enter %s: " % (" or ".join(menu.keys()))) if choice not in menu: return None return choice def choose_qty(): qty=raw_input("How many would you like?: ") iqty=None try: …

Member Avatar for vegaseat
0
1K
Member Avatar for FreezeBlink

The type function documentation says: type( object) Return the type of an object. The return value is a type object. [...] So. Object str happens to be a type object. There is no instance type in the global scope however. If you want to have all types, then: [CODE=python] import …

Member Avatar for Ene Uran
0
264

The End.