Saturday, October 1, 2011

List manipulation at the command line.


>>> alist = ['one','two','three']
>>> alist
['one', 'two', 'three']
>>> alist.pop[2]
Traceback (most recent call last):
  File "", line 1, in
TypeError: 'builtin_function_or_method' object is not subscriptable
>>> alist
['one', 'two', 'three']
>>> alist.append('four')
>>> alist
['one', 'two', 'three', 'four']
>>> alist.pop([3])
Traceback (most recent call last):
  File "", line 1, in
TypeError: an integer is required
>>> alist.pop(3)
'four'
>>> alist
['one', 'two', 'three']
>>>

Friday, September 30, 2011

Code for work

This is a program I wrote for work. It will list attributes from selected parcels.

Thursday, September 1, 2011

My deed processor program.

I wrote a program to help me process deeds at work. I added #!/usr/bin/python to the code and I used chmod +x to make it executeable.

Friday, August 5, 2011

I did my first animation with pygame!

I used the nano text editor to write my first animation using pygame. I downloaded a png file from google images.

#!/usr/bin/python
import sys, pygame
pygame.init()
size = width, height = 600,600
black = 0,0,0
screen = pygame.display.set_mode(size)

tux = pygame.image.load("tux2.png")
x = 0y = 0

while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:sys.exit()

    screen.fill(black)
    screen.blit(tux,(200,200))
    screen.blit(tux,(x,y))

    pygame.display.flip()
    x = x+1
    y = y+1

Saturday, July 23, 2011

exec can execute code! Cool.

I learned how to start a python program from inside the python interpreter using exec, and I tried opening up more than one program at a time. It worked!

>>> f=open('Gridtest.py')
>>> exec f

This is going to be cool, because I can easily start other programs from inside python!

Wednesday, July 20, 2011

I love the bluefish editor for javascript!

I found a great linux editor for java script, and it is called bluefish. I love it, and I just found it a few minutes ago.

Saturday, July 16, 2011

I love Tkinters grid manager!

I wrote a simple GUI, and used the grid manager to arrange the widgets. I think I am going to like it better than Tkinter's pack.

from Tkinter import *
#I love Tkinter's grid manager! This is a simple example.
root = Tk()

def startVirus():
    print('Erasing hard drive now.')

Label(root, text="First").grid(row=0)
Label(root, text="Second").grid(row=1)

ent = Entry(root)
ent2 = Entry(root)

ent.grid(row=0, column=1)
ent2.grid(row=1, column=1)

btn = Button(root,text='Start the Virus',command=startVirus)
btn.grid(row=3, column=1)
root.mainloop()

Followers

Blog Archive

About Me

My photo
Biking helps me to cope with life.