Re: [Tutor] eval and exec

2004-12-04 Thread Brian van den Broek
Marilyn Davis said unto the world upon 2004-12-04 01:37: Hello Tutors, I'm having trouble understanding the difference between eval and exec. Can anyone explain it to me please? Marilyn Davis Hi Marilyn, does this help? print a Traceback (most recent call last): File "", line 1, in -toplevel-

Re: [Tutor] eval and exec

2004-12-04 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2004-12-04 04:28: Marilyn Davis said unto the world upon 2004-12-04 01:37: Hello Tutors, I'm having trouble understanding the difference between eval and exec. Can anyone explain it to me please? Marilyn Davis Hi Marilyn, does this help? Darn. I l

Re: [Tutor] Global presets ?

2004-12-04 Thread Brian van den Broek
Kent Johnson said unto the world upon 2004-12-04 06:21: You are on the right track. Put your common definitions in a configuration module like this: # Config.py arch_data_dir='/home/dave/mygg/gg1.3/arch_data' data_dir='/home/dave/mygg/gg1.3/data' Then in client code, import Config. When you use t

Re: [Tutor] Simple RPN calculator

2004-12-04 Thread Brian van den Broek
Liam Clarke said unto the world upon 2004-12-05 00:31: RPN calculator, with operators and operands separate? Sounds counter-intuitive to me. What's the advantage I'm missing? P.S. Hi Liam and all, Is RPN really written with operators and operands separate? If so, that is a bit odd. The name, so fa

Re: [Tutor] Simple RPN calculator

2004-12-05 Thread Brian van den Broek
Kent Johnson said unto the world upon 2004-12-05 06:55: RPN reverses the order of operator and operand, it doesn't reverse the whole string. So in Polish Notation 2 + 3 is +23 and (2 + 3) - 1 is -+231; in RPN they become 23+ and 23+1- Kent Hi all, Thanks Kent, that is what I had assumed it would

Re: [Tutor] Could I have used time or datetime modules here?

2004-12-05 Thread Brian van den Broek
Dick Moores said unto the world upon 2004-12-05 11:17: I'm wondering if my timer3.py could have been written more simply and easily by using the time or datetime modules to get the number of seconds separating the time now and the time to which the alarm is set. IOW, is there an easier way to cal

Re: [Tutor] Could I have used time or datetime modules here?

2004-12-05 Thread Brian van den Broek
Dick Moores said unto the world upon 2004-12-05 15:03: Thanks, Brian. I looked at your code a long time, and also read the 11/26 thread you started. I can see how I could use datetime() and your t2 - t1 to get the seconds for time.sleep(), but the resulting code I have in mind is more convolute

Re: [Tutor] eval and exec

2004-12-05 Thread Brian van den Broek
Hi all, in a discussion of security risks with eval() and exec() Alan Gauld said unto the world upon 2004-12-05 18:41: Even in a config file, if its plain text a hostile (or just mischievous) user could add a dangerous line and when you try to exec it bad things happen. Any time you allow users to

Re: [Tutor] Could I have used time or datetime modules here?

2004-12-05 Thread Brian van den Broek
Dick Moores said unto the world upon 2004-12-05 22:02: Brian van den Broek wrote at 16:53 12/5/2004: Dick Moores said unto the world upon 2004-12-05 15:03: Thanks, Brian. I looked at your code a long time, and also read the 11/26 thread you started. I can see how I could use datetime() and your

Re: [Tutor] Re: Could I have used time or datetime modules here?

2004-12-07 Thread Brian van den Broek
Dick Moores said unto the world upon 2004-12-07 07:04: To Liam and Brian, Here's Brian's script in it's bare bones, without the input error checking and his extensive and helpful comments: ===begin code import datetime import time alarm_time = raw_input("Enter ala

Re: [Tutor] Re: Could I have used time or datetime modules here?

2004-12-07 Thread Brian van den Broek
Dick Moores said unto the world upon 2004-12-07 12:04: Brian van den Broek wrote at 07:50 12/7/2004: It seems I've missed out on something important BTW I'm not sure you need the +4 of "now.year + 4". I've run this without the +4 and it doesn't seem to be needed.

Re: [Tutor] Re: Could I have used time or datetime modules here?

2004-12-07 Thread Brian van den Broek
Tim Peters said unto the world upon 2004-12-07 11:45: [Brian van den Broek] ... Or, so I thought. I'd first tried getting the alarm datetime by simply taking the date component of datetime.datetime.now() and adding to the day value. That works fine, provided you are not on the last day o

Re: [Tutor] Re: Could I have used time or datetime modules here?

2004-12-08 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2004-12-07 23:57: Dick Moores said unto the world upon 2004-12-07 12:04: The note you reference: date2 is moved forward in time if timedelta.days > 0, or backward if timedelta.days < 0. Afterward date2 - date1 == timedelta.days. timedelta.secon

Re: [Tutor] OT?: how to google just the 2.4 tutorial?

2004-12-12 Thread Brian van den Broek
Dick Moores said unto the world upon 2004-12-12 11:53: I know how to limit google search results to a single site, but is it possible to google just one section of a site? I'd like to be able to search just the 2.4 tutorial, http://www.python.org/doc/2.4/tut/tut.html Possible? And if so, how to?

Re: [Tutor] check_range

2004-12-14 Thread Brian van den Broek
Marc Gartler said unto the world upon 2004-12-14 18:12: Hi all, I am fairly new to both Python & programming, and am attempting to create a function that will test whether some user input is an integer between 10 and 89, but the check isn't happening... def check_range(myrange): if range(myr

Re: [Tutor] User selection as both string and int

2004-12-14 Thread Brian van den Broek
Marc Gartler said unto the world upon 2004-12-14 22:13: I am trying to have a user select from amongst a list of items, and then make use of that choice later on as both a string (e.g. "you chose _"). My function currently allows for a numerical choice, but I am not sure how to return it as

[Tutor] am I missing another simpler structure?

2004-12-15 Thread Brian van den Broek
Hi all, in Marc's check_range thread, I had proposed: def check_in_range(value): in_range = False if 9 < value < 90: in_range = True return in_range and DogWalker suggested the better: def check_in_range(value): return 9 < value < 90 As I mentioned, I feel as though I have a

Re: [Tutor] am I missing another simpler structure?

2004-12-15 Thread Brian van den Broek
[Brian van den Broek] import datetime def is_leap_year(year): '''-> boolean Returns True or False as year is, or is not, a leap year. ''' is_leap = True try: datetime.date(year, 2, 29) except ValueError: is_leap = False return i

Re: [Tutor] am I missing another simpler structure?

2004-12-16 Thread Brian van den Broek
Liam Clarke said unto the world upon 2004-12-16 02:05: Alright, so that was a quick example, but return not x % 2 A light dawns. On Thu, 16 Dec 2004 15:58:38 +0900, Guillermo Fernandez Castellanos <[EMAIL PROTECTED]> wrote: Well... I find multiple returns to be rather useful def isOdd(x):

Re: [Tutor] am I missing another simpler structure?

2004-12-16 Thread Brian van den Broek
Blake Winton said unto the world upon 2004-12-16 09:20: Juan Shen wrote: Yeah, I support Kent. Brian's code is obviously C style, define a variable and give it an origin value, then use it, modify its value and so on. If you choose Python, you should adapt to it that variable needn't to be

[Tutor] suggestion for group project

2004-12-17 Thread Brian van den Broek
Hi all, A while ago, in a response: Danny Yoo said unto the world upon 2004-11-29 17:14: I just got in contact with Nick Parlante of the Nifty Assignments project; he's been collecting material on fun projects: http://nifty.stanford.edu/ The projects there look pretty nice. In fact, I'm thinking o

Re: [Tutor] check_range

2004-12-15 Thread Brian van den Broek
DogWalker said unto the world upon 2004-12-15 00:32: "Brian van den Broek" <[EMAIL PROTECTED]> said: Marc Gartler said unto the world upon 2004-12-14 18:12: Hi all, I am fairly new to both Python & programming, and am attempting to create a function that will test whether s

Re: [Tutor] am I missing another simpler structure?

2004-12-16 Thread Brian van den Broek
Gregor Lingl said unto the world upon 2004-12-16 04:14: Brian van den Broek schrieb: If my original bit of code, the structure was like: output_value = False if condition: output_value = True return output_value Mine would be like yours if transformed to: if condition: return True return

[Tutor] class overriding question

2004-12-18 Thread Brian van den Broek
Hi all, instead of sleeping, I've been up all night finally attacking my apprehension about classes. I think I'm mostly getting the hang of it -- I managed to convert a 300 line procedural script into (what I think is) a fully object-oriented approach. :-) I made a lot of use of Mark Pilgrim's Di

Re: [Tutor] class overriding question

2004-12-18 Thread Brian van den Broek
he class (type) of self, finally the base classes. So, in your example, self.foo is found in the class of bar, while self.ham is found in the base class of the class of bar. Kent Brian van den Broek wrote: reconstructed it to make sure I had the intent of Guido's point> Thanks Kent! I

Re: [Tutor] Nifty

2004-12-18 Thread Brian van den Broek
Jacob S. said unto the world upon 2004-12-18 21:06: I probably wouldn't be any help on projects, but I would probably learn stuff from it. I'm okay with it. Jacob Schmidt I just got in contact with Nick Parlante of the Nifty Assignments project; he's been collecting material on fun projects: http:

Re: [Tutor] Matrix

2004-12-19 Thread Brian van den Broek
Bugra Cakir said unto the world upon 2004-12-19 10:33: hi, I want to create a matrix in Python. For example 3x4 how can i create this? thanks ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor Hi, at least two ways usin

Re: [Tutor] OT: Flow chart

2004-12-19 Thread Brian van den Broek
Alan Gauld said unto the world upon 2004-12-19 12:23: I'm looking for any good link or tutorial of flow charting A good resource for all notations related to software design is at smartdraw.com: http://www.smartdraw.com/exp/tec/tutorials/software.htm But flow charts are more generic so info abo

Re: [Tutor] Matrix

2004-12-19 Thread Brian van den Broek
[2, 5, 1, 3],\ ... [2, 1, 2, 8] ] >>> print my_matrix_as_lists[1][1] 5 Rob On Dec 19, 2004, at 1:31 PM, Brian van den Broek wrote: Bugra Cakir said unto the world upon 2004-12-19 10:33: hi, I want to create a matrix in Python. For example 3x4 how can i create this? thanks Hi, at le

Re: [Tutor] class overriding question

2004-12-20 Thread Brian van den Broek
Alan Gauld said unto the world upon 2004-12-20 09:27: Its another reason why you should never refer to an object or method *calling* another method (as Pilgrim does). Rather think of the method sending a *message* to the self object which invokes the appropriate method. This decoupling of message

Re: [Tutor] class overriding question

2004-12-20 Thread Brian van den Broek
Alan Gauld said unto the world upon 2004-12-20 15:51: I hope that short history of OOP clarifies rather than confuses! :-) Alan G. Thanks for that Alan. Seems to clarify thing to me ;-) Best, Brian vdB ___ Tutor maillist - [EMAIL PROTECTED] http://mail

Re: [Tutor] O.T.

2004-12-31 Thread Brian van den Broek
Jacob S. said unto the world upon 2004-12-27 16:31: I hate to sound weird... But who are you all, what are you're ages, what do you do, marriage status, etc? You obviously don't have to answer, I'm just curious who I'm boldly sending emails to. Jacob Schmidt P.S. I'm a student. 14 years. Play the p

Re: [Tutor] Am I storeing up problems ?

2005-01-02 Thread Brian van den Broek
Max Noel said unto the world upon 2005-01-02 19:43: On Jan 2, 2005, at 23:00, Danny Yoo wrote: (Aside: one nonobvious example where copying can be avoided is in Conway's Game of Life: when we calculate what cells live and die in the next generation, we can actually use the 'Command' design patter

Re: [Tutor] Breaking down integers?

2005-01-03 Thread Brian van den Broek
kilovh said unto the world upon 2005-01-03 17:17: I would like to be able to take an integer, break it down into individual items in a list, and then put them back together. I know how to do this last part thanks to Orri Ganel and Guillermo Fernandex, but what about taking the integer apart? Sorry

Re: [Tutor] The Game of Life question

2005-01-05 Thread Brian van den Broek
Kooser, Ara S said unto the world upon 2005-01-05 10:15: This is most likely a silly question and me not understanding python enough. I am a mentor for some high school kids participating in a supercomputing challenge. My background in programming is F77 (yeah laugh it up) and I want the kids to

[Tutor] Re: The Game of Life

2005-01-06 Thread Brian van den Broek
Danny Yoo said unto the world upon 2005-01-03 04:11: On Mon, 3 Jan 2005, Brian van den Broek wrote: (Aside: one nonobvious example where copying can be avoided is in Conway's Game of Life: when we calculate what cells live and die in the next generation, we can actually use the 'Comma

Re: [Tutor] Re: The Game of Life

2005-01-06 Thread Brian van den Broek
Max Noel said unto the world upon 2005-01-06 15:39: On Jan 6, 2005, at 20:05, Brian van den Broek wrote: I gave some thought (though produced no code) to the question of how to do a life game before you [Danny] posted your code. My naive approach differs a bit, and it seems to me better. I&#

[Tutor] Re: The Game of Life

2005-01-06 Thread Brian van den Broek
n > self.total_generations: NameError: name 'self' is not defined That surprised me -- I'd have guessed that within a class, self was everywhere defined, and not just within methods. Clearly, I'm confused about something. Anyway, thanks for reading. Best to all, Brian vdB # pyli

Re: [Tutor] Ooer, OT Lisp

2005-01-20 Thread Brian van den Broek
Liam Clarke said unto the world upon 2005-01-20 21:46: Oops, and OT ~ Has anyone used Lisp? I've been reading Paul Graham's essays on how great Lisp is, and how Python is near to implementing features Lisp had in the 60's. Also found the concept of macros interesting. Regards, Liam Clarke Hi Li

Re: [Tutor] Unique Items in Lists

2005-01-26 Thread Brian van den Broek
Srinivas Iyyer said unto the world upon 2005-01-27 01:17: Dear Jacob, thank you for your suggestion. however, i think my question was not clear. what i meant to ask in my previous question was, how to know which elements repeated and how many times they were repeated. while my question was flying

Re: [Tutor] Should this be a list comprehension or something?

2005-01-26 Thread Brian van den Broek
Sean Perry said unto the world upon 2005-01-27 02:13: And now, for the pedant in me. I would recommend against naming functions with initial capital letters. In many languages, this implies a new type (like your Water class). so CombineWater should be combineWater. Do you mean implies by the domin

Re: [Tutor] Re: Unique Items in Lists

2005-01-27 Thread Brian van den Broek
Wolfram Kraus said unto the world upon 2005-01-27 03:24: Brian van den Broek wrote: Thanks Wolfram, I knew someone would improve what I posted. (It can always be done ;-) for i in a_list: if i in items_dict: items_dict[i] = items_dict[i] + 1 else

Re: [Tutor] Re: Unique Items in Lists

2005-01-27 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-01-27 05:57: Brian van den Broek wrote: Wolfram Kraus said unto the world upon 2005-01-27 03:24: This whole part can be rewritten (without sorting, but in Py2.4 you can use sorted() for this) with a list comprehension (Old Python2.1 style, with a newer

Re: [Tutor] Re: Unique Items in Lists

2005-01-27 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-01-27 16:08: Brian van den Broek wrote: Finally, in the first instance, I was aiming for the OP's stated end. To make this more general and reusable, I think I'd do: def get_list_dup_dict(a_list, threshold=1): items_dict

Re: [Tutor] Should this be a list comprehension or something?

2005-01-27 Thread Brian van den Broek
Tony Meyer said unto the world upon 2005-01-27 21:46: [Sean Perry] And now, for the pedant in me. I would recommend against naming functions with initial capital letters. In many languages, this implies a new type (like your Water class). so CombineWater should be combineWater. [Brian van den

Re: [Tutor] Should this be a list comprehension or something?

2005-01-29 Thread Brian van den Broek
Alan Gauld said unto the world upon 2005-01-28 16:28: So you've been looking at Eiffel then? :-) I don't get this joke, but it sounds like the basis for it would be interesting. Can you explain? Bertrand Meyer, the inventor of Eiffel uses rich text to display code in his books. The commercial Ei

Re: [Tutor] Introductory Links

2005-02-01 Thread Brian van den Broek
jhomme said unto the world upon 2005-02-01 17:15: Hi, Is it possible to get a copy of the message sent to us when we first join? I want to follow the links in it so I can learn how to do the research and ask questions on the list. Thanks. Jim Hi Jim, I don't still have a copy of my Welcome msg. Bu

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-04 Thread Brian van den Broek
Andrew D. Fant said unto the world upon 2005-02-04 18:27: Alan Gauld wrote: I said awk was easier to learn but less capable than Perl. Perl is capable of things that awk can only dream of! Surely you jest, Alan. :-) I'm prettry sure he means it. And stop calling him Surely ;-) Brian vdB __

[Tutor] help with refactoring needed -- which approach is more Pythonic?

2005-02-09 Thread Brian van den Broek
Hi all, I have data files with a format that can be scheamatized as: File Header Contents . . . File Header End Tag Node Header Contents . . . Node Header End Tag Node Contents . . . Node End Tag [Repeat Node elements until end of file] I'm refactoring the heck out of a file conversion utility I wr

Re: [Tutor] help with refactoring needed -- which approach is more Pythonic?

2005-02-09 Thread Brian van den Broek
Danny Yoo said unto the world upon 2005-02-09 19:06: If we want to be fancy, we can also take advantage of Python's generator support to avoid constructing an explicit list: Hi Brian, Oh good grief. *grin* That last snippet won't work; I had forgotten about appending lines into current_node_conte

Re: [Tutor] Hex to Str - still an open issue

2005-02-10 Thread Brian van den Broek
Johan Geldenhuys said unto the world upon 2005-02-10 00:43: I am not so clued up on the 'base 2' and 'base 8' stuff. Care to explain that a little? Johan On Tue, 2005-02-08 at 12:12, Pierre Barbier de Reuille wrote: Hi Johan, here's a go: We have 10 fingers. Not coincidentally, we have a base 10 n

Re: [Tutor] help with refactoring needed -- which approach is morePythonic?

2005-02-10 Thread Brian van den Broek
Alan Gauld said unto the world upon 2005-02-10 02:58: The main change in refactoring is moving it to OOP. I have a method that serves as the entry point for parsing the files. Not an object? If you are thinking terms of what the methods do its probably not OOP... Hi Alan, That may well be :-) What

[Tutor] default argument frustration

2005-02-11 Thread Brian van den Broek
Alan Gauld said unto the world upon 2005-02-10 02:58: class Node: def __init__(self,lines=[]): # here's the zowie BvdB self.lines = lines def append(self,item): self.lines.append(item) def parse(self): #

Re: [Tutor] help with refactoring needed -- which approach is morePythonic?

2005-02-11 Thread Brian van den Broek
Alan Gauld said unto the world upon 2005-02-10 02:58: Pseudo code: class Body: def __init__(self,content): self.contents = contents self.nodes = [] def parse(self): for line in self.contents: if line == NodeStartTag:

Re: [Tutor] Idle needles

2005-02-12 Thread Brian van den Broek
Lobster said unto the world upon 2005-02-12 10:34: Danny Yoo wrote: On Sat, 12 Feb 2005, Lobster wrote: Just to nail this issue down: try turning ZoneAlarm off, just for a moment, and then start up IDLE. (You can always turn ZoneAlarm back on after this experiment.) If you don't see any proble

Re: [Tutor] help with refactoring needed -- which approach is more Pythonic?

2005-02-12 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-02-11 11:34: Brian van den Broek wrote: Alan Gauld said unto the world upon 2005-02-10 02:58: Pseudo code: class Body: def __init__(self,content): self.contents = contents self.nodes = [] def parse(self

Re: [Tutor] help with refactoring needed -- which approach is morePythonic?

2005-02-12 Thread Brian van den Broek
Alan Gauld said unto the world upon 2005-02-12 07:51: Thanks Alan and Kent for the replies. I'm responding to a couple of questions Alan asked me about my problem. I don't think I have any further questions of my own (yet), though. :-) Call it node_linkify. The new thought is to create two new

Re: [Tutor] default argument frustration

2005-02-12 Thread Brian van den Broek
I've combined a few email's worth of quoting as no previous post had all the elements I wanted to refer to. Alan Gauld said unto the world upon 2005-02-11 13:30: >> >>FOR THE LOVE OF MIKE can someone tell me even one reason why this >>isn't a misfeature?!?! >> > > Its the only sane way to impleme

Re: ****SPAM(11.2)**** [Tutor] Larger program organization

2005-02-12 Thread Brian van den Broek
Bob Gailer said unto the world upon 2005-02-11 15:34: At 10:39 AM 2/11/2005, Ryan Davis wrote: I'm starting to make a code-generation suite in python, customized to the way we ASP.NET at my company, and I'm having some trouble finding a good way to organize all the code. My take on doing that in

Re: [Tutor] how to read from a txt file

2005-02-13 Thread Brian van den Broek
jrlen balane said unto the world upon 2005-02-13 11:49: guys, how would i do this: i want to read from a text file the text file should contain should contain data (say, decimal value from 1-1200). there should be no other type of entry but decimal it should contain 96 data all in all, with each d

Re: ****SPAM(11.2)**** [Tutor] Larger program organization

2005-02-13 Thread Brian van den Broek
Bob Gailer said unto the world upon 2005-02-13 10:13: At 03:21 PM 2/12/2005, Brian van den Broek wrote: [snip] > I am curious about Bob's "Whenever you find yourself writing > an if statement ask whether this would be better handled by subclasses." Thanks Bob and Alan,

Re: [Tutor] how to read from a txt file

2005-02-13 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-02-13 14:04: Brian van den Broek wrote: Since you files are quite short, I'd do something like: data_file = open(thedata.txt, 'r') # note -- 'r' not r data = data_file.readlines() # returns a list of lines

Re: [Tutor] how to read from a txt file

2005-02-13 Thread Brian van den Broek
jrlen balane said unto the world upon 2005-02-13 18:45: ei guys, chill out! what if i choose to numbered my data from 1-96 for example. how would i be able to exclude the numbered part from the data part? and, mind if I ask, what's a YAGNI by the way? _

Re: [Tutor] Re: Tutor Digest, Vol 12, Issue 71

2005-02-14 Thread Brian van den Broek
Lobster said unto the world upon 2005-02-14 13:32: >> - I am trying to call up an external program >> with something like a "Shell" command - can not find a way of doing >> this >> (in windows) >> >> Any hints? What about os.system('your_command_here')? = That is a good tip and seems t

[Tutor] dictionary dispatch for object instance attributes question

2005-02-15 Thread Brian van den Broek
Hi all, I'm still plugging away at my project of writing code to process treepad files. (This was the task which I posted about in the recent "help with refactoring needed -- which approach is more Pythonic?" thread.) My present problem is how best to reorganize a long (20 elements) elif chain

Re: [Tutor] dictionary dispatch for object instance attributes question

2005-02-15 Thread Brian van den Broek
Liam Clarke said unto the world upon 2005-02-15 18:08: Hi Brian, why not take it the next step and for key in metadata_dict: if data.startswith(key): exec('''self.%s = """%s"""''' %(metadata_dict[key], data[len(key):])) # tripl

Re: [Tutor] dictionary dispatch for object instance attributes question

2005-02-15 Thread Brian van den Broek
Jeff Shannon said unto the world upon 2005-02-15 21:20: On Tue, 15 Feb 2005 17:19:37 -0500, Brian van den Broek <[EMAIL PROTECTED]> wrote: My Node class defines a _parse method which separates out the node header, and sends those lines to a _parse_metadata method. This is where the elif

Re: [Tutor] dictionary dispatch for object instance attributes question

2005-02-16 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-02-16 05:58: Brian van den Broek wrote: Also, I know the general security concerns about things like exec. They make me nervous in using it, even though I am (as yet) the sole user. Am I right in thinking that the constrained way I am using it here

Re: [Tutor] dictionary dispatch for object instance attributes question

2005-02-16 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2005-02-16 14:04: Kent Johnson said unto the world upon 2005-02-16 05:58: if 'text' == self.document_type: self.do_text_stuff() if 'RTF' == self.document_type: self.do_RTF_stuff() Conditionals on a 'type' flag are a

Re: [Tutor] dictionary dispatch for object instance attributes question

2005-02-16 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-02-16 15:02: Brian van den Broek wrote: I had been thinking better to get everything working and then refactor. Is that an unsound approach? My worry about refactoring now is that I feel like I am rearranging deck-chairs when I should be worried about

Re: [Tutor] dictionary dispatch for object instance attributes question

2005-02-16 Thread Brian van den Broek
Jeff Shannon said unto the world upon 2005-02-16 16:09: On Tue, 15 Feb 2005 23:48:31 -0500, Brian van den Broek <[EMAIL PROTECTED]> wrote: Yes, if you know that you will only have one header per line, then it's reasonable to process them one line at a time. You could alternative

Re: ****SPAM(11.2)**** [Tutor] Larger program organization

2005-02-16 Thread Brian van den Broek
Terry Carroll said unto the world upon 2005-02-16 16:18: On Fri, 11 Feb 2005, Bob Gailer wrote: Whenever you find yourself writing an if statement ask whether this would be better handled by subclasses. Whenever you find yourself about to write a global statement, consider making the variables pro

Re: [Tutor] how to read from a txt file

2005-02-17 Thread Brian van den Broek
jrlen balane said unto the world upon 2005-02-17 02:41: sir, what seemed to be the problem with this: def process(list_of_lines): data_points = [] for line in list_of_lines: data_points.append(int(line)) return data_points data_file = open('C:/Documents and Settings/nyer/Desktop

Re: [Tutor] how to read from a txt file

2005-02-17 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2005-02-17 03:51: jrlen balane said unto the world upon 2005-02-17 02:41: sir, what seemed to be the problem with this: Hi, I think the traceback is my fault from an oversight in the code I sent you when you posted before. Sorry about that :-[ In

Re: [Tutor] how to read from a txt file

2005-02-17 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2005-02-17 03:51: > jrlen balane said unto the world upon 2005-02-17 02:41: sir, what seemed to be the problem with this: def process(list_of_lines): data_points = [] for line in list_of_lines: data_points.append(int(line)) ret

Re: [Tutor] Help needed with script to batch-create shapefiles

2005-02-17 Thread Brian van den Broek
Chris Bromley said unto the world upon 2005-02-17 11:05: Prior to running the script I use the ‘check’ button in the PythonWin and the script’s syntax is fine. When I run the script though, the message ‘Script ‘C:\ dBase_File_To_Shapefile.py’ returned exit code 0’ appears in the status bar at the

Re: [Tutor] Active Python

2005-02-19 Thread Brian van den Broek
Bill Mill said unto the world upon 2005-02-18 20:29: On Fri, 18 Feb 2005 17:20:03 -0800 (PST), Terry Carroll <[EMAIL PROTECTED]> wrote: On Thu, 17 Feb 2005, Jeff Shannon wrote: On Thu, 17 Feb 2005 15:54:43 -0800 (PST), Terry Carroll <[EMAIL PROTECTED]> wrote: Interesting -- I prefer the CHM (Win

Re: [Tutor] Advanced Calculator Program...

2005-02-19 Thread Brian van den Broek
. Sm0kin'_Bull said unto the world upon 2005-02-19 16:15: I want to make caculator program which enables me to enter 2numbers and mathsmatics sign and calculates it. I think this is too difficult for newbie like me... Please input data Number1: Mathsmetics Sign: Number2: (Number1) (Sign) (Number2)

[Tutor] design?--having subclassed methods add logic in the middel of class methods

2005-02-21 Thread Brian van den Broek
Hi all, I am still building my toolset for working with treepad files. (This is the one all my recent posts concerning Node classes have been about.) I am exploring ways of having the methods of a sub-class insert additional logic into their version of a class's methods, while still running the

Re: [Tutor] design?--having subclassed methods add logic in the middel of class methods

2005-02-21 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-02-21 16:40: Brian van den Broek wrote: I am exploring ways of having the methods of a sub-class insert additional logic into their version of a class's methods, while still running the original class's method logic. All code below is pseud

[Tutor] subclassing list -- slicing doesn't preserve type

2005-02-22 Thread Brian van den Broek
Hi all, I'm trying to figure out how to subclass the list built-in. .>>> class my_list(list): def __init__(self, sequence=None): list.__init__(self, sequence) self.spam = 1 .>>> mine = my_list((1,2,3,4)) .>>> mine.append(42) .>>> mine [1, 2, 3, 4,

Re: [Tutor] subclassing list -- slicing doesn't preserve type

2005-02-22 Thread Brian van den Broek
Karl Pflästerer said unto the world upon 2005-02-22 07:53: On 22 Feb 2005, [EMAIL PROTECTED] wrote: I'm trying to figure out how to subclass the list built-in. .>>> class my_list(list): def __init__(self, sequence=None): list.__init__(self, sequence) self.spam = 1

[Tutor] puzzling traceback -- what to do with it?

2005-02-27 Thread Brian van den Broek
Hi all, I just ran a program of mine and got the traceback: Traceback (most recent call last): File "C:\PYTHON24\lib\idlelib\rpc.py", line 233, in asyncqueue self.putmessage((seq, request)) File "C:\PYTHON24\lib\idlelib\rpc.py", line 333, in putmessage raise IOError IOError This stumps

Re: [Tutor] (no subject)

2005-03-04 Thread Brian van den Broek
Kevin said unto the world upon 2005-03-04 10:43: Hello all. I have just completed my very first python program just a simple number guessing. I would like for someone to try it out if they could and let me know how I did with it and where I could have improved apon it. There are t files main.py and

Re: [Tutor] (no subject)

2005-03-06 Thread Brian van den Broek
Adam Cripps said unto the world upon 2005-03-06 02:38: On Fri, 04 Mar 2005 12:14:28 -0500, Brian van den Broek <[EMAIL PROTECTED]> wrote: Kevin said unto the world upon 2005-03-04 10:43: Hello all. I have just completed my very first python program just a simple number guessing. I would li

Re: [Tutor] Please help me get started on how to program useing python 2.4!!!

2005-03-11 Thread Brian van den Broek
Danny Yoo said unto the world upon 2005-03-11 16:07: On Fri, 11 Mar 2005 [EMAIL PROTECTED] wrote: When we ask: "Is the number 'one' greater than the number 'two'?", Python is telling us "No!" by giving us back the value 'False'. Whenever we ask Python a question that's a yes/no sort of thing, Pyt

Re: [Tutor] help me please!!!

2005-03-11 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 2005-03-11 19:00: Ok some thing is messed up.. when i try to open the python shell i get a error meesage saying socket error:connection refused and the head line at the top says IDLE subprocess error.. and then the python shell pops up with a e

Re: [Tutor] help me please!!!

2005-03-11 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 2005-03-11 20:21: ok i just restarted my pc and it works now thank you ..ok when i go to the start menu then go to all programs then to python 2.4 it gives me five things ok it says IDLE (python GUI) Module Docs python (command line) python manuals unins

Re: [Tutor] Python on USB device

2005-03-11 Thread Brian van den Broek
Ralfas Jegorovas said unto the world upon 2005-03-11 20:33: Hi everyone, I would like to know if it is possible to install python on a usb device and run it. I found some references to this topic in the archives but I didnt find the information conclusive. Any information would be appreciated.

Re: [Tutor] Whats so good about OOP ?

2005-03-12 Thread Brian van den Broek
Mark Kels said unto the world upon 2005-03-12 08:04: Hi list ! I want to know whats so great in OOP... I have learned some of it, but I don't understand why everybody like it so much... Can anyone give me an example for a task that could be done only with OOP or will be much simpler to do with it

[Tutor] Terminology WAS Whats so good about OOP ?

2005-03-13 Thread Brian van den Broek
Sean Perry said unto the world upon 2005-03-13 02:49: Brian van den Broek wrote: 1) Namespace issues With procedural (or imperative -- don't know which is the right terms for non-OOP code which employs functions) code, you can have issues caused by namespaces. Just yesterday, someone on the

Re: [Tutor] creating a tab delimited filename

2005-03-13 Thread Brian van den Broek
jrlen balane said unto the world upon 2005-03-13 19:37: so for example, i am creating a text file with file.write() how am i going to make the file a tab-delimited file??? any parameters needed??? >>> record1 = ['Foo', 'Bar', 'Baz'] >>> record2 = ['Ham', 'Spam', 'Eggs'] >>> records = [record1, reco

Re: [Tutor] How do you use pydoc?

2005-03-14 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 2005-03-14 19:28: I have read but don't under stand how to use pydoc. here what i read can't figer out how to use it. Hi, try this: Fire up IDLE and your web browser of choice. In IDLE's shell, type: import HTMLParser There is nothing special about the

Re: [Tutor] How do you use pydoc?

2005-03-15 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 2005-03-15 04:16: ok thanks for the help but i did what you said and heres what i got don't know exactly what i got but here lol will you help me figer what i got out and the module docs dose not work whem i go to the browser in opens a window sayi

Re: [Tutor] Help with unnamed arguments in a merge function

2005-03-15 Thread Brian van den Broek
Colin Corr said unto the world upon 2005-03-16 01:38: Greetings Tutors, I am having some difficulties with the concept of functions which can accept an unnamed number of arguments. Specifically, when trying to write a function that deals with an unnamed number of dictionaries. I want to be able to

[Tutor] subclassing across multiple modules

2005-03-17 Thread Brian van den Broek
Hi all, I'm uncertain of how to make use of OOP design across multiple modules. (Actually, on reflection, I'm not certain the multiple modules aspect is central.) I'm also uncertain of how to frame the question well, so please bear with me :-) A schematic of what I have (with fake names for eas

[Tutor] Re: subclassing across multiple modules

2005-03-17 Thread Brian van den Broek
Hi all, Thanks for the reply, Lloyd. Lloyd Kvam said unto the world upon 2005-03-17 20:36: You want a method in a base class to parse input and create instances of certain derived classes. Not quite. One class (Tree) parses a file and creates instances of Node1 and Node2 (derived from Node). None o

Re: [Tutor] subclassing across multiple modules

2005-03-17 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-03-17 20:44: Brian van den Broek wrote: A schematic of what I have (with fake names for ease of example) is a base module Toolkit.py and I want to write a module Application.py which specializes the behaviour of the Toolkit.py classes. (I'm using

Re: [Tutor] subclassing across multiple modules

2005-03-18 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-03-18 07:35: Brian van den Broek wrote: Kent Johnson said unto the world upon 2005-03-17 20:44: The multiple inheritance from MyNode and Toolkit.NodeX is a smell. I guess you do this because you want to override methods of Toolkit.Node as well as

[OT] Re: [Tutor] primes (Cautious remark on Python and Scheme)

2005-03-18 Thread Brian van den Broek
Gregor Lingl said unto the world upon 2005-03-18 19:57: Hi Danny! Preliminary remark: I know that "beautiful" and "beauty" are concepts very seldom applied to computer programs or programming languages. I suppose mainly because they are to a large extent a matter of taste ... Hi Gregor and all, Tho

  1   2   3   4   >