background preloader

Python

Facebook Twitter

Sort MAN Page. Sort text files. Sort, merge, or compare all the lines from the files given (or standard input.) Syntax sort [options] [file...] sort --help sort --version Options sort has three modes of operation: Sort (the default), Merge (-m), and Check(-c) -c Check whether the given files are already sorted: if they are not all sorted, print an error message and exit with a status of 1. -m Merge the given files by sorting them as a group. Each input file should already be individually sorted. It always works to sort instead of merge; merging is provided because it is faster, in the case where it works.

The following options affect the ordering of output lines. `-b' Ignore leading blanks when finding sort keys in each line. A pair of lines is compared as follows: if any key fields have been specified, `sort' compares each pair of fields, in the order specified on the command line, according to the associated ordering options, until a difference is found or no fields are left. Examples. Python-iptools - Utilities for dealing with ip addresses. A few useful functions and objects for manipulating ip addresses in python.

python-iptools - Utilities for dealing with ip addresses

This was all inspired by a desire to be able to use CIDR address notation to designate INTERNAL_IPS in a Django project's settings file. Functions: validate_ip: Validate a dotted quad ip address. ip2long: Convert a dotted quad ip address to a network byte order 32-bit integer. long2ip: Convert a network byte order 32-bit integer to a dotted quad ip address. validate_cidr: Validate a CIDR notation ip address. cidr2block: Convert a CIDR notation ip address into a tuple containing network block start and end addresses. Objects: IpRange: Range of ip addresses providing `in` and iteration. Using with Django The IpRangeList object can be used in a django settings file to allow CIDR notation and/or (start, end) ranges to be used in the INTERNAL_IPS list.

Example: #! Bsterne-tools/cidr/cidr.py at master · bsterne/bsterne-tools. Python: How to return something from a function that makes a dictionary. Creating a list of objects in Python. Python Packages « Python Conquers The Universe. I’ve avoided putting my Python modules into packages.

Python Packages « Python Conquers The Universe

That’s because (like a lot of other folks) I don’t really understand how to create a package. And that’s because (probably like a lot of other folks) I’m too time-constrained and over-worked to be able to grok anything except a very short, clear, and simple explanation of how packages work… and I never found one. That’s all over now. In a post on comp.lang.python Steven D’Aprano has made it all beautifully clear. Here is an excerpt from his post. A package is a special arrangement of folder + modules. To be a package, there must be a file called __init__.py in the folder, e.g parrot/ +-- __init__.py +-- feeding/ +-- __init__.py +-- eating.py +-- drinking.py +-- fighting.py +-- flying.py +-- sleeping.py +-- talking.py This defines a package called parrot which includes a sub-package feeding and modules fighting, flying, sleeping and talking.

Without needing to manually import sub-packages. Thank you, Steven! Like this: Like Loading... Www.ibiblio.org/swaroopch/byteofpython/files/120/byteofpython_120.pdf. Python Development with PyDev and Eclipse. Python Development with PyDev and Eclipse - Tutorial Copyright © 2009, 2010, 2011, 2012, 2013 vogella GmbH Python, Pydev and Eclipse This article describes how to write and debug Python programs with Eclipse This article is based on Eclipse 4.3, Python 3.3.1 and PyDev version 2.7.3.

Python Development with PyDev and Eclipse

Python is an interpreted programming language and claims to be a very effective programming language. The name Python is based on the TV show called Monty Python's Flying Circus. Key features of Python are: high-level data types, as for example extensible lists statement grouping is done by indentation instead of brackets variable or argument declaration is not necessary supports for object-orientated, procedural and functional programming style.