Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uses of Python's "from" keyword?

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

like image 624
Shon Freelen Avatar asked Aug 28 '11 04:08

Shon Freelen


People also ask

How many keywords does Python have?

They are for defining the syntax and structures of Python language. You should know there are 33 keywords in Python programming language as of writing this tutorial. Although the number can vary in course of time. Also keywords in Python is case sensitive.


2 Answers

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.

like image 104
Ray Toal Avatar answered Oct 23 '22 07:10

Ray Toal


There is a new syntax for delegating to a subgenerator in Python 3.3 which uses the from keyword.

like image 23
agf Avatar answered Oct 23 '22 07:10

agf