Re: [Tutor] RE:

2005-01-17 Thread Danny Yoo
> > >>> stuff = [[0,'sdfsd','wrtew'], [1, 'rht','erterg']] > > >>> stuff > > [[0, 'sdfsd', 'wrtew'], [1, 'rht', 'erterg']] > > >>> print [stuff[i][0] for i in range(len(stuff))] > > [0, 1] > > > > An alternative way to write this is: > > > > ### > > print [row[0] for row in stuff] > > ### > >

[Tutor] RE:

2005-01-17 Thread Gopinath V, ASDC Chennai
Title: RE: On Wed, 12 Jan 2005, Orri Ganel wrote: >  >>> stuff = [[0,'sdfsd','wrtew'], [1, 'rht','erterg']] >  >>> stuff > [[0, 'sdfsd', 'wrtew'], [1, 'rht', 'erterg']] >  >>> print [stuff[i][0] for i in range(len(stuff))] > [0, 1] Hi Orri, An alternative way to write this is: ### pr

Re: [Tutor] Objects & Classes...

2005-01-17 Thread Liam Clarke
Curious - what's mod_python? On Tue, 18 Jan 2005 03:10:44 +, Max Noel <[EMAIL PROTECTED]> wrote: > > On Jan 18, 2005, at 02:59, Jack Cruzan wrote: > > > Wouldn't it though! I haven't checked but doesn't he use xml for his > > equipment lists - if that was the case it would be worth it to as

Re: [Tutor] need advice on streamlining code...

2005-01-17 Thread Liam Clarke
yeah, I wasn't sure about that readline/lines thing, cos I'm not sure how popen works. On Mon, 17 Jan 2005 21:38:37 -0500, Jacob S. <[EMAIL PROTECTED]> wrote: > I seem to always be the one to suggest this, but -- > > "String methods are better than using the string module because the string > mo

Re: [Tutor] Objects & Classes...

2005-01-17 Thread Max Noel
On Jan 18, 2005, at 02:59, Jack Cruzan wrote: Wouldn't it though! I haven't checked but doesn't he use xml for his equipment lists - if that was the case it would be worth it to ask him for those files 'eh? Last time I checked, he didn't. I have the DAT files here (extracted them off a Windows in

Re: [Tutor] Walking a directory

2005-01-17 Thread Jacob S.
Kent's suggestions are always my favorites, along with others, c. --nevermind To get the full path in your list-- change Kent's to this import os filelist = [] for root,directories,filenames in os.walk("Aircraft"): for filename in filenames: if filename.endswith("-set.xml"):

Re: [Tutor] Objects & Classes...

2005-01-17 Thread Jack Cruzan
Wouldn't it though! I haven't checked but doesn't he use xml for his equipment lists - if that was the case it would be worth it to ask him for those files 'eh? Thanx for the input by the way will have to let you know how this goes... > Ah, things would be so much easier if McMackie would re

Re: [Tutor] need advice on streamlining code...

2005-01-17 Thread Jacob S.
I seem to always be the one to suggest this, but -- "String methods are better than using the string module because the string module has been ?deprecated? or will be soon. I think that is the word here. So, do this instead." insideipgrepfd = os.popen("grep ifconfig_fxp0 /etc/rc.conf") insideipg

Re: [Tutor] COP vs OOP

2005-01-17 Thread Max Noel
On Jan 17, 2005, at 23:07, Bernard Lebel wrote: Okay... so if I follow you, a class that has methods not part of itself, it's not a static class...? So should I understand that a class that gets inherited methods can be considered OOP? Not exactly. Basically, object-oriented programming is just

Re: [Tutor] Posting a large amount of code?

2005-01-17 Thread Bill Burns
[Jacob] > > Actually according to the above paragraph, he suggests putting them > > all in > > > a seperate class. So pseudo-code... > > > > class Pipe: > > All things related to pipe program here. > > > > class GUI: > [Alan] > Exactly so. The rationale for that was that you could work with >

Re: [Tutor] Objects, persistence & getting

2005-01-17 Thread Mike Hansen
Subject: Re: [Tutor] Objects, persistence & getting From: "Alan Gauld" <[EMAIL PROTECTED]> Date: Mon, 17 Jan 2005 07:48:28 - To: "Liam Clarke" <[EMAIL PROTECTED]>, "Tutor Tutor" To: "Liam Clarke" <[EMAIL PROTECTED]>, "Tutor Tutor" Well, one thing learning Java is good for is for thoroughly

Re: [Tutor] COP vs OOP

2005-01-17 Thread Bernard Lebel
Max Noel wrote: if you're only using static (class) methods, then your class can't/needn't be instanciated, and then is nothing more than the equivalent of a Python module. I think that's what Alan means by class-oriented programming. Okay... so if I follow you, a class that has methods not p

Re: [Tutor] COP vs OOP (was: Objects, persistence & getting)

2005-01-17 Thread Max Noel
On Jan 17, 2005, at 22:41, Bernard Lebel wrote: Alan Gauld wrote: In fact I usually refer to Java as a Class Oriented Programming rather than Object Oriented. If you allow me a question What is the fundamental difference between the two? To me this is not clear. I thought that a class was ba

Re: [Tutor] Objects & Classes...

2005-01-17 Thread Max Noel
On Jan 17, 2005, at 22:02, Chad Crabtree wrote: (why would an attri bute need to be a separate class?) So that the points or Karma (depending on the generation system) cost of the Attribute can be calculated without having to resort to procedural programming. You'd be then able to get the Karm

Re: [Tutor] COP vs OOP (was: Objects, persistence & getting)

2005-01-17 Thread Bernard Lebel
Alan Gauld wrote: In fact I usually refer to Java as a Class Oriented Programming rather than Object Oriented. If you allow me a question What is the fundamental difference between the two? To me this is not clear. I thought that a class was basically a programming object with properties an

[Tutor] Getting access to the speakers

2005-01-17 Thread Orri Ganel
Hello all, I've googled the topic a bit, and can't seem to find any relevant information. Does anyone know how to gain access to the speakers and, for example, tell when they are playing a sound and when they are not? I would think it's something with sockets, but I don't know how to go about

Re: [Tutor] Objects & Classes...

2005-01-17 Thread Chad Crabtree
I was thinking (it's been a while since I played) that I would do it like this. (strawman code) class Character: def __init__(self,name,attribs,skills,cyberware): ...initialize.. and code to check attrib and skill mins and maxes physical and menatl attributes should be part

Re: [Tutor] Objects & Classes...

2005-01-17 Thread Max Noel
On Jan 17, 2005, at 20:51, Jack Cruzan wrote: Ok, so each character has his name, race, his stats, his skills, and his gear. since the name and character is unique there is no need for a class these things. hmmm maybe I am conceptualizing this wrong. would each new character then be a dictonary?

Re: [Tutor] need advice on streamlining code...

2005-01-17 Thread Liam Clarke
Well, if you're looking to extract the IP & mask you could use a regEx. They're not to bad If it's only that line that you're extracting, and it's format doesn't change import re pattern='ifconfig_fxp0="inet (?P*.?) netmask (?P*.?)" reObj=re.compile(pattern, IGNORECASE) jay = os.popen("

Re: [Tutor] py2exe

2005-01-17 Thread jfouhy
Quoting Guillermo Fernandez Castellanos <[EMAIL PROTECTED]>: > but when I try to package it with py2exe, I obtain the following > result: The following modules appear to be missing > ['mx'] I've got a program that uses mx.texttools.. Whenever I freeze it (with py2exe), I get a list of about thre

Re: [Tutor] Objects & Classes...

2005-01-17 Thread jfouhy
On Mon, 2005-01-17 at 10:59 -0800, Chad Crabtree wrote: > class NewCharacter(Character): > def __init__(self,stats,*args,**kwds): > super(Character,self).__init__(*args,**kwds) > self.stats=stats > > super is a function that calls a specific function from a parent > class. This way you c

Re: [Tutor] Objects & Classes...

2005-01-17 Thread Jack Cruzan
Ok, so each character has his name, race, his stats, his skills, and his gear. since the name and character is unique there is no need for a class these things. hmmm maybe I am conceptualizing this wrong. would each new character then be a dictonary? Made up of different elements or would the ch

Re: [Tutor] Walking a directory

2005-01-17 Thread Kent Johnson
Something like this (not tested!): import os for dirpath, dirnames, filenames in os.walk('Aircraft'): for filename in filenames: if filename.endswith('-set.xml'): print filename[:-8] This is probably a good time to mention Jason Orendorff's wonderful path module, which makes

Re: [Tutor] Objects, persistence & getting

2005-01-17 Thread Liam Clarke
Law of Demeter? And, OK I'll just pass references, it was a passing idle thought. But thanks : ) What kind of languages espouse real OOP? Smalltalk gets mentioned a lot. Ruby? Regards, Liam Clarke On Mon, 17 Jan 2005 07:48:28 -, Alan Gauld <[EMAIL PROTECTED]> wrote: > > Well, one thing

[Tutor] Walking a directory

2005-01-17 Thread Arthur Wiebe
What I want to do is rather simple, but I cannot find any good documentation for something like this. The directory structure is sort of like this: >Aircraft >>A-10 +A-10cl-set.xml +A-10fg-set.xml For example Aircraft/A-10/A-10cl-set.xml Now I want to loop though each aircrafts folder (such as A

Re: [Tutor] need advice on streamlining code...

2005-01-17 Thread Chad Crabtree
I can't really think of a more elegant solution than what you have, maybe regex's but I hate those. You *can* reduce the number of lines by two, and there was a variable you never used. HTH Eric L. Howard wrote: >The following block of code works, and provides the necessary output I'm >looking

Re: [Tutor] Objects & Classes...

2005-01-17 Thread Chad Crabtree
Jack Cruzan wrote: >class Character: > > def __init__(self, name = ' ', race = 'Human', magic = 'None'): > > self.name=name > > self.race=race > > self.magic=magic > > I know your going to need some other stuff. class NewCharacter(Character):

[Tutor] need advice on streamlining code...

2005-01-17 Thread Eric L. Howard
The following block of code works, and provides the necessary output I'm looking for...but I have a feeling that it's working through sheer brute force and could be better: insideipgrepfd = os.popen("grep ifconfig_fxp0 /etc/rc.conf") insideipgrep = insideipgrepfd.readlines() insideipfi

[Tutor] Objects & Classes...

2005-01-17 Thread Jack Cruzan
Hello! I am writing (or at least attempting) to write a Character generation utility for Shadowrun in Python of course! After reading about other attempts to make and RPG dealing with with character generation it looks like OOP is the best way to go. I have no experiance with OOP and its kinda thr

Re: [Tutor] py2exe

2005-01-17 Thread Chad Crabtree
Right what he said. I'm sorry I didn't make that clear. This way py2exe can look and see import Tix and see it's needed. Py2exe does not ship the whole python distribution, rather only what is needed. Indeed it tends to ship many things that are not needed but it's better than the whole dis

Re: [Tutor] Tkinter Radiobutton

2005-01-17 Thread Kent Johnson
Is this code running in a larger program that has a window? You are only supposed to have one root window (Tk()) in a program, maybe that is the problem. Kent Ismael Garrido wrote: Ismael Garrido wrote: Hello. I can't figure out what's wrong in here! For some reason I can't understand, the radio