Skip to content
This repository was archived by the owner on Dec 2, 2021. It is now read-only.
This repository was archived by the owner on Dec 2, 2021. It is now read-only.

listcomp_speed.py will rasise a error in python2.7 and run well in python3.5 #10

@wllbll

Description

@wllbll

the code in listcomp_speed.py will rasise an syntax error:
def clock(label, cmd):
... res = time.repeat(cmd, setup=SETUP, number=TIMES)
... print(label, *('{:3.f}.formart(x) for x in res'))
File "", line 3
print(label, *('{:3.f}.formart(x) for x in res'))
^
SyntaxError: invalid syntax

but it doesn't make sense to me, as the asterisk in print is unpacking, and unpacking is support in print, as
print(*("1","2")) will work well.

and the same code run well in python3.5.

the book did not specify the environment of python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions