4,305 Posted Topics

Member Avatar for geekazine
Member Avatar for geekazine
0
73
Member Avatar for Seagull One
Member Avatar for Seagull One
0
456
Member Avatar for Scuppery

She got a mudpack, looked good for a while, then the mud fell off.

Member Avatar for abetageek
-2
275
Member Avatar for donlinmj

[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 …

Member Avatar for Jx_Man
0
225
Member Avatar for sneekula

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.

Member Avatar for sittas87
0
52
Member Avatar for friendklay

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 ... # …

Member Avatar for vegaseat
0
98
Member Avatar for k9triz

Looks like the library you have does not know how to handle unicode characters.

Member Avatar for vegaseat
0
94
Member Avatar for TheOneElectroni

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 …

Member Avatar for TheOneElectroni
0
748
Member Avatar for ratperson

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 …

Member Avatar for vegaseat
0
2K
Member Avatar for rysin

Care to elaborate a little more on what your AIM bot should accomplish?

Member Avatar for EAnder
0
99
Member Avatar for Ancient Dragon

I like SOS's avatar, it stimulates your mind, is artistic and has a certain amount of je ne sais quoi.

Member Avatar for peter_budo
0
217
Member Avatar for Aia

[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!

Member Avatar for Aia
0
761
Member Avatar for Das246

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]

Member Avatar for vegaseat
0
287
Member Avatar for vegaseat

I keep hearing that Python is about as slow as Java. Does anybody have experience with speeding things up?

Member Avatar for Gribouillis
0
491
Member Avatar for docaholic
Member Avatar for raymarquise

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 …

Member Avatar for vegaseat
0
129
Member Avatar for Mazille

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 …

Member Avatar for Mazille
0
2K
Member Avatar for Billg

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 = …

Member Avatar for vegaseat
0
107
Member Avatar for Das246

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.

Member Avatar for jlm699
0
153
Member Avatar for MikeyFTW

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 …

Member Avatar for MikeyFTW
0
1K
Member Avatar for ddwyer50

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]

Member Avatar for EAnder
0
219
Member Avatar for The Dude
Member Avatar for dinilkarun

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 …

Member Avatar for dinilkarun
0
2K
Member Avatar for Matt Tacular

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 ); …

Member Avatar for mchen10
0
474
Member Avatar for sardarji

Python does have a hash(object) function, or do you mean something like jlm699 mentioned?

Member Avatar for vegaseat
0
77
Member Avatar for david_09

Python was not written to do such low level system operations. That sort of thing is the level of C or C++.

Member Avatar for vegaseat
0
127
Member Avatar for The Dude

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 …

Member Avatar for vegaseat
0
50
Member Avatar for rinsukaze

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""" …

Member Avatar for vegaseat
0
78
Member Avatar for devstudio.2007

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.

Member Avatar for Ene Uran
0
122
Member Avatar for db_ozbecool

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]

Member Avatar for ZZucker
0
313
Member Avatar for dandan5448505

[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.

Member Avatar for vegaseat
0
35
Member Avatar for swills
Member Avatar for vegaseat
0
75
Member Avatar for safir8100

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()) …

Member Avatar for vegaseat
0
80
Member Avatar for linkrulesx10

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 …

Member Avatar for linkrulesx10
0
5K
Member Avatar for R.V.

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 …

Member Avatar for R.V.
0
155
Member Avatar for tommy1988

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.

Member Avatar for AKarnisky
0
216
Member Avatar for leegeorg07

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.

Member Avatar for vegaseat
0
109
Member Avatar for programmingnoob

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 # …

Member Avatar for jlm699
0
116
Member Avatar for pravdexter
Member Avatar for Scuppery

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.

Member Avatar for jrcagle
0
5K
Member Avatar for cheesedoodle

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]

Member Avatar for vegaseat
0
133
Member Avatar for LaurenceB

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)) …

Member Avatar for LaurenceB
0
88
Member Avatar for itdupuis

How would you generate hydrogen locally? It is difficult to store and handle. Even small leaks can cause massive explosions.

Member Avatar for Ene Uran
0
159
Member Avatar for s7plc

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' …

Member Avatar for sneekula
0
6K
Member Avatar for megazear7

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 = …

Member Avatar for vegaseat
0
90
Member Avatar for FreezeBlink

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]

Member Avatar for vegaseat
0
93
Member Avatar for lllllIllIlllI

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 …

Member Avatar for vegaseat
0
118
Member Avatar for mg0959

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 …

Member Avatar for woooee
0
2K
Member Avatar for dr_kac

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 …

Member Avatar for paddy3118
0
191
Member Avatar for reyev

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]

Member Avatar for reyev
0
138

The End.