4,305 Posted Topics
Re: The word "literal" appears often with hexadecimal or octal numbers, they are literal representations of a number. So hex(255) gives the string '0xff', the value 255 is still contained within that string. You can say that '0xff' is the hex literal of 255. | |
Re: G-Do, nice thinking here! I looked in my code samples and found another way, a little strange at first blush, but it works! I commented it heavily for Bumsfeld so he can follow it. You can put a test print in front of count.append(7) to make it more visible. [code=python]# … | |
Re: G-Do, what operating system are you using? I am a little frustrated with PyGame, since I can never get a midi file to play! PyGame is based on SDL, when I use its SDL counterpart in Ruby it plays midi files! In my Delphi days I used the MPlayer component, … | |
Re: The module "graphics" is foreign to me. Is this something your teacher has writtten? Also everything belonging to function main() should be indented properly! Replace userid = "frodo" with userid = last.lower()[:6] + first.lower()[:1] | |
Re: Hmmm, you might want to give us a code sample of what you have written. (please wrap your code in code tags) [code]# your code here # press Quote Reply to see the tags [/code] - | |
Re: Do you mean ... [CODE]class FlashPanel(wxPanel): def __init__(self, parent, flashFile): wxPanel.__init__(self, parent, -1) sizer = wxBoxSizer(wxVERTICAL) ActiveXWrapper = MakeActiveXClass(flashControl.ShockwaveFlash) self.Flash = ActiveXWrapper( self, -1) self.Flash.Movie = os.path.join(os.getcwd(), flashFile) self.Flash.Menu=False sizer.Add(self.Flash, 1, wxEXPAND) self.SetSizer(sizer) self.SetAutoLayout(True) EVT_WINDOW_DESTROY(self, self.OnDestroy)[/CODE] When you create your Frame, you can specify style=wxMINIMIZE_BOX, but now you have to … | |
Re: Will this help? [php]# module datetime allows you to do calendar math # corrects for jump to previous month and even leap years import datetime today = datetime.date.today() one_week_ago = (today + datetime.timedelta(days=-7)) two_weeks_ago = (today + datetime.timedelta(days=-14)) # make filenames oldmxd1 = "new" + one_week_ago.strftime("%m-%d-%y") + ".mxd" print "oldmxd1 … | |
Re: I also noticed that "Comatose is an unknown quantity at this point"! Is there any better wording for a moderator with 1,064 helpful posts? | |
Re: This will show the PYTHONPATH: [php]# show the system path for Python = PYTHONPATH import sys print sys.path # notice that your present working folder is print sys.path[0][/php] To add another path, the one with your module perhaps, do this at the beginning of your program: [php]# let's say your … | |
Re: Several languages offer the eval() function and its safety is hotly debated. You hear eval() is only one letter away from evil()! My feelings, if eval() is directly connected to a user input, avoid it!!! This is particularly true for Python's input() function that uses raw_input() and then sends the … | |
Re: Looks like you met Narue on the C/C++ forum, she is the best! Your Python code is great, works well. It would be a fabulous addition to the Python Snippets. It depends how you look at it, Python variables are all pointers or references to a heap memory location. Take … | |
Re: Which code snippet are you thinking of? Wordcount of a text file (Python) [url]http://www.daniweb.com/code/snippet238.html[/url] or Word Frequency in a Text String (Python) [url]http://www.daniweb.com/code/snippet374.html[/url] | |
Re: There are also some dictionary functions that can give you access to the inner sanctum: [CODE]d = {"test.tif": {1: [1,2,3]}} for key, dic in d.iteritems(): for x in dic.values()[0]: print x """ result = 1 2 3 """[/CODE] | |
Re: The simplest way would be coverage_rate = coverage_percent /100.0 Remember an integer division behaves different then a floating-point division in most languages. 80/100 = 0 80/100.0 = 0.8 | |
Re: A line by line translation from Java to Python is almost impossible. Java is simply too cumbersome. It is usually best to look at what the Java app does and then start new with Python. Here is a small side by side comparison of Java and Python: [url]http://www.ferg.org/projects/python_java_side-by-side.html[/url] | |
Re: I looked around in code I had written and could only find these two examples ... # pipe calendar.prmonth(2005, 6) to a string # save the short code within the triple quotes as cal_mar2006.py: """ import calendar calendar.prmonth(2006, 3) """ import os # give full path of .py file so … | |
Re: I am scratching my head on this. Would be nice to have for Tkinter! I know wxPython has wx.calendar.CalendarCtrl(), which is quite elaborate and allows to select any month of any year at runtime. | |
Re: I don't want to step on any C++ toes, but there is a "Projects for Beginners" thread in the Python forum. Much of it is applicable to C++ programmers too. Take a look at: [url]http://www.daniweb.com/techtalkforums/thread32007.html[/url] For Dev-C++ users there is a little handholding advice in this code snippet: [url]http://www.daniweb.com/code/snippet82.html[/url] Also … | |
Re: The function clock() in time.h or ctime returns the number of ticks since "process start". A tick is about a millisecond. | |
Re: You are right, this is the wrong forum. DaniWeb does not a have a specific forum for Lisp, but you can try the more general forums [url]http://www.daniweb.com/techtalkforums/forum14.html[/url] or [url]http://www.daniweb.com/techtalkforums/forum42.html[/url] You will reach folks that program more in Lisp at: [url]http://forums.belution.com/en/lisp/[/url] or [url]http://www.tek-tips.com/threadminder.cfm?pid=217[/url] A short tutorial can be found at: [url]http://www.cs.sfu.ca/CC/310/pwfong/Lisp/[/url] … | |
Re: The simplest way would be to convert tax to a string and concatinate with a +. This avoids a comma, which adds one space. [code] price = 50.00 tax = price * 0.08 print "Tax = $",tax # Tax = $ 4.0 print "Tax = $"+str(tax) # Tax = $4.0 … | |
Re: Here is an example using wxPython. Once you have Python installed you need to download wxPython appropriate for your system and Python version, it's free! [code=python]# the wxChoice() widget, a simple dropdown box # wx.Choice(parent, id, pos, size, choices, style) # tested with Python24 and wxPython26 # should work on … | |
Re: Are you just counting letters, and they all have to be lower case? | |
Re: Can you give us an example what you mean with "new tag"? | |
Re: Generally, you create your window and other controls in WinMain() after the call to RegisterClass() and before the start of the event loop. I prefer to put these things into their own functions to make things more readable. Anything related to an actual response to an event goes into CALLBACK … | |
Re: You are making progress on your own. Just some small corrections and it does work. From here you can improve the code. [code]#The number of lines, and the number of words. #import string # not needed def main(): data = raw_input("Enter the path and name of your text file: ") … | |
Re: The folks at [url]http://xoomer.virgilio.it/infinity77/eng/freeware.html[/url] have designed quite a number of nice custom wxPython controls and a system to work with wxPython called PyAUI. All I can say, download some of the free controls and experiment with them. | |
Re: You got to show us the code for wc.py. Most of us are not very good in mind reading! | |
Re: wx.Gauge() seems to be fixed on one color. However, you can create a colorful gauge from a label by changing its width. | |
Re: Take a look at these two PIL examples and see if you can apply them to your task ... [code=python]# using the PIL Python Image Library: # get a region of an image import Image # open an image file (.bmp,.jpg,.png,.gif) you have in the working folder im1 = Image.open("Donald.gif") … | |
Re: Thanks for letting us know, this fits our beginner circle well. Don't know how we lost that colon after def countdown(val)? | |
Re: For starters, here is a simple code sample for bringing up a child window. You can use a button, or in your case a menu click. [code=python]# display message in a child window from Tkinter import * def messageWindow(): # create child window win = Toplevel() # display message message … | |
Re: I think you need to give us a little more information. What does the network library have to do for you? | |
Re: Take a look at the C++ code snippet at [url]http://www.daniweb.com/code/snippet122.html[/url] You will have to format your text to fit the labels. | |
Re: Boa Constructor will do a similar thing as Delphi or Visual-MS-languages using the wxPython GUI kit. Boa Constructor home page: [url]http://boa-constructor.sourceforge.net/[/url] | |
Re: The Tkinter text widget would most likely serve you better than canvas. Yes, you can save the canvas contents in PostSript format. | |
Re: This little while loop will ask for an integer input until it gets one ... [CODE]// controlled integer input in C++: #include <iostream> #include <string> #include <sstream> int main(void) { std::string response; int value; while(1) { std::cout << "Enter an integer number: "; std::cin >> response; // convert to integer … | |
Re: I asked some of our friends in the C/C++ Forum at DaniWeb and it looks like ANSI C limits the level of nesting to 15, some compilers a little more. The Python interpreter DLL is written in ANSI C. The standard C++ compiler may have a higher limit of nesting, … | |
Re: This is a secure website you are trying to get to, that could be a problem! | |
Re: The toolbar in Tkinter is usually a frame with buttons added below the menubar. Depending how you configure the frame there should be a visible separation. If you want to separate the toolbar, you could use two frames properly packed. Here is an example ... [code=python]# the toolbar is a … | |
Re: Can you give us an idea what the final product is supposed to look like? | |
Re: Can you give us an example what your data looks like? | |
Re: The PhotoImage class can only read GIF and PGM/PPM images from files. If you had an image file called calculator.gif in your working directory, you would use ... [code]p=PhotoImage(file="calculator.gif") [/code] Also add something like compound=TOP to your button() to let tk know where your image is in relation to your … | |
Re: 1) find the directory that contains file libg2c.so.0 2) Run this little program: [code]import sys print sys.path [/code] It should show you PYTHONPATH, see if it contains the directory for file libg2c.so.0 Normally your installation should take care of it! 3) if not, then you have to tell Python by … | |
Re: There is a discussion of how C and Python handle integers, and explains why n++ does not make sense in Python. See: [url]http://www.daniweb.com/tutorials/tutorial32575.html[/url] Editor's note: this tutorial has been send to the doghouse as utter kaka junk! In your corrected code this would work fine ... [code]list = [('mark', 'jacky','jane'),('stick','cheri','nice'),('elly','younces','pluto')] … | |
Re: I have used the SPE editor on Windows XP and it works fine. SPE comes with the movable Python system that runs on a flash drive. I don't have a Linux machine. What is your exact problem? | |
Re: Maybe this example from the "Starting Python" sticky will help ... [php] # use a tuple to return multiple items from a function # a tuple is a set of values separated by commas def multiReturn(): return 3.14, "frivolous lawsuits", "Good 'N' Plenty" # show the returned tuple # notice … | |
Re: Why not write a Python program to translate C++ code to Python code? Would be a nice project. Start with something simple and go from there. |
The End.