Sumber : http://docs.python.org/library/stdtypes.html#index-601

Methods are functions that are called using the attribute notation. There are two flavors: built-in methods (such as append() on lists) and class instance methods. Built-in methods are described with the types that support them.

The implementation adds two special read-only attributes to class instance methods: m.im_self is the object on which the method operates, and m.im_func is the function implementing the method. Calling m(arg-1, arg-2, ..., arg-n) is completely equivalent to calling m.im_func(m.im_self, arg-1, arg-2, ..., arg-n).

Class instance methods are either bound or unbound, referring to whether the method was accessed through an instance or a class, respectively. When a method is unbound, its im_self attribute will be None and if called, an explicit self object must be passed as the first argument. In this case, self must be an instance of the unbound method’s class (or a subclass of that class), otherwise a TypeError is raised.

Like function objects, methods objects support getting arbitrary attributes. However, since method attributes are actually stored on the underlying function object (meth.im_func), setting method attributes on either bound or unbound methods is disallowed. Attempting to set a method attribute results in a TypeError being raised. In order to set a method attribute, you need to explicitly set it on the underlying function object:

class C:
    def method(self):
        pass
c = C()
c.method.im_func.whoami = 'my name is c'

See The standard type hierarchy for more information.

5.11.5. Code Objects

Code objects are used by the implementation to represent “pseudo-compiled” executable Python code such as a function body. They differ from function objects because they don’t contain a reference to their global execution environment. Code objects are returned by the built-in compile() function and can be extracted from function objects through their func_code attribute. See also the code module.

A code object can be executed or evaluated by passing it (instead of a source string) to the exec statement or the built-in eval() function.

See The standard type hierarchy for more information.

Sumber : http://docs.python.org/library/stdtypes.html#index-601

<a href=”http://diploma.ipb.ac.id” title=”IPB Badge by:Farhad”><img src=”http://ipb.ac.id/badge/img/20100612201767940.png” alt=”IPB Badge” width=”207″ height=”104″/></a>

Sumber : http://docs.python.org/library/stdtypes.html#index-601

File objects are implemented using C’s stdio package and can be created with the built-in open() function. File objects are also returned by some other built-in functions and methods, such as os.popen() and os.fdopen() and the makefile() method of socket objects. Temporary files can be created using the tempfile module, and high-level file operations such as copying, moving, and deleting files and directories can be achieved with the shutil module.

When a file operation fails for an I/O-related reason, the exception IOError is raised. This includes situations where the operation is not defined for some reason, like seek() on a tty device or writing a file opened for reading.

Files have the following methods:

file.close()
Close the file. A closed file cannot be read or written any more. Any operation which requires that the file be open will raise a ValueError after the file has been closed. Calling close() more than once is allowed.

As of Python 2.5, you can avoid having to call this method explicitly if you use the with statement. For example, the following code will automatically close f when the with block is exited:

from __future__ import with_statement # This isn't required in Python 2.6
with open("hello.txt") as f:
    for line in f:
        print line

In older versions of Python, you would have needed to do this to get the same effect:

f = open("hello.txt")
try:
    for line in f:
        print line
finally:
    f.close()

Note

Not all “file-like” types in Python support use as a context manager for the with statement. If your code is intended to work with any file-like object, you can use the function contextlib.closing() instead of using the object directly.

file.flush()
Flush the internal buffer, like stdio‘s fflush(). This may be a no-op on some file-like objects.

Note

flush() does not necessarily write the file’s data to disk. Use flush() followed by os.fsync() to ensure this behavior.

file.fileno()

Return the integer “file descriptor” that is used by the underlying implementation to request I/O operations from the operating system. This can be useful for other, lower level interfaces that use file descriptors, such as the fcntl module or os.read() and friends.

Note

File-like objects which do not have a real file descriptor should not provide this method!

file.isatty()
Return True if the file is connected to a tty(-like) device, else False.

Note

If a file-like object is not associated with a real file, this method should not be implemented.

file.next()
A file object is its own iterator, for example iter(f) returns f (unless f is closed). When a file is used as an iterator, typically in a for loop (for example, for line in f: print line), the next() method is called repeatedly. This method returns the next input line, or raises StopIteration when EOF is hit when the file is open for reading (behavior is undefined when the file is open for writing). In order to make a for loop the most efficient way of looping over the lines of a file (a very common operation), the next() method uses a hidden read-ahead buffer. As a consequence of using a read-ahead buffer, combining next() with other file methods (like readline()) does not work right. However, using seek() to reposition the file to an absolute position will flush the read-ahead buffer.

New in version 2.3.

file.read([size])
Read at most size bytes from the file (less if the read hits EOF before obtaining size bytes). If the size argument is negative or omitted, read all data until EOF is reached. The bytes are returned as a string object. An empty string is returned when EOF is encountered immediately. (For certain files, like ttys, it makes sense to continue reading after an EOF is hit.) Note that this method may call the underlying C function fread() more than once in an effort to acquire as close to size bytes as possible. Also note that when in non-blocking mode, less data than was requested may be returned, even if no size parameter was given.

Note

This function is simply a wrapper for the underlying fread() C function, and will behave the same in corner cases, such as whether the EOF value is cached.

file.readline([size])
Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). [6] If the size argument is present and non-negative, it is a maximum byte count (including the trailing newline) and an incomplete line may be returned. An empty string is returned only when EOF is encountered immediately.

Note

Unlike stdio‘s fgets(), the returned string contains null characters ('') if they occurred in the input.

file.readlines([sizehint])
Read until EOF using readline() and return a list containing the lines thus read. If the optional sizehint argument is present, instead of reading up to EOF, whole lines totalling approximately sizehint bytes (possibly after rounding up to an internal buffer size) are read. Objects implementing a file-like interface may choose to ignore sizehint if it cannot be implemented, or cannot be implemented efficiently.
file.xreadlines()
This method returns the same thing as iter(f).

New in version 2.1.

Deprecated since version 2.3: Use for line in file instead.

file.seek(offset[, whence])
Set the file’s current position, like stdio‘s fseek(). The whence argument is optional and defaults to os.SEEK_SET or 0 (absolute file positioning); other values are os.SEEK_CUR or 1 (seek relative to the current position) and os.SEEK_END or 2 (seek relative to the file’s end). There is no return value.

For example, f.seek(2, os.SEEK_CUR) advances the position by two and f.seek(-3, os.SEEK_END) sets the position to the third to last.

Note that if the file is opened for appending (mode 'a' or 'a+'), any seek() operations will be undone at the next write. If the file is only opened for writing in append mode (mode 'a'), this method is essentially a no-op, but it remains useful for files opened in append mode with reading enabled (mode 'a+'). If the file is opened in text mode (without 'b'), only offsets returned by tell() are legal. Use of other offsets causes undefined behavior.

Note that not all file objects are seekable.

Changed in version 2.6: Passing float values as offset has been deprecated.

file.tell()
Return the file’s current position, like stdio‘s ftell().

Note

On Windows, tell() can return illegal values (after an fgets()) when reading files with Unix-style line-endings. Use binary mode ('rb') to circumvent this problem.

file.truncate([size])
Truncate the file’s size. If the optional size argument is present, the file is truncated to (at most) that size. The size defaults to the current position. The current file position is not changed. Note that if a specified size exceeds the file’s current size, the result is platform-dependent: possibilities include that the file may remain unchanged, increase to the specified size as if zero-filled, or increase to the specified size with undefined new content. Availability: Windows, many Unix variants.
file.write(str)
Write a string to the file. There is no return value. Due to buffering, the string may not actually show up in the file until the flush() or close() method is called.
file.writelines(sequence)
Write a sequence of strings to the file. The sequence can be any iterable object producing strings, typically a list of strings. There is no return value. (The name is intended to match readlines(); writelines() does not add line separators.)

Files support the iterator protocol. Each iteration returns the same result as file.readline(), and iteration ends when the readline() method returns an empty string.

File objects also offer a number of other interesting attributes. These are not required for file-like objects, but should be implemented if they make sense for the particular object.

file.closed
bool indicating the current state of the file object. This is a read-only attribute; the close() method changes the value. It may not be available on all file-like objects.
file.encoding
The encoding that this file uses. When Unicode strings are written to a file, they will be converted to byte strings using this encoding. In addition, when the file is connected to a terminal, the attribute gives the encoding that the terminal is likely to use (that information might be incorrect if the user has misconfigured the terminal). The attribute is read-only and may not be present on all file-like objects. It may also be None, in which case the file uses the system default encoding for converting Unicode strings.

New in version 2.3.

file.errors
The Unicode error handler used along with the encoding.

New in version 2.6.

file.mode
The I/O mode for the file. If the file was created using the open() built-in function, this will be the value of the mode parameter. This is a read-only attribute and may not be present on all file-like objects.
file.name
If the file object was created using open(), the name of the file. Otherwise, some string that indicates the source of the file object, of the form <...>. This is a read-only attribute and may not be present on all file-like objects.
file.newlines
If Python was built with the –with-universal-newlines option to configure (the default) this read-only attribute exists, and for files opened in universal newline read mode it keeps track of the types of newlines encountered while reading the file. The values it can take are '\r', '\n', '\r\n', None (unknown, no newlines read yet) or a tuple containing all the newline types seen, to indicate that multiple newline conventions were encountered. For files not opened in universal newline read mode the value of this attribute will be None.
file.softspace
Boolean that indicates whether a space character needs to be printed before another value when using the print statement. Classes that are trying to simulate a file object should also have a writable softspace attribute, which should be initialized to zero. This will be automatic for most classes implemented in Python (care may be needed for objects that override attribute access); types implemented in C will have to provide a writable softspace attribute.

Note

This attribute is not used to control the print statement, but to allow the implementation of print to keep track of its internal state.

Sumber : http://docs.python.org/library/stdtypes.html#index-601

<a href=”http://diploma.ipb.ac.id” title=”IPB Badge by:Farhad”><img src=”http://ipb.ac.id/badge/img/20100612201767940.png” alt=”IPB Badge” width=”207″ height=”104″/></a>

Sumber : http://docs.python.org/library/stdtypes.html#index-601

A set object is an unordered collection of distinct hashable objects. Common uses include membership testing, removing duplicates from a sequence, and computing mathematical operations such as intersection, union, difference, and symmetric difference. (For other containers see the built in dict, list, and tuple classes, and the collections module.)

New in version 2.4.

Like other collections, sets support x in set, len(set), and for x in set. Being an unordered collection, sets do not record element position or order of insertion. Accordingly, sets do not support indexing, slicing, or other sequence-like behavior.

There are currently two built-in set types, set and frozenset. The set type is mutable — the contents can be changed using methods like add() and remove(). Since it is mutable, it has no hash value and cannot be used as either a dictionary key or as an element of another set. The frozenset type is immutable and hashable — its contents cannot be altered after it is created; it can therefore be used as a dictionary key or as an element of another set.

The constructors for both classes work the same:

class set([iterable])
class frozenset([iterable])
Return a new set or frozenset object whose elements are taken from iterable. The elements of a set must be hashable. To represent sets of sets, the inner sets must be frozenset objects. If iterable is not specified, a new empty set is returned.

Instances of set and frozenset provide the following operations:

len(s)
Return the cardinality of set s.
x in s
Test x for membership in s.
x not in s
Test x for non-membership in s.
isdisjoint(other)
Return True if the set has no elements in common with other. Sets are disjoint if and only if their intersection is the empty set.

New in version 2.6.

issubset(other)
set <= other
Test whether every element in the set is in other.
set < other
Test whether the set is a true subset of other, that is, set <= other and set != other.
issuperset(other)
set >= other
Test whether every element in other is in the set.
set > other
Test whether the set is a true superset of other, that is, set >= other and set != other.
union(other, )
set | other | ...
Return a new set with elements from the set and all others.

Changed in version 2.6: Accepts multiple input iterables.

intersection(other, )
set & other & ...
Return a new set with elements common to the set and all others.

Changed in version 2.6: Accepts multiple input iterables.

difference(other, )
set - other - ...
Return a new set with elements in the set that are not in the others.

Changed in version 2.6: Accepts multiple input iterables.

symmetric_difference(other)
set ^ other
Return a new set with elements in either the set or other but not both.
copy()
Return a new set with a shallow copy of s.

Note, the non-operator versions of union(), intersection(), difference(), and symmetric_difference(), issubset(), and issuperset() methods will accept any iterable as an argument. In contrast, their operator based counterparts require their arguments to be sets. This precludes error-prone constructions like set('abc') & 'cbs' in favor of the more readable set('abc').intersection('cbs').

Both set and frozenset support set to set comparisons. Two sets are equal if and only if every element of each set is contained in the other (each is a subset of the other). A set is less than another set if and only if the first set is a proper subset of the second set (is a subset, but is not equal). A set is greater than another set if and only if the first set is a proper superset of the second set (is a superset, but is not equal).

Instances of set are compared to instances of frozenset based on their members. For example, set('abc') == frozenset('abc') returns True and so does set('abc') in set([frozenset('abc')]).

The subset and equality comparisons do not generalize to a complete ordering function. For example, any two disjoint sets are not equal and are not subsets of each other, so all of the following return False: a<b, a==b, or a>b. Accordingly, sets do not implement the __cmp__() method.

Since sets only define partial ordering (subset relationships), the output of the list.sort() method is undefined for lists of sets.

Set elements, like dictionary keys, must be hashable.

Binary operations that mix set instances with frozenset return the type of the first operand. For example: frozenset('ab') | set('bc') returns an instance of frozenset.

The following table lists operations available for set that do not apply to immutable instances of frozenset:

update(other, )
set |= other | ...
Update the set, adding elements from all others.

Changed in version 2.6: Accepts multiple input iterables.

intersection_update(other, )
set &= other & ...
Update the set, keeping only elements found in it and all others.

Changed in version 2.6: Accepts multiple input iterables.

difference_update(other, )
set -= other | ...
Update the set, removing elements found in others.

Changed in version 2.6: Accepts multiple input iterables.

symmetric_difference_update(other)
set ^= other
Update the set, keeping only elements found in either set, but not in both.
add(elem)
Add element elem to the set.
remove(elem)
Remove element elem from the set. Raises KeyError if elem is not contained in the set.
discard(elem)
Remove element elem from the set if it is present.
pop()
Remove and return an arbitrary element from the set. Raises KeyError if the set is empty.
clear()
Remove all elements from the set.

Note, the non-operator versions of the update(), intersection_update(), difference_update(), and symmetric_difference_update() methods will accept any iterable as an argument.

Note, the elem argument to the __contains__(), remove(), and discard() methods may be a set. To support searching for an equivalent frozenset, the elem set is temporarily mutated during the search and then restored. During the search, the elem set should not be read or mutated since it does not have a meaningful value.Sumber :

http://docs.python.org/library/stdtypes.html#index-601

<a href=”http://diploma.ipb.ac.id” title=”IPB Badge by:Farhad”><img src=”http://ipb.ac.id/badge/img/20100612201767940.png” alt=”IPB Badge” width=”207″ height=”104″/></a>

Sumber : http://docs.python.org/library/stdtypes.html#index-601

String and Unicode objects have one unique built-in operation: the % operator (modulo). This is also known as the string formatting or interpolation operator. Given format % values (where format is a string or Unicode object), % conversion specifications in format are replaced with zero or more elements of values. The effect is similar to the using sprintf() in the C language. If format is a Unicode object, or if any of the objects being converted using the %s conversion are Unicode objects, the result will also be a Unicode object.

If format requires a single argument, values may be a single non-tuple object. [4] Otherwise, values must be a tuple with exactly the number of items specified by the format string, or a single mapping object (for example, a dictionary).

A conversion specifier contains two or more characters and has the following components, which must occur in this order:

  1. The '%' character, which marks the start of the specifier.
  2. Mapping key (optional), consisting of a parenthesised sequence of characters (for example, (somename)).
  3. Conversion flags (optional), which affect the result of some conversion types.
  4. Minimum field width (optional). If specified as an '*' (asterisk), the actual width is read from the next element of the tuple in values, and the object to convert comes after the minimum field width and optional precision.
  5. Precision (optional), given as a '.' (dot) followed by the precision. If specified as '*' (an asterisk), the actual width is read from the next element of the tuple in values, and the value to convert comes after the precision.
  6. Length modifier (optional).
  7. Conversion type.

When the right argument is a dictionary (or other mapping type), then the formats in the string must include a parenthesised mapping key into that dictionary inserted immediately after the '%' character. The mapping key selects the value to be formatted from the mapping. For example:

>>> print '%(language)s has %(#)03d quote types.' % \
...       {'language': "Python", "#": 2}
Python has 002 quote types.

In this case no * specifiers may occur in a format (since they require a sequential parameter list).

The conversion flag characters are:

Flag Meaning
'#' The value conversion will use the “alternate form” (where defined below).
'0' The conversion will be zero padded for numeric values.
'-' The converted value is left adjusted (overrides the '0' conversion if both are given).
' ' (a space) A blank should be left before a positive number (or empty string) produced by a signed conversion.
'+' A sign character ('+' or '-') will precede the conversion (overrides a “space” flag).

A length modifier (h, l, or L) may be present, but is ignored as it is not necessary for Python – so e.g. %ld is identical to %d.

The conversion types are:

Conversion Meaning Notes
'd' Signed integer decimal.
'i' Signed integer decimal.
'o' Signed octal value. (1)
'u' Obsolete type – it is identical to 'd'. (7)
'x' Signed hexadecimal (lowercase). (2)
'X' Signed hexadecimal (uppercase). (2)
'e' Floating point exponential format (lowercase). (3)
'E' Floating point exponential format (uppercase). (3)
'f' Floating point decimal format. (3)
'F' Floating point decimal format. (3)
'g' Floating point format. Uses lowercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise. (4)
'G' Floating point format. Uses uppercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise. (4)
'c' Single character (accepts integer or single character string).
'r' String (converts any Python object using repr()). (5)
's' String (converts any Python object using str()). (6)
'%' No argument is converted, results in a '%' character in the result.

Notes:

  1. The alternate form causes a leading zero ('0') to be inserted between left-hand padding and the formatting of the number if the leading character of the result is not already a zero.
  2. The alternate form causes a leading '0x' or '0X' (depending on whether the 'x' or 'X' format was used) to be inserted between left-hand padding and the formatting of the number if the leading character of the result is not already a zero.
  3. The alternate form causes the result to always contain a decimal point, even if no digits follow it.The precision determines the number of digits after the decimal point and defaults to 6.
  4. The alternate form causes the result to always contain a decimal point, and trailing zeroes are not removed as they would otherwise be.The precision determines the number of significant digits before and after the decimal point and defaults to 6.
  5. The %r conversion was added in Python 2.0.The precision determines the maximal number of characters used.
  6. If the object or format provided is a unicode string, the resulting string will also be unicode.The precision determines the maximal number of characters used.
  7. See PEP 237.

Since Python strings have an explicit length, %s conversions do not assume that '' is the end of the string.

For safety reasons, floating point precisions are clipped to 50; %f conversions for numbers whose absolute value is over 1e50 are replaced by %g conversions. [5] All other errors raise exceptions.

Additional string operations are defined in standard modules string and re.

Sumber : http://docs.python.org/library/stdtypes.html#index-601

<a href=”http://diploma.ipb.ac.id” title=”IPB Badge by:Farhad”><img src=”http://ipb.ac.id/badge/img/20100612201767940.png” alt=”IPB Badge” width=”207″ height=”104″/></a>

Sumber : http://docs.python.org/library/stdtypes.html#index-601

Below are listed the string methods which both 8-bit strings and Unicode objects support. Note that none of these methods take keyword arguments.

In addition, Python’s strings support the sequence type methods described in the Sequence Types — str, unicode, list, tuple, buffer, xrange section. To output formatted strings use template strings or the % operator described in the String Formatting Operations section. Also, see the re module for string functions based on regular expressions.

str.capitalize()
Return a copy of the string with only its first character capitalized.

For 8-bit strings, this method is locale-dependent.

str.center(width[, fillchar])
Return centered in a string of length width. Padding is done using the specified fillchar (default is a space).

Changed in version 2.4: Support for the fillchar argument.

str.count(sub[, start[, end]])
Return the number of non-overlapping occurrences of substring sub in the range [start, end]. Optional arguments start and end are interpreted as in slice notation.
str.decode([encoding[, errors]])
Decodes the string using the codec registered for encoding. encoding defaults to the default string encoding. errors may be given to set a different error handling scheme. The default is 'strict', meaning that encoding errors raise UnicodeError. Other possible values are 'ignore', 'replace' and any other name registered via codecs.register_error(), see section Codec Base Classes.

New in version 2.2.

Changed in version 2.3: Support for other error handling schemes added.

str.encode([encoding[, errors]])
Return an encoded version of the string. Default encoding is the current default string encoding. errors may be given to set a different error handling scheme. The default for errors is 'strict', meaning that encoding errors raise a UnicodeError. Other possible values are 'ignore', 'replace', 'xmlcharrefreplace', 'backslashreplace' and any other name registered via codecs.register_error(), see section Codec Base Classes. For a list of possible encodings, see section Standard Encodings.

New in version 2.0.

Changed in version 2.3: Support for 'xmlcharrefreplace' and 'backslashreplace' and other error handling schemes added.

str.endswith(suffix[, start[, end]])
Return True if the string ends with the specified suffix, otherwise return False. suffix can also be a tuple of suffixes to look for. With optional start, test beginning at that position. With optional end, stop comparing at that position.

Changed in version 2.5: Accept tuples as suffix.

str.expandtabs([tabsize])
Return a copy of the string where all tab characters are replaced by one or more spaces, depending on the current column and the given tab size. The column number is reset to zero after each newline occurring in the string. If tabsize is not given, a tab size of 8 characters is assumed. This doesn’t understand other non-printing characters or escape sequences.
str.find(sub[, start[, end]])
Return the lowest index in the string where substring sub is found, such that sub is contained in the slice s[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 if sub is not found.
str.format(*args, **kwargs)
Perform a string formatting operation. The string on which this method is called can contain literal text or replacement fields delimited by braces {}. Each replacement field contains either the numeric index of a positional argument, or the name of a keyword argument. Returns a copy of the string where each replacement field is replaced with the string value of the corresponding argument.

>>> "The sum of 1 + 2 is {0}".format(1+2)
'The sum of 1 + 2 is 3'

See Format String Syntax for a description of the various formatting options that can be specified in format strings.

This method of string formatting is the new standard in Python 3.0, and should be preferred to the % formatting described in String Formatting Operations in new code.

New in version 2.6.

str.index(sub[, start[, end]])
Like find(), but raise ValueError when the substring is not found.
str.isalnum()
Return true if all characters in the string are alphanumeric and there is at least one character, false otherwise.

For 8-bit strings, this method is locale-dependent.

str.isalpha()
Return true if all characters in the string are alphabetic and there is at least one character, false otherwise.

For 8-bit strings, this method is locale-dependent.

str.isdigit()
Return true if all characters in the string are digits and there is at least one character, false otherwise.

For 8-bit strings, this method is locale-dependent.

str.islower()
Return true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.

For 8-bit strings, this method is locale-dependent.

str.isspace()
Return true if there are only whitespace characters in the string and there is at least one character, false otherwise.

For 8-bit strings, this method is locale-dependent.

str.istitle()
Return true if the string is a titlecased string and there is at least one character, for example uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return false otherwise.

For 8-bit strings, this method is locale-dependent.

str.isupper()
Return true if all cased characters in the string are uppercase and there is at least one cased character, false otherwise.

For 8-bit strings, this method is locale-dependent.

str.join(iterable)
Return a string which is the concatenation of the strings in the iterable iterable. The separator between elements is the string providing this method.
str.ljust(width[, fillchar])
Return the string left justified in a string of length width. Padding is done using the specified fillchar (default is a space). The original string is returned if width is less than len(s).

Changed in version 2.4: Support for the fillchar argument.

str.lower()
Return a copy of the string converted to lowercase.

For 8-bit strings, this method is locale-dependent.

str.lstrip([chars])
Return a copy of the string with leading characters removed. The chars argument is a string specifying the set of characters to be removed. If omitted or None, the chars argument defaults to removing whitespace. The chars argument is not a prefix; rather, all combinations of its values are stripped:

>>> '   spacious   '.lstrip()
'spacious   '
>>> 'www.example.com'.lstrip('cmowz.')
'example.com'

Changed in version 2.2.2: Support for the chars argument.

str.partition(sep)
Split the string at the first occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return a 3-tuple containing the string itself, followed by two empty strings.

New in version 2.5.

str.replace(old, new[, count])
Return a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced.
str.rfind(sub[, start[, end]])
Return the highest index in the string where substring sub is found, such that sub is contained within s[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure.
str.rindex(sub[, start[, end]])
Like rfind() but raises ValueError when the substring sub is not found.
str.rjust(width[, fillchar])
Return the string right justified in a string of length width. Padding is done using the specified fillchar (default is a space). The original string is returned if width is less than len(s).

Changed in version 2.4: Support for the fillchar argument.

str.rpartition(sep)
Split the string at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return a 3-tuple containing two empty strings, followed by the string itself.

New in version 2.5.

str.rsplit([sep[, maxsplit]])
Return a list of the words in the string, using sep as the delimiter string. If maxsplit is given, at most maxsplit splits are done, the rightmost ones. If sep is not specified or None, any whitespace string is a separator. Except for splitting from the right, rsplit() behaves like split() which is described in detail below.

New in version 2.4.

str.rstrip([chars])
Return a copy of the string with trailing characters removed. The chars argument is a string specifying the set of characters to be removed. If omitted or None, the chars argument defaults to removing whitespace. The chars argument is not a suffix; rather, all combinations of its values are stripped:

>>> '   spacious   '.rstrip()
'   spacious'
>>> 'mississippi'.rstrip('ipz')
'mississ'

Changed in version 2.2.2: Support for the chars argument.

str.split([sep[, maxsplit]])
Return a list of the words in the string, using sep as the delimiter string. If maxsplit is given, at most maxsplit splits are done (thus, the list will have at most maxsplit+1 elements). If maxsplit is not specified, then there is no limit on the number of splits (all possible splits are made).

If sep is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, '1,,2'.split(',') returns ['1', '', '2']). The sep argument may consist of multiple characters (for example, '1<>2<>3'.split('<>') returns ['1', '2', '3']). Splitting an empty string with a specified separator returns [''].

If sep is not specified or is None, a different splitting algorithm is applied: runs of consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the start or end if the string has leading or trailing whitespace. Consequently, splitting an empty string or a string consisting of just whitespace with a None separator returns [].

For example, ' 1  2   3  '.split() returns ['1', '2', '3'], and '  1  2   3  '.split(None, 1) returns ['1', '2   3  '].

str.splitlines([keepends])
Return a list of the lines in the string, breaking at line boundaries. Line breaks are not included in the resulting list unless keepends is given and true.
str.startswith(prefix[, start[, end]])
Return True if string starts with the prefix, otherwise return False. prefix can also be a tuple of prefixes to look for. With optional start, test string beginning at that position. With optional end, stop comparing string at that position.

Changed in version 2.5: Accept tuples as prefix.

str.strip([chars])
Return a copy of the string with the leading and trailing characters removed. The chars argument is a string specifying the set of characters to be removed. If omitted or None, the chars argument defaults to removing whitespace. The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped:

>>> '   spacious   '.strip()
'spacious'
>>> 'www.example.com'.strip('cmowz.')
'example'

Changed in version 2.2.2: Support for the chars argument.

str.swapcase()
Return a copy of the string with uppercase characters converted to lowercase and vice versa.

For 8-bit strings, this method is locale-dependent.

str.title()
Return a titlecased version of the string where words start with an uppercase character and the remaining characters are lowercase.

The algorithm uses a simple language-independent definition of a word as groups of consecutive letters. The definition works in many contexts but it means that apostrophes in contractions and possessives form word boundaries, which may not be the desired result:

>>> "they're bill's friends from the UK".title()
"They'Re Bill'S Friends From The Uk"

A workaround for apostrophes can be constructed using regular expressions:

>>> import re
>>> def titlecase(s):
        return re.sub(r"[A-Za-z]+('[A-Za-z]+)?",
                      lambda mo: mo.group(0)[0].upper() +
                                 mo.group(0)[1:].lower(),
                      s)
>>> titlecase("they're bill's friends.")
"They're Bill's Friends."

For 8-bit strings, this method is locale-dependent.

str.translate(table[, deletechars])
Return a copy of the string where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256.

You can use the maketrans() helper function in the string module to create a translation table. For string objects, set the table argument to None for translations that only delete characters:

>>> 'read this short text'.translate(None, 'aeiou')
'rd ths shrt txt'

New in version 2.6: Support for a None table argument.

For Unicode objects, the translate() method does not accept the optional deletechars argument. Instead, it returns a copy of the s where all characters have been mapped through the given translation table which must be a mapping of Unicode ordinals to Unicode ordinals, Unicode strings or None. Unmapped characters are left untouched. Characters mapped to None are deleted. Note, a more flexible approach is to create a custom character mapping codec using the codecs module (see encodings.cp1251 for an example).

str.upper()
Return a copy of the string converted to uppercase.

For 8-bit strings, this method is locale-dependent.

str.zfill(width)
Return the numeric string left filled with zeros in a string of length width. A sign prefix is handled correctly. The original string is returned if width is less than len(s).

New in version 2.2.2.

The following methods are present only on unicode objects:

unicode.isnumeric()
Return True if there are only numeric characters in S, False otherwise. Numeric characters include digit characters, and all characters that have the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION ONE FIFTH.
unicode.isdecimal()
Return True if there are only decimal characters in S, False otherwise. Decimal characters include digit characters, and all characters that that can be used to form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.
Sumber : http://docs.python.org/library/stdtypes.html#index-601
<a href=”http://diploma.ipb.ac.id” title=”IPB Badge by:Farhad”><img src=”http://ipb.ac.id/badge/img/20100612201767940.png” alt=”IPB Badge” width=”207″ height=”104″/></a>

Sumber : http://rootzone.net/index-of-bash-command-line-for-linux-servers/

a

  • alias           Create an alias
  • apropos    Search Help manual pages (man -k)
  • apt-get       Search for and install software   packages (Debian)
  • aspell        Spell Checker
  • awk        Find and Replace text, database   sort/validate/index

b

  • bash       GNU Bourne-Again SHell
  • bc         Arbitrary precision calculator language
  • bg         Send to background
  • break      Exit from a loop
  • builtin    Run a shell builtin
  • bzip2      Compress or decompress named file(s)

c

  • cal        Display a calendar
  • case       Conditionally perform a command
  • cat        Display the contents of a file
  • cd         Change Directory
  • cfdisk     Partition table manipulator for Linux
  • chgrp      Change group ownership
  • chmod      Change access permissions
  • chown      Change file owner and group
  • chroot     Run a command with a different root directory
  • chkconfig     System services (runlevel)
  • cksum      Print CRC checksum and byte counts
  • clear      Clear terminal screen
  • cmp        Compare two files
  • comm       Compare two sorted files line by line
  • command    Run a command – ignoring shell functions
  • continue   Resume the next iteration of a loop
  • cp         Copy one or more files to another location
  • cron       Daemon to execute scheduled commands
  • crontab    Schedule a command to run at a later time
  • csplit     Split a file into context-determined pieces
  • cut        Divide a file into several parts

d

  • date       Display or change the date & time
  • dc         Desk Calculator
  • dd         Convert and copy a file, write disk headers, boot records
  • ddrescue   Data recovery tool
  • declare    Declare variables and give them attributes
  • df         Display free disk space
  • diff       Display the differences between two files
  • diff3      Show differences among three files
  • dig        DNS lookup
  • dir        Briefly list directory contents
  • dircolors Colour setup for `ls’
  • dirname    Convert a full pathname to just a path
  • dirs       Display list of remembered directories
  • dmesg      Print kernel & driver messages
  • du         Estimate file space usage

e

  • echo        Display message on screen
  • egrep       Search file(s) for lines that match an extended expression
  • eject      Eject removable media
  • enable     Enable and disable builtin shell commands
  • env        Environment variables
  • ethtool    Ethernet card settings
  • eval       Evaluate several commands/arguments
  • exec       Execute a command
  • exit       Exit the shell
  • expect     Automate arbitrary applications accessed over a terminal
  • expand     Convert tabs to spaces
  • export     Set an environment variable
  • expr       Evaluate expressions

f

  • false      Do nothing, unsuccessfully
  • fdformat   Low-level format a floppy disk
  • fdisk      Partition table manipulator for Linux
  • fg         Send job to foreground
  • fgrep      Search file(s) for lines that match a fixed string
  • file       Determine file type
  • find       Search for files that meet a desired criteria
  • fmt        Reformat paragraph text
  • fold       Wrap text to fit a specified width.
  • for        Expand words, and execute commands
  • format     Format disks or tapes
  • free       Display memory usage
  • fsck       File system consistency check and repair
  • ftp        File Transfer Protocol
  • function   Define Function Macros
  • fuser      Identify/kill the process that is accessing a file

g

  • gawk     Find and Replace text within file(s)
  • getopts  Parse positional parameters
  • grep     Search file(s) for lines that match a given pattern
  • groups   Print group names a user is in
  • gzip     Compress or decompress named file(s)

h

  • hash     Remember the full pathname of a name argument
  • head     Output the first part of file(s)
  • history  Command History
  • hostname Print or set system name

i

  • id       Print user and group id’s
  • if       Conditionally perform a command
  • ifconfig   Configure a network interface
  • ifdown   Stop a network interface
  • ifup     Start a network interface up
  • import   Capture an X server screen and save the image to file
  • install  Copy files and set attributes

j

  • join     Join lines on a common field

k

  • kill     Stop a process from running
  • killall  Kill processes by name

l

  • less     Display output one screen at a time
  • let      Perform arithmetic on shell variables
  • ln       Make links between files
  • local    Create variables
  • locate   Find files
  • logname     Print current login name
  • logout   Exit a login shell
  • look     Display lines beginning with a given string
  • lpc      Line printer control program
  • lpr      Off line print
  • lprint   Print a file
  • lprintd   Abort a print job
  • lprintq    List the print queue
  • lprm     Remove jobs from the print queue
  • ls       List information about file(s)
  • lsof     List open files

m

  • make     Recompile a group of programs
  • man      Help manual
  • mkdir    Create new folder(s)
  • mkfifo   Make FIFOs (named pipes)
  • mkisofs    Create an hybrid ISO9660/JOLIET/HFS filesystem
  • mknod    Make block or character special files
  • more     Display output one screen at a time
  • mount    Mount a file system
  • mtools   Manipulate MS-DOS files
  • mv       Move or rename files or directories
  • mmv      Mass Move and rename (files)

n

  • netstat    Networking information
  • nice     Set the priority of a command or job
  • nl       Number lines and write files
  • nohup    Run a command immune to hangups
  • nslookup   Query Internet name servers interactively

o

  • open     Open a file in its default application
  • op       Operator access

p

  • passwd   Modify a user password
  • paste    Merge lines of files
  • pathchk    Check file name portability
  • ping     Test a network connection
  • pkill    Stop processes from running
  • popd     Restore the previous value of the current directory
  • pr       Prepare files for printing
  • printcap    Printer capability database
  • printenv    Print environment variables
  • printf     Format and print data
  • ps       Process status
  • pushd    Save and then change the current directory
  • pwd      Print Working Directory

q

  • quota    Display disk usage and limits
  • quotacheck     Scan a file system for disk usage
  • quotactl   Set disk quotas

r

  • ram      ram disk device
  • rcp      Copy files between two machines
  • read     read a line from standard input
  • readonly    Mark variables/functions as readonly
  • reboot     Reboot the system
  • renice     Alter priority of running processes
  • remsync     Synchronize remote files via email
  • return     Exit a shell function
  • rev      Reverse lines of a file
  • rm       Remove files
  • rmdir    Remove folder(s)
  • rsync    Remote file copy (Synchronize file trees)

s

  • screen     Multiplex terminal, run remote shells via ssh
  • scp      Secure copy (remote file copy)
  • sdiff    Merge two files interactively
  • sed      Stream Editor
  • select   Accept keyboard input
  • seq      Print numeric sequences
  • set      Manipulate shell variables and functions
  • sftp     Secure File Transfer Program
  • shift    Shift positional parameters
  • shopt    Shell Options
  • shutdown   Shutdown or restart linux
  • sleep    Delay for a specified time
  • slocate    Find files
  • sort     Sort text files
  • source   Run commands from a file `.’
  • split    Split a file into fixed-size pieces
  • ssh      Secure Shell client (remote login program)
  • strace   Trace system calls and signals
  • su       Substitute user identity
  • sudo     Execute a command as another user
  • sum      Print a checksum for a file
  • symlink     Make a new name for a file
  • sync     Synchronize data on disk with memory

t

  • tail     Output the last part of files
  • tar      Tape ARchiver
  • tee      Redirect output to multiple files
  • test     Evaluate a conditional expression
  • time     Measure Program running time
  • times    User and system times
  • touch    Change file timestamps
  • top      List processes running on the system
  • traceroute    Trace Route to Host
  • trap     Run a command when a signal is set(bourne)
  • tr       Translate, squeeze, and/or delete characters
  • true     Do nothing, successfully
  • tsort    Topological sort
  • tty      Print filename of terminal on stdin
  • type     Describe a command

u

  • ulimit   Limit user resources
  • umask    Users file creation mask
  • umount   Unmount a device
  • unalias  Remove an alias
  • uname    Print system information
  • unexpand    Convert spaces to tabs
  • uniq     Uniquify files
  • units    Convert units from one scale to another
  • unset    Remove variable or function names
  • unshar   Unpack shell archive scripts
  • until    Execute commands (until error)
  • useradd    Create new user account
  • usermod    Modify user account
  • users    List users currently logged in
  • uuencode Encode a binary file
  • uudecode    Decode a file created by uuencode

v

  • v        Verbosely list directory contents (`ls -l -b’)
  • vdir     Verbosely list directory contents (`ls -l -b’)
  • vi       Text Editor
  • vmstat    Report virtual memory statistics

w

  • watch    Execute/display a program periodically
  • wc       Print byte, word, and line counts
  • whereis    Report all known instances of a command
  • which    Locate a program file in the user’s path.
  • while    Execute commands
  • who      Print all usernames currently logged in
  • whoami    Print the current user id and name (`id -un’)
  • Wget     Retrieve web pages or files via HTTP, HTTPS or FTP
  • write    Send a message to another user

x

  • xargs    Execute utility, passing constructed argument list(s)
  • yes      Print a string until interrupted
  • .        Run a command script in the current shell
  • ###      Comment / Remark

NOTE : for more details on each bash commandline, just type it in console root with –help command, e.g wget –help

Sumber : http://rootzone.net/index-of-bash-command-line-for-linux-servers/

<a href=”http://diploma.ipb.ac.id” title=”IPB Badge by:Farhad”><img src=”http://ipb.ac.id/badge/img/20100612201767940.png” alt=”IPB Badge” width=”207″ height=”104″/></a>