988 Posted Topics

Member Avatar for trihaitran
Member Avatar for trihaitran
0
134
Member Avatar for Stefano Mtangoo

The str() function returns a normal string. Test it out: [code=python]s = u"a unicode string" d = {} d['a'] = s print(d) # {'a': u'a unicode string'} d['b'] = str(s) # str() converts s to a normal string print(d) # {'a': u'a unicode string', 'b': 'a unicode string'} [/code]

Member Avatar for Stefano Mtangoo
0
114
Member Avatar for thehivetyrant

As a general rule it is best to write these things the long way: [B]if x == 4 and y == 4:[/B] or: [B]if x == False and y == False:[/B] In case you don't remember the precendence rules, you can even use: [B]if (x == False) and (y == …

Member Avatar for BearofNH
0
105
Member Avatar for drew7py
Member Avatar for drew7py

As long as there is no comma in your individual data elements, you can use function join() and replace() in this manner: [code=python]q = ['23', 'CL', '006', '2004', 'DBA8ORPU', '41', '8Y', '0', 'S0111P', '2'] s = ",".join(q).replace(",", " ") print(s) """ my result --> 23 CL 006 2004 DBA8ORPU 41 …

Member Avatar for Ene Uran
0
4K
Member Avatar for planetPlosion

First of all, do yourself and the rest of us a big favor and do not use tabs for indentations. As you can see, your code shows up badly in the Daniweb code area. Most of us use 4 spaces for indentation. Here is an example of wxPython's GridSizer to …

Member Avatar for planetPlosion
0
477
Member Avatar for artemis_f

I have used PyQT, it is okay, but the user base is tiny and there is precious little help and too few good examples out on the net. You post a question on PyQt and rarely ever get an answer.

Member Avatar for Stefano Mtangoo
0
163
Member Avatar for lllllIllIlllI

There is also pixel graphics and vector graphics. In the more common pixel graphics an image is made up of pixels with a given location and colour. In vector graphics the image is calculated using a series of mathematical operations. The advantage of vector graphics is that is smoothly scalable. …

Member Avatar for Ene Uran
0
131
Member Avatar for Ancient Dragon

[QUOTE=jbennet;794474]I want one![/QUOTE]Be careful! Most hamburgers are loaded with one of the worst fats you can eat, a recipe for an early departure.

Member Avatar for Ene Uran
0
40
Member Avatar for wheatontrue

Something like this should be faster, since it avoids the use of function calls: [code=python]text = """\ A list of Pythonyms ... pythonanism: spending way too much time programming Python pythoncology: the science of debugging Python programs pythondemic: something bad that lots of Pyton programmers do pythonerous: something hard to …

Member Avatar for wheatontrue
0
142
Member Avatar for breatheasier
Member Avatar for Stefano Mtangoo
0
99
Member Avatar for serkan sendur
Member Avatar for Nick Evan
0
140
Member Avatar for Stefano Mtangoo
Member Avatar for Stefano Mtangoo
0
133
Member Avatar for jaysonperry22

raw_input gives gives a string, so for numbers you can do calculations with, you will have change the numeric string to a float: total_sales = float(raw_input('Please enter your total sales: '))

Member Avatar for vegaseat
0
130
Member Avatar for iuessele

Two loops will do, or you can use a list comprehension: [code=python]rank = ("A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K") suit = ("c", "h", "s", "d") card = [] for r in rank: for s in suit: card.append(r+s) card = tuple(card) print(card) """ my …

Member Avatar for Stefano Mtangoo
0
107
Member Avatar for Stefano Mtangoo

The way you have written it, onCreateTable() doesn't seem to return anything. Maybe you should write a simpler test program first.

Member Avatar for Stefano Mtangoo
0
128
Member Avatar for juzzy

You could put the two windows in question onto a borderless (invisible) window.

Member Avatar for Stefano Mtangoo
0
139
Member Avatar for ithelp

The real cost of printing too much money to pay for wars and failed banks will be hyperinflation down the road. Just ask folks from countries like Argentina or Zimbabwe.

Member Avatar for ithelp
0
212
Member Avatar for mruane

Here is a typical example: [code=python]# use module pickle to save/dump and load a dictionary object # or just about any other intact object import pickle # create the test dictionary before_d = {} before_d[1]="Name 1" before_d[2]="Name 2" before_d[3]="Name 3" # pickle dump the dictionary fout = open("dict1.dat", "w") pickle.dump(before_d, …

Member Avatar for mruane
0
296
Member Avatar for Salem

With all these additional 'forced users' maybe Microsoft stock will go up for a change? I am stuck with Vista at work and at home, and I hate it!

Member Avatar for Ene Uran
0
92
Member Avatar for Stefano Mtangoo

There is the [B]Pyglet[/B] multimedia module from: [url]http://www.pyglet.org/index.html[/url] You can download the Windows installer: [url]http://pyglet.googlecode.com/files/pyglet-1.1.2.msi[/url] and the documentation: [url]http://pyglet.googlecode.com/files/pyglet-1.1.2-docs.zip[/url] [B]AVbin[/B] is a thin wrapper around FFmpeg a collection of audio and video codecs widely used in projects such as mplayer, xine, gstreamer and VLC. It is needed to play .ogg …

Member Avatar for Ene Uran
0
532
Member Avatar for aegis042404

Use SetBitmapSelected() only if you want the different image to show as long as the button is pressed. For what you have in mind, you may want to use SetBitmapLabel(): [code=python]# playing with wxPython's # wx.BitmapButton(parent, id, bitmap, pos, size, style) # show a different image for selected (depressed) button …

Member Avatar for aegis042404
0
260
Member Avatar for revenge2

You can use simple string functions: [code=python]html = """\ <html> <head> <title>Ordered List Example</title> </head> <body bgcolor="#FFFF00" text="#FF0000"> <OL STYLE = "font-family: comic sans ms; font-size:10pt"> <LI>Religious tolerance</LI> <LI>Exact estimate</LI> <LI>Military Intelligence</LI> <LI>Passive aggression</LI> <LI>Tight slacks</LI> <LI>Business ethics</LI> <LI>Advanced BASIC</LI> <LI>Extinct Life</LI> <LI>Pretty ugly</LI> <LI>Genuine imitation</LI> </OL> </body> </html> """ …

Member Avatar for Ene Uran
0
159
Member Avatar for hasanatkazmi

That task would be very specific to the Operating System you have. So, what OS do you have?

Member Avatar for Ene Uran
0
69
Member Avatar for tom_avs

To access Oracle databases you need to get module cx_Oracle. You need to download ad install the correct module for your version of Python and your version of Oracle. see: for info [url]http://www.orafaq.com/wiki/Python[/url] and downloads [url]http://cx-oracle.sourceforge.net/[/url]

Member Avatar for Ene Uran
0
89
Member Avatar for The Dude

Very nice! She is a lot more funny than most of the stuff on Comedy Central!

Member Avatar for The Dude
1
88
Member Avatar for GrimJack

[QUOTE=GrimJack;790699]I am sorry but these are not bureaucrats - they are worse, [URL="http://thinkprogress.org/2009/01/22/rice-wicked-witch/"]they are political appointees.[/URL] "Another person pointed out to me that after Rice’s arrival in 2005 the tone of official State Department publications changed; they began to praise and glorify Rice. “No prior secretary,” said the twenty-year veteran, …

Member Avatar for GrimJack
0
73
Member Avatar for revenge2

Widgets in wxPython need a unique integer ID number. When you use -1 then wxPython will pick a unique ID number for you. BTW, wx.ID_ANY is a constant set to -1 and a little more descriptive. You also may want to look at class basics before you use them, so …

Member Avatar for Ene Uran
0
125
Member Avatar for scru

[QUOTE=scru;788225]Is there a gui library that has already been ported to python 3? I'm interested in using some of the new python 3 features in the back end for my project.[/QUOTE]For the time being you will have to use good old Tkinter that ships with Python3.0.

Member Avatar for Ene Uran
-1
270
Member Avatar for Ghostenshell

Do you mean something like that? [code=python]import random def main(): ##Open a file outfile = open('numbers.txt', 'w') for count in range(10): ##Get random numbers rebmun = random.randint(1,99) outfile.write(str(rebmun) + '\n') outfile.close() # read the file you just created text = open('numbers.txt','r').read() num_list = text.split() # create a dictionary with ix:val …

Member Avatar for woooee
0
158
Member Avatar for wotthe2000

First of all, you are mixing spaces and tabs in your indentations, which will srew up most editors. Please use spaces only! I assume the error happens in the for loop, and it looks like when you reach the integer element in your booklist you are trying to use "in" …

Member Avatar for Ene Uran
0
4K
Member Avatar for GrimJack
Member Avatar for GrimJack
0
130
Member Avatar for thehivetyrant
Member Avatar for OffbeatPatriot

[QUOTE=OffbeatPatriot;786415]I've got it working now.[/QUOTE]In a forum we try to inform each other. What did you do different?

Member Avatar for OffbeatPatriot
0
259
Member Avatar for scru

You simply append the directory to PYTHONPATH before you import your custom module: [code=python]import sys # appends to PYTHONPATH the location of the example codes sys.path.append(r'C:\Python25\Examples') [/code]

Member Avatar for scru
0
143
Member Avatar for revenge2

Some slicing examples in there: [url]http://www.webreference.com/programming/python/2.html[/url]

Member Avatar for Ene Uran
0
125
Member Avatar for EAnder
Member Avatar for Ene Uran
0
118
Member Avatar for revenge2

Avoid Python 2.6 if you can. It was supposed to help preparing folks for Python 3.0, but it is just confusing to most users. Also like scru mentioned, wxPython for Python 2.6 has some errors in it. I finally managed to get my SciTE IDE editor set for Python30. Actually, …

Member Avatar for Ene Uran
0
106
Member Avatar for harrykokil

You are importing Tkinter twice, first with a namespace and then without, kind of goofy. This "Traffic Simulation" must be homework, because I have seen this import approach a fair number of times on several forums.

Member Avatar for harrykokil
0
78
Member Avatar for harrykokil

You mean something like this? [code=python]import Tkinter as tk import time import sys import datetime as dt root = tk.Tk() root.title("Traffic Simulation") canvas = tk.Canvas(root, width=1000, height=400, bg="#FFFFFF") canvas.pack() for k in range (1,10): s = 'orange' + str(k) x = k * 50 y = 20 canvas.create_text(x, y, text=s) …

Member Avatar for harrykokil
0
97
Member Avatar for revenge2

The combination of pydev + eclipse is a huge sluggish thing. I enjoy DrPython, it has some nice downloadable plugins like code assist and run from buffer. My test criteria for a good editor is how it handles the input() function in its output window.

Member Avatar for Ene Uran
0
91
Member Avatar for Stonehambey

Programs like py2exe work very well with wxPython and will include the needed parts in the distribution package of your code for Windows users. Also wxPython is available for most of the common Operating Systems.

Member Avatar for Ene Uran
0
2K
Member Avatar for leegeorg07

Here is an example how to do this: [code=python]# encoding and decoding a cipher structure def encode(text): text = "".join([c.upper() for c in text if c.isalpha() or c==" "]) temp = "" for c in text: temp += code_dic[c] return temp def decode(crypt): temp = "" # use groups of …

Member Avatar for leegeorg07
0
125
Member Avatar for Gribouillis

This would do the trick, but would not be very readable: [code=python]if testA: actionA() if testB: actionB() if testC: actionC() if not(testA and testB and testC): actionDefault() [/code]

Member Avatar for Gribouillis
0
139
Member Avatar for Ene Uran

Since so many folks are going around and wishing you a 'Happy New Year', I wonder what would make you happy. Getting an interesting higher paying job would make me happy.

Member Avatar for vegaseat
0
160
Member Avatar for revenge2

Swaroop C.H. has rewritten his excellent beginning Python tutorial online book for Python30: [url]http://www.swaroopch.com/notes/Python_en:Table_of_Contents[/url]

Member Avatar for Stefano Mtangoo
0
468
Member Avatar for revenge2

[QUOTE=evstevemd;768548]I use one tab or four spaces They give me no problem, so I guess: 1Tab = 4spaces[/QUOTE]You may not have a problem with your tabs and your tab setting, but I have run into plenty of problems with other folks' code that have used tabs. Please avoid tabs!

Member Avatar for mn_kthompson
0
122
Member Avatar for nrupparikh

... and here is how you would do this with Python: [code=python]arr = [12, 7, 9, 25, 87] for item in arr: print(item) [/code]Just to compare the syntax, here is the same thing in C: [code=c]#include <stdio.h> int main() { int arr[] = {12, 7, 9, 25, 87}; int i; …

Member Avatar for Aia
-1
151
Member Avatar for revenge2

[QUOTE=revenge2;766883]thanks. Can you suggest some tutorials?, all the ones on the net seem to be outdated and i cant get some of them to work...[/QUOTE] Swaroop C.H. has rewritten his excellent beginning Python tutorial online book for Python30: [url]http://www.swaroopch.com/notes/Python_en:Table_of_Contents[/url]

Member Avatar for sneekula
0
126
Member Avatar for sillyboy

This time of the year I like to add a shot of eggnog to my extra strong brew.

Member Avatar for brandmantra
0
272

The End.