Re: [Tutor] 2 problems in a small script

2007-10-12 Thread Ian Witham
On 10/12/07, Dick Moores <[EMAIL PROTECTED]> wrote: > > Please see the code and it's output here: > > > > I'm attempting to eliminate the elements (strings) of lstA that are > not well-formed in that they contain at least one character that is > not i

Re: [Tutor] An idea for a script

2007-10-10 Thread Ian Witham
On 10/11/07, Dick Moores <[EMAIL PROTECTED]> wrote: > > At 04:20 PM 10/10/2007, Dick Moores wrote: > >How about a hint of how to get those ">jcooley<" things from the > >source? (I'm able to have the script get the source, using urllib2.) > > > >BTW I thought I wouldn't try to use BeautifulSoup rig

Re: [Tutor] An idea for a script

2007-10-10 Thread Ian Witham
On 10/11/07, Dick Moores <[EMAIL PROTECTED]> wrote: > > At 02:06 PM 10/10/2007, Ian Witham wrote: > > > On 10/11/07, *Dick Moores* <[EMAIL PROTECTED]> wrote: > I think I could learn a lot about the use of Python with the web by > writing a script that would look

Re: [Tutor] An idea for a script

2007-10-10 Thread Ian Witham
On 10/11/07, Dick Moores <[EMAIL PROTECTED]> wrote: > > I think I could learn a lot about the use of Python with the web by > writing a script that would look at > and find all the links > to more that just the default shown by this one: >

Re: [Tutor] Sqrt on a variable

2007-10-09 Thread Ian Witham
On 10/9/07, samir amassine <[EMAIL PROTECTED]> wrote: > > hello, > i can't seem to use the sqrt function on a variable, do you know how i > can??? > i want to make the ABC formula > > Samir > Hi Samir, You could import sqrt from the math module OR, you can do it without importing anything by rai

Re: [Tutor] print question

2007-10-08 Thread Ian Witham
> > > Thanks! > > So now I have > > def secsToHMS(seconds): > """ > Convert seconds to hours:minutes:seconds, with seconds rounded > to hundredths of a second, and print > """ > hours, minutes = 0, 0 > if seconds >= 60 and seconds < 3600: > minutes, seconds = divmo

Re: [Tutor] print question

2007-10-08 Thread Ian Witham
On 10/9/07, Dick Moores <[EMAIL PROTECTED]> wrote: > > def secsToHMS(seconds): > """ > Convert seconds to hours:minutes:seconds, with seconds rounded > to nearest hundredths of a second, and print > """ > hours, minutes = 0, 0 > if seconds >= 60 and seconds < 3600: >

Re: [Tutor] creating the equivalent of string.strip()

2007-10-03 Thread Ian Witham
On 10/3/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > > "Ricardo Aráoz" <[EMAIL PROTECTED]> wrote > > >sorry, forgot a piece of the code : > > > >s = list(s) > >while s[0].isspace() : > > while s[-1].isspace() : > > del s[-1] > > del s[0] > > s = ''.join(s) > > It still won't work.

Re: [Tutor] Really basic web templating

2007-09-30 Thread Ian Witham
On 10/1/07, wormwood_3 <[EMAIL PROTECTED]> wrote: > > Hello all, > > I am trying to think of a way to make this happen, but it may not be at > all possible:-) I would like to use Python to generate pages on demand for > my website. By this I mean, when someone hits www.mysite.com/pagex.html, I > wa

Re: [Tutor] [tutor] creating image from a given data in wxpython

2007-09-30 Thread Ian Witham
On 10/1/07, Varsha Purohit <[EMAIL PROTECTED]> wrote: > > Hi All, > I basically wanna create a bitmap image in python. This will be > basically in pixels. X and y coordinates will be specified in the program > and python should create an image by matching the colours. I came across a > function

Re: [Tutor] exec sintax error or bug?

2007-09-27 Thread Ian Witham
What version of Python arre you running Paulino? When I run your second snippet on 2.5 I get an error: >>> exp = "if i == 3 : continue" >>> for i in range(5): exec(exp) print i, Traceback (most recent call last): File "", line 2, in exec(exp) File "", line 1 SyntaxError: 'contin

Re: [Tutor] How to adjust a text file...

2007-09-27 Thread Ian Witham
> > > I am trying to write a script that will take the CSV file and output > another text file as follows: > > ID Products > 1a > 1b > 1c > 1d > 1a > 1e > > etc.. for all of the ID's essentially I need to create a single instance > for products for each ID - currently the

Re: [Tutor] How to speed up input/string parsing ...

2007-09-27 Thread Ian Witham
Check the SPOJ Python forums, the process is explained there. It's all about adding two lines of code at the beginning of your script. But I can't recall which two. Ian. On 9/28/07, Aditya Lal <[EMAIL PROTECTED]> wrote: > > Hello Kent, > I tried finding solution with using only strings but unfor

Re: [Tutor] i am stuck...

2007-09-26 Thread Ian Witham
On 9/27/07, Ian Witham <[EMAIL PROTECTED]> wrote: > > On 9/27/07, Chris <[EMAIL PROTECTED]> wrote: > > > > I don't know what to do at this point. I do not have the book, but will > > get > > it just to have... > > > > Can anyone help me?

Re: [Tutor] i am stuck...

2007-09-26 Thread Ian Witham
On 9/27/07, Chris <[EMAIL PROTECTED]> wrote: > > I don't know what to do at this point. I do not have the book, but will > get > it just to have... > > Can anyone help me? > > > Here some more work: > > > > > > guess = 0 > > > > Print ?Pick a number between 0 and 100? > > > > > > While guess != __

Re: [Tutor] home_finance.py

2007-09-25 Thread Ian Witham
On 9/26/07, Christopher Spears <[EMAIL PROTECTED]> wrote: > > I'm working on a problem in Chapter 5 of Core Python > Programming(2nd Edition). I am supposed to write a > script that take an opening balance and a monthly > payment from the user. The script then displays the > balance and payments

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Ian Witham
On 9/26/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > > On Tue, 25 Sep 2007, Ian Witham wrote: > > def numfaczeroes(n): > """ > return the count of trailing zeroes from n! > e.g., 10! = 3628800; count of trailing zeros = 2 > "&qu

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Ian Witham
On 9/26/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > > On Wed, 26 Sep 2007, Ian Witham wrote: > > > My solution still took over 5 seconds on the Sphere Judge machine. > > How much data are they throwing at you? For the sample data they provide > on the websi

Re: [Tutor] Need help speeding up algorithm.

2007-09-25 Thread Ian Witham
> > > from itertools import count, takewhile > > def numfaczeroes2(n): > def while_(e): > return n//(5**e) > 0 > return sum(n//(5**exponent) for exponent in takewhile(while_, > count(1))) > > > It is quite a bit slower, though; probably because of the extra function > call introd

Re: [Tutor] Need help speeding up algorithm.

2007-09-24 Thread Ian Witham
On 9/25/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > > On Tue, 25 Sep 2007, Ian Witham wrote: > > > I am attempting to do this <https://www.spoj.pl/problems/FCTRL/> project > for > > the Sphere Online Judge. > > (Summary of the problem: for a given int

[Tutor] Need help speeding up algorithm.

2007-09-24 Thread Ian Witham
Hello, I am attempting to do this project for the Sphere Online Judge. I think my program is getting the right answer, however it exceeds the 6s time limit on the judge machine. Here is my code: import sys testnums = [] tests = int(sys.stdin.r

Re: [Tutor] (no subject)

2007-09-20 Thread Ian Witham
On 9/21/07, david lazaro <[EMAIL PROTECTED]> wrote: > > the book is called "Python Programming, Second Edition for the absolute > beginner". im using the triple quotes in the beginning and end. im sending > an attachment of what its coming out as. the actual program should say Game > Over, but its

Re: [Tutor] (no subject)

2007-09-20 Thread Ian Witham
On 9/21/07, david lazaro <[EMAIL PROTECTED]> wrote: > > hi, im relatively new to this, im on chapter 2 of the python book and its > asking me to print version 2.0 of "Game over" by using keyboard art, but > when i draw out "over" is comes up half cut off, any reasons why that would > happen? > Ple

Re: [Tutor] Income calculator

2007-09-19 Thread Ian Witham
Your links aren't working for me. On 9/20/07, Ulrich Holtzhausen <[EMAIL PROTECTED]> wrote: > > Hi there, > > I started out with Python about two days ago, it's my very first shot at > programming and I find it quite interesting. Anyway I'll get to the point: > > I made a simple script that works,

Re: [Tutor] sales tax

2007-09-18 Thread Ian Witham
As Michael points out, you need to explicitly use the round function, as the float formatting merely truncates anything after the second decimal place. I ran across a similar problem with the int() fuction early on. Anything after the decimal point is truncated, not rounded, leading to behavior I

Re: [Tutor] [Slightly OT] Inheritance, Polymorphism and Encapsulation

2007-09-18 Thread Ian Witham
On 9/19/07, Stephen Nelson-Smith <[EMAIL PROTECTED]> wrote: > > > "Place the following three in order: Inheritance, Polymorphism, > Encapsulation." > > They specifically did not define in *what* order, leaving that for > the answerer to decide. > I would place them in alphabetical order. BTW, the

Re: [Tutor] remove instances from a list

2007-09-16 Thread Ian Witham
On 9/17/07, Ara Kooser <[EMAIL PROTECTED]> wrote: > > Hello all, > >On my continuing quest to grapple with OO programming Kent showed > me that I could call instances and store them in a list like: > yeasts = > [Yeast("Red_1","Red","ade","lys"),Yeast("Yellow_1","Yellow","lys","ade"), > >

Re: [Tutor] Importing Excel sheet data

2007-09-05 Thread Ian Witham
ish': '', 'add2': 'Grenada Village', 'add1': '13B Mandeville Crescent', 'price': '299000', 'list_number': '8803', 'start': '2.00PM', 'bedrooms': '3', 'date': &

Re: [Tutor] Importing Excel sheet data

2007-09-05 Thread Ian Witham
t; I have read the CSV module. But I felt difficult to write a code for my > requirement. > > Thank You. > > > On 9/5/07, Ian Witham <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > You should look at the 'csv' module in the P

Re: [Tutor] Importing Excel sheet data

2007-09-05 Thread Ian Witham
Hi, You should look at the 'csv' module in the Python Standard Library. If you export your excel data to csv format, you can easily import the data in to python using the csv module. Ian On 9/6/07, saradhi dinavahi <[EMAIL PROTECTED]> wrote: > > hello all, > > I am new to the Python Programming.

Re: [Tutor] indexing elements

2007-09-03 Thread Ian Witham
Hi, I'm not too sure what your asking here, your code assigns the following to endings: ['st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'st'] This is what we would

Re: [Tutor] checking if a number is evan or odd

2007-09-03 Thread Ian Witham
Hi Max, A better way to check if a number is odd or even would be to find the remainder after it is divided by two. for instance: 4 divided by 2 = 2 with 0 remainder 5 divided by 2 = 2 with 1 remainder 6 divided by 2 = 3 with 0 remainder 7

Re: [Tutor] Filemaker interactions

2007-08-28 Thread Ian Witham
xODBC extension. Thanks for the suggestions. On 8/26/07, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: > > On 2007-08-01 23:41, Ian Witham wrote: > > Hello, > > > > I'm hoping someone here can put me on the right track with some broad > > concepts here. > &

Re: [Tutor] tagging pieces of information

2007-08-27 Thread Ian Witham
You may be able to use a dictionary to store your data chunks. eg: >>> tagged_items = {('spam, swordfights'): 'ITEM A', ... ('swordfights', 'custard'): 'ITEM B'} >>> [tagged_items[tags] for tags in tagged_items if 'spam' in tags] ['ITEM A'] >>> [tagged_items[tags] for tags in tagged_items if '

Re: [Tutor] Accesing "column" of a 2D list

2007-08-20 Thread Ian Witham
This looks like a job for List Comprehensions! >>> list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> new_list = [item[1] for item in list] >>> new_list [2, 5, 8] >>> looks good? Ian On 8/21/07, Orest Kozyar <[EMAIL PROTECTED]> wrote: > > I've got a "2D" list (essentially a list of lists where all su

[Tutor] Filemaker interactions

2007-08-01 Thread Ian Witham
Hello, I'm hoping someone here can put me on the right track with some broad concepts here. I've cross-posted this email to the comp.lang.python, I hope that's acceptable. What I am hoping to achieve is a simple HTML page to be served over our company LAN, into which the users (Real Estate Agents

Re: [Tutor] Which GUI?

2007-07-31 Thread Ian Witham
Hi Scott, I'm no expert (yet) but I have come across this fun online tool which helps you choose a GUI toolkit for Python: Choose Your GUI Toolkit I had no problem installing WxPython from the Ubuntu repos, and I have heard that is is one of the top choice

Re: [Tutor] if and things

2007-07-18 Thread Ian Witham
try this: for a in range(10): r, g, b = pixel[1030*(y-a) + x] if g > r and g > b: box += 1 This is an example of "unpacking" a tuple into separate variables, r, g and b. On 7/19/07, elis aeris <[EMAIL PROTECTED]> wrote: # pixel[] is a list of tuples: (r,g,b) # pixel[1030*(y-

Re: [Tutor] odd

2007-07-18 Thread Ian Witham
from Guido's tutorial: The given end point is never part of the generated list; range(10) generates a list of 10 values, the legal indices for items of a sequence of length 10. It is possible to let the range start at another number, or to specify a different increment (even negative; sometimes t