Category : python-3.x

I’m trying to allow users to have access to my app for 7 days after they register with this function: from datetime import datetime, timedelta from django.utils import timezone from django.utils.timezone import localdate class CustomUser(AbstractUser): def free_trial(self): if (self.date_joined – timezone.now()) < timedelta(days=7): return True But testing with accounts made more than 7 days ago ..

Read more

I have this simple query in python pymongo to retrieve the last inserted document from a mongodb collection. Even though there is are documents in the collection, it returns 0 documents retrieved. last_id_val = db_collection.media_m_service.find({}).sort([{"_id": -1}]).limit(1) Is this the correct syntax? is there a better way to retrieve the last inserted document from any given ..

Read more

Out of the blue, my python installation seems to have broken. When trying to run a python script, I get the following… [[email protected] ~/Code/CTF/aero/house]$ ./solve.py Traceback (most recent call last): File "/home/michael/Code/CTF/aero/house/./solve.py", line 5, in <module> from pwn import * File "/home/michael/.local/lib/python3.9/site-packages/pwn/__init__.py", line 20, in <module> pwnlib.update.check_automatically() File "/home/michael/.local/lib/python3.9/site-packages/pwnlib/update.py", line 199, in check_automatically log.info("n".join(message)) File ..

Read more

my graph couldn’t change. when I try to use y_sel and x_sel in the plot it throws error. sometimes it says value error ‘Countries’ and some time too many inputs for one value something like that. ydata = online_act_major.loc[ : , [‘socionet’, ‘info_good_serv’,’banking’,’selling’,’news’,’learn_act’] ] xdata = online_act_major.index.values # gca stands for ‘get current axis’ dropdown ..

Read more

How to generate mathematical operations using values of predefined list and also the math operations generated must equal a certain value, like: math_set = [1, 2, 5, 6] target_value = 21 >>> generate_math_operation_now(math_set, target_value) >>> ‘5*6-2*5+1’ #random 100%, (length doesn’t matter as long the value is desired) small note: i tried to use itertools.combinations but ..

Read more

I’m going a little bug-eyed here trying to troubleshoot this. In the process, I’ve tried to create a self-contained function to reproduce the issue, but for some reason it works as expected in the micro-example, but not in my prod code. I have a subclass of pathlib.Path: class WalkPath(Path): _flavour = type(Path())._flavour def __init__(self, *args, ..

Read more

I have a piece of code using os.listdir() to show the files inside the folder. But I have the error because can´t find the path. I’ve already verify but is ok. How can I obtain the list with os.listdir() or other method? My piece of code: context[‘files’] = os.listdir("/static/assets/external_files/"+info_curso.code) Source: Python..

Read more