Python Coding Interview Python Advanced Use enumerate() to iterate over both indices and values Debug problematic code with breakpoint() Format strings effectively with f-strings Sort lists with custom arguments Use generators instead of list compreh…
高性能编程 几个核心问题 • 生成器是怎样节约内存的?• 使用生成器的最佳时机是什么?• 我如何使用 itertools 来创建复杂的生成器工作流?• 延迟估值何时有益,何时无益? From: https://www.dataquest.io/blog/python-generators-tutorial/ • The basic terminology needed to understand generators • What a generator is • How to create y…
#! /usr/bin/python a = 1 b = [2, 3] def func(): a = 2 print("in func a:", a) b[0] = 1 print("in func b:", b) print("before func a:", a) print("before func b:", b) func() print("after func a:", a) print(&qu…