15,181 Topics
| |
Hi, I am trying to write a python func. which can replace nth occurance of any substring present in any string. For example: main_string = "badZZZZZZZZZZZZZZZZZZbadZZZZZZZZZZZZZZZZZZZZzbadZZZZZZZZZZZZZZZZZ" If I wanna replace the 2nd occurance of string "bad" with 'good' i will pass customreplace(main_string,'bad','good',2) So the Function should return badZZZZZZZZZZZZZZZZZZgoodZZZZZZZZZZZZZZZZZZZZzbadZZZZZZZZZZZZZZZZZ I have … | |
just wrote a snippet that return true if whole image sequnce exist else returns false, import os def sequenceExists(seqPath,firstFrame,lastFrame,sep=None): """ Checks if sequence exist on disk. seqPath = image sequence path example: J:/Footages/33x01_02a/33x01_02a.%04d.sgi where %04d can be any number like 0001, 231 but not KFd001 string change buildPath at line … | |
I'm soliciting advice for performace improvements for creating a weak checksum for file segments (used in the rSync algorithm) Here's what I have so far: def blockchecksums(instream, blocksize=4096): from hashlib import md5 weakhashes = [] stronghashes = [] for chunk in iter(lambda: instream.read(blocksize),""): a = b = 0 l = … | |
Hi I wonder How I can add version detection to port scanning? from socket import * ip = raw_input("Enter IP to scan : ") start=input("Enter start port number : ") end=input("Enter end port number : ") print "Scanning IP: " , ip for port in range(start,end): s =socket(AF_INET, SOCK_STREAM) if(s.connect_ex((ip,port))==0): … | |
is it any different to use with in python 2.5, becuase at work i wasnt getting error, but now i am implementing the logic at home on python 2.5 i am getting error from __future__ import with_statement import nuke grp = nuke.toNode("Group1") with grp: nodes = nuke.allNodes() for node in … | |
Dear friends, I have a problem that I don't seem to be able to solve... so I ask for your help! It is basically a math problem, not so much a python, but possibly there is an easy python solution. My problem is the following: I have to know the … | |
Hi I get a littel problem to read,sort,count and remove punctuation marks from text file. data="""I love the python programming How love the python programming? We love the python programming Do you like python for kids? I like Hello World Computer Programming for Kids and Other Beginners.""" ##f = open … | |
Hi, it's been a while since I have used Python and I am very rusty. I have a problem with a piece of code and I can't for the life of me figure out what is wrong. Basically I need a piece of code that prints 'to cold' if the … | |
Hi, I am looking to write a internet scraper, and have considered the following languages: Python C++ Java The scraper will need to: - Retrieve HTML code from a page - Select a link, name and description from a section of the page - Ask for user confirmation (non gui … | |
Hi, I'm having trouble trying to figure out a code that converts negative decimal numbers to binary, as well as specifying the number of bits. For example. convert -18 using 8 bits. This should come out as 10010010 doing it manually, I think. I'd appreciate the help, thanks. | |
Hi - I have a project I am going to be working on which will be a python gui. After meeting with the user yesterday I have found out that the computer this application will run on will not have internet access always. Which brings me to my question, how … | |
Hello everyone, I'm a beginner in programming languages and in Python. I came across this error and I don't khow if it is a logical error or a design error. The problem is with class_average a = {1:[1, 2, 3], 2:[3,4,5], 3:[6,7,8] } b = {1:[3,7,4], 2:[8,2,9], 3:[3,6,3] } c … | |
Hello, I am wondering what I am missing. Keep getting a syntax error at the chara on Line 8..... def main(): print('WELL! Hello. Thank you for choosing your path to'\ 'righteousness! bahahaha!') chara = raw_input(str('Please input your character name: ')) #print the welcome for user print('Ok,'chara,'This is just protype son … | |
Hi i am trying to parse a *large xml* file and printing the tags to a output file. I am using *minidom*, my code is working fine for 30Mb files but more than that its getting memory error.So i used buffer reading the file but unable to get the desired … | |
Hi, I have downloaded a code for Speech Recognition using Windows API (SAPI 5.1). In this part of code: `class ContextEvents(win32com.client.getevents("SAPI.SpSharedRecoContext")):` I get this error: class ContextEvents(win32com.client.getevents("SAPI.SpSharedRecoContext")): TypeError: Error when calling the metaclass bases cannot create 'NoneType' instances I checked and found that `win32com.client.getevents("SAPI.SpSharedRecoContext")` returns `None` I did search all … | |
file_name = raw_input('Name of the file you will use to encode the your data \n') file_name = file_name+'.txt' fp = open(file_name, 'r') text = fp.read() #create a string that is just the first letter of every word in the sentence then close file output = "" for i in text.split(): … | |
Hi again I’m working with the text file and I need suggestions about 2,4,5? and mybe about 1 and 3 also. For example I have this text. “I love the python programming How love the python programming? We love the python programming Do you like python for kids? I like … | |
I have been working with numbers in tkinter using operators but I'm unsure on how to process the input and using maths on them. I also wouldn't mind knowing how to use words either for future reference. Reply if you know anything. | |
Here is my line of code: class Rectangle(object): def __init__(self,x,y): self.x=x self.y=y def Area(self): return self.x*self.y def Perimeter(self): return self.x*2+self.y*2 def main(): print "Rectangle a:" a = Rectangle(5, 7) print "area: %d" % a.area print "perimeter: %d" % a.perimeter #print "" #print "Rectangle b:" #b = Rectangle() #b.width = 10 … | |
well basically i have to draw a stick figure for which is my first question... i cant figure out how to draw a horizontal line and also a line at a angle for the legs... here is the code for the first one def drawStickFigure(): from graphics import * win … | |
I'm currently working on an assignment for my intro python class in school. The program is a "guess my number" variant, but its focus is on global variables and the try/except operation. I've managed to figure out most of it, but I'm having trouble calling my function that gives a … | |
I have NO IDEA how to use Python. Best answer if you write the full program! Please help me! I will be forever grateful! Accept / Reject Monte Carlo Part I: Goal: Write a python program that will: 1. define a function for a specific probability density function f(x), 2. … | |
Assuming that every person has a National ID number, I am trying to check if the Entered number is a valid ID number, under these conditions: 1. ID number must be of 10 digits length. 2. If ID length is greater than/equal to 8 and less than 10 digits, add … | |
on linux i have been using pwd to get the file owner, but how do i do for Windows in python 2.6 since pwd module is supported in linux only..? | |
i have downloaded and installed from this [page](http://sourceforge.net/projects/pywin32/) but still when I import any of the modules[win32api, win32security, win32con] i get import error, please help me if I am not downloading the right version | |
I installed the new **pillow 2.0** on windows 7 python 3.3 using one of the installers with no problems. Apparently that installer provides the jpeg support necessary for Vegaseat's program (link below). However, I am having some kind of trouble getting the jpeg support to work on Ubuntu. After my … | |
Hello all...this is stumping me...it keeps returning a repetition of num ten times rather than multplying by 10...Which way can I fix this? def main(): num = input('Please enter a number: ') print(times_ten(num)) def times_ten(num): return 10 * num main() Thanks!!! | |
Hey, please how can i logically sort for numbers in a list list = [10, 5, 2, 7, 20] without the sort() using only if statements and for loops and no while loop. | |
Simple code to show you how to display an image from a Web URL using the Tkinter Python GUI toolkit, the Python Image Library (PIL) and the data_stream created with io.BytesIO(). | |
Hello , the problem i'm facing is how to insert a cliquable image in a frame , i show the code : def InterfaceDeps(): global interf0 interf0 = Toplevel() interf0.geometry("500x400") interf0.title(' Test Data') f1 = Frame(interf0, bg="blue", width=500, height=500) f1.pack( fill=X, expand=0) ####### Image ############# imageinfo = Image.open("C:/Documents and Settings/Administrateur/Bureau/Python_tests/nvprojet/Info1.jpg") … |
The End.