User Profile

Collapse

Profile Sidebar

Collapse
leegao
leegao
Last Activity: Nov 15 '10, 12:35 AM
Joined: Mar 20 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • A common Javascript pattern is to directly insert elements into the DOM. To this effect, you will encounter many instances where an "improperly " coded script element (as in without using CDATA, a rare habit and one that I'm completely against) will cause the parser to grind to a screeching halt. The fix is simple, apply the following filter to your source string:

    Code:
    import re
    re_script = re.compile("<script.*?>((?:.|\s)+?)</script>")
    ...
    See more | Go to post

    Leave a comment:


  • leegao
    replied to Sudoku in python
    I'm not quite sure if you still need this still, but the basic gist would be something like

    Code:
    if __name__ == "__main__":
        grid = []
        from random import randint
        
        SIZE = 9
        MINI = 3
        
        HARD = int(float(SIZE)*1.5)
        MEDIUM = SIZE*2+2
        EASY = SIZE*3
        
        for i in range(SIZE):
            _grid = []
    ...
    See more | Go to post

    Leave a comment:


  • leegao
    replied to Getting a string from a list in a list
    One way of doing this is to convert the 2d list into a dictionary via {}.update()
    Code:
    players_dict = {}
    players_dict.update(players)
    if username in players_dict: 
        if password == players_dict[username]:
            print "Welcome back,",username+"!"

    Another (shorter, but messier) way:
    Code:
    lst = zip(*players)[0]
    if username in lst:
        print "Welcome
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...