Should you find Irony, you can keep her!
bumsfeld 413 Nearly a Posting Virtuoso
fredzik commented: Good post, reminded me of how time.sleep() worked. +1
Should you find Irony, you can keep her!
Something little more entertaining:
Write program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number, and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
Japan is an island just like the UK, but they have zero immigration! Makes you wonder what they do?
I think I could come up with a much version of this using PhotoShop.
How do they know that they are actually devoid of any matter without acttually going there? I mean sure maybe no visible matter but that doesn't mean that there is no matter.
I read that it's the lack of gravitational pull. It could however be, that the never before observed phenomenon of antigravity plays one role here?
Here are the latest stats for Europe:
Of the 474 million citizens and legal foreign residents of the EU/EEA and Switzerland, some 42 million were born outside their European country of residence. In absolute terms, Germany had by far the largest foreign-born population (10.1 million), followed by France (6.4 million), the UK (5.8 million), Spain (4.8 million), Italy (2.5 million), Switzerland (1.7 million), and the Netherlands (1.6 million).
Source: http://www.migrationinformation.org/Feature/display.cfm?id=402
So, why does Cal Thoma and Fox News single out Britain?
The English have survived wars with the Scotts, the Danish, the Germans, the Spanish, the French, also rebellious Irish, and Dutch settlers. They have been kicked out of America, the Middle East, India, and Africa. Yet they are resilient, proud, smart and capable people! Despite Cal Thoma and his negativism, I would think they will easily survive those few hard working foreigners in their neighborhood! Where is the famous stiff upper lip!
If nothing is a hole
A black nothing eats it all
All, but for your soul
The video has been removed by the user... :(
It's called freedom of speech!
I was once in Indiana and wondered why the people in the market place carried submachine guns and drove armored personnel carriers!
If the pilot's fate is to die, do the passengers come along? What is your fate as a coal-miner, if the owner has bought politicians to bypass safety?
My choice of female who thinks she is smart and bitches all the time, or women with a good body and I can tell to be quiet is obvious! There is nothing more deflating to man than excessive bitchig.
This little code could be beginning of a scrambled sentence game:
# simple sentence scrambler
import random
def scatter_word(a_word):
"""
scramble a word, and leave words less than 4 characters long,
and the beginning and ending characters of longer words alone
"""
if len(a_word) < 4:
return a_word
else:
# create a list of interior characters
t = list(a_word[1:-1])
# shuffle the characters
random.shuffle(t)
# join back to form a word
return a_word[0] + "".join(t) + a_word[-1]
def scatter_text(text):
return " ".join(scatter_word(x) for x in text.split(" "))
text = "A goldfish has a memory span of three seconds"
print scatter_text(text)
"""
possible result -->
A gfiosldh has a momery sapn of trehe sondecs
"""
Wouldn't it be simpler to create a polygon with coordinates x0,y0 and x,y and x1,y1 back to x0,y0 and fill it with the color to match?
If you want to do that sort of thing, you might as well download the console module from:
http://effbot.org/downloads/
Console interface for Windows only (versions up to Python25 available):
console-1.1a1-20011229.win32-py2.5.exe
Look at documentation at:
http://effbot.org/zone/console-handbook.htm
Yes, Python allows you to create packages in one folder, that's how wx works. I just don't know how to do this yet!
Why only punish the corporals? How about the sergeants and lieutenants?
You can create and save a module of your favorite class collection this way:
# put number of your favorite classes into one module
# save it as MyClassCollection.py (preserve filename case) somewhere
# on the PYTHONPATH so Python's import can find it
class ClassA(object):
def __init__(self, color='blue'):
self.color = color
def show(self):
print "ClassA likes color", self.color
class ClassB(object):
def __init__(self, color='red'):
self.color = color
def show(self):
print "ClassB likes color", self.color
class ClassC(object):
def __init__(self, color='green'):
self.color = color
def show(self):
print "ClassC likes color", self.color
# optionally test this module ...
if __name__ == '__main__':
a = ClassA()
b = ClassB()
c = ClassC('yellow')
a.show()
b.show()
c.show()
"""
result -->
ClassA likes color blue
ClassB likes color red
ClassC likes color yellow
"""
Once you have saved the collection you can access it this way:
# MyClassCollection.py is collection of your favorite classes
# it should be somewhere on the PYTHONPATH so Python can find it
# this program shows how to access this collection
# note that filename and modulename are case sensiive!
import MyClassCollection as mcc
# to make typing easier the optional alias 'mcc' is used for 'MyClassCollection'
# mcc becomes the namespace to access the class collection
# test it ...
a = mcc.ClassA()
b = mcc.ClassB()
c = mcc.ClassC('yellow')
a.show()
b.show()
c.show()
"""
result -->
ClassA likes color blue
ClassB likes color red
ClassC likes color yellow
"""
I hope that's what you where looking for? BTW, function collections would …
15 minutes into testing the new Boa Constructor (boa-constructor-0.6.1.bin.setup.exe), very impressed with it.
It does have ctrl/space for code completion choices!
Sorry, I have not used Boa Constructor for a while. It seems like they have had major recent upgrade at:
http://sourceforge.net/project/downloading.php?group_id=1909&use_mirror=osdn&filename=boa-constructor-0.6.1.bin.setup.exe&74856058
That one installs well and works with Python25 and wxPython28, even on a Vista machine. I am testing it out now.
There is Boa Forum at:
http://sourceforge.net/forum/forum.php?thread_id=1617033&forum_id=5483
They might be defunct?
You can type in the SPE Python shell
help('Tkinter')
from Tkinter import *
root = Tk()
root.
Actually an IDE called PyScripter has this feature. The moment you type the dot a dropdown list of possible choices appears.
Which version of wxPython do you have installed?
I am having the same problem on my newest computer.
For those of you who like visual frame builders/designers for the wxPython toolkit, wxGlade has been much improved lately. You can down load it free from:
http://wxglade.sourceforge.net/
It also comes integrated into Stani's Python Editior (SPE), which is still available from:
http://www.tradebit.com/filedetail.php/839343
Downloads as spe-0.8.3c.zip, and will work with Python 2.3 - 2.5. Simply extract the '_spe' directory into your Python 'lib' folder. You can then run 'spe.pyw' from there. Again, you need the wxPython GUI toolkit installed first for SPE and wxGlade to work!
wxGlade takes one moment to get used to, there is one short tutorial.
The frame builder wxGlade comes with Stani's Python Editor (SPE). You can still get a free download of SPE 0.8.3c, the Python IDE for Movable Python at:
http://www.tradebit.com/filedetail.php/839343
Downloads as spe-0.8.3c.zip, and should work with Python 2.3 - 2.5. Simply extract the '_spe' directory into your Python 'lib' folder. You can then run 'spe.pyw' from there. Again, you need the wxPython GUI toolkit installed first for SPE to work!
There is Boa Constructor (similar to Delphi) that uses wxPython as the GUI toolkit (you need wxPython isstalled first), free download from:
http://downloads.sourceforge.net/boa-constructor/boa-constructor-0.4.4.win32.exe
There is also wxGlade, just frame builder/designer, also using wxPython:
http://wxglade.sourceforge.net/
For those of you, who absolutely have to clear the console screen, you can use:
print '\n'*35
This of course leaves the cursor at the bottom of the screen. If you don't like that, this will do better:
# works on Windows or Linux, also Vista
import os
os.system(['clear','cls'][os.name == 'nt'])
Also match width and height on your canvas widget!
You can't mix geometry managers pack() and grid() withint the same parent widget. I would stick with grid(), now it works:
from Tkinter import *
try:
from PIL import Image, ImageTk
except ImportError:
import Image, ImageTk
class SplashScreen(Toplevel):
def __init__(self, master, image=None, timeout=1000):
"""(master, image, timeout=1000) -> create a splash screen
from specified image file. Keep splashscreen up for timeout
milliseconds"""
Toplevel.__init__(self, master, relief=RAISED, borderwidth=5)
self.main = master
"""
# you don't need this!!!!!!!!!!!
if self.main.master != None: # Why ?
self.main.master.withdraw()
"""
self.main.withdraw()
self.overrideredirect(1)
im = Image.open(image)
self.image = ImageTk.PhotoImage(im)
self.after_idle(self.centerOnScreen)
self.update()
self.after(timeout, self.destroy)
def centerOnScreen(self):
self.update_idletasks()
width, height = self.width, self.height = \
self.image.width(), self.image.height()
xmax = self.winfo_screenwidth()
ymax = self.winfo_screenheight()
x0 = self.x0 = (xmax - self.winfo_reqwidth()) / 2 - width/2
y0 = self.y0 = (ymax - self.winfo_reqheight()) / 2 - height/2
self.geometry("+%d+%d" % (x0, y0))
self.createWidgets()
def createWidgets(self):
# Need to fill in here
self.canvas = Canvas(self, height=self.width, width=self.height)
self.canvas.create_image(0,0, anchor=NW, image=self.image)
self.canvas.pack()
def destroy(self):
self.main.update()
self.main.deiconify()
self.withdraw()
if __name__ == "__main__":
import os
tk = Tk()
l = Label(tk, text="Phone Book")
l.grid(row=0, column=0, columnspan=2, pady=5)
n = Label(tk,text="Name")
n.grid(row=1, column=0, pady=5)
E1=Entry(tk,width=40)
E1.grid(row=1, column=1)
b = Button(tk, text='button', width=40)
b.grid(row=2,column=0, pady=5)
s = Label(tk,text="Surname")
s.grid(row=3,column=0,pady=5)
E2=Entry(tk,width=40)
E2.grid(row=3,column=1)
nr = Label(tk,text="Number")
nr.grid(row=4,column=0,pady=5)
E3=Entry(tk,width=40)
E3.grid(row=4,column=1)
assert os.path.exists("python.jpg")
s = SplashScreen(tk, timeout=5000, image="python.jpg")
tk.mainloop()
Can you tell us what you mean under synchronization. You may be using the wrong terminology.
The problem with time.sleep(sec) is that your whole program sleeps unless you thread the background action. So BearofNH's use of time.time() is more appropriate.
I believe that global warming is natural (if we examin ice cores and other evidence we can see that over time, the earth naturally warms up then enters an ice age) BUT i believe that mans CO2 emissions has worsened the problem.
You make it sound like global warming is a religion.
America is lucky, their immigrants (illegal or not) come to work and work hard! In Europe they come to blow up trains and burn cars.
Who exactly are you talking about? My dad is a "real" scientist. He believes in global warming. My friends dad works at NOAA as a programmer/scientist and he believes in global warming, So who exactly are these scientists that do not believe in global warming? Regardless, the video advocates the proper course of action.
Your daddy works for the government, so he believes what ever he is told to believe!
Now here are some real scientists presenting their work on global warming:
YouTube - Global Warming - Doomsday Called Off (1/5)
http://www.youtube.com/watch?v=fr5O1HsTVgA
YouTube - Global Warming - Doomsday Called Off (2/5)
http://www.youtube.com/watch?v=fD6VBLlWmCI
YouTube - Globabl Warming - Doomsday Called Off (3/5)
http://www.youtube.com/watch?v=gZS2eIRkcR0&NR=1
YouTube - Global Warming - Doomsday Called Off (4/5)
http://www.youtube.com/watch?v=dIbTJ6mhCqk&NR=1
YouTube - Global Warming - Doomsday Called Off (5/5)
http://www.youtube.com/watch?v=v2XALmrq3ro&mode=related&search=
-----------------------------------------------------
YouTube - The Great Global Warming Swindle 1 of 8
http://www.youtube.com/watch?v=8f8v5du5_ag&mode=related&search=
YouTube - The Great Global Warming Swindle 2 of 8
http://www.youtube.com/watch?v=R2S5OGS-g9g&mode=related&search=
YouTube - The Great Global Warming Swindle 3 of 8
http://www.youtube.com/watch?v=vufPWwsUu_k&mode=related&search=
YouTube - The Great Global Warming Swindle 4 of 8
http://www.youtube.com/watch?v=U9Ku1_gruaQ&mode=related&search=
YouTube - The Great Global Warming Swindle 5 of 8
http://www.youtube.com/watch?v=zalexeUwtNw&mode=related&search=
YouTube - The Great Global Warming Swindle 6 of 8
http://www.youtube.com/watch?v=MvkX3jNjPK8&mode=related&search=
YouTube - The Great Global Warming Swindle 7 of 8
http://www.youtube.com/watch?v=660hjo4f6Ig&mode=related&search=
YouTube …
I play guitar... I have a Gibson Les Paul and a Fender Stratocaster. Hear some of my stuff:
http://www.soundclick.com/alexglasserIt's not much, but I like it.
Alex, thanks for the link, neat site!
Good for MySpace! I hate spammers!
Unquestionably one of the squirrels left over from Hitler's Killer Squirrel experiment. After all this murderous fellow grew up somewhere near there.
I think that computer programming can be made exciting even with old languages like Qbasic. It's the dullfugg of a teacher that can bore the students out of their mind.
Hollywood movies aren't real ;)
What do you mean? They look pretty real to me! Not all of them are men in rubber suits.
Call me strange, but I like the stink of it! The noice is exciting too! Best of all, I like when they throw sparks. Beats ice hockey anytime.
Honest politicians would annoy me, if there were any. I am so used to the fact that they all lie.
Dinosaurs are extinct. There can't be new ones. Only old, dead ones... :icon_razz:
I have seen plenty of Hollywood movies were the dinos where very much alive!
Python is glue language for all sorts of other computer languages. Might be possible to use C# dlls. All you really need to do is to figure out how to relate Python argument types and C# argument types. Similar to the ctypes module.
Look into modpython, django and cherrypy.
Sorry, I don't really know what you are talking about. I have never seen those purple thingies.
Just one small hint:
Your title "find way out !!!" is not conducive to get help. should have been something like "help with GSM/GPIO". This way anyone with knowledge of the subject will look further.
I was forced to learn it in school. Kind of one unsightly language, and lots of things to trip over, but you get used to that! We used Dev-Cpp (GNU CPP) and I still use that.
256 colors is 8 bits per pixel. Hope that helps.
My advice, use the vector container. One of the advantages of using C++.
Here is code for simple word guessing game:
# a very simple word guessing game
import random
def check(veil, guess, word):
"""
check if the guess letter is in the word
if found then update the veil
"""
for ix, letter in enumerate(word):
if letter == guess:
veil[ix] = guess
return veil
print "Guess a word (lower case letters only) ... "
words = ['art', 'bush', 'letter', 'banana', 'radio', 'hard',
'kiss', 'perl', 'target', 'fork', 'rural', 'zero', 'organ']
while True:
# pick a word at random
word = random.choice(words)
tries = 0
# create veil of dashes matching the word length
veil = list('-' * len(word))
while '-' in veil:
print "".join(veil),
guess = raw_input("Enter a letter: ").lower()
veil = check(veil, guess, word)
tries += 1
print "".join(veil)
prompt = "You guessed correctly in %d tries, try again (y or n): " % tries
tries = 0
yn = raw_input(prompt).lower()
if 'n' in yn:
print "Thank you for playing!"
break
Improve the game making sure each random word is picked only once. How would you add an hint to each of the words?
Interesting project! I am working myself though the code. I have never written anyhing like that.