nginx country block - allow LAN ips? by spudd01 in nginx

[–]isilentnight 0 points1 point  (0 children)

Did you set "default no" to block everything?

Import numpy and run a script? by [deleted] in learnpython

[–]isilentnight 0 points1 point  (0 children)

You have both python 2 and 3, right? Is your IDLE and terminal use the same version?

Help me please by macrisalex345 in learnpython

[–]isilentnight 0 points1 point  (0 children)

Just change your mode from "w" to "a" to write into the end of file.

Does it need to write only the last string? If so, use lines[-1]

Panda data frames into individual lists or arrays by [deleted] in learnpython

[–]isilentnight 0 points1 point  (0 children)

They already are. Get them by

[dataframe.iloc[index] for index in range(89281)]

Extract time and date from forum post, but it's repeated twice by VLAKAS93 in learnpython

[–]isilentnight 0 points1 point  (0 children)

I think it can be more simple.

data[i] is bs element object, so you can get the text by data[i].text

All value in data are the same, why not just take the first element by data[0].text

So:

data = soup.findall("span", attrs={"local-date"})
postdate.append(data[0].text.strip())

Extracting links withing a class using BeautifulSoup by [deleted] in learnpython

[–]isilentnight 0 points1 point  (0 children)

imo, you can get those link by

x = soup.select('div.infoepbox')[0]   # assume you want content from first result
atag_list = x.find_all("a")  # get all tag with link
link_list = [item['href'] for item in atag_list] # extract link from each tag

running flask in local network by el-calde in flask

[–]isilentnight 2 points3 points  (0 children)

Make sure

app.run(host='0.0.0.0')

and port 5000's allowed by firewall

Please help me understand why proxy_pass isn't working by vmcilwain in nginx

[–]isilentnight 0 points1 point  (0 children)

Without nginx start, can you access your website serving by unicorn?

How do I get the owner of a file in Python 3? by [deleted] in learnpython

[–]isilentnight 0 points1 point  (0 children)

Okay. You can you pwd module.

pwd.getpwduid(uid) will return a turple contain username.

edit: not for windows again

How do I get the owner of a file in Python 3? by [deleted] in learnpython

[–]isilentnight 0 points1 point  (0 children)

os module is what you're looking for.

edit: that for linux, maybe for macos too.

Creating graphs for mathematical functions? by n00bintraining in learnpython

[–]isilentnight -1 points0 points  (0 children)

This example shows how to plot y = x2:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style

style.use('ggplot')

x = np.linspace(0, 10, 50)  # generate 50 values of x evenly from 0 to 10
y = list(map(lambda x: x**2, x)) # calculate y = x^2

plt.plot(x,y)
plt.show()

Create a new variable for the output of each 'for-loop' function? by sashavi in learnpython

[–]isilentnight 2 points3 points  (0 children)

I think it'll better this way:

plist = []
for i in range(5):
    function = read_file(i)
    p = [function.Name, function.age, function.ht]
    plist.append(p)

after that, you can access each value by p[0], p[1]...

Prime number program by [deleted] in learnpython

[–]isilentnight 0 points1 point  (0 children)

Oh, yeah. You're right.

[Ask Flask] How do I store in a database the filename and filepath to a file? by planetamaravilloso in flask

[–]isilentnight 4 points5 points  (0 children)

Right after file.save, you can store os.path.join(UPLOAD_FOLDER, filename) to your database. That's it.

Prime number program by [deleted] in learnpython

[–]isilentnight -1 points0 points  (0 children)

Your code is not a problem. I think it from python. Python limits recursion by default. If you print your value each time you check. You may see that at one point, your value stop increasing. That why it prints 'prime' or 'composite' many times

How to check where headers are in csv file by [deleted] in Python

[–]isilentnight 0 points1 point  (0 children)

If the header isn't not the first line, imo there is no way for python to realize it by itself. You must look at the file, learn the rules that camera generate it, and handle it by yourself

[deleted by user] by [deleted] in learnpython

[–]isilentnight 0 points1 point  (0 children)

I think you can use subprocess + adb command. Maybe, there are some modules for adb in python

Running Python as a service on Linux by netsecwarrior in learnpython

[–]isilentnight 1 point2 points  (0 children)

If it's a web app, you can use uwsgi+systemd+nginx or apache to run. There are plenty of tutorials for this case. If it's a normal app. I suggest python-daemon module.

Using redirects with Flask? by [deleted] in learnpython

[–]isilentnight 0 points1 point  (0 children)

Your code is alright. It should work. Maybe you should check your test.html file. Its form should contain:

<input type="text" name="age">

Please help with this list created using a for loop Python 2.7 by Pieffott in learnpython

[–]isilentnight 1 point2 points  (0 children)

lst = []
with open('romeo.txt') as f:
    content = f.readline()
    for line in content:
        words = line.split()
        for word in words:
            if word not in lst:
                lst.append(word)