Use 'is None' and 'is not None'
This commit is contained in:
@@ -13,7 +13,7 @@ def query_yes_no(question, default="yes"):
|
||||
"""
|
||||
valid = {"yes":True, "y":True, "ye":True,
|
||||
"no":False, "n":False}
|
||||
if default == None:
|
||||
if default is None:
|
||||
prompt = " [y/n] "
|
||||
elif default == "yes":
|
||||
prompt = " [Y/n] "
|
||||
|
||||
@@ -115,7 +115,7 @@ def get_date_for_press(publish_date):
|
||||
|
||||
def press(request):
|
||||
json_articles = cache.get("student_press_json_articles")
|
||||
if json_articles == None:
|
||||
if json_articles is None:
|
||||
if hasattr(settings, 'RSS_URL'):
|
||||
content = urllib.urlopen(settings.PRESS_URL).read()
|
||||
json_articles = json.loads(content)
|
||||
@@ -301,7 +301,7 @@ def change_enrollment(request):
|
||||
action = request.POST.get("enrollment_action", "")
|
||||
|
||||
course_id = request.POST.get("course_id", None)
|
||||
if course_id == None:
|
||||
if course_id is None:
|
||||
return HttpResponse(json.dumps({'success': False,
|
||||
'error': 'There was an error receiving the course id.'}))
|
||||
|
||||
@@ -1203,7 +1203,7 @@ def _get_news(top=None):
|
||||
"Return the n top news items on settings.RSS_URL"
|
||||
|
||||
feed_data = cache.get("students_index_rss_feed_data")
|
||||
if feed_data == None:
|
||||
if feed_data is None:
|
||||
if hasattr(settings, 'RSS_URL'):
|
||||
feed_data = urllib.urlopen(settings.RSS_URL).read()
|
||||
else:
|
||||
|
||||
@@ -524,7 +524,7 @@ class PeerGradingModule(XModule):
|
||||
'''
|
||||
Show individual problem interface
|
||||
'''
|
||||
if get == None or get.get('location') == None:
|
||||
if get is None or get.get('location') is None:
|
||||
if not self.use_for_single_location:
|
||||
#This is an error case, because it must be set to use a single location to be called without get parameters
|
||||
#This is a dev_facing_error
|
||||
|
||||
@@ -49,7 +49,7 @@ def course_wiki_redirect(request, course_id):
|
||||
if not course_slug:
|
||||
log.exception("This course is improperly configured. The slug cannot be empty.")
|
||||
valid_slug = False
|
||||
if re.match('^[-\w\.]+$', course_slug) == None:
|
||||
if re.match('^[-\w\.]+$', course_slug) is None:
|
||||
log.exception("This course is improperly configured. The slug can only contain letters, numbers, periods or hyphens.")
|
||||
valid_slug = False
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ def grade(student, request, course, student_module_cache=None, keep_raw_scores=F
|
||||
grading_context = course.grading_context
|
||||
raw_scores = []
|
||||
|
||||
if student_module_cache == None:
|
||||
if student_module_cache is None:
|
||||
student_module_cache = StudentModuleCache(course.id, student, grading_context['all_descriptors'])
|
||||
|
||||
totaled_scores = {}
|
||||
|
||||
@@ -68,7 +68,7 @@ def get_course_settings(coursename):
|
||||
|
||||
|
||||
def is_valid_course(coursename):
|
||||
return get_course_settings(coursename) != None
|
||||
return get_course_settings(coursename) is not None
|
||||
|
||||
|
||||
def get_course_property(coursename, property):
|
||||
|
||||
@@ -236,7 +236,7 @@ def history(request, article_path, page=1, course_id=None):
|
||||
|
||||
page_size = 10
|
||||
|
||||
if page == None:
|
||||
if page is None:
|
||||
page = 1
|
||||
try:
|
||||
p = int(page)
|
||||
@@ -310,7 +310,7 @@ def revision_feed(request, page=1, namespace=None, course_id=None):
|
||||
|
||||
page_size = 10
|
||||
|
||||
if page == None:
|
||||
if page is None:
|
||||
page = 1
|
||||
try:
|
||||
p = int(page)
|
||||
|
||||
@@ -23,7 +23,7 @@ class Model(object):
|
||||
try:
|
||||
return self.attributes[name]
|
||||
except KeyError:
|
||||
if self.retrieved or self.id == None:
|
||||
if self.retrieved or self.id is None:
|
||||
raise AttributeError("Field {0} does not exist".format(name))
|
||||
self.retrieve()
|
||||
return self.__getattr__(name)
|
||||
|
||||
@@ -70,7 +70,7 @@ StrPrinter._print_hat = _print_hat
|
||||
|
||||
|
||||
def to_latex(x):
|
||||
if x == None: return ''
|
||||
if x is None: return ''
|
||||
# LatexPrinter._print_dot = _print_dot
|
||||
xs = latex(x)
|
||||
xs = xs.replace(r'\XI', 'XI') # workaround for strange greek
|
||||
@@ -278,7 +278,7 @@ class formula(object):
|
||||
|
||||
if self.the_sympy: return self.the_sympy
|
||||
|
||||
if xml == None: # root
|
||||
if xml is None: # root
|
||||
if not self.is_mathml():
|
||||
return my_sympify(self.expr)
|
||||
if self.is_presentation_mathml():
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<%page args="active_page=None" />
|
||||
|
||||
<%
|
||||
if active_page == None and active_page_context is not UNDEFINED:
|
||||
if active_page is None and active_page_context is not UNDEFINED:
|
||||
# If active_page is not passed in as an argument, it may be in the context as active_page_context
|
||||
active_page = active_page_context
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
<h2 class="problem-header">
|
||||
${ problem['name'] }
|
||||
% if problem['weight'] != 1 and problem['weight'] != None:
|
||||
% if problem['weight'] != 1 and problem['weight'] is not None:
|
||||
: ${ problem['weight'] } points
|
||||
% endif
|
||||
</h2>
|
||||
@@ -30,4 +30,4 @@
|
||||
</section>
|
||||
% endif
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user