4,305 Posted Topics

Member Avatar for patrick91

I am a little confused here. What are your resizing, the frame, the panel, the image? I changed your code so I could see the meat and used it with a larger image ... [code=python]import wx class MyFrame(wx.Frame): def __init__(self, parent=None, id=-1, title=None): wx.Frame.__init__(self, parent, id) self.panel_1 = wx.Panel(self, -1) …

Member Avatar for patrick91
0
224
Member Avatar for roulette843

One of the more simple ways to do this is to use Python module HTMLParser ... [code=python]# extract text from HTML code of a web site import urllib2 import HTMLParser import cStringIO class HTML2Text(HTMLParser.HTMLParser): """ extract text from HTML code """ def __init__(self): HTMLParser.HTMLParser.__init__(self) self.output = cStringIO.StringIO() def get_text(self): """get …

Member Avatar for vegaseat
0
3K
Member Avatar for Mackjan

The function extend() adds the contents of another list to your list ... [code=python]listA = [1, 2, 3] listB = [4, 5, 6] # make a simple non-alias copy listC = listA[:] listA.append(listB) print listA # [1, 2, 3, [4, 5, 6]] listC.extend(listB) print listC # [1, 2, 3, 4, …

Member Avatar for vegaseat
0
110
Member Avatar for FreezeBlink

When you send a mutable object like a list to a function as an argument, a pointer to the object is established (allows the objects to be mutable). Inside the function you have created a simple alias copy of the list, that still has the same pointer reference. With a …

Member Avatar for vegaseat
0
142
Member Avatar for Micko

My suggestion would be to use the newer string functions and to add some comments ... [code]file = open("Test.txt", "r") text = file.read() file.close() word_list = text.lower().split(None) word_freq = {} for word in word_list: word_freq[word] = word_freq.get(word, 0) + 1 keys = sorted(word_freq.keys()) for word in keys: print "%-10s %d" …

Member Avatar for vegaseat
0
5K
Member Avatar for Azurea

If your module is in folder c:\Python25\myFolder then you can tell Python to look there by appending PYTHONPATH ... [code=python]# appends to PYTHONPATH the location of your custom module folder # use this in the beginning of your program import sys sys.path.append(r"c:\Python25\myFolder") [/code]To see the folders where Python normally looks …

Member Avatar for Azurea
0
89
Member Avatar for eemqjunk
Member Avatar for Stefano Mtangoo

This might just help you ... [code=python]import wx class MyFrame(wx.Frame): def __init__(self,parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(300, 200)) toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER) # image file is in the same folder as the source code # otherwise give a full path name toolbar.AddSimpleTool(1, wx.Image('quit.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'quit', …

Member Avatar for Stefano Mtangoo
0
245
Member Avatar for blade321

My suggestion, use code tags around your code and stop using livewires, it's an old module and really not Python ... [code=python]x = input("Enter an integer number: ") y = 1234 n = 0 while x <> y: print "need", y, "you entered", x # limit a possible endless loop …

Member Avatar for jrcagle
0
109
Member Avatar for billabong2388

[QUOTE=MitkOK;589570]I've just started learning Python :icon_cool:[/QUOTE]Welcome to the DaniWeb Python community, looks like you are doing great.

Member Avatar for vegaseat
0
154
Member Avatar for donnerCobra
Member Avatar for Kythas

Remember, function calls are expensive in Python (and some other laguages), so keep them to a minimum within the loop.

Member Avatar for jice
0
134
Member Avatar for Acidburn

If searchSpace[0] is an instance of class TData, then what would searchSpace[0].ac be?

Member Avatar for Acidburn
0
256
Member Avatar for Islandstone

I have used py2exe with PIL programs successfully with Windows XP. However the same thing on Windows Vista scews up royally.

Member Avatar for Islandstone
0
326
Member Avatar for gehher

Anything the cocktail girl brings me, be it a ... Manhattan, martini, Gibson, gimlet, old-fashioned, champagne, sidecar, horse's neck, Margarita, Bronx, pink lady, whisky sour, black Russian, white Russian, orange blossom, piña colada, mai tai, mimosa, Rob Roy, Sazerac, blue blazer, old Hickory, Vieux Carré, green opal, jitters, Daiquiri, Bloody …

Member Avatar for lio04
0
305
Member Avatar for b04e3ian

b04e3ian, please use 4 spaces per indentation and try not to exceed 72 characters per code line, it will make your code much more readable for all of us. Good luck with your game and welcome to DaniWeb.

Member Avatar for vegaseat
0
397
Member Avatar for vegaseat

I am keeping these to 100 pixel height thumbs so the JPEGs range between 5 and 15k (trying to safe Dani some disk space). You give me an educated guess what plane it is. I will (or you should) acknowledge the first correct guess.

Member Avatar for jwenting
1
1K
Member Avatar for sanoski
Member Avatar for gelcode

I simply get 1 I would also avoid using object as a variable name since it is a built in term for the basic Python object.

Member Avatar for vegaseat
0
90
Member Avatar for fongoos

If I would have to write an office suite to compete with Microsoft's Office, I would use Java, as has been successfully done with "Open Office". For projects that are less gigantic, and I need to develop quickly, I would use Python.

Member Avatar for linux
0
821
Member Avatar for IU34

In line 11 of your code you still go back to the originating function, that's called recursion. You should not do that!

Member Avatar for IU34
0
162
Member Avatar for bachmabt

It's got to be the way your data file has been written. Try this ... [code=python]str1 = """\ 88 10112213 33332332 22011220 23110122 21231102 12222321 32131132 10023232 """ # save your data file fout = open('slink.txt', 'w') fout.write(str1) fout.close() f = open('slink.txt', 'r') rows = int(f.read(1)) cols = int(f.read(1)) f.read(1) …

Member Avatar for bachmabt
0
146
Member Avatar for aot
Member Avatar for ZZucker
0
148
Member Avatar for rt7878
Member Avatar for Laurence26

Your problem is that book.items() gives you a key, value pair where value is most likely a tuple (year, roles). You have to edit your function like this ... [code=python]def saveBook(book): store = open(filename, 'w') for name, val in book.items(): year, roles = val store.write(name + '\n') store.write(year + '\n') …

Member Avatar for Laurence26
0
181
Member Avatar for jgritty

Looks like your problem is in line 7, you are using a list as default argument. The addresses of a function's default arguments get set at compile time. When a mutable object like a list is used as a default argument it will have this fixed address, adding more elements …

Member Avatar for jgritty
0
303
Member Avatar for bbmatten

So lightning strikes and you count off let's say ten seconds before you hear the thunder. Sound travels at 1100 ft/second, so the distance will by 10 times 1100ft.

Member Avatar for vegaseat
0
76
Member Avatar for watermark
Member Avatar for The Dude

I saw one of his last concerts in May 1977 at the University of Michigan. He was old and puffy looking from all the steroids, but his singing had not suffered. He was only able to do half a show. Despite all of this the show was dynamite. His final …

Member Avatar for jwenting
0
67
Member Avatar for fredomondi

I am discussing that in one of my Python code snippets, take a look at: [url]http://www.daniweb.com/code/snippet326.html[/url] There is one caveat, Peter has not updated his module for a while, and you need the MS speech engine.

Member Avatar for vegaseat
0
127
Member Avatar for haukee

Give VPython a try, a free 3D modeling/simulating package ...[code=python]# a rotating cube using vpython from http://vpython.org # also known as visual python import visual as vs # set up the frame vs.scene.width = 500 vs.scene.height = 500 vs.scene.center = (0,0.5,0) vs.scene.title = "rotating cube" cube = vs.box(pos=(0,0.5,0), axis=(1,1,1), length=1.2, …

Member Avatar for vegaseat
0
136
Member Avatar for nish88

You can find all the information on this popular simulation system at: [url]http://www.alcyone.com/software/cage/[/url]

Member Avatar for vegaseat
0
113
Member Avatar for strictlycustom

Look at the code in: [url]http://www.daniweb.com/forums/post570512-4.html[/url] ... and you will figure it out.

Member Avatar for strictlycustom
0
3K
Member Avatar for kharan

I would recomment to always use the namespace of a module. It makes your code much easier to understand. Here is the module ... [code=python]# a simple module save as test.py def printA(): try: print a except NameError: print 'variable undefined' # test the module as such if __name__ == …

Member Avatar for vegaseat
0
105
Member Avatar for a1eio

If you use frame as a parent you can do it easily ... [code=python]# using frame as the parent you can access its arguments # (does not work with root itself) import Tkinter as tk root = tk.Tk() frame = tk.Frame(width=500) # test frame 'dictionary' print frame['width'] # 500 root.mainloop() …

Member Avatar for a1eio
0
182
Member Avatar for majestic0110

[QUOTE=sneekula;566789]Spending time with my family and my GF Cooking Walking[/QUOTE]I always thought you were some kind of car buff. What happened?

Member Avatar for jbennet
0
164
Member Avatar for The Dude
Member Avatar for vegaseat
0
44
Member Avatar for The Dude

Here I done it! I wasted a perfectly good hour playing air hockey and enjoyed every minute of it!

Member Avatar for The Dude
1
68
Member Avatar for mcenley

When you swap the key:value pairs you can get value to key collisions since keys have to be unique. The standard way is to but collisions into a list ... [code=python]# invert a dictionary and take care of value to key collisions def invert_dict(d): inv = {} for k, v …

Member Avatar for mcenley
0
185
Member Avatar for mcenley

Rewrite your code this way ... [code=python]def histogram(s): d={} for c in s: d[c] = d.get(c, 0) + 1 return d h=histogram('brontosaurus') print h """ my result --> {'a': 1, 'b': 1, 'o': 2, 'n': 1, 's': 2, 'r': 2, 'u': 2, 't': 1} """ [/code]To better understand what is …

Member Avatar for mcenley
0
158
Member Avatar for gwarguy

There is a Python snippet telling you how to work with py2exe right here on DaniWeb: [url]http://www.daniweb.com/code/snippet499.html[/url]

Member Avatar for sinkingships7
0
94
Member Avatar for EnderX

Since EnderX holds the view of a small but vocal minority, maybe he/she should explain his/her reasoning.

Member Avatar for Ravenous Wolf
1
373
Member Avatar for random7

If your data file is created from a list of lists, then you you need to save(dump) and load it as a complete object using Python module pickle. If your data file is just a text file of lines that look like lists, then you have to do some processing …

Member Avatar for vegaseat
0
2K
Member Avatar for rmurphy1061

First of all, let me welcome you to the DaniWeb Python forum! In your code you are almost there, but you can only concatenate strings ... [code=python]import datetime as dt # US format month/day/year #dateStr1 = '7/14/2006' #dateStr2 = '5/1/2007' mm1 = '01' # need to be strings dd1 = …

Member Avatar for vegaseat
0
131
Member Avatar for Google Spider

I understand that the Martian pilot they recovered from the last crashed UFO is on display in Area 51, and actually is a female.

Member Avatar for sneekula
0
218
Member Avatar for strictlycustom

You are on the right track. Read your tutorial, do the code samples, and try to solve the problems. Python, being an interpreter, makes it easy to quickly test the code you write. As you get a little more experienced change the code and see how it behaves.

Member Avatar for vegaseat
0
95
Member Avatar for Mahen

[QUOTE=Mahen]I completely agree with U, I even have two free compilers on my computer, LccWin32 & DevCpp but the problems is that they contain too much bugs, and working on them does not tell us where the bug is comming from, the compiler or the code. :cool:[/QUOTE] Dev-C++ works just …

Member Avatar for Mahen
0
431
Member Avatar for a1eio

Try it this way ... [code=python]# recommended Python style is to start # class names with an upper case letter # function names with a lower case letter class TestClass(object): def show(self, data=None): print data def funk(data): instance.show(data) def main(): #instance = TestClass() funk("hello") # create an instance of the …

Member Avatar for BearofNH
0
124
Member Avatar for sigkill9

Move your while loop for more data into function main(). Once you return from validated_input() it will pop out of the loop there.

Member Avatar for sigkill9
0
205
Member Avatar for Zelores

One approach would be to group the lines in the contacts string into a list of [first, last, number] lists ... [code=python]# assume your contacts string looks like this after file read contacts = """\ Adam Adler 12345 Bart Johnson 23456 Carl Lark 34567 Don Herbst 45678 """ # remove …

Member Avatar for vegaseat
0
105

The End.