Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)
On 6/19/2012 6:07 AM, Wolfgang Keller wrote: And the lack of success of Python so far to replace, in your application case, Labview, or, in my application case, all those proprietary 4GL IDEs/frameworks/GUI builders (just check the success that Realbasic has) proves imho that the Python community has totally missed to address the vast crowd of potential users who are domain experts in other domains than software development. Sincerely, Wolfgang I have been compelled to occasionally use LV by my current employer. I do not know if LabView is the disease or is a symptom. It is an evil parasite and has resulted in a disaster at my place of employment and another that I am aware. As for 'designers' and 'builders', the discussion threads on Python gui builders is legion. In the end, the consensus is always to learn one and write the gui. Regardless of the multitude of clever gui libraries, event code in this language seems a bit contrived, and is attractive only to professional programmers. But the community must know that the language is used by hundreds of thousands of scientists and engineers that have a job to do, and do not have the time and have no interest in learning the frameworks du jour. This is why I see test and manufacturing engineers refuse to give up VB6 where Windows is required. I disagree with those that say Python can be used as a VB6 replacement. And the touted 'interactive' feature of Python does nothing for gui coding. It would not be difficult to convince me to commit homicide for a Delphi-like Python gui machine that runs on a Linux box. I have played with many - Boa, WxDes, Glade, Tk, Dabo, QtDesigner, Card, etc. Am currently experimenting with IronPython, because the factory boss says no more Linux boxes on his production lines. And the person that said Python is best tool for data acq/hw control needs to get out more. Very dangerous. C first, Python second. This is why I insist on only C and Python for the engineering lab, and use one of three proven pre-coded Tk-based GUIs for production and ATE drivers. You want to argue with me? First come visit my employer's TJ factory and watch the boys test 600kVA transformers or 250kVA inverters. 150,000 A of fault current. Brian -- http://mail.python.org/mailman/listinfo/python-list
import fails in non-interactive interpreter
I've been banging my head against this for the past hour, and I'm hoping someone here can set me straight. I have a virtualenv setup for a Pyramid app and I'm having trouble importing the paste.deploy module in a standalone, non-Pyramid script within the virtualenv. For testing purposes I have a one line "test.py" file: from paste.deploy import appconfig > python test.py ImportError: No module named paste.deploy but, using the same same python, I'm able to import the module from the interactive interpreter. The PATH and PYTHONPATH environment variables are identical in both contexts. Under what situations would a module be available to through the interactive interpreter but not the non-interactive? I greatly appreciate any thoughts, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Disable use of pyc file with no matching py file
On 2/2/2012 1:21 AM, Terry Reedy wrote: On 2/2/2012 1:42 AM, Devin Jeanpierre wrote: On Wed, Feb 1, 2012 at 2:53 PM, Terry Reedy wrote: And it bothers me that you imput such ignorance to me. You made what I think was a bad analogy and I made a better one of the same type, though still imperfect. I acknowledged that the transition will take years. Ah. It is a common attitude among those that make these sorts of comments about Python 3, and I hadn't read anything in what you said that made me think that you were considering more than the superficial costs of moving. I thought '95% in 10 years' would be a hint that I know upgrading is not trivial for every one ;-). I am sorry that I did not give you the benefit of the doubt. Apology accepted. This is OT, but relevant to the side discussion. Also note that the community respects and appreciates the T.J. Reedy contributions and hard work. Reality. It was a monumental task to convert ATE driver dev and related factory automation stuff from C to Python starting in 2000. Most was done guerrilla-style. My employer now appreciates the resultant infrastructure that even the Mexico factory engineering team can use, and is good for their pride because they are no longer totally dependent on gringo engineers. Am currently being disruptive to their little world with my recent (1Q 2011) switch to 3.x. The corporate natives are restless and there is talk of an armed insurrection. Humans, at the tribal level, do not adapt to change. Expect a long series of battles that are ruthless, bloody, and have a high body count. Vive la Revolution. -- http://mail.python.org/mailman/listinfo/python-list
Re: Yappi error "context not found"
Thanks - I've opened a ticket at http://code.google.com/p/yappi/issues/detail?id=21 -- http://mail.python.org/mailman/listinfo/python-list
Re: I'm happy with Python 2.5
While some may see this thread as troll candy, others may not. We want cake. And we need to eat it. Doing a lot of instrument control and data acquisition stuff. And a short dev period has same importance as short run time. As for the safety of those that dwell under and walk over bridges, yes I wrote a strain gage calibrator system that was used by a civil engr for monitoring a bridge. On 2/27/2011 6:27 AM, Tom Zych wrote: n00m wrote: Am I turmoiling your wishful thinking? You may nourish it till the end of time. Let us cease to nourish those fabled ones who dwell under bridges. -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for a good python module for MS SQL server
I've had good results with adodbapi as well. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQT installation
For those curious about Trolltech's stance on Windows, here's what Trolltech's "License FAQ - Open Source Edition" ( http://www.trolltech.com/developer/faqs/license_gpl.html ) has to say: " Why is there no Open Source (GNU GPL) version of Qt on Windows ? We have regrettably not found a way of making GPL versions for Windows available without risking the very business model we depend upon to be able to further develop and support Qt. Please note that if you make the source code for your project available and your license allows it, any holder of a commercial Qt Windows license can create binaries for your project. " -- http://mail.python.org/mailman/listinfo/python-list
Re: extreme newbie
Hi Cpunerd4, For beginners, I would strongly recommend checking out http://www.GreenTeaPress.com -- they publish a FREE, online book that is used in Highschools and other educational facilities to teach Python programming. Excellent -- a must have for those who wish to learn about the language. Brian --- cpunerd4 wrote: > Hello programmers, > I stumbled onto the python language by chance and it looks like a > great language. Although from what I've read so far (which isn't much) > I've guessed that python is purely an interpreted language unless its > compiled into another language (ie. it needs python installed in order > to run programs). Is this correct? If it is, I guess my plan of action > would be to use python embeded in java applets. > Another question I have: Does any one know any really good, really > easy to understand python books? I would prefer one that is avalible > online for free, but I would also like to know my choices in print. > Thanks in advance for any advice, > cpunerd4 > > P.S. I'm 14 and I know HTML, PHP, and I know about many others! > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python choice of database
I am really surprised that someone hasn't mentioned Gadfly yet. It is a quick, free, relational database written directly for Python itself. http://gadfly.sourceforge.net/ Brian --- Philippe C. Martin wrote: > Hi, > > I am looking for a stand-alone (not client/server) database solution for > Python. > > 1) speed is not an issue > 2) I wish to store less than 5000 records > 3) each record should not be larger than 16K > > > As I start with Python objects, I thought of using shelve, but looking at > the restrictions (record size + potential collisions) I feel I should study > my options a bit further before I get started. > > > Regards, > > Philippe > -- http://mail.python.org/mailman/listinfo/python-list
Re: Excellent Site for Developers
Do Re Mi chel La Si Do wrote: > rather... super troll 100% Agreed. Can anyone say, "This looks like spam... Feels like spam... and is about as useful here in the Python forums as spam -- therfore my conclusion is that his VB message probably IS SPAM." :-D Brian --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Boss wants me to program
Hi Xeys, Even though I absolutely love Python... Microsoft Visual Basic (.NET) would be your best bet for this type of software development. It allows you to create GUI apps that can work with a variety of database options, such as Access or MS SQL Server. My personal opinion is this: 1) Python shines the best on the server realm. 2) VB.net shines the best on the client-computer realm. Brian --- [EMAIL PROTECTED] wrote: > I'm a manager where I work(one of the cogs in a food service company). > The boss needed one of us to become the "tech guy", and part of that is > writing small windows programs for the office. He wants the development > work done in house, and he knows I am in school for a CS minor. I know > basic C++(Part 2 of that is in the fall), and I will be taking Java 1 > in the fall also. What is the easiest way for me to make windows > programs that will do basic things like(Inventory, Menu Management, > etc...)? I have heard visual basic is where it's at. I want to keep an > open mind though, so I am wondering if python could be an option. The > programs have > no speed requirement. But they must be pretty, and not confuse my > boss. Plus he wants well documented help for each function. I asked the > windows programming group, but I thought I would ask here also. Thanks. > > Xeys > -- http://mail.python.org/mailman/listinfo/python-list
Re: Boss wants me to program
Thomas Bartkus wrote: > I would modify that. > > 1) VB shines in the MS Windows/Office realm. > 2) Python shines everywhere else. True. However, it's also important to remember that most computer systems (at least in the United States) come with Microsoft Windows installed on them. You have to write software for the platform that one will be working with -- in most cases, that's Microsoft Windows. :-) Brian --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Better console for Windows?
The alt-enter tip is handy, although I must say on multiple monitors it's not so helpful. It full screens all of them (cloned across screens), at least on my nVidia card. I'm sure you're all sympathizing with my multiple monitor problem ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: I need help figuring out how to fix this code.
Hi Nathan, Please see my comments listed below. Nathan Pinno wrote: > print "Program Author: Nathan Pinno" > print "ID# 2413448" > print > print "Program 3 - Loops and IF Conditions" > print > password = raw_input("Type in the password, please: ") > while password != "hello": > print "Incorrect password!" At this point, you need to add the following statement again: password = raw_input("Type in the password, please: ") Otherwise, it just keeps stating "Incorrect password!" forever without giving the user the ability to re-enter another password attemp / try. > print "Welcome to the second half of the program!" > name = raw_input("What is your name, please? ") > if name == "Nathan": > print "What a great name!" > elif name == ["Madonna", "Cher"]: > print "May I have your autograph please!" > else > print name,", that's a nice name!" Remove the tab indentions in front of the "if", "elif", and "else" statements. This will cause an error in your program. The only time that you need to indent is the code following the if statements. if name == "Steven": print "Then I indent this code here." else: print "This is another coded statement here." > Thanks, > Nathan Pinno You're welcome, Nathan! Hope this helps (HTH), Brian --- -- http://mail.python.org/mailman/listinfo/python-list
Re: When someone from Britain speaks, Americans hear a "British accent"...
Steven, Very well written... I enjoyed reading your post! Brian --- Steven D'Aprano wrote: > On Tue, 28 Jun 2005 11:27:40 -0700, muldoon wrote: > > >>Americans consider having a "British accent" a sign of sophistication >>and high intelligence. Many companies hire salespersons from Britain to >>represent their products,etc. Question: When the British hear an >>"American accent," does it sound unsophisticated and dumb? > > > Which American accent? > > Texan? Georgian cracker or Maine fisherman? New York taxi driver? Bill > Clinton or Jesse Jackson or George W Bush? California Valley girl, > Arkansas redneck or boyz from th' hood? Paris Hilton or Queen Latifah? > > >>Be blunt. We Americans need to know. Should we try to change the way we >>speak? Are there certain words that sound particularly goofy? Please >>help us with your advice on this awkward matter. > > > Speaking as an Australia, the typical "film voice" (eg Harrison > Ford, Tom Cruise, etc) doesn't sound unsophisticated. In fact, when we > hear it, it doesn't sound like an accent at all, such is the influence of > Hollywood. (Which is linguistically impossible, of course, since *every* > way of speaking is by definition an accent.) The Hollywood voice is a > mixture of West Coast and very light mid-Western. > > But as for the rest of you, yes, you sound -- strange. It depends on the > specific regional accent. At best, just different. At worst, dumber than a > box of hammers. Which is of course unfair: there is no connection between > accent and intelligence. But by gum, some accents just sound dumber than > others. My fiancee, from Ireland, has worked and lived in the USA for half > her life, and to her you all sound like Kermit the Frog and Miss Piggy. > > Lest anyone gets offended, I should point out that every English-speaking > country have accents which are considered by others to mark the speaker as > a thick yokel. In Ireland, they look down on Kerrymen. In England, even > Yorkshiremen look down on Summerset, Devon and Dorset accents. And there > is nothing as thick-sounding as a broad Ocker Aussie accent. > > But don't worry, there is one thing we all agree on throughout the > English-speaking world: you Americans don't speak English. > > There are a few things that you can do to help: > > Herb starts with H, not E. It isn't "ouse" or "ospital" or "istory". It > isn't "erb" either. You just sound like tossers when you try to pronounce > herb in the original French. And the same with homage. > > Taking of herbs, there is no BAY in basil. And oregano sounds like Ray > Romano, not oh-reg-ano. > > And please, fillet of fish only has a silent T if you are speaking French. > > Aluminium is al-u-min-ium, not alum-i-num. > > Scientists work in a la-bor-atory, not a lab-rat-ory, even if they have > lab rats in the laboratory. > > Fans of the X-Men movies and comics will remember Professor Charles > Xavier. Unless you are Spanish (Kh-avier), the X sounds like a Z: Zaviour. > But never never never Xecks-Aviour or Eggs-Savior. > > Nuclear. Say no more. > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Defending Python
Raymond Hettinger wrote: > So, I would recommend Python to these > folks as an easily acquired extra skill. I agree 100% with your statement above. Python may not be sufficient for being the only programming language that one needs to know -- yet, it does come in VERY handy for projects that need to perform tasks on non-Microsoft operating systems. :-) Brian --- -- http://mail.python.org/mailman/listinfo/python-list
Hello
The message cannot be represented in 7-bit ASCII encoding and has been sent as a binary attachment. -- Virus Warning Message (on cse.iitkgp.ernet.in) body.scr is removed from here because it contains a virus. --- http://mail.python.org/mailman/listinfo/python-list
Re: Success using Python .NET with py2exe?
I haven't spent any time recently with it, but I seem to recall having more success using cx_Freeze for packaging than with py2exe (when using Python.NET). In the time since I then, I suspect all of the packagers have gotten more sophisticated, and you might have more options. A good place for questions like these is the Python.NET list: http://mail.python.org/mailman/listinfo/pythondotnet -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython tutorials
Raghul, The second link Harlin gave is to the wxPython wiki - it has a variety of pages with information about the toolkit including a number of tutorial pages. The "Getting Started" document linked on the main page is pretty thorough. Once you comfortable with some of the basic concepts, I'd suggest looking through the wxPython demo code. Find something interesting in the demo, then look at the associated "Demo Code" tab to see how it's implemented. In case you have any questions, the wxpython-users list is a great source of information for wxpython beginners as well as more advanced users. It's archived in a few different locations (some are easier to read or search than others): Via wxwidgets.org http://lists.wxwidgets.org/cgi-bin/ezmlm-cgi/11 Via ActiveState http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/wxPython-users Via Gmane http://dir.gmane.org/gmane.comp.python.wxpython -- http://mail.python.org/mailman/listinfo/python-list
Need help
I am working with a 3rd party credit card company that is using Python version 2.2.2. They are using the httplib module to post data to my server which is a dedicated server with no firewall or any rate-limiting or DDoS prevention. Every time they try, the first 2 posts are successful and it always throws this error on the third attempt. It is reproducable every time they run the program. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help
They tell me the error is Recv Timed Out. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help
I totally agreebut that being said...I want to make sure its not something on my server causing the problem. Im on a windows 2003 server. Let me also throw this into the mixbefore we went down the HTTP post route we first tried to post data directly into MSSQL, but we were getting connection errors. Im inquiring with "them" if they also used Python to do this, Im assuming the answer is yes. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help
When you say tools, can you give me one in particular that I can install on my server to do what you were mentioning? -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help
Got code from the 3rd party, maybe someone can see something wrong with it: def sendDataHTTP( url, postData ): # url format: http://www.blah.com/notrealurl # postData is either a dictionary or list of dictionaries # that contain the data that you want to post. responseList = [] urlList = urlparse.urlparse( url ) host = urlList[1] scriptPath = urlList[2] if not type( postData ) == list: postData = [ postData ] headers = { "Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain" } conn = httplib.HTTPConnection( host ) for thisDict in postData: params = urllib.urlencode( thisDict ) conn.request("POST", scriptPath, params, headers ) response = conn.getresponse() responseList.append( (response.status,response.reason) ) conn.close() return responseList -- http://mail.python.org/mailman/listinfo/python-list
Ack! Zombie processes won't die!
>From one script, I'm spawnv'ing another that will launch mpg123 to play a specified mp3. Problem is that After the second script has launched mpg123, it'll turn into a zombie process. It doesn't happen when I launch it from the command line, so there's something wrong with the way I'm calling it (I believe). mp3pid = os.spawnv(os.P_NOWAIT, "/oter/playfile.py", ["playfile", filename, "0"]) Shouldn't this launch the script without waiting for it to finish? -- http://mail.python.org/mailman/listinfo/python-list
Detecting if a program is currently running.
On a Slackware 9.1 box, I'm trying to detect if mpg123 is currently running/playing a song so that when the song is done, it'll play the next in the list. The problem is that popen'ing ps doesn't always give a correct return. My function is below and I added a second check that runs 1 second later which sometimes works, sometimes doesn't. Here's my function: def pid_defunct(): #1 = defunct processes #2 = show is currently playing #0 = no mpg123 processes found t = os.popen( "ps axc | grep '[mpg123] '" ).read() if len(t) > 0: return 1 else: t = os.popen( "ps axc | grep 'mpg123'" ).read() if len(t) > 0: return 2 else: print "Check 1: mpg123 is dead" #Check twice, because popen doesn't always return #correct value time.sleep(1) t = os.popen( "ps axc | grep 'mpg123'" ).read() if len(t) > 0: print "Check 1 was wrong" return 2 else: print "Check 2: mpg123 is dead" return 0 This function is run during each iteration of a loop with a time.sleep(1) executed right before it. Is there a better way to make this work? -- http://mail.python.org/mailman/listinfo/python-list
Re: Detecting if a program is currently running.
Thanks, that does the trick. Mike Meyer <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Yeah, but it takes work on both ends. You could wrap your mpg123 in a > shell script like so: > > #!/bin/sh > mpg123 "$@" & > echo $! >/tmp/mpg123.pid > > > Or in python 2.4: > > #!/usr/bin/env python > from subprocess import Popen > > p = Popen('mpg123') > pidfile = file('/tmp/mpg123.pid', 'w') > pidfile.write("%d" % p.pid) > pidfile.close() > > Then have your check program do (again, using the 2.4 subprocess > module) > > from subprocess import Popen, PIPE > > try: > pidfile = file('/tmp/mpg123.pid') > except IOError: > print 'mpg123 is dead' > else: > pid = pidfile.read() > t = Popen('ps p %s' % pid, shell=True, stdout=PIPE).stdout > if t.readlines() < 2: > print 'mpg123 is dead' > os.remove('/tmp/mpg123.pid') > return 0 > return 2 > > Basically, instead of trusting grep to find mpg123, save the pid in a > file and let ps find it (or not) by pid. > > http://mail.python.org/mailman/listinfo/python-list
Re: Best editor?
Yes, we vi/vim users are apparently extraordinary. Is that such a sad thing? ;-) -- http://mail.python.org/mailman/listinfo/python-list
what is Jython?
I tried to find out more on the internet but didn't have much success. All I know is that its a combination of Python and Java. Is it more Java than Python or the other way around? Is Jython free like Python? Is the programming language for Jython similar to Python or similar to Java? Are there pros and cons then switching from Python to Jython? -- Regards Brian -- https://mail.python.org/mailman/listinfo/python-list
Python 3 and the requests library
On the Mac running Mavericks, I have successfully managed to install and use the requests library for HTTP and HTTPS requests using Python 2. But I'd like to move to Python 3. I downloaded the most recent stable version of Python 3 for Mac. All is well. I did a pip3 install requests command and it worked. I could then start the interpreter and perform a simple HTTP GET request: $ python3 Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import requests >>> r = requests.get("http://www.google.com";) >>> r So, with that success, I created an executable script filled with the same commands: #!/usr/bin/env python3 import requests r = requests.get("http://www.google.com";) print(r) At first it failed because it couldn't find httplib2. Not sure why, but I installed httplib2 and now get the following error: $ ./test.py Traceback (most recent call last): File "test.py", line 3, in import requests File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/__init__.py", line 53, in from .packages.urllib3.contrib import pyopenssl File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/__init__.py", line 3, in from . import urllib3 File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/__init__.py", line 10, in from .connectionpool import ( File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 2, in import logging File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 26, in import sys, os, time, io, traceback, warnings, weakref, collections File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/traceback.py", line 3, in import linecache File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/linecache.py", line 10, in import tokenize File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py", line 40, in __all__ = token.__all__ + ["COMMENT", "tokenize", "detect_encoding", AttributeError: 'module' object has no attribute '__all__' Here is the full list of installed packages that I have in python3 (the list in python2 is huge and not posted here): $ pip3 list httplib2 (0.9) pip (1.5.6) requests (2.5.1) setuptools (2.1) urllib3 (1.10) Notre that if I change python3 to python in my script, it works fine using the default Python 2.7.5 version. And as a Plan B I can stay with Python 2.7.5. But I'd really like to move to Python 3 on the Mac. Thanks in advance for any thoughts or help! Brian -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 and the requests library
I am also seeing this in my Mac Mavericks Python 3 installation when I use just the built-in logging library. Again, a tiny example executable script and the results: $ cat test2.py #!/usr/bin/env python3 import logging logging.info("TEST2 starting") $ ./test2.py Traceback (most recent call last): File "./test2.py", line 3, in import logging File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 26, in import sys, os, time, io, traceback, warnings, weakref, collections File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/traceback.py", line 3, in import linecache File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/linecache.py", line 10, in import tokenize File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py", line 40, in __all__ = token.__all__ + ["COMMENT", "tokenize", "detect_encoding", AttributeError: 'module' object has no attribute '__all__' Googling hasn't helped track this one down. In lieu of an answer, some pointers to tools or other things to look for would be greatly appreciated. Thanks! Brian -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 and the requests library
Zach, Here is what I get on the Mac: $ python3 -c "import token;print(token.__file__)" /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/token.py Just for grins, I also ran it against the built-in Python 2.7.5 version: $ python -c "import token;print(token.__file__)" /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/token.pyc The only difference seems to be that the 2.7.5 version has precompiled it. Then I followed your example but ran it against the logging module instead, as that seems to be where the problem lies. Again, for both version (broken 3 and working 2) as a comparison: $ python3 -c "import logging;print(logging.__file__)" /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py $ python -c "import logging;print(logging.__file__)" /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.pyc But nothing is pointing to anything except what appears to be the formally installed versions of these library modules. Brian -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 and the requests library
Thank you, Ian and Zack! That was exactly the issue. Apparently, having a token.py script (one of my first Python 2 scripts to get an authorization token from a billing server) is OK for Python 2 but breaks Python 3. *face palm* Thank you again so very much! Brian On Monday, February 9, 2015 at 3:59:11 PM UTC-5, Ian wrote: > On Mon, Feb 9, 2015 at 1:37 PM, Brian wrote: > > Zach, > > > > Here is what I get on the Mac: > > > > $ python3 -c "import token;print(token.__file__)" > > /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/token.py > > Are you running this from the same directory where you have your test > scripts (in case there is also a token module hanging around in that > directory)? -- https://mail.python.org/mailman/listinfo/python-list
Python client support for NATS.io
Hello all...we're updating our Python client support at NATS.io cloud messaging project, and as part of that would like to get your input on which version of Python: https://groups.google.com/forum/#!topic/natsio/e6aoJ6GYqTw Thanks in advance to anyone who has a moment to let us know. Best, B -- https://mail.python.org/mailman/listinfo/python-list
Python and Outlook-style rules
I'm about to create a system which will need to allow hundreds of users to create and maintain their own rules in a similar fashion to MS Outlook rules. ie. Each rule consists of one or more user configurable conditions and if/ when the conditions are met then one or more user configurable actions will be applied. The conditions will be things like "a specified key in a dictionary is in a specified list of values" (where the user can choose the key and the values), or "a specific record is in the specified database" (where the user chooses the primary key of the record and the database table to look in). The actions will be things like "send an email to address" (where the user chooses the address and the email template to use). The user will do their configuration in a browser. Also, I need to be able to continue to add new conditions and actions to the system over time. Is there a python module (preferably free/open source) which already does (some of) this? I can write the back-end logic easily enough (although I'd rather not re-invent the wheel) but I'd particularly like to find a widget or similar which will make the front-end look nice and be cross-browser compatible. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Outlook-style rules
On Sep 9, 5:19 pm, Alec Taylor wrote: > Something like this? > > http://stackoverflow.com/questions/387606/using-user-input-to-find-in... > Actually, I'm looking for a framework or something similar - something more like this, only for python: http://www.codeproject.com/KB/macros/RulesWizard.aspx -- http://mail.python.org/mailman/listinfo/python-list
Re: Python crash when trying to generate an Excel worksheet with VBA macros
dan_roman wrote: > Hi, > I developed a script with a nice interface in Tkinter that allows me to > edit some formulas and to generate an Excel worksheet with VBA macros > within it. The script runs perfectlly in Office 2000, but in Office > 2003 crash at line: "wbc = workbook.VBProject.VBComponents.Add(1)" > Please help me :-( The Excel on the box you're testing this, have you set it to trust programmatic access to the VB Project? If you haven't, I wouldn't be surprised if that line would likely raise an exception. I'm pretty sure Excel's security model has changed a bit between 2000 and 2003, so perhaps this is what is biting you. -- http://mail.python.org/mailman/listinfo/python-list
Strange re problem on OSX but Not Linux
I have a very small script: import re text = open('eq.txt','r').read() regex = '[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]' pattern = re.compile(regex) match = pattern.findall(text) print ''.join(match) However, when I try to run it, I get this error: Traceback (most recent call last): File "/Applications/Komodo.app/Contents/SharedSupport/dbgp/bin/pydbgp", line 66, in import dbgp.client File "/Applications/Komodo.app/Contents/SharedSupport/dbgp/pythonlib/dbgp/client.py", line 44, in import traceback, re File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py", line 5, in # AttributeError: 'module' object has no attribute 'compile' --- Here is the error outside of Komodo: Traceback (most recent call last): File "reg1.py", line 1, in import re File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py", line 5, in # AttributeError: 'module' object has no attribute 'compile' -- This is running 2.5 on my OSX box. If I run it (again with 2.5) on my SUSE machine, I get no errors. I am sure that I have overlooked something trivial here - so please be gentle if it is on the stupid side of things. Thanks, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange re problem on OSX but Not Linux
Paul McGuire wrote: > "Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Dont use regex as a name. Also, do you have any script called "re.py" > > hidding that library module? or regex.py? > > My bet is that a local re.py is masking the lib module. (It's a shame this > error is so easy to trip over.) > > -- Paul I figured that one out so I renamed the file. Unfortunately it took me a while to realize that I needed to delete re.pyc as well. Brian -- http://mail.python.org/mailman/listinfo/python-list
TSV to HTML
I was wondering if anyone here on the group could point me in a direction that would expllaing how to use python to convert a tsv file to html. I have been searching for a resource but have only seen information on dealing with converting csv to tsv. Specifically I want to take the values and insert them into an html table. I have been trying to figure it out myself, and in essence, this is what I have come up with. Am I on the right track? I really have the feeling that I am re-inventing the wheel here. 1) in the code define a css 2) use a regex to extract the info between tabs 3) wrap the values in the appropriate tags and insert into table. 4) write the .html file Thanks again for your patience, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: TSV to HTML
First let me say that I appreciate the responses that everyone has given. A friend of mine is a ruby programmer but knows nothing about python. He gave me the script below and it does exactly what I want, only it is in Ruby. Not knowing ruby this is greek to me, and I would like to re-write it in python. I ask then, is this essentially what others here have shown me to do, or is it in a different vein all together? Code: class TsvToHTML @@styleBlock = <<-ENDMARK td { border-left:1px solid #00; padding-right:4px; padding-left:4px; white-space: nowrap; } .cellTitle { border-bottom:1px solid #00; background:#e0; font-weight: bold; text-align: center; } .cell0 { background:#eff1f1; } .cell1 { background:#f8f8f8; } ENDMARK def TsvToHTML::wrapTag(data,tag,modifier = "") return "<#{tag} #{modifier}>" + data + "\n" end # wrapTag def TsvToHTML::makePage(source) page = "" rowNum = 0 source.readlines.each { |record| row = "" record.chomp.split("\t").each { |field| # replace blank fields with field.sub!(/^$/," ") # wrap in TD tag, specify style row += wrapTag(field,"td","class=\"" + ((rowNum == 0)?"cellTitle":"cell#{rowNum % 2}") + "\"") } rowNum += 1 # wrap in TR tag, add row to page page += wrapTag(row,"tr") + "\n" } # finish page formatting [ [ "table","cellpadding=0 cellspacing=0 border=0" ], "body","html" ].each { |tag| page = wrapTag(@@styleBlock,"head") + page if tag == "html" page = wrapTag(page,*tag) } return page end # makePage end # class # stdin -> convert -> stdout print TsvToHTML.makePage(STDIN) -- http://mail.python.org/mailman/listinfo/python-list
Re: TSV to HTML
Dennis, Thank you for that response. Your code was very helpful to me. I think that actually seeing how it should be done in Python was a lot more educational than spending hours with trial and error. One question (and this is a topic that I still have trouble getting my arms around). Why is the text in STYLEBLOCK tripple quoted? Thanks again, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: TSV to HTML
Dennis Lee Bieber wrote: > On 1 Jun 2006 03:29:35 -0700, "Brian" <[EMAIL PROTECTED]> declaimed the > following in comp.lang.python: > > > Thank you for that response. Your code was very helpful to me. I > > think that actually seeing how it should be done in Python was a lot > > more educational than spending hours with trial and error. > > > It's not the best code around -- I hacked it together pretty much > line-for-line from an assumption of what the Ruby was doing (I don't do > Ruby -- too much PERL idiom in it) > > > One question (and this is a topic that I still have trouble getting my > > arms around). Why is the text in STYLEBLOCK tripple quoted? > > > Triple quotes allow: 1) use of single quotes within the block > without needing to escape them; 2) allows the string to span multiple > lines. Plain string quoting must be one logical line to the parser. > > I've practically never seen anyone use a line continuation character > in Python. And triple quoting looks cleaner than parser concatenation. > > The alternatives would have been: > > Line Continuation: > STYLEBLOCK = '\n\ > \n\ > td {\n\ > border-left:1px solid #00;\n\ > padding-right:4px;\n\ > padding-left:4px;\n\ > white-space: nowrap;}\n\ > .cellTitle {\n\ > border-bottom:1px solid #00;\n\ > background:#e0;\n\ > font-weight: bold;\n\ > text-align: center; }\n\ > .cell0 { background:#3ff1f1;}\n\ > .cell1 { background:#f8f8f8;}\n\ > \n\ > ' > Note the \n\ as the end of each line; the \n is to keep the > formatting on the generated HTML (otherwise everything would be one long > line) and the final \ (which must be the physical end of line) > signifying "this line is continued". Also note that I used ' rather than > " to avoid escaping the " on text/css. > > Parser Concatenation: > STYLEBLOCK = ( > '\n' > "td {\n" > "border-left:1px solid #00;\n" > "padding-right:4px;\n" > "padding-left:4px;\n" > "white-space: nowrap;}\n" > ".cellTitle {\n" > "border-bottom:1px solid #00;\n" > "background:#e0;\n" > "font-weight: bold;\n" > "text-align: center; }\n" > ".cell0 { background:#3ff1f1;}\n" > ".cell1 { background:#f8f8f8;}\n" > "\n" > ) > > Note the use of ( ) where the original had """ """. Also note that > each line has quotes at start/end (the first has ' to avoid escaping > text/css). There are no commas separating each line (and the \n is still > for formatting). Using the ( ) creates an expression, and Python is nice > enough to let one split expressions inside () or [lists], {dicts}, over > multiple lines (I used that feature in a few spots to put call arguments > on multiple lines). Two strings that are next to each other > > "string1" "string2" > > are parsed as one string > > "string1string2" > > Using """ (or ''') is the cleanest of those choices, especially if > you want to do preformatted layout of the text. It works similar to the > Ruby/PERL construct that basically said: Copy all text up to the next > occurrence of MARKER_STRING. Thank you for your explanation, now it makes sense. Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Replace one element of a tuple (LONG)
Captain Dondo wrote: > What I'd like to do is build the correct selectlist in the first place, > rather than build the wrong one and then rebuild a correct one. This is sounding more like a SQL/DB problem and less like a Python one. If you have a field that is being pulled from the database that you would like to do a substitution on, I'm fairly sure MySQL includes a CASE statement in their flavor of SQL. Instead of performing a SELECT * in your script you could select the individual fields you want, and instead of just pulling the problematic column as is, you could pull it as something like "select case when sourcehost = x then y else sourcehost end case, ...". Naturally if an entire column needs to be replaced with a static value, you won't even need to use CASE. HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: Are there something like "Effective Python"?
You might want to give this site a look: http://www.livewires.org.uk/python/ -- http://mail.python.org/mailman/listinfo/python-list
calling functions style question
I just have a basic style question here. Suppose you have the program: def foo1(): do something def foo2() do something else Assume that you want to call these functions at execution. Is it more proper to call them directly like: foo1() foo2() or in an if __name__ == "__main__": ? Both will execute when the script is called directly, I was just wondering if there is a preference, and what the pros and cons to each method were. Thanks, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Django Quick Start with Schema Evolution Support
Ilias Lazaridis wrote: > http://lazaridis.com I would agree with you that this is a place to discuss python. However, your posts primarily deal with your expulsion from another group. Instead of discussing that, why don't your discuss the python technicalities of your project and leave the rest alone since we want to hear about the former and not the later. Brian -- http://mail.python.org/mailman/listinfo/python-list
creating and naming objects
I have a question that some may consider silly, but it has me a bit stuck and I would appreciate some help in understanding what is going on. For example, lets say that I have a class that creates a student object. Class Student: def setName(self, name) self.name = name def setId(self, id) self.id = id Then I instantiate that object in a method: def createStudent(): foo = Student() /add stuff Now, suppose that I want to create another Student. Do I need to name that Student something other than foo? What happens to the original object? If I do not supplant the original data of Student (maybe no id for this student) does it retain the data of the previous Student object that was not altered? I guess I am asking how do I differentiate between objects when I do not know how many I need to create and do not want to hard code names like Student1, Student2 etc. I hope that I am clear about what I am asking. Thanks, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: creating and naming objects
Thank you all for your response. I think that I am getting it. Based on those responses, would I be correct in thinking that this would be the way to initialize my Student object and return the values? class Student: def __init__(self, name, id): self.name = name self.id = id def getName(self): return self.name def getId(self): return self.id Additionally, correct me if I am wrong but I can recycle: foo = Student() And doing so will just create a new instance of Student (with whatever attributes it is given) and the original foo is gone? Thanks for your help and patience. After reading my original post and then this one, I could see that it may look suspiciously like a home work assignment. Trust me it's not. The student example just seemed like a good fit to discuss this. Thanks again, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: creating and naming objects
Maarten van Veen wrote: Hi Brian, > > If you would do it like this: > Class Student: > def setName(self, name) > self.name = name > def setId(self, id) > self.id = id > > > def createStudent(): > foo = Student() > foo.setName("Brian") > foo = Student() > print foo.getName() > > You would get an error here, because foo now equals the second Student > object which has no name. And you can't get to the first one. > Perhaps you could do something like this. > > Class Student: > def setName(self, name) > self.name = name > def setId(self, id) > self.id = id > > listWithStudents = [] > > def createStudent(): > listWithStudent.append(Student()) > > Now every student you create is put in the list with students so you can > access them but don't have to give them names. > You could do something to all of them like this: > for student in listWithStudent: >student.doSomething() > > Or change just one student: > listWithStudent[23].doSomething() # this is the 24th student though!!! > > Hope this is what you're looking for. > Maarten This is of great help. Thank you, Brian -- http://mail.python.org/mailman/listinfo/python-list
upgrading python on virtual hosting server
Hello, I have a dedicated linux server with several virtual domains on it. These domains are chrooted for security. I need to upgrade python and be able to have it available for all accounts. I am also concerned that I may muck up some of the server processes that use python. Can someone tell me: 1) Where should I do the install? 2) How do I make sure that the new version is available to all users? 3) What do I need to do to make sure that current services can use the new version? Thank you, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: XBox 360 free SDK (XNA) and IronPython
> IronPython won't work on the XBox 360. Yup. Perhaps sometime in the future. A few weeks ago Albert Ho, MS XNA program manager wrote the following on the MSDN XNA Game Studio Express forum: "Because the Xbox 360 uses a special port of the .NET CF, the LCG method-generation functionality isn't available -- unfortunately IronPython won't work on the Xbox 360 today. We are planning on investigating this for future releases." -- http://mail.python.org/mailman/listinfo/python-list
Working with unsigned/signed types
Hi everyone- I've been away from coding for a while (I turned into a professional photographer)... So now I've taken up a project involving working with EXIF and XMP metadata in image files (mainly JPEG and TIFF), and am having some trouble figuring out how to handle some of the data... Here's what I'm having to do: Inside the files, there are various types of data which can be split apart and organized fairly easily, given you have unsigned and signed types... Which is where I'm running into problems remembering how everything works. The first part of the question is fairly basic - in C, working with signed integers, the MSB (is that still the right term?) is used to denote positive and negative, and the following bits increase towards positive infinity, correct? Such that in C, adding one to 0x7fff would cause the number to go around to -0x7fff (or whatever that is), giving -1 for 0x? Secondly, (and this is my weak point as a programmer) to re-insert the data after, what would be the most efficient way to pull everything back apart into individual characters for putting it all back into the files? I could probably figure out something that would work, but I wouldn't be so sure as to its reliability. Third, being a photographer now rather than a coder, I'd like to give back the modules I'm writing to the community (it looks like very little of the sort exists), but would rather not worry about them in the future... Is there a good way to go about this? Thanks! -Brian Shirk Avalanche Photography LLC www.AvalanchePhoto.com McCall, Idaho -- http://mail.python.org/mailman/listinfo/python-list
Re: Working with unsigned/signed types
That seems like it'll do the trick quite well. As far as the future generations go, there's no question as to whether it would last if it were on my site - there are always changes being made to it and I'm not expecting it to be very stable over the course of time, especially since it would confuse the heck out of a bride trying to find her pictures if she stumbled on it... Is there a repository of some sort available for this sort of thing anywhere? Thanks! -Brian On Tue Dec 19 22:07 , Ben Finney <[EMAIL PROTECTED]> sent: >[EMAIL PROTECTED]> writes: > >> The first part of the question is fairly basic - in C, working with >> signed integers, the MSB (is that still the right term?) is used to >> denote positive and negative, and the following bits increase >> towards positive infinity, correct? Such that in C, adding one to >> 0x7fff would cause the number to go around to -0x7fff (or >> whatever that is), giving -1 for 0x? >> >> Secondly, (and this is my weak point as a programmer) to re-insert >> the data after, what would be the most efficient way to pull >> everything back apart into individual characters for putting it all >> back into the files? I could probably figure out something that >> would work, but I wouldn't be so sure as to its reliability. > >I think, from the above, that you want to read about the 'struct' >module in the standard library. > >http://docs.python.org/lib/module-struct.html> > >> Third, being a photographer now rather than a coder, I'd like to >> give back the modules I'm writing to the community (it looks like >> very little of the sort exists), but would rather not worry about >> them in the future... Is there a good way to go about this? > >Ideally, find someone who will actively maintain the code into the >foreseeable future; maybe a user of the code with more interest in >programming than you. > >Failing that, find a place to put it online for the foreseeable >future, and notify repositories like Freshmeat >http://freshmeat.net/> of its existence and location. > >The most important thing to do is to explicitly license the rights to >modify and redistribute freely for all people who receive the code, so >they never have to try to track you down for permission. > >Choose a permissive license like the Expat license >http://www.jclark.com/xml/copying.txt> if you want to allow >people to do just about anything except claim you didn't write it; >choose a copyleft like the GNU General Public License >http://www.gnu.org/copyleft/gpl.html> if you want to ensure >nobody can redistribute under more restrictive terms in future. > >Make each file clearly marked so that the grant of license is clear, >and include the text of the license terms in an obvious file in the >source code package. See the addendum of the GNU GPL for how this is >best done, even if you end up not choosing that particular license. > >Thanks for thinking of the future hackers :-) > >-- > \ "...one of the main causes of the fall of the Roman Empire was | > `\that, lacking zero, they had no way to indicate successful | >_o__) termination of their C programs." -- Robert Firth | >Ben Finney > >-- >http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting started with Crystal Reports...little help in the far court.
Mudcat wrote: > I am not that familiar with Crystal Reports, but having read some other > posts I know that the way to integrate the API with Python is through > the COM interface provide by win32all. > Any pointers in the right direction would be helpful. Like Armury, I worked on Crystal stuff quite a long time ago. Here's a script I was able to dig up. Edited to protect the innocent. ;-) import sys from win32com.client import Dispatch app = Dispatch('CrystalRunTime.Application') rep = app.OpenReport('foo.rpt') tbl = rep.Database.Tables.Item(1) prop = tbl.ConnectionProperties('Password') prop.Value = sys.argv[1] prop = tbl.ConnectionProperties('Data Source') prop.Value = 'server' # tbl.TestConnectivity() should return 1 # clear and set 3 parameters params = rep.ParameterFields p1 = params(1) p2 = params(2) p3 = params(3) for param in (p1,p2,p3): param.ClearCurrentValueAndRange() p1.AddCurrentValue(123) p2.AddCurrentValue(456) p3.AddCurrentValue('12/31/99') rep.PrintOut(promptUser=False) -- http://mail.python.org/mailman/listinfo/python-list
float formatting
Hello all, I am a bit stuck with a float formatting issue. What I want to do is print a float to the screen with each line showing one more decimal place. Here is a code snip that may explain it better: #!/usr/bin/env python num1 = 32 num2 = 42.98765 for i in range(2,7): print "|" + "%10.3f" % num2 + "|" In the for loop, is the line with my difficulty. In a perfect world it would read something like this: for i in range(2,7): print "|" + "%10.if" % num2 + "|" #where i would be the iteration and the num of decimal places However, if I do that I get errors saying that all args were not converted during string formatting. An escaped 'i' does not work either. Any thoughts would be appreciated. Thanks, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: float formatting
Thanks guys, that really helped. Am I to assume that the * references the args in the parens? Thanks, Brian -- http://mail.python.org/mailman/listinfo/python-list
Strange behavior of int()
Hello, Can someone tell me what I am doing wrong in this code. If I create a file change.py with the following contents: def intTest(M, c): r = M for k in c: print 'int(r/k) = ', int(r/k), 'r =', r, 'k =', k, 'r/k =', r/k r = r - (k*int(r/k)) intTest(2.30, [0.25, 0.10, 0.05, 0.01]) and execute it, I get the output: int(r/k) = 9 r = 2.3 k = 0.25 r/k = 9.2 int(r/k) = 0 r = 0.05 k = 0.1 r/k = 0.5 int(r/k) = 0 r = 0.05 k = 0.05 r/k = 1.0 int(r/k) = 4 r = 0.05 k = 0.01 r/k = 5.0 Why is int(r/k), where r = 0.5 and k = 0.5 = 0? Shouldn't it be 1? And why is the last one = 4 and not 5? If I execute a similar command from the command line, it works just fine: >>> int(0.05/0.05) 1 I have tested this on Linux, python 2.3.2 and 2.4.1 and Windows python 2.4.2 all with the same results. I think I am doing something wrong in this line: r = r - (k*int(r/k)) Thanks for any help. Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe and library.zip
> > >The zip file essentially contains the whole system in on lump. Change > >the system, and naturally your users will have to download the whole > >lump again. [...] > > > but if it was just a dir, when they update from the svn at log in, all > they do is download the extra\changed files. much much quicker then > downloading a 4 meg uncompressed zip file. Not clear what you are really asking for, but maybe this will help. I have a application that is 95% normal code, packaged up via py2exe. Other 5% is a few .py files in a separate directory, modified regularly by the users (report specifications in some lists/dicts). These files are *excluded* from the py2exe build, and I manually add this directory to sys.path during the application startup. A change to one of the spec files is picked up like any normal python session, and I don't need to rebuild the entire app. Could you do the same type of thing? Brian. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python suitable for a huge, enterprise size app?
john67 wrote: > [...] that will cost us tens-of-millions to develop. > [...] > Right now it looks like Java is the language of choice that the app > will be developed in. However, I have been looking and reading a lot > about Python recently [...] Ignoring the technical aspects: if you have good group of people that already know Java, and don't know Python, then use Java for this huge project. Do a smaller project in Python first for the learning curve, to build expertise and confidence, etc. People are more important than programming language. Brian. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best Web dev language
Hi Jon, Yes, there are a variety of tutorials on the Internet that can help you learning how to use Python with the web. Two of the best ones you can get for free by clicking on the link below. 1) http://www.devshed.com/c/a/Python/Writing-CGI-Programs-in-Python/ 2) http://www.devshed.com/c/a/Python/Python-on-the-Web/ However, in order to understand the tutorials above, it is important to first have a basic understanding of the Python programming language. Python is not hard to learn, but it might take you a few hours to learn it, if you have not done so already. 1) http://www.greenteapress.com/thinkpython/ 2) http://www.devshed.com/c/a/Python/ Hope this helps, Brian :-) --- Jon Slaughter wrote: > I'm trying to get into web development for creating a professional web site > and I'm confused on which language I should use. I've read some comparisons > between the major languages and I was thinking that python might be the way > to go for the most powerful and general language but I am not sure. Does > anyone know of any detailed and objective comparisons between the major > languages(perl, php, java, javascript, etc...) that might help me get a > clearer picture? > > I have some experience with C/C++ but it has been some time since I have > done any real programming... I'd prefer to use C++ style so I would no thave > to learn a new language completely. I've also read that one can use C/C++ > to develop just as one would use any other language and I'm wondering if > this is advisable? (since it seems most web pages are done in perl, python, > or php?) > > Also, can anyone recommend any book or web page that gives an introduction > to the method in which one programs web sites? I am not clear on who one, > for instance, would use C++ as the language for a web site except by using > it to create html... I'm not sure if basicaly all languages goal is creating > html dynamically or if there is more to do. What I mean is that basicaly > one is using some other language to wrap the html code or possibly generate > it at run-time for dynamic results. (so all client based web interfaces are > really just html readers but all this "extra" stuff is used to make certain > things easier and dynamic(just as generating tables and forms and all that). > > Thanks for any help, > Jon > > -- http://mail.python.org/mailman/listinfo/python-list
Re: cgi script runs under Opera, but not firefox
Yes, I agree that it is best to check the HTML source code of the page that is being generated. The server is obviously generating the code, but the difference here is how the two browsers are interpreting the HTML data. Check the source code for the HTML document. I bet the problem resides in the page itself. Brian --- [EMAIL PROTECTED] wrote: > Hey there, > i have a python cgi script that prints out html just fine in the Opera > browser > but doesnt print at all under FireFox. > weird, eh? > i am getting nothing in the apache logs about any error. > perhaps its a firefox issue, but i doubt it. > > any suggestions. simple script here.. > -- http://mail.python.org/mailman/listinfo/python-list
Re: cgi script runs under Opera, but not firefox
Bingo, found it! Notice that you accidentally close the document before displaying any information... [EMAIL PROTECTED] wrote: > > Customer Data > > > Watkins Crop Consulting > > Notice the tag above. There's the problem! Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: What language to manipulate text files
Hi Roose, Actually, it is a good thing because it allows those who know the Python language to be able to show the benefits and weaknesses of the language. Sure, the attitude here will be "Yes, it's a great language." Yet, at the same time, it also enables the poster to be able to see potential benefits to Python that he or she may not of been aware of. If we don't let others know about the benefits of Python, who will? Brian --- Roose wrote: > Why do people keep asking what language to use for certain things in the > Python newsgroup? Obviously the answer is going to biased. > > Not that it's a bad thing because I love Python, but it doesn't make sense > if you honestly want an objective opinion. > > R -- http://mail.python.org/mailman/listinfo/python-list
Re: checking for when a file or folder exists, typing problems?
Hi Bryan, Here's a potential idea. Try converting the variable to a string by using the following syntax: thePath = str(thePathArg) This will convert the current variable type to a string, which follows the data type syntax that you have specified at the beginning of your message. Hope this helps, Brian :-) --- Bryan Rasmussen wrote: > Hi > I have a little program that is importing from os.path import exists, join, > isdir, normpath, isfile > at one point in my program I check if a file exists using > if exists("c:\projects"): > > and that works fine. > > If I change it to be > if exists(thepath): > where thepath is a commandline argument it does not work fine. > > Note that the commandline is c:\projects and when I print thepath to check > what > is going on it prints > c:\projects > > The only thing I can assume is that there is some sort of typing problem going > on here, but then it should go ahead and give an error then if it's getting > something unexpected obviously. > > Any help on what this error is? > > Thanks > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python Suitable for Large Find & Replace Operations?
Hi Rbt, To give an example of processing a lot of data, I used Python to read and process every word in a single text file that contained the entire King James Bible version. It processed it within about one second -- split the words, etc. Worked quite well. Hope this helps, Brian --- rbt wrote: > Here's the scenario: > > You have many hundred gigabytes of data... possible even a terabyte or > two. Within this data, you have private, sensitive information (US > social security numbers) about your company's clients. Your company has > generated its own unique ID numbers to replace the social security numbers. > > Now, management would like the IT guys to go thru the old data and > replace as many SSNs with the new ID numbers as possible. You have a tab > delimited txt file that maps the SSNs to the new ID numbers. There are > 500,000 of these number pairs. What is the most efficient way to > approach this? I have done small-scale find and replace programs before, > but the scale of this is larger than what I'm accustomed to. > > Any suggestions on how to approach this are much appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: How should threads be terminated? (related to 'Help with thread related tracebacks')
Hi Maxwell, Yes, to terminate a thread in Python early, use the following: import sys; sys.exit(0) This kills the particular thread without wiping out the entire Python application. Hope this helps, Brian :-) --- Maxwell Hammer wrote: > Hi all, > > This is related to an earlier post 'Help with thread related > tracebacks'...for which I have had no feedback yet :-( > > How should a thread complete i.e. how should it exit? > Reading the python online docs one gets the idea that simply returning is > OK - but I'm not sure. > Is it ok to do a sys.ext()? Use 'return' or just let them run out with no > 'return' ??? > > thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: How should threads be terminated? (related to 'Help with thread related tracebacks')
Here's a site that provides an easy, *beginners* example of how to do threading. You might find this useful too... :-) http://www.codesampler.com/python.htm (Look for the "Spawning Threads" section.) Brian --- [EMAIL PROTECTED] wrote: > see http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65448 for a > useful recipe on how to do threading > -- http://mail.python.org/mailman/listinfo/python-list
Re: thread.start_new_thread question
Hi KV, Here's a site that provides an easy, beginners example of how to do threading. You might find this useful too... :-) http://www.codesampler.com/python.htm (Look for the "Spawning Threads" section.) Brian --- Konstantin Veretennicov wrote: > Hi, > > Just curious: > >>>>import thread >>>>help(thread.start_new_thread) > > . . . > start_new_thread(function, args[, kwargs]) > . . . > > Second argument is mandatory. Is it incidental or for a reason? > > - kv -- http://mail.python.org/mailman/listinfo/python-list
Text-To-Speech for the Mac (OS X)
Hello, Does anyone know how to get Python to be able to perform text-to-speech abilities for the Mac (OS X)? I have been searching Google, but have not found any helpful solutions or resources yet. Brian --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Text-To-Speech for the Mac (OS X)
Hi Graham, Ahh, that works! Thank you... :-) Brian --- Graham Dumpleton wrote: > On Jun 21, 9:41 am, Brian <[EMAIL PROTECTED]> wrote: >> Hello, >> >> Does anyone know how to get Python to be able to perform text-to-speech >> abilities for the Mac (OS X)? I have been searching Google, but have >> not found any helpful solutions or resources yet. > > os.system('say read the man page for "say"') > > :-) > > Graham > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Newbie Suggestions
What about "Learning With Python"? It was written by a high school teacher for teaching python in the classroom for absolute beginners. Best of all, it's FREE: http://www.greenteapress.com/ Byron --- [EMAIL PROTECTED] wrote: > I'm a mechanical engineer with little experience programming. I've > used C++ and machine language for getting micro-controllers to work > and thats about it. I work allot with software developers at my job > and can read C++ code pretty good (ie. I understand whats going on). > Does anyone have any good tips or resources for someone interested in > learning PYTHON. This is purely for hobby purposes and I'd like to > expose my kids to a programing language too. If any one has any > helpful books, tips or suggestions please let me know. I have > Windows, MAC and Linux box's at my house but I'm a primarily a MAC > user. > -- http://mail.python.org/mailman/listinfo/python-list
Newbie Question: Getting a list of files
Hello, I am currently working on putting together a free, open source, anti-spyware program for the Mac (and eventually for other OS's too.) However, there's one thing that I am currently trying to figure out: How do I, in Python, obtain a recursive list of files in a specified directory, including the subdirectories, etc? For example, in the old MS-DOS days, we could specify at the command prompt "DIR /S" and this would provide a listing of all files, including those in subdirectories, no matter how far down the branch they were. How can this be done with Python? P.S. I have been searching Google, but haven't found the answer yet. Any info appreciated! Dusty --- -- http://mail.python.org/mailman/listinfo/python-list
Re: transparent images
[EMAIL PROTECTED] wrote: > Does any one know how to make a transparent image with specifically > PIL, but any standard python library will do. I need a spacer, and it > has to be transparent. > > Thanks > Does this have to be done through Python? If not, you might enjoy GIMP (http://www.gimp.org), which can do this easily. Best of all, you can customize the size, etc. Dusty --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Question: Getting a list of files
Hi Steven, Thanks for all of the good advice! Much appreciated. Dusty --- Steven D'Aprano wrote: > On Tue, 15 May 2007 17:12:01 -0700, Brian wrote: > >> How do I, in Python, obtain a recursive list of files in a specified >> directory, including the subdirectories, etc? For example, in the old >> MS-DOS days, we could specify at the command prompt "DIR /S" and this >> would provide a listing of all files, including those in subdirectories, >> no matter how far down the branch they were. How can this be done with >> Python? > > In MS DOS days, you were dealing with a small number of files. Python has > to deal with file systems that could contain billions of files. If each > file name has an average of eight characters, your recursive list of > files could require a gigabyte of memory just to hold the file names. (It > might not, of course -- it depends on the file system in use.) > > I suggest you have a look at the os module, in particular os.listdir and > os.walk. > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Question: Getting a list of files
Thank you very much for your examples! Much appreciated. Dusty --- Ant wrote: > On May 16, 3:07 pm, Gerard Flanagan <[EMAIL PROTECTED]> wrote: > ... >> import os >> >> def iter_dirs(root, dirs=False): > ... > > Rather than rolling your own directory walker: > > The same iterator using os.walk: > > def iter_dirs(root, dirs=False): > for root, directories, files in os.walk(root): > if dirs: > for dir in directories: > yield os.path.join(root, dir) > for file in files: > yield os.path.join(root, file) > > > os.path.walk requires a different mindset: > > def visitor(yield_dirs, dirname, names): > for name in names: > pth = os.path.join(dirname, name) > if os.path.isfile(pth) or yield_dirs: > print pth > > os.path.walk(root, visitor, False) > > -- http://mail.python.org/mailman/listinfo/python-list
python 2.5 problems
Finally deleted 2.2 and loaded 2.5 (see below), using the msi, on my XP partition. Having intermittent system crashes. Assumed a corrupt download, so deleted and did another download/install. Same problems. The associated DLLs when XP says that it must shut down the idle shell are not consistent. So is there something not stable about ver 2.5 on XP ? Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Thanks very much from my cat and dog. -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 problems
Was not specific about my process. Yes, I did use the 'formal' windoze uninstall using Add/Remove Programs. I ran the same code and idle at work (XP Pro/SP2/Python 2.4) with no problems. My next step is to install python 2.5 at work. My Linux partition has Python 2.4, and I do not use idle on Linux, so the test would probably not be legit. any ideas/suggestions ??? Ant wrote: > On Sep 9, 6:57 pm, "O.R.Senthil Kumaran" <[EMAIL PROTECTED]> wrote: >>> Finally deleted 2.2 and loaded 2.5 (see below), using >> Dont delete. Uninstall python 2.2 and additional modules if you have >> installed them. > > But since you've already deleted 2.2, download and reinstall 2.2, > uninstall 2.2 and 2.5 via Add/Remove Programs and then reinstall 2.5 > again. > > -- > Ant... > -- http://mail.python.org/mailman/listinfo/python-list
Python too complex ?!?!?!
Had a unsettling conversation with a CS instructor that teaches at local high schools and the community college. This person is a long-term Linux/C/Python programmer, but he claims that the install, config, and library models for C# have proved to be less problematic than Python. So both his courses (intro, data structs, algorithms) are taught in C#. I am a low-end (3-year) journeyman Pythonista, and I was attracted to the language because of its simplicity. And I have come to enjoy the richness of available libraries. Many of the good people of this NG may be 'too close' to answer, but has Python, as a general devel platform, lost its simplicity ? Is library install too complex and unreliable ? Will my dog go to heaven ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python too complex ?!?!?!
Chris Mellon wrote: > On Nov 20, 2007 2:43 PM, John J. Lee <[EMAIL PROTECTED]> wrote: >> "Chris Mellon" <[EMAIL PROTECTED]> writes: >> [...] >>> These modules exist, but aren't that common. Certainly anything you're >>> likely to be using in an introductory compsci course is well packaged. >>> And even if it's not, it's really not that hard to create packages or >>> installers - a days work of course prep would take care of the >>> potential problem. >> "A day's worth of course prep" for beginners would let them debug all >> the crap that building MySQLdb on Windows might throw at them, for >> example? I think not! (MySQLdb, last time I looked, was one of the >> not-so-obscure modules that don't have a Windows installer available >> and kept up to date. Maybe it does now, but that's not really the >> point.) >> > A days worth of course prep would allow the professor (or his TA, more > likely) to produce a set of installers that's suitable for use with > the course. This is a comp sci course, not a "how to sysadmin a Python > installation" course. > > For the record, it took me less than 3 minutes to install MySqldb, the > first time I've ever needed to do it - I don't like or approve of > MySql. Steps required: Google for "mysql python" and click through 3 > or 4 links to the SF download page. Download the binary installer, > from March 2007. Not exactly rocket science. > > On a similar note, I have or create executable installers for all the > third party modules I use, because I need to provide them to the > people who do our deployments. This has never been much of a burden. > >> I certainly don't recognise what some people have been saying, though. >> It's a rare thing that I have any real pain installing a Python module >> on Linux. That's not to say you don't need some background knowledge >> about distributions and Python if doing it "by hand", of course >> (rather than with a packaging tool like apt-get). Occasionally you'll >> want the newest version of something, which will in turn occasionally >> get you into some grim automake issue or similar. But all of this can >> be entirely avoided in an introductory course -- simply restrict >> yourself to what can be installed with apt-get (if the instructor >> feels they *must* make some new library available, they can always >> package it themselves). >> > The obstacles as presented in the OP seem pretty bogus to me. Of > course, it's third hand anecdotal evidence, so there's not much of a > reason to believe that the original statement really preserves the > essence of the problem. > > I'd be pretty interested if the OP could ask his associate to chime in > with some of the actual issues he encountered / Chime Mode I have, in fact, sent this thread to my friend. His limiting factors are - money-control people favor MS platforms - C# and VS have minimal cost impact for academia - sys admins have everything locked down (probably essential for high school and community college) - both Python 2.4.2, then 2.5.1, on XP and Win2k crashed approx 10% of lab cptrs, so lab techs refused to allow further install of any 'third-party' s/w. (side note - I have installed Python and all the supporting stuff for PyVISA on 14 work-site (11 XP, 3 Debian) cptrs with no problem, so I do not understand). - no such thing as TAs in JC or HS. - CS instructors, for the effected schools, are not allowed to config machines or admin the network. - money-control people want students to learn skills that are on the IT buzz-word list. - my friend is no longer allowed to use me as an 'unofficial' assistant in these classes (not considered qualified because I only have a B.S. degree), so he only uses stuff that existing staff are (supposedly) familiar with... / Chime Mode I told my friend, the wannabe Python instructor, to walk away from any more volunteer work, and stick to the paid stuff. American education, what a mess... luck, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: A critic of Guido's blog on Python's lambda
Bill Atkins wrote: > Does Python have any support for closures? If so, ignore this point. > But if not, what about examples like this: > > (defun make-window (window observer) > ;; initialization code here > (add-handler window 'close > (lambda (event) > (notify observer event))) > ;; more code) > > Being able to keep pass around state with functions is useful. I agree and Python supports this. What is interesting is how counter-intuitive many programmers find this. For example, one of my colleges (who is a reasonably average programmer), was completely stumped by this: >>> def right_partial(fn, *args): ... def inner(*innerargs): ... return fn(*(innerargs + args)) ... return inner ... >>> square = right_partial(pow, 2) >>> square(5) 25 >>> cube = right_partial(pow, 3) >>> cube(5) 125 (for those of you unfamiliar with Python, the '>>>' and '...' means that I typed this in the interactive shell) So I try to use this sort of pattern sparingly because many programmers don't think of closures as a way of saving state. That might be because it is not possible to do so in most mainstream languages. There are already some people in the Python community who think that Python has already gone too far in supporting "complex" language features and now imposes two steep a learning curve i.e. you now have to know a lot to be considered a Python expert. And there is a lot of resistance to adding features that will raise the bar even higher. > There are also cases where a function is so trivial that the simplest > way to describe it is with its source code, where giving it a name and > putting it at the beginning of a function is just distracting and > time-consuming. E.g.: > > (remove-if (lambda (name) >(find #\- name :test #'char=)) > list-of-names) There are some ways to write it in Python (if I understand the code): # prefered [name for name in list_of_names if '-' not in name] OR: # 2nd choice def contains_no_dash(name): return '-' not in name filter(contains_no_dash, list_of_names) # not recommended filter(lambda name: return '-' not in name, list_of_names) > What's the sense of giving that function its own name? It's much > clearer to simply write it in place. Yes, it's _possible_ to use > named functions, but in this case its functionality is so simple that > it's clearer to simply type it in place. Why is this expressiveness a > bad thing, aside from its power to wreck an indentation-significant > language? There are a few people in the Python community who think that unnamed functions are inherently inferior to named ones because the name provides documentation. The majority probably just don't care about the issue at all. I will say that I am not sure that I know what your LISP code does. However, even if you didn't understand the Python code in my named-function version, the name "contains_no_dash" might provide you with a small clue. Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: A critic of Guido's blog on Python's lambda
Bill Atkins wrote: > Buh? The project doesn't have to be late for Brooks's law to hold; > adding programmers, so goes Brooks reasoning, will always increase the > time required to complete the project because of various communication > issues. 1. This is not what Brooks says. Brooks was talking about late projects. Please provide a supporting quote if you wish to continue to claim that "adding programmers will always increase the time required to complete the project". 2. There has to be a mechanism where an organization can add developers - even if it is only for new projects. Python advocates would say that getting developers up to speed on Python is easy because: - it fits most programmers brains i.e. it is similar enough to languages that most programmers have experience with and the differences are usually perceived to beneficial (exception: people from a Java/C/C++ background often perceive dynamic typing as a misfeature and have to struggle with it) - the language is small and simple - "magic" is somewhat frowned upon in the Python community i.e. most code can be taken at face value without needing to learn a framework, mini-language, etc. (but I think that the Python community could do better on this point) I'm sure that smarter people can think of more points. > Fair enough. But what does Python offer above any garbage-collected > language that makes it so scalable? See above point - you can more easily bring programmers online in your organization because most programmers find Python easily learnable. And, as a bonus, it is actually a pretty flexible, powerful language. Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: A critic of Guido's blog on Python's lambda
Bill Atkins wrote: > [EMAIL PROTECTED] writes: > >> Bill Atkins wrote: >>> Buh? The project doesn't have to be late for Brooks's law to hold; >>> adding programmers, so goes Brooks reasoning, will always increase the >>> time required to complete the project because of various communication >>> issues. >> 1. This is not what Brooks says. Brooks was talking about late >>projects. Please provide a supporting quote if you wish to continue >>to claim that "adding programmers will always increase the time >>required to complete the project". > > The "always" in my claim should not be there, I admit. Brooks didn't > claim that. > > I refer you to pages 17 - 18 of The Mythical Man-Month: > > Since software construction is inherently a systems effort - an > exercise in complex interrelationships - communication effort is > great...Adding more men then lengthens, not shortens, the schedule. > > It is totally absurd to assume that, simply because a project has not > yet passed its deadline, it will somehow become immune to the kinds of > things Brooks is talking about. Right. But only when a project is late does Brooks say that adding programmers will always make it later (the claim that you made). In other cases he says "Add manpower, ..., this may or may not help". That seems intuitively obvious to me. If the programmers being added require extensive training [1] by the team to become productive, and their contribution to the project will be smaller than that amount (e.g. it is a small or nearly completed project) then their net impact on the project will be negative. If, OTOH, the new programmers are able to quickly understand the project/organization/technologies and almost immediately make useful contributions, then they are likely to have a net positive impact. >> 2. There has to be a mechanism where an organization can add >>developers - even if it is only for new projects. Python advocates > > Obviously. It's good that you agree. I think that the ability to add new productive developers to a project/team/organization is at least part of what Alex means by "scaleability". I'm sure that he will correct me if I am wrong. >> [list of proposed Python advantages snipped] > These are not things I look for in a programming language. Fair enough. That doesn't mean that these advantages aren't important to others or, in some situations, objectively important in the survival of a project/organization. For example, imagine that Google had used language X instead of Python to develop their tools (assume they started with 10 expert X programmers). Expert X programmers are Y percent more productive than expert Python programmers. Now Google wants to grow aggressively and needs 100 times more developer productivity (and expects to need even more productivity in the future). If it is harder to find/hire/create experts in language X than Python, then Y will have to be large to make language X a better choice than Python. Also, if non-expert Python programmers can be more productive than non-expert X programmers, then Python also has an advantage. Eric Raymond claims that Python has very high initial productivity and that becoming an expert is fairly easy. BTW, I'm not saying that Common Lisp fits X in this example. Cheers, Brian [1] I'm considering introducing bugs or misdesigns that have to be fixed as part of training for the purposes of this discussion. Also the time needed to learn to coordinate with the rest of the team. -- http://mail.python.org/mailman/listinfo/python-list
Re: A critic of Guido's blog on Python's lambda
Patrick May wrote: > [EMAIL PROTECTED] (Alex Martelli) writes: >> In my opinion (and that of several others), the best way for Python to >> grow in this regard would be to _lose_ lambda altogether, since named >> functions are preferable > > Why? I find the ability to create unnamed functions on the fly > to be a significant benefit when coding in Common Lisp. 1. They don't add anything new to the language semantically i.e. you can always used a named function to accomplish the same task as an unnamed one. 2. Giving a function a name acts as documentation (and a named function is more likely to be explicitly documented than an unnamed one). This argument is pragmatic rather than theoretical. 3. It adds another construction to the language. Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
performance difference between OSx and Windows
I have been a Mac and linux guy since 1998 and except for a handful of times, have not touched a MS box since then. This changes a few days ago when I needed to get a MS box for another project. This leads me to my question... A while ago, I borrowed a python script from someone's blog that showed some interesting profiling schemes. I made some modifications to it, ran it and until I got this new machine forgot about it. Just for kicks I ran it again on both boxes to see what the differences were. To say I was surprised is an understatement. Here is the code: #!/usr/bin/env python import time elasped = 0 def slowS(): t1 = time.clock() slow_str='' for i in range(10): slow_str = slow_str + str(i) print 'Slow concatenation finsished in', time.clock() - t1, 'sec.' def fastS(): t2 = time.clock() fast_str = [] for i in range(10): fast_str.append(str(i)) fast_str = ''.join(fast_str) print 'fast concatenation finished in', time.clock() - t2, 'sec.' #slowS() #fastS() if __name__ == '__main__': import hotshot from hotshot import stats prof = hotshot.Profile("Concant_Stats") prof.runcall(slowS) prof.runcall(fastS) prof.close() s = stats.load("Concant_Stats") s.sort_stats("time").print_stats() On my Quad G5 Mac with 4g of memory I get this result... Slow concatenation finsished in 51.05 sec. fast concatenation finished in 0.63 sec. 15 function calls in 51.036 CPU seconds Ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 1 51.033 51.033 51.033 51.033 /Users/brian/Desktop/strTest.py:7(slowS) 10.0030.0030.0030.003 /Users/brian/Desktop/strTest.py:14(fastS) 120.0000.0000.0000.000 /Applications/Komodo.app/Contents/SharedSupport/dbgp/bin/pydbgp:83(write) 10.0000.0000.0000.000 /Applications/Komodo.app/Contents/SharedSupport/dbgp/bin/pydbgp:95(__getattr__) 00.000 0.000 profile:0(profiler) The MS box is an HP with an Athlon 64 X2 Dual with 1g of memory. Here are it's results... Slow concatenation finsished in 23.798 sec fast concatenation finished in 0.622 sec 15 function calls in 87.417 CPU seconds Ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 1 85.188 85.188 85.188 85.188 c:\documents and settings\hp_administrator\desktop\strtest.py:5(slowS) 12.2282.2282.2292.229 c:\documents and settings\hp_administrator\desktop\strtest.py:12(fastS) 120.0010.0000.0010.000 c:\program files\activestate komodo 3.5\lib\support\dbgp\bin\pydbgp.py:83(write) 10.0000.0000.0000.000 c:\program files\activestate komodo 3.5\lib\support\dbgp\bin\pydbgp.py:95(__getattr__) 00.000 0.000 profile:0(profiler) While the CPU speed on the G5 was faster the total execution time was much quicker on the MS box. Can anyone give some suggestions as to why this is? Thanks, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: performance difference between OSx and Windows
Thanks for the response. I was unaware that the G5 was only using one core. Can I ask why that is, and if there is a way to take advantage of all 4 within python? Thanks, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: performance difference between OSx and Windows
Thank you for your answer. I had a feeling that it would be a threading issue, but I wasn't sure. Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: performance difference between OSx and Windows
As one additional question, can someone point me in the direction of a resource that would explain how I could use Python to tell me what core is actually handling the process? I am not even sure if something like this exists, but it would be an interesting feature to explore. Thanks, Brian -- http://mail.python.org/mailman/listinfo/python-list
problem with my regex?
I have a simple script below that is causing me some problems and I am having a hard time tracking them down. Here is the code: import urllib import re def getPicLinks(): found = [] try: page = urllib.urlopen("http://continuouswave.com/whaler/cetacea/";) except: print "ERROR RREADING PAGE." sys.exit() page1 = page.read() cetLinks = re.compile("cetaceaPage..\.html", page1) for line in page1: found.append(cetLinks.findall(line)) print found This is the error message: "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/sre_parse.py", line 396, in _parse if state.flags & SRE_FLAG_VERBOSE: TypeError: unsupported operand type(s) for &: 'str' and 'int' I am trying to extract the links on a web page that have a similar pattern. Here is an example of the html source: PHOTO-LOG How-To-Submit01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 My problem is that I can't seem to be able to figure out what is going wrong here. Mostly because I am a bit confused by the error message as it points to a file (presumable part of re) that I am unfamiliar with, and I am a bit new with python. Any help is greatly appreciated, as is your patience. Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with my regex?
I sincerely appreciate your reply and the time you took to explain it. Thank you, Brian -- http://mail.python.org/mailman/listinfo/python-list
Too big of a list? and other problems
First off, I am sorry for cluttering this group with my inept questions, but I am stuck again despite a few hours of hair pulling. I have a function (below) that takes a list of html pages that have images on them (not porn but boats). This function then (supposedly) goes through and extracts the links to those images and puts them into a list, appending with each iteration of the for loop. The list of html pages is 82 items long and each page has multiple image links. When the function gets to item 77 or so, the list gets all funky. Sometimes it goes empty, and others it is a much more abbreviated list than I expect - it should have roughly 750 image links. When I looked at it while running, it appears as if my regex is actually appending a tuple (I think) of the results it finds to the list. My best guess is that the list is getting too big and croaks. Since one of the objects of the function is also to be able to count the items in the list, I am getting some strange errors there as well. Here is the code: def countPics(linkList): foundPics = [] count = 0 for link in linkList: picPage = urllib.urlopen("http://continuouswave.com/whaler/cetacea/"; + link) count = count +1 print 'got page', count html = picPage.read() picPage.close() pics = re.compile(r"images/.*\.jpeg") foundPics.append(pics.findall(html)) #print len(foundPics) print "found", len(foundPics), "pictures" print foundPics Again, I sincerely appreciate the answers, time and patience this group is giving me. Thank you for any help you can provide in showing me where I am going wrong. Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Too big of a list? and other problems
Thank you for your insight. It appears that using .extend rather than .append solved the problem. Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Too big of a list? and other problems
Tim Chase wrote: > While I'm not sure if this is the issue, you might be having some > trouble with the greediness of the "*" repeater here. HTML like > > > > will yield a result of > > "images/1.jpeg"> > rather than the expected > > "images/1.jpeg" > > You can make it "stingy" (rather than greedy) by appending a > question-mark: > > r"images/.*?\.jpeg" > > I also don't know if they all are coming back as "jpeg", or if > some come back as "jpg", in which case you might want to use > > r"images/.*?\.jpe?g" > Thanks Tim! That modification to the regex helped a lot, and believe it or not, my pic count went up! Thank you, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: performance difference between OSx and Windows
[EMAIL PROTECTED] wrote: > Hi Brian, > > You may have already considered this, but since I didn't see it > mentioned in your post, I'll reply anyway. > > I believe the Python binaries that Apple includes with OS X are always > slightly behind the latest that you can get from the official sources. > I'm not infront of my Mac right now, so I can't tell you the disparity. You are right. Apple is quite far behind. I upgraded to 2.4.2 from 2.3.x. The MS box has the same version. > > One thing I would suggest would be to normalize the versions of Python > accross the two machines. I find that using Fink > (http://fink.sourceforge.net/) on OS X is the easiest way to install a > new version of Python (as well as much other open source software). I have explored fink but have not put it to use. Thanks for the tip. Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Programming Books?
[EMAIL PROTECTED] wrote: > Thanks, if you don't mind could I have a small personal > description on the quality of the books (pros, cons). > > I also am interested if anyone has used "Python Programming: An > Introduction to Computer Science" and if I could be given a detailes > evaluation about it. > I have a copy of this book on my shelf. I think it may be a good choice since you are new to programming. One thing to keep in mind is that is it a Computer Science book that uses Python to teach CS. As a result, you do not get too deep into the language. One book that I think you should definitely look at is Beginning Python from Novice to Professional. I think that it is one of the best books out there on the subject, is an easy read, has clear and concise examples, and does a great job of explaining the whys without making you think you are reading a PhD thesis. On a final note, I think that Python Essential Reference is a good reference book on the language. One thing you might want to look at is Safari Bookshelf by O'Reilly http://safari.oreilly.com/ . They have all of their books online for your to read. It costs $14/month, but you get a 2 week free trial to decide if you want it. You can even download whole chapters as pdf's. In my mind it is a great place to test drive a book, or to have one that you only need to see one or two things in. HTH, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Encrypting a short string?
Hi Erik, I really don't recommend the ROT13 cipher, as this is extremely easy to crack. Most grade school kids could break this one in seconds. ;-) If the project that you are working upon has low security needs, (in other words, it's not a financial institution), than you might try something quite basic such as a Vigenere, transposition, or even a playfair. These encryption methodologies are not secure and can be cracked by hackers. Yet, for the average Joe, it will keep them away from the information / data stored inside. One thing that seems to work well is to use to ciphers together. For example, encrypt the data using the playfair cipher -- and then run a transposition cipher. This will erase most of the "data signatures" that are needed for most hackers to crack the code. At this point, brute force is what most people have to resort upon -- and it's mostly "governments" that have this ability. ;-) Best wishes! Dusty --- Bjoern Schliessmann wrote: > Lie wrote: > >> There is a simple encryption, called ROT13 (Rotate 13). This is >> very unsecure for any cryptographical purpose, > > For enhanced security use TROT13 (triple ROT13). > >> but enough to make uninformed user to think it's just a random >> piece of letters. > > Security by obscurity doesn't work. If it needs to be protected, > protect it well. If it doesn't need to, you don't need to obscure > it at all. > > Regards, > > > Björn > -- http://mail.python.org/mailman/listinfo/python-list
UnknownTimeZoneError
I'm running App Engine with Django. I'm having troubles executing timezone conversion via pytz. I have looked at the Google example implementation. The following works in IDLE: >>> import pytz >>> from pytz import common_timezones >>> from pytz import timezone >>> import datetime >>> timestamp = datetime.datetime.utcnow() >>> print timestamp 2009-03-22 11:02:41.578000 >>> translated = >>> timestamp.replace(tzinfo=pytz.utc).astimezone(timezone('US/Central')) >>> print translated 2009-03-22 06:02:41.578000-05:00 I have tried to run the following in my app (modules imported, too): def tz(request): timestamp = datetime.datetime.utcnow() translated = timestamp.replace(tzinfo=pytz.utc).astimezone (timezone ('US/Central')) return respond(request, user, 'tz', {'translated':translated,'timestamp':timestamp}) When I pull up the page, I get the following error: UnknownTimeZoneError at /tz 'US/Central' Request Method: GET Request URL:http://localhost:8080/tz Exception Type: UnknownTimeZoneError Exception Value:'US/Central' Does this not work in App Engine for some reason? -- http://mail.python.org/mailman/listinfo/python-list
Listing all python modules robustly
I've used the C api to write a method that can call any python module function. I would like to extend the interface to allow dynamically listing all python modules, and for a given module all functions, and for a given function all argument types and the return types if possible. Starting with the modules, I came up with this bit of code: from pkgutil import walk_packages; modules=[] modules = [modules.append(item[1]) for item in walk_packages()] I then took this to my various systems for testing. It works fine on OSX and one of my Ubuntu boxes, but two of the Ubuntu boxes fail, each with a different error message. The failure is due to python importing every single module and some of the modules failing. One example is the UniConverter package - towards the end of __init__.py it calls sys.exit(0) which kills the interpreter completely. I've spent a ton of time trying to rewrite walk_packages to be robust to failure, but so far without luck. Any advice is appreciated. /Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Listing all python modules robustly
Turns out that the Twisted framework provides better introspective support than standard python, so problem solved! http://twistedmatrix.com/documents/8.2.0/api/twisted.python.modules.html#walkModules On Tue, Mar 31, 2009 at 8:12 AM, Brian wrote: > I've used the C api to write a method that can call any python module > function. I would like to extend the interface to allow dynamically listing > all python modules, and for a given module all functions, and for a given > function all argument types and the return types if possible. > Starting with the modules, I came up with this bit of code: > > from pkgutil import walk_packages; > > modules=[] > > modules = [modules.append(item[1]) for item in walk_packages()] > > > I then took this to my various systems for testing. It works fine on OSX > and one of my Ubuntu boxes, but two of the Ubuntu boxes fail, each with a > different error message. The failure is due to python importing every > single module and some of the modules failing. One example is the > UniConverter package - towards the end of __init__.py it calls sys.exit(0) > which kills the interpreter completely. > > I've spent a ton of time trying to rewrite walk_packages to be robust to > failure, but so far without luck. Any advice is appreciated. > > /Brian > -- http://mail.python.org/mailman/listinfo/python-list
exporting symbols with ctypes?
I'd like to load a library that expects executables which link against it to provide a particular symbol. Is there a way to do the inverse of the in_dll() operation? I'd prefer to avoid creating a brand new library on the fly just to satisfy this one dependency. -- http://mail.python.org/mailman/listinfo/python-list