Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
What is the best way to mark deprecated fields in Django 1.4 models if I don't want to delete them right away?
Sorry, I can't comment yet.
If you don't want anything fancy you could simply compare the Python version and launch a warning.
import django
print django.VERSION
>> (1, 8, 5, 'final', 0)
if django.VERSION[1] < 4:
print "[DEPRECATION WARNING]"
Or you could do the best approach: to go to a popular package and see how they do it. For example in Django CMS:
cms/exceptions.py (https://github.com/divio/django-cms/blob/develop/cms/exceptions.py)
# -*- coding: utf-8 -*-
class Deprecated(Exception): pass
cms/utils/check.py (https://github.com/divio/django-cms/blob/develop/cms/utils/check.py)
#define_check
def check_deprecated_settings(output):
with output.section("Deprecated settings") as section:
found = False
for deprecated in ['CMS_FLAT_URLS', 'CMS_MODERATOR']:
if hasattr(settings, deprecated):
section.warn("Deprecated setting %s found. This setting is no longer in use and can be removed" % deprecated)
found = True
if not found:
section.skip("No deprecated settings found")
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 20 days ago.
Improve this question
Very general question: I am attempting to write a fairly complext Python script.
#Part A: 100 lines of python code
#Part B: 500 lines of python code
#Part C: 100 lines of python code
Assume that I want "Part B" taken out of the picture for readability and debugging purposes, because I know that it is running well and I want to focus on the other parts of the code.
I would define a function like this:
def part_b():
#500 lines of python code
#Part A: 100 lines of python code
part_b()
#Part C: 100 lines of python code
The problem with this approach in my case is that there are more than twenty variables that need to be sent to "Part C". The following looks like bad practice.
def part_b():
global var1
global var2
global var3...
I am aware that I could return an object with more than twenty attibutes, but that would increase complexity and decrease readability.
In other words, is there a pythonic way of saying "execute this block of code, but move it away from the code that I am currently focusing on". This is for a Selenium automation project.
Sounds like what you're looking for is modules. Move part B into a separate file, and then import it.
import part_B
# part A here
part_B.run()
# part C here
# to access things that part B does:
do_part_C_stuff(part_B.something)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 months ago.
Improve this question
I am trying to configure gimme-aws-creds with below configuration
[DEFAULT]
okta_org_url = https://xxxxx.okta.com
okta_auth_server =
client_id =
gimme_creds_server = appurl
aws_appname =
aws_rolename = all
write_aws_creds = True
cred_profile = default
okta_username = my_okta_user_name
app_url = https://xxxxx.okta.com/home/amazon_aws/app_instance_id/something
resolve_aws_alias = True
include_path = True
preferred_mfa_type = token:software:totp
remember_device = True
aws_default_duration = 150000
device_token =
output_format =
I have
Windows 10
Python 3.10.5
pip3 22.1.2
gimme-aws-creds 2.4.0
When I execute the gimme-aws-creds --register-device command to register MFA device I get error
File "C:\Tools\Python\lib\site-packages\requests\cookies.py", line
413, in _find_no_duplicates
raise KeyError(f"name={name!r}, domain={domain!r}, path={path!r}") KeyError: "name='sid', domain=None, path=None"
To fix it, I had to lower python version to 3.9.13 Issue
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Hello i am your assistant and i am gonna remind you periodically to have a break or do exercise or to drink water
Traceback (most recent call last):
File "C:\Users\lenovo\.spyder-py3\python_project_exercise7.py", line 51, in <module>
schedule.every(10).minutes.do(waater())
AttributeError: 'Job' object has no attribute 'do'
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 29 15:14:04 2021
#author: Asrar
"""
import schedule
import time
import datetime
from datetime import *
def waater():
print('hehe')
schedule.every(10).minutes.do(waater())
and the output is like this:
Schedule should call the method for you, so you only have to pass the method without the parentheses as the argument for do().
schedule.every(10).minutes.do(waater)
You only have to refer to your function as an object (waater), not call upon it (waater()).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is it possible, using Python to get a value of a variable from RAM using an address, something like Cheat Engine?
It's really implementation dependent, you could try this in CPython with ctypes.string_at function (it dumps whole Python3 integer structure):
import ctypes
from sys import getsizeof
my_value_1 = int(1)
my_value_2 = int(2)
b1 = ctypes.string_at(id(my_value_1), getsizeof(my_value_1))
b2 = ctypes.string_at(id(my_value_2), getsizeof(my_value_2))
print(hex(id(b1)), ''.join(format(x, '02x') for x in b1))
print(hex(id(b2)), ''.join(format(x, '02x') for x in b2))
Prints:
0x7ffff670ffb0 4d0300000000000040b89d0000000000010000000000000001000000
0x7ffff670f5f0 740000000000000040b89d0000000000010000000000000002000000
In other implementations of Python (Jython, Iron Python etc.) this probably won't work. On CPython id() returns memory address of the object.
I found a Python module hackManager, and it solved my issue.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
ETE2 (a Python Environment for phylogenetic Tree Exploration) has a method .phonehome() which can be called on tree/node class objects. This returns:
== Calling home... Got answer!
He11o alien,
How is everything in the Earth?
We miss you in Brodo Asogi.
I see you are in shape.
No updates are available.
== Do you want to leave any message?
(Press enter to finish)
If you want to test this for yourself, try:
from ete2 import Tree
t = Tree() # generate random Tree
t.phonehome() # communicate with Aliens!
Is this an easter egg?
The project logo is:
So you could call it an easter egg. But it also has a real purpose, as it is the projects version check method, named with a pinch of humor:
''' I use this module to check for newer versions of ETE '''
and
def call():
print " == Calling home...",
try:
f = url.urlopen('http://ete.cgenomics.org/et_phone_home.php?VERSION=%s&ID=%s'
%(__VERSION__, __ETEID__))
and:
if not latest:
print "I could not find data about your version [%s]" %module_name
print "Are you ok?"
elif not current:
print "I could not determine your version [%s]" %module_name
print "Are you ok?"
print "Latest stable ETE version is", latest
elif latest > current:
print "You look a bit old."
print "A newer version is available: rev%s" %latest
print "Use 'easy_install -U %s' to upgrade" %module_name
else:
print "I see you are in shape."
print "No updates are available."
See the source code of the ete2._ph module; phonehome() calls ete2._ph.call().