1,175 Posted Topics

Member Avatar for sneekula

There used to be a Python module called pyglet that allowed graphics and sound. I can't find it anywhere.

Member Avatar for sneekula
0
256
Member Avatar for Jai_4

Couldn't you simply do this: digits = '234' size = len(digits) sum_odd = 0 for ix in range(1, size, 2): sum_odd += int(digits[ix]) prod_even = 1 for ix in range(0, size, 2): prod_even *= int(digits[ix]) print("sum of odd indexed integers = {}". format(sum_odd)) print("product of even indexed integers = {}". …

Member Avatar for sneekula
0
802
Member Avatar for sneekula

I would like to break up a list into sublists of 3 elements each. I have this code, but it will give an index error when the length of the list is not divisible by 3. mylist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] …

Member Avatar for sneekula
0
260
Member Avatar for mcroni
Member Avatar for La

Here is a typical example: def funk(arg1, arg2, arg3): pass arg1 = 77 # call function with only one argument funk(arg1) ''' error --> Traceback (most recent call last): File "<module1>", line 5, in <module> TypeError: funk() takes exactly 3 arguments (1 given) '''

Member Avatar for sneekula
-1
233
Member Avatar for abaddon2031
Member Avatar for vegaseat

The newer Portable Python 2.7.6.1 package contains the following applications/libraries: PyScripter v2.5.3 PyCharm Community Edition 3.1.2 (Thanks to cebik) NymPy 1.8.1 SciPy 0.13.3 Matplotlib 1.3.1 PyWin32 218 Django 1.6.2 PIL 1.1.7 Py2Exe 0.6.9 wxPython 3.0.0.0 NetworkX 1.7 Lxml 3.3.4 PySerial 2.7 PyODBC 3.0.7 PyGame 1.9.1 PyGTK 2.24.2 PyQt 4.10.4 IPython …

Member Avatar for sneekula
2
3K
Member Avatar for sneekula

I asked that in another thread, but it got lost: [QUOTE]When do you use root.quit() and when do you use root.destroy() to exit a Tkinter program?[/QUOTE] Also, can you intercept an exit when you use the little x in the title bar, just to affirm that you really want to …

Member Avatar for entropicII
0
45K
Member Avatar for MartinIT2type

You can use this approach to get an input dialog without the Tkinter window: [code=python]# use Tkinter's dialogs to ask for input # dialogs are askfloat, askinteger, and askstring import Tkinter as tk from tkSimpleDialog import askstring root = tk.Tk() # show askstring dialog without the Tkinter window root.withdraw() name …

Member Avatar for jules1234567
0
8K
Member Avatar for debasisdas
Member Avatar for Zebibyte

To take care of the ever present binary roundoff error that is associated with floating point numbers (most any computer language) do this: [code=python] # compensate for the binary roundoff error while change >= (m - 0.001): [/code]In the matter of fact you can streamline your code to this: [code=python]# …

Member Avatar for newbieee
0
748
Member Avatar for eplymale3043

Please use code tags for your code. You are getting close, but you need to find if the score is a new minimum or maximum each time through the loop. Something like this: [code=python]infile = open("test_scores.dat", "r") mylist = infile.readlines() infile.close() # remove the header, first item in the list …

Member Avatar for vegaseat
0
2K
Member Avatar for ddanbe

Old folks are just a drag on society. Putting up with them with about 25 years after retirement is generous enough. Making this 925 years would be insane. They are a major source of income for the medical profession now.

Member Avatar for Ancient Dragon
2
2K
Member Avatar for Warrens80

Santa has no religious meaning. He is a jolly soul that represents gift giving, flying sleds and obesity. Let's name the whole thing Santaday.

Member Avatar for Reverend Jim
0
1K
Member Avatar for davidw87

I would use this approach, use whatever .gif file you have, sorry this is from my iPad and it does not work well with DaniWeb commands: ,,, display an image using Tkinter for Python2 ''' import Tkinter as tk root = tk.Tk() image_file = "Vacation2013.gif" photo = tk.PhotoImage(file=image_file) root.title(image_file) label …

Member Avatar for vegaseat
0
474
Member Avatar for Caulm64
Member Avatar for Zahra_1
Member Avatar for Zahra_1
Member Avatar for tunisia
Member Avatar for ZielonySBS

[QUOTE=ZielonySBS;806195]I have a company scanner but very often people forget to remove scanned (confidencial documents) I want to create a script which will once day check a "/home/scanner" folder and if there are any files it moves them to my /home/Administrator folder. I dont really dont know how to start. …

Member Avatar for Gribouillis
0
19K
Member Avatar for Panarchy
Member Avatar for EarthHorse
0
5K
Member Avatar for dean.ong.14

Note that in Python3 the / division gives a float value, use integer division //

Member Avatar for sneekula
0
760
Member Avatar for aditya369

If you have a PC, take the mouse and double click in the code. This will highlight the code. Now right click on the highlighted code and use copy from the pop up menu. If you have a touch pad like the iPad, you are plain out of luck!

Member Avatar for Nils_1
0
267
Member Avatar for james.lu.75491856

This code snippet is pretty stupid. If I could down vote it from my iPad, I would!

Member Avatar for sneekula
-4
363
Member Avatar for Stefano Mtangoo

[QUOTE=evstevemd;769472]Yeah, I understand! I wanted us to keep each other updated in case any module comes for python 3[/QUOTE]Nice idea! Will keep checking it for the next year or so.

Member Avatar for vegaseat
0
985
Member Avatar for stevewilliams02
Member Avatar for vegaseat
Member Avatar for Pioggia254
Member Avatar for vegaseat
0
173
Member Avatar for vinodvinu

See: http://www.daniweb.com/software-development/python/threads/191210/python-gui-programming/6#post1246492

Member Avatar for vegaseat
0
445
Member Avatar for bryann
Member Avatar for bryann
0
321
Member Avatar for wolfraven004
Member Avatar for HiHe
Member Avatar for onalenna_1

Hint: # assume this is your data file (CSV type) # each line has last name, first name, grade data = '''\ Miller,Jean,75 Paulson,Peter,47 Tanner,Abraham,88 Norton,Sheila,33 ''' filename = "grades123.txt" # write a test file with open(filename, "w") as fout: fout.write(data) # now read your test file back in and …

Member Avatar for sneekula
0
145
Member Avatar for steven woodman
Member Avatar for stultuske
4
399
Member Avatar for rude_god

Here is an example how to use lambda to pass arguments in Tkinter's button command: [code=python]import Tkinter as tk def getCond(par): firstCond = par #conditions.remove(firstCond) print firstCond #print conditions root = tk.Tk() firstCond = '' condNames = ['1', '2', '3', '4', '5', '6'] for item in condNames: # use lambda …

Member Avatar for Lardmeister
0
4K
Member Avatar for rwe0

I though it was odd, but that 'bug' has been in there ever since Python26.

Member Avatar for vegaseat
1
398
Member Avatar for vegaseat
Member Avatar for tony75

You need to change your first data file format to something like this, where for instance the ';' character is the separator: A233;Apple;FOOD;5.00 A345;Blanck CD 10;DATA;2.50 B453;Pasta;FOOD;12.00 T545;USB-Memory 16GB;DATA;25

Member Avatar for tony75
0
345
Member Avatar for usongo123

This might give you some hints: ''' file gemstone.csv looks like this: valid gemstone owing mark channels code No Diamond 26.06 20 218 (KJQ:10E)2 Yes Diamond 15.43 25 36 (DRX:25H)7 No Sapphire 11.44 51 141 (XKL:31L)4 No Zircon 79.68 23 60 (BYA:26Ix8 No Moonstone 79.41 11 67 (BWC:79L)4 Yes Garnet …

Member Avatar for vegaseat
0
184
Member Avatar for dude1

One way to do this: def make_userid(user): first, last = user.split() user_id = first[0] + last return user_id user = "John Doe" user_id = make_userid(user) print(user_id) # JDoe

Member Avatar for Lucaci Andrew
0
297
Member Avatar for welshly_2010

You can use something like this: myvar.set("Current Folder Selected is: {}".format(dirname))

Member Avatar for vegaseat
0
169
Member Avatar for vegaseat

The factorial function is part of the math module in later versions of Python: ''' math_factorial.py tested with Python 2.7.3 ''' from math import factorial for k in range(1, 101): print("factorial of {} = {}".format(k, factorial(k))) print(type(factorial(10))) # <type 'int'> print(type(factorial(100))) # <type 'long'> print(len(str(factorial(100)))) # 158 print(len(str(factorial(69)))) # 99

Member Avatar for sneekula
2
5K
Member Avatar for hitman007
Member Avatar for gangster88

[QUOTE=Ene Uran;1060514]Sorry, I am using Python 3.1.1 and graphics.py does not work with Python3.[/QUOTE]This little module has been updated to work with Python2 and Python3 recently, look at the new beta version at: [url]http://mcsp.wartburg.edu/zelle/python/[/url]

Member Avatar for TrustyTony
0
2K
Member Avatar for The Dude

Dear Grandson Snee: I have become a little older since I saw you last, and a few changes have come into my life since then. Frankly, I have become a frivolous old gal. I am seeing five gentlemen everyday. As soon as I wake up, Will Power helps me get …

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

Another option is to make a DailyExpenses.pth text file that contains the directory name where you can find the DailyExpenses.py file. You can save the path file in Python's "site-packages" directory.

Member Avatar for sneekula
0
580
Member Avatar for Lardmeister

Are we talking about the earth? I have always looked at "world" as something larger than "earth".

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

Portable Python (aka. Flashcard Python or Python on a stick) comes with PyScripter and that IDE is a pleasure to code with. Python is a great language to solve scientific problems.

Member Avatar for sneekula
0
211
Member Avatar for giancan
Member Avatar for sneekula
0
1K

The End.