988 Posted Topics

Member Avatar for wandie

Soemthing like that? [code=python]s = "c:/hello/scot" if s.endswith("scot"): s = s.replace("scot", "bob") print s # c:/hello/bob [/code]

Member Avatar for LouLouLou
0
166
Member Avatar for wandie

You have to add a newline character to the end of each line in the string: [code=python]mylist = [[2934110, 'B1', 'D4', '7C7C7C7C804040404040F140404000'], [2934110, 5, 1, 1, '01', 'Actes Sud '], [2934110, 4, 1, 2, '8C00Dubbelganger (motief)'], [2934110, 3, 1, 1, '01', '01', '03', 'Les amants imparfaits', ' : roman'], [2934110, …

Member Avatar for wandie
0
104
Member Avatar for fredzik

First of all, take the second line out, vegaseat did not write your program! Note that print is used in console programs and will not work in a GUI. You have to use a label. Also line [code=python]label25=tk.Label(root, text="Enter your number here:") [/code]asks for an input, so you need an …

Member Avatar for fredzik
0
122
Member Avatar for ONELA

[QUOTE=ONELA;348550]I M A Girl Reading A Degree At A Local University , I M Having A Assignment To Do Please Help Me On That Fact[/QUOTE] Very funny, but a little late for an April first joke!

Member Avatar for Ene Uran
-1
95
Member Avatar for pareshv22

Don't forget to take a look at the Python module BioPython. More info, free download and docs at: [url]http://biopython.org/wiki/Main_Page[/url]

Member Avatar for Ene Uran
0
87
Member Avatar for Ene Uran

Illustrates the close relationship of the hard-software industry to April first: [CODE=c]#include <nonsense.h> #include <lies.h> #include <spyware.h> /* Microsoft Network Connectivity library */ #include <process.h> /* For the court of law */ #define say(x) lie(x) #define computeruser ALL_WANT_TO_BUY_OUR_BUGWARE #define soon next_year #define the_product_is_ready_to_ship another_beta_version void main() { if (latest_window_version>one_month_old) { …

Member Avatar for thekashyap
0
158
Member Avatar for fredzik

First of all, welcome to the forum! To preserve the code's indentations, please use the [b][noparse][code=python][/noparse][/b] and [b][noparse][/code][/noparse][/b] tag pair to enclose your python code.

Member Avatar for fredzik
0
217
Member Avatar for nitinloml

Somethin along this line: [code=python]# get the IP address of the machine the program is running on import socket print socket.getaddrinfo(socket.gethostname(), None)[0][4][0] [/code]

Member Avatar for ghostdog74
0
90
Member Avatar for covertx

The advantage of BF is that it allows you to use the f-word in an academic setting.

Member Avatar for linux
0
125
Member Avatar for the_python

If you just want to remove the first 'n' use: [code=python]old = "open sesame nnnn" # replace first occurance of 'n' new = old.replace('n', '', 1) print new # 'ope sesame nnnn' [/code]

Member Avatar for jrcagle
0
5K
Member Avatar for pinder
Member Avatar for pinder
0
101
Member Avatar for alba07

You define method __str__() within the class: [code=python]class Book: def __init__(self, author, title, price): self.author = author self.title = title self.price = price def __str__(self): # overrides print for the instance text = "%s by %s" % (self.title, self.author) return text abook = Book(author = "Amy Doe", title = "Sun …

Member Avatar for jrcagle
0
240
Member Avatar for sneekula

I modified mawe's code so you don't have to worry about the date of the day: [code=python]# using just time and not date ... import datetime lunch_start = datetime.time(11, 30) lunch_end = datetime.time(12, 45) now = datetime.datetime.now().time() # testing print lunch_start # 11:30:00 print lunch_end # 12:45:00 print now # …

Member Avatar for sneekula
0
161
Member Avatar for fonzali

Several things: Try to give Tkinter and Calendar a namespace, so you know where the functions come from. Give variables names that don't confuse, like 'l1' looks a lot like '11' in many editors, switching to 'lb1' helps readability. Please use the [b][noparse][code=python][/noparse][/b] and [b][noparse][/code][/noparse][/b] tag pair to enclose your …

Member Avatar for sneekula
0
161
Member Avatar for aot

No need to blush, we all have made that mistake. Python allows functions to be passed to and from other functions, so all you have to remember is to use the function object and not the function call for the argument. Makes more sense once you look at it that …

Member Avatar for Ene Uran
0
115
Member Avatar for sneekula

Tkinter does not have a fancy spreadsheet like widget like wxPython. However, you could create a matrix of Entry widgets and go from there.

Member Avatar for Ene Uran
0
5K
Member Avatar for sneekula

I took mawe's code and Jeff's ideas and came up with this: [php]# analyze a chemical recipe to create a chemical data list rcp = """23 g chemicalA is dissolved in 250 ml methanol. The solution is cooled to 0 - 5 degC and 18 ml compoundB is added dropwise …

Member Avatar for jbennet
0
212
Member Avatar for scru

A couple of things wrong with your countdown timer. 1 - don't limit the size of your root window, widgets won't fit 2 - labels take strings 3 - root.update() is needed Look this over: [php]#Gamal Crichton #Teje's Counter #04/02/07 from Tkinter import * import time class Application(Frame): def __init__(self,master,act_name,time_): …

Member Avatar for scru
0
828
Member Avatar for Matt Tacular
Member Avatar for ~s.o.s~
0
92
Member Avatar for Xzantose
Member Avatar for blacklight
0
145
Member Avatar for KalebG
Member Avatar for John A
0
114
Member Avatar for mattyd

Unless you have a huge amount of events in your loop, it could very well be your mouse.

Member Avatar for mattyd
0
189
Member Avatar for chris99

Well, this one is tough because the code is frankly a nightmare! Here are some hints (look at !!!!!!! comments): [php]#Role Playing Form.py from Tkinter import * #Create the Start window class character(object): def __init__(self, master): # \Images is a subfolder of current folder torch=PhotoImage(file=r".\Images\Title Screen Flames.gif") #!!!!! grave=PhotoImage(file=r".\Images\TitleScreenGraves.gif") #!!!!! …

Member Avatar for Ene Uran
0
142
Member Avatar for Aia

[QUOTE=Aia;311655]I have learn more with you that almost six month going through several books on C programming. Again. Thank you.[/QUOTE]Reading the books might help.

Member Avatar for ~s.o.s~
6
136
Member Avatar for fonzali

Here is something very simple that you can fancy up with a +/- year and a +/- month button: [php]# as simple monthly calendar with Tkinter # give calendar and Tkinter abbreviated namespaces import calendar as cd import Tkinter as tk # supply year and month year = 2007 month …

Member Avatar for vegaseat
0
4K
Member Avatar for sneekula

I have used this info on Tkinter: [url]http://infohost.nmt.edu/tcc/help/pubs/tkinter/[/url] A liitle dry with few examples however! This one has a nice Tkinter section and more examples: [url]http://bembry.org/technology/python/index.php[/url]

Member Avatar for sneekula
0
1K
Member Avatar for wandie

I am a little lost here. I assume your data comes from a file? Well, anyway, using assumptions here is some code: [code=python]def strip_brackets(txt): if txt[0] == "[": # remove leading '[' txt = txt[1:] if txt[-1] == "]": # remove trailing ']' txt = txt[:-1] return txt # assume …

Member Avatar for ghostdog74
0
161
Member Avatar for mattyd

Sharky, DrPython is not a compiler nor an interpreter, it is simply an fancy editor that allows you to run code from. I assume from your question that you want to retain the previous outputs in your output window, so you can compare them?

Member Avatar for vegaseat
0
135
Member Avatar for Extremist

"Data Mining" is an increasingly popular field and Python is pretty good at it. To data-mine HTML pages on the Web you can use an HTML Scraper like "Beautiful Soup" from: [url]http://www.crummy.com/software/BeautifulSoup/[/url] More involved are data scrapers like Orange from: [url]http://www.ailab.si/orange[/url]

Member Avatar for jrcagle
0
329
Member Avatar for mattyd

I have used SPE for quite a while. No, it's not the "Society of Petroleum Engineers", but "Stani's Python Editor". For some odd reason it has vanished on the net. Now I am starting to use DrPython, that one seems to be still quite active and just released a new …

Member Avatar for Ene Uran
0
201
Member Avatar for jDSL

Similar to Jeff's code: [php]# write this as a list of lists ... matrix = [[9,8,12,15], [0,11,15,18], [0,0,10,13], [0,0,0,5]] # find the minimum value above val in each list val = 0 for n in matrix: print n # test mv = min([v for v in n if v > …

Member Avatar for Ene Uran
0
103
Member Avatar for sneekula

I find counter4 to be a very interesting function, thanks for putting it up vegaseat.

Member Avatar for jrcagle
0
230
Member Avatar for sneekula

In case of the capital:state pair I did it this way: [php]def swap_dictionary(original_dict): temp_dict = {} dict_list = original_dict.items() for i in dict_list: temp_dict[i[1]] = i[0] return temp_dict cs = {"indianapolis":"indiana", "columbus":"ohio", "jackson":"mississippi", "phoenix":"arizona", "honolulu":"hawaii", "richmond":"virginia", "springfield":"illnois", "lincoln":"nebraska", "boston":"massachuettes", "lansing":"michigan", "desmoines": "iowa", "salem": "oregon"} dic = swap_dictionary(cs) print dic """ …

Member Avatar for mawe
0
2K
Member Avatar for babutche

Your initial problem is right here: [code]def main(): print "This program sorts student grade information" filename = raw_input("Enter the name of the data file: ") dfield = raw_input("Enter gpa, name, or credits to sort: ") filename = raw_input("Enter a name for the output file: ") data = readStudents(filename) ... [/code]You …

Member Avatar for babutche
0
468
Member Avatar for Matt Tacular

I played wit it for a little while and came up with these obvious shortcuts: [php]# changed playerInitialList to pL to save on typing # changed pL1 etc. to pL[1] etc. # What do you do if initials of the two players match? import random def continents(): #<--- Visual Display …

Member Avatar for Matt Tacular
0
163
Member Avatar for chris99

Method curselection() returns a tuple of the selections in case you selected more than one line, in your case pick tuple item zero. Change the your code line to reflect that: [code] passType=self.listPass.curselection()[0] [/code]

Member Avatar for chris99
0
1K
Member Avatar for trihaitran

Could be your editor/IDE. Also, a Unicode string literal is preceded with a 'u'.

Member Avatar for trihaitran
0
162
Member Avatar for babutche

I would use the state as the key just in case there could be two capitol cities with the same name: [php]dic = {'mississippi': 'jackson', 'arizona': 'phoenix', 'iowa': 'desmoines', 'massachuettes': 'boston', 'michigan': 'lansing', 'virginia': 'richmond', 'oregon': 'salem', 'hawaii': 'honolulu', 'nebraska': 'lincoln', 'indiana': 'indianapolis', 'ohio': 'columbus', 'illnois': 'springfield'} while True: state …

Member Avatar for babutche
0
6K
Member Avatar for sneekula

Not knowing Tkinter that well, here is a somewhat simple minded approach: from Tkinter import * def center_window(w=300, h=200): # get screen width and height ws = root.winfo_screenwidth() hs = root.winfo_screenheight() # calculate position x, y x = (ws/2) - (w/2) y = (hs/2) - (h/2) root.geometry('%dx%d+%d+%d' % (w, h, …

Member Avatar for Ene Uran
0
13K
Member Avatar for wandie

You most likely get the error because you haven't selected anything on the listbox yet. You need to bind the listbox to the mouseclick that does the selection and to a function that contains your get(index) code. Something like this: [php]from Tkinter import * musicfolder = [ ["CollegeRock/"], ['RnB/'], ['HipHop/'], …

Member Avatar for wandie
0
5K
Member Avatar for sTorM
Member Avatar for mattyd

1) Py2Exe is not easy to use! 2) Have you looked at the Py2Exe snippet at Daniweb? That should make it easier to use! 3) Have you been able to package any Python code into an exe? 4) Your program might be small, but there are some 'outhouse' modules that …

Member Avatar for vegaseat
0
293
Member Avatar for babutche

Always check you statement blocks! After you program with Python for a short while, these kind of things stick out like a sore thumb.

Member Avatar for Ene Uran
0
141
Member Avatar for babutche

Your error trapping in the letter grades can be mildly improved: [php]s = 'A,A-,A+,B,B-,B+,C,C-,C+,D,D-,D+,F' ps = """ Enter grade letters A through F, you can also postfix A through D with + or - (press just Enter to exit the loop when done): """ while True: x = raw_input(ps).upper() print …

Member Avatar for babutche
0
118
Member Avatar for bento

Ah, the old Turbo C bad habit clrscr() function. First try to make your program without it, it is rarely needed! You can replace one bad habit with another and use: [code]#include <stdlib.h> void clrscr(void) { system ("cls"); //system ("clear"); // for Unix } [/code]A more official version of a …

Member Avatar for Ene Uran
0
368
Member Avatar for Lynqu2

I think that Dev C++ follows the standard better, since it really uses a very common open source compiler. A program should close unless you make it wait within the code. Anything else is added by the IDE and is not standard. Your version of Borland C++ is very old. …

Member Avatar for ~s.o.s~
0
164
Member Avatar for babutche

This if statment logic will not work for you [INLINECODE]if letter == "A" or "A-" or "A+": [/INLINECODE]. You have to break it up, here is an example: [php]ps = """ Enter grade letters A through F, you can also postfix A through D with + or - (press just …

Member Avatar for babutche
0
130
Member Avatar for seasou

Actually the Python25 version of wxPython has a flash player component. Here is the demo they give: [CODE]import os import wx if wx.Platform == '__WXMSW__': from wx.lib.flashwin import FlashWindow from Main import opj #---------------------------------------------------------------------- class TestPanel(wx.Panel): def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.pdf = None sizer = wx.BoxSizer(wx.VERTICAL) btnSizer …

Member Avatar for seasou
0
2K
Member Avatar for babutche

I looked at some of your questions. [CODE]#I AM CONFUSED RIGHT HERE. SHOULD IT BE: self.letter = letter[/CODE]Since you only going to use the variable 'letter' in this particular method, you can keep it local, no need to add the 'self.' prefix. [CODE] for ch in letter: print ord(ch)[/CODE]The function …

Member Avatar for babutche
0
182
Member Avatar for jrcagle

There are 4,017,010 characters in the authorized version of the Bible. War and Peace shouldn't be much larger. Can you put the entire text of the Bible in one string and save it? You can test it with this simple program, gives no problems on my PC: [PHP]# create a …

Member Avatar for Ene Uran
0
91

The End.