904 Posted Topics

Member Avatar for girish_sahani

You need to give more details of what you want to accomplish. At first look, there are quite a few errors in your code. Your indentations are a mess (they are not cosmetic, they actually form statement blocks in Python!), if needs == as comparison operator, for needs colon at …

Member Avatar for girish_sahani
0
212
Member Avatar for girish_sahani

Indentations are the bread and butter of Python. Yours are all messed up! Did you mix tabs and spaces in your code? Avoid the mix! This is corrected code: [code]def get_colocations(filename): sentences = open(filename).read().split("\n") colocations = [] for sent in sentences: colocations.append(sent) return colocations def main(): colocations = get_colocations("colocations.txt") # …

Member Avatar for girish_sahani
0
127
Member Avatar for gbs

The module subprocess is new in Python24 and is much more reliable than os.system(). You may have to give the full path of file "ps2pdf" and file "file.ps" (eg. "/tmp/test/file.ps"). [code]import subprocess subprocess.call(["ps2pdf", "file.ps", "file.pdf"]) [/code] Note that subprocess.call() takes a list.

Member Avatar for G-Do
0
2K
Member Avatar for madloch

All statement lines that belong to while loop get an indentation of 4 spaces (4 is traditional with Python code). I have removed main() as that is throwback to C. Also wrap your code in code tags,see: [url]http://www.daniweb.com/techtalkforums/announcement114-3.html[/url] [code]print "This program calculates how long it takes for an investment to …

Member Avatar for madloch
0
3K
Member Avatar for NumNut

I don't have linux OS on my machine, but fail to understand why wxPython should bring up a gtk error? Also, is gdk and gtk a mix up? Please use code tags around your Python code to show proper indentations, take a look here: [url]http://www.daniweb.com/techtalkforums/announcement114-3.html[/url]

Member Avatar for NumNut
0
222
Member Avatar for Ene Uran

Hi Ene, looks like you are working on Friday the 13th project. It took me a while, but I solved it. I can give you a hint, replace the line [code] print next_day [/code] with this expanded line [code] print next_day, "day of week =", next_day.weekday() [/code] The week starts …

Member Avatar for bumsfeld
0
5K
Member Avatar for boofus
Member Avatar for Ene Uran

[QUOTE=Ene Uran]... Also, why are you using self.button1 = Button( ... ) and not just button1 = Button( ... )?[/QUOTE] The self. prefix makes the button global within the class, so it can be used by methods of the class.

Member Avatar for Ene Uran
0
381
Member Avatar for Confucius

[QUOTE=Confucius]Im sort of new to python, and I have been looking at some tutorials, manuals, etc. and I saw how to find prime numbers, so I thought it would be a good place to start, so I added some stuff to hopefully allow for user input, and it doesnt work. …

Member Avatar for Ene Uran
0
310
Member Avatar for pythonguy

I can not quite figure out what you want to do. I wrote these little test files. Test1.py contains a variable I want to use in Testing1.py. Test1.py: [code]# test module, save as test1.py test_path = "test1234" [/code] Testing1.py: [code]# testing module test1.py import test1 print test1.test_path [/code] I am …

Member Avatar for pythonguy
0
139
Member Avatar for q8z

Learn several languages. You may want to learn one language that runs on more than just Microsoft platform.

Member Avatar for Killer_Typo
0
261
Member Avatar for swapnamishra

Looks more like message from lint-filter, telling you to use self. Some of the commercial IDEs have filters built in.

Member Avatar for bumsfeld
0
151
Member Avatar for Blujacker

Try this short Tkinter code, only tested it on Windows XP: [code]from Tkinter import * root = Tk() sw = root.winfo_screenwidth() sh = root.winfo_screenheight() # test print "screen width =", sw print "screen height =", sh # set to full screen use this: root.geometry("%dx%d+0+0" % (sw, sh)) # more code …

Member Avatar for bumsfeld
0
114
Member Avatar for butterflyTee

Use the while loop for indeterminate number of entries, for loop for fixed number. If you need to use main(), define main to call your calc_sum function. Let the user know how to stop the loop. [CODE]# while loop is used to sum an indeterminate number of integers entered, until …

Member Avatar for bumsfeld
0
130
Member Avatar for butterflyTee

Very nice effort, just a a few corrections needed to make this work. [code]# class.py # tpm # A program to calculate the volume and surface area of a sphere from its # radius given as input. from math import * # for pi class Sphere: def __init__(self, radius): # …

Member Avatar for butterflyTee
0
132
Member Avatar for gYbU

Found code in one of the books in the CS library: [code]# view and delete e-mail using the POP3 protocol import sys, getpass, poplib, re # change according to your needs POPHOST = "pop.domain.com" POPUSER = "joedoe" POPPASS = "" # the number of message body lines to retrieve MAXLINES …

Member Avatar for vegaseat
0
598
Member Avatar for Blujacker
Member Avatar for butterflyTee

Once more, please put your code into code tags to show the right indentation, see: [url]http://www.daniweb.com/techtalkforums/announcement114-3.html[/url] Most people will not read any of your code unless you do that! Your first program worked just fine, why did you change it? This program will give you error, because you are giving …

Member Avatar for bumsfeld
0
92
Member Avatar for Ene Uran

Python lambda can substitute, just harder to read: [code]tuple1 = ('\t', '\n') for k in range(100): a = (k % 10 == 9) b = 1 c = 0 # similar to C conditional expression a ? b : c # if a is true return b else c f …

Member Avatar for Ene Uran
0
118
Member Avatar for johnhl007

There is no module called graphics in normal Python distribution! Without this custom module will be hard to help! I suggest you print p1 and see what it looks like! If it is tuple like (30, 45), then most likely p1x = p1[0].

Member Avatar for Scagli3tti
0
470
Member Avatar for butterflyTee

Since your discount is calculated from the total purchase, you do not need to ask for it. Discount calculations are done using conditional if statements. Do not use % as a variable name! All calculations are simple, no need for "from math import *"

Member Avatar for butterflyTee
0
111
Member Avatar for Spasticmoose

I and some of my friends left project ideas on [url]http://www.daniweb.com/techtalkforums/thread32007.html[/url] They can appply to any computer language!

Member Avatar for Spasticmoose
0
173
Member Avatar for bumsfeld

I need to know how many times my function has been accessed in my program. Any suggestions other than global variable?

Member Avatar for vegaseat
0
3K
Member Avatar for G-Do

G-Do, you and vegaseat seem to share fascination with midi music files. I have explored vegaseat's code snippet [url]http://www.daniweb.com/code/snippet431.html[/url] and it work well at least on Windows XP. Midi is great stuff! I am thinking that pythonmidi is the same package as PMIDI, at least the files/directories are the same.

Member Avatar for G-Do
0
287
Member Avatar for butterflyTee

Please wrap you code in code tags, see: [url]http://www.daniweb.com/techtalkforums/announcement114-3.html[/url] This way the proper indentations are added. I would not pass function on as argument, so rewrite you code: [code]from math import * # to get pi def main(): # first get the area of the whole pizza area = area_of_pizza() …

Member Avatar for Ene Uran
0
139
Member Avatar for vieome

I am here to use the Linux OS on my computer. Was Linux really called Freax originally?

Member Avatar for DMR
0
503
Member Avatar for bumsfeld

This small program is neat: [CODE]import calendar calendar.prmonth(2006, 3) """ March 2006 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 …

Member Avatar for vegaseat
0
919
Member Avatar for Cole

I would learn C++ to get used to an oops language. Java is simple lame version of C++ anyway!

Member Avatar for jwenting
0
195
Member Avatar for wizmonster

I knew I was in trouble when doctor dentist took many pictures during surgery, so it would make it harder to sue him afterwards! I smile anyway, at least on Halloween!

Member Avatar for bumsfeld
0
80
Member Avatar for coopedw

If you exclude number 2, and start you for loop with 3, you need to check only odd numbers, increment you for loop by 2.

Member Avatar for bumsfeld
0
220
Member Avatar for hak
Member Avatar for bumsfeld
0
203
Member Avatar for butterflyTee

Here is simplified approach, the number of new-line characters '\n' give number of lines, the number of spaces are approximately the number of words, and the number of characters is the length of the text string read from file. You simply use a for loop and and iterate each character …

Member Avatar for butterflyTee
0
492
Member Avatar for ultra vires

There is something like in a C code snippet here: [url]http://www.daniweb.com/code/snippet377.html[/url]

Member Avatar for bumsfeld
0
153
Member Avatar for katharnakh

You mean something like that: [code]import tkFileDialog # examples: def open_it(): filename = tkFileDialog.askopenfilename() print filename # test def save_it(): filename = tkFileDialog.askopenfilename() print filename # test def save_as(): filename = tkFileDialog.asksaveasfilename() print filename # test [/code]

Member Avatar for bumsfeld
0
1K
Member Avatar for bumsfeld

I am making progress learning Python. and English. I understands tuples, lists and dictionaries, but sets don't make muchly sense. Why use a set? What is a set good for?

Member Avatar for bumsfeld
0
246
Member Avatar for abell1234

You can write much more clean code if you start with Python over again. VB code is usually just to "helter skelter"! Look at your application and rewrite it in Python.

Member Avatar for bumsfeld
0
242
Member Avatar for katharnakh
Member Avatar for bumsfeld
0
107
Member Avatar for katharnakh

I hope you are talking about Tkinter as GUI. This code might help you. You have to use a if statements to get the right key value to go to the proper function then. [code]# bind and show a key event with Tkinter from Tkinter import * root = Tk() …

Member Avatar for bumsfeld
0
307
Member Avatar for juergenkemeter

Working with SQL I found this site. It may help! [url]http://www.mayukhbose.com/python/ado/index.php[/url]

Member Avatar for bumsfeld
0
187
Member Avatar for bobthetree
Member Avatar for k_en

Something like this works fine: [code]try: case = int(raw_input("enter a number less then 3 or more than 4: ")) except: case = 0 while case <=2 or case >=5: # do something to get out of loop case += 1 print case if case > 10: break [/code] Notice that …

Member Avatar for bumsfeld
0
143
Member Avatar for bumsfeld

I am trying things with wxStaticText (a label). I can chnage background colour, but not the text colour: [code]import wx class MyPanel(wx.Panel): def __init__(self, parent, id): wx.Panel.__init__(self, parent, id) str1 = "Camembert cheese is the best!" self.label1 = wx.StaticText(self, -1, str1 , wx.Point(15, 30)) self.label2 = wx.StaticText(self, -1, str1 , …

Member Avatar for vegaseat
0
901
Member Avatar for leb

A friend of me says that you can play mp3, mid and ogg files with Pygame but you need extra install modules for SDLs.

Member Avatar for bumsfeld
0
190
Member Avatar for bumsfeld

The Internet has many animated GIF files, they are funny to watch. Does Python have a way to play those? I am asking to much?

Member Avatar for vegaseat
0
171
Member Avatar for bumsfeld

A somewhat strange find in the Pyton Code Snippets here on this site. Is the BOO language very much like Python? It seems nice that one can compile and interpret the same language. Will it be worth to translate Python code to BOO just to get a nice small exe …

Member Avatar for Dani
0
301
Member Avatar for bumsfeld

I did find the Python code snippet on PMIDI module here. It works fine and I have made some interesting sounds with it. Is there way to save this as sound file?

Member Avatar for vegaseat
1
244
Member Avatar for snaidis

[QUOTE=jim mcnamara]factorials get BIG really fast and exceed the limits of 32-bit unsigned integer variables by 13!. If you want to play with them use a datatype that can handle huge numbers, or switch to an extended precision mathematics library like GMP.[/QUOTE] Or use Ruby or Python that do not …

Member Avatar for Narue
0
377
Member Avatar for ! !

A good idea for a developing country which has lots of powerlines already but not much highspeed cables. Places like India, China, Russia, South Africa and such. Imagine all these poor people exposed to spyware and idiot popups!

Member Avatar for kAtHicKa
0
516
Member Avatar for bumsfeld

Is there a function in wxPython or anything that can creat a variable frequency sounds?

Member Avatar for vegaseat
0
650
Member Avatar for c_shaft05

The End.