4,305 Posted Topics
Re: Instead of lambda you can also use Python's partial function, new in Python25. Here is a simple example ... [code=python]# a tiny Tkinter calculator showing the # use of the new Python25 partial function import Tkinter as tk from functools import partial # needs Python25 or higher def click(key): global … | |
| |
Re: Because of the rapid and deliberate devaluation of the US Dollar, you have to make sure your wealth is in another currency. | |
Re: To retrieve key and val from the key:val pairs of a dictionary use this ... [code=python]stats_dic = { "ECSE":8, "LCSI":6, "ECOM":13, "ABIT":4, "ACSM":3, "AEXH":2, "AEXP":9, "BULS":6, "APME":8, "BBMB":3, "EBCL":2, "EEEL":9, "LDES":4, "LMAT":3, "LPHY":3, "LPSC":4, "LUHU":4, "LUPS":5, "LUSS":2 } for key, val in stats_dic.items(): # test it ... print key, val … | |
| |
Re: People who talk about global warming on a hot day, but on a cold day they ignore the subject. | |
Re: Another way to stay healthier, just in the news (3/7/2008): People who started drinking in middle age were 38 percent less likely to have a heart attack or other serious heart event than abstainers. [url]http://news.yahoo.com/s/nm/20080307/hl_nm/heart_drinking_dc_1[/url] | |
Re: First of all, please use the Python style guide by GVR himself: [url]http://www.python.org/peps/pep-0008.html[/url] To make code easier to read. I used a different Words.txt, but this should work ... [code=python]# WordPlay.py # saved the module in D:\Python25\Atest\Bull # use sys.path.append(r'D:\Python25\Atest\Bull') so PYTHONPATH can find it def avoid(word, forbid): """ Function … | |
Re: Check a program called Pyton4Delphi at: [url]http://www.mmm-experts.com/[/url] It allows you to use Python code within Delphi. | |
Re: kath is right, you have to keep track of it as a list, really a number of lists. | |
Re: Some of the basics of sending a text string to the printer are in the Python code snippet at: [url]http://www.daniweb.com/code/snippet399.html[/url] If you have a Python code file like this ... [code=python]# days2xmas.py # calculate days till xmas of 2008 import datetime as dt now = dt.date.today() # change the year … | |
Re: [quote] Overview Java Language Conversion Assistant is a tool that automatically converts existing Java-language code into Visual C#® for developers who want to move existing applications to the .NET Framework. Java Language Conversion Assistant provides developers using Visual Studio .NET 2003 a quick, low-cost method of converting Java-language applications to … | |
Re: A city car can be driven with compressed air for a distance of about 100 miles. Compressed air can be supplied by stations using electricty from nuclear power plants. The problem is that compressing air generates heat that needs to be used to heat homes, industry or green houses to … | |
Re: If richedit is your wx.TextCtrl object set to style=wx.TE_MULTILINE|wx.TE_RICH2 then use richedit.SetInsertionPoint(0) richedit.SetStyle(start, end, wx.TextAttr("red", "yellow")) where start/end is the index range in your string you want to highlight in the given fg/bg colors. | |
Re: Then you have to give your image object a name ... img1 = canvas.create_image(200, 250, image=photo) ... and delete that on specifically... canvas.delete(img1) | |
Re: If you use the Tkinter GUI toolkit, you can use an input dialog box called askinteger, it makes sure only integers are entered. A typical example ... [code=python]# use Tkinter popup dialogs for input import Tkinter as tk import tkSimpleDialog as tsd # has askfloat, askinteger, askstring def get_data(): miles … | |
Re: You could do it with something like label.config(bg='white') | |
Re: [QUOTE=vmanes;542154]My favorite way to mess with folks is do a screen capture of their desktop, save it as an image, then display the image fullscreen (irfanview works well) They spend minutes clicking on their shortcuts, the start button, taskbar....[/QUOTE]Now that is really evil! Here I thought you were such a … | |
Re: [QUOTE=jaepi;500009]I made love with Megan Fox. That was nasty![/QUOTE]I hope it was in Technicolor, Stereo and Smellavision (smile). | |
Re: To be honest, never could stand the guy, but may he rest in peace! | |
Re: McDonalds used to serve an egg nog flavored milk shake this time of the year, I need to check if they still do. Maybe AD can give us a hint what else tastes good there. | |
Re: I think Indonesia is lucky enough to have the most earthquakes, tsunamis and exploding volcanoes. | |
Re: My nick goes back to my younger days when I designed a more luxurious seat (with heating, cooling and stereo) for the Chevy Vega. It was rejected because it cost 10 cent more than the standard seat from Fisher. | |
Re: How does this challenge your intelligence? Knowing Lardmeister and his ilk, this is a euphemism for mildly unintelligent. | |
Re: vegas-eat: I go to Las Vegas a lot to eat, drink and gamble. Gambling costs money, drinks and food are mostly free! | |
Re: You can use the enumerate function and incrementally increment the ascii value of the character ... [code=python]s = 'aaaa' q = "" for ix, e in enumerate(s): q += chr(ord(e) + ix) print q # abcd [/code]For your first problem you could use something similar ... [code=python]a = [1, 2, … | |
Re: [code=python]s = "u'mystring'" # assuming it is always u' s2 = s.replace("u'", "'") print s2 # 'mystring' [/code] | |
Re: [QUOTE=Lardmeister;541712]Swiss banks are notorious for laundrying dirty criminal money. I wish more of their employees would come foreward and spill the beans.[/QUOTE]Hmm, I thought only the Lichtenstein bankers did that sort of stuff. I will have to check it out. | |
Re: My basic assumption is that there is no such thing as privacy when it comes to government action. This has been broadened by the fear of terrorism. You want some privacy, encrypt your files. | |
Re: Fun with ascii values of a string ... [code=python]def ascii_list(s): """return a list of ascii values of the characters in string s""" return [ord(c) for c in s] s = 'cat' alist = ascii_list(s) print alist # [99, 97, 116] # manipulate the list elements alist[0] += 1 alist[1] += … | |
Re: Please use the [b][noparse][code=python][/noparse][/b] and [b][noparse][/code][/noparse][/b] tag pair to enclose your python code. Without this the code becomes very difficult to read, since all indentations are lost. | |
Re: I am not sure if it's the best one, but pyenchant is very good: [url]http://pyenchant.sourceforge.net/[/url] | |
Re: Here is a hint ... [code=python]""" Part of typical csv file (Country.csv): NAME,ISO,CAPITAL,POPULATION,AREA Afghanistan ,AF ,Kabul,28513677,647500 Albania ,AL ,Episkopi,3544808,28748 Algeria ,AG ,Tirana,32129324,2381740 American Samoa ,AQ ,Algiers,57902,199 Andorra ,AN ,Pago Pago,69865,468 Angola ,AO ,Andorra la Vella,10978552,1246700 """ for line in file("Country.csv"): # skip header if 'NAME' in line: continue # remove … | |
Re: I would put lawyers under politicians, since most of them are lawyers. I haven't bought a used car for a long time and always assumed that kicking a tire or two would be better than listening to the used car salesman. | |
Re: Here is one way to do this ... [code=python]from Tkinter import * from tkFileDialog import askdirectory def browser(): dir1 = askdirectory(title="Select A Folder", mustexist=1) if len(dir1): #print dir1 e1.insert(0, dir1) root = Tk() e1 = Entry(root) e1.pack() b1 = Button(root, text='Browse', command=browser) b1.pack() root.mainloop() [/code] | |
Re: As many times as I say "Oh God!" there better be one. God seems to be individually modified to suit the person. | |
Re: February 2nd is just around the corner, hope the line isn't too long! | |
Re: Create the initial test file ... [code=python]data = """Astronomical Applications Dept. U.S. Naval Observatory Washington, DC 20392-5420 ST. PETER'S NOVA SCOTIA o , o , W 60 52, N45 39 Altitude and Azimuth of the Sun Jun 7, 2008 Zone: 3h West of Greenwich Altitude Azimuth (E of N) h … | |
Re: You might be able to use this ... [code=python]# this gives daily info: # takes care of leap-years too import datetime as dt wday = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] start = dt.date(1900, 1, 1) oneday = dt.timedelta(days=1) # test it for the first 370 days for x … | |
Re: I think there needs to be a self.window.show() in __init__ similar to the example below. [code=python]# very basic GTK/Python program showing just a window # you have to install GTK runtime, PyCairo, PyGobject and PyGTK for this to work import gtk class Base(object): def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.show() def … | |
Re: "SuPeRcAlIfRaGiLiStIcExPiAlIdOcIoUs" works well for me as a password. | |
Re: I checked my old Borland C++ compiler, you may have to add the .h to your includes! #include<iostream.h> #include<cstdlib.h> | |
Re: I will watch it for the beer and pizza party, the halftime show, and the Budwiser commercials. I also hope to see some more or less spectacular plays! Maybe somebody runs over a ref for the fun of it. It's true, Budwiser does make your bud wiser. |
The End.