background preloader

Python

Facebook Twitter

Python time strptime() Function. Description The method strptime() parses a string representing a time according to a format.

Python time strptime() Function

The return value is a struct_time as returned by gmtime() or localtime(). The format parameter uses the same directives as those used by strftime(); it defaults to "%a %b %d %H:%M:%S %Y" which matches the formatting returned by ctime(). If string cannot be parsed according to format, or if it has excess data after parsing, ValueError is raised. Syntax Following is the syntax for strptime() method: Python - Extension Programming with C. Any code that you write using any compiled language like C, C++ or Java can be integrated or imported into another Python script.

Python - Extension Programming with C

This code is considered as an "extension. " A Python extension module is nothing more than a normal C library. On Unix machines, these libraries usually end in .so (for shared object). On Windows machines, you typically see .dll (for dynamically linked library). Pre-Requisite: To start writing your extension, you are going to need the Python header files. On Unix machines, this usually requires installing a developer-specific package such as python2.5-dev.Windows users get these headers as part of the package when they use the binary Python installer. Developing emol! - video tutorials for python, wxpython, opengl, sqlite, deb, bazaar, launchpad, pyopengl, design, files. An Introduction To Python Objects Using IPython (Part-3) video tutorial - An Introduction to Python Objects, using IPython - Learn: code, beginner_programming, programming, wxpython, introduction, cover, help, objects, transition, tkinter, ipython, beginn.

Pyvideo.org. UT Python Tutorial — Documentation.

Python_examples

Python_advanced. Python_GUI. Python_package. Python. Tutorial - Learn Python in 10 minutes. NOTE: If you would like some Python development done, my company, Stochastic Technologies, is available for consulting.

Tutorial - Learn Python in 10 minutes

This tutorial is available as a short ebook. The e-book features extra content from follow-up posts on various Python best practices, all in a convenient, self-contained format. All future updates are free for people who purchase it. Preliminary fluff So, you want to learn the Python programming language but can't find a concise and yet full-featured tutorial. Properties Python is strongly typed (i.e. types are enforced), dynamically, implicitly typed (i.e. you don't have to declare variables), case sensitive (i.e. var and VAR are two different variables) and object-oriented (i.e. everything is an object).

Getting help Help in Python is always available right in the interpreter. >>> help(5)Help on int object:(etc etc) >>> dir(5)['__abs__', '__add__', ...] >>> abs. Syntax Python has no mandatory statement termination characters and blocks are specified by indentation. Strings. Learn Python with our free tutorials. Programming is great.

Learn Python with our free tutorials

You get to create something new, stimulate your brain and have fun along the way - especially if you're programming games. So we're going to show you how to write your very own Space Invaders lookalike called PyInvaders - but don't panic if you're tired of dull programming theory: take that palm away from your forehead. Here we'll focus on doing Cool Stuff(tm), making a game work instead of warbling about algorithms, data structures and object oriented polymorphism encapsulation. Or whatever. Consequently, to follow this guide it helps if you have some prior programming experience. The Python Challenge. (3) What are common uses of Python decorators. Style Guide for Python Code. Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such).For example, do not rely on CPython's efficient implementation of in-place string concatenation for statements in the form a += b or a = a + b.

Style Guide for Python Code

This optimization is fragile even in CPython (it only works for some types) and isn't present at all in implementations that don't use refcounting. In performance sensitive parts of the library, the ''.join() form should be used instead. This will ensure that concatenation occurs in linear time across various implementations.Comparisons to singletons like None should always be done with is or is not, never the equality operators.Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. Code Like a Pythonista: Idiomatic Python. In this interactive tutorial, we'll cover many essential Python idioms and techniques in depth, adding immediately useful tools to your belt.

Code Like a Pythonista: Idiomatic Python

There are 3 versions of this presentation: PyHed. Camelot - See it. Python: import a module from a folder. UsefulModules. The intent of this page is to list some of the most commonly used Python modules, in the hope that it will provide useful recommendations for other programmers (especially beginners).

UsefulModules

Remember that in addition to the listings below, there are other directories of Python modules - see PublishingPythonModules for details. Another collection of library details can be found on the Libraries page. Be warned that this list is subjective by its very nature - it is only intended as a helpful guide.

It is not definitive in any way, nor should it discourage developers from developing their own modules. Standard Library Backports StandardLibraryBackports - modules that make later standard library functionality available in earlier version Cryptography Python and Cryptography Database Foreign Function Interface CTypes - A package for calling the functions of dlls/shared libraries. Game Development PyGame - Principal wrapper of the SDL library.

GIS (Geographic Information System) Console Ascii Table packages. Manipulating PDFs with Python and pyPdf. There’s a handy 3rd party module called pyPdf out there that you can use to merge PDFs documents together, rotate pages, split and crop pages, and decrypt/encrypt PDF documents.

Manipulating PDFs with Python and pyPdf

In this article, we’ll take a look at a few of these functions and then create a simple GUI with wxPython that will allow us to merge a couple of PDFs. A pyPdf Tour To get the most out of pyPdf, you need to learn its two major functions: PdfFileReader and PdfFileWriter. They are the ones that I use the most.

Let’s take a look at what they can do: # Merge two PDFsfrom pyPdf import PdfFileReader, PdfFileWriter output = PdfFileWriter() pdfOne = PdfFileReader(file( "some\path\to\a\PDf", "rb")) pdfTwo = PdfFileReader(file("some\other\path\to\a\PDf", "rb")) output.addPage(pdfOne.getPage(0)) output.addPage(pdfTwo.getPage(0)) outputStream = file(r"output.pdf", "wb") output.write(outputStream) outputStream.close() The code above is just taken from the pyPdf documentation and shortened for this example.

Can I use Python as a bash replacement. 5. Built-in Types — Python v2.7.2 documentation. The following sections describe the standard types that are built into the interpreter.

5. Built-in Types — Python v2.7.2 documentation

Note Historically (until release 2.2), Python’s built-in types have differed from user-defined types because it was not possible to use the built-in types as the basis for object-oriented inheritance. Python from Scratch – Create a Dynamic Website. We’ve covered quite a bit of Python in the previous tutorials in this Session.

Python from Scratch – Create a Dynamic Website

Today, we’re going to combine everything we’ve learned so far to build a dynamic website with Python. Prefer a Video Tutorial? So, how do you get started creating websites with Python? Well, you could do it all yourself, and write a program that runs on a web server, accepting page requests and serving up responses in the form of HTML and other resources. However, that’s a lot of work, so why go to all the trouble when there are plenty of existing tools out there to do the job for you?

Django