What do backticks mean to the python interpreter: `num`

前端 未结 3 712
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 03:51

I\'m playing around with list comprehensions and I came across this little snippet on another site:

return \'\'.join([`num` for num in xrange(loop_count)])
<         


        
3条回答
  •  时光说笑
    2020-11-28 04:50

    Backtick quoting is generally non-useful and gone in Python 3.

    For what it's worth, this:

    ''.join(map(repr, xrange(10000000)))
    

    is marginally faster than the backtick version for me. But worrying about this is probably a premature optimisation.

提交回复
热议问题