From teresa@saintmail.net Sun Apr 2 12:36:43 2000 From: teresa@saintmail.net (teresa@saintmail.net) Date: Sun, 02 Apr 2000 11:36:43 Subject: [Tutor] Hear this! Message-ID: <200004021936.PAA19614@tiroloco> FOLLOW ME TO FINANCIAL FREEDOM!! 1-888-217-0292 CALL NOW!! see below for remove. I am looking for people with a Good Work Ethic and extraordinary Desire to Earn at Least $10,000 per Month Working From Home! NO SPECIAL SKILLS OR EXPERIENCE REQUIRED. We will give you all the training and personal support you will need to ensure your success! This LEGITIMATE HOME-BASED INCOME OPPORTUNITY can put you back in Control of your Time, Your Finances, and Your Life! If you've tried other opportunities in the past that have failed to live up to their promises, THIS IS DIFFERENT THAN ANYTHING ELSE YOU'VE SEEN! THIS IS NOT A GET-RICH-QUICK SCHEME! YOUR FINANCIAL PAST DOES NOT HAVE TO BE YOUR FINANCIAL FUTURE! CALL ONLY IF YOU ARE SERIOUS! ABOUT MAKING MONEY!!! CALL NOW 1-888-217-0292 DON'T GO TO SLEEP WITHOUT LISTENING TO THIS! "All our dreams can come true - if we have the courage to pursue them" -Walt Disney Please leave your name and number and best time to call. DO NOT respond by Email. We are trttibly sorry if you have received this message in error. If you wish to be removed. Please, type "REMOVE"in the subject line. frice@beijingoffice.com From rosa16@pplmail.com Sun Apr 2 12:29:39 2000 From: rosa16@pplmail.com (rosa16@pplmail.com) Date: Sun, 02 Apr 2000 11:29:39 Subject: [Tutor] Hear this! Message-ID: <20000402182937.4657A1CDA7@dinsdale.python.org> FOLLOW ME TO FINANCIAL FREEDOM!! 1-888-217-0292 CALL NOW!! see below for remove. I am looking for people with a Good Work Ethic and extraordinary Desire to Earn at Least $10,000 per Month Working From Home! NO SPECIAL SKILLS OR EXPERIENCE REQUIRED. We will give you all the training and personal support you will need to ensure your success! This LEGITIMATE HOME-BASED INCOME OPPORTUNITY can put you back in Control of your Time, Your Finances, and Your Life! If you've tried other opportunities in the past that have failed to live up to their promises, THIS IS DIFFERENT THAN ANYTHING ELSE YOU'VE SEEN! THIS IS NOT A GET-RICH-QUICK SCHEME! YOUR FINANCIAL PAST DOES NOT HAVE TO BE YOUR FINANCIAL FUTURE! CALL ONLY IF YOU ARE SERIOUS! ABOUT MAKING MONEY!!! CALL NOW 1-888-217-0292 DON'T GO TO SLEEP WITHOUT LISTENING TO THIS! "All our dreams can come true - if we have the courage to pursue them" -Walt Disney Please leave your name and number and best time to call. DO NOT respond by Email. We are trttibly sorry if you have received this message in error. If you wish to be removed. Please, type "REMOVE"in the subject line. frice@beijingoffice.com From alan.gauld@bt.com Mon Apr 3 10:56:45 2000 From: alan.gauld@bt.com (Gauld,AJ,Alan,NEL1A GAULDAJ R) Date: Mon, 3 Apr 2000 10:56:45 +0100 Subject: [Tutor] IDLE - working in windows Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF6132@mbtlipnt02.btlabs.bt.co.uk> > David Kaye wrote: > | > |Why do so many on-line tutorials constantly suggest working > in a DOS window > One thing i prefer about the dos prompt is that i have a history of > commands i've typed available w/the up arrow. > p.s. unless i haven't found the keystroke that accesses > history in idle Get IDLE 0.5 its much better than the original. It has command history on ALT-P/N The original might have but I only found it on v0.5... Alan g. From timc@ans.net Mon Apr 3 14:35:51 2000 From: timc@ans.net (Tim Condit) Date: Mon, 3 Apr 2000 13:35:51 +0000 (GMT) Subject: [Tutor] list initialization question Message-ID: Greetings, Why thus? Why does this fail... >>> x = [] >>> for i in range(11): ... x[i] = whrandom.randint(1, 100) ... print i, x[i] ... Traceback (innermost last): File "", line 2, in ? IndexError: list assignment index out of range ... but this succeeds? >>> x = range(11) >>> x [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> for i in range(11): ... x[i] = whrandom.randint(1, 100) ... print i, x[i] ... 0 96 1 38 2 20 3 52 4 60 5 7 6 46 7 78 8 5 9 81 10 89 Is it necessary to not only initialize a list, but also to populate it? Or am I doing something wrong (I hope so..)? If you can add, delete, etc. items to a list, then why am I getting the error "list assignment index out of range"? Thanks! Tim From bwinton@tor.dhs.org Mon Apr 3 14:53:10 2000 From: bwinton@tor.dhs.org (Blake Winton) Date: Mon, 3 Apr 2000 09:53:10 -0400 Subject: [Tutor] list initialization question In-Reply-To: References: Message-ID: <20000403095310.A8897@tor.dhs.org> * Tim Condit [000403 09:38]: > Why does this fail... > > >>> x = [] > ... x[i] = whrandom.randint(1, 100) > IndexError: list assignment index out of range > > ... but this succeeds? > >>> x = range(11) > ... x[i] = whrandom.randint(1, 100) > > Is it necessary to not only initialize a list, but also to populate it? Or Exactly. Well, sort of exactly. The line "x=[]" says that x is a list, but it doesn't tell it how long it is. Well, it actually tells it that it's a list of length 0, so any index is out of the valid range. (As well, what do you expect the list to contain if you specify a length, but no data? I can guarantee that someone else expects something different, so in the spirit of Fewest Surprises, Python has decided to not let you do that. ;) For a Java-esque workaround try this instead: >>> x = [None]*10 >>> x [None, None, None, None, None, None, None, None, None, None] >>> x[1] = 3 >>> x [None, 3, None, None, None, None, None, None, None, None] Later, Blake. -- 9:44am up 5 days, 10:18, 2 users, load average: 0.54, 0.11, 0.04 From bwinton@tor.dhs.org Mon Apr 3 14:55:03 2000 From: bwinton@tor.dhs.org (Blake Winton) Date: Mon, 3 Apr 2000 09:55:03 -0400 Subject: [Tutor] list initialization question In-Reply-To: References: Message-ID: <20000403095503.A8936@tor.dhs.org> * Tim Condit [000403 09:38]: > Is it necessary to not only initialize a list, but also to populate it? Or Oh, yeah, there's also list.append(). So you could write: x=[] for i in range(11): x.append( i ) and it would the way you think. Later, Blake. -- 9:44am up 5 days, 10:18, 2 users, load average: 0.54, 0.11, 0.04 From amoreira@mercury.ubi.pt Mon Apr 3 15:55:19 2000 From: amoreira@mercury.ubi.pt (amoreira@mercury.ubi.pt) Date: Mon, 03 Apr 2000 14:55:19 +0000 Subject: [Tutor] list initialization question References: Message-ID: <38E8B0D7.43DF1FD2@mercury.ubi.pt> Hello! You can't assign to an element of a list before you create it. Then, either you populate it before (for instance, with zeros: x=[0]*11), or you use the append method of lists: x=[] for i in range(11): x.append(whrandom.randint(1,100)) print i,x[i] In this case, I'd choose the x.append way. You can add elements to a list using the append method, not by straight away assignement. Hope it helps, Ze Amoreira amoreira@mercury.ubi.pt Tim Condit wrote: > Why does this fail... > > >>> x = [] > >>> for i in range(11): > ... x[i] = whrandom.randint(1, 100) > ... print i, x[i] > ... > Traceback (innermost last): > File "", line 2, in ? > IndexError: list assignment index out of range > > ... but this succeeds? > > >>> x = range(11) > >>> x > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > >>> for i in range(11): > ... x[i] = whrandom.randint(1, 100) > ... print i, x[i] > ... > Is it necessary to not only initialize a list, but also to populate it? Or > am I doing something wrong (I hope so..)? If you can add, delete, etc. > items to a list, then why am I getting the error "list assignment index > out of range"? > > Thanks! > Tim From timc@ans.net Mon Apr 3 14:58:48 2000 From: timc@ans.net (Tim Condit) Date: Mon, 3 Apr 2000 13:58:48 +0000 (GMT) Subject: [Tutor] list initialization question In-Reply-To: Message-ID: Hello again, On Mon, 3 Apr 2000, Tim Condit wrote: > > Greetings, > > Why thus? > > Why does this fail... > > >>> x = [] > >>> for i in range(11): > ... x[i] = whrandom.randint(1, 100) > ... print i, x[i] > ... > Traceback (innermost last): > File "", line 2, in ? > IndexError: list assignment index out of range > > > ... but this succeeds? > > >>> x = range(11) > >>> x > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > >>> for i in range(11): > ... x[i] = whrandom.randint(1, 100) > ... print i, x[i] > ... > 0 96 > 1 38 > 2 20 > 3 52 > 4 60 > 5 7 > 6 46 > 7 78 > 8 5 > 9 81 > 10 89 > > > Is it necessary to not only initialize a list, but also to populate it? Or > am I doing something wrong (I hope so..)? If you can add, delete, etc. > items to a list, then why am I getting the error "list assignment index > out of range"? > > Thanks! > Tim > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor > From dhoward@sympatico.ca Mon Apr 3 15:57:27 2000 From: dhoward@sympatico.ca (Dan Howard) Date: Mon, 3 Apr 2000 10:57:27 -0400 Subject: [Tutor] Convert a file from sequential to direct access... In-Reply-To: Message-ID: Hi all... I'm a newbie to Python and would appreciate some advice on the best way to read a sequential file of data and map the contents to a direct access file. The sequential file has fixed size fields and each field is separated by spaces - some fields are filled with spaces as filler. The first field in each record is the key that I'd like to use to access the records. Any comments on best practices here would be most welcome Thanks Dan From alan.gauld@bt.com Mon Apr 3 17:28:12 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 3 Apr 2000 17:28:12 +0100 Subject: [Tutor] list initialization question Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF6137@mbtlipnt02.btlabs.bt.co.uk> > Why does this fail... > > >>> x = [] Here you create an empty list - ie. no members > >>> for i in range(11): > ... x[i] = whrandom.randint(1, 100) here you try to access the ith element of x - which doesn't exist yet.... Try x.append(....) instead. > ... but this succeeds? > > >>> x = range(11) Here you create a list with 11 members > >>> for i in range(11): > ... x[i] = whrandom.randint(1, 100) and access one of its members. > Is it necessary to not only initialize a list, but also to > populate it? Yes, or use append. Alan G. From Tim Condit Mon Apr 3 19:18:28 2000 From: Tim Condit (Tim Condit) Date: Mon, 3 Apr 2000 18:18:28 +0000 (GMT) Subject: [Tutor] list initialization question In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB202DF6137@mbtlipnt02.btlabs.bt.co.uk> Message-ID: Hello, I just want to say a quick thanks for all the help I've gotten on my question. Not only did I get very prompt responses, but they were consistent too! This is one of the things I really like about Python.. the clarity and consistency. (A lot of the time) I can focus on the problem I'm trying to solve, and the language lets me do it. The rest of the time, there is a friendly user community that is very helpful. :) Thanks, Tim On Mon, 3 Apr 2000 alan.gauld@bt.com wrote: > > Why does this fail... > > > > >>> x = [] > > Here you create an empty list - ie. no members > > > >>> for i in range(11): > > ... x[i] = whrandom.randint(1, 100) > > here you try to access the ith element of x > - which doesn't exist yet.... > > Try x.append(....) instead. > > > ... but this succeeds? > > > > >>> x = range(11) > > Here you create a list with 11 members > > > >>> for i in range(11): > > ... x[i] = whrandom.randint(1, 100) > > and access one of its members. > > > Is it necessary to not only initialize a list, but also to > > populate it? > > Yes, or use append. > > Alan G. > From dsh8290@rit.edu Mon Apr 3 22:52:11 2000 From: dsh8290@rit.edu (D-Man) Date: Mon, 03 Apr 2000 17:52:11 -0400 Subject: [Tutor] function overloading Message-ID: <38E9128B.B9D5731B@rit.edu> I would like to know if Python has a few features that I like to use in C++, function and operator overloading. Does python even allow operators to be defined for classes? I want to be able to specify both a default constructor for a class and a constructor that takes initial values of state as arguments. Thanks, -D From cwebster@nevada.edu Mon Apr 3 23:41:04 2000 From: cwebster@nevada.edu (Corran Webster) Date: Mon, 3 Apr 2000 15:41:04 -0700 Subject: [Tutor] function overloading In-Reply-To: <38E9128B.B9D5731B@rit.edu> Message-ID: At 5:52 PM -0400 3/4/00, D-Man wrote: > I would like to know if Python has a few features that I like to use in > C++, function and operator overloading. Does python even allow > operators to be defined for classes? Yes, there is pretty extensive support for overloading of operators via the double-underscored special methods, such as __add__ and __init__. See Section 3.3 of the Python Reference Manual for descriptions of the special methods which are recognised by Python. A trivial example: class Foo: def __init__(self, value): self.value = value def __add__(self, other): return Foo(self.value + other.value) a = Foo(5) b = Foo(3) c = a+b # c gets assigned Foo(8) print c.value # prints 8 The behaviour of overloaded functions/methods (if I remember my C++ terminology correctly) are best implemented in Python using default arguments, or by explicitly looking at the types of the arguments passed into the function. > I want to be able to specify both a default constructor for a class and > a constructor that takes initial values of state as arguments. This is best done via default arguments to the __init__ method: class Foo: def __init__(self, bar = 0): self.bar = bar def printbar(self): print self.bar x = Foo() x.printbar() # prints 0 y = Foo("Spam") y.printbar() # prints "Spam" WARNING! If you want a mutable argument as a default (such as a list or dictionary), do not use this: class Foo: def __init__(self, bar = []): ... use something like this instead: class Foo: def __init__(self, bar = None): if bar == None: bar = [] ... Once you get a better feel for how Python does things, this will make sense. Regards, Corran From dhoward@sympatico.ca Tue Apr 4 01:58:23 2000 From: dhoward@sympatico.ca (Dan Howard) Date: Mon, 3 Apr 2000 20:58:23 -0400 Subject: [Tutor] help converting a Sequential file to an indexed file Message-ID: Hi all... I'm a newbie to Python and would appreciate some advice on the best way to read a sequential file of data and map the contents to a direct access file. The sequential file has fixed size fields and each field is separated by spaces - some fields are filled with spaces as filler. The first field in each record is the key that I'd like to use to access the records. Any comments on best practices here would be most welcome Thanks Dan From sjb@crosswinds.net Tue Apr 4 06:22:13 2000 From: sjb@crosswinds.net (sjb@crosswinds.net) Date: Tue, 4 Apr 2000 00:22:13 -0500 Subject: [Tutor] AD&D Character generator problems Message-ID: <20000404002213.A805@crosswinds.net> To test out my abilities so far I am writing an AD&D character generator. It is going fine so far except that even if I tell the program not to it still re-rolls the character's stats. Hopefully someone here can spot the problem. # Samuel Bridgeland # --a script to generate AD&D 2nd ed. characters-- import random # ask for a name and make a file for it CharName= raw_input("What will you character's name be? ") CharFile= open(CharName, 'w') # generate stats for the character statlist= ['str', 'dex', 'con', 'int', 'wis', 'cha'] stats= {'str': 0, 'dex': 0, 'con': 0, 'int': 0, 'wis': 0, 'cha': 0} def MakeStats(): for genstat in statlist: stats[genstat]= random.randint(3, 18) for stat in statlist: print stat, ':', stats[stat] def OkStats(): goodstats= raw_input("Re-roll? ") if goodstats == 'yes' or 'y': MakeStats() elif goodstats == 'no' or 'n': return '' else: print "(y)es or (n)o please." OkStats() MakeStats() OkStats() And I know the rest isn't important(because the rest has yet to be written). -- SJB sjb@crosswinds.net From dworkin@ccs.neu.edu Tue Apr 4 16:00:11 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 04 Apr 2000 11:00:11 -0400 Subject: [Tutor] AD&D Character generator problems In-Reply-To: sjb@crosswinds.net's message of "Tue, 4 Apr 2000 00:22:13 -0500" References: <20000404002213.A805@crosswinds.net> Message-ID: sjb@crosswinds.net writes: > even if I tell the program not to it still re-rolls the character's > stats. Hopefully someone here can spot the problem. It's an operator precedence issue. > if goodstats == 'yes' or 'y': > MakeStats() This may be illustrative: >>> if 'a' == 'b' or 1: ... print 'NI!' ... NI! You should change the if to be something like: if goodstats == 'yes' or goodstats == 'y': If you don't want to be that wordy, you could do this instead: if goodstats in ('yes', 'y'): Good luck, and have fun. -Justin From alan.gauld@bt.com Tue Apr 4 17:28:28 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Tue, 4 Apr 2000 17:28:28 +0100 Subject: [Tutor] AD&D Character generator problems Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF6146@mbtlipnt02.btlabs.bt.co.uk> > def OkStats(): > goodstats= raw_input("Re-roll? ") > if goodstats == 'yes' or 'y': if goodstats == 'yes' or goodstats == 'y': What you did is checked whether 'y' is true - which being non zero it always is... Try putting parens round it to make it more obvious... if (goodstats == 'yes') or ('y'): ... HTH, Alan G. From dyoo@hkn.EECS.Berkeley.EDU Tue Apr 4 18:34:57 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Tue, 4 Apr 2000 10:34:57 -0700 (PDT) Subject: [Tutor] Re: Tutor digest, Vol 1 #281 - 7 msgs In-Reply-To: <20000404160009.27C811CD3D@dinsdale.python.org> Message-ID: > if goodstats == 'yes' or 'y': > MakeStats() > elif goodstats == 'no' or 'n': The way that python will probably group those lines is: if (goodstats == 'yes') or 'y': and likewise with the third line. Since 'y' is a true value (in Python), the program's always going to call MakeStats(). To fix this, you probably want to write if goodstats == 'yes' or goodstats == 'y' The or expression needs to be wedged in between independent expressions, so that's why the test against goodstats needs to be repeated. From cwebster@nevada.edu Tue Apr 4 19:15:10 2000 From: cwebster@nevada.edu (Corran Webster) Date: Tue, 4 Apr 2000 11:15:10 -0700 Subject: [Tutor] AD&D Character generator problems In-Reply-To: <20000404002213.A805@crosswinds.net> Message-ID: > To test out my abilities so far I am writing an AD&D character generator. It > is going fine so far except that even if I tell the program not to it still > re-rolls the character's stats. Hopefully someone here can spot the problem. > def MakeStats(): > for genstat in statlist: > stats[genstat]= random.randint(3, 18) I'm revealing my roleplayer past here, but this won't do what you want it to do. randint generates a uniform distribution - in AD&D terms you would be rolling 1d16+2 - when you want 3d6 which is a more bell-shaped distribution. I'd suggest that you write a little utility function, something like: def dice(number, sides, bonus = 0): # roll (number)d(sides)+(bonus) total = bonus for i in range(number): total = total + random.randint(1, sides) return total and then your MakeStats() would look something like this: def MakeStats(): for stat in statlist: stats[stat] = dice(3,6) print stat, ":", stats[stat] In fact, you would have a more versatile program if you passes the stats variable in and out, rather than using a global. > def OkStats(): > goodstats= raw_input("Re-roll? ") > if goodstats == 'yes' or 'y': The problem you noticed is here: Python reads this as ((goodstats == 'yes') or 'y') which evaluates to either 1 or 'y' (and because 'y' is not the empty string, it is always true). You should re-write the line to be something like if goodstats == 'yes' or goodstats == 'y': or if goodstats in ['yes', 'y']: > MakeStats() > elif goodstats == 'no' or 'n': And you'll need to make a similar change here for the same reason. > return '' > else: > print "(y)es or (n)o please." > OkStats() And this is rather unneeded recursion - a while loop would suit you better for this whole thing. There are a number of other style problems with the program, but since it's a learning exercise, not a production program, that shouldn't matter too much, but here are some pointers: - A character should probably be represented by an object, rather than a collection of data. Try writing it as a class, with methods like "MakeStats". - save output to a file until the end, once you know that the user really has something they want to save. - separate the user interface out from the generating routines as much as possible, possibly even putting it in a module of its own. You never know when you might want to add a nice little Tk GUI front-end to your code. - as I recall, AD&D has large amounts of data that your program will need to have access to (tables and so forth). Try to separate these out from the rest of the code as much as possible. - take care with your variable names. For example, the name "goodstats" above is misleading because goodstats == 'yes' means the stats are _bad_. With this sort of thing in mind, I'd re-write it something like this: # Another AD&D generator (code untested) import random, string # Data statnames = ['str', 'dex', 'con', 'int', 'wis', 'cha'] yes = ['yes', 'y'] no = ['no', 'n'] # Utility functions def dice(number, sides, bonus = 0): # roll (number)d(sides)+(bonus) total = bonus for i in range(number): total = total + random.randint(1, sides) return total def ask(question, responses = None, invalid = "Please enter a valid response."): # ask a question which must match a list of valid responses while 1: answer = raw_input(question) if responses: if string.lower(answer) in responses: return answer else: print invalid else: return answer # Main class class Character: def __init__(self, name): self.name = name self.stats = {} self.makestats(): def makestats(self): for stat in statnames: self.stats[stat] = dice(3,6) def printstats(self): for stat in statnames: print stat, ":", self.stats[stat] # etc # Interface def CreateChar(): name = raw_input("Name your character: ") char = Character(name) # generate stats while 1: char.printstats() answer = ask("Re-roll? (y/n) ", yes + no, "(y)es or (n)o please.") if answer in no: break char.makestats() #and so on if __name__ == "__main__": CreateChar() Regards, Corran From agusarif@tf.itb.ac.id Wed Apr 5 03:51:24 2000 From: agusarif@tf.itb.ac.id (Agus Arif) Date: Wed, 5 Apr 2000 09:51:24 +0700 (JAVT) Subject: [Tutor] ReadKey function in Python Message-ID: Hi. I'm a newbie in Python and want to know how to read-in each key in the keyboard (including the F1-F12, Ctrl, Alt, and Shift keys) in Python? Is it possible? Thanks, Agus Arif From Moshe Zadka Wed Apr 5 06:48:35 2000 From: Moshe Zadka (Moshe Zadka) Date: Wed, 5 Apr 2000 07:48:35 +0200 (IST) Subject: [Tutor] Re: Tutor digest, Vol 1 #281 - 7 msgs In-Reply-To: Message-ID: On Tue, 4 Apr 2000, Daniel Yoo wrote: > if goodstats == 'yes' or goodstats == 'y' Or, if you want to write more idiomatic Python, if goodstats in ('yes', 'y'): one-less-place-to-make-a-typo-is-one-less-typo-ly y'rs. Z. -- Moshe Zadka . http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From sgobillon@atos.be Wed Apr 5 08:39:33 2000 From: sgobillon@atos.be (sgobillon@atos.be) Date: Wed, 5 Apr 2000 09:39:33 +0200 Subject: [Tutor] (no subject) Message-ID: <38EB09D5.9193.CB075@localhost> unscribe ___________________________________________________ .--. |o_o | St=E9phane Gobillon, |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=3D(___/ ATOS N.V. TEL : +32.02.663.11.11 VORSTLAAN 191 +32.02.402.06.28 Direct B-1160 BRUSSEL +32.02.663.11.99 Fax BELGIUM +0495.24.48.10 GSM Email: SGOBILLON@ATOS.BE __________________________________________________ From borgulya@pons.sote.hu Wed Apr 5 12:35:17 2000 From: borgulya@pons.sote.hu (Borgulya Gabor) Date: Wed, 5 Apr 2000 13:35:17 +0200 (CEST) Subject: [Tutor] AD&D Character generator problems In-Reply-To: <20000404002213.A805@crosswinds.net> Message-ID: On Tue, 4 Apr 2000 sjb@crosswinds.net wrote: > # generate stats for the character > statlist= ['str', 'dex', 'con', 'int', 'wis', 'cha'] > stats= {'str': 0, 'dex': 0, 'con': 0, 'int': 0, 'wis': 0, 'cha': 0} > > def MakeStats(): > for genstat in statlist: > stats[genstat]= random.randint(3, 18) > for stat in statlist: > print stat, ':', stats[stat] Hi! A shorter version for the code fragment above: #statlist= ['str', 'dex', 'con', 'int', 'wis', 'cha'] stats= {'str': 0, 'dex': 0, 'con': 0, 'int': 0, 'wis': 0, 'cha': 0} def MakeStats(): for stat in stata.keys(): stats[stat]= random.randint(3, 18) print stat, ':', stats[stat] So the list statlist is not needed. Of course if you plan to add other keys to the stats vocabulary, it may be a practical way to keep the statlist to know which values have to be randomized. Yours, Gabor From bwinton@tor.dhs.org Wed Apr 5 14:23:49 2000 From: bwinton@tor.dhs.org (Blake Winton) Date: Wed, 5 Apr 2000 09:23:49 -0400 Subject: [Tutor] AD&D Character generator problems In-Reply-To: References: <20000404002213.A805@crosswinds.net> Message-ID: <20000405092349.A11879@tor.dhs.org> * Borgulya Gabor [000405 07:39]: > stats= {'str': 0, 'dex': 0, 'con': 0, 'int': 0, 'wis': 0, 'cha': 0} > def MakeStats(): > for stat in stata.keys(): ^^^^^ This should probably be "stats", not "stata". (Typo) > stats[stat]= random.randint(3, 18) And while I'm here, I might as well commment on this line. In AD&D, to get an stat for a character, you used to roll 3 6-sided dice. While it's true that would give you a number between 3 and 18, the distribution of values would be very different than the distribution you get from the above code. (i.e. in the code above, you have a 1 in 15 chance of getting a 3, but with dice, you have a 1 in 216 chance.) So for more accurate stats, you might want to change the line to stats[stat] = random.randint(1,6) + random.randint(1,6) + random.randint(1,6) Or, move that into a function called, say, GenerateSingleStat, which would return an integer. That way, if you decide to switch the algorithm later (to roll four dice, and take the best three, for instance), you know where to find it. Later, Blake. -- 9:12am up 7 days, 9:46, 1 user, load average: 0.32, 0.07, 0.02 From alan.gauld@bt.com Wed Apr 5 17:31:53 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 5 Apr 2000 17:31:53 +0100 Subject: [Tutor] ReadKey function in Python Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF6150@mbtlipnt02.btlabs.bt.co.uk> > I'm a newbie in Python and want to know how to read-in each key in the > keyboard (including the F1-F12, Ctrl, Alt, and Shift keys) in > Python? Is it possible? It is in Tkinter. See my tutor under the topic 'Event Driven Programming' for an example: http://www.crosswinds.net/~agauld But if anyone knows how in 'raw' Python I'd be interested too. Even more so if you can tell me how to do a QBASIC INKEY$ type function. I thought there might be a py-curses module but can't see one. (I usually use curses for this in C on Unix...) Alan G. From andre@beta.telenordia.se Wed Apr 5 22:08:52 2000 From: andre@beta.telenordia.se (=?ISO-8859-1?Q?Andr=E9_Dahlqvist?=) Date: Wed, 5 Apr 2000 23:08:52 +0200 (CEST) Subject: [Tutor] ReadKey function in Python In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB202DF6150@mbtlipnt02.btlabs.bt.co.uk> Message-ID: On Wed, 5 Apr 2000 alan.gauld@bt.com wrote: >I thought there might be a py-curses module but can't see one. (I usually >use curses for this in C on Unix...) "import curses" should do it:-) It's in the standard library. // Andr=E9 From sjb@crosswinds.net Wed Apr 5 21:21:30 2000 From: sjb@crosswinds.net (sjb@crosswinds.net) Date: Wed, 5 Apr 2000 15:21:30 -0500 Subject: [Tutor] AD&D Character Generator- thanks Message-ID: <20000405152130.A1330@crosswinds.net> Thanks to everyone for all the help I revieved as well as all the good ideas. -- SJB sjb@crosswinds.net From tourinho@descartes.ucpel.tche.br Thu Apr 6 04:09:43 2000 From: tourinho@descartes.ucpel.tche.br (Gustavo Passos Tourinho) Date: Thu, 6 Apr 2000 00:09:43 -0300 (EST) Subject: [Tutor] Table or Matrix Whatever Message-ID: Hi all again! :) I would like to know how can i creat a table or matrix. I need to store datas like: 1 2 3 q1 a b a,b q2 b a a And how can i acess the datas from table like: test[2][2]=a I think that is it! Thanks for any help From alan.gauld@bt.com Thu Apr 6 09:57:52 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Thu, 6 Apr 2000 09:57:52 +0100 Subject: [Tutor] ReadKey function in Python Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF6153@mbtlipnt02.btlabs.bt.co.uk> > On Wed, 5 Apr 2000 alan.gauld@bt.com wrote: > > >I thought there might be a py-curses module but can't see > one. (I usually > >use curses for this in C on Unix...) > > "import curses" should do it:-) It's in the standard library. Not for me its not... I tried Python 1.5.1 on Solaris and 1.5.2 under NT and win95. They all give: >>> import curses Traceback (innermost last): File "", line 1, in ? import curses ImportError: No module named curses >>> I did think a python curses would be kind of an obvious thing to find, but I can't see it. Maybe I'm looking in the wrong places? Alan G. From andre@beta.telenordia.se Thu Apr 6 12:27:52 2000 From: andre@beta.telenordia.se (=?ISO-8859-1?Q?Andr=E9_Dahlqvist?=) Date: Thu, 6 Apr 2000 13:27:52 +0200 (CEST) Subject: [Tutor] ReadKey function in Python In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB202DF6153@mbtlipnt02.btlabs.bt.co.uk> Message-ID: >Not for me its not... I tried Python 1.5.1 on Solaris=20 >and 1.5.2 under NT and win95. They all give: From=20the library reference: http://www.python.org/doc/1.5.2p2/lib/module-curses.html That's the library reference for 1.5.2, but I can't find it in the 1.5.1 docs, which is probably the reason you can't get it to work on Solaris using 1.5.1. I'm not sure this module works in Windows at all. // Andr=E9 From rbl@hal.cwru.edu Thu Apr 6 11:34:25 2000 From: rbl@hal.cwru.edu (Robin B. Lake) Date: Thu, 6 Apr 2000 06:34:25 -0400 (EDT) Subject: [Tutor] Table or Matrix Whatever Message-ID: <200004061034.GAA14623@hal.epbi.cwru.edu> > Hi all again! :) > > I would like to know how can i creat a table or matrix. I need to store > datas like: > > 1 2 3 > q1 a b a,b > q2 b a a > Because there is one element that is a tuple, I would guess that you would want to create your table/matrix tuple-capable. And assuming you will want to CHANGE the matrix elements at some time, I'd check which Python structures are mutable. I would first try a dict[ ] structure, using the (qn, n) matrix index as the index for the dict. Then I'd look at some dict examples to see how best to access the elements. I'm not at the office yet, so I can't look up the answers (nor have I had my caffeination yet) ... Cheers, Rob Lake rbl@hal.cwru.edu > And how can i acess the datas from table like: > test[2][2]=a > > I think that is it! > Thanks for any help > From arcege@shore.net Thu Apr 6 12:47:47 2000 From: arcege@shore.net (Michael P. Reilly) Date: Thu, 6 Apr 2000 07:47:47 -0400 (EDT) Subject: [Tutor] ReadKey function in Python In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB202DF6153@mbtlipnt02.btlabs.bt.co.uk> from "alan.gauld@bt.com" at Apr 06, 2000 09:57:52 AM Message-ID: <200004061147.HAA28226@northshore.shore.net> > > > On Wed, 5 Apr 2000 alan.gauld@bt.com wrote: > > > > >I thought there might be a py-curses module but can't see > > one. (I usually > > >use curses for this in C on Unix...) > > > > "import curses" should do it:-) It's in the standard library. > > Not for me its not... I tried Python 1.5.1 on Solaris > and 1.5.2 under NT and win95. They all give: > > >>> import curses > Traceback (innermost last): > File "", line 1, in ? > import curses > ImportError: No module named curses > >>> > > I did think a python curses would be kind of an obvious > thing to find, but I can't see it. Maybe I'm looking in > the wrong places? The curses module is optional, like _locale, stdwin and various dbm modules. The creation of it must be activated in Modules/Setup of the source distribution. There are different curses packages that could be compiled with the module, and not all platforms will have curses available (OS/2, Mac, VMS). Also, the original question was to get access to key-strokes (CntlLeft, ShiftLck, etc.), not just input characters. UNIX terminal device drivers do not give access to such low-level values. Curses is designed and built on top of the terminal device driver; it's likely that the WinXX port of (n)curses will not have that functionality as well. X-Windows and Windows will have access to those values, but in different manners. For example through Tkinter, this would be thru the event system (the "keysym" attribute of the event object). WxPython and win32ui will likely have something similar. -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From tescoil@rtpro.net Thu Apr 6 14:14:20 2000 From: tescoil@rtpro.net (Tesla Coil) Date: Thu, 06 Apr 2000 08:14:20 -0500 Subject: [Tutor] Table or Matrix Whatever References: Message-ID: <38EC8DAC.8433A48@rtpro.net> On 6 Apr 2000, Gustavo Passos Tourinho > I would like to know how can i creat a table or matrix. > I need to store datas like: > > 1 2 3 > q1 a b a,b > q2 b a a > > And how can i acess the datas from table like: > test[2][2]=a test[2][2] would be out of range because indexing begins at zero. Otherwise... >>> a = 42 >>> b = 23 >>> test = [[a, b, [a, b]], [b, a, a]] >>> test[0][0] 42 >>> test[0][1] 23 >>> test[0][2] [42, 23] >>> test[0][2][0] 42 >>> test[0][2][1] 23 >>> test[1][0] 23 >>> test[1][1] 42 >>> test[1][2] 42 >>> a=90 #Take note, we've loaded test with values >>> test #to which a and b point, not the pointers. [[42, 23, [42, 23]], [23, 42, 42]] >>> test[0][2] = [a,b] >>> test [[42, 23, [90, 23]], [23, 42, 42]] >>> test = [[a, b, [a, b]], [b, a, a]] [[90, 23, [90, 23]], [23, 90, 90]] Now that we have this much out of the way, someone else can elaborate on the topic... From bwinton@tor.dhs.org Thu Apr 6 15:13:37 2000 From: bwinton@tor.dhs.org (Blake Winton) Date: Thu, 6 Apr 2000 10:13:37 -0400 Subject: [Tutor] Re: [Distutils] Installation on Win2K In-Reply-To: References: <000001bf9f19$d189a1c0$0100a8c0@pinol1.sfba.home.com> Message-ID: <20000406101337.A13078@tor.dhs.org> * Robin Becker [000406 03:05]: > On my system I have Microsoft Chat, Microsoft FrontPage Express, > Microsoft Visual Studio, .... all with spaces in side in directory > Program Files. If I want to set up a path programatically to my VC++ > files (inside Visual studio) how do I know to use MICROS~1 rather than > MICROS~6? Depending on how programmatically you're talking about, there's a Win32 function which will return the short name for any given long name. But then you're interfacing with the system DLLs, and down that road lies madness. ;) Or parse the output of "dir /x"... Later, Blake. -- 10:08am up 8 days, 10:42, 1 user, load average: 0.00, 0.00, 0.00 From borgulya@pons.sote.hu Thu Apr 6 17:02:09 2000 From: borgulya@pons.sote.hu (Borgulya Gabor) Date: Thu, 6 Apr 2000 18:02:09 +0200 (CEST) Subject: [Tutor] lambda problem Message-ID: Dear Tutors, Isn't it possible to use a lambda inside a lamda? I demonstrate what I want to do: 1. without "lambda in lambda": ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> a=map(lambda x:x+1, [30,40]) >>> a [31, 41] >>> b=map(lambda x:x+2, [30,40]) >>> b [32, 42] >>> c=map(lambda x:x+3, [30,40]) >>> c [33, 43] >>> li=[a,b,c] >>> li [[31, 41], [32, 42], [33, 43]] 2. With a "lambda in lambda" shortcut: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> li=map(lambda y:map(lambda x:x+y, [30,40]),[1,2,3]) Traceback (innermost last): File "", line 1, in ? li=map(lambda y:map(lambda x:x+y, [30,40]),[1,2,3]) File "", line 1, in li=map(lambda y:map(lambda x:x+y, [30,40]),[1,2,3]) File "", line 1, in li=map(lambda y:map(lambda x:x+y, [30,40]),[1,2,3]) NameError: y The inner lambda seems not to recognize the variable y defined by the outer lambda. Do I want something impossible or do I misunderstand how lambda is functionning? Gabor From cwebster@nevada.edu Thu Apr 6 17:23:23 2000 From: cwebster@nevada.edu (Corran Webster) Date: Thu, 6 Apr 2000 09:23:23 -0700 Subject: [Tutor] lambda problem In-Reply-To: Message-ID: > Dear Tutors, > > Isn't it possible to use a lambda inside a lamda? The short answer is yes - see below. > 2. With a "lambda in lambda" shortcut: > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > >>> li=map(lambda y:map(lambda x:x+y, [30,40]),[1,2,3]) > Traceback (innermost last): > File "", line 1, in ? > li=map(lambda y:map(lambda x:x+y, [30,40]),[1,2,3]) > File "", line 1, in > li=map(lambda y:map(lambda x:x+y, [30,40]),[1,2,3]) > File "", line 1, in > li=map(lambda y:map(lambda x:x+y, [30,40]),[1,2,3]) > NameError: y > > The inner lambda seems not to recognize the variable y defined by the > outer lambda. Do I want something impossible or do I misunderstand how > lambda is functionning? The problem is that the inner lambda has no knowledge of the variable y (this is indicated by the NameError This is not a problem particular to lambdas, but to any python function. What you are doing is effectively: def f(y): def g(x): # can't see y in here! return x+y map(g, [30,40]) map(f, [1, 2, 3]) and this won't work either. The problem is how Python scopes variables - there is no nesting of scopes, so there is no way (without severe hackish wizardry) for g to get any information about f's variables. This is probably because functions in Python are first-class objects, and so it's unclear whether the 'y' you want is the one from f, or perhaps one from some other function which has managed to get ahold of g (perhaps because f returned g) and is calling it. There is a work-around, which is standard to the point of being idiomatic for lambdas in Python. By passing y in as a default argument to the second lambda, you get the result you want: >>> li = map(lambda y: map(lambda x, y=y: x+y, [30,40]),[1,2,3]) >>> li [[31, 41], [32, 42], [33, 43]] This isn't entirely foolproof (you can get weird results if y is mutable and the lambda mutates it somehow), and is definitely hackish, but it works. Regards, Corran From alan.gauld@bt.com Thu Apr 6 17:42:35 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Thu, 6 Apr 2000 17:42:35 +0100 Subject: [Tutor] Table or Matrix Whatever Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF6156@mbtlipnt02.btlabs.bt.co.uk> > I would like to know how can i creat a table or matrix. I > need to store datas like: > > 1 2 3 > q1 a b a,b > q2 b a a > > And how can i acess the datas from table like: > test[2][2]=a A two dimensional list? >>> table = [ ['a','b',('a','b')],['b','a','a']] >>> table[1][1] 'a' >>> table[0][2] ('a','b') Note: it has to be a zero based index. Alan g. From borgulya@pons.sote.hu Thu Apr 6 17:54:46 2000 From: borgulya@pons.sote.hu (Borgulya Gabor) Date: Thu, 6 Apr 2000 18:54:46 +0200 (CEST) Subject: [Tutor] lambda problem In-Reply-To: Message-ID: Hello Corran, Thanks for the code tip and for the explanation of scopes! Gabor From dworkin@ccs.neu.edu Thu Apr 6 23:07:33 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 06 Apr 2000 18:07:33 -0400 Subject: [Tutor] Table or Matrix Whatever In-Reply-To: Gustavo Passos Tourinho's message of "Thu, 6 Apr 2000 00:09:43 -0300 (EST)" References: Message-ID: Gustavo Passos Tourinho writes: > I would like to know how can i creat a table or matrix. I need to store > datas like: > > 1 2 3 > q1 a b a,b > q2 b a a > > And how can i acess the datas from table like: > test[2][2]=a There are several ways. You could use a dictionary with tuples for keys: >>> table = {} >>> table[('q1', 1)] = 'a' >>> table[('q1', 2)] = 'b' >>> table[('q1', 3)] = ('a', 'b') >>> table[('q2', 1)] = 'b' >>> table[('q2', 2)] = 'a' >>> table[('q2', 3)] = 'a' >>> table[('q1', 3)] ('a', 'b') >>> table[('q2', 2)] 'a' >>> table[('q1', 3)] = 'a' >>> table[('q1', 3)] 'a' You could also use nested lists... -Justin From alextp@ig.com.br Fri Apr 7 00:56:26 2000 From: alextp@ig.com.br (Alexandre Passos) Date: Thu, 06 Apr 2000 20:56:26 -0300 Subject: [Tutor] Problems with tkinter callbacks Message-ID: <38ED242A.8645162A@ig.com.br> I tried to make a big program, but I had problems with changing objects's positions with the grid manager. I wrote a simple program to test solutions an couldn't find any. Thanks for every help. I try this: #! /usr/bin/env python from Tkinter import * root = Tk() class All: def __init__(self): self.main_screen=Frame(root, width=600, height=200, bg='', colormap='new' ) self.main_screen.grid() Label(self.main_screen, text="Nothing will be here when the program is done").grid(row=0, column=1) self.title = Label(self.main_screen, text="Frame_Title") self.title.grid(row=0, column=0) self.title.bind('<1>',self.callback) def callback(self): self.title.grid_configure(column=2) all=All() root.mainloop() ang get this confusing error message: Exception in Tkinter callback Traceback (innermost last): File "/var/tmp/python-root/usr/lib/python1.5/lib-tk/Tkinter.py", line 752, in __call__ return apply(self.func, args) TypeError: too many arguments; expected 1, got 2 Again, thanks for any help on this. "The thruth is out there" X-Files From jonggi98@hotmail.com Fri Apr 7 04:20:28 2000 From: jonggi98@hotmail.com (Jonathan Harrison) Date: Thu, 06 Apr 2000 20:20:28 PDT Subject: [Tutor] how do I get off this list? Message-ID: <20000407032028.62600.qmail@hotmail.com> I was wondering how to take myself off of this list.... Thanks -Jon ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From mackay@streathamcommon.demon.co.uk Fri Apr 7 15:19:00 2000 From: mackay@streathamcommon.demon.co.uk (Andrew MacKay) Date: Fri, 7 Apr 2000 15:19:00 +0100 Subject: [Tutor] adding together strings Message-ID: <002201bfa09c$65492ce0$7604e4d4@demon.co.uk> Hello python tutors, I hope you can help me with a little problem. (I am a beginner). I am working on a program which will access some files in a folder on the desktop without me having to type in the whole address every time. Here is what I would like to do. filename = raw_input("type name of file ") filename="C:\windows\desktop\targetfolder\" + filename When I try this kind of thing at the command line it works fine, but when I put it into a module it tells me that "filename" is an "invalid token" Help! Andrew From cwebster@nevada.edu Fri Apr 7 16:02:02 2000 From: cwebster@nevada.edu (Corran Webster) Date: Fri, 7 Apr 2000 08:02:02 -0700 Subject: [Tutor] adding together strings In-Reply-To: <002201bfa09c$65492ce0$7604e4d4@demon.co.uk> Message-ID: > Hello python tutors, > > I hope you can help me with a little problem. (I am a beginner). > I am working on a program which will access some files in a folder on the > desktop without me having to type in the whole address every time. > Here is what I would like to do. > > filename = raw_input("type name of file ") > filename="C:\windows\desktop\targetfolder\" + filename > > When I try this kind of thing at the command line it works fine, but when I > put it into a module it tells me that "filename" is an "invalid token" I'm suprised it works at the command line - you have a problem here with Python's rules for escaping special characters in strings. The primary problem is that the \ before the final " on the second line escapes the ", so that Python thinks of it as being a quote within the string rather than the quote that ends the string. Similarly, although you may not have noticed it, the \t in \targetfolder gets turned into a tab. You can fix this immediately by something like: filename = raw_input("type name of file ") filename="C:\\windows\\desktop\\targetfolder\\" + filename In other words, in regular strings in Python, whenevr you want a "\" you should type a "\\". A better solution to your problem, because it will be breeding good habits for the future, is to use the os.path module's functions, particularly os.path.join. This will help if you ever have to work with unix or mac systems in python; and means you don't have to work with all those double backslashes on your system. Hope this helps. Regards, Corran From alan.gauld@bt.com Fri Apr 7 17:27:05 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Fri, 7 Apr 2000 17:27:05 +0100 Subject: [Tutor] Problems with tkinter callbacks Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF615E@mbtlipnt02.btlabs.bt.co.uk> > I tried to make a big program, but I had problems with changing > objects's positions with the grid manager. I wrote a simple program to > test solutions an couldn't find any. Thanks for every help. Not sure this is relevant, or even correct but it looks slightly dodgy to me... > self.title.grid(row=0, column=0) > self.title.bind('<1>',self.callback) > > def callback(self): > self.title.grid_configure(column=2) > return apply(self.func, args) > TypeError: too many arguments; expected 1, got 2 Suggests that the bind passes an event to your callback function but it does not expect any arguments(except the hidden 'self'). So maybe adding a parameter to the callback method will help? OTOH me taking the time to read the code and work out whats going might help too... Sorry, but I'm going home, its been a long week! Alan G. From dworkin@ccs.neu.edu Fri Apr 7 18:50:48 2000 From: dworkin@ccs.neu.edu (Justin Sheehy) Date: 07 Apr 2000 13:50:48 -0400 Subject: [Tutor] how do I get off this list? In-Reply-To: "Jonathan Harrison"'s message of "Thu, 06 Apr 2000 20:20:28 PDT" References: <20000407032028.62600.qmail@hotmail.com> Message-ID: "Jonathan Harrison" writes: > I was wondering how to take myself off of this list.... Read any message that you have received from the list, and follow the URL at the bottom. -Justin From slay3241@bright.net Fri Apr 7 20:26:27 2000 From: slay3241@bright.net (bill slaybaugh) Date: Fri, 07 Apr 2000 15:26:27 -0400 Subject: [Tutor] Tkinter vs wxPython Message-ID: <38EE3663.DFE7F8D2@bright.net> I'm just getting my legs under me writing some fairly basic Python scripts. So far the need for a GUI is minimal, but there have already been times when I would like to put a simple interface in front of a 95/98 user. I had begun to work with Tkinter and barely had the first couple things running when I stumbled unto wxPython. It appears to have good endorsements. Is there a consensus on how Tkinter stacks up against wxPython? Bill Slaybaugh Novar Controls From plutek@infinity.net Sat Apr 8 02:46:10 2000 From: plutek@infinity.net (Peter Lutek) Date: Fri, 7 Apr 2000 21:46:10 -0400 Subject: [Tutor] secondary prompt Message-ID: <001901bfa0fc$4c4fe390$380970d1@palstudio> This is a multi-part message in MIME format. ------=_NextPart_000_0014_01BFA0DA.AFDFD5E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable just starting..... here's a simple question: when entering code in interactive mode, how do you tell the interpreter = that the next line is a continuation (and have it display the secondary = prompt), rather than a new line? -p ------=_NextPart_000_0014_01BFA0DA.AFDFD5E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
just starting..... here's a simple = question:
 
when entering code in interactive mode, how do you = tell the=20 interpreter that the next line is a continuation (and have it display = the=20 secondary prompt), rather than a new line?
 
-p
------=_NextPart_000_0014_01BFA0DA.AFDFD5E0-- From jstok@bluedog.apana.org.au Sat Apr 8 03:13:59 2000 From: jstok@bluedog.apana.org.au (Jason Stokes) Date: Sat, 8 Apr 2000 12:13:59 +1000 Subject: [Tutor] secondary prompt Message-ID: <005b01bfa100$1ec0ffa0$43e60ecb@jstok> Peter Lutek wrote: >just starting..... here's a simple question: > >when entering code in interactive mode, how do you tell the interpreter that the next >line is a continuation (and have it display the secondary prompt), rather than a new >line? Python's syntax indicates when a statement requires a sub-block automatically. As soon as you enter, eg, def fun1(): It'll automatically respond with a secondary prompt. From arcege@shore.net Sat Apr 8 03:43:39 2000 From: arcege@shore.net (Michael P. Reilly) Date: Fri, 7 Apr 2000 22:43:39 -0400 (EDT) Subject: [Tutor] secondary prompt In-Reply-To: <001901bfa0fc$4c4fe390$380970d1@palstudio> from "Peter Lutek" at Apr 07, 2000 09:46:10 PM Message-ID: <200004080243.WAA21217@northshore.shore.net> > when entering code in interactive mode, how do you tell the interpreter = > that the next line is a continuation (and have it display the secondary = > prompt), rather than a new line? There are three basic times when you will get a secondary prompt. 1. when you explicitly add a line continuation with a backslash (\): >>> print "The Knights who " + \ ... "say Ni!" (reference: Python Language Reference, 2.1.4 Explicit line joining) 2. when various forms of parentheses are incomplete: >>> print ("The Knights who " + ... "say Hi!") >>> a = { ... 'spam': 'eggs' ... } (reference: Python Language Reference, 2.1.5 Implicit line joining) 3. when Python's syntax demands it, with multi-line statements: >>> if 1: ... pass this will be most lines that end with ":" (reference: Python Language Reference, 7. Compound statements) Enjoy, -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From plutek@infinity.net Sat Apr 8 03:59:50 2000 From: plutek@infinity.net (Peter Lutek) Date: Fri, 7 Apr 2000 22:59:50 -0400 Subject: [Tutor] secondary prompt References: <005b01bfa100$1ec0ffa0$43e60ecb@jstok> Message-ID: <002501bfa106$97f206c0$380970d1@palstudio> > It'll automatically respond with a secondary prompt. ahhh... yes, i've seen that happen now. i was misled by some stuff in the tutorial, like: >>> # This is a comment ... 2+2 4 and like: >>> # Fibonacci series: ... # the sum of two elements defines the next ... a, b = 0, 1 where the secondary prompt is not appropriate (and does not come up in the interpreter when entering these lines). thanks for your response! -p From jstok@bluedog.apana.org.au Sat Apr 8 14:10:54 2000 From: jstok@bluedog.apana.org.au (Jason Stokes) Date: Sat, 8 Apr 2000 23:10:54 +1000 Subject: [Tutor] secondary prompt Message-ID: <00b601bfa15b$e1072160$44e60ecb@jstok> -----Original Message----- From: Peter Lutek To: Jason Stokes ; tutor@python.org Date: Friday, April 07, 2000 8:12 AM Subject: Re: [Tutor] secondary prompt >> It'll automatically respond with a secondary prompt. > >ahhh... yes, i've seen that happen now. >i was misled by some stuff in the tutorial, like: > >>>> # This is a comment >... 2+2 >4 > > >and like: > >>>> # Fibonacci series: >... # the sum of two elements defines the next >... a, b = 0, 1 > > > >where the secondary prompt is not appropriate (and does not come up in the >interpreter when entering these lines). Hmm.. that might be something to look at in the tutorial. Are these misleading? They certainly were for you. From alextp@ig.com.br Fri Apr 7 23:41:46 2000 From: alextp@ig.com.br (Alexandre Passos) Date: Fri, 07 Apr 2000 19:41:46 -0300 Subject: [Tutor] Problems with frame size Message-ID: <38EE642A.E69F95A8@ig.com.br> In the same program, I noticed that it doesn't takes the frame size it should and the window takes just the Label widget's size and not the size it should. #! /usr/bin/env python from Tkinter import * root = Tk() class All: def __init__(self): self.main_screen=Frame(root, width=600, height=200, bg='', colormap='new' ) self.main_screen.grid() Label(self.main_screen, text="Nothing will be here when the program is done").grid(row=0, column=1) self.title = Label(self.main_screen, text="Frame_Title") self.title.grid(row=0, column=0) self.title.bind('<1>',self.callback) def callback(self, event): self.title.grid_configure(column=2) all=All() root.mainloop() "The thruth is out there" X-Files From rbl@hal.cwru.edu Mon Apr 10 20:30:33 2000 From: rbl@hal.cwru.edu (Robin B. Lake) Date: Mon, 10 Apr 2000 15:30:33 -0400 (EDT) Subject: [Tutor] Python using "posting" in URL Message-ID: <200004101930.PAA04411@hal.epbi.cwru.edu> I could use some help with Python interactions with Web sites. I currently use WebMiner on a Mac to grab stock quotes from a Web site. The relevant AppleScript is: local theDoc, thePath tell application "WebMiner" try set y to first word of time string of (current date) & second word of time string of (current date) & third word of time string of (current date) set z to "O" & y set theDoc to open "http://quote1.interquote.com/cgi-bin/newserv/qs" posting {{"portname", "Custom 1"}, {"action", "Portfolio Quotes"}, {"login", "xxxxx"}, {"password", "yyyyy"}} Note the: " posting {{"portname", "Custom 1"}, ..." stuff. How can I have Python contact the site and shove the "posting" stuff up to the site so I can get my quotes back? Thanks, Rob Lake rbl@hal.cwru.edu From deirdre@deirdre.net Mon Apr 10 20:47:04 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Mon, 10 Apr 2000 12:47:04 -0700 (PDT) Subject: [Tutor] Python using "posting" in URL In-Reply-To: <200004101930.PAA04411@hal.epbi.cwru.edu> Message-ID: On Mon, 10 Apr 2000, Robin B. Lake wrote: > I could use some help with Python interactions with Web sites. > > I currently use WebMiner on a Mac to grab stock quotes from a Web site. You can get quotes from Yahoo on a day-by-day basis without having to parse anything. Intraday quotes (which I haven't done) require more work. > How can I have Python contact the site and shove the "posting" stuff up > to the site so I can get my quotes back? http://baypiggies.org/quotes/fetchtick.py retrieves historical quotes. I have a later version that is better about time, but I have to remember which computer it's on. :) -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "Dictators ride to and fro upon tigers which they dare not dismount. And the tigers are getting hungry." -- Winston Churchill From johnc@greatentertaining.com Mon Apr 10 21:24:38 2000 From: johnc@greatentertaining.com (John Choi) Date: Mon, 10 Apr 2000 13:24:38 -0700 Subject: [Tutor] Changing filenames Message-ID: This is a multi-part message in MIME format. ------=_NextPart_000_001B_01BFA2F0.1F41F410 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit I'd like to change all the filenames in a directory. They have a standard naming convention, but the important stuff is being used as a file type extension. Does anyone know of a way to append the existing extension to the end of the filename and then switch all the extensions to ".this"? -- John C. ------=_NextPart_000_001B_01BFA2F0.1F41F410 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I'd like to change all the = filenames in a=20 directory.  They have a standard naming convention, but the = important stuff=20 is being used as a file type extension.  Does anyone know of a way = to=20 append the existing extension to the end of the filename and then switch = all the=20 extensions to ".this"?
-- John = C.
------=_NextPart_000_001B_01BFA2F0.1F41F410-- From MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV Mon Apr 10 22:04:55 2000 From: MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV (MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV) Date: Mon, 10 Apr 2000 17:04:55 -0400 Subject: [Tutor] Changing filenames Message-ID: <0004109554.AA955401009@customs.treas.gov> --955401009@customs.treas.gov Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Description: "cc:Mail Note Part" I'm not sure that I know what you want, but here's a go at it >>> import re >>> file = "myfile.doc" >>> matchstr = re.compile(r"(\.\w+)$") >>> file = matchstr.sub(r".this\1", file) >>> print file myfile.this.doc (Is this what you wanted?) ______________________________ Reply Separator _________________________________ Subject: [Tutor] Changing filenames Author: at smtplink Date: 4/10/00 1:24 PM I'd like to change all the filenames in a directory. They have a standard naming convention, but the important stuff is being used as a file type extension. Does anyone know of a way to append the existing extension to the end of the filename and then switch all the extensions to ".this"? -- John C. --955401009@customs.treas.gov Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Description: "cc:Mail Note Part"
I'd like to change all the filenames in a directory.  They have a standard naming convention, but the important stuff is being used as a file type extension.  Does anyone know of a way to append the existing extension to the end of the filename and then switch all the extensions to ".this"?
-- John C.
--955401009@customs.treas.gov-- From arcege@shore.net Mon Apr 10 23:09:19 2000 From: arcege@shore.net (Michael P. Reilly) Date: Mon, 10 Apr 2000 18:09:19 -0400 (EDT) Subject: [Tutor] Changing filenames In-Reply-To: from "John Choi" at Apr 10, 2000 01:24:38 PM Message-ID: <200004102209.SAA25916@northshore.shore.net> > > I'd like to change all the filenames in a directory. They have a standard > naming convention, but the important stuff is being used as a file type > extension. Does anyone know of a way to append the existing extension to > the end of the filename and then switch all the extensions to ".this"? > -- John C. > You might want to clarify what "standard naming convention" is. Standard for Windows is not a standard for Mac or UNIX. I assume that you are asking how to append ".this" to the end of all names of files in a directory. >>> import os >>> for fname in os.listdir(os.curdir): # files in current directory ... os.rename(fname, fname + '.this') ... >>> This gets you filenames like "spam.txt.this" and "eggs.spam.this". If you want to do something more complex, for example, changing each extension to be a part of the base name instead of the extension, e.g. changing ".txt" to "-txt". Here you might get instead "spam-txt.this" and "eggs-spam.this". >>> import os >>> for fname in os.listdir(os.curdir): ... basename, ext = os.path.splitext(fname) ... newname = basename + '-' + ext[1:] # chop off '.' ... os.rename(fname, newname + '.this') ... >>> Most of the tools in the os.path module will help you with what you need. Enjoy! :) -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From johnc@greatentertaining.com Tue Apr 11 00:20:22 2000 From: johnc@greatentertaining.com (John Choi) Date: Mon, 10 Apr 2000 16:20:22 -0700 Subject: FW: [Tutor] Changing filenames Message-ID: Hi, The file naming convention goes like this... filename.YYYYMMDD, where the extension is the date when the file was saved. This file is saved everyday (you guessed it, web log file). > > I'd like to change all the filenames in a directory. They have a standard > naming convention, but the important stuff is being used as a file type > extension. Does anyone know of a way to append the existing extension to > the end of the filename and then switch all the extensions to ".this"? > -- John C. > You might want to clarify what "standard naming convention" is. Standard for Windows is not a standard for Mac or UNIX. I assume that you are asking how to append ".this" to the end of all names of files in a directory. >>> import os >>> for fname in os.listdir(os.curdir): # files in current directory ... os.rename(fname, fname + '.this') ... >>> This gets you filenames like "spam.txt.this" and "eggs.spam.this". If you want to do something more complex, for example, changing each extension to be a part of the base name instead of the extension, e.g. changing ".txt" to "-txt". Here you might get instead "spam-txt.this" and "eggs-spam.this". >>> import os >>> for fname in os.listdir(os.curdir): ... basename, ext = os.path.splitext(fname) ... newname = basename + '-' + ext[1:] # chop off '.' ... os.rename(fname, newname + '.this') ... >>> Most of the tools in the os.path module will help you with what you need. Enjoy! :) -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From johnc@greatentertaining.com Tue Apr 11 00:42:25 2000 From: johnc@greatentertaining.com (John Choi) Date: Mon, 10 Apr 2000 16:42:25 -0700 Subject: FW: [Tutor] Changing filenames Message-ID: I'm trying this out on a text file on a mapped network drive but get a.... SyntaxError: can't assign to literal What does this mean? -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of John Choi Sent: Monday, April 10, 2000 4:20 PM To: Python Tutor Mailing List Subject: FW: [Tutor] Changing filenames Hi, The file naming convention goes like this... filename.YYYYMMDD, where the extension is the date when the file was saved. This file is saved everyday (you guessed it, web log file). > > I'd like to change all the filenames in a directory. They have a standard > naming convention, but the important stuff is being used as a file type > extension. Does anyone know of a way to append the existing extension to > the end of the filename and then switch all the extensions to ".this"? > -- John C. > You might want to clarify what "standard naming convention" is. Standard for Windows is not a standard for Mac or UNIX. I assume that you are asking how to append ".this" to the end of all names of files in a directory. >>> import os >>> for fname in os.listdir(os.curdir): # files in current directory ... os.rename(fname, fname + '.this') ... >>> This gets you filenames like "spam.txt.this" and "eggs.spam.this". If you want to do something more complex, for example, changing each extension to be a part of the base name instead of the extension, e.g. changing ".txt" to "-txt". Here you might get instead "spam-txt.this" and "eggs-spam.this". >>> import os >>> for fname in os.listdir(os.curdir): ... basename, ext = os.path.splitext(fname) ... newname = basename + '-' + ext[1:] # chop off '.' ... os.rename(fname, newname + '.this') ... >>> Most of the tools in the os.path module will help you with what you need. Enjoy! :) -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From venkataramana.boddhula@wipro.com Tue Apr 11 04:47:48 2000 From: venkataramana.boddhula@wipro.com (boddhula venkat) Date: Tue, 11 Apr 2000 09:17:48 +0530 Subject: [Tutor] Why python?????// Message-ID: <38F2A064.DBA8D498@wipro.com> Group! What all I can do with Python? Why should I prefer to learn python, than any other languages like Java , C++ etc.. How is the Python usage in the Industry...What about Job Opportunities... If somebody can reply to these queries , it would be great help to me... Thanks &Regards B. venkata ramana From jcm@bigskytel.com Tue Apr 11 10:00:57 2000 From: jcm@bigskytel.com (David Porter) Date: Tue, 11 Apr 2000 03:00:57 -0600 Subject: [Tutor] Why python?????// In-Reply-To: <38F2A064.DBA8D498@wipro.com>; from venkataramana.boddhula@wipro.com on Tue, Apr 11, 2000 at 09:17:48AM +0530 References: <38F2A064.DBA8D498@wipro.com> Message-ID: <20000411030057.B5148@bigskytel.com> * boddhula venkat : > Why should I prefer to learn python, than any other languages like Java > , C++ etc.. http://www.python.org/doc/Comparisons.html > How is the Python usage in the Industry...What about Job > Opportunities... http://www.python.org/Jobs.html > If somebody can reply to these queries , it would be great help to me... Be sure to take a look around www.python.org ! david. From dhoward@sympatico.ca Tue Apr 11 14:05:50 2000 From: dhoward@sympatico.ca (D Howard) Date: Tue, 11 Apr 2000 09:05:50 -0400 Subject: [Tutor] Why python?????// In-Reply-To: <38F2A064.DBA8D498@wipro.com> Message-ID: <000001bfa3b6$a97a4080$840702a3@efgcorporate> Boddhula I'd suggest that you review the several Python website for this type of information - you will find several excellent white papers comparing Python to other languages and highlighting its benefits. A good place to start is www.python.org Regards, Dan -----Original Message----- From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of boddhula venkat Sent: April 10, 2000 11:48 PM To: tutor@python.org Subject: [Tutor] Why python?????// Group! What all I can do with Python? Why should I prefer to learn python, than any other languages like Java , C++ etc.. How is the Python usage in the Industry...What about Job Opportunities... If somebody can reply to these queries , it would be great help to me... Thanks &Regards B. venkata ramana _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From jonggi98@hotmail.com Wed Apr 12 04:41:21 2000 From: jonggi98@hotmail.com (Jonathan Harrison) Date: Tue, 11 Apr 2000 20:41:21 PDT Subject: [Tutor] removal Message-ID: <20000412034121.2146.qmail@hotmail.com> hi...I was wondering how do I remove my name from this list? -jon ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From timc@ans.net Wed Apr 12 19:38:37 2000 From: timc@ans.net (Tim Condit) Date: Wed, 12 Apr 2000 18:38:37 +0000 (GMT) Subject: [Tutor] fileobject.close() question Message-ID: Greetings, I'm wondering about something Pythonic. The first time I ran the little code snip below, I left the 'fileobject.close()' function out. Basically, I forgot it, but at the same time, in the Quick Python book, pg. 132, section 13.2, curiously enough, it says: "In small scripts, not closing a file object will generally not have much of an effect.." I'm seeing something different. Before I caught my oversight, I ran this same little snip twice.. the first time to create the file, and the second time to trigger the else: statement. The file was created, but nothing was written to it, until I went back and added fileobject.close(). Does anyone know what is causing this to happen? Thanks, Tim FYI: the third line (testfile = ...) is all on one line) >>> dir() ['__builtins__', '__doc__', '__name__'] >>> import os >>> testfile = os.path.join('/', 'afs', 'ans.net', 'user', 'timc', 'testfile') >>> if not os.path.isfile(testfile): ... fileobject = open(testfile, 'w') ... fileobject.write("hi there.") ... fileobject.close() ... else: ... print "Sorry, that file already exists." ... >>> From dsh8290@rit.edu Wed Apr 12 20:21:47 2000 From: dsh8290@rit.edu (D-Man) Date: Wed, 12 Apr 2000 15:21:47 -0400 Subject: [Tutor] fileobject.close() question References: Message-ID: <38F4CCCB.8E5D360F@rit.edu> I remember something about buffers. I think that when you do a file.write() it only writes it to the file object in memory. When you do a file.close() it dumps the memory buffer to the actual file on the disk. I think there was another way to dump the buffer to the disk without closeing the file, but I don't remember now what it is. -D Tim Condit wrote: > > Greetings, > > I'm wondering about something Pythonic. The first time I ran the little > code snip below, I left the 'fileobject.close()' function out. Basically, > I forgot it, but at the same time, in the Quick Python book, pg. 132, > section 13.2, curiously enough, it says: > > "In small scripts, not closing a file object will generally > not have much of an effect.." > > I'm seeing something different. Before I caught my oversight, I ran this > same little snip twice.. the first time to create the file, and the second > time to trigger the else: statement. The file was created, but nothing was > written to it, until I went back and added fileobject.close(). Does anyone > know what is causing this to happen? > > Thanks, > Tim > > FYI: the third line (testfile = ...) is all on one line) > > >>> dir() > ['__builtins__', '__doc__', '__name__'] > >>> import os > >>> testfile = os.path.join('/', 'afs', 'ans.net', 'user', 'timc', > 'testfile') > >>> if not os.path.isfile(testfile): > ... fileobject = open(testfile, 'w') > ... fileobject.write("hi there.") > ... fileobject.close() > ... else: > ... print "Sorry, that file already exists." > ... > >>> > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From mdockrell@yahoo.com Wed Apr 12 22:30:23 2000 From: mdockrell@yahoo.com (Morris Dockrell) Date: Wed, 12 Apr 2000 14:30:23 -0700 (PDT) Subject: [Tutor] Python and C Message-ID: <20000412213023.14854.qmail@web210.mail.yahoo.com> I'm a novice at Python. CAn anyone tell me how to do the following: 1) Calling a C function within Python 2) Use arguments to access a directory ( I need to do a search within the directory) Thanks __________________________________________________ Do You Yahoo!? Send online invitations with Yahoo! Invites. http://invites.yahoo.com From MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV Wed Apr 12 20:56:15 2000 From: MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV (MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV) Date: Wed, 12 Apr 2000 15:56:15 -0400 Subject: [Tutor] fileobject.close() question Message-ID: <0004129555.AA955576542@customs.treas.gov> This has to do with buffer flushing, to be honest I'm not sure how to set autoflushing with python (perl would be $| = 1;), but anyway, the buffer waits to be filled before it writes and it flushes on a close. If you don't write enough to fill the buffer, and the program exits, the buffer is cleaned up before the close occurs, therefore the remaining bytes are lost. Not closing a file handle is not a big deal with reads (at all), but I'd be careful with writes. Mike ______________________________ Reply Separator _________________________________ Subject: [Tutor] fileobject.close() question Author: Tim Condit at smtplink Date: 4/12/00 6:38 PM Greetings, I'm wondering about something Pythonic. The first time I ran the little code snip below, I left the 'fileobject.close()' function out. Basically, I forgot it, but at the same time, in the Quick Python book, pg. 132, section 13.2, curiously enough, it says: "In small scripts, not closing a file object will generally not have much of an effect.." I'm seeing something different. Before I caught my oversight, I ran this same little snip twice.. the first time to create the file, and the second time to trigger the else: statement. The file was created, but nothing was written to it, until I went back and added fileobject.close(). Does anyone know what is causing this to happen? Thanks, Tim FYI: the third line (testfile = ...) is all on one line) >>> dir() ['__builtins__', '__doc__', '__name__'] >>> import os >>> testfile = os.path.join('/', 'afs', 'ans.net', 'user', 'timc', 'testfile') >>> if not os.path.isfile(testfile): .. fileobject = open(testfile, 'w') .. fileobject.write("hi there.") .. fileobject.close() .. else: .. print "Sorry, that file already exists." .. >>> _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From arcege@shore.net Thu Apr 13 00:05:55 2000 From: arcege@shore.net (Michael P. Reilly) Date: Wed, 12 Apr 2000 19:05:55 -0400 (EDT) Subject: [Tutor] Python and C In-Reply-To: <20000412213023.14854.qmail@web210.mail.yahoo.com> from "Morris Dockrell" at Apr 12, 2000 02:30:23 PM Message-ID: <200004122305.TAA08287@northshore.shore.net> > I'm a novice at Python. CAn anyone tell me how to do > the following: > > 1) Calling a C function within Python You need to wrap the arguments and return value in the Python/C API, you can do this with SWIG (http://www.swig.org/) or with the C API itself (http://www.python.org/doc/current/ext/ext.html). For example you have a header file with, char *get_user_fullname(char *username); Then you might have the Python/C function: PyObject *get_py_user_fullname(PyObject *unused, PyObject *args) { char *username, *result; if (!PyArg_ParseTuple(args, "s", &username)) return NULL; /* indicate exception (already set by ParseTuple) */ result = get_user_fullname(username); if (result == NULL) { PyErr_SetString(PyExc_ValueError, "invalid username"); return NULL; } return Py_BuildValue("s", result); } The PyArg_ParseTuple() function works like scanf(), but on a Python tuple and Py_BuildValue() is the reverse. I also raise an exception explicitly, and pass an exception through (from PyArg_ParseTuple). > 2) Use arguments to access a directory ( I need to do > a search within the directory) You will want to look at the "os" standard module, which has a function to retrieve the filenames in a directory. There is also the "glob" standard module. os - http://www.python.org/doc/current/lib/module-os.html os.path http://www.python.org/doc/current/lib/module-os.path.html glob - http://www.python.org/doc/current/lib/module-glob.html -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Engineer | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From cwebster@nevada.edu Thu Apr 13 00:23:23 2000 From: cwebster@nevada.edu (Corran Webster) Date: Wed, 12 Apr 2000 16:23:23 -0700 Subject: [Tutor] fileobject.close() question In-Reply-To: <0004129555.AA955576542@customs.treas.gov> Message-ID: > This has to do with buffer flushing, to be honest I'm not sure how to set > autoflushing with python (perl would be $| = 1;), file = open("filename", "w", 0) The third (and optional) parameter is the buffer size; 0 means unbuffered. You can also flush the file explicitly at any time with file.flush() > but anyway, the buffer > waits to be filled before it writes and it flushes on a close. If you > don't write enough to fill the buffer, and the program exits, the buffer is > cleaned up before the close occurs, therefore the remaining bytes are lost. > Not closing a file handle is not a big deal with reads (at all), but I'd > be careful with writes. This is partially correct - while the original problem was caused in part by the buffer not having been written to the disk yet, Python file objects automatically call their close() methods when they are garbage collected (ie. at a random time, but surely before Python shuts itself down). So you do not need to worry about buffers not being flushed unless Python crashes (and if this is a problem, even an explicit close() may not help you if Python never reaches it). For long-running programs you will always want to explicitly close() files, particularly if there could be circular references floating around which will prevent timely garbage collection of your file. On to the original question: > Subject: [Tutor] fileobject.close() question > Author: Tim Condit at smtplink > Date: 4/12/00 6:38 PM > > > > Greetings, > > I'm wondering about something Pythonic. The first time I ran the little > code snip below, I left the 'fileobject.close()' function out. Basically, > I forgot it, but at the same time, in the Quick Python book, pg. 132, > section 13.2, curiously enough, it says: > > "In small scripts, not closing a file object will generally > not have much of an effect.." Notice the "scripts" above. > I'm seeing something different. Before I caught my oversight, I ran this > same little snip twice.. the first time to create the file, and the second > time to trigger the else: statement. The file was created, but nothing was > written to it, until I went back and added fileobject.close(). Does anyone > know what is causing this to happen? > > > Thanks, > Tim > > FYI: the third line (testfile = ...) is all on one line) > > > >>> dir() > ['__builtins__', '__doc__', '__name__'] > >>> import os > >>> testfile = os.path.join('/', 'afs', 'ans.net', 'user', 'timc', > 'testfile') > >>> if not os.path.isfile(testfile): > .. fileobject = open(testfile, 'w') > .. fileobject.write("hi there.") > .. fileobject.close() > .. else: > .. print "Sorry, that file already exists." > .. > >>> It looks like you're running this from the interactive prompt. If this is the case, I suspect that what happened was: - You ran it the first time from the interactive prompt. This opened the file, but because the data was smaller than the buffer, it wasn't flushed and so nothing had yet been written to disk. Also, since you did not explicitly close(), your file is still open, and fileobject references it, so it will not be garbage collected. - you ran it a second time from the command line (without exiting the interpreter, so fileobject still exists). Because the data still had not been written, the file doesn't exist yet on the disk, and it doesn't work as you expect. - when you add the close(), it explicitly closes the file, which flushes the data and creates the file in the filesystem; and so the second time you run it, all is well. However, if you had put exactly the original code: import os testfile = os.path.join('/', 'afs', 'ans.net', 'user', 'timc', 'testfile') if not os.path.isfile(testfile): fileobject = open(testfile, 'w') fileobject.write("hi there.") else: print "Sorry, that file already exists." into it's own little script and run it twice via: python myfile.py it would have worked perfectly without the explicit close. This is the behaviour that the comment in Quick Python is referring to. Regards, Corran From sessile@in-gen.net Thu Apr 13 11:33:23 2000 From: sessile@in-gen.net (sessile@in-gen.net) Date: Thu, 13 Apr 2000 06:33:23 -0400 Subject: [Tutor] Recursive search Message-ID: <3.0.6.32.20000413063323.007f77d0@mail.in-gen.net> Hello, I am reading a configuration file that can point to other configuration files with a similar format. Each of those files can call other such files and so on. Given the first file, I would like to build a list of all the config files. I thought a recursive function would do the trick, but I don't appear to be saving the list of configs properly. The files may be out of date so I need to test for thier existance. The code below seems to print the files out correctly, but the "configs" list remains empty. Advice appreciated! Example files: !This is a comment. include /path/to/some/file include /path/to/config.2 ===== include /bad/file include /yet/another/file ===== def getConfigs(file): configs = [] if not os.path.isfile(file): print "Not a file: %s" % file else: for line in open(file,"r").readlines(): split = map(string.strip, string.split(line)) try: split[0] except IndexError: pass else: if split[0] == "include": print split[-1] configs.getConfigs(split[-1]) return configs myconfigs = getConfigs(myconfigfile) -- E-Mail: sessile@in-gen.net "I don't want the world... I just want your half." -- TMBG (Anna Ng) From MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV Thu Apr 13 13:48:27 2000 From: MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV (MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV) Date: Thu, 13 Apr 2000 08:48:27 -0400 Subject: Re[2]: [Tutor] fileobject.close() question Message-ID: <0004139556.AA955630411@customs.treas.gov> If the file object is closed at gc (in this case, at the end of the program) and before the buffer is gc'd, why doesn't that close flush the buffer out to the file? I was under the impression that the buffer was gc'd first and then the close was called (therefore explaining why bytes are lost), the other way doesn't seem to explain what happens. Mike ______________________________ Reply Separator _________________________________ Subject: Re: [Tutor] fileobject.close() question Author: Corran Webster at smtplink Date: 4/12/00 4:23 PM > This has to do with buffer flushing, to be honest I'm not sure how to set > autoflushing with python (perl would be $| = 1;), file = open("filename", "w", 0) The third (and optional) parameter is the buffer size; 0 means unbuffered. You can also flush the file explicitly at any time with file.flush() > but anyway, the buffer > waits to be filled before it writes and it flushes on a close. If you > don't write enough to fill the buffer, and the program exits, the buffer is > cleaned up before the close occurs, therefore the remaining bytes are lost. > Not closing a file handle is not a big deal with reads (at all), but I'd > be careful with writes. This is partially correct - while the original problem was caused in part by the buffer not having been written to the disk yet, Python file objects automatically call their close() methods when they are garbage collected (ie. at a random time, but surely before Python shuts itself down). So you do not need to worry about buffers not being flushed unless Python crashes (and if this is a problem, even an explicit close() may not help you if Python never reaches it). For long-running programs you will always want to explicitly close() files, particularly if there could be circular references floating around which will prevent timely garbage collection of your file. On to the original question: > Subject: [Tutor] fileobject.close() question > Author: Tim Condit at smtplink > Date: 4/12/00 6:38 PM > > > > Greetings, > > I'm wondering about something Pythonic. The first time I ran the little > code snip below, I left the 'fileobject.close()' function out. Basically, > I forgot it, but at the same time, in the Quick Python book, pg. 132, > section 13.2, curiously enough, it says: > > "In small scripts, not closing a file object will generally > not have much of an effect.." Notice the "scripts" above. > I'm seeing something different. Before I caught my oversight, I ran this > same little snip twice.. the first time to create the file, and the second > time to trigger the else: statement. The file was created, but nothing was > written to it, until I went back and added fileobject.close(). Does anyone > know what is causing this to happen? > > > Thanks, > Tim > > FYI: the third line (testfile = ...) is all on one line) > > > >>> dir() > ['__builtins__', '__doc__', '__name__'] > >>> import os > >>> testfile = os.path.join('/', 'afs', 'ans.net', 'user', 'timc', > 'testfile') > >>> if not os.path.isfile(testfile): > .. fileobject = open(testfile, 'w') > .. fileobject.write("hi there.") > .. fileobject.close() > .. else: > .. print "Sorry, that file already exists." > .. > >>> It looks like you're running this from the interactive prompt. If this is the case, I suspect that what happened was: - You ran it the first time from the interactive prompt. This opened the file, but because the data was smaller than the buffer, it wasn't flushed and so nothing had yet been written to disk. Also, since you did not explicitly close(), your file is still open, and fileobject references it, so it will not be garbage collected. - you ran it a second time from the command line (without exiting the interpreter, so fileobject still exists). Because the data still had not been written, the file doesn't exist yet on the disk, and it doesn't work as you expect. - when you add the close(), it explicitly closes the file, which flushes the data and creates the file in the filesystem; and so the second time you run it, all is well. However, if you had put exactly the original code: import os testfile = os.path.join('/', 'afs', 'ans.net', 'user', 'timc', 'testfile') if not os.path.isfile(testfile): fileobject = open(testfile, 'w') fileobject.write("hi there.") else: print "Sorry, that file already exists." into it's own little script and run it twice via: python myfile.py it would have worked perfectly without the explicit close. This is the behaviour that the comment in Quick Python is referring to. Regards, Corran _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor From dsh8290@rit.edu Thu Apr 13 14:46:27 2000 From: dsh8290@rit.edu (D-Man) Date: Thu, 13 Apr 2000 09:46:27 -0400 Subject: [Tutor] Recursive search References: <3.0.6.32.20000413063323.007f77d0@mail.in-gen.net> Message-ID: <38F5CFB3.9C8E5EF9@rit.edu> In your code I didn't see any line like configs.append( file ) Additionally, the list is a local variable for the function. That means that each call to the function will have its own version of configs. You want to share it in some way so that all of the files will be in the same list. It would probably be best to add it as an argument to the function. def getConfigs( file, configs = [] ): ... Then pass configs to the recursive function call. I used a default argument here so the first time the function is called by the client, the list will be initialized to the empty list. configs.getConfigs(split[-1]) This line here confuses me. configs is a list object. List objects don't have a member function getConfigs(). I don't think this is what you meant. Maybe configs = configs + getConfigs( split[-1] )? If you do this, then you wouldn't need to pass the list as an argument to the function, but you would still need to put a configs.append( file ) somewhere. -D sessile@in-gen.net wrote: > > Hello, > > I am reading a configuration file that can point to other > configuration files with a similar format. Each of those > files can call other such files and so on. Given the first > file, I would like to build a list of all the config files. > I thought a recursive function would do the trick, but I > don't appear to be saving the list of configs properly. > > The files may be out of date so I need to test for thier > existance. > > The code below seems to print the files out correctly, > but the "configs" list remains empty. Advice appreciated! > > Example files: > > > > !This is a comment. > include /path/to/some/file > include /path/to/config.2 > > ===== > > > include /bad/file > include /yet/another/file > > ===== > > def getConfigs(file): > configs = [] > if not os.path.isfile(file): > print "Not a file: %s" % file > else: > for line in open(file,"r").readlines(): > split = map(string.strip, string.split(line)) > try: > split[0] > except IndexError: > pass > else: > if split[0] == "include": > print split[-1] > configs.getConfigs(split[-1]) > return configs > > myconfigs = getConfigs(myconfigfile) > > -- > E-Mail: sessile@in-gen.net > "I don't want the world... I just want your half." > -- TMBG (Anna Ng) > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From cwebster@nevada.edu Thu Apr 13 15:44:52 2000 From: cwebster@nevada.edu (Corran Webster) Date: Thu, 13 Apr 2000 07:44:52 -0700 Subject: [Tutor] Recursive search In-Reply-To: <38F5CFB3.9C8E5EF9@rit.edu> References: <3.0.6.32.20000413063323.007f77d0@mail.in-gen.net> Message-ID: > In your code I didn't see any line like > configs.append( file ) > > > Additionally, the list is a local variable for the function. That means > that each call to the function will have its own version of configs. > You want to share it in some way so that all of the files will be in the > same list. It would probably be best to add it as an argument to the > function. > > def getConfigs( file, configs = [] ): > ... > > Then pass configs to the recursive function call. I used a default > argument here so the first time the function is called by the client, > the list will be initialized to the empty list. This won't work the way you expect because of Python's mutable default argument gotcha. To see why, consider the following code which attempts to append an item to a list, or create a new list if no list is passed: >>> def f(n, spam = []): ... spam.append(n) ... return spam ... >>> foo = f(1) >>> print foo [1] >>> bar = f(2) >>> print bar # uh-oh! [1, 2] >>> print foo # even worse! [1, 2] >>> print f.func_defaults # this is the culprit ([1, 2],) This is because python variables are references to objects, and in this case all the variables spam, foo and bar refer to the same list (the one in f.func_defaults). Changing any one will change all the others The standard way to avoid this sort of problem is to do something like: def getConfigs(file, configs = None): if configs is None: configs = [] ... This ensures that a new list is created if only one argument is passed in. Regards, Corran From cwebster@nevada.edu Thu Apr 13 16:02:08 2000 From: cwebster@nevada.edu (Corran Webster) Date: Thu, 13 Apr 2000 08:02:08 -0700 Subject: Re[2]: [Tutor] fileobject.close() question In-Reply-To: <0004139556.AA955630411@customs.treas.gov> Message-ID: > If the file object is closed at gc (in this case, at the end of the > program) and before the buffer is gc'd, why doesn't that close flush > the buffer out to the file? I was under the impression that the > buffer was gc'd first and then the close was called (therefore > explaining why bytes are lost), the other way doesn't seem to explain > what happens. If you read the original question, you will see that the code was being run from the interactive prompt. Because of this, garbage collection never had a chance to kick in because Python was never shut down (indeed, the file object never even went out of scope). If you check the Python source code (in Objects/fileobject.c), you will see that when the file object is deallocated, it checks to see if its file is closed, and then closes it if needed. As other writers have pointed out, however, this garbage collection feature is _not_ documented as a feature in the language or library references. As a result, it may be implementation dependent, and there are no guarantees that the behaviour will continue in the future (although, to be honest, it is likely that it will). Regards, Corran From alan.gauld@bt.com Thu Apr 13 17:26:59 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Thu, 13 Apr 2000 17:26:59 +0100 Subject: [Tutor] fileobject.close() question Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202DF6187@mbtlipnt02.btlabs.bt.co.uk> > I forgot it, but at the same time, in the Quick Python book, pg. 132, > section 13.2, curiously enough, it says: > > "In small scripts, not closing a file object will generally > not have much of an effect.." Because Python will close it for you when it garbage collects the objects at the end of the session. You are running from the interpreter so the object is still referenced, if you had exitted Python the file would have been written(I assume!!) Equally if your code was in a script file which you ran from the OS prompt then it would have worked as expected. Personally I'm paranoid and allways close files by hand anyway... Alan G. From sessile@in-gen.net Fri Apr 14 03:32:58 2000 From: sessile@in-gen.net (sessile@in-gen.net) Date: Thu, 13 Apr 2000 22:32:58 -0400 Subject: [Tutor] Re: Recursive search Message-ID: <3.0.6.32.20000413223258.007abcb0@mail.in-gen.net> My thanks to everyone who responded so quickly! The following was graciously provided by one of the tutor list members and does exactly what I wanted (it also made me slap myself a few times for not catching on to a solution earlier)... def getConfigs(file, visited = None): if not os.path.isfile(file): print "Not a file: %s" % file return [] if visited == None: visited = [file] else: visited.append(file) for line in open(file,"r").readlines(): split = string.split(line) if len(split) >= 2 and split[0] == "include": if len(split) != 2: print "In file %s:" % file print "Illegal include syntax: %s" % line else: # Only recurse if we haven't seen it yet. if not split[1] in visited: getConfigs(split[1], visited) return visited -- E-Mail: sessile@in-gen.net "I don't want the world... I just want your half." -- TMBG (Anna Ng) From scarblac@pino.selwerd.nl Fri Apr 14 09:40:35 2000 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Fri, 14 Apr 2000 10:40:35 +0200 Subject: [Tutor] Re: Recursive search In-Reply-To: <3.0.6.32.20000413223258.007abcb0@mail.in-gen.net>; from sessile@in-gen.net on Thu, Apr 13, 2000 at 10:32:58PM -0400 References: <3.0.6.32.20000413223258.007abcb0@mail.in-gen.net> Message-ID: <20000414104035.A3830@pino.selwerd.nl> On Thu, Apr 13, 2000 at 10:32:58PM -0400, sessile@in-gen.net wrote: > My thanks to everyone who responded so quickly! > > The following was graciously provided by one of > the tutor list members and does exactly what I > wanted (it also made me slap myself a few times > for not catching on to a solution earlier)... Thanks for posting it to the list, I accidentally sent it to you personally and my mail client didn't keep a copy that I could send to the list. -- Remco Gerlich, scarblac@pino.selwerd.nl From tf@malcolmsmith.net Tue Apr 4 13:27:17 2000 From: tf@malcolmsmith.net (tf@malcolmsmith.net) Date: Tue, 4 Apr 2000 15:27:17 +0300 Subject: [Tutor] will the book remain good? Message-ID: <20000404152717.C273@malcolmsmith.net> hi guys, I have the book, "Learning Python", but have not had the time to delve into it very much yet. Should I "hurry", since new versions of Python are in the works? I suspect that the "old" book will remain a good tutorial, but I wanted to check. will 1.6 and beyond render "Learning Python" obsolete? Thanks, -- -Tom From scarblac@pino.selwerd.nl Sun Apr 16 09:56:23 2000 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Sun, 16 Apr 2000 10:56:23 +0200 Subject: [Tutor] will the book remain good? In-Reply-To: <20000404152717.C273@malcolmsmith.net>; from tf@malcolmsmith.net on Tue, Apr 04, 2000 at 03:27:17PM +0300 References: <20000404152717.C273@malcolmsmith.net> Message-ID: <20000416105623.A9117@pino.selwerd.nl> On Tue, Apr 04, 2000 at 03:27:17PM +0300, tf@malcolmsmith.net wrote: > I have the book, "Learning Python", but have not had the time to > delve into it very much yet. Should I "hurry", since new versions > of Python are in the works? I suspect that the "old" book will > remain a good tutorial, but I wanted to check. will 1.6 and beyond > render "Learning Python" obsolete? No, not at all. There are a few new things in 1.6 that Learning Python obviously doesn't cover, but everything in the book will still work, AFAIK. When 1.6 final will be out in a month or two, just look at the changes list to see what they are. Python doesn't change much between versions. -- Remco Gerlich, scarblac@pino.selwerd.nl From jstok@bluedog.apana.org.au Sun Apr 16 11:48:54 2000 From: jstok@bluedog.apana.org.au (Jason Stokes) Date: Sun, 16 Apr 2000 20:48:54 +1000 Subject: [Tutor] will the book remain good? Message-ID: <002001bfa791$5e93bc20$42e60ecb@jstok> >hi guys, > >I have the book, "Learning Python", but have not had the time to >delve into it very much yet. Should I "hurry", since new versions >of Python are in the works? I suspect that the "old" book will >remain a good tutorial, but I wanted to check. will 1.6 and beyond >render "Learning Python" obsolete? Don't worry. Python doesn't evolve so dramatically that everything becomes obsolete. (It's difficult to improve on near perfection.) From curtis.larsen@Covance.Com Thu Apr 20 17:30:28 2000 From: curtis.larsen@Covance.Com (Curtis Larsen) Date: Thu, 20 Apr 2000 11:30:28 -0500 Subject: [Tutor] help converting a Sequential file to an indexed file (LONGISH) Message-ID: Dan - It depends a bit on the size of your serial file(s). You can either read the complete file into a list via the "readlines()" method, or just read it line-by-line using the "readline()" method. Although it's quite a bit slower, I personally prefer the latter on files whose size I don't know the EOF of. Once you have (or are reading) your serial data, you can populate a dictionary with the values, providing that field you spoke of is a unique key -- dictionaries are awesome for this. If it's not a unique key, then you'll need to find a way to keep the duplicate entries. You don't HAVE to read stuff into a list, of course -- you could read the file and write the new record directly -- but it helps not only for speed, but for doing "stuff" with the info you read. (Totalling items, counting records, etc.) Once you have (even part of) your list populated, you can begin writing it to a new file using the Key of Your Choice. Here's a script that illustrates reading from a serial file, then using a dictionary to sort/total some stuff. I used methods from the "string" module to separate the fields: columns 1-n = variable #1, cols n+1-y = variable #2, etc. If my values had been space-delimited, then I could have used the "split" method to excellent effect, but they weren't, so I had to slice the string "r" (record) up. for line in fileinput.input(): r = string.strip(line) if r[0:5] == "Logon": # Detail record? rdate = "0" + string.strip(r[07:14]) rdate = rdate[-7:] rdev = int(string.strip(r[23:27])) rlogon = string.strip(r[27:62]) rname = string.strip(r[63:94]) hist[rdev] = (rdate, rlogon, rname) # Load the dictionary if rdate <> x: # Where are we at? x = rdate print rdate if not totals.has_key(rdev): totals[rdev] = 0 totals[rdev] = totals[rdev] + 1 keylist = hist.keys() keylist.sort() for ldev in keylist: rdate, rlogon, rname = hist[ldev] print "%04u %5u %7s %s" % (ldev, totals[ldev], rdate, rlogon) The file was a list of logons I wanted to summarize by device. I read each record from the file (specified on the command line), and if it's one of the details records I'm looking for (it has the word "Logon:" at the beginning) then I strip values out of it and assign them to variables (so I can format them a tad bit more -- stripping space-padded ends, chang a string to an integer, etc.) Once I have my variables, I populate the "hist" dictionary using one of the variables (the device used in logging on) as the unique key, with a tuple of the variables as the information I want to record. The device key won't truly be unique, since many people log on/off using the same device(s), so I end up overwriting the previous data using that key -- but since the data file is already sorted by date, I'll always have the info on the *last* time that device was used. (Automatic duplication elimination -- How I *LOVE* dictionaries!) The "if" just watches to see when I change days in my reading so it can print the new date to the screen, which in turn keeps me from thinking the script is hung. (Fun With Auditing.) Finally, I sum all the times I've seen that device used, and put the count into another dictionary named "totals", using the device as a key once more. (Yep, coulda' put it into a tuple entry in the "hist" dictionary, but I was thinking of adding more to "totals" later on, so I kept "totals" separate.) Once out of the loop, I create a List of the keys I used, then sort that List. Lastly, I read through that sorted List and pull the data out of the dictionary as though the dictionary were a random file. That info gets prettily printed for the waiting human (that'd be me) and there ya go. To write to a random-access file, just use the "seek" and "write" methods for your file. The "seek" method positions for the next read or write. Its usage is "seek(offset,where)" where "offset" is, well, an offset, and "where" is a value affecting the offset. It "where" is omitted or zero, then the offset is relative to the beginning of the file. If "where" is 1, then the offset is relative to the current postion, and if "where" is 2, then the offset is relative to the end of the file. IMPORTANT: the offset is in BYTES (*not* records). Hope that helps. As always, there's more than one way to do it, and the above illustrates only one of those ways. If anyone can offer more, or ways to imporve upon the above, I'm open for it. Thanks! Curtis >>> "Dan Howard" 04/03/00 07:58PM >>> Hi all... I'm a newbie to Python and would appreciate some advice on the best way to read a sequential file of data and map the contents to a direct access file. The sequential file has fixed size fields and each field is separated by spaces - some fields are filled with spaces as filler. The first field in each record is the key that I'd like to use to access the records. Any comments on best practices here would be most welcome Thanks Dan _______________________________________________ Tutor maillist - Tutor@python.org http://www.python.org/mailman/listinfo/tutor ----------------------------------------------------- Confidentiality Notice: This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual or entity named in the e-mail address. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or reliance upon the contents of this e-mail is strictly prohibited. If you have received this e-mail transmission in error, please reply to the sender, so that Covance can arrange for proper delivery, and then please delete the message from your inbox. Thank you. From fcabral@i-next.net Mon Apr 24 19:24:23 2000 From: fcabral@i-next.net (Fiel Cabral) Date: Mon, 24 Apr 2000 14:24:23 -0400 Subject: [Tutor] Question: Converting ints to strings Message-ID: <000d01bfae1a$c8d2bca0$4e00a8cb@fcabral> Please tell me how to convert an int to a string. I'm trying to do the following: block_number = 1 file_name = 'temp.file' output = open(file_name + '.$' + block_number + '$', 'wb') This didn't work. I was hoping that it would create a file called 'temp.file.$1$'. Thank you. Fiel Cabral From wesc@alpha.ece.ucsb.edu Mon Apr 24 08:29:31 2000 From: wesc@alpha.ece.ucsb.edu (Wesley J. Chun) Date: Mon, 24 Apr 2000 00:29:31 -0700 (PDT) Subject: [Tutor] Question: Converting ints to strings Message-ID: <200004240729.AAA25554@alpha.ece.ucsb.edu> > From: "Fiel Cabral" > Date: Mon, 24 Apr 2000 14:24:23 -0400 > > Please tell me how to convert an int to a string. > I'm trying to do the following: > > block_number = 1 > file_name = 'temp.file' > output = open(file_name + '.$' + block_number + '$', 'wb') > > This didn't work. I was hoping that it would create > a file called 'temp.file.$1$'. there are (at least) two ways accomplishing this. in your situation, you can either use the string format operator (%) like this... output = open('%s.$%d$' % (file_name, block_number), 'wb') (%s indicates a string and %d indicates an integer) ... or you can directly convert the number (or any object) to a string using the str() built-in function, like this: output = open(file_name + '.$' + str(block_number) + '$', 'wb') hope this helps!! -wesley "Core Python Programming", Prentice-Hall, TBP Summer 2000 wesley.j.chun :: wesc@alpha.ece.ucsb.edu cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ From jstok@bluedog.apana.org.au Mon Apr 24 08:23:19 2000 From: jstok@bluedog.apana.org.au (Jason Stokes) Date: Mon, 24 Apr 2000 17:23:19 +1000 Subject: [Tutor] Question: Converting ints to strings Message-ID: <004201bfadc2$20001440$42e60ecb@jstok> -----Original Message----- From: Fiel Cabral To: tutor@python.org Date: Sunday, April 23, 2000 11:48 AM Subject: [Tutor] Question: Converting ints to strings >Please tell me how to convert an int to a string. >I'm trying to do the following: > > block_number = 1 > file_name = 'temp.file' > output = open(file_name + '.$' + block_number + '$', 'wb') > >This didn't work. I was hoping that it would create >a file called 'temp.file.$1$'. For any object x, str(x) will return a string which is a printable representation of that object. so you can use: output = open(file_name + '.$' + str(block_number) + '$', 'wb') Cheers, Jason Stokes: jstok@bluedog.apana.org.au From dyoo@hkn.EECS.Berkeley.EDU Mon Apr 24 17:43:26 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Mon, 24 Apr 2000 09:43:26 -0700 (PDT) Subject: [Tutor] Re: Tutor digest, Vol 1 #293 - 3 msgs In-Reply-To: <20000424160015.E50231CE05@dinsdale.python.org> Message-ID: > Please tell me how to convert an int to a string. > I'm trying to do the following: > > block_number = 1 > file_name = 'temp.file' > output = open(file_name + '.$' + block_number + '$', 'wb') > > This didn't work. I was hoping that it would create > a file called 'temp.file.$1$'. Python doesn't automatically convert your block_number into a string --- you can make it a string by surrounding it with back-quotes, as follows: block_number = 1 file_name = 'temp.file' output = open(file_name + '.$' + `block_number` + '$', 'wb') You can also use the str() function to string convert. From curtis.larsen@Covance.Com Mon Apr 24 17:19:05 2000 From: curtis.larsen@Covance.Com (Curtis Larsen) Date: Mon, 24 Apr 2000 11:19:05 -0500 Subject: [Tutor] Helpful Python Books Message-ID: I too have had problems reading the "Learning Python" book as others have mentioned, as it greatly supposes I've used C, and I haven't. (FORTRAN, COBOL, Pascal, Basic, Various JCLs, some Assembly -- even a dash of Lisp -- but no C.) For whatever it's worth though, I just picked up two books that I've been most happy with: "Python Essential Reference" By David M. Beazley Published by New Riders Publishing ISBN: 0-7357-0901-7 Retail Cost: US$34.95 This book is always near me now, taking the place of the little O'Reilly "Python Pocket Reference" (US$6.95). (Well OK, I still use the pocket reference sometimes -- it's very handy.) This book is an incredibly good "what was the module that did this thing I wanna do and what were it's parms again?" book. It has good explanations, and good basic examples on many things, as well as nice "extending and embedding" section. It also has very nice foreward from Guido endorsing it (?), saying (among other things) that David and he were able to spend time together, allowing direct communications on things Pythonish. (Note: My Barnes&Noble had it on the 20%-off rack, so you might get a similar deal on it at your local B&N.) "Python Annotated Archives" By Martin C. Brown Published by Osborne/McGraw Hill ISBN: 0-07-212104-1 Retail Cost: US$49.99 This book is an absolute *gem*! It is exactly what I've personally been looking for in learning Python -- code with step-by-step commentary. This book takes most of the main modules and line-by-line, function-by-function, breaks down what's going on and why. It's about 2 inches thick(!), and includes a CD-ROM with all of the many Python scripts contained in the book (as well as the latest Python distro's for various OSes). It has so very (very) many nice examples, links, references, etc. in it that I can't extol them all here -- I strongly suggest you hunt it down at your local book store and leaf through it. It was a bit expensive, but since it had everything(!) I have been looking for, I waffled on purchasing it for only a short time. :) I heartily recommend this book -- it's helped me tremendously. HTH, Curtis ----------------------------------------------------- Confidentiality Notice: This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual or entity named in the e-mail address. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or reliance upon the contents of this e-mail is strictly prohibited. If you have received this e-mail transmission in error, please reply to the sender, so that Covance can arrange for proper delivery, and then please delete the message from your inbox. Thank you. begin 644 TEXT.htm M/"%$3T-465!%($A434P@4%5"3$E#("(M+R]7,T,O+T141"!(5$U,(#0N,"!4 M7!E/@T*/$U%5$$@8V]N=&5N=#TB35-(5$U,(#4N,#`N,CDQ M.2XV,S`W(B!N86UE/4=%3D52051/4CX\+TA%040^#0H\0D]$62!B9T-O;&]R M/2-F9F9F9F8@#0IS='EL93TB1D].5#H@,3!P="!!#L@34%21TE.+51/4#H@,G!X(CX-"CQ$258^22!T;V\@:&%V92!H M860@<')O8FQE;7,@2!S M=7!P;W-E2!$879I9"!-+B!"96%Z;&5Y/"]$ M258^#0H\1$E6/E!U8FQI2!.97<@4FED97)S(%!U8FQI7,@;F5A2`-"B)0>71H;VX@ M4&]C:V5T(%)E9F5R96YC92(@*%53)#8N.34I+B9N8G-P.R`H5V5L;"!/2RP@ M22!S=&EL;"!U&%M<&QE2!T:&EN9W,L(&%S('=E;&P@87,@;FEC929N8G-P.R)E>'1E;F1I;F<@ M86YD(&5M8F5D9&EN9R(@#0IS96-T:6]N+B9N8G-P.R!)="!A;'-O(&AA6]U&%C=&QY('=H870@22=V92!P97)S;VYA;&QY(`T*8F5E;B!L;V]K:6YG(&9O M71H;VX@+2T@8V]D92!W:71H('-T97`M8GDM2UL:6YE+"9N8G-P.V9U M;F-T:6]N+6)Y+69U;F-T:6]N+"!B29N8G-P.RAV97)Y*2!M86YY(&YI8V4@97AA M;7!L97,L(&QI;FMS+"!R969E2!S=6=G M97-T('EO=29N8G-P.VAU;G0@:70@9&]W;B!A="!Y;W5R(`T*;&]C86P@8F]O M:R!S=&]R92!A;F0F;F)S<#ML96%F('1H71H M:6YG*"$I($D@:&%V92!B965N(&QO;VMI;F<@9F]R+"9N8G-P.TD@=V%F9FQE M9"!O;B!P=7)C:&%S:6YG(`T*:70@9F]R(&]N;'D@82!S:&]R="!T:6UE+B`Z M*29N8G-P.R!)(&AE87)T:6QY(')E8V]M;65N9"!T:&ES(&)O;VL@+2T@:70G M Dear friends, I am educator and I have started to learning python language, in order to show to my students that they can develope applications without using commercial software. I would be pleased if you said me, how I can create a pyc file from a source (py) file in unix (linux) environment. I have already tried the py_compile module without success, and I didn't find such an example in python documentation. Regards Antony Sakellariou Greece From scarblac@pino.selwerd.nl Mon Apr 24 22:47:14 2000 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Mon, 24 Apr 2000 23:47:14 +0200 Subject: [Tutor] .py to .pyc In-Reply-To: <3904BF1F.6497B774@otenet.gr>; from vansak@otenet.gr on Tue, Apr 25, 2000 at 12:39:43AM +0300 References: <3904BF1F.6497B774@otenet.gr> Message-ID: <20000424234714.A6992@pino.selwerd.nl> On Tue, Apr 25, 2000 at 12:39:43AM +0300, Antony Sakellariou wrote: > I am educator and I have started to learning python language, in > order to show to my students that they can develope applications without > using commercial software. > I would be pleased if you said me, how I can create a pyc file from a > source (py) file in unix (linux) environment. > I have already tried the py_compile module without success, and I > didn't find such an example in python documentation. This is done automatically the first time the .py file is used, so that it doesn't have to be compiled the next time. So importing or running the file should be enough. Or did I misunderstand the question? -- Remco Gerlich, scarblac@pino.selwerd.nl From mlfloren@bulldog.unca.edu Wed Apr 26 01:49:10 2000 From: mlfloren@bulldog.unca.edu (Marcella Louise Florence) Date: Tue, 25 Apr 2000 20:49:10 -0400 (EDT) Subject: [Tutor] Learning to Code with Python In-Reply-To: <20000425160010.515681CD6A@dinsdale.python.org> Message-ID: After some research and hearty recomendations, I have decided to learn Python as my first language. I'm very thrilled about the prospect, and I have been looking at several online tutorials. However, I would be interested if anyone knows any books I could purchase with my frame of reference in mind. If there are any other suggestions, I would be welcome to those as well. -Marcella *** "Me like stardust on your shoulders, friend..." -Yoko of Planet Rondo *** From ivanlan@callware.com Wed Apr 26 02:00:09 2000 From: ivanlan@callware.com (Ivan Van Laningham) Date: Tue, 25 Apr 2000 19:00:09 -0600 Subject: [Tutor] Learning to Code with Python References: Message-ID: <39063F99.9E241ED@callware.com> Hi All-- Marcella Louise Florence wrote: > > After some research and hearty recomendations, I have decided to learn > Python as my first language. I'm very thrilled about the prospect, and I > have been looking at several online tutorials. However, I would be > interested if anyone knows any books I could purchase with my frame of > reference in mind. > > If there are any other suggestions, I would be welcome to those as well. > > -Marcella > How can I resist? My book, _Teach Yourself Python in 24 Hours_, should be in stores *any day now* (if it isn't already). Please look it over; I wrote it explicitly for beginners to programming. > *** > "Me like stardust on your shoulders, friend..." > -Yoko of Planet Rondo > -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. http://www.pauahtun.org and http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From victory@chollian.net Wed Apr 26 05:43:34 2000 From: victory@chollian.net (victory) Date: Wed, 26 Apr 2000 13:43:34 +0900 Subject: [Tutor] Tutor -- confirmation of subscription -- request 825847 Message-ID: DQoNCi0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQpGcm9tOiB0dXRvci1hZG1pbkBweXRob24u b3JnIFttYWlsdG86dHV0b3ItYWRtaW5AcHl0aG9uLm9yZ11PbiBCZWhhbGYNCk9mIHR1dG9yLXJl cXVlc3RAcHl0aG9uLm9yZw0KU2VudDogV2VkbmVzZGF5LCBBcHJpbCAyNiwgMjAwMCAxMToyMSBB TQ0KVG86IHZpY3RvcnlAY2hvbGxpYW4ubmV0DQpTdWJqZWN0OiBUdXRvciAtLSBjb25maXJtYXRp b24gb2Ygc3Vic2NyaXB0aW9uIC0tIHJlcXVlc3QgODI1ODQ3DQoNCg0KDQpUdXRvciAtLSBjb25m aXJtYXRpb24gb2Ygc3Vic2NyaXB0aW9uIC0tIHJlcXVlc3QgODI1ODQ3DQoNCldlIGhhdmUgcmVj ZWl2ZWQgYSByZXF1ZXN0IGZyb20gcGFycm90LnB5dGhvbi5vcmcgZm9yIHN1YnNjcmlwdGlvbiBv Zg0KeW91ciBlbWFpbCBhZGRyZXNzLCA8dmljdG9yeUBjaG9sbGlhbi5uZXQ+LCB0byB0aGUgdHV0 b3JAcHl0aG9uLm9yZw0KbWFpbGluZyBsaXN0LiAgVG8gY29uZmlybSB0aGUgcmVxdWVzdCwgcGxl YXNlIHNlbmQgYSBtZXNzYWdlIHRvDQp0dXRvci1yZXF1ZXN0QHB5dGhvbi5vcmcsIGFuZCBlaXRo ZXI6DQoNCi0gbWFpbnRhaW4gdGhlIHN1YmplY3QgbGluZSBhcyBpcyAodGhlIHJlcGx5J3MgYWRk aXRpb25hbCAiUmU6IiBpcw0Kb2spLA0KDQotIG9yIGluY2x1ZGUgdGhlIGZvbGxvd2luZyBsaW5l IC0gYW5kIG9ubHkgdGhlIGZvbGxvd2luZyBsaW5lIC0gaW4gdGhlDQptZXNzYWdlIGJvZHk6IA0K DQpjb25maXJtIDgyNTg0Nw0KDQooU2ltcGx5IHNlbmRpbmcgYSAncmVwbHknIHRvIHRoaXMgbWVz c2FnZSBzaG91bGQgd29yayBmcm9tIG1vc3QgZW1haWwNCmludGVyZmFjZXMsIHNpbmNlIHRoYXQg dXN1YWxseSBsZWF2ZXMgdGhlIHN1YmplY3QgbGluZSBpbiB0aGUgcmlnaHQNCmZvcm0uKQ0KDQpJ ZiB5b3UgZG8gbm90IHdpc2ggdG8gc3Vic2NyaWJlIHRvIHRoaXMgbGlzdCwgcGxlYXNlIHNpbXBs eSBkaXNyZWdhcmQNCnRoaXMgbWVzc2FnZS4gIFNlbmQgcXVlc3Rpb25zIHRvIHR1dG9yLWFkbWlu QHB5dGhvbi5vcmcuDQo= From genius@idirect.com Wed Apr 26 15:21:46 2000 From: genius@idirect.com (Charles Takacs) Date: Wed, 26 Apr 2000 10:21:46 -0400 Subject: [Tutor] Learning to Code with Python Message-ID: <001301bfaf8a$c2389920$69069ad8@charlest> Hi Marcella :-)) I am also learning Python as the first Programming language.If you are Learning Python as the first Language then I would definatelly recommend you starting with the book "Learning Python in 24 Hours" by Ivan Van Laningham. You can get it from "amazon.com". I live in Canada and I just picked the book up a couple days ago from the local Computer Book Store since it was just released (finally) for publication. I've been anxiously waiting for this book to be released since it is supposedly for Newbies. For the past couple of days I've been browsing through it and already can see, that it is much better for a beginner than any of the other books currenly available. So a congradulation is definatelly due to Ivan for writing it. I also found Alan Gauld's Tutorial exceptionally good. Until now I used the book "Learning Python-by Mark Lutz" since it was highly recommended for beginners. This book is also very good but as a Newbie I found it somewhat over-whealming. In my opinion after finishing Ivan's book then this one should be your next choice. Needless to say that Guido's Tutorial should also be part of your Learning Experience. Best regards Charles Takacs -----Original Message----- From: Marcella Louise Florence To: tutor@python.org Date: Tuesday, April 25, 2000 8:47 PM Subject: [Tutor] Learning to Code with Python >After some research and hearty recomendations, I have decided to learn >Python as my first language. I'm very thrilled about the prospect, and I >have been looking at several online tutorials. However, I would be >interested if anyone knows any books I could purchase with my frame of >reference in mind. > >If there are any other suggestions, I would be welcome to those as well. > >-Marcella > >*** >"Me like stardust on your shoulders, friend..." >-Yoko of Planet Rondo >*** > > > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://www.python.org/mailman/listinfo/tutor From ivanlan@callware.com Wed Apr 26 15:41:09 2000 From: ivanlan@callware.com (Ivan Van Laningham) Date: Wed, 26 Apr 2000 08:41:09 -0600 Subject: [Tutor] Learning to Code with Python References: <001301bfaf8a$c2389920$69069ad8@charlest> Message-ID: <39070005.1413EC7@callware.com> Hi All-- Charles Takacs wrote: > > Hi Marcella :-)) > I am also learning Python as the first Programming language.If you are > Learning Python as the first Language then I would definatelly recommend you > starting with the book "Learning Python in 24 Hours" by Ivan Van Laningham. > You can get it from "amazon.com". > Thank you for the kind words, Charles. But there is a teeny correction I must make: the book is entitled _Teach Yourself Python in 24 Hours_, from SAMS. > I live in Canada and I just picked the book up a couple days ago from the > local Computer Book Store since it was just released (finally) for > publication. I'm glad to hear that it is actually out there in bookstores! Metta, Ivan PS: The book's website, http://www.pauahtun.org/TYPython/ is currently inaccessible other than by IP address: http://63.64.27.76/TYPython/ due to some nameserver madness here at work. I'm working to resolve the situation. One way or another, it will be online within the next week or so. I apologize for the inconvenience. Anyone who can't access the site with the IP address should write to me off-list. ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. http://www.pauahtun.org http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From genius@idirect.com Wed Apr 26 17:14:57 2000 From: genius@idirect.com (Charles Takacs) Date: Wed, 26 Apr 2000 12:14:57 -0400 Subject: [Tutor] Congradulations to Ivan :-))--for his BOOK Message-ID: <001501bfaf9a$9220a2e0$69069ad8@charlest> Hi All :-)) IMHO a definate congradulation as well as a "Thank You" is due to Ivan Van Laningham for writing the recently released book "Learning Python in 24 Hrs". I've been anxiously waiting since November for the release of the book . Finally a couple days ago I picked it up at my local Book Store where I had it on Pre-Order. To satisfy my curiousity I spent a couple of sleepless nights and days browsing through the chapters. As a complete Newbie in Programming I found the book considerably easier to comprehend than any of the other Python Books. From a Newbie point of view I beleive that it definatelly should be recommended as the 1st Book to Buy for a Beginner Programmer. So Once again I would like to express my appreciation for Ivan's efforts and contributions toward the Python Community. Best regards Charles Takacs From mjboylan@sover.net Wed Apr 26 14:52:54 2000 From: mjboylan@sover.net (Michael J. Boylan) Date: Wed, 26 Apr 2000 13:52:54 Subject: [Tutor] Re: Tutor digest, Vol 1 #295 - 5 msgs In-Reply-To: <20000426160005.E07211CD20@dinsdale.python.org> Message-ID: <3.0.1.16.20000426135254.324f27fa@mail.sover.net> Hello, I also tried the online turor, but found Van Laningham,s book to be much better. He explains functions, rather than demonstrating them. He's also very funny, and certainly knowledgeable. Mike Boylan At 12:00 PM 4/26/00 -0400, you wrote: >Send Tutor mailing list submissions to > tutor@python.org > >To subscribe or unsubscribe via the World Wide Web, visit > http://www.python.org/mailman/listinfo/tutor >or, via email, send a message with subject or body 'help' to > tutor-request@python.org > >You can reach the person managing the list at > tutor-admin@python.org > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of Tutor digest..." > > >Today's Topics: > > 1. Learning to Code with Python (Marcella Louise Florence) > 2. Re: Learning to Code with Python (Ivan Van Laningham) > 3. Tutor -- confirmation of subscription -- request 825847 (victory) > 4. Re: Learning to Code with Python (Charles Takacs) > 5. Re: Learning to Code with Python (Ivan Van Laningham) > >--__--__-- > >Message: 1 >Date: Tue, 25 Apr 2000 20:49:10 -0400 (EDT) >From: Marcella Louise Florence >To: tutor@python.org >Subject: [Tutor] Learning to Code with Python > >After some research and hearty recomendations, I have decided to learn >Python as my first language. I'm very thrilled about the prospect, and I >have been looking at several online tutorials. However, I would be >interested if anyone knows any books I could purchase with my frame of >reference in mind. > >If there are any other suggestions, I would be welcome to those as well. > >-Marcella > >*** >"Me like stardust on your shoulders, friend..." >-Yoko of Planet Rondo >*** > > > > >--__--__-- > >Message: 2 >Date: Tue, 25 Apr 2000 19:00:09 -0600 >From: Ivan Van Laningham >Organization: God N Locomotive Works >To: "tutor@python.org" >Subject: Re: [Tutor] Learning to Code with Python > >Hi All-- > >Marcella Louise Florence wrote: >> >> After some research and hearty recomendations, I have decided to learn >> Python as my first language. I'm very thrilled about the prospect, and I >> have been looking at several online tutorials. However, I would be >> interested if anyone knows any books I could purchase with my frame of >> reference in mind. >> >> If there are any other suggestions, I would be welcome to those as well. >> >> -Marcella >> > > How can I resist? My book, _Teach Yourself Python in 24 Hours_, >should be in stores *any day now* (if it isn't already). Please look it >over; I wrote it explicitly for beginners to programming. > >> *** >> "Me like stardust on your shoulders, friend..." >> -Yoko of Planet Rondo >> > >-ly y'rs, >Ivan >---------------------------------------------- >Ivan Van Laningham >Callware Technologies, Inc. >http://www.pauahtun.org and >http://www.foretec.com/python/workshops/1998-11/proceedings.html >Army Signal Corps: Cu Chi, Class of '70 >Author: Teach Yourself Python in 24 Hours > > >--__--__-- > >Message: 3 >From: "victory" >To: >Date: Wed, 26 Apr 2000 13:43:34 +0900 >charset="ks_c_5601-1987" >Subject: [Tutor] Tutor -- confirmation of subscription -- request 825847 > >DQoNCi0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQpGcm9tOiB0dXRvci1hZG1pbkBweXRob24u >b3JnIFttYWlsdG86dHV0b3ItYWRtaW5AcHl0aG9uLm9yZ11PbiBCZWhhbGYNCk9mIHR1dG9yLXJl >cXVlc3RAcHl0aG9uLm9yZw0KU2VudDogV2VkbmVzZGF5LCBBcHJpbCAyNiwgMjAwMCAxMToyMSBB >TQ0KVG86IHZpY3RvcnlAY2hvbGxpYW4ubmV0DQpTdWJqZWN0OiBUdXRvciAtLSBjb25maXJtYXRp >b24gb2Ygc3Vic2NyaXB0aW9uIC0tIHJlcXVlc3QgODI1ODQ3DQoNCg0KDQpUdXRvciAtLSBjb25m >aXJtYXRpb24gb2Ygc3Vic2NyaXB0aW9uIC0tIHJlcXVlc3QgODI1ODQ3DQoNCldlIGhhdmUgcmVj >ZWl2ZWQgYSByZXF1ZXN0IGZyb20gcGFycm90LnB5dGhvbi5vcmcgZm9yIHN1YnNjcmlwdGlvbiBv >Zg0KeW91ciBlbWFpbCBhZGRyZXNzLCA8dmljdG9yeUBjaG9sbGlhbi5uZXQ+LCB0byB0aGUgdHV0 >b3JAcHl0aG9uLm9yZw0KbWFpbGluZyBsaXN0LiAgVG8gY29uZmlybSB0aGUgcmVxdWVzdCwgcGxl >YXNlIHNlbmQgYSBtZXNzYWdlIHRvDQp0dXRvci1yZXF1ZXN0QHB5dGhvbi5vcmcsIGFuZCBlaXRo >ZXI6DQoNCi0gbWFpbnRhaW4gdGhlIHN1YmplY3QgbGluZSBhcyBpcyAodGhlIHJlcGx5J3MgYWRk >aXRpb25hbCAiUmU6IiBpcw0Kb2spLA0KDQotIG9yIGluY2x1ZGUgdGhlIGZvbGxvd2luZyBsaW5l >IC0gYW5kIG9ubHkgdGhlIGZvbGxvd2luZyBsaW5lIC0gaW4gdGhlDQptZXNzYWdlIGJvZHk6IA0K >DQpjb25maXJtIDgyNTg0Nw0KDQooU2ltcGx5IHNlbmRpbmcgYSAncmVwbHknIHRvIHRoaXMgbWVz >c2FnZSBzaG91bGQgd29yayBmcm9tIG1vc3QgZW1haWwNCmludGVyZmFjZXMsIHNpbmNlIHRoYXQg >dXN1YWxseSBsZWF2ZXMgdGhlIHN1YmplY3QgbGluZSBpbiB0aGUgcmlnaHQNCmZvcm0uKQ0KDQpJ >ZiB5b3UgZG8gbm90IHdpc2ggdG8gc3Vic2NyaWJlIHRvIHRoaXMgbGlzdCwgcGxlYXNlIHNpbXBs >eSBkaXNyZWdhcmQNCnRoaXMgbWVzc2FnZS4gIFNlbmQgcXVlc3Rpb25zIHRvIHR1dG9yLWFkbWlu >QHB5dGhvbi5vcmcuDQo= > > > >--__--__-- > >Message: 4 >From: "Charles Takacs" >To: "Marcella Louise Florence" , > >Subject: Re: [Tutor] Learning to Code with Python >Date: Wed, 26 Apr 2000 10:21:46 -0400 >charset="iso-8859-1" > >Hi Marcella :-)) >I am also learning Python as the first Programming language.If you are >Learning Python as the first Language then I would definatelly recommend you >starting with the book "Learning Python in 24 Hours" by Ivan Van Laningham. >You can get it from "amazon.com". > > I live in Canada and I just picked the book up a couple days ago from the >local Computer Book Store since it was just released (finally) for >publication. I've been anxiously waiting for this book to be released since >it is supposedly for Newbies. For the past couple of days I've been >browsing through it and already can see, that it is much better for a >beginner than any of the other books currenly available. So a >congradulation is definatelly due to Ivan for writing it. I also found Alan >Gauld's Tutorial exceptionally good. > >Until now I used the book "Learning Python-by Mark Lutz" since it was highly >recommended for beginners. This book is also very good but as a Newbie I >found it somewhat over-whealming. In my opinion after finishing Ivan's book >then this one should be your next choice. Needless to say that Guido's >Tutorial should also be part of your Learning Experience. >Best regards >Charles Takacs >-----Original Message----- >From: Marcella Louise Florence >To: tutor@python.org >Date: Tuesday, April 25, 2000 8:47 PM >Subject: [Tutor] Learning to Code with Python > > >>After some research and hearty recomendations, I have decided to learn >>Python as my first language. I'm very thrilled about the prospect, and I >>have been looking at several online tutorials. However, I would be >>interested if anyone knows any books I could purchase with my frame of >>reference in mind. >> >>If there are any other suggestions, I would be welcome to those as well. >> >>-Marcella >> >>*** >>"Me like stardust on your shoulders, friend..." >>-Yoko of Planet Rondo >>*** >> >> >> >>_______________________________________________ >>Tutor maillist - Tutor@python.org >>http://www.python.org/mailman/listinfo/tutor > > > >--__--__-- > >Message: 5 >Date: Wed, 26 Apr 2000 08:41:09 -0600 >From: Ivan Van Laningham >Organization: Callware Technologies, Inc. >To: "tutor@python.org" >Subject: Re: [Tutor] Learning to Code with Python > >Hi All-- > >Charles Takacs wrote: >> >> Hi Marcella :-)) >> I am also learning Python as the first Programming language.If you are >> Learning Python as the first Language then I would definatelly recommend you >> starting with the book "Learning Python in 24 Hours" by Ivan Van Laningham. >> You can get it from "amazon.com". >> > >Thank you for the kind words, Charles. But there is a teeny correction >I must make: the book is entitled _Teach Yourself Python in 24 Hours_, >from SAMS. > > >> I live in Canada and I just picked the book up a couple days ago from the >> local Computer Book Store since it was just released (finally) for >> publication. > >I'm glad to hear that it is actually out there in bookstores! > >Metta, >Ivan > >PS: The book's website, > > http://www.pauahtun.org/TYPython/ > >is currently inaccessible other than by IP address: > > http://63.64.27.76/TYPython/ > >due to some nameserver madness here at work. I'm working to resolve the >situation. One way or another, it will be online within the next week >or so. I apologize for the inconvenience. > >Anyone who can't access the site with the IP address should write to me >off-list. >---------------------------------------------- >Ivan Van Laningham >Callware Technologies, Inc. >http://www.pauahtun.org >http://www.foretec.com/python/workshops/1998-11/proceedings.html >Army Signal Corps: Cu Chi, Class of '70 >Author: Teach Yourself Python in 24 Hours > > > >--__--__-- > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://www.python.org/mailman/listinfo/tutor > > >End of Tutor Digest_______________________________________________ >Tutor maillist - Tutor@python.org >http://www.python.org/mailman/listinfo/tutor > From doering@muse.calarts.edu Wed Apr 26 19:09:09 2000 From: doering@muse.calarts.edu (Jennifer Doering) Date: Wed, 26 Apr 2000 11:09:09 -0700 Subject: [Tutor] python as 'native' language Message-ID: Hi! I'm also learning Python as my 'native' language. I'd suggest "Learning Python" from O'Reilly. Be warned, though. Skip over parts that discuss other languages or find someone who can explain what they're talking about in the discussions of C and Perl. There's also a tutorial at the python website (www.python.org) for beginning programmers that helped me quite a bit. Pax, Jen From genius@idirect.com Wed Apr 26 19:20:34 2000 From: genius@idirect.com (Charles Takacs) Date: Wed, 26 Apr 2000 14:20:34 -0400 Subject: [Tutor] Learning to Code with Python Message-ID: <000601bfafac$28e698e0$0b019ad8@charlest> Hi Ivan :-)) I would have responded earlier to your correction, however I was to busy taking my foot out of my mouth AGAIN :-)). Please note the word AGAIN. Since a couple of months ago I gave credit to Alan Gauld for your book. You didn't catch me that time :-)) But Alan refused to take the credit which belong to you. So I guess he is not such bad guy as his enemies might profess. On the other hand; there is also the possibility that he doesn't like you. Heh-heh!! Just in case he doesn't have a sense of humor and also I can't afford to get on his "Black-List", I think it's advisable to cut out the Jokes. My mistake regarding your book's title came from not looking it the book's cover page. But at least I did some thing nice by not giving a link to a "Porno Page in referring to your book. Any way thanks again for your efforts and contribution. I am sure you will be hearing from me again (soon). BTY. What is going to be your nex Project ?? Best regards; Charles Takacs -----Original Message----- From: Ivan Van Laningham To: tutor@python.org Date: Wednesday, April 26, 2000 10:40 AM Subject: Re: [Tutor] Learning to Code with Python >Hi All-- > >Charles Takacs wrote: >> >> Hi Marcella :-)) >> I am also learning Python as the first Programming language.If you are >> Learning Python as the first Language then I would definatelly recommend you >> starting with the book "Learning Python in 24 Hours" by Ivan Van Laningham. >> You can get it from "amazon.com". >> > >Thank you for the kind words, Charles. But there is a teeny correction >I must make: the book is entitled _Teach Yourself Python in 24 Hours_, >from SAMS. > > >> I live in Canada and I just picked the book up a couple days ago from the >> local Computer Book Store since it was just released (finally) for >> publication. > >I'm glad to hear that it is actually out there in bookstores! > >Metta, >Ivan > >PS: The book's website, > > http://www.pauahtun.org/TYPython/ > >is currently inaccessible other than by IP address: > > http://63.64.27.76/TYPython/ > >due to some nameserver madness here at work. I'm working to resolve the >situation. One way or another, it will be online within the next week >or so. I apologize for the inconvenience. > >Anyone who can't access the site with the IP address should write to me >off-list. >---------------------------------------------- >Ivan Van Laningham >Callware Technologies, Inc. >http://www.pauahtun.org >http://www.foretec.com/python/workshops/1998-11/proceedings.html >Army Signal Corps: Cu Chi, Class of '70 >Author: Teach Yourself Python in 24 Hours > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://www.python.org/mailman/listinfo/tutor From mlfloren@bulldog.unca.edu Wed Apr 26 20:11:10 2000 From: mlfloren@bulldog.unca.edu (Marcella Louise Florence) Date: Wed, 26 Apr 2000 15:11:10 -0400 (EDT) Subject: [Tutor] Re: Learning to Program with Python In-Reply-To: <20000426160005.E07211CD20@dinsdale.python.org> Message-ID: I must thank the several who responded to me with such haste and kind words in an equally timely fashion. The reccomendations I've received are heartening and exciting. If anyone has nay further reccomendations, I would still be pleased to hear suggestions. Right now, it looks like Ivan's book, _Teach_Yourself_Python_in_24_Hours_ is top of the list for beginner programmers, and it shall probably be the first one I look at. I've received a couple secondary suggestions which I shall also look in to. I must say, I'm generally wary of books which suggest I can learn something in a specified amount of time when undoubtedly reading the book takes a lot longer than said amount of time. However, in this case I shall forgo my skepticism of such a lack of time-sense. Thank you, Ivan, for making this book available to people like myself. -Marcella *** "Me like stardust on your shoulders, friend..." -Yoko of Planet Rondo *** From danstar@execpc.com Wed Apr 26 20:26:02 2000 From: danstar@execpc.com (Dan Star) Date: Wed, 26 Apr 2000 14:26:02 -0500 Subject: [Tutor] _Teach_Yourself_Python_in_24_Hours_ Message-ID: <390742CA.C8CC0B19@execpc.com> Would this book also be useful for someone that has programmed in Pascal and VB? From some of the comments, it sounds like it focuses on fundamental programming concepts as best practices that may not have been taught in other programming books. --Dan From DOUGS@oceanic.com Wed Apr 26 20:34:48 2000 From: DOUGS@oceanic.com (Doug Stanfield) Date: Wed, 26 Apr 2000 09:34:48 -1000 Subject: [Tutor] Re: Learning to Program with Python Message-ID: <5650A1190E4FD111BC7E0000F8034D26A0F41C@huina.oceanic.com> To spare Ivan having to explain the title, yet once again, I'll try to step in. In actuality it may take just about 24 hours reading time to get through the book. I don't think its suggested to sprint through in a single marathon session though. If you take 24, hour long, reading sessions with sufficient time between for experimentation and digestion, its expected to have the most impact. HTH, I'm-sure-Ivan-can-speak-for-himself-if-I'm-wrong'ly -Doug- [Marcella Louise Florence said:] > I must say, I'm generally wary of books which suggest I can learn > something in a specified amount of time when undoubtedly > reading the book > takes a lot longer than said amount of time. From ivanlan@callware.com Wed Apr 26 20:33:05 2000 From: ivanlan@callware.com (Ivan Van Laningham) Date: Wed, 26 Apr 2000 13:33:05 -0600 Subject: [Tutor] _Teach_Yourself_Python_in_24_Hours_ References: <390742CA.C8CC0B19@execpc.com> Message-ID: <39074471.1DD6C7A3@callware.com> Hi All-- Dan Star wrote: > > Would this book also be useful for someone that has programmed in Pascal > and VB? From some of the comments, it sounds like it focuses on > fundamental programming concepts as best practices that may not have > been taught in other programming books. > The central third of the book concentrates on Objects and Object-Oriented Programming. The final third gives a solid introduction to Tkinter programming. Neither of these would have been covered in Pascal or VB, I should think. To get a feel for the basic concepts of Python, you should at least review the first third, but it can be skipped. -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. http://www.pauahtun.org http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From jimbruce007@hotmail.com Thu Apr 27 10:09:22 2000 From: jimbruce007@hotmail.com (jim bruce) Date: Thu, 27 Apr 2000 02:09:22 PDT Subject: [Tutor] (no subject) Message-ID: <20000427090922.40641.qmail@hotmail.com> jimbruce007@hotmail.com ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com From johnc@greatentertaining.com Fri Apr 28 00:24:59 2000 From: johnc@greatentertaining.com (John Choi) Date: Thu, 27 Apr 2000 16:24:59 -0700 Subject: [Tutor] Reading text files Message-ID: This is a multi-part message in MIME format. ------=_NextPart_000_0038_01BFB065.21867A70 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi everyone, I've got another text file question and was hoping I could glean more knowledge... Problem: Over a hundred text files by the following file name convention: quickYYYYMMDD.txt For each file, read the 1st and 7th line, and then write those lines to another file named aggy.txt in the following format: <1st line>, "~", <7th line> Any help or suggestions on how to go about doing this would be greatly appreciated. As it stands, I'm opening each file copy/pasting the lines. John Choi (415) 845-9072 ------------------------------------------------------------------ Shooting star of SPAM, Tail like a greasy white plume, Gastonomical. ------------------------------------------------------------------ Spam-ku: Tranquil Reflections on Luncheon Loaf John Nagamichi Cho (1998) ------=_NextPart_000_0038_01BFB065.21867A70 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi everyone,
 
I've got another text file = question and was=20 hoping I could glean more knowledge...
 
Problem:
Over a hundred text files by the = following=20 file name convention:
 
quickYYYYMMDD.txt
 
For each file, read the 1st = and 7th=20 line, and then write those lines to another file named aggy.txt in the = following=20 format:
 
<1st line>, "~", <7th=20 line>
 
Any help or suggestions on how to = go about=20 doing this would be greatly appreciated.  As it stands, I'm opening = each=20 file copy/pasting the lines.
 
John Choi
(415) = 845-9072
 
----------------------------------------------------------------= --
Shooting star of = SPAM,
Tail like a greasy white = plume,
Gastonomical.
----------------------------------------------------------------= --
Spam-ku:  Tranquil Reflections on = Luncheon=20 Loaf
John Nagamichi Cho = (1998)
 
------=_NextPart_000_0038_01BFB065.21867A70-- From scarblac@pino.selwerd.nl Fri Apr 28 01:19:08 2000 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Fri, 28 Apr 2000 02:19:08 +0200 Subject: [Tutor] Reading text files In-Reply-To: ; from johnc@greatentertaining.com on Thu, Apr 27, 2000 at 04:24:59PM -0700 References: Message-ID: <20000428021908.A15418@pino.selwerd.nl> On Thu, Apr 27, 2000 at 04:24:59PM -0700, John Choi wrote: > I've got another text file question and was hoping I could glean more > knowledge... > > Problem: > Over a hundred text files by the following file name convention: > > quickYYYYMMDD.txt > > For each file, read the 1st and 7th line, and then write those lines to > another file named aggy.txt in the following format: > > <1st line>, "~", <7th line> > > Any help or suggestions on how to go about doing this would be greatly > appreciated. As it stands, I'm opening each file copy/pasting the lines. I can't test here, but I think something like this works: import glob aggy = open('aggy.txt','w') files = glob.glob('quick*.txt') for file in files: f = open(file,'r') line1 = f.readline() for i in range(6): spam = f.readline() # Skip 5 lines line2 = f.readline() f.write('%s~%s' % (line1, line2)) f.close() aggy.close() Not sure if I got the format right though. -- Remco Gerlich, scarblac@pino.selwerd.nl From scarblac@pino.selwerd.nl Fri Apr 28 02:27:01 2000 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Fri, 28 Apr 2000 03:27:01 +0200 Subject: [Tutor] Reading text files In-Reply-To: <20000428021908.A15418@pino.selwerd.nl>; from scarblac@pino.selwerd.nl on Fri, Apr 28, 2000 at 02:19:08AM +0200 References: <20000428021908.A15418@pino.selwerd.nl> Message-ID: <20000428032701.A15489@pino.selwerd.nl> On Fri, Apr 28, 2000 at 02:19:08AM +0200, Remco Gerlich wrote: > for i in range(6): > spam = f.readline() # Skip 5 lines range(5) of course, duh. > f.write('%s~%s' % (line1, line2)) Also I'm quite sure now that this formatting isn't what you meant, but you'll have to explain better, and anyway, 3:26 am is really time to go to bed ;-). -- Remco Gerlich, scarblac@pino.selwerd.nl From genius@idirect.com Fri Apr 28 18:22:19 2000 From: genius@idirect.com (Snoopy :-))) Date: Fri, 28 Apr 2000 13:22:19 -0400 Subject: [Tutor] Help Needed--IDLE Upgrading Message-ID: <3909C8CB.23C5DD3F@idirect.com> No Flames Please. I am a NEWBIE :-)) Using Linux (RH-6.1) I have downloaded the Idle-0.5 Upgrade "tgz". package.But I don't know where and how to install the package. After unzipping the package I've read the README file which doesn't seem to give clear instructions regarding installation of the upgrade. On my system Idle is in /usr/bin but this is only the executable file without subdirectories where I would be able to put the untared and uzipped files. I would appreciate a helping hand Best regards Charles Takacs From charlie@intelligenesis.net Fri Apr 28 18:59:09 2000 From: charlie@intelligenesis.net (Charlie Derr) Date: Fri, 28 Apr 2000 13:59:09 -0400 Subject: [Tutor] Help Needed--IDLE Upgrading In-Reply-To: <3909C8CB.23C5DD3F@idirect.com> Message-ID: what i did (on NT, though i think that shouldn't matter) was to rename the existing directory (you would change /usr/bin/idle to /usr/bin/idle_4), and then to put the unzipped folder in there and rename it to idle good luck, ~c |-----Original Message----- |From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of |Snoopy :-)) |Sent: Friday, April 28, 2000 1:22 PM |To: Python Tutor |Subject: [Tutor] Help Needed--IDLE Upgrading | | |No Flames Please. I am a NEWBIE :-)) |Using Linux (RH-6.1) I have downloaded the Idle-0.5 Upgrade "tgz". |package.But I don't know where and how to install the package. After |unzipping the package I've read the README file which doesn't seem to |give clear instructions regarding installation of the upgrade. On my |system |Idle is in /usr/bin but this is only the executable file without |subdirectories where I would be able to put the untared and uzipped |files. | |I would appreciate a helping hand |Best regards |Charles Takacs | |_______________________________________________ |Tutor maillist - Tutor@python.org |http://www.python.org/mailman/listinfo/tutor | From charlie@intelligenesis.net Fri Apr 28 19:05:44 2000 From: charlie@intelligenesis.net (Charlie Derr) Date: Fri, 28 Apr 2000 14:05:44 -0400 Subject: [Tutor] Help Needed--IDLE Upgrading In-Reply-To: Message-ID: Sorry, I didn't read closely enough. On further examination, my attempted help may very well be no help at all to you. Sorry, and i hope i haven't wasted too much of your time, ~c |-----Original Message----- |From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of |Charlie Derr |Sent: Friday, April 28, 2000 1:59 PM |To: Snoopy :-)); Python Tutor |Subject: RE: [Tutor] Help Needed--IDLE Upgrading | | |what i did (on NT, though i think that shouldn't matter) was to rename the |existing directory (you would change /usr/bin/idle to /usr/bin/idle_4), and |then to put the unzipped folder in there and rename it to idle | | good luck, | ~c | ||-----Original Message----- ||From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of ||Snoopy :-)) ||Sent: Friday, April 28, 2000 1:22 PM ||To: Python Tutor ||Subject: [Tutor] Help Needed--IDLE Upgrading || || ||No Flames Please. I am a NEWBIE :-)) ||Using Linux (RH-6.1) I have downloaded the Idle-0.5 Upgrade "tgz". ||package.But I don't know where and how to install the package. After ||unzipping the package I've read the README file which doesn't seem to ||give clear instructions regarding installation of the upgrade. On my ||system ||Idle is in /usr/bin but this is only the executable file without ||subdirectories where I would be able to put the untared and uzipped ||files. || ||I would appreciate a helping hand ||Best regards ||Charles Takacs || ||_______________________________________________ ||Tutor maillist - Tutor@python.org ||http://www.python.org/mailman/listinfo/tutor || | | |_______________________________________________ |Tutor maillist - Tutor@python.org |http://www.python.org/mailman/listinfo/tutor | From genius@idirect.com Fri Apr 28 19:05:58 2000 From: genius@idirect.com (Snoopy :-))) Date: Fri, 28 Apr 2000 14:05:58 -0400 Subject: [Tutor] Help Needed--IDLE Upgrading References: Message-ID: <3909D306.9A5AA64B@idirect.com> Thanks for the reply Your instructions only apply to Windows, I had no problems there. But in linux I don't know how to proceed. Best regards Charles Charlie Derr wrote: > > Sorry, I didn't read closely enough. On further examination, my attempted > help may very well be no help at all to you. Sorry, and i hope i haven't > wasted too much of your time, > ~c > > |-----Original Message----- > |From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > |Charlie Derr > |Sent: Friday, April 28, 2000 1:59 PM > |To: Snoopy :-)); Python Tutor > |Subject: RE: [Tutor] Help Needed--IDLE Upgrading > | > | > |what i did (on NT, though i think that shouldn't matter) was to rename the > |existing directory (you would change /usr/bin/idle to /usr/bin/idle_4), and > |then to put the unzipped folder in there and rename it to idle > | > | good luck, > | ~c > | > ||-----Original Message----- > ||From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > ||Snoopy :-)) > ||Sent: Friday, April 28, 2000 1:22 PM > ||To: Python Tutor > ||Subject: [Tutor] Help Needed--IDLE Upgrading > || > || > ||No Flames Please. I am a NEWBIE :-)) > ||Using Linux (RH-6.1) I have downloaded the Idle-0.5 Upgrade "tgz". > ||package.But I don't know where and how to install the package. After > ||unzipping the package I've read the README file which doesn't seem to > ||give clear instructions regarding installation of the upgrade. On my > ||system > ||Idle is in /usr/bin but this is only the executable file without > ||subdirectories where I would be able to put the untared and uzipped > ||files. > || > ||I would appreciate a helping hand > ||Best regards > ||Charles Takacs > || > ||_______________________________________________ > ||Tutor maillist - Tutor@python.org > ||http://www.python.org/mailman/listinfo/tutor > || > | > | > |_______________________________________________ > |Tutor maillist - Tutor@python.org > |http://www.python.org/mailman/listinfo/tutor > | From tismer@tismer.com Fri Apr 28 19:39:02 2000 From: tismer@tismer.com (Christian Tismer) Date: Fri, 28 Apr 2000 20:39:02 +0200 Subject: [Tutor] _Teach_Yourself_Python_in_24_Hours_ References: <390742CA.C8CC0B19@execpc.com> <39074471.1DD6C7A3@callware.com> Message-ID: <3909DAC6.BD7ED40E@tismer.com> Ivan Van Laningham wrote: > > Hi All-- > > Dan Star wrote: > > > > Would this book also be useful for someone that has programmed in Pascal > > and VB? From some of the comments, it sounds like it focuses on > > fundamental programming concepts as best practices that may not have > > been taught in other programming books. > > > > The central third of the book concentrates on Objects and > Object-Oriented Programming. The final third gives a solid introduction > to Tkinter programming. Neither of these would have been covered in > Pascal or VB, I should think. > > To get a feel for the basic concepts of Python, you should at least > review the first third, but it can be skipped. > > -ly y'rs, > Ivan;-) 24 days with an hour each would work better, right? :-) Unfortunately I cannot get your book here in Germany already, but I will try to get it ASAP. I was planning my own book for absolute programming beginners, and I have an offer to do that. Would you say this makes still sense after your work, or do you know whether someone else is already writing such a thing? ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From ivanlan@callware.com Fri Apr 28 19:42:45 2000 From: ivanlan@callware.com (Ivan Van Laningham) Date: Fri, 28 Apr 2000 12:42:45 -0600 Subject: [Tutor] _Teach_Yourself_Python_in_24_Hours_ References: <390742CA.C8CC0B19@execpc.com> <39074471.1DD6C7A3@callware.com> <3909DAC6.BD7ED40E@tismer.com> Message-ID: <3909DBA5.AA47E227@callware.com> Hi All-- Christian Tismer wrote: > [snip] > 24 days with an hour each would work better, right? :-) > Yes, or a month, or whatever you need. > Unfortunately I cannot get your book here in Germany already, > but I will try to get it ASAP. > Good luck. If US sales are good enough, there might be a German edition eventually, though. > I was planning my own book for absolute programming beginners, > and I have an offer to do that. Would you say this makes still > sense after your work, or do you know whether someone else > is already writing such a thing? > Alan Gauld is writing one, I think. Alan? But honestly, there are very few good books for complete beginners, and any addition, as long as it's good, can only benefit the field. I'll buy *anything* Python, so you've got at least one sale;-) (Unless it's in German!) -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. http://www.pauahtun.org http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From tismer@tismer.com Fri Apr 28 20:02:54 2000 From: tismer@tismer.com (Christian Tismer) Date: Fri, 28 Apr 2000 21:02:54 +0200 Subject: [Tutor] _Teach_Yourself_Python_in_24_Hours_ References: <390742CA.C8CC0B19@execpc.com> <39074471.1DD6C7A3@callware.com> <3909DAC6.BD7ED40E@tismer.com> <3909DBA5.AA47E227@callware.com> Message-ID: <3909E05E.51119B73@tismer.com> Ivan Van Laningham wrote: [schnipp] > Alan Gauld is writing one, I think. Alan? But honestly, there are very > few good books for complete beginners, and any addition, as long as it's > good, can only benefit the field. I'll buy *anything* Python, so you've > got at least one sale;-) (Unless it's in German!) It would be in German probably first. The other offer I have is the opposite: Writing an "Advanced Python Programming" in English, for O'Reilly. A hard decision. How to stand an O'Reilly offer? > -ly y'rs, > Ivan;-) We met at least at one IPC, so its me? :-)) ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From ivanlan@callware.com Fri Apr 28 20:08:46 2000 From: ivanlan@callware.com (Ivan Van Laningham) Date: Fri, 28 Apr 2000 13:08:46 -0600 Subject: [Tutor] _Teach_Yourself_Python_in_24_Hours_ References: <390742CA.C8CC0B19@execpc.com> <39074471.1DD6C7A3@callware.com> <3909DAC6.BD7ED40E@tismer.com> <3909DBA5.AA47E227@callware.com> <3909E05E.51119B73@tismer.com> Message-ID: <3909E1BE.EB868A15@callware.com> Hi All-- Christian Tismer wrote: > > Ivan Van Laningham wrote: > [schnipp] > > Alan Gauld is writing one, I think. Alan? But honestly, there are very > > few good books for complete beginners, and any addition, as long as it's > > good, can only benefit the field. I'll buy *anything* Python, so you've > > got at least one sale;-) (Unless it's in German!) > > It would be in German probably first. Then I *doubly* encourage you to pursue this offer! > The other offer I have is the opposite: > Writing an "Advanced Python Programming" in English, for O'Reilly. > A hard decision. How to stand an O'Reilly offer? > Oh, do that too! But leave out all the evil tricks you know--especially the ones you've forgotten on purpose;-) > > -ly y'rs, > > Ivan;-) > > We met at least at one IPC, so its me? :-)) > Hee, hee! I meant that the only *words* in German I know are impolite, but you can be an impolite German if you want! -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. http://www.pauahtun.org http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From iamito@mail.telepac.pt Sat Apr 29 15:06:23 2000 From: iamito@mail.telepac.pt (iamito) Date: Sat, 29 Apr 2000 15:06:23 +0100 Subject: [Tutor] (no subject) Message-ID: <033801bfb1e4$1aea8460$29600dd5@mop53109> confirm 995922 From scorder@cinci.rr.com Sat Apr 29 17:54:57 2000 From: scorder@cinci.rr.com (Samus) Date: Sat, 29 Apr 2000 12:54:57 -0400 Subject: [Tutor] Help Needed--IDLE Upgrading References: <3909D306.9A5AA64B@idirect.com> Message-ID: <390B13E1.B89D2CCA@cinci.rr.com> Actually if you open the idle file that is in your bin dir you will see that it is a script that runs the real idle program. /usr/lib/python/site-packages/idle/ Just follow the instructions below but with this dir. -Sam "Snoopy :-))" wrote: > > Thanks for the reply > Your instructions only apply to Windows, I had no problems there. But in > linux I don't know how to proceed. > Best regards > Charles > > Charlie Derr wrote: > > > > Sorry, I didn't read closely enough. On further examination, my attempted > > help may very well be no help at all to you. Sorry, and i hope i haven't > > wasted too much of your time, > > ~c > > > > |-----Original Message----- > > |From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > > |Charlie Derr > > |Sent: Friday, April 28, 2000 1:59 PM > > |To: Snoopy :-)); Python Tutor > > |Subject: RE: [Tutor] Help Needed--IDLE Upgrading > > | > > | > > |what i did (on NT, though i think that shouldn't matter) was to rename the > > |existing directory (you would change /usr/bin/idle to /usr/bin/idle_4), and > > |then to put the unzipped folder in there and rename it to idle > > | > > | good luck, > > | ~c > > | > > ||-----Original Message----- > > ||From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > > ||Snoopy :-)) > > ||Sent: Friday, April 28, 2000 1:22 PM > > ||To: Python Tutor > > ||Subject: [Tutor] Help Needed--IDLE Upgrading > > || > > || > > ||No Flames Please. I am a NEWBIE :-)) > > ||Using Linux (RH-6.1) I have downloaded the Idle-0.5 Upgrade "tgz". > > ||package.But I don't know where and how to install the package. After > > ||unzipping the package I've read the README file which doesn't seem to > > ||give clear instructions regarding installation of the upgrade. On my > > ||system > > ||Idle is in /usr/bin but this is only the executable file without > > ||subdirectories where I would be able to put the untared and uzipped > > ||files. > > || > > ||I would appreciate a helping hand > > ||Best regards > > ||Charles Takacs > > || > > ||_______________________________________________ > > ||Tutor maillist - Tutor@python.org > > ||http://www.python.org/mailman/listinfo/tutor > > || > > | > > | > > |_______________________________________________ > > |Tutor maillist - Tutor@python.org > > |http://www.python.org/mailman/listinfo/tutor > > | > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From genius@idirect.com Sat Apr 29 20:40:47 2000 From: genius@idirect.com (Snoopy :-))) Date: Sat, 29 Apr 2000 15:40:47 -0400 Subject: [Tutor] Help Needed--IDLE Upgrading References: <3909D306.9A5AA64B@idirect.com> <390B13E1.B89D2CCA@cinci.rr.com> Message-ID: <390B3ABF.E1838E5F@idirect.com> Hi Samus :-)) Thanks for your reply. Actually I was able to figure it out by myself and solve it last night. I just didn't have the chance to get back and let the Group know until now. What I did was: to go into GnoRpm and did a "Query" on Python and was able to trace idle. Then I just followed the downloaded README by copying the files into the old directory. So what do you think? Is there any hope for me in becoming a genius one day?? :-)) Best regards Charles Samus wrote: > > Actually if you open the idle file that is in your bin dir you will see > that it is a script that runs the real idle program. > /usr/lib/python/site-packages/idle/ Just follow the instructions below > but with this dir. > > -Sam > > "Snoopy :-))" wrote: > > > > Thanks for the reply > > Your instructions only apply to Windows, I had no problems there. But in > > linux I don't know how to proceed. > > Best regards > > Charles > > > > Charlie Derr wrote: > > > > > > Sorry, I didn't read closely enough. On further examination, my attempted > > > help may very well be no help at all to you. Sorry, and i hope i haven't > > > wasted too much of your time, > > > ~c > > > > > > |-----Original Message----- > > > |From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > > > |Charlie Derr > > > |Sent: Friday, April 28, 2000 1:59 PM > > > |To: Snoopy :-)); Python Tutor > > > |Subject: RE: [Tutor] Help Needed--IDLE Upgrading > > > | > > > | > > > |what i did (on NT, though i think that shouldn't matter) was to rename the > > > |existing directory (you would change /usr/bin/idle to /usr/bin/idle_4), and > > > |then to put the unzipped folder in there and rename it to idle > > > | > > > | good luck, > > > | ~c > > > | > > > ||-----Original Message----- > > > ||From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of > > > ||Snoopy :-)) > > > ||Sent: Friday, April 28, 2000 1:22 PM > > > ||To: Python Tutor > > > ||Subject: [Tutor] Help Needed--IDLE Upgrading > > > || > > > || > > > ||No Flames Please. I am a NEWBIE :-)) > > > ||Using Linux (RH-6.1) I have downloaded the Idle-0.5 Upgrade "tgz". > > > ||package.But I don't know where and how to install the package. After > > > ||unzipping the package I've read the README file which doesn't seem to > > > ||give clear instructions regarding installation of the upgrade. On my > > > ||system > > > ||Idle is in /usr/bin but this is only the executable file without > > > ||subdirectories where I would be able to put the untared and uzipped > > > ||files. > > > || > > > ||I would appreciate a helping hand > > > ||Best regards > > > ||Charles Takacs > > > || > > > ||_______________________________________________ > > > ||Tutor maillist - Tutor@python.org > > > ||http://www.python.org/mailman/listinfo/tutor > > > || > > > | > > > | > > > |_______________________________________________ > > > |Tutor maillist - Tutor@python.org > > > |http://www.python.org/mailman/listinfo/tutor > > > | > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://www.python.org/mailman/listinfo/tutor > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor From genius@idirect.com Sat Apr 29 20:51:09 2000 From: genius@idirect.com (Snoopy :-))) Date: Sat, 29 Apr 2000 15:51:09 -0400 Subject: [Tutor] Thanks for The Help :-) Message-ID: <390B3D2D.ACAF41FF@idirect.com> I'd like to thank every one for the helpin hand. Actually I was able to figure it out by myself and solve it last night. I just didn't have the chance to get back and let the Group know until now. What I did was: to go into GnoRpm and did a "Query" on Python and was able to trace idle. Then I just followed the downloaded README by copying the files into the old directory. So what do you think? Is there any hope for me in becoming a genius one day?? :-)) Best regards Charles From phoenix@kollegie6400.dk Sat Apr 29 23:00:53 2000 From: phoenix@kollegie6400.dk (Carsten Jensen) Date: Sun, 30 Apr 2000 00:00:53 +0200 Subject: [Tutor] (no subject) Message-ID: <000701bfb226$6393df80$3559f9c3@phoenix.uk.kollegie6400.dk> This is a multi-part message in MIME format. ------=_NextPart_000_0004_01BFB237.26FB1DC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ------=_NextPart_000_0004_01BFB237.26FB1DC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
 
------=_NextPart_000_0004_01BFB237.26FB1DC0--