15,181 Topics

Member Avatar for
Member Avatar for debasishgang7

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 …

Member Avatar for bumsfeld
0
6K
Member Avatar for krystosan

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 …

0
131
Member Avatar for ihatehippies

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

Member Avatar for ihatehippies
0
246
Member Avatar for tony75

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

Member Avatar for tony75
0
314
Member Avatar for krystosan

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 …

Member Avatar for vegaseat
0
261
Member Avatar for giancan

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 …

Member Avatar for vegaseat
0
145
Member Avatar for tony75

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 …

Member Avatar for tony75
0
491
Member Avatar for PSB92

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 …

Member Avatar for Schol-R-LEA
0
159
Member Avatar for John Linux

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 …

0
76
Member Avatar for ALJ

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.

Member Avatar for klickagent
0
9K
Member Avatar for lancevo3

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 …

Member Avatar for slate
0
156
Member Avatar for gmorcan

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 …

Member Avatar for woooee
0
262
Member Avatar for mkweska

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 …

Member Avatar for Schol-R-LEA
0
218
Member Avatar for vivsshake

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 …

Member Avatar for vivsshake
0
347
Member Avatar for molisoft

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 …

0
55
Member Avatar for Rick345

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

Member Avatar for Rick345
0
225
Member Avatar for tony75

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 …

Member Avatar for tony75
0
498
Member Avatar for entropic3105

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.

Member Avatar for bumsfeld
0
314
Member Avatar for lewisrs89

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 …

Member Avatar for bumsfeld
0
1K
Member Avatar for jaison2

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 …

Member Avatar for bumsfeld
0
10K
Member Avatar for cobaltbravo

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 …

Member Avatar for cobaltbravo
0
300
Member Avatar for alexamicaa

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

Member Avatar for sepp2k
-2
664
Member Avatar for M.S.

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 …

Member Avatar for M.S.
0
2K
Member Avatar for krystosan

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

Member Avatar for krystosan
0
114
Member Avatar for krystosan

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

Member Avatar for krystosan
0
823
Member Avatar for rwe0

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 …

Member Avatar for vegaseat
0
844
Member Avatar for mkweska

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

Member Avatar for vegaseat
0
272
Member Avatar for Subomi

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.

Member Avatar for vegaseat
0
290
Member Avatar for vegaseat

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

Member Avatar for vegaseat
3
4K
Member Avatar for Ismatus3

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

Member Avatar for Ismatus3
0
6K

The End.