4,305 Posted Topics

Member Avatar for thare

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.

Member Avatar for vegaseat
0
117
Member Avatar for bumsfeld

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]# …

Member Avatar for vegaseat
0
3K
Member Avatar for G-Do

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, …

Member Avatar for G-Do
0
287
Member Avatar for butterflyTee

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]

Member Avatar for mechdriver
0
173
Member Avatar for python_dev

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] -

Member Avatar for python_dev
0
171
Member Avatar for jaafit

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 …

Member Avatar for jaafit
0
1K
Member Avatar for jread

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 …

Member Avatar for jread
0
256
Member Avatar for Comatose

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?

Member Avatar for Dani
0
258
Member Avatar for Ene Uran

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 …

Member Avatar for vegaseat
0
175
Member Avatar for Ene Uran

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 …

Member Avatar for Ene Uran
0
104
Member Avatar for Micko

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 …

Member Avatar for Ene Uran
0
542
Member Avatar for JoshBebbington
Re: Help

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]

Member Avatar for a1eio
0
128
Member Avatar for shafter111

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]

Member Avatar for shafter111
0
145
Member Avatar for magnumbi

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

Member Avatar for magnumbi
0
269
Member Avatar for csaha

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]

Member Avatar for G-Do
0
1K
Member Avatar for a1eio

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 …

Member Avatar for vegaseat
0
3K
Member Avatar for bumsfeld

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.

Member Avatar for vegaseat
0
919
Member Avatar for comwizz

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 …

Member Avatar for Narue
0
186
Member Avatar for mhm_ra

The function clock() in time.h or ctime returns the number of ticks since "process start". A tick is about a millisecond.

Member Avatar for WolfPack
0
452
Member Avatar for coolman2006

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] …

Member Avatar for vegaseat
0
211
Member Avatar for Ene Uran

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 …

Member Avatar for vegaseat
0
111
Member Avatar for sharma_vivek82

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 …

Member Avatar for vegaseat
0
793
Member Avatar for butterflyTee
Member Avatar for JabaPyth
Member Avatar for Ene Uran
0
124
Member Avatar for hak

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 …

Member Avatar for bumsfeld
0
202
Member Avatar for butterflyTee

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: ") …

Member Avatar for butterflyTee
0
93
Member Avatar for dhanu_shiv

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.

Member Avatar for vegaseat
0
390
Member Avatar for butterflyTee
Member Avatar for butterflyTee
0
491
Member Avatar for dhanu_shiv

wx.Gauge() seems to be fixed on one color. However, you can create a colorful gauge from a label by changing its width.

Member Avatar for vegaseat
0
93
Member Avatar for juergenkemeter

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") …

Member Avatar for vegaseat
0
319
Member Avatar for IamRasheed

Thanks for letting us know, this fits our beginner circle well. Don't know how we lost that colon after def countdown(val)?

Member Avatar for IamRasheed
0
108
Member Avatar for katharnakh

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 …

Member Avatar for vegaseat
0
11K
Member Avatar for Alexander1987

I think you need to give us a little more information. What does the network library have to do for you?

Member Avatar for monkeyy
0
166
Member Avatar for muthuivs

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.

Member Avatar for dwks
0
584
Member Avatar for bumsfeld
Member Avatar for bumsfeld
0
246
Member Avatar for abell1234
Member Avatar for katharnakh

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]

Member Avatar for bumsfeld
0
107
Member Avatar for katharnakh

The Tkinter text widget would most likely serve you better than canvas. Yes, you can save the canvas contents in PostSript format.

Member Avatar for vegaseat
0
106
Member Avatar for Cooberman76

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 …

Member Avatar for vegaseat
0
169
Member Avatar for bobpierce01

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, …

Member Avatar for alc6379
0
390
Member Avatar for hummer010

This is a secure website you are trying to get to, that could be a problem!

Member Avatar for alc6379
0
196
Member Avatar for katharnakh

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 …

Member Avatar for katharnakh
0
2K
Member Avatar for Steko
Member Avatar for Steko
0
411
Member Avatar for Ghent
Member Avatar for katharnakh
0
174
Member Avatar for katharnakh

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 …

Member Avatar for vegaseat
0
191
Member Avatar for uv2005

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 …

Member Avatar for vegaseat
0
142
Member Avatar for senateboy

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')] …

Member Avatar for vegaseat
0
154
Member Avatar for ajitmote

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?

Member Avatar for vegaseat
0
165
Member Avatar for senateboy

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 …

Member Avatar for vegaseat
0
171
Member Avatar for davalend

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.

Member Avatar for Narue
0
166

The End.