Re: [Tutor] IndexError: list index out of range [ Program work fine , but gives this message , guidance requested ]

2006-01-09 Thread Brian van den Broek
John Joseph said unto the world upon 09/01/06 03:47 AM: Hi Brian It was a excellent tutorial, Thanks a lot for the advice I got my concepts of def of functions , sort functions , count , cleared for me I was able to do and understand all the function

Re: [Tutor] IndexError: list index out of range [ Program work fine , but gives this message , guidance requested ]

2006-01-08 Thread Brian van den Broek
John Joseph said unto the world upon 08/01/06 06:36 AM: --- Guillermo Fernandez Castellanos [EMAIL PROTECTED] wrote: Hi, Look at this: i=[1,2,3] i[len(i)] Traceback (most recent call last): File stdin, line 1, in ? IndexError: list index out of range This means that I have tried to

Re: [Tutor] string to integer

2006-01-05 Thread Brian van den Broek
Alan Gauld said unto the world upon 05/01/06 04:16 PM: Here is how it should work: val(7) = 7 val(bbab7) = 7 val(aa7aa) = 7 val( 7) = 7 There is no direct equivalent for val() as shpwn above the nearest is int() or float() but that will only work with the first and last examples. (It

Re: [Tutor] TypeError: object doesn't support item assignment [ Trying to learn how to enter value in array ]

2006-01-02 Thread Brian van den Broek
John Joseph said unto the world upon 02/01/06 02:48 AM: Hi All I am trying to write a program in which I enter the no of students and then for the students I enter the marks and later on Display the marks The script which I wrote is given below , when I run the program I get error

Re: [Tutor] SyntaxError while defining tuple : Guidance requested

2005-12-31 Thread Brian van den Broek
John Joseph said unto the world upon 31/12/05 02:09 AM: Hi I am trying out learning python , using the book “Python Programming for the absolute beginner “ by Michael Dawson I get File page114.py, line 12 inventory = (Sword,Armor,Shield,Healing Potion)

Re: [Tutor] code review please

2005-12-28 Thread Brian van den Broek
Eakin, W said unto the world upon 27/12/05 09:59 AM: Hello, Although I've been coding in PHP and ASP and JavaScript for a couple of years now, I'm relatively new to Python. For learning exercises, I'm writing small Python programs that do limited things, but hopefully do them well. The

Re: [Tutor] code review please

2005-12-28 Thread Brian van den Broek
Kent Johnson said unto the world upon 28/12/05 07:06 AM: Brian van den Broek wrote: def punctuation_split(sequence): '''returns list of character sequences separating punctuation characters''' for mark in punctuation: sequence = sequence.replace(mark, ' %s ' %mark

[Tutor] new to linux and I cannot find some python things

2005-12-28 Thread Brian van den Broek
Hi all, I'm a week or so into having switched from WinXP to linux (ubuntu breezy). There is a lot to learn about the differences in the OS'es and that's just fine. But, a couple of things have been in my way with Python. Most notably, I don't know how one browses the documentation. On

Re: [Tutor] new to linux and I cannot find some python things

2005-12-28 Thread Brian van den Broek
Simon Gerber said unto the world upon 28/12/05 05:12 PM: Hi all, I'm a week or so into having switched from WinXP to linux (ubuntu breezy). There is a lot to learn about the differences in the OS'es and that's just fine. Excellent! Another Ubuntu Breezy user here. If there's anything Ubuntu

[Tutor] [OT] A thanks for all the help since I've found tutor

2005-12-28 Thread Brian van den Broek
Hi all, I'd like to thank the tutor community, especially Alan, Danny, and Kent, but all the other posters, regular and occasional, tutor or tutee, too. I've recently been engaged in what, for pre-python and -tutor me, would have been some deeply black magic unrelated to python, and the

Re: [Tutor] Books

2005-12-22 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 2005-12-22 05:00: While we are on the topic of books, what book would you recommend for the experienced C++/C# programmer looking to pick up Python? I've been looking at 'Python in a Nutshell' and 'Programming Python' on amazon.co.uk, as I've found

Re: [Tutor] question !

2005-12-20 Thread Brian van den Broek
Krava Magare said unto the world upon 2005-12-19 17:31: How can I remove and add record ( dictionary type) to a file. This is the program that I'm working on: the program should create a text file, print the contents of the text file, read the file after it's been created, add a record

Re: [Tutor] design advice for function

2005-12-19 Thread Brian van den Broek
Danny Yoo said unto the world upon 2005-12-18 15:19: This is caused by the line: print adder(). Obviously if adder() doesn't receive any arguments, it can't build the lists resulting in an IndexError. Right. Hello! Just wanted to clarify the situation: argsList ends up being the

Re: [Tutor] design advice for function

2005-12-18 Thread Brian van den Broek
Christopher Spears said unto the world upon 2005-12-18 01:30: I got my function to work! It takes arguments and adds them: Hi Christopher, great! def adder(**args): argsList = args.values() sum = argsList[0] for x in argsList[1:]: sum = sum + x return

Re: [Tutor] mysterious object

2005-12-17 Thread Brian van den Broek
Christopher Spears said unto the world upon 2005-12-17 17:42: I'm working on Exercise 4 from Part 4 from Learning Python. I'm trying to write a function using **args. I want to create a function that adds its arguments together. Here is what I have written: def adder(**args): for x

Re: [Tutor] Guess my number game

2005-12-15 Thread Brian van den Broek
Pujo Aji said unto the world upon 2005-12-15 14:52: Hi, your guess still use random.randrange that's make computer doesn't care about whether guess is low or higher than your number. This code should be like this: snip pujo's corrected code Hope this help pujo On 12/15/05, William

Re: [Tutor] empty class methods

2005-12-14 Thread Brian van den Broek
david said unto the world upon 2005-12-14 05:39: class foo: def sayhi(self): print 'hello world' def saybye(self): ##is there any reason for this to be here? pass class bar(foo): def saybye(self): print 'bye now' class baz(foo): def

Re: [Tutor] Introspecting class and method names

2005-12-14 Thread Brian van den Broek
Tim Johnson said unto the world upon 2005-12-14 18:02: I was pleasantly surprised to notice in a previous thread that python can automagically retrieve a class name thru __class__.__name__ 1)Can someone point me to further documentation on this topic? 2)Is it possible for the name of a class

Re: [Tutor] Editors

2005-12-13 Thread Brian van den Broek
Ismael Garrido said unto the world upon 2005-12-12 23:07: Will Harris wrote: Any of you familar with SPE http://freshmeat.net/projects/spe/?branch_id=44185release_id=214367 ? I found this just recently on freshmeat and was curious if anyone had used it? If so how well it works and what

Re: [Tutor] Editors

2005-12-13 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2005-12-13 12:23: Ismael Garrido said unto the world upon 2005-12-12 23:07: snip BTW: Does anyone know how to change the color configuration? I really like IDLE's one.. Kinda grew up with that one, I'd love to see it in SPE Ismael Hi Ismael

[Tutor] better way to make __repr__ methods for family of similar classes

2005-12-13 Thread Brian van den Broek
Hi all, I think I must be doing something incorrectly. I have a family of classes that all have the same arguments to their __init__ methods. I want to give them all __repr__ methods. From the docs, this method should be written so that it looks like a valid Python expression that could be

Re: [Tutor] better way to make __repr__ methods for family of similar classes

2005-12-13 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-12-13 20:57: snip much helpful goodness See Guido's Unifying Types and Classes essay and PEP 253 for details. And ask questions - maybe if I answer enough questions I will understand this stuff!

[Tutor] advice on idiom replacing if test requested

2005-12-11 Thread Brian van den Broek
Hi all, I have a case like this toy code: import random list1 = [1,2,3] list2 = ['a', 'b', 'c'] item = random.choice(list1 +list2) if item in list1: others = list2 else: others = list1 Another way occurred to me, but I wonder if I'm being too cute: item = random.choice(list1 +list2)

Re: [Tutor] advice on idiom replacing if test requested

2005-12-11 Thread Brian van den Broek
Danny Yoo said unto the world upon 2005-12-11 22:13: On Sun, 11 Dec 2005, Brian van den Broek wrote: I have a case like this toy code: import random list1 = [1,2,3] list2 = ['a', 'b', 'c'] item = random.choice(list1 +list2) if item in list1: others = list2 else: others = list1

Re: [Tutor] bnf

2005-12-10 Thread Brian van den Broek
david said unto the world upon 2005-12-10 06:31: ::= is bnf notation for is defined as please spend that extra minute googling before you bother all the nice people on this list. - Original Message - From: david To: tutor@python.org Sent: Saturday, December 10, 2005

Re: [Tutor] (no subject)

2005-12-07 Thread Brian van den Broek
david said unto the world upon 2005-12-03 20:36: hello again. i think my dig function is working correctly now. any input on how to save and restore all the rooms and descriptions? thanks for helping. Hi David, I'm catching up on mail backlog, so I'm a bit late, but I've a suggestion or two

Re: [Tutor] reduce with comprehension

2005-11-21 Thread Brian van den Broek
János Juhász said unto the world upon 2005-11-21 01:20: Hi, I can't imagine how this could be made with list comprehension. import operator a = (([1],[2],[3,31,32],[4]), ([5],[6],[7, 71, 72]), ([8],[9])) reduce(operator.add, a) # it makes a long list now ([1], [2], [3, 31, 32], [4],

Re: [Tutor] Lists with just an item

2005-11-21 Thread Brian van den Broek
Negroup - said unto the world upon 2005-11-21 03:26: Hi all. In my application I have chosen as data structure a list of dictionaries. Each dictionary has just one key and the corresponding value. structure = [{'field1': lenght1}, {'field2': lenght2}, ] Initially, to obtain the

Re: [Tutor] identify python interpreters platform?

2005-10-25 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-10-25 11:46: Ed Hotchkiss wrote: Well, on windows XP it returns nt for os.name http://os.name and for sys.platform it returns win32. how can i determine win2k, xp, 9x, etc etc ... I don't know...maybe something in os.environ?

Re: [Tutor] manipulating list of lists

2005-10-24 Thread Brian van den Broek
Vincent Gulinao said unto the world upon 2005-10-24 09:29: I have a list of lists of constant width (2 rows). I need to: 1. delete sub-lists with None element 2. sort it by any sub-list index say: [ ['c','d'], ['g',None], ['a','b',], ['e','f'] if sorted using 2nd index: [ ['a','b'],

Re: [Tutor] manipulating list of lists

2005-10-24 Thread Brian van den Broek
John Fouhy said unto the world upon 2005-10-24 22:18: On 25/10/05, Brian van den Broek [EMAIL PROTECTED] wrote: To sort by the second item, try def sort_by_second(sequence): decorated = [(x[1], x) for x in sequence] decorated.sort() return [x[1] for x in decorated

Re: [Tutor] setting

2005-10-19 Thread Brian van den Broek
Shi Mu said unto the world upon 2005-10-19 07:22: I have installed Python 2.3 and I type help() and then Keywords. I get a list of words. And it says that I can enter any of the words to get more help. I enter and and I get the following error message: Sorry, topic and keyword documentation

[Tutor] subclass problem: __names and type-checking

2005-10-08 Thread Brian van den Broek
Hi all, I'm having an issue which resists my attempts to give a snappy label to it. I have a solution that doesn't feel entirely correct, and which I cannot actual apply to my original case. The Issue: I have a class which I want to subclass. The subclass adds some additional arguments to

Re: [Tutor] Frustrated Beginner

2005-09-28 Thread Brian van den Broek
Rosalee Dubberly said unto the world upon 2005-09-28 15:41: I am trying to learn Python to use in my lesson plans. I am using Windows XP and the textbooks I am using are Beginning Python by WROX and Learning Pyhton by O'Reilly. I am definning a range of words 0 to 55, if the number is

Re: [Tutor] Question on listing cards, then deleting one or more items by user's choice.

2005-08-10 Thread Brian van den Broek
Nathan Pinno said unto the world upon 2005-08-09 23:31: Say I deal 5 cards, and then list them. How would I print the list of cards, with the numbers of each card(the position in the list)? Then delete a certain card or cards, based upon the user's choice?. Nathan Nathan, I write this

Re: [Tutor] Use functions re avoid Re: Can the following algorithmbe improved?

2005-08-09 Thread Brian van den Broek
Nathan Pinno said unto the world upon 2005-08-09 17:35: It printed 25.973 as the result. snip I don't think I got the math wrong. My thinking is there are 52**6 ways to choose 6 items from 52 if you don't care about duplicates, and 52*51*50*49*48*47 ways to choose if you do. (The first

Re: [Tutor] PLEASE HELP ON PYTHON

2005-07-16 Thread Brian van den Broek
Suranga Sarukkali said unto the world upon 16/07/2005 00:18: Hai, I (Suranga) started using Python2.4 Downloaded from the Original WebSite www.python.org a week ago but still I have not made any good progress on Programming and all that Tutorials available make it like hell to get started at

Re: [Tutor] deleting files that are older than x days old

2005-07-13 Thread Brian van den Broek
Mike Hansen said unto the world upon 13/07/2005 12:54: From a python program, I want to delete certain files that are older than x days old. To get the time that the file was last modified, it looks like I need to use os.path.getmtime(path). This gives you the time represented in the

Re: [Tutor] OT python Licences

2005-07-12 Thread Brian van den Broek
Dave S said unto the world upon 12/07/2005 05:49: This is a bit OT but here goes. My work wants me to write a fairly large python script to analyze some technical ASCII data files. Python and its libraries are GPL. That being the case am I right in thinking that my script would also have

[Tutor] recursion odities accross diferent versions of the 2.4.1 interpreter

2005-07-12 Thread Brian van den Broek
Hi all, I'm playing about with some recursive functions where I am getting near the recursion limit. This caused me to do a test, and I am puzzled by the different results when run in the prompt, IDLE and PythonWin. My simple test code is: c = 0 def recursion_test(): global c

Re: [Tutor] adding quotation marks around variables

2005-07-10 Thread Brian van den Broek
Robert said unto the world upon 10/07/2005 17:31: Hello all, I am a college student and I am currently working on a two numbers program for our class, The purpose of this program is to take user input and do some math functions. I have figured out how to do the math but I need to display

Re: [Tutor] Can I use def without ( ) at the end?

2005-07-09 Thread Brian van den Broek
Nathan Pinno said unto the world upon 09/07/2005 19:03: Hi all, Is the subject possible without getting an error? Nathan Pinno Crew, McDonalds Restaurant, Camrose, AB Canada http://www.npinnowebsite.ca/ No. Why do you want to do this? If it is to have a function with no arguments:

Re: [Tutor] Can I use def without ( ) at the end?

2005-07-09 Thread Brian van den Broek
Nathan Pinno said unto the world upon 09/07/2005 20:36: top post corrected - Original Message - From: Brian van den Broek Nathan Pinno said unto the world upon 09/07/2005 19:03: Hi all, Is the subject possible without getting an error? Nathan Pinno Crew

Re: [Tutor] Why does invalid syntax pop up?

2005-07-08 Thread Brian van den Broek
Nathan Pinno said unto the world upon 08/07/2005 16:14: Thanks, Danny and all. Adjusted the code, here is the newest code and error: snip def add_login_command(site,filename): print Add a login info card site = raw_input(Site: ) id = raw_input(User ID: )

Re: [Tutor] dictionary values

2005-07-08 Thread Brian van den Broek
Don Parris said unto the world upon 08/07/2005 20:09: On 7/8/05, luke p [EMAIL PROTECTED] wrote: snip what I want to do is find out which value in my dictionary is lowest. is there a dictionary function for this, like alpha.min() that will return a key:value pair of the lowest? I cannot find

Re: [Tutor] dictionary values

2005-07-08 Thread Brian van den Broek
luke p said unto the world upon 08/07/2005 19:40: just assume all the below code is correct. I am not having a problem with it, it is all for example only. I have a dictionary like this: alpha = {'a':0,'b':0, ... 'z':0} and the following code f = file(hamlet.txt,r) text = f.readlines()

Re: [Tutor] dictionary values

2005-07-08 Thread Brian van den Broek
Kent Johnson said unto the world upon 08/07/2005 21:09: Brian van den Broek wrote: if you care about the possibility that there is no unique key with the lowest value, I'd do: def get_low_keys(a_dict): ... '''- list of keys in a_dict with lowest value''' ... min_val = min(a_dict.values

Re: [Tutor] Can't figure out AttributeError message

2005-07-07 Thread Brian van den Broek
Jim Roush said unto the world upon 07/07/2005 12:42: I'm getting the following error message: AttributeError: 'tuple' object has no attribute 'seek' below is the code that produced the error. The line in question is marked with arrow in the left margin. Any help would be

Re: [Tutor] What's wrong with this code?

2005-07-05 Thread Brian van den Broek
Andre Engels said unto the world upon 05/07/2005 02:44: From the program:: answer = raw_input(What is the password? ) while password != answer: print The password is incorrect. snip Andre's description of the problem with the above OP's code I think you intended to make it so that the

Re: [Tutor] And function

2005-07-05 Thread Brian van den Broek
gordnjen said unto the world upon 04/07/2005 22:24: I need to write a program that will do the following: Ask the user's age. If their age is below 1 yr old, it prints you are old enought to eat baby food If they are over 16, it prints You are old enough to drive If they are over 65, it

Re: [Tutor] search through a list

2005-07-03 Thread Brian van den Broek
nephish said unto the world upon 02/07/2005 23:41: hey there i have a file that i want to read. each line in the file is the name of a file. the next line is how many lines are in that file. example of loglist.txt log1.txt 232 log2.txt 332 log3.txt 223 so log1 is a text file that

Re: [Tutor] OT self-implementation?

2005-07-02 Thread Brian van den Broek
Alan G said unto the world upon 02/07/2005 03:53: the original 19th c. German ;-) Naively, one thinks that to write anything in C, you'd have to *have* C to write in, etc. You are correct. Or at least you need the subset of C needed for a minimal compiler. So you figure out your minimal

[Tutor] code for expressing rationals in arbitrarty bases

2005-07-02 Thread Brian van den Broek
Hi all, In a private exchange about floating point representation error spun off of c.l.p., I'd sent someone some code to express rationals (subject to some constraints) in arbitrary bases, 1 base 37. The aim was to illustrate my claim that whether a rational had a repeating expansion[*] or

Re: [Tutor] slicing nested lists/dicts/tuples

2005-07-02 Thread Brian van den Broek
Luis N said unto the world upon 02/07/2005 07:51: On 7/2/05, Luis N [EMAIL PROTECTED] wrote: Umm, sorry, I meant: d[desc[x]] = exec('vw[%s].desc[%s]' % (r,x )) ___

[Tutor] OT self-implementation?

2005-07-01 Thread Brian van den Broek
Hi all, a bit off topic for Python Tutor, but I am think there are decent odds that folks here both know good resources and have an idea of what level would be appropriate for me. So, I hope no one minds. A recent thread on comp.lang.python has touched on to what extent C was written in C. I

Re: [Tutor] Missing methods in string module?

2005-06-29 Thread Brian van den Broek
Philip Carl said unto the world upon 29/06/2005 15:32: If I check the Python Libray Reference for String Methods (2.3.6.1) I find many methods listed e.g. decode, encode, endswith etc. that do not seem to be listed by the command line dir(string) in Python 2.4 under Windows XP, although

Re: [Tutor] super() and inherited attributes?

2005-06-27 Thread Brian van den Broek
Marcus Goldfish said unto the world upon 28/06/2005 00:58: Hi, The following example doesn't work as I would like-- the child instance doesn't expose the attribute set in the parent. Can someone point out what I am missing? Thanks, Marcus class Parent(object): def

[Tutor] filtering a webpage for plucking to a Palm

2005-06-26 Thread Brian van den Broek
Hi all, I have a Palm handheld, and use the excellent (and written in Python) Plucker http://www.plkr.org/ to spider webpages and format the results for viewing on the Palm. One site I 'pluck' is the Daily Python URL http://www.pythonware.com/daily/. From the point of view of a daily custom

Re: [Tutor] Numbers Characters As Dictionary Keys

2005-06-20 Thread Brian van den Broek
DC Parris said unto the world upon 20/06/2005 01:13: I have a dictionary called Menu_Main: Menu_Main = { 1: ['People', Call_Fam], 2: ['Groups', Call_Group], 3: ['Events', nullfunc], 4: ['Attendance', nullfunc], 5:

Re: [Tutor] Calling web browser from Python

2005-06-20 Thread Brian van den Broek
Andre Engels said unto the world upon 20/06/2005 04:26: Is it possible to call a web browser from Python, opening a certain page? Preferably the user's standard web browser. Andre Engels ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Numbers Characters As Dictionary Keys

2005-06-20 Thread Brian van den Broek
Don Parris said unto the world upon 20/06/2005 14:10: On Mon, 20 Jun 2005 09:11:53 +0100 Alan G [EMAIL PROTECTED] wrote: snip for m in menu.keys(): print %s\t%s % (m,menu[m][0]) I am curious what the % by itself is doing. snip Don Hi Don, it is indicating that the tuple that

Re: [Tutor] dictslists vs objects

2005-05-11 Thread Brian van den Broek
Chris Somerlot said unto the world upon 2005-05-11 15:02: I have been working on a scientific application for awhile, and have been using dictionaries and lists to store data and attributes of datasets. This is getting cumbersome as there are many, every dict/list is a premutation of another,

Re: [Tutor] scoping oddity

2005-05-07 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 2005-05-07 09:56: Good morning, I came across a rather odd issue with scoping. Can someone explain why testa and testc works, but not testb. I am running under python 2.4.1 on Windows NT. thanks, Michael SNIP def testb(astr): x = x -

Re: [Tutor] scoping oddity

2005-05-07 Thread Brian van den Broek
Bob Gailer said unto the world upon 2005-05-07 11:46: At 07:43 AM 5/7/2005, Brian van den Broek wrote: [EMAIL PROTECTED] said unto the world upon 2005-05-07 09:56: Good morning, I came across a rather odd issue with scoping. Can someone explain why testa and testc works

Re: [Tutor] properties and subclasses

2005-04-26 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-04-26 06:24: Brian van den Broek wrote: Hi all, I'm trying to get a hang of properties. It isn't quite clear to me what is the best way to make properties differ in subclasses. Some code snips to show what I've tried: I can get what I want this way: class

Re: [Tutor] properties and subclasses

2005-04-26 Thread Brian van den Broek
Alan Gauld said unto the world upon 2005-04-26 17:01: I had found the first thread you linked. I see what you mean about the cure -- my general belief is that *I* am unlikely to have problems for which meta-classes are really the best solution :-) Once you get used to them meta-classes are very

[Tutor] properties and subclasses

2005-04-25 Thread Brian van den Broek
Hi all, I'm trying to get a hang of properties. It isn't quite clear to me what is the best way to make properties differ in subclasses. Some code snips to show what I've tried: class A(object): ... def __init__(self): pass ... def prop_set(self): return I was set by A's method ...

Re: [Tutor] design questions: pythonic approach to ostriches

2005-04-24 Thread Brian van den Broek
Danny Yoo said unto the world upon 2005-04-23 22:16: I do remain a bit surprised that there seems to be no way to implement what I naively thought would be the obvious solution -- to remove an inherited method from the instance's dictionary. Hi Brian, If we're trying to do this, we probably

Re: [Tutor] design questions: pythonic approach to ostriches

2005-04-23 Thread Brian van den Broek
Alan Gauld said unto the world upon 2005-04-23 15:18: I am wondering about the Pythonic way to handle the problem of ostriches, emus, and penguins. (I cannot recall from where I got the example.) Its not really a Python issue its one of several similar conundrums in OOP in any language. Thanks

Re: [Tutor] Contructor Overloading and Function Tooktips

2005-04-19 Thread Brian van den Broek
Gooch, John said unto the world upon 2005-04-19 10:20: Brian, I think in the OO world it is called Polymorphism, where you have a single function name, but multiple definitions that are distinguished from one another by the number of arguments, type of arguments, and sometimes ( Smalltalk ) the

Re: [Tutor] Newbie question

2005-04-18 Thread Brian van den Broek
Lee Cullens said unto the world upon 2005-04-18 21:07: That just gives you a spacer line after your output. To see such as a separator change it to print '*'*10 On Apr 18, 2005, at 8:55 PM, Hoffmann wrote: Hi All: I am a newbie, and I am enjoying to study Python a lot. I have a question about

Re: [Tutor] Re: Eceptions

2005-04-17 Thread Brian van den Broek
Diana Hawksworth said unto the world upon 2005-04-16 17:39: SNIP Diana Hawksworth said unto the world upon 2005-04-15 22:25: Hello list, I have been trying to trap a string entry by raising an exception. The code follows - but the exception is never raised. What am I doing

Re: [Tutor] More Function Questions (Joseph Q.)

2005-04-17 Thread Brian van den Broek
Joseph Quigley said unto the world upon 2005-04-17 12:29: Hi all, Another function question. def bar(x, y): return x + y bar(4, 5) So I can put anything I want in there. What good is a function like that? Of course I know about. def foo(): print Hello all you who subscribe to the

Re: [Tutor] Re: Exceptions

2005-04-17 Thread Brian van den Broek
Diana Hawksworth said unto the world upon 2005-04-17 20:05: Brian - thanks for your continuing help! Here is ALL of the code. Sure hope you can help. Cheers. Diana Hi Diana, whew! A bit of an adventure, but I think I've got it. (The adventure comes in as I have used Tkinter about twice. I've

Re: [Tutor] Contructor Overloading and Function Tooktips

2005-04-15 Thread Brian van den Broek
Gooch, John said unto the world upon 2005-04-15 18:03: I have a couple of questions: Is there a way to create multiple __init__ routines in a Python Class? Hi John, I'm not sure what you mean by that. Could be me, or could be the question. :-) Secondly, I cannot remember how to make it so that

Re: [Tutor] exceptions

2005-04-15 Thread Brian van den Broek
Diana Hawksworth said unto the world upon 2005-04-15 22:25: Hello list, I have been trying to trap a string entry by raising an exception. The code follows - but the exception is never raised. What am I doing wrong? TIA Diana try: self.guess = int(self.num_ent.get())

Re: [Tutor] (no subject)

2005-04-14 Thread Brian van den Broek
Jim and Laura Ahl said unto the world upon 2005-04-14 02:09: How come when I ask it to print i[2:4] from an inputted string it gives me the letters between two and four But when I ask it to print i[-1:-4] it does not print anything. Jim Hi Jim, good to see you are still working at it. And posting

Re: [Tutor] New to programming question (Ben M.) (Joseph Q.)

2005-04-14 Thread Brian van den Broek
Joseph Quigley said unto the world upon 2005-04-14 10:46: SNIP Do you see? The == binds more tightly than the or. And, in python, 'Q' is considered True for the purposes of tests. SNIP What you can do instead is this: for letter in prefixes: if letter in ['O', 'Q']: print

Re: [Tutor] Question regarding the len function of a list while using a loop

2005-04-14 Thread Brian van den Broek
Ben Markwell said unto the world upon 2005-04-14 08:14: Could somebody explain to me why the code I used to complete this exercise doesn't work. And how do you send an integer to len? Thanks Ben == *As an exercise, write a loop that traverses a list and prints

Re: [Tutor] (no subject)

2005-04-14 Thread Brian van den Broek
Jim and Laura Ahl said unto the world upon 2005-04-14 12:08: SNIP 'my test string'[-1:-4:-1] 'gni' When I do this it tells me that the sequence index must be an integer. What is that telling me and how do I fix that? Jim Kent addressed that already. But, my mistake for not thinking about which

Re: [Tutor] Python backwards program (fwd)

2005-04-14 Thread Brian van den Broek
-- Forwarded message -- Date: Thu, 14 Apr 2005 00:41:40 -0500 From: Jim and Laura Ahl [EMAIL PROTECTED] To: Danny Yoo [EMAIL PROTECTED] Subject: Re: [Tutor] Python backwards program I thought you were on me a bit but I am so frustrated at this point. My instructor wrote and told

Re: [Tutor] Defining a function (Joseph Q.)

2005-04-13 Thread Brian van den Broek
Joseph Quigley said unto the world upon 2005-04-13 13:05: SNIP def silly(this_is_serious): print 'this is serious But I get an error! Traceback (most recent call last): File C:\Python24\saved\tmp1.py, line 7, in -toplevel- silly(this_is_serious) NameError: name 'this_is_serious' is

Re: [Tutor] Defining a function (Joseph Q.)

2005-04-12 Thread Brian van den Broek
Joseph Quigley said unto the world upon 2005-04-11 20:23: Well, now I've learned what def is good for. But what could I put in the parenthesis of def foo():? Of course self is always available, but what would maybe def foo(number1): do? An error right? So I now repeat my self, what else

Re: [Tutor] New to programming question

2005-04-12 Thread Brian van den Broek
Ben Markwell said unto the world upon 2005-04-12 12:56: This is an exercise from How to think like a Computer Scientist. The following example shows how to use concatenation and a for loop to generate an abecedarian series. Abecedarian refers to a series or list in which the elements appear in

Re: [Tutor] Cell Bio Newbie Here

2005-04-11 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 2005-04-11 14:54: Hey all, Sorry for the bother, thanks for the help. I'm trying to write a password guessing program to keep track of how many times the user has entered the password wrong. If it is more than 3 times, print ``That must have been

Re: [Tutor] Cell Bio Newbie Here

2005-04-11 Thread Brian van den Broek
Alberto Troiano said unto the world upon 2005-04-11 16:09: Hey Gary password=foobar ### the variable password has to be here because you are referiencing before the assignment inside the while sentence. You can also set it to password= and still will work because you have to tell (in this

Re: [Tutor] Cell Bio Newbie Here

2005-04-11 Thread Brian van den Broek
Alberto Troiano said unto the world upon 2005-04-11 17:43: Hi Brian Thanks for correcting me about the variable and reserved word differences (just for the record the problem is that my english is not so good, you see I'm from Bolivia so pardon my francôis :P) Hi Alberto, I wouldn't have known

Re: [Tutor] Trying to write a string formatting demo

2005-04-10 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2005-04-10 03:58: Dick Moores said unto the world upon 2005-04-10 03:38: I'm trying to write a string formatting demo, just for things like %.4f, %.3e, and %.3g. Here's what I have, but of course it doesn't work. What should the print statement

Re: [Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Brian van den Broek
John Ridley said unto the world upon 2005-04-10 10:05: Hello Brian I think the source of your problem is that the second instance of Wall_clock doesn't get deleted in the interval doctest. This is critical, because the is_instanced attribute is reset by __del__. def interval(self, interval_name

Re: [Tutor] Re: problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Brian van den Broek
Lee Harr said unto the world upon 2005-04-10 10:21: I have apparent interference between doctests embedded in the docstrings of different methods, and this interference also appears to be influenced by seemingly irrelevant things such as whether the module has a (non-doctest-containing) docstring

Re: [Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Brian van den Broek
) and the call of Wall_clock.__del__() helps explain a good deal. Thanks for pointing that out! See below for more... Brian van den Broek wrote: def check_point(self, check_point_name = None): '''Creates a new _Check_point instance; appends it to .data. SNIP new_wclock = Wall_clock

Re: [Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-10 Thread Brian van den Broek
John Ridley said unto the world upon 2005-04-10 19:19: --- Brian van den Broek [EMAIL PROTECTED] wrote: But: it still leaves me wondering why removing either a) the one-line no-doctest-containing docstring of the Wall_clock class or b) the unreferenced Wall_clock.stop_interval method made my

[Tutor] problems with doctest: apparent interferance between tests (LONG)

2005-04-09 Thread Brian van den Broek
Hi all, I must apologize for the length of the post. I have explained my problem as tersely as able, and have done my level-best to produce the minimum code snippet illustrative of my difficulties. But, as (I hope) will become clear, any substantial attempts to further cull it made the problem

Re: [Tutor] Re: If elif not working in comparison

2005-04-05 Thread Brian van den Broek
gerardo arnaez said unto the world upon 2005-04-05 23:00: Hi all. I would like some crituqe on this code. It is three separate files (all put on one web page) Each one is labeled in the comment that begins each section of code. It is a little longer when I put it all on one page, so I have it up

Re: [Tutor] RE: Using IDLE on Mac OS X?

2005-03-30 Thread Brian van den Broek
Lee Cullens said unto the world upon 2005-03-29 23:52: This is not a great way to start on this list, but I am having trouble with an annoyance that I have not been able to solve and have not found an answer to elsewhere. (Dual 2.5 Mac G5; 10.3.8; Python 2.3; retired software engineer getting

Re: hash issues [WAS] Re: [Tutor] hash()ing a list

2005-03-29 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 2005-03-29 03:14: Quoting Brian van den Broek [EMAIL PROTECTED]: I had thought lookup was by hash value, and thus expected the access to some_dict to cause troubles. Yet it worked. Is it that lookup is by hash value, and then equality if need be so

Re: hash issues [WAS] Re: [Tutor] hash()ing a list

2005-03-29 Thread Brian van den Broek
Danny Yoo said unto the world upon 2005-03-29 03:37: *Almost* all ints are fixed points for the hashing function in the sense that hash(some_int) == some_int. Almost all as: hash(-1) -2 Any idea why -1 is the sole exception? [warning: beginners, skip this. Completely inconsequential CPython

Re: [Tutor] If elif not working in comparison

2005-03-29 Thread Brian van den Broek
Sean Perry said unto the world upon 2005-03-29 03:48: Kent Johnson wrote: Not without using round. Have *NO* faith in floating points. This is especially true when you are creating the decimals via division and the like. What?!?! OK, floats don't necessarily have the exact values you expect

hash issues [WAS] Re: [Tutor] hash()ing a list

2005-03-28 Thread Brian van den Broek
Danny Yoo said unto the world upon 2005-03-28 14:33: Snip much useful discussion I know I'm rushing this, so please feel free to ask more questions about this. Hi Danny, Orri, and all, I'm really glad Orri raised the hashing issues he did, and appreciate your informative posts, Danny. :-) There

Re: [Tutor] python console, IDLE startup scripts

2005-03-21 Thread Brian van den Broek
Marcus Goldfish said unto the world upon 2005-03-21 17:06: Is there a special startup script the command-line python IDE and/or IDLE use? As per Liam's response to my previous post, I would like to use os.walk() to automatically set my sys.path() variable... Marcus

<    1   2   3   >