Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Showing results 1 to 15 of 15
Search took 0.01 seconds.
Search: Posts Made By: ptmcg
Forum: Python Feb 19th, 2008, 8:14 AM
Replies: 6
Views: 341
Posted By ptmcg
Re: Downloading Tkinter and Wxpython

As GameEnder said, tk is bundled with Python, so you should be able to just import it in your scripts and start using it.

Be patient and read the wx download page (GameEnder sent you the link),...
Forum: Show Off Your Open Source Projects Feb 12th, 2008, 8:23 AM
Replies: 15
Views: 710
Posted By ptmcg
Re: www.thefilegarage.com - the world's ultimate file sharing website!

Spelling counts, too. The term is "bandwidth", not "brandwidth".
Forum: Show Off Your Open Source Projects Feb 11th, 2008, 8:50 AM
Replies: 0
Views: 273
Posted By ptmcg
Lightbulb pyparsing - Python parser library

Pyparsing is a Python module for creating parsers. Here is a parser for "Hello, World!", or any string of the form "<greeting>, <person>!":

greeting = Word(alphas) + "," + Word(alphas) + "!"
print...
Forum: Python Feb 8th, 2008, 9:30 AM
Replies: 7
Views: 365
Posted By ptmcg
Re: Other people want to see my programs, how to send them?

If you don't care that the whole world can see your program, you can use a pastebin. There are many to choose from, an easy one is http://pastebin.com/. You can even create your own personal...
Forum: Python Jan 28th, 2008, 5:11 AM
Replies: 6
Views: 459
Posted By ptmcg
Re: Object-Oriented Habits

I absolutely agree that it depends on the program.

In general, I use inheritance for modeling similarities in behavior or expectations of the class user. Strictly speaking, this is not required in...
Forum: Python May 1st, 2007, 5:25 PM
Replies: 4
Views: 253
Posted By ptmcg
If you are looping for the purpose of building a...

If you are looping for the purpose of building a list, read up on list comprehensions. Here is a quick way to build a list of the odd numbers up to 20:


print [c for c in range(20) if c%2 ]
Forum: Python Apr 10th, 2007, 4:13 PM
Replies: 4
Views: 239
Posted By ptmcg
Out of curiosity, I timed how long a do-nothing...

Out of curiosity, I timed how long a do-nothing for loop takes to iterate 1e9 times. On my 2GHz CPU system, running Python 2.4.1:


for i in xrange(1e9): pass


takes 127.5 seconds. So it is...
Forum: Python Apr 9th, 2007, 2:27 AM
Replies: 4
Views: 239
Posted By ptmcg
Don't forget range() creates a list of all of the...

Don't forget range() creates a list of all of the entries, so range(1,2,1e-9) would create a billion-entry list. If instead you are trying to iterate a billion times (and I hope you have some time...
Forum: Python Feb 20th, 2007, 9:17 AM
Replies: 5
Views: 252
Posted By ptmcg
:beard: I guess my OO training from...

:beard: I guess my OO training from Smalltalk/C++/Java days is still showing, I instinctively jump to writing a class, especially since Python offers such nice built-in class impersonation features,...
Forum: Python Feb 19th, 2007, 2:57 PM
Replies: 5
Views: 252
Posted By ptmcg
You could create a class that implements __call__...

You could create a class that implements __call__ that takes all of the methods and calls them in turn. Here's a version that returns all of the return values in a list, unless an exception is...
Forum: Python Feb 18th, 2007, 10:43 AM
Replies: 9
Views: 531
Posted By ptmcg
I felt a little disoriented at the beginning,...

I felt a little disoriented at the beginning, maybe you need a clearer intro on what you are about to tutor and to whom. Once you got going, the meat of your tutorial looks very clear and helpful. ...
Forum: Python Jan 31st, 2007, 5:34 AM
Replies: 18
Views: 515
Posted By ptmcg
Just a couple more examples: fica =...

Just a couple more examples:

fica = Percent(7)
fedtax = Percent(15)
medicare = Percent(3)
deductions = fica + fedtax + medicare
gross = 100000
net = gross - deductions
print net # answer: 75000
Forum: Python Jan 30th, 2007, 5:55 PM
Replies: 18
Views: 515
Posted By ptmcg
Well, once you get the class junk out of the way,...

Well, once you get the class junk out of the way, I'd say this is pretty short/elegant, certainly more along the lines of what the OP was looking for.

discount = Percent(20)
origprice =...
Forum: Python Jan 30th, 2007, 9:52 AM
Replies: 18
Views: 515
Posted By ptmcg
A Percent class for doing percentage arithmetic

Python's ability to emulate numeric types makes it easy to "extend" Python with some interesting behavior. Here's a Percent class that allows you to write code like: saleprice = origprice -...
Forum: Python Jun 20th, 2006, 11:28 PM
Replies: 12
Views: 315
Posted By ptmcg
Sorry you don't find the pyparsing docs to be...

Sorry you don't find the pyparsing docs to be more helpful. I've put more effort into code examples (I think there are about 20 examples now), based on experience that programmers generally prefer...
Showing results 1 to 15 of 15

 
Forum Jump



DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:22 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC