fdate=time.strptime("SEPTEMBER 19 2010", "%B %d %Y")worked, and
fdate=datetime.strptime("SEPTEMBER 19 2010", "%B %d %Y")triggered an exception.
Mostly Linux & Python syntax notes and hyperlinks.
fdate=time.strptime("SEPTEMBER 19 2010", "%B %d %Y")worked, and
fdate=datetime.strptime("SEPTEMBER 19 2010", "%B %d %Y")triggered an exception.
from my_one_function_file import my_one_functionThen if I stop using that function, I know I can get rid of the import statement. When I look at the import statement, I know exactly why it is there.
import my_one_function_filethen calling my_one_function via
my_one_function_file.my_one_function()In general, this recommendation does look like wise practice. It's more object-oriented.
>>> x=['a','b']That's not what I want.. Instead:
>>> x
['a', 'b']
>>> y=['c','d']
>>> z={}
>>> z.fromkeys(x,y)
{'a': ['c', 'd'], 'b': ['c', 'd']}
>>> d=dict(zip(x,y))That's as close as I can get it.
>>> d
{'a': 'c', 'b': 'd'}
>>>
>>> d['a']It seems awkward, but if you put it in a loop, it looks fine:
'c'
>>> d['b']
'd'
>>> x=['a','b','c','d','e']
>>> y=['q','r','s','t','u']
>>> z=zip(x,y)
>>> z
[('a', 'q'), ('b', 'r'), ('c', 's'), ('d', 't'), ('e', 'u')]
>>> d=dict(z)
>>> d
{'a': 'q', 'c': 's', 'b': 'r', 'e': 'u', 'd': 't'}
>>> for key in x:
... print key, "=", d[key]
...
a = q
b = r
c = s
d = t
e = u
>>>
>>> a,b="c","d"
>>> a
'c'
>>> b
'd'
>>> a,b='f g'.split()
>>> a
'f'
>>> b
'g'