You can not imagine im actually just scripting away again today :) Yes, some could call it geeky, but in this case i actually have to finish something, of which once again i found out i approached it wrong. I know right, happens all the time. In this case im just twisting myself in a maze of lists which i wont bore you with since its not part of my posting plan :)
Every now and then when i write something in Python i get to the ‘import’ lines and type ‘#from pub import beer’. Its funny and geeky all at the same time, and no one would notice unless he checks out my clumsily written source :)
But now i thought, what the heck :) lets just make a ‘pub.py’ with only one definition ‘beer’ and this is what it looks like :D
-
# filename : pub.py
-
# beer can be true
-
import random
-
-
def beer():
-
rangebeer = ['0','1']
-
beer = random.choice(rangebeer)
-
return int(beer)
And now all u do in my other scripts is call it :
-
from pub import beer
-
-
a = beer()
-
if a == 1:
-
print "The beer, it is true!"
-
#…
It must be friday :D

