988 Posted Topics
Re: Just a WAG, but it looks like you changed your OS permission/access level. | |
Re: 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] | |
Re: 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 == … | |
Re: Take a look at: help(numpy.set_printoptions) | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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. … | |
Re: [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. | |
Re: 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 … | |
Re: My advice, start out simple and make it work, then go more complex. | |
Re: As girls get smarter, they are almost impossible to put up with. | |
Re: The 'u' implies the use of unicode (a more international character set). | |
Re: 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: ')) | |
Re: 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 … | |
Re: The way you have written it, onCreateTable() doesn't seem to return anything. Maybe you should write a simpler test program first. | |
Re: You could put the two windows in question onto a borderless (invisible) window. | |
Re: 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. | |
Re: 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, … | |
Re: 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! | |
Re: 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 … | |
Re: 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 … | |
Re: 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> """ … | |
Re: That task would be very specific to the Operating System you have. So, what OS do you have? | |
Re: 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] | |
Re: Very nice! She is a lot more funny than most of the stuff on Comedy Central! | |
Re: [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, … | |
Re: 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 … | |
Re: [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. | |
Re: 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 … | |
Re: 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" … | |
Re: All those boos from the crowd for old George Bush was a little sad. | |
Re: You can do (a**2+b**2)**0.5 do get the proper result. | |
Re: [QUOTE=OffbeatPatriot;786415]I've got it working now.[/QUOTE]In a forum we try to inform each other. What did you do different? | |
Re: 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] | |
Re: Some slicing examples in there: [url]http://www.webreference.com/programming/python/2.html[/url] | |
Re: Using class UpdateLabels(threading.Thread): should work too. | |
Re: 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, … | |
Re: 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. | |
Re: 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) … | |
Re: 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. | |
Re: 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. | |
![]() | Re: 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 … ![]() |
Re: 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] | |
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. | |
Re: 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] | |
Re: [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! | |
Re: ... 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; … | |
Re: [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] | |
Re: This time of the year I like to add a shot of eggnog to my extra strong brew. |
The End.