Re: python decorator
On Wednesday 22 Feb 2017 08:49 CET, Argentinian Black ops lll wrote: > *** SOLVED *** It would be nice if you shared the solution. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list
I need help with a game in (turtle graphics - python)
Hi! How can i make the score stop blinking and how can i make a high score table, in this game made with python? (this game is made on a Macbook) (there are some files in the game that i don't haven't copied into this file! like pyth.GIF) #turtle game (take down the yellow astroides 1v1) import turtle import math import random import os #asks for players name print("player 1 uses W,A,S,D and player 2 are using arrow Up, Down, Left, Right.") print("write player 1's name") name1 = input() print("write player 2's name") name2 = input() #set up screen wn = turtle.Screen() wn.bgcolor("black") wn.bgpic("pyth.GIF") #borders mypen = turtle.Turtle() mypen.penup() mypen.setposition(-300,-300) mypen.pendown() mypen.pensize(3) mypen.color("white") mypen.left(90) mypen.forward(600) mypen.right(90) mypen.forward(600) mypen.right(90) mypen.forward(600) mypen.right(90) mypen.forward(600) mypen.hideturtle() #creates the scores score1 = 0 score2 = 0 #create player 1 player = turtle.Turtle() player.color("blue") player.shape("triangle") player.penup() player.speed(0) player.setposition(285, 285) #create player 2 player2 = turtle.Turtle() player2.color("white") player2.shape("triangle") player2.penup() player2.speed(0) player2.setposition(-285, -285) #creats goals maxGoals = 1 goals = [] for count in range(maxGoals): goals.append(turtle.Turtle()) goals[count].color("yellow") goals[count].shape("circle") goals[count].penup() goals[count].speed(0) goals[count].setposition(random.randint(-290, 290), random.randint(-290, 290)) #set speed variable speed = 3 #define functions def turnleft(): player.left(30) def turnright(): player.right(30) def turnright2(): player2.right(30) def turnleft2(): player2.left(30) def up(): player.forward(50) def up2(): player2.forward(50) def down(): player.right(180) def down2(): player2.right(180) def speedup(): global speed speed += 1 def stop(): global speed speed = 0 def reset(): goals[count].setposition(random.randint(-290, 290), random.randint(-290, 290)) player.setposition(random.randint(-290, 290), random.randint(-290, 290)) player2.setposition(random.randint(-290, 290), random.randint(-290, 290)) def isCollision(t1, t2): d = math.sqrt(math.pow(t1.xcor()-t2.xcor(),2) + math.pow(t1.ycor()-t2.ycor(),2)) if d < 20: return True else: return False #set keyboard bindings turtle.listen() turtle.onkey(turnleft, "a") turtle.onkey(turnleft2, "Left") turtle.onkey(turnright, "d") turtle.onkey(turnright2, "Right") turtle.onkey(speedup, "o") turtle.onkey(stop, "b") turtle.onkey(down, "s") turtle.onkey(down2, "Down") turtle.onkey(up, "w") turtle.onkey(up2, "Up") turtle.onkey(reset, "r") while True: player.forward(speed) player2.forward(speed) #boundary checking player if player.xcor() > 290 or player.xcor() < -290: player.right(180) os.system("afplay bing.mp3&") #boundary Checking player if player.ycor() > 290 or player.ycor() < -290: player.right(180) os.system("afplay bing.mp3&") #boundary checking player2 if player2.xcor() > 290 or player2.xcor() < -290: player2.right(180) os.system("afplay bing.mp3&") #boundary Checking player2 if player2.ycor() > 290 or player2.ycor() < -290: player2.right(180) os.system("afplay bing.mp3&") #boundary checking if goals[count].xcor() > 290 or goals[count].xcor() < -290: goals[count].right(180) os.system("afplay bing.mp3&") #boundary Checking if goals[count].ycor() > 290 or goals[count].ycor() < -290: goals[count].right(180) os.system("afplay bing.mp3&") #move ball for count in range(maxGoals): goals[count].forward(1) #collision checking with goals if isCollision(player, goals[count]): goals[count].setposition(random.randint(-300, 300), random.randint(-300, 300)) goals[count].right(random.randint(0,360)) os.system("afplay yes.mp3&") score1 += 2 speed += 0.5 #collision checking with goals if isCollision(player2, goals[count]): goals[count].setposition(random.randint(-300, 300), random.randint(-300, 300)) goals[count].right(random.randint(0,360)) os.system("afplay yes.mp3&") score2 += 2 speed += 0.5 #collision checking with player 2 if isCollision(player, player2): player.setposition(random.randint(-300, 300), random.randint(-290, 290)) player.right(random.randint(0,360)) os.system("afplay yes.mp3&") score1 -= 1 speed += 0.5 if isCollision(player2, player): player2
Re: python decorator
On Wed, 22 Feb 2017 08:47 pm, Cecil Westerhof wrote: > On Wednesday 22 Feb 2017 08:49 CET, Argentinian Black ops lll wrote: > >> *** SOLVED *** > > It would be nice if you shared the solution. I believe Cameron's post contains the bones of a solution. Here's my untested solution. def func_cache(cache): # Create a decorator that uses cache. def decorate(function): @functools.wraps(function) def wrapper(*args): try: result = cache[args] except KeyError: result = function(*args) cache[args] = result except TypeError: result = function(*args) return result return wrapper return decorate @func_cache({}): def something(x): ... -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Re: problems installing pylab
On Tuesday, February 21, 2017 at 3:55:40 PM UTC, Robert William Lunnon wrote: > Dear Python > > I am trying to install pylab alongside python 3.6. However when I type > > python -m pip install pylab > > I get the message > > No module named site > > In the documentation [documentation for installing python modules in > python 3.6.0 documentation] it says: The above example assumes that the > option to adjust the system PATH environment variable was selected when > installing python. > > How do I do this? > > I am running Windows 10 > > Looking forward to hearing from you > > Bob If you actually need matplotlib I suggest that you read this http://stackoverflow.com/questions/11469336/what-is-the-difference-between-pylab-and-pyplot Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
Re: I need help with a game in (turtle graphics - python)
Kasper wrote: > How can i make the score stop blinking The following part > #draws the score on the screen > mypen.undo() > mypen.penup() > mypen.hideturtle() > mypen.setposition(-290, 310) > scorestring1 = (name1 + ": %s" + " points ") %score1 > scorestring2 = (name2 + ": %s" + " points") %score2 > mypen.write(scorestring1 + scorestring2, False, align="left", > font=("Arial",14, "normal")) of your code removes what was written before and then draws something new, hence the blinking. One easy improvement is to call the above only when the score has changed: # untested ... # outside the loop: old_score1 = None old_score2 = None ... # in the loop: if old_score1 != score1 or old_score2 != score2: mypen.undo() mypen.penup() mypen.hideturtle() mypen.setposition(-290, 310) scorestring1 = (name1 + ": %s" + " points ") %score1 scorestring2 = (name2 + ": %s" + " points") %score2 mypen.write(scorestring1 + scorestring2, False, align="left", font=("Arial",14, "normal")) # make sure the if-suite is not executed again # unless there was a change old_score1 = score1 old_score2 = score2 > and how can i make a high score table, in this game made with python? You can store the (score, name) pairs in a file that you update when the program terminates. Do you know how to read/write a file? Given a file containing 10 Jim 13 Sue 5 Dave you can use the split() method break a line into the score and the name, and int() to convert the score from a string to an integer. When you put the entries into a list it is easy to sort them in reverse order: >>> highscores = [(10, "Jim"), (13, "Sue"), (5, "Dave")] >>> for score, name in sorted(highscores, reverse=True): ... print("%3d %s" % (score, name)) ... 13 Sue 10 Jim 5 Dave -- https://mail.python.org/mailman/listinfo/python-list
Re: I need help with a game in (turtle graphics - python)
Thanks! This helped me! -- https://mail.python.org/mailman/listinfo/python-list
Re: python decorator
On 2/22/17, Steve D'Aprano wrote: > On Wed, 22 Feb 2017 08:47 pm, Cecil Westerhof wrote: > >> On Wednesday 22 Feb 2017 08:49 CET, Argentinian Black ops lll wrote: >> >>> *** SOLVED *** >> >> It would be nice if you shared the solution. > > I believe Cameron's post contains the bones of a solution. > > Here's my untested solution. > > > def func_cache(cache): > # Create a decorator that uses cache. > def decorate(function): > @functools.wraps(function) > def wrapper(*args): > try: > result = cache[args] > except KeyError: > result = function(*args) > cache[args] = result > except TypeError: > result = function(*args) > return result > return wrapper > return decorate > > > @func_cache({}): > def something(x): > ... Maybe this technique could be reusable (and maybe part of functools?) With this decorator: def wrap_args(decorator): def decor_out(*args, **kwargs): def decor_in(func): return decorator(func, *args, **kwargs) return decor_in return decor_out Alfredo needs to change only (*) next 2 lines: def fun_cache(function): memo = {} to: @wrap_args def fun_cache(function, cache): memo = cache (*) - Steve's improvements (for example using functools.wraps) are good to consider as well! :) (but maybe catching TypeError could more problems hide than solve) -- https://mail.python.org/mailman/listinfo/python-list
Re: Python application launcher (for Python code)
On 2017-02-21, Chris Warrick wrote: > Git Bash, or basically msys, is pretty reasonable. But if you are on > Windows 10, you might like the built-in Windows Subsystem for Linux > (aka Bash on Ubuntu on Windows) more — it’s real Linux that runs > alongside Windows, but less crazy than Cygwin. Cygwin is indeed crazy. I've been in awe of it for 15 years. Even sshd works (if you're carefuly and a little lucky). It's a medium-sized miracle that Cygwin works as well as it does. For a few years, I distributed and supported a custom snapshot of base Cygwin plus a software development kit for a specific hardware product. It was not fun. Cygwin is a bit brittle and presents many mysterious failure modes. But, had I not seen it myself, I never would have believed Cygwin would work in a useful way. In then end, we gave up on supporting Cygwin for our Windows customers. It's actually easier to install Ubuntu in a VM and have them use that. The last customer I had who was trying to install Cyginw and use it for development spent weeks and never got everything to work with Cygwin. About two hours after I finally convinced him to try Linux on a VM, I got an e-mail saying his Linux VM as installed, the devleopment tools were installed on that, and he was happily building his applications. -- Grant Edwards grant.b.edwardsYow! I know how to do at SPECIAL EFFECTS!! gmail.com -- https://mail.python.org/mailman/listinfo/python-list
If statement with or operator
Hello Friends, I need suggestion on the if statement in the below code , all that I was trying to do was to add a check i.e if any one of the functions return True then break the loop. end_time = time.time() + 300 umount_completed = False while time.time() < end_time: if attempt_umount() is True or df_output_lines() is True: logging.info("umount completed sucessfully") umount_completed = True break time.sleep(15) assert umount_completed, "ERROR: The umount failed Exiting" Can this be optimized better , please suggest. I am on Linux and Python 2.7 Regards. Ganesh -- https://mail.python.org/mailman/listinfo/python-list
Re: If statement with or operator
On Wed, 22 Feb 2017 22:33:31 +0530, Ganesh Pal wrote: > Hello Friends, > > I need suggestion on the if statement in the below code , all that I > was trying to do was to add a check i.e if any one of the functions > return True then break the loop. > > > end_time = time.time() + 300 > umount_completed = False while time.time() < end_time: > if attempt_umount() is True or df_output_lines() is True: >logging.info("umount completed sucessfully") >umount_completed = True break > time.sleep(15) > assert umount_completed, "ERROR: The umount failed Exiting" > > Can this be optimized better , please suggest. I am on Linux and > Python 2.7 > > > Regards. > Ganesh a simple if attempt_umount() or df_output_lines(): would suffice (Q argument on whether the unnecessary is True makes the code more readable or not) there may also be better ways to perform your unmount but without knowing the details of the code it is difficult to say -- "Nuclear war would really set back cable." - Ted Turner -- https://mail.python.org/mailman/listinfo/python-list
Re: If statement with or operator
On Wed, 22 Feb 2017 22:33:31 +0530, Ganesh Pal wrote: [snip] > I need suggestion on the if statement in the below code , all that I was > trying to do was to add a check i.e if any one of the functions return > True then break the loop. > > end_time = time.time() + 300 > umount_completed = False > while time.time() < end_time: > if attempt_umount() is True or df_output_lines() is True: >logging.info("umount completed sucessfully") >umount_completed = True >break > time.sleep(15) > assert umount_completed, "ERROR: The umount failed Exiting" The if statement is healthy and reasonable. If you have a guarantee that attempt_umount and df_output_lines return only True or False, then this would be equivalent: if attempt_umount() or df_output_lines(): However, at the bottom, checking for completion with "assert" is (as I understand it) weak because assertions may be ignored in optimized situations. I'd raise RuntimeError. Also, an consider this alternative loop structure: while not (attempt_umount() or df_output_lines()): if end_time < time.time(): raise RuntimeError("The umount failed. Exiting.") time.sleep(15) logging.info("umount completed successfully") -- To email me, substitute nowhere->runbox, invalid->com. -- https://mail.python.org/mailman/listinfo/python-list
Re: python decorator
On Wed, Feb 22, 2017 at 8:16 AM, Pavol Lisy wrote: > Maybe this technique could be reusable (and maybe part of functools?) > > With this decorator: > > def wrap_args(decorator): > def decor_out(*args, **kwargs): > def decor_in(func): > return decorator(func, *args, **kwargs) > return decor_in > return decor_out > > Alfredo needs to change only (*) next 2 lines: > > def fun_cache(function): > memo = {} > > to: > > @wrap_args > def fun_cache(function, cache): > memo = cache > > (*) - Steve's improvements (for example using functools.wraps) are > good to consider as well! :) > (but maybe catching TypeError could more problems hide than solve) When all the arguments are optional it's generally desirable that @foo and @foo() be equivalent. See: https://blogs.it.ox.ac.uk/inapickle/2012/01/05/python-decorators-with-optional-arguments/ I would augment that example by making the optional arguments keyword-only to prevent accidentally passing one as the function to be decorated. Hopefully this feature would also be part of any general reusable solution. -- https://mail.python.org/mailman/listinfo/python-list
CSV
Why does this not run? It is right out of the CSV file in the Standard Lib. Python ver 3.4.4, 64 bit. import csv """ READ EXCEL FILE """ filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv' with open (filename, newline = ' ') as bp: dialect = csv.excel reader = csv.reader(bp) for row in reader: print (row) Marc -- https://mail.python.org/mailman/listinfo/python-list
Re: CSV
On Thu, Feb 23, 2017 at 4:26 AM, Braxton Alfred wrote: > filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv' Use forward slashes instead. Also, if something isn't working, post the actual output - probably an exception. Don't assume that we can read your mind, even when we can. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: CSV
On 22-2-2017 18:26, Braxton Alfred wrote: > Why does this not run? It is right out of the CSV file in the Standard Lib. What does "not run" mean. We can't help if you are not telling us the exact error message you're getting (if any) > filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv' That being said, there's at least a problem with this line because you're not escaping the backslashes. So the resulting filename string is not what you intended it to be (try printing it to see what I mean). Several solutions possible: - switch to using forward slashes / this works on windows too. - use a raw string literal r'.' - or escape the backslashes \\ Irmen -- https://mail.python.org/mailman/listinfo/python-list
Re: python decorator
On 22-2-2017 8:39, Argentinian Black ops lll wrote: > Thanks for the quick response...! you saved me a lot of time, thank you! > I don't know if you want/have to use your own custom caching decorator, but are you aware of the lru_cache decorator that's part of the standard library? https://docs.python.org/3/library/functools.html#functools.lru_cache Irmen -- https://mail.python.org/mailman/listinfo/python-list
Re: If statement with or operator
On 22/02/17 17:38, Peter Pearson wrote: On Wed, 22 Feb 2017 22:33:31 +0530, Ganesh Pal wrote: [snip] I need suggestion on the if statement in the below code , all that I was trying to do was to add a check i.e if any one of the functions return True then break the loop. end_time = time.time() + 300 umount_completed = False while time.time() < end_time: if attempt_umount() is True or df_output_lines() is True: logging.info("umount completed sucessfully") umount_completed = True break time.sleep(15) assert umount_completed, "ERROR: The umount failed Exiting" The if statement is healthy and reasonable. Quite to the contrary, the if statement should be discouraged with great vigour unless the OP is certain that the functions return only the object True for success, and not just values that are true in a boolean context. if attempt_umount() or df_output_lines(): is far more likely to do what you expect. -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list
RE: Python application launcher (for Python code)
Grant Edwards wrote, on February 22, 2017 7:52 AM > > On 2017-02-21, Chris Warrick wrote: > > > Git Bash, or basically msys, is pretty reasonable. But if you are on > > Windows 10, you might like the built-in Windows Subsystem for Linux > > (aka Bash on Ubuntu on Windows) more - it's real Linux that runs > > alongside Windows, but less crazy than Cygwin. > > Cygwin is indeed crazy. > > I've been in awe of it for 15 years. > > Even sshd works (if you're carefuly and a little lucky). > > It's a medium-sized miracle that Cygwin works as well as it > does. For a few years, I distributed and supported a custom > snapshot of base Cygwin plus a software development kit for a > specific hardware product. It was not fun. Cygwin is a bit > brittle and presents many mysterious failure modes. But, had > I not seen it myself, I never would have believed Cygwin > would work in a useful way. > > In then end, we gave up on supporting Cygwin for our Windows > customers. It's actually easier to install Ubuntu in a VM > and have them use that. The last customer I had who was > trying to install Cyginw and use it for development spent > weeks and never got everything to work with Cygwin. About > two hours after I finally convinced him to try Linux on a VM, > I got an e-mail saying his Linux VM as installed, the > devleopment tools were installed on that, and he was happily > building his applications. > > -- > Grant Edwards grant.b.edwardsYow! I > know how to do > at SPECIAL EFFECTS!! > gmail.com I tried Cygwin once. I had a fairly complex library of C functions I wanted to rewrite portions of in Python, and I wanted to run the C code first, and be able to use a running C version to check my Python version against. I couldn't afford Visual Studio, especially since there was only this one project to use it for, and Cygwin seemed like a reasonable alternative. Cygwin has an avid fan club of followers for using Cygwin to write and execute C code, and as an IDE, I think. But I couldn't get it to run right, and I usually get along pretty well with software. Not an experience I'm eager to repeat. Deborah -- https://mail.python.org/mailman/listinfo/python-list
concurrent futures, async futures and await
I'm in a situation where I would like to refactor some code to use native coroutine functions (aync def) instead of "normal" coroutines that use yield. Most of the code is asnyc, but some of the operations are performed in different threads (using concurrent.futures.Executor). We have concurrent.futures.Future and asyncio.Future. The former one an be used to execute code in a different thread, the later one can be awaited. Since concurrent.futures.Future does not implement the __await__ method, it cannot be awaited in an ioloop. For example, if I want to read from a file in a different thread, then I can submit that as a task to a ThreadPoolExecutor, but it is not possible to await for it. It is still possible to read from the file in the same thread, but obviously I do not want to do that (because file read can block the loop, and I do not want that). In other words: this makes it impossible to refactor coroutine functions to native coroutine functions. In my concrete use case, coroutines are used in tornado's ioloop, and tornado handles both types of futures *if they are yielded*. But once I switch to async def, yield becomes await and the native await is incompatible with concurrent.futures.Future. Both the await keyword and concurrent.futures.Future are in the standard library. They should be compatible. Is there a reason why concurrent.futures does not implement __await__ ? Thanks, Laszlo -- https://mail.python.org/mailman/listinfo/python-list
Re: CSV
Braxton Alfred writes: > Why does this not run? It is right out of the CSV file in the Standard Lib. > > > > > Python ver 3.4.4, 64 bit. > > > > > > > > import csv > """ READ EXCEL FILE """ > filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv' '\b' is backspace. A couple of months ago I actually met a filename with a backspace in it. I renamed the file. Or maybe I removed it, I forget. But don't you get a SyntaxError from '\user'? [snip] -- https://mail.python.org/mailman/listinfo/python-list
Re: How to store properties
On 2017-02-22 21:08, Gilmeh Serda wrote: On Wed, 08 Feb 2017 09:31:09 -0800, Rob Gaddi wrote: JSON's cute, but the format doesn't support inline comments. { "your_key": "whatever", "COMMENT": "blah", "meh": [ "yup", "yep", "yip" ], "COMMENT": "mooh" } Works fine for me. As long as you don't have any use for your "COMMENT" key elsewhere, it will continue to work. That's a dictionary, so if you read it in and then write it out again, the order might change, and one of the comments will be lost. -- https://mail.python.org/mailman/listinfo/python-list
Re: CSV
On Wednesday, February 22, 2017 at 5:55:47 PM UTC, Braxton Alfred wrote: > Why does this not run? It is right out of the CSV file in the Standard Lib. > > Python ver 3.4.4, 64 bit. > > import csv > """ READ EXCEL FILE """ > filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv' > with open (filename, newline = ' ') as bp: > dialect = csv.excel > reader = csv.reader(bp) > for row in reader: > print (row) > > Marc Of course it will run, assuming that there are no syntax errors. Besides that using raw strings or forward slashes will probably help. Of course we don't actually know as you haven't shown us the actual error that you get, and our crystal balls broke down long ago owing to over use. You might like to read http://www.catb.org/~esr/faqs/smart-questions.html and then http://sscce.org/ or even http://stackoverflow.com/help/mcve and then ask again. Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
Re: CSV
One other thing besides the issues noted with filename - newline is set to a space. It should be set to an empty string. See: https://docs.python.org/3/library/csv.html#id3 Regards, Nate On Wed, Feb 22, 2017 at 3:52 PM, wrote: > On Wednesday, February 22, 2017 at 5:55:47 PM UTC, Braxton Alfred wrote: > > Why does this not run? It is right out of the CSV file in the Standard > Lib. > > > > Python ver 3.4.4, 64 bit. > > > > import csv > > """ READ EXCEL FILE """ > > filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv' > > with open (filename, newline = ' ') as bp: > > dialect = csv.excel > > reader = csv.reader(bp) > > for row in reader: > > print (row) > > > > Marc > > Of course it will run, assuming that there are no syntax errors. > > Besides that using raw strings or forward slashes will probably help. > > Of course we don't actually know as you haven't shown us the actual error > that you get, and our crystal balls broke down long ago owing to over use. > > You might like to read http://www.catb.org/~esr/faqs/smart-questions.html > and then http://sscce.org/ or even http://stackoverflow.com/help/mcve and > then ask again. > > Kindest regards. > > Mark Lawrence. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
RE: Python application launcher (for Python code)
Dennis Lee Bieber wrote, on February 22, 2017 6:48 PM > > On Wed, 22 Feb 2017 10:50:18 -0800, "Deborah Swanson" > declaimed the following: > > > >first, and be able to use a running C version to check my Python > >version against. I couldn't afford Visual Studio, especially since > >there was > > Must have been quite some time ago, since VS Express > versions have been available since 2005. > > Granted, Express has limitations... But if porting C > code, you would likely not have been affected -- it's > unlikely your code used MFC... > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ Didn't even look. Visual Studio has always been pricey, and it never occurred to me that they might have a free or cheap version now. This was last summer, and I ended up just writing the Python by looking at the C, and attempting to verify against a data set I knew the correct answers for. But it wasn't looking exactly right and I dropped the project. I'll remember VS Express if I revisit this, so thanks! Deborah -- https://mail.python.org/mailman/listinfo/python-list
First Live Online Python Syntax Checker
Hi everyone! :) I just wanted to share with everyone a lightweight online tool I created called PythonBuddy (https://github.com/ethanchewy/PythonBuddy) which actively lints Python online. I made this so that MOOCs like edX or codecademy could easily embed and use this on their courses. Also, PythonBuddy could help alleviate the frustrations with setting up a programming environment. Just thought it might be helpful for those who want to program in Python online with a helpful live syntax checker. Please leave a 🌟 if you found this project to be helpful! I'm currently trying to convert this project to an XBlock so that online courses (like 6.00.1x) can embed a live python syntax checker for quizzes and assignments online. -- https://mail.python.org/mailman/listinfo/python-list
Re: any one used moviepy please come in!!! I need help, thanks!
On Thursday, January 26, 2017 at 8:12:24 AM UTC+5:30, Tony Chen wrote: > On Wednesday, January 25, 2017 at 8:34:01 PM UTC+13, Chris Angelico wrote: > > On Wed, Jan 25, 2017 at 6:22 PM, Tony Chen > > wrote: > > > This error can be due to the fact that ImageMagick is not installed on > > > your computer, or (for Windows users) that you didn't specify the path to > > > the ImageMagick binary in file conf.py, or.that the path you specified is > > > incorrect > > > > So... is ImageMagick installed? > > > > ChrisA > > Okay... Yes it's installed. This problem has been solved haha. Thank you for > replying. Hi Tony, same issue facing by me. kindly help me please list the solution -- https://mail.python.org/mailman/listinfo/python-list
Re: concurrent futures, async futures and await
On Wed, Feb 22, 2017 at 12:50 PM, Nagy László Zsolt wrote: > > I'm in a situation where I would like to refactor some code to use > native coroutine functions (aync def) instead of "normal" coroutines > that use yield. Most of the code is asnyc, but some of the operations > are performed in different threads (using concurrent.futures.Executor). > > We have concurrent.futures.Future and asyncio.Future. The former one an > be used to execute code in a different thread, the later one can be > awaited. Since concurrent.futures.Future does not implement the > __await__ method, it cannot be awaited in an ioloop. For example, if I > want to read from a file in a different thread, then I can submit that > as a task to a ThreadPoolExecutor, but it is not possible to await for > it. It is still possible to read from the file in the same thread, but > obviously I do not want to do that (because file read can block the > loop, and I do not want that). > > In other words: this makes it impossible to refactor coroutine functions > to native coroutine functions. > > In my concrete use case, coroutines are used in tornado's ioloop, and > tornado handles both types of futures *if they are yielded*. But once I > switch to async def, yield becomes await and the native await is > incompatible with concurrent.futures.Future. > > Both the await keyword and concurrent.futures.Future are in the standard > library. They should be compatible. Is there a reason why > concurrent.futures does not implement __await__ ? My guess: because asyncio wouldn't know what to do with a concurrent.futures.Future. The tornado docs say that "You can also use tornado.gen.convert_yielded to convert anything that would work with yield into a form that will work with await": http://www.tornadoweb.org/en/stable/guide/coroutines.html#python-3-5-async-and-await -- https://mail.python.org/mailman/listinfo/python-list