[Tutor] good django book?

2014-02-06 Thread Christopher Spears
Can anyone recommend a good Django book? I have been looking on Amazon, and the books seem to be out of date. Thanks, Chris ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/

[Tutor] creating a pie chart in Python

2011-12-07 Thread Christopher Spears
I need to create a pie chart that is referenced by a wiki page.  I am impressed with matplotlib.  Any other good libraries out there? I do need to be able to save the chart as an image file, so it can be linked to the wiki.  My only complaint about matplotlib is that I have not figured out a wa

[Tutor] floats

2010-12-03 Thread Christopher Spears
I have a float variable that is very long. >>> float_a = 1.16667 However, I want to pass the value of float_a to float_b, but I want the float to be accurate to two decimal points. >>> float_a = 1.16667 >>> print "%.2f" % float_a 1.17 I tried the following: >>> float_b = "%.2f" % float_a >>>

[Tutor] trouble with dates and python and databases

2010-03-11 Thread Christopher Spears
I'm trying to write a script that calculates the rate of disk usage. I think the best way to accomplish this task is to write a script that will monitor a server's capacity and how much space is being used on a daily basis and store the information in a SQLite database. Then the program can re

[Tutor] parsing Spreadsheet document

2009-12-09 Thread Christopher Spears
I want to fill a database with the contents of a spreadsheet. The spreadsheet was created by OpenOffice and is a .sxc document. What is the best way to do this? I think the best approach is to save the spreadsheet as a .csv document and then just parse the file. Am I on the right track here?

Re: [Tutor] parsing XML into a python dictionary

2009-11-14 Thread Christopher Spears
erything under the "comic" tag. --- On Sat, 11/14/09, Kent Johnson wrote: > From: Kent Johnson > Subject: Re: [Tutor] parsing XML into a python dictionary > To: "Christopher Spears" > Cc: tutor@python.org > Date: Saturday, November 14, 2009, 5:03 AM &

[Tutor] parsing XML into a python dictionary

2009-11-13 Thread Christopher Spears
I've been working on a way to parse an XML document and convert it into a python dictionary. I want to maintain the hierarchy of the XML. Here is the sample XML I have been working on: Neil Gaiman Glyn Dillon Charles Vess This is my first stab at this: #!/usr/bin/env pyth

[Tutor] moving directories into directories

2009-11-11 Thread Christopher Spears
I'm trying to move a bunch of files and directories into another directory. Unfortunately, I keep getting an error message: Traceback (most recent call last): File "checkDeviceType.py", line 46, in ? cdt.moveFiles(barcodeList) File "checkDeviceType.py", line 40, in moveFiles shutil.m

[Tutor] parsing XML

2009-11-09 Thread Christopher Spears
Hi! I need to parse several XML documents into a Python dictionary. Is there a module that would be particularly good for this? I heard beginners should start with ElementTree. However, SAX seems to make a little more sense to me. Any suggestions? __

[Tutor] PyQT forum?

2009-10-28 Thread Christopher Spears
I'm starting to learn PyQt. Can anyone recommend a good mailing list or forum? Thanks. "I'm the last person to pretend that I'm a radio. I'd rather go out and be a color television set." -David Bowie "Who dares wins" -British military motto "There is no such thing as luck; there is only adeq

[Tutor] Where is www.wxpython.org?

2009-06-08 Thread Christopher Spears
Hey, I am trying to get to www.wxpython.org, but my connection keeps timing out. Is the site down? I just want to download wxPython for Python 2.6 (Windows Vista 32 bit). Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailm

[Tutor] renumbering a sequence

2009-04-04 Thread Christopher Spears
I want to write a script that takes a list of images and renumbers them with a user supplied number. Here is a solution I came up while noodling around in the interpreter: >>> alist = ["frame.0001.tif","frame.0002.tif","frame.0003.tif"] >>> new_start = 5000 >>> for x in alist: ... name, nu

[Tutor] noise function

2008-12-01 Thread Christopher Spears
Hi! Does anyone know if python has a noise function? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] using rect.inflate()

2008-11-05 Thread Christopher Spears
I'm modifying a game for an assignment in "Game Programming" by Andy Harris. I'm not reading this book as part of a class. Basically, I turned one of the example games into an Asteroid rip off. However, I didn't like the collisions between the spaceship and the asteroids, so I decided to shri

[Tutor] accessing an image with pygame.image.load()

2008-11-03 Thread Christopher Spears
I want to access a spaceship image with pygame.image.load(), so I wrote self.image = pygame.image.load("C:Users\Chris\Documents\python\assignment07\chris_graphics\spaceship.gif") However, I got this error message: error: Couldn't open C:Users\Chris\Documents\python\assignment07\chris_graphics

[Tutor] inheriting from a class

2008-09-25 Thread Christopher Spears
I'm working out of "Game Programming (The L Line)" by Andy Harris. He writes subclasses like so: class TransCircle(collisionObjects.Circle): def __init__(self): collisionObjects.Circle.__init__(self) self.image.set_colorkey((255, 255, 255)) Basically, he is creating a TransC

[Tutor] renumbering a sequence

2008-08-26 Thread Christopher Spears
I'm trying to write a script that will renumber items in a list. Here is the list: unordered_list = ["frame.0029.dpx", "frame.0028.dpx", "frame.0025.dpx", "frame.0026.dpx", "frame.0027.dpx", "frame.0017.dpx", "frame.0019.dpx", "frame.0023.dpx", "frame.0018.dpx",

Re: [Tutor] ecommerce.py

2008-08-12 Thread Christopher Spears
reak else: print "Invalid Choice!" print "Try Again!" --- On Tue, 8/12/08, Kent Johnson <[EMAIL PROTECTED]> wrote: > From: Kent Johnson <[EMAIL PROTECTED]> > Subject: Re: [Tutor] ecommerce.py > To: [EMAIL PROTECTED] >

[Tutor] ecommerce.py

2008-08-11 Thread Christopher Spears
I am working on problem 13-11 from Core Python Programming (2nd Edition). For the problem, I am supposed to create the foundations of an e-commerce engine for a B2C business-to-consumer) retailer. I need to create a class that represents the customer called User, a class for items in inventory

Re: [Tutor] date formatter

2008-08-07 Thread Christopher Spears
Ok, here is the working version of my program. Thanks for all of the advice: #!/usr/bin/python import time class date_format(object): def __init__(self, month, day, year): month_dict = {("jan","january") : 1, ("feb","february") :2,

[Tutor] date formatter

2008-08-06 Thread Christopher Spears
Hey, I'm working on a problem out of Core Python Programming (2nd Edition). Basically, I'm creating a class that formats dates. Here is what I have so far: #!/usr/bin/python import time class date_format(object): def __init__(self, month, day, year): month_dict = {("j

Re: [Tutor] adding a watermark to a sequence of images

2008-07-21 Thread Christopher Spears
> To: [EMAIL PROTECTED], tutor@python.org > Date: Monday, July 21, 2008, 1:30 PM > On Sun, 20 Jul 2008, Christopher Spears wrote: > > > Has anyone used Python to watermark of sequence of > images? > > There's a recipe for watermarking using PIL here: > > http://a

[Tutor] adding a watermark to a sequence of images

2008-07-20 Thread Christopher Spears
Has anyone used Python to watermark of sequence of images? Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] creating pop method for stack class

2008-07-17 Thread Christopher Spears
> > First, a tip: > > Instead of lista[:len(lista)-1], you can (and should) just > write lista[:-1]. > > Now, what if we wrap that in a function: > > >>> def shorten(lst): > ... lst = lst[:-1] # identical to: lst = > lst[:len(lst)-1] > ... > > Then test it: > > >>> lista = [1, 2, 3, 4] >

[Tutor] creating pop method for stack class

2008-07-17 Thread Christopher Spears
I am almost done with a stack class that I wrote: #!/usr/bin/python class Stack(list): def isempty(self): length = len(self) if length == 0: return True else: return False def peek(self): length = len(self) if le

[Tutor] stack class

2008-07-11 Thread Christopher Spears
For another Core Python Programming question, I created a stack class. I then put the class into a script to test it: #!/usr/bin/python class Stack(list): def isempty(self): length = len(self) if length == 0: return True else: return False

[Tutor] line class

2008-07-08 Thread Christopher Spears
I have been reading everyone's comments on my line class. I have decided to implement some of the suggestions. Someone suggested that I create a Point.__cmp__ method. Here is what I have so far: def __cmp__(self, other): if self.x == other.x and self.y == other.y: return 0

[Tutor] line class

2008-07-07 Thread Christopher Spears
For problem 13-6 out of Core Python Programming, I created a line class that consists of two points. The line class has the following methods: __repr__, length, and slope. Here is the code: #!/usr/bin/python import sys,math class Point(object): def __init__(self, x=0.0,y=0.0): se

[Tutor] TypeError: not enough arguments for format string

2008-07-01 Thread Christopher Spears
I'm working on problem 13-5 in Core Python Programming (2nd Edition). I am supposed to create point class. Here is what I have so far: #!/usr/bin/python class Point(object): def __init__(self, x=0.0,y=0.0): self.x = float(x) self.y = float(y) def __repr__(self)

[Tutor] dollarize.py

2008-06-20 Thread Christopher Spears
I'm working on an exercise from Core Python Programming. I need to create a function that takes a float value and returns the value as string rounded to obtain a financial amount. Basically, the function does this: dollarize(1234567.8901) returns-> $1,234,567,89 The function should allow for

[Tutor] a question about iterators

2008-06-16 Thread Christopher Spears
I've been learning about how to implement an iterator in a class from Core Python Programming (2nd Edition). >>> class AnyIter(object): ... def __init__(self, data, safe=False): ... self.safe = safe ... self.iter = iter(data) ... ... def __iter__(self): ... return self

[Tutor] text editor for Windows?

2008-06-11 Thread Christopher Spears
I just got Python installed on my Dell laptop running Windows Vista Business. Can someone recommend a good text editor to use for Python programming? Some people seem to like PythonWin. In the past I have use ConText. Thanks! ___ Tutor mail

[Tutor] error message with multiple inheritance

2008-06-10 Thread Christopher Spears
I've been working out of Core Python Programming (2nd Edition). Here is an example demonstrating multiple inheritance. >>> class A(object): ... pass ... >>> class B(A): ... pass ... >>> class C(B): ... pass ... >>> class D(A, B): ... pass ... Traceback (most recent call last):

[Tutor] static methods and class methods

2008-06-10 Thread Christopher Spears
I am reading Wesley Chun's "Core Python Programming" (2nd Edition) and have reached the part on static and class methods. I typed in the following to demonstrate the difference between the two methods: >>> class TestClassMethod: ... def foo(cls): ... print 'calling class method fo

[Tutor] most efficient way to do this

2008-02-14 Thread Christopher Spears
I created a file called arrays.py: #!/usr/bin/python locations = ["/home/", "/office/" , "/basement/" , "/attic/"] Now I want to add the word "chris" on to each element of the locations list, so I wrote another script called chris_arrays.py: #!/usr/bin/python/ from arrays import locations add

[Tutor] matching a street address with regular expressions

2007-10-03 Thread Christopher Spears
One of the exercises in Core Python Programming is to create a regular expression that will match a street address. Here is one of my attempts. >>> street = "1180 Bordeaux Drive" >>> patt = "\d+ \w+" >>> import re >>> m = re.match(patt, street) >>> if m is not None: m.group() ... '1180 Bordeaux'

Re: [Tutor] creating the equivalent of string.strip()

2007-10-03 Thread Christopher Spears
I know people might be sick of this thread by now, but I decided to post a solution to this problem that uses regular expressions. #!/usr/bin/env python import string import re def my_strip(s): remove_leading = re.sub(r'^\s+','',s) remove_trailing = re.sub(r'\s+$','',remove_leading)

Re: [Tutor] creating the equivalent of string.strip()

2007-10-01 Thread Christopher Spears
I was looking for the source code for the strip functions at python.org. I didn't find anything. Do you or someone else know where the source code is posted? I tried to find python on my workstation, but I'm not sure where the sys admin installed it. _

[Tutor] creating the equivalent of string.strip()

2007-09-28 Thread Christopher Spears
I'm working out of chapter 6 of Core Python Programming (2nd Edition). For one problem, I am supposed to write a script that is the equivalent of string.strip(). Obviously, using any version of string.strip() defeats the purpose of the exercise. I'm not sure how to proceed. My biggest stumbling

[Tutor] detecing palindromic strings

2007-09-28 Thread Christopher Spears
I'm trying to write a script that detects if a string is palindromic (same backward as it is forward). This is what I have so far: #!/usr/bin/env python my_str = raw_input("Enter a string: ") string_list = [] for s in my_str: string_list.append(s) string_list_orig = string_list strin

[Tutor] case insensitivity

2007-09-27 Thread Christopher Spears
I wrote a script that checks if two strings match. The script ignores case. #!/usr/bin/env python string_a = raw_input("Enter a string: ") string_b = raw_input("Enter another string: ") if cmp(string_a.lower(), string_b.lower()) == 0: print "The strings match!" else: print "The strings

[Tutor] home_finance.py

2007-09-25 Thread Christopher Spears
I'm working on a problem in Chapter 5 of Core Python Programming(2nd Edition). I am supposed to write a script that take an opening balance and a monthly payment from the user. The script then displays the balance and payments like so: Enter opening balance: 100 Enter monthly payment: 16.13

[Tutor] largest and smallest numbers

2007-09-24 Thread Christopher Spears
One of the exercises from Core Python Programmng (2nd Edition) asks me to determine the largest and smallest integers, float, and complex numbers my system can handle. Using python.org and Google, I have discovered my system's largest and smallest ingtegers: >>> import sys >>> sys.maxint 21474836

[Tutor] sales tax

2007-09-18 Thread Christopher Spears
I wrote a script that takes a price and a sales tax and calculates the new price. #!/usr/bin/env python def calculate_price(price, percent_tax): sales_tax = price * percent_tax new_price = price + sales_tax return new_price price = float(raw_input("Enter a price: ")) percent_tax = fl

[Tutor] catching errors in calculator script

2007-09-17 Thread Christopher Spears
I wrote a simple calculator script: #!/usr/bin/python env def calculator(n1, operator, n2): f1 = float(n1) f2 = float(n2) if operator == '+': return f1 + f2 elif operator == '-': return f1 - f2 elif operator == '*': return f1 * f2 elif operator == '

[Tutor] editTextFile.py

2007-09-12 Thread Christopher Spears
I created a script that opens an existing text file, allows the user to write over the original contents, and then save the file. The original contents are then saved in a separate file. Here is the script: #!/usr/bin/python 'editTextFile.py -- write over contents of existing text file' import

[Tutor] replacing while loop

2007-09-07 Thread Christopher Spears
I've been reading 'Core Python Programming (2nd Edition)'. I have been given the following script: #!/usr/bin/env python 'makeTextFile.py -- create text file' import os # get filename while True: fname = raw_input('Enter file name: ') if os.path.exists(fname): print"*** ERROR:

[Tutor] rewriting script

2007-09-07 Thread Christopher Spears
I have written a script that reads and displays text files: #!/usr/bin/env python 'readTextFile.py -- read and display text file' import os # get filename while True: fname = raw_input('Enter file name: ') print if os.path.exists(fname): fobj = open(fname, 'r') for e

[Tutor] manually sorting variables

2007-09-06 Thread Christopher Spears
I'm working out of Core Python Programming (2nd Edition) by Wesley Chun. Here is the problem: Have the user enter three numeric values and store them in three different variables. Without using lists or sorting algorithms, manually sort these three numbers from smallest to largest. Here is what

[Tutor] or

2007-03-29 Thread Christopher Spears
I was doodling at the interpreter: >>> fruit = ["apples","pears","oranges"] >>> for f in fruit: ... if f != "apples": ... print f ... print "This is not an apple." ... pears This is not an apple. oranges This is not an apple. What I can't remember is what is 'or' in py

[Tutor] summer_v04.py

2007-02-20 Thread Christopher Spears
I've been working on a version of a script I found in "Programming Python". The helpful users of this forum gave me some advice to make the code less wordy. Here is the code: #!/usr/bin/python import string def find_longest_line(fileName): line_list = [line.split() for line in open(file

[Tutor] critique my script: add columns in a file

2007-02-13 Thread Christopher Spears
I created a file called table.txt. Here is the file's contents: 1 5 10 2 1.0 2 10 20 4 2.0 3 3 15 30 8 3 2 1 4 20 40 16 4.0 I modified a script I found in "Programming Python" and created scri

[Tutor] adding columns of numbers

2007-02-01 Thread Christopher Spears
I've been reading an old copy of "Programming Python" and started to work on one of its challenges. I have a text file called table.txt: 1 5 10 2 1.0 2 10 20 4 2.0 3 3 15 30 8 3 2 1 4 20 40 16

[Tutor] more fun and games with padded numbers

2007-01-11 Thread Christopher Spears
Let's say I have a series of files that are named like so: 0001.ext 0230.ext 0041.ext 0050.ext How would I convert these from a padding of 4 to a padding of 1? In other words, I want the files to be renamed as: 1.ext 230.ext 41.ext 50.ext At first I used strip(), which was a mistake because it

[Tutor] removing padded numbers

2007-01-10 Thread Christopher Spears
Does anyone how to remove padded numbers with python? I want to be able to take a file like afile.0001.cin and convert it to afile.1.cin I've been checking the docs but nothing jumps out at me. Thanks! ___ Tutor maillist - Tutor@python.org http:

[Tutor] rename files

2007-01-10 Thread Christopher Spears
I'm trying to write a script that will rename files. The files are in this format: replace_dashes_stuff03 I want to rename the files to replace.dashes.STF.v03 Here is what I have so far: #!/usr/bin/python import os,sys oldFile = sys.argv[1] if oldFile.find('_') != -1: print "Found

Re: [Tutor] foreach loops

2006-09-11 Thread Christopher Spears
Hmmm...Perl is probably a bad example. My apologies. I was thinking more along the lines of this: A C++ for loop: #include using std::cout; int main() { for (int i = 0; i < 10; i++) { cout << i << "\n"; } return 0; } __

[Tutor] foreach loops

2006-09-11 Thread Christopher Spears
Does python have foreach loops? I don't see any mention of them in the docs. Am I going to have to use Perl (gasp!) if I want my beloved foreach loop? -Chris ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] more rps

2006-08-14 Thread Christopher Spears
Here is the latest version of my Rock, Paper, Scissors game: #!/usr/bin/python import random random.seed() class Human: def __init__(self): self.points = 0 self.choice = " " def plays(self): fromUser = raw_input("Pi

Re: [Tutor] rock, paper, scissors

2006-08-11 Thread Christopher Spears
--- Tom Wilson <[EMAIL PROTECTED]> wrote: > hi, > > could you please explain to me how your rock paper > scissors game script > works because i am a bit confused. > > thanks > tom > > The game does not work in its current form, which may be some cause for confusion. :-) In designing the pr

[Tutor] Rock, Paper, Scissors

2006-08-10 Thread Christopher Spears
Here is my Rock,Paper,Scissors script: #!/usr/bin/python import random random.seed() class Human: def __init__(self): self.points = 0 self.choice = " " def plays(self): self.choice = raw_input("Pick (R)ock, (P)aper,

[Tutor] Rock, Paper, Scissors

2006-08-07 Thread Christopher Spears
I have been looking for a new project to tackle when I came across this link: http://www.ibiblio.org/obp/pyBiblio/practice/wilson/rockpaperscissors.php. Here is some sample output that was provided at the webpage: Welcome to Rock, Paper, Scissors! How many points are required for a win? 3 Choos

[Tutor] critique my script again!

2006-08-03 Thread Christopher Spears
Here is the complete script with documentation: #!/usr/bin/python #This script prompts the user for a path and a glob pattern. #The script firsts looks in the directory denoted by the path #for a matching file. If a match is found, the path and file are added #to a dictionary as a key and value.

Re: [Tutor] critique my script!

2006-08-03 Thread Christopher Spears
I rewrote my code with Alan's suggestions in mind. #!/usr/bin/python import os, os.path, glob def glob_files(pattern, base_path = '.'): abs_base = os.path.abspath(base_path) #path_list = [] #path_list.append(abs_base) globbed_dict = {} cwd = os.getcwd()

Re: [Tutor] critique my script!

2006-08-03 Thread Christopher Spears
I didn't know I could place the glob in the os.walk traversal. Could you give me an example of how to do this? --- Alan Gauld <[EMAIL PROTECTED]> wrote: > >I created a function that takes a pattern and a > base > > path and then uses os.walk and glob to traverse > > directories starting from the

[Tutor] critique my script!

2006-08-02 Thread Christopher Spears
I created a function that takes a pattern and a base path and then uses os.walk and glob to traverse directories starting from the base path and place files that match the glob pattern in a dictionary. #!/usr/bin/python import os, os.path, glob def glob_files(pattern, base = '.'): path_l

[Tutor] os.walk()

2006-08-02 Thread Christopher Spears
I'm creating a function that traverses a directory tree and prints out paths to files: #!/usr/bin/python import os, os.path, glob def traverse(base = '.'): for root,dirs,files in os.walk(base): for name in files: path = os.path.join(root, name)

[Tutor] When am I ever going to use this?

2006-08-01 Thread Christopher Spears
I've been working through a tutorial: http://www.ibiblio.org/obp/thinkCSpy/index.htm. Lately, I have been learning about abstract data types (linked lists, stacks, queues, trees, etc.). While I do enjoy the challenge of creating these objects, I am not sure what they are used for. __

[Tutor] syntax error

2006-07-31 Thread Christopher Spears
My brain has gone squishy. I am combining a linked list with a priority queue. This is the last exercise out of How To Think Like A Computer Scientist (Chapter 19). class Node: def __init__(self, cargo=None, next=None): self.cargo = cargo self.next = next

Re: [Tutor] remove function

2006-07-26 Thread Christopher Spears
ems[maxi:maxi+1] = [] return item --- Luke Paireepinart <[EMAIL PROTECTED]> wrote: > Christopher Spears wrote: > > Here is a class called PriorityQueue: > > > > class PriorityQueue: > > def __init

[Tutor] remove function

2006-07-26 Thread Christopher Spears
Here is a class called PriorityQueue: class PriorityQueue: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def insert(self, item): self.items.append(item)

[Tutor] confused by linked queue

2006-07-24 Thread Christopher Spears
After reading John's reply, I think I get it now: >>> from linked_queue import * >>> queue = Queue() >>> queue.isEmpty() True >>> queue.insert("cargo") >>> queue.length 1 >>> queue.insert("more cargo") >>> queue.length 2 >>> print queue.head cargo >>> print queue.head.next more cargo >>> queue.ins

[Tutor] confused by linked queue

2006-07-24 Thread Christopher Spears
I am working out of How To Think Like A Computer Scientist. I am on the chapter that covers linked queues. Here is some code that creates a linked queue class: class Queue: def __init__(self): self.length = 0 self.head = None def isEmpty(self):

[Tutor] lists and recursion

2006-07-21 Thread Christopher Spears
I am working out of How To Think Like A Computer Scientist. Here is the code for a module called node.py: def printList(node): nodeList = [] while node: nodeList.append(node.cargo) node = node.next pri

[Tutor] removing a card

2006-07-19 Thread Christopher Spears
Chapter 15 of How to Think Like a Computer Scientist teaches you how to deal with sets of objects by creating a deck of cards. The tutorial can be found here: http://www.ibiblio.org/obp/thinkCSpy/chap15.htm. Here is my code so far in card.py: class Card: suitList = ["Clubs", "Diamonds",

[Tutor] no loops

2006-07-11 Thread Christopher Spears
I am working on another problem from "How To Think Like A Computer Scientist". Here is a function: def increment(time, seconds): time.seconds = time.seconds + seconds while time.seconds >= 60: time.seconds = time.seconds - 60 time.minutes = time.minutes + 1 while time.minutes >= 6

[Tutor] printing 00

2006-07-10 Thread Christopher Spears
I'm working on a problem from "How To Think Like A Computer Scientist". I created a Time class: class Time: def __init__(self, hours, minutes, seconds): self.hours = hours self.minutes = minutes self.seconds = seconds I created a

[Tutor] critique my script!

2006-06-23 Thread Christopher Spears
I wrote a script that creates a gui using pygtk. The gui consists of a vertical scrollbar and two buttons. The user picks a number (degrees Fahrenheit) with the scrollbar and then clicks the convert button. A functions converts the number to its equivalent in degrees Celsius and prints a respons

[Tutor] help with GUI

2006-06-21 Thread Christopher Spears
I am trying to write a GUI that consists of a scrollbar and two buttons. One button is called Convert, and the other is called Quit. The vertical scrollbar represents degrees Fahrenheit starting from 212 at the top and ending at 32 at the bottom. I want to be able to pick degrees Fahrenheit with

Re: [Tutor] critique my script!

2006-06-20 Thread Christopher Spears
I made the changes that Danny suggested to my script: #!/usr/bin/python import os, pygtk pygtk.require('2.0') import gtk class View: def delete_event(self, widget, event, data=None): gtk.main_quit() return False def button

[Tutor] critique my script!

2006-06-20 Thread Christopher Spears
Here is a little gui I created: #!/usr/bin/python import os, pygtk pygtk.require('2.0') import gtk class GetCwd: def getcwd(self, widget, data=None): print os.getcwd() def delete_event(self, widget, event, data=None): gtk.main_qu

Re: [Tutor] lambda and creating GUIs

2006-06-16 Thread Christopher Spears
I understand this: > > def f(w): gtk.main_quit() > button.connect("clicked", f) > > lambda simply saves cluttering up the code with lots > of tiny function > derfinitions which are never referred to apart from > in the binding > operation. > Now my question is what is "w"? What is being passe

[Tutor] lambda and creating GUIs

2006-06-15 Thread Christopher Spears
I have been reading though the PyGTK tutorial. Can anyone explain how lambda is being used in this statement: button.connect("clicked", lambda w: gtk.main_quit()) This code might put the statement in context: # Create "Quit" button 66 button = gtk.Button("Quit") 67 68

[Tutor] problems using PyGTK on cygwin

2006-06-09 Thread Christopher Spears
I have been trying to work throught the PyGTK tutorial using cygwin, but I have been having problems. For example when I try to launch the helloworld.py program (http://www.pygtk.org/pygtk2tutorial/ch-GettingStarted.html#sec-HelloWorld), I get this: $ python helloworld.py No fonts found; this pr

[Tutor] What is a widget?

2006-06-08 Thread Christopher Spears
I'm a bit embarassed to ask this...I am looking at a tutorial for PyGTK+ that is discussing widgets. What are widgets? -Chris ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] PyGTK on cygwin

2006-06-08 Thread Christopher Spears
Does PyGTK work well on cygwin? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] _next

2006-05-24 Thread Christopher Spears
How does this script work? #!/usr/bin/python class IteratorExample: def __init__(self, s): self.s = s self.next = self._next().next self.exhausted = 0 def _next(self): if not self.exhausted: flag = 0 for x in self.s:

[Tutor] class Writer

2006-05-24 Thread Christopher Spears
I've been working my way through an online tutorial and came across the following sample script: import sys class Writer: def __init__(self, filename): self.filename = filename def write(self, msg): f = file(self.filename, 'a') f.write(msg) f.close() sys.s

[Tutor] using cmd

2006-03-17 Thread Christopher Spears
I just completed an assignment out of Learning Python in which I used the Cmd class from the cmd module to create a little shell: import cmd, os, shutil, sys class shell(cmd.Cmd): def do_EOF(self, line): sys.exit() def do_ls(self, line): if line == '': dirs = [os.

[Tutor] walking down directories

2006-03-17 Thread Christopher Spears
I am trying to write a function that takes a directory's name, finds any subdirectories, and then prints out the size of the files in all found directories. import os, os.path def describeDirectory(directory): dirList = [directory] for d in os.listdir(directory): if os.path.isdir(

[Tutor] OSError

2006-03-14 Thread Christopher Spears
I am trying to write a function that takes a directory name and describes the contents of the directory (file name and size) recursively. Here is what I have written so far: import os, os.path def describeDirectory(directory): if os.listdir(directory) == []: print "Empty directory!"

[Tutor] How does this work?

2006-03-13 Thread Christopher Spears
Out of Learning Python, I was given this text: This is a paragraph that mentions bell peppers multiple times. For one, here is a red pepper and dried tomato salad recipe. I don't like to use green peppers in my salads as much because they have a harsher flavor. This second paragraph mentions red

[Tutor] how does this list comprehension work?

2006-03-08 Thread Christopher Spears
I copied this program from Learning Python and got it to work on Windows XP: import sys, glob print sys.argv[1:] sys.argv = [item for arg in sys.argv for item in glob.glob(arg)] print sys.argv[1:] What the program does is first print the glob and then a list of everything caught by the glob. For

Re: [Tutor] Why None?

2006-02-07 Thread Christopher Spears
I get it! Have printFood return a string! def printFood(self): return self.food.foodName Now I don't get the weird output anymore! -Chris --- Danny Yoo <[EMAIL PROTECTED]> wrote: > > Hi Chris, > > I'm going to be a little insidous and bring some > ideas from the textbook > "

[Tutor] Why None?

2006-02-07 Thread Christopher Spears
Here is some code I wrote: class Food: def __init__(self, name): Food.foodName = name class Customer: def __init__(self,name): Customer.name = name Customer.food = 0 def placeOrder(self, foodName, employee): p

[Tutor] lunch.py

2006-02-07 Thread Christopher Spears
I'm working on a program where a Customer orders Food from an Employee. Here is what I have so far: class Food: def __init__(self, name): Food.foodName = name class Customer: def __init__(self,name): Customer.name = name def placeOrder(self

[Tutor] subclass

2006-02-03 Thread Christopher Spears
Here is a problem I'm working on out of Learning Python: Make a subclass of MyList from exercise 2 called MyListSub which extends MyList to print a message to stdout before each overloaded operation is called and counts the number of calls. MyListSub should inherit basic method behavoir from MyLi

[Tutor] critique my wrapper

2006-02-02 Thread Christopher Spears
This is a class I created that wraps a list. Could someone please critique the class? class MyList: def __init__(self, aList=None): if aList is None: self.mylist = [] else: self.mylist = aList[:] def _

[Tutor] the chicken and the egg

2006-01-27 Thread Christopher Spears
Thanks to all of the tutors on this mailing list! I'm finally making some headway! I originally decided to tackle my problem one operator at a time: class MyList: def __init__(self, aList=None): if aList is None: self.mylist = [] el

Re: [Tutor] designing a class

2006-01-27 Thread Christopher Spears
> class MyList: >def __init__(self, aList=None): > if aList is None: >self._list = [] > else: >self._list = aList[:] > This code certainly looks like it will do the trick. I'm just not sure what the _ in front of list (i.e. _list) denotes. "I'm the last person t

  1   2   >