我是Python编程语言的新手.我想知道是否可以编译用Python编写的程序.
是否有可能将Python脚本转换为某些较低级别的编程语言,然后可以编译为二进制代码?
正在考虑使用Python编写代码的开发人员可能希望保持开放的可能性,以便以后能够进行二进制分发.
当ttk.Combobox是只读且不在焦点时,其文本背景变为白色,这与灰色场背景不同,并使组合框看起来很丑:
所需的风格将是第二个.如何使组合框像这样工作?
我尝试编写一个装饰器函数,它包装asyncio.coroutine
并返回完成所需的时间。下面的食谱包含按我预期工作的代码。我唯一的问题是,尽管使用了@functools.wraps
. 如何保留原来协程的名称?我检查了来源asyncio.
import asyncio
import functools
import random
import time
MULTIPLIER = 5
def time_resulted(coro):
@functools.wraps(coro)
@asyncio.coroutine
def wrapper(*args, **kargs):
time_before = time.time()
result = yield from coro(*args, **kargs)
if result is not None:
raise TypeError('time resulted coroutine can '
'only return None')
return time_before, time.time()
print('= wrapper.__name__: {!r} ='.format(wrapper.__name__))
return wrapper
@time_resulted
@asyncio.coroutine
def random_sleep():
sleep_time = random.random() * MULTIPLIER
print('{} -> {}'.format(time.time(), sleep_time))
yield from asyncio.sleep(sleep_time)
if __name__ == '__main__':
loop = asyncio.get_event_loop() …
Run Code Online (Sandbox Code Playgroud) python ×2
python-3.x ×2
combobox ×1
compilation ×1
coroutine ×1
decorator ×1
python-3.4 ×1
tkinter ×1
ttk ×1