Fwd: [Tutor] How and where to use pass and continue

Liam Clarke cyresse at gmail.com
Mon Mar 28 04:22:29 CEST 2005


Oops, forward to list as well.


---------- Forwarded message ----------
From: Liam Clarke <cyresse at gmail.com>
Date: Mon, 28 Mar 2005 14:22:00 +1200
Subject: Re: [Tutor] How and where to use pass and continue
To: Kevin <python.programming at gmail.com>


Hi Kevin,

I generally use pass as a placeholder -

if you have a function that you want to define so you can use it
without creating syntax errors, but you haven't written it yet, it's
just a case of -

def neededFunc(x):
     pass

continue is good.

say you have a loop -

for i in range(10):
      if i % 2 == 0:
          continue
      print i * 3

So, what the loop does, is it gets i, checks if i divided by 2 has
zero remainder and if it does, it continues.

Which, basically means, it doesn't do anything else in the loop (i.e.
print i * 3), it just goes back, get the next value of i, and go
through the loop again.

You'll find you don't need continue that often. It's good for checking
an value in a list you're looping through meets your criteria before
passing it to a big function.

That's about it.

HTH,

Liam Clarke


On Sun, 27 Mar 2005 20:37:02 -0500, Kevin <python.programming at gmail.com> wrote:
> I am having lot of trouble learning where and when to use pass and
> continue. The two books that I use don't explian these very good. Is
> there a website the explains these is great detail?
> I have also looked at the python tutorial as well.
>
> Thanks
>
> Kevin
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>

--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.


-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.


More information about the Tutor mailing list