Re: [Tutor] decision structures

2008-10-20 Thread Brian Lane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 bob gailer wrote: > Brummert_Brandon wrote: >> Hello. I am working with python for computer science this semester. I am >> having a difficult time on one of my lab assignments. It is in the python >> programming book in chapter 7 under decision st

[Tutor] auto referer handler/opener for urlib2?

2008-10-20 Thread xbmuncher
I was reading about urllib2 openers.. Can I make any kind of def or function and make the urllib2 "urlopen" function run through this function first before opening a url? For example, something like a reporthook function. What I want to do is this: def autoReferer(handle): if handle.lastRequest.ur

Re: [Tutor] decision structures

2008-10-20 Thread bob gailer
Brummert_Brandon wrote: Hello. I am working with python for computer science this semester. I am having a difficult time on one of my lab assignments. It is in the python programming book in chapter 7 under decision structures. I am being asked to write a program in that accepts a date in the

[Tutor] decision structures

2008-10-20 Thread Brummert_Brandon
Hello. I am working with python for computer science this semester. I am having a difficult time on one of my lab assignments. It is in the python programming book in chapter 7 under decision structures. I am being asked to write a program in that accepts a date in the form month/date/year

Re: [Tutor] Multiple lists from single list with nested lists

2008-10-20 Thread Kent Johnson
On Mon, Oct 20, 2008 at 5:33 PM, Sander Sweers <[EMAIL PROTECTED]> wrote: > Hi, I am learning myself python and I need to create 2, or more but > let's use 2 as an example, lists from a list with nested lists. > > For example the below, > > ['Test1', 'Text2', ['1', '2'], 'Text3'] > > Should result

Re: [Tutor] String and integer

2008-10-20 Thread wesley chun
>> def nr(): >>nr1 = input('Enter value: ') >>print str(nr1).strip('nr0') >> >> The user input is always on the form "nr08756" and i'd like to take out >> the "nr0" and then print the result. >> I can see that there is a problem with a variable looking like "pn0123" >> because i get: NameEr

Re: [Tutor] String and integer

2008-10-20 Thread bob gailer
Jens Frid wrote: Hi, the code is: def nr(): nr1 = input('Enter value: ') print str(nr1).strip('nr0') The user input is always on the form "nr08756" and i'd like to take out the "nr0" and then print the result. I can see that there is a problem with a variable looking like "pn0123" bec

Re: [Tutor] how to see a number as two bytes

2008-10-20 Thread Alan Gauld
"shawn bright" <[EMAIL PROTECTED]> wrote i have a script that needs to send a number as two bytes. how would i be able to see a number expressed as a hi byte and a lo byte? One way is to use the struct module. It has the advantage of allowing selection of big endian(>) or little endian(<) rep

Re: [Tutor] finding numbers in range of of numbers

2008-10-20 Thread W W
On Mon, Oct 20, 2008 at 5:19 PM, Srinivas Iyyer <[EMAIL PROTECTED]>wrote: > dear group, > a simple question that often challenges me. > > I have > > I have a list of list: > > [[10,45],[14,23],[39,73],[92,135]] > > I want to identify if any of the items in this list are in range of [5,100] > > The

Re: [Tutor] Which exceptions should I be catching?

2008-10-20 Thread W W
On Mon, Oct 20, 2008 at 4:36 PM, Wesley Brooks <[EMAIL PROTECTED]> wrote: > That's why you should write an error log ;) > > > The error log is a valid point. Is there a way to capture the error > messages that go the the terminal window or command prompt rather than all > my print statements? Can

[Tutor] finding numbers in range of of numbers

2008-10-20 Thread Srinivas Iyyer
dear group, a simple question that often challenges me. I have I have a list of list: [[10,45],[14,23],[39,73],[92,135]] I want to identify if any of the items in this list are in range of [5,100] These numbers are large in original data, I will be using xrange for memory issues. thank

Re: [Tutor] Which exceptions should I be catching?

2008-10-20 Thread Wesley Brooks
> > That's why you should write an error log ;) The error log is a valid point. Is there a way to capture the error messages that go the the terminal window or command prompt rather than all my print statements? Can this be set up as a global thing for the whole application rather than inside eac

[Tutor] Multiple lists from single list with nested lists

2008-10-20 Thread Sander Sweers
Hi, I am learning myself python and I need to create 2, or more but let's use 2 as an example, lists from a list with nested lists. For example the below, ['Test1', 'Text2', ['1', '2'], 'Text3'] Should result in, [['Test1', 'Text2', '1', 'Text3'], ['Test1', 'Text2', '2', 'Text3'] I though of u

[Tutor] String and integer

2008-10-20 Thread Jens Frid
Hi,the code is: def nr(): nr1 = input('Enter value: ') print str(nr1).strip('nr0') The user input is always on the form "nr08756" and i'd like to take out the "nr0" and then print the result. I can see that there is a problem with a variable looking like "pn0123" because i get: NameError:

Re: [Tutor] Which exceptions should I be catching?

2008-10-20 Thread W W
On Mon, Oct 20, 2008 at 3:30 PM, Wesley Brooks <[EMAIL PROTECTED]> wrote: > Unfortunately due to the nature of the program the error has normally > happened hours ago and the error message has disappeared from the buffer of > the command prompt. > That's why you should write an error log ;) > >

Re: [Tutor] Fwd: how to see a number as two bytes

2008-10-20 Thread Steve Willoughby
> > high, low = ((num % 2**16) >> 8, num % 2**8) or something thereabouts. My take would be something like high, low = (num >> 8) & 0xff , num & 0xff In case you want another option. This is probably more efficient since you're not raising to powers or taking the modulus, although for all I kn

[Tutor] Which exceptions should I be catching?

2008-10-20 Thread Wesley Brooks
Dear Users, I've got a program that passes messages to another program in the form of empty files, whereby the title of the file is the command. I've been speaking to this board about this before about doing this in the quickest possible way. Even with the code layed out as follows the code still

Re: [Tutor] Can't start IDLE 2.6 on Mac

2008-10-20 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote Unfortunately there is a problem with the Mac release of Python 2.6 and Tkinter (which IDLE uses) does not work correctly. The only fix at this point is to use 2.5 or to build Python yourself. http://bugs.python.org/issue4017 I hope there will be an o

Re: [Tutor] How to clear the screen

2008-10-20 Thread Alan Gauld
"W W" <[EMAIL PROTECTED]> wrote if os.system('cls') == 0: pass elif os.system('clear') == 0: pass else: print '\n' * 80 That should take care of most of your OS' out there... Why raise an error when you can just clear it by brute force? -- Alan Gauld Author of the Learn to Pro

Re: [Tutor] Fwd: how to see a number as two bytes

2008-10-20 Thread Luke Paireepinart
I'm not sure if those values are correct; I can check later tonight, but I'm doing some statechart diagrams for class right now. They sound reasonable but I can't be sure. On Mon, Oct 20, 2008 at 11:20 AM, shawn bright <[EMAIL PROTECTED]> wrote: > jeez, i screwed up, i ment num = 600, not 6 > th

Re: [Tutor] Fwd: how to see a number as two bytes

2008-10-20 Thread Luke Paireepinart
No, I'm not sure what you mean. Given this number 100101010101101011 the operation will slice off bits on the left with the % 2**16 so that we only have 16 bits, 0101010101101011 then it will shift this value to the right so that we only have the highest 8 bits 01010101 that will be stored in hig

Re: [Tutor] Fwd: how to see a number as two bytes

2008-10-20 Thread shawn bright
thanks, Luke, got me started anyway. shawn On Mon, Oct 20, 2008 at 11:23 AM, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > I'm not sure if those values are correct; I can check later tonight, > but I'm doing some statechart diagrams for class right now. They > sound reasonable but I can't be su

Re: [Tutor] Fwd: how to see a number as two bytes

2008-10-20 Thread shawn bright
jeez, i screwed up, i ment num = 600, not 6 thanks On Mon, Oct 20, 2008 at 11:16 AM, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > No, I'm not sure what you mean. > Given this number > > 100101010101101011 > > the operation will slice off bits on the left with the % 2**16 so that > we only have 1

Re: [Tutor] Fwd: how to see a number as two bytes

2008-10-20 Thread shawn bright
so using this, if num ==6, then i should get 2 and 88 ? thanks, just checking to make sure i get what you wrote. shawn On Mon, Oct 20, 2008 at 11:00 AM, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > -- Forwarded message -- > From: Luke Paireepinart <[EMAIL PROTECTED]> > Date: Mon,

[Tutor] Fwd: how to see a number as two bytes

2008-10-20 Thread Luke Paireepinart
-- Forwarded message -- From: Luke Paireepinart <[EMAIL PROTECTED]> Date: Mon, Oct 20, 2008 at 11:00 AM Subject: Re: [Tutor] how to see a number as two bytes To: shawn bright <[EMAIL PROTECTED]> high, low = ((num % 2**16) >> 8, num % 2**8) or something thereabouts. On Mon, Oct 2

[Tutor] how to see a number as two bytes

2008-10-20 Thread shawn bright
hey there all, i have a script that needs to send a number as two bytes. how would i be able to see a number expressed as a hi byte and a lo byte? thanks shawn ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Printing concatenated unicode strings

2008-10-20 Thread Tim Golden
Siim Märtmaa wrote: i would like to do this print u'\u30fa' ヺ with a method like this b = "30fa" uni = u'\u' + b + '\'' but it prints this UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 0-1: end of string in escape sequence so how to concatenate properly to print

[Tutor] Printing concatenated unicode strings

2008-10-20 Thread Siim Märtmaa
Hello i would like to do this >>> print u'\u30fa' ヺ with a method like this b = "30fa" uni = u'\u' + b + '\'' but it prints this UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 0-1: end of string in escape sequence so how to concatenate properly to print the characte

Re: [Tutor] How to clear the screen

2008-10-20 Thread bob gailer
W W wrote: On Mon, Oct 20, 2008 at 3:13 AM, Alan Gauld <[EMAIL PROTECTED] > wrote: "Chris Fuller" <[EMAIL PROTECTED] > wrote want to clear the screen, printing the control sequence ESC[2J is all you need.

Re: [Tutor] How to clear the screen

2008-10-20 Thread W W
On Mon, Oct 20, 2008 at 3:13 AM, Alan Gauld <[EMAIL PROTECTED]>wrote: > "Chris Fuller" <[EMAIL PROTECTED]> wrote > > want to clear the screen, printing the control sequence ESC[2J is all you >> need. >> >> print chr(0x1b) + '[2J' > I don't know if this is the most graceful solution... b

Re: [Tutor] Can't start IDLE 2.6 on Mac

2008-10-20 Thread Kent Johnson
On Sun, Oct 19, 2008 at 5:53 PM, Rob Stevenson <[EMAIL PROTECTED]> wrote: > Hello, > > A slightly different question. I use python on vista but recently bought a > mac laptop running tiger so I could use garageband. > > I decided to put 2.6 on it but even though it installs fine, when I go to > Ap

Re: [Tutor] RUNNING A PROGRAM

2008-10-20 Thread Alan Gauld
"WM" <[EMAIL PROTECTED]> wrote a = "Futzenburgerstein" b = ( 7 + 2 ) / 3 c = b / 2 print a, b, c The above text was copied from a window named "??futz.py-C:\Python26\futz.py" The ?? is two red script characters which I cannot read. When I go 'F5' or Run > Run Module I get kicked back into ID

Re: [Tutor] Can't start IDLE 2.6 on Mac

2008-10-20 Thread Alan Gauld
"Rob Stevenson" <[EMAIL PROTECTED]> wrote I decided to put 2.6 on it but even though it installs fine, when I go to Applications / Python 2.6 and double click IDLE, nothing happens. Does basic Python work? If you open the Terminal application and type python at the prompt does it come up? And

Re: [Tutor] How to clear the screen

2008-10-20 Thread Alan Gauld
"Chris Fuller" <[EMAIL PROTECTED]> wrote want to clear the screen, printing the control sequence ESC[2J is all you need. print chr(0x1b) + '[2J' Only on *nix with a VT100 compatible terminal. Doesn't work for vanilla DOS window or Tektronix mode terminals, 3270 etc. Thats why screen contro

Re: [Tutor] How to clear the screen

2008-10-20 Thread Alan Gauld
"Johnny" <[EMAIL PROTECTED]> wrote In this program, it would be really neat if their was a way to clear the screen off. I have inserrted comments as to where I'd like the screen to be cleared. Such a simple question. Such a complex answer :-) It all depends on what OS and terminal setup you

Re: [Tutor] Creating a single .exe file without py2exe and pyinstaller

2008-10-20 Thread Alan Gauld
"Abah Joseph" <[EMAIL PROTECTED]> wrote I have written a small application of about 40-45 lines which is about 4KB, so I want to create a single .exe file from it, using py2exe it created unnecessary files, that just increase the size of the program and also less portable to me. What kind