Re: I need an idea for practise!
On 7/17/14, 12:30 PM, Rick Johnson wrote: You know, you would fit in nicely in the American public school system, since American teachers are not only free of the requirement of teaching, they are actually*COMPELLED* not to do so by the greedy unions. Hi Rick, I know a lot of American public school teachers, and they are among the hardest-working people I've ever encountered. I have no clue what you mean about them being free of the requirement to teach. Do you find that insulting people achieves your goals? Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: What should i do
On 6/27/14, 2:19 AM, suburb4nfi...@gmail.com wrote: Hello I finished the codeacademy python course a week ago and my goal is to start developing websites (both back and front end) ,my question is do i start the web dev tuts and learn the holes of knoledge on the go or continue to learn python? In my opinion if you want to start developing both front and backend of websites, then you should start developing a full-stack web application. You'll stumble and have to redo things along the way, but there's no better way to learn. 1) Get a Linux host with root access, like from Rackspace cloud. You are only charged while it is switched on. If you leave it on for a month you'll owe maybe $16. 2) Install python, virtualenv, pip, and a web framework. Starting with flask would be an excellent choice. 3) Install a database backend. Starting with PostgreSQL would be an excellent choice. 4) Implement the polling app from the Django tutorial, or maybe you have your own idea of a simple app to make. 5) Learn CSS and throw in some javascript to make it pretty. 6) Push your commits to GitHub along the way. Do all of this and I can't promise how long it will take, but I can promise you'll be well on your way to becoming a strong web developer. Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: What should i do
On 6/27/14, 11:12 AM, alister wrote: On Fri, 27 Jun 2014 08:18:24 -0700, Paul McNett wrote: On 6/27/14, 2:19 AM, suburb4nfi...@gmail.com wrote: Hello I finished the codeacademy python course a week ago and my goal is to start developing websites (both back and front end) ,my question is do i start the web dev tuts and learn the holes of knoledge on the go or continue to learn python? In my opinion if you want to start developing both front and backend of websites, then you should start developing a full-stack web application. You'll stumble and have to redo things along the way, but there's no better way to learn. 1) Get a Linux host with root access, like from Rackspace cloud. You are only charged while it is switched on. If you leave it on for a month you'll owe maybe $16. Better yet host internally on your own Linux box Even a Raspberry pi for £45 (inc case PSU sd card) could do this if you don't have a spare PC to use. you don't want a development system exposed to the public internet anyway (unless you want to become Nicos Mk 2) Well, that's part of the experience too. :) Seriously, set up the firewall to only allow port 80 from your address, etc. Installing VirtualBox and Ubuntu on your local system is probably the better way to go at first, agreed. Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: Not Responding When Dealing with Large Data
On 6/18/14, 10:20 AM, cutey Love wrote: I'm trying to read in 10 lines of text, use some functions to edit them and then return a new list. How is it that you are opening the file, and iterating the contents? The problem is my program always goes not responding when the amount of lines are a high number. What do you mean, goes not responding? What environment are you running in? Windows and IDLE? I don't care how long the program takes to work, just need it to stop crashing? Note that not responding isn't the same as crashing. If your program crashed, it would likely print on your terminal something like: Traceback (most recent call last): ... lots of lines including useful information about the problem or Segmentation Fault If it just goes not responding for a while in your tight loop, it could simply mean just that: your IDE or whatever is focusing so hard on running your program that there aren't any cycles to say still here to the OS, so the OS has no clue what's going on and says to the user not responding. Have you waited to see if it ever completes? Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: Generate Single PowerPoint from two powerpoints using pywin32(python)
On 6/16/14, 11:20 PM, Jaydeep Patil wrote: I have two powerpoints, which consists of images in each slide. I need to read each powerpoint, copy images from both powerpoint paste these images into output powerpoint side by side. How should i do thism using python? The repoisition of shapes seems to be difficult. This seems like the wrong forum to ask this. Whatever the right Powerpoint calls are to accomplish this, it has nothing to do with Python. Well, you are making the calls via Python but the content of the calls aren't python. Back in the old days (it's been over a decade since I've worked with Microsoft Office using COM automation) when I needed to figure out how to programatically manipulate a Powerpoint slide or Excel spreadsheet, my general flow was: 1) turn on the macro recorder in Office. 2) do the operation that needs doing, using the Office UI. 3) save the macro. 4) set up the situation again, and this time play back the macro to make sure it works. 5) convert the macro code into whatever is needed in the client programming language (usually just wrapping the actual macro lines of code into strings passed using a pywin32 function) 6) test running the situation with the calling client programming language. Frankly, I'm not sure COM automation is the current way to interact with Microsoft stuff, but surely by querying other forums (Microsoft Office automation forums should exist, I'd think) on how to do #1-3 above would get you halfway. Then you could ask here about how to use pywin32 (or whatever) to communicate with Powerpoint to do the work. Does that make sense? Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: Not Responding When Dealing with Large Data
On 6/18/14, 3:32 PM, cutey Love wrote: Hi, thanks for the replies, I mean windows displays Not responding close the program now How can I do it asynconistrically? It's simple code just open file, loop through line by line and do some comparons with the string. To get anything better from us than we've already given, you must tell us your environment and show us some code. Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Fails to Write to File
On 6/18/14, 4:03 PM, cutey Love wrote: I'm trying to write data to a text file But I'm getting the error: TypeError: invalid file: _io.TextIOWrapper Always better to err on posting too much context (the entire traceback) than too little. Code is def saveFile(): file_path = filedialog.asksaveasfile(mode='w', filetypes=[('text files', '.txt')], defaultextension=.txt) fo = open(file_path, 'w') I used Google (searched on filedialog.asksaveasfile) to realize that you are likely using Tkinter. I then used Google to find out the API for filedialog.asksaveasfile() and I found that it returns the ALREADY OPEN FILE for you to write to, not the name of the file you are writing to. Referring to that same documentation, I see there's another function you are probably more interested in: filedialog.asksaveasfilename(). Then, you can open the file, write to it, and close it and be in control of every step. Not sure which is preferable, though, as I have no (recent) Tkinter experience. for e in myList: fo.write(e) fo.close() You should use a context manager to open, write to, and close files. Such as: with open(file_path, 'w') as fo: for e in myList: fo.write(e) The file is being created if not already present but no data is written filedialog.asksaveasfile() was opening it for you. It was being closed automatically when file_path fell out of scope (after the exception caused by your fo = open(file_path, 'w') line. My response was intended to help. Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: Suds and Python3
On 5/31/14, 11:36 AM, tokib...@gmail.com wrote: Suds is defacto python SOAP client, but it does not mainte recent few years. Why? Is it really the defacto? It seems like I've heard more about pysimplesoap, and looking at GitHub there have been commits in the past 4 days. As far as why it hasn't been maintained, you could write and ask the authors directly. In general, SOAP has been falling out of favor over the past half decade at least because of its relative heaviness next to, e.g. RESTful web services usually using JSON instead of XML. Way, way simpler and more fun to do. That said, SOAP will be around for a long time and if you need to do it, you want a good library for it. I don't have direct experience, but I did do cursory reviews of a handful of the SOAP libaries listed here in the python wiki: https://wiki.python.org/moin/WebServices And from what I can tell without actually trying any of them, pysimplesoap feels like the best option currently. I want to use SOAP and Python3. How do it? If it were me, I'd install each of the libraries listed on the wiki page and make a matrix of features desired, make up a suite of unit tests to test those features, and then run each of them through the suite to see how they stack up. Also consider how alive the project is, and how the project's bug tracker is maintained, look at their forum, etc. Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: Script suddenly stops
On 5/29/14, 7:47 PM, Chris wrote: I'm trying to read ten 200 MB textfiles into a MySQL MyISAM database (Linux, ext4). The script output is suddenly stopping, while the Python process is still running (or should I say sleeping?). It's not in top, but in ps visible. Does it stop in the same place every time? How long are you waiting before giving up? Is it at all possible that it is the MySQL side that is blocking? Why is it stopping? Is there a way to make it continue, without calling kill -9, deleting the processed lines and starting it again? One thing to try (maybe, depending on whether it still fits into your requirements for a database transaction) is to increase the number of rows inserted before each commit. [1] http://pastebin.com/CxHCA9eB It won't have any bearing, but those globals aren't necessary... Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: Challenge: Please break this! [Python Security]
tav wrote: I'm keen to know your experiences even if you don't manage to write to the filesystem -- and especially if you do! Does it count when it breaks some standard libs that aren't even trying to write to the filesystem? mac:ss pmcnett$ python sbs_studio.py pkm Traceback (most recent call last): File sbs_studio.py, line 159, in module main() File sbs_studio.py, line 15, in main parser = OptionParser() File /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/optparse.py, line 1191, in __init__ self.set_usage(usage) File /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/optparse.py, line 1266, in set_usage self.usage = _(%prog [options]) File /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/gettext.py, line 566, in gettext return dgettext(_current_domain, message) File /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/gettext.py, line 530, in dgettext codeset=_localecodesets.get(domain)) File /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/gettext.py, line 465, in translation mofiles = find(domain, localedir, languages, all=1) File /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/gettext.py, line 437, in find for nelang in _expand_lang(lang): File /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/gettext.py, line 131, in _expand_lang from locale import normalize ImportError: cannot import name normalize Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Unexpected scientific notation
Mark Dickinson wrote: On Jan 8, 1:00 am, Paul McNett p...@ulmcnett.com wrote: It displays '3E+1' instead of '30.0'. As I can't reproduce I'm looking for an idea brainstorm of what could be causing this. What would be choosing to display such a normal number in scientific notation? Ideas? [I thought I replied to this earlier, but the post isn't showing up. So here it is again.] LOL! I suspect it's your use of the Decimal normalize() method that's causing this. Trailing zeros on Decimal instances are significant, so Decimal('30.0'), Decimal('30') and Decimal('3E+1') are considered distinct (though they all have the same value). The normalize method strips all trailing zeros, turning Decimal('30.0') into Decimal('3E +1'). One way to get around this is to add 0 after normalizing: this will make sure that scientific notation is used only for very large or small numbers, as usual. Thank you for the insight. I believe the problem is with my use of normalize(), but I still can't figure out why I can't reproduce the issue in my running app. But I can see in the interpreter that printing Decimal(30.0).normalize() results in 3E+1. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Unexpected scientific notation
Paul McNett wrote: Mark Dickinson wrote: On Jan 8, 1:00 am, Paul McNett p...@ulmcnett.com wrote: It displays '3E+1' instead of '30.0'. As I can't reproduce I'm looking for an idea brainstorm of what could be causing this. What would be choosing to display such a normal number in scientific notation? Ideas? [I thought I replied to this earlier, but the post isn't showing up. So here it is again.] LOL! I'll clarify my LOL: Mark initially replied to me directly, to which I responded directly. Because he replied directly, I kept my response offline, too, not knowing if he had a special reason to discuss this offline instead of in public. Then he replied to the list, so I made a different response to the list. Anyway, thanks again Mark for your guidance. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Replying to list messages
Ben Finney wrote: Paul McNett p...@ulmcnett.com writes: But arguing about this here isn't going to change anything: opinions differ just like tabs/spaces and bottom-post/top-post. In cases like this, one side can simply be wrong :-) Best of luck getting your programs behaving as you want them to! BTW, I agree with you that in an ideal, pure world mailing lists wouldn't munge the reply-to field, but when 80% of the people use email clients that don't support reply-list, the practical thing to do as a list admin that wants to avoid having to explain over and over again that your client software is broken is to simply swallow some pride and munge the reply-to. Now, 99% of the users are happy, and the remaining 1% are elite enough to understand how to get around any problems this caused. Happy is good. Paul -- http://mail.python.org/mailman/listinfo/python-list
Unexpected scientific notation
One of my users has reported that my app is giving them scientific notation instead of decimal notation for one specific value among many that display properly. I am unable to reproduce on my end, and this is the first I've heard of anything like this since the app's launch 2 years ago. The app bundles python 2.5.2 using py2exe. It displays '3E+1' instead of '30.0'. As I can't reproduce I'm looking for an idea brainstorm of what could be causing this. What would be choosing to display such a normal number in scientific notation? Ideas? Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Unexpected scientific notation
Robert Kern wrote: Paul McNett wrote: One of my users has reported that my app is giving them scientific notation instead of decimal notation for one specific value among many that display properly. I am unable to reproduce on my end, and this is the first I've heard of anything like this since the app's launch 2 years ago. The app bundles python 2.5.2 using py2exe. It displays '3E+1' instead of '30.0'. As I can't reproduce I'm looking for an idea brainstorm of what could be causing this. What would be choosing to display such a normal number in scientific notation? Ideas? Locales? Do you at last know the code that's responsible for formatting the number? I do use locale.format, but I use it for all numbers, and only one such number displays in scientific notation - the rest are fine. Here's the code: 1355 def uom_string(self, val): 1356 Given a decimal value, format it for string display. 1357 if self.unit_of_measure == inches: 1358 fd = dabo.dAppRef.getSSPref(fraction_display) 1359 if fd == decimal: 1360 return '%s' % locale.format(%.5f, val.normalize(), True) 1361 else: 1362 return '%s' % fractions.getImperial(val) 1363 elif self.unit_of_measure == millimeters: 1364 #return u%s\u339C % self.uom_round(val) 1365 return %smm % locale.format(%.1f, self.uom_round(val), True) 1366 else: 1367 raise ValueError, Unit of Measure '%s' not recognized. % self.unit_of_measure In this case, self.unit_of_measure == inches and fd == decimal. Thanks Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Unexpected scientific notation
[Some day hopefully I'll remember to change the to: address to python-list@python.org instead of the original sender. I always end up sending the first reply to the sender, then going oops, forgot to hit 'reply-all', and sending another copy to the list.] Ben Finney wrote: Paul McNett p...@ulmcnett.com writes: The app bundles python 2.5.2 using py2exe. It displays '3E+1' instead of '30.0'. As I can't reproduce I'm looking for an idea brainstorm of what could be causing this. What would be choosing to display such a normal number in scientific notation? As I understand it, the Python string formatting operations URL:http://docs.python.org/library/stdtypes.html#string-formatting use the operating system's C library to perform (some of?) the formatting. The different behaviours you see might therefore be caused by different C libraries in the operating system. To avoid these and related problems, I would avoid floating point wherever possible and use the ‘Decimal’ type for representing decimal numbers. Thanks. I forgot to mention that all numbers are already instances of decimal.Decimal, not float. As I mentioned in a prior message, they do go through a locale.format() call to display the value. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Replying to list messages
Ben Finney wrote: Paul McNett p...@ulmcnett.com writes: [Some day hopefully I'll remember to change the to: address to python-list@python.org instead of the original sender. Even better: Take full advantage of the standards-compliant messages from the list, by using the “Reply to list” function of your RFC 2369 compliant mail program. That way the message is sent to the declared list posting address, without you having to change anything. If your mail program still doesn't have such a function, over a decade since RFC 2369 was written, lobby the vendor to add it. Or, in the case of free software, act some way yourself (write code, pay someone else to do so, or some other action) to have that function added for everyone. I remember taking advantage of that in KMail, before that program became unusably bloated. For Thunderbird (which I see you're using, Paul), the open bug report is URL:https://bugzilla.mozilla.org/show_bug.cgi?id=45715. Meanwhile, you can install an add-on to provide the function URL:http://www.juergen-ernst.de/addons/replytolist.html. Thanks; I'll follow up with those. In general I don't tend to use add-ons because I have at least 3 computers I regularly use and it is a pain to keep them all configured consistently. I always end up sending the first reply to the sender, then going oops, forgot to hit reply-all', and sending another copy to the list.] At least that's merely a minor inconvenience; easily rectified by just sending the message again using the correct function. Yep. That's much better, of course, than the opposite situation which exists on some misconfigured mailing lists: that a message sent using the “Reply to sender” function, with content written in the knowledge that only the original message's sender should be reading it, instead ends up going to the mailing list. That damage can't be undone. Well, when you are a member of a public mailing list, replying to a thread, the expectation is that you are replying to the list, so I happen to think the correct behavior is the one you think is broken, because practicality beats purity. If I want to send a private message to someone, I'll start a new mail to that person, or simply copy/paste their email addy over the list address, but the most common case is that someone intends to reply to the list. But arguing about this here isn't going to change anything: opinions differ just like tabs/spaces and bottom-post/top-post. Thanks to the Python mailing list administrators for conforming to the standards and not breaking the configuration like that! Thanks to the Python mailing list volunteers for running such a well-oiled and popular list! Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Check file is
Colin J. Williams wrote: The ReportLab toolkit appears to be concerned with building Portable Document Files. I would be interested in any utility which will read any pdf - for example, to convert pdf - html I don't know of any Python utility to do this, but pdftohtml, pdftotext, pdftoppm, and pdftops exist on my Ubuntu Linux system. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Building musical chords starting from (a lot of) rules
Mr.SpOOn wrote: Anyway, I think I can use a chain of if-clauses, one per rule and at the end remove the notes marked with no. But this seems to me a very bad solution, not so pythonic. Before I proceed for this way, do you have any suggestion? Hope the problem is not too complicated. I say, start with what you can think of (the chain of if clauses). Get it working. Then, you'll likely find ways to refactor if needed. Get it working first. Make it right iteratively over time. At least that's what I do. And it works for me. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the perfect (OS independent) way of storing filepaths ?
Steven D'Aprano wrote: On Sun, 19 Oct 2008 20:50:46 +0200, Stef Mientki wrote: Duncan, in windows it's begin to become less common to store settings in DocsSettings, because these directories are destroyed by roaming profiles The directories aren't destroyed by roaming profiles. When the user logs out, they get copied to the server. When they log in at a different machine, they get copied to the workstation. So configuration information saved in c:\Documents and Settings\pmcnett\Application Data\My Application gets conveniently migrated from machine to machine where I happen to login. A really nice feature. Isn't *everything* destroyed by roaming profiles? *wink* I've heard such bashing of roaming profiles but I've never had anything but love for them. That is, until people go and start saving their movies and pictures in My Documents. Which is why I set their home directory to a server share and have them save their docs there. Seriously, I don't know anyone who has anything nice to say about roaming profiles. I loathe Windows, but roaming profiles was one thing they did (mostly) right. I couldn't be happy in a world that didn't include roaming profiles. Perhaps I'm not seeing the worst of it as I use Samba on Linux as the PDC? Anyway, on Windows user configuration information should go in the user's Application Data directory. If you don't want it to roam, you can instead put it in the (hidden) Local Settings/Application Data directory. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: [1,2,3] exactly same as [1,2,3,] ?
Steven D'Aprano wrote: On Thu, 28 Aug 2008 16:28:03 -0700, Paul McNett wrote: [EMAIL PROTECTED] wrote: x=[1,2,3] and x=[1,2,3,] are exactly the same, right? When confronted with this type of question, I ask the interpreter: {{{ mac:~ pmcnett$ python Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin Type help, copyright, credits or license for more information. [1,2,3] == [1,2,3,] True }}} Putting on my pedantic hat... In this case you're right about the two lists being the same, and I'm a great believer in checking things in the interactive interpreter, but you need to take care. Just because two objects compare as equal doesn't *necessarily* mean they are the same: True. 1.0 == 1 True 1.0 == decimal.Decimal('1.0') False 1.0 == float(decimal.Decimal('1.0')) True These are comparing different types. collections.defaultdict(999) == {} True I try this and get: TypeError: first arument must be callable Paul -- http://mail.python.org/mailman/listinfo/python-list
ctypes version mismatch
Anyone have anything to suggest on this error: {{{ Traceback (most recent call last): File shutter_studio.py, line 41, in module File App.pyo, line 25, in module File ui\__init__.pyo, line 23, in module File ui\FrmProductionOrders.pyo, line 10, in module File ui\PagEditProductionOrders.pyo, line 8, in module File ui\GrdProductionOrderOpenings.pyo, line 5, in module File ui\DlgEditProductionOrderOpening.pyo, line 17, in module File ui\ShutterCanvas.pyo, line 9, in module File wx\lib\floatcanvas\FloatCanvas.pyo, line 6, in module File numpy\__init__.pyo, line 46, in module File numpy\ctypeslib.pyo, line 9, in module File ctypes\__init__.pyo, line 20, in module Exception: ('Version number mismatch', '1.0.2', '1.0.3') }}} I just updated from python 2.5.1 to 2.5.2, and wxPython 2.8.7.1 to 2.8.8.1. The issue is only in the py2exe-built app, not when running the script from the command line. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes version mismatch
Thomas Heller wrote: Paul McNett schrieb: Anyone have anything to suggest on this error: {{{ Traceback (most recent call last): File shutter_studio.py, line 41, in module File App.pyo, line 25, in module File ui\__init__.pyo, line 23, in module File ui\FrmProductionOrders.pyo, line 10, in module File ui\PagEditProductionOrders.pyo, line 8, in module File ui\GrdProductionOrderOpenings.pyo, line 5, in module File ui\DlgEditProductionOrderOpening.pyo, line 17, in module File ui\ShutterCanvas.pyo, line 9, in module File wx\lib\floatcanvas\FloatCanvas.pyo, line 6, in module File numpy\__init__.pyo, line 46, in module File numpy\ctypeslib.pyo, line 9, in module File ctypes\__init__.pyo, line 20, in module Exception: ('Version number mismatch', '1.0.2', '1.0.3') }}} I just updated from python 2.5.1 to 2.5.2, and wxPython 2.8.7.1 to 2.8.8.1. The issue is only in the py2exe-built app, not when running the script from the command line. I guess you should remove the build and dist directories and rebuild your app - this is always a good idea when something goes wrong, not only after upgrading Python or Python packages. Thanks for responding (and thanks for starting py2exe!). Yes, my build script always wipes out the build and dist directories first. The problem turned out to be (it was right there in the traceback, but I glossed over it at first) that numpy includes their own ctypeslib, and *that* version was 1.0.2. Now, I'm still not sure why it mattered in the exe but not running just the script, but upgrading numpy resolved the issue. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: [1,2,3] exactly same as [1,2,3,] ?
[EMAIL PROTECTED] wrote: x=[1,2,3] and x=[1,2,3,] are exactly the same, right? When confronted with this type of question, I ask the interpreter: {{{ mac:~ pmcnett$ python Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin Type help, copyright, credits or license for more information. [1,2,3] == [1,2,3,] True }}} Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: [1,2,3] exactly same as [1,2,3,] ?
James Mills wrote: I must point out though that although they contain the same elements/data, they are not the same object/instance. True, but the OP wanted equality: I want to be sure I'm generating an equivalent data structure. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: How to figure out if the platform is 32bit or 64bit?
Gary Josack wrote: Trent Mick wrote: Manuel Vazquez Acosta wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Just test for maxint value: from sys import maxint if maxint 33: print more than 32 bits # probably 64 else: print 32 bits I believe that was already suggested in this thread. That test will just tell you if the Python *build* is 32-bit or 64-bit. If the answer is 32-bit, then that doesn't tell you if this is a 32-bit Python running on a 64-bit OS. Trent have you tried platform.architecture()? I just tried it: WindowsXP in Parallels Desktop: ('32bit', 'WindowsPE') Ubuntu 7.10 in Parallels Desktop: ('32bit', '') Ubuntu 8.04 on a AMD64 Machine: ('64bit', '') Mac 10.4 on a Intel64 Machine: ('32bit', '') All look correct except for Mac. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython: How can I get window's HANDLE in wxPython.
Leo Lee wrote: I need a window's handle to be passed to external c++. Thanks in advance import wx help(wx.Window.GetHandle) GetHandle(*args, **kwargs) unbound wx._core.Window method GetHandle(self) - long Returns the platform-specific handle (as a long integer) of the physical window. On wxMSW this is the win32 window handle, on wxGTK it is the XWindow ID, and on wxMac it is the ControlRef. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: [Employment] New TurboGears Job in Eugene, OR
Silas Snider wrote: Full-time academic year position Salary range: $2819 - $4404 per month ( $16.26 - $25.41 per hour) The following knowledge, skills and experience are necessary for this position: Expert Python and SQL programming skills, and proficiency with Javascript, CSS, XHTML and web standards. Professional experience with open source projects, ideally using Turbogears and MySQL. Experience with Mac OSX Server or other server administration. Familiarity with version control. Skills using on-line documentation for open source packages. Wide knowledge of open-source software and ability to find, evaluate, learn and implement new open source technologies. They want an expert for a maximum of $25 per hour? If they find someone, it'll be a pretty good bullshitter looking for experience. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Making wxPython a standard module?
Grant Edwards wrote: On 2008-06-14, Torsten Bronger [EMAIL PROTECTED] wrote: I've never used any of the designers, but I agree 100% that wxPython code is nasty ugly. wxPython has a very un-Pythonic API that's is, IMO, difficult to use. I know that such requests may start a never-ending thread but I'd really like to know what you mean with this. [...] Well, if we want this thread to be never ending, I'd better put a little dramatic hyperbole into my answer, so here goes... ;) (blatant self-promotion warning: I'm one of the founders of Dabo, and it sounds like you may like to take a look at it, given your comments below) IMO, a few of the un-Pythonic things about wxPython are: 1) Window ID numbers. You don't need to know what it's for, just pass a -1. Their very existence at the user level feels wrong. I'm told that for approximately 3 uber-sophisticated wxWidgets programmers window IDs can be useful in some rare situations. Meanwhile everybody else working under normal conditions has to pass a useless positional parameter every time they instantiate a widget. Things that are useful only in exceptional situations should only be visible in exception situations. Dabo is a nice wrapper around wxPython, which among other things does away with id numbers. There are a few places (wxMenu events, for one) where you need to deal with window id's, but Dabo doesn't expose the user to that, it handles it the way it should work. 2) the flags parameter. 1975 called, and they want their bit-masks back. The mashing together of a several dozen different, completely unrelated attributes into the flags parameter is a trick left over from C/assembly language programming on machines who's memory size was measure in KB. Rather than OR-ing together a bunch of bit-patterns to make the window act the way you want, you should be setting individually named object attributes or passing optional, named parameters to the class method. Dabo uses properties for everything, including the individual style bits. And it handles making the setting in the right place so it just works without the user needing to know, for instance, that flag x only works after the class is fully instantiated, or vice-versa. Properties can be set on the object once instantiated, sent to the constructor, or set in a subclass: # create a textbox by instantiating the baseclass # and sending property values to the constructor: txt = dabo.ui.dTextBox(self, Value=Hello, FontBold=True) # tweak some other properties: txt.FontItalic = True txt.BackColor = yellow 3) the parent/child tree the only thing less well understood than Window IDs I've been writing wxPython apps for about 9 years now, and I still have only a very vague idea what the parent/child tree is for. Everybody I know just makes everything the child of the first panel they put in the application frame. The same people who specify Window IDs other than -1 probably use complex parent/child trees for something. Every container object needs to know about its children, and every object needs to know about its parent. So, in Dabo we have 2 properties: Children and Parent. 4) sizers they're like aspirin -- they work, but nobody knows exactly how OK, that's a bit out-of-date since I seem to recall that somebody did finally figure out how aspirin works a couple years back. The way sizers work seems pretty complex compared to other GUI toolkits I've used, and the extra complexity doesn't seem to provide any extra capability. The one thing that seems to me to be particular complicated is controlling which objects stretch in what axis when a window is resized. I've been using them for many years, but I've never gotten them more than about 90% figured out. Every time I write a wxPython apps, I'm initially surprised at its behavior when the window is resized and have to spend some trial-and-error time fiddling with the sizer parameters. I don't remember having to do that in tkInter or in Trestle: things just worked. Sizers are admittedly a bit complex in Dabo, too. Or, sizers aren't complex, but the code that creates them gets pretty wordy pretty fast. vs = dabo.ui.dSizer(v) hs = dabo.ui.dSizer(h) hs.append(dabo.ui.dLabel(self, Caption=Name:)) hs.append(dabo.ui.dTextBox(self)) vs.append(hs) 5) binding What? you wanted a button that _did_ something when you clicked it? Binding has actually improved a bit in the past few years. It's not as obscure as it used to be, but it's still an extra explicit step that shouldn't be required. It should only take one line of code to create a button widget that calls a specified callable when it's clicked. Something like this: b = wx.Button(label=Click Me, action=myCallable) Instead you used to have to create a
Re: readlines with line number support?
Nikhil wrote: I am reading a file with readlines method of the filepointer object returned by the open function. Along with reading the lines, I also need to know which line number of the file is read in the loop everytime. I am sure, the line should have the property/attribute which will say the line number of the file. If there is none, do I have to end up using the counter in the loop? fp = open(file, r) lineno = 0 for line in fp.readlines(): print line number: + lineno + : + line.rstrip() lineno = lineno + 1 Untested: for lineno, line in enumerate(open(file)): print line number: %s : %s % (idx, line.rstrip()) Note the other stylistic changes, too. HTH. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is None = 0
Gregor Horvath wrote: None = 0 True More accurately: None 0 True Why? Is there a logical reason? None is less than everything except for itself: None 'a' True None False True None == None True In my humble opinion, I think that comparisons involving None should return None, but I trust that the designers came up with this for very good reasons. As far as I know I've never been bitten by it. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: how to mysqldb dict cursors
Vaibhav.bhawsar wrote: I have been trying to get the DictCursor working with mysqldb module but can't seem to. I have pasted the basic connection code and the traceback from pydev. The connection does open with the default cursor class. can't figure this one out. many thanks. Try one of: import MySQLdb, MySQLdb.cursors conn = MySQLdb.connect(..., cursorclass=MySQLdb.cursors.DictCursor) -or- import MySQLdb, MySQLdb.cursors conn = MySQLdb.connect(...) cur = MySQLdb.cursors.DictCursor(conn) I'm going off of memory here, though, but I'm at least close. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: function that accepts any amount of arguments?
globalrev wrote: if i want a function that can take any amount of arguments how do i do? Put an asterisk before the argument name. lets say i want a function average that accepts any number of integers and returns the average. def avg(*args): return sum(args) / len(args) There are some dangers (at least two glaring ones) with this code, though, which I leave as an exercise for the reader. :) Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Pysqlite issue no attribute 'autocommit'
Andy Smith wrote: Im trying to run a Python based program which uses MySQL with python-sqlite and Im recieving this error, 'Connection' object has no attribute 'autocommit' I´ve had a google for this and its seems like it may be a bug python-sqlite or sqlite bug , but also I tried searching for it on the python issue traker and didnt find anything. Is anyone else aware of this issue and any solution? thanks for any help! Andy. PS sorry if I didnt include much info, hoping its a known issue (and also I didnt write the code, so not sure what else to include off the top of my head! :P) What you should do is post the entire traceback. Paul -- http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL linux err
dzizes wrote: I'm trying to run simple .py on linux, which is using PIL. Below error message which I receive: IOError: decoder jpeg not available Do you know what might be the problem? No, but google seems to: http://effbot.org/zone/pil-decoder-jpeg-not-available.htm Paul -- http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Terminology: script versus program
Steven D'Aprano wrote: Linux/Unix/Mac admins may be excused for saying that they've never come across a .BAT file at all. $ locate .bat | wc -l 14 $ locate .sh | wc -l 606 $ locate .bat | wc -l 115 $ locate .sh | wc -l 763 $ locate .py | wc -l 44030 Hmmm... that matched all the .pyo and .pyc files, too. Not fair. $ locate -r '\.py$' | wc -l 17425 $ locate -r '\.sh$' | wc -l 278 $ locate -r '\.bat$' | wc -l 49 Still a bit unbelievable, although I do have all the branches and tags checked out of my main projects, and I tend to make lots of little .py files so most of that 17,425 number is probably me. Paul -- http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: mac dashboad
Carl K wrote: Yes. But I don't want to rely on wx - trying to use just native mac python (whatever they ship with) Since OSX 10.4, Mac ships with wxPython installed. Paul -- http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: DBApi Question with MySQL
Hans Müller wrote: Hi, I'd like to modify some tables in a database in one transaction. This approach doesn't work: import MySQLdb con = MySQLdb.connect(servernam, user = username, passwd = verysecret, db = test, use_unicode = True, charset = utf8) cursor = con.cursor() con.begin() cursor.execute(delete from table) do-some-stuff and wait cursor.execute(insert into table value(%s, %s), (1, 2)) con.commit() When I look into the databse while the script is running, all rows from table are gone. The expected behavior would be to see the new lines only when the script is finished. The deletion should be (since inside a transaction) invisible up to the commit(). Has someone an idea how to use transactions correctly ? What I need is this start transaction delete a lot of date in some tables (about 2 million rows) insert a lot of new date in these tables (also about 2 million lines) commit all changes, so all changes become visible here and only here. Thanks a lot, Greetings Hans Quick questions before going any further: 1) What's the table type in MySQL: ISAM, INNO, or ? As you probably know MyISAM doesn't support transactions. 2) Is MySQL set to AutoCommit? Issue: cursor.execute(select @@autocomit) print cursor.fetchall() If so try sending: cursor.execute(set autocommit=0) ...and then doing the code you posted. Paul -- http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Copy database with python..
Abandoned wrote: Hi. I want to copy my database but python give me error when i use this command. cursor.execute(pg_dump mydata old.dump) What is the problem ? And how can i copy the database with python ? You are just going to have to give us more to go on. Please post the entire traceback of the error that you see (copy/paste it from your terminal). You can't issue system commands using the cursor's execute() method and expect that to work. execute() is for executing SQL, DML, or DDL, not for doing shell stuff. Try: import os os.system(pg_dump mydata /tmp/old.dump) but I'm not versed in postgressql, so this probably won't work exactly as written. You'd need to run that code from the server hosting the postgresql database. Note: The database's size is 200 GB Well, then you may want to make sure you have enough room on the target volume before trying to dump the file! Note that the dump file could conceivably be much larger (or much smaller) than the database itself. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: 3 number and dot..
Abandoned wrote: Hi.. I want to do this: for examle: 12332321 == 12.332.321 How can i do? Assuming that the dots are always in the 3rd and 7th position in the string: def conv(s, sep=.): l = [s[0:3], s[3:6], s[6:]] return sep.join(l) print conv(12332321) -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: 3 number and dot..
Abandoned wrote: On Oct 31, 10:18 pm, Paul McNett [EMAIL PROTECTED] wrote: Abandoned wrote: Hi.. I want to do this: for examle: 12332321 == 12.332.321 How can i do? Assuming that the dots are always in the 3rd and 7th position in the string: def conv(s, sep=.): l = [s[0:3], s[3:6], s[6:]] return sep.join(l) print conv(12332321) But it's starts from the end.. print conv(12332321) 123.323.21 This is wrong it would be 12.332.321 Ok, my slicing was off by one. Mea culpa. I leave it as an exercise to fix it. It is really easy, if you understand basic slicing in Python. If you don't understand slicing, you should google 'python slicing tutorial'. But, from the other messages in the thread it has become apparent that you are wanting to group by thousands (that wasn't at all clear in your initial message). Chris Mellon has given you the best response: use the locale module for this. Other people have done all the work for you, all you need to do is learn how to use locale to get what you want. It seems like you are looking for a spoonfed solution rather than looking for guidance on how to solve the problem for yourself. If I'm wrong about that assessment, I apologize in advance. Best regards and good luck with your project! Paul -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with format string / MySQL cursor
[EMAIL PROTECTED] wrote: On Oct 19, 7:32 am, Florian Lindner [EMAIL PROTECTED] wrote: Hello, I have a string: INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`, `gid`, `password`) VALUES (%s, %s, %s, %s, %i, %i, %s) that is passed to a MySQL cursor from MySQLdb: ret = cursor.execute(sql, paras) paras is: ('flindner', '[EMAIL PROTECTED]', '/home/flindner/', '/home/ flindner/Mail/test', 1001, 1001, '123') But that gives me an error: Traceback (most recent call last): File account.py, line 188, in ? main() File account.py, line 33, in main execute(action, account_type, options) File account.py, line 129, in execute executeSQL(sql, options.username, options.login, options.home, options.directory, options.uid, options.gid, options.password) File /home/flindner/common.py, line 29, in executeSQL ret = cursor.execute(sql, paras) File /usr/lib/python2.4/site-packages/MySQLdb/cursors.py, line 148, in execute query = query % db.literal(args) TypeError: int argument required I don't see errors in the format string or some other problem What's wrong? You should be using '?' for parameter bindings in your sql string not python format specifiers (you are after all writing sql here not python). INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`, `gid`, `password`) VALUES (?, ?, ?, ?, ?, ?, ?) Sorry Tim, but that isn't correct: import MySQLdb MySQLdb.paramstyle 'format' Florian, what happens when you replace your %i with %s? -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite and TemporaryFile under Windows
Matthieu Brucher wrote: If this is the way of using sqlite, it is still cumbersome as a lot of other classes that work on files can work on file-like (and isn't it the whole point of Python ;) ? I don't think that sqlite can work on streams, or on file-like objects. Obviously it cannot, but what are the reason it can't ? I have no idea. You could just save it as tempfile.mktemp(). I think the utility of this function in this case outweighs the possibility that your routine will coincidentally overwrite another file of the same name within the same fraction of a second. The warning is dire, but when you think about it in context it doesn't seem that bloody likely that there will be a problem. ;) Well, I could, but in this case I have to delete the file myself, which the whole point of the use of TemporaryFile. Go with the flow dude! Unless you want to solve the issue by delving in to the source for pysqlite yourself so that it can work on file-like object, the extra os.unlink call doesn't seem to be a big deal. Also, you are downloading the file off the Internet somewhere anyway. Either you work with that stream without creating a file (which we've already discovered isn't possible) or you save it to a file. Sure, it would be nice to use TemporaryFile(), but it shouldn't be a showstopper to use mktemp() an unlink() instead. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite and TemporaryFile under Windows
Matthieu Brucher wrote: I want to create a temporary database that is downloaded for the net. So I want to use a temporary file that will be deleted at the end of my program. For this, I wanted to use tempfile.TemporaryFile. The problem with Windows is that I can't give to sqlite3.connect() the file neither can I give its name (if I use NamedTemporaryFile). Is there a solution somewhere ? Are you aware that you can do an in-memory database (IOW no file at all)? cur = sqlite.connect(:memory:) -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite and TemporaryFile under Windows
Matthieu Brucher wrote: Are you aware that you can do an in-memory database (IOW no file at all)? cur = sqlite.connect (:memory:) Yes, but in this case, how can I use the DB that I downloaded from the net ? Ah, sorry, I guess I missed that part. If this is the way of using sqlite, it is still cumbersome as a lot of other classes that work on files can work on file-like (and isn't it the whole point of Python ;) ? I don't think that sqlite can work on streams, or on file-like objects. You could just save it as tempfile.mktemp(). I think the utility of this function in this case outweighs the possibility that your routine will coincidentally overwrite another file of the same name within the same fraction of a second. The warning is dire, but when you think about it in context it doesn't seem that bloody likely that there will be a problem. ;) -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there some sort of portable IDE?
Lamonte Harris wrote: Like say you don't got python installed, but you want to test code is there a way?(School) Like way, dude, check this out: http://www.portablepython.com/ -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you limit the # of lines Read?
[EMAIL PROTECTED] wrote: I am working on a loop for my code and was wondering if there is a way to limit the number of lines read through? I'd hate to cut the test file in order to run the code in the testing phase. Can you add a value in the parenthesis of the readline() function? t = string.readline() # Limit this somehow? Assuming s is a file-like object: for idx, line in enumerate(s): if idx 2: break print idx, line -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Cron
Greg Lindstrom wrote: This may be more of a Linux question, but I'm hoping some of you may be able to help me. I have a python (2.4) routine running on Gentoo Linux. It creates a file and, after the file is complete, renames the file using the os.rename() command. When I run the file from the command line everything works great, but when I schedule the job to run from the crontab file, the original file is created and populated, but the rename fails. I am using full paths for both the original and destination file, and run the command line version after I 'su' to the production account (named 'edith'). I am told by my sysadmin that the cron jobs run as edith as well, so he does not think it is a permission issue (he points out the original file is being created and populated as expected...the rename fails) Have any of you dealt with anything like this? It really has me scratching my head. Can you post the Python script? What's the name of the original file, and what are you trying to rename it to? I'm wondering if you are deriving the new name from something, and that thing is failing from within the cronjob for some reason. Perhaps the new name contains a complete path in one of the cases but not in the other... Edith should be getting email (if email routing is set up correctly) if the job is failing or producing output. Specifically, perhaps she's getting Python tracebacks and not telling you... :) -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Dealing with PayPal's messy SPF records
I administer email for a few clients of mine, using Postfix. One of the policies that is in place is SPF-checking, and rejecting messages accordingly. This has been working well for months. However, today a user called me to complain that they weren't able to get confirmed with PayPal to set up a new account. Turns out, SPF was rejecting the email from PayPal because of Too many DNS lookups. This was somewhat surprising as I had been expecting the problem to be with my greylisting setup. I took a look at PayPal's SPF structure and it is indeed a big mess - lots of includes, and those includes have lots of hosts and mx records, etc. I helped the user by temporarily disabling all SPF checking and then reenabling it after the user got confirmed, but I was wondering if there is an elegant way to tell postfix to ignore the going over MAX_LOOKUPS for (paypal.com,). I guess this would involve modifying policyd-spf.py? I took a look at the source spf.py, and see where these values are hardcoded, complete with references to the RFC, and I don't want to modify those hardcoded values. I also don't want to disable SPF as the final layer of policy checking on my mail server. But, I have to recognize that companies like PayPal are big players, and I'm probably not going to get them to budge by complaining, so I should try to accommodate their messy setups as much as possible, as my users are nearly always right. Anyone been down this road before and can offer tips/advice? I did google for relevant strings, but didn't come up with anything that appeared to address this specific problem. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Mouse control with ctypes in OS X
Niklas Ottosson wrote: I need to get hold of the mouse position and also need to be able to change it. In windows I have used ctypes.windll.user32.getCursorPos() and ctypes.windll.user32.setCursorPos() with great success in my program but now I also need to make a Mac OS X version of the program. Does anyone know what the above libraries and functions are called in OS X? Any help is greatly appreciated. All I can offer you is the knowledge that OS X will probably not let you set the mouse position, as it is a gross violation of the HIG (The user is in charge of where the mouse appears, not the application). But, I'm sure someone will chime in on how to get the mouse position. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Why PHP is so much more popular for web-development
Steve Holden wrote: When someone starts to push the limits of PHP they either continue to push until they get where they want to be (producing an ugly or ill-maintained bunch of code along the way) or they choose a more appropriate tool. The latter behavior is typical of programmers. The former is typical of typical users. There are many people producing web sites who I wouldn't let within yards of any of my code. but it's some kind of tribute to PHP that it manages to satisfy so many of them. This doesn't mean that grafting PHP features into Python mindlessly will improve the language. The Python approach is a scalpel, which can easily cut your fingers off. The PHP approach is a shovel, which will do for many everyday tasks. Exactly right on. I actually use PHP quite a bit. For websites that would otherwise be static html pages other than the fact that I want to reuse elements (header, footer, etc.), I choose PHP in a heartbeat, because it's easy, and I'm lazy. Ditto if it is a simple db-driven site. Start adding business rules and complex program flow and I run away from PHP as fast as I can. I wouldn't want to actually code anything in it, after all. ;) I've seen comments that mod_python is hard to use, but I just haven't found that to be the case. For me, mod_python is the next step up when PHP no longer suits my needs. Granted, I'm spoiled because I run my own server and don't rely on some hosting provider to tell me what I can and cannot do. :) -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Advice on sending images to clients over network
Frank Millman wrote: I guess the point of all this rambling is that my thought process is leading me towards my third option, but this would be a bit of work to set up, so I would appreciate any comments from anyone who has been down this road before - do I make sense, or are there better ways to handle this? Any suggestions will be much appreciated. I would put the images into a static web directory, either on the same or different server. Then your main server just sends the url (or relevant portion of the url, or list of all urls to download), and then the client grabs the images from your image server using urllib. Let Apache do what it's good at, instead of reinventing that particular wheel. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Advice on sending images to clients over network
Paul Rubin wrote: Frank Millman [EMAIL PROTECTED] writes: Any suggestions will be much appreciated. Why on earth don't you write the whole thing as a web app instead of a special protocol? Then just use normal html tags to put images into the relevant pages. I believe he has a full desktop client app, not a web app. Believe it or not, there's still a solid place for desktop applications even in this ever-increasing webified world. Use the right tool for the job... -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Advice on sending images to clients over network
Calvin Spealman wrote: On 7/22/07, Paul McNett [EMAIL PROTECTED] wrote: Paul Rubin wrote: Frank Millman [EMAIL PROTECTED] writes: Any suggestions will be much appreciated. Why on earth don't you write the whole thing as a web app instead of a special protocol? Then just use normal html tags to put images into the relevant pages. I believe he has a full desktop client app, not a web app. Believe it or not, there's still a solid place for desktop applications even in this ever-increasing webified world. Use the right tool for the job... There is no reason that something being a desktop app means they can't use HTTP instead of reinventing the protocol wheel all over again. Absolutely! Which is why I recommended setting up an httpd to serve the images... I interpreted Paul Rubin's response to say rewrite the whole thing (client, server, everything) as a web app. Cheers! -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: New guy help with setup
meg99 wrote: I just downloaded 2.5 and read the readme file. It says Before you can build Python, you must first confiigure itStart by running the script ./configure. I can't find ./configure I am running Windows XP SP2 You downloaded the wrong file. You want the Windows Installer: http://python.org/ftp/python/2.5.1/python-2.5.1.msi HTH Paul -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: New guy help with setup
meg99 wrote: On Jul 12, 4:24 pm, Paul McNett [EMAIL PROTECTED] wrote: meg99 wrote: I just downloaded 2.5 and read the readme file. It says Before you can build Python, you must first confiigure itStart by running the script ./configure. I can't find ./configure I am running Windows XP SP2 You downloaded the wrong file. You want the Windows Installer:http://python.org/ftp/python/2.5.1/python-2.5.1.msi My applogies - I did download and install 2.5.1 In that case, open up your command window (Start|Run cmd enter). Type 'python' at the c:\ prompt. Or, Start|All Programs|Python 2.5|IDLE Enjoy! -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: New guy help with setup
meg99 wrote: On Jul 12, 4:35 pm, Paul McNett [EMAIL PROTECTED] wrote: meg99 wrote: On Jul 12, 4:24 pm, Paul McNett [EMAIL PROTECTED] wrote: meg99 wrote: I just downloaded 2.5 and read the readme file. It says Before you can build Python, you must first confiigure itStart by running the script ./configure. I can't find ./configure I am running Windows XP SP2 You downloaded the wrong file. You want the Windows Installer:http://python.org/ftp/python/2.5.1/python-2.5.1.msi My applogies - I did download and install 2.5.1 In that case, open up your command window (Start|Run cmd enter). Type 'python' at the c:\ prompt. Or, Start|All Programs|Python 2.5|IDLE I opened the command window and typed 'python' got 'not recognized as a command' Add c:\python25 to your Windows system path. went to the python25 folder and typed 'python' got the prompt Good! Python is installed and working normally. typed './configure' got 'no Python documentation found for './configure' You don't need to ./configure. That's for when you are going to compile Python from source code into a binary, which you don't need to do because you installed a precompiled binary for Windows. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Build EXE on Mac OsX 10.4
Sherm Pendley wrote: Gabriel Genellina [EMAIL PROTECTED] writes: En Wed, 13 Jun 2007 17:35:19 -0300, Paul McNett [EMAIL PROTECTED] escribió: Tempo wrote: Has anyone sucesfully built a *.exe file on a mac operating system before from a *.py file? I have been trying to do this with pyinstaller, but I keep getting errors and I don't know how to install [...] You need to build Mac Apps on Mac, Windows EXE's on Windows, and Linux ELF's on Linux. You can't build a windows.exe from Mac, just as you can't build a mac.app from Windows. That's not entirely true. gcc on linux can generate a Windows EXE, and using: python setup.py bdist_wininst, you can generate a complete binary installer for Windows. I'm not sure if this can be done on a Mac too. In principle, certainly - there's even a MacPort package for a complete cygwin installation. I've built a number of packages with it - SDL and several related libraries, for instance. There are also ELF cross-compiler MacPort packages, presumably for building Linux binaries. On the other hand, I *haven't* tried any of those compilers with setup.py, and I have no idea if it can support those targets in practice. :-( There's the rub. In practice, it is hard enough getting my setup.py correct for building a nice windows.exe from Windows. Plus, the first thing I want to do after building an exe is *test* it on the target platform... -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: OS X install confusion
John Fisher wrote: Ted [EMAIL PROTECTED] wrote: On Jun 14, 1:31 pm, Kevin Walzer [EMAIL PROTECTED] wrote: John Fisher wrote: Hi Groupies, I have an Intel Macbook running OS X 10.4. It came installed with Python 2.3.5. I have since installed MacPython with version 2.4.4, cool. When I open a bash terminal session and type python, it brings up version 2.3.5. If I type IDLE it brings up version 2.4.4. My question: what do I have to do to get it to bring up 2.4.4 with the python command? Thanks for bringing light to my ignorance. JF Sounds like a path problem. Apple's system Python is installed in /usr/bin. Your installation is probably in /usr/local/bin. Edit your profile or use the full path. -- Kevin Walzer Code by Kevinhttp://www.codebykevin.com The default python on tiger (2.3.5) is sym-linked to /usr/bin/python and /usr/bin/pythonw. I found it easier to relink to the new installation path. This also leaves /usr/bin/python23 and /usr/bin/pythonw23 still linked to the original version if you want to quickly check something. Cheers, Ted OK, please give a little more information how I can accomplish this re-link. Your Python 2.5 is likely installed here: /Library/Frameworks/Python.framework/Versions/Current/bin But OS X comes with a system Python, version 2.3.5, likely installed here: /usr/bin If you look at /usr/bin, you'll see: lrwxr-xr-x 1 root wheel 9 Jan 31 17:24 python - python2.3 lrwxr-xr-x 1 root wheel 72 Jan 31 17:24 python2.3 - ../../System/Library/Frameworks/Python.framework/Versions/2.3/bin/python lrwxr-xr-x 1 root wheel 10 Jan 31 17:24 pythonw - pythonw2.3 -rwxr-xr-x 1 root wheel 29704 Aug 19 2006 pythonw2.3 So, python is linked to python2.3, and python2.3 is in turn linked to /System/Library/Frameworks/Python.framework/Versions/2.3/bin/python You need to (warning: watch for line wrap): sudo -s enter your password cd /usr/bin ln -s /Library/Frameworks/Python.framework/Versions/Current/bin/python python_current ln -s /Library/Frameworks/Python.framework/Versions/Current/bin/pythonw pythonw_current rm python rm pythonw ln -s python python_current ln -s pythonw pythonw_current However, that isn't what I did. I like the system being able to find and use the system-installed python, but I like my scripts to use the python version I installed (2.5). To get that, skip the above symlinking and instead edit your .bash_profile file (hidden file inside your home directory) and put these lines at the top: PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH} export PATH -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Build EXE on Mac OsX 10.4
Tempo wrote: Has anyone sucesfully built a *.exe file on a mac operating system before from a *.py file? I have been trying to do this with pyinstaller, but I keep getting errors and I don't know how to install UPX properly. I tried putting the linux UPX folder in my python 2.4 directory, but that didn't work. I am just generally confused right now. Ha. If anybody can lend me some insight I would really appreciate it. Thank you for taking the time to read this post. You need to build Mac Apps on Mac, Windows EXE's on Windows, and Linux ELF's on Linux. You can't build a windows.exe from Mac, just as you can't build a mac.app from Windows. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: updates in sqlite3 do not work
Chris Fonnesbeck wrote: I have a script set up to perform UPDATE commands on an sqlite database using the sqlite3 module. Everything appears to run fine (there are no error messages), except that none of the UPDATE commands appear to have actually updated the table. If I run each command on its own in a sqlite session, the UPDATE command works fine, so it is not a SQL syntax issue. UPDATE simply seems not to work. Any idea what the problem might be? You need to explicitly commit the transaction e.g.: import sqlite3.dbapi2 as sqlite con = sqlite.connect(temp.db) cur = con.cursor() cur.execute(create table test (id INTEGER, name CHAR)) cur.execute(insert into test values (1, 'bob')) con.commit() HTH Paul -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get started as a xhtml python mysql freelancer ?
gert wrote: I made something that i was hoping it could make people happy enough so i could make a living by providing support for commercial use of http://sourceforge.net/projects/dfo/ But in reality i am a lousy sales men and was wondering how you people sell stuff as a developer ? In my experience, you don't make money by selling support unless you are a large company selling support for a large project or a wide array of projects. The people that will use your library will mostly be developers and not end-users, after all. To make money from things you develop, I think you need to take your library and either build an application that has wide appeal and sell that, or sell yourself as a custom developer that can build the application the customer needs, using the tools you are comfortable with. You can then build in the cost of developing your library that you will reuse for the custom applications. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script not mapping our site correctly?
[EMAIL PROTECTED] wrote: We have been using the Google recommended python script for about a year. Which script would that be? Googling for 'python script' yields approx. 27 million hits. We recently realized that the script was not crawling our sites url's, but just our folders which reside on the server. The behavior of the script recently changed, or you were running the script for a year not realizing what its purpose was? The python script seems to be designed for 'non database' sites, not a site which is using .asp, and has dynamic pages. It sounds like your script is just traversing a directory structure on disk, presumably indexing the text in the files found there. I think it sounds like (but I'm guessing, here) that you want what is known as a web crawler, that communicates via http with your site, follows links, and indexes the resulting pages. We are an ecommerce site. What are other ecommerce sites using to create an xml file? XML is mostly used to persist data of one sort or another. What kind of XML file do you want to create? Are they using the python script? We aren't going to be able to help you with this question until you become *much more specific*: + Which python script? Where did you download it from and what is it called? + What is the purpose of the XML you want generated? (WAG: Submit to Froogle?) + What pages do you want indexed? Usually, for database-driven ecommerce sites, for developing lists of products for submission to places like Froogle, I don't go via the web interface at all: I write python scripts (there's that word again!) to connect to the database, and run queries to determine the results, run that through a template for each line that figures out things such as the URL of the page that represents the product, etc.) But I hesitate to say much more until we understand what you want your python script to do. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: dabo framework dependancies
Peter Decker wrote: On 5/22/07, daniel gadenne [EMAIL PROTECTED] wrote: I'm considering moving over to dabo for wxpython development. However I do not write traditional database applications à la foxpro (I'm a 20 years user of fox...) anymore. Only xml-fed applications. I'm a bit hesitant to jump onboard since dabo seemns to carry over its own lot of database connectivity dependancy. Can you reasonably use dabo for plain datafree application? That's exactly how I use it. I write apps that don't use database servers, and don't have any database programs installed. I just want the dabo.ui stuff, since it makes wxPython so easy to work with. Dabo has three main modules: db, biz, and ui, and an overarching application object. Every class descends from an abstract dObject. For database apps, you'd typically set some connection information in the db layer, put all your business code in the biz layer, and define your GUI in the (you guessed it) ui layer. You can certainly do what Peter has done and only use the ui layer and application object. I've done this myself and if I ever had to code a non-database UI that's probably what I'd do, too. Although I have to admit I can't really picture an application that doesn't need to save data. Here's a simple example that puts up a textbox: import dabo dabo.ui.loadUI(wx) app = dabo.dApp() app.setup() frm = app.MainForm tb = dabo.ui.dTextBox(frm, Value=Type in here, FontBold=True) app.start() You can easily define your own subclasses, too: import dabo dabo.ui.loadUI(wx) class MyRadioList(dabo.ui.dRadioList): def initProperties(self): self.Choices = [Snakes, Bees, Fishes] def onHit(self, evt): print Radio choice '%s' selected. % self.Value app = dabo.dApp() app.setup() frm = app.MainForm rl = MyRadioList(frm) app.start() So, yes, you can reasonably use Dabo even if you have no traditional database in the mix. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and GUI
[EMAIL PROTECTED] wrote: Just wondering on what peoples opinions are of the GUIs avaiable for Python? Python has, I believe, 4 compelling choices for GUI library: Tkinter, wxPython, PyQt, and PyGTK. Like everything in life, each has their relative merits and downsides. Briefly, here are my feelings on each, but I'm mostly versed in wxPython. Tkinter: Pros: comes with Python out of the box; terse; easy Cons: owner-drawn (not-native OS widgets); limited in out-of box functionality; kind of ugly wxPython: Pros: easy to install binary on all platforms, active development, active friendly community of contributors, native os base widgets on all platforms. Cons: hard to build from source on all platforms, everything but the kitchen sink comes with it, and some things are pretty buggy still or abandoned. PyQt: Pros: looks good on all platforms, easy to install and use. Cons: licensing issues require you to understand lots of specifics; owner-drawn widgets. PyGTK: Can't comment because I haven't used it. The major con in my mind is that (I think) you need the Gtk library to be installed on all platforms, so on OS X / Windows the widgets won't look platform-native. All I am doing is prompting users for some data (listbox, radio buttons, text box, ect...). Then I will have some text output, maybe a scrolling text message as things are happening. I think each of the GUI libraries would be able to handle this easily. I have some minor things I need to do, for example, if Checkbutton X is clicked, I need to disable TextBox Y, and I would like to display the scrolling text (output) Again, this is simply responding to events as they happen. You set up a callback function with your reactive code, and tell the GUI library to call that function when the event occurs. Ultimately, is it worth downloading and learning some of the packages avaiable for Python, or should I just stick to the Tkinter stuff that is included. I think everyone should use wxPython, but I'm biased. More specifically, has anyone used the Qt stuff for python, easy to use? I've used it and it is easy, yes. Relative ease I can't answer though, because I find wxPython extremely easy due to depth of use over the years. Shameless plug: consider using Dabo on top of wxPython - we feel it makes wxPython even easier and more pythonic, but admittedly there's a bit of a learning curve there too. Even though Dabo is a full application framework originally meant for desktop database applications, it is modular and you can choose to only use the UI bits... http://dabodev.com -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: File DB instead of real database?
Jia Lu wrote: I donot want to use a real DB like MySQL ... But I need something to save about more than 1000 articles. Is there any good ways? (in Python 2.5): #-- begin import sqlite3.dbapi2 as sqlite con = sqlite.connect(path/to/new/filename.db) cur = con.cursor() cur.executescript( create table articles (id integer primary key autoincrement, name text, content clob); create index articles_name on articles (name); insert into articles (name, clob) values (My new article, Article text. blah blah); ) con.commit() #-- end -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: DOS, UNIX and tabs
Sebastian 'lunar' Wiesner wrote: Paul McNett [EMAIL PROTECTED] typed Steven D'Aprano wrote: But I think we all agree that mixing tabs and spaces is A Very Bad Thing. I like mixing tabs and spaces, actually. Tabs for indentation, and additional spaces to make the code look pretty. Somebody please tell me why this is bad and I'll stop. class Apple(object): def contrived_example_function(self, argument1, argument2, argument3, argument4): print hello, world Apparently, emacs in python mode follows this convention, too. That doesn't seem like a standard settings to me. I can't remember changing the indentation settings for python, nonetheless my gnu emacs uses four spaces for indentation. Placing wrapped lines into ordered columns is done by inserting additional spaces. This all happens automatically; you never need to insert spaces manually... I never tried emacs, but somebody once told me that if you have set indentation-by-tab, it will indent with tabs but insert additional spaces in wrapped lines to look pretty. I like it because I get the best of both worlds: the only thing against using tabs-only-indentation is that wrapping long lines can be quite ugly, while space-only-indentation allows for beautifying it somewhat by lining up the columns to match. Did you try to open your code files with another editor, which has a different length for tabulator chars? It would look quite ugly, I guess... Actually, no. Everyone can choose their own number of spaces-per-tab and it'll look right, as long as everyone uses a monospace font. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: DOS, UNIX and tabs
Steven D'Aprano wrote: But I think we all agree that mixing tabs and spaces is A Very Bad Thing. I like mixing tabs and spaces, actually. Tabs for indentation, and additional spaces to make the code look pretty. Somebody please tell me why this is bad and I'll stop. class Apple(object): def contrived_example_function(self, argument1, argument2, argument3, argument4): print hello, world Apparently, emacs in python mode follows this convention, too. I like it because I get the best of both worlds: the only thing against using tabs-only-indentation is that wrapping long lines can be quite ugly, while space-only-indentation allows for beautifying it somewhat by lining up the columns to match. Tabs+spaces allows the lining up with spaces to be explicitly separate from indentation. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Good Looking UI for a stand alone application
Luc Heinrich wrote: Peter Decker [EMAIL PROTECTED] wrote: You're full of it. I routinely write GUI apps in Dabo for both Windows and Linux users, and they look just fine on both platforms. Oh, I'm sure you do. Now go try to run one of your Dabo apps on a Mac and see how it looks/feels... : It looks/feels like a native app on OS X. Here's a hint directly taken from the Dabo homepage: It also suffers from the same display limitations on some platforms (most notably OS X), but these should improve as the underlying toolkits improve. That was written a long time ago, and doesn't really apply anymore as a lot of effort has gone into wxPython over the past three years getting correctly interfaced to the OS X native API. (Note to self: rewrite that (prescient) paragraph). Using sizers is the key; layouts just 'look right' no matter what the native fonts and control sizes are. No, sizers are a tiny part of a much bigger problem. Sizers might be the key to solve parts of the look problem, they don't address any of the feel problem. Admittedly, to some extent there is a lowest common denominator problem inherent in any UI toolkit that tries to be crossplatform and use the platform's native GUI. But for the most part, that just isn't the case anymore in a practical sense. Why not use the best crossplatform native toolkit (wxPython) and then if you need native features that aren't provided, use ctypes or something to get access to the native GUI? Nothing in wxPython or Dabo prevents you from doing that. But you clearly have a point here, so let me rephrase: Crossplatform toolkits/frameworks suck. All of them. No exception. UNLESS you only target the lowest common denominator, aka Windows and its Linux followers. Absolutism sucks. Please try not to be so black and white about things, and you may find you enjoy life more. Now, the OP *explicitely* said that [his] requirement is that the application needs to look as good on Windows as on the Apple Mac, so the rephrasing does not apply in this case. So here's a last try: Crossplatform toolkits/frameworks suck. All of them. No exception. ESPECIALLY if one of your target is Mac OS. It is much more nuanced than that. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: detecting that a SQL db is running
bill ramsay wrote: none of this matters, all i am trying to find out is whether or not the local MSDE is actually running. If it is a local MSDE then you may be able to rely on the connection being refused if the server isn't running. #-- begin import socket host = 127.0.0.1 port = 1433 ## replace with msde_port, if it differs s = socket.socket(socket.AF_INET) try: s.connect((host, port)) print Server on %s is running % port except socket.error, e: print Server on %s appears to be down (%s) % (port, e) #-- end Please note that this is untested and not very well thought through. But try it and see if it gets you on the right track. If this isn't run locally, you'll probably need to set the timeout low enough for the connect call not to appear to hang before returning the timeout error. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting Microsoft Works databases.... *shudder*
Michael B. Trausch wrote: GISDude wrote: Mike, I totally forgot that MS Works was out there. Haven't used that one in about 6 or 7 years. Honestly, your best bet is to convert to .csv or some delimited .txt file. Once that is done, all your rows/columns will be nice and neat . Once that is done, (and since your client doesn't have ACCESS, try MYSQL or POSTGRESQL(they are open source). They can handle A LOT OF DATA, so however big your orginal DB is, you can import it to one of these more than capable OS freebie Databases. Yeah; the only thing is that I am going to have to write a solution to give them easy access to their data. Sometimes, they just want to look up a row of data, but they don't want to put their data in a database server -- they want it on their machine so that it is private (FSVO private--it's a Windows box). You can set up database servers that only serve to the local machine. I have a couple applications out there that have MySQL server running on a Windows box and the only client that connects is the local machine. However, you may find it easier and every bit as rewarding to go with the simpler solution: sqlite. As far as easy access to the data, it is quite possible that Dabo could help you there. Once you have your data in sqlite or MySQL, the Dabo AppWizard can generate a basic application for you to search, browse, edit, and report on your records. The basic application generated can then be modified by you (in Python) to make it more custom and to enhance it as your needs grow. sqlite information: http://initd.org/tracker/pysqlite dabo information: http://dabodev.com (Please note that the dabodev website is going through some scheduled maintenance so it may not be available when you call this weekend, but in any case it will be fully functional by Monday). -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Serious wxPython Error while executing..
kath wrote: Hello, sorry about the lengthy message. I finding difficult to execute this program. The wx.Notebook i created is coming on the splitted frame(self.p2). How do I that. I am started to learn wxPython, and when I run the code, the code doesnot close gracefully, it throughs me an error. pythonw.exe has encountered a problem and needs to close. We are sorry for the inconvenience I get a segmentation fault on Linux, after running the script, choosing Add new fund from the menu, and then closing the application. I don't get the segmentation fault if I merely start the app and close it. here is the code seems a bit lengthy, sorry about that. Please help me to find my mistake, and how do I go forward resolving this problem. You actually have several problems. But, the segmentation fault appears to be directly related to the fact that you add boxsizer to the border sizer twice. Another problem is that you create the notebook every single time, and add just one page to it, but you probably want just one notebook with one or more pages. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: .doc to html and pdf conversion with python
Alexander Klingenstein wrote: I need to take a bunch of .doc files (word 2000) which have a little text including some tables/layout and mostly pictures and comvert them to a pdf and extract the text and images separately too. If I have a pdf, I can do create the html with pdftohtml called from python with popen. However I need an automated way to converst the .doc to PDF first. Is there a way to do what I want either with a python lib, 3rd party app, or maybe remote controlling Word (a la VBA) by printing to PDF with a distiller? I already tried wvware from gwnuwin32, however it has problems with big image files embedded in .doc file(looks like a mmap error). I would try scripting OpenOffice from Python, using the Python-UNO bridge. http://udk.openoffice.org/python/python-bridge.html Once you have the pdf, use the pdftohtml to get access to the image elements you need. -- pkm ~ http://paulmcnett.com -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?)
[EMAIL PROTECTED] wrote: Do you know what INNER JOIN means? Do you know how important it is to a relational database? Can you explain how an INNER JOIN can even work, in theory, with dynamic data types? Let's stop the pissing contest and just see how it works. After all, this is Python and we can easily just try it out. Here's my example. Please tell me how this causes unexpected results, and why it isn't SQL. Please modify my example to get it to cause a catastrophe, and post it here so we can see the errors of our ways and be properly humbled. #-- Preliminaries: from pysqlite2 import dbapi2 as sqlite con = sqlite.connect(test.db) cur = con.cursor() #-- Create 3 tables for a M:M relationship between customers #-- and categories: cur.execute(create table customers (id integer primary key autoincrement, name char)) cur.execute(create table categories (id integer primary key autoincrement, name char)) cur.execute(create table cust_cat (id integer primary key autoincrement, cust_id integer, cat_id integer)) #-- Insert some test data into customer and categories: cur.execute(insert into customers (name) values ('Ziggy Marley')) cur.execute(insert into customers (name) values ('David Bowie')) cur.execute(insert into categories (name) values ('Glam Rock')) cur.execute(insert into categories (name) values ('Nuevo Reggae')) cur.execute(insert into categories (name) values ('Male Singers')) cur.execute(select * from customers) #-- Take a look at the data (and retrieve the pk's): cur.fetchall() [(1, u'Ziggy Marley'), (2, u'David Bowie')] cur.execute(select * from categories) cur.fetchall() [(1, u'Glam Rock'), (2, u'Nuevo Reggae'), (3, u'Male Singers')] #-- Relate some customers to some categories. Note how I send strings #-- in some places and ints in others: cur.execute(insert into cust_cat (cust_id, cat_id) values (1, 3)) cur.execute(insert into cust_cat (cust_id, cat_id) values (1, '2')) cur.execute(insert into cust_cat (cust_id, cat_id) values ('2', '1')) cur.execute(insert into cust_cat (cust_id, cat_id) values ('2', 3)) #-- Run some queries: cur.execute(select customers.id as cust_id, customers.name as cust_name, categories.id as cat_id, categories.name as cat_name from customers inner join cust_cat on cust_cat.cust_id = customers.id inner join categories on categories.id = cust_cat.cat_id order by 2,4) cur.fetchall() [(2, u'David Bowie', 1, u'Glam Rock'), (2, u'David Bowie', 3, u'Male Singers'), (1, u'Ziggy Marley', 3, u'Male Singers'), (1, u'Ziggy Marley', 2, u'Nuevo Reggae')] cur.execute(select customers.id as cust_id, customers.name as cust_name, categories.id as cat_id, categories.name as cat_name from customers inner join cust_cat on cust_cat.cust_id = customers.id inner join categories on categories.id = cust_cat.cat_id where categories.id = 1 order by 2,4) cur.fetchall() [(2, u'David Bowie', 1, u'Glam Rock')] cur.execute(select customers.id as cust_id, customers.name as cust_name, categories.id as cat_id, categories.name as cat_name from customers inner join cust_cat on cust_cat.cust_id = customers.id inner join categories on categories.id = cust_cat.cat_id where categories.id = '1' order by 2,4) cur.fetchall() [(2, u'David Bowie', 1, u'Glam Rock')] cur.execute(select customers.id as cust_id, customers.name as cust_name, categories.id as cat_id, categories.name as cat_name from customers inner join cust_cat on cust_cat.cust_id = customers.id inner join categories on categories.id = cust_cat.cat_id where categories.id = '2' order by 2,4) cur.fetchall() [(1, u'Ziggy Marley', 2, u'Nuevo Reggae')] cur.execute(select customers.id as cust_id, customers.name as cust_name, categories.id as cat_id, categories.name as cat_name from customers inner join cust_cat on cust_cat.cust_id = customers.id inner join categories on categories.id = cust_cat.cat_id where categories.id = '3' order by 2,4) cur.fetchall() [(2, u'David Bowie', 3, u'Male Singers'), (1, u'Ziggy Marley', 3, u'Male Singers')] cur.execute(select customers.id as cust_id, customers.name as cust_name, categories.id as cat_id, categories.name as cat_name from customers inner join cust_cat on cust_cat.cust_id = customers.id inner join categories on categories.id = cust_cat.cat_id where categories.id = 3 order by 2,4) cur.fetchall() [(2, u'David Bowie', 3, u'Male Singers'), (1, u'Ziggy Marley', 3, u'Male Singers')] If I have skipped the test case that will fail, please enlighten me. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: urlopen() error
Tempo wrote: Hello. I am getting an error and it has gotten me stuck. I think the best thing I can do is post my code and the error message and thank everybody in advanced for any help that you give this issue. Thank you. # Here's the code: # import urllib2 import re import xlrd from BeautifulSoup import BeautifulSoup book = xlrd.open_workbook(ige_virtualMoney.xls) sh = book.sheet_by_index(0) rx = 1 for rx in range(sh.nrows): u = sh.cell_value(rx, 0) page = urllib2.urlopen(u) soup = BeautifulSoup(page) p = soup.findAll('span', sale) p = str(p) p2 = re.findall('\$\d+\.\d\d', p) for price in p2: print price ## Here are the error messages: ## Traceback (most recent call last): File E:\Python24\scraper.py, line 16, in -toplevel- page = urllib2.urlopen(u) File E:\Python24\lib\urllib2.py, line 130, in urlopen return _opener.open(url, data) File E:\Python24\lib\urllib2.py, line 350, in open protocol = req.get_type() File E:\Python24\lib\urllib2.py, line 233, in get_type raise ValueError, unknown url type: %s % self.__original ValueError: unknown url type: List You were expecting u to be a url string like http://google.com;, but it looks like it is actually a list. I'm not familiar with package xlrd but cell_value() must be returning a list and not a cell value. Presumably, the list contains the cell value probably in element 0. Put in a print statement before your call to urlopen() like: print u You'll likely discover your error. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Class instantiation
Colin J. Williams wrote: class arSpread(object): def __init__(self, fileId= None, ar= None): if fileId: if ar is not None: print fileId self.connect(fileID, mode= 'r') # open sheet in the read mode else: self.connect(fileID, mode= 'w') # open the sheet in the 'dOH! smack's head. Change to self.connect(fileId, ...) :) -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: I'm just not cut out for web programming, I guess :)
John Salerno wrote: Ok, I've tinkered with this thing for a while, and I keep fixing little problems, but I always get a 500 Internal Server error when I go to this site: I don't necessarily even want help just yet, I'd like to figure it out myself, but can someone at least tell me why I'm not getting helpful feedback from the cgitb module? Am I using it wrong? The webpage just displays the internal server error. Thanks. import cryptogen import cgitb; cgitb.enable() quote_file = open('quotes.txt') quote = quote_file.readline().strip() quote_file.close() print '''content-type: text/html !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd; html lang=en-us head meta http-equiv=content-type content=text/html; charset=utf-8 title/title /head bodyform action=cryptopage.py''' quote = cryptogen.convert_quote(quote) for word in quote[0].split(' '): word_len = len(word) print 'input type=text name=%s size=%d' % (word, word_len) print 'input type=submit value=Submit/form/body/html' Are you sure the python that the web server runs has the cryptogen module available? Have you set the execute bit on your script? What's the output in your web server error log? -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: is there any overheard with try/except statements?
John Salerno wrote: One of the things I learned with C# is that it's always better to handle any errors that might occur within the codes itself (i.e. using if statements, etc. to catch potential out of range indexing) rather than use too many try/catch statements, because there is some overhead every time the program encounters the try. Is this the case at all with Python, in terms of extra work or slower speed? Or is try/except implemented differently in Python than it is in other languages, so that it runs just like any other code? The try structure is very efficient. However, when an exception happens at runtime, the creation of the exception object is expensive. That said, it does seem to be considered Pythonic to ask for forgiveness instead of asking for permission. If you check for every exceptional possibility before actually doing the thing you want to do, your code gets ugly very quickly. I would use try...catch liberally, and then if profiling determines that you have a performance bottleneck (e.g., because an exception object is being created in lots of iterations of a loop) then factor out the try block in that case, placing a comment explaining why you did it that way. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: how do you move to a new line in your text editor?
John Salerno wrote: But I read in the PEP that spaces are recommended over tabs. If this is If you like tabs, stick with tabs. There isn't any reason to use spaces unless your boss is demanding it. Tabs are the slightly better choice, in my humble opinion. That said, you should be able to tell your editor how to behave in the indent/unindent case, no matter whether you use tabs or spaces. If not, time to switch editors! ;) -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: commenting out blocks of code
john peter wrote: in java, i can prevent a block of code from executing by bracketing the block with comment indicators, as shown below: /* statement1 will not execute; statement2 will not execute; */ statement3 will execute is there a similar mechanism in python, other than prefixing the '#' character to the start of each statement i do not want to execute (which gets old very quickly if one needs to comment and uncomment several statements a couple of times while playing around with code say during initial design)? IMO this is a missing feature in Python. However, if the block of code you are wanting to comment out doesn't happen to contain any triple-quotes, you can surround the code with those. For example: def myFunc(arg): return arg + 2 def myFunc(arg): return arg + 1 print myFunc(2) 4 -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Visual Report Editor
Pawel wrote: I plan to make Visual Reporting Editior, a new product for corporate-class systems. Data will be in XML and in my application, designer should be able to make fascinating templates of reports. I will use Python and MSVS 2005 Pro. My question is, which libaries will be useful in my job. I plan to buy Qt and make visual layer of application using Qt. I'm making businessplan soI have to decide which tool will be useful. Is Qt best choice, maybe I should buy something different? Before you go to all that work, please take a look at the Dabo Report Designer, which uses wxPython for the UI and ReportLab for the PDF generation. There's a 23-minute screencast here which may give you an idea if its design is compatible with yours: http://dabodev.com/documentation It isn't complete and I could certainly use help making it so. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with super()
David Hirschfield wrote: So, the larger question is how to do anything that resembles what I want, which is to have a chain of subclasses with a single attribute that each subclass can define as it wishes to, but with the ability to get the combined value from all the ancestors down to the current subclass I access that attribute from. Does that make any sense? Yes, it makes sense. The trick is to not query the values using self, but to ask the class definitions for the attribute. See my second message that gives an example, climbing the __mro__ tree backwards. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with super()
David Hirschfield wrote: Is there a way to get what I'm after using super()? Probably. The idea is that I could have a chain of subclasses which only need to redefine _v, and getting the value of v as a property would give me back the full chain of _v values for that class and all its ancestor classes. Does this work? : class A(object): _v = [1,2,3] def _getv(self): ret = [] mroList = list(self.__class__.__mro__) mroList.reverse() for c in mroList: print c, ret if hasattr(c, _v): ret += c._v return ret v = property(_getv) class B(A): _v = [4,5,6] b = B() print b.v -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Tabs bad
Björn Lindström wrote: Paul Rubin http://[EMAIL PROTECTED] writes: [EMAIL PROTECTED] (Björn Lindström) writes: Actually using tabs for eight spaces and then filling out with spaces to the correct indentation is the convention for Emacs Lisp. Of course, since everyone coding Emacs Lisp does it with the same editor, it's no problem. The variable `indent-tabs-mode' controls this. I like no tabs. Same here. It's still the convention for Emacs code, regrettably. I don't use Emacs, I do indent with tabs, and I do fill in the extra spaces of continuation lines with spaces. Therefore, I break all the commandments and do everything wrong. ;) FWIW, I've long struggled with my opinion on tabs versus spaces. When I started programming in 1995, tabs seemed the logical choice because I was using different editors all the time and I could tell each editor how many spaces to give each tab. But then as I started reading more people's code I started seeing patterns in source code that I couldn't emulate using pure tabs. This comes down to horizontal lining up continuation lines with prior lines. Examples: select customer.cfirst, customer.clast from customer where customer.cstate in (CA, OR) order by customer.clast win = dabo.ui.dDialog(self, NameBase=frmRulesDialog, Caption=Minesweeper Rules, SaveRestorePosition=True, Centered=True, Modal=False) Everyone that was writing beautiful code like this was using spaces only. So I switched. But it was a real PITA to not be able to use any old editor, only ones that could set how many hard spaces to make for each hard tab. And, I had to remember to make that setting because I prefer 2 spaces per tab. So now I'm back to tabs for indentation and spaces for lining up continuation lines. Example: win = dabo.ui.dDialog(self, NameBase=frmRulesDialog, Caption=Minesweeper Rules, SaveRestorePosition=True, Centered=True, Modal=False) (if that didn't come over email correctly, that is one tab for indentation on all three lines, followed by several spaces on lines 2 and 3 for getting the arguments lined up with the previous line.) I've been reluctant to admit to doing this since it violates the NEVER MIX TABS AND SPACES commandment, but there you go. I found a way to reconcile the best of both worlds, because let's face it, tabs do make slightly more sense. Finding out that Emacs has been doing this by default makes me feel better about admitting this publicly. There are definitely issues with mixing whitespace like this, especially is someone is encountering it without understanding it. But Python handles it just fine. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao Language v.0.9.6-beta is release!
[EMAIL PROTECTED] wrote: Python is the superior design, today. But, like Betamax tape format, Python isn't mainstream yet. And, sadly, maybe it never will be. I want that changed. I want Python to take over the world so I don't have to beg my next boss to let me use it. And if adding an optional dumbed-down format will help then that might be an improvement in the big picture. I couldn't disagree more. I most certainly do *not* want Python to take over the world. I want .NET and Java to prevail, so that large companies with money to throw away at such technologies will continue to do so, and so that I can still fly in under the radar to my small clients and be able to provide them with the simplest solution that works at a price they can afford and a price that I can live on. Having .NET and Java in the world makes me into more of a hero when I can swoop in and get the real business problem solved using Python. Now, say Python were to usurp everything else and become the dominant language. Everyone would learn Python. Python would become all the rage and get all the hype. Sun, Oracle, Microsoft, IBM, Apple, and SCO would all evangelize on their new Python initiatives. Microsoft would attempt to release their version with just a few non-standard things added on. Sun would sue them for not sticking with standards. Books and articles would be written. Middle-level management would start identifying places that Python is deficient in their eyes. CIO Insight would start making recommendations. Everyone would be pumping so much energy into so many different places that, like Java, Python would stall out and be consumed by its own hype, and the programmers that made Python what it is would burn out on it (read: they'd be busy counting all their stock options). Plus, there would now be a deluge of Python programmers in the market place, competing with my billing rate. No, I like Python just where it is, thank you very much. If someone doesn't want to give Python a second look because of their own bigoted ideas, I say Python doesn't want that type of person to begin with. Perhaps that sounds a bit elitist, but if people would just put their preconceptions aside, they'd quickly realize that Python really does get block indentation (and a whole host of other things besides) right. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao Language v.0.9.6-beta is release!
Christopher Subich wrote: [EMAIL PROTECTED] wrote: From The Design of Everyday Things, docs are a sign of poor design. Even a single word, such as the word Push on the face of a door, is an indication that the design can be improved. Please, rethink the design instead of trying to compensate with more documentation. This quote, with a naive reading, would seem to imply that needing documentation is evidence of bad design. I think we can all agree that this interpretation is ludicrous: the only programming language, for example, which does not need documentation is the natural language, and that contains so many ambiguities that humans often get instructions wrong. Indeed, there is only one user interface that needs no documentation whatsoever. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: an intriguing wifi http server mystery...please help
[EMAIL PROTECTED] wrote: Please excuse any ignorance here. I would love to show you what you are asking for, but I am not sure what you are asking for (newbie here). All these connections (i.e. client-server connections) are within my local area network. I have a simple linksys 802.11b router. My server is set to say, 192.168.1.100, port , and my client is set to say, 192.168.1.101 I load up the server, then go to the client computer webbrowser and enter http://192.168.1.100:; If you are on Windows, please open a command window (Start|Run and then type 'cmd') and type: route print On Linux or Mac, the command would simply be: route Do this on both computers, and post the output here. If you are using ip addresses only in your URL's the problem isn't with DNS or name lookup so let's eliminate a routing problem next. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython installation issues on Debian
[EMAIL PROTECTED] wrote: Thanks a lot for the clarification. I don't have a compelling reason not to use 2.3 other than having to install the modules I've already set up for 2.4. Not really a big deal. Looks like I'll be switching to 2.3. Umm, for what it's worth: I'm on Ubuntu (a Debian derivative), using Python 2.4.2 and wxPython 2.6. The wxPython was installed using 'apt-get install python-wxGtk2.6'. So I don't know why you say you need to use Python 2.3 as I don't even have that on my system. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython installation issues on Debian
Robert Kern wrote: Although Ubuntu is a Debian derivative, it does have different packages. At the moment, Debian's default Python is 2.3 although one can also install Python 2.4, and most Python packages in Debian have been built for both (that's why I erroneously recommended installing the apparently nonexistant python2.4-wxgtk2.4). However, it appears that the maintainer of the Debian wxPython is not building packages for both Python 2.3 and 2.4. The maintainer of the Ubuntu wxPython package apparently is. As far as I know, the maintainer of the wxPython package is the same (Ron) and Ubuntu just uses the upstream wxPython from Debian. However, I see above that you are referencing wxPython 2.4 and not 2.6. It is very possible that for wxPython 2.4, there is only a Python 2.3 package. wxPython 2.4 is obsolete. If possible, wxPython 2.6 should be used. But, I don't know if it is available for Python 2.4 under Debian (or Ubuntu, for that matter). -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: wxGrid and Focus Event
lux wrote: How can I capture the EVT_SET_FOCUS on a wxGrid? If you want to catch when the grid as a whole gets the focus, use: grid.Bind(wx.grid.EVT_SET_FOCUS, self.onGridFocus) If you want to catch when a cell in the grid gets the focus, use: grid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.onCellSelected) And, your questions will be better on the wxpython-users list at http://wxpython.org/maillist.php -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: wxGrid and Focus Event
Paul McNett wrote: lux wrote: How can I capture the EVT_SET_FOCUS on a wxGrid? If you want to catch when the grid as a whole gets the focus, use: grid.Bind(wx.grid.EVT_SET_FOCUS, self.onGridFocus) Oops, my bad: grid.Bind(wx.EVT_SET_FOCUS, self.onGridFocus) If you want to catch when a cell in the grid gets the focus, use: grid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.onCellSelected) And, your questions will be better on the wxpython-users list at http://wxpython.org/maillist.php -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: wxGrid and Focus Event
lux wrote: Can you try this code? Sure, thanks for posting it! If you press only the TAB key the focus go from the TextCtrl to the Grid (I suppose) but onGridFocus in not called. Confirmed, at least on Gtk. any idea? Yep, the grid is actually a collection of subwindows, and I made the guess that the first window to get the focus is actually that little corner window at the intersection of the column labels and the row labels. Try this instead: g.GetGridCornerLabelWindow().Bind(wx.EVT_SET_FOCUS, onGridFocus) -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: wxGrid and Focus Event
lux wrote: TANKS!!! Now it work!!! Not so fast. I've found out that I had to do the following ugly workaround to ensure it works in all cases: def _initEvents(self): ... if self.BaseClass.__name__ == dGrid: ## Ugly workaround for grids not firing focus events from the keyboard ## correctly. self._lastGridFocusTimestamp = 0.0 self.GetGridCornerLabelWindow().Bind(wx.EVT_SET_FOCUS, self.__onWxGotFocus) self.GetGridColLabelWindow().Bind(wx.EVT_SET_FOCUS, self.__onWxGotFocus) self.GetGridRowLabelWindow().Bind(wx.EVT_SET_FOCUS, self.__onWxGotFocus) self.GetGridWindow().Bind(wx.EVT_SET_FOCUS, self.__onWxGotFocus) self.Bind(wx.EVT_SET_FOCUS, self.__onWxGotFocus) ... def __onWxGotFocus(self, evt): if self.BaseClass.__name__ == dGrid: ## Continuation of ugly workaround for grid focus event. Only raise the ## Dabo event if we are reasonably sure it isn't a repeat. prev = self._lastGridFocusTimestamp now = self._lastGridFocusTimestamp = time.time() if now-prev .05: return self.raiseEvent(dEvents.GotFocus, evt) -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: wxGrid and Focus Event
Bugs wrote: So Paul, are you saying there's a bug with the wxGrid control and if so, Yes, I think it is a bug. do you know if there's been a bug-report submitted to the wxWidgets and/or wxPython folks? I don't know, but I've been meaning to check. Or is this just the way the wxGrid control works? Thanks! wxPython/wxWidgets, like any GUI toolkit, is pretty complex. For the most part all the commonly-needed things work just fine - it is when you venture into the less-used things that you get into trouble. If I filed a proper bug report for everything wrong with wxPython/wxWidgets, I'd probably not get anything else done. But on the other hand you couldn't force me to stop using wxPython if you tried! -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: an intriguing wifi http server mystery...please help
[EMAIL PROTECTED] wrote: 1) Laptop wired, client Desktop wired, server GREAT! webpage served in 2 seconds 2) Laptop wired, server Deskop wired, client GREAT! webpage served in 2 seconds 3) Laptop wireless, client Desktop wireless, server GREAT! webpage served in 2 seconds 4) Laptop wireless, server Desktop wireless, client CRAP! webpage served in 90 seconds What the heck is happening? Please post your routing tables and, if you are referencing your server machine by name, your name server addresses (/etc/resolv.conf on Linux). -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: exceptions, internals (introspection?)
ej wrote: I have often wondered how to get at other internals, such as the name of the current function, file, line number I am in? The arguments to the current function, etc. Others have given you information on how to get at the stack trace. But regarding getting at some of the other internals you are talking about: import inspect help(inspect) Back to exceptions, you can also provide your own global exception handler by overriding sys.excepthook (drop in your own function). -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: how to modify text in html form from python
Philippe C. Martin wrote: PS: If my question is not clear, I am trying to share the form between the client and server. just as many sites out there allow you to modify existing data: 1) the server pops up a form with your data in it. 2) the client can modify it and submit. I know this is a _basic_ question, sorry. When debugging Python cgi scripts, it is helpful to run the scripts from a command line just to make sure there aren't any compiler errors. Depending on how the server is set up, you'll get a server error or just a blank page if your script won't compile. When I run your script directly as I suggest, here's what I get: [EMAIL PROTECTED]:~$ python test.py File test.py, line 23 html ^ SyntaxError: invalid syntax D'oh! You needed to surround the html with quotes to make it a string, as in: print html ... /html I don't really understand your original problem, but perhaps this will help get you rolling again. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Documenting properties
Lasse Vågsæther Karlsen wrote: So, my question is, is there a way to get __doc__ support for properties, in effect, use the xxx syntax for documenting properties. Yes, the property() function accepts a doc argument, as in: property(fget, fset, fdel, doc) ex: MyProp = property(_get, _set, None, This will show up in __doc__) Is the preferred way to use xxx or # to document ? # is for source code commenting (audience is the person reading your code). x is for documenting your API (audience is the person using your code). They are quite different. Whatever is preferred, what's the upside/downsides of the two beyond what I just explained? Nothing really, but something handy to keep in mind is that the string literal (x) can be used to block out huge sections of code during testing, where you'd have to put a # in front of every line otherwise. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK or wXPython?
Jarek Zgoda wrote: I would use wx, if it wasn't so dog slow on linux. Qt and GTK are much faster, but each one has disadvantages. Finally, you get 3 GUI toolkits, of which each claims to be cross-platform, but each is working at acceptable level of WTF only on one system (wx on Windows, Qt and GTK on linux) and the most appealing (Qt) has no free version for Windows. I must say, I haven't found wx to be slow on Linux at all. Slow on Mac, yes, but faster on Linux than on Windows (and getting much much better on Mac). The exception to this is the StyledTextControl, which is by far much faster on Windows, and with lots of styled text dog-slow on Linux. Wx does use the native underlying toolkit for the platform (Qt is owner-drawn), which can cause some platform inconsistencies. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list
ANN: Dabo 0.4.1
We are happy to announce the release of Dabo 0.4.1, available for download from: http://dabodev.com/download Dabo is a framework for developing 3-tier database applications, and comes with database wrappers for MySQL, PostgreSQL, Firebird, and SQLite. It wraps the wxPython GUI toolkit, making it easier to use and more polymorphic, providing a nice property interface to the controls. In addition to the main dabo-0.4.1 package, there are also updated downloads for dabodemo-0.4.1 and daboide-0.2.1. There have been numerous improvements in Dabo over the past few weeks since 0.4, summarized here: Improved test framework for uiwx. Now you can run ui/uiwx/test.py and get almost all of the dabo controls in one form, and they are the same tests that you get when you run an individual control directly. Factored out the saving/restoring of user settings out of dApp into the separate dUserSettingProvider class, which can be subclassed or overridded by the developers. Added properties UserSettingProvider and UserSettingProviderClass to dApp. Dabo user settings are no longer saved to .userSettings.ini in the app directory, but are saved to the user's home directory (in ~.dabo/) or if on Windows, in User Profile/Application Data/Dabo/. Support for SQLite added. As of this moment, Dabo supports several major open-source database backends: MySQL, PostgreSQL, Firebird, and SQLite. Next on the list should be Oracle, Sybase, and MS-SQL. Started work implementing a Quick Report in the datanav library, which replaces the old HTML Print Preview. This uses the fledgling Dabo Report Writer to create a PDF rendition of the dataset. Added new property for all controls: StatusText. When set, and when the form has a status bar, that text will show in the form's status bar when the mouse enters the control. Expanded the dabo.ui.strToBmp() function to accept an optional scale factor or width/height values. If they are passed, the returned bitmap image is sized to those values. Added an optional parameter to the bizobj and cursor's getDataSet() method. If you send a list of field names, only those fields are returned. Fixed some lingering bugs in the dabo.ui.uiwx package and the datanav lib. dWizard works better now. Improved dGauge, dLine, dBox, dRadioBox, dListBox, dToolBar, and dSizers. Added simple decimal support to dTextBox. Work continues on dGrid, specifically dColumn is now better worked into the Dabo Way. Added dabo.trace() function, that will drop you into pdb. dConnectInfo reworked to have better property names. Removed dependency on PIL and reportlab from Dabo. These are dependencies still, but only if you try to run a report. Added dabo.lib.StopWatch.StopWatch class, which is a light Python stopwatch with start(), stop(), reset() methods and Value property. This is a partial list. Both Ed and Paul have been very busy with Dabo since 0.4 a few weeks ago. Lots of bugfixes and enhancements were made, and we encourage everyone to upgrade. --- In addition, we'd like to note that the minesweeper game in dabodemo has been greatly improved, and also the addition of the card game of montana. The development of these games are helping us iron out user interface issues that otherwise may have gone unnoticed. The AppWizard in daboide/wizards has also been updated to produce even better generated applications, ones that give the developer a starting structure that is relatively easy to tweak, modify, and augment. -- Paul McNett http://paulmcnett.com http://dabodev.com -- http://mail.python.org/mailman/listinfo/python-list