4,305 Posted Topics
Re: Rewrite the program as soon as you can, before all your memory of the actual code has fainted too much. Also, there are places that specialize in the recovery of your hard drive. | |
Re: You are almost there, but you have to fix your precision and perhaps make the console wait so you can see the result. Thoroughly check the code and learn ... [php] // program to calculate area of circle (tested with Dev-C++) #include <iostream> #include <iomanip> // setprecision(), setiosflags() const float … | |
Re: Here is an example of the simplest way to show an image with wxPython ... [code]# really simple way to show an image from a file with wxPython # pick an image file you have in the working folder # or give the image file a full path name # … | |
Re: The only blemish I can see with wxPython is that it will not work with Python3 at the moment. PyQT works with Python3, but may have licensing problems down the road. Tkinter is pretty much cross platform and comes with Python2 and Python3. Its widgets are rather basic and look … | |
Re: Yes, that is the way it's done in most languages. You should get away with this ... [code]if self.combobox.GetValue() and self.FilePathTextBox.GetValue(): [/code] Test it with something simple like this ... [code]a = "m" b = "n" if a and b: print('okay') else: print('error') print('-'*20) a = "" b = "n" … | |
Re: Python3 offers the [B]named tuple[/B], it sounds like something you may be interested in. Here is an example ... [code]# named tuple instances require no more memory than regular tuples # tested with Python 3.1.1 import collections as co EmpRec = co.namedtuple('EmpRec', 'name, department, salary') bob = EmpRec('Bob Zimmer', 'finance', … | |
Re: BTW, the letter 'l' is a rather poor choice for a variable name, since it looks much like the number '1' on many editors. I have gotten in the habit to use 'mylist' or 'qq' for casual lists. | |
Re: Maybe Baidu's corruption of Chinese officials has finally succeeded in forcing Google out of that country. | |
Re: RE djidjadji I test drove your final code and it works like a charm! Thanks for the very nice contribution! Would be great for a code snippet. | |
Re: According to some recent pop-up ads, Bill Gates lives in terror worrying about online software created by this advertiser. :) | |
Re: You can take Paul's code and simplify it a bit more with list comprehension ... [code]# a test class we can instantiate class Instance: def __init__(self, number): self.number = number instances = [Instance(n) for n in range(6)] for f in instances: print(f.number) [/code] | |
Re: Here is an example how to find all the files with extension .ini in a given folder and add them to a list ... [code]# find all the .ini files in a folder import os print "add all the .ini in a folder to a list:" folder = 'C:/Windows/' file_list … | |
Re: Yes, it would be a major project and much of the code would have to be written in C to get down to the low level sound access. | |
Re: Process numeric data from a file ... [code]# numeric data string, for instance from a text file s = """\ 44 36 11 66 24 92 3 8""" mylist = [] for line in s.split('\n'): sublist = [float(item) for item in line.split()] mylist.append(sublist) print(mylist) print('-'*50) # now you can process … | |
Re: "Dive Into Python" Mark Pilgrim's Free online book, novice to pro, is updated constantly, and has been rewritten for Python3 (check appendix A for Py2-to-Py3 differences), see: [url]http://diveintopython3.org/[/url] OOP has changed a bit with the introduction of Python3. | |
Re: Open Office Writer text saved as an .odt file contains a fair amount of formatting directives, Save your file as a plain Text (.txt) file, so you can read it with Python. | |
Re: To flatten (unnest) a more complex nested list you need to go to a recursive function ... [code]def flatten(q): """ a recursive function that flattens a nested list q """ flat_q = [] for x in q: # may have nested tuples or lists if type(x) in (list, tuple): flat_q.extend(flatten(x)) … | |
Re: Q: "How Old Is the Universe?" A: "At least as old as I am." | |
Re: Gruess Gott mawe! Your solution is very simple and very sweet! The elegance of Python keeps amazing an old programmer like me. Here I was thinking Tkinter and rectangles. Well, I am almost done with that much more fancy/complicated solution. I guess I will just stick it into the code … | |
Re: You can always start a simple data base using a class for the structure. However a real database engine also needs to handle/control multiple client access and have some kind of query language.. | |
Re: Something like this may do ... [code]class A: def __init__(self, num=1): self.strA = '<>' * num class B: def __init__(self): # create an instance of class A within class B a = A() print(a.strA) # <> a = A(3) print(a.strA) # <><><> a = A(5) print(a.strA) # <><><><><> b = … | |
Re: The result of the list comprehension you showed will be a list, not a dictionary. | |
Convert a decimal (denary) integer to a binary string. An exercise in do ... while and while loops. | |
Re: Note: this should be a regular post, not a code snippet post! Code Snippets are for finished code. | |
Re: What does your file helloworld.py look like? Also the shebang line [B]#!/usr/bin/python[/B] only works with the Linux/Unix OS. Don't run your Python programs from the shell, use an IDE editor, see: [url]http://www.daniweb.com/forums/post104834.html#post104834[/url] The shell is for short tests of mostly one line code. | |
Re: With such a large number of class instances you may have to use disk space and check into modules pickle and shelve. | |
Re: If communities is a list, you may want to use something like [B]for community in communities:[/B] as a loop. If itself or [B]community = communities [:][/B] does not form a loop. | |
Re: When the can of frozen Orange juice says "Concentrate" and you do. | |
Re: I don't have a lawn out here in the desert, but one of those robotic vacuum cleaners would do it for me. | |
Re: Almost there, you could do it like this ... [code]def avoid(forbidden_letters, word): for letter in forbidden_letters: print letter # for test only if letter in word: return True # test data forbidden_letters = "mvy" words = "house mouse validate kitchen honey love" # pull out the individual word from words … | |
Re: This will give you the version of your installed pygame ... [code]import pygame print pygame.ver # for instance --> 1.8.0release [/code]This version has no [B]font.py[/B] file, but a [B]font.pyd[/B] file which is compiled C code to a DLL for Python use. The pygame file you want to take a look … | |
Re: [QUOTE=cwarn23;994270]From the list I would say Java as it is so easy to use with the Netbeans compiler. But my favourite which isn't on the list is php/php-gtk.[/QUOTE]I think the pole is limited to 10 items, so it's always good to have [B]other[/B]. Solving science and engineering problems, to me … | |
Re: You need to start with an empty list and append to it ... [code]import time import random data_list = [] n = 10 while n >= 0: data_list.append(random.randint(0, 99)) print data_list time.sleep(0.1) n = n - 1 [/code] | |
Re: This module is not part of the standard Python distribution. You need to download and install it separately from: [url]http://python-sybase.sourceforge.net/download.html[/url] | |
Re: For those of you who use Python3: BeautifulSoup works fine with Python3 if you copy BeautifulSoup.py (version3.0.7a or lower) and sgmllib.py (find it typically in C:\Python25\Lib) to a separate directory and convert both programs with 2to3.py | |
Re: For one way to accomplish this that includes an example see: [url]http://www.daniweb.com/forums/post1096761.html#post1096761[/url] | |
Re: [QUOTE=Godflesh;1098214]Hello i have a big problem, i want to import queue but i get this message, somehow it dont exist. Traceback (most recent call last): File "D:\Python26\test.py", line 9, in <module> import queue ImportError: No module named queue isnt that strange.[/QUOTE]Module [B]Queue[/B] has been renamed [B]queue[/B] starting with Python3 to … | |
Re: You could put into the Geeks Lounge, but then not everybody is a geek. [B]A prosperous and successful New Year you all![/B] | |
Re: Works just fine with Python 2.5.4 and Pygame 1.8.0 on a Windows XP machine. Font "arial" may only be available with the Windows OS. | |
Re: Microsoft has invested a lot of effort into speech handling for their operating system. That's why Windows will blow Linux out of the water when it comes to media functionality. | |
Re: You need to check your calculations. You are charging the poor customer 30 Pounds per km for traveling a distance above 10 km. You really want to charge him 1 Pound (0.7+0.3) per km. Also, you need to add a 10 mile short price to the distance-10 long distance price | |
Re: You need to study up on functions a little, for instance see: [url]http://www.daniweb.com/forums/post104853.html#post104853[/url] Again, you can use a formatted string to show the result ... [code]def length(word): print( "%s %d" % (word, len(word)) ) # test the function # here you use the string "python" as argument/parameter word length("python") # … | |
Re: You got a good start and can can do it with a formatted string ... [code]def displayDate(day, month, year): months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Dec'] print( "%s %s %s" % (day, months[month-1], year) ) # test it ... displayDate(10, 2, 2010) # 10 … | |
Re: What exactly is the name of your win32all installation file? What is your Operating System? | |
Re: Take a look at: [url]http://www.daniweb.com/forums/post1077620.html#post1077620[/url] | |
Re: Here is a little experiment you can do ... [code]# assume this would be the content of your data file data = """\ 1 2 3 4 5 6 """ fname = "mynumbers.dat" # write your test data file fout = open(fname, "w") fout.write(data) fout.close() # now read the test … | |
Re: If you use code tags, I will take a look at your code. Please use the [b][noparse][code][/noparse][/b] and [b][noparse][/code][/noparse][/b] tag pair to enclose your code. This way the proper indentations will show, making your code readable. |
The End.