Uses of Python's “from” keyword?

前端 未结 6 658
一整个雨季
一整个雨季 2021-01-11 11:53

Are there any other uses for Python\'s \"from\" keyword aside from import statements?

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-11 12:44

    No and yes.

    According to the official Python 2.7.2 grammar, the only occurrence of the word from is in the clause import_from, so no.

    In the Python 3.1.3 grammar a new clause

    raise_stmt: 'raise' [test ['from' test]]
    

    appears, so yes.

提交回复
热议问题