HOME - Recent Changes - Search:

Academic Work


Personal

* pot de départ


dblp


(:twitter:)

-----

[ edit | logout ]
[ help | sandbox | passwd ]

Introspection

#############################

Built-in functions are grouped in the so-called __builtin__ module. Everything is imported from this module automatically. See also http://docs.python.org/library/functions.html#built-in-functions for a complete list of the built-in functions.


type: (see also http://docs.python.org/library/functions.html#type)

print type(1)     # <type 'int'>

dct = {}
print type(dct)   # <type 'dict'>

Testing the type of an object: (see also http://docs.python.org/library/types.html#module-types)

import types

dct = {}
print type(dct)   # <type 'dict'>
print type(dct) == types.DictType   # True

dir: (see also http://docs.python.org/library/functions.html#dir)

li = []
print dir(li)
# ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']

Returns a list of attribute names and method names defined by the given object. The returned value is a list of strings.


callable: (see also http://docs.python.org/library/functions.html#callable)

import string
print callable(string.join)   # True
i = 2
print callable(i)   # False

getattr: (see also http://docs.python.org/library/functions.html#getattr)

li = [1, 2]
print li
# [1, 2]
p = getattr(li, "append")   # p is a reference to the append function of the li object
print p
# <built-in method append of list object at 0xb7cced0c>
p(4)   # it's like calling li.append(4)
print li
# [1, 2, 4]
Cloud City


anime | bash | blogs | bsd | c/c++ | c64 | calc | comics | convert | cube | del.icio.us | digg | east | eBooks | egeszseg | elite | firefox | flash | fun | games | gimp | google | groovy | hardware | hit&run | howto | java | javascript | knife | lang | latex | liferay | linux | lovecraft | magyar | maths | movies | music | p2p | perl | pdf | photoshop | php | pmwiki | prog | python | radio | recept | rts | scala | scene | sci-fi | scripting | security | shell | space | súlyos | telephone | torrente | translate | ubuntu | vim | wallpapers | webutils | wikis | windows


Blogs and Dev.

* Ubuntu Incident
* Python Adventures
* me @ GitHub


Places

Debrecen | France | Hungary | Montreal | Nancy


Notes

full circle | km


Hobby Projects

* Jabba's Codes
* PmWiki
* Firefox
* PHP
* JavaScript
* Scriptorium
* Tutorials
* me @ GitHub


Quick Links


[ edit ]

View - Edit - History - Attach - Print *** Report - Recent Changes - Search
Page last modified on 2009 October 21, 03:44