407 Posted Topics
Re: I am unhappy to report that Python 3.3.1 still comes with the Tkinter Filedialog bug. Could be a bug introduced by the Windows OS? Looking in C:\Python33\tcl\tk8.5 is the highest version listed | |
Re: Thanks for the info, I have to look into Pillow replacing PIL for Python33. | |
![]() | |
Re: Check out: http://code.activestate.com/recipes/189858-python-text-to-pdf-converter/ | |
Re: The Python3 str.format() method has been backported to Python 2.6. See http://docs.python.org/2.6/library/stdtypes.html http://docs.python.org/2.6/whatsnew/2.6.html and PEP 3101 Even with Python33 you can still use the % specifier: import sys for key in sys.modules.keys(): print("hello from %s" % key) | |
Re: The Pentagon admitted Sunday that a 2,000-pound bomb dropped by a U.S. Navy fighter accidentally landed on a row of houses in Kabul. The CIA's targeting is improving each and every year. This time, we missed the Chinese embassy by a good five blocks. | |
Re: Convert the json string object to a Python dictionary and look at the dictionary keys. | |
Re: You need to save your updates and a dictionary is ideal to do this with. Python has module shelve to make a 'persistent to file' dictionary automatically. Very powerful stuff indeed! | |
Re: Being from California I am rooting for the 49ers. I really like the halftime show! | |
I am exploring the J language for scientific purposes and am running this Fibonacci number code. Does anyone know how to add up the values in each of the four columns? NB. Fibo101.ijs NB. Fibonacci numbers NB. using J language free from www.jsoftware.com NB. F creates a list of the … | |
Re: [QUOTE=Ezzaral;598315]Conversely, please accept that some of us do not. Our simple request is that need be kept as a personal matter and out of our schools, laws, government, and international dealings. Simple enough from our point of view anyway, obviously not so for the majority.[/QUOTE]Amen to that! For those of … | |
Re: I like the SharpDevelop IDE very useful for C# and IronPython. With Java having all those security issues right now, I am reluctant to use software like Eclipse or Netbeans. | |
Re: Not sure if QMainWindow accepts absolute layout? | |
Re: Holy smokes woooee, this person has been a busy little beaver. All this because he/she confuses thousands with hundreths of a second. | |
Santa just brought me a fancy notebook computer and I want to know if anyone has some experiemce with accessing that little camera with Python code? | |
Re: Look at something like **PIL.pth** the PIL package directory and it's `__init__.py` file | |
Re: Slate is right, a little test print within the function allows you to follow what is going on: def f(x, y): print(x, y) # test print to check progress if y == 0: return x else: return f(y, x%y) print(f(240, 150)) Or: num = 0 for i in range(0,10,1): if … | |
Re: One more stone turned: import collections import random # values are integers ddict = collections.defaultdict(int) for k in range(100): n = random.randint(0, 10) ddict[n] += 1 print(ddict[3]) | |
Re: Python 2.7.3 has all the features of Python2 and also allows you to bring in features of Python3. Python3 has a lot of changes when it comes to byte strings that can bite (no pun intended) a beginner trying to use older code examples. | |
Re: I would stick with a list of tuples and module pickle to save/dump and load the container object. Use a list of lists if you want to edit the contents. | |
Re: What does your file look like? Did you save it as a CSV file from excel? | |
Re: Thanks Lardmeister for pointing out that the introduction of byte strings in Python3 makes quite a few changes to Python2 code. I guess it eliminates some of the unicode problems. | |
Re: What are modules ogr and osr? | |
Re: Generally: import os filename = "example.txt" if os.path.exists(filename): print("file %s exists" % filename)) # now do something with the file | |
Re: Put a test print(f(guess)) after guess = 1.0 and see. | |
Re: Maybe this: mylist = [0x123D, 0x844F, 0x33E9, 0xFFFF, 0xFFFF, 0xFFFF] newlist = (mylist[:mylist.index(0xFFFF)])[::-1] | |
Re: Hint, in program 1 you need to read all the lines. Right now you are only reading one line. | |
Re: Tkinter bind passes an event argument that you have to take care of even if you don't use it: from tkinter import * class App: def __init__(self, master): self.left = 0 self.right = 0 widget = Label(master, text='Hello bind world') widget.config(bg='red') widget.config(height=5, width=20) widget.pack(expand=YES, fill=BOTH) widget.bind('<Up>',self.incSpeed) widget.focus() def incSpeed(self, event): … | |
Re: Try this: [code]import os a = 'hello' cmd_string = "echo $%s" % a os.system(cmd_string) [/code] | |
Re: Join the Air Force and bomb the beast called boredom. | |
Re: Maybe you mean something like this: def create_string_list(mylist): string_list = "" for item in mylist: string_list += str(item) + '\n' return string_list mylist = ['1','2','a','b'] string_list = create_string_list(mylist) print(string_list) '''result>> 1 2 a b ''' | |
Re: You can also use the Python function eval(): print("A math expression is something like 3+5+7 (no spaces)") math_expression = raw_input("Enter a math expression: ") result = eval(math_expression) print("Result of %s is %s" % (math_expression, result)) | |
| |
Re: You could add a few test prints: # write a test file data = '177' with open('money.$','w') as fout: fout.write(data) # read file back in money_file = open('money.$','r').read() # test print value and type print money_file, type(money_file) '''result >> 177 <type 'str'> ''' if money_file: money = int(money_file) print money | |
Re: If you want to span over 2 rows (rows 4 and 5) use: text.grid(row=4, column=1, rowspan=2) | |
![]() | Re: A little bit more univeral: def clear_screen(): """ clear the screen in the command shell works on windows (nt, xp, Vista) or Linux """ import os os.system(['clear','cls'][os.name == 'nt']) |
Re: In your if statement (i) is a string and (len(s) - 1) gives an integer. Just a note, don't use sum and str, those are in the Python syntax. Also l gets easily confused with the number 1. Since you are already using slicing, why not this: # a simple … | |
Re: The Eric5 IDE for Python has a built-in Icon Editor (Extras/Tools/Icon Editor) | |
Re: Try something like this: # A program to calculate date of Easter def calc_easter(year): if year in range(1982, 2049): a = year % 19 b = year % 4 c = year % 7 d = ((19*a) + 24)%30 e = ((2*b) + (4*c) + (6*d) + 5)%7 f = … | |
Re: Sooner or later all cars will run electric, then we will have to post a new thread called **"Kilowatthour Prices"** | |
![]() | Re: You would be better off to use a Python IDE like IDLE (comes with Python) or Eric5. Notepad++ is more geared for html development. ![]() |
Re: A number of things wrong here, see the comments in the code: # guess the number in a GUI from tkinter import * import random class Application(Frame): ''' GUI guess the number application ''' def __init__(self, master): '''initialise frame''' super(Application, self).__init__(master) self.grid() self.create_widgets() # create the random number self.rnumber # … | |
Re: To run a timer in the background you have to use the module threading. You can also use the current time at start and end of the game and calculate the difference. # time elapsed using time.clock() or time.time(): import time # time.clock() is for windows only, updates every 1 … | |
Re: Barbara Bush and Willard Mitt Romney are firends? | |
Re: Ah, I always wanted something like that: # an input generator for strings # works with Python2 or Python3 try: input = raw_input except: pass def input_generator(prompt='> ', stop=''): ''' keep asking for input until stop value entered ''' while True: inp = input(prompt) if inp.lower() == stop.lower(): return yield … | |
Re: I love yogurt, particularly Greek yogurt! I agree that most newscasters need stuff thrown at them, but why waste good yogurt? | |
Re: The proper way to save a dictionary object is with Python module pickle. Here is an example: # use module pickle to save/dump and load a dictionary object # or just about any other intact object # use modes "wb" and "rb" to work with Python2 and Python3 import pickle … |
The End.