[Tutor] [tutor] Problem in saving image file which is modified by ImageEnhance

2008-02-09 Thread Varsha Purohit
Hello All, I am using PIL function to change brightness of an image. But i am getting an error when i am trying to save that image. Here is the code.. import Image import ImageChops, ImageEnhance import math, operator file1 = Image.open("r10001t0.jpg") file2 = Image.open("r10001t1.jpg")

Re: [Tutor] seek and slice a range in a list of dates

2008-02-09 Thread Kent Johnson
washakie wrote: > It's not pretty, but this is what seems to work... I'd be happy hear more > about a better approach... I like the idea of using a list, but ran into > troubles with min and max, maybe I don't entirely understand the lambda > function, but when I tried a list, I got an error that m

Re: [Tutor] designing POOP

2008-02-09 Thread Kent Johnson
Alan Gauld wrote: >> def values(self): >> return (self.name, self.wealth, self.strenth) >> >> Or get rid of values() entirely and just refer to the attributes > > Nope, I don't like that as much since it encourages direct > access. Maybe we just need to agree to disagree here. I don't see

Re: [Tutor] seek and slice a range in a list of dates

2008-02-09 Thread washakie
It's not pretty, but this is what seems to work... I'd be happy hear more about a better approach... I like the idea of using a list, but ran into troubles with min and max, maybe I don't entirely understand the lambda function, but when I tried a list, I got an error that min() has no optional va

Re: [Tutor] How to... (a) write to files, (b) use try/except

2008-02-09 Thread Kent Johnson
Rob Stevenson wrote: > Title = book.ProductName > printstring = isbn + "\t" + book.ProductName + "\t" + > book.Authors.Author + "\tUsed from...\t" + book.UsedPrice + "\tNew > price\t" + book.OurPrice > print printstring > print printstring >> fle

[Tutor] How to... (a) write to files, (b) use try/except

2008-02-09 Thread Rob Stevenson
Hello, Sorry to be dense, but I'm having trouble writing to a file... I have a list of book numbers - ISBNs in a file, one per line... (see list at bottom of this message) my code below... import amazon amazon.setLicense(' -- my amazon id is in here when I run - ') isbn_list = "c:\\ISBN.txt" a

[Tutor] How to (a) write to files, (b) use try/except (clarification)

2008-02-09 Thread Rob Stevenson
by amazon ID in my message I meant my web services license number. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] seek and slice a range in a list of dates

2008-02-09 Thread Alan Gauld
"washakie" <[EMAIL PROTECTED]> wrote > dates, to selected dates (Tstart, Tend)... Now, I need to get all > the dates > (slice) from the dictionary in between the two dates TstartNew and > TendNew. > Basically, I need to know what the 'index' is for them in the in the > dictionay dates_dt. How c

Re: [Tutor] designing POOP

2008-02-09 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote >> e = Explorer() >> >> e.describe(withText=True) # gets the long version >> >> or >> >> print """ >> You are an explorer whose name is %s, >> You have wealth of %s and strength of %s >> """ % e.describe() # uses tuple result > > Um, yuck. A functio

[Tutor] Game

2008-02-09 Thread Seon Kang
First off, here is the code I am working with so far. import random from livewires import games, color games.init(screen_width = 640, screen_height = 480, fps = 50) controls = "Use The Arrow Keys to Move and the Spacebar to Shoot" game_controls = games.Message(value = controls,

Re: [Tutor] seek and slice a range in a list of dates

2008-02-09 Thread Kent Johnson
washakie wrote: > Hello, > > I'm using the code below to select the closest dates in a dictionary of > dates, to selected dates (Tstart, Tend)... Now, I need to get all the dates > (slice) from the dictionary in between the two dates TstartNew and TendNew. > Basically, I need to know what the 'ind

[Tutor] seek and slice a range in a list of dates

2008-02-09 Thread washakie
Hello, I'm using the code below to select the closest dates in a dictionary of dates, to selected dates (Tstart, Tend)... Now, I need to get all the dates (slice) from the dictionary in between the two dates TstartNew and TendNew. Basically, I need to know what the 'index' is for them in the in t

Re: [Tutor] Adding network play to an open source game.

2008-02-09 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Timothy Sikes wrote: > >> Anyone have any advice on good tutorials/books/examples of python >> network programming? > > The book "Foundations of Python Network Programming" ;-) is pretty > good. > http://www.apress.com

Re: [Tutor] designing POOP

2008-02-09 Thread Kent Johnson
Alan Gauld wrote: > class Explorer(object): > fmtStr = """ > My name is %s > and I have wealth of $%s and > strength of %s""" > > # other code here > > def describe(withText=False) > values = (self.name, self.wealth, self.strenth) > if not withText: >

Re: [Tutor] designing POOP

2008-02-09 Thread Alan Gauld
"bhaaluu" <[EMAIL PROTECTED]> wrote > When you're designing a program, how do you go about dealing > with text descriptions, like the descriptions for a room? Here is an > example of a room description: > > THIS IS THE AUDIENCE CHAMBER > THERE IS A WINDOW TO THE WEST. BY LOOKING TO THE RIGHT > THR

Re: [Tutor] designing POOP

2008-02-09 Thread Alan Gauld
> ..., I'd like to have the finished program > be identical to the procedural program as far as I/O goes. You could do it but it would be easier to change it a little because the original games prompts etc betray its internal structure. You can just get the objects to return their attributes an

Re: [Tutor] if ... else shorthand form ?

2008-02-09 Thread Dave Kuhlman
On Sat, Feb 09, 2008 at 09:21:41AM +, dave selby wrote: > Hi all, > > Returning to python after a brief affair with C++, I have the following code > ... > > if (items.has_keys('snapshot_interval')): > self.snap_init[i] = items['snapshot_interval'] >

Re: [Tutor] designing POOP

2008-02-09 Thread Kent Johnson
bhaaluu wrote: > When you're designing a program, how do you go about dealing > with text descriptions, like the descriptions for a room? Here is an > example of a room description: > > THIS IS THE AUDIENCE CHAMBER > THERE IS A WINDOW TO THE WEST. BY LOOKING TO THE RIGHT > THROUGH IT YOU CAN SEE

Re: [Tutor] designing POOP

2008-02-09 Thread bhaaluu
On Feb 9, 2008 8:46 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > "bhaaluu" <[EMAIL PROTECTED]> wrote > Some more thoughts on designing here. You said I can use the procedural program as a program "requirement" because it defines I/O. Even though the OOP program will have the data and functions in

Re: [Tutor] Adding network play to an open source game.

2008-02-09 Thread Kent Johnson
Timothy Sikes wrote: > Anyone have any advice on good tutorials/books/examples of python network > programming? The book "Foundations of Python Network Programming" ;-) is pretty good. http://www.apress.com/book/view/9781590593714 Kent ___ Tutor maill

Re: [Tutor] Adding network play to an open source game.

2008-02-09 Thread Michael Langford
Your game is perfectly within reach of a novice programmer. Board Games are often used as the final project for early courses at Georgia Tech that many people take who aren't going to be programmers for a living. You're also going to chop up some code you didn't write and make it do something funda

Re: [Tutor] designing POOP

2008-02-09 Thread Alan Gauld
"bhaaluu" <[EMAIL PROTECTED]> wrote > the second chapter deals with a Blackjack game. One thing I noticed > (and remember, this is a Noob's viewpoint): The classes seemed to be > designed from small to large, rather than from large to small. As I mentioned in an earlier mail it tends to oscillate

Re: [Tutor] Anyone fancy giving me some tips and an expert opinion??

2008-02-09 Thread Ricardo Aráoz
Damian Archer wrote: > I have written what i see as a pretty decent script to resolve this > question: > > Write an improved version of the Chaos program from Chapter 1 that > allows a user to input two initial > values and the number of iterations and then prints a nicely formatted > table showin

Re: [Tutor] if ... else shorthand form ?

2008-02-09 Thread Tiago Saboga
On Sat, Feb 09, 2008 at 09:21:41AM +, dave selby wrote: > Hi all, > > Returning to python after a brief affair with C++, I have the following code > ... > > if (items.has_keys('snapshot_interval')): > self.snap_init[i] = items['snapshot_interval'] >

Re: [Tutor] designing POOP

2008-02-09 Thread bhaaluu
On Feb 9, 2008 4:09 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > > "Tiger12506" <[EMAIL PROTECTED]> wrote > > > Are some simple examples off the top of my head. It's not difficult > > to model > > real-life things with classes, but ... > > This is a good point, it is excellent practice for thinking

Re: [Tutor] if ... else shorthand form ?

2008-02-09 Thread Eric Abrahamsen
> Hi all, > > Returning to python after a brief affair with C++, I have the > following code ... > >if (items.has_keys('snapshot_interval')): >self.snap_init[i] = items['snapshot_interval'] >else: >self.snap_init[i] = 0 > > I

[Tutor] if ... else shorthand form ?

2008-02-09 Thread dave selby
Hi all, Returning to python after a brief affair with C++, I have the following code ... if (items.has_keys('snapshot_interval')): self.snap_init[i] = items['snapshot_interval'] else: self.snap_init[i] = 0 I thought Python h

Re: [Tutor] designing POOP

2008-02-09 Thread Alan Gauld
"Tiger12506" <[EMAIL PROTECTED]> wrote > Are some simple examples off the top of my head. It's not difficult > to model > real-life things with classes, but ... This is a good point, it is excellent practice for thinking about the responsibilities of objects > ...it is much more difficult to m