def main(): ip_address = request.headers['X-Forwarded-For'] return greet(ip_address)
def test_it_shouts_well(self): self.assertEqual(greet("BOB"), "HELLO, BOB!")
def test_it_interpolates_simple_greetings(self): interpolated = greet(name="Bob") self.assertEqual(interpolated, "Hello, Bob.")
def test_it_substitutes_my_friend_for_None(self): interpolated = greet(None) self.assertEqual(interpolated, "Hello, my friend.")
def test_it_substitutes_my_friend_for_empty_string(self): interpolated = greet("") self.assertEqual(interpolated, "Hello, my friend.")
import greeting print(greeting.greet())
def test_it_interpolates_another_simple_greeting(self): interpolated = greet(name="Sally") self.assertEqual(interpolated, "Hello, Sally.")
# 直接引入? # python 也不含有private的属性 # 非常有用的代码封装和抽象的方法,即: # 外部不需要引用的函数全部定义成private,只有外部需要引用的函数才定义为public。 import index import greeting print(greeting.greet('hhp')) index.test()
import sys import screen import menu import settings import midi_replay import midi import led import greeting import color_handler import helper import octaves from gpiozero import Button screen.init() if len(sys.argv) != 2 or sys.argv[1] != "skip": greeting.greet() menu.add_sub_menu(color_handler.HandlerSelector) menu.add_sub_menu(midi_replay.Replay) menu.add_sub_menu(midi_replay.ReplayViewer) menu.add_sub_menu(settings.main_settings) menu.add_sub_menu(midi.MidiStatus) menu.add_sub_menu(led.LedTest) menu.init() led.init() led_handle = led.LedHandle(is_hsv=True) led_handle.enable() _btn = Button(3, hold_time=0.8, bounce_time=0.05)
import sys, os, re def modifyPythonPathWithStage(): base = "../src/build/" # search for directory begining with 'lib' for root, dirs, files in os.walk(base): for dir in dirs: if re.search(r"^lib", dir) != None: stage = dir try: sys.path.append(base + stage) except: print "must build application first" sys.exit() modifyPythonPathWithStage() import greeting print greeting.greet() print greeting.average(5.0, 6.0)
from greeting import greet import boto3 print(boto3.__version__) greet("hoge")
from greeting import greet greet("Bazel Python")
import greeting print('Python is Versatile') def greet(name): print(f'Hello {name}!') greet('aman') greeting.greet('rishabh') print('git version system is best')
elif "lyrics" in command and "by" in command: print(music.query_handler(command)) elif "run" in command: print(terminal.run_bash(command[command.index("run")+3:])) elif "plus one" in command or "+1" in command or "+ 1" in command or "plus 1" in command: print(motiv.plus_one()) elif "get score" in command or "getscore" in command: print(motiv.get_score(False)) elif "reset" in command: print(motiv.reset()) elif "quit" in command or "exit" in command or "nothing" in command or "go" in command: break else: print("Invalid command: " + command) if validity_checker(command): history.add_to_history(command) return "Have a nice day! (=^..^=)" #################################################################################################################### # execution block BLOCKED = scheduler.get_block_status() WEB_ACCESS = scheduler.web_access_handler(BLOCKED) print(greeting.greet(greeting.getname())) print(history.output_recents(history.x_in_y_most_recents(4, 20))) results = command_handler() print(results) RETURNDIR = terminal.run_bash('cd ' + LOCALDIR, True)