Re: [Tutor] Accuracy of time.sleep()

2004-12-04 Thread Bob Gailer
u get something other than a command not found kind of error then we can do something. Let us know. Bob Gailer [EMAIL PROTECTED] 303 442 2625 home 720 938 2625 cell ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Simple RPN calculator

2004-12-05 Thread Bob Gailer
list's append() and pop() methods). For grins I just wrote one that takes '1 2.3 - 3 4 5 + * /' as input and prints -0.0481481 8 lines of Python. That indeed is less than 100. Took about 7 minutes to code and test. Bob Gailer [EMAIL PROTEC

[Tutor] Re: Can I see it?

2004-12-05 Thread Bob Gailer
s a module named operators Bob Gailer [EMAIL PROTECTED] 303 442 2625 home 720 938 2625 cell ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: Can I see it?

2004-12-06 Thread Bob Gailer
f): print 'Retrieves value of the X register from before the last' print 'operation and pushes it in the X register, lifting the' print 'stack.' def help_multiply(self): print 'Multiply X by Y register. Use "*&

Re: [Tutor] Printing two elements in a list

2004-12-07 Thread Bob Gailer
ele1 in x: for ele2 in seq: if match: print ele2 match = False if ele1 in ele2: print ele2 match = True OR for ele1 in x: for index, ele2 in enumerate(seq): if ele1 in ele2: print ele2, seq[index+1] [snip] B

Re: [Tutor] "TypeError: 'int' object is not callable"??

2004-12-08 Thread Bob Gailer
s: DO function WITH parameters (FoxPro, similar in COBOL) function parameter or parameter1 function parameter2 (APL) Bob Gailer [EMAIL PROTECTED] 303 442 2625 home 720 938 2625 cell ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/li

Re: [Tutor] "TypeError: 'int' object is not callable"??

2004-12-08 Thread Bob Gailer
At 12:39 PM 12/8/2004, Bob Gailer wrote: At 11:27 AM 12/8/2004, Dick Moores wrote: My thanks to both Max and Kent. So Python tries, and fails, to see 2() as a function! I also got some help from <http://www.pcwebopedia.com/TERM/c/call.html> Note that SOME languages use () for call. The

Re: [Tutor] Please help matching elements from two lists and printing them

2004-12-08 Thread Bob Gailer
nts of a spot_int element to match a spot_cor element. Then (for the subset of data you've provided): >>> for ele1 in spot_cor: ... for ele2 in spot_int: ... if ele1 == ele2[:2]: ... print "%8s %8s %8s" % ele2 ... 10

Re: [Tutor] Simple RPN calculator

2004-12-08 Thread Bob Gailer
At 06:05 AM 12/6/2004, you wrote: Bob Gailer wrote: > For grins I just wrote one that takes '1 2.3 - 3 4 5 + * /' as input > and prints -0.0481481 8 lines of Python. That indeed is less than > 100. Took about 7 minutes to code and test. I'm quite interested in seeing

Re: [Tutor] Difference between for i in range(len(object)) and for i in object

2004-12-09 Thread Bob Gailer
you don't seem to benefit from some of our suggestions. Bob Gailer [EMAIL PROTECTED] 303 442 2625 home 720 938 2625 cell ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Difference between for i in range(len(object)) andfor i in object

2004-12-12 Thread Bob Gailer
don't they just read the book?" That's how I learned almost everything I know about programming. So it can be hard for me to understand your struggle. Nuf said for now... [snip] Bob Gailer [EMAIL PROTECTED] 303 442 2625 home 720 938 2625 cell _

Re: [Tutor] Leading zero for hex numbers

2004-12-15 Thread Bob Gailer
hich it should instead of 0x03039 and print "0x%05X" % 12345 displays 0x03039 The Python docs state The conversion will be zero padded for numeric values, when a 0 is used as a flag between the % and the conversion type. If you continue in the documentation right after 3 Conversion flags comes

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

2004-12-15 Thread Bob Gailer
e, and then writing if e == True: instead of if e: For some reason, that's extremely common in code written by newcomers to Pascal. Not to mention coding examples provided by Microsoft in some help topics! [snip] Bob Gailer [EMAIL PROTECTED] 303 442 2625 home 720 938 2625 cell _

Re: [Tutor] Question on "import foobar" vs "from foobar import *"

2010-01-09 Thread bob gailer
t a new reference to the original attribute. Example >>> import sys >>> from sys import modules >>> sys.modules is modules True >>> m = dict(sys.modules) # create a copy >>> m is modules False -- Bob Gailer Chapel Hill NC 919-636-4239

Re: [Tutor] help with random.randint

2010-02-02 Thread bob gailer
terseness: terms = [random.randint(1, 99) for i in 'ab'] -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] help with random.randint (cont. -- now: pseudo code)

2010-02-02 Thread bob gailer
swers. Good idea? Yes indeed. That is what I did before reading your comment! Great minds think alike. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] rstrip in list?

2010-02-09 Thread bob gailer
f the '\n' but kept getting an error of : AttributeError: 'list' object has no attribute 'rstrip' rstrip is a string method, not a list method. You must apply it to each element in the list. One way is: print [item.rstrip() for iten in mylist] -- Bob Gailer 919-6

Re: [Tutor] Defining operators for custom types

2010-02-12 Thread bob gailer
supported operand type(s) for *: 'int' and 'vector' I'm using python 3.1. Thanks. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscri

Re: [Tutor] Input() is not working as expected in Python 3.1

2010-02-15 Thread bob gailer
imes should it be printed?") print snumber A good robust alternative is to try int() and capture / report the failure: text = str(input("Type in some text: ")) snumber = input("How many times should it be printed?") try: number = int(snumber) except ValueError:

Re: [Tutor] Python 3.0

2010-02-20 Thread bob gailer
s a special function key, this will return '\000' or '\xe0'; the next call will return the keycode. The Control-C keypress cannot be read with this function." IOW - getch always returns 1 character. You are testing for a 0 length string. Will never happen. What keystrok

Re: [Tutor] List append method: St Petersburg Game

2010-02-20 Thread bob gailer
run only and produces the output I expect. Then your expectation is misguided, given my comments regarding multiple calls to flipCoin! You don't actually know how many tosses were made! [snip] -- Bob Gailer 919-636-4239 Chapel Hill NC __

Re: [Tutor] Understanding (Complex) Modules

2010-03-05 Thread bob gailer
foo' in sys.modules: foo = sys.modules['foo'] else: compile foo.py if successful: execute the compiled code thus creating a module object if successful: sys.modules['foo'] = the new module object foo = sys.modules['foo'

Re: [Tutor] difflib context to string-object?

2010-03-19 Thread bob gailer
of writing them to files? Take a look at the stringIO module. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Press Enter to quit. Silently maybe.

2010-03-23 Thread bob gailer
x27;m executing from IDLE. Is there a way to just return to the >>> prompt there? def finish(): print; print "Bye" print raw_input('Press Enter to quit') sys.exit() -- Bob Gailer 919-636-4239 Chapel Hill NC __

Re: [Tutor] a bug I cannot solve myself ;-)

2010-03-25 Thread bob gailer
n data = scope Then you reassign data = data.getAttr(key) OR data = data.getItem(key) data no longer refers to scope! Hence the error. How can it branch to the "getItem" side of the choice? Denis ________ vit esse est

Re: [Tutor] help with loops

2010-03-25 Thread bob gailer
y other way I can make it fast. In file 1, how a dictionary can be made. I mean unique keys that are common to file 1 and 2. thanks Kumar. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.

Re: [Tutor] inter-module global variable

2010-03-28 Thread bob gailer
lly, they *are* code nodes). 'w' is a kind of global scope -- say the state of the running program. Indeed, most code objects need to read/write in w. Any comments on this model welcome. I have few knowledge on implementation of languages. ________ vit esse estrany ☣

Re: [Tutor] help

2010-03-30 Thread bob gailer
ppens -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] help

2010-03-31 Thread bob gailer
** IDLE 2.6.3 >>> import sys >>> for i in sys.path: print i C:\Python26\Lib\idlelib C:\Windows\system32\python26.zip C:\Python26\DLLs C:\Python26\lib C:\Python26\lib\plat-win C:\Python26\lib\lib-tk C:\Python26 C:\Python

Re: [Tutor] what's wrong in my command?

2010-03-31 Thread bob gailer
Traceback (most recent call last): File "geek_translator3.py", line 4, in import pickle File "/usr/local/lib/python2.5/pickle.py", line 13, in AttributeError: 'module' object has no attribute 'dump' I suspect that file is not the one packaged with Python. Try renaming it and rerun the program. I don't understand, I don't write anything about pickle.py, why it mentioned? what's wrong with "import pickle"? I read many examples online whose has "import pickle", they all run very well. Thank you! -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Matching zipcode in address file

2010-04-04 Thread bob gailer
matches records that do NOT match zipcodes. How do I get this running so that it matches zips? Thanks -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Matching zipcode in address file

2010-04-04 Thread bob gailer
ts. What is the exact program that you want me to run? #!/usr/bin/env python infile = open("filex") match_zips = open("zippys") [line for line in infile if line in match_zips] print line I did what you said and I get '345' output both times. Sorry - my mistake - try:

Re: [Tutor] Matching zipcode in address file

2010-04-05 Thread bob gailer
match_zips = zips.readlines() lines = [ line for line in infile if line[149:154] in match_zips ] outfile.write(''.join(lines)) #print line[149:154] print lines infile.close() outfile.close() main() -- Bob Gailer 919-636-4239 Chapel Hill NC ___

Re: [Tutor] Extracting lines in a file

2010-04-06 Thread bob gailer
ation" in line: lines_to_be_read.append(lineno + 25) if lineno in lines_to_be_read: # process this line lines_to_be_read.pop(0) -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change s

Re: [Tutor] ask-why I cannot run it, and I am so confused about the traceback

2010-04-07 Thread bob gailer
You have the solution. Good. I beg you to avoid colored text. I find it hard to read. Just use good old plain text. No fancy fonts, sizes, colors. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or

Re: [Tutor] Problems with creating XML-documents

2010-04-14 Thread bob gailer
arse it, it keeps giving errors. I am frustrated with the lack of clarity and completeness. Please respect our time as volunteers by giving complete explicit informaion. Show us the resultant file. Tell us what parsing tool you are using. Show us the exact errors. [snip] -- Bob Gailer 919-636-423

Re: [Tutor] Raw string

2010-04-18 Thread bob gailer
s raw string marker, as my problem must be solved differently? Can you help me? Kind regards, Neven -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List index usage: is there a more pythonesque way?

2010-04-18 Thread bob gailer
spaceDict = collections.defaultdict(0) adjustedSpaceDict = {} If you use enumerate then you can replace timetable[i] with key for i, key in enumerate(timetable): numDict[key] += 1 Something is wrong in the following if statement, as both paths execute the same code. if spaceDict['1st'+key] == 0: spaceDict['nth'+key] = i else: spaceDict['nth'+key] = i for form in forms: adjustedSpaceDict[form] = spaceDict['nth'+form] - \ spaceDict['1st'+form] return (numDict, adjustedSpaceDict) # End example This function works fine, but I think that using range(len(timetable)) is clumsy. On the other hand, I need the indexes to track the number of spaces between instances of each form. Without using another loop (so not using list.index), is there a way of getting the index of the list entries? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] set and sets.Set

2010-04-21 Thread bob gailer
s replaced this module. So either way is OK for now, but the sets module might go away in a newer version. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.

Re: [Tutor] sqrt?

2010-04-25 Thread bob gailer
howcome does math.sqrt not do square roots on a simple number like 4??? O but it does, as others have pointed out >>> math.sqrt(4) 2.0 I am now officiciously pissed. Help? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor mailli

Re: [Tutor] module import problems

2010-04-25 Thread bob gailer
import statement. And what is the purpose of the following line? from tables.report_db_engine import * -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] For loop breaking string methods

2010-04-26 Thread bob gailer
t;> # note the leading whitespace that has not been removed. But this does: >>> L = [i.strip() for i in L] >>> L ['foo', 'bar'] What other strange behaviour should I expect from for loops? None - loops do not have "strange" behaviors. Perhaps

Re: [Tutor] For loop breaking string methods

2010-04-27 Thread bob gailer
x < 0: a.remove(x) """ -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Question about Python being object oriented

2010-05-08 Thread bob gailer
neral, have been promoted as techniques to improve the maintainability and overall quality of imperative programs. Object-oriented programming extends this approach." -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@pyt

Re: [Tutor] Find Elements in List That Equal A Specific Value

2010-05-12 Thread bob gailer
This seems pretty simple if a 'which' statement exists e.g. (which values in list 1 == list3[k], and looping through k), but I can't find one. To write one seems to require a loop. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tuto

Re: [Tutor] Trying to get this to work - attached is the source code

2010-05-17 Thread bob gailer
| | | | / / | __| | _ / | |_| | | |/ /| |___ | | \ \ \_/ |___/ |_| |_| \_\ """ ) input("\n\nPress the enter key to exit.") ___ Tutor maillist - Tutor@python.org To unsubsc

Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread bob gailer
gnise that the problem is with "the" rather than "range(10)" To be more specific - Python is "happy" with "for i in the ". It is "expecting"either : or some operator. "range" is neither - so that is where the error pointer is. Ex

Re: [Tutor] loop raw input

2010-05-21 Thread bob gailer
be in the try block. I also suggest unique error messages. If the user does not enter a number tell him so. Also you need a way to break out of the loop once user enters a valid key. Consider using the isdigit function to test the input instead of an exception. -- Bob Gailer 919-636-4239

Re: [Tutor] loop raw input

2010-05-21 Thread bob gailer
Also note that the database function creates a local variable "database" but does nothing with it. When the function terminates that variable is lost. Did you intend to return it? Also it is not good practice to use the same name for a function and a variable. -- Bob Gailer 91

Re: [Tutor] parse text file

2010-06-01 Thread bob gailer
n(all_data)) finally: input_file.close() -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] parse text file

2010-06-02 Thread bob gailer
Colin Talbert GIS Specialist US Geological Survey - Fort Collins Science Center 2150 Centre Ave. Bldg. C Fort Collins, CO 80526 (970) 226-9425 talbe...@usgs.gov From: bob gailer To: Colin Talbert Cc: tutor@python.org Date: 06/01/2010 04:43 PM Subject:Re

Re: [Tutor] Misc question about scoping

2010-06-03 Thread bob gailer
f size == "thumbnail" isThumbnail = False ] and the scoping extending to one level above without resorting to the global keyword? I have no idea what you mean by that. Please provide context. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor ma

Re: [Tutor] JS for location detection

2010-06-06 Thread bob gailer
eached the Python Tutor list. This is not the appropriate place for a JavsScript question. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailma

Re: [Tutor] JS for location detection

2010-06-06 Thread bob gailer
tion; please PM me. There are no laws. By "inappropriate" I meant that 1 - you would be less likely to get an answer here. 2 - my preference is that only Python questions be asked, as it takes my time to decipher a question. I examined your code to see if it were Python related.

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-06 Thread bob gailer
On 6/6/2010 8:44 PM, Alex Hall wrote: -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com;http://www.facebook.com/mehgcap What is your question? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-06 Thread bob gailer
On 6/6/2010 9:37 PM, Alex Hall wrote: On 6/6/10, Lie Ryan wrote: On 06/07/10 11:08, Alex Hall wrote: On 6/6/10, bob gailer wrote: On 6/6/2010 8:44 PM, Alex Hall wrote: -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com;http

Re: [Tutor] a class query

2010-06-07 Thread bob gailer
you will get a syntax error! Feed: Yes Originally it was not legal. Then in some version it became legal. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] Better construct? (was no subject)

2010-06-12 Thread bob gailer
startswith("yes") will cover all your cases. You can collect functions in a sequence, then iterate over it. This allows for easy expansion (when you decide to add another function). funcs = (dosomething(), dosomethingelse()) for func in funcs: getid() func() -- Bob Gailer 919-6

Re: [Tutor] Better construct? (was no subject)

2010-06-12 Thread bob gailer
On 6/12/2010 3:59 PM, Alan Gauld wrote: "bob gailer" wrote You can collect functions in a sequence, then iterate over it. This allows for easy expansion (when you decide to add another function). funcs = (dosomething(), dosomethingelse()) I suspect Bob meant to leave off the

Re: [Tutor] large file

2010-06-13 Thread bob gailer
if not line: break print line + " RG:Z:2302" -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Structuring a class

2010-06-14 Thread bob gailer
the credit attributes, just like you did for Student. Then assign instances of Credit to entries in self.credit. If I don't set it to anything, ie, like it is, I get an error Stud instance has no attribute '__getitem__' If I try to leave it available for adding to somewha

Re: [Tutor] Trouble with sockets...

2010-06-18 Thread bob gailer
is processed. That in turn closes the client socket. Either keep the channel open or put the client connect in the loop. # Execution starts here: try: main() except KeyboardInterrupt: sys.exit("Aborting.") ___________ Tutor maillist - Tu

Re: [Tutor] pydoc?

2010-06-18 Thread bob gailer
tell us a lot more about what you are doing. Please also reply-all so a copy of your reply goes to the tutor list. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mai

Re: [Tutor] pydoc?

2010-06-18 Thread bob gailer
ess - that you are typing $ pydoc -g at the Python Interpreter prompt (>>>) The manual recommends typing it a the shell prompt. In which case the $ represents the prompt and you should just type pydoc -g. -- Bob Gailer 919-636-4239 Chapel Hill NC __

Re: [Tutor] Question

2010-06-19 Thread bob gailer
rewrote the entire course, starting them with a program that read 2 numbers, added them and printed the result. In those days students sat at terminals, edited program files, submitted them to the resident HP 3000 computer and shortly received printouts. -- Bob Gailer 919-636-4239 Chapel Hill NC

Re: [Tutor] Question

2010-06-20 Thread bob gailer
hon interpreter written in Java. It allows you to use Java classes in your Python code. You might want to learn Java to take advantage of that. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or chan

Re: [Tutor] finally

2010-06-23 Thread bob gailer
inue statement is executed in the try <#try> suite of a try <#try>...finally <#finally> statement, the finally <#finally> clause is also executed 'on the way out.' A continue statement is illegal in the finally <#finally> clause. (The reason is a prob

Re: [Tutor] unsubscribe

2010-06-24 Thread bob gailer
: http://mail.python.org/mailman/listinfo/tutor -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Suggestions for output on multiple platforms

2010-06-29 Thread bob gailer
ure I could output the analysis using that but am not sure it will be readable under Mac and Windows. Any ideas are welcome! Write the data to an html file and view it in a browser. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist -

Re: [Tutor] Help with choices for new database program

2010-07-02 Thread bob gailer
. But the differences are much more dramatic than the commonalities. I have developed in both. I find it painful to work in one while desiring a feature that exists only in the other. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist

Re: [Tutor] Help with choices for new database program

2010-07-03 Thread bob gailer
On 7/2/2010 9:44 PM, Jeff Johnson wrote: On 07/02/2010 08:19 PM, bob gailer wrote: On 7/2/2010 5:56 PM, Jeff Johnson wrote: [snip] Visual FoxPro ... is very similar to Access I differ. Access and FoxPro are very different. Yes they both use tables, relationships, indexes and SQL. Yes they

Re: [Tutor] Tutor Digest, Vol 77, Issue 25

2010-07-09 Thread bob gailer
We received 2 copies of the tutor digest from you. If you intentionally sent it - why? Please do not do that again. If you have a specific question or comment - change the subject to something more meaningful - delete everything from the digest that is not related to your question. -- Bob

Re: [Tutor] Help

2010-07-13 Thread bob gailer
You have gotten good advice from others. My request is that you provide a meaningful subject when you post a question. We track by subject. "Help" is not the best subject. Better would be "How to find prime numbers" -- Bob Gailer 919-636

Re: [Tutor] Help

2010-07-13 Thread bob gailer
(0,7,3): isPrime(i-1) isPrime(i+1) -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Searching a text file's contents and comparing them toalist

2010-07-14 Thread bob gailer
aisleNo < MAX_AISLE - 1: print "Located on aisle %s" % aisleNo + 1 else: print "Not in store" print "\n".join(items) -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-17 Thread bob gailer
f = open("c:\test.txt", "w") f.write("1234") f.write("5678") print open("c:\test.txt").read() When you say "line" I assume you mean text followed by whatever the OS defines as end-of-line or end-of-record. To write such a line in Python

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-17 Thread bob gailer
a platform-specific representation on writing and back on reading. Thus, when opening a binary file, you should append 'b' to the /mode/ value to open the file in binary mode, which will improve portability. (Appending 'b' is useful even on systems that don't treat

Re: [Tutor] Return error message for my script in Blender

2010-07-17 Thread bob gailer
nts with wings'), ('Eye size:' , EYESIZE, 0.1,10, 'Size of the eyes'), ('Tail taper:' , TAILTAPER, 0.1,10, 'Taper fraction of each tail segment'),]): return Anybody know why I keep getting this error? The return statement is not in a function. Wha

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-18 Thread bob gailer
1.25 seconds Therefore 1 billion in ~21 minutes. 3 ghz processor 2 g ram. Changing length up or down seems to increase time. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Contents of Tutor digest, help with Hangman program

2010-07-19 Thread bob gailer
user for a password without echoing. The user is prompted using the string /prompt/, which defaults to 'Password: '. HTH -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscr

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-19 Thread bob gailer
On 7/19/2010 10:48 AM, Richard D. Moores wrote: I've been unable to find any mention of that use of the asterisk in the 3.1 docs http://docs.python.org/py3k/library/stdtypes.html#old-string-formatting -- Bob Gailer 919-636-4239 Chapel Hi

Re: [Tutor] A file containing a string of 1 billion random digits.

2010-07-19 Thread bob gailer
[snip] I did not read the documentation with enough understanding. I withdraw the use of sample. Sigh! -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] how i can change two lists into one directory

2010-07-22 Thread bob gailer
t possible Indeed. There are several ways to do this. Easiest: dict(zip(a,b)) i mean i tried it using loops d = {} for i in range(len(a)): d[a[i] = b[i] and all but i cant append a directory Of course you can't append, since a dictionary is not a sequence. But you can add a

Re: [Tutor] FTP from mainframe

2010-07-29 Thread bob gailer
will guess that you want: def writer(line): myfile.write(line + '\n') session.retrlines("RETR 'mainframe.filename'", writer) The documentation is in error in that it does not explicitly state that a line is passed to the callback function as an argument. I am

Re: [Tutor] Python and Abaqus

2010-07-30 Thread bob gailer
quot; are too vague. Post your script if not too large else use a pastebin and provide the link. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python - RPG Combat System

2010-07-31 Thread bob gailer
, passing 1 or 2 as the divisor for my_dmg and returning the updated values for my_ho and my_hp. def update(factor): print "The Lich King is at", mo_hp, "Hit Points" print "you did ", my_dmg / factor, "damage!" print print "I was attacked b

Re: [Tutor] Simple Python Program

2010-07-31 Thread bob gailer
se p1number == p2number: playerOne, playerTwo = winnerName def displayInfo(): #how do I display winner? main() ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread bob gailer
nd returns the traceback to the web browser. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread bob gailer
On 7/31/2010 6:40 PM, Eric Hamiter wrote: On Sat, Jul 31, 2010 at 4:48 PM, bob gailer <mailto:bgai...@gmail.com>> wrote: Please post that code, and the URL you use to invoke it. test.py: this works on my laptop but not on the server http://pastebin.com/ChjUzLRU test-working

Re: [Tutor] Simple Python Program

2010-07-31 Thread bob gailer
On 7/31/2010 8:24 PM, Steven D'Aprano wrote: On Sun, 1 Aug 2010 04:35:03 am bob gailer wrote: Continue to avoid writing functions. They are not necessary for such a simple program. That is *terrible* advice. Absolutely awful. Well I disagree. I was trying to steer the OP t

Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread bob gailer
On 7/31/2010 11:03 PM, Eric Hamiter wrote: On Sat, Jul 31, 2010 at 9:53 PM, bob gailer <mailto:bgai...@gmail.com>> wrote: Main difference I see is lack of any html tags in test.py! Try adding 1. print "" 2. print "Publix Aide&q

Re: [Tutor] web-based python?

2010-08-01 Thread bob gailer
following script - let's call it "test.py". Upload it then invoke it. Try http://url-to-your-site/test.py #!/usr/bin/python print "Content-type: text/html" print print "" print "Hello World from Python" print "" print "Standard Hel

Re: [Tutor] getattr()

2010-08-04 Thread bob gailer
bals()['__name__'], in various forms, to no avail. Replace those stars with main as derived above. globals()['output_text'] will also give you a reference to the function. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor ma

Re: [Tutor] getattr()

2010-08-04 Thread bob gailer
def output_text(self, data):return data def output_hex(self, data):return '\\x' + data def __getattr__(self, name): return self.output_text a = A() data='bar' print a.output_text(data) print a.output_hex(data) print a.foo(data) -- Bob Gailer 91

Re: [Tutor] getattr()

2010-08-04 Thread bob gailer
On 8/4/2010 4:04 PM, bob gailer wrote: On 8/4/2010 3:44 PM, Huy Ton That wrote: Oh, that's right, I should have tried to example in the interpreter instead of in my head:P Say Bob, Is that the preferred method over something like: I would prefer to create a class and make these func

Re: [Tutor] getattr()

2010-08-04 Thread bob gailer
7;, data) print a.call_by_name('output_hex', data) print a.call_by_name('foo', data) -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] getattr()

2010-08-05 Thread bob gailer
On 8/4/2010 4:32 PM, Huy Ton That wrote: I have a side question, I am using python 2.7. Why do you use class A: instead of class A(object): ? My example does not depend on old / new style classes. -- Bob Gailer 919-636-4239 Chapel Hill NC

Re: [Tutor] os.urandom()

2010-08-07 Thread bob gailer
On 8/7/2010 6:29 PM, Evert Rol wrote: [a for a in map(chr, os.urandom(6))] Overkill! map(chr, os.urandom(6)) is sufficient. Or [chr(x) for x in os.urandom(6))] The latter is easier to read. -- Bob Gailer 919-636-4239 Chapel Hill NC

Re: [Tutor] os.urandom()

2010-08-08 Thread bob gailer
een written so that it printed only hex, b'l\xbb\xae\xb7\x0ft' would have been b'\x6c\xbb\xae\xb7\x0f\x74' , right? Thanks very much for that, Alan. How were we supposed to know that all the hexes have 2 digits? In version 2.6.5 Language Reference 2.4.1 -

Re: [Tutor] Reading every 5th line

2010-08-08 Thread bob gailer
the other files go? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

  1   2   3   4   5   6   7   8   9   10   >