how to check the 'content/type' using urlopen

2007-04-15 Thread John
i have the following code to open a URL address, but can you please tell me how can I check the content type of the url response? Thank you. try: req = Request(url, txdata, txheaders) handle = urlopen(req) except IOError, e: print e print 'Failed to open %s'

Re: Getting started with python

2007-04-15 Thread James Stroud
Gabriel Genellina wrote: > En Sun, 15 Apr 2007 10:46:54 -0300, Army1987 <[EMAIL PROTECTED]> escribió: > >> "Paddy" <[EMAIL PROTECTED]> ha scritto nel messaggio >> news:[EMAIL PROTECTED] >> >>> On a different tack, from: >>> http://tickletux.wordpress.com/2007/01/24/using-fizzbuzz-to-find-developer

Re: is laziness a programer's virtue?

2007-04-15 Thread Cor Gest
Some entity, AKA [EMAIL PROTECTED], wrote this mindboggling stuff: (selectively-snipped-or-not-p) > Of course, for functional languages, 'lazy' means something rather > different... > lazy means: just get a post-grad to do the grunt-work for free. Cor -- The biggest problem LISP has is that

working of round()

2007-04-15 Thread Krishna . K . 1900
Does round() always perfectly return the output expected or are there some artifacts which don't allow perfect functionality Using python 2.5: >>> round(12.234, 2) 12.23 >>> round(12.234, 3) 12.234 >>> round(12.234, 1) 12.199 >>> but was expecting 12.2 Also, for round(x,n), can't 'x'

Re: Portably generating infinity and NaN

2007-04-15 Thread Robert Kern
Paul Rubin wrote: > I doubt any Crays are still running, or at least > running any numerical code written in Python. You are wrong. > Same for VMS. Also wrong. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad at

Re: working of round()

2007-04-15 Thread Robert Kern
[EMAIL PROTECTED] wrote: > Does round() always perfectly return the output expected or are there > some artifacts which don't allow perfect functionality > > Using python 2.5: round(12.234, 2) > 12.23 round(12.234, 3) > 12.234 round(12.234, 1) > 12.199 > > but was expec

Re: Portably generating infinity and NaN

2007-04-15 Thread Steve Holden
Paul Rubin wrote: > [EMAIL PROTECTED] writes: >> But PEP 754 will only work for architectures supporting IEEE 754. I realize >> that's the vast majority of systems, but aren't there still a few Crays and >> VMS machines out there? (Do those architectures support NaN and Inf?) > > I wouldn't worr

Re: how to strip the domain name in python?

2007-04-15 Thread Steve Holden
[EMAIL PROTECTED] wrote: > On Apr 15, 11:57 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> In <[EMAIL PROTECTED]>, Marko.Cain.23 >> wrote: >> >> >> >>> On Apr 14, 10:36 am, [EMAIL PROTECTED] wrote: On Apr 14, 12:02 am, Michael Bentley <[EMAIL PROTECTED]> wrote: > On Apr 13

Re: Getting started with python

2007-04-15 Thread Steve Holden
James Stroud wrote: > Gabriel Genellina wrote: >> En Sun, 15 Apr 2007 10:46:54 -0300, Army1987 <[EMAIL PROTECTED]> escribió: >> >>> "Paddy" <[EMAIL PROTECTED]> ha scritto nel messaggio >>> news:[EMAIL PROTECTED] >>> On a different tack, from: http://tickletux.wordpress.com/2007/01/24/usin

Re: working of round()

2007-04-15 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > Does round() always perfectly return the output expected or are there > some artifacts which don't allow perfect functionality > > Using python 2.5: round(12.234, 2) > 12.23 round(12.234, 3) > 12.234 round(12.234, 1) > 12.199 > > but was expec

Re: yield, curry, mix-in, new.function, global, closure, .... what will work?

2007-04-15 Thread ecir . hana
On Apr 15, 8:07 pm, Paul Rubin wrote: > That is total madness. Just use a normal object or dictionary with a lock. Please, can you elaborate further, I'm not sure if I understood. Should I lock global variables i, j during the execution of run()? In that case I have to

Re: combination function in python

2007-04-15 Thread [EMAIL PROTECTED]
On Apr 15, 4:16?pm, Anton Vredegoor <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > >> We're getting closer and closer to something I already posted a few > >> times here. This implementation was unfortunate because I consistently > >> used an uncommon name for it so people couldn't easily

Re: how to strip the domain name in python?

2007-04-15 Thread Michael Bentley
On Apr 15, 2007, at 4:24 PM, [EMAIL PROTECTED] wrote: > On Apr 15, 11:57 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> In <[EMAIL PROTECTED]>, >> Marko.Cain.23 >> wrote: >> >> >> >>> On Apr 14, 10:36 am, [EMAIL PROTECTED] wrote: On Apr 14, 12:02 am, Michael Bentley <[EMAIL PRO

Re: Python and JMS?

2007-04-15 Thread Leonard J. Reder
Thanks Jarek, Yes indeed, we are using ActiveMQ and I did see the StomPy python package. But I also saw that it said stomp was done as a student project that ended. Maybe I will try hjb for now - all I need to do is listen for messages on a certain topic. Maybe some of our internal people will

Re: yield, curry, mix-in, new.function, global, closure, .... what will work?

2007-04-15 Thread Paul Rubin
[EMAIL PROTECTED] writes: > On Apr 15, 8:07 pm, Paul Rubin wrote: > > That is total madness. Just use a normal object or dictionary with a lock. > > Please, can you elaborate further, I'm not sure if I understood. > Should I lock global variables i, j during the executi

Re: Getting started with python

2007-04-15 Thread chengzhiannahuang
On Apr 15, 9:53 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Apr 14, 7:46 pm, "Eric" <[EMAIL PROTECTED]> wrote: > > > Hello, after reading some of the book Programming Python it seems that > > python is something I would like to delve deeper into. The only thing > > is, I have no idea wh

Re: Python and XML?

2007-04-15 Thread Leonard J. Reder
Stefan Behnel wrote: > Leonard J. Reder wrote: >> What I as really after though was other possible solutions >> like JAX in the Java world or Gnosis in the Python world. >> >> Something that can take a Relax NG Schema and compile >> it into a bunch of parser/generator objects for handling >> an XML

Re: Portably generating infinity and NaN

2007-04-15 Thread skip
Michael> Will float("NaN") work on these systems? (I don't know.) I Michael> guess it probably works on some system that isn't IEEE 754. My thought was that in configure you could test if strtof("NaN") and strtof("Inf") worked. If not, calculate the necessary bit patterns at that point a

Re: Python editor/IDE on Linux?

2007-04-15 Thread Daniel Gee
didn't know that one. Perhaps I'll look into Gvim (I still like to cut and paste with the mouse, even if I left that off my list). -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Feature Request: Allow changing base of member indices to 1

2007-04-15 Thread Dan Bishop
On Apr 15, 6:06 pm, "Beliavsky" <[EMAIL PROTECTED]> wrote: > On Apr 14, 10:12 pm, "Paddy" <[EMAIL PROTECTED]> wrote: > > > > > So the running count is: > > Ayes to the left: VB compatibility. > > Nays to the right: QuadIO, Perl, Dijkstra paper. > > > The nays have it! > > One-based indexing

Re: Getting started with python

2007-04-15 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes: > You'd be worth more if you'd used elif and omitted the continue > statements, but for a first solution it's acceptable. > > For better readability I'd have used > if i % 5 == 0 I think I'd be more concerned about getting rid of the i%15 test. What i

Re: how to check the 'content/type' using urlopen

2007-04-15 Thread Michael Bentley
On Apr 15, 2007, at 6:25 PM, John wrote: > > i have the following code to open a URL address, but can you please > tell me how can I check the content type of the url response? > > Thank you. > > try: > req = Request(url, txdata, txheaders) > handle = urlopen(req) > except I

pyparsing Catch-22

2007-04-15 Thread 7stud
To the developer: 1) I went to the pyparsing wiki to download the pyparsing module and try it 2) At the wiki, there was no index entry in the table of contents for Downloads. After searching around a bit, I finally discovered a tiny link buried in some text at the top of the home page. 3) Link

How to initialize a table of months.

2007-04-15 Thread Steven W. Orr
I'm reading a logfile with a timestamp at the begging of each line, e.g., Mar 29 08:29:00 I want to call datetime.datetim() whose arg2 is a number between 1-12 so I have to convert the month to an integer. I wrote this, but I have a sneaky suspicion there's a better way to do it. mons = {'Jan':

Re: is laziness a programer's virtue?

2007-04-15 Thread D Herring
Blatherskite! http://innovators.vassar.edu/innovator.html?id=8 http://www.itweek.co.uk/itweek/comment/2160655/laziness-mother-invention -- http://mail.python.org/mailman/listinfo/python-list

Re: pyparsing Catch-22

2007-04-15 Thread Steven Bethard
7stud wrote: > For as hard as you push pyparsing on this forum, I would think you > would make it easier to download and install your module. In my > opinion, the wiki should provide detailed installation instructions > for all supported os's, and the sourceforge downloading process is too > comp

Re: How to initialize a table of months.

2007-04-15 Thread John Zenger
On Apr 15, 9:30 pm, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > I'm reading a logfile with a timestamp at the begging of each line, e.g., > > Mar 29 08:29:00 > > I want to call datetime.datetim() whose arg2 is a number between 1-12 so I > have to convert the month to an integer. > I wrote this, bu

Re: combination function in python

2007-04-15 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > You could take it up with the gmpy author and > > induce him to get gmpy included in the standard distro if you are so > > inclined. > > Alex Martelli knows more about that subject than I and > it would be pointless for me to bug him about it. gmp

Re: Any Pythonistas in Mexico?

2007-04-15 Thread Alex Martelli
Gabriel Genellina <[EMAIL PROTECTED]> wrote: > En Thu, 12 Apr 2007 10:56:32 -0300, Marcpp <[EMAIL PROTECTED]> escribió: > > > On 12 abr, 09:41, Hugo González Monteverde <[EMAIL PROTECTED]> wrote: > >> Leí este mail viejísimo en una lista. Yo uso Python y también quería > >> saber quién pythoneaba

Re: pyparsing Catch-22

2007-04-15 Thread 7stud
On Apr 15, 7:41 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > 7stud wrote: > > For as hard as you push pyparsing on this forum, I would think you > > would make it easier to download and install your module. In my > > opinion, the wiki should provide detailed installation instructions > > for a

Re: Calling private base methods

2007-04-15 Thread Alex Martelli
Isaac Rodriguez <[EMAIL PROTECTED]> wrote: > > The fact that I had > > to resort to this trick is a big indication of course that genuinely > > private members (as opposed to a 'keep off' naming convention) are a bad > > idea in general. > > The fact that you had to resort to this trick is a big

Re: pyparsing Catch-22

2007-04-15 Thread Alex Martelli
7stud <[EMAIL PROTECTED]> wrote: > 1) Even though the download at sourceforge said the file name was: > > pyparsing-1.4.6.tar.gz > > it was downloaded to my Desktop as: > > pyparsing-1.4.6.tar > > Did os x 10.4.7 automatically unzip it for me? .gz means the file was > compressed with gzip, bu

Re: pyparsing Catch-22

2007-04-15 Thread 7stud
On Apr 15, 9:16 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > 7stud <[EMAIL PROTECTED]> wrote: > > 1) Even though the download at sourceforge said the file name was: > > > pyparsing-1.4.6.tar.gz > > > it was downloaded to my Desktop as: > > > pyparsing-1.4.6.tar > > > Did os x 10.4.7 automatically

Re: How to initialize a table of months.

2007-04-15 Thread 7stud
On Apr 15, 7:30 pm, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > I'm reading a logfile with a timestamp at the begging of each line, e.g., > > Mar 29 08:29:00 > > I want to call datetime.datetim() whose arg2 is a number between 1-12 so I > have to convert the month to an integer. > I wrote this, bu

Re: How to initialize a table of months.

2007-04-15 Thread 7stud
On Apr 15, 9:30 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 15, 7:30 pm, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: Arrgh. import calendar months = calendar.month_abbr #returns an array with the 0 element empty #so the month names line up with the indexes 1-12 d = {} for i in range(1, 13):

Re: Getting started with python

2007-04-15 Thread James Stroud
Paul Rubin wrote: > Steve Holden <[EMAIL PROTECTED]> writes: >> You'd be worth more if you'd used elif and omitted the continue >> statements, but for a first solution it's acceptable. >> >> For better readability I'd have used >> if i % 5 == 0 > > I think I'd be more concerned about getting

Re: Getting started with python

2007-04-15 Thread Paul Rubin
James Stroud <[EMAIL PROTECTED]> writes: > 1. This doesn't act according to the specification if you add, for > example, (2, 'Zonk'). Now 30 gives 'ZonkFizzBuzz' and not 'FizzBuzz' > according to the specification. Correct, the original specification only had 3 and 5. I gave a longer example to i

Re: working of round()

2007-04-15 Thread Robert Kern
Steven Bethard wrote: > I'm not sure why you would have expected 2.62 for the latter when:: > > >>> 5.25 / 2 > 2.625 Round-to-nearest-even is a valid, and oft-recommended rounding mode for numbers exactly halfway between two round numbers. -- Robert Kern "I have come to believe that

Re: how to strip the domain name in python?

2007-04-15 Thread Michael Bentley
On Apr 15, 2007, at 7:57 PM, Michael Bentley wrote: > if net_location[0].lower() == 'www': > net_location = net_location[1:] It is not guaranteed that the host name will be 'www' though, is it? If you *really* want to strip the host portion of a domain name, I suppose you could m

Re: Getting started with python

2007-04-15 Thread James Stroud
Steve Holden wrote: > You'd be worth more if you'd used elif and omitted the continue > statements, but for a first solution it's acceptable. Depends on what you are after. py> s = """ ... for i in xrange(1,101): ... if not i % 15: ... continue ... if not i % 5: ... continue ... if

Re: Qt4 in ubuntu

2007-04-15 Thread Parthan SR
On 15 Apr 2007 13:24:22 -0700, Marcpp <[EMAIL PROTECTED]> wrote: Is possible install Qt4 pyqt4 under kubuntu? Few times ago i tried to run pyqt in ubuntu (gnome) but i can't do it. Installation as in [1] Installing using the apt-get/synaptic/adept/aptitude which is present in Ubuntu/Kubuntu o

Re: pyparsing Catch-22

2007-04-15 Thread Paul McGuire
On Apr 15, 8:26 pm, "7stud" <[EMAIL PROTECTED]> wrote: > To the developer: > > 1) I went to the pyparsing wiki to download the pyparsing module and > try it > 2) At the wiki, there was no index entry in the table of contents for > Downloads. After searching around a bit, I finally discovered a t

Re: Getting started with python

2007-04-15 Thread [EMAIL PROTECTED]
On Apr 15, 8:05 pm, [EMAIL PROTECTED] wrote: > On Apr 15, 9:53 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > > > > > On Apr 14, 7:46 pm, "Eric" <[EMAIL PROTECTED]> wrote: > > > > Hello, after reading some of the book Programming Python it seems that > > > python is something I would like

Re: pyparsing Catch-22

2007-04-15 Thread Paul McGuire
Please take a look at the new page added to the pyparsing wiki. -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting started with python

2007-04-15 Thread [EMAIL PROTECTED]
The Python Papers (http://pythonpapers.org) is another resource for Python developers, especially those interested in keeping tabs on the various projects and articles out there in the community. Cheers, -T (Editor-In-Chief, The Python Papers) -- http://mail.python.org/mailman/listinfo/python-li

Re: How to initialize a table of months.

2007-04-15 Thread Paul McGuire
On Apr 15, 10:33 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 15, 9:30 pm, "7stud" <[EMAIL PROTECTED]> wrote: > > > On Apr 15, 7:30 pm, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > > Arrgh. > > import calendar > > months = calendar.month_abbr > #returns an array with the 0 element empty > #so th

Re: working of round()

2007-04-15 Thread subscriber123
On Apr 15, 8:06 pm, [EMAIL PROTECTED] wrote: > Does round() always perfectly return the output expected or are there > some artifacts which don't allow perfect functionality > > Using python 2.5: > > >>> round(12.234, 2) > 12.23 > >>> round(12.234, 3) > 12.234 > >>> round(12.234, 1) > 12.19

Re: How to initialize a table of months.

2007-04-15 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > I'm reading a logfile with a timestamp at the begging of each line, e.g., > > Mar 29 08:29:00 > > I want to call datetime.datetim() whose arg2 is a number between 1-12 so I > have to convert the month to an integer. >

Re: How to initialize a table of months.

2007-04-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Steven W. Orr wrote: > I want to call datetime.datetim() whose arg2 is a number between 1-12 so I > have to convert the month to an integer. > I wrote this, but I have a sneaky suspicion there's a better way to do it. > > mons = {'Jan':1, 'Feb':2, 'Mar':3, 'Apr':4, 'May':

Re: How to initialize a table of months.

2007-04-15 Thread [EMAIL PROTECTED]
On Apr 16, 1:14 pm, "Paul McGuire" <[EMAIL PROTECTED]> wrote: > On Apr 15, 10:33 pm, "7stud" <[EMAIL PROTECTED]> wrote: > > > > > On Apr 15, 9:30 pm, "7stud" <[EMAIL PROTECTED]> wrote: > > > > On Apr 15, 7:30 pm, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > > > Arrgh. > > > import calendar > > > mo

Queue enhancement suggestion

2007-04-15 Thread Paul Rubin
I'd like to suggest adding a new operation Queue.finish() This puts a special sentinel object on the queue. The sentinel travels through the queue like any other object, however, when q.get() encounters the sentinel, it raises StopIteration instead of returning the sentinel. It does not remo

Re: How to initialize a table of months.

2007-04-15 Thread Michel Claveau
Hi! Not best, but another lisibility : mons=dict(Jan=1, Feb=2, Fev=2, Mar=3, Apr=4, Avr=4, May=5, Mai=5, Jun=6, Jui=6, Jul=7, Aug=8, Aou=8, Sep=9, Oct=10, Nov=11, Dec=12) def mon2int(m): return mons[m] def mond2int(**m): return mons[m.keys()[0]] print mons['Mar'] print mon2int('May')

Re: How to initialize a table of months.

2007-04-15 Thread Michel Claveau
Hi (bis) A class way : class cmon(object): Jan=1 Feb=2 Fev=2 Mar=3 Apr=4 Avr=4 May=5 Mai=5 Jun=6 Jui=6 Juin=6 Jul=7 Juil=7 Aug=8 Aou=8 Sep=9 Oct=10 Nov=11 Dec=12 print cmon.Mar print cmon.Sep print cmon.Dec -- @-salutations Miche

Antigen Notification: Antigen found a message matching a filter

2007-04-15 Thread Antigen_VITORIA
Microsoft Antigen for Exchange found a message matching a filter. The message is currently Detected. Message: "Python_list Digest_ Vol 43_ Issue 249" Filter name: "KEYWORD= spam: graduate" Sent from: "[EMAIL PROTECTED]" Folder: "SMTP Messages\Inbound And Outbound" Location: "ITURAN/First Administr

Re: sqlite3 question

2007-04-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Gabriel Genellina wrote: > En Thu, 12 Apr 2007 08:43:49 -0300, Marc 'BlackJack' Rintsch > <[EMAIL PROTECTED]> escribió: > >> In <[EMAIL PROTECTED]>, Jorgen Bodde >> wrote: >> >> r = c.execute('select * from song where id = 1') >> for s in r: >>> ... print

<    1   2