407 Posted Topics

Member Avatar for rwe0

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

Member Avatar for vegaseat
1
398
Member Avatar for rwe0
Member Avatar for vegaseat
0
847
Member Avatar for LastMitch
Member Avatar for Assembly Guy
0
339
Member Avatar for fonzali

Check out: http://code.activestate.com/recipes/189858-python-text-to-pdf-converter/

Member Avatar for fonzali
0
160
Member Avatar for krystosan

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)

Member Avatar for vegaseat
0
345
Member Avatar for The Dude

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.

Member Avatar for Ene Uran
9
4K
Member Avatar for donkatsu

Convert the json string object to a Python dictionary and look at the dictionary keys.

Member Avatar for donkatsu
0
281
Member Avatar for longtomjr

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!

Member Avatar for ZZucker
0
216
Member Avatar for <M/>

Being from California I am rooting for the 49ers. I really like the halftime show!

Member Avatar for <M/>
0
90
Member Avatar for TrustyTony
Member Avatar for ZZucker

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 …

Member Avatar for TrustyTony
0
176
Member Avatar for ndeniche
Member Avatar for Lardmeister

[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 …

Member Avatar for sneekula
2
2K
Member Avatar for <M/>

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.

Member Avatar for sneekula
0
211
Member Avatar for krystosan
Member Avatar for pmec

Holy smokes woooee, this person has been a busy little beaver. All this because he/she confuses thousands with hundreths of a second.

Member Avatar for ZZucker
0
5K
Member Avatar for ZZucker

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?

Member Avatar for ZZucker
0
220
Member Avatar for jimmyshote

Look at something like **PIL.pth** the PIL package directory and it's `__init__.py` file

Member Avatar for ZZucker
0
555
Member Avatar for hotblink

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 …

Member Avatar for Xantipius
0
142
Member Avatar for efwon

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])

Member Avatar for snippsat
0
234
Member Avatar for runlevel3nut

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.

Member Avatar for runlevel3nut
0
248
Member Avatar for giancan

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.

Member Avatar for ZZucker
0
326
Member Avatar for darealsavage
Member Avatar for snippsat
0
265
Member Avatar for vegaseat

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.

Member Avatar for HiHe
5
8K
Member Avatar for mbh1992
Member Avatar for nUmbdA

Generally: import os filename = "example.txt" if os.path.exists(filename): print("file %s exists" % filename)) # now do something with the file

Member Avatar for ZZucker
0
117
Member Avatar for ggauravag2012
Member Avatar for valorien

Maybe this: mylist = [0x123D, 0x844F, 0x33E9, 0xFFFF, 0xFFFF, 0xFFFF] newlist = (mylist[:mylist.index(0xFFFF)])[::-1]

Member Avatar for valorien
0
152
Member Avatar for nabzlfc

Hint, in program 1 you need to read all the lines. Right now you are only reading one line.

Member Avatar for nabzlfc
0
108
Member Avatar for Kert

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): …

Member Avatar for ZZucker
0
343
Member Avatar for sasdap

Try this: [code]import os a = 'hello' cmd_string = "echo $%s" % a os.system(cmd_string) [/code]

Member Avatar for Jimleeeel
0
159
Member Avatar for PrimeOutsourcin
Member Avatar for 3e0jUn

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 '''

Member Avatar for peterparker
0
255
Member Avatar for Frensi

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))

Member Avatar for HiHe
0
6K
Member Avatar for depy
Member Avatar for ZZucker
0
121
Member Avatar for 3e0jUn

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

Member Avatar for HiHe
0
156
Member Avatar for 3e0jUn

If you want to span over 2 rows (rows 4 and 5) use: text.grid(row=4, column=1, rowspan=2)

Member Avatar for 3e0jUn
0
183
Member Avatar for HTMLperson5

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'])

Member Avatar for 3e0jUn
2
4K
Member Avatar for manticmadman

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 …

Member Avatar for TrustyTony
0
195
Member Avatar for mattyd

The Eric5 IDE for Python has a built-in Icon Editor (Extras/Tools/Icon Editor)

Member Avatar for ZZucker
0
5K
Member Avatar for zaphoenix

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 = …

Member Avatar for ZZucker
0
189
Member Avatar for Lardmeister

Sooner or later all cars will run electric, then we will have to post a new thread called **"Kilowatthour Prices"**

Member Avatar for Stuugie
1
178
Member Avatar for CriticalError

You would be better off to use a Python IDE like IDLE (comes with Python) or Eric5. Notepad++ is more geared for html development.

Member Avatar for polochen
0
537
Member Avatar for The Dude
Member Avatar for evvo69

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 # …

Member Avatar for evvo69
0
2K
Member Avatar for idislikemacs

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 …

Member Avatar for memomk
0
147
Member Avatar for Ancient Dragon
Member Avatar for TrustyTony

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 …

Member Avatar for vegaseat
0
551
Member Avatar for Ancient Dragon

I love yogurt, particularly Greek yogurt! I agree that most newscasters need stuff thrown at them, but why waste good yogurt?

Member Avatar for happygeek
0
103
Member Avatar for Bamahonky

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 …

Member Avatar for Bamahonky
0
210

The End.