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

#!/usr/bin/python
  1. # filename : pub.py
  2. # beer can be true
  3. import random
  4.  
  5. def beer():
  6.     rangebeer = ['0','1']
  7.     beer = random.choice(rangebeer)
  8.     return int(beer)

And now all u do in my other scripts is call it :

#…
  1. from pub import beer
  2.  
  3. a = beer()
  4. if a == 1:
  5.     print "The beer, it is true!"
  6. #…

It must be friday :D