4,305 Posted Topics
Re: Welcome to DaniWeb! I have family in Verona and New Glarus nearby. | |
Re: A very interesting project. Can you give us more information about your setup? | |
Re: She got a mudpack, looked good for a while, then the mud fell off. | |
Re: [QUOTE=donlinmj;665140]Hi, I just joined DaniWeb. I came across the forum in search of help to a particular issue. I'm a research professor at Saint Louis University. I conduct biomedical research using bioinformatics tools. As part of my role, I maintain two Linux servers (redhat) which host various bioinformatics software, custom … | |
Re: Yes Snee, you finally made 10% of Ancient Dragon's posts, but then he has been here a year longer. Congratulations! Also, thanks for all your fine Python science contributions. | |
Re: You need to create an instance of class Target and give it some more needed information. This is a standalone file and will run the whole thing ... [code=python]# Just save this file to the working folder # that contains your code file. # Then just run it ... # … | |
Re: Looks like the library you have does not know how to handle unicode characters. | |
Re: Take a look at this, it might explain the limitations of the grid layout manager ... [code=python]# the size of a grid cell in a given row or column is determined # by its largest widget # if you give a grid layout more space than it needs, it will … | |
Re: This is modified code from one of the Python snippets on DaniWeb ... [code=python]# move an image rectangle to follow the mouse click position import pygame as pg # initialize pygame pg.init() # use an image you have (.bmp .jpg .png .gif) image_file = "ball_r.gif" # RGB color tuple for … | |
Re: Care to elaborate a little more on what your AIM bot should accomplish? | |
Re: I like SOS's avatar, it stimulates your mind, is artistic and has a certain amount of je ne sais quoi. | |
Re: [QUOTE=jwenting;631336]your bile proves my point... It takes a foreigner to see through the campaign promises and subterfuge of Osama bin Barak bin Laden ibn Hosseini.[/QUOTE]Wenting, why don't you just report to the nearest mental hospital and get it over with! | |
Re: Just a guess, but this approach is supposed to behave better then os.system() ... [code=python]import subprocess # ... subprocess.call(["dom3.exe", gameName, "--verify"]) [/code] | |
I keep hearing that Python is about as slow as Java. Does anybody have experience with speeding things up? | |
Re: This is very unclear, you got to give us some code! | |
Re: Python is very much like Java, it compiles your source code into bytecode (Python Virtual Machine code) that the Python interpreter then converts to the actual CPU specific code. Programs like Py2Exe are really packagers that take your bytecode, any needed modules, the Python interpreter (Pythonxx.dll) and package it all … | |
Re: You are almost there. Line 14 should be: randomWord = random.choice(fileList) Actually your text file has all the words listed on a separate line, so you can simplify this to ... [code=python]import random def getRandomFiveLetterWord(e): fh = open(e, "r") fileList = fh.readlines() fh.close() randomWord = random.choice(fileList) return randomWord.rstrip() print "The … | |
Re: Font is not part of the bread and butter console version of Python. Any of the GUI toolkits and PyGame make fonts available. Here is an example using the Tkinter GUI toolkit that normally comes with Python ... [code=python]import Tkinter as tk # create mainwindow root = tk.Tk() mytext = … | |
Re: wx.TextCtrl() does have an IsModified() method that returns True if the text has been modified. We might have to set up a simple example to test this all out. | |
Re: Recommended style for Python code is capitalized names for class names and non-capitalized names for functions. Don't let def click(): dangle in space, use at least a ... [code]def click(): pass [/code].. until you fill it in with your code. Your prograsm can only have one main window or root … | |
Re: I am just getting my feet wet with WEB programming in Python. I found these two articles very useful: [url]http://www.devshed.com/c/a/Python/Writing-CGI-Programs-in-Python/[/url] [url]http://www.devshed.com/c/a/Python/Python-on-the-Web/[/url] | |
Re: The wx.Frame default style is wx.DEFAULT_FRAME_STYLE and is normally defined as: wx.MINIMIZE_BOX|wx.MAXIMIZE_BOX|wx.RESIZE_BORDER|wx.SYSTEM_MENU|wx.CAPTION| wx.CLOSE_BOX|wx.CLIP_CHILDREN so remove wx.MAXIMIZE_BOX to disable it ... [code=python]# a wxFrame with the max button/box disabled import wx class MyFrame(wx.Frame): def __init__(self, parent, mytitle, mysize): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize, style=wx.MINIMIZE_BOX|wx.RESIZE_BORDER|wx.SYSTEM_MENU| wx.CAPTION|wx.CLOSE_BOX|wx.CLIP_CHILDREN) app = wx.App(0) # create a … | |
Re: There is a WinAPI function to put the cursor into a specified location on the console. I have used it in a C++ program a long time ago. I am getting too old to remember the details. [code]BOOL SetCursorPos( int X, // horizontal position int Y // vertical position ); … | |
Re: Python does have a hash(object) function, or do you mean something like jlm699 mentioned? | |
Re: Python was not written to do such low level system operations. That sort of thing is the level of C or C++. | |
Re: The Ford Pinto was quite a car! I drove one as a poor student, the doors were hard to close, the dashboard was at least two inches higher on one side, it was made from crude recycled steel and rusted like crazy, the gas tank was in a real bad … | |
Re: This works just fine with Python2.5.2 and wxPython2.8.8.0 ... [code=python]# create a wxPython application with OnInit() # IMHO somewhat oldfashioned! import wx class MyFrame(wx.Frame): """inherits wx.Frame""" def __init__(self, parent, id, title): # first call base class __init__ method to create the frame wx.Frame.__init__(self, parent, id, title) class MyApp(wx.App): """inherits wx.App""" … | |
Re: When you upgrade Python you may also need to upgrade some external modules like Pygame or wxPython, if you get them as binaries. Also, Python25 is the present release, why bother with Python24. Take advantage of the speedier compiler and some additional functions. | |
Re: the code within [] is called list comprehension and it creates a list [code]... q = [process(x) for x in somelist if condition(x)] is a shorthand notation for ... q = [] for x in somelist: if condition(x): q.append(process(x)) ...[/code] | |
Re: [QUOTE=Ancient Dragon;649241]why? our support for what? Ok, so he has my support (clap! clap! applause!) I'm moving this thread to Geek's Lounge because it is just a lot of unexplained dribble. Perfect for Geek's Lounge :)[/QUOTE]Maybe we should call it the Dripple Lounge. | |
Re: Now that was easy! For the rest of us, it helps to see your code. | |
Re: You can test if an object can be iterated over ... [code=python]import operator a = 1 b = 'abc' c = [1, 2, 3] d = {'a': 1, 'b': 2, 'c': 3} print operator.isSequenceType(a) # False print operator.isSequenceType(b) # True print operator.isSequenceType(c) # True print operator.isSequenceType(d) # False print operator.isSequenceType(d.items()) … | |
Re: This is just jlm699's code wrapped into a function ... [code=python]def isPositiveNumber(n): """returns True if n is a positive number, else returns False""" # check if n is a string q = str(n) if q == n: return False if n > 0: return True else: return False # test … | |
Re: The way floating point numbers are represented in many computer languages leads to roundoff errors. Take a look at this ... [code=python]q = [157.73 * 100.0] print q # [15772.999999999998] # this explains why print int(157.73 * 100.0) # gives 15772 [/code]For really high precision math that prepresents floating point … | |
Re: This is the one I like ... 476 Manualy selected Python Programming Language Resources at: [url]http://www.cbel.com/python_programming_language/?order=alpha[/url] ... and don't forget to look a the "code snippets" right here on DaniWeb, there are some Python ones. | |
![]() | Re: There are programs available that package the needed code and modules into an executable file, see: [url]http://www.daniweb.com/code/snippet499.html[/url] This example shows py2exe, but there are other ones like pyinstaller and pyfreeze. |
Re: Generally, to convert binary data to a string you have to use base64 encoding [code=python]import base64 str_base64 = base64.encodestring(open('input.bin',"rb").read()) # test it # should only contain printable characters # 0-9, A-Z, a-z, /+ and a few others (also \n) print str_base64 # now save str_base64 to a text file # … | |
Re: What files have you downloaded, and where are they installed? | |
Re: XML handles subscripts and superscripts amongst other things. Look into the module PyXML or wxPython's Fancytext widget. For a fancytext example see: [url]http://www.daniweb.com/forums/post643697-23.html[/url] Another way would be to use the richedit format, again wxPython's TextCtrl() widget can handle that. | |
Re: If you want to know what local variables the function has, you can show the local dictionary of the function using vars() ... [code=python]def funk1(a): c = 7 print vars() a = 1 b = 2 c = 3 funk1(b) # {'a': 2, 'c': 7} [/code] | |
Re: Just to give a rough idea ... [code=python]import random x = random.randint(0,30) y = random.randint(0,30) z = random.randint(0,30) t = random.randint(0,30) list1 = [x, y, z, t] print "Enter 4 numbers between 0 and 30:" for k in range(1, 5): prompt = str(k) + " --> " choice = int(raw_input(prompt)) … | |
Re: How would you generate hydrogen locally? It is difficult to store and handle. Even small leaks can cause massive explosions. | |
Re: You are better off doing it this way and then process the resulting list ... [code=python]import re fl = re.compile('(abc|def|ghi)') ts = 'xyz abc mno def' q = fl.findall(ts) print q # ['abc', 'def'] [/code]For a straight replace ... [code=python]import re fl = re.compile('(abc|def|ghi)') ts = 'xyz abc mno def' … | |
Re: You could make these variables global within the class, but you also need to straighten out your math ... [code=python]player_name = raw_input("What is your name?") class Stock_investor(object): wind_stock_price = 50 empire_stock_price = 50 widget_stock_price = 50 def __init__(self, num_wind, num_empire, num_widget, name): self.num_wind = num_wind self.num_empire = num_empire self.num_widget = … | |
Re: You could use enumerate() to index the list entries ... [code=python]fishSticksList = [1, 2, 3, 4, 5] for ix, entry in enumerate(fishSticksList): print entry, if ix == len(fishSticksList) - 2: print "Fish sticks" else: print "" [/code] | |
Re: Something like this might work ... [code=python]x = (214, 521) q = [(200, 500),(250, 550),(300, 600)] t = [] for item in q: #print item a = abs(item[0]-x[0]) b = abs(item[1]-x[1]) avg = (a + b)/2.0 t.append((avg, item)) # the closest is ... print min(t) # (17.5, (200, 500)) print … | |
Re: This might be what you want ... [code=python]# a simple Tkinter ListBox example for multiline select # use ctrl mouse click or shift mouse click from Tkinter import * def get_list(): """ function to read the listbox selection(s) (mutliple lines can be selected) and put the result(s) in a label … | |
Re: woooee is on the right track. I broke out a sample list into distinct steps, so you can figure out how to do this ... [code=python]# raw data test list from file via readlines() q = ['A aa 9\n', 'A ac 3\n', 'B ff 4\n', 'B vv 1\n', 'C hh … | |
Re: As a oneliner ... [code=python]import os s = "C:\path1\path2\path3\path4" print os.sep.join(s.split(os.sep)[:2]) # C:\path1 [/code] |
The End.