content_copy
dashboard

#python

if "blah" not in somestring: 
    continue
content_copy
dashboard

#python

import pathlib
pathlib.Path('/my/directory').mkdir(parents=True, exist_ok=True) 
content_copy
dashboard

#python

import glob
print(glob.glob("/home/adam/*.txt"))
content_copy
dashboard

#python

a = []

if not a:
  print("List is empty")
content_copy
dashboard

#python

>>> ["foo", "bar", "baz"].index("bar")
1
content_copy
dashboard

#python

if 'key1' in dict:
  print "blah"
else:
  print "boo"
content_copy
dashboard

#python

for idx, val in enumerate(ints):
    print(idx, val)
content_copy
dashboard

#python

import time
time.sleep(5)   # Delays for 5 seconds. You can also use a float value.
content_copy
dashboard

#python

>>> from time import gmtime, strftime
>>> strftime("%Y-%m-%d %H:%M:%S", gmtime())
'2009-01-05 22:14:39'
content_copy
dashboard

#python

newlist = old_list.copy()
content_copy
dashboard

#python

>>> a = "545.2222"
>>> float(a)
545.22220000000004
>>> int(float(a))
545
content_copy
dashboard

#python

x = tf.random_normal([300], mean = 5, stddev = 1)
y = tf.random_normal([300], mean = 5, stddev = 1)
avg = tf.reduce_mean(x - y)
cond = tf.less(avg, 0)
left_op = tf.reduce_mean(tf.square(x-y))
right_op = tf.reduce_mean(tf.abs(x-y))
out = tf.where(cond, left_op, right_op) #tf.select() has been fucking deprecated
keyboard_arrow_up