sneekula 969 Nearly a Posting Maven

Microsoft vs. GM

At one of the more recent computer expos, Bill Gates reportedly compared the computer industry with the auto industry and stated, "If GM had kept up with technology like the computer industry has, we would all be driving twenty-five dollar cars that got 1000 mi/gal."

It took a while, but General Motors addressed this comment by releasing the statement, "Yes, but would you want your car to crash twice a day?"

sneekula 969 Nearly a Posting Maven

Q: "Why does the law society prohibit sex between lawyers and their clients?"
A: "To prevent clients from being billed twice for essentially the same service."

sneekula 969 Nearly a Posting Maven

It would seem strange if old friends lacked certain quirks.

sneekula 969 Nearly a Posting Maven

Very interesting indeed!

sneekula 969 Nearly a Posting Maven

A hole has appeared in the wall of the ladies changing room at the sports club.

Police are looking into it.

sneekula 969 Nearly a Posting Maven

A juicy pork steak with green beans.

sneekula 969 Nearly a Posting Maven

I thought CO2 was good for the growth of plants. We need more CO2 to encourage the growth of plants that are used for food and materials of construction. Again, Google is on the leading edge!

sneekula 969 Nearly a Posting Maven
sneekula 969 Nearly a Posting Maven

If you are just interested to extract the text of a PDF formatted page, then take a close look at:
http://code.activestate.com/recipes/511465/

sneekula 969 Nearly a Posting Maven

Coffee with a spot of eggnog, and some cranberry/walnut oatmeal cookies (extra soft variety for seniors). I am not a senior, but they do taste good. Besides, I got them as a gift from my grandma.

sneekula 969 Nearly a Posting Maven

You will have to add a few extra print statements to space it out:

import random

house =["Mansion", "Apartment", "Shack", "House"]
spouse =["EMPTY", "EMPTY", "EMPTY", "EMPTY"]
car =["EMPTY", "EMPTY", "EMPTY", "EMPTY"]
kids =["0", "1", "2", "5"]

print "Enter the name of three people you could marry: "
name1 = raw_input("Name1: ")
spouse[0]= name1
name2 = raw_input("Name2: ")
spouse[1]= name2
name5 = raw_input("Name3: ")
spouse[2]= name5

print
print "Enter the name of one person you wouldn't want to marry:"
name4 =raw_input("Name4: ")
spouse[3]= name4

print
print "Enter the name of 3 cars you want: "
car1 =raw_input("car1: ")
car[0]= car1
car2 = raw_input("car2: ")
car[1] = car2
car3=raw_input("car3: ")
car[2]=car3
print
print "Enter the name of one car you don't want: "
car4 =raw_input("car4: ")
car[3]=car4


#conclusion
print '-'*40  # prints 40 dashes across
print "You will live in a:", random.choice(house)
print "Married to:", random.choice(spouse)
print "While driving your:", random.choice(car) 
print "With your", random.choice(kids), "kids in it!"
sneekula 969 Nearly a Posting Maven

You may want to look at "Starting Python" right here:
http://www.daniweb.com/forums/thread20774.html

sneekula 969 Nearly a Posting Maven

You are almost there:

def isCMD(msgstrlist):
    for word in msgstrlist:
        if word[0].upper() == 'C':
            print word
        else:
            print "Not CMD message"

msgstrlist = ['Ox', 'Dog', 'Cow', 'mouse', 'cat']

isCMD(msgstrlist)

"""
my result -->
Not CMD message
Not CMD message
Cow
Not CMD message
cat
"""

Note:
Looks like you are using a mix of tabs and spaces for indentations in your code, very bad habit!

sneekula 969 Nearly a Posting Maven

It acts like container.catalog_object has been used as the variable name for a string somewhere in your code.

books = container.getBookTitleToCatalog()

for book in books:
    params=urlencode({'code':book.id})
    container.catalog_object(book, 
        '/APP_New/app-home/app-information/Publications/showBookDetails?%s'%params)
sneekula 969 Nearly a Posting Maven

You might get further if class Thing inherits class FuncObj.

sneekula 969 Nearly a Posting Maven

Here is an example how to use lambda to pass arguments in Tkinter's button command:

import Tkinter as tk

def getCond(par):
    firstCond = par
    #conditions.remove(firstCond)
    print firstCond
    #print conditions


root = tk.Tk()

firstCond = ''

condNames = ['1', '2', '3', '4',  '5', '6']
for item in condNames:
    # use lambda to pass arguments to command-function
    tk.Button(root, text=str(item), command=lambda i=item: getCond(i)).pack()

root.mainloop()

Also, create your function before you call it.

ABMorley commented: Perfect answer +0
sneekula 969 Nearly a Posting Maven

Also, Python30 should give you an error if you use the print statement instead of the print function.

Do you find pycurl easier to use than the usual cookielib and urllib2 modules that come with Python?

sneekula 969 Nearly a Posting Maven

re Q1:
In this case you want to make sure that guess will be an integer, even if the user enters a floating point number.

Actually with Python30 the int() becomes very important, since input() now returns a string.

re Q5:
This shows you the danger of using global. When you change x=2 in the function, than the x outside the function will also change.

sneekula 969 Nearly a Posting Maven

A building full of lawyers was held hostage. The bad guys threatened that, until all their demands were met, they would release one lawyer every hour.

sneekula 969 Nearly a Posting Maven

Didn't find my Chevy Malibu there.

sneekula 969 Nearly a Posting Maven

A hummingbird weighs less than a penny.

sneekula 969 Nearly a Posting Maven

Death is a very dull, dreary affair, and my advice to you is to have nothing whatever to do with it.
~~~ William Somerset Maugham's dry sense of humour

sneekula 969 Nearly a Posting Maven

Wow, she playes well!

sneekula 969 Nearly a Posting Maven

Fried chicken legs and home made bread.

sneekula 969 Nearly a Posting Maven

Just a simple pygame application to show you the basics:

# a simple pygame example
# creates a white circle on a black background
# the event loop makes exit from the program easier

import pygame

pygame.init()

# create a 300 x 300 display window
# the default background is black
win = pygame.display.set_mode((300, 300))

white = (255, 255, 255)
center = (100, 100)
radius = 20
pygame.draw.circle(win, white, center, radius)

# this puts the circle on the display window
pygame.display.flip()

# event loop and exit conditions (windows x click)
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            raise SystemExit
sneekula 969 Nearly a Posting Maven

If you want the window to stay open and allow for a graceful exit procedure, you need to set up a simple event loop at the end of the program:

# a simple pygame example
# creates a white circle on a black background
# the event loop makes exit from the program easier

import pygame

pygame.init()

# create a 300 x 300 display window
win = pygame.display.set_mode((300, 300))

white = (255, 255, 255)
center = (100, 100)
radius = 20
pygame.draw.circle(win, white, center, radius)

# this puts the circle on the display window
pygame.display.flip()

# event loop and exit conditions (windows x click)
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            raise SystemExit
sneekula 969 Nearly a Posting Maven

Re: Why does it make another file with the ending ".Pyc" at the end?

When you saved your class module as awclassPet.py, then Python will also create a compiled bytecode version of this file the first time it is used by an application. The precompiled file awclassPet.pyc will speed things up on reuse. Also notice that module file names are case sensitive.

The variable names you create in main() are local to the function, so you can use the same variable names you use in your class.

You can test your module out with this arrangement:

class Pet:
    def __init__(self,name, an_type, age):
        self.name =  name
        self.an_type = an_type
        self.age = age

    def set_name(self, name):
        self.name = name

    def set_an_type(self, an_type):
        self.an_type = an_type

    def set_age(self, age):
        self.age = age

    def get_name(self):
        return self.name

    def get_an_type(self):
        return self.an_type

    def get_age(self):
        return self.age


# allows you to test the module
# will not be used when the module is imported
if __name__ == '__main__':

    name = "Oscar"
    an_type = "cat"
    age = 13
    
    animals = Pet(name, an_type, age)

    print animals.get_name()
    print animals.get_an_type()
    print animals.get_age()
    print
    
    animals.set_name("Ruby")
    animals.set_an_type("cow")
    animals.set_age(17)
    
    print animals.get_name()
    print animals.get_an_type()
    print animals.get_age()

Tests okay!

I would suggest you write and run your code on an IDE made for Python code, something like IDLE or DrPython. Otherwise your output window will be set to the OS command window colors.

sneekula 969 Nearly a Posting Maven

Happiness -- over 65 and working because I want to not because I have to.

Age is an issue of mind over matter. If you don't mind, it doesn't matter.

sneekula 969 Nearly a Posting Maven

It's harder to read code than to write it.

sneekula 969 Nearly a Posting Maven

Stop smoking.

sneekula 969 Nearly a Posting Maven

You're just a tad bit late for 2009 :) Or are you working on 2010 already ?

Hehe, I am just a perpetual procrastinator. Good things take their time.

How long does New Year last anyway? Just a day or all year?

sneekula 969 Nearly a Posting Maven

Thanks AD, the moon has its lowest intensity on January 26, 2009.
One more reason to celebrate. Other than drinking copious amounts of that good Chinese beer, are there special festive customs?

sneekula 969 Nearly a Posting Maven

Thanks for the info on a Python3.0 tutorial.

sneekula 969 Nearly a Posting Maven

This simple code shows you the version of Python that is active on your computer:

# show the version of Python installed

import sys

print sys.version
print sys.version[ :3]
sneekula 969 Nearly a Posting Maven

The "Chinese New Year" starts some day after January 20th and before February 20th, when the moon is at its lowest intensity. Write a Python program to show the intensity of the moon in its monthly cycle for a given monthly period.

sneekula 969 Nearly a Posting Maven

A nice hot bowl of chili loaded with garlic, and a good California red wine.

sneekula 969 Nearly a Posting Maven

The road to success is always under construction.

sneekula 969 Nearly a Posting Maven

(牛 Ox 丑 Chou) should start on January 26, 2009
Not completely sure.

sneekula 969 Nearly a Posting Maven

Grapes explode if you heat them in the microwave.

Important, we need someone to verify this!

sneekula 969 Nearly a Posting Maven

Q: "How many college students does it take to screw in a light bulb?"
There is no answer, just another question:
"Will this be on the next test?"

sneekula 969 Nearly a Posting Maven

Happy New year!
I am prepared for an all-nighter!

sneekula 969 Nearly a Posting Maven

A Happy New Year even to the people we missed so far!

sneekula 969 Nearly a Posting Maven

I am happy if my old Chevy Malibu makes it to school without breaking down.

sneekula 969 Nearly a Posting Maven

There is "no beauty" in even simple C code! Let's all thank the Python development team for giving us a readable syntax. Come to think of it, they all were very fluent in C since the core of Python is writtten in C.

I guess the true beauty of C is somewhat hidden, it can do low level stuff more readable than assembly language.

sneekula 969 Nearly a Posting Maven

Yeah, I understand!
I wanted us to keep each other updated in case any module comes for python 3

Nice idea! Will keep checking it for the next year or so.

sneekula 969 Nearly a Posting Maven

ok so, just practising here sorry for useless console app but why not use {} to separate blocks.

number = 2
guess = 2

if number == guess:
print ('yep its identicle')

when i run that it says indentation error, but when i do

number = 2
guess = 2

if number == guess: {
print ('yep its identicle') }

is indentation the preferred and standard method when writing python code?

There are many code editors out there that cater to Python and do the proper indentation for you after you type a statement with a colon.

sneekula 969 Nearly a Posting Maven

If I would be a beginner, I would simply start with Python30 and Swaroop's online tutorial book. If you bump into old code and have compatibility problems ask, there are enough old timers here to help. Or you could always try the 2to3.py utility that comes with Python30.

Enjoy our learning experience, Python makes it easy! Well, at least when compared to other computer languages.

sneekula 969 Nearly a Posting Maven

A real sick place!

However, in my place someone attempted to karate kick (as seen in some movie) my front door in two days before xmas to steal my meager xmas presents. One way to get presents for your loved ones!

sneekula 969 Nearly a Posting Maven

The "Auto Dealers Association" has legislated themself one heck of a deal too. You can't buy a new car in the US without going through them.

sneekula 969 Nearly a Posting Maven

Never answer an anonymous letter.