15,179 Topics
| |
Write a program that reads n digit number. after reading the number, compute and display the sum of odd positioned digits,multiply all even positioned digits and add the two numbers. I have attempteed this problem like this a = input("Enter number") s = 0 p = 1 n = 1 … | |
Ok so I found this code online and though it looked interesting so I ran it but can someone tell me why it doesn't work? I have scapy installed btw #!/usr/bin/env python from scapy.all import * from scapy.error import Scapy_Exception m_iface="wlan0" filter_message="http" count=0 def pktTCP(pkt): global count if pkt.haslayer(TCP) and … | |
How might I gather all the songs in my music library (maintained in iTunes) on Mac OS X 10.8.5 with ID3 title tags (I guess? their titles in iTunes) that consist of 4 random capital letters. Or all the ones whose titles are 4 characters long, case insensitive, or mixed … | |
from xml.dom import minidom dict[1] = "country" xmldoc = minidom.parse('TestStep.xml') itemlist = xmldoc.getElementsByTagName('TestStepBody') print len(itemlist) print itemlist[0].attributes['Author'].value itemlist[0].setAttribute("Author",dict[1]); for s in itemlist : print s.attributes['Author'].value dict[1] value will be changing dynamically, So i need to dynamically change the attribute value of the Author in python. I this possible? if so … | |
I would like to break up a list into sublists of 3 elements each. I have this code, but it will give an index error when the length of the list is not divisible by 3. mylist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] … | |
Inspired by violent python and some of the scripts in there, I would like to make a http request sniffer to sniff http requests on a network. In the book violent python there is a tutorial for a section to make a google keg logger (gets what people search on … | |
I'm having some trouble getting importing stuff from another class, I think I may be doing it wrong. I have a simple main class called Test and at the top I say: [CODE] from WordFixer import WordFixer import sys [/CODE] Then in the same folder (the src folder) I have … | |
Hello, I have few question regarding importing modules. I have created a folder for my python work [quote]/usr/home/pratz/pyfiles[/quote] I have exported this to set the $PATH. And now if I issue the command [code]echo $PATH [/code] I am getting the string the "/usr/home/pratz/pyfiles" in the list. If I am not … | |
def askopenfilename(self): filename= tkFileDialog.askopenfilename(initialdir='C:/..',title='Select File' , filetypes=[('Bitmap Images', '*.bmp'),('Png Images', '*.png'),('Gif Images', '*.gif'),("Jpeg","*.jpg"),("All files", "*")]) self.entryVariable.set(filename) if filename == None: return open(filename,'rb') self.entry.update(filename) self.image = Image.open(filename) self.img = ImageTk.PhotoImage(self.image) self.canvas.config(width=400, height=300) self.lab.img = self.img self.lab.pack() self.canvas.create_image(1,1, anchor=NW, image=self.img) self.scrollbar_vert = Scrollbar(self.canvas) self.scrollbar_vert.pack(side=RIGHT, fill=Y) self.scrollbar_hor = Scrollbar(self.canvas) self.scrollbar_hor.config(orient=HORIZONTAL) self.scrollbar_hor.pack(side=BOTTOM, fill=X) self.canvas.config(yscrollcommand=self.scrollbar_vert.set) … | |
Hi all, i am trying to write a mortgage amortization schedule calculator and am stuck. please see the code below. It appears that the principal is being counted twice before subtracting it from the balance. Any ideas on what the issue is? I am new to python: loanAmount = input("Please … | |
I have a class containing: class CounterList: __n_comparisons__ = 0 def __init__(self, data=None): if data is None: self.data = [] else: self.data = data self.__n_accesses__ = 0 def __getitem__(self, i): self.__n_accesses__ += 1 return self.data[i] def __setitem__(self, i, item): self.__n_accesses__ += 1 if type(item) != CounterNode: raise ValueError("Only Counter objects … | |
Hi, I have created one signal in python using pyside. I'm connecting with that signal 3 times with 3 different methods. when i emit this signal, it has to execute these 3 methods. It works perfectly fine. ValueChanged = QtCore.Signal(list) ValueChanged.connect(method1) ValueChanged.connect(method2) ValueChanged.connect(method3) valueChanged.emit([1,2,3]) But i would like to know … | |
I am updating an xml file and want to preserve multiple namespaces with same URI but different anchor tag using ET.register_namespace Following code is what I've tried : <code> ET.register_namespace('', "http://oval.mitre.org/XMLSchema/oval-definitions-5") ET.register_namespace('', "http://oval.mitre.org/XMLSchema/oval-definitions-5#windows") ET.register_namespace('', "http://oval.mitre.org/XMLSchema/oval-definitions-5#independent") ns = "{http://oval.mitre.org/XMLSchema/oval-definitions-5}" f = open ("def_ex.xml","ra") tree = ET.parse(f) root = tree.getroot() for defn … | |
Recently, I've been trying to find out how to make my computer think that a button on the keyboard has been pressed using python. I want the whole system to think the key has been pressed. I need this to be possible in windows 7 and 8, on the latest … | |
Hi everynone and Good Afternoon I am looking to implement a Program using Python for USB interfacing. How should i go for it.Any idea? | |
I have just figured out how to search for the element that im looking for in a xml file but now when I run it the code loops through i know 3 times maybe even more. I want to know what im missing that would cause it to loop like … | |
Can any one help me in, creating the Python code for the below XML.Please copy it in to notepad <?xml version="1.0" encoding="UTF-8"?> -<TemplateBlock SchemaVersion="(3, 6, 0, 313)" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">-<Block ConstructorType="dstt_framework.DSTT_TestStep" IsCallerBlock="False" CollapsedState="False" EnableMode="True" Guid="u'{79DDB3BE-30F2-4CC4-AE65-C47A39390F34}'" ModifyTime="1409059399.51" CreationDate="1409059390.1270001" ResultLevel="1" ProtoType="''" DevelopmentNode="u''" LibraryDescription="u'To add a functional unit to the test sequence.'" Author="u't8187sa'" _CustomAttributes="{}" Description="u''" … | |
So I was learning python from "Learn python the hard way" in python3 (my preferance) (I also tried everything in the 2nd python) and when I came across "Parameters, Unpacking, Variables" I was stuck for good. When I type in exactly the same thing as he does: from sys import … | |
Hi all, I am working on simplest web browser import socket mysock=socket.socket(socket.AF_INET,socket.SOCK_STREAM) mysock.connect(('www.py4info.com',80)) mysock.send('GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n') while True: data=mysock.recv(512) print data mysock.close() It's returning error 408:Request timeout at one time and at other runs smoothly but with incomplete output as: HTTP/1.1 200 OK Date: Sun, 14 Mar 2010 23:52:41 GMT … | |
Hello everyone. I was wondering if somebody could solve this problem for me. I have a bot that is required to refresh and grab back times here is the code for that task : def findNST(html): NST = re.findall(r'<td id="nst">(.*) am', html) if NST == []: NST = re.findall(r'<td id="nst">(.*) … | |
Below is a Python program I wrote to draw lines as many al there are mouse clicks. However, I wanted all the line segments to have the same attributes (eg: color, width etc), but that's not happening - only the last segment has my desired attributes. I am a beginner … | |
| Is there any way to encrypt/decrypt all image files and audio files with python storing them in a password protected file and then retrieving them again without slowing donw the decryption part? |
#i use python 3xx from tkinter import * from tkinter import ttk # i couldnt install PIL on my computer so I used Pillow. Hope you dont run into any problems import datetime import pickle ## init the variables here since i dont use objects in your code name = … | |
def askopenfilename(self): filename= tkFileDialog.askopenfilename(initialdir='C:/..',title='Select File' , filetypes=[('Bitmap Images', '*.bmp'),('Png Images', '*.png'),('Gif Images', '*.gif'),("Jpeg","*.jpg"),("All files", "*")]) self.image = Image.open(filename) self.photo = ImageTk.PhotoImage(self.image) self.label = Label(self.photo) def encode_files(self,image,data): #get the image file image = Image.open(self.photo) #get message from entry box data= self.data_entry self.encoded = LSBSteg.encode(image, data) | |
SO i have a python code that collects xml data in a file then seraches the file for the scancode and once it finds that the scan code is there it starts scanning for the order number this is where im running into trouble at. What i want it to … | |
The portable version of Python (versions 2.7 and 3.2 are available) can be run from your hard drive or a flash drive. In many ways this makes your live easier, since a lot of libraries are included already. Also, you can take your code to a friend on a flash … | |
Hi there, creating new variable to add to a function, and when the user inputs a value, I get this: ValueError: need more than 2 values to unpack This is for sizeWindow variable by the way, I'll bold the parts I'm talking about. [CODE]from graphics import * def main(): doorColour, … | |
I am workign with a xml file that contains the order information for a company. What i am tryign to do is see if the xml file have a scan code in it and if it does then to pull the order number so that it can be passed to … | |
This short Python program calculates Euler's number e, the base of natural logarithms, to a precision of at least 100 digits in this case. To get the precision needed, the Python module decimal is used. The result is compared to a published result. | |
| I plan to write a program that allows the user to move shapes around on the canvas once they are drawn. A given shape will be drawn when an appropriate button is pressed. I'm using simple test programs to learn my way around. I've looked at a number of examples … |
The End.