Showing posts from January 31, 2010

photo beauties

Architecture beauties: Hyperboloid Towers (photos)Source Star Spangled Bikes.Cicada. Source perm url: Cicada Photo. Beautiful photography: Planetary Art. Silkroad Watchtower Ruin (photo)

A Complexity In URL Encoding

perm url with updates: Complexity In URL EncodingXah Lee, 2009-06-02, 2010-02-01[2010-02-03 addendum: this article is incorrect. Actually, it is simple to check if the url is a cgi script, by looking for “?”. If so, any “&” before the “?” should be “%26”, and after should be “&”]Discovered a subtle issue with automating url encoding. In url, if you have the ampersand “&” char, and if this url is to be inside a html doc as a link, then, there's no automated procedure that determines correctly whether the char should be encoded as “%26” or “&”. If the char is used as part of the file name or path, then it should be encoded as “%26”, but if it is used as a separator for CGI parameters, then it should be encoded as “&”. The ampersand char is a reserved char in Percent encoding. Therefore it must be percent encoded if it is used for normal file path names. So, when it is NOT used as part of path names, but used as…

Python's Reference And Internal Model Of Computing Languages

perm url with updates:'s Reference And Internal Model Of Computing LanguagesXah Lee, 2010-02-02In Python, there are 2 ways to clear a hash: “myHash = {}” and “myHash.clear()”. What is the difference?↓ The difference is that “myHash={}” simply creates a new empty hash and assigns to myHash, while “myHash.clear()” actually clear the hash the myHash is pointing to.What does that mean?? Here's a code that illustrates:# python # 2 ways to clear hash and their difference aa = {'a':3, 'b':4} bb = aa aa = {} print bb # prints {'a': 3, 'b': 4} aa = {'a':3, 'b':4} bb = aa aa.clear() print bb # prints {} This is like this because of the “reference” concept. The opposite alternative, is that everything is a copy, for example in most functional langs. (with respect to programer-visible behavior, not how it is implemented)From the aspect of the relation of the language source code to the prog…