Re: [Tutor] String and integer

2008-10-21 Thread Jens Frid
Thank you all!Very informative and much appreciated! Regards, Jens On Tue, Oct 21, 2008 at 1:33 AM, wesley chun <[EMAIL PROTECTED]> wrote: > >> def nr(): > >>nr1 = input('Enter value: ') > >>print str(nr1).strip('nr0') > >> > >> The user input is always on the form "nr08756" and i'd like

[Tutor] How to compute performance of python program

2008-10-21 Thread rajasekhar mamilla
Hi tutors, Iam relatively new to python. I developed a project in python,now i want to know the performance of my code. Can i know how much time each python file takes or each program or each loop takes to get executed. Please help me if any such ways are available or any other ways using whi

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

2008-10-21 Thread Alan Gauld
"Srinivas Iyyer" <[EMAIL PROTECTED]> wrote [[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] Sorry, I have no idea what you mean by that. Can you give an example of passing and failing tests? For example do any/all of the elements

Re: [Tutor] decision structures

2008-10-21 Thread Alan Gauld
"Brummert_Brandon" <[EMAIL PROTECTED]> wrote Hello. I am working with python for computer science this semester. I am having a difficult time on one of my lab assignments We won't do your homework for you but we can offer specific help for specific queries. But you need to help us help you.

Re: [Tutor] How to compute performance of python program

2008-10-21 Thread Alan Gauld
"rajasekhar mamilla" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi tutors, Iam relatively new to python. I developed a project in python,now i want to know the performance of my code. Look at the timeit command and the profiling module. Very simple profile example here:

Re: [Tutor] auto referer handler/opener for urlib2?

2008-10-21 Thread Kent Johnson
On Tue, Oct 21, 2008 at 12:05 AM, xbmuncher <[EMAIL PROTECTED]> wrote: > 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.

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

2008-10-21 Thread Richard Lovely
Guessing you mean [5,100] as the inclusive interval notation, so all but the last element of the example pass? if any(True for x, y in listoflists if 5 <= x and y <= 100): #do stuff does this do it for you? Or if you want to know if any elements of the lists within the larger list are within

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

2008-10-21 Thread Kent Johnson
On Tue, Oct 21, 2008 at 8:47 AM, Richard Lovely <[EMAIL PROTECTED]> wrote: > Guessing you mean [5,100] as the inclusive interval notation, so all > but the last element of the example pass? > > if any(True for x, y in listoflists if 5 <= x and y <= 100): > #do stuff or if any((5 <= x and y <= 10

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

2008-10-21 Thread Srinivas Iyyer
Dear Alan and tutors, I apologize for careless description of my problem that lead to confusion. the problem arises due to large range of numbers and range has direction (both ascending and descending). I am giving an example from my real problem. What I want to do: I want to check if a[.][1

Re: [Tutor] decision structures

2008-10-21 Thread bob gailer
Please reply to the tutor list, not just to me. We all learn and many of us can help. Brummert_Brandon wrote: This is what I have so far. I am still confused by the string.split setup. Thank you. # dateCheck.py # A program that accepts a date in the form month/day/year and outputs whether

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

2008-10-21 Thread bob gailer
Srinivas Iyyer wrote: Dear Alan and tutors, I apologize for careless description of my problem that lead to confusion. the problem arises due to large range of numbers and range has direction (both ascending and descending). I am giving an example from my real problem. What I want to do

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

2008-10-21 Thread ALAN GAULD
a = [['xa','1511255', '1511279'],['xb','7516599','7516623'],['xc','98356290','98356266']] b = [['G1','1511200','1511325'],['G2','7516500','7516625'],['G3','98356335','98356126']] >>> for item1 in a: ... i1st = int(item1[1]) ... i1en = int(item1[2]) ... for item2 in b: ...

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

2008-10-21 Thread Kent Johnson
On Tue, Oct 21, 2008 at 10:43 AM, bob gailer <[EMAIL PROTECTED]> wrote: > I would make a copy of each list; take a pass thru each copy, convert the > strings to integers and reverse the descending pairs. > > a1 = [['xa', 1511255, 1511279],['xb', 7516599, 7516623],['xc', 98356266, > 98356290]] > >

[Tutor] appending to a utf-16 encoded text file

2008-10-21 Thread Tim Brown
Hi, I'm trying to create and append unicode strings to a utf-16 text file. The best I could come up with was to use codecs.open() with an encoding of 'utf-16' but when I do an append I get another UTF16 BOM put into the file which other programs do not expect to see :-( Is there some way to stop

[Tutor] Providing Solutions for all the Common Questions

2008-10-21 Thread Calvin Spealman
There was a discussion in the #python channel over at freenode about the common questions we seem to field daily. These often revolve around problems a lot of people need solutions for, and for which we have specific answers to we always give. A lot of times this leads to teeth grinding as we try t

Re: [Tutor] appending to a utf-16 encoded text file

2008-10-21 Thread Tim Golden
Tim Brown wrote: Hi, I'm trying to create and append unicode strings to a utf-16 text file. The best I could come up with was to use codecs.open() with an encoding of 'utf-16' but when I do an append I get another UTF16 BOM put into the file which other programs do not expect to see :-( Is the

Re: [Tutor] Providing Solutions for all the Common Questions

2008-10-21 Thread vishwajeet singh
That seems to be nice idea. we can look into mailing archives and pick problems from there. Congratulations and thanks for nice initiative. keep the good work On Tue, Oct 21, 2008 at 10:06 AM, Calvin Spealman <[EMAIL PROTECTED]>wrote: > There was a discussion in the #python channel over at free

Re: [Tutor] Providing Solutions for all the Common Questions

2008-10-21 Thread Hansen, Mike
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Calvin Spealman > Sent: Tuesday, October 21, 2008 8:07 AM > To: tutor@python.org > Subject: [Tutor] Providing Solutions for all the Common Questions > > There was a discussion in the #python chan

Re: [Tutor] appending to a utf-16 encoded text file

2008-10-21 Thread Kent Johnson
On Tue, Oct 21, 2008 at 9:52 AM, Tim Brown <[EMAIL PROTECTED]> wrote: > Hi, > I'm trying to create and append unicode strings to a utf-16 text file. > The best I could come up with was to use codecs.open() with an > encoding of 'utf-16' but when I do an append I get another UTF16 BOM > put into the

Re: [Tutor] Providing Solutions for all the Common Questions

2008-10-21 Thread Kent Johnson
On Tue, Oct 21, 2008 at 10:06 AM, Calvin Spealman <[EMAIL PROTECTED]> wrote: > There was a discussion in the #python channel over at freenode about the > common questions we seem to field daily. > We've decided to come here to organize this, as it seems to fit. Welcome. Please subscribe to the lis

Re: [Tutor] Providing Solutions for all the Common Questions

2008-10-21 Thread Scott Nelson
To throw out an idea... http://www.showmedo.com/ is a site that believes that learning-by-watching is a very effective way to teach people new skills. So, they host lots of (user-generated) screencasts (usually 5-10 minutes) that show people how to do things. Because the site is Python focused,

[Tutor] Python 2.4 threading

2008-10-21 Thread Ertl, John C CIV 63134
Classification: UNCLASSIFIED Caveat (s): FOUO All, I have a program that basically loops through two loops and I wanted to speedup the stuff inside the second loop so I thought threading would be a good idea but I am having a hard time getting it to work. All of the examples I have seen that

Re: [Tutor] appending to a utf-16 encoded text file

2008-10-21 Thread Jerry Hill
On Tue, Oct 21, 2008 at 9:52 AM, Tim Brown <[EMAIL PROTECTED]> wrote: > Hi, > I'm trying to create and append unicode strings to a utf-16 text file. > The best I could come up with was to use codecs.open() with an > encoding of 'utf-16' but when I do an append I get another UTF16 BOM > put into the

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

2008-10-21 Thread Richard Lovely
I felt I need to appolgise for my first post in this thread... I don't have internet access, and I've yet to find a public computer with Python, so I'm unable to test any code I write. I'm going have to discpline myself not to post to here unless its: a) a problem of my own, or b) an answer that

Re: [Tutor] Python 2.4 threading

2008-10-21 Thread Kent Johnson
On Tue, Oct 21, 2008 at 1:04 PM, Ertl, John C CIV 63134 <[EMAIL PROTECTED]> wrote: > Classification: UNCLASSIFIED > Caveat (s): FOUO > > All, > > I have a program that basically loops through two loops and I wanted to > speedup the stuff inside the second loop so I thought threading would be a > go

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

2008-10-21 Thread Kent Johnson
On Tue, Oct 21, 2008 at 2:26 PM, Richard Lovely <[EMAIL PROTECTED]> wrote: > I felt I need to appolgise for my first post in this thread... I don't know why... > I don't have internet access, and I've yet to find a public computer > with Python, so I'm unable to test any code I write. I'm going

[Tutor] Python in a web browser (was Re: finding numbers in range of of numbers)

2008-10-21 Thread Jerry Hill
On Tue, Oct 21, 2008 at 2:26 PM, Richard Lovely <[EMAIL PROTECTED]> wrote: > I don't have internet access, and I've yet to find a public computer > with Python, so I'm unable to test any code I write. I'm going have > to discpline myself not to post to here unless its: a) a problem of my > own, or

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

2008-10-21 Thread shawn bright
Thanks for all your help on this, gents. found what works. shawn On Mon, Oct 20, 2008 at 6:06 PM, Alan Gauld <[EMAIL PROTECTED]>wrote: > "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

Re: [Tutor] decision structures

2008-10-21 Thread bob gailer
Perhaps someone else will help you. I won't offer anything more until you respond to a lot more of my questions and comments. AND PLEASE reply to tutor@python.org as well as whoever responds to you. Brummert_Brandon wrote: I have written other programs for the assignment. Here is a progra

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

2008-10-21 Thread Sander Sweers
On Tue, Oct 21, 2008 at 01:36, Kent Johnson <[EMAIL PROTECTED]> wrote: >> somelist = ['Test1', 'Text2', ['1', '2'], 'Text3'] >> templist = [] >> for x in range(len(somelist[2])): >>templist.append([somelist[0], somelist[1], somelist[2][x], somelist[3]]) > > Is it always just the third item that

Re: [Tutor] decision structures

2008-10-21 Thread christopher . henk
> Perhaps someone else will help you. I won't offer anything more until you respond to a lot more of my questions and comments. > Read what Bob has written back to you and try it or ask questions related to it if you don't understand something he said. > AND PLEASE reply to tutor@python.org as

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

2008-10-21 Thread Luke Paireepinart
Nice mention of the struct module, Alan. I had forgotten about it and I just finished an app that really could've been simplified by it. I might retool it to use struct when I have to revisit it for the next part of my class assignment. On Tue, Oct 21, 2008 at 3:34 PM, shawn bright <[EMAIL PROTE

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

2008-10-21 Thread Kent Johnson
On Tue, Oct 21, 2008 at 5:09 PM, Sander Sweers <[EMAIL PROTECTED]> wrote: > This did not work but the below did ;-) > templist = [ somelist[:1] + [x] + somelist[3:] for x in somelist[2] ] somelist[:1] doesn't include somelist[1] so I think you are missing one element of your original list. List

Re: [Tutor] appending to a utf-16 encoded text file

2008-10-21 Thread Mark Tolonen
"Tim Golden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Tim Brown wrote: Hi, I'm trying to create and append unicode strings to a utf-16 text file. The best I could come up with was to use codecs.open() with an encoding of 'utf-16' but when I do an append I get another UTF16

[Tutor] (no subject)

2008-10-21 Thread amit sethi
Hi can any body give me an example as to how i can use Incremental Parser in xml.sax -- A-M-I-T S|S ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor