Convert string to number in python
For integers, use the built-in int() type constructor, e.g. int('144') == 144. Similarly, float() converts to floating-point, e.g. float('144') == 144.0.
Read tutorialTHE TUTORIAL LIBRARY
For integers, use the built-in int() type constructor, e.g. int('144') == 144. Similarly, float() converts to floating-point, e.g. float('144') == 144.0.
Read tutorialTo specify an octal digit, precede the octal value with a zero, and then a lower or uppercase 'o'. For example, to set the variable 'a' to the octal value '10' (8 in decimal), type
Read tutorialC language's ternary operator equivalent was added in Python 2.5. The syntax would be as follows
Read tutorialYou can make a higher order function in Python using two choices: you can use nested scopes or you can use callable objects. For example, suppose you wanted to define linear(a,b) w
Read tutorialRemember that arguments are passed by assignment in Python. Since assignment just creates references to objects, there's no alias between an argument name in the caller and callee,
Read tutorialIt can be a surprise to get the UnboundLocalError in previously working code when it is modified by adding an assignment statement somewhere in the body of a function.
Read tutorialFor reasons of efficiency as well as consistency, Python only reads the module file on the first time a module is imported. If it didn't, in a program consisting of many modules wh
Read tutorialmodule can find out its own module name by looking at the predefined global variable __name__. If this has the value '__main__', the program is running as a script. Many modules th
Read tutorialWhen a module is imported for the first time (or when the source is more recent than the current compiled file) a .pyc file containing the compiled code should be created in the sa
Read tutorialI had extensive experience with implementing an interpreted language in the ABC group at CWI, and from working with this group I had learned a lot about language design. This is th
Read tutorialWhile trying to install mysql-python using easy_install you get this error. It means you have not installed mysql-devel in your system. To resolve this, install mysql-devel first a
Read tutorialIf you are getting this error, it means you don't have 'south' installed and you are trying to execute from one of your python files. To resolve this error, obviously you need to i
Read tutorialOne example today. A better developer tomorrow.