[Tutor] Tutor Digest, Vol 135, Issue 12

Siya 360 siya360 at gmail.com
Tue May 5 09:17:52 CEST 2015


Hi,

Twice i unsubscribed to this mailing list, and i still continue to get them, why?

Please remove with immediate effect as this course has not served me well too many of my enquires went unanswered so i see no use for it, just flooding my mailbox

Kind Regards,
Siya

 
> On 05 May 2015, at 1:26 AM, tutor-request at python.org wrote:
> 
> Send Tutor mailing list submissions to
> 	tutor at python.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	https://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
> 	tutor-request at python.org
> 
> You can reach the person managing the list at
> 	tutor-owner at python.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
> 
> 
> Today's Topics:
> 
>   1. Re: Sieve of Erastthotenes without sofisticated tools (Dave Angel)
>   2. Re: trouble with stringio function in python 3.2 (eryksun)
>   3. Jacob Kaplan-Moss's keynote at PyCon 2015 (Danny Yoo)
>   4. Integrating TDD into my current project work-flows (WolfRage)
>   5. Re: Integrating TDD into my current project work-flows
>      (Martin A. Brown)
>   6. Re: Python program malfunction (Jag Sherrington)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Mon, 04 May 2015 06:00:24 -0400
> From: Dave Angel <davea at davea.name>
> To: tutor at python.org
> Subject: Re: [Tutor] Sieve of Erastthotenes without sofisticated tools
> Message-ID: <55474338.6050407 at davea.name>
> Content-Type: text/plain; charset=windows-1252; format=flowed
> 
> On 05/04/2015 03:19 AM, yvan moses Levy wrote:
>> My code is wrong!
> 
> You'd find it a lot easier to get responses if you'd say in what way the 
> code is wrong.  If you get an exception, show the full traceback.  If 
> you get printed results, show what you expected, and what you got 
> instead.  If it hung, or crashed the OS, or ran out of memory, say so.
> 
>> I tried and tried
>> But I'm very isolated and It's hard without consultation with a tutor
>> <code>from math import sqrt
>> def holeofStrainer():
>>   bigList = [False, False] + [True]*100
>>   print("line 4 - bigList : ", bigList)
>>   for num in range(2, 101):
>>     print("line 6 - num : ", num)
>>     for x in range(bigList[2], bigList[int(sqrt(num)) + 1]):
> 
> What did you expect this to do?  What is bigList[2] ?  What is 
> bigList[int(sqrt(num)) + 1] ?  Are these reasonable values to put into a 
> range() function?
> 
> 
> 
>>       print("line 8 x : %d"%x)
>>       if num % x == 0:
>>         print("line 10 {0} divise par {1} = {2} ".format(num, x, num/x))
>>         bigList[num] == False
>>         print "bigList[{0} == {1}]".format(num, bigList[num])
>>       bigList[num] == True
>> 
>>     for multiple in range (2, int(101/num) + 1):
>>       bigList[multiple] = False
>>   return(bigList)
>> print("the last result of bigList {} ".format(holeofStrainer()))</code>
>> I WANT TO KNOW WHILE THE EXECUTION DO NOT GOING DOWNWARD
>> 
>> --
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
>> 
>> 
> 
> 
> -- 
> DaveA
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Mon, 4 May 2015 09:58:05 -0500
> From: eryksun <eryksun at gmail.com>
> To: Chris Warrick <kwpolska at gmail.com>
> Cc: tutor at python.org
> Subject: Re: [Tutor] trouble with stringio function in python 3.2
> Message-ID:
> 	<CACL+1at3QzV=iQMfpZe6UM_kt2ETc8x_W+n4QAhfouio2rb6Jw at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
> 
> On Mon, May 4, 2015 at 2:46 AM, Chris Warrick <kwpolska at gmail.com> wrote:
>> Python 3.0?3.2 do not support the u'' notation for Unicode strings, it
>> was restored in Python 3.3 to make it easier to write code compatible
>> with 2.x and 3.x
> 
> Whoever restored this forgot about raw literals:
> 
>>>> ur'abc'
>      File "<stdin>", line 1
>        ur'abc'
>              ^
>    SyntaxError: invalid syntax
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Mon, 4 May 2015 10:03:31 -0700
> From: Danny Yoo <dyoo at hashcollision.org>
> To: Python Tutor Mailing List <tutor at python.org>
> Subject: [Tutor] Jacob Kaplan-Moss's keynote at PyCon 2015
> Message-ID:
> 	<CAGZAPF4WV=BPRUso2oTDphU9nEg6deJ03BjV+0J1hdGnxy+DaA at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
> 
> Apologies: this is somewhat off-topic, but I thought it might resonate
> with the audience here:
> 
>    https://www.youtube.com/watch?v=hIJdFxYlEKE
> 
> It reminds me of Camille Fournier's talk back in 2014 at BangBangCon:
> 
>    https://www.youtube.com/watch?v=sc8sc-ELMhA
> 
> Both express the experience of being a programmer, on the dangers of
> thinking of programming skill as some kind of bi-modal thing.  A key
> point in both their talks, I think, is that almost all of us aren't
> born natural programmers.  It's a skill.  We stumble, we learn, and we
> can get better at it.
> 
> 
> I hope that's an encouraging thought.
> 
> 
> ------------------------------
> 
> Message: 4
> Date: Mon, 04 May 2015 15:04:31 -0400
> From: WolfRage <wolfrage8765 at gmail.com>
> To: Python Tutor Mailing List <tutor at python.org>
> Subject: [Tutor] Integrating TDD into my current project work-flows
> Message-ID: <5547C2BF.7050100 at gmail.com>
> Content-Type: text/plain; charset=utf-8; format=flowed
> 
> I would like some help integrating TDD into my current projects.
> My chosen TDD framework is unittest from the standard library.
> My system details are: Linux Mint 17.1 64-bit, Python 3.4, bzr(for 
> version control).
> 
> My projects are structured like:
> Project > develop > Project > Project > __main__.py
>                               tests   > __main__.py
> I want to be able to execute my Project from a cwd of:
> Project/develop/Project
> as: Python3 -m Project
> That currently works.
> But executing my tests as: Python3 -m tests
> requires that test_Project.py has this hack to import the Project module:
> sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
> do you consider that OK? Is there a better way?
> I call it a hack because every testcase file will have to have this line 
> added to it in order to work.
> 
> I am also using coverage.py and it is good but seems to be testing the 
> coverage of my tests, which is not desired, how can I stop this 
> behaviour. Or is it really OK.
> 
> Output of running the tests:
> python3 -m tests
> Ran Main.
> .
> ----------------------------------------------------------------------
> Ran 1 test in 0.001s
> 
> OK
> Name                 Stmts   Miss  Cover   Missing
> --------------------------------------------------
> Project/Project          3      0   100%
> tests/test_Project       8      0   100%
> --------------------------------------------------
> TOTAL                   11      0   100%
> 
> 
> The test files:
> {FileName = __main__.py}
> # -*- coding: utf-8 -*-
> if __name__ == '__main__':
>     import coverage
>     import unittest
>     cov = coverage.coverage()
>     cov.start()
>     # .. call your code ..
>     from .test_Project import ProjectTestCase  # lint:ok
>     unittest.main(exit=False)
>     cov.stop()
>     cov.save()
>     import sys
>     cov.report(file=sys.stdout)
> 
> 
> {FileName = test_Project.py}
> # -*- coding: utf-8 -*-
> import os
> import sys
> import unittest
> sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
> from Project import Project
> 
> 
> class ProjectTestCase(unittest.TestCase):
> 
>     def test_example(self):
>         self.assertTrue(Project.main())
> 
> 
> The Project Files:
> {FileName = __main__.py}
> # -*- coding: utf-8 -*-
> 
> if __name__ == '__main__':
>     from . import Project
>     Project.main()
> 
> {FileName = Project.py}
> # -*- coding: utf-8 -*-
> 
> 
> def main():
>     return True
> 
> 
> ------------------------------
> 
> Message: 5
> Date: Mon, 4 May 2015 13:49:44 -0700
> From: "Martin A. Brown" <martin at linux-ip.net>
> To: WolfRage <wolfrage8765 at gmail.com>
> Cc: Python Tutor Mailing List <tutor at python.org>
> Subject: Re: [Tutor] Integrating TDD into my current project
> 	work-flows
> Message-ID: <alpine.LSU.2.11.1505041332210.31213 at znpeba>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
> 
> 
> Hi there,
> 
>> I would like some help integrating TDD into my current projects. 
>> My chosen TDD framework is unittest from the standard library. My 
>> system details are: Linux Mint 17.1 64-bit, Python 3.4, bzr(for 
>> version control).
>> 
>> My projects are structured like:
>> Project > develop > Project > Project > __main__.py
>>                             tests   > __main__.py
>> I want to be able to execute my Project from a cwd of:
>> Project/develop/Project
>> as: Python3 -m Project
>> That currently works.
>> But executing my tests as: Python3 -m tests
>> requires that test_Project.py has this hack to import the Project module:
>> sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
> 
> Yes, a bit ugly.  Have you tried using nose?  I have used a 
> similar project development tree and use nose to run the tests.
> 
> Here are a few sample command-lines (I'm on an opensuse-13.2 system 
> with Python 3.4 and nose for Python-3.4, which is called 
> 'nosetests-3.4'):
> 
>   nosetests-3.4 -- ./tests/
>   nosetests-3.4 --with-coverage -- ./tests/
>   nosetests-3.4 --with-coverage --cover-package=Project -- ./tests/
> 
> I like nose because it will discover any unittest and doctest 
> testing code under the specified files/directories.
> 
>> do you consider that OK? Is there a better way?
> 
>> I call it a hack because every testcase file will have to have 
>> this line added to it in order to work.
> 
> Agreed, is a hack.
> 
>> I am also using coverage.py and it is good but seems to be testing 
>> the coverage of my tests, which is not desired, how can I stop 
>> this behaviour. Or is it really OK.
> 
> That's precisely what coverage is supposed to do--that is it should 
> report on how much of the 'code under test' has been exercised by 
> the testing code.  So, in fact, it's better than OK--it's the 
> primary point!
> 
> There are two good things about using coverage.
> 
>   #1: You see how much more effort you should invest to get
>       substantial testing coverage of the code under test.
>       [Though, some code is easy to test and others very difficult.]
> 
>   #2: You get a report of the lines in the code under test which are
>       NOT yet tested; handy!
> 
> Good luck,
> 
> -Martin
> 
> -- 
> Martin A. Brown
> http://linux-ip.net/
> 
> 
> ------------------------------
> 
> Message: 6
> Date: Mon, 4 May 2015 23:08:13 +0000 (UTC)
> From: Jag Sherrington <braveart08 at yahoo.com.au>
> To: Alan Gauld <alan.gauld at btinternet.com>,  "tutor at python.org"
> 	<tutor at python.org>
> Subject: Re: [Tutor] Python program malfunction
> Message-ID:
> 	<1061178286.1841397.1430780893043.JavaMail.yahoo at mail.yahoo.com>
> Content-Type: text/plain; charset=UTF-8
> 
> Hi, Alan> Enter the item's wholesale cost: 0.50?(AFTER THIS LINE PRINTS I HIT ENTER AND WOULD EXPECT THE NEXT LINE TO GIVE ME THE RESULT> Enter the item's wholesale cost: ? ?"Retail price: $1.25" ?INSTEAD WHEN I HIT ENTER I GET "Enter the item's wholesale cost: " AGAIN AND AGAIN
> Regards, Jag
> BraveArt Multimedia
> 
> 
> 
> 
>     On Monday, 4 May 2015, 17:35, Alan Gauld <alan.gauld at btinternet.com> wrote:
> 
> 
> On 04/05/15 05:26, Jag Sherrington wrote:
>> Hi,
>> There appears to be a problem with this program.
>> It is taken from the "Starting out with Python" book third edition.
>> 
>> The problem is when the "validate the wholesale cost" is introduced.
>> Without the validator the code works fine, but with it the code won't let you enter a positive wholesale cost unless you do a negative cost first.
>> Even after you have entered a negative cost and got the results of your positive cost it asks wether you want to do another item if you type "y" you still can't enter a positive amount.
>> 
>> HERE IS THE CODE AS COPIED FROM THE BOOK:
>> 
>> #This program calculates retail prices.
>> 
>> mark_up = 2.5? # The mark up percentage.
>> another = 'y'? # Variable to control the loop.
>> 
>> # Process one or more items.
>> while another == 'y' or another == 'y':
> 
> That's the same test twice. Is that what you meant?
> 
>> ? ? ? #Get the item 's wholesale cost'
>> ? ? ? wholesale = float(input("Enter the item's wholesale cost: "))
>> 
>> ? ? ? # Validate the wholesale cost.
>> ? ? ? while wholesale < 0:
>> ? ? ? ? ? print('ERROR: the cost cannot be negative.')
>> ? ? ? ? ? wholesale = float(input('Enter the correct wholesale cost: '))
>> 
>> ? ? ? ? ? #Calculate the retail price.
>> ? ? ? ? ? retail = wholesale * mark_up
>> 
>> ? ? ? ? ? #Display the retail price.
>> ? ? ? ? ? print('Retail price: $', format(retail, ',.2f'), sep='')
>> 
>> ? ? ? ? ? #Do this again.
>> ? ? ? ? ? another = input('Do you have another item? ' + \
>> ? ? ? ? ? ? ? ? ? ? ? ? ? '(Enter y for yes): ')
>> 
>> HERE ARE THE RESULTS:
>> 
>> Enter the item's wholesale cost: 0.50
>> Enter the item's wholesale cost:? ? (THIS SEEMS TO BE A PROBLEM)
> 
> No problem, its exactly what your program tells it to do.
> If the cost is >0 there is nothing else to do so it goes
> round the loop a second time.
> 
> What did you expect it to do?
> 
> 
> HTH
> -- 
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
> 
> 
> _______________________________________________
> Tutor maillist? -? Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
> 
> 
> 
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> https://mail.python.org/mailman/listinfo/tutor
> 
> 
> ------------------------------
> 
> End of Tutor Digest, Vol 135, Issue 12
> **************************************



More information about the Tutor mailing list