Background: #fff
Foreground: #000
PrimaryPale: #8cf
PrimaryLight: #18f
PrimaryMid: #04b
PrimaryDark: #014
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #f88
<!--{{{-->
<div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'></div>
<div class='title' macro='view title'></div>
<div class='editor' macro='edit title'></div>
<div macro='annotations'></div>
<div class='editor' macro='edit text'></div>
<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser excludeLists'></span></div>
<!--}}}-->
To get started with this blank [[TiddlyWiki]], you'll need to modify the following tiddlers:
* [[SiteTitle]] & [[SiteSubtitle]]: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
* [[MainMenu]]: The menu (usually on the left)
* [[DefaultTiddlers]]: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
You'll also need to enter your username for signing your edits: <<option txtUserName>>
<<importTiddlers>>
<!--{{{-->
<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' />
<!--}}}-->
These [[InterfaceOptions]] for customising [[TiddlyWiki]] are saved in your browser

Your username for signing your edits. Write it as a [[WikiWord]] (eg [[JoeBloggs]])

<<option txtUserName>>
<<option chkSaveBackups>> [[SaveBackups]]
<<option chkAutoSave>> [[AutoSave]]
<<option chkRegExpSearch>> [[RegExpSearch]]
<<option chkCaseSensitiveSearch>> [[CaseSensitiveSearch]]
<<option chkAnimate>> [[EnableAnimations]]

----
Also see [[AdvancedOptions]]
<!--{{{-->
<div class='header' role='banner' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
<div class='headerShadow'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
<div class='headerForeground'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
</div>
<div id='mainMenu' role='navigation' refresh='content' tiddler='MainMenu'></div>
<div id='sidebar'>
<div id='sidebarOptions' role='navigation' refresh='content' tiddler='SideBarOptions'></div>
<div id='sidebarTabs' role='complementary' refresh='content' force='true' tiddler='SideBarTabs'></div>
</div>
<div id='displayArea' role='main'>
<div id='messageArea'></div>
<div id='tiddlerDisplay'></div>
</div>
<!--}}}-->
/*{{{*/
body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}

a {color:[[ColorPalette::PrimaryMid]];}
a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
a img {border:0;}

h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}

.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}

.header {background:[[ColorPalette::PrimaryMid]];}
.headerShadow {color:[[ColorPalette::Foreground]];}
.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
.headerForeground {color:[[ColorPalette::Background]];}
.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}

.tabSelected {color:[[ColorPalette::PrimaryDark]];
	background:[[ColorPalette::TertiaryPale]];
	border-left:1px solid [[ColorPalette::TertiaryLight]];
	border-top:1px solid [[ColorPalette::TertiaryLight]];
	border-right:1px solid [[ColorPalette::TertiaryLight]];
}
.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
.tabContents .button {border:0;}

#sidebar {}
#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}

.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
	border:1px solid [[ColorPalette::PrimaryMid]];}
.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
	border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
	border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}

.wizard .notChanged {background:transparent;}
.wizard .changedLocally {background:#80ff80;}
.wizard .changedServer {background:#8080ff;}
.wizard .changedBoth {background:#ff8080;}
.wizard .notFound {background:#ffff80;}
.wizard .putToServer {background:#ff80ff;}
.wizard .gotFromServer {background:#80ffff;}

#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}

.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}

.popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];}
.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}

.tiddler .defaultCommand {font-weight:bold;}

.shadow .title {color:[[ColorPalette::TertiaryDark]];}

.title {color:[[ColorPalette::SecondaryDark]];}
.subtitle {color:[[ColorPalette::TertiaryDark]];}

.toolbar {color:[[ColorPalette::PrimaryMid]];}
.toolbar a {color:[[ColorPalette::TertiaryLight]];}
.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}

.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
.tagging .button, .tagged .button {border:none;}

.footer {color:[[ColorPalette::TertiaryLight]];}
.selected .footer {color:[[ColorPalette::TertiaryMid]];}

.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
.lowlight {background:[[ColorPalette::TertiaryLight]];}

.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}

.imageLink, #displayArea .imageLink {background:transparent;}

.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}

.viewer .listTitle {list-style-type:none; margin-left:-2em;}
.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}

.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}

.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
.viewer code {color:[[ColorPalette::SecondaryDark]];}
.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}

.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}

.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
.editorFooter {color:[[ColorPalette::TertiaryMid]];}
.readOnly {background:[[ColorPalette::TertiaryPale]];}

#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:alpha(opacity=60);}
/*}}}*/
/*{{{*/
* html .tiddler {height:1%;}

body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}

h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
h4,h5,h6 {margin-top:1em;}
h1 {font-size:1.35em;}
h2 {font-size:1.25em;}
h3 {font-size:1.1em;}
h4 {font-size:1em;}
h5 {font-size:.9em;}

hr {height:1px;}

a {text-decoration:none;}

dt {font-weight:bold;}

ol {list-style-type:decimal;}
ol ol {list-style-type:lower-alpha;}
ol ol ol {list-style-type:lower-roman;}
ol ol ol ol {list-style-type:decimal;}
ol ol ol ol ol {list-style-type:lower-alpha;}
ol ol ol ol ol ol {list-style-type:lower-roman;}
ol ol ol ol ol ol ol {list-style-type:decimal;}

.txtOptionInput {width:11em;}

#contentWrapper .chkOptionInput {border:0;}

.externalLink {text-decoration:underline;}

.indent {margin-left:3em;}
.outdent {margin-left:3em; text-indent:-3em;}
code.escaped {white-space:nowrap;}

.tiddlyLinkExisting {font-weight:bold;}
.tiddlyLinkNonExisting {font-style:italic;}

/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
a.tiddlyLinkNonExisting.shadow {font-weight:bold;}

#mainMenu .tiddlyLinkExisting,
	#mainMenu .tiddlyLinkNonExisting,
	#sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}

.header {position:relative;}
.header a:hover {background:transparent;}
.headerShadow {position:relative; padding:4.5em 0 1em 1em; left:-1px; top:-1px;}
.headerForeground {position:absolute; padding:4.5em 0 1em 1em; left:0; top:0;}

.siteTitle {font-size:3em;}
.siteSubtitle {font-size:1.2em;}

#mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;}

#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
#sidebarOptions {padding-top:0.3em;}
#sidebarOptions a {margin:0 0.2em; padding:0.2em 0.3em; display:block;}
#sidebarOptions input {margin:0.4em 0.5em;}
#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
#sidebarOptions .sliderPanel input {margin:0 0 0.3em 0;}
#sidebarTabs .tabContents {width:15em; overflow:hidden;}

.wizard {padding:0.1em 1em 0 2em;}
.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0; margin:0.4em 0 0.2em;}
.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0; margin:0.4em 0 0.2em;}
.wizardStep {padding:1em 1em 1em 1em;}
.wizard .button {margin:0.5em 0 0; font-size:1.2em;}
.wizardFooter {padding:0.8em 0.4em 0.8em 0;}
.wizardFooter .status {padding:0 0.4em; margin-left:1em;}
.wizard .button {padding:0.1em 0.2em;}

#messageArea {position:fixed; top:2em; right:0; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
.messageToolbar {display:block; text-align:right; padding:0.2em;}
#messageArea a {text-decoration:underline;}

.tiddlerPopupButton {padding:0.2em;}
.popupTiddler {position: absolute; z-index:300; padding:1em; margin:0;}

.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
.popup .popupMessage {padding:0.4em;}
.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0;}
.popup li.disabled {padding:0.4em;}
.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
.listBreak {font-size:1px; line-height:1px;}
.listBreak div {margin:2px 0;}

.tabset {padding:1em 0 0 0.5em;}
.tab {margin:0 0 0 0.25em; padding:2px;}
.tabContents {padding:0.5em;}
.tabContents ul, .tabContents ol {margin:0; padding:0;}
.txtMainTab .tabContents li {list-style:none;}
.tabContents li.listLink { margin-left:.75em;}

#contentWrapper {display:block;}
#splashScreen {display:none;}

#displayArea {margin:1em 17em 0 14em;}

.toolbar {text-align:right; font-size:.9em;}

.tiddler {padding:1em 1em 0;}

.missing .viewer,.missing .title {font-style:italic;}

.title {font-size:1.6em; font-weight:bold;}

.missing .subtitle {display:none;}
.subtitle {font-size:1.1em;}

.tiddler .button {padding:0.2em 0.4em;}

.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
.isTag .tagging {display:block;}
.tagged {margin:0.5em; float:right;}
.tagging, .tagged {font-size:0.9em; padding:0.25em;}
.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
.tagClear {clear:both;}

.footer {font-size:.9em;}
.footer li {display:inline;}

.annotation {padding:0.5em; margin:0.5em;}

* html .viewer pre {width:99%; padding:0 0 1em 0;}
.viewer {line-height:1.4em; padding-top:0.5em;}
.viewer .button {margin:0 0.25em; padding:0 0.25em;}
.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}

.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
table.listView {font-size:0.85em; margin:0.8em 1.0em;}
table.listView th, table.listView td, table.listView tr {padding:0 3px 0 3px;}

.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
.viewer code {font-size:1.2em; line-height:1.4em;}

.editor {font-size:1.1em;}
.editor input, .editor textarea {display:block; width:100%; font:inherit;}
.editorFooter {padding:0.25em 0; font-size:.9em;}
.editorFooter .button {padding-top:0; padding-bottom:0;}

.fieldsetFix {border:0; padding:0; margin:1px 0px;}

.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
.zoomer div {padding:1em;}

* html #backstage {width:99%;}
* html #backstageArea {width:99%;}
#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em;}
#backstageToolbar {position:relative;}
#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em;}
#backstageButton {display:none; position:absolute; z-index:175; top:0; right:0;}
#backstageButton a {padding:0.1em 0.4em; margin:0.1em;}
#backstage {position:relative; width:100%; z-index:50;}
#backstagePanel {display:none; z-index:100; position:absolute; width:90%; margin-left:3em; padding:1em;}
.backstagePanelFooter {padding-top:0.2em; float:right;}
.backstagePanelFooter a {padding:0.2em 0.4em;}
#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}

.whenBackstage {display:none;}
.backstageVisible .whenBackstage {display:block;}
/*}}}*/
/***
StyleSheet for use when a translation requires any css style changes.
This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes.
***/
/*{{{*/
body {font-size:0.8em;}
#sidebarOptions {font-size:1.05em;}
#sidebarOptions a {font-style:normal;}
#sidebarOptions .sliderPanel {font-size:0.95em;}
.subtitle {font-size:0.8em;}
.viewer table.listView {font-size:0.95em;}
/*}}}*/
/*{{{*/
@media print {
#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none !important;}
#displayArea {margin: 1em 1em 0em;}
noscript {display:none;} /* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
}
/*}}}*/
<!--{{{-->
<div class='toolbar' role='navigation' macro='toolbar [[ToolbarCommands::ViewToolbar]]'></div>
<div class='title' macro='view title'></div>
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
<div class='tagging' macro='tagging'></div>
<div class='tagged' macro='tags'></div>
<div class='viewer' macro='view text wikified'></div>
<div class='tagClear'></div>
<!--}}}-->
Background: #fff
Foreground: #000
PrimaryPale: #8cf
PrimaryLight: #18f
PrimaryMid: #04b
PrimaryDark: #014
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #f88
[[SciComp WS12/13]]
[[GettingStarted]]
{{{
def f(x,n=10,eps=0.01)
    """
    Dokumentation
    der Funktion f
    wird durch f? ausgegeben
    """
    <Anweisungsblock>
    return <Ausdruck>
}}}
- Die Funkion kann aufgerufen werden als
{{{
f(x)
f(x,n)
f(x,n,eps)
f(x,eps=<value>)
f(x,n=<value>)
f(x,n=<value>,eps=<value>)
f(x,eps=<value>,n=<value>)
}}}
- x ist Positionsargument
- n und eps sind Keyword Argumente
- Alle Positionsargumente muessen den Keyword Argumenten vorausgehen und beim Funktionsaufruf uebergeben werden
- Die Keyword Argumente sind optional und haben Standardwerte, wenn sie nicht angegeben werden
!unpacking
- sequenzierbare Container L koennen durch *L als Positionsargumente uebergeben werden
- dict Container M koennen durch **M als Keyword Argumente uebergeben werden
!Funktionen als Objekte
- Funktionen sind Python Objekte, welche wie Variablen behandelt werden koennen
- Die {{{lambda}}} Funktion kann ein Funktionsobjekt waehrend des Programmablaufs erzeugen, z.B.
{{{
filter(lambda x : x%2==0,L) # Liste aller geraden Zahlen in L
}}}
{{{
def shift(f,n)
    return lambda x : f(x)+n

g=shift(sin, 0.5)
print(g(0.0))
}}}
This wiki is a single, self evolving html / css / javascript file! 
Find out more at [[TiddlyWiki.com|http://tiddlywiki.com/]] <<smiley :-D>>

How would you like to be called? <<option txtUserName>>
- Python Programme sind Textdateien, die zeilenweise interpretiert werden.
- Der Programmablauf wird durch Kontrollstrukturen geregelt und ist im Allgemeinen nicht linear
- nicht linear bedeutet, dass die die Aussfuehrung bestimmter Anweisungsbloecke an Bedingungen geknuepft werden kann.

!{{{if}}}-Verzweigung
{{{
if <Bedingung 1> :
    <Anweisungsblock 1>
elif <Bedingung 2> :
    <Anweisungsblock 2>
elif <Bedingung 3> :
...
else :
    <alternativer Anweisungsblock>
}}}
- Der erste Anweisungsblock, fuer welchen die Bedingung den Wahrheitswert {{{True}}} hat wird ausgefuehrt
- Der alternative Anweisungsblock hinter {{{else}}} wird ausgefuehrt wenn keine der Bedingungen {{{True}}} ist
- Die {{{elif}}} oder die {{{else}}} Anweisungen koennen auch weggelassen werden.

!{{{for}}}-Schleife
{{{
for x in M :
    <Anweisungsblock>
    # x nimmt im Anweisungsblock 
    # nacheinander die Identitaet 
    # der Elemente aus M an.
}}}
- Wenn ueber ganze Zahlen 0<=x<j iteriert werden soll, verwendet man am besten xrange(j) fuer M.

!{{{while}}}-Schleife
{{{
while <Bedingung> :
    <Anweisungsblock>
}}}
- Solange die Bedingung den Wahrheitswert {{{True}}} hat wird der Anweisungsblock ausgefuehrt
- Die Bedingung wird ''vor'' jeder Ausfuerhung des Anweisungsblocks ueberprueft

!Schleifenkontrolle mit {{{for/while ... break/continue ... else}}}
{{{
loop (while or for) :
    <Anweisungsblock>
    break # bricht Schleife ab, ohne in den else Anweisungsblock zu gehen
    continue # bricht Anweisungsblock ab, und fuehrt den naechsten Schleifendurchgang aus
else :
    <Anweisungsblock>
    # wird nach Beendigung der Schleife ausgefuehrt,
    # wenn diese nicht durch break beendet wurde
}}}

!{{{pass}}}
- macht gar nichts
- dient als Platzhalter an Stellen wo ein Anweisungsblock benoetigt wird
{{{
if x>0 :
   print(sqrt(x))
else : 
   pass
}}}
{{{import numpy.linalg as linalg}}} (Dokumentation : [[numpy.linalg|http://docs.scipy.org/doc/numpy/reference/routines.linalg.html]])
{{{import scipy.linalg as linalg}}} (Dokumentation : [[scipy.linalg|http://docs.scipy.org/doc/scipy/reference/linalg.html]])

- Sowohl {{{numpy}}} als auch {{{scipy}}} haben Lineare Algebra Unterpakete {{{numpy.linalg}}} und {{{scipy.linalg}}}

- {{{scipy.linalg}}} beinhaltet oder ersetzt alle Funktionen von {{{numpy.linalg}}} und stellt weiter Funktionen zur Verfuegung

Ein- und mehrdimensionale Arrays werden wie Vektoren, Matrizen und Tensoren behandelt, in Abhaengigkeit vom shape :

|CssClass|k
|{{{shape==N}}}| Vektor mit N-Elementen (N-dimensionaler Vektorraum)|
|{{{shape==(1,M)}}}|Zeilenvektor (1 Zeile und M Spalten)|
|{{{shape==(N,1)}}}|Spaltenvektor (N Zeilen und 1 Spalte)|
|{{{shape==(N,M)}}}|NxM matrix|

Fuer Vektoren {{{x}}}, {{{y}}} und Matrizen {{{A}}} und {{{B}}} :
|CssClass|k
|{{{A.dot(x)}}}|berechnet den Vektor Ax|
|{{{A.dot(B)}}}|berechnet die Matrix AB|
|{{{x.dot(y)}}}|berechnet das innere oder aeussere Produkt der Vektoren x und y (abhaengig vom shape)|
|{{{linalg.solve(A,y)}}}|berechnet Loesung x des linearen Gleichungssystems Ax = y (LinAlgError falls nicht loesbar)|
[[SciComp WS12/13]]
[[Help|markup system]]
/***
|''Name:''|MathJaxPlugin|
|''Description:''|Enable LaTeX formulas for TiddlyWiki|
|''Version:''|1.0.1|
|''Date:''|Feb 11, 2012|
|''Source:''|http://www.guyrutenberg.com/2011/06/25/latex-for-tiddlywiki-a-mathjax-plugin|
|''Author:''|Guy Rutenberg|
|''License:''|[[BSD open source license]]|
|''~CoreVersion:''|2.5.0|
 
!! Changelog
!!! 1.0.1 Feb 11, 2012
* Fixed interoperability with TiddlerBarPlugin
!! How to Use
Currently the plugin supports the following delemiters:
* """\(""".."""\)""" - Inline equations
* """$$""".."""$$""" - Displayed equations
* """\[""".."""\]""" - Displayed equations
!! Demo
This is an inline equation \(P(E)   = {n \choose k} p^k (1-p)^{ n-k}\) and this is a displayed equation:
\[J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \, \Gamma(m + \alpha + 1)}{\left({\frac{x}{2}}\right)}^{2 m + \alpha}\]
This is another displayed equation $$e=mc^2$$
!! Code
***/
//{{{
config.extensions.MathJax = {
  mathJaxScript : "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML",
  // uncomment the following line if you want to access MathJax using SSL
  // mathJaxScript : "https://d3eoax9i5htok0.cloudfront.net/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML",
  displayTiddler: function(TiddlerName) {
    config.extensions.MathJax.displayTiddler_old.apply(this, arguments);
    MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
  }
};
 
jQuery.getScript(config.extensions.MathJax.mathJaxScript, function(){
    MathJax.Hub.Config({
      extensions: ["tex2jax.js"],
      "HTML-CSS": { scale: 100 }
    });
 
    MathJax.Hub.Startup.onload();
    config.extensions.MathJax.displayTiddler_old = story.displayTiddler;
    story.displayTiddler = config.extensions.MathJax.displayTiddler;
});
 
config.formatters.push({
	name: "mathJaxFormula",
	match: "\\\\\\[|\\$\\$|\\\\\\(",
	//lookaheadRegExp: /(?:\\\[|\$\$)((?:.|\n)*?)(?:\\\]|$$)/mg,
	handler: function(w)
	{
		switch(w.matchText) {
		case "\\[": // displayed equations
			this.lookaheadRegExp = /\\\[((?:.|\n)*?)(\\\])/mg;
			break;
		case "$$": // inline equations
			this.lookaheadRegExp = /\$\$((?:.|\n)*?)(\$\$)/mg;
			break;
		case "\\(": // inline equations
			this.lookaheadRegExp = /\\\(((?:.|\n)*?)(\\\))/mg;
			break;
		default:
			break;
		}
		this.lookaheadRegExp.lastIndex = w.matchStart;
		var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
			createTiddlyElement(w.output,"span",null,null,lookaheadMatch[0]);
			w.nextMatch = this.lookaheadRegExp.lastIndex;
		}
	}
});
//}}}
Background: #fff
Foreground: #000
PrimaryPale: #8cf
PrimaryLight: #18f
PrimaryMid: #04b
PrimaryDark: #014
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #f88
* [[Uebungsblaetter]]
* [[tutorial]] (kind of)
* [[example codes]]

the scientific computing wiki
Ein String ist eine Zeichenkette, die in einfachen, doppelten oder doppelt und dreifachen Anfuehrungszeichen steht, und Steuerbefehle zur Ausgabeformatierung mit print beinhalten kann.

{{{
s0 = 'hello '
s1 = "world!"
s2 = 'Achtung hier kommt ein Zeilenumbruch .... \n\ .... danke fuer die Aufmerksamkeit.'
s3 = ' "knee!" '
s4 = " 'ack!' "
s5 = ' \'ack!\' '
s6 = '\\backslashes\\'
s7 = """ Dies ist ein
Mehrzeiler."""
}}}

Python Objekte koennen durch {{{str(x)}}} in Strings umgewandelt werden

Eine Ausgabe von {{{str(x)}}} erfolgt durch den Befehl {{{print(x)}}}

Eine einfache Eingabe durch einen Benutzer ueber die Tastatur erfolgt durch {{{s=raw_input(promt)}}}

Dieser Befehl bewirkt :

- einen Zeilenumbruch
- die Ausgabe von {{{promt}}}
- Keyboard Eingabe bis Return gedrueckt wird
- einen weiteren Zeilenumbruch

z.B.:

{{{
x=0
while x<=0 :
    s=raw_input('Bitte geben Sie eine positive Zahl ein :')
    try :
        x=float(s)
    except :              # Fehler bei Umwandlung von Eingabe in float
       print('Eingabe ist keine reelle Zahl...')
}}}

!{{{string}}} Methoden
|CssClass|k
|{{{s.upper()}}}|Umwandeln in Grossbuchstaben |
|{{{s.lower()}}}|Umwandeln in Kleinbuchstaben|
|{{{s1 in s2}}}|Ist s1 als Teilstring in s2 enthalten? |
|{{{s1==s2}}}|Sind die Strings identisch? |
|{{{s1<s2}}}|Kommt s1 vor s2 bei lexikalischer Ordnung|
|{{{s1<=s2}}}|ist s1==s2 oder kommt s1 vor s2 bei lexikalischer Sortierung|
|{{{s1>s2}}}|Kommt s2 vor s1 bei lexikalischer Ordnung|
|{{{s1>=s2}}}|ist s1==s2 oder kommt s2 vor s1 bei lexikalischer Sortierung|
|{{{s.endswith(suffix[,i[,j]])}}}|Endet der String oder das Teilstueck auf den suffix? |
|{{{s.startswith(prefix[,i[,j]])}}}|Beginnt der String oder das Teilstueck mit dem prefix? |
|{{{s.find(sub[,i[,j]])}}}|erstes Vorkommen von sub in s (-1 falls sub nicht vorkommt) |
|{{{s.rfind(sub[,i[,j]])}}}|letztes Vorkommen von sub in s (-1 falls sub nicht vorkommt) |
|{{{s.index(sub[,i[,j]])}}}|wie find, aber mit Fehlermeldung, falls sub nicht vorkommt |
|{{{s.rindex(sub[,i[,j]])}}}|wie rfind aber mit Fehlermeldung, falls sub nicht vorkommt |
|{{{s.count(sub[,i[,j]])}}}|Anzahl nicht-ueberlappender Vorkommen von sub in s |
|{{{s.partition(sep)}}}|Trennung von s bei erstem Vorkommen von sep |
|{{{s.rpartition(sep)}}}|Trennung von s bei letztem Vorkommen von sep |
|{{{s.split([sep[, maxsplit]])}}}|Liste von substrings, die durch sep getrennt werden (die ersten maxsplit); ohne Argument sep=' '|
|{{{s.rsplit([sep[,maxsplit]])}}}|Wie split aber von rechts|
|{{{s.splitlines([keepsends])}}}|Liste der Zeilen im String s mit oder ohne Zeilenumbruch Code|
|{{{s.zfill(width)}}}|Auffuellen von s mit Nullen von Links|
|{{{exec(s)}}}|Uebergabe und Ausfuehrung des Strings s durch Pyhton Interpreter |
|{{{eval(s)}}}|Evaluation des Strings s durch Python Interpreter |

!{{{string}}} Formatierung
{{{
s.format(*args,**kwargs)
s.format(a0,a1,...,p0=b0, p1=b1, ...)
s.format(*[a0,a1,...], **{p0 : b0, p1 : b1, ...}])
}}}
- Geschweifte Klammern und deren Inhalt im String s werden nach bestimmten Regeln durch die format-Argumente ersetzt. 
- Leere geschweifte Klammern {{{ {} }}} werden der Reihenfolge nach durch die Positionsargumente ersetzt.
- Geschweifte Klammern mit Indexnummer bzw. Keyword als Identifizierung werden durch die entsprechenden Positions- oder Keyword Argumente ersetzt.
- Indexnummer bzw. Keyword Argument koennen weiter indiziert werden, falls das entsprechende Argument eine komplexe Struktur besitzt (siehe Beispiel)

{{{
"{0} {1} {2}".format(99,"bottles","of beer on the wall")
"{} {} {}".format(1,2,'3')
"{2} {1} {0}".format(1,2,'3')
"{0}{1}{0}".format('abra','cad')
"{0[0]} {0[1]} {1[Title]} {1[Name]} !!".format(['Brave', 'brave brave'], {'Name' : 'Robin', 'Title' : 'Sir'})
"Die komplexe Zahl {0} hat den Realteil {0.real} und den Imaginaerteil {0.imag}".format(1+2j)
}}}

- Zahlenformatierung erfolgt nach einem Doppelpunkt hinter der Identifizierung des Arguments
{{{ {identifer:format} }}}
{{{format : [minimum width][.precision][conversion]}}}
conversion:
|CssClass|k
|f,F|float ohne Exponent Darstellung|
|e,E|float in Exponent Darstellung|
|d|integer|
[[Ue01|http://www.stat.physik.uni-potsdam.de/~toenjes/GetSimple_3.1.2/data/uploads/sc1ws1213/scicomp1_ueb_01.pdf]] (Abgabe bis 7. November)
[[Ue02|http://www.stat.physik.uni-potsdam.de/~toenjes/GetSimple_3.1.2/data/uploads/sc1ws1213/scicomp1_ueb_02.pdf]] (Abgabe bis 21. November)
!boolean

es gibt die zwei Wahrheitswerte {{{True}}} und {{{False}}}

Alle Objekte haben einen Wahrheitswert, welcher durch {{{bool(x)}}} angezeigt wird.

{{{bool(x)==False}}} fuer :

{{{x==None}}}
{{{x==False}}}
{{{x==0}}} (Null in irgendeiner Zahlenart, z.B. auch 0L, 0.0, 0+0j etc.)
{{{len(x)==0}}}, wenn das Objekt die Laenge Null hat, also z.B. leer ist
{{{nonzero(x)==False}}}, wenn das Objekt das Protokoll {{{x.__nonzero__()}}} besitzt und dieses {{{False}}} zurueckliefert

{{{bool(x)==True}}} fuer alle anderen Objekte

{{{
a or b           # der Wahrheitswert von b wird nur ueberprueft, wenn a==False ist
a and b           # der Wahrheitswert von b wird nur ueberprueft, wenn a==True ist
not a
}}}

!Vergleiche

Alle Objekte koennen verglichen werden (in python v2.x)
{{{
x<y             # fuehrt zu TypeError falls x oder y einen Imaginaerteil besitzt
x<=y           # s.o.
x>y            # s.o.
x>=y          # s.o.
x==y           # Inhalt gleich?
x!=y            # Inhalt ungleich?
x is y          # Identitaet gleich?
x is not y    # Identitaet ungleich?
}}}

!numerische Typen

{{{1}}},{{{-2}}} / {{{1L}}}, {{{-2L}}}, {{{int}}} / {{{long}}} 32bit/64bit ganze Zahlen einschl. Vorzeichen

{{{1.0}}}, {{{-3.1415}}}, {{{float}}} 64bit Gleitkommazahlen

{{{1+1j}}}, {{{1.0+1.0j}}}, {{{complex}}} 2x64bit komplexe Gleitkommazahlen

Alle numerischen Typen unterstuetzen die folgenden Operationen
{{{
x+y
x-y
x*y
x/y
x//y                             # Division mit Abrundung auf naechstkleinere ganze Zahl
x%y                            # der Restbetrag x%y == x-(x//y)*y
-x
+x
x**y                             # x zur Potenz y
abs(x)
int(x)                            # Typumwandlung (hier unter Wegfall der Nachkommastellen)
long(x)
float(x)
x.real                           # Objektattribut, Realteil von x
x.imag                         # Objektattribut, Imaginaerteil von x
x.conjugate()                # Objektmethode, komplex konjugierte Zahl von x
}}}

bei gemischten Typen in einer Operation hat das Ergebnis den allgemeineren Typ

!math modul

{{{
import math
x=math.sqrt(2.0)
}}}

oder

{{{
import math as m
x=m.sqrt(2.0)
}}}

oder

{{{
from math import sqrt
x=sqrt(2.0)
}}}

oder

{{{
from import math import *
x=sqrt(2.0)
}}}

das {{{math}}} Modul unterstuetzt die folgenden Methoden

{{{
ceil(x)                                                 # naechst groessere ganze Zahl
floor(x)                                               # naechst kleinere ganze Zahl
fmod(x,y)                                            # Rest bei Division
exp(x), expm1(x)                                # e^x bzw. e^x-1 (ist genauer fuer kleinere argumente, da ohne Bitausloeschung)
log(x), log(x,base),  log10(x), log1p(x)  # Logarithmus von x, zur Basis [base], 10 und log(1+x) (fuer kleine x)
sqrt(x)
sin(x)
cos(x)
tan(x)
asin(x), acos(x), atan(x)                      # Umkehrfunktionen der trigonometrischen Funktionen
atan2(y,x)                                           # Winkel des Punktes (x,y) zur x-Achse (beachte Argumentreihenfolge)
sinh(x), cosh(x), tanh(x)                      # hyperbolische Funktionen
asinh(x), acosh(x), atanh(x)                 # Umkehrfunktionen
erf(x)                                                  # Gaussche Errorfunktion (Gaussches Integral)
gamma(x)                                          # Gammafunktion. fuer ganze Zahlen x==n gilt gamma(n+1)=n!
pi
e
}}}

das Modul {{{cmath}}} unterstuetzt die obigen Funktionen mit komplexen Argumenten, und hat ausserdem die Methoden

{{{
phase(x)      # phase von x im Intervall (-pi,pi]
polar(x)        # tupel (r,phi) wobei r der Betrag von x und phi die Phase ist
rect(r,phi)      # komplexe Zahl r*(cos(phi)+sin(phi)*1j)
}}}
|CssClass|k
|{{{list}}}|{{{M=[x,1,"z",[1.0,"foo"]]}}}|
|{{{tuple}}}|{{{M=(x,1,"z",[1.0,"foo"],(x,1j))}}}|
|{{{str}}}|{{{s="abcdef"}}}|
|{{{set}}}|{{{M={a,b,(1,2),"bar"} }}}|
|{{{frozenset}}}|{{{M={1,(1,2),"bar"} }}}|
|{{{dict}}}|{{{M={"title" : "Sir", "name" : "Robin", 42 : True} }}}|

Container Typen sind //iterierbar//, z.B. {{{for x in M : print(x)}}}

Es gibt aber auch nicht-container Objekte, die iterierbar sind, z.B. {{{xrange(n0,n1)}}}.

Container koennen //sequenzierbar// sein, d.h. die Elemente haben Nummern und sind durch {{{M[n]}}} abrufbar

Woerterbuecher werden durch ihre Schluesselworte indiziert, z.B. {{{M["title"]}}}, {{{M[42]}}}

Es gibt veraenderbare (//mutable//) Objekte, welche nach der Erzeugung ihren Inhalt aendern koennen und unveraenderbare (//immutable//) Objekte.

mutable : {{{list}}},{{{set}}},{{{dict}}}
immutable : {{{str}}}, {{{tuple}}}, {{{frozenset}}}, Zeichen {{{char}}} und alle Zahlen

Unveraenderbare Objekte koennen //hashable// sein, dann sind sie geeignet als Elemente von {{{set}}} und {{{frozenset}}} und koennen als Woerterbuchindex ({{{dict}}}) verwendet werden.


Alle built-in container sind iterierbar und koennen im Prinzip ineinander umgewandelt werden, z.B. S={1,2,3}; M=list(S)

Alle built-in container unterstuetzen die folgenden Anfragen
{{{
x in M                      # is x in M enthalten? Auch Substring Test moeglich.
x not in M
min(M)                    # kleinstes Element unter Verwendung der Vergleichsprotokolle
max(M)
any(M)                    # existiert ein Element x in M mit bool(x)==True ?
len(M)                     # Anzahl der Elemente in M
sorted(M)                # sortierte Liste {{{list}}} der Elemente aus M
}}}

Listen mit ganzen Zahlen werden durch die Funktion {{{range(i,j,k)}}} erzeugt.

{{{
range(j)        # [0,1, ... , j-1]
range(i,j)      # [i,i+1, ... , j-1]
range(i,j,k)   # [i,i+k,i+2k, ... , i+nk<j]
}}}

Die Funktion {{{xrange(i,j,k)}}} liefert ein iterierbares Objekt mit den gleichen Eigenschaften, jedoch ohne die komplette Liste im Speicher anzulegen

!Methoden fuer {{{list}}} und {{{tuple}}}
|CssClass|k
|{{{M+N}}}|Verkettung |
|{{{n*M}}}|n-fache Verkettung |
|{{{M[i]}}}|Element mit index i (Start bei i=0) |
|{{{M[i:j]}}}|Teilstueck von i bis j-1 |
|{{{M[i:j:k]}}}|Teilstueck von i bis i+nk < j (Schrittweite k) |
|{{{M.index(x)}}}|erster index idx mit M[idx]==x |
|{{{M.index(x,i)}}}|erster index idx>=i mit M[idx]==x |
|{{{M.index(x,i,j)}}}|erster index j>idx>=i mit M[idx]==x |
|{{{M.count(x)}}}|Anzahl von x in M |

- Bei der Indizierung durch Intervallgrenzen, koennen diese auch weggelassen werden, wobei dann standardmaessig {{{i=0}}}, {{{j=len(M)}}} und {{{k=1}}} gewaehlt werden
- Negative Werte fuer i und j werden als {{{len(M)+i}}} bzw. {{{len(M)+j}}} interpretiert

|CssClass|k
|{{{M[:]}}}|Neue Liste mit allen Elementen aus M |
|{{{M[i:-j]}}}|Teilstueck von i bis len(M)-j |
|{{{M[-1::-1]}}}|Teilstueck von len(M)-1 bis 0, (invertierte Liste) |

!Methoden fuer {{{list}}}
|CssClass|k
|{{{M[i]=x}}}|Zuweisung von Element bei Index i |
|{{{M[i:j]=N}}}|Ersetzen von Teilstueck i...j-1 durch alle Elemente aus N |
|{{{M[i:j:k]=N}}}|Ersetzen aller Elemente M[i:j:k] durch alle Elemente aus N (N muss exact so viele Elemente enthalten)|
|{{{M[i:j]=[], del(M[i:j]), del(M[i:j:k]) }}}|Loeschen von Teilstueck |
|{{{M.append(x)}}}|Anhaengen von x an Liste M |
|{{{M.extend(N)}}}|Anhaengen aller Elemente aus N an M |
|{{{M.insert(i,x)}}}|Einfuegen von x bei Index i |
|{{{x=M.pop(i), x=M.pop()}}}|Entfernen von Element mit Index i bzw. vom Ende der Liste und Zuweisung an x |
|{{{M.remove(x)}}}|Entfernt das erste Vorkommen von x aus der Liste M oder gibt Fehler aus, wenn x nicht vorkommt |
|{{{M.reverse()}}}|Umkehrung der Reihenfolge der Elemente |
|{{{M.sort()}}}|Sortierung der Elemente aus M |

!Methoden fuer {{{set}}} und {{{frozenset}}}
|CssClass|k
|{{{M==N}}}|Mengen Vergleich |
|{{{M.isdisjoint(N)}}}|Ist die Schnittmenge von M und N leer? |
|{{{M<=N, M.issubset(N)}}}|Ist M Teilmenge von N? |
|{{{M<N}}}|Ist M echte Teilmenge von N? |
|{{{M>=N, M.issuperset(N)}}}|Ist N Teilmenge von M? |
|{{{M=N0|N1|N2|..., M=N0.union(N1,N2,...)}}}|Zuweisung der Vereinigung von N0, N1, N2... zu einer Menge M |
|{{{M=N0&N1&...,  M=N0.intersection(N1,N2,...)}}}|Zuweisung der Schnittmenge von N0,N1,... zu einer Menge M |
|{{{M=N0-N1-N2-..., M=N0.difference(N1,N2,...)}}}|Zuweisung einer Differenzmenge |
|{{{M=N0^N1, M=N0.symmetric_difference(N1)}}}|Symmetrische Differenz = Elemente entweder in N0 oder in N1|


!Methoden zur Veraenderung einer Menge {{{set}}}
|CssClass|k
|{{{M|=N0|N1|...,  M.update(N0,N1,...)}}}|Erweiterung der Menge M um die Elemente in N0, N1, ... (der senkrechte Strich bedeutet //oder//)|
|{{{M&=N0&N1&...,  M.intersection_update(N0,N1,...)}}} |Schnittmengenbildung (& bedeutet //und//)|
|{{{M-=N0|N1|...,  M.difference_update(N0,N1,...)}}} |Entfernen der Elemente von N0,N1,... aus M |
|{{{M^=N,  M.symmetric_difference_update(N)}}} |M=M^N |
|{{{M.add(x)}}} |Einfuegen von Element x in M |
|{{{M.remove(x)}}} |Entfernen von x aus M; KeyError wenn x nicht in M ist |
|{{{M.discard(x)}}} |Entfernen von x aus M; kein KeyError wenn x nicht in M ist |
|{{{x=M.pop()}}} |Entfernen eines Elements aus M und Zuweisung an x |
|{{{M.clear()}}} |Entfernen aller Elemente |

[[String Methoden und Formatierung]]

!binary representation of float (double)
{{{
from struct import pack, unpack
def doublebin(x) :
    """
    convert x to c-type string, back to long integer 1-tuple and return the binary string for that long integer
    remove the trailing '0b' indicator, pad with zeros up to 64 binary digits and insert seperators after sign and exponent
    """
    bx = bin(unpack('L',pack('d',x))[0])[2:].zfill(64)
    sign = (bx[0], (-1)**int(bx[0]))
    exponent = (bx[1:12], int(bx[1:12],2)-1023)
    fraction = (bx[12:], int(bx[12:],2)/(2.0**52))
    bx = bx[0] + '|' + bx[1:12] + '|' + bx[12:]
    return {'binary': bx, 'sign' : sign, 'exponent' : exponent, 'fraction' : fraction}
}}}
!functions as objects
{{{
def central_difference(f,h=0.01) # function f is positional argument and difference h is keyword argument (optional; default value h=0.01)
    """
    takes a function f that should be callable with one argument and returns the 
    central difference quotient function Df with Df(x)=(f(x+h)-f(x-h))/2h
    """
    return lambda x : (f(x+h)-f(x-h))/float(2*h)

import math
f=math.sin                                   # f is now the function f(x)=sin(x)
Df=central_difference(f,0.001)      # Df is now the function Df(x)=(f(x+0.001)-f(x-0.001))/0.002
}}}
!simple scanf function
{{{
def scanf(file,N=None,comment='#') :
    """
    Open file or use file object's current position, and
    read line by line, split at whitespaces and convert
    to float N times (if N!=None), until file is finished,
    or conversion error occurs. Skip lines starting with
    comment string. Returns list of floats.
    """
    if (type(file)==str) : f = open(file,'r')
    else : f=file
    X=[]
    comment=str(comment)
    l=f.readline()
    while l :
        if not l.startswith(comment) :
            nmbr=l.split()
            for s in nmbr :
                try : r=float(s)
                except : break
                if (N==None) or (len(X)<N) : X.append(r)
                if len(X)==N : break
        l=f.readline()
    if (type(file)==str) : f.close()
    return X
}}}
!mean over all non-nan entries
{{{
from numpy import isnan,logical_not,mean

def nanmean(x) :
    """ 
    Mean over ALL non-nan entries of array-like object x.
    """
    return mean(x[logical_not(isnan(x))])
}}}
!regular expression tester
{{{
import re
def regtest(file) :
    """
    read one line from file and use this line as regular expression.
    match the rest of the file against the regular expression and print result.
    search the rest of the file for the regular expression and print result. 
    """
    if type(file)==str : f=open(file)
    else : f=file
    reg=f.readline()
    reg=reg[:-1]
    print('regular expression : {}\n'.format(reg))
    rx=re.compile(reg)
    s=f.read()
    print('string to match (rest of the file) : ')
    print(s)
    print('\n')
    if rx.match(s) : print('regex matches the string.\n')
    else : print('regex does not match the string.\n')
    print('findall results : ')
    L=rx.findall(s)
    print(L)
    if type(file)==str : f.close()
}}}
!scan file for regular expression
{{{
import re

def filescan(file,reg,comment='#') :
    """
    Open file or from file object's current position read
    line by line and pull out matches to the regular expression
    given by string reg (lines starting with comment string are
    ignored). Returns list of matches, group tuples or dictionaries.
    """
    if not (type(reg)==str) : return None
    if type(file)==str : f=open(file,'r')
    else : f = file
    rx=re.compile(reg)
    L=[]
    l=f.readline()
    while l :
        if not (l.startswith(comment)) : L.extend(rx.findall(l))
        l=f.readline()
    if (type(file)==str) : f.close()
    return L
}}}
!Erzeugung von Listen (Tupeln, Mengen)

{{{L=[<Ausdruck> for x in L (if <Bedingung>)]}}}

{{{
L=[x/2.0 for x in N]
L=[1.0/x for x in N if x!=0]
L=list(x/2.0 for x in N)
L=tuple(x/2.0 for x in N)
L=set(x/2.0 for x in N)
xfx = [(x,f(x)) for x in N]
}}}

kann auch geschachtelt werden :

{{{
L = [x/y for x in N0 for y in N1 if y!=0]
}}}

{{{zip(N0,N1,...)}}} erzeugt Liste mit Tupeln (x0,x1,....) von Elementen aus L0,L1 (Anzahl von Tupeln ist die kuerzeste Laenge len(Ni))

{{{
x = range(10)
fx = map(f,x)
xfx = zip(x,fx)
}}}

!filter(), map() und reduce()

|CssClass|k
|{{{filter(f,L)}}}|Liste aller Elemente x aus L mit f(x)==True bzw. bool(f(x))==True (string oder tuple, wenn L string oder tuple)|
|{{{map(f,L)}}}|Liste mit Elementen f(x) fuer alle x in L|
|{{{map(f,L0,L1,...)}}}|Liste mit Elementen f(x0,x1,...) fuer alle i mit x0==L0[i], x1==L1[i] ... (xn==None fuer nicht vorhandene Elemente falls Listen nicht gleich lang sind)|
|{{{reduce(f,L)}}}|Fehler wenn len(L)==0, L[0] falls len(L)==1, ansonsten f(...f( f(L[0],L[1]) ,L[2]),L[3]),...)|
|{{{sum(L)}}}|0 + Summe aller Elemente aus L (Elemente muessen Zahlen sein)|

{{{
filter(lambda x : x%2, L) # Liste aller Zahlen aus L, die bei Division durch 2 nicht den Rest Null haben
filter(lambda x : x%2==0,L) # Liste aller geraden Zahlen in L
map(lambda x,y : (x+y)*0.5, L0,L1) # elementweises gewichtetes Mittel zweier Listen
reduce(lambda x,y : y-x, L) # alternierende Summe?
}}}

!Inline Formatting
|!Option|!Syntax|!Output|
|bold font|{{{''bold''}}}|''bold''|
|italic type|{{{//italic//}}}|//italic//|
|underlined text|{{{__underlined__}}}|__underlined__|
|strikethrough text|{{{--strikethrough--}}}|--strikethrough--|
|superscript text|{{{^^super^^script}}}|^^super^^script|
|subscript text|{{{~~sub~~script}}}|~~sub~~script|
|Colored text|@@color(green):green colored@@|{{{@@color(green):green colored@@}}}|
|Text with colored background|@@bgcolor(#ff0000):color(#ffffff):red colored@@|{{{@@bgcolor(#ff0000):color(#ffffff):red colored@@}}}|
|highlighted text|{{{@@highlighted@@}}}|@@highlighted@@|
|preformatted text|<html><code>{{{preformatted}}}</code></html>|{{{preformatted}}}|
!Block Elements
!!Headings
{{{
!Heading 1
!!Heading 2
!!!Heading 3
!!!!Heading 4
!!!!!Heading 5
}}}
<<<
!Heading 1
!!Heading 2
!!!Heading 3
!!!!Heading 4
!!!!!Heading 5
<<<
!!Lists
{{{
* unordered list, level 1
** unordered list, level 2
*** unordered list, level 3

# ordered list, level 1
## ordered list, level 2
### ordered list, level 3

; definition list, term
: definition list, description
}}}
<<<
* unordered list, level 1
** unordered list, level 2
*** unordered list, level 3

# ordered list, level 1
## ordered list, level 2
### ordered list, level 3

; definition list, term
: definition list, description
<<<
!!Blockquotes
{{{
> blockquote, level 1
>> blockquote, level 2
>>> blockquote, level 3

<<<
blockquote
<<<
}}}
<<<
> blockquote, level 1
>> blockquote, level 2
>>> blockquote, level 3

> blockquote
<<<
!!Preformatted Text
<html><pre>
{{{
preformatted (e.g. code)
}}}
</pre></html>
<<<
{{{
preformatted (e.g. code)
}}}
<<<
!!Tables
{{{
|CssClass|k
|!heading column 1|!heading column 2|
|row 1, column 1|row 1, column 2|
|row 2, column 1|row 2, column 2|
|>|COLSPAN|
|ROWSPAN| … |
|~| … |
|CssProperty:value;…| … |
|caption|c
}}}
''Annotation:''
* The {{{>}}} marker creates a "colspan", causing the current cell to merge with the one to the right.
* The {{{~}}} marker creates a "rowspan", causing the current cell to merge with the one above.
<<<
|CssClass|k
|!heading column 1|!heading column 2|
|row 1, column 1|row 1, column 2|
|row 2, column 1|row 2, column 2|
|>|COLSPAN|
|ROWSPAN| … |
|~| … |
|CssProperty:value;…| … |
|caption|c
<<<
!!Images /% TODO %/
cf. [[TiddlyWiki.com|http://www.tiddlywiki.com/#EmbeddedImages]]
!Hyperlinks
* [[WikiWords|WikiWord]] are automatically transformed to hyperlinks to the respective tiddler
** the automatic transformation can be suppressed by preceding the respective WikiWord with a tilde ({{{~}}}): {{{~WikiWord}}}
* [[PrettyLinks]] are enclosed in square brackets and contain the desired tiddler name: {{{[[tiddler name]]}}}
** optionally, a custom title or description can be added, separated by a pipe character ({{{|}}}): {{{[[title|target]]}}}<br>''N.B.:'' In this case, the target can also be any website (i.e. URL).
!Custom Styling
* {{{@@CssProperty:value;CssProperty:value;…@@}}}<br>''N.B.:'' CSS color definitions should use lowercase letters to prevent the inadvertent creation of WikiWords.
* <html><code>{{customCssClass{…}}}</code></html>
* raw HTML can be inserted by enclosing the respective code in HTML tags: {{{<html> … </html>}}}
!Special Markers
* {{{<br>}}} forces a manual line break
* {{{----}}} creates a horizontal ruler
* [[HTML entities|http://www.tiddlywiki.com/#HtmlEntities]]
* {{{<<macroName>>}}} calls the respective [[macro|Macros]]
* To hide text within a tiddler so that it is not displayed, it can be wrapped in {{{/%}}} and {{{%/}}}.<br/>This can be a useful trick for hiding drafts or annotating complex markup.
* To prevent wiki markup from taking effect for a particular section, that section can be enclosed in three double quotes: e.g. {{{"""WikiWord"""}}}.
{{{import numpy as np}}}

Wichtige Untermodule :
{{{import numpy.doc as npdoc}}}
{{{import numpy.linalg as linalg}}}
{{{import numpy.random as rnd}}}

Numpy wird von Scipy automatisch geladen.

Numpy stellt einen Neuen Datentyp zur Verfuegung : {{{array()}}}

Arrays sind ein- und mehrdimensionale Felder, deren Elemente alle den gleichen Datentyp haben muessen.

|CssClass|k
|{{{A[i0,i1,...]}}}|Element mit Indizes i0,i1,...|
|{{{A = np.zeros(shape,dtype=float)}}}|Erzeugung eines d0 x d1 x d2 ... dimensionalen Feldes A mit shape=[d0,d1,d2,...] und Nuller Elementen vom Typ dtype|
|{{{A = np.ones(shape,dtype=float)}}}|Erzeugung eines d0 x d1 x d2 ... dimensionalen Feldes A mit shape=[d0,d1,d2,...] und Einser Elementen vom Typ dtype|
|{{{A = np.eye(N,M=None,k=0,dtype=float)}}}|Erzeugung eines NxM Feldes bzw. NxM wenn M nicht gegeben ist mit Einser Elementen auf der k-ten nebendiagonale und Nullen sonst|
|{{{A = np.arange(i,j,k)}}}|wie range(i,j,k) und alle Variationen davon|
|{{{A = np.linspace(x0,x1,n)}}}| Feld mit n Elementen x0<=x<=x1 in gleichmaessigem Abstand|
|{{{A = np.logspace(x0,x1,n,base)}}}| Feld mit n Elementen base**x und x0<=x<=x1 in gleichmaessigem Abstand|
|{{{A.shape = newshape}}}| Veraenderung des shapes; Die Anzahl der Elemente d0 x d1 x d2 ... muss konstant bleiben|
|{{{B=A.reshape(newshape)}}}| Erzeugt eine //andere Ansicht// ''auf dasselbe Feld'' A|

!slicing

- Slices sind Ausschnitte aus einem Feld
- Aendert sich das Feld, so aendern sich auch alle betroffenen Ausschnitte

1d Feld : {{{B=A[i:j:k]}}} liefert den Ausschnitt {{{array([A[i], A[i+k], A[i+2*k], ....A[i+n*k<j]])}}}

- Mehrdimensionale Felder koennen ueber jeden Index geschnitten werden : A[i0:j0:k0, i1:j1:k1, ...]

- Die Slicing Notation ist die gleiche wie bei der Listen Indizierung. Bei Nichtangabe haben i:j:k die Standardwerte 0:len(A):1.

- Negative Werte -i und -j werden als len(A)-i bzw. len(A)-j interpretiert.

!Indexfelder

- Indexfelder sind Arrays (oder aequivalent strukturierte Container) mit Elementen vom Typ {{{int}}} oder {{{bool}}}

- Mit integer-Indexfeld {{{I}}} erzeugt {{{A[I]}}} ''ein neues Feld mit dem shape von'' {{{I}}} und den Elementen im (1d) Feld {{{A}}}, die durch die Elemente von {{{I}}} indiziert werden.

{{{A[[1,3,5]]}}}

- Bei n-dimensionalen Feldern {{{A}}} sind n Indexfelder {{{I1}}}, {{{I2}}}, ... , {{{In}}} notwendig

{{{B=A[range(2,4),range(5,6)]}}}

- boolean-Indexfelder {{{B}}} beschreiben eine Auswahl von Elementen aus einem Feld. {{{A[B]}}} ist ein 1d Feld mit den Werten {{{A[i1,i2,...in]}}} an denen {{{B[i1,i2,...,in]==True}}} ist.

z.B :{{{x[x>0]}}}

!Vektorisierung

Die meisten numerischen Operationen und Vergleiche ueber Felder sind vektorisiert, d.h. sie funktionieren ''elementweise'' ohne explizite zusaetzliche {{{for}}}-Schleife.

Vektorisierte Funktionen koennen schneller berechnet werden als {{{for}}}-Schleifen ueber Felderindizes

{{{
import numpy as np
def f(a,b) :
    if a>b : 
        return a-b
    else : 
        return a+b

vfunc = np.vectorize(f)
print(vfunc([1,2,3,4,5],2))
print(vfunc([1,2,3,4,5],[5,4,3,2,1]))
}}}

* [[python.org|http://docs.python.org/]] : references and tutorial
* [[scipy.org|http://docs.scipy.org/doc/]] : numpy user guide, numpy and scipy reference manuals
* [[matplotlib.org|http://matplotlib.org/]] : matplotlib docs, gallery and examples
* [[Springer Link|http://www.springerlink.com/content/978-3-642-02474-0/contents/]] : H.P.Langtangen, A Primer on Scientific Computing with Python
version.extensions.smileyMacro = {major: 0, minor: 1, revision: 0, date: new Date(2005,7,20)};
//Author: Alan Hecht
config.macros.smiley = {}
config.macros.smiley.handler = function(place,macroName,params)
{
	var palette = ["transparent","#000000","#1a1507","#352e18","#464646","#666666","#a3141e","#b06b63","#cc9900","#dd9030","#dddddd","#e89d00","#edc32a","#f3cb3c","#fdf201","#fdf526","#ff3149","#ffac00","#ffbf06","#ffc846","#ffcc66","#ffd758","#ffdd01","#ffea7b","#ffed55","#ffffff"];
	var data = params;
	var imageMap = null;
	if(data[0] == ":-)" || data[0] == ":)")

		imageMap = "aaaaabbbbbaaaaaaaabdtyyvtdbaaaaabnyxxxxxujbaaabmyyffyffuujbaadyyyeeyeetttdabppppddyddpmmlbbwoooooooowsrlbbwwpooooowwmrlbbwwboooowwwbllbbwwwboooowbrllbacwwwbbbbbrllcaablswwwwsrrlibaaablsssrrllibaaaaabcrrlllcbaaaaaaaabbbbbaaaaa";
	else if(data[0] == ":-(" || data[0] == ":(")
		imageMap = "aaaaabbbbbaaaaaaaabdtyyvtdbaaaaabnyxxxxxujbaaabmyyyyyyyuujbaadyyyeeyeetttdabppppddyddpmmlbbwoooooooowsrlbbwwpooooowwmrlbbwwoooooowwrllbbwwwwbbbbbsrllbacwwbwwwwsbllcaablswwwwsrrlibaaablsssrrllibaaaaabcrrlllcbaaaaaaaabbbbbaaaaa";
	else if(data[0] == ";-)" || data[0] == ";)")
		imageMap = "aaaaabbbbbaaaaaaaabdtyyvtdbaaaaabnyxxxxxujbaaabmyyxxxxxuujbaadyyyxxxeetttdabppphddyddpmmlbbwoooooooowsrlbbwwpooooowwmrlbbwwboooowwwbllbbwwwboooowbrllbacwwwbbbbbrllcaablswwwwsrrlibaaablsssrrllibaaaaabcrrlllcbaaaaaaaabbbbbaaaaa";
	else if(data[0] == ":-|" || data[0] == ":|")
		imageMap = "aaaaabbbbbaaaaaaaabdtyyvtdbaaaaabnyxxxxxujbaaabmyyffyffuujbaadyyyeeyeetttdabppppddyddpmmlbbwoooooooowsrlbbwwpooooowwmrlbbwwoooooowwrllbbwwwwbbbbbsrllbacwwwwwwwsrllcaablswwwwsrrlibaaablsssrrllibaaaaabcrrlllcbaaaaaaaabbbbbaaaaa";
	else if(data[0] == ":-D" || data[0] == ":D")
		imageMap = "aaaaabbbbbaaaaaaaabdtyyvtdbaaaaabnyxxxxxujbaaabmyyeeyeeuujbaadyyyeeyeetttdabppppyyyyypmmlbbwbbbbbbbbbbblbbwbkzzzzzzzkbwbbwbfzzzzzzzfbwbbwbkzzzzzzzkbwbacwbkzzzzzkblcaablsbkzzzkblibaaablsbbbbblibaaaaabcrrlllcbaaaaaaaabbbbbaaaaa";
	else
		createTiddlyElement(place,"span",null,"errorNoSuchMacro","unknown smiley");
	if(imageMap)
		{
		var box = createTiddlyElement(place,"span",null,"smiley",String.fromCharCode(160));
		box.style.position = "relative";
		box.style.width = "15px";
		box.style.height = "15px";
		box.style.marginLeft = "1px";
		box.style.marginRight = "1px";
		box.style.paddingRight = "12px";
		box.style.verticalAlign = "top";

		//now divide into 15x15 grid and create each pixel
		// rows
		for(r=0; r<15; r++)
			{
			// columns
			for(c=0; c<15; c++)
				{
				//create each pixel with the correct background
				var pix = document.createElement("img");
				pix.className = "smileyPixel";
				pix.style.position = "absolute";
				pix.border = 0;
				pix.style.top = r + "px";
				pix.style.left = c + "px";
				pix.style.width = "1px";
				pix.style.height = "1px";
				pix.style.backgroundColor = palette[imageMap.charCodeAt((r*15)+c)-97];
				pix.src = "data:image/gif,GIF89a%01%00%01%00%91%FF%00%FF%FF%FF%00%00%00%C0%C0%C0%00%00%00!%F9%04%01%00%00%02%00%2C%00%00%00%00%01%00%01%00%40%02%02T%01%00%3B";
				box.appendChild(pix);
				}
			}
		}
}
Das time modul von python stellt neben verschiedenen Datentypen und Umwandlungen von Zeit- und Datumsangaben (don't go there if you want to avoid a headache) auch die praktischen Funktionen clock(), time() und sleep() zur Verfuegung.

{{{
import time
tic=time.time()               # oder time.clock()
# your code
toc=time.time()              # oder time.clock()
print("Ausfuehrung dauerte {} Sekunden".format(toc-tic))
}}}

{{{time.time()}}} und {{{time.clock()}}} liefern jeweis eine Zeit in Sekunden als Gleitkommazahlen zurueck. Die Funktion {{{time.time()}}} ist die Zeit seit Beginn der Epoche (lange her) waerend {{{time.clock()}}} auf Unix Systemen die Zeit angibt, welche die CPU dem aktuellen Skript gewidmet hat. Diese kann je nach Auslastung des Rechners erheblich kuerzer sein als die Zeit, welche in der realen Welt vergeht. Man spricht von CPU time und walltime (Echtzeit). Auf Windows Systemen liefert {{{time.clock()}}} die Echtzeit zurueck, welche seit dem ersten Aufruf von {{{time.clock()}}} im Skript vergangen ist. Je langer die Epoche dauert, um so ungenauer wird {{{time()}}} waehrend {{{clock()}}} auf Linux Systemen von sich aus auf 10ms Genauigkeit beschraenkt ist und auf Windows ein anderes Ergebnis leifern kann. Ein und derselbe Code kann fuer verschiedene Durchlaeufen unterschiedlich lange brauchen. Die beiden Funktionen {{{time()}}} und {{{clock()}}} geben daher nur grobe Orientierungen.

{{{time.sleep(sec)}}} unterbricht die Ausfuehrung eines Skriptes fuer {{{sec}}} Sekunden Echtzeit, wobei {{{sec}}} eine Gleitkommazahl ist. Die tatsaechliche Unterbrechung kann laenger sein, aber auch kuerzer.

{{{
import time
cL=[]
tL=[]
for i in xrange(100) :
    ctic=time.clock()
    ttic=time.time()
    time.sleep(0.5)
    ctoc=time.clock()
    ttoc=time.time()
    cL.append(ctoc-ctic)
    tL.append(ttoc-ttic)
print("{}, {}".format(mean(cL),std(cL)))
print("{}, {}".format(mean(tL),std(tL)))
}}}
* [[boolean und Zahlen Typen]]
* [[container Typen]]
* [[list comprehensions]]
* [[String Methoden und Formatierung]]
* [[Kontrollstrukturen]]
* [[Funktionen]]
* [[numpy und scipy]]
* [[Lineare Algebra]]
* [[timing und sleeping]]

!Python

- ist eine Skriptsprache
- Programme werden //zeilenweise interpretiert//

positiv :

- Programme sind sowohl lesbar als auch direkt ausfuehrbar
- kann interaktiv z.B. als Taschenrechner verwendet werden
- ist frei und kostenlos verfuegbar
- es gibt viele nuetzliche Module (Programmbibliotheken, die man in eigene Programme einbinden kann)
- diese beinhalten Schnittstellen zu anderen Programmen, Programmiersprachen, betriebssystemen, Datenbanken, dem Internet ...
- Python is weit verbreitet
- man hat schnell eine Loesung fuer einfache Probleme

negativ :

- etwa 100 mal langsamer als C++

!ipython

start mit 
{{/> ipython

{{>> In[0] : (Eigabezeile)

Hilfesystem und einfache referenz zu ipython mit ? und //%quickref//

{{{help}}} ruft das python Hilfesystem auf

{{{object?}}}, {{{object??}}} bzw {{{?object}}} geben Informationen und Dokumentationen von Funktionen und anderen Objekten aus

die Taste 'q' fuerht zurueck zur Eingabeaufforderung der interaktiven Session

Programme werden gestartet aus ipython heraus mittels

{{{%run program.py [arguments]}}}

und von der Komandozeile durch

{{{/>python program.py [arguments]}}}

//[arguments]// bezeichnet hier optionale Programmargumente

ipython wird durch die Befehle {{{Quit}}} und {{{Exit}}} verlassen


!Objekte

Alles in python ist ein Objekt

|CssClass|k
|!Objekte haben|!Test und Ausgabe|
|Typ <type>|{{{type(x)}}}|
|Identitaet <identity>|{{{id(x)}}},   {{{x is y}}}|
|Variablennamen <name(s)>|{{{x}}}, {{{y}}}|
|Werte <value>|{{{x==y}}}|
|Atribute <attributes>|{{{x.imag}}}, {{{x.real}}}|
|Methoden <methods>|{{{str(x)}}}, {{{x.conjugate()}}}|

Die Zuweisung {{{x=y}}} erzeugt ''keine Kopie'' des Objektes {{{y}}} sondern einen weiteren Namen, bzw. Referenz {{{x}}}, fuer dasselbe Objekt! Dies fuehrt insbesondere bei veraenderbaren Objekten dazu, dass sich der Inhalt aller Referenzvariablen aendert, wenn sich das Objekt aendert. 

Objekte sollten bestimmte //Protokolle// besitzen. Dies sind besondere Methoden, welche das generelle Verhalten von Objekten bestimmen. Besondere Protokolle sind

{{{str(x)}}} oder {{{x.__str__()}}} zur Ausgabe eines informellen Strings (Zeichenkette) welcher das Objekt repraesentiert
{{{repr(x)}}} oder {{{x.__repr__()}}} zur Ausgabe eines ausfuehrbaren python code strings, welcher dieses Objekt bzw. eine Kopie davon erzeugen kann
{{{doc(x)}}} oder {{{x.__doc__()}}} zur Ausgabe des Dokumentationsstrings, welcher bei allen Funktionen und Klassen vorhanden sein sollte

Es gibt diverse Vergleichsprotokolle, z.B. {{{x.__ge__(self,y)}}} fuer {{{x>=y}}} usw.

Eine ausfuehrlich Beschreibung von Python Protokollen ist in der [[Python Datenmodell Referenz|http://docs.python.org/reference/datamodel.html]]  zu finden

Beispiel :
{{{
x=3.1415                # Zuweisung eines Wertes
print(x)                   # Ausgabe von x (unter Benutzung des x.__str__() Protokolls)
y=x                        # Erzeugung einer neuen Referenz auf dasselbe Objekt
x==y                      # Vergleich des Objektinhalts
y is x                     # Vergleich der Objektidentitaet
id(x)                      # Ausgabe der Identitaetsnummer
type(x)                   # Ausgabe des Typs von x
type(x)==float        # test, ob x ein float ist (Gleitkommazahl)
}}}