tutor@python.org

2010-02-14 Thread Alan Gauld
"Steven D'Aprano" wrote They are not gone however there are still 32 bits in an integer so the top bits *should* be set to zero. No, Python ints are not 32 bit native ints. They're not even 64 bit ints. Python has unified the old "int" type with "long", so that ints automatically grow as n

tutor@python.org

2010-02-14 Thread Steve Willoughby
On Sun, Feb 14, 2010 at 09:16:18AM -, Alan Gauld wrote: > But ths is not simple integer arithmetic it is bit m,anippulation. > You can use bit manipulation to fake arithmetic but they are > fundamentally different operations and may not always > produce the same results depending on how the

[Tutor] Editing html using python

2010-02-14 Thread Amit Sethi
Hi I need to edit html programmatically . Sadly the html might be broken at places . I was using BeautifulSoup but there were lots of problems and it is also not maintained can some one guide me to any tutorials on editing html using lxml . -- A-M-I-T S|S _

Re: [Tutor] Getting caller name without the help of "sys._getframe(1).f_code.co_name" ?

2010-02-14 Thread patrice laporte
2010/2/13 Luke Paireepinart > > > On Sat, Feb 13, 2010 at 9:56 AM, patrice laporte wrote: > >> >> Hi, >> >> Being in an exeption of my own, I want to print the name of the caller, >> and I'm looking for a way to have it. >> >> Could you tell us exactly why you want to do this? It seems sort of >

Re: [Tutor] Getting caller name without the help of "sys._getframe(1).f_code.co_name" ?

2010-02-14 Thread Luke Paireepinart
I see why you would want the error messages but why is the default error message not enough, that is why I am curious, and typically introspection on objects is not necessary (for example, people often want to convert a string into a variable name to store a value (say they have the string "foobar1

Re: [Tutor] Editing html using python

2010-02-14 Thread Luke Paireepinart
On Sun, Feb 14, 2010 at 5:10 AM, Amit Sethi wrote: > Hi I need to edit html programmatically . Sadly the html might be broken at > places . I was using BeautifulSoup but there were lots of problems and it is > also not maintained can some one guide me to any tutorials on editing html > using lxml

Re: [Tutor] Getting caller name without the help of "sys._getframe(1).f_code.co_name" ?

2010-02-14 Thread Kent Johnson
On Sun, Feb 14, 2010 at 6:33 AM, patrice laporte wrote: > - try/catch open(this_file_name) and if I got an IOErro exception, I > re-raise my own exception with : >- the name of the class where that IOError occured >- the name of the method in that class that make that error occured >-

Re: [Tutor] Editing html using python

2010-02-14 Thread Kent Johnson
On Sun, Feb 14, 2010 at 6:10 AM, Amit Sethi wrote: > Hi I need to edit html programmatically . Sadly the html might be broken at > places . I was using BeautifulSoup but there were lots of problems and it is > also not maintained can some one guide me to any tutorials on editing html > using lxml

Re: [Tutor] file exception & behaviour (was: Getting caller name...)

2010-02-14 Thread spir
On Sun, 14 Feb 2010 12:33:09 +0100 patrice laporte wrote: > 2010/2/13 Luke Paireepinart > > > > > > > On Sat, Feb 13, 2010 at 9:56 AM, patrice laporte > > wrote: > > > >> > >> Hi, > >> > >> Being in an exeption of my own, I want to print the name of the caller, > >> and I'm looking for a way t

tutor@python.org

2010-02-14 Thread spir
Just reviewed this post and wonder whether the explanation is clear for anyone else as myself ;-) Denis On Sat, 13 Feb 2010 23:17:27 +0100 spir wrote: > On Sat, 13 Feb 2010 13:58:34 -0500 > David Abbott wrote: > > > I am attempting to understand this little program that converts a > > networ

tutor@python.org

2010-02-14 Thread spir
On Sun, 14 Feb 2010 09:16:18 - "Alan Gauld" wrote: > In the case in point the & 255 keeps the coding style consistent > and provides an extra measure of protection against unexpected > oddities so I would keep it in there. You're right on that, Kent. My comment was rather wrong. Especially

Re: [Tutor] Getting caller name without the help of "sys._getframe(1).f_code.co_name" ?

2010-02-14 Thread Steven D'Aprano
On Sun, 14 Feb 2010 10:33:09 pm patrice laporte wrote: > I got a class that takes a file name in its __init__ method (it > could be elsewhere, but why not here ?). Then, somewhere in that > class, a method will do something with that file name, such as "try > to open that file". > > If the file

Re: [Tutor] command error help

2010-02-14 Thread Shurui Liu (Aaron Liu)
SyntaxError: EOL while scanning single-quoted string. 2010/2/14 Shurui Liu (Aaron Liu) > Here is a program I need to run in putty.exe, but there is an error in it. > I cannot find out. When I ran this program, it mentions that the error is in > red line.It shows that "SyntaxError: EOL while

[Tutor] command error help

2010-02-14 Thread Shurui Liu (Aaron Liu)
Here is a program I need to run in putty.exe, but there is an error in it. I cannot find out. When I ran this program, it mentions that the error is in red line. Would you please help me? Thank you! # Useless Trivia # # Gets personal information from the user and then # prints true, but useless i

Re: [Tutor] command error help

2010-02-14 Thread Alan Gauld
"Shurui Liu (Aaron Liu)" wrote SyntaxError: EOL while scanning single-quoted string. Yes, that sounds about right. But it doesn't add much. Can you print the entifre error message not just that single line? Or Here is a program I need to run in putty.exe, but there is an error in it. I

Re: [Tutor] Getting caller name without the help of"sys._getframe(1).f_code.co_name" ?

2010-02-14 Thread Alan Gauld
"patrice laporte" wrote Maybe the fact I'm à pure C coder for a longtime prevent me from thinking in Python, ... And now, something different : what I want to do, and why. Based on that last line I think your brain is well on the way to thinking like a Python programmer! :-) Others have ad

[Tutor] try MySQLdb Error

2010-02-14 Thread Grigor Kolev
Hi. I want to catch MySQL error. This is my code. #!/usr/bin/env python #-*- coding:utf-8 -*- # Copyright 2009 Grigor Kolev # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by #

[Tutor] A Stuborn Tab Problem in IDLE

2010-02-14 Thread Wayne Watson
When I use F5 to execute a py program in IDLE, Win7, I get a tab error on an indented else. I've selected all and untabifed with 4 spaces several times, and get the same problem. I've tried re-typing the line with zero results. What next? I had been modifying the program repeatedly over several

Re: [Tutor] A Stuborn Tab Problem in IDLE

2010-02-14 Thread Steven D'Aprano
On Mon, 15 Feb 2010 09:19:35 am Wayne Watson wrote: > When I use F5 to execute a py program in IDLE, Win7, I get a tab > error on an indented else. I've selected all and untabifed with 4 > spaces several times, and get the same problem. I've tried re-typing > the line with zero results. What next?

tutor@python.org

2010-02-14 Thread Steven D'Aprano
On Sun, 14 Feb 2010 08:16:18 pm Alan Gauld wrote: > >> But glitches can occur from time to time... > > > > If Python had a glitch of the magnitude of right-shifting non-zero > > bits into a number, that would be not just a bug but a HUGE bug. > > Bit shifting is machine specific. Pardon me, but

Re: [Tutor] A Stuborn Tab Problem in IDLE

2010-02-14 Thread Wayne Watson
I'm not sure it's postable or attachable for this mail list. I'll give it a try. Attachments do work with other lists. On 2/14/2010 2:51 PM, Steven D'Aprano wrote: On Mon, 15 Feb 2010 09:19:35 am Wayne Watson wrote: When I use F5 to execute a py program in IDLE, Win7, I get a tab error on

tutor@python.org

2010-02-14 Thread Alan Gauld
"Steven D'Aprano" wrote Pardon me, but that's incorrect. Python is not assembly, or C, and the behaviour of bit shifting in Python is NOT machine specific. http://docs.python.org/library/stdtypes.html#bit-string-operations-on-integer-types In Python, a left shift of n MUST return the equivale

Re: [Tutor] A Stuborn Tab Problem in IDLE

2010-02-14 Thread Alan Gauld
"Wayne Watson" wrote When I use F5 to execute a py program in IDLE, Win7, I get a tab error on an indented else. What happens if you execute from a command line? Do you get the same error? If so look at the lines before. If not try closing and restarting IDLE HTH, Alan G _

Re: [Tutor] A Stuborn Tab Problem in IDLE

2010-02-14 Thread Wayne Watson
I rebooted, and no change. I saved it under a new name, and no change. I tried to activate it as a file, and it put up a screen and down that I had no chance to read it. Since I have been on W7 for a month, have no clue as how to run it from a command line. I'll check with help, and report bac

Re: [Tutor] A Stuborn Tab Problem in IDLE

2010-02-14 Thread Wayne Watson
Well, command line was easy to get to. It's on the menu for python, but it gives me >>>. How do I get to the folder with the py file? Can I switch to a c:\ type operation? Back to exploring. On 2/14/2010 5:05 PM, Alan Gauld wrote: "Wayne Watson" wrote When I use F5 to execute a py progra

Re: [Tutor] A Stuborn Tab Problem in IDLE

2010-02-14 Thread Wayne Watson
I got to the dos command line facility and got to the file. I executed the program, and it failed with a syntax error. I can't copy it out of the window to paste here, but here's the code surrounding the problem: (arrow ==> points at the problem. The console code shows [ missing. I SEE the synta

Re: [Tutor] A Stuborn Tab Problem in IDLE

2010-02-14 Thread Dave Angel
Wayne Watson wrote: I got to the dos command line facility and got to the file. I executed the program, and it failed with a syntax error. I can't copy it out of the window to paste here, but here's the code surrounding the problem: (arrow ==> points at the problem. The console code shows [ mi

Re: [Tutor] A Stuborn Tab Problem in IDLE

2010-02-14 Thread Wayne Watson
Thanks for the reminder on that. I haven't need the DOS box for 8 months. Just off on other non-programming efforts for the most part. Things have picked up of late. I was beginning to think for awhile that Win7 might have dropped it. I don't see any changes to it. On 2/14/2010 7:01 PM, Dave A