Re: [Tutor] Newbie question - syntax - BeautifulSoup

2010-07-29 Thread Tommy Kaas
Thanks for the explanation. It's clearer now. Tommy "Tommy Kaas" wrote > > > for row in soup('table', {'class' : 'spad'})[0].tbody('tr'): > > > >Do you understand the syntax from a Python point of view? > > No. That's the problem. OK, I'll assume you understand the basic for loop structure and

Re: [Tutor] FTP from mainframe

2010-07-29 Thread Alan Gauld
"Christian Witts" wrote When I'm retrieving items I use retrbinary for eg. The only issue with that is that if this is a real big-iron mainframe then ftp can translate EBCDIC to ASCII during the transfer whereas binary will, I think, bring the original file across untranslated. So you would

Re: [Tutor] FTP from mainframe

2010-07-29 Thread Christian Witts
On 29/07/2010 18:34, Steve Bricker wrote: This is my first attempt to FTP a file from a mainframe. The code: import ftplib session = ftplib.FTP('company.lan.com','userid','passwd') myfile = open('PC.filename','w') session.retrlines("RETR 'mainframe.filename'", myfile) myfile.close() session.qui

Re: [Tutor] finding duplicates within a tuple of tuples

2010-07-29 Thread Norman Khine
Hello, Thanks for the replies. On Thu, Jul 29, 2010 at 7:10 PM, Gregory, Matthew wrote: > Norman Khine wrote: >> basically i have two tables: >> >> id, url >> 24715L, 'http://aqoon.local/muesli/2-muesli-tropical-500g.html' >> 24719L, 'http://aqoon.local/muesli/2-muesli-tropical-500g.html' >> >> i

Re: [Tutor] A better way for greatest common divisor

2010-07-29 Thread David Hutto
On Thu, Jul 29, 2010 at 10:16 PM, James Mills wrote: > On Fri, Jul 30, 2010 at 12:10 PM, James Mills > wrote: >> def gcd(a, b): >>    while b != 0: >>        (a, b) = (b, a%b) >>    return a That was pretty short, and sweet. > > Here's another solution that uses a generator called factors to >

Re: [Tutor] A better way for greatest common divisor

2010-07-29 Thread David Hutto
On Thu, Jul 29, 2010 at 10:36 PM, James Mills wrote: > On Fri, Jul 30, 2010 at 12:22 PM, Richard D. Moores > wrote: >> On Thu, Jul 29, 2010 at 19:10, James Mills >> wrote: >>> On Fri, Jul 30, 2010 at 11:47 AM, David Hutto wrote: This is basically to get feedback, on a better way to show

Re: [Tutor] A better way for greatest common divisor

2010-07-29 Thread James Mills
On Fri, Jul 30, 2010 at 12:22 PM, Richard D. Moores wrote: > On Thu, Jul 29, 2010 at 19:10, James Mills > wrote: >> On Fri, Jul 30, 2010 at 11:47 AM, David Hutto wrote: >>> This is basically to get feedback, on a better way to show the >>> greatest common divisor in fraction, in order to reduce

Re: [Tutor] A better way for greatest common divisor

2010-07-29 Thread Richard D. Moores
On Thu, Jul 29, 2010 at 19:10, James Mills wrote: > On Fri, Jul 30, 2010 at 11:47 AM, David Hutto wrote: >> This is basically to get feedback, on a better way to show the >> greatest common divisor in fraction, in order to reduce it fully, than >> the one I've come up with. I'm sure there are bet

Re: [Tutor] A better way for greatest common divisor

2010-07-29 Thread James Mills
On Fri, Jul 30, 2010 at 12:10 PM, James Mills wrote: > def gcd(a, b): >    while b != 0: >        (a, b) = (b, a%b) >    return a Here's another solution that uses a generator called factors to generate a list of factors for any given value. The gcd function then uses sets and intersection and th

Re: [Tutor] A better way for greatest common divisor

2010-07-29 Thread James Mills
On Fri, Jul 30, 2010 at 11:47 AM, David Hutto wrote: > This is basically to get feedback, on a better way to show the > greatest common divisor in fraction, in order to reduce it fully, than > the one I've come up with. I'm sure there are better ways, so if you > have simpler method, or critique o

[Tutor] A better way for greatest common divisor

2010-07-29 Thread David Hutto
This is basically to get feedback, on a better way to show the greatest common divisor in fraction, in order to reduce it fully, than the one I've come up with. I'm sure there are better ways, so if you have simpler method, or critique of what I've done, let me know. '''Greatest Common Divisor Fu

Re: [Tutor] problem with simple script

2010-07-29 Thread Richard D. Moores
On Wed, Jul 28, 2010 at 08:35, Richard D. Moores wrote: > Now I'll dig into all the help I received. I see an *args in Steven's > detailed reply. That'll take some reviewing to understand. Here's my slight revision of Steven's script (see my note, lines 9-14) -- revised only because I wanted it

Re: [Tutor] FTP from mainframe

2010-07-29 Thread Bill Campbell
On Thu, Jul 29, 2010, bob gailer wrote: > > On 7/29/2010 12:34 PM, Steve Bricker wrote: > > This is my first attempt to FTP a file from a mainframe. The code: > import ftplib The easiest way I've found to get a file via ftp in python is to user urllib, not ftplib. Something like this (

Re: [Tutor] FTP from mainframe

2010-07-29 Thread Alan Gauld
"Steve Bricker" wrote }This is my first attempt to FTP a file from a mainframe. Thats one more than me! The resulting error is: session.retrlines("RETR 'mainframe.filename'", myfile) File "c:python26libftplib.py", line 428, in retrlines callback(line) TypeError: 'file' object is n

Re: [Tutor] FTP from mainframe

2010-07-29 Thread bob gailer
On 7/29/2010 12:34 PM, Steve Bricker wrote: This is my first attempt to FTP a file from a mainframe. The code: import ftplib session = ftplib.FTP('company.lan.com','userid','passwd') myfile = open('PC.filename','w') session.retrlines("RETR 'mainframe.filename'", myfile) myfile.close() session.q

Re: [Tutor] finding duplicates within a tuple of tuples

2010-07-29 Thread Gregory, Matthew
Norman Khine wrote: > basically i have two tables: > > id, url > 24715L, 'http://aqoon.local/muesli/2-muesli-tropical-500g.html' > 24719L, 'http://aqoon.local/muesli/2-muesli-tropical-500g.html' > > id, tid, > 1, 24715L > 2, 24719L > > so i want to first update t(2)'s tid to t(1)'s id for each d

Re: [Tutor] finding duplicates within a tuple of tuples

2010-07-29 Thread Peter Otten
Norman Khine wrote: > hello, > > i have this tuple: > > http://paste.lisp.org/+2F4X > > i have this, which does what i want: > > from collections import defaultdict > > d = defaultdict(set) > for id, url in result: > d[url].add(id) > for url in sorted(d): > if len(d[url]) > 1: > print('%d --

[Tutor] FTP from mainframe

2010-07-29 Thread Steve Bricker
BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }This is my first attempt to FTP a file from a mainframe. The code: import ftplib session = ftplib.FTP('company.lan.com','userid','passwd') myfile = open('PC.filename','w') session.retrlines("RETR 'mainframe.filename'", myfile) myf

[Tutor] finding duplicates within a tuple of tuples

2010-07-29 Thread Norman Khine
hello, i have this tuple: http://paste.lisp.org/+2F4X i have this, which does what i want: from collections import defaultdict d = defaultdict(set) for id, url in result: d[url].add(id) for url in sorted(d): if len(d[url]) > 1: print('%d -- %s' % (len(d[url]), u

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-29 Thread ZUXOXUS
2010/7/28 Dave Angel > ZUXOXUS wrote: > >> >> >> My doubt now is whether I can change the way python show the combinations. >> >> I mean, here's what python actually does: >> >> >> >>> for prod in itertools.product('abc', repeat=3): > > print(prod) >> >> ('a', 'a', 'a') >> ('a', 'a'

Re: [Tutor] Python Help - How to end program

2010-07-29 Thread Alan Gauld
"Jason MacFiggen" wrote Python keeps looping when it gets past the int 0, how do I end the program when it the int 0 or > 0. while True: if mo_hp < 0: print "The Lich King has been slain!" elif my_hp < 0: /etc... When using a while True loop you need ttto have a

Re: [Tutor] A Django Beginner View Question

2010-07-29 Thread Evert Rol
Consider using the django-users Google group for typical Django questions (unless you figure they're really about Python). Will likely get you better or more answers. Anyway: > Hi > > I am building my first Django site which has a lot of effectively 'static' > pages where I just want to make t