15,190 Topics
![]() | |
Hi Everyone, I have a list of numbers I'm trying to write to a file, which I want to be a binary file. Here's my code: nums = [0x1234, 0x5678, 0xabcd, 63, 44] with open('filename', 'wb') as bin_file: for number in nums: bin_file.write(number) The problem is that I keep getting … | |
Hi, I am making a music player in python 2.6 with Tkinter. Here's my code : from Tkinter import * import mp3play import tkFileDialog import Tkinter def open_file(): #Opens a dialog box to open .mp3 file global music #then sends filename to file_name_label. global mp3 global play_list filename.set (tkFileDialog.askopenfilename(defaultextension = … | |
I am trying to teach myself Python. I have started out creating several small programs. This one area has me stumpped. I have created a simple password saver program. I thought using a dictionary would be the best option. The only problem I have ran into is I cannot get … | |
This came up, maybe it is usefull to somebody. Later I plan to do a managing context interface to `with`statement for this. | |
We have been getting this error and needs to be fixed. We use python code to connect to LDAP and this is trowing the following ldap.SERVER_DOWN: {'info': 'TLS: hostname does not match CN in peer certificate', 'desc': "Can't contact LDAP server"} Is there a way to ignore this name mismatch? … | |
I would like a user to select text on a webpage, and to capture that text as a string automatically using the least number of user inputs as possible. Ideally, the user would simply select the desired text using ctrl-c, immediately after I would run the GetClipboardData() function and obtain … | |
Hi All, I wanna generate all possible combination of certain list using python. For Example I have a list like list = ['A','B','C'] I wanna generate all possible combination of these list elements like using "itertools": AAA AAB AAC ABA ABB ABC ACA ACB ACC BAA BAB BAC BBA BBB … | |
Recently i've been coding my own game, it was working fine up to a point but suddenly the backround is moving over the sprites drawn to the screen... I've loaded them unto the screen alright, and sometimes when i run they actually do come out on top. Here's my main: … | |
Hi All, I am working on a project for school. Notice that I am a liberal arts major. My project is to develop a multiple choice test. I decided it would be a cool time to teach myself how to program so people could take the test on the computer. … | |
I have two arrays: n = [30, 47.2, 70.2, 77.4, 36.3, 20.6, 18.1, 21.4, 22, 25.4, 27.1, 40.3, 57, 76.6, 52.3, 19.5, 11.2, 7.6, 14.6, 16.2, 24.7] p = [4, 6.1, 9.8, 35.2, 59.4, 41.7, 19, 13, 8.3, 9.1, 7.4, 8, 12.3, 19.5, 45.7, 51.1, 29.7, 15.8, 9.7, 10.1, 8.6] … | |
Though I've seen some modules and stuff for doing this they seem to deprecated. So how do you use python to update your status on Facebook? (Please provide examples to explain) Thanks In Advance, | |
Greetings. I did not write the below code. I got it from [Click Here](http://itknowledgeexchange.techtarget.com/itanswers/python-script-to-download-wallpapers-from-interface-lift/) Thanks for any help. When I try to check the syntax it gives me an error on the very last line of code. The error "SyntaxError:invalid syntax (line 119, offset 26):a.getWallpaperList()[/pre] #!/usr/bin/env python import urllib2 import … | |
Problem 1: Phone book. A phone book file is organized so that each line is an entry for one person. Each line has the following format: first, a name (one word, no spaces), then zero or more phone numbers, each preceded by a space (no spaces within a phone number). … | |
Hi there one and all. I am attempting to learn to code in python with the intention of teaching it to a class of 12 year olds later in the year!!! So far I've been going ok if a little slowly, however this one is stumping me. I am trying … | |
Hi, i'm new to python and I'm having a problem that I'm not able to solve. I have the following 2D array: valuearray = [['A', '21', '45'], ['A', '12', '23'], ['A', '54', '21'], ['A', '15', '54'], ['B', '23', '53'], ['B', '34', '53'], ['B', '32', '54'], ['B', '24', '13'], ['C', '31', … | |
Problem 2. tttCheckMove() Write a function named tttCheckMove() that checks whether or not a TicTacMove is on an empty space on a TTT board. Input (two parameters): · Parameter 1: A string of 9 characters denoting the state of a TTT board. Each character in the string indicates the state … | |
Here slightly edited code from one of my earliest posts to DaniWeb. Limitted by recursion limit of Python as it uses recursion, but interesting for me. | |
I'm not entirely sure how function work, and ive been trying different combos for a while.. Main: import pygame, motherWhale, scoreBoard pygame.init() def main(): global motherWhale global seaWorld global scoreBoard screen = pygame.display.set_mode((640, 480)) pygame.display.set_caption("Bubble Battle") background = pygame.Surface(screen.get_size()) background = background.convert() background.fill((255, 255, 255)) screen.blit(background, (0, 0)) motherwhale = … | |
I came across a problem that I can't solve and it's associated with multiprocessing and use it inside the decorator. When I'm calling the method **run_in_parallels** using multiprocessing I 'm getting the error: `Can't pickle <function run_testcase at 0x00000000027789C8>: it's not found as __main__.run_testcase` The call takes place inside the … | |
Here is my take on [balanced ternary](http://en.wikipedia.org/wiki/Balanced_ternary) conversion (the base considered by [Donald Knuth](http://en.wikipedia.org/wiki/Donald_Knuth) "Maybe the prettiest") | |
I would like to take string argument for class BalancedTrinary intializer, but the string type of argument is processed before it enters the init function. I guess I must override any class method which deals with those for int/long? def val(number_sequence, base): """ produce integer value of number_sequence as base … | |
I currently have this login form in my python program with a submit button: <input type="text" class="input-small" placeholder="Email"> <input type="password" class="input-small" placeholder="Password"> and I have an sql database that has emails/logins/etc. How do I make it so the after pushing the submit button, the email/password is verified with the database … | |
import os def a(): print("A") def b(): print("B") # I want to sometimes skip the main body if os.path.isdir("C:\\Blender\\mainbody"): print("main body of module_A") Is there a way to control whether or not the main body of a module gets executed by passing in arguments to the import command, such as … | |
I am finding myself a little confused about how Python imports. Would the following be a correct statement: In any Python interactive shell, if the shell (since it was initiated or opened) has never before imported "myScript.py" then if the user types in "myScript" he will get an error like: … | |
Hi I am trying to run a simple gui app using wxPython as follow to list pdf files in a listbox but I am getting this error" return _controls_.ListBox_Insert(*args, **kwargs) TypeError: String or Unicode type required import os import wx class ButtonFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, 'Button Example',size=(500, 500)) … | |
Here is base conversion function written to deal also with [negative bases](http://en.wikipedia.org/wiki/Negative_base). Not yet balanced ternary, where numbers themselves can be negative, maybe later I add it.. Based on the code in the wikipedia article, which has bug for converting 0.[**Edit: I fixed the bug in wikipedia**] | |
Hi, I have a little problem. I want to replace words in a text, but only 'whole words'. That is, I'm looking for a method that changes "cat", but not "catfood". I know how to do it using re.sub, like this: re.sub(r'\bword\b', 'change', text) Only problem is, I'm using a … | |
""" # Tic Tac Toe Author: Tlamangile Ngobeni Lecture: Gary Stewart Department: University of Cape Town Website: www.uct.ac.za Last edited: March 2011 """ from random import* # to alternate who play first def move(position,matrix,symbol): #define the fuction to make a move by replacing to list #if statement to check user … | |
# Here is a piece of code I wrote as to a homework assignment # # I would like the community's opinion on structure and style. This code gives the factorial of a user defined number(near as I could tell by the online math help.) print "This is a problem … | |
I have finally managed to make some progress on PyOpenGL textures. Now I have another problem. Here is my OpenGL init function (its in a script called gl2D.py: [CODE]def init(): glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) glEnable(GL_TEXTURE_2D) glShadeModel(GL_SMOOTH) glClearColor(0.0, 0.0, 0.0, 0.0) glDisable(GL_DEPTH_TEST) glEnable(GL_ALPHA_TEST) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) glAlphaFunc(GL_NOTEQUAL,0.0)[/CODE] And here is … |
The End.