By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,743 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,743 IT Pros & Developers. It's quick & easy.

How do I use Code Context under Options in IDLE?

P: n/a
Hi all,
I have this Code Context feature under Options in the IDLE.
How should I use it? Are there folks here who use it regularly and find
it useful.
Please guide me.

Thanks!
Senthil

Apr 17 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Phoe6 wrote:
Hi all,
I have this Code Context feature under Options in the IDLE.
How should I use it? Are there folks here who use it regularly and find
it useful.
Please guide me.
Well, you could start by looking at the Help:

Options Menu:

Configure IDLE -- Open a configuration dialog. Fonts, indentation,
keybindings, and color themes may be altered.
Startup Preferences may be set, and Additional Help
Souces can be specified.
---
Code Context -- Open a pane at the top of the edit window which
shows the block context of the section of code
which is scrolling off the top or the window.

But what does that actually mean?

Take this code fragment example (with line numbers added
for reference)

1 import collatz_functions as cf
2
3 def makepath(dstart,cstart,pattern,reps):
4 print pattern
5 alphabet = '
123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmno pqrstuvwxyz'
6 # fopen('pathmade.lst', WRITE,TEXT)
7 coeff = dstart
8 oldcoeff = coeff/3
9 const = cstart
10 print 'coeff %d const %d oldcoeff %d' % (coeff,const,oldcoeff)
11 for i in xrange(1,reps+1):
12 print 'i',i
13 for j in xrange(1,len(pattern)):
14 print 'j',j
15 currstep = alphabet.index(pattern[j])
16 print 'currstep',currstep
17 while currstep>2:
18 coeff = 4 * coeff
19 const = 4 * const
20 currstep = currstep - 2
21 print 'coeff %d const %d currstep %d' %
(coeff,const,currstep)
22 if currstep==1:

The moment line 3 scrolls off the top of the edit window, it appears
in the code context window. This tells you that the current line at
the top of the screen is in line 3's scope. When line 11 scrolls off,
it appears in the code context window showing you that the current
lines are now in the scope of the for loop.

By the time you reach line 18, your code context window looks like
(line 3 has scrolled off the code context window):

11 for i in xrange(1,reps+1):
13 for j in xrange(1,len(pattern)):
17 while currstep>2:

Allowing you to see where line 18 is in the big picture. The moment
I scroll past line 21, line 17 drops off the code context window
showing me that my scope is now back to that of line 13.

And no, I don't use it regulary because I wasn't even aware of it
until you asked.

Thanks!
Senthil


Apr 17 '06 #2

P: n/a
me********@aol.com wrote:
---
Code Context -- Open a pane at the top of the edit window which
shows the block context of the section of code
which is scrolling off the top or the window.

But what does that actually mean?

Take this code fragment example (with line numbers added
for reference)


That explaination was very helpful and cleared my doubts.

Thanks a lot.

Regards,
Senthil

Apr 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.