background preloader


Facebook Twitter

Amazon s3

3.0 Announcement - Django REST framework. The 3.0 release of Django REST framework is the result of almost four years of iteration and refinement. It comprehensively addresses some of the previous remaining design issues in serializers, fields and the generic views. This release is incremental in nature. There are some breaking API changes, and upgrading will require you to read the release notes carefully, but the migration path should otherwise be relatively straightforward. The difference in quality of the REST framework API and implementation should make writing, maintaining and debugging your application far easier. 3.0 is the first of three releases that have been funded by our recent Kickstarter campaign. As ever, a huge thank you to our many wonderful sponsors. New features Notable features of this new release include: Significant new functionality continues to be planned for the 3.1 and 3.2 releases. REST framework: Under the hood.

Below is an in-depth guide to the API changes and migration notes for 3.0. Request objects. Django Rest Framework: Disable field update after object is created. Oauth2 token authentication using django-oauth-toolkit and python-social-auth. Iphone - How to login on ios device with django server? Python - Which authentication to be used when using Django Rest Framework and IOS app? Learn Python The Hard Way. An important concept that you have to understand is the difference between a class and an object. The problem is, there is no real "difference" between a class and an object. They are actually the same thing at different points in time. I will demonstrate by a Zen koan: What is the difference between a Fish and a Salmon?

Did that question sort of confuse you? Really sit down and think about it for a minute. I mean, a Fish and a Salmon are different but, wait, they are the same thing, right? This question is confusing because most people do not think about real things this way, but they intuitively understand them. Let's take it one step further. What is the difference between Mary and a Salmon?

Again this is a weird question, but it's a bit easier than the Fish versus Salmon question. Now for the mind-bending idea: Fish is a class, and Salmon is a class, and Mary is an object. There you have it: Mary is a kind of Salmon that is a kind of Fish. object is a class is a class. Exactly. A Coder, a Programmer, a Hacker, a Developer, and a Computer Scientist walk into a Venn Diagram.

Creating themes — Pelican 3.5.0 documentation. To generate its HTML output, Pelican uses the Jinja templating engine due to its flexibility and straightforward syntax. If you want to create your own theme, feel free to take inspiration from the “simple” theme. To generate your site using a theme you have created (or downloaded manually and then modified), you can specify that theme via the -t flag: If you’d rather not specify the theme on every invocation, you can define THEME in your settings to point to the location of your preferred theme.

Templates and variables¶ The idea is to use a simple syntax that you can embed into your HTML pages. This document describes which templates should exist in a theme, and which variables will be passed to each template at generation time. All templates will receive the variables defined in your settings file, as long as they are in all-caps. Common variables¶ All of these settings will be available to all templates. Sorting¶ {% for tag, articles in tags|sort %} Date Formatting¶ index.html¶ author.html¶ Packaging and Distributing Projects — Python Packaging User Guide documentation. Initial Files¶¶ The most important file is “” which exists at the root of your project directory. For an example, see the in the PyPA sample project.

“” serves two primary functions: It’s the file where various aspects of your project are configured. The primary feature of is that it contains a global setup() function. <your package>¶ Although it’s not required, the most common practice to is to include your python modules and packages under a single top-level package that has the same name as your project, or something very close. For an example, see the sample package that’s include in the PyPA sample project setup() args¶ As mentioned above, The primary feature of is that it contains a global setup() function.

The most relevant arguments are explained below. Name¶ This is the name of your project, and will determine how your project is listed on PyPI. Version¶ Projects should comply with the version scheme specified in PEP440. Description¶


Django. Python - pip geoip installing in ubuntu gcc error. Exception handling - Python try-else. How to use *args and **kwargs in Python. How to use *args and **kwargs in Python Or, How to use variable length argument lists in Python. The special syntax, *args and **kwargs in function definitions is used to pass a variable number of arguments to a function. The single asterisk form (*args) is used to pass a non-keyworded, variable-length argument list, and the double asterisk form is used to pass a keyworded, variable-length argument list.

Here is an example of how to use the non-keyworded form. This example passes one formal (positional) argument, and two more variable length arguments. def test_var_args(farg, *args): print "formal arg:", farg for arg in args: print "another arg:", arg test_var_args(1, "two", 3) Results: formal arg: 1 another arg: two another arg: 3 Here is an example of how to use the keyworded form. Def test_var_kwargs(farg, **kwargs): print "formal arg:", farg for key in kwargs: print "another keyword arg: %s: %s" % (key, kwargs[key]) test_var_kwargs(farg=1, myarg2="two", myarg3=3) arg1: 1 arg2: two arg3: 3.


YAML Tutorial - Essentials. This website uses cookies to display custom content and advertising. We therefore share information about your use of our site with Google. See details From Essentials YAML Rules Applicable YAML files: all files with a .yml extension. Essentials uses a config.yml file. YAML Parser ALWAYS check your YAML config files against this parser: YAML Parser When using the parser, CORRECT output looks like this: Image:Output.png The file used for the tutorial and for the output is here: HelloWorld Please use notepad++ (free) or another program to convert your TABs to spaces if you want to easily edit your YAML config files using the TAB key. Within notepad++ Click Settings -> Preferences -> Language Menu/Tab Settings, which will take you to the following screen.

Notice that the properties are spaced 2 from the margin. Notice that this key-property structure and the above one are similar, but are fundamentally different (by YAML standards that is). Data Processing in Python.ipynb. Python decorators finally demystified. Hi there guys! I hope all of you are fine and doing well. Recently I was hanging out on a python related IRC where I got a request from someone to write an article on decorators in Python. It is perhaps one of the most difficult concept to grasp. So as usual without wasting anytime let get on with it. Edit: this article has been published on my other blog where it will be easier for you to read the code. Everything in python is an object (Functions too!)

First of all let’s understand functions in python: def hi(name="yasoob"): return "hi "+name print hi() #output: 'hi yasoob' #We can even assign a function to a variable like greet = hi #We are not using parentheses here because we are not calling the function hi #instead we are just putting it into the greet variable. Defining functions within functions: So those are the basics when it comes to functions. So now we know that we can define functions in other functions. Returning functions from within functions: def hi(): return "hi yasoob! " PEP 8 -- Style Guide for Python Code.


Code Style. If you ask Python programmers what they like most in Python, they will often say its high readability. Indeed, a high level of readability is at the heart of the design of the Python language, following the recognized fact that code is read much more often than it is written. One reason for Python code to be easily read and understood is its relatively complete set of Code Style guidelines and “Pythonic” idioms.

Moreover, when a veteran Python developer (a Pythonista) points to portions of code and says they are not “Pythonic”, it usually means that these lines of code do not follow the common guidelines and fail to express the intent in what is considered the best (hear: most readable) way. On some border cases, no best way has been agreed upon on how to express an intent in Python code, but these cases are rare. General concepts Explicit code While any kind of black magic is possible with Python, the most explicit and straightforward manner is preferred. Bad Good One statement per line 3. Note.