15,181 Topics
| |
Hey guys...Need some help with a program for class...here's the assignment If your program detects an error condition, you can make it raise an exception. Here is an example that gets input from the user and checks for the value 17. Assuming that 17 is not valid input for some … | |
hey guys and girls i am having a bit of a problem with my code [CODE] import os,string,sys,pprint,time,glob from datetime import datetime, timedelta fileList = os.walk('.')#if i use glob.glob it does not show any files now = datetime.now() TWA = now + timedelta(days=-1) #print(TWA) files=str() for files in fileList: fileStats … | |
I am relatively new to Python and just have a couple quick questions about using file paths in Python code. 1) As I was recently playing around with the command line, I could not get a file path to work correctly unless I used forward slashes in the path...for example: … | |
Why I have not seen any underline with the menu items although I have put "&" within the menu names. My code is as follows: [CODE]import wx import os class MainWindow(wx.Frame): def __init__(self, parent): self.dirname='' # A "-1" in the size parameter instructs wxWidgets to use the default size. # … | |
[code] a = 10 def foo(x = a): print x a = 5 foo() [/code] Can someone explain why it prints 10 ? | |
Hey Guys, I have a minor problem with pytesser for the internet!!! I want to create a program that calculates equation from the internet. I need pytesser to recognize the equation and python to calculate it. Example: 5 + 5 = [ ] Then Sendkeys will type the answer in … | |
I am trying to figure this problem out but I can't seem to get the code right. Please help. OUESTION: Implement a subclass of list called myList. It will behave just like the list class except for iteration: Usage: >>> l = myList([3,5,7,9]) >>> for item in l: print(item) 3 … | |
hi... using pysnmp, an 'snmp get' varBinds gives me an 'octet string' of values like: 1+1 Protection; East-West; Spiral Search; ODU Enable/Disable I need to loop through these strings and see whether a particular string say, 'East-West' is present. I am not finding way to do this. can this octet … | |
Hi... I want ti contril the while loop, just make it looping just for x times, ex: loop for 5 times and pass to the next code :) | |
I've been trying to find information on this for a while, but I can't seem to find anything. I want to use python to send a command to the command prompt, then instead of sending the output to the console window, put the output into a variable that I can … | |
I've built a Counter (which is not implemented for python 2.6) for reading a sequence file of strings to a dictionary and trying to return those sequences are unique for that file/a number of files. I use sequences with a length of X-characters as key in my dictionary and put … | |
hello there guys. im quite confused regarding the use of pyserial classes. ive been reading up on the pyserial documentation. i followed an example and used the code below [CODE]import serial ser = serial.Serial (0 , baudrate = 57600 , timeout = 1) #open serial port (1) - 1 line … | |
Im pretty new to python so im still finding my feet.. Ive written a small ftp program that downloads a file but its quite basic in that it gets the last element from the list and then downloads it. What is the easiest way to add some logic so it … | |
Hi, I'd like to find the maximum value in a list but be able to state certain exceptions. For example: if list A=[1,5,3,4] I want to say [CODE]max(A) except index 1[/CODE] which would return '4' as the maximum value. Is there a way of doing this? Thanks. | |
When I execute; tkFileDialog.askopenfilename(title='Open file', filetypes=[('csv files', '*.csv')]) I get a file open dialog just fine, but there's also a blank TK panel about 2 inches square with nothing in it titled 'tk' behind the dialog. What is it, and how do I make it go away? I'm on Windows … | |
I can't get images to load.. I always get an error here's my code so far: #pong import os, sys import pygame from pygame.locals import * if not pygame.font: print "Warning, fonts disabled" #-------------------------------------------------------- def load_image(name, colorkey=None): fullname = os.path.join('data', name) try: image = pygame.image.load(fullname) except pygame.error, message: print 'Cannot … | |
How can I get my editor to expand both horizontal and vertical? I have a simple test application that uses a subclass of a StyledTextCtrl. I create my editor object in a subclass of wx.Frame. [CODE=python] def CreateEditor(self): myEditor = editor.SyntaxControl(self) # subclass of StyledTextCtrl sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(myEditor, 0, … | |
So i made a small game using pygame, and I want to be able to give it out to some friends who don't have python, so I want to make it into an EXE. i've been trying for several hours using several different methods, but nothings seems to be working. … | |
| Hello everybody!! I know that the topic "compiling python script" is a very popular topic, and there are informations about it everywhere on the net. I use windows and want to make a .exe-executable My problem: Everything I found... * is to old * does not work (exe has an … |
import urllib.request page = urllib.request.urlopen("http://www.randompickupline.com/") text = page.read().decode("utf8") where = text.find('<p id="pickupline">') start_of_line = where + 18 end_of_line = start_of_line + 150 line = (text[start_of_line:end_of_line]) print (line) This is a basic html import for a text based game I'm writing for fun, and I'm making a dynamic string. However, the … | |
hi all.......... 1)~ # free cat /proc/meminfo total used free shared buffers Mem: 62192 32080 30112 0 0 Swap: 0 0 0 Total: 62192 32080 30112 2)~ # free cat /proc/meminfo total used free shared buffers Mem: 62192 32440 29752 0 0 Swap: 0 0 0 Total: 62192 32440 29752 … | |
Hi... Let's say that we have this: [CODE]somme = raw_input('1 + 1 = ') if somme == 2: print 'Good - Time For Answer: ' else: print 'False - The Right Answer is: 2 -Time For Answer:'[/CODE] So... how can we get the time for writing any things on raw_input() | |
Hi... I want to start with PyQt and I don't from where should I beggin !! I'm using Fedora Linux 14 ! | |
plz see this code [icode] x=raw_input('enter any number :') def adder(d): d=d+1 adder(x) [/icode] in this function when x is passed to function adder ,,is 'x' and 'd' are copy of each other or d is reference of x.. | |
I'm looking for a way to get the first letter of of a string. I already know about the .startswith() but that is for "if" statements I want something like [CODE]print text.startswith() # to give me the left most symbol[/CODE] | |
If I have example code: [CODE]url = "someurl" values = {"username" : USERNAME, "password" : PASSWORD} data = urllib.parse.urlencode(values) req = urllib.request.Request(url, data) urllib.request.urlopen(req)[/CODE] it passes username and password to the url that you request. So I want to post a thread in a forum. When I look at the … | |
Hello, Is it possible to use ctypes for this? I tried a sample code from net but it is not working. [CODE]from ctypes import cdll myDll = ctypes.LoadLibrary('C++dll.dll') mydll.testString()[/CODE] Can u tell me how to load a C++ dll and call the functions from python? | |
I have been trying to learn Django (and Python). I have a form that can have up to [I]n[/I] elements. Each of those elements has 3 parts to it (a TextField, a TagField and a Checkbox). The form init looks like this [CODE] def __init__(self, *args, **kwargs): notesAndTags = kwargs.pop('notesAndTags') … | |
| Hey all, It's been a really really long time since I did any Python programming; upon the launch of the Web Store - I've been interested in developing a basic app myself. So here I am! Anyways, can anyone tell me if its possible to make a Packaged App using … |
How can i make a pyhton calculator that launches on click? Thank You. |
The End.