Re: Create new instance of Python class in C

2005-09-09 Thread djw
Sybren Stuvel wrote:
 Hi people,
 
 I'm creating a program that can solve and create Sudoku puzzles. My
 creation function needs to make a lot of copies of a puzzle. Until
 now, I used copy.deepcopy(), but that's too slow. I want to implement
 such a copying function in C and use that instead. My idea about this
 is:
 
 - Get the data from a puzzle (a list containing lists containing
   strings) and make a copy of it. That's coded already.
 
 - Create a new SodokuPuzzle instance and assign the data to it.
 
 That last step can be done by passing the data to the constructor, so
 that's easy too once I know how to do that in C. My question is: how
 do I create a new instance in C of a class written in Python? I've
 searched Google, but found nothing of help.
 
 Sybren
Personally, I would try Psyco first, and consider Pyrex next. Are you 
sure your algorithm can't be optimized first, before you start trying to 
write this in C?

-Don
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Pythoneers reinvent the wheel?

2005-09-09 Thread djw
Stefano Masini wrote:

 I don't know what's the ultimate problem, but I think there are 3 main 
 reasons:
 1) poor communication inside the community (mhm... arguable)
 2) lack of a rich standard library (I heard this more than once)
 3) python is such an easy language that the I'll do it myself evil
 side lying hidden inside each one of us comes up a little too often,
 and prevents from spending more time on research of what's available.
 

I think, for me, this most important reason is that the stdlib version 
of a module doesn't always completely fill the requirements of the 
project being worked on. That's certainly why I wrote my own, much 
simpler, logging module. In this case, its obvious that the original 
author of the stdlib logging module had different ideas about how 
straightforward and simple a logging module should be. To me, this just 
demonstrates how difficult it is to write good library code - it has to 
try and be everything to everybody without becoming overly general, 
abstract, or bloated.

-Don
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Printer List from CUPS

2005-09-08 Thread djw
Mike Tammerman wrote:
 Hi,
 
 I want to get the printer list from CUPS. I found some ways using
 
 lpstat -p and
 http://localhost:631/printers
 
 but, these ways require some parsing and I am not sure, if the parsing
 works all the time. A pythonic way would be very helpful.
 
 Thanks,
 Mike
 

The HPLIP project (hpinkjet.sf.net) includes a basic CUPS extension 
module in the src/prnt/cupsext directory. Its pretty rough, but it will 
return a list of CUPS printers easily enough. I am in the process of 
rewriting it in Pyrex and hope to include more complete CUPS API coverage.

-Don
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling a python function from C++

2005-05-09 Thread djw
[EMAIL PROTECTED] wrote:
 Let's say I have a python function do some math like the following:
 
 def doMath(self):
self.val = self.val + 1
 
 
 How can I call this python function from C++? Assuming I have some sort
 of Python wrapper around my C++ codes.
 

Elmer?

http://elmer.sourceforge.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyvm -- faster python

2005-05-09 Thread djw
Paul Rubin wrote:
 Stelios Xanthakis [EMAIL PROTECTED] writes:
 
- The demo is an x86/linux binary only. You shouldn't trust binaries,
   run it in a chrooted environment not as root!
 
 
 Are you going to release the source?  If not, it's a lot less interesting.

 From the website:

...the source will be released when it becomes more complete and stable.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Comparision of GUI framworks

2005-05-02 Thread djw
Florian Lindner wrote:
 Hello,
 I've read the chapter in the Python documentation, but I'm interested in a a
 more in-depth comparision. Especially regarding how pythonic it is and how
 well it performs and looks under Windows.
 I've some C++ experiences with Qt, so I'm very interested to have PyQt
 compared to wxWindows and Tk. How fast does PyQt catches up with the
 versiones released from Trolltech? etc..
 
 Thx,
 Florian
I would ask this question on the pyqt/pykde mailing list... but, for 
what's its worth, I've been using PyQt (on Linux) for  4 years, and am 
very happy with it. I find it very Pythonic. When I first started 
looking at UI toolkits, the decision came down to wx vs. Qt. I found wx 
a bit more complex and cryptic and less OO than Qt. Also, I find Qt 
Designer + Eric to be a nicer development environment than Boa 
Constructor. The main problem with Qt is apparently licensing issues on 
Windows... I can't comment since I only use PyQt/Qt on Linux.

-Don
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which IDE is recommended?

2005-04-27 Thread djw
monkey wrote:
Read through python site for programming tool, really plenty of choices :-)
(For c++, I just can't breath with very very limited choices)
Tried Spe, it come with wxGlade built-in very nice(is Spe still actively
develop?). But seem that Boa Constructor and PyDev(the plug-in for Eclipse)
also worth looking. Actually which one are you guys using? and why? I think
it is also valuable for those who are new to python as me.

Eric3 for big stuff.
SciTE for small stuff.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Regular Expressions - Python vs Perl

2005-04-21 Thread djw
Thomas Bartkus wrote:
codecraig [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
snip
Well so far from what I have found, Perl is faster than Python for
RegEx, although perl is harder to read.

Yawn
How about Python being easier to *write*?
It never ceases to amaze me.  It takes days, weeks, months, sometimes even
years to write significantly useful software.  And yet so many seem to think
it is worthy to bother over the seconds that might be saved at execution
time.
If one were to achieve a mere percentage point or two in improving the
write efficiency of software - think how much more the world gains in
software quality and quantity.  How about man hours saved?  Why does anyone
still waste so much angst over execution speed?
I doubt the total execution time for all the RegEx queries you ever ran took
as much time as you just wasted on your little experiment.
Thomas Bartkus

While I agree with (most of) your points, one should not overlook the 
fact that there are cases when performance does matter (huge datasets 
maybe?). Since the OP didn't indicate why performance was important to 
him/her, one cannot assume that its not a valid concern.

-Don
--
http://mail.python.org/mailman/listinfo/python-list


Re: Refactoring in Python.

2005-04-19 Thread djw
Skip Montanaro wrote:
Peter I am trying to write Master Thesis on refactoring Python code.
Peter Where should I look for information?
I'm not sure, but one piece of code to check out would probably be Bicycle
Repair Man, a early-stage prototype refactoring tool for Python.  I don't
recall where it's hosted.  Google will know.
Skip
If you install Eric3, its included.
-Don
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python's use in RAD

2005-04-15 Thread djw
Ross Cowie wrote:
Hi,
I am currenly a second year university student and was wondering if you 
could help me ut. As part of a project i have decided to write about 
python, i am not having very much luck with regards to finding 
infrmation on pythons use in Rapid Application Development, and was 
wondering of you could highlight some of the features that make it 
suitable for RAD. Like the use of dinamic binding.

Your healp would be appreciated.
Hope to hear from you soon.
Ross

I got plenty of info in  1 min using Google and the query python rad. 
Does your university not have access to Google?

http://www.ukuug.org/events/linux2001/papers/html/CEgli/Gnome-Talk.html
http://www.iol.ie/~padraiga/talks/pygtk/
http://www.linuxjournal.com/article/7421
http://pythonnotes.blogspot.com/2005/03/rad-style-programming-for-web-apps.html
http://www.pythonology.com/successstory=philips
http://librenix.com/?inode=3701
http://linuxgazette.net/issue78/krishnakumar.html
http://www.pycs.net/lateral/stories/16.html
http://dot.kde.org/1073680602/
etc...etc...etc...
--
http://mail.python.org/mailman/listinfo/python-list


PyZeroConf Question

2005-03-17 Thread djw
AMK, thanks for your work on PyZeroConf!
Using PyZeroConf 0.12.
I'm seeing an issue with the Browser.py code. I am scanning for printers 
using:

type = _pdl-datastream._tcp.local.
The list of printers is returned, but every call to getServiceInfo() in 
the Listener objectresults in a timeout and None being returned.

I am not trying to publish any services, just discovery.
Also, at the end of the list, the code seems to hang.
Any ideas?
Thanks,
Don
--
http://mail.python.org/mailman/listinfo/python-list


Exception handling code (try/except/finally)

2005-03-07 Thread djw
c.l.p-
I am having trouble understanding how one is supposed to correctly 
utilize try:...except:...finally: in real code. If I have a block of 
code like:

def foo():
try:
... some code that can raise an exception ...
finally:
... do some cleanup ...
return something
If any exception occurs in the code inside the try:...finally:, it will 
fail silently, which is a bad thing.

So, the obvious thing to do (I think) is:
def foo():
try:
try:
... some code that can raise an exception ...
except someerror:
... handle the error...
finally:
... do some cleanup ...
return something
But, now the finally doesn't really serve any purpose, if all the 
exceptions are handled by except:, finally will never be called as a 
result of an exception, only as the last statements of the function.

So, the next step is to do this?
def foo():
try:
try:
... some code that can raise an exception ...
except someerror:
... handle the error...
raise someerror
finally:
... do some cleanup ...
return something
Which, I guess will work, but it feels very awkward. Is this the 
preferred/correct way to handle this? Is there a more elegant solution?

Also, why is this construct not possible?:
try:
... some code that can raise an exception ...
except someerror:
... handle the error...
finally:
... do cleanup, etc. ...
Thanks,
Don

--
http://mail.python.org/mailman/listinfo/python-list


Re: PyQt documentation

2005-02-11 Thread djw
Eric Jardim wrote:
Hi,
Is there any site that gather all the documentation about PyQt?
The docs of the Riverbank site is poor, and I have found separate
tutorials on the net.
I know that the Kompany have made a Qtdoc-like to PyQt. But it is not
free doc.
Does anybody know anything about any project for making PyQt
development more easy?
thanks,
[Eric Jardim]
If you follow a few simple rules, you can use the C++ Qt docs as-is:
1. Replace ::'s with .'s
2. Replace -'s with .'s
3. Access to things like .text member variables have to be done with .text()
4. .exec() becomes .exec_loop()
5. Follow the PyQt instructions on how to do signals and slots with 
connect()
6. Convert QStrings with str() from Qt functions/methods if you want to 
work with them with std. Python string functions

I'm sure there's a few more, but those are the main ones. Its actually 
very easy to convert in your head as you go to the proper Pythonic usage 
of Qt.

-Don
--
http://mail.python.org/mailman/listinfo/python-list


Re: what would you like to see in a 2nd edition Nutshell?

2004-12-29 Thread djw

I found the discussion of unicode, in any python book I have, insufficient.
Thomas

+1
Don
--
http://mail.python.org/mailman/listinfo/python-list