Sublassing tuple works, subclassing list does not

2010-03-30 Thread Frank Millman
Hi all I needed something similar to, but not quite the same as, collections.namedtuple. The differences are that namedtuple requires the 'names' to be provided at creation time, and then lends itself to creating multiple instances of itself. I wanted a more generic class where I could suppl

Re: xpat error in xmlrp client. How to inspect data.

2010-03-30 Thread Gabriel Genellina
En Tue, 30 Mar 2010 18:01:40 -0300, News123 escribió: Gabriel Genellina wrote: En Thu, 25 Mar 2010 05:31:05 -0300, News123 escribió: I'm havign a small xmlrpc client, which works normally fine. (xmlrpc via https) Sometimes however I receive an Exception about an expat error. The output, t

Re: sort array, apply rearrangement to second

2010-03-30 Thread Robert Kern
On 2010-03-30 18:25 , Victor Eijkhout wrote: I have two arrays, made with numpy. The first one has values that I want to use as sorting keys; the second one needs to be sorted by those keys. Obviously I could turn them into a dictionary of pairs and sort by the first member, but I think that's n

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Tim Chase
John Bokma wrote: And maybe you're right, the Python one could've been written: if list is None: list = [] which looks, now, also more readable to me as well. Though there's a slight difference[1], I'd usually use lst = lst or [] for your particular initialization use case. -tkc [1]

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Russ P.
On Mar 30, 10:08 am, John Nagle wrote: > Chris Rebert wrote: > > On Tue, Mar 30, 2010 at 8:40 AM, gentlestone wrote: > >> Hi, how can I write the popular C/JAVA syntax in Python? > > >> Java example: > >>    return (a==b) ? 'Yes' : 'No' > > >> My first idea is: > >>    return ('No','Yes')[bool(a=

Re: sort array, apply rearrangement to second

2010-03-30 Thread Chris Colbert
On Tue, Mar 30, 2010 at 9:59 PM, Chris Colbert wrote: > > > On Tue, Mar 30, 2010 at 7:25 PM, Victor Eijkhout wrote: > >> I have two arrays, made with numpy. The first one has values that I want >> to use as sorting keys; the second one needs to be sorted by those keys. >> Obviously I could turn t

Re: sort array, apply rearrangement to second

2010-03-30 Thread Chris Colbert
On Tue, Mar 30, 2010 at 7:25 PM, Victor Eijkhout wrote: > I have two arrays, made with numpy. The first one has values that I want > to use as sorting keys; the second one needs to be sorted by those keys. > Obviously I could turn them into a dictionary of pairs and sort by the > first member, bu

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread John Bokma
Robert Fendt writes: > And thus spake John Bokma > Tue, 30 Mar 2010 13:19:19 -0600: > >> And >> >> a == b and 'Yes' or 'No' >> >> isn't a Perl-ism? > > I never said that this would be better. It was not my intention to imply you did. But yet I do see books on Python mention the and or usage

Re: "Usability, the Soul of Python"

2010-03-30 Thread Cameron Simpson
On 30Mar2010 10:25, Chris Colbert wrote: | not really, the int will eventually overflow and cycle around ;) | | On Tue, Mar 30, 2010 at 8:11 AM, Xavier Ho wrote: | | > Did no one notice that | > for(i = 99; i > 0; ++i) | > Gives you an infinite loop (sort of) because i starts a 99, and increase

Re: Re: Fetch files from mail in python

2010-03-30 Thread Chris Rebert
> On Mar 30, 2010 7:39pm, Chris Rebert wrote: >> On Tue, Mar 30, 2010 at 4:33 PM,  hid...@gmail.com> wrote: >> > Hello list, i want to know how could i fetch a file from an email, what >> > kind >> > of library i have to use for that, actually i am working in the support >> > of >> > IMAP and POP3

Re: Re: Fetch files from mail in python

2010-03-30 Thread hidura
I did that but i want to know if i have a file inside the mail how could i download that file from my mail. On Mar 30, 2010 7:39pm, Chris Rebert wrote: On Tue, Mar 30, 2010 at 4:33 PM, hid...@gmail.com> wrote: > Hello list, i want to know how could i fetch a file from an email, what kind

Re: sort array, apply rearrangement to second

2010-03-30 Thread MRAB
Victor Eijkhout wrote: I have two arrays, made with numpy. The first one has values that I want to use as sorting keys; the second one needs to be sorted by those keys. Obviously I could turn them into a dictionary of pairs and sort by the first member, but I think that's not very efficient, at

Re: "Usability, the Soul of Python"

2010-03-30 Thread Steve Holden
Jonathan Hayward wrote: > I've posted "Usability, the Soul of Python: An Introduction to the > Python Programming Language Through the Eyes of Usability", at: > >http://JonathansCorner.com/python/ > > The basic suggestion is that much of what works well in Python has > something to do with th

Re: psycopg2 / psycopg2.DataError: invalid input syntax for type timestamp with time zone:

2010-03-30 Thread D'Arcy J.M. Cain
On Tue, 30 Mar 2010 15:46:12 -0700 (PDT) ASh wrote: > > >             new_start_date = "NOW() - '29 days'::INTERVAL" > > >             self.dyndb.orderdb.query('''update set creation_date > > > = %s > > >             where id_order = %s''', (new_start_date, "123")) > > > > Put single quotes a

Re: sort array, apply rearrangement to second

2010-03-30 Thread Steve Holden
Victor Eijkhout wrote: > I have two arrays, made with numpy. The first one has values that I want > to use as sorting keys; the second one needs to be sorted by those keys. > Obviously I could turn them into a dictionary of pairs and sort by the > first member, but I think that's not very efficien

Re: Sometimes the python shell cannot recognize the presence of an attribute.

2010-03-30 Thread Steve Holden
Justin Park wrote: > Sorry, my mistake. > > The real problem is this. > When I started working on the package, somehow all of indentations were > made by space-bars instead of using tabs. > But when I am implementing my own on top of it, I still use tabs to make > indentations. > > This is causin

Re: psycopg2 / psycopg2.DataError: invalid input syntax for type timestamp with time zone:

2010-03-30 Thread Steve Holden
D'Arcy J.M. Cain wrote: > On Tue, 30 Mar 2010 13:47:42 -0700 (PDT) > ASh wrote: >> Hi, please help me understand why am I getting error with this query >> >> >> new_start_date = "NOW() - '29 days'::INTERVAL" >> self.dyndb.orderdb.query('''update set creation_date >> =

Re: sort array, apply rearrangement to second

2010-03-30 Thread Alf P. Steinbach
* Victor Eijkhout: I have two arrays, made with numpy. The first one has values that I want to use as sorting keys; the second one needs to be sorted by those keys. Obviously I could turn them into a dictionary of pairs and sort by the first member, but I think that's not very efficient, at leas

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Steve Holden
Lawrence D'Oliveiro wrote: > In message <7316f3d2-bcc9-4a1a-8598- > cdd5d41fd...@k17g2000yqb.googlegroups.com>, Joaquin Abian wrote: > >> (a==b) and 'YES' or 'NO' >> >> Yes, ugly > > Why would you say that’s ugly? > > By the way, you don’t need the parentheses. But at the same time, if you don'

Re: Fetch files from mail in python

2010-03-30 Thread Chris Rebert
On Tue, Mar 30, 2010 at 4:33 PM, wrote: > Hello list, i want to know how could i fetch a file from an email, what kind > of library i have to use for that, actually i am working in the support of > IMAP and POP3. Next time, consult the Global Module Index (http://docs.python.org/modindex.html) b

Re: "Usability, the Soul of Python"

2010-03-30 Thread Lawrence D'Oliveiro
In message , Alf P. Steinbach wrote: > This is just unsubstantiated opinion, but worse, it makes a tacit > assumption that there is "best" way to do indentation. However, most > programmers fall into that trap, and I've done it myself. Having used so many different languages over the years, I ha

Fetch files from mail in python

2010-03-30 Thread hidura
Hello list, i want to know how could i fetch a file from an email, what kind of library i have to use for that, actually i am working in the support of IMAP and POP3. Thanks. Diego I. Hidalgo D. -- http://mail.python.org/mailman/listinfo/python-list

sort array, apply rearrangement to second

2010-03-30 Thread Victor Eijkhout
I have two arrays, made with numpy. The first one has values that I want to use as sorting keys; the second one needs to be sorted by those keys. Obviously I could turn them into a dictionary of pairs and sort by the first member, but I think that's not very efficient, at least in space, and this

Re: "Usability, the Soul of Python"

2010-03-30 Thread Lawrence D'Oliveiro
In message <20100331003241.47fa9...@vulcan.local>, Robert Fendt wrote: > The braces are gone, and with them the holy wars. Let me start a new one. I would still put in some kind of explicit indicator of the end of the grouping construct: count = 99 while count > 0: print u'%d sl

Re: "Usability, the Soul of Python"

2010-03-30 Thread Chris Rebert
On Tue, Mar 30, 2010 at 3:32 PM, Robert Fendt wrote: > And thus spake "Alf P. Steinbach" > Tue, 30 Mar 2010 13:40:22 +0200: >> >>  From a usability standpoint, the braces go with the lines to print out the >> stanza rather than the for statement or the code after, so the following is >> best: >

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Lawrence D'Oliveiro
In message <7316f3d2-bcc9-4a1a-8598- cdd5d41fd...@k17g2000yqb.googlegroups.com>, Joaquin Abian wrote: > (a==b) and 'YES' or 'NO' > > Yes, ugly Why would you say that’s ugly? By the way, you don’t need the parentheses. -- http://mail.python.org/mailman/listinfo/python-list

Re: Sometimes the python shell cannot recognize the presence of an attribute.

2010-03-30 Thread Justin Park
Sorry, my mistake. The real problem is this. When I started working on the package, somehow all of indentations were made by space-bars instead of using tabs. But when I am implementing my own on top of it, I still use tabs to make indentations. This is causing a problem. I have to either conform

Sometimes the python shell cannot recognize the presence of an attribute.

2010-03-30 Thread Justin Park
Sometimes when I am working on an already generated package, the python shell cannot perceive the presence of an attribute that I implemented on top of what was there. Is there a way to have it perceive newly created attributes? Thanks, Justin. -- http://mail.python.org/mailman/listinfo/python-l

Re: psycopg2 / psycopg2.DataError: invalid input syntax for type timestamp with time zone:

2010-03-30 Thread ASh
On Mar 31, 12:50 am, "D'Arcy J.M. Cain" wrote: > On Tue, 30 Mar 2010 13:47:42 -0700 (PDT) > > ASh wrote: > > Hi, please help me understand why am I getting error with this query > > >             new_start_date = "NOW() - '29 days'::INTERVAL" > >             self.dyndb.orderdb.query('''update xxx

Re: psycopg2 / psycopg2.DataError: invalid input syntax for type timestamp with time zone:

2010-03-30 Thread ASh
On Mar 31, 12:26 am, Philip Semanchuk wrote: > On Mar 30, 2010, at 4:47 PM, ASh wrote: > > > Hi, please help me understand why am I getting error with this query > > >            new_start_date = "NOW() - '29 days'::INTERVAL" > >            self.dyndb.orderdb.query('''update set creation_date

Re: "Usability, the Soul of Python"

2010-03-30 Thread Robert Fendt
And thus spake "Alf P. Steinbach" Tue, 30 Mar 2010 13:40:22 +0200: > > From a usability standpoint, the braces go with the lines to print out the > stanza rather than the for statement or the code after, so the following is > best: > > for(i = 99; i > 0; ++i) > { > printf("%d slabs

Re: Can't get odtwriter to work

2010-03-30 Thread Grant Edwards
On 2010-03-30, Grant Edwards wrote: > I just installed odtwriter 1.3d on a Gentoo system running Python > 2.6.4. I used the normal "python setup.py build" then "python > setup.py install" method. But, odtwriter doesn't seem to work: > > rst2odt.py --help > > Traceback (most recent call l

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Stephen Hansen
On 2010-03-30 13:16:00 -0700, Robert Fendt said: I find such a convoluted construct especially ugly in a language which I previously regarded as having a rather striking beauty of syntactical simplicity. The construct is superfluous, illogical, unelegant, and thus very un-pythonesque, IMHO. But

Re: A question about making a sort-of-counter.

2010-03-30 Thread Chris Rebert
On Tue, Mar 30, 2010 at 2:31 PM, Justin Park wrote: > Suppose I have a list. > a = list() > And suppose allowed digits as the element are 1,2,3,4,5. > > What can I do in order to iterate over all possible values for each element? > For instance, the sequence of the list I want to have would be > [

Re: A question about making a sort-of-counter.

2010-03-30 Thread Justin Park
Thanks! It works! Justin. Chris Rebert wrote: > On Tue, Mar 30, 2010 at 2:31 PM, Justin Park wrote: > >> Suppose I have a list. >> a = list() >> And suppose allowed digits as the element are 1,2,3,4,5. >> >> What can I do in order to iterate over all possible values for each element? >> For i

Can't get odtwriter to work

2010-03-30 Thread Grant Edwards
I just installed odtwriter 1.3d on a Gentoo system running Python 2.6.4. I used the normal "python setup.py build" then "python setup.py install" method. But, odtwriter doesn't seem to work: rst2odt.py --help Traceback (most recent call last): File "/usr/bin/rst2odt.py", line 5, in

Re: A question about making a sort-of-counter.

2010-03-30 Thread anon
Justin Park wrote: Suppose I have a list. a = list() And suppose allowed digits as the element are 1,2,3,4,5. What can I do in order to iterate over all possible values for each element? For instance, the sequence of the list I want to have would be [1,1,1,1,1] [1,1,1,1,2] [1,1,1,1,3] [5,

Re: A question about making a sort-of-counter.

2010-03-30 Thread Robert Kern
On 2010-03-30 16:31 PM, Justin Park wrote: Suppose I have a list. a = list() And suppose allowed digits as the element are 1,2,3,4,5. What can I do in order to iterate over all possible values for each element? For instance, the sequence of the list I want to have would be [1,1,1,1,1] [1,1,1,1,2

Re: psycopg2 / psycopg2.DataError: invalid input syntax for type timestamp with time zone:

2010-03-30 Thread D'Arcy J.M. Cain
On Tue, 30 Mar 2010 13:47:42 -0700 (PDT) ASh wrote: > Hi, please help me understand why am I getting error with this query > > > new_start_date = "NOW() - '29 days'::INTERVAL" > self.dyndb.orderdb.query('''update set creation_date > = %s > where id_order

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Robert Fendt
And thus spake MRAB Tue, 30 Mar 2010 22:43:04 +0100: > I think you mean that it's very _un-Pythonic_ (perhaps because it's very > very Pythonesque)! :-) Yes. Of course. What was I thinking. ;-) Regards, Robert -- http://mail.python.org/mailman/listinfo/python-list

Re: logging: local functions ==> loss of lineno

2010-03-30 Thread Hellmut Weber
Hi Peter and Jean-Michel, thanks for all your hints and pieces of code. It took me a while to play around with what I got from you (and some study of Vinay's module documentation. Now I have come up with a more complete solution I'm quite satisfied with. And I would be very glad to receive yo

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread MRAB
Robert Fendt wrote: And thus spake John Bokma Tue, 30 Mar 2010 13:19:19 -0600: And a == b and 'Yes' or 'No' isn't a Perl-ism? I never said that this would be better. I don't even get the point of what the advantage is supposed to be of inverting the order of the return statement and the

Re: decorators only when __debug__ == True

2010-03-30 Thread MRAB
LX wrote: On Mar 29, 6:34 pm, MRAB wrote: LX wrote: Hi all, I have a question about decorators. I would like to use them for argument checking, and pre/post conditions. However, I don't want the additional overhead when I run in non-debug mode. I could do something like this, using a simple tr

A question about making a sort-of-counter.

2010-03-30 Thread Justin Park
Suppose I have a list. a = list() And suppose allowed digits as the element are 1,2,3,4,5. What can I do in order to iterate over all possible values for each element? For instance, the sequence of the list I want to have would be [1,1,1,1,1] [1,1,1,1,2] [1,1,1,1,3] [5,5,5,5,4] [5,5,5,5,5]

Re: psycopg2 / psycopg2.DataError: invalid input syntax for type timestamp with time zone:

2010-03-30 Thread Philip Semanchuk
On Mar 30, 2010, at 4:47 PM, ASh wrote: Hi, please help me understand why am I getting error with this query new_start_date = "NOW() - '29 days'::INTERVAL" self.dyndb.orderdb.query('''update set creation_date = %s where id_order = %s''', (new_start_date,

Re: Binary Decimals in Python

2010-03-30 Thread Mensanator
On Mar 30, 1:52 pm, MRAB wrote: > John Nagle wrote: > > aditya wrote: > >> On Mar 30, 10:49 am, Raymond Hettinger wrote: > >>> On Mar 30, 8:13 am, aditya wrote: > > To get the decimal representation of a binary number, I can just do > this: > int('11',2) # returns 3 > But dec

Re: xpat error in xmlrp client. How to inspect data.

2010-03-30 Thread News123
Hi Gabriel, Gabriel Genellina wrote: > En Thu, 25 Mar 2010 05:31:05 -0300, News123 escribió: > >> I'm havign a small xmlrpc client, which works normally fine. >> (xmlrpc via https) >> >> Sometimes however I receive an Exception about an expat error. >> >> >> The output, that I receive is: >> F

psycopg2 / psycopg2.DataError: invalid input syntax for type timestamp with time zone:

2010-03-30 Thread ASh
Hi, please help me understand why am I getting error with this query new_start_date = "NOW() - '29 days'::INTERVAL" self.dyndb.orderdb.query('''update set creation_date = %s where id_order = %s''', (new_start_date, "123")) ... psycopg2.DataError: invali

Re: decorators only when __debug__ == True

2010-03-30 Thread LX
On Mar 29, 7:11 pm, Steven D'Aprano wrote: > On Mon, 29 Mar 2010 17:54:26 -0700, LX wrote: > > Hi all, I have a question about decorators. I would like to use them for > > argument checking, and pre/post conditions. However, I don't want the > > additional overhead when I run in non-debug mode. I

Re: decorators only when __debug__ == True

2010-03-30 Thread LX
On Mar 29, 6:34 pm, MRAB wrote: > LX wrote: > > Hi all, I have a question about decorators. I would like to use them > > for argument checking, and pre/post conditions. However, I don't want > > the additional overhead when I run in non-debug mode. I could do > > something like this, using a simpl

"jobs in kuwait" "jobs in kuwait for pakistanis" "jobs in kuwait 2010" "jobs in kuwait airways" "jobs in kuwait banks" "jobs in kuwait telecom" "kuwait jobs" "kuwait airways" "kuwait jobs online" on

2010-03-30 Thread saima81
"jobs in kuwait" "jobs in kuwait for pakistanis" "jobs in kuwait 2010" "jobs in kuwait airways" "jobs in kuwait banks" "jobs in kuwait telecom" "kuwait jobs" "kuwait airways" "kuwait jobs online" on http://jobsinkuwait-net.blogspot.com/"jobs in kuwait" "jobs in kuwait for pakistanis" "jobs

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Steve Holden
Robert Fendt wrote: > And thus spake John Bokma > Tue, 30 Mar 2010 13:19:19 -0600: > >> And >> >> a == b and 'Yes' or 'No' >> >> isn't a Perl-ism? > > I never said that this would be better. I don't even get the > point of what the advantage is supposed to be of inverting the > order of the re

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Robert Fendt
And thus spake John Bokma Tue, 30 Mar 2010 13:19:19 -0600: > And > > a == b and 'Yes' or 'No' > > isn't a Perl-ism? I never said that this would be better. I don't even get the point of what the advantage is supposed to be of inverting the order of the return statement and the conditional ch

Re: Binary Decimals in Python

2010-03-30 Thread Chris Kaynor
Chris On Tue, Mar 30, 2010 at 11:14 AM, John Nagle wrote: > aditya wrote: > >> On Mar 30, 10:49 am, Raymond Hettinger wrote: >> >>> On Mar 30, 8:13 am, aditya wrote: >>> >>> To get the decimal representation of a binary number, I can just do this: int('11',2) # returns 3 But d

Re: "Usability, the Soul of Python"

2010-03-30 Thread Russ P.
According to Wikipedia, this is called the Whitesmith style: for(i = 99; i > 0; ++i) { printf("%d slabs of spam in my mail!\n", i); printf("%d slabs of spam,\n", i); printf("Send one to abuse and Just Hit Delete,\n"); printf("%d slabs of spam in my mail!\n\n", i + 1);

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Pierre Quentel
On 30 mar, 21:19, John Bokma wrote: > Robert Fendt writes: > > In fact, the syntax just shouts 'do [...] unless' to me. And > > that's so strong a Perl-ism I cannot quite express how ugly I > > actually find it... > > And > >  a == b and 'Yes' or 'No' > > isn't a Perl-ism? > > Sheesh, this group

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread John Bokma
Robert Fendt writes: > In fact, the syntax just shouts 'do [...] unless' to me. And > that's so strong a Perl-ism I cannot quite express how ugly I > actually find it... And a == b and 'Yes' or 'No' isn't a Perl-ism? Sheesh, this group would be so much nicer without the constant dragging in

Re: Binary Decimals in Python

2010-03-30 Thread MRAB
John Nagle wrote: aditya wrote: On Mar 30, 10:49 am, Raymond Hettinger wrote: On Mar 30, 8:13 am, aditya wrote: To get the decimal representation of a binary number, I can just do this: int('11',2) # returns 3 But decimal binary numbers throw a ValueError: int('1.1',2) # should return 1.5,

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Robert Fendt
And thus spake Steve Holden Tue, 30 Mar 2010 13:56:04 -0400: > >> Yes, Python has ternary operator-like syntax: > >> return ('Yes' if a==b else 'No') > >> > >> Note that this requires a recent version of Python. > > > > Who let the dogs in? That's awful syntax. > > Yes, that's deliberately

Re: Binary Decimals in Python

2010-03-30 Thread Grant Edwards
On 2010-03-30, John Nagle wrote: > Hex floats are useful because you can get a string representation of > the exact value of a binary floating point number. It should always > be the case that > >float.fromhex(float.hex(x)) == x Until you try running your program on a machine that repre

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Robert Kern
On 2010-03-30 12:11 PM, Steven D'Aprano wrote: On Tue, 30 Mar 2010 10:08:31 -0700, John Nagle wrote: Yes, Python has ternary operator-like syntax: return ('Yes' if a==b else 'No') Note that this requires a recent version of Python. Who let the dogs in? That's awful syntax. I used to

Re: How many packages there are in PyPI

2010-03-30 Thread John Nagle
Joaquin Abian wrote: Hi, PyPI is reaching the 1 package figure (In the case of 3.x only about 140 packages and increasing very very slowly). Looking at available packages for 3.x I observed that some packages are listed several times. For example, lxml is listed 5 times. Are these repetition

Re: Binary Decimals in Python

2010-03-30 Thread Mensanator
On Mar 30, 10:49 am, Raymond Hettinger wrote: > On Mar 30, 8:13 am, aditya wrote: > > > To get the decimal representation of a binary number, I can just do > > this: > > > int('11',2) # returns 3 > > > But decimal binary numbers throw a ValueError: > > > int('1.1',2) # should return 1.5, throws e

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Steve Holden
John Nagle wrote: > Chris Rebert wrote: >> On Tue, Mar 30, 2010 at 8:40 AM, gentlestone >> wrote: >>> Hi, how can I write the popular C/JAVA syntax in Python? >>> >>> Java example: >>>return (a==b) ? 'Yes' : 'No' >>> >>> My first idea is: >>>return ('No','Yes')[bool(a==b)] >>> >>> Is there

Re: Binary Decimals in Python

2010-03-30 Thread John Nagle
aditya wrote: On Mar 30, 10:49 am, Raymond Hettinger wrote: On Mar 30, 8:13 am, aditya wrote: To get the decimal representation of a binary number, I can just do this: int('11',2) # returns 3 But decimal binary numbers throw a ValueError: int('1.1',2) # should return 1.5, throws error instea

How many packages there are in PyPI

2010-03-30 Thread Joaquin Abian
Hi, PyPI is reaching the 1 package figure (In the case of 3.x only about 140 packages and increasing very very slowly). Looking at available packages for 3.x I observed that some packages are listed several times. For example, lxml is listed 5 times. Are these repetitions included in the packa

Re: CPAN for python?

2010-03-30 Thread Steven Howe
This question comes up at least once a month, eliciting a thread that goes on for day. Wouldn't it be wise to put a link on the bottom of the mail list? Something like CPAN for Python == PyPi << make that an href or Python( CPAN ) = PyPi Not too many characters. sph On 03/30/2010 09:23 AM

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Steven D'Aprano
On Tue, 30 Mar 2010 10:08:31 -0700, John Nagle wrote: >> Yes, Python has ternary operator-like syntax: return ('Yes' if a==b >> else 'No') >> >> Note that this requires a recent version of Python. > > Who let the dogs in? That's awful syntax. I used to think so to, but now I like it. It m

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Chris Colbert
On Tue, Mar 30, 2010 at 1:08 PM, John Nagle wrote: > Chris Rebert wrote: > >> On Tue, Mar 30, 2010 at 8:40 AM, gentlestone >> wrote: >> >>> Hi, how can I write the popular C/JAVA syntax in Python? >>> >>> Java example: >>> return (a==b) ? 'Yes' : 'No' >>> >>> My first idea is: >>> return ('N

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Steven D'Aprano
On Tue, 30 Mar 2010 08:40:56 -0700, gentlestone wrote: > Hi, how can I write the popular C/JAVA syntax in Python? > > Java example: > return (a==b) ? 'Yes' : 'No' > > My first idea is: > return ('No','Yes')[bool(a==b)] You don't need the call to bool. ('No','Yes')[a==b] > Is there a

Re: Binary Decimals in Python

2010-03-30 Thread Steven D'Aprano
On Tue, 30 Mar 2010 08:28:50 -0700, Patrick Maupin wrote: > On Mar 30, 10:13 am, aditya wrote: >> To get the decimal representation of a binary number, I can just do >> this: >> >> int('11',2) # returns 3 >> >> But decimal binary numbers throw a ValueError: >> >> int('1.1',2) # should return 1.5,

Re: CPAN for python?

2010-03-30 Thread Philip Semanchuk
On Mar 30, 2010, at 12:23 PM, Someone Something wrote: Hi, I've learned python a few months ago but I still use Perl because of CPAN and the tremendous amount of stuff that's already been done for you. is there something like CPAN for python? Yes and no, depending on what CPAN means to yo

Re: CPAN for python?

2010-03-30 Thread Shashwat Anand
This has been discussed tons of times. You should have atleast googled it. Python have nothing like CPAN and Cheese Shop (pypi) comes closest to it. On Tue, Mar 30, 2010 at 10:21 PM, Kushal Kumaran < kushal.kumaran+pyt...@gmail.com > wrote: > On Tue, Mar 30, 2010 at 9:53 PM, Someone Something >

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Joaquin Abian
On Mar 30, 5:40 pm, gentlestone wrote: > Hi, how can I write the popular C/JAVA syntax in Python? > > Java example: >     return (a==b) ? 'Yes' : 'No' > > My first idea is: >     return ('No','Yes')[bool(a==b)] > > Is there a more elegant/common python expression for this? (a==b) and 'YES' or 'NO

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Robert Kern
On 2010-03-30 12:08 PM, John Nagle wrote: Chris Rebert wrote: On Tue, Mar 30, 2010 at 8:40 AM, gentlestone wrote: Hi, how can I write the popular C/JAVA syntax in Python? Java example: return (a==b) ? 'Yes' : 'No' My first idea is: return ('No','Yes')[bool(a==b)] Is there a more elegant/com

Re: CPAN for python?

2010-03-30 Thread Kushal Kumaran
On Tue, Mar 30, 2010 at 9:53 PM, Someone Something wrote: > Hi, > I've learned python a few months ago but I still use Perl because of CPAN > and the tremendous amount of stuff that's already been done for you. is > there something like CPAN for python? > Try PyPI. http://pypi.python.org/pypi --

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread John Nagle
Chris Rebert wrote: On Tue, Mar 30, 2010 at 8:40 AM, gentlestone wrote: Hi, how can I write the popular C/JAVA syntax in Python? Java example: return (a==b) ? 'Yes' : 'No' My first idea is: return ('No','Yes')[bool(a==b)] Is there a more elegant/common python expression for this? Yes

Re: Python Script Creator/Generator (function factory)

2010-03-30 Thread Andrej Mitrovic
I forgot to mention, I'm using Python 2.5.x. I can't use Python 3 unfortunately, the 3rd party application uses Py2.5.x internally, so I have to limit the functionality to that version. -- http://mail.python.org/mailman/listinfo/python-list

Python Script Creator/Generator (function factory)

2010-03-30 Thread Andrej Mitrovic
Hello, I have the following situation: I've got a 3rd party application that has a Python API. The applicaiton has integrated support for MIDI Hardware Controllers, which can be used to manipulate various parameters of the application. The app can also load Python User Scripts, which can define th

CPAN for python?

2010-03-30 Thread Someone Something
Hi, I've learned python a few months ago but I still use Perl because of CPAN and the tremendous amount of stuff that's already been done for you. is there something like CPAN for python? -- http://mail.python.org/mailman/listinfo/python-list

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Daniel Fetchinson
>> Hi, how can I write the popular C/JAVA syntax in Python? >> >> Java example: >> return (a==b) ? 'Yes' : 'No' >> >> My first idea is: >> return ('No','Yes')[bool(a==b)] >> >> Is there a more elegant/common python expression for this? > > return ('Yes' if a == b else 'No') And for less cl

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Chris Rebert
On Tue, Mar 30, 2010 at 8:40 AM, gentlestone wrote: > Hi, how can I write the popular C/JAVA syntax in Python? > > Java example: >    return (a==b) ? 'Yes' : 'No' > > My first idea is: >    return ('No','Yes')[bool(a==b)] > > Is there a more elegant/common python expression for this? Yes, Python

Re: Binary Decimals in Python

2010-03-30 Thread aditya
On Mar 30, 10:49 am, Raymond Hettinger wrote: > On Mar 30, 8:13 am, aditya wrote: > > > To get the decimal representation of a binary number, I can just do > > this: > > > int('11',2) # returns 3 > > > But decimal binary numbers throw a ValueError: > > > int('1.1',2) # should return 1.5, throws e

Re: PyDispatcher on sourceforge doesn't play nice with easy_install

2010-03-30 Thread Mike C. Fletcher
Chris Withers wrote: > Hi All, > > Using easy_install to get PyDispatcher results in: > ... > Who's the maintainer of PyDispatcher nowadays? Would be handy if they > removed the sourceforge link from pypi. ... Thanks for the report. I've released a 2.0.2 version on PyPI. That should now work pro

Re: Binary Decimals in Python

2010-03-30 Thread aditya
On Mar 30, 10:37 am, Benjamin Kaplan wrote: > On Tue, Mar 30, 2010 at 11:13 AM, aditya wrote: > > To get the decimal representation of a binary number, I can just do > > this: > > > int('11',2) # returns 3 > > > But decimal binary numbers throw a ValueError: > > > int('1.1',2) # should return 1.5

Re: Binary Decimals in Python

2010-03-30 Thread MRAB
aditya wrote: To get the decimal representation of a binary number, I can just do this: int('11',2) # returns 3 But decimal binary numbers throw a ValueError: int('1.1',2) # should return 1.5, throws error instead. Is this by design? It seems to me that this is not the correct behavior. int

Re: Binary Decimals in Python

2010-03-30 Thread Grant Olson
Doh! Well the problem is that int's are integers. So yeah, you can't even do that with normal value "int ('2.1')" will also throw an error. And floats don't support radix conversion, because no-one really writes numbers that way. (At least computer programmers...) On 3/30/2010 11:43 AM, Shash

Re: Binary Decimals in Python

2010-03-30 Thread Raymond Hettinger
On Mar 30, 8:13 am, aditya wrote: > To get the decimal representation of a binary number, I can just do > this: > > int('11',2) # returns 3 > > But decimal binary numbers throw a ValueError: > > int('1.1',2) # should return 1.5, throws error instead. > > Is this by design? It seems to me that this

Re: (a==b) ? 'Yes' : 'No'

2010-03-30 Thread Mike Kent
On Mar 30, 11:40 am, gentlestone wrote: > Hi, how can I write the popular C/JAVA syntax in Python? > > Java example: >     return (a==b) ? 'Yes' : 'No' > > My first idea is: >     return ('No','Yes')[bool(a==b)] > > Is there a more elegant/common python expression for this? return ('Yes' if a ==

(a==b) ? 'Yes' : 'No'

2010-03-30 Thread gentlestone
Hi, how can I write the popular C/JAVA syntax in Python? Java example: return (a==b) ? 'Yes' : 'No' My first idea is: return ('No','Yes')[bool(a==b)] Is there a more elegant/common python expression for this? -- http://mail.python.org/mailman/listinfo/python-list

Re: Binary Decimals in Python

2010-03-30 Thread Shashwat Anand
The conversion is not supported for decimal integers AFAIK, however '0b123.456' is always valid. I guess you can always get a decimal number convertor onto Python-recipes On Tue, Mar 30, 2010 at 9:05 PM, Grant Olson wrote: > On 3/30/2010 11:13 AM, aditya wrote: > > To get the decimal represent

Re: Binary Decimals in Python

2010-03-30 Thread Benjamin Kaplan
On Tue, Mar 30, 2010 at 11:13 AM, aditya wrote: > To get the decimal representation of a binary number, I can just do > this: > > int('11',2) # returns 3 > > But decimal binary numbers throw a ValueError: > > int('1.1',2) # should return 1.5, throws error instead. > > Is this by design? It seems t

Re: Binary Decimals in Python

2010-03-30 Thread Grant Olson
On 3/30/2010 11:13 AM, aditya wrote: > To get the decimal representation of a binary number, I can just do > this: > > int('11',2) # returns 3 > > But decimal binary numbers throw a ValueError: > > int('1.1',2) # should return 1.5, throws error instead. > > Is this by design? It seems to me tha

Re: sum for sequences?

2010-03-30 Thread Patrick Maupin
On Mar 30, 8:53 am, Mel wrote: > floats are nasty -- as evidence the recent thread on comparing floats for > equality.  People use floats when they have to.  fsum exists because of > this: ... I understand there are technical reasons for why math.fsum() exists. I still think that whatever math.f

Re: Binary Decimals in Python

2010-03-30 Thread Patrick Maupin
On Mar 30, 10:13 am, aditya wrote: > To get the decimal representation of a binary number, I can just do > this: > > int('11',2) # returns 3 > > But decimal binary numbers throw a ValueError: > > int('1.1',2) # should return 1.5, throws error instead. > > Is this by design? It seems to me that thi

Re: Binary Decimals in Python

2010-03-30 Thread Shashwat Anand
decimal binary number is not included AFAIK On Tue, Mar 30, 2010 at 8:43 PM, aditya wrote: > To get the decimal representation of a binary number, I can just do > this: > > int('11',2) # returns 3 > > But decimal binary numbers throw a ValueError: > > int('1.1',2) # should return 1.5, throws err

Binary Decimals in Python

2010-03-30 Thread aditya
To get the decimal representation of a binary number, I can just do this: int('11',2) # returns 3 But decimal binary numbers throw a ValueError: int('1.1',2) # should return 1.5, throws error instead. Is this by design? It seems to me that this is not the correct behavior. - Aditya -- http://

Re: "Usability, the Soul of Python"

2010-03-30 Thread Chris Colbert
not really, the int will eventually overflow and cycle around ;) On Tue, Mar 30, 2010 at 8:11 AM, Xavier Ho wrote: > Did no one notice that > > > for(i = 99; i > 0; ++i) > > Gives you an infinite loop (sort of) because i starts a 99, and increases > every loop? > > Cheers, > > Ching-Yun Xavier H

Re: sum for sequences?

2010-03-30 Thread Mel
Patrick Maupin wrote: > Because sum() is the obvious way to sum floats; now the existence of > math.fsum() means there are TWO obvious ways to sum floats. Is that > really that hard to understand? How can you misconstrue this so badly > that you write something that can be (easily) interpreted t

Re: StringChain -- a data structure for managing large sequences ofchunks of bytes

2010-03-30 Thread Steve Holden
Lie Ryan wrote: > On 03/29/2010 01:59 AM, Steven D'Aprano wrote: >> On Sun, 28 Mar 2010 06:48:21 +1100, Lie Ryan wrote: >> >>> On 03/22/2010 07:07 PM, Steven D'Aprano wrote: Perhaps you should have said that it was a wrapper around deque giving richer functionality, rather than giving the

  1   2   >