Re: Automatically advancing a bi-directional generator to the point of accepting a non-None value?
Go Luhng wrote at 2020-11-21 14:30 -0500: >Suppose we write a very simple bi-directional generator in Python: > >def share_of_total(): >s = 0 >new_num = 0 >while True: >new_num = yield new_num / (s or 1) >s += new_num > >share_calculator = share_of_total() >next(share_calculator) # Without this we get the TypeError > >for num in [1, 2, 3]: >print(share_calculator.send(num)) > >This generator just accepts a number and yields a float representing >its share of the sum of all previously provided numbers. > >We would ideally like to just use it immediately as follows: > >share_calculator = share_of_total() >print(share_calculator.send(num)) > >However, this causes `TypeError: can't send non-None value to a >just-started generator`. All users of the `share_of_total()` must >remember to execute `next(share_calculator)` before the generator is >usable as intended. When you want to automate things, you write a function. In your case, you have a generator function and you want that this generator function is called, then `next` is applied to the resulting generator; the resulting generator is what you actually want. >From this description, it should be easy to define a function which does precisely this for you. If you find that you regularly want to automate the initial `next`, you can implement your function as a so called "decorator", say `auto_next`. Then you can define generator functions with automatic `next` via: @auto_next def gen_fun(...): ... -- https://mail.python.org/mailman/listinfo/python-list
Error issue - Kindly resolve
Dear Sir/Madam,I am trying to install python on my laptop with windows 7, 32 bit operating system with service pac 1 installed. I have installed python 3.7.1 and some more versions but while opening the command prompt always it is showing the message as :The above program can’t start because api-ms-win-crt-runtime-|1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.Kindly resolve this issue and suggest the solution.Thanks and regardsSheetal M Chavan -- https://mail.python.org/mailman/listinfo/python-list
Re: Error issue - Kindly resolve
Hi, Sheetal, On Sun, Nov 22, 2020 at 2:44 PM sheetal chavan via Python-list wrote: > > Dear Sir/Madam,I am trying to install python on my laptop with windows 7, 32 > bit operating system with service pac 1 installed. I have installed python > 3.7.1 and some more versions but while opening the command prompt always it > is showing the message as :The above program can’t start because > api-ms-win-crt-runtime-|1-1-0.dll is missing from your computer. Try > reinstalling the program to fix this problem.Kindly resolve this issue and > suggest the solution.Thanks and regardsSheetal M Chavan Unfortunately we can't resolve it for you as we don't have access to your machine. But in reality - you are missing the Windows Runtime DLL. Google that name given to you in the error, download it and instal it (preferably from the MS site). Then you should be good to go. Thank you. > > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Error issue - Kindly resolve
On 2020-11-22 19:17, sheetal chavan via Python-list wrote: Dear Sir/Madam,I am trying to install python on my laptop with windows 7, 32 bit operating system with service pac 1 installed. I have installed python 3.7.1 and some more versions but while opening the command prompt always it is showing the message as :The above program can’t start because api-ms-win-crt-runtime-|1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.Kindly resolve this issue and suggest the solution.Thanks and regardsSheetal M Chavan Your PC is missing the Visual C++ Redistributable file api-ms-win-crt-runtime-l1-1-0.dll. You'll need to download and install it. The instructions are here: https://www.microsoft.com/en-in/download/details.aspx?id=48145 -- https://mail.python.org/mailman/listinfo/python-list
