[Tutor] lan with python

2008-02-10 Thread Treloar, Nick
hey i was just wondering if any one could tell me if they know if you can make multi player games through lan with python heres the code i want to lan. just hash out the sound files #NiCk TrEloaR PrOgRaMiNg Co. #scissors paper rock #10/6/07 from Tkinter import* import pygame from random im

Re: [Tutor] designing POOP

2008-02-10 Thread Kent Johnson
Alan Gauld wrote: > Over-use of direct access tends, in my experience, to lead to > the temptation to move code that should be in the class (or a > subclass) into client code. And it is avoidance of that temptation > that is my main reason for providing a values() or state() type > method, rather

Re: [Tutor] designing POOP

2008-02-10 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote > Alan doesn't like direct attribute access *or* getters and setters, > IIUC. He wants all access to the attributes of a class instance to > be > through higher-level methods. I'd moderate that slightly. I really, really, don't like getters/setters. So, i

Re: [Tutor] permissions problem using subprocess

2008-02-10 Thread washakie
Answering my own question here, but for the sake of it... adding: os.chdir(newpath) makes it all work... so we have: def run_cmd(cmd): """RUN A BASH CMD""" import subprocess as sub p = sub.Popen(['/bin/bash', '-c', cmd], stdout=sub.PIPE, stderr=sub.STDOUT) output =

[Tutor] permissions problem using subprocess

2008-02-10 Thread washakie
Hello, I'm converting a perl script which calls shell scripts which call fortran routines into a python cgi that calls fortran directly (well, not yet using f2py), but using subprocess.popen. Here's my code: def run_cmd(cmd): """RUN A BASH CMD""" import subprocess as sub p = sub.Popen(

Re: [Tutor] Change dictionary value depending on a conditionalstatement.

2008-02-10 Thread Norman Khine
thanks Tiger12506 wrote: > >>> list = [] > total = 0 > if total > 0: >> ... x = {'id': 'name', 'link': 'XX'} >> ... list.append(x) >> ... else: >> ... y = {'id': 'name', 'link': 'YY'} >> ... list.append(y) >> ... >> > > Yeah. > > list = [] > x = {'id':'name'} > if total

Re: [Tutor] Change dictionary value depending on a conditionalstatement.

2008-02-10 Thread Tiger12506
>>> list = [] > >>> total = 0 > >>> if total > 0: > ... x = {'id': 'name', 'link': 'XX'} > ... list.append(x) > ... else: > ... y = {'id': 'name', 'link': 'YY'} > ... list.append(y) > ... > Yeah. list = [] x = {'id':'name'} if total > 0: x['link'] = 'XX' else: x['link'] = 'Y

[Tutor] Change dictionary value depending on a conditional statement.

2008-02-10 Thread Norman Khine
Hello, Is there a better way to do this: >>> list = [] >>> total = 0 >>> if total > 0: ... x = {'id': 'name', 'link': 'XX'} ... list.append(x) ... else: ... y = {'id': 'name', 'link': 'YY'} ... list.append(y) ... I would like to change the key 'link' value depending on the valu

Re: [Tutor] designing POOP

2008-02-10 Thread Kent Johnson
Dave Kuhlman wrote: > Here is something relevant to this argument, although I'm not sure > that I agree with it: > > "Getters and setters are evil. Evil, evil, I say! Python objects > are not Java beans. Do not write getters and setters. This is > what the 'property' built-in is for.

Re: [Tutor] designing POOP

2008-02-10 Thread Dave Kuhlman
On Sat, Feb 09, 2008 at 08:42:04PM -0500, Kent Johnson wrote: > 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 encourage

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

2008-02-10 Thread Kent Johnson
Varsha Purohit wrote: > 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.

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

2008-02-10 Thread Kent Johnson
washakie wrote: > Yes, I'm using 2.4, and will not likely be able to upgrade... so, the final, > as you suggested Kent: > > > dates_dt=([datetime.datetime(int(dates_list[i][0][:4]),int(dates_list[i][0][4:6]), > > int(dates_list[i][0][6:8]),int(dates_list[i][0][8:

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

2008-02-10 Thread washakie
Yes, I'm using 2.4, and will not likely be able to upgrade... so, the final, as you suggested Kent: dates_dt=([datetime.datetime(int(dates_list[i][0][:4]),int(dates_list[i][0][4:6]), int(dates_list[i][0][6:8]),int(dates_list[i][0][8:10]),