Created
October 6, 2011 11:44
-
-
Save williame/1267214 to your computer and use it in GitHub Desktop.
shows idea of single-static-type-assignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head><title>test.py</title> | |
<style> | |
.v { font-weight: bold; color: navy; } | |
.error { font-weight: bold; color: yellow; background-color: red; } | |
.unused { font-weight: light; color: darkgray; } | |
</style> | |
<script type="text/javascript"> | |
var highlight = {}; | |
function clear_highlight() { | |
for(var id in highlight) { | |
document.getElementById(id).style.backgroundColor = highlight[id]; | |
} | |
highlight = {}; | |
} | |
function mouse_over(event) { | |
clear_highlight(); | |
if((typeof event == "undefined")||(!event)) event = window.event; | |
var span = event.target||event.srcElement; | |
var v = null; | |
if(0==span.id.indexOf("r")) { // is reference | |
v = span.getAttribute('v'); | |
span = document.getElementById(v); | |
if((typeof span == "undefined")||(!span)) return; | |
} else if(0==span.id.indexOf('v')) { | |
v = span.id; | |
} else return; | |
highlight[span.id] = ''+span.style.backgroundColor; | |
span.style.backgroundColor = "lightblue"; | |
if(span.getAttribute('ssta')) { | |
span = document.getElementById(span.getAttribute('ssta')); | |
if(span) { | |
highlight[span.id] = ''+span.style.backgroundColor; | |
span.style.backgroundColor = "orange"; | |
} | |
} | |
var spans = document.getElementsByTagName("span"); | |
for(var i=0; i<spans.length; i++) { | |
span=spans[i]; | |
if(span.getAttribute('v')==v) { | |
highlight[span.id] = ''+span.style.backgroundColor; | |
span.style.backgroundColor = "lightgreen"; | |
} | |
} | |
} | |
function mouse_out(event) { | |
clear_highlight(); | |
} | |
function attach() { | |
var spans = document.getElementsByTagName("span"); | |
for(var i=0; i<spans.length; i++) { | |
var span=spans[i]; | |
if(0==span.id.indexOf("v")) | |
span.style.fontStyle = 'italic'; | |
span.onmouseover = mouse_over; | |
//span.onmouseout = mouse_out; | |
} | |
} | |
window.onload=attach | |
</script> | |
</head><body><pre> | |
class <span id="v2">Ho</span>: | |
def <span id="v3">__init__</span>(<span id="v4">self</span>): | |
<span id="r7" v="v4">self</span>.idx = 1 | |
def <span class="unused"><span id="v5">hum</span></span>(<span class="unused"><span id="v6">self</span></span>, <span class="unused"><span id="v7">foo</span></span>): | |
return foo | |
def <span id="v8">test</span>(<span class="unused"><span id="v9">w_a</span></span>, <span id="v10">w_b</span>=2, *<span class="unused"><span id="v11">args</span></span>, **<span class="unused"><span id="v12">kwargs</span></span>): | |
<span id="v13" ssta="v9">w_a</span> = [1, 2, 3] | |
for <span class="unused"><span id="v14">i</span></span> in 3: | |
<span id="r30" v="v10">w_b</span> = 12 | |
if (<span id="r34" v="v13">w_a</span> > 4): | |
<span class="unused"><span id="v16" ssta="v10">w_b</span></span> = 42 | |
<span id="r41" v="v10">w_b</span> = 12 | |
elif (<span id="r45" v="v10">w_b</span> != 2): | |
<span class="unused"><span id="v18" ssta="v11">args</span></span> = 12 | |
<span class="unused"><span id="v19" ssta="v18">args</span></span> = 13 | |
<span id="r55" v="v10">w_b</span> = 15 | |
else: | |
<span id="v21" ssta="v10">w_b</span> = 'x' | |
<span id="r61" v="v10">w_b</span> = <span id="r63" v="v21">w_b</span> + 2 | |
print <span id="r67" v="v10">w_b</span> | |
<span class="unused"><span id="v23" ssta="v19">args</span></span> = 13 | |
def <span id="v24">hmm</span>(<span id="v25">i</span>): | |
print <span title="closure"><span id="r76" v="v27">w_a</span></span>[<span id="r78" v="v25">i</span>] | |
print <span title="closure"><span id="r81" v="v28">w_b</span></span>[<span id="r83" v="v25">i</span>] | |
<span id="v26" ssta="v10">w_b</span> = ['ab', 'cd'] | |
(<span title="closure"><span id="v27" ssta="v13">w_a</span></span>, <span title="closure"><span id="v28" ssta="v26">w_b</span></span>) = (<span id="r94" v="v26">w_b</span>, <span id="r95" v="v13">w_a</span>) | |
<span id="r98" v="v24">hmm</span>(<span title="closure"><span id="r99" v="v28">w_b</span></span>) | |
for <span id="v29">w_i</span> in <span title="closure"><span id="r102" v="v27">w_a</span></span>: | |
print <span id="r104" v="v29">w_i</span> | |
for <span id="v30" ssta="v29">w_i</span> in <span title="closure"><span id="r107" v="v28">w_b</span></span>: | |
print <span id="r109" v="v30">w_i</span> | |
for (<span id="v31" ssta="v30">w_i</span>, <span id="v32">w_j</span>) in <span title="closure"><span id="r114" v="v28">w_b</span></span>: | |
print <span id="r116" v="v31">w_i</span>, <span id="r117" v="v32">w_j</span> | |
<span class="unused"><span id="v33" ssta="v32">w_j</span></span> = 2 | |
<span class="unused"><span id="v34" ssta="v28">w_b</span></span> = 'abx' | |
<span title="closure"><span id="r125" v="v28">w_b</span></span> = (10, 10, 'z') | |
<span id="r132" v="v24">hmm</span>(<span title="closure"><span id="r133" v="v37">b_b</span></span>) | |
<span class="unused"><span id="v36" ssta="v28">w_b</span></span> = 2 | |
<span title="closure"><span id="v37">b_b</span></span> = 'atx' | |
<span id="r142" v="v8">test</span>(<span id="r144" v="v3">Ho</span>(3), 2)</pre></body></head> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment