Re: [Tutor] basic class loading question

2011-11-22 Thread Dave Angel
On 11/22/2011 08:17 AM, Cranky Frankie wrote: I have a basic question about how to load a class. If I have this class: class QB: def __init__(self, first_name='', last_name='', phone='', email='', stadium=''): self.first_name = first_name self.last_name = last_name

Re: [Tutor] basic class loading question

2011-11-22 Thread Dave Angel
On 11/22/2011 09:20 AM, Cranky Frankie wrote: OK, but this is still not working: class Qb: def __init__(self, first_name='', last_name='', phone='', email='', stadium=''): self.first_name = first_name self.last_name = last_name self.phone = phone self.ema

Re: [Tutor] basic class loading question

2011-11-22 Thread Dave Angel
On 11/22/2011 12:09 PM, Cranky Frankie wrote: On Tue, Nov 22, 2011 at 11:26 AM, Dave Angel wrote: snip quarterbacks = [] for quarterbacks.append( ) Now that you really have a list, then you can print a particular one with: print (quarterbacks[2].last_name) Dave I'm

Re: [Tutor] Random order program

2011-11-27 Thread Dave Angel
On 11/27/2011 05:17 PM, myles broomes wrote: I requested help for this code earlier and I thought it had been corrected but apparently, there is still a problem with it... To start with, tell us what version of Python, and what operating system platform you're using. I'm assuming Python 3.x a

Re: [Tutor] Coin game

2011-11-27 Thread Dave Angel
On 11/27/2011 07:43 PM, Guess?!? wrote: Hello All, I am learning python and hence was writing code for school assignments I could find online. I wrote my solution for this problem below. Please find it attached. I would like someone to review and give me comments on it. Basically improvements/

Re: [Tutor] Critique and Question

2011-11-28 Thread Dave Angel
On 11/28/2011 04:28 AM, Mark Lybrand wrote: Okay, so I just started to learn Python. I have been working through Dive Into Python 3 and the Google stuff (great exercises IMHO, totally fun). However, with Dive, I had an issue with him referencing the files in the example directory, which from t

Re: [Tutor] Critique and Question

2011-11-28 Thread Dave Angel
the 'Wu' flag when writing. I might just be 'w'-ing. I will look when I get home. Thanks Mark Also a little bummed that subprocess module doesn't appear to work on windows. I probably (hopefully) won't need it, but it still bums me. On Nov 28, 2011 4:27 AM, "

Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-28 Thread Dave Angel
On 11/28/2011 12:47 PM, James Reynolds wrote: On Mon, Nov 28, 2011 at 12:32 PM, Mayo Adams wrote: I am trying to pass a set of tuple strings from a file to a function I That's an undefined term. Python doesn't have a type called 'tuple strings'. have defined. Each tuple is on a separate li

Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-28 Thread Dave Angel
1. Please post messages to the list, a private response is not appropriate unless it's just a thanks, or other private msg. Easiest way is probably to use Reply-All. 2. Don't top-post. Put your responses AFTER whatever you're quoting. It's a forum policy, for most usenet groups. On 11/28

Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-28 Thread Dave Angel
On 11/28/2011 11:25 PM, bob gailer wrote: On 11/28/2011 12:47 PM, James Reynolds wrote: On Mon, Nov 28, 2011 at 12:32 PM, Mayo Adams > wrote: I am trying to pass a set of tuple strings from a file to a function I have defined. Each tuple is on a separat

Re: [Tutor] useful function or reinventing the wheel??

2011-11-28 Thread Dave Angel
On 11/28/2011 11:30 PM, Mark Lybrand wrote: I am a habitual wheel re-inventor, so it would not surprise me, but I made this little function that I was kinda proud of (seeing that I have only been learning python like a week now): It just takes a directory and checks to see if all the directories

Re: [Tutor] useful function or reinventing the wheel??

2011-11-28 Thread Dave Angel
On 11/29/2011 12:19 AM, Mark Lybrand wrote: I couldn't follow your code, but finally concluded that it's trying to create a directory, creating the directories parents also if they don't exist either. It would be much simpler if written recursively, but there's no need. Check out os.maked

Re: [Tutor] How to handle try and except in this case

2011-11-29 Thread Dave Angel
On 11/29/2011 03:37 AM, Mic wrote: On 2011-11-27 17:58, Mic wrote: Say that I want to try and open 10 files. If none of these exists, I want an error message to appear. But only if NONE of these files exists. I know how to handle this with one file. But I don't know how to do that with mor

Re: [Tutor] How to handle try and except in this case

2011-11-29 Thread Dave Angel
(You top-posted again. Try to put your remarks AFTER the part you're quoting, so that the message is self-descriptive) On 11/29/2011 10:16 AM, Mic wrote: Could you explain what's unclear about it? Andreas couldn't get more specific, since you didn't say how these 10 names are provided. Yes,

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Dave Angel
(You put your response in the wrong place; it belongs after the part you're quoting.) he On 11/29/2011 10:19 AM, bod...@googlemail.com wrote: You won't get it exactly on because the time it takes to call the function will affect your trigger time. I would use something like an infinite loop w

Re: [Tutor] How to handle try and except in this case

2011-11-29 Thread Dave Angel
On 11/29/2011 10:35 AM, Mic wrote: -Ursprungligt meddelande- From: Dave Angel Sent: Tuesday, November 29, 2011 4:25 PM To: Mic Cc: tutor@python.org Subject: Re: [Tutor] How to handle try and except in this case (You top-posted again. Try to put your remarks AFTER the part you&#x

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Dave Angel
On 11/29/2011 10:52 AM, Mic wrote: -Ursprungligt meddelande- From: Dave Angel Sent: Tuesday, November 29, 2011 4:33 PM -Original Message- From: "Mic" Sender: tutor-bounces+bodsda=googlemail@python.org Date: Tue, 29 Nov 2011 15:54:59 To: Subject: [Tutor] Making

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Dave Angel
On 11/29/2011 11:09 AM, Dave Angel wrote: On 11/29/2011 10:52 AM, Mic wrote: Okay, I undestand. Hmm, what is a drift? I just noticed I hadn't answered that one. It doesn't matter any more since you're running tkinter. But for completeness: If you had a non-event driven

Re: [Tutor] How to write lines in a text file (GUI)

2011-11-29 Thread Dave Angel
On 11/29/2011 01:02 PM, Mic wrote: Hey again. I figured I would first post this piece of code and then ask my questions. How is this different from the question you posted 3 hours ago, with subject: "[Tutor] Creating a line in a text file every time a button ispressed." I'm working

Re: [Tutor] Creating a line in a text file every time a button is pressed.

2011-11-29 Thread Dave Angel
On 11/29/2011 10:09 AM, Mic wrote: Hey again. root=Tk() root.title("testV2") app=Mainwindow(root) root.mainloop() What's that code got to do with the question below? I am now writing another program. It turned out just fine, but I have one question. If button one is pressed I want t

Re: [Tutor] How to write lines in a text file (GUI)

2011-11-29 Thread Dave Angel
On 11/29/2011 02:24 PM, Mic wrote: Actually, I nearly know how do to solve this problem. I just have one problem. Can I use writeline() to write text into line 3 or line 5 for example? Say that I want to write the text "hi" into line five of a text file, can I do this using writeline(), i

Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-29 Thread Dave Angel
On 11/29/2011 04:40 PM, Mayo Adams wrote: Apologies for my numerous offenses to protocol, and gratitude for the suggestions all around.And yet... as to the notion of a tuple existing in some non-Platonic sense, I suspect I will have carry my confusion away in order to dispel it by further readi

Re: [Tutor] pass tuples to user defined function(beginner)

2011-11-29 Thread Dave Angel
On 11/29/2011 06:40 PM, emile wrote: Dave Angel wrote: > The whole Y2K problem was caused because too many programmers made unwarranted assumptions about their data (in that case about the range of valid dates). Well, yes. But we knew then that the stuff we were writing wouldn't

Re: [Tutor] Treating lists as lists

2011-11-29 Thread Dave Angel
On 11/29/2011 08:09 PM, Mark Lybrand wrote: I am pretty sure I saw this somewhere but now I can't. Here's the problem: list = ['hello', 'world'] template = '%s %s' print template % list But it appears that list is just one (list) when I want to treat it as two (items). I can do that right? Ho

Re: [Tutor] is there a better way to organise this code

2011-11-30 Thread Dave Angel
On 11/30/2011 07:49 PM, Steven D'Aprano wrote: Norman Khine wrote: hello, is there a better way to organise this code or optimise it. http://pastie.org/2944797 Is that a question? Because I get a syntax error in my brain when I parse it without the question mark. Sorry to pick on you, but

Re: [Tutor] Need help adding a funcation

2011-12-01 Thread Dave Angel
On 12/01/2011 10:33 AM, Michael Hall wrote: Here is the code I have written. # Create main function. def main(): a = input('Please Enter a Number: ') # Ask user for input. number = int(a) x = 1 sum_of = 0 while number> x: if number % x == 0: sum_of

Re: [Tutor] Need help adding a funcation

2011-12-01 Thread Dave Angel
(You forgot to post your response on the list, instead posting it privately to me. Please use Reply-All, or whatever the equivalent is on your email app) On 12/01/2011 11:49 AM, Michael Hall wrote: On Thu, Dec 1, 2011 at 7:51 AM, Dave Angel wrote: On 12/01/2011 10:33 AM, Michael Hall

Re: [Tutor] Need help adding a funcation

2011-12-01 Thread Dave Angel
(You top-posted, so I'm deleting all the out-of-order stuff. in these forums, you should put your response after whatever you quote.) On 12/01/2011 02:55 PM, Michael Hall wrote: The OP has been taught but is still having an issue and all I am doing is asking for help. Here is what I have so fa

Re: [Tutor] unexpected list entry

2011-12-02 Thread Dave Angel
On 12/02/2011 08:49 AM, surya k wrote: Hi, Just take a look at this small code.. I am just taking a string as input and assigning it as a list. But I am finding an unexpected entry in the list.. Why this is happening? I am using PyScripter IDE. code : #!/usr/bin/env python def main():

Re: [Tutor] unexpected list entry

2011-12-02 Thread Dave Angel
ate stuff when I used Windows. The following material is out of order, but I left it in anyway, for some context. I've used PyScripter many times before and worked on lists.. but I never faced any problem like this ------ From: "Dave Ange

Re: [Tutor] unexpected list entry

2011-12-02 Thread Dave Angel
On 12/02/2011 11:48 AM, surya k wrote: Dave, I am now puzzled.. I don't understand but the list is now not showing unicode. I just restarted the IDE and rewrote the code again! however, I tried print repr(name1), it didn't show me any unicode notation. Well, since the symptom went away,

Re: [Tutor] Splitting a Tuple in Python 2.7

2011-12-05 Thread Dave Angel
On 12/05/2011 09:31 PM, Greg Nielsen wrote: The following gets returned from a function that I am calling. (120, 400) While I can use the Tuple as is in my program, I would like the ability to change one or even both of the numbers depending on other events that happen. So here is my question,

Re: [Tutor] unable to run file though dir path included

2011-12-06 Thread Dave Angel
On 12/06/2011 01:57 PM, surya k wrote: I have included the path directory of the file but still I couldn't run it!. 1. I created a .pth file and wrote all required path list's and saved in "site-packages" of python dir.( python\Lib\Site-packages). 2. I also included python path ( c:\python27\) i

Re: [Tutor] beginner here

2011-12-07 Thread Dave Angel
On 12/07/2011 08:39 PM, Max S. wrote: You are using an 'elif' for your 'coin_rolls == 1:'. The 'elif' keyword means that if the last 'if' statement (and any 'elif's behind it) was *not* true, only then will it be executed. Your code could be written as 'if rolls is NOT less than or equal to 100

Re: [Tutor] Python and Tkinter (total newbie)

2011-12-09 Thread Dave Angel
On 12/09/2011 02:03 PM, Richard Lyons wrote: I have tried to enter the first sample program from p. 19 in Grayson: Python and Tkinter Programming. When I run the program I get an error as follows: Traceback (most recent call last): File "/home/dick/Desktop/calc1.py", line 50, in if _name_

Re: [Tutor] how to handle big numbers

2011-12-09 Thread Dave Angel
On 12/09/2011 02:25 PM, surya k wrote: Finding factorial of 8 or 9 isn't big. If I would like to find factorial of 32327, how can I ?? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscriptio

Re: [Tutor] how to handle big numbers

2011-12-09 Thread Dave Angel
On 12/09/2011 03:04 PM, surya k wrote: Date: Fri, 9 Dec 2011 14:53:07 -0500 From: d...@davea.name To: sur...@live.com CC: tutor@python.org Subject: Re: [Tutor] how to handle big numbers On 12/09/2011 02:25 PM, surya k wrote: Finding factorial of 8 or

Re: [Tutor] What style do you call Python programming?

2011-12-09 Thread Dave Angel
On 12/09/2011 08:58 PM, Cranky Frankie wrote: I appreciate all the comments in this thread so far, but what I'm really looking for is what to call the style of programming where you have no direct branching via line numbers, statement names, and gotos. I'm finding that lacking these things that I

Re: [Tutor] where I am going wrong?

2011-12-14 Thread Dave Angel
On 12/14/2011 09:29 AM, surya k wrote: From: waynejwer...@gmail.com Date: Wed, 14 Dec 2011 08:25:53 -0600 Subject: Re: [Tutor] where I am going wrong? To: sur...@live.com CC: tutor@python.org On Wed, Dec 14, 2011 at 8:13 AM, surya k mailto:sur...@live.com>> w

Re: [Tutor] while loops

2011-12-14 Thread Dave Angel
On 12/14/2011 05:41 PM, rog capp wrote: # Guess my number # # The computer picks a random number between 1 and 100 # The player tries to guess it and the computer lets # the player know if the guess is to high, to low # or right on the money import random print("\tWelcome to 'Guess My Number'!

Re: [Tutor] reset password program

2011-12-16 Thread Dave Angel
On 12/16/2011 05:02 PM, ADRIAN KELLY wrote: Hi guys, i created a program that allows users to login using a password that i set at the top of the program. Among other things users are given the option to change their password. My questions is; Is it possible for me to make this new password s

Re: [Tutor] Baccarat code check.

2011-12-17 Thread Dave Angel
On 12/16/2011 03:29 AM, col speed wrote: If anyone has the time, please have a look at the attached text file and let me know any comments on how to improve it. Thanks a lot Col I don't see any response for 24 hours, so I'd say that nobody has the time. However, you could have improved the odd

Re: [Tutor] PYTHONPATH (Mac OS X)

2011-12-19 Thread Dave Angel
On 12/19/2011 08:33 PM, Stayvoid wrote: Please clarify, or expand, or tell us what problem you are having or trying to solve. Hi! I want to have a possibility to import modules from the folder, which is not included in the load path. Example: module.py - def testfunc(name): file =

Re: [Tutor] A few Python Mysteries

2011-12-19 Thread Dave Angel
On 12/19/2011 08:47 PM, Wayne Watson wrote: The PATH variable for me (user) has c:\Users\Wayne\g95\bin By top-posting, you've ruined the whole continuity of what you quoted. Anyway, with a PATH like that, you won't be able to type Python at a command prompt. It works much better if it's on

Re: [Tutor] Python challenge and decryption

2011-12-21 Thread Dave Angel
On 12/21/2011 06:39 AM, Joaquim Santos wrote: Hi List! Thanks for all the input you guys gave me! I'm trying to implement your ideas on the function and I've been getting some parts right (the correct translation, still vertical and without spaces) or the wrong translation but with spaces... My

Re: [Tutor] list mail formatting

2011-12-21 Thread Dave Angel
On 12/21/2011 06:49 AM, Jamie Paul Griffin wrote: Can I just ask why the majority of the mail on this list is in multipart/alternative and/or html format. It's driving me nuts trying to read this on my console. Is there not a requirement to use plain text as with most other technical mailing l

Re: [Tutor] list mail formatting

2011-12-21 Thread Dave Angel
On 12/21/2011 08:29 AM, Jamie Paul Griffin wrote: On Wed, Dec 21, 2011 at 07:57:33AM -0500, Dave Angel wrote: On 12/21/2011 06:49 AM, Jamie Paul Griffin wrote: Can I just ask why the majority of the mail on this list is in multipart/alternative and/or html format. It's driving me nuts t

Re: [Tutor] A few Python Mysteries

2011-12-21 Thread Dave Angel
On 12/21/2011 07:10 PM, Alan Gauld wrote: One thing that may be significant... Are you installing your Windows Python versions from python.org or from ActiveState? They are very similar but not identical. And one difference is that ActiveState sets up both the PATH and the registry to make it

Re: [Tutor] Television simulation

2011-12-23 Thread Dave Angel
On 12/23/2011 04:21 PM, myles broomes wrote: Im trying to create a 'Television simulation' program. Heres the code ive written for it: #television simulation #a program that simulates a television #the user can turn the television on or off, change the volume or change the channel #create the

Re: [Tutor] Television simulation

2011-12-23 Thread Dave Angel
On 12/23/2011 04:43 PM, Dave Angel wrote: On 12/23/2011 04:21 PM, myles broomes wrote: Im trying to create a 'Television simulation' program. Heres the code ive written for it: #television simulation #a program that simulates a television #the user can turn the television on or o

Re: [Tutor] PYTHONPATH (Mac OS X)

2011-12-26 Thread Dave Angel
On 12/26/2011 07:23 AM, Stayvoid wrote: Simply that python is saying it cannot find the file. So it is probably in a different folder to the one in which the program is running. You need to provide a valid path to the file, Those files are in the same folder: /Users/Username/Python_modules/ I

Re: [Tutor] while loop ends prematurly

2012-01-01 Thread Dave Angel
On 01/01/2012 09:48 PM, brian arb wrote: Hello, Can some please explain this to me? My while loop should continue while "owed" is greater than or equal to "d" first time the function is called the loop exits as expected False: 0.00>= 0.01 the next time it does not False: 0.01>= 0.010

Re: [Tutor] while loop ends prematurly

2012-01-02 Thread Dave Angel
(You accidentally forgot to include the list when you replied. The easiest way (for most people) to avoid that is to use Reply-all) On 01/02/2012 01:00 AM, Sarma Tangirala wrote: On 2 Jan 2012 08:56, "Dave Angel" wrote: Easiest answer is to use integers. Scale everything up by a

Re: [Tutor] Random number selection

2012-01-02 Thread Dave Angel
On 01/02/2012 08:52 PM, shane wrote: I was wondering is there a way to have a variable generate a random integer each time the variable is called. Ive tried random.randint(a, b) and the range one to. It selects a random number and assigns it to the variable this part of the program would be mat

Re: [Tutor] Making a Computer Guess My Number

2012-01-06 Thread Dave Angel
On 01/06/2012 03:05 PM, Garland W. Binns wrote: Hello, I have been experimenting with trying to rewrite the following script so that a computer tries to guess a number I'm thinking of: https://gist.github.com/1572067 I was thinking that basically I need to create a while loop, and somehow redefi

Re: [Tutor] Python problem

2012-01-10 Thread Dave Angel
On 01/10/2012 05:04 AM, Bojan Antonijevic wrote: Hello, I send you a mail at 29.12.2011. about problem with my IDLE (Python GUI) and I didnt recive any ansfer; Instead, I am receiving correspondence between other members of forum; Honestly, I don't want to receive all this conversation's. Thank

Re: [Tutor] generating unique set of dicts from a list of dicts

2012-01-10 Thread Dave Angel
On 01/10/2012 03:24 PM, bruce wrote: Since dict_hash returns a string, which is immutable, you can now use a dictionary to find the unique elements: uniques_map = {} for d in list_of_dicts: uniques[dict_hash(d)] = d unique_dicts = uniques_map.values() *** not sure what the "uniqes" is, o

Re: [Tutor] Defining a File path

2012-01-10 Thread Dave Angel
On 01/10/2012 04:53 PM, Hugo Arts wrote: On Tue, Jan 10, 2012 at 8:31 PM, Adrian wrote: Hi guys, I know that if i dont include any path information, python looks in the current directory for the file. My question is how do i specify a file path to open a file saved on my desktop for example.

Re: [Tutor] append index out of range

2012-01-12 Thread Dave Angel
On 01/12/2012 09:38 AM, lina wrote: Hi, there is a file $ cat atom-pair_9.out | wc -l 75426 there is 75426 lines there, results=[] unique={} for line in open(tobetranslatedfile,"r"): tobetranslatedparts=line.strip().split() results.append(dictionary[tobetransl

Re: [Tutor] Trying to access a random value in a list

2012-01-12 Thread Dave Angel
On 01/12/2012 06:56 PM, Nick W wrote: first problem: easy fix just remember that len() returns the actual number of items in the list but that list is indexed starting at 0 so just replace your line of pick = len(names) with: pick = len(names) - 1 and for problem #2: just use str

Re: [Tutor] Class vs. instance

2012-01-17 Thread Dave Angel
On 01/17/2012 09:13 PM, Stayvoid wrote: Hello! Here is another one. class A: def __init__(self, data): self.data = data print self.data I'm trying to understand this function-like syntax: A('foo').__init__(42) A(12).data What are we actually calling thi

Re: [Tutor] appending to a file on a new line

2012-01-19 Thread Dave Angel
On 01/19/2012 09:32 AM, ADRIAN KELLY wrote: Hi everyone, is there an easy way to write to a file (that already exists with data contained) on a new line. I understand that the file pointer appends where it left off but how do i write to the next line or even skip a line if possible? User_info

Re: [Tutor] appending to a file on a new line

2012-01-19 Thread Dave Angel
On 01/19/2012 10:04 AM, ADRIAN KELLY wrote: guys, its a text file i am writing to and when i write the first time its fine, i get 3 lines of input collected from a user and written to my text file, however if i run the program again the next 3 lines begin at the end of the previous users detai

Re: [Tutor] Namespace question

2012-01-20 Thread Dave Angel
On 01/20/2012 01:34 PM, Tino Dai wrote: Hi everybody, Got a namespace question framed inside a Django project (but I still think it's pertinent to Python). We moved and broke settings.py four different files in a separate directory called settings. So instead of doing a import settings s

Re: [Tutor] delete an object from method (was Tutor Digest)

2012-01-21 Thread Dave Angel
On 01/21/2012 09:58 AM, George Nyoro wrote: Hey guys, I've been making an application and have made a delete method where the user can delete the instance of that application. e.g. if I have a table object, I need to be able to delete that instance from within the class and then it becomes access

Re: [Tutor] OverflowError in lucky numbers script

2012-01-22 Thread Dave Angel
On 01/22/2012 06:37 AM, Shreesh bhat wrote: I m using Python 2.7 Steven wrote: " Scale your numbers from time to time, to avoid them getting too big" What does this mean? inp refers to the sample input test case I have given at first.Its a string containing two numbers, The program has to handle

Re: [Tutor] OverflowError in lucky numbers script

2012-01-22 Thread Dave Angel
You sent me this message privately, instead of on the list (use Reply-All in most mail programs). Two problems with that: 1) nobody else gets to help 2) I don't give private help, except as a contractor. On 01/22/2012 12:44 PM, Shreesh bhat wrote: *Lucky numbers:* def sieve(maxi): prime

Re: [Tutor] how to handle very large numbers

2012-01-22 Thread Dave Angel
On 01/22/2012 09:08 PM, Surya K wrote: Well, I have been doing a puzzle where I have to deal with number 10^18. A variable can store that value but can't do operations.Ex: If I use range() on it, it shows overflow error. So, How do I handle this. I have to use range() for that number.. in this

Re: [Tutor] how to handle very large numbers

2012-01-23 Thread Dave Angel
On 01/23/2012 07:32 AM, Surya K wrote: Date: Sun, 22 Jan 2012 21:28:14 -0500 From: d...@davea.name To: sur...@live.com CC: tutor@python.org Subject: Re: [Tutor] how to handle very large numbers On 01/22/2012 09:08 PM, Surya K wrote: Well, I have been doing a puzzle where I have to deal with

Re: [Tutor] OverflowError in lucky numbers script

2012-01-23 Thread Dave Angel
On 01/23/2012 01:20 PM, Alan Gauld wrote: On 23/01/12 13:13, Shreesh bhat wrote: I tried optimizing everything all things you guys pointed out and still its orders of magnitude away from the expected result. That's what I suspected. It means the fundamental approach of testing every number ca

Re: [Tutor] OverflowError in lucky numbers script

2012-01-23 Thread Dave Angel
On 01/23/2012 08:13 AM, Shreesh bhat wrote: I tried optimizing everything all things you guys pointed out and still its orders of magnitude away from the expected result. The program should check the islucky condition between range of (1,10**18) numbers and iterate over that 10**5 times. This

Re: [Tutor] OverflowError in lucky numbers script

2012-01-23 Thread Dave Angel
On 01/23/2012 10:31 PM, Marc Tompkins wrote: On Mon, Jan 23, 2012 at 12:08 PM, Shreesh bhatwrote: No,i meant sum of digits is prime and also sum of square of digits is prime. E.g: 23 is lucky cos 2+3=>5 (prime) 2**2+3**2 => 4+9 => 13 (prime) Thanks for the clarification - or I should say "c

Re: [Tutor] OverflowError in lucky numbers script

2012-01-23 Thread Dave Angel
On 01/23/2012 05:55 PM, Steven D'Aprano wrote: On Mon, Jan 23, 2012 at 10:01:33PM +, Alan Gauld wrote: Just to be clear this has nothing to do with Python. It doesn't matter what programming language you choose there is not a PC on Earth that can do what you want using the technique you are

Re: [Tutor] Why do you have to close files?

2012-01-26 Thread Dave Angel
On 01/26/2012 06:20 PM, amt wrote: Exercise 17, extra credit 6 Learn python the hard way: Find out why you had to do output.close() in the code. Code: from sys import argv from os.path import exists script, from_file, to_file = argv print "Copying from %s to %s" % (from_file, to_file) input

Re: [Tutor] Issue with a shapefile (ArcGIS) library (pyshp) "unpack requires a string argument of length 8"

2012-02-03 Thread Dave Angel
On 02/03/2012 10:46 AM, Simeon Tesfaye wrote: Hello everyone, Two thoughts, but realize I don't know anything about pyshp. I am having a bit of trouble here with my code, which uses a shapefile library, named pyshp, to import, edit, and save GIS files within Python. So, I open up my shapefile

Re: [Tutor] Urgent Help Required

2012-02-04 Thread Dave Angel
On 02/04/2012 08:17 AM, Zafrullah Syed wrote: Hi, I need urgent help: I am unable to commit code to svn, I am getting this warning: *svn: Commit failed (details follow):* *svn: Commit blocked by pre-commit hook (exit code 1) with output:* *:17: Warning: 'with' will become a reserved keyword in

Re: [Tutor] Tutor Digest, Vol 96, Issue 8

2012-02-04 Thread Dave Angel
On 02/04/2012 08:29 AM, Zafrullah Syed wrote: Hi, I need urgent help: I am unable to commit code to svn, I am getting this warning: *svn: Commit failed (details follow):* *svn: Commit blocked by pre-commit hook (exit code 1) with output:* *:17: Warning: 'with' will become a reserved keyword in

Re: [Tutor] Pizza panic game

2012-02-04 Thread Dave Angel
On 02/04/2012 06:43 PM, myles broomes wrote: Im currently using a book called 'Programming in Python for the complete beginner' and at the end of each chapter, the reader is given challenges to do. The current chapter im on, one of the challenges is to take the source code for a 'Pizza Panic'

Re: [Tutor] Pizza panic game

2012-02-05 Thread Dave Angel
(You forgot to do a Reply-all, and thus your message(s) came only to me. I'm forwarding it, but with my response as well) On 02/05/2012 05:35 AM, myles broomes wrote: I apologise, this is what the code actually looks like: Spikey ball class: class Spikey_ball(games.Sprite): """A hazard

Re: [Tutor] decimal precision in python

2012-02-06 Thread Dave Angel
On 02/06/2012 10:25 AM, Kapil Shukla wrote: i tried writing a small code to calculate option price using the binomial tree model. I compared my results with results of the same program in excel. There seems to be a minor difference due to decimal precision as excel is using 15 decimal precision a

Re: [Tutor] exercise with classes

2012-02-06 Thread Dave Angel
On 02/06/2012 01:24 PM, Tonu Mikk wrote: Now I get an error: NameError: global name 'self' is not define. Tonu Put your remarks after the stuff you quote. You're top-posting, which makes the reply difficult to follow. Use copy/paste to describe an error message. You retyped the one above

Re: [Tutor] Backwards message program

2012-02-06 Thread Dave Angel
On 02/06/2012 02:05 PM, myles broomes wrote: Im trying to code a program where the user enters a message and it is returned backwards. Here is my code so far: message = input("Enter your message: ") backw = "" counter = len(message) while message != 0: backw += message[counter-1]

Re: [Tutor] what is the basic difference

2012-02-06 Thread Dave Angel
On 02/06/2012 02:12 PM, Debashish Saha wrote: what is the basic difference between the commands import pylab as * import matplotlib.pyplot as plt import numpy as np import numpy as * import pylab as *pollutes your global namespace with all kinds of symbols. If you don't know them all, you m

Re: [Tutor] Class Nesting

2012-02-06 Thread Dave Angel
On 02/06/2012 08:17 PM, Greg Nielsen wrote: Hello List, My name is Greg, and while working on a project I've come across a rather interesting problem. I'm trying to create a rough model of a star cluster and all of the stars and planets contained within. Kind of a cool project; hopefully i

Re: [Tutor] confusion with else command

2012-02-07 Thread Dave Angel
On 02/07/2012 01:52 PM, Debashish Saha wrote: for i in range(1, 8): print(i) if i==3: break else: print('The for loop is over') Output: 1 2 3 Question: but after breaking the for loop why the else loop could not work? It works fine. The else clause of a for loop exe

Re: [Tutor] Question on how to do exponents

2012-02-07 Thread Dave Angel
On 02/07/2012 01:57 PM, Sarma Tangirala wrote: On 8 February 2012 00:01, Steven D'Aprano wrote: Sarma Tangirala wrote: Is is better to use pow() against **? Advantages of ** - it is shorter to type x**y vs pow(x, y) - being an operator, it is slightly faster than calling a function - you

Re: [Tutor] bogus characters in a windows file

2012-02-08 Thread Dave Angel
On 02/08/2012 08:46 PM, Garry Willgoose wrote: I'm reading a file output by the system utility WMIC in windows (so I can track CPU usage by process ID) and the text file WMIC outputs seems to have extra characters in I've not seen before. I use os.system('WMIC /OUTPUT:c:\cpu.txt PROCESS GET Pr

Re: [Tutor] exercise with classes

2012-02-09 Thread Dave Angel
On 02/09/2012 02:23 PM, Tonu Mikk wrote: On Mon, Feb 6, 2012 at 12:58 PM, Dave Angel wrote: On 02/06/2012 01:24 PM, Tonu Mikk wrote: Now I get an error: NameError: global name 'self' is not define. Tonu Put your remarks after the stuff you quote. You're top-posting, w

Re: [Tutor] Dictionaries

2012-02-10 Thread Dave Angel
On 02/10/2012 09:13 AM, myles broomes wrote: Ive been given a challenge in the book im learning Python from and its basically create a program with a dictionary of father - son pairs and allow the user to add, replace and delete pairs. Ive done that without any problems but ive been giving ano

Re: [Tutor] Cmd Advice

2012-02-11 Thread Dave Angel
(Please don't top-post. Please put your comments after whatever parts you're quoting (replying to) ) On 02/11/2012 05:06 AM, Dave Hanson wrote: Hi Walter, I can't thank you enough for taking the time to explain all of this in such level of detail. :) also apologies for taking so long to respo

Re: [Tutor] Cmd Advice

2012-02-11 Thread Dave Angel
On 02/11/2012 06:46 AM, Dave Hanson wrote: On Sat, Feb 11, 2012 at 11:35 AM, Dave Angel wrote: (Please don't top-post. Please put your comments after whatever parts you're quoting (replying to) ) Apologies Dave. You need to learn how to create a DOS window (or cmd window, ju

Re: [Tutor] Cmd Advice

2012-02-11 Thread Dave Angel
On 02/11/2012 07:14 AM, Dave Angel wrote: On 02/11/2012 06:46 AM, Dave Hanson wrote: On Sat, Feb 11, 2012 at 11:35 AM, Dave Angel wrote: (Please don't top-post. Please put your comments after whatever parts you're quoting (replying to) ) Apologies Dave. You need to learn how t

Re: [Tutor] Cmd Advice

2012-02-11 Thread Dave Angel
On 02/11/2012 07:53 AM, Dave Hanson wrote: I did try with pause during my previous attempts to get the .bat file running and when it ran with no errors I tried the pause again, pressed Enter and the window just closes and nothing happens. Cmd.exe does still exist, it's just that when you run

Re: [Tutor] Learn Python The Hard Way, Ex19-3

2012-02-11 Thread Dave Angel
On 02/11/2012 05:26 PM, amt wrote: Hello! I'm currently stuck at the Extra Credit 3 from LPTHW. Link to the actual exercise:http://learnpythonthehardway.org/book/ex19.html The exercise: Write at least one more function of your own design, and run it 10 different ways. Code from the book: def c

Re: [Tutor] repeat a sequence in range

2012-02-11 Thread Dave Angel
On 02/11/2012 06:22 PM, Michael Lewis wrote: I am trying to repeat a certain sequence in a range if a certain even occurs. Forgive me for not pasting my code; but I am not at the machine where it's saved. Basically, I want to get user input and append that input to a list only if the input is no

Re: [Tutor] Running Files with Command Lines

2012-02-11 Thread Dave Angel
On 02/12/2012 02:24 AM, Yony Torres wrote: Hello buddies I'm trying to learn Python from a well known book, and i'm stuck with something that i know that might seem surprisingly easy for you and i would like to humbly request your help: i created a script in a file named script1.py and i saved

Re: [Tutor] string integers?

2012-02-12 Thread Dave Angel
On 02/12/2012 08:25 AM, William Stewart wrote: I am trying to get 2 string variables and 2 integer variables to be able to be multiplied can anyone tell me what I did wrong str1 = raw_input("Type in a String: ") str2 = raw_input("Type in a String: ") int1 = raw_input("Type in a integer varia

Re: [Tutor] Same code has different result

2012-02-12 Thread Dave Angel
On 02/12/2012 12:02 PM, Andreas Perstinger wrote: [You've forgot to include the list in your reply] On Mon, 13 Feb 2012 00:04:54 +0800 daedae11 wrote: Sorry, I'm not sure I know your viewpoint. Could you give me a detailed explanation about "you need more than about 6-7 seconds (on my compute

Re: [Tutor] Running Files with Command Lines

2012-02-12 Thread Dave Angel
On 02/12/2012 11:57 AM, Yony Torres wrote: 1. i tried this morning and it worked in the CMD check it out: copied and pasted from the CMD C:\Users\myusername>cd documents C:\Users\myusername\Documents>cd varios2 C:\Users\myusername\Documents\varios2>cd pythonjourney C:\Users\myusername\Documents\

Re: [Tutor] How to convert seconds to hh:mm:ss format

2012-02-16 Thread Dave Angel
On 02/16/2012 04:46 PM, alain Delon wrote: userName = raw_input("Enter your name ") print "hi " + userName + ". \n " seconds = input("Enter the number of seconds since midnight:") hours = seconds/3600 hoursRemain = hours%60 minutes = hoursReamain/60 secondsRema

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