tuna / collection

idea collections from TUNA
267 stars 4 forks source link

PHPython string interpolation #64

Open hexchain opened 8 years ago

hexchain commented 8 years ago

故事背景:大鹰改坏了 pdns-ldap,xiaq 协助 debug 中…

xiaq: 完了我看我当年写的代码 xiaq: 有一种强烈的「这代码作者是傻逼」的感觉 xiaq: 待我静心研读一下 pdns-ldap xiaq: 这谁写的代码,都不写 docstring 的!!! xiaq: 天诛地灭 xiaq: 噫,还发现了 fmt % locals() 这种强行 string interpolation 的写法 bigeagle: locals() 😱😱😱 xiaq: 就这样

a = 'xyz'
b = 'haha'
print 'a = %(a)s, b = %(b)s' % locals()

xiaq: 谁说 python 没有 string interpolation,这不就是么 bigeagle: 😱😱 xiaq: 大鹰 panic 了 bigeagle: 特么……竟然…… bigeagle: 我…… bigeagle: 完全无法……反驳……

... 2分钟后 ...

bigeagle: output("LOG", "%(qtype)s %(t)s" % locals()) bigeagle: 这就活学活用 xiaq: 😂😂😂

bigeagle commented 8 years ago

https://github.com/tuna/pdns-ldap/issues/2

ppwwyyxx commented 8 years ago

orz % locals()......

alick commented 8 years ago

膜拜 Python 菊苣

On Tue, Mar 8, 2016 at 10:12 AM, Yuxin Wu notifications@github.com wrote:

orz % locals()......

— Reply to this email directly or view it on GitHub https://github.com/tuna/collection/issues/64#issuecomment-193843121.

Regards, Alick

Artoria2e5 commented 7 years ago

https://www.python.org/dev/peps/pep-0498