In [1]:
help()
Welcome to Python 2.7! This is the online help utility.
If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/2.7/tutorial/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".
To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics". Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".
help> keywords
Here is a list of the Python keywords. Enter any keyword to get more help.
and elif if print
as else import raise
assert except in return
break exec is try
class finally lambda while
continue for not with
def from or yield
del global pass
help> topics
Here is a list of available topics. Enter any topic name to get more help.
ASSERTION DEBUGGING LITERALS SEQUENCEMETHODS2
ASSIGNMENT DELETION LOOPING SEQUENCES
ATTRIBUTEMETHODS DICTIONARIES MAPPINGMETHODS SHIFTING
ATTRIBUTES DICTIONARYLITERALS MAPPINGS SLICINGS
AUGMENTEDASSIGNMENT DYNAMICFEATURES METHODS SPECIALATTRIBUTES
BACKQUOTES ELLIPSIS MODULES SPECIALIDENTIFIERS
BASICMETHODS EXCEPTIONS NAMESPACES SPECIALMETHODS
BINARY EXECUTION NONE STRINGMETHODS
BITWISE EXPRESSIONS NUMBERMETHODS STRINGS
BOOLEAN FILES NUMBERS SUBSCRIPTS
CALLABLEMETHODS FLOAT OBJECTS TRACEBACKS
CALLS FORMATTING OPERATORS TRUTHVALUE
CLASSES FRAMEOBJECTS PACKAGES TUPLELITERALS
CODEOBJECTS FRAMES POWER TUPLES
COERCIONS FUNCTIONS PRECEDENCE TYPEOBJECTS
COMPARISON IDENTIFIERS PRINTING TYPES
COMPLEX IMPORTING PRIVATENAMES UNARY
CONDITIONAL INTEGER RETURNING UNICODE
CONTEXTMANAGERS LISTLITERALS SCOPING
CONVERSIONS LISTS SEQUENCEMETHODS1
help> LISTS
Mutable Sequence Types
**********************
List and ``bytearray`` objects support additional operations that
allow in-place modification of the object. Other mutable sequence
types (when added to the language) should also support these
operations. Strings and tuples are immutable sequence types: such
objects cannot be modified once created. The following operations are
defined on mutable sequence types (where *x* is an arbitrary object):
+--------------------------------+----------------------------------+-----------------------+
| Operation | Result | Notes |
+================================+==================================+=======================+
| ``s[i] = x`` | item *i* of *s* is replaced by | |
| | *x* | |
+--------------------------------+----------------------------------+-----------------------+
| ``s[i:j] = t`` | slice of *s* from *i* to *j* is | |
| | replaced by the contents of the | |
| | iterable *t* | |
+--------------------------------+----------------------------------+-----------------------+
| ``del s[i:j]`` | same as ``s[i:j] = []`` | |
+--------------------------------+----------------------------------+-----------------------+
| ``s[i:j:k] = t`` | the elements of ``s[i:j:k]`` are | (1) |
| | replaced by those of *t* | |
+--------------------------------+----------------------------------+-----------------------+
| ``del s[i:j:k]`` | removes the elements of | |
| | ``s[i:j:k]`` from the list | |
+--------------------------------+----------------------------------+-----------------------+
| ``s.append(x)`` | same as ``s[len(s):len(s)] = | (2) |
| | [x]`` | |
+--------------------------------+----------------------------------+-----------------------+
| ``s.extend(x)`` | same as ``s[len(s):len(s)] = x`` | (3) |
+--------------------------------+----------------------------------+-----------------------+
| ``s.count(x)`` | return number of *i*'s for which | |
| | ``s[i] == x`` | |
+--------------------------------+----------------------------------+-----------------------+
| ``s.index(x[, i[, j]])`` | return smallest *k* such that | (4) |
| | ``s[k] == x`` and ``i <= k < j`` | |
+--------------------------------+----------------------------------+-----------------------+
| ``s.insert(i, x)`` | same as ``s[i:i] = [x]`` | (5) |
+--------------------------------+----------------------------------+-----------------------+
| ``s.pop([i])`` | same as ``x = s[i]; del s[i]; | (6) |
| | return x`` | |
+--------------------------------+----------------------------------+-----------------------+
| ``s.remove(x)`` | same as ``del s[s.index(x)]`` | (4) |
+--------------------------------+----------------------------------+-----------------------+
| ``s.reverse()`` | reverses the items of *s* in | (7) |
| | place | |
+--------------------------------+----------------------------------+-----------------------+
| ``s.sort([cmp[, key[, | sort the items of *s* in place | (7)(8)(9)(10) |
| reverse]]])`` | | |
+--------------------------------+----------------------------------+-----------------------+
Notes:
1. *t* must have the same length as the slice it is replacing.
2. The C implementation of Python has historically accepted multiple
parameters and implicitly joined them into a tuple; this no longer
works in Python 2.0. Use of this misfeature has been deprecated
since Python 1.4.
3. *x* can be any iterable object.
4. Raises ``ValueError`` when *x* is not found in *s*. When a negative
index is passed as the second or third parameter to the ``index()``
method, the list length is added, as for slice indices. If it is
still negative, it is truncated to zero, as for slice indices.
Changed in version 2.3: Previously, ``index()`` didn't have
arguments for specifying start and stop positions.
5. When a negative index is passed as the first parameter to the
``insert()`` method, the list length is added, as for slice
indices. If it is still negative, it is truncated to zero, as for
slice indices.
Changed in version 2.3: Previously, all negative indices were
truncated to zero.
6. The ``pop()`` method's optional argument *i* defaults to ``-1``, so
that by default the last item is removed and returned.
7. The ``sort()`` and ``reverse()`` methods modify the list in place
for economy of space when sorting or reversing a large list. To
remind you that they operate by side effect, they don't return the
sorted or reversed list.
8. The ``sort()`` method takes optional arguments for controlling the
comparisons.
*cmp* specifies a custom comparison function of two arguments (list
items) which should return a negative, zero or positive number
depending on whether the first argument is considered smaller than,
equal to, or larger than the second argument: ``cmp=lambda x,y:
cmp(x.lower(), y.lower())``. The default value is ``None``.
*key* specifies a function of one argument that is used to extract
a comparison key from each list element: ``key=str.lower``. The
default value is ``None``.
*reverse* is a boolean value. If set to ``True``, then the list
elements are sorted as if each comparison were reversed.
In general, the *key* and *reverse* conversion processes are much
faster than specifying an equivalent *cmp* function. This is
because *cmp* is called multiple times for each list element while
*key* and *reverse* touch each element only once. Use
``functools.cmp_to_key()`` to convert an old-style *cmp* function
to a *key* function.
Changed in version 2.3: Support for ``None`` as an equivalent to
omitting *cmp* was added.
Changed in version 2.4: Support for *key* and *reverse* was added.
9. Starting with Python 2.3, the ``sort()`` method is guaranteed to be
stable. A sort is stable if it guarantees not to change the
relative order of elements that compare equal --- this is helpful
for sorting in multiple passes (for example, sort by department,
then by salary grade).
10. **CPython implementation detail:** While a list is being sorted,
the effect of attempting to mutate, or even inspect, the list is
undefined. The C implementation of Python 2.3 and newer makes the
list appear empty for the duration, and raises ``ValueError`` if
it can detect that the list has been mutated during a sort.
Related help topics: LISTLITERALS
help> modules
Please wait a moment while I gather a list of all available modules...
/usr/local/lib/python2.7/dist-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.
"You should import from ipykernel or jupyter_client instead.", ShimWarning)
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion 'g_type_from_name (name) == 0' failed
import gobject._gobject
No handlers could be found for logger "oneconf.distributor"
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:127: RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK
set_interactive(1)
ANSI apt gtkunixprint requests
AptUrl apt_inst gzip resource
BaseHTTPServer apt_pkg hashlib rexec
Bastion aptdaemon heapq rfc822
BeautifulSoup aptsources hmac rlcompleter
BeautifulSoupTests argparse hotshot rmagic
CDROM array html5lib robotparser
CGIHTTPServer ast htmlentitydefs runpy
Canvas asynchat htmllib samba
CommandNotFound asyncore httplib sched
ConfigParser atexit httplib2 screen
Cookie atk idlelib select
Crypto audiodev ihooks serial
DLFCN audioop imaplib sessioninstaller
Dialog autoreload imghdr sets
DocXMLRPCServer axi imp setuptools
Exscript backports importlib sexy
Exscriptd backports_abc imputil sgmllib
FSM base64 inspect sha
FileDialog bdb io shelve
FixTk binascii ipykernel shlex
HTMLParser binhex ipython_genutils shutil
IN bisect ipywidgets shutil_backports
IPython bonobo itertools signal
Image bpdb jinja2 simplegeneric
ImageChops bpython json singledispatch
ImageColor bsddb jsonschema singledispatch_helpers
ImageCrackCode bz2 jupyter sip
ImageDraw cPickle jupyter_client sipconfig
ImageEnhance cProfile jupyter_console sipconfig_nd
ImageFile cStringIO jupyter_core site
ImageFileIO cairo keyword sitecustomize
ImageFilter calendar ldb six
ImageFont caribou lib2to3 smbc
ImageGL certifi libxml2 smtpd
ImageGrab cgi libxml2mod smtplib
ImageMath cgitb linecache sndhdr
ImageOps chardet linuxaudiodev socket
ImagePalette chunk locale spwd
ImagePath cmath lockfile spyderlib
ImageQt cmd logging spyderplugins
ImageSequence code lsb_release sqlite3
ImageStat codecs lxml sre
ImageTk codeop macpath sre_compile
ImageWin collections macurl2path sre_constants
MimeWriter colorama mailbox sre_parse
MySQLdb colorsys mailcap ssl
ORBit commands mako stat
OpenSSL compileall markupbase statvfs
PAM compiler markupsafe storemagic
PIL configglue marshal string
PSDraw configobj math stringold
PngImagePlugin configparser md5 stringprep
PyQt4 contextlib mhlib strop
Queue cookielib mimetools struct
ScrolledText copy mimetypes subprocess
SimpleDialog copy_reg mimify sunau
SimpleHTTPServer crypt mistune sunaudio
SimpleXMLRPCServer csv mmap symbol
SocketServer ctypes modulefinder sympyprinting
StringIO cups multifile symtable
TYPES cupshelpers multiprocessing sys
Tix curl mutex sysconfig
TkExscript curses mysql syslog
Tkconstants cv nbconvert tabnanny
Tkdnd cv2 nbformat talloc
Tkinter cythonmagic netrc tarfile
UbuntuSystemService datetime new tdb
UserDict dbhash nis telnetlib
UserList dbm nntplib tempfile
UserString dbus notebook terminado
_LWPCookieJar deb822 ntdb termios
_MozillaCookieJar debconf ntpath test
__builtin__ debian nturl2path tests
__future__ debian_bundle numbers textwrap
_abcoll debtagshw numpy this
_ast decimal oauthlib thread
_bisect decorator oneconf threading
_bsddb defer opcode tidy
_codecs difflib operator time
_codecs_cn dircache optparse timeit
_codecs_hk dirspec os tkColorChooser
_codecs_iso2022 dis os2emxpath tkCommonDialog
_codecs_jp distlib ossaudiodev tkFileDialog
_codecs_kr distutils pango tkFont
_codecs_tw django pangocairo tkMessageBox
_collections dns paramiko tkSimpleDialog
_csv doctest parser toaiff
_ctypes drv_libxml2 parted token
_ctypes_test dsextras pathlib2 tokenize
_curses dumbdbm pdb tornado
_curses_panel dummy_thread pexpect trace
_dbus_bindings dummy_threading pickle traceback
_dbus_glib_bindings duplicity pickleshare traitlets
_elementtree easy_install pickletools ttk
_functools email pip tty
_hashlib encodings pipes turtle
_heapq entrypoints piston_mini_client twisted
_hotshot errno pkg_resources types
_io exceptions pkgutil ubuntu_sso
_json fabfile platform unicodedata
_locale fabric plistlib unittest
_lsprof fcntl popen2 urllib
_markerlib fdpexpect poplib urllib2
_md5 feedparser posix urllib3
_multibytecodec filecmp posixfile urlparse
_multiprocessing fileinput posixpath user
_mysql fnmatch pprint uu
_mysql_exceptions formatter profile uuid
_osx_support fpectl prompt_toolkit validate
_ped fpformat pstats virtualenv
_pyio fractions pty vte
_random ftplib ptyprocess warnings
_sha functools pwd wave
_sha256 functools32 pxssh wcwidth
_sha512 future_builtins py_compile weakref
_smbc gc pyatspi webbrowser
_socket gconf pyclbr webkit
_sqlite3 gdbm pycurl whichdb
_sre genericpath pydoc widgetsnbextension
_ssl getopt pydoc_data wsgiref
_strptime getpass pyexpat xapian
_struct gettext pygments xdg
_symtable gi pygtk xdrlib
_sysconfigdata gio pygtkcompat xml
_sysconfigdata_nd glib pyinotify xmllib
_testcapi glob pynotify xmlrpclib
_threading_local gnome pyodbc xxsubtype
_tkinter gnomecanvas pysqlite2 zipfile
_warnings gnomekeyring qtconsole zipimport
_weakref gnomevfs quopri zlib
_weakrefset gobject random zmq
abc google re zope
aifc grp readline
antigravity gtk reportlab
anydbm gtksourceview2 repr
Enter any module name to get more help. Or, type "modules spam" to search
for modules whose descriptions contain the word "spam".
help> quit
You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)". Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.
In [2]:
my_string="python"
In [3]:
my_string.capitalize?
Content source: tuxfux-hlp-notes/python-batches
Similar notebooks: