Re: how to setup for localhost:8000

2016-04-15 Thread Chris Angelico
On Fri, Apr 15, 2016 at 3:59 PM, Vito De Tullio wrote: > Chris Angelico wrote: > >>> Just a note, some browsers will try to resolve this as www.localhost.com >>> - try http://127.0.0.1:8000 . >> >> Huh? Why should the name 'localhost' get a dot com added? > > ask browser vendors... I'd more ask y

Re: How to parameterize unittests

2016-04-15 Thread Chris Angelico
On Fri, Apr 15, 2016 at 4:52 PM, Antoon Pardon wrote: > Op 14-04-16 om 17:05 schreef Steven D'Aprano: >> On Fri, 15 Apr 2016 12:08 am, Antoon Pardon wrote: >> >>> I have a unittest for my avltree module. >>> >>> Now I want this unittest to also run on a subclass of avltree. >>> How can I organise

Re: How to parameterize unittests

2016-04-15 Thread Antoon Pardon
Op 15-04-16 om 09:42 schreef Chris Angelico: > On Fri, Apr 15, 2016 at 4:52 PM, Antoon Pardon > wrote: >> Op 14-04-16 om 17:05 schreef Steven D'Aprano: >>> On Fri, 15 Apr 2016 12:08 am, Antoon Pardon wrote: >>> I have a unittest for my avltree module. Now I want this unittest to als

Re: How to parameterize unittests

2016-04-15 Thread Serhiy Storchaka
On 14.04.16 18:05, Steven D'Aprano wrote: On Fri, 15 Apr 2016 12:08 am, Antoon Pardon wrote: I have a unittest for my avltree module. Now I want this unittest to also run on a subclass of avltree. How can I organise this, so that I can largely reuse the original TestCase? class Test_AVLTree(

Re: How to parameterize unittests

2016-04-15 Thread Chris Angelico
On Fri, Apr 15, 2016 at 6:20 PM, Antoon Pardon wrote: > But the tests, at this moment, are not written to instantiate self.tree > but to call avltree directly. So I have to rewrite these tests. That > will IMO involve a lot of cut and paste. Ah. In that case, it either involves a lot of editing (

Re: How to parameterize unittests

2016-04-15 Thread Serhiy Storchaka
On 15.04.16 11:20, Antoon Pardon wrote: But the tests, at this moment, are not written to instantiate self.tree but to call avltree directly. So I have to rewrite these tests. That will IMO involve a lot of cut and paste. There is yet one approach. Import your original test file, patch it by s

Re: How to parameterize unittests

2016-04-15 Thread Ben Finney
Antoon Pardon writes: > But the tests, at this moment, are not written to instantiate > self.tree but to call avltree directly. That is exactly what the ‘TestCase.setUp’ method is for: to have the test case class specify how its test cases will customise themselves. class AVLTree_TestCase(u

Re: Serious error in int() function?

2016-04-15 Thread blindanagram
On 15/04/2016 01:36, Dennis Lee Bieber wrote: > On Thu, 14 Apr 2016 13:07:03 +0100, blindanag...@nowhere.net declaimed the > following: > >> On 14/04/2016 09:13, blindanag...@nowhere.net wrote: >>> On 14/04/2016 08:59, blindanag...@nowhere.net wrote: On 14/04/2016 07:52, ast wrote: >>> T

Re: How to parameterize unittests

2016-04-15 Thread Steven D'Aprano
On Fri, 15 Apr 2016 06:20 pm, Antoon Pardon wrote: class Test_MySubclassTree(Test_AVLTree): tree = My_Subclass_Tree >>> I see, that's going to be a lot of cut & pastes. >>> Thanks. >> Not really; the first class has all the tests, and the second one is >> literally just those two lines.

Re: sum accuracy

2016-04-15 Thread Robin Becker
On 13/04/2016 18:05, Random832 wrote: . No, it doesn't. Sum works on any type that can be added (except strings), it can't make any assumptions about the characteristics of floating point types. For non-numeric types, the addition operator may not be semantically commutative or associati

Re: sum accuracy

2016-04-15 Thread Oscar Benjamin
On 15 April 2016 at 10:24, Robin Becker wrote: > On 13/04/2016 18:05, Random832 wrote: > . >> >> >> No, it doesn't. Sum works on any type that can be added (except >> strings), it can't make any assumptions about the characteristics of >> floating point types. For non-numeric types, the ad

Re: How to parameterize unittests

2016-04-15 Thread Michael Selik
On Fri, Apr 15, 2016, 11:16 AM Steven D'Aprano wrote: > On Fri, 15 Apr 2016 06:20 pm, Antoon Pardon wrote: > > >>> I see, that's going to be a lot of cut & pastes. > > (3) In your editor, run a global Find and Replace "avltree -> self.tree". > You will need to inspect each one rather than do it a

Re: sum accuracy

2016-04-15 Thread Ben Bacarisse
Oscar Benjamin writes: > On 15 April 2016 at 10:24, Robin Becker wrote: >> yes indeed summation is hard :( > > Not with Fraction it isn't: > > from fractions import Fraction > > def exact_sum(nums): > return sum(map(Fraction, nums)) > > This will give you the exact result with precisely zer

Python garbage collection: not releasing memory to OS!

2016-04-15 Thread cshintov
I have written an application with flask and uses celery for a long running task. While load testing I noticed that the celery tasks are not releasing memory even after completing the task. So I googled and found this group discussion.. https://groups.google.com/forum/#!topic/celery-users/jVc3I

Re: sum accuracy

2016-04-15 Thread Tony van der Hoff
On 15/04/16 11:10, Ben Bacarisse wrote: Oscar Benjamin writes: On 15 April 2016 at 10:24, Robin Becker wrote: yes indeed summation is hard :( Not with Fraction it isn't: from fractions import Fraction def exact_sum(nums): return sum(map(Fraction, nums)) This will give you the exa

Re: Serious error in int() function?

2016-04-15 Thread John Pote
On 15/04/2016 03:38, Christian Gollwitzer wrote: Am 15.04.16 um 02:36 schrieb Dennis Lee Bieber: I should also have said that the square root of integer squares with between 15 and 30 decimal digits will only be correct if the square numbers themselves are exactly representable in 53 bits. So

Re: sum accuracy

2016-04-15 Thread Jussi Piitulainen
Tony van der Hoff writes: > On 15/04/16 11:10, Ben Bacarisse wrote: >> Oscar Benjamin writes: >> >>> On 15 April 2016 at 10:24, Robin Becker wrote: >> yes indeed summation is hard :( >>> >>> Not with Fraction it isn't: >>> >>> from fractions import Fraction >>> >>> def exact_sum(nums): >>>

Re: How to parameterize unittests

2016-04-15 Thread Antoon Pardon
Op 15-04-16 om 11:10 schreef Steven D'Aprano: > If you have code which is not parameterized, and you want to parameterize > it, you have to refactor. Unit tests are no different from anything else. I don't agree with that. If I have a piece of code that I want to parameterize, Often enough all I n

Re: How to XOR a byte output?

2016-04-15 Thread durgadevi1
On Wednesday, April 13, 2016 at 9:18:37 PM UTC+8, durgadevi1 wrote: > Hi all, > > I have a doubt regarding a problem. > > First, I am required to read a given file. > > > The output from the file is given below: > > b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\' > > > I used the type() to identify

Re: Serious error in int() function?

2016-04-15 Thread alister
On Fri, 15 Apr 2016 12:05:18 +0100, John Pote wrote: > On 15/04/2016 03:38, Christian Gollwitzer wrote: >> Am 15.04.16 um 02:36 schrieb Dennis Lee Bieber: > I should also have said that the square root of integer squares with > between 15 and 30 decimal digits will only be correct if the s

Static files load problem Django 1.9

2016-04-15 Thread asimkon .
I have got a problem with static files regarding Django 1.9. These files are (js,css) in the standard folder static, inside project folder directory. I got an error Http 404 that can not be loaded. Project folder / static / css / several files *.css /static / js / several file

How to print a part of a string?

2016-04-15 Thread durgadevi1
Hello all, I have another homework problem. I have a textfile. It contains lines of string. I am required to only print out a certain part of the string. For example the textfile contain: ABC X N BCD Q E ABC W A I need to print all the parts that come after only ABC.

Re: How to print a part of a string?

2016-04-15 Thread Joel Goldstick
On Fri, Apr 15, 2016 at 8:13 AM, durgadevi1 wrote: > Hello all, > > I have another homework problem. > > I have a textfile. It contains lines of string. > > I am required to only print out a certain part of the string. > > For example the textfile contain: > > ABC X N > BCD Q E > A

Re: How to parameterize unittests

2016-04-15 Thread Antoon Pardon
Op 15-04-16 om 13:43 schreef Antoon Pardon: > Op 15-04-16 om 11:10 schreef Steven D'Aprano: >> If you have code which is not parameterized, and you want to parameterize >> it, you have to refactor. Unit tests are no different from anything else. > I don't agree with that. If I have a piece of code

Re: Python garbage collection: not releasing memory to OS!

2016-04-15 Thread Oscar Benjamin
On 15 April 2016 at 11:25, wrote: > The input was a 4MB file. Even after returning from the 'fileopen' function > the 4MB memory was not released. I checked htop output while the loop was > running, the resident memory stays at 14MB. So unless the process is stopped > the memory stays with it.

Re: sum accuracy

2016-04-15 Thread Oscar Benjamin
On 15 April 2016 at 11:10, Ben Bacarisse wrote: > Oscar Benjamin writes: > >> On 15 April 2016 at 10:24, Robin Becker wrote: > >>> yes indeed summation is hard :( >> >> Not with Fraction it isn't: >> >> from fractions import Fraction >> >> def exact_sum(nums): >> return sum(map(Fraction, nu

Re: Python garbage collection: not releasing memory to OS!

2016-04-15 Thread Michael Torrie
On 04/15/2016 04:25 AM, cshin...@gmail.com wrote: > The input was a 4MB file. Even after returning from the 'fileopen' > function the 4MB memory was not released. I checked htop output while > the loop was running, the resident memory stays at 14MB. So unless > the process is stopped the memory sta

RE: How to print a part of a string?

2016-04-15 Thread Dan Strohl via Python-list
As with lots of things in python, there are lots of ways of approaching this, here are some hints for you to think about (in no particular order): - REGEX - replace() - string[:y] - split() And of course, you could consider creating a table with every possible string that could start with "ABC

Re: Python garbage collection: not releasing memory to OS!

2016-04-15 Thread Sam
On 04/15/2016 05:25 AM, cshin...@gmail.com wrote: I have written an application with flask and uses celery for a long running task. While load testing I noticed that the celery tasks are not releasing memory even after completing the task. So I googled and found this group discussion.. https:

help install numpy and scipy in window 7 and 3.5.0 shell

2016-04-15 Thread wrh8609
Hi all, I have downloaded the numpy-1.11.01 and scipy-0.17.0 but after running setup files over IDLE in numpy and scipy, it still can not get through. Can someone give me a hand? or you can provide the installation instruction for both. Thanks, Wen-Ruey -- https://mail.python.org/mailman/list

Re: help install numpy and scipy in window 7 and 3.5.0 shell

2016-04-15 Thread Bob Gailer
On Apr 15, 2016 10:40 AM, wrote: > > Hi all, > > I have downloaded the numpy-1.11.01 and scipy-0.17.0 but after running setup files over IDLE in numpy and scipy, it still can not get through. Can someone give me a hand? or you can provide the installation instruction for both. Can you be more spe

Re: Static files load problem Django 1.9

2016-04-15 Thread justin walters
On Fri, Apr 15, 2016 at 5:13 AM, asimkon . wrote: > I have got a problem with static files regarding Django 1.9. These files > are (js,css) in the standard folder static, inside project folder > directory. I got an error Http 404 that can not be loaded. > > Project folder / static / css / severa

Re: help install numpy and scipy in window 7 and 3.5.0 shell

2016-04-15 Thread wrh8609
On Friday, April 15, 2016 at 10:56:28 AM UTC-4, Bob Gailer wrote: > On Apr 15, 2016 10:40 AM, wrote: > > > > Hi all, > > > > I have downloaded the numpy-1.11.01 and scipy-0.17.0 but after running > setup files over IDLE in numpy and scipy, it still can not get through. Can > someone give me a hand

Re: How to parameterize unittests

2016-04-15 Thread Steven D'Aprano
On Fri, 15 Apr 2016 10:48 pm, Antoon Pardon wrote: > Starting from this: > > class Test_AVLTree(unittest.TestCase): > > def test_empty_tree_is_false(self): > instance = avltree() > self.assertFalse(instance) > > Changing it into this: > > def MakeAVLTes

Re: sum accuracy

2016-04-15 Thread Ben Bacarisse
Oscar Benjamin writes: > On 15 April 2016 at 11:10, Ben Bacarisse wrote: >> Oscar Benjamin writes: >> >>> On 15 April 2016 at 10:24, Robin Becker wrote: >> yes indeed summation is hard :( >>> >>> Not with Fraction it isn't: >>> >>> from fractions import Fraction >>> >>> def exact_sum(num

Re: sum accuracy

2016-04-15 Thread Matt Wheeler
So we could build on this On 15 April 2016 at 11:10, Ben Bacarisse wrote: >> from fractions import Fraction >> >> def exact_sum(nums): >> return sum(map(Fraction, nums)) >> >> This will give you the exact result with precisely zero rounding >> error. You can convert it to float at the end. >

Re: How to parameterize unittests

2016-04-15 Thread Chris Angelico
On Sat, Apr 16, 2016 at 2:47 AM, Steven D'Aprano wrote: > If the tests for your AVL tree and it's subclasses are *identical*, then > what's the point of the subclasses? If the tree classes all have the same API but different performance trade-offs, it would make sense to use all the same tests to

Re: Looking for feedback on weighted voting algorithm

2016-04-15 Thread sohcahtoa82
On Thursday, April 14, 2016 at 1:48:40 PM UTC-7, Michael Selik wrote: > On Thu, Apr 14, 2016, 7:37 PM justin walters > wrote: > > > On Apr 14, 2016 9:41 AM, "Martin A. Brown" wrote: > > > > > > > > > Greetings Justin, > > > > > > >score = sum_of_votes/num_of_votes > > > > > > >votes = [(72,

Re: python3 - No module named 'html5lib'

2016-04-15 Thread Sergio Spina
Il giorno giovedì 14 aprile 2016 17:54:00 UTC+2, Wildman ha scritto: > On Thu, 14 Apr 2016 02:31:59 -0700, Sergio Spina wrote: > > > I'm running a python3 program that requires html5lib but I receive the > > error No module named 'html5lib'. > > > > Here are two session of terminal: > > > >

Re: how to setup for localhost:8000

2016-04-15 Thread Pierre Quentel
Le jeudi 14 avril 2016 22:50:33 UTC+2, wrh...@gmail.com a écrit : > On Thursday, April 14, 2016 at 2:23:36 PM UTC-4, Andrew Farrell wrote: > > What happens when you type > > > > http://localhost:8000 > > > > Into the address bar of your browser as this is running? > > > > On Thu, Apr 14, 2016 at

Re: help install numpy and scipy in window 7 and 3.5.0 shell

2016-04-15 Thread Martin Schöön
Den 2016-04-15 skrev wrh8...@gmail.com : > On Windows (at work) I use Python(x,y) http://python-xy.github.io/ It has yet to fail me. /Martin -- https://mail.python.org/mailman/listinfo/python-list

Re: help install numpy and scipy in window 7 and 3.5.0 shell

2016-04-15 Thread Oscar Benjamin
On 15 April 2016 at 17:29, wrote: >> On Apr 15, 2016 10:40 AM, wrote: >> > >> > I have downloaded the numpy-1.11.01 and scipy-0.17.0 but after running >> setup files over IDLE in numpy and scipy, it still can not get through. Can >> someone give me a hand? or you can provide the installation ins

Re: Looking for feedback on weighted voting algorithm

2016-04-15 Thread Michael Selik
On Fri, Apr 15, 2016, 7:56 PM wrote: > On Thursday, April 14, 2016 at 1:48:40 PM UTC-7, Michael Selik wrote: > > I suggest not worrying about sanitizing inputs. If someone provides bad > > data, Python will do the right thing: stop the program and print an > > explanation of what went wrong, ofte

Re: sys.exit(1) vs raise SystemExit vs raise

2016-04-15 Thread cs
On 12Apr2016 18:20, Ganesh Pal wrote: I m on python 2.7 and Linux , I have a simple code need suggestion if I I could replace sys.exit(1) with raise SystemExit . ==Actual code== def main(): try: create_logdir() create_dataset() unittest.main() except Exception as

Re: good way to avoid recomputations?

2016-04-15 Thread Mike
On Tuesday, April 5, 2016 at 4:54:50 PM UTC-4, Maurice wrote: > Hi. I working on a project where I have 5 scripts loading the same file at > the very beginning so I would like to know the best way I can get this file > without having to compute it 5 times. > > I also perform, in all the scripts,

Re: sys.exit(1) vs raise SystemExit vs raise

2016-04-15 Thread Ben Finney
c...@zip.com.au writes: > My preferred pattern is like this: > > def main(argv): >try: > ... >except Exception as e: > logging.exception(e) > return 1 > > if __name__ == '__main__': >sys.exit(main(sys.argv)) > > Notice that main() is back to being a normal function wit

Guido sees the light: PEP 8 updated

2016-04-15 Thread Steven D'Aprano
Until now, PEP 8 has recommended that multi-line expressions should break *after* infix operators: result = (this_value * some_value + another_value - excess_value or default_value ) After a mercifully short discussion on the Python-Ideas mailin

Python 2.7

2016-04-15 Thread a3a95797
Sirs(s) I wish to have python 2.7 on a computer. I have not been able to get a working copy to work on my machine. I am prepared to follow instructions or to pay someone to install Python on my computer. Either the Debian or the Windows operating system is satisfactory. I am prepared to pa

Re: Python 2.7

2016-04-15 Thread Chris Angelico
On Sat, Apr 16, 2016 at 8:48 AM, a3a95797 wrote: > > Sirs(s) > > I wish to have python 2.7 on a computer. I have not been able to get a > working copy to work on my machine. I am prepared to follow instructions or > to pay someone to install Python on my computer. Either the Debian or the >

Re: sys.exit(1) vs raise SystemExit vs raise

2016-04-15 Thread Stephen Hansen
> * You can use named constants from ‘os’ for the purpose of specifying > exit status numbers. Only on *nix. Even then it varies from platform to platform which constants you can use. I'd prefer to document the return status and use numbers/my own constants directly, that way supporting any p

Re: Python 2.7

2016-04-15 Thread Ben Finney
a3a95797 writes: > I wish to have python 2.7 on a computer. I have not been able to get a > working copy to work on my machine. Welcome! Thank you for learning Python. Please be aware that Python 2.7 is a dead end today. It will never get any new features, and only bug fixes will ever be made.