15,181 Topics
| |
Since there is so much discussion on one of the threads on zipping/unzipping files and all the associated incompatibilities, is there a way to do this with Python and cut out the middleman? | |
This is part of a short script I wrote to find out whether students had submitted any corrections to work in December or January. [code=Python] import os, os.path months = ['Dec', 'Jan'] # actually a raw_input() files = get_all_files(root_dir) # actually a call to os.path.walk() dates = [] for i … | |
I know wxpython is supposed to be better than tkinter, but I can't find any easy to understand tutorials on how to begin using wxpython. But anyway. How can I get tkinter to load up a jpg? | |
I'd like to set up something like this: a=0 class b: def__init__(self, foo): self.foo = foo def create(): global a a=a+1 a=b("FOO") Where the number 1 will define the instance (I'm not sure if define is the write word, whatever you put before the equals sign when your creating an … | |
code: you can change this code as you like [code] import wx import os from wxPython.wx import * import wx.html class MyHtmlFrame(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title) html = wx.html.HtmlWindow(self) html.SetPage( "This is test implementation of Simple <b>Notepad</b> using <font color=\"red\">wxPython</font> !!!! " "<br>View is created using … | |
[code]#Auther : vivek sharma #date : 06-11-2006 #Description : This script is used to get the list of week in given year, user have to input the year , def WeekFinderFromYear(year): """ will return all the week from selected year """ import datetime WEEK = {'MONDAY':0,'TUESDAY':1,'WEDNESDAY':2,'THURSDAY':3,'FRIDAY':4,'SATURDAY':5,'SUNDAY':6} MONTH = {'JANUARY':1,'FEBRUARY':2,'MARCH':3,'APRIL':4,'MAY':5,'JUNE':6,'JULY':7,'AUGUST':8,'SEPTEMBER':9,'OCTOBER':10,'NOVEMBER':11,'DECEMBER':12} year=int(year) … | |
can anybody help me by writing a code for opening my web connection. it locks itself after some time as it is password protected and i have to open it again.The thing is that i actually leave my computer on to download stuff and when i come back it locks … | |
| Hello, I am new to Python and find it really nice. But I can not launch an executable file using only its name. I have to give its whole path. I expected that the PATH environment variable is known by Python and that it could retrieve the full path itself... … |
I am in the end part of a Python Gui game build; it is going quite well but I am finding that I underestimated one area of the logic, incorrectly coding it: The game is blackjack. One area that, although it seemed simple on the surface (and in fact it … | |
Hi, I am a newbie to python. I was trying to import an execl application to python. To startwith i'm trying to open a excel file using python script. In some of the sample scripts that are available on internet has the following contents. -------------------------------------------------------------------------------- import win32API.client import pythoncom app … | |
import wx import os from wxPython.wx import * import wx.html class MyHtmlFrame(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title) html = wx.html.HtmlWindow(self) html.SetPage( "This is test implementation of Simple <b>Notepad</b> using <font color=\"red\">wxPython</font> !!!! " "<br>View is created using <font color=\"red\">wxGlade</font>") class MyFrame(wx.Frame): def __init__(self, *args, **kwds): # begin … | |
def WeekFinderFromYear(year): """ will return all the week from selected year """ import datetime WEEK = {'MONDAY':0,'TUESDAY':1,'WEDNESDAY':2,'THURSDAY':3,'FRIDAY':4,'SATURDAY':5,'SUNDAY':6} MONTH = {'JANUARY':1,'FEBRUARY':2,'MARCH':3,'APRIL':4,'MAY':5,'JUNE':6,'JULY':7,'AUGUST':8,'SEPTEMBER':9,'OCTOBER':10,'NOVEMBER':11,'DECEMBER':12} year=int(year) month= MONTH['JANUARY'] day=WEEK['MONDAY'] dt = datetime.date(year,month,1) dow_lst = [] while dt.weekday() != day: dt = dt + datetime.timedelta(days=1) lst_month = MONTH.values() lst_month.sort() for mont in lst_month: while dt.month == … | |
result=[] list = int(raw_input("enter the length of list:")) size_of_batch=int(raw_input("enter the size of batch:")) def createBatch(lst): lenLst = len(lst) if lenLst > size_of_batch: no_of_batch=lenLst/size_of_batch last_entry_batch=lenLst%size_of_batch first_index=0 last_index=size_of_batch else: no_of_batch=0 first_index=0 last_entry_batch=lenLst newList = lst[0:last_entry_batch] runChangeState(result,newList) return while no_of_batch != 0: newList = lst[first_index:last_index] runChangeState(result,newList) first_index=first_index+size_of_batch last_index=last_index+size_of_batch no_of_batch = no_of_batch-1 if no_of_batch==0: … | |
Is there any way to get the python interpreter installed on a thumb drive? So that I can edit some programs while at my work, where I'm never on the same computer twice, so installing on each machine isn't as pratical as the thumb drive. Just anything that would let … | |
Hi there, I am sitting here and thinking. The best way to learn a new language is to play in it, but I have a little problem: I don't know where to start , how about a few ideas | |
hai, This is punitha.Iam having some doubts regarding python (python extending with c).In our application python is used as a glue language.It is used to call c funcions(which is in the form of dlls).Once a c function is called,Pyhton variable receives the return value and it passes that value to … | |
I have a function which should work, and it actually does... just not all the time. Sometimes it just freezes. Can anyone identify a problem in the ai_northAmericaCheck(): function? Here is the code: [php] import random ai_countries = [] firstTurnsCountries = [] northAmericaList = [0,1,2,3,4,5,6,7,8,9] availableCountries = range(20) country0value = … | |
About one month ago or so my Dr. Python compiler (interpreter) died. I had closed Dr. Python to go and eat dinner then came back to re-open and continued where I had stopped and... nothing. This came at a terrible time as I was in the middle of some very … | |
Hi, this is my first post, and im trying to compare a matrix to find the minus element greater than zero, my list is matrix= [9,8,12,15], [0,11,15,18], [0,0,10,13], [0,0,0,5] I dont want to use "min" function because each element is associated to (X,Y) position. Thanks a lot ! jDSL | |
I know that one has to be careful with mutable arguments like lists applied to function calls, so that things like this won't accidentally happen: [php]def add_item(list2): list2.append(99) return list2 list1 = [1, 2, 3] list3 = add_item(list1) print list1 # [1, 2, 3, 99] oops! print list3 # [1, … | |
Hi, I am trying to average student GPA. I thought I had this problem solved but then I ran it and the GPA did not come out correct. Can anyone give any suggestions? [CODE]import string import math class Student: def __init__(self, name, hours, qpoints): self.name = name self.hours = float(hours) … | |
I took a mixed type list and set out to find the min and max values. The results are very surprising to me: [php]mixed_list = [11, 'Dick', 12, 'Mary', 7, 'Zoe', 9, 700, 777, 'Paul', 13456789] mn = min(mixed_list) mx = max(mixed_list) print mn, type(mn) # 7 <type 'int'> print … | |
I was experimenting with the nested list example in thread: [URL]http://www.daniweb.com/techtalkforums/post246791-72.html[/URL] and was trying to search a nested list like that: [code]nested_list = [1 ,'Dick', 2, ['Mary', 7, 9, [700, 777, 'Paul']], 13] if 'Paul' in nested_list: print 'found Paul' else: print 'Paul not found' [/code]It always tells me that … | |
I want to make a Tkinter button respond to a left and right mouse click differently. How can I do this? | |
How do you best swap the key:value pair of a dictionary? | |
Hi, I did get the problem fixed with my "break" not working properly but now my ValueError will not work properly. If you enter a number that is not a floating number it should create a value error(as a matter of fact it did before I fixed my other problem … | |
Hi, I am trying to extend my "Student with the best GPA" program so that it allows the user to sort a file of students based on gpa, name, or credits. The program needs to prompt for the input and output files and also the field to sort on (gpa, … | |
I am having a problem getting my "break" to work correctly in this program. Can anyone help me see what I am doing wrong? This is my program: [code]import string import math class Student: def __init__(self, name, hours, qpoints): self.name = name self.hours = float(hours) self.qpoints = float(qpoints) def getName(self): … | |
How can I make a Tkinter window take up all my display screen area? | |
I'm going to have to include a lengthy bit of code, but its every necessary part for you to see what I need. [php]import random availableCountries = range(20) # <--- Used at games start, player's countries taken from here firstTurnsCountries = [] # <--- Player one's country possesion secondTurnsCountries = … |
The End.