Re: [Tutor] Debugging a sort error.

2019-01-14 Thread Cameron Simpson

On 14Jan2019 09:29, mhysnm1...@gmail.com  wrote:
Once again thanks for all the suggestions. It was the input data after 
all. As I am importing three sheets into python. One of the sheets had 
one less column.


Semantic nit: "fewer". "less" is for continuous values.

I've had to deal with loosely defined spreadsheets in the past year, and 
ended up with some mapping classes for reading "heading based" CSV and 
Excel sheets, where the first column contains column headings. It reads 
the rows and constructs a namedtuple class for the rows with field names 
based on the headings and then fills in the fields for each subsequent 
row.


The advantage here is that then you can access the column data by name, 
eg:


 row.description

provided the column heading remains the same. See the xl_import function 
from the cs.csvutils module:


 https://pypi.org/project/cs.csvutils/

The code is here:

 https://bitbucket.org/cameron_simpson/css/src/tip/lib/python/cs/csvutils.py

Right at the bottom of that file is an example use of xl_import() for a 
worksheet where row 1 is a title and the column names are in row 2.


On and forward to start working on text pattern exercise which I always 
have struggled with. Last language I did this in was Perl and had all 
sorts of headaches.  Python seems cleaner from the reading I have 
done thus far. Lets see what challenges wait in front of me.


I used to use Perl extensively. I put off moving to Python for too long.

Cheers,
Cameron Simpson 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging a sort error.

2019-01-13 Thread mhysnm1964
Peter,

Thanks for the code for a custom key. That will come in handy later down the
track.

-Original Message-
From: Tutor  On Behalf Of
Peter Otten
Sent: Sunday, 13 January 2019 10:00 PM
To: tutor@python.org
Subject: Re: [Tutor] Debugging a sort error.

mhysnm1...@gmail.com wrote:

> Issue, following error is generated after trying to sort a list of 
> strings.
> 
> description.sort()
> TypeError: unorderable types: float() < str()

Consider

>>> descriptions = ["foo", "bar", 123, 3.14, 42, 200.1, "0"]
>>> sorted(descriptions)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unorderable types: int() < str()

If there are only numbers and strings in the list you can force the sort to
succeed with the following custom key function:

>>> def key(item):
... return isinstance(item, str), item
... 

This will move the numbers to the beginning of the list:

>>> sorted(descriptions, key=key)
[3.14, 42, 123, 200.1, '0', 'bar', 'foo']


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging a sort error.

2019-01-13 Thread mhysnm1964
All,
Once again thanks for all the suggestions. It was the input data after all. As 
I am importing three sheets into python. One of the sheets had one less column. 
Thus how I ended up with float points. The testing for the string helped here 
greatly.  Now things are correct again. 

On and forward to start working on text pattern exercise which I always have 
struggled with. Last language I did this in was Perl and had all sorts of 
headaches.  Python seems cleaner from the reading I have done thus far. Lets 
see what challenges wait in front of me.




-Original Message-
From: Stephen Nelson-Smith  
Sent: Monday, 14 January 2019 1:15 AM
To: mhysnm1...@gmail.com
Cc: Python Tutor mailing list 
Subject: Re: [Tutor] Debugging a sort error.

Hi,

On Sun, Jan 13, 2019 at 8:34 AM  wrote:

> description.sort()
> TypeError: unorderable types: float() < str()

So, fairly obviously, we can't test whether a float is less than a string.  Any 
more than we can tell if a grapefruit is faster than a cheetah.  So there must 
be items in description that are strings and floats.

With 2000 lines, you're going to struggle to eyeball this, so try something 
like this:

In [69]: irrational_numbers = [3.14159265, 1.606695, "pi", "Pythagoras 
Constant"] In [70]: from collections import Counter In [71]: 
dict(Counter([type(e) for e in irrational_numbers]))
Out[71]: {float: 2, str: 2}

If with your data, this shows only strings, I'll eat my hat.

S.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging a sort error.

2019-01-13 Thread mhysnm1964
Everyone,

I did find out the issue. When looking at the output in a spreadsheet. I was 
inserting floats into the description dictionary from the code I was using to 
extract the data. Thus I have gone back to the drawing board. Rather than 
extracting by columns which became difficult to achieve what I want to do. I am 
now extracting by row and the code has greatly simplified.

Sorry about the data example. AS I am dealing with personal information. I 
don't want to share the original data. I will look at my editor to see if it is 
able to change the indent.

Note: I am a Vision Impaired (blind) person learning to code in Python. Thus 
indents don't really matter to me.  But I will change the indents to make it 
easier to read.

Thanks for the test, this will help greatly.


-Original Message-
From: Cameron Simpson  
Sent: Sunday, 13 January 2019 8:12 PM
To: mhysnm1...@gmail.com
Cc: Tutor@python.org
Subject: Re: [Tutor] Debugging a sort error.

Discussion inline below.

On 13Jan2019 13:16, mhysnm1...@gmail.com  wrote:
>I am hoping someone can help with the below error using Python3.5 in 
>the Windows 10 bash environment. I found the below link which I am not 
>sure if this is related to the issue or not. As I don't fully understand the 
>answer.
>
>https://github.com/SethMMorton/natsort/issues/7

I'm not sure that URL is very relevant, except to the extent that it points out 
that Python 3 issues an error when comparing incomparable types. In Python 2 
this problem could go unnoticed, and that just leads to problems later, much 
farther from the source of the issue.

>Issue, following error is generated after trying to sort a list of strings.
>
>description.sort()
>TypeError: unorderable types: float() < str()
>
>Each list items (elements) contain a mixture of alpha chars, numbers, 
>punctuation chars like / and are in a string type. Below is an example 
>extract of the data from the list.
>
>['Description', 'EFTPOS WOOLWORTHS  1294 ", "withdrawal Hudson
>street 3219"]

The error message says that some of these values are not strings. One at least 
is a float.

My expectation is that the openpyxl module is reading a floating point value 
into your description array. This might be openpxyl being too clever, or it 
might be (more likely IMO) be Excel turning something that looked like a float 
into a float. Spreadsheets can be ... helpful like that.

>There is over 2000 such entries. This used to work and now doesn't.  

You'll need to examine the values. But I see that you're trying to do this. 
I've snipped the data loading phase. Here:

>description = data['Description']
>for i in description:
>  if not str(i):
>print "not a string")

This is not a valid check that "i" is a string. That expression:

  str(i)

tries to convert "i" into a string (via its __str__ method). Most objects have 
such a method, and str() of a float is the textual representation of the float. 
So the if statement doesn't test what you want to test. Try this:

  if not isinstance(i, str):
print("not a string:", i, type(i))

>description.sort()
>I am suspecting it is something to do with the data but cannot track 
>down the cause. Any suggestions on how to debug this?

Your exception is in here, but as you expect you want to inspect the 
description types first.

If the description column does contain a float in the original data then you 
could convert it to a string first! Note that this may not match visually what 
was in the spreadsheet. (BTW, your cited code never fills out the description 
list, not it cannot be current.)

But first, fine out what's wrong. Try the type test I suggest and see how far 
you get.

Cheers,
Cameron Simpson 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging a sort error.

2019-01-13 Thread Stephen Nelson-Smith
Hi,

On Sun, Jan 13, 2019 at 8:34 AM  wrote:

> description.sort()
> TypeError: unorderable types: float() < str()

So, fairly obviously, we can't test whether a float is less than a
string.  Any more than we can tell if a grapefruit is faster than a
cheetah.  So there must be items in description that are strings and
floats.

With 2000 lines, you're going to struggle to eyeball this, so try
something like this:

In [69]: irrational_numbers = [3.14159265, 1.606695, "pi", "Pythagoras
Constant"]
In [70]: from collections import Counter
In [71]: dict(Counter([type(e) for e in irrational_numbers]))
Out[71]: {float: 2, str: 2}

If with your data, this shows only strings, I'll eat my hat.

S.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging a sort error.

2019-01-13 Thread Peter Otten
mhysnm1...@gmail.com wrote:

> Issue, following error is generated after trying to sort a list of
> strings.
> 
> description.sort()
> TypeError: unorderable types: float() < str()

Consider

>>> descriptions = ["foo", "bar", 123, 3.14, 42, 200.1, "0"]
>>> sorted(descriptions)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unorderable types: int() < str()

If there are only numbers and strings in the list you can force the sort to 
succeed with the following custom key function:

>>> def key(item):
... return isinstance(item, str), item
... 

This will move the numbers to the beginning of the list:

>>> sorted(descriptions, key=key)
[3.14, 42, 123, 200.1, '0', 'bar', 'foo']


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging a sort error.

2019-01-13 Thread Steven D'Aprano
On Sun, Jan 13, 2019 at 01:16:10PM +1100, mhysnm1...@gmail.com wrote:

> Issue, following error is generated after trying to sort a list of strings.
> 
> description.sort()
> TypeError: unorderable types: float() < str()

That tells you that you don't have a list of strings. You have a list of 
strings with at least one float mixed in.


> There is over 2000 such entries. This used to work and now doesn't. Only
> change to the code was modifying the data variable from a list to a
> dictionary.

I doubt that. Anytime people say "nothing changed except..." it 
invariably turns out to be "oh yeah, these other ten things changed 
too..." 

*wink*



> Below is the full code:

Not it isn't, because the code you supply has at least one syntax error. 
So it is impossible for it to be the actual code you are running.

In any case, we are volunteers, not paid consultants. If you want to pay 
us $200 an hour to debug your code, you get to dump a big ball of mud in 
our laps and say "fix it". But as volunteers, we have no obligation to 
trawl through your code trying to debug it (unless it looks interesting, 
or easy, or we're bored and looking for something to do...)

To maximize your chances of people actually helping, please read this:

http://www.sscce.org/


Having said that, I have spotted one obvious bug:

> description = data['Description']
> 
> for i in description:
>   if not str(i):
> print "not a string")

(See what I mean about a syntax error?)

That does not do what you think it does. My *guess* is that you are 
trying to check that every item in description is a string. But that's 
not what you do: you run through the items, make a string copy of each 
one (regardless of what kind of object it is) and then test whether the 
string is not the empty string (which it never will be, unless the 
original was the empty string).

Instead, try this:

for item in description:
if not isinstance(item, str):
print(type(item), repr(item), "is not a string")



-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging a sort error.

2019-01-13 Thread Cameron Simpson

Discussion inline below.

On 13Jan2019 13:16, mhysnm1...@gmail.com  wrote:
I am hoping someone can help with the below error using Python3.5 in 
the Windows 10 bash environment. I found the below link which I am not sure if

this is related to the issue or not. As I don't fully understand the answer.

https://github.com/SethMMorton/natsort/issues/7


I'm not sure that URL is very relevant, except to the extent that it 
points out that Python 3 issues an error when comparing incomparable 
types. In Python 2 this problem could go unnoticed, and that just leads 
to problems later, much farther from the source of the issue.



Issue, following error is generated after trying to sort a list of strings.

description.sort()
TypeError: unorderable types: float() < str()

Each list items (elements) contain a mixture of alpha chars, numbers,
punctuation chars like / and are in a string type. Below is an example
extract of the data from the list.

['Description', 'EFTPOS WOOLWORTHS  1294 ", "withdrawal Hudson
street 3219"]


The error message says that some of these values are not strings. One at 
least is a float.


My expectation is that the openpyxl module is reading a floating point 
value into your description array. This might be openpxyl being too 
clever, or it might be (more likely IMO) be Excel turning something that 
looked like a float into a float. Spreadsheets can be ... helpful like 
that.


There is over 2000 such entries. This used to work and now doesn't.  


You'll need to examine the values. But I see that you're trying to do 
this. I've snipped the data loading phase. Here:



description = data['Description']
for i in description:
 if not str(i):
   print "not a string")


This is not a valid check that "i" is a string. That expression:

 str(i)

tries to convert "i" into a string (via its __str__ method). Most 
objects have such a method, and str() of a float is the textual 
representation of the float. So the if statement doesn't test what you 
want to test. Try this:


 if not isinstance(i, str):
   print("not a string:", i, type(i))


description.sort()
I am suspecting it is something to do with the data but cannot track 
down the cause. Any suggestions on how to debug this?


Your exception is in here, but as you expect you want to inspect the 
description types first.


If the description column does contain a float in the original data then 
you could convert it to a string first! Note that this may not match 
visually what was in the spreadsheet. (BTW, your cited code never fills 
out the description list, not it cannot be current.)


But first, fine out what's wrong. Try the type test I suggest and see 
how far you get.


Cheers,
Cameron Simpson 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging a sort error.

2019-01-13 Thread Alan Gauld via Tutor
On 13/01/2019 02:16, mhysnm1...@gmail.com wrote:

> Issue, following error is generated after trying to sort a list of strings.
> 
> description.sort()
> TypeError: unorderable types: float() < str()


Please send the complete error message not just the
last line summary. There is a lot of potentially
useful information in the missing lines.

> ['Description', 'EFTPOS WOOLWORTHS  1294 ", "withdrawal Hudson
> street 3219"] 

That doesn't look right. The quotes are all mixed
up and miss-matched. Can you send an actual example?

> There is over 2000 such entries. This used to work and now doesn't. Only
> change to the code was modifying the data variable from a list to a
> dictionary.

The data variable appears to only have one entry, namely "Amount".
Is that what you intended?

 Below is the full code:
> 
>  
> 
> import openpyxl 
> 
> from openpyxl.utils import get_column_letter
> 
> from  more_itertools import unique_everseen
> 
>  
> 
> # Loding the workbook and names for the sheets.
> 
> wb = openpyxl.load_workbook("test.xlsx")
> 
> wss = wb.get_sheet_names()
> 
>  
> 
> description = [] # all the descriptions
> 
> data = {}
> 
>  
> 
> for ws_name in wss:
> 
>   ws = wb.get_sheet_by_name(ws_name)
> 
>   for column in ws.columns:
> 
>col_data = [] # column list
> 
>for cell in column:
> 
>  value = cell.value
> 
>  col_data.append(value)
> 
># end for cell loop
> 
>if ws_name == "WestPac":
> 
>  if col_data[0] == 'Credit Amount':
> 
>num = 1
> 
>while num <=
> (len(col_data) - 1):
> 
>  value =
> col_data[num]
> 
>  if
> value:
> 
>  
> data['Amount'][num] = value
> 
>  else:
> 
>  
> data['Amount'][num] = data['Amount'][num] * -1
> 
>  num +=
> 1
> 
># end while num 
> 
>break
> 
>  # end if 
> 
># end if
> 
>if col_data[0] in data:
> 
>  
> data[col_data[0]].extend(col_data[1:-1])
> 
>else:
> 
>  data[col_data[0]] = col_data
> 
>   # end for column
> 
> #end for ws_name 
> 
>  
> 
> description = data['Description']

You try to assign data["Description"] but you never populated
that in the code above. You only ever used data["Amount"].


> for i in description:
>   if not str(i):
> print "not a string")

I'm not sure what you think that's doing but the print should
give a syntax error if you are using Python 3.5 as you claim.
You need parens around it. Can you cut n paste the actual code?

Also, it is unlikely to ever print anything because most
things can be converted to a string.

However, given that description is supposed to contain
lists of values I suspect you need another inner loop
to convert the list contents.

I think you wanted something like:

for lst in description:
for i in lst:
   if type(i) is not str:
  print(i, "is not a string")

> description.sort()
> 
> I am suspecting it is something to do with the data but cannot track down
> the cause. Any suggestions on how to debug this?

Send the full error and some genuine data and try
the modified type test loop above.

Oh, and using smaller indentation will make it more
readable too. 3-4 spaces is the usual size.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Debugging a sort error.

2019-01-13 Thread mhysnm1964
Hello everyone.

 

I am hoping someone can help with the below error using Python3.5 in the
Windows 10 bash environment. I found the below link which I am not sure if
this is related to the issue or not. As I don't fully understand the answer.

https://github.com/SethMMorton/natsort/issues/7

 

Issue, following error is generated after trying to sort a list of strings.

 

description.sort()
TypeError: unorderable types: float() < str()

 

Each list items (elements) contain a mixture of alpha chars, numbers,
punctuation chars like / and are in a string type. Below is an example
extract of the data from the list.

 

['Description', 'EFTPOS WOOLWORTHS  1294 ", "withdrawal Hudson
street 3219"] 

 

There is over 2000 such entries. This used to work and now doesn't. Only
change to the code was modifying the data variable from a list to a
dictionary. Below is the full code:

 

import openpyxl 

from openpyxl.utils import get_column_letter

from  more_itertools import unique_everseen

 

# Loding the workbook and names for the sheets.

wb = openpyxl.load_workbook("test.xlsx")

wss = wb.get_sheet_names()

 

description = [] # all the descriptions

data = {}

 

for ws_name in wss:

  ws = wb.get_sheet_by_name(ws_name)

  for column in ws.columns:

   col_data = [] # column list

   for cell in column:

 value = cell.value

 col_data.append(value)

   # end for cell loop

   if ws_name == "WestPac":

 if col_data[0] == 'Credit Amount':

   num = 1

   while num <=
(len(col_data) - 1):

 value =
col_data[num]

 if
value:

 
data['Amount'][num] = value

 else:

 
data['Amount'][num] = data['Amount'][num] * -1

 num +=
1

   # end while num 

   break

 # end if 

   # end if

   if col_data[0] in data:

 
data[col_data[0]].extend(col_data[1:-1])

   else:

 data[col_data[0]] = col_data

  # end for column

#end for ws_name 

 

description = data['Description']

for i in description:

  if not str(i):

print "not a string")

description.sort()

 

I am suspecting it is something to do with the data but cannot track down
the cause. Any suggestions on how to debug this?

 

Sean 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging in Python

2015-11-17 Thread John Wong
On Mon, Nov 16, 2015 at 12:48 PM, Alan Gauld 
wrote:
>
>
> The correct fix is to exit() from the python3 shell and start it again.
>>
>
> He's tried that and didn't find it satisfactory. That's why
> he wants a "better" workflow.
>
> Alternatively, add some main code at the end of your file and use
>> `python3 hlibert.py`:
>>
>> if __name__ == '__main__':
>>  hilbert(3)
>>
>
> That depends on the nature of his module and the type of testing he wants
> to do. He could, I agree, create a new test file that imports hilbert and
> then add his test code there but that loses the interactivity of a shell
> prompt which may be important.


Yeah, the only way you can actually keep trying is to write some kind of
test script. It doesn't have to be using any testing library. i.e. whatever
code you throw at the console for testing can be written down in another
python file. I call that a scratch pad. Obviously a proper test is
desirable. I too recommend investing time in that.

Doesn't matter whether you use a scratch pad or not, you can use PDB as
your debugger. I often use it to step into my code and hold on the
execution. I often do this when I need to inspect what an object instance
can do...

for example:

main.py

def main():
import pdb; pdb.set_trace()
file_object = some_complex_code_written_by_someone_else()
do_stuff_with_file_object(file_object)

main()


Now when I run main.py, I get an interpreter session inside the PDB
debugger (it's similar to GDB if you have written C/C++ code). I can now
type  dir(file_object), play with file_object, or step inside code to
inspect errors. Hope this helps.

Thanks.

John
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging in Python

2015-11-16 Thread Chris Warrick
On 16 November 2015 at 15:43, Alan Gauld  wrote:
> Thats not an IDE its just a raw interpreter.
> IDLE is a full IDE that includes a debugger.

It’s an awful piece of garbage that pretends to be an IDE.

>> I encountered some error in the source , then I fixed it and tried to run
>> the module with the above snippet again , but the the error prevails even
>> though the error part is commented and the updated version saved.
>
>
> You need to reload the module but sadly there is no simple command to do
> that in the interpreter. There is in IDLE ("Restart Shell" menu item)
>
> So if you use IDLE your issues will be resolved. You can install
> IDLE3 from the Ubuntu package manager.

No, they won’t. They will be replaced by a much worse and less
friendly IDE. Please don’t bother installing IDLE and use the normal
`python3` shell, ipython or bpython.

The correct fix is to exit() from the python3 shell and start it again.
Alternatively, add some main code at the end of your file and use
`python3 hlibert.py`:

if __name__ == '__main__':
hilbert(3)

-- 
Chris Warrick 
PGP: 5EAAEA16
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Debugging in Python

2015-11-16 Thread Sajjadul Islam
Hello forum,

I am trying Python 3.4 on Ubuntu and I am a bit confused with the debugging
scope of python in general.

I wrote a small function and then I tried to run with the following call:

///

import hilbert
hilbert.hilbert(3)

///

Please note that , I am not using the IDLE IDE. Instead I am using the
typical IDE that shows up with the command "python3" in the linux command
line.

I encountered some error in the source , then I fixed it and tried to run
the module with the above snippet again , but the the error prevails even
though the error part is commented and the updated version saved.

If I get out of the python3 console entirely, get into it again, import the
module and execute, then the last update in the source is effected.


Why is it so clumsy ? I believe that there is better way to program in
python which I am missing ?


Thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging in Python

2015-11-16 Thread Alan Gauld

On 16/11/15 09:55, Sajjadul Islam wrote:

Hello forum,

I am trying Python 3.4 on Ubuntu and I am a bit confused with the debugging
scope of python in general.

I wrote a small function and then I tried to run with the following call:

///

import hilbert
hilbert.hilbert(3)

///

Please note that , I am not using the IDLE IDE. Instead I am using the
typical IDE that shows up with the command "python3" in the linux command
line.


Thats not an IDE its just a raw interpreter.
IDLE is a full IDE that includes a debugger.


I encountered some error in the source , then I fixed it and tried to run
the module with the above snippet again , but the the error prevails even
though the error part is commented and the updated version saved.


You need to reload the module but sadly there is no simple command to do 
that in the interpreter. There is in IDLE ("Restart Shell" menu item)


So if you use IDLE your issues will be resolved. You can install
IDLE3 from the Ubuntu package manager.


Why is it so clumsy ? I believe that there is better way to program in
python which I am missing ?


Use IDLE :-)
Or any of the other IDEs.

Alternatively use multiple windows.
I personally prefer to have a vim window for editing the code and
a separate terminal for running it. But that assumes I have a
main file and can just type

$ python myfile.py.

In the terminal.

If I'm only creating a module I use the IDLE shell instead of the
terminal window.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging in Python

2015-11-16 Thread Alan Gauld

On 16/11/15 15:42, Chris Warrick wrote:

On 16 November 2015 at 15:43, Alan Gauld  wrote:

Thats not an IDE its just a raw interpreter.
IDLE is a full IDE that includes a debugger.


It’s an awful piece of garbage that pretends to be an IDE.


Would you care to expand. Its been doing a fair impression
for the past 20 odd years. And in its IDLEX incarnation most
of the niggles have been removed. It's not Eclipse but it
doesn't pretend to be. But for beginners like the OP its
adequate IMHO. Certainly easier than the raw interpreter
prompt.


You need to reload the module but sadly there is no simple command to do
that in the interpreter. There is in IDLE ("Restart Shell" menu item)

So if you use IDLE your issues will be resolved. You can install
IDLE3 from the Ubuntu package manager.


No, they won’t. They will be replaced by a much worse and less
friendly IDE. Please don’t bother installing IDLE and use the normal
`python3` shell, ipython or bpython.


He's tried the normal shell and that didn't work for him.
iPython and bPython are certainly other more advanced options
but he needs to install them too and both have a steeper
learning curve for the average user than IDLE.


The correct fix is to exit() from the python3 shell and start it again.


He's tried that and didn't find it satisfactory. That's why
he wants a "better" workflow.


Alternatively, add some main code at the end of your file and use
`python3 hlibert.py`:

if __name__ == '__main__':
 hilbert(3)


That depends on the nature of his module and the type of testing he 
wants to do. He could, I agree, create a new test file that imports 
hilbert and then add his test code there but that loses the 
interactivity of a shell prompt which may be important.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging While Loops for Control

2012-02-17 Thread Alan Gauld

On 17/02/12 03:27, Luke Thomas Mergner wrote:



In the meantime, and continuing my problem of over-cleverness,


At least you know what your problem is :-)



Bonus question: when I create a the def score(self) in class Hand,

 should that be an generator?

No.


And if so where do I go as a newb to understand generators?


The documentation.
Or Google python generator tutorial howto


I'm really not understanding them yet.


You don't need to for what you are doing.


 The x for x in y: syntax makes it harder to follow for learners,


Read about list comprehensions first.
It helps if you studied sets in math at school. The format is
somewhat like the math notation for defining a set. But FWIW it took me 
a long time to get used to that syntax too.




Some thoughts


class Card(object):
def __init__(self):
self.score = self.deal()

def deal(self):
deal a card from 1 to 52 and return it's points
return self.getValue(int(math.floor(random.uniform(1, 52


I think you only need random.randint(1,52) here. It simplifies it quite 
a lot! But you still have the problem that you might wind up with two 
identical cards! It might be better to create a deck(list) of 52 cards, 
shuffle() them and then pop the value off of that deck.



def getValue(self, card):
Converts the values 1 - 52 into a 1 - 13 and returns the correct blackjack 
score based on remainder.
if (card % 13 == 0 or card % 13 == 11 or card % 13 == 12):
#Face Cards are 10 points
return 10
elif (card % 13 == 1):
return 11
else:
#Regular cards, return their value
return card % 13


Just calculate the value once rather than doing a mod division each 
time. Much more efficient and easier to read.



def showCard(self):
return repr(self.score)


Why are you using repr? Why not just return the integer value?


class Hand:
def __init__(self):
self.cards = []
#Add cards this way to avoid duplicates.
for i in range(2):
self.cards.append(Card())


What makes you think it will avoid duplicates? The card values are 
generated at random.



def hit(self):
self.cards.append(Card())



def showHand(self):
return self


This seems fairly pointless. If i already have a reference to an object 
why would I call a method that returns what I already have? Maybe 
returning self.cards would make sense. But really the Hand class should 
do whatever is needed to cards so even that doesn't make sense. The only 
thing this could usefully do is pretty print the cards in a formatted 
string.




def score(self):
#how do you sum(objects) ???


You could define an __add__() method on your cards so that Card()+Card() 
returns an integer. (Or you could use a generator

here if you really, really wanted to. But the __add__ method
is cleaner IMHO)


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging While Loops for Control

2012-02-17 Thread Robert Sjoblom
 class Card(object):
        def __init__(self):
                self.score = self.deal()

        def deal(self):
                deal a card from 1 to 52 and return it's points
                return self.getValue(int(math.floor(random.uniform(1,
 52

 I think you only need random.randint(1,52) here. It simplifies it quite a
 lot! But you still have the problem that you might wind up with two
 identical cards! It might be better to create a deck(list) of 52 cards,
 shuffle() them and then pop the value off of that deck.

I'd suggest using random.sample() instead, but it might just be a
matter of style:

 from random import sample
 deck = range(1,53)
 sample(deck, 2)
[43, 9]
 sample(deck, 2)
[8, 27]

It's a function a lot of people doesn't know about, for some reason.
Best part is that it leaves deck (or whatever population you're taking
the sample from) alone, so you don't have to rebuild it every time you
want to reset the deck. Ah, but I suppose you want to keep track of
what cards are available, too. Forgot about that part. I guess you can
do:
sample(deck, 52) #or instead of deck range(1,53)
for each new round, and pop items from the returned sample instead of
popping the deck list every time. In the end I suppose it's a matter
of style. Oh, and the returned list is in selection order (which might
be important but maybe not in Black Jack). Maybe I should have just
stayed quiet.
-- 
best regards,
Robert S.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging While Loops for Control

2012-02-17 Thread Peter Otten
Alan Gauld wrote:

The x for x in y: syntax makes it harder to follow for learners,
 
 Read about list comprehensions first.
 It helps if you studied sets in math at school. The format is
 somewhat like the math notation for defining a set. But FWIW it took me
 a long time to get used to that syntax too.

To grok list comprehensions it helps to write the equivalent for loops 
first. You can mechanically convert

items = []
for x in abcd:
if x  d:
if x != b:
items.append(x)

to

items = [x for x in abcd if x  d if x != b]

The for loops and ifs stay in place, the expression passed to append() in 
the innermost loop moves to the beginning. Another example:

items = []
for x in abcd:
if x  d:
for y in x + x.upper():
if y != A:
items.append(y*2)

This becomes

items = [y*2 for x in abcd if x  d for y in x + x.upper() if y != A]

Real-world list comprehensions tend to be less complicated, but to 
understand them you just have to reverse the conversion:

items = [y*2 
for x in abcd 
if x  d 
for y in x + x.upper() 
if y != A
# append y*2
]


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging While Loops for Control

2012-02-16 Thread Alan Gauld

On 16/02/12 04:57, Luke Thomas Mergner wrote:


My problem is that I am using two functions that return True or False

 to determine whether the player receives another card.


Because of the way it evaluates the while condition, it either

 prints too little information or previously called the hitMe()
 function too many times.


I am assuming that I am misusing the while loop in this case.



while ask_for_raw_input() AND is_the_score_over_21():
hitMe(hand)


I haven't looked at the code for the functions but going
by their names I'd suggest you need to reverse their order to

while is_the_score_over_21() and ask_for_raw_input():
hitMe(hand)

The reason is that the first function will always get called
but you (I think) only want to ask for, and give out, another
card if the score is over 21 (or should that maybe be
*under* 21?).

Personally I would never combine a test function with
an input one. Its kind of the other side of the rule that
says don't don;t put print statements inside logic functions.
In both cases its about separating himan interaction/display from 
program logic. So I'd make the ask_for_raw_input jusat return a value(or 
set of values) and create a new funtion to test

the result and use that one in the while loop.

HTH,
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging While Loops for Control

2012-02-16 Thread Luke Thomas Mergner
 
 --
 
 Message: 1
 Date: Wed, 15 Feb 2012 23:57:08 -0500
 From: Luke Thomas Mergner lmerg...@gmail.com
 To: tutor@python.org
 Subject: [Tutor] Debugging While Loops for Control
 Message-ID: a8bdf988-fe78-4ca1-8cb7-c0a0e68fd...@gmail.com
 Content-Type: text/plain; charset=us-ascii
 
 Hi,
 
 I've been translating and extending the Blackjack project from 
 codeacademy.com into Python. My efforts so far are here: 
 https://gist.github.com/1842131
 
 My problem is that I am using two functions that return True or False to 
 determine whether the player receives another card.  Because of the way it 
 evaluates the while condition, it either prints too little information or 
 previously called the hitMe() function too many times.  I am assuming that I 
 am misusing the while loop in this case. If so, is there an elegant 
 alternative still running the functions at least once.
 
 e.g. 
 while ask_for_raw_input() AND is_the_score_over_21():
   hitMe(hand)
 
 
 Any advice or observations are appreciated, but please don't solve the whole 
 puzzle for me at once! And no, not all the functionality of a real game is 
 implemented. The code is pretty raw. I'm just a hobbyist trying to learn a 
 few things in my spare time.
 
 Thanks in advance.
 
 Luke
 
 --
 
 Message: 2
 Date: Thu, 16 Feb 2012 09:05:39 +
 From: Alan Gauld alan.ga...@btinternet.com
 To: tutor@python.org
 Subject: Re: [Tutor] Debugging While Loops for Control
 Message-ID: jhigt3$jdp$1...@dough.gmane.org
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 
 On 16/02/12 04:57, Luke Thomas Mergner wrote:
 
 My problem is that I am using two functions that return True or False
 to determine whether the player receives another card.
 
 Because of the way it evaluates the while condition, it either
 prints too little information or previously called the hitMe()
 function too many times.
 
 I am assuming that I am misusing the while loop in this case.
 
 while ask_for_raw_input() AND is_the_score_over_21():
  hitMe(hand)
 
 I haven't looked at the code for the functions but going
 by their names I'd suggest you need to reverse their order to
 
 while is_the_score_over_21() and ask_for_raw_input():
   hitMe(hand)
 
 The reason is that the first function will always get called
 but you (I think) only want to ask for, and give out, another
 card if the score is over 21 (or should that maybe be
 *under* 21?).
 
 Personally I would never combine a test function with
 an input one. Its kind of the other side of the rule that
 says don't don;t put print statements inside logic functions.
 In both cases its about separating himan interaction/display from 
 program logic. So I'd make the ask_for_raw_input jusat return a value(or 
 set of values) and create a new funtion to test
 the result and use that one in the while loop.
 
 HTH,
 -- 
 Alan G
 Author of the Learn to Program web site
 http://www.alan-g.me.uk/


Alan (and list),

Thanks for the advice. It at least points me to an answer: I'm trying to be too 
clever for my experience level. I am going to go back and incorporate your 
suggestions.

In the meantime, and continuing my problem of over-cleverness, I was trying to 
rethink the program in classes.  With the caveat that I'm only a few hours into 
this rethinking, I've added the code below. My question is: when I want to 
build in a return self into the Hand class, which is made up of the card 
class; how do I force a conversion from card object into integer object which 
is all the card class is really holding? Should I make the class Card inherit 
from Integers? or is there a __repr__ def I don't understand yet? 

Bonus question: when I create a the def score(self) in class Hand, should 
that be an generator? And if so where do I go as a newb to understand 
generators? I'm really not understanding them yet.  The x for x in y: syntax 
makes it harder to follow for learners, even if I appreciate brevity.


Thanks in advance,
Luke


class Card(object):
def __init__(self):
self.score = self.deal()

def deal(self):
deal a card from 1 to 52 and return it's points
return self.getValue(int(math.floor(random.uniform(1, 52

def getValue(self, card):
Converts the values 1 - 52 into a 1 - 13 and returns the 
correct blackjack score based on remainder.
if (card % 13 == 0 or card % 13 == 11 or card % 13 == 12):
#Face Cards are 10 points
return 10
elif (card % 13 == 1):
return 11
else:
#Regular cards, return their value
return card % 13

def showCard(self):
return repr(self.score)

class Hand:
def __init__

[Tutor] Debugging While Loops for Control

2012-02-15 Thread Luke Thomas Mergner
Hi,

I've been translating and extending the Blackjack project from codeacademy.com 
into Python. My efforts so far are here: https://gist.github.com/1842131

My problem is that I am using two functions that return True or False to 
determine whether the player receives another card.  Because of the way it 
evaluates the while condition, it either prints too little information or 
previously called the hitMe() function too many times.  I am assuming that I am 
misusing the while loop in this case. If so, is there an elegant alternative 
still running the functions at least once.

e.g. 
while ask_for_raw_input() AND is_the_score_over_21():
hitMe(hand)


Any advice or observations are appreciated, but please don't solve the whole 
puzzle for me at once! And no, not all the functionality of a real game is 
implemented. The code is pretty raw. I'm just a hobbyist trying to learn a few 
things in my spare time.

Thanks in advance.

Luke
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Debugging, other

2008-11-01 Thread Jennifer Miller
Hello,

I would like to step through with debugging in PythonWin, I have added
this toolbar, but I cannot click on it as an option.  Also, when I
click run, to define the arguments, do I enter them in the format
name, name?  Also, when I try to run my code, I get a message at the
bottom of the screen that says, Failed to run script - syntax error -
expected an indented block.  I am not sure where I am going wrong here
- maybe if I could do the debugging, that would help.

Thanks,

Python Beginner
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging, other

2008-11-01 Thread W W
On Sat, Nov 1, 2008 at 11:21 AM, Jennifer Miller [EMAIL PROTECTED]wrote:

 Hello,

 I would like to step through with debugging in PythonWin, I have added
 this toolbar, but I cannot click on it as an option.  Also, when I
 click run, to define the arguments, do I enter them in the format
 name, name?  Also, when I try to run my code, I get a message at the
 bottom of the screen that says, Failed to run script - syntax error -
 expected an indented block.  I am not sure where I am going wrong here
 - maybe if I could do the debugging, that would help.


It helps to post the exact error message.

For instance:


  File stdin, line 2
print x
^
IndentationError: expected an indented block

came from this entered into the interactive interpreter:

 for x in xrange(1,10):
... print x

Because after a for statement, it expects an indentation. It's considered
standard to indent with four spaces.

My guess is there's something in your code that caused such an error. The
more information you give us, the better we are able to help you.

HTH,
Wayne
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging, other

2008-11-01 Thread bob gailer

Jennifer Miller wrote:

Hello,

I would like to step through with debugging in PythonWin, I have added
this toolbar, but I cannot click on it as an option.  
cannot click on it is pretty vague. Is your mouse broken? Or do you 
mean that nothing happens when you click.

Also, when I click run, to define the arguments, do I enter them in the format
name, name?  

the same as you would do at a command or shell prompt: name name

Also, when I try to run my code, I get a message at the
bottom of the screen that says, Failed to run script - syntax error -
expected an indented block.  
As Wayne said check the indentation. When you get a syntax error the 
program failed to compile. It does not get to execute, so debugging is 
not available.


The cursor should be on the line where the problem was detected.

I am not sure where I am going wrong here
- maybe if I could do the debugging, that would help.
  
Press shift-ctrl-C to error check the program. To set breakpoints: put 
the cursor on a line then click the hand icon or press F9. Press F5 to 
run the program, or F11 to start it and suspend at the first line.

Thanks,

Python Beginner
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

  



--
Bob Gailer
Chapel Hill NC 
919-636-4239


When we take the time to be aware of our feelings and 
needs we have more satisfying interatctions with others.


Nonviolent Communication provides tools for this awareness.

As a coach and trainer I can assist you in learning this process.

What is YOUR biggest relationship challenge?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Debugging

2007-02-08 Thread Toon Pieton

Hey friendly users!

I have a question considering debugging: is it possible to get the current
code line that is being executed?

Thanks in advance!
Toon Pieton
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging

2007-02-08 Thread John Fouhy
On 09/02/07, Toon Pieton [EMAIL PROTECTED] wrote:
 Hey friendly users!

 I have a question considering debugging: is it possible to get the current
 code line that is being executed?

Are you using pdb [the python debugger]?

If you have a script 'myscript.py', you can start the script like this:

  python -m pdb myscript.py

You can then set breakpoints and step through the code line-by-line using pdb.

(brief summary:

'break module:line' -- set breakpoint, eg: 'break mymodule:23'
'r' -- run program
'n' -- move to next line
's' -- move to next line, or step into function call
'c' -- continue running until next breakpoint
'p' -- print; used to inspect variables, etc.
)

Note that pdb has difficulties with multithreaded programs.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Debugging multithreaded programs in python

2006-08-01 Thread Noufal Ibrahim
Greetings all,
A friend here is trying to debug a rather badly written python program
which spawns off lots of threads here and there.  Are there any
frameworks that I can reccommend that would ease his pain?

On a more general note, it seems rather strange that I can't quickly
google and find a debugger for multithreaded python programs. Python's
batteries included philosophy has always been very useful to me.
I've always managed to find what I need without any hassles. This is
the first exception. Any insights? Are there any decent ways to debug
a multi threaded program which make a debugger redundant?

Peace.
-- 
-NI

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging multithreaded programs in python

2006-08-01 Thread Kent Johnson
Noufal Ibrahim wrote:
 Greetings all,
 A friend here is trying to debug a rather badly written python program
 which spawns off lots of threads here and there.  Are there any
 frameworks that I can reccommend that would ease his pain?
   
winpdb claims to debug multi-threaded programs. I have found it useful 
for single-threaded programs, haven't tried it for m-t.
http://www.digitalpeers.com/pythondebugger/

Debugging m-t programs can be very hard. Placing a breakpoint can change 
the timing so a bug doesn't appear, or ruin a critical response time. 
Print statements can help.

You say the program is badly written, if it uses more threads than 
needed maybe the first step is to get rid of some of them. You could 
also look for subsystems that could be tested independently, perhaps 
using unittest.

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Debugging method

2006-02-20 Thread Kermit Rose









Kermit have you actually bothered going through any tutorials? You just seem to be asking every time you get an error, I know the list is here for people to ask questions but you really should try and work some things out for yourself. Traceback (most recent call last): File "pyshell#8", line 1, in -toplevel- v = transfac(v) File "c:\math\factoring\factor30.py", line 46, in transfac  a,b,c,d,m,n = a,b.c+a*t,d-b*t,m+t,nAttributeError: 'int' object has no attribute 'c'
Your problem here is that you have b.c instead of what I presume should be a comma. b.c means that it's trying to find the method c of the integer b which doesn't exist. 

Thank you very much.


Actually, I have been working things out myself. The many questions I've sent you are only a fraction of the
problems I've encountered while developing this program.

The tutorials are helpful only if I know what to look for.

For this particular error message, I had no clue that "has no attribute" is a hint that a period is typed where
it should not be.

Now I know how to interpret that particular error message should it occur in the future.

I had looked the code over. I knew to look on that line, but was totally baffled because I could not distinguish the 
comma from the period.

Kermit  [EMAIL PROTECTED] 




















___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging method

2006-02-20 Thread Alan Gauld
 I had looked the code over.  I knew to look on that line,   but was 
 totally
 baffled because I could not distinguish the
 comma from the period.

You are using IDLE right?
It sounds like you might need to change the font if the difference is
not clear because that's a pretty important difference! Try the Options
dialogue.

Alan G. 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Debugging in emacs

2004-12-27 Thread Alan Gauld
Marilyn,

I seemed to have missed the start of this one, but which debugger
are you trying to use? There is plain ole Python pdb, the IDLE
debugger and the Pythonwin debugger (and probably more!)

The pdb debugger is fashioned on the gdb debugger and works
very like that if you've ever sen it before? THe pdb help
system works that way too.

  Debugging in emacs is obviously not the hottest topic around here.

You should be able to use the standard pdb features, and
the emacs shortcuts are just that - shortcuts. So try the
long hand commands first.

  1. Add the following to your program:
  import pdb
  pdb.set_trace()
  2. Start an interactive Python buffer (C-c !)

I'd go with the import but set_trace isn't necessary to
use pdb. My normal way of using pdb is to ipport both
it and my module, then *run* the module.

 import pdb, mymodule
 pdb.run('mymodule.myfunction(aParameter)')
some output here
(pdb)


 If I set a breakpoint, then 'c'/'continue' doesn't work.  Instead of
 continuing, it only goes one step.

Set the breakpoint using b and a function name

(pdb) b mymodule.somefunc

notice no parems, just the name

then c for contnue (usually a few times (2 or 3) to get past the
internal pdb bits)

(pdb) c
some location verbiage here
the line of code pdb is on
(pdb)

Now you can start using the print command to check state etc,
up to navigate the call stack, 'step' into functions and 'next'
over them etc...

 I am using regular ole raw emacs, on a plain terminal, no X.  Are
you?

 How are you doing with this?  I could sure use a debugger.

pdb is OK, although IDLE is better and Pythonwin is better
still - they are graphical debuggers...

FWIW there is a very short intro to both pdb and IDLE in my book...
I seem to recall that Mark Lutz has a chapter onpdb in
Programming Python too.

Alan G.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


RE: [Tutor] Debugging in emacs

2004-12-26 Thread Marilyn Davis
Hi Toby, 

You still here?  I'm finally trying (again) to get debugging going.

On Mon, 22 Nov 2004, McLaughlin, Toby wrote:

 Thanks Marilyn,
 
 Debugging in emacs is obviously not the hottest topic around here.
 
 Luckily, I have something working now.  For anyone who is interested,
 here is the trick:
 
 1. Add the following to your program:
   import pdb
   pdb.set_trace()
 2. Start an interactive Python buffer (C-c !)

This doesn't seem to do anything.  But, when I run my program, after
following step 1.,  I'm in the debugger.  And it is a beautiful sight.

 3. Run your program (I use C-c C-c)
 
 Emacs picks up the line numbers from set_trace() and marks the
 appropriate line in the source buffer.  You can now type 'n' to single
 step, as well as issue any of the pdb commands mentioned here:
 http://tinyurl.com/3na4u .

If I set a breakpoint, then 'c'/'continue' doesn't work.  Instead of
continuing, it only goes one step.

If I don't set a breakpoint, then continue does work.  But that's no
use.

 
 The only trouble I have now is that the Python buffer and my source code
 keep switching places from top to bottom.  A minor annoyance that
 hopefully I will rectify soon.

This doesn't happen to me.

I am using regular ole raw emacs, on a plain terminal, no X.  Are you?

How are you doing with this?  I could sure use a debugger.

Marilyn

 
 Toby McLaughlin.
 
  -Original Message-
  From: Marilyn Davis [mailto:[EMAIL PROTECTED] 
  Sent: Saturday, 20 November 2004 9:28 AM
  To: McLaughlin, Toby
  Cc: tutor@python.org
  Subject: Re: [Tutor] Debugging in emacs
  
  
  On Fri, 19 Nov 2004, McLaughlin, Toby wrote:
  
   Hi All,
   
   Could somebody suggest a way to debug python in emacs?  I'd 
  like to be
   able to single-step while seeing the code marked in some way and
   possiblly set breakpoints.  I read about using pdb from the 
  command line
   but would love to have debugging integrated in emacs.  
  Perhaps I should
   make life easy for myself and use one of the fancy GUI 
  editors, but I
   think it's character building for me to learn emacs.
  
  Boy, you could hear a pin drop on this topic.
  
  I use emacs, even though I have spent some time with idle, because I
  like it much better.  I'm real handy in emacs though, and I don't like
  mousing.  Mice cause lots of repetitive stress injury.
  
  I spent some time and some email conversations trying to make use of
  the debugger in any environment.  I don't remember what happened
  exactly but I gave up.
  
  The thing about an interpreted language is that you can say print
  my_var in the code instead of in the debugger.  And with emacs, I go
  back and forth between my code and the emacs shell to run it.  I'm
  pretty efficient that way.
  
  If anyone has any suggestions about debugging, in idle or anywhere, I
  too would love to hear them.
  
  Thank you.
  
  Marilyn Davis
  
  
   
   Thanks,
   Toby McLaughlin.
   ___
   Tutor maillist  -  Tutor@python.org
   http://mail.python.org/mailman/listinfo/tutor
   
  
  -- 
  
  
 

-- 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor