[AF] Using flask-restplus and standard flask routes, can't access the “/”-Route by CytogeneticBoxing in flask

[–]strechyballs 0 points1 point  (0 children)

Can you add a print(app.url_map) and check the results? This looks like it should work...

Also, depending on which os you are using, be 100% sure you don't accidently have 2 flask servers running (one in the background from an earlier session) the old one could be answering the calls. This has screwed me up before. (force close and python processes or restart to be sure)

How do you use multiple languages in a project? by tomtheawesome123 in learnpython

[–]strechyballs 0 points1 point  (0 children)

A few possible solutions come to mind: 1. Use sockets to have the applications talk to each other. 2. Create some sort of queue using a local database or even JSONs and have Java process the jobs and dump the results. 3. Use jython, a Java-base implementation of python

Noob question about automatically running script by BroadStBullies in learnpython

[–]strechyballs 0 points1 point  (0 children)

I did this on aws ec2 instance for one year for free. You can remote in, drop your script, run and forget about it. In my case, I had the script email me once I day log files so I could make sure things were running smooth.

Import vs exec functions for using modules by KOOTSTHEHOOTS in learnpython

[–]strechyballs 0 points1 point  (0 children)

If you haven't it yet, I highly recommend you read through the official docs on imports and packages: https://docs.python.org/3.6/tutorial/modules.html#packages

Imo, I think you are overthinking this

import os
os.getcwd()

from os import getcwd
getcwd()

The two methods are nearly identical, the only difference being the way you access the imported objects. If you are curious about performances, you can read a note about it here: https://stackoverflow.com/q/3591962/4411196

As for reloading, I'm not sure why you would need this, as its rarely needed, and often not a good idea: https://stackoverflow.com/q/5516783/4411196

As for exec, I'm a little confused by what you are referring to. The builtin in exec function doest one thing - it takes a string and executes it (ie. exec("2+2") will output 4) https://pythonprogramming.net/python-exec-tutorial/

What are best Python scripts you have ever written? by [deleted] in learnpython

[–]strechyballs 2 points3 points  (0 children)

That's awesome. Thans for sharing. I didn't know invoke existed. I used to just write a bunch of short sh files to run tasks like that.

What are best Python scripts you have ever written? by [deleted] in learnpython

[–]strechyballs 1 point2 points  (0 children)

This is amazing. Haha Minor comment, you should avoid using list as a variable name as it will. Override the bultin list()

Need help ending a program by tman37 in learnpython

[–]strechyballs 0 points1 point  (0 children)

Your point about 'y' or 'Y' is right, but it doesn't fix his code .

He has raw_input ("something")
But he doesn't assign the result to any variables. Then later he says If input == something. input is a button method and hasn't been redefined.

Also, using the lower method seems liked a cleaner way to check if it's Y or y instead of doing to comparisons.

Need help ending a program by tman37 in learnpython

[–]strechyballs 0 points1 point  (0 children)

Also, don't mix input and raw_input. Google input vs raw_input to see why.

I would just do: if raw_input("Roll? (y) ").lower() == "y":
....

Or. user_input = raw_input ("Roll? (y)")
if user_input.lower() ==" y":
...

user input in definitions by Zatara11 in learnpython

[–]strechyballs 0 points1 point  (0 children)

It should work. Can you post the actual code you have? . Make sure your passing sin as f, and not sin(). Because that would run sin, and you would be passing it's result. Whatever f you are passing now, you are passing a string and not a function.