15,175 Topics

Member Avatar for
Member Avatar for chebude

I am trying to catch error on file input/output. The try functions works fine but as it pass to the next line my code breaks. How can I exit gracefully when the 'infile' doesnt exist? [CODE] try: infile = open ('Book1.txt', "r") except IOError: print "input file %s is missing" …

Member Avatar for chebude
0
326
Member Avatar for apeiron27

i imported struct module and packed my integer data with '<I' do my packed data still retain their number characteristics? i only need to do booliean check comparing two numbers in packed form like a>b or a=b stuff like that. i did couple of tests and it seems to work …

Member Avatar for TrustyTony
0
120
Member Avatar for pwolf

Is there something wrong with this code i wrote? i get the feeling i made a mistake and cant quite recall what, its quite frustrating. The function is supposed to determine the dimensions of a matrix and if it is, or is not, a valid matrix ( for example, if …

Member Avatar for pwolf
0
206
Member Avatar for pwolf

I have the task of writing a function to determine the outcome of a game of tictactoe, i at first thought use a couple of for loops but that proved pointless, and then the only way i could think of was to write an if...elif...else statement for each row, column …

Member Avatar for woooee
0
307
Member Avatar for Tcll

hey... I can't seem to find any tutorials that only use PyOGL... can anyone help out?? also... I found an early thread asking the same Q, where vegaseat mislead someone about OGL back in 2008... :P I just thought I'd point out OGL development is actually thriving, but it's code-base …

Member Avatar for Tcll
0
1K
Member Avatar for Sinnocence

I was wondering if anyone could tell me how to save a html page to a website's filemanager labeled as .html so that it would be searchable. Like a wiki. for example: print "<html>" print "<title>python</title>" print "<body>" print """<h1> I would Like to save this page as http://www.mysite.com/python.html</h1>""" print …

Member Avatar for Sinnocence
0
333
Member Avatar for Mouche

Hello. I wrote a program to convert decimal fraction values into binary fractions. I seem to be running into some floating point accuracy problems. After multiplying a floating point number by 2 over and over, eventually the number becomes corrupted. Since I'm multiplying so many times, I think the error …

Member Avatar for Mouche
0
241
Member Avatar for ihatehippies

I've been working with python's SocketServer.ThreadingTCPServer a bit and I'm having some difficulty making a publicly available server. Everything works fine when I set the server address as 'localhost' [CODE=python]self.server = SocketServer.ThreadingTCPServer(('localhost', constants.cmdport), Handler)[/CODE] As long as the both the server and client are on the same computer and both …

Member Avatar for ihatehippies
0
7K
Member Avatar for Pony Cursed

Hi, My question is about: How select a "Window" that exist ? Because I don't know how select. What I know is create a new window, but don't select a that already exists. What I have done this is it: (throw how "sub-process" already minimized) [CODE] import subprocess if subprocess.mswindows: …

Member Avatar for Pony Cursed
0
119
Member Avatar for natehome

hi im trying to make a program that will go to 4chan and download a the images on a thread(i.e. [url]http://4chan.org/b[/url]). the program will work the first time but after that when i go to run it again it trys to download the same urls as it did the first …

0
191
Member Avatar for pwolf

Im stuck with the following: Define a function isPrime(number) that takes in a number as argument and return True if the number is a prime number. Hint: A number, x is a prime number if it is only divisible by 1 and x itself. By definition, 1 is not a …

Member Avatar for pwolf
0
459
Member Avatar for RLS0812

This is a working beta of a virtual slot machine I am working on. Eventually I'm going to add a GUI. [CODE]# Python 3 # Slot Machine # By : RLS0812 # Note: The Odds are a bit off of what they actually are. import random def Reels(): # [0]Winning …

Member Avatar for woooee
0
3K
Member Avatar for vegaseat

Take a look at a typical Windows GUI frame (form) with a menubar, statusbar, panel, label and buttons. Set the font and size of text, click the buttons to create some events. All of this and much more is in the free wxPython package.

Member Avatar for pyphil
2
281
Member Avatar for drlockdown

I'm new to Python. Just started school for programming and have run into a bit of trouble with python. seems every time i go to run module a little window will pop up labeled SyntaxError, and inside of the window it says invalid syntax. Not to sure what's going on, …

Member Avatar for snippsat
0
192
Member Avatar for wzunix

Hiya, recently came across these two grid methods; but am confused about the distinction between them. wonder if anyone could give a simple example to tell the diff? Thanks a million!

Member Avatar for wzunix
0
190
Member Avatar for Plastico Bolha

Hi peoople, My doubt is: how to make a "process" go to "sub-process" ? (in Ctrl+Alt+del) I know that the response this in "import subprocess", but I can't organize this ideia. I need of a help. Thank you patience :icon_wink:

Member Avatar for Plastico Bolha
0
32
Member Avatar for ryniek

I've got a code fragment: [CODE] #!/usr/bin/env python import sys num_lst = [] num_circ = [] while True: print "Type number or [e]nd operation" inpt = sys.stdin.readline() print inpt if inpt == 'e': sys.stdin.flush() print "\n" break else: num_lst.append(inpt) sys.stdin.flush() for i in num_lst: if isinstance(i, int): num_circ.append(i) else: pass …

Member Avatar for griswolf
0
382
Member Avatar for dolphinaura

If I am creating an exception class, along with a stack [CODE]class CustomError(Exception): def __init__(self): self.contents=[] print "Stack Created"[/CODE] How can I make it so that if [CODE]x=CustomError()[/CODE], the stack contents will be [code] x.historical.contents [/code], not [code] x.contents[/code]?

Member Avatar for griswolf
0
110
Member Avatar for Plastico Bolha

Hi people, my doubt is it: How I do to a file if "auto-start" with the "Windows" ? I have this it done already: [CODE] aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE) aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run") aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE) SetValueEx(aKey,"name",0, REG_SZ, r"C:\name.extension") CloseKey(aKey) CloseKey(aReg) [/CODE] Thank you patience :icon_wink:

Member Avatar for Plastico Bolha
0
67
Member Avatar for jone kim

grid = [[0,0,0][0,0,0][0,0,0]] user fills the gird simultaneously. Now I want to make a list of empty squaes of the gird. Suppose user has filled: grid [col1][row1] , grid [col3][row1], grid [col3][row2]. Now I need a list with indexes of the empty list i.e. emptyGrid = [1,2,4,5,7,8,9] First I've to …

0
108
Member Avatar for Luxifour

Hey everyone, How would you go about creating a loop for taking user input without knowing beforehand exactly how many times it will run - as I can't seem to work out how to generate a unique name each time. So, for instance, say you want to take user input …

Member Avatar for Luxifour
0
186
Member Avatar for roshurwill

Hi everyone, recentley new to programming and the language python. So ive learned an amount of python, i decided to start a projct. My project is to make a game, which the user plays using only commands, like walk foward, open the door etc, you are in the bedroom... whatever. …

Member Avatar for woooee
0
509
Member Avatar for moroccanplaya

hi i got a a Tkinter text widget and a string i want to know how to display the string in the text widget ?? [CODE] abc = "hello world" text = Text(app, width=80,height=40, wrap='none').grid(row=2, column=2) [/CODE]

Member Avatar for bumsfeld
0
220
Member Avatar for suravi99

Dear Sir, I want to import PyTango library but it gives this error,please help me >>> import PyTango Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\PyTango\__init__.py", line 90, in <module> raise ie ImportError: DLL load failed: The specified module could not be found. my platform …

Member Avatar for woooee
0
172
Member Avatar for Tcll

I actually have 2 Q's the files I'm working with only provide 4x3 inverse bind matrices for bones. what I first need is a function that writes the 4th row of the matrix and then I need to know PyOpenGL's matrix inversion function (since it's faster than my current function) …

Member Avatar for Tcll
0
30
Member Avatar for Malraux

Hello I have a sequence that looks like this: 60211401dc070000 which is a string (it was build through a series of concatenations and conversions) How can i just tell him that it is actually a hex ?? without modifying it's value... Thanks! Have a nice day

Member Avatar for Lucy Four
0
319
Member Avatar for arunpawar

I am learning regex in php but want to try out how the regex in python works. I have not yet moved to the code side of things and for the same reason, i am searching for the regex examples in both php and python. To start somewhere, i decided …

Member Avatar for TrustyTony
0
213
Member Avatar for Malraux

Hello, I'm trying to represent the system date in a sequence such as: dd mm yy yy So far i got: dd mm yyy so, the year is represented on 2 ytes, but I only have 3 characters, i need to split after the first character and then add a …

Member Avatar for TrustyTony
0
228
Member Avatar for pwolf

i was wondering if this was an efficient way to achieve the objective or not, some advice on the matter is much appreciated. the objective is to define a function to determine the standard achieved by a participant taking a physical fitness test. The standard is determined based on the …

Member Avatar for TrustyTony
0
244
Member Avatar for pwolf

Write the function search(word, substring) that takes in a word and a substring as arguments and returns the position (0 indexed) of the substring if it is found in the word. The function returns -1 if the substring is not found. is there a method to do this? i tried; …

Member Avatar for TrustyTony
0
181

The End.