Re: [Tutor] iterating in the same line

2005-08-13 Thread Bob Gailer
k The 3rd alternative is to use regular expression matching. That is beyond the scope of this thread. [snip] Bob Gailer mailto:[EMAIL PROTECTED] 303 442 2625 home 720 938 2625 cell ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] re and more ... read on

2005-08-14 Thread Bob Gailer
p/' + pdf try: # report and skip bad urls pn = urllib2.urlopen(url) except: print "Bad url:", url continue p = pn.read() z = file(outfile, 'wb') z.write(p) z.close() BTW if you answered YES to the "What!" question you got "Congratulations - you just killed a bear." Bob Gailer 303 442 2625 home 720 938 2625 cell ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] convert a file from plaintext(Ascii) to unicode? very quick questions

2005-08-15 Thread Bob Gailer
gt;and I have a hard time keeping them straight. I'm pretty sure I knew >the answer to this and now cannot find it anywhere (even googling >through my old tutor posts!) > >Does anyone have a quick answer/pointer? Try the unicode() built-in function. Read the file into a variable, app

Re: [Tutor] Is there anyway to set how many numbers are used after the decimal in floating numbers?

2005-08-18 Thread Bob Gailer
cision can caus cumulative errors. Example: >>> i = 0.0 >>> for j in range(10):i += j*.1 >>> i 4.5009 If you have Python 2.4 + the decimal module may give you what you need. Bob Gailer 303 442 2625 home 720 938 2625 cell _

Re: [Tutor] Is there anyway to set how many numbers are used after the decimal in floating numbers?

2005-08-18 Thread Bob Gailer
At 11:17 AM 8/18/2005, Nathan Pinno wrote: >I want to use it for a currency exchange program. It's useful, then the user >wouldn't have to round it himself/herself, and mistakes could be avoided. That is what the decimal module is for. I suggest you use it. Bob Gailer 303 442 2

Re: [Tutor] hi HELP

2005-08-19 Thread Bob Gailer
subscribe. Click >http://mail.python.org/mailman/listinfo/tutor and look for unsubscribe under the subscribe section. Bob Gailer 303 442 2625 home 720 938 2625 cell ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Writing to text files

2005-08-22 Thread Bob Gailer
Your new line of data with the time stamp goes here.\n" + >filedata >file = open("datafile.txt", "w") >file.write(newLine) >file.close() or if you like terseness: newText = newLine + open("datafile.txt", "r").read() open("datafile.txt&

Re: [Tutor] Working with files

2005-08-24 Thread Bob Gailer
he string assemble a new string consisting of: the original string up to the location (index) of "something" "what" the rest of the original string write the new string to the file Bob Gailer 303 442 2625 home 720 938 2625 cell _

Re: [Tutor] Aschenputtel problem

2005-09-15 Thread Bob Gailer
At 10:12 AM 9/15/2005, Christopher Arndt wrote: Hi,I wonder if there is a shorter form of the following idiom:list1 = []list2 = []for item in original_list:    if condition(item):    list1.append(item)    else:    list2.append(item)Consider (5 lines instead of 7):lists = [[], []]for it

[Tutor] Calling Modules in ActiveState 2.4

2005-09-21 Thread Bob Nienhuis
s. Is this new behavior in Activstate 2.4, or do I need to set an environment variable? Bob ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Calling Modules in ActiveState 2.4

2005-09-21 Thread Bob Nienhuis
r script (0 = okay, other = problem). sys.path is an attribute (of type list) of sys not a function. So don't put () after path. I hope it will help. Damien. Bob Nienhuis wrote: Working my way through Alan Gauld's tutorial, and I am on the section on modules. When I call: import sys sys

Re: [Tutor] Calling Modules in ActiveState 2.4

2005-09-21 Thread Bob Nienhuis
24\Lib\site-packages\pythonwin\pywin\framework\interact.py", line 257, in runcode     exec code in self.globals, self.locals   File "", line 1, in ? SystemExit sys.exit(0) >>> On 9/21/05, Bob Nienhuis <[EMAIL PROTECTED]> wrote: When I do: import sys sys.exit(0) I

[Tutor] Delete an attribute using Beautiful Soup?

2005-11-22 Thread Bob Tanner
bad HTML can define the same #attribute multiple times. self._getAttrMap() if self.attrMap.has_key(key): del self.attrMap[key] -- Bob Tanner <[EMAIL PROTECTED]> | Phone : (952)943-8700 http://www.real-time.com, Minnesota, Linux | Fax : (

Re: [Tutor] Delete an attribute using Beautiful Soup?

2005-11-22 Thread Bob Tanner
Bob Tanner wrote: > I'd like to delete an attribute of tag, the BGCOLOR to the BODY tag to be > exact. I believe I answered my own question. Looking for confirmation this is the "right" solution. del(soup.body['bgcolor']) -- Bob Tanner <[EMAIL PROTECTED]

[Tutor] Beautiful Soup, inserting a node?

2005-11-28 Thread Bob Tanner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Is there a way to insert a node with Beautiful Soup? I found away to append "things". But Blah Foo! I'd like to insert a tag, like this: Blah Foo! -

Re: [Tutor] Beautiful Soup, inserting a node?

2005-12-02 Thread Bob Tanner
parsing of the html. -- Bob Tanner <[EMAIL PROTECTED]> | Phone : (952)943-8700 http://www.real-time.com, Minnesota, Linux | Fax : (952)943-8500 Key fingerprint = AB15 0BDF BCDE 4369 5B42 1973 7CF1 A709 2CC1 B288 ___ Tutor maillist

[Tutor] ElementTree, TidyHTMLTreeBuilder, find

2005-12-13 Thread Bob Tanner
ot() >>> print root.find('html/body') None >>> print root.find('body') None >>> Viewing the html under firefox DOM tool -#document -HTML +HEAD #TEXT +BODY No sure how to use the find. -- Bob Tanner <[EMAIL PROTECTED]>

Re: [Tutor] Controling my loops and redundant code?!?

2006-01-26 Thread Bob Gailer
ntry is convertible.: available_points = MAX_POINTS - sum(points) print "You have " + available_points + " available." for x in range(len(attributes)):  cvalue = raw_input("How much would you like to assign to " + attributes[x] + " ?: "))   if cvalue.isdigit():    

Re: [Tutor] Controling my loops and redundant code?!?

2006-01-26 Thread Bob Gailer
t;,attributes[x], points[x] To assign values. Note I separated getting input from converting it to integer so we can see if the user's entry is convertible.: available_points = MAX_POINTS - sum(points) print "You have " + available_points + " available." for x in range(len(

[Tutor] AttributeError - ChatServer

2006-01-26 Thread Bob Hinkle
While following a tutorial on how to create a simple chat server I stumbled upon this problem: AttributeError: ChatServer instance has no attribute 'decriptors' here is my code: #... import socket import select class

Re: [Tutor] Trying to enter text from a file to a Dictionary

2006-01-27 Thread Bob Gailer
Alan Gauld wrote: > Hi Ben, > > >> I want to enter the words and definitions from the text file into the >> dict. >> The way the text file is set up is that one line is the word and the >> next line is the definition. >> > > >> I tried using a for loop like this >> >> f = open('glos

Re: [Tutor] Trying to enter text from a file to a Dictionary

2006-01-27 Thread Bob Gailer
Bob Gailer wrote: > Alan Gauld wrote: > >> Hi Ben, >> >> >> >>> I want to enter the words and definitions from the text file into the >>> dict. >>> The way the text file is set up is that one

Re: [Tutor] Trying to enter text from a file to a Dictionary

2006-01-27 Thread Bob Gailer
Ben Markwell wrote: > > > On 1/27/06, *Bob Gailer* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > Bob Gailer wrote: > > Alan Gauld wrote: > > > >> Hi Ben, > >> > >> > >> >

Re: [Tutor] Newbie question re. Functions

2006-01-31 Thread Bob Gailer
Jon Moore wrote: > Hi, > > I am still working my way through my 'Python for absolute beginners > book' and have hit a brick wall with one of the end of chapter exercises. > > The challenge says: > > Improve the function ask_number() so that the function can be called > with a step value. Make the

Re: [Tutor] Cannot run .py file from apache web server , Guidance requested

2006-01-31 Thread Bob Gailer
John Joseph wrote: > Hi > I am trying to execute .py scripts from my > apache web server , but it is not giving the results > as how I run php files , it just displays the > contents of the script , I am able to run and get > results of PHP from the same loaction > my “sample-test.py “file

Re: [Tutor] Cannot run .py file from apache web server , Guidance requested

2006-01-31 Thread Bob Gailer
Further delving leads to "Apache Tutorial: Dynamic Content with CGI" in the Apache Documentation. Under that is a section "But it's still not working! ... you see ... The source code of your CGI program ...That means that you have not properly configured Apache to process your CGI program. Rere

Re: [Tutor] Todays Learning Python Question From a Newbie ;)

2006-02-01 Thread Bob Gailer
Jon Moore wrote: > Hi, > > Ok its the last exercise in the chapter of the python book (Python for > the absolute beginner) I am working my way through. > > I have been learning about functions using a tic-tac-toe game as an > example and I understand it fairly clearly, however the author says >

Re: [Tutor] Sqrt is listed as always available.

2006-02-15 Thread Bob Gailer
Kermit Rose wrote: > Sqrt is listed as always available. > Where did you see that? Try: >>> import math >>> math.sqrt(24) 4.8989794855663558 > Why did I get these diagnostics? > > > Sqrt(J0) > > Traceback (most recent call last): > File "", line 1, in -toplevel- >

Re: [Tutor] Grepping a file for words in a list

2006-02-24 Thread Bob Gailer
John Purser wrote: > Hello, > > I'm writing a system admin script in python that checks recently > accessed files for keywords like "failed, denied, error,..." etc. I'm > using popen to call grep -F but it's VERY slow. Can > anyone suggest a faster method to do this? > I don't know whether i

Re: [Tutor] RDT server for excel

2006-02-27 Thread Bob Gailer
János Juhász wrote: > Hi All, > > I would like to make a small RDT Server as COM Server in python that can be > called from excel as =RDT("StockBalance.MyServer",,"17") > I for one have no idea what RDT is, so can't help. Maybe someone else has an idea. Or can you give us more information o

Re: [Tutor] switch-case in python

2006-02-28 Thread Bob Gailer
铁石 wrote: > I know this may seem to be stupid. > but as I found that there's no > switch-case control flow in python, > an I just can't remember( or know) any > method to make such a control flow. > if cond1: stmts elif cond2: stmts ... else: stmts No need for break. > > > --

Re: [Tutor] How can a function know where it was called from

2006-03-02 Thread Bob Gailer
Ben Vinger wrote: > Thanks to all who responded. I ended up using a sender parameter as > suggested by Andre and Alan, as this was very simple to do. When confronted with problems like this I tend to create classes, then subclass as needed for special circumstances. You might consider that app

Re: [Tutor] Delete in .dat

2006-03-05 Thread Bob Gailer
ryan luna wrote: > My question seems like itd be farly simple but i cant > seem to get it to work, > My .dat file is a dictionary and i need to be able to > only delete a single word and its definition, > heres what i have so far but it doesn't work. > AARHG! I am always frustrated by "it doesn'

Re: [Tutor] module imports

2006-03-08 Thread Bob Gailer
kevin parks wrote: > i have a module called foo.py > > foo.py imports random > > kp.py imports foo.py ... but in kp.py i also need to use stuff from > random... > > so kp.py also imports random > > but i prolly shouldn't do that right? > Wrong. > Cause now, haven't i needlessly copied the s

Re: [Tutor] Cannot Understand

2006-03-10 Thread Bob Gailer
Edgar Antonio Rodriguez Velazco wrote: > Hi, > Could you please explain this code?. > > f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 You've had 2 replies that dissect the "expression". I fear they might not make lambda itself clear, so I will add my explanation. lambda is a Python operator that

Re: [Tutor] scaling values

2006-03-14 Thread Bob Gailer
kevin parks wrote: > i have various functions (that i didn't write) that put out data in > lists of various types. But some functions (which i didn't write) that > expect the data to be scaled, sometimes 0-1 sometimes 1-2, sometimes > 0-127..., sometimes 0 - 32768... gosh you name it. In other w

Re: [Tutor] Automating web page parsing

2006-03-29 Thread Bob Gailer
Srinivas Iyyer wrote: > Dear group, > > ***Disclaimer***Not suitable for BioPython list*** > > I work with GeneChips to analyze human gene expression > patterns. These genechips are various kinds one of the > variety is made at Stanford University. In a typical > experiment, an experimenter uses r

Re: [Tutor] defined()

2006-04-03 Thread Bob Gailer
Hugo González Monteverde wrote: > Alan Gauld wrote: > > >> Which language(s) do you know that has such a feature? >> And why do you consider it so useful that you expect to find >> it in Python? >> > > I'm not the original poster, but being a perlhead before, I can say it > exists in Perl.

Re: [Tutor] Question about large numbers of arguments

2006-04-04 Thread Bob Gailer
Dana Robinson wrote: > Hello, > > Suppose you have a situation where you have a large number of command-line > options that you will parse with getopt. You want to keep track of these > as you move around in the code and do various things. > > Is it more Pythonic to: > > Have the functions take la

Re: [Tutor] Beginner question (variables, namespaces...)

2006-04-07 Thread Bob Gailer
Jesse wrote: > Why is it that when one variable is assigned a value in terms of > another variable, assigning a new value to the first doesn't change > the value of the second? This is giving me a huge headache, since I > have a bunch of variables defined in terms of one another, and I want > t

[Tutor] Bob Gibson is out of the office.

2006-04-08 Thread Bob Gibson
I will be out of the office starting 03/31/2006 and will not return until 04/10/2006. I will respond to your message when I return.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] failing to learn python

2006-04-10 Thread Bob Gailer
Payal Rathod wrote: > On Mon, Apr 10, 2006 at 10:05:45AM -0400, Kent Johnson wrote: > >> You might like to look at "Python Programming for the absolute >> beginner". It is oriented to beginners and has many examples and >> exercises. >> > > I might not be able to afford another book, due

Re: [Tutor] input with default value option

2006-04-10 Thread Bob Gailer
Keo Sophon wrote: > Hi, > > With raw_input(), it allows to input value. Can it be used to input value > with default value option? > response = raw_input("Enter some data:") if not response: response = "default value" ___ Tutor maillist - Tutor@pyt

Re: [Tutor] Decorators

2006-04-11 Thread Bob Gailer
Alan Gauld wrote: >> Syntactic sugar *IS* a practical benefit. After all, every language above >> assember is syntactic sugar, and by your definition of no practical use. >> > > Ah, but by that standard even assembler is syntactic sugar, now > where are those hex codes and my keypunch? :-) Onl

Re: [Tutor] Decorators

2006-04-11 Thread Bob Gailer
Andrew D. Fant wrote: > [snip] try crossing lisp > with APL for a mathematically pure language that nobody can ever read. > One problem is that APL allowed unbalanced parentheses (as in )SAVE), whereas LISP does not. And of course there is the right-to-left vs left-to-right issue... I do mis

Re: [Tutor] n00b question: dictionaries and functions.

2006-04-12 Thread Bob Gailer
Jesse wrote: > Hey, this should be an easy question for you guys. I'm writing my > first program (which Bob, Alan, and Danny have already helped me > with--thanks, guys!), and I'm trying to create a simple command-line > interface. I have a good portion of the pro

Re: [Tutor] Difficulty connecting with odbc drivers

2006-04-15 Thread Bob Gailer
John Corry wrote: > Liam, > > Thanks for the quick response. I have changed the code so that dsn is now > DSN. However I get the same error. I agree with Alan.the dsn should point to a data source rather than a file. To be more precise Start -> Settings -> Control Panel -> Administrative Tools

Re: [Tutor] Changing lists in place

2006-04-17 Thread Bob Gailer
Paul D. Kraus wrote: > I have a list that I want to change in a for loop. It changes in the > loop but the changes are not persistant outside of the loop. > I thought lists were mutuable objects They are. > so I am a bit confused. > > Sample Code > #!/usr/bin/env python > """ Testing lists ""

Re: [Tutor] My Name is John and I copy and paste

2006-04-18 Thread Bob Gailer
John CORRY wrote: > > Hi, > > > > Thanks for all the help so far on my database questions. I have now > developed a program that reads in info from a csv file and updates > already existing records in my database. I have enclosed the code > below. The good news is that it is working. Howev

Re: [Tutor] Object defined by initialization parameters

2006-04-24 Thread Bob Gailer
Andre Engels wrote: > Is it possible to define a class in such a way, that if twice an > object is made with the same initialization parameters, the same > object is returned in both cases? > Use a "factory" function, and store a dictionary of instances as a class property: class myObj(object)

Re: [Tutor] Object defined by initialization parameters ADDITION

2006-04-24 Thread Bob Gailer
Bob Gailer wrote: Andre Engels wrote: Is it possible to define a class in such a way, that if twice an object is made with the same initialization parameters, the same object is returned in both cases? Use a "factory" function, and store a dictionary of inst

Re: [Tutor] Avoiding the use of files to store intermediate results

2006-04-25 Thread Bob Gailer
Andre Roberge wrote: > On 4/25/06, Hugo González Monteverde <[EMAIL PROTECTED]> wrote: > >> Remember duck typing. An object just needs to look like a file in order >> to be used like one. >> >> Guido's time machine has already forseen your problem. Take a look at >> the StringIO module. It allo

Re: [Tutor] Pyton and Webpages

2006-05-01 Thread Bob Gailer
Jon Whitehouse wrote: > Greetings All, > > I'm a newbie to python and am curious if I can do the following in python. I'm > not asking HOW to do this, just if it is possible before I spend the time to > learn python and do it myself. > > I want to write a program to go to a webpage, pull the data,

Re: [Tutor] Summing part of a list

2006-05-09 Thread Bob Gailer
Matthew Webber wrote: > I have a list that looks a bit like this - > > [(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299), > (u'fin', 6), (u'ven', 6), (u'chi', 3), (u'hun', 3), (u'mar', 3), > (u'lux', 2), (u'smo', 2), (u'tch', 2), (u'aho', 1), (u'ber', 1)] > > The list items are tuples

Re: [Tutor] Crossword program

2006-05-10 Thread Bob Gailer
[EMAIL PROTECTED] wrote: > ok checking out crossword program how do i run this program Sorry but that is not enough information for us to act on. What "crossword program"? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tu

Re: [Tutor] Database topic now fixed

2006-05-13 Thread Bob Gailer
Alan Gauld wrote: > The mistakes in my databae topic have now been rectified. > I have no idea how I managed to post the file without testing > that section of code. And unfortunately it's one of the areas > where SqlLite SQL syntax varies from the Oracle syntax that > I'm most familiar with. Bu

Re: [Tutor] Bit-level field extraction

2006-05-17 Thread Bob Gailer
emory to one of its IBM Mainframes runnuig VM, at a cost over $100,000! At least that reduced the spooling of virtual memory to the card punch/reader. ;-) -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mail

Re: [Tutor] unpacking PyTime

2006-05-17 Thread Bob Gailer
,%m,%d") to get yy,mm,dd. Or you can, as the ActivePython docs suggest, use int(curr_date) to get an integer value which you can then float. -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] New programmer, need some help getting started on my first project

2006-05-18 Thread Bob Gailer
Because there are several things that will lead to "compile errors" and "execution errors". I hope you run it and think about the errors, then if stumped ask us. -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] New programmer, need some help getting started on my first project

2006-05-18 Thread Bob Gailer
Chris Delgado wrote: > Bob et al, > > Ok guys, program is all fixed up and runs well. HEre is the final > code. Thanks for the help and its on to the next prog. Thanks for the > patience and help! > > Chris > > # A program that simulates flipping a coin 100 times an

Re: [Tutor] New programmer, need some help getting started on my first project

2006-05-19 Thread Bob Gailer
hon. The hardest part was wading thru Oracle tech support, and dealing with error messages such as "invalid type or number of parameters" in a call that involved many parameters. :'( -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] problem with class - get message that self is not defined

2006-05-23 Thread Bob Gailer
or any other variable. When defining a method in a class one writes def abc(self, a,b,c) OR def abc(this, a,b,c). Then one refers to "self" or "this" within the method to refer to the instance calling the method. -- Bob Gailer 510-978-4454 Broadband Phone Service for local

Re: [Tutor] partial string matching in list comprehension?

2006-05-25 Thread Bob Gailer
like. Just say the magic word PLUGH! Be sure to pick up the batteries while you're in there. How about re? import re Build the search pattern: pattern = "|".join(junkList) Compile it: junkListPattern = re.compile(pattern) def removeJunk(reply, junkListPattern): return

Re: [Tutor] a question about symbol

2006-05-28 Thread Bob Gailer
5)) On my computer I get the desired result. I paste it here 80°F = 27°C and I see degree symbols. What operating system / terminal hardware are you using? -- Bob Gailer 510-978-4454 Broadband Phone Service for local and long distance $19.95/mo plus 1 mo Free

Re: [Tutor] Enumeration and constant

2006-05-28 Thread Bob Gailer
ation class. -- Bob Gailer 510-978-4454 Broadband Phone Service for local and long distance $19.95/mo plus 1 mo Free ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Enumeration and constant

2006-05-29 Thread Bob Gailer
ogrammers to use upper case names to represent constants, e.g. RED = 3. -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Not Really Questions

2006-06-04 Thread Bob Gailer
nstances of the same thing it is a lot easier for me to track the individual data values in class instances rather than in some sequence or mapping (the alternative if one does not use classes). Welcome to the adventure. You are standing -- Bob Gailer 510-978-4454 Broadband P

Re: [Tutor] What is a widget?

2006-06-08 Thread Bob Gailer
Christopher Spears wrote: I'm a bit embarassed to ask this...I am looking at a tutorial for PyGTK+ that is discussing widgets. What are widgets? http://en.wikipedia.org/wiki/Widget_(computing) -- Bob Gailer 510-978-4454 Broadband Phone Service for local and long distance $19.

Re: [Tutor] pyexcelerator

2006-06-09 Thread Bob Gailer
r used hex a lot. I just looked at my copy of PyExcelerator. It seems to be in poor shape. I tried running some of the modules that have if __name__ == '__main__': (i.e. self-testing) and they failed with errors! And I find no visible documentation or working examples. Sigh. The only

Re: [Tutor] pyexcelerator CORRECTION

2006-06-09 Thread Bob Gailer
Bob Gailer wrote: Paul D. Kraus wrote: Are their docs anywhere for pyexcelerator? the built in docs are a bit lacking. For instance I can't figure out how to set a column width. I am just reading the examples and they kind of help but I don't follow this ... ws.co

Re: [Tutor] numpy speed problems

2006-06-09 Thread Bob Gailer
ange(b): > for kk in range(d): > fileHandle.write('%f %f %f %f\n' % (x_r[ii], y_r[jj], z_r[kk], > p_field[ii][jj][kk])) > fileHandle.close() > > > > """ > contour of surface velocity > """ > > fileHandle = file('mode shape.dat', "w") > fileHandle.write('TITLE = "HW 4"\n') > fileHandle.write('VARIABLES = "x"\n"y"\n"velocity"\n') > fileHandle.write('ZONE T="%s"\n' % 'velocity field') > fileHandle.write('I=%d, J=1, ZONETYPE=Ordered\n' % (num_y*num_x)) > fileHandle.write('DATAPACKING=POINT DT=(DOUBLE DOUBLE DOUBLE)\n') > for ii in range(num_x): > for jj in range(num_y): > fileHandle.write('%f %f %f\n' % (x_coord[ii], y_coord[jj], > V_mn[ii][jj])) > fileHandle.close() > > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] An Introduction and a question (continuing)

2006-06-09 Thread Bob Gailer
m.seed(time) sets the seed to the same value each time. (You are passing a module object, whose ID becomes the seed). Try random.seed(time.time()). Also you can set the seed once, then let each call to uniform get the next "random" number. Also consider:

Re: [Tutor] [tutor] debug process

2006-06-13 Thread Bob Gailer
development tools that include debuggers. http://www.digitalpeers.com/pythondebugger/ http://pydev.sourceforge.net/ http://www.die-offenbachs.de/detlev/eric3.html If you are running under Windows there is also http://sourceforge.net/projects/pywin32/. -- Bob Gailer 510-978-4454

Re: [Tutor] Writing over a line in a text file

2006-06-21 Thread Bob Gailer
e welcome. > > Cheers > Kieran > > > -- > "Behind every great man, there is a great woman. Behind that woman is > Mr.T." > > > ___

Re: [Tutor] How to make the loop work?

2006-06-22 Thread Bob Gailer
print out of this loop. > But this will not work. Where is the error? > "Will not work" does not (in general) give us enough to go on. Please in the future tell us what the evidence of the problem is - e.g. unexpected output, exception, ... If it is an exception please i

Re: [Tutor] How to make the loop work?

2006-06-22 Thread Bob Gailer
Ivan Low wrote: > Bob Gailer wrote: > >> Ivan Low wrote: >> >>> Hi, I'm new to python trying to figure how to make this work. >>> >>> c=0;d=raw_input("input number limit: ") >>> >>> while 1: >>> c =

Re: [Tutor] Needing help with my account tracker program.

2006-06-23 Thread Bob Gailer
oice == 4: > lookup() > elif menu_choice == 5: > deposit() > elif menu_choice == 6: > withdraw() > elif menu_choice == 9: > break > else: > print "That's not an option. Please choose a valid option." > save_file(accountlist) > print "Have a nice day!" > Here is the error I'm having troubles solving: > Traceback (most recent call last): > File "C:\Python24\Account Tracker.py", line 87, in -toplevel- > add() > File "C:\Python24\Account Tracker.py", line 36, in add > accountlist[account] = amount > TypeError: list indices must be integers > > So. how do I solve it to make it work the way I want it to? > > Thanks, > Nathan Pinno > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] search engine

2006-06-24 Thread Bob Gailer
o look for the keywords of interest in the page text and store them with references to the links to the pages containing them. Python dictionaries are the way to collect this data and the shelve module provides a way to save Python objects such as dictionaries for later retrieval. Hope this helps g

Re: [Tutor] search engine

2006-06-24 Thread Bob Gailer
ition of search engine was too narrow. I did a Google search on python search engine and came up with interesting links. I recommend you do this search too. -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] beginner: using optional agument in __init__ breaks my code

2006-06-25 Thread Bob Gailer
hod do here? > When the function definition is processed, Python creates an empty list, which will be used as the default value for q whenever the function is called with no 2nd parameter. Any changes to that list are visible in any call to the function that has no 2nd parameter. To get th

Re: [Tutor] Why doesn't it save the data before exiting?

2006-06-26 Thread Bob Gailer
u_choice = int(raw_input("Which item? ")) > if menu_choice == 1: > add() > elif menu_choice == 2: > remove() > elif menu_choice == 3: > printall() > elif menu_choice == 4: > lookup() > elif menu_choice == 5: > deposit() > elif menu_choice == 6: > withdraw() > elif menu_choice == 9: > break > else: > print "That's not an option. Please choose a valid option." > save_file(accountlist) > print "Have a nice day!" > > Thanks for the help so far! > Nathan Pinno > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Why doesn't it save the data before exiting? CORRECTION

2006-06-26 Thread Bob Gailer
Bob Gailer wrote: > Nathan Pinno wrote: > >> Hey all, >> >> I am needing help on this. Why isn't it saving the data beore exiting >> the program? >> > But it does save it. What evidence do you have that it is not? > > Please in the futur

Re: [Tutor] Why doesn't it save the data before exiting? CORRECTION

2006-06-26 Thread Bob Gailer
countlist is still {}. Can you figure out why? Hint: load_file(accountlist) does not change accountlist. > > Nathan Pinno > - Original Message - From: "Bob Gailer" <[EMAIL PROTECTED]> > To: "Bob Gailer" <[EMAIL PROTECTED]> > Cc: "Nat

Re: [Tutor] Why doesn't it save the data before exiting? CORRECTION

2006-06-26 Thread Bob Gailer
' if os.path.exists(filename): store = open(filename, 'r') ac = pickle.load(store) store.close() else: ac = {} return ac And change load_file(accountlist) to: accountlist = load_file() [snip] -- Bob Gailer 510-978-4454 __

Re: [Tutor] Variables don't change when altered within a loop?

2006-06-29 Thread Bob Gailer
gt; > What is going on? Why aren't the values of my variables changing when > I change them inside a loop like this? > The program is not changing a or b or c in the loop. The for statement assigns a to i. The next statement assigns a new value to i. a is not affected. Change print i

Re: [Tutor] Variables don't change when altered within a loop?

2006-06-29 Thread Bob Gailer
my variables changing when > I change them inside a loop like this? > > -- Evan > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help IDLE Compile Problem

2006-07-11 Thread Bob Gailer
s used by the first file". I will assume you are importing it. Import runs the imported module once. Subsequent executions of import do NOT rerun the module. Therefore any changes you make to it are not showing up. To work around this "problem", after importing, use the reloa

Re: [Tutor] no loops

2006-07-11 Thread Bob Gailer
> Now the exercise is: > As an exercise, rewrite this function so that it > doesn't contain any loops. > > I have been staring at this function and drawing a > blank. Something tells me that I need to use > iteration, but I am not sure how I could implement it. > take a look at the divmod built-in function. > -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python on AIX

2006-07-12 Thread Bob Gailer
> The second which is off topic is human nature and really is off topic. > If you are interested in this, email me directly. Thanks! Please include me on this discussion if you have it. I'm very interested in this aspect, and may have something to contribute. -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] email anonymizing

2006-07-12 Thread Bob Gailer
anil maran wrote: > i m trying to do email anonymizing like cl in a webapp can you suggest > how to do it I can't, but then I don't understand the terms you're using. And how does this relate to Python? -- Bob Gailer 510-978-4454 _

Re: [Tutor] email anonymizing

2006-07-13 Thread Bob Gailer
tly and retrieve mappings of real to anonymous addresses? 7) anything else you can tell us so we can give specific help. > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Bob Gailer 51

Re: [Tutor] python challenge 2

2006-07-18 Thread Bob Gailer
print dict[c], Also since dict and list are built-in functions it is not a good idea to reassign these names. -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Win32Com.client help

2006-07-18 Thread Bob Gailer
ments is strictly prohibited. The company > accepts no liability for any damage caused by any virus transmitted by > this email. Furthermore, the company does not warrant a proper and > complete transmission of this information, nor does it accept > liability for a

Re: [Tutor] dictionary manipulation

2006-07-26 Thread Bob Gailer
ext + "\n") > output.flush() > output.write ("\n") > > I need to remove the extra characters so the file and email output > isn't difficult to read. I also need to be able to use the dictionary > data so that I can compose the message used by the smtplib. > > > Any suggestions? I for one have no suggestions to offer because I don't know what you want. "suggestions on how to work with a dictionary" is not adequate. Where are you stuck? Do you want critique of the code you posted, or how use smtplib or what? -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Community documentation framework?

2006-08-06 Thread Bob Nienhuis
Have you had the experience of finding a nifty bit of code on the web, trying it out, and then discovering that technique only worked in version X.YY, or requires module Z that is no longer available? Well perhaps we can address this situation. I would like to see an online system that facilitat

Re: [Tutor] true and false

2006-08-07 Thread Bob Gailer
onaries, sets and frozensets). All other values are interpreted as true." The 2 flow control statements that use expressions in this way are if and while. Boolean operations are or, and, not. So in "if [1]: print 1" [1] will be interpreted as True. However in "[1] ==

Re: [Tutor] How to teach Python

2006-08-12 Thread Bob Gailer
I would like something that is easy, > standard, and multi-platform. I am considering Tkinter and Jython. Any > opnions on this? > Jython is not a GUI. > Thanks for any answers you might have. > Thanks for asking. And good luck with the class. And just for grins see http://www.fortran.com/come_from.html for FORTRAN's COME FROM statement. -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] suggestions for read unread items datastructure

2006-08-13 Thread Bob Gailer
it will be very sparse Just a guess but I think the lack of response is due to (at least for me) not knowing enough about your situation to give a useful response. Please tell us more. -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@pyt

Re: [Tutor] Global variables

2006-08-14 Thread Bob Gailer
A while back you attached factor34.py. Is that the program you are having trouble with? And you said it misbehaves "consistently with certain numbers to be factored." What are these numbers? -- Bob Gailer 510-978-4454 ___ Tutor maillist

Re: [Tutor] more rps

2006-08-15 Thread Bob Gailer
h], media[c], outcome[winner[h][c]]) for h in range(3) for c in range(3)]: print '%10s%10s%10s' % r else: c = random.randint(0,2) print '%10s%10s%10s' % (media[h], media[c], outcome[winner[h][c]]) -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

<    2   3   4   5   6   7   8   9   10   11   >