4,305 Posted Topics

Member Avatar for python_bite

The way your class is written the list 'fld' is global to all instances of the class. You need to write your class this way ... [code=python]class A: id = "" #fld = [] def __init__(self, id): self.fld = [] self.id = id [/code]

Member Avatar for vegaseat
0
125
Member Avatar for moe3ius

Office Suite: Open Office (does everything MS Office does) Image Viewers: XnView or IrfanView (small and nimble) Programming Editor: ConText (robust, handles a number of languages)

Member Avatar for sreein1986
0
191
Member Avatar for lllllIllIlllI

The wx.StaticBitmap() is pretty well static. To be able to clear the old image you best use a canvas to display your image ... [code=python]# show a JPEG image using a wx.PaintDC() canvas # allows you to clear any previous image on the canvas import wx class ImagePanel(wx.Panel): """ create …

Member Avatar for lllllIllIlllI
0
570
Member Avatar for swills
Member Avatar for s7plc

Different Operating Systems use different CR, Linux uses '\n' and Windows uses '\r\n' and the Mac uses '\r'. This might cause your problem. Take a hexeditor and look at your file. If you have a two byte CR you will have to replace accordingly.

Member Avatar for s7plc
0
254
Member Avatar for shadwickman

Try ... [code=python]names = [ "main", "secondary", "tertiary" ] for item in names: cmd = "__import __(%s)" % item eval( cmd ) [/code]

Member Avatar for shadwickman
0
223
Member Avatar for lllllIllIlllI

Try ... [code=python] frame.SetSize((x, y)) # another way, wx.Frame has a ShowFullScreen method # strips all border decorations and buttons # (False restores original frame) myFrame.ShowFullScreen(True, style=wx.FULLSCREEN_ALL) [/code]

Member Avatar for lllllIllIlllI
0
68
Member Avatar for cheechand

One way ... [code=python]d = {'Jim': 19, 'Slim': 45, 'Peter': 23, 'Joe': 30, 'Mark': 27} q = ['Frank', 'Hank', 'Joe', 'Luke', 'Paul'] for key in d.keys(): if key in q: print key [/code]

Member Avatar for woooee
0
113
Member Avatar for inkcoder

Not quite sure what you want, but maybe this will help ... [code=python]word = raw_input("Enter a word: ") for c in word: c = c.upper() print c, "=", ord(c) - 64 """ my output for instance --> A = 1 B = 2 S = 19 O = 15 L …

Member Avatar for a1eio
0
140
Member Avatar for Py-er

You could use the pygame module ... [code=python]# display text in a given font # get the total text width import pygame as pg # initiate pygame pg.init() # color tuple(r,g,b) yellow = (255,255,0) # create a 480x80 window/frame screen = pg.display.set_mode((480, 80)) # create a surface (canvas) surface = …

Member Avatar for Py-er
0
121
Member Avatar for lllllIllIlllI

Depends a little on what applications you want to write. Tkinter may be all you ever need. Once things get more demanding you then can switch to wxPython, PyGTK or PyQT. Knowing Tkinter will make the learning curve of these other toolkits a little easier.

Member Avatar for lllllIllIlllI
0
549
Member Avatar for dangermini

Looks like Windows Vista screws you up. The above PyQt-Py2.5-gpl-4.4.2-1.exe installed perfectly fine on my Windows XP machine. I tested dangermini's pyqt code and it works without a hitch. Not quite sure why he has a problem?

Member Avatar for woooee
0
4K
Member Avatar for Hugh Pittman

I would stick with the stable production release: [url]http://www.python.org/ftp/python/2.5.2/python-2.5.2.amd64.msi[/url] Python30 is still alpha and won't be stable until the fall of this year. I know it's tempting to play with the new features.

Member Avatar for vegaseat
0
110
Member Avatar for pukebag

[QUOTE=Dunganb;623322]Here was my solution to the problem: [code]word = 'cake' cakeList = [] mixedList = ["cake", 12, "cakecar", "cAKe", "orange", "apple", "1cake", "cake1"] for x in mixedList: if word in str(x).lower(): cakeList.append(x) print cakeList[/code] With the output: [ICODE]['cake', 'cakecar', 'cAKe', '1cake', 'cake1'][/ICODE] Each element in mixedList is searched for the …

Member Avatar for vegaseat
0
148
Member Avatar for caribedude

Just installed PMIDI-1.1.win32-py2.5.exe on my XP machine running under Python25 and it works just fine with the sample code given.

Member Avatar for vegaseat
0
126
Member Avatar for Timotei

Here is an example using PIL ... [code=python]# generate a true opaque watermark with the Python Image Library (PIL) # free download from: http://www.pythonware.com/products/pil/ from PIL import Image, ImageEnhance def reduce_opacity(im, opacity): """returns an image with reduced opacity""" assert opacity >= 0 and opacity <= 1 if im.mode != 'RGBA': …

Member Avatar for Timotei
0
2K
Member Avatar for clouddragon

Here is one way to access key, value pairs sorted by key ... [code=python]stats = { "ECSE":45, "LCSI":37, "ECOM":20, "ABIT":6, "ACSM":12, "AEXH":2, "AEXP":9, "BULS":8, "APME":7, "BBMB":1, "EBCL":5, "EEEL":27, "LDES":4, "LMAT":31, "LPHY":22, "LPSC":41, "LUHU":15, "LUPS":11, "LUSS":10 } # create a list of (key, value) tuples kvt = [(k, v) for k, …

Member Avatar for vegaseat
0
168
Member Avatar for jimbox123

Hey slate, nice code. You sure pulled a number of Python features out of the box. I am always amazed how many ways there are to solve a problem. Just don't stop learning.

Member Avatar for vegaseat
0
1K
Member Avatar for dalaharp

Turbo C? I didn't know anybody still used this old horse! Anyway, I found something in my archives and removed the dust! This reads a character file, you want to read a binary file. The end of file marker will be different. Well partner, it's a start! [PHP]/******************************* fgetc.c ******************************** …

Member Avatar for jephthah
0
3K
Member Avatar for alivip

Unusual, but here is one way to do this ... [code=python]data = "Every man has a price. Every woman has a price?" # optional remove punctuation marks data = "".join(c for c in data if c not in '.,!?') my_list = data.split(None) pair_list = [] for ix, s in enumerate(my_list): …

Member Avatar for Freaky_Chris
0
244
Member Avatar for zls11610

[QUOTE=zls11610;607995]what function can converte a real to string[/QUOTE]str()

Member Avatar for zls11610
0
77
Member Avatar for Seagull One

Shouldn't it be ... [code=python]if LawRecite == True: speaker.Speak(LOR1) speaker.Speak(LOR2) speaker.Speak(LOR3) #speaker.Speak(random.choice(LOR4)) else: speaker.Speak('Yes please what?') [/code]

Member Avatar for Seagull One
0
143
Member Avatar for FreezeBlink

Simply put the nested loop into a function and use return to break out ... [code=python]def exit_nested_loop(): w = h = 100 # for testing for x in range(0, w): for y in range(0, h): print x, y stop = raw_input("Stop? y/n") if stop == "y": return exit_nested_loop() [/code]If you …

Member Avatar for vegaseat
0
173
Member Avatar for etc123
Member Avatar for callie_360
Member Avatar for Azurea

If your lists have other lists nested in them, then you need to use module copy and make a deepcopy.

Member Avatar for Azurea
0
92
Member Avatar for mattyd

[QUOTE=Nichito;526044]hey!! since when are you a mod? congrats!!![/QUOTE]Hey JB, I want to congratulate you too!

Member Avatar for ~s.o.s~
3
10K
Member Avatar for Altarium

The closest thing I know to solve your problem is the Boo language. It uses pretty much Python syntax but compiles with the Microsoft.NET C# compiler. Take a look at: [url]http://www.daniweb.com/code/snippet429.html[/url]

Member Avatar for Typhon
0
544
Member Avatar for FreezeBlink

In Python you can set up a dictionary to mimic switch/case ... [code=python]def choose(s): return { '1' : lambda:"You inputted one.", '2' : lambda:"You inputted two.", '3' : lambda:"You inputted three." }[s]() var1 = raw_input("Input a number between one and three.") print choose(var1) [/code]Even in C the switch/case statement is …

Member Avatar for kdoiron
0
1K
Member Avatar for harakiri1976

Look into Python module shelve. It works like a dictionary for your data and saves all updates automatically as long as it is open.

Member Avatar for woooee
0
118
Member Avatar for sch0009

Can you give us just a short subset of the .csv file? We are not allowed access to the page. This way we can help you.

Member Avatar for bvdet
0
264
Member Avatar for ayman86

Your function betsort(integer_array) should look like this ... [code=python]def betsort(x): n = len(x) for k in range(n, 1, -1): flag = 0 for i in range(0, k-1): if x[i] > x[i+1]: swap(x, i, i+1) flag = 1 if flag == 0: break [/code]

Member Avatar for ayman86
0
128
Member Avatar for Igor_MK

Python has a high speed module for this sort of thing, take a look at module difflib in the Python manual. Initially you would do a line by line compare and identify the lines that are different. If you need more help, ask the forum.

Member Avatar for woooee
0
168
Member Avatar for maui_mallard

Well JB, when you are the front runner you have to put up with the envy of others.

Member Avatar for jbennet
2
311
Member Avatar for DangerDev

Today Microsoft Chief Executive Steve Ballmer said Microsoft is growing impatient more than two months after the Redmond, Washington-based software behemoth made its unsolicited takeover offer for Yahoo. Yahoo Inc. has three weeks to accept Microsoft Corp.'s $31 per share cash-and-stock offer, or Microsoft will mount a proxy battle to …

Member Avatar for sneekula
0
582
Member Avatar for lllllIllIlllI

Very nice example of threading a1eio! Could you do all of us a favor and contribute that to the Python code snippets? It would be much appreciated! My appologies, but just a hint to stay in the Python code guidelines, in the snippet could you start your class with an …

Member Avatar for a1eio
0
8K
Member Avatar for FreezeBlink

Actually, the next version of Python (3.0) will use '/' for floating point divisions and '//' for integer divisions. Pascal for instance has '/' for floating point divisions and 'div' for integer divisions since inception 30+ years ago.

Member Avatar for vegaseat
0
103
Member Avatar for The Dude

Hehe! When I grow up I would love to look like Albert Einstein. Even the real eggheads listened to him.

Member Avatar for twomers
-1
293
Member Avatar for vegaseat

This was a comment from ee_programmer in reference to one of the Python code snippets. [code=python]""" I was expecting the first class instance to only have one dictionary entry {'person0': 0} rather than two dictionary entries. Similar expectation with second class instance. How do I create and assign value to …

Member Avatar for a1eio
0
212
Member Avatar for FreezeBlink

DrPython requires the wxPython GUI toolkit to be installed first, both should work under Ubuntu. Another nice IDE is UliPad from: [url]http://code.google.com/p/ulipad/[/url] Again this one requires wxPython installed. Should work under Ubuntu.

Member Avatar for bumsfeld
0
184
Member Avatar for briansmall
Member Avatar for tondeuse34

You problems are very basic, function raw_input() returns a string, but in your if statement you are trying to compare it with an integer. That means choice == 1 needs to be choice == '1' and so on. Don't use a Python function name like 'list' as a variable name. …

Member Avatar for tondeuse34
0
95
Member Avatar for wizard wusa
Member Avatar for happimani

You simply do that within the program that needs the additional path information ... [code=python]# if you want to import a custom module that is not # normally on the PYTHONPATH let's say it is in directory my_directory import sys # put this line before you start importing the module …

Member Avatar for vegaseat
0
125
Member Avatar for bhagyaR
Member Avatar for micam

You need to make this a GUI program ... [code=python]# bind mouse clicks using the Tkinter GUI toolkit # (usually included in your Python installation) import Tkinter as tk def change_color(event): btn1.config(fg='red') root = tk.Tk() btn1 = tk.Button(root, text='Click me with the right mouse button ...') btn1.pack() btn1.bind('<Button-3>', change_color) # …

Member Avatar for vegaseat
0
498
Member Avatar for SUBHABRATAIISC

Try this ... [code=python]# open a file for appending fap = open("file1.txt", "a") n = 0 # append numbers 1 to 9 to the file while n < 9: n = n + 1 # or n += 1 fap.write(str(n)) fap.close() [/code]

Member Avatar for SUBHABRATAIISC
0
65
Member Avatar for scru

[QUOTE=cscgal;594281]I don't know what paper is?[/QUOTE]Paper is the stuff you can make paper airplanes with.

Member Avatar for Lardmeister
0
104
Member Avatar for GrimJack
Member Avatar for zandiago

The End.