- Home
- Interview Questions
- Python
Python is an open source language that is getting a lot of attention from the market.
1) Created by: Guido van Rossum nearly 11 years ago
2) Python is an interpreted, high-level programming language, pure object-oriented and powerful server-side scripting language for the Web.
3) Python is a good prototype language. In just a few minutes, you can develop prototypes that would take you several hours in other languages.
Byte code is the lower-level form of your program after Python compiles it. Python automatically stores byte code in files with a .pyc extension.
It used to create small anonymous functions at run time. Like e.g.
def fun1(x):
return x**2
print fun1(2)
it gives you answer 4
the same thing can be done using
sq=lambda x: x**2
print sq(2)
it gives the answer 4
The PVM is the Python Virtual Machine—the runtime engine of Python that interprets your compiled byte code.
CPython is the standard implementation of the language. Jython and IronPython implement Python programs for use in Java and .NET environments, respectively; they are alternative compilers for Python.
Stackless is an enhanced version of Python aimed at concurrency, and PyPy is a reimplementation of Python targeted at speed. PyPy is also the successor to Psyco, and incorporates the JIT concepts that Psyco pioneered.
You can start an interactive session on Windows 7 and earlier by clicking your Start button, picking the All Programs option, clicking the Python entry, and selecting the “Python (command line)” menu option. You can also achieve the same effect on Windows and other platforms by typing python as a system command line in your system’s console window (a Command Prompt window on Windows). Another alternative is to launch IDLE, as its main Python shell window is an interactive session. Depending on your platform and Python, if you have not set your system’s PATH variable to find Python, you may need to cd to where Python is installed, or type its full directory path instead of just python (e.g., C:\Python33\python on Windows, unless you’re using the 3.3 launcher).
You type system command lines in whatever your platform provides as a system console: a Command Prompt window on Windows; an xterm or terminal window on Unix, Linux, and Mac OS X; and so on. You type this at the system’s prompt, not at the Python interactive interpreter’s ">>>" prompt—be careful not to confuse these prompts.
Scripts that print and then exit cause the output file to disappear immediately, before you can view the output (which is why the input trick comes in handy); error messages generated by your script also appear in an output window that closes before you can examine its contents (which is one reason that system command lines and IDEs such as IDLE are better for most development).
A namespace is just a package of variables (i.e., names). It takes the form of an object with attributes in Python. Each module file is automatically a namespace— that is, a package of variables reflecting the assignments made at the top level of the file. Namespaces help avoid name collisions in Python programs: because each module file is a self-contained namespace, files must explicitly import other files in order to use their names.