Re: [Tutor] help -Global name xxxxxxxx is not definied.

2012-08-09 Thread leon zaat
Thanks, adding the self as suggested did the trick. > To: tutor@python.org > From: __pete...@web.de > Date: Thu, 9 Aug 2012 14:45:58 +0200 > Subject: Re: [Tutor] help -Global name is not definied. > > leon zaat wrote: > > > Hello everyone, > >

Re: [Tutor] help -Global name xxxxxxxx is not definied.

2012-08-09 Thread Peter Otten
leon zaat wrote: > Hello everyone, > > Can anybody help me with this problem. > Ik have a program that i' am modifying. > > Ik build a function to export data to a csv file. I tried the functions > over different parts, that needed to be extracted. The parts on it self > worked fine. Now I put a

Re: [Tutor] help -Global name xxxxxxxx is not definied.

2012-08-09 Thread leon zaat
Hello everyone, Can anybody help me with this problem. Ik have a program that i' am modifying. Ik build a function to export data to a csv file. I tried the functions over different parts, that needed to be extracted. The parts on it self worked fine. Now I put all parts in my function. Becaus

Re: [Tutor] help - SyntaxError: Non-UTF-8 code using python 3

2012-08-09 Thread Alan Gauld
On 09/08/12 04:26, Lily Tran wrote: I am getting the following error when I try to run this python program in eclipse. I am running python 3: I see you fixed that,but there are other problems: def MagicEightBallEmulator(): answers = ["As I see it, yes", "Very doubtful"] while

Re: [Tutor] help - SyntaxError: Non-UTF-8 code using python 3

2012-08-08 Thread Lily Tran
Thanks. I found the problem character and was able to resolve it. Lily On 8/8/12 10:10 PM, "Dave Angel" wrote: >On 08/08/2012 11:26 PM, Lily Tran wrote: >> Hello; >> >> >> I am getting the following error when I try to run this python program >>in eclipse. I am running python 3: >> >> >> Fil

Re: [Tutor] help - SyntaxError: Non-UTF-8 code using python 3

2012-08-08 Thread Dave Angel
On 08/08/2012 11:26 PM, Lily Tran wrote: > Hello; > > > I am getting the following error when I try to run this python program in > eclipse. I am running python 3: > > > File "/Users/lilytran/Desktop/python/Ex_Files_Python_3_EssT/Exercise > Files/class_beginner_python/hw3_2_lab6.py", line 30 >

Re: [Tutor] Help please!

2012-07-31 Thread ttmticdi .
>> Ex: >> > No! >> print "Hi %s! You like %s and %s" (user_name, x, y) >> > Yes! > print "Hi %s! You like %s and %s" % (user_name, x, y) >> >> >>> Forgot the interpolation operator(%). Thank you very much Joel for correcting me. Regards, ttmticdi. ___

Re: [Tutor] Help please!

2012-07-31 Thread Joel Goldstick
On Tue, Jul 31, 2012 at 5:52 AM, ttmticdi . wrote: >> > print "Mum is in a %s mood" % (mum_mood) >> > print "Dad is in a %s mood" % (dad_mood) >> >> > > > Hi Victoria! > > Since you have only one format character in the strings above there is > no need to surround the variables mum_mood and dad_mo

Re: [Tutor] Help please!

2012-07-31 Thread ttmticdi .
> > print "Mum is in a %s mood" % (mum_mood) > > print "Dad is in a %s mood" % (dad_mood) > > Hi Victoria! Since you have only one format character in the strings above there is no need to surround the variables mum_mood and dad_mood with parenthesis. You only do that when you have multiple form

Re: [Tutor] Help please!

2012-07-30 Thread Prasad, Ramit
> Hello all! I have a very simple question but I'm very new to python. Could you > describe to me what the following piece of Python code says in English > please? Welcome to the list and Python! When posting code in the future I recommend posting in plain text and not "rich" text or HTML. If you

Re: [Tutor] Help please!

2012-07-30 Thread Emile van Sebille
On 7/30/2012 12:52 PM Victoria Homsy said... Hello all! I have a very simple question but I'm very new to python. Could you describe to me what the following piece of Python code says in English please? def print_a_line(line_count, f): print line_count, f.readline() This function accepts

Re: [Tutor] Help please!

2012-07-30 Thread Puneeth Chaganti
On Mon, Jul 30, 2012 at 9:35 PM, Victoria Homsy wrote: > Hi! I am a new Python user, and would really appreciate some help. My code > is as follows: > > from sys import argvs > script, mum_mood, dad_mood = argvs > > # my own function > def dad_and_mum_mood(mum_mood, dad_mood): > print "If both mum

Re: [Tutor] Help with Matplotlib labels

2012-06-19 Thread Mark Lawrence
On 19/06/2012 00:46, Alan Gauld wrote: On 19/06/12 00:13, Sean Carolan wrote: and not the total of all the individual items. Anyone matplotlib experts out there who can weigh in? Not me, but I notice there is a gmane newsfeed for matplotlib: gmane.comp.python.matplotlib.general Probably wor

Re: [Tutor] Help with Matplotlib labels

2012-06-18 Thread Sean Carolan
> I also noticed another issue with my stacked bar graph; the total > height of the bar is the size of the largest number of the dataset, > and not the total of all the individual items.  Anyone matplotlib > experts out there who can weigh in? I figured out what was going on here; the bars were al

Re: [Tutor] Help with Matplotlib labels

2012-06-18 Thread Sean Carolan
> Unfortunately my graph is generated dynamically. How can I create my > legend when my 'bar' objects have no names to refer to? > >    for admin in bd: >        bar(ind, bd[admin], width, color=colordict[admin]) >    xticks(ind+width/2., datenames) >    legend() >    grid('on') >    outfile = 'tes

Re: [Tutor] Help with Matplotlib labels

2012-06-18 Thread Sean Carolan
> Not me, but I notice there is a gmane newsfeed for matplotlib: > > gmane.comp.python.matplotlib.general > > Probably worth posting questions there. Thank you, I will inquire on the newsfeed. ___ Tutor maillist - Tutor@python.org To unsubscribe or cha

Re: [Tutor] Help with Matplotlib labels

2012-06-18 Thread Alan Gauld
On 19/06/12 00:13, Sean Carolan wrote: and not the total of all the individual items. Anyone matplotlib experts out there who can weigh in? Not me, but I notice there is a gmane newsfeed for matplotlib: gmane.comp.python.matplotlib.general Probably worth posting questions there. -- Alan G

Re: [Tutor] Help with Matplotlib labels

2012-06-18 Thread Sean Carolan
> Unfortunately my graph is generated dynamically. How can I create my > legend when my 'bar' objects have no names to refer to? I also noticed another issue with my stacked bar graph; the total height of the bar is the size of the largest number of the dataset, and not the total of all the indivi

Re: [Tutor] Help with graphics please

2012-04-24 Thread Steven D'Aprano
On Tue, Apr 24, 2012 at 03:57:58PM +0800, Ivor Surveyor wrote: > > I request help in locating the graphics module "graphics.py" Have you tried searching for "Python programming by John Zelle graphics.py" on any of the major search engines, like Google, Yahoo or DuckDuckGo? That should always be

Re: [Tutor] Help with regular expression

2012-04-15 Thread syed zaidi
Thanks for the help I need the whole line starting from 'D' but in seperate columns.like KO, EC, Gene ID, Enzyme Name etc > Date: Mon, 16 Apr 2012 00:24:17 +1000 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] Help with regular expression

Re: [Tutor] Help with regular expression

2012-04-15 Thread Steven D'Aprano
syed zaidi wrote: Dear Steve,Tutor doesn't allow attachment of huge files. I am attaching the files I am taking as input, code and the output CSV file. I hope then you would be able to help me. DOT keg files open in file viewer, you can also view them in python. The CSV file is the desired output

Re: [Tutor] Help with regular expression

2012-04-15 Thread Steven D'Aprano
syed zaidi wrote: Dear all Can someone please tell me how to solve the following problem. I have developed a python code to extract specific information from more than 1000 files which have slightly different format. The problem I am facing is that I have to develop specific RE for each of the

Re: [Tutor] Help for to do a script

2012-03-16 Thread Alan Gauld
On 16/03/12 18:52, Boris Vladimir Comi wrote: *File "/home/mcidasv/JYTHON/TIR.py", line 22 count = count + 1; ^ SyntaxError: invalid syntax* Error messages indicate where Python found the problem. Often the real problem is a line or so before that. In your case you omitted the colon after the

Re: [Tutor] Help for to do a script

2012-03-16 Thread Joel Goldstick
On Fri, Mar 16, 2012 at 2:58 PM, Joel Goldstick wrote: > On Fri, Mar 16, 2012 at 2:52 PM, Boris Vladimir Comi > wrote: >> Hello, I am writing to request your help in the realization of a script. I >> am new to this and I'm just learning the wonderful world of python and this >> has made me a litt

Re: [Tutor] Help for to do a script

2012-03-16 Thread Joel Goldstick
On Fri, Mar 16, 2012 at 2:52 PM, Boris Vladimir Comi wrote: > Hello, I am writing to request your help in the realization of a script. I > am new to this and I'm just learning the wonderful world of python and this > has made me a little difficult. > > Briefly I commented what I intend to do: > >

Re: [Tutor] Help with Python Program

2012-02-26 Thread Robert Sjoblom
> import random #import random number generator module > target = random.randint(1,100) #generates random number between 1 and 100 > guess = float(raw_input('pick a number between 1 and 100')) > while guess != target: >    if guess < target: print 'too low' >    elif guess > target: print 'too high

Re: [Tutor] Help with Python Program

2012-02-26 Thread Carolina Dianne LaCourse
First off I want to really thank you for all of the help! I am in my first semester as I started as a non traditional student in January. Even though I am in an intro class I think that many of my class mates had more of a c/s foundation in high then I did. It took me a few tries but I did finally

Re: [Tutor] Help with Python Program

2012-02-24 Thread Steven D'Aprano
Carolina Dianne LaCourse wrote: [...] I understand that I need to ask for raw input from the user and that I need to be able to use the if elif else to tell the user whether their number matches or id too high or to low but am just not sure what to do first. Any advice would be greatly appreciat

Re: [Tutor] Help with Python Program

2012-02-24 Thread bob gailer
On 2/24/2012 10:18 PM, Carolina Dianne LaCourse wrote: Hi, I have never programed before and am brand new to python also. I am trying to create a Hi-Lo game and am not really sure where to start. These are the instructions that I have. I know that I will need to import the random number generator

Re: [Tutor] help writing functions

2012-02-24 Thread Wayne Werner
On Thu, 23 Feb 2012, Saad Javed wrote: I am learning python and need guidance for writing some code. I've written a simple program (with pointers from people) that parses an tv show xml feed and prints their values in plain text after performing some string operations. Unless you're really i

Re: [Tutor] help writing functions

2012-02-23 Thread Saad Javed
Sorry for the formatting. Added return statements to both functions. Adding return [x, y] to get_value func. That solved the problem. Thank you! :) Saad On Thursday, February 23, 2012, Alan Gauld wrote: > On 23/02/12 00:59, Saad Javed wrote: > > [CODE]feed = urllib.urlopen(rssPage) #rssPage: ad

Re: [Tutor] help writing functions

2012-02-23 Thread Alan Gauld
On 23/02/12 00:59, Saad Javed wrote: [CODE]feed = urllib.urlopen(rssPage) #rssPage: address of xml feed tree = etree.parse(feed) x = tree.xpath("/rss/channel/item/title/text()") x = str(x[0]) for tag in tags: #tags is a list of items like hdtv, xvid, 720p etc x = re.sub(r'\b' + tag + r'\b', '',

Re: [Tutor] help writing functions

2012-02-22 Thread Andreas Perstinger
On 2012-02-23 01:59, Saad Javed wrote: I am learning python and need guidance for writing some code. I've written a simple program (with pointers from people) that parses an tv show xml feed and prints their values in plain text after performing some string operations. [CODE]feed = urllib.urlope

Re: [Tutor] Help Designing a simple Program called Life

2012-02-22 Thread Alan Gauld
On 22/02/12 18:50, leo degon wrote: Hello All, My name is Leo. I'm just beginning to learn python. I am learning on my own and have no previous programming experience. I decided to create a version of john conway's game of life as a personal project. OK, Thats quite a good project

Re: [Tutor] Help Designing a simple Program called Life

2012-02-22 Thread bob gailer
On 2/22/2012 1:50 PM, leo degon wrote: Hello All, My name is Leo. Hi Leo & Welcome to Python help. We are a few volunteers who like assisting others. A few guidelines: - always reply-all so a copy goes to the list - reply in-line rather than at the top. - if your code is large put

Re: [Tutor] Help Glade Tutorial.

2012-01-29 Thread Chris Fuller
Which ones did you look at, and why did you not like them? Keep in mind that Glade is an interface builder, and hasn't got anything much to do with the target language, other than requiring there be a libglade library to read the XML files. I actually got started with some articles in Linux J

Re: [Tutor] help with program from learning python the hard way

2012-01-19 Thread Walter Prins
Hi Jason, On 19 January 2012 13:02, Jason Loeve wrote: > good day i seem to be stuck, my code is > > from sys import argv > > script, user_name = argv > > and i get an error ValueError: need more than 1 value to unpack > The implication of this message is that the value of "argv" contains only

Re: [Tutor] help with program from learning python the hard way

2012-01-19 Thread bodsda
If I say that sys.argv is a list, does that help you? Also, run things from a command prompt for this kind of thing, at least then you can guarantee what args get passed Bodsda Sent from my BlackBerry® wireless device -Original Message- From: Jason Loeve Sender: tutor-bounces+bodsda

Re: [Tutor] help with program from learning python the hard way

2012-01-19 Thread vishwajeet singh
On Thu, Jan 19, 2012 at 6:32 PM, Jason Loeve wrote: > good day i seem to be stuck, my code is > > from sys import argv > > script, user_name = argv > Are you passing an additional parameter while executing the script ?? you must execute it passing an additional parameter which will get assigned

Re: [Tutor] Help with lag

2012-01-10 Thread Hugo Arts
On Wed, Jan 4, 2012 at 9:45 PM, Nate Lastname wrote: > Hello! > > The attached file 'cameramovement.py' is very laggy. Could someone help me > out by telling me what part of this is slowing it down so much?  I've > checked the whole file through, and I can't see why it's so slow. You'll > have to

Re: [Tutor] help with script

2011-12-28 Thread Alan Gauld
On 28/12/11 01:31, nickto...@comcast.net wrote: hello, my name is nick. i got python for software design by Allen B. Downey as a gift for christmas. i am completely new to programming Welcome, we are here to help :-) 5 x=5 x+1 im ok when it comes to using python so far. but it has asked me to

Re: [Tutor] help with script

2011-12-27 Thread James Reynolds
On Tue, Dec 27, 2011 at 8:31 PM, wrote: > hello, my name is nick. i got python for software design by Allen B. > Downey as a gift for christmas. i am completely new to programming and i am > having trouble figuring out how to do an exercise concerning script.. > my problem > 5 > x=5 > x+1 > im ok

Re: [Tutor] Help with update_wrapper

2011-12-10 Thread Peter Otten
Emeka wrote: > Could someone explain " functools.update_wrapper" with simple examples? Since this is not for the absolute beginner I'm assuming you are already familiar with decorators. In their most common form these are functions that take a function and wrap that function into another functi

Re: [Tutor] Help with error in ski game

2011-11-20 Thread Steven D'Aprano
Chloe Beck wrote: Traceback (most recent call last): File "/Users/Chloe/Documents/SKI SKI/ski ski ski", line 99, in skier.move(speed) File "/Users/Chloe/Documents/SKI SKI/ski ski ski", line 28, in move if self.rect.centerx < 20: self.rect.centrex = 20 AttributeError: 'pygame.Rect'

Re: [Tutor] Help with error in ski game

2011-11-20 Thread bodsda
Just a guess but take a look at the spelling. centerx Or centrex Bodsda Sent from my BlackBerry® wireless device -Original Message- From: Chloe Beck Sender: tutor-bounces+bodsda=googlemail@python.org Date: Sun, 20 Nov 2011 11:58:25 To: Subject: [Tutor] Help with error in ski game

Re: [Tutor] Help with re in Python 3

2011-11-05 Thread Andreas Perstinger
On 2011-11-04 20:59, Albert-Jan Roskam wrote: It seems that you are not opening the file properly. You could do f = file('///Users/joebatt/Desktop/python3.txt','r') or: withfile('///Users/joebatt/Desktop/python3.txt','r') as f: OP is using Python 3, where "file" is removed. Thus, you have to us

Re: [Tutor] Help with re in Python 3

2011-11-04 Thread Steven D'Aprano
Prasad, Ramit wrote: m = re.search("[A-Z]{3}[a-z][A-Z]{3}", line) That is the expression I would suggest, except it is still more efficient to use a compiled regular expression like the original version. Not necessarily. The Python regex module caches recently used regex strings, avoiding re

Re: [Tutor] Help with re in Python 3

2011-11-04 Thread Prasad, Ramit
>m = re.search("[A-Z]{3}[a-z][A-Z]{3}", line) That is the expression I would suggest, except it is still more efficient to use a compiled regular expression like the original version. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX

Re: [Tutor] Help with re in Python 3

2011-11-04 Thread Albert-Jan Roskam
It seems that you are not opening the file properly. You could do f = file('///Users/joebatt/Desktop/python3.txt','r') or: withfile('///Users/joebatt/Desktop/python3.txt','r') as f:   for line in f:     m = re.search("[A-Z]{3}[a-z][A-Z]{3}", line)     if m:   print("Pattern found")   print(

Re: [Tutor] Help with re in Python 3

2011-11-04 Thread Joel Goldstick
On Fri, Nov 4, 2011 at 3:42 PM, Joe Batt wrote: > Hi all, > Still trying with Python and programming in general…. > > I am trying to get a grip with re. I am writing a program to open a text > file and scan it for exactly 3 uppercase letters in a row followed by a > lowercase followed by exactly

Re: [Tutor] Help

2011-11-01 Thread Alan Gauld
On 01/11/11 04:10, Chris Kavanagh wrote: before. In other languages, ala C++, don't global variables have to be declared at the 'top' of the code?? No, that's just common usage. You can declare a variable anywhere in C/C++ provided it's before it is used. But that can lead to hard to read code

Re: [Tutor] Help

2011-11-01 Thread Dave Angel
(Pleas put your reply after the part you're quoting. What you did is called top-posting, and makes reading the messages very confusing) On 11/01/2011 12:10 AM, Chris Kavanagh wrote: I'm going to thank Steven once again, and answer my own question in the 2nd paragraph directly below (Steven hasn

Re: [Tutor] Help

2011-10-31 Thread Chris Kavanagh
I'm going to thank Steven once again, and answer my own question in the 2nd paragraph directly below (Steven hasn't had a chance to respond yet). I just learned that the Function definitions are not read by the interpreter UNTIL they are called. I was reading them and assuming they were execut

Re: [Tutor] Help

2011-10-31 Thread Chris Kavanagh
Yes Steven, that solved my question(s). It also cleared up what was to be my next question! Thanks so much. You might not realize how grateful I am to be able to have you & others on the list answer my questions. Just trust me when I say, I am grateful. And I apologize for the code being mangle

Re: [Tutor] Help

2011-10-31 Thread Steven D'Aprano
Chris Kavanagh wrote: However, I'm confused on Line 30 {if chosenCave== str(friendlyCave)}. Here's the description of this line the author gives: "Here we check if the integer of the cave we chose ('1' or '2') is equal to the cave randomly selected to have the friendly dragon" My question i

Re: [Tutor] help

2011-10-10 Thread Alan Gauld
On 10/10/11 20:23, George Nyoro wrote: On 10/10/2011, tutor-requ...@python.org wrote: Send Tutor mailing list submissions to tutor@python.org To subscribe or unsubscribe via the World Wide Web, visit snip >> When replying, please edit your Subject line so it is more specifi

Re: [Tutor] Help refactoring this code

2011-10-09 Thread Steven D'Aprano
D. Guandalino wrote: Hi, in this class many methods share common code. Given your example, I wouldn't bother refactoring it. There's not enough code in common to matter. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change s

Re: [Tutor] Help refactoring this code

2011-10-09 Thread Alan Gauld
On 09/10/11 23:41, D. Guandalino wrote: Hi, in this class many methods share common code. class Foo(object): def m1(self): if self.foo: pass # m1 do something elif self.bar: pass # m1 do something else else: pass # m1 do some

Re: [Tutor] Help!

2011-10-07 Thread bob gailer
On 10/7/2011 12:32 PM, rmntcver...@aol.com wrote: I need serious help with this Rock, Paper, Scissors program. The program runs smoothly but I can't get the score to print. Please help me with this one aspect! Here is my code right now: Welcome to Python Help. In future please use a meaningfu

Re: [Tutor] Help!

2011-10-07 Thread Alex Hall
On 10/7/11, rmntcver...@aol.com wrote: > I need serious help with this Rock, Paper, Scissors program. The program > runs smoothly but I can't get the score to print. Please help me with this > one aspect! Here is my code right now: > > > > import random > > > def computerrockPaperScissors(): >

Re: [Tutor] Help me in this programme

2011-10-06 Thread Alan Gauld
On 06/10/11 08:15, Praveen Singh wrote: CountWords("google") [('e',1),('g',2),('l',1),('o',2)] by the level of this question you can easily understand i am new in python.the problem i am facing is how to make set of word and count(e,1) and add this to list?? Some clues: a for loop will itera

Re: [Tutor] help with a recursive function

2011-09-27 Thread Alan Gauld
On 27/09/11 19:32, c smith wrote: i understand the general idea of recursion and if I am following well written code I can understand how it works, but when I try to write it for myself I get a bit confused with the flow. Others have dealt with the specifics. If you really want to learn how to

Re: [Tutor] help with a recursive function

2011-09-27 Thread Steven D'Aprano
Mac Ryan wrote: raise BaseException('Something is wrong here!') Never raise BaseException directly! BaseException is the very top of the exception hierarchy, you should raise the *most* specific exception you can, not the least specific. BaseException isn't even just for errors, it's al

Re: [Tutor] help with a recursive function

2011-09-27 Thread Steven D'Aprano
c smith wrote: hi list, i understand the general idea of recursion and if I am following well written code I can understand how it works, but when I try to write it for myself I get a bit confused with the flow. Your flow is fine. You just forget to return anything in two of the three branches

Re: [Tutor] help with a recursive function

2011-09-27 Thread Mac Ryan
On Tue, 27 Sep 2011 14:32:00 -0400 c smith wrote: > hi list, > i understand the general idea of recursion and if I am following well > written code I can understand how it works, but when I try to write > it for myself I get a bit confused with the flow. > I was trying to turn an ackerman functio

Re: [Tutor] Help!

2011-09-22 Thread xDog Walker
Move the following two lines to immediately follow the while. player=raw_input("Please pick your throw: (r,s,p):") computer= random.choice(['r','s','p']) -- I have seen the future and I am not in it. ___ Tutor maillist - Tutor@python.org To unsub

Re: [Tutor] Help!

2011-09-22 Thread Prasad, Ramit
From: tutor-bounces+ramit.prasad=jpmorgan@python.org [mailto:tutor-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of Joseph Shakespeare Sent: Thursday, September 22, 2011 12:05 PM To: tutor@python.org Subject: [Tutor] Help! Hello, I am new Python (about 2 weeks) and need some help.

Re: [Tutor] Help with if-elif-else structure

2011-08-27 Thread Emile van Sebille
Behalf Of TheIrda Sent: Friday, August 26, 2011 8:55 AM To: Christopher King Cc: python mail list Subject: Re: [Tutor] Help with if-elif-else structure Hello, I'm quite new on python, so don't hit too hard if I'm wrong ;) A question on the logic... Does this means if roll[0]>

Re: [Tutor] Help with if-elif-else structure

2011-08-27 Thread TheIrda
asad | JPMorgan Chase Investment Bank | Currencies Technology > 712 Main Street | Houston, TX 77002 > work phone: 713 - 216 - 5423 > > > From: tutor-bounces+ramit.prasad=jpmorgan@python.org > [mailto:tutor-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of > T

Re: [Tutor] Help with if-elif-else structure

2011-08-26 Thread Peter Otten
Robert Sjoblom wrote: > #assuming target number 15 > roll = (result, initial_mins, initial_max) > if roll[0] > 15: > if roll[1] >= 2: > print("Success") > elif roll[2] >= 2: > print("Critical failure!") > else: > print("Failure.") > elif roll[0] <= 15: > if

Re: [Tutor] Help with if-elif-else structure

2011-08-26 Thread Bspymaster
Well, I'm not sure what your asking for the first question, but for the second one, you would have an unhandled exception in your code if roll[0] was less than or equal to 0. Hope that helps a bit! On Fri, Aug 26, 2011 at 8:55 AM, TheIrda wrote: > Hello, > > I'm quite new on python, so don't hi

Re: [Tutor] Help with if-elif-else structure

2011-08-26 Thread Prasad, Ramit
002 work phone: 713 - 216 - 5423 From: tutor-bounces+ramit.prasad=jpmorgan@python.org [mailto:tutor-bounces+ramit.prasad=jpmorgan....@python.org] On Behalf Of TheIrda Sent: Friday, August 26, 2011 8:55 AM To: Christopher King Cc: python mail list Subject: Re: [Tutor] Help with if-elif-else str

Re: [Tutor] Help with if-elif-else structure

2011-08-26 Thread TheIrda
Hello, I'm quite new on python, so don't hit too hard if I'm wrong ;) A question on the logic... Does this means if roll[0] > 15: if roll[1] >= 2: print("Success") elif roll[2] >= 2: print("Critical failure!") that rolling multiple 1's get the priority on rolling multiple

Re: [Tutor] help with 'organization'

2011-08-25 Thread Steven D'Aprano
John wrote: I know a code example might help, so I try to show it here (my code I'm afraid is too complex and ugly at the moment). You can see the it fails because MyTools doesn't have 'this' attribute... Then give it one. class MyTools: Add an initialisation method: def __init__(self

Re: [Tutor] help with 'organization'

2011-08-25 Thread James Reynolds
On Thu, Aug 25, 2011 at 1:51 PM, John wrote: > Hello, I am writing a module that will have two classes ('runners') I > am calling them, as they will ultimately use subprocess to run a > command line program, so they are basically option parsers, etc... > > As I wrote the second 'runner', I realiz

Re: [Tutor] help with 'organization'

2011-08-25 Thread John
Ha! Inheritance! On Thu, Aug 25, 2011 at 7:51 PM, John wrote: > Hello, I am writing a module that will have two classes ('runners') I > am calling them, as they will ultimately use subprocess to run a > command line program, so they are basically option parsers, etc... > > As I wrote the second '

Re: [Tutor] Help with if-elif-else structure

2011-08-25 Thread Christopher King
Looks good, although I would add one or two things. > #assuming target number 15 > Put that in a variable for the target number > roll = (result, initial_mins, initial_max) > if roll[0] > 15: >if roll[1] >= 2: You could even put all the constants in variables > print("Success") >

Re: [Tutor] help with a class

2011-08-25 Thread Steven D'Aprano
John wrote: Thanks for the feedback. I wasn't aware about the assert usage not being intended for production code. That's not quite true. There is nothing wrong with using asserts in production code. The important thing is to use them *properly*. Asserts are for checking your internal program

Re: [Tutor] Help with if-elif-else structure

2011-08-25 Thread Robert Sjoblom
>> #assuming target number 15 >> roll = (result, initial_mins, initial_max) > I'd forget the tuple and just use the names, > it is more readable that way... >if result > 15: >if initial_mins >= 2:... >elif initial_max >=2:... > But otherwise it seems to reflect the rules as you've writte

Re: [Tutor] Help with if-elif-else structure

2011-08-25 Thread Alan Gauld
On 25/08/11 08:51, Robert Sjoblom wrote: If I roll two sixes (on the initial roll) and below the target number (in total), it's a failure. If I roll two sixes (on the initial roll) and above the target number (in total), it's a critical failure. If I roll two ones (on the initial roll) and abov

Re: [Tutor] help with a class

2011-08-25 Thread John
Thanks for the feedback. I wasn't aware about the assert usage not being intended for production code. On Wed, Aug 24, 2011 at 11:37 PM, Alan Gauld wrote: > On 24/08/11 21:03, Prasad, Ramit wrote: >> >> I was under the impression that asserts are more for testing > >> than for production code > >

Re: [Tutor] help with a class

2011-08-24 Thread Alan Gauld
On 24/08/11 21:03, Prasad, Ramit wrote: I was under the impression that asserts are more for testing > than for production code That's true. def overide_options(self, options, run_id=None): if not isinstance(options, dict): raise TypeError("override options requires

Re: [Tutor] help with a class

2011-08-24 Thread Prasad, Ramit
I was under the impression that asserts are more for testing than for production code (especially since they can be removed when running from python from command line). Instead I removed the assert and replaced it to raise an error. def overide_options(self, options, run_id=None): """

Re: [Tutor] help with a class

2011-08-24 Thread John
Thank you. I've corrected the KeyError, and changed the function to: def overide_options(self, options, run_id=None): """ completely overide the options dict """ assert isinstance(options, dict), "override options requires a dict" if run_id in self.run_queue:

Re: [Tutor] help with a class

2011-08-24 Thread Hugo Arts
On Wed, Aug 24, 2011 at 8:34 PM, John wrote: > Hello, I have a class that has an attribute that is a dict which I > fill with more dicts. I've created a function to return those > dictionaries if a key is provide, otherwise, it returns the 'default' > dictionary. > > I have the following methods (

Re: [Tutor] help in TKINTER

2011-08-16 Thread Alan Gauld
On 16/08/11 05:31, aditya wrote: Hello tutors, I wanted some help in using the Tkinter class for button creation, I am not able to add on click events i.e. when I press the button certain action should be performed for example if I press the button named 5, then it should display 5 in the text f

Re: [Tutor] Help with making emacs work with python syntax checking?

2011-07-06 Thread col speed
Alan Gauld" > Sender: tutor-bounces+eire1130=gmail....@python.org > Date: Mon, 4 Jul 2011 23:59:48 > To: > Subject: Re: [Tutor] Help with making emacs work with python syntax > checking? > > "Tidal Espeon" wrote > > >I need help with installing this setu

Re: [Tutor] Help with making emacs work with python syntax checking?

2011-07-04 Thread eire1130
d I'm still happy. Other than it took too long to set up in mint Bonus is I can use it django as well. Sent from my Verizon Wireless BlackBerry -Original Message- From: "Alan Gauld" Sender: tutor-bounces+eire1130=gmail@python.org Date: Mon, 4 Jul 2011 23:59:48 To:

Re: [Tutor] Help with making emacs work with python syntax checking?

2011-07-04 Thread Alan Gauld
"Tidal Espeon" wrote I need help with installing this setup on my emacs: Why do you want this? Are you already an emacs user? If so then fine, go ahead. But if you do not already use emacs, lerarning it will be a big effort. emacs is a big, powerful tool and once you know it you can use i

Re: [Tutor] Help with making emacs work with python syntax checking?

2011-07-04 Thread Peter Otten
Tidal Espeon wrote: > I need help with installing this setup on my emacs: > http://hide1713.wordpress.com/2009/01/30/setup-perfect-python-environment- in-emacs/ > The problem is that I have no clue how to access any .emacs file or > .emacs.d folder. I'm running linux, and they are apparently invis

Re: [Tutor] Help with making emacs work with python syntax checking?

2011-07-04 Thread Lisi
On Monday 04 July 2011 15:46:31 Tidal Espeon wrote: > I need help with installing this setup on my emacs: > http://hide1713.wordpress.com/2009/01/30/setup-perfect-python-environment-i >n-emacs/ The problem is that I have no clue how to access any .emacs file or > .emacs.d folder. I'm running linux,

Re: [Tutor] Help with understanding classes

2011-05-22 Thread Robert Sjoblom
> That's pretty much all you need to know to start using objects. There's > a lot more though: inheritance, class methods and static methods (as > opposed to ordinary methods), properties, descriptors (advanced!), > slots, and more. But one step at a time. > > Any questions, don't hesitate to ask!

Re: [Tutor] Help with understanding classes

2011-05-22 Thread Lowell Tackett
Robert...I am similarly where you are stuck, a beginner with little insight, so my perspective might have some draw to it. Try this on for size - while watching a friend stencil Christmas decorations on living room windows last year, it dawned on me that a class is quite simply - a stencil. Wh

Re: [Tutor] Help with understanding classes

2011-05-21 Thread RL Berman
What a phenomenally clear explanation. Thank you very much, Steven. Robert Berman On 05/21/2011 07:49 AM, Steven D'Aprano wrote: On Sat, 21 May 2011 08:24:34 pm Robert Sjöblom wrote: I'm trying to wrap my head around classes and their attributes, but am having a hard time doing so. The websit

Re: [Tutor] Help with understanding classes

2011-05-21 Thread Alan Gauld
"Robert Sjöblom" wrote I'm trying to wrap my head around classes ...The websites and books that I have consulted ...assume prior programming/oop experience, something I lack. Alex, and especially Steven (great job BTW!,) have given you good explanations, provided you understand the basics of

Re: [Tutor] Help with understanding classes

2011-05-21 Thread Alex Hall
On 5/21/11, Robert Sjöblom wrote: > I'm trying to wrap my head around classes and their attributes, but am > having a hard time doing so. The websites and books that I have consulted > haven't been much help; most of them assume prior programming/oop > experience, something I lack. > > From what I

Re: [Tutor] Help with understanding classes

2011-05-21 Thread Steven D'Aprano
On Sat, 21 May 2011 08:24:34 pm Robert Sjöblom wrote: > I'm trying to wrap my head around classes and their attributes, but > am having a hard time doing so. The websites and books that I have > consulted haven't been much help; most of them assume prior > programming/oop experience, something I la

Re: [Tutor] Help with exceptions please

2011-05-14 Thread Timo
On 14-05-11 05:05, Wayne Werner wrote: On Fri, May 13, 2011 at 7:48 PM, Lea Parker > wrote: Hello I have another assignment I am trying to fine tune. The idea is to make sure exceptions work. I have come up with a problem when testing my code. When

Re: [Tutor] Help with exceptions please

2011-05-13 Thread Wayne Werner
On Fri, May 13, 2011 at 7:48 PM, Lea Parker wrote: > Hello > > > > I have another assignment I am trying to fine tune. The idea is to make > sure exceptions work. I have come up with a problem when testing my code. > When I enter a golf score for a player the program returns the ‘error that > has

Re: [Tutor] Help with sys.argv

2011-04-29 Thread Dave Angel
On 01/-10/-28163 02:59 PM, monkey...@aim.com wrote: Hello, I am trying to learn how to use python with Facebook's Open Graph API. I am getting my feet wet with the following code authored by Matthew A. Russell. I copied it line for line for learning purposes, but I am getting the following

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