15,175 Topics
| |
hi friends! i was searching for a base conversion script in python when i was stumped with the following code snippet [code language=python] >>> number = 1000 >>> hex2bin = {"0":"0000", "1":"0001", "2":"0010", "3":"0011", "4":"0100", "5":"0101", "6":"0110", "7":"0111", "8":"1000", "9":"1001", "A":"1010", "B":"1011", "C":"1100", "D":"1101", "E":"1110", "F":"1111"} >>> "".join([hex2bin[h] for h … | |
Hello, I am a new user to programming and to python. I have been trying to program for a while now, yet have been extremely busy for the past few months, and have done the minimum amount of work every day. But, I hope to be able to further my … | |
if i have a string e.g. string = "Hello\nWorld" and do list = string.split() '\n' would be ignored how can I preserve '\n' when splitting strings..? Thanks | |
Sorry to have to post two consecutive questions for other people to help me with, but I'm having a problem with winsound that I simply can't figure out. I've checked all the documentation I could, but there's no answer. The problem is with SND_PURGE. [quote=Python Library Reference]SND_PURGE Stop playing all … | |
[code=python]Y=1 N=0 cont=Y print "Welcome to SCLMIP(Simple Calculator For Linux Made In Python)" while cont == Y: equation=input("Equation: ") print equation cont=input("Continue? (Y,N)") else: print "Exiting..." [/code] If you type 5/2 you get 2, I want it to display 2.5. A workaround is typing 5.0/2.0, but it gets annoying. I … | |
Hi all, Could not work out if this belonged in the c++ forum, or the python forum.... Basically, I am writing an application in c++ which embeds python. The annoying thing is that I have no way of knowing in advance what version of python will be installed on a … | |
Me and my cousin are making a python text-editor. and im having trouble getting our program to work with py2exe and im not sure what the problem is. I set everything up like the py2exe website tell you to and it all went together perfectly fine. but when i try … | |
I have written a small code to parse and execute a sql statement but it fails to execute statement if it caontains ['<=','>='.'!=','<>'] how can i make changes in following regex. rawstr = r"""(.*)[( *)?]?([|=|>|<])[( *)?]?(.*)""" string_to_join="([ *]?and|[ *]?or|[ *]?not)[( *)?](.*)[( *)?]?([=|>|<])[( *)?]?(.*)" sql statement ="select name from table_name where … | |
Hi All, If anybody has worked on the custom tree control in wx.lib of wx python 2.7 and above, can you please help me in implementing the checkboxes in it as i'm unable to do so.... Regards, Dinil | |
Hi, this is my first post. Ive made a number game which is written in python 2.5 and have some problems with it: ------------------------------------- import random # You've got to guess 4 numbers between 0 and 30, if you one right the program will output "WINNER" and tell you the … | |
I have a question about the range function. How is it that the function has three parameters (start, stop, step), but the mandatory one (stop) is in the MIDDLE? I thought mandatory parameters have to be at the beginning, and optional parameters come afterwards? When I try to create my … | |
Hello there, again! Well, once I solved the stupid bug I had in my first Python class ever, now I'm getting results I wasn't expecting. The problem is: I instantiated two objects of this class but, apparently, one of the objects is just a copy of the other. And if … | |
Hello, I am trying to write a login script for a windows network that gets the groups that a member is part of from active directory in order to determine what drives to map. I am attempting to use Tim Golden's active_directory module to do this however when I try … | |
Hello! I'm studying Python and wrote a very simple class to work with bidimensional arrays - just as an exercise. Before writing te class I played around with functions and they worked fine. When I tried to do the same using a class, things became strange... Okay, I wrote this … | |
I'm just learning python and i'm trying to make a game where someone puts in 3 numbers and the program picks one of them at random [ICODE]import random print "Enter 3 numbers and i'll choose 1 at random" a = 0 b = 0 c = 0 nmlist = [a, … | |
Hi! I just started using Python yesterday and I have written a program that reads in a very large data file and rearranges the data so that it can be read into a different program. I am doing this for some engineering modeling simulations. I wanted to create an interface … | |
Ok, I would like to use a regular expression that I create dynamically to search and replace words in a file. For instance: import re fl = re.compile('abc|def|ghi') ts = 'xyz abc mno def' n = fl.search(ts) print n How would I find all matches in the string? So far, … | |
Hi. *** SHORT QUSETION: Is there a way I can run a <large> socket server withought having to have a thread for each client/socket created? ***LONGER EXPLAINATION IVe recently written a small network program, that sends messages over TCP or UDP... depending on user input. I want ot adapt that … | |
Hi, I have 2 modules, grepforapp.py and myApp.py. Basically i'm trying to make a 'search' utility. myApp makes the UI with one textbox for taking input, start button and a list box which displays the file names where the pattern was found. grepforApp walks through the dir tree and searches … | |
Dear All, I am trying to write the following code: def try1(n): a1="God Godess Borother Sister Family" a2=a1.split() a3=raw_input("PRINT A WORD") a4=a1.find(a3) print a4 a5=[] if a4>0: a5=a2.index(a3) a6=a5+1 a7=a2[a6] print "The new word is" print a7 a8=a5.append(a7) print a5 elif a4<0: a11=a3 print "The word is not availiable in … | |
I am currently trying to convert a program I just wrote to application form, on the Mac. I'm using py2app to accomplish this, and everything works fine up until the last stage; when I try to complete the conversion with: [code] python setup.py py2app [/code] and then run the resulting … | |
Here's my code: [code=python]from Tkinter import * import tkFileDialog import ImageTk import Image class GUI(Tk): def __init__(self, master = None): ## self.apfr = Frame() ## self.before = self.graphicWindow("Input") ## self.after = self.graphicWindow("Output") ## ## self.apfr.icon = Button(self.apfr, text = "Minimize", ## command = self.ico) ## ## self.apfr.quit = Button(self.apfr, text … | |
I made a Class, and I am trying to change a variable (a variable that I set up at the beggining of the program) from inside a Class. But an error pops up and says: "local variable 'widget_stock_price' referenced before assignment" I made the variable "widget_stock_price" at the beggining of … | |
It's always bugged me how it seems that the only way to find out where you are inside a for loop is to use a counter. For instance, suppose you want to iterate through a list, and print every entry on a second line, but for the second-to-last entry you … | |
Hi Guys What i am trying to do here is have a tuple of numbers, lets say X. Then i have a list of a few other tuples. I want the program to find the tuple that is closest in value. [code=python] x = (214,521) lis = [(200,500),(250,550),(300,600)] [/code] I … | |
I have a Python program that uses Mechanize to open a page at a website with a log-on/password form, set the entries to preset values and then submit to begin the session. This works, I can get the log-in/password from a form I build in the program. What I an … | |
Hi all, I want to append our own images with nodes and their children in a tree control. I am using wxPython and it has wx.ART feature which contains many custom images, but if I want some other images to be appended in a tree, what should I do? Please … | |
Hi all, I am using a tree control for multiple selections by implementing "wx.TR_MULTIPLE" property. The tree is bound by the event "EVT_TREE_SEL_CHANGING". On click of each item, value for that item is being populated.Similarly, The value should disappear on clicking the selected item again.Now,when I click the last item … | |
Hello, Here I go again. I have the simplest of ideas...yet cannot seem to find a solution to implement it: [CODE=Python] from socket import * import time BUFSIZE = 256 IP = 'localhost' PORT = 25000 ADDR =(IP, PORT) tcpCliSock = socket(AF_INET, SOCK_STREAM) tcpCliSock.connect(ADDR) tcpCliSock.send('I want a response from you … | |
i have been trying to create my python command prompt directory but always recieve this imformation "the system cannot find the path specified" please i will be glad if someone can shade more highlight on how to set the python command prompt directory |
The End.