Re: Question about floating point

2018-08-30 Thread Gregory Ewing
Steven D'Aprano wrote: The right way is to set the rounding mode at the start of your application, and then let the Decimal type round each calculation that needs rounding. It's not clear what you mean by "rounding mode" here. If you mean whether it's up/down/even/whatever, then yes, you can p

Re: Shall I worry about python2/3 compatibility when using library?

2018-08-30 Thread Chris Angelico
On Fri, Aug 31, 2018 at 3:50 PM, Cameron Simpson wrote: > And aim for Python 2.7 - this goes a long way to making 2 and 3 easy to work > with. The fursther back you go in 2.x the harder it gets. Yep; also, aim for 3.5+, since you get the ability to write u"..." (from 3.3) and b"..."%... (from 3.5

Re: Shall I worry about python2/3 compatibility when using library?

2018-08-30 Thread Cameron Simpson
On 30Aug2018 19:27, Stone Zhong wrote: I think the fact is: - There are still considerable amount of people still using python2 - Python2 user will eventually upgrade to python3 So any library not written in a compatible way will either break now for python2 user, or will break in the future f

Re: Shall I worry about python2/3 compatibility when using library?

2018-08-30 Thread Stone Zhong
On Thursday, August 30, 2018 at 10:19:34 PM UTC-7, Terry Reedy wrote: > On 8/30/2018 10:27 PM, Stone Zhong wrote: > > Hi there, > > > > I think the fact is: > > - There are still considerable amount of people still using python2 > > - Python2 user will eventually upgrade to python3 > > > > So any

Re: Shall I worry about python2/3 compatibility when using library?

2018-08-30 Thread Terry Reedy
On 8/30/2018 10:27 PM, Stone Zhong wrote: Hi there, I think the fact is: - There are still considerable amount of people still using python2 - Python2 user will eventually upgrade to python3 So any library not written in a compatible way will either break now for python2 user, or will break in

Shall I worry about python2/3 compatibility when using library?

2018-08-30 Thread Stone Zhong
Hi there, I think the fact is: - There are still considerable amount of people still using python2 - Python2 user will eventually upgrade to python3 So any library not written in a compatible way will either break now for python2 user, or will break in the future for python3 user. So I suppose a

Re: Cannot pass a variable given from url to route's callback fucntion and redirect issue

2018-08-30 Thread Rurpy via Python-list
On Thursday, August 30, 2018 at 10:08:34 AM UTC-6, Νίκος Βέργος wrote: > I did try it with 'None' and as page='index.html' Flask return an error both > ways (while bottle framework does not) I think you are mistaken, making the change I suggested fixes the "TypeError: index() missing 1 required p

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-08-30 Thread pjmclenon
On Thursday, August 30, 2018 at 2:05:16 PM UTC-4, pjmc...@gmail.com wrote: > On Thursday, August 30, 2018 at 1:29:48 PM UTC-4, MRAB wrote: > > On 2018-08-30 17:57, pjmcle...@gmail.com wrote: > > > On Thursday, August 30, 2018 at 9:28:09 AM UTC-4, Steven D'Aprano wrote: > > >> On Thu, 30 Aug 2018 05

Re: __init__ patterns

2018-08-30 Thread Terry Reedy
On 8/30/2018 9:43 AM, Steven D'Aprano wrote: On Thu, 30 Aug 2018 06:01:26 -0700, Tim wrote: I saw a thread on reddit/python where just about everyone said they never put code in their __init__ files. Pfft. Reddit users. They're just as bad as Stackoverflow users. *wink* Here's a stackoverf

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-08-30 Thread pjmclenon
On Thursday, August 30, 2018 at 1:29:48 PM UTC-4, MRAB wrote: > On 2018-08-30 17:57, pjmcle...@gmail.com wrote: > > On Thursday, August 30, 2018 at 9:28:09 AM UTC-4, Steven D'Aprano wrote: > >> On Thu, 30 Aug 2018 05:21:30 -0700, pjmclenon wrote: > >> > >> > my question is ... at the moment i can

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-08-30 Thread MRAB
On 2018-08-30 17:57, pjmcle...@gmail.com wrote: On Thursday, August 30, 2018 at 9:28:09 AM UTC-4, Steven D'Aprano wrote: On Thu, 30 Aug 2018 05:21:30 -0700, pjmclenon wrote: > my question is ... at the moment i can only run it on windows cmd prompt > with a multiple line entry as so:: > > pyth

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-08-30 Thread pjmclenon
On Thursday, August 30, 2018 at 9:28:09 AM UTC-4, Steven D'Aprano wrote: > On Thu, 30 Aug 2018 05:21:30 -0700, pjmclenon wrote: > > > my question is ... at the moment i can only run it on windows cmd prompt > > with a multiple line entry as so:: > > > > python createIndex_tfidf.py stopWords.dat t

Re: Cannot pass a variable given from url to route's callback fucntion and redirect issue

2018-08-30 Thread Rurpy via Python-list
On Wednesday, August 29, 2018 at 10:57:35 AM UTC-6, Νίκος Βέργος wrote: > Flask app.py > == > @app.route( '/' ) > @app.route( '/' ) > def index( page ): > > # use the variable form template for displaying > counter = ''' > > td> Αριθμός Επισκεπτών: >

Re: Calling an unbound method in C using the Public API

2018-08-30 Thread Serhiy Storchaka
29.08.18 17:33, Matthieu Dartiailh пише: I tried to look at the public C API for a way to call an unbound method with a minimal cost (in term of speed and memory). It seems to me, but please correct me if I am wrong, that one cannot call a MethodDef using only the public API. To use the public

RE: How to sort over dictionaries

2018-08-30 Thread David Raymond
Remember to check what the res["date"] types actually are. If they're just text, then it looked like they were in M/D/Y format, which won't sort correctly as text, hence you might want to include using datetime.strptime() to turn them into sortable datetimes. -Original Message- From: P

Re: __init__ patterns

2018-08-30 Thread Steven D'Aprano
On Thu, 30 Aug 2018 06:01:26 -0700, Tim wrote: > I saw a thread on reddit/python where just about everyone said they > never put code in their __init__ files. Pfft. Reddit users. They're just as bad as Stackoverflow users. *wink* > Here's a stackoverflow thread saying the same thing. > https://

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-08-30 Thread Steven D'Aprano
On Thu, 30 Aug 2018 05:21:30 -0700, pjmclenon wrote: > my question is ... at the moment i can only run it on windows cmd prompt > with a multiple line entry as so:: > > python createIndex_tfidf.py stopWords.dat testCollection.dat > testIndex.dat titleIndex.dat > > and then to query and use the n

RE: __init__ patterns

2018-08-30 Thread Dan Strohl via Python-list
I will put imports into my __init__ files, so that I can import things from the module directly instead of having to import from a file in the module. I almost never put code in the __init__'s, I have a couple of times put in something that was designed to modify which routine was imported (i.e.

Re: __init__ patterns

2018-08-30 Thread Paul Moore
On Thu, 30 Aug 2018 at 14:07, Tim wrote: > > I saw a thread on reddit/python where just about everyone said they never put > code in their __init__ files. > > Here's a stackoverflow thread saying the same thing. > https://stackoverflow.com/questions/1944569/how-do-i-write-good-correct-package-ini

Re: Question about floating point

2018-08-30 Thread Steven D'Aprano
On Thu, 30 Aug 2018 19:22:29 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Why in the name of all that's holy would anyone want to manually round >> each and every intermediate calculation when they could use the Decimal >> module and have it do it automatically? > > I agree that Decima

__init__ patterns

2018-08-30 Thread Tim
I saw a thread on reddit/python where just about everyone said they never put code in their __init__ files. Here's a stackoverflow thread saying the same thing. https://stackoverflow.com/questions/1944569/how-do-i-write-good-correct-package-init-py-files That's new to me. I like to put functio

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-08-30 Thread pjmclenon
On Thursday, August 30, 2018 at 8:21:47 AM UTC-4, pjmc...@gmail.com wrote: > On Wednesday, June 13, 2018 at 7:14:06 AM UTC-4, INADA Naoki wrote: > > ​> 1st is this script is from a library module online open source > > > > If it's open source, why didn't you show the link to the soruce? > > I assu

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-08-30 Thread pjmclenon
On Wednesday, June 13, 2018 at 7:14:06 AM UTC-4, INADA Naoki wrote: > ​> 1st is this script is from a library module online open source > > If it's open source, why didn't you show the link to the soruce? > I assume your code is this: > > https://github.com/siddharth2010/String-Search/blob/6770c7

Re: How to sort over dictionaries

2018-08-30 Thread harish
> > sort = sorted(results, key=lambda res:itemgetter('date')) > > print(sort) > > > > > > I have tried the above code peter but it was showing error like > > TypeError: '<' not supported between instances of 'operator.itemgetter' > > and 'operator.itemgetter' > > lambda res: itemgetter('

Re: Question about floating point

2018-08-30 Thread Gregory Ewing
Steven D'Aprano wrote: Why in the name of all that's holy would anyone want to manually round each and every intermediate calculation when they could use the Decimal module and have it do it automatically? I agree that Decimal is the safest and probably easiest way to go, but saying that it "d