Look down and up there.
Tuesday, May 1, 2012
[Python] Unofficial Windows Binaries for Python Extension Packages
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pymedia
Monday, April 23, 2012
Wednesday, February 8, 2012
Vizard: add nodes.
There are some nodes we'd better remember.
<viz>.addRenderNode
<viz>.addRenderTexture
<viz>.addBlankTexture
<viz>.addTexture
<viz>.addTextureFromBuffer
<viz>.addVideo
<viz>.addAudio
<viz>.addGroup
<viz>.objectGroup
Display background texture
http://kb.worldviz.com/articles/813
Tuesday, January 10, 2012
Shader: Water-Fire-Sky
http://www.bonzaisoftware.com/
This application demonstrates the realistic rendering of clean and foggy water, Fire and Sky. A tutorial about the water effect is included. It also features y-axis billboarding and simple collision detection/response.
You need a graphics card supporting Vertex & Fragment programs to see all of the effects.
This application demonstrates the realistic rendering of clean and foggy water, Fire and Sky. A tutorial about the water effect is included. It also features y-axis billboarding and simple collision detection/response.
You need a graphics card supporting Vertex & Fragment programs to see all of the effects.
Wednesday, September 14, 2011
python: pitfalls
http://zephyrfalcon.org/labs/python_pitfalls.html
This one bites beginners over and over again. It's really a variant of #2, combined with unexpected behavior of default arguments. Consider this function:
This was expected. But now:
Maybe you expected that the output would be [666] in all cases... after all, when popo() is called without arguments, it takes [] as the default argument for x, right? Wrong. The default argument is bound *once*, when the function is *created*, not when it's called. (In other words, for a function
Solution: This behavior can occasionally be useful. In general, just watch out for unwanted side effects.
5. Mutable default arguments
This one bites beginners over and over again. It's really a variant of #2, combined with unexpected behavior of default arguments. Consider this function:
>>> def popo(x=[]): ... x.append(666) ... print x ... >>> popo([1, 2, 3]) [1, 2, 3, 666] >>> x = [1, 2] >>> popo(x) [1, 2, 666] >>> x [1, 2, 666]
This was expected. But now:
>>> popo() [666] >>> popo() [666, 666] >>> popo() [666, 666, 666]
Maybe you expected that the output would be [666] in all cases... after all, when popo() is called without arguments, it takes [] as the default argument for x, right? Wrong. The default argument is bound *once*, when the function is *created*, not when it's called. (In other words, for a function
f(x=[]), x is *not* bound whenever the function is called. x got bound to [] when we defined f, and that's it.) So if it's a mutable object, and it has changed, then the next function call will take this same list (which has different contents now) as its default argument.Solution: This behavior can occasionally be useful. In general, just watch out for unwanted side effects.
Tuesday, September 13, 2011
Monday, September 12, 2011
prog: namespace
http://www.freenetpages.co.uk/hp/alan.gauld/tutname.htm
What is namespace?
The concept is pretty straightforward, a namespace is a space or region, within a program, where a name (variable, class etc) is valid.
We actually use this idea in everyday life. Suppose you work in a big company and there is a colleague called Joe. In the accounts department there is another guy called Joe who you see occasionally but not often. In that case you refer to your colleague as "Joe" and the other one as "Joe in Accounts". You also have a colleague called Susan and there is another Susan in Engineering with whom you work closely. When referring to them you might say "Our Susan" or "Susan from Engineering". Do you see how you use the department name as a qualifier? That's what namespaces do in a program, they tell both programmers and the translator which of several identical names is being referred to.
What is namespace?
The concept is pretty straightforward, a namespace is a space or region, within a program, where a name (variable, class etc) is valid.
We actually use this idea in everyday life. Suppose you work in a big company and there is a colleague called Joe. In the accounts department there is another guy called Joe who you see occasionally but not often. In that case you refer to your colleague as "Joe" and the other one as "Joe in Accounts". You also have a colleague called Susan and there is another Susan in Engineering with whom you work closely. When referring to them you might say "Our Susan" or "Susan from Engineering". Do you see how you use the department name as a qualifier? That's what namespaces do in a program, they tell both programmers and the translator which of several identical names is being referred to.
##### module first.py ######### spam = 42 def print42(): print spam ###############################
##### module second.py ######## from first import * # import all names from first spam = 101 # create spam variable, hiding first's version print42() # what gets printed? 42 or 101? ################################If you thought it would print 101 then you were wrong. A name is simply a label used to reference an object. Now in the first module the name print42 refers to the function object defined in the module. So although we imported the name into our module we did not actually import the function which still refers to its own version of spam. Thus when we created our new spam variable it has no effect on the function referred to by print42.
Subscribe to:
Posts (Atom)