User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 456,521 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,802 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 835 | Replies: 5
Reply
Join Date: Jul 2006
Posts: 562
Reputation: jrcagle is on a distinguished road 
Rep Power: 4
Solved Threads: 72
jrcagle jrcagle is offline Offline
Posting Pro

What's your favorite error?

  #1  
Sep 29th, 2007
I'm writing a lesson on debugging for my students. They will have already had a lesson on how to read code and do walkthroughs, either manually or using the debugger. They currently know about if, while, types, math operators, and have some experience with but no formal training in functions and methods. (We're finishing ch. 3 of Dawson's Python Programming for the Absolute Beginner).

So the lesson on debugging will emphasize verifying that the code does what it looks like it should do. In addition, we'll discuss common errors (bad indentation; naming a function instead of calling it; off-by-one; infinite loops; etc.).

So: what Python errors cause you fits? Or, do you have any hair-pulling stories to share? Or, do you have any "I had to debug someone else's code and it was a stupid ___ error" stories?

Thanks,
Jeff
Last edited by jrcagle : Sep 29th, 2007 at 10:39 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Posts: 2,529
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 11
Solved Threads: 178
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: What's your favorite error?

  #2  
Sep 30th, 2007
Even though Python has // as an integer division operator, I most commonly use the / operator. Right now you can use the / or the // operator for integer divisions, and here is were I get into trouble.
  1. a = 4/5
  2. print a # oops the result is 0 and I wanted 0.8
This will change with Python30, there you have to use // for integer division or you will get float division.

Another of my common errors is mismatching the numbers of () or [].
May 'the Google' be with you!
Reply With Quote  
Join Date: Apr 2005
Location: Dundee, Scotland
Posts: 12,883
Reputation: jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough 
Rep Power: 32
Solved Threads: 305
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: What's your favorite error?

  #3  
Sep 30th, 2007
So the lesson on debugging will emphasize verifying that the code does what it looks like it should do. In addition, we'll discuss common errors (bad indentation; naming a function instead of calling it; off-by-one; infinite loops; etc.).

Okay, i dont know anything about python(Im a VB guy) but in VB its always interesting to give someone a equasion which works if they do it by themselves in thier head, but not on the computer, due to operator precedence (BODMAS)


(B)rackets
(O)rder (sometimes called (I)ndicies)
(D)ivision
(M)ultiplication
(A)ddition
(S)ubtraction

e.g

What do you think the answer to 2 + 3 x 5 is?

Is it (2 + 3) x 5 = 5 x 5 = 25 ?

or 2 + (3 x 5) = 2 + 15 = 17 ?

(its actually 17!!)!
Last edited by jbennet : Sep 30th, 2007 at 7:23 pm.
TRY MY SUGGESTIONS AT YOUR OWN RISK

Master of puppets Im pulling your strings, blinded by me, you cant see a thing. Master! Master!
Reply With Quote  
Join Date: Oct 2007
Location: Pennsylvania, US
Posts: 37
Reputation: maddog39 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
maddog39 maddog39 is offline Offline
Light Poster

Re: What's your favorite error?

  #4  
Oct 10th, 2007
>>> from __future__ import braces
  File "<stdin>", line 1
SyntaxError: not a chance
Haha! Favorite error ever! All versions of python have this "hidden feature." It's obviously making fun at C. : P
Last edited by maddog39 : Oct 10th, 2007 at 7:14 pm.
Reply With Quote  
Join Date: Aug 2005
Posts: 1,196
Reputation: Ene Uran is on a distinguished road 
Rep Power: 6
Solved Threads: 67
Ene Uran's Avatar
Ene Uran Ene Uran is offline Offline
Veteran Poster

Re: What's your favorite error?

  #5  
Oct 11th, 2007
Originally Posted by maddog39 View Post
>>> from __future__ import braces
  File "<stdin>", line 1
SyntaxError: not a chance
Haha! Favorite error ever! All versions of python have this "hidden feature." It's obviously making fun at C. : P
A very funny discovery, thank you!
drink her pretty
Reply With Quote  
Join Date: Jul 2006
Posts: 562
Reputation: jrcagle is on a distinguished road 
Rep Power: 4
Solved Threads: 72
jrcagle jrcagle is offline Offline
Posting Pro

Re: What's your favorite error?

  #6  
Oct 11th, 2007
I laughed out loud! Thanks!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Python Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Python Forum

All times are GMT -4. The time now is 4:13 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC