[Tutor] Problem python script
Hello, I am using a script which extracts data from internet every Monday, but sometimes I have a problem that the script is not finishing properly. In terminal I stop it with Ctrl-C and the message it gives me is: File "castorama.py", line 255, in main p.map(get_all_data,magasins) File "/usr/lib/python3.5/multiprocessing/pool.py", line 260, in map return self._map_async(func, iterable, mapstar, chunksize).get() File "/usr/lib/python3.5/multiprocessing/pool.py", line 602, in get self.wait(timeout) File "/usr/lib/python3.5/multiprocessing/pool.py", line 599, in wait self._event.wait(timeout) File "/usr/lib/python3.5/threading.py", line 549, in wait Traceback (most recent call last): File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap self.run() File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run self._target(*self._args, **self._kwargs) File "/usr/lib/python3.5/multiprocessing/pool.py", line 108, in worker task = get() File "/usr/lib/python3.5/multiprocessing/queues.py", line 342, in get with self._rlock: Traceback (most recent call last): File "/usr/lib/python3.5/multiprocessing/synchronize.py", line 96, in __enter__ return self._semlock.__enter__() File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap self.run() KeyboardInterrupt File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run self._target(*self._args, **self._kwargs) File "/usr/lib/python3.5/multiprocessing/pool.py", line 108, in worker task = get() File "/usr/lib/python3.5/multiprocessing/queues.py", line 342, in get with self._rlock: File "/usr/lib/python3.5/multiprocessing/synchronize.py", line 96, in __enter__ return self._semlock.__enter__() KeyboardInterrupt Traceback (most recent call last): File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap self.run() File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run self._target(*self._args, **self._kwargs) File "/usr/lib/python3.5/multiprocessing/pool.py", line 108, in worker task = get() File "/usr/lib/python3.5/multiprocessing/queues.py", line 342, in get with self._rlock: File "/usr/lib/python3.5/multiprocessing/synchronize.py", line 96, in __enter__ return self._semlock.__enter__() KeyboardInterrupt signaled = self._cond.wait(timeout) File "/usr/lib/python3.5/threading.py", line 293, in wait waiter.acquire() KeyboardInterrupt Traceback (most recent call last): File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap self.run() File "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run self._target(*self._args, **self._kwargs) File "/usr/lib/python3.5/multiprocessing/pool.py", line 108, in worker task = get() File "/usr/lib/python3.5/multiprocessing/queues.py", line 343, in get res = self._reader.recv_bytes() File "/usr/lib/python3.5/multiprocessing/connection.py", line 216, in recv_bytes buf = self._recv_bytes(maxlength) File "/usr/lib/python3.5/multiprocessing/connection.py", line 407, in _recv_bytes buf = self._recv(4) File "/usr/lib/python3.5/multiprocessing/connection.py", line 379, in _recv chunk = read(handle, remaining) KeyboardInterrupt I am using map function on a list and a pool of processes. I attach a picture that show some information which I extract and I print everytime but as shown the script stopped to print and blocked so the left opportunity is to Ctrc-C. I would be really grateful If you could help me. Have a nice day. Antoan Hristov ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problem python script
On 19/12/17 09:47, Antoan Hristov wrote: > I am using a script which extracts data from internet every Monday, but > sometimes I have a problem that the script is not finishing properly. In > terminal I stop it with Ctrl-C and the message it gives me is: It is very hard to comment on code which you cannot see. Digging through the error messages might yield something but since they are triggered by your Ctrl-C rather than a code bug its not likely to be that helpful. -- 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@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] When do you know you're ready to start applying for jobs?
Why has no one mentioned Github/Gitlab? Set up a free account on either or both platforms, and start committing your code. When applying for jobs potential employers will often want to see what you're capable of even before inviting you for an interview, and many will ask for a github page to see your work and whether you're contributing to open source projects. They'll also want to see if your code is unit tested as they'll want to employ programmers who are happy and able to write unit tests and that understand the value of unit tests. It also goes to show that you understand and know how to use source control effectively as this will be a requirement for any software development company. https://about.gitlab.com/ https://github.com/ Gitlab offers better features than github and it's arguable a better git source control platform than github, that said, github has somehow become the defacto standard for open source projects. At the company where I work, we're also migrating to github enterprise. Demand for python programmers has grown over the years, reflected in the Tiobe index: https://www.tiobe.com/tiobe-index/ If you're able to write and understand what's happening on any of these projects (https://github.com/trending/python) then you're ready to start applying for jobs. Show off your skills via public git profiles and you should have something in no time, especially if you're not fussy! Programmers are in demand! Hope that helps and good luck. James ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Floating decimal question
On 2017-12-18, Roger Lea Scherer wrote: > This is my first time in this "forum", please be patient I will do my best. > > As I was going through a book and came across this challenge, I did what I > believe was a success. And I know there are ways of making the decimal > place be limited to 2 places, but my question is more of understanding why > the following happened. > > This is the code I wrote in python: > > bill = float(input("What is the price of the bill?: ")) > tip15 = bill*1.15 > tip20 = bill*1.20 > > print("Bill plus 15% gratuity is " + str(tip15)) > print("Bill plus 20% gratuity is " + str(tip20)) > > This is the result I got after I ran the code in an IDE > (obviously) and then entered 29.99 in the first line: > > What is the price of the bill?: 29.99 > Bill plus 15% gratuity is 34.4884995 > Bill plus 20% gratuity is 35.988 > > My question is why does the 15% gratuity go so far beyond the > decimal place when really there should only be 4 places because > of multiplication rules, you know, and I do understand > sometimes things work behind the scenes that you don't see, but > on the 20% gratuity it gives the "right" answer? So I guess I'm > just asking why did this happen like this? Decimal notation cannot represent every rational number. For example, you cannot write 1/3 in a straight-forward way, since the digit 3 repreats infinitely. Alan has given you a link which gives a lot more detail, but the gist is that the floating point representation computers use has an analogous limitation. It feels surprising at first because some of the numbers it can't represent in a finite way do have finite representations in decimal notation. For your specific problem, you can use Python's format function, for example: >>> for i in range(1, 11): print('{:.4f}'.format(1 / i)) 1. 0.5000 0. 0.2500 0.2000 0.1667 0.1429 0.1250 0. 0.1000 -- Neil Cerutti ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problem python script
Sent from my iPhone > On Dec 19, 2017, at 3:47 AM, Antoan Hristov wrote: > > Hello, > > I am using a script which extracts data from internet every Monday, but > sometimes I have a problem that the script is not finishing properly. In > terminal I stop it with Ctrl-C and the message it gives me is: > File "castorama.py", line 255, in main >p.map(get_all_data,magasins) > As Alan has said, knowing what is going on when the error was triggered by the ^C is difficult to impossible. What you may have to do is insert a fair number of “progress” statements that are all directed to a log file. Then, even if you have to stop execution with a ^C, you can still see what was happening or where it was spinning its wheels. With that info at your finger tips, you can zoom in with finer resolution and even dump the state of all the relevant variables. Bill > Antoan Hristov > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Code
Hi, We need help coding the range formula, and we don’t really know how to do it. This is the formula, R=(V2Sin2theangle)/(g). We are trying to solve for the angle. Thanks, Vinay ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Code
Welcome to Tutor! We won't do your homework for you, but will help you if you get stuck. Normally you would show us your current best coding effort and we would help you from there. On Tue, Dec 19, 2017 at 6:22 PM, Vinay Rao wrote: > Hi, > > We need help coding the range formula, and we don’t really know how to do it. > This is the formula, R=(V2Sin2theangle)/(g). We are trying to solve for the > angle. To get you started, I might suggest the following outline of what to do: 1) Put your range formula in proper mathematical form. Assuming your email formatting did not get mangled, you have a little bit of cleanup effort to get the formula right. Example, V is squared not V2. 2) Use your knowledge of algebra and trigonometry to solve for the angle. 3) Express this solution in Python terms, using "*" for multiplication, "/" for division, etc. Use understandable variable names. You will probably want to use the math standard library. Attempt this and if you get into trouble copy and paste both your actual code you tried to run and any error tracebacks into a plain text email and we will endeavor to help you along. HTH! -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor