Re: Program to compute and print 1000th prime number
On Nov 7, 2009, at 9:44 AM, Ray Holt wrote: I am taking the MIT online course Introduction to Computer Science and Programming. I have a assignment to write a program to compute and print the 1000th. prime number. Can someone give me some leads on the correct code? Thanks, Ray Copying code != doing an assignment. Try Knuth. S -- http://mail.python.org/mailman/listinfo/python-list
Re: Choosing GUI Module for Python
On Nov 9, 2009, at 3:59 AM, Antony wrote: You may want to offer a little more info, like what exactly you are looking to do with such GUI. are your needs for a VW, Corvette, or Mercedes? etc, etc. All these kits have pros and cons, some better for this some for that, yadda yadda I would like to know about that pros and cons only ... What might be a "pro" for one use case could easily be a "con" for another. For example, Kit-X may be infinitely configurable to run on everything from 800x600 to 1680x1050 pixel monitors with full viewport control, full zoom, pan, etc. and requires that all those cases be handled with correct configuration. That's great if you're writing an application that requires that. But, if you're writing a Pref Pane for OS X, which will never be any bigger than the pref-pane window and will only run on OS X, that particular kit might be a huge waste of time. The "pro" of infinite flexibility becomes a huge "con" for the OS X Pref Pane use-case. S -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI vs mod_python
On Nov 9, 2009, at 9:32 AM, Victor Subervi wrote: Hi; I've been told by a server farm that they're having trouble getting my scripts to work because they're written with cgi calls as opposed to mod_python. Is there a basis for their complaint? These pages serve fine on another server. Does the server they're working fine on use CGI? Yes, they're different. S -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI vs mod_python
On Nov 9, 2009, at 10:18 AM, Victor Subervi wrote: Yes, obviously. But if CGI is enabled, it should work anyway, should it not? Depends on what "CGI is enabled" means. Usually, web servers are not set to just handle cgi scripts from anywhere, but only from specific file system locations. Otherwise, an an anonymous upload could be executed as CGI and wreak havoc. And "it should work anyway, should it not" is already answered by "they're having trouble getting my scripts to work." S -- http://mail.python.org/mailman/listinfo/python-list
Re: Req. comments on "first version" ch 2 progr. intro (using Python 3.x in Windows)
On Nov 9, 2009, at 11:54 AM, Jon Clements wrote: On Nov 9, 4:10 pm, "Alf P. Steinbach" wrote: First, because as opposed to ch 1 there is quite a bit of code here, and since I'm a Python newbie I may be using non-idiomatic constructs, Welp, there goes my last excuse. I'm off to write my book: Heart Surgery at Home *** How to Save Thousands and Get Results Just Like in Hospital Chapter 1: Sanitation, Schmanitation: How Clean is Clean Enough? Chapter 2: Surgical Tools vs. Ginsu: How Sharp is Sharp Enough? Chapter 3: Gray's Anatomy and Sharpies: Laying out The Surgery Chapter 4: Before You Start: Charging Your Cell Phone, and Testing 911 Chapter 5: Anesthesia: Jack Daniels or Smirnoffs; How Much is Enough? Chapter 6: The Insanity Defense: Laying the Groundwork with 6 Month Plan That's as far as I've gotten... Amazon best seller list, here I come! S -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating formatted output using picture strings
On Feb 10, 2010, at 2:57 PM, Grant Edwards wrote: > On 2010-02-10, pyt...@bdurham.com wrote: > > [regardning "picture" output format specifiers] > >> I was thinking that there was a built-in function for this >> common(?) use case > > I haven't seen that paradigm since my one-and-only exposure to > COBOL in a class I took back in 1979. Is the "picture" thing > commonly used in other places than COBOL? Seriously? I've seen it in dozens places other than COBOL over the years in everything from templating languages to report generators, to built-in support in a variety of languages (dBASE II anyone?). Haven't you ever had to get a e.g. a phone number or social security number from user input? S -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating formatted output using picture strings
On Feb 10, 2010, at 3:40 PM, Grant Edwards wrote: > On 2010-02-10, sstein...@gmail.com wrote: >> On Feb 10, 2010, at 2:57 PM, Grant Edwards wrote: >> >>> On 2010-02-10, pyt...@bdurham.com wrote: >>> >>> [regardning "picture" output format specifiers] >>> >>>> I was thinking that there was a built-in function for this >>>> common(?) use case >>> >>> I haven't seen that paradigm since my one-and-only exposure to >>> COBOL in a class I took back in 1979. Is the "picture" thing >>> commonly used in other places than COBOL? >> >> Seriously? > > Seriously. > >> I've seen it in dozens places other than COBOL over the years >> in everything from templating languages to report generators, >> to built-in support in a variety of languages (dBASE II >> anyone?). >> >> Haven't you ever had to get a e.g. a phone number or social >> security number from user input? > > Nope. I guess it's specific to certain application areas. I've > never done any database type stuff. I do mostly embedded, > device drivers, networking/protocols, industrial automation, > Unix system admin/automation, and scientific visualization. Yah, I've hardly ever had to get SSN input from users in a device driver ;-). That's what makes groups like this go 'round; we have all done different types of things which gives us all different perspectives. S -- http://mail.python.org/mailman/listinfo/python-list
Re: Terminating threaded programs
On Feb 11, 2010, at 11:43 AM, Aahz wrote: > In article , > mk wrote: >> >> I have a problem with a threaded program: it frequently hangs on sys.exit. >> >> The problem is that my program uses threads which in turn use paramiko >> library, which itself is threaded. >> >> I try to gracefully close the threads (below), but it doesn't always >> work, if paramiko calls happen to be at stage of negotiating ssh >> connection or smth similar. >> >> The only workable solution I have is a program sending itself SIGKILL, >> which makes it terminated by OS (I think so). > > You can also use os._exit(). This just came up on the Twisted IRC channel last night and came to the same conclusion. Python's going to wait for threads to terminate and if they're not going to, neither is Python. os._exit() came up as the 'last resort' way out of the app. S -- http://mail.python.org/mailman/listinfo/python-list
Re: MemoryError, can I use more?
On Feb 12, 2010, at 7:21 PM, Echavarria Gregory, Maria Angelica wrote: > Dear group: > > I am developing a program using Python 2.5.4 in windows 32 OS. The amount of > data it works with is huge. I have managed to keep memory footprint low, but > have found that, independent of the physical RAM of the machine, python > always gives the MemoryError message when it has occupied exactly only 2.2 > GB. I have tested this in 4 different machines, all with memory of 3 to 4 > GB... I'm amazed. > > Could any of you please help me to figure out how to change that limit? I > typed help(MemoryError) and it is a class itself, but that help told me > nothing I can use... How are you determining that it has occupied "exactly only 2.2GB?" S -- http://mail.python.org/mailman/listinfo/python-list
Re: how to structure a directory with many scripts and shared code
On Feb 15, 2010, at 11:06 AM, Jean-Michel Pichavant wrote: > 3/ make sure your working copy of myBeautifulPackage is in your PYTHONPATH. Or, make a simple setup.py which imports distribute or setuptools and use: # python setup.py develop which will put your code into the PYTHONPATH by virtue of a link inside your site-packages. First one I found googling for "setup.py develop" : https://www.siafoo.net/article/77 There's a typo in the code of section 1.2 (parenthesis at the end of import, wrong), but the basic idea is there. S -- http://mail.python.org/mailman/listinfo/python-list
Re: how to structure a directory with many scripts and shared code
On Feb 16, 2010, at 3:28 AM, Benedict Verheyen wrote: > Steven D'Aprano wrote: >> On Mon, 15 Feb 2010 16:29:05 +0100, Benedict Verheyen wrote: >> >>> However, when i make a subdirectory, for example database and put a >>> script in there, how would i import logutils or mailtutils from within >>> the database subdirectory? This fails: >>>from tools.logutils import logger >> >> Sounds like you need to ensure that the top level directory needs to be >> added to your PYTHONPATH. >> >> Do you need instructions to do this? >> > > Hi Steve, > > > thanks, i think i know how to add the top level directory to the PYTHONPATH. > > I'm however looking further into the suggestion of ssteinerX to use a > setup.py file to add the tools utility scripts to the pythonpath. > In the near future, another person will be helping me with programming > and thus, i want to make sure the structure is usable by other people > than myself. > > Furthermore, i'm thinking if it wouldn't be cleaner to make such a setup.py > file per script, at least the bigger, more important scripts. > Now my structure is like this: > > python_scripts > | > |-->trunk > ..|-> all scripts > ..|-> tools > > The python_scripts directory and subdirs are versioned via SVN. > I think these steps would help: > > 1. Make a package of tools. > 2. Put the bigger scripts in a seperate directory also using a setup.py file. > 3. If possible, put the other scripts that somehow belong together in a > seperate > directory. Names need to be more clear but i'm just illustrating a point. > > python_scripts > | > |-->trunk > ..|-> my big script 1 > |-> setup.py > ..|-> my big script 2 > |-> setup.py > ..|-> database > |-> database script 1 > |-> database script 2 > ..|-> tools > |-> setup.py > > Does that look like a clear structure? No. Make one setup.py at the top, put related scripts (like database) into separate sub-modules, so they can all be imported off a common 'trunk' as you have it above i.e. as trunk.database.xxx. Then use entry points for any command line scripts. Slightly harder, to setup initially but much cleaner to use and maintain and, it all installs with one call to setup.py develop. S -- http://mail.python.org/mailman/listinfo/python-list
Re: listing existing windows services with python
On Feb 16, 2010, at 4:04 AM, Ben Finney wrote: > Please, don't send the above kind of vitriol to this public forum. > Better yet, compose it in your editor, bask in what you've written, then > delete it unsent. +1 If you kids want to have some sort of pissing-in-your-sockpuppet type of contest to see who can out-whatever each other, do it off-list and don't waste everyone else's time with. What ever happened to "don't feed the trolls" ?? If you really believe someone's trolling, don't answer, block them, and move on. Providing a lengthy, well-reasoned reply only shows that they've pulled you into the troll pit for a fight with them, regardless of whether you're "right." S -- http://mail.python.org/mailman/listinfo/python-list
Re: What happened to pyjamas?
Down from here (NH, US). S On Feb 18, 2010, at 1:44 PM, Chris Colbert wrote: > -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to continue after an exception ?
On Feb 20, 2010, at 9:17 PM, Lie Ryan wrote: > On 02/21/10 12:02, Stef Mientki wrote: >> On 21-02-2010 01:21, Lie Ryan wrote: On Sun, Feb 21, 2010 at 12:52 AM, Stef Mientki > wrote: > hello, > > I would like my program to continue on the next line after an uncaught > exception, > is that possible ? > > thanks > Stef Mientki > > >>> That reminds me of VB's "On Error Resume Next" >>> >> I think that's what I'm after ... > > First, read this: > http://www.developerfusion.com/code/4325/on-error-resume-next-considered-harmful/ The link goes to an "Oh dear. Gremlins at work!" page. They're probably using On Error Resume Next in their VBScript code and this is the "last resort" page ;-). S -- http://mail.python.org/mailman/listinfo/python-list
Re: DreamPie - The Python shell you've always dreamed about!
On Feb 21, 2010, at 11:51 AM, Chris Colbert wrote: > http://dreampie.sourceforge.net/download.html > > reading is a wonderful thing. I got it running on OS X with MacPorts after about an hour of installing everything required for gtk and gtksourceview (including a new gcc, apparently). Now...if I can just figure out how to set the font to something I can actually read both size and anti-alias-wise. S > > On Sun, Feb 21, 2010 at 11:32 AM, Mensanator wrote: > On Feb 21, 10:30�am, Mensanator wrote: > > On Feb 21, 3:42 am, Noam Yorav-Raphael wrote:> I'm > > pleased to announce DreamPie 1.0 - a new graphical interactive > > > Python shell! > > > > What versions of Python does it suuport? > > What OS are supported? > -- > http://mail.python.org/mailman/listinfo/python-list > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: DreamPie - The Python shell you've always dreamed about!
On Feb 21, 2010, at 4:40 PM, Mensanator wrote: > On Feb 21, 12:14 pm, Paul Boddie wrote: >> On 21 Feb, 17:32, Mensanator wrote: >> >>> On Feb 21, 10:30 am, Mensanator wrote: >> What versions of Python does it suuport? >> >>> What OS are supported? >> >> From the Web site referenced in the announcement (http:// >> dreampie.sourceforge.net/): >> >> """ >> # Supports Python 2.5, Python 2.6, Jython 2.5, IronPython 2.6 and >> Python 3.1. >> # Works on Windows and Linux. >> """ > > Yeah, I saw that. Funny that something important like that wasn't part > of the > announcement. I notice no mention of Mac OS, so visiting the website > was a complete > waste of time on my part, wasn't it? See my earlier message -- I have it running just fine on 10.6 with MacPorts and even managed to report a bug! S > >> Paul > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: DreamPie - The Python shell you've always dreamed about!
On Feb 21, 2010, at 9:10 PM, Shashwat Anand wrote: > Just got it working in mac. Installing dependencies took a bit though. I used macports and it was only 2 installs: # sudo port install py26-pygtksourceview # sudo port install py26-gtk2 It sure did install a lot of other stuff, like a new gcc(?) though; took almost an hour. S > > On Mon, Feb 22, 2010 at 7:38 AM, Philip Semanchuk > wrote: > > On Feb 21, 2010, at 8:39 PM, rantingrick wrote: > > > > Mensanator snipped: """Yeah, I saw that. Funny that something > important like that wasn't part of the announcement. I notice no > mention of Mac OS, so visiting the website was a complete waste of > time on my part, wasn't it?""" > > Oh Mensanator, why you always so grumpy? I visited your site a few > years ago and i found it to be a complete waste of my time but you > don't hear me whining about it do you? Besides mac is always the last > to get releases (if any) everybody knows that. > > > Erm...not if the developer uses a Mac. =) > > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: When will Python go mainstream like Java?
On Feb 23, 2010, at 10:10 AM, Martin P. Hellwig wrote: > Actually I am still waiting for Java to be mainstream :-) > You could say it is popular, which it is without doubt but in my opinion > after C handed over it's pseudo de facto standard (mostly because a lot of > OS'es are written in it) nobody else has had enough momenta to reach for that > crown. > > Actually I quite like the soup of languages these days, what amuses me > though, that Python seems to emerge as the de facto glue language to bind > them all :-) I'm sure there's a Tolkien 1-liner in there somewhere ;-). S -- http://mail.python.org/mailman/listinfo/python-list
Re: python dowload
On Feb 23, 2010, at 2:42 PM, monkeys paw wrote: > I used the following code to download a PDF file, but the > file was invalid after running the code, is there problem > with the write operation? > > import urllib2 > url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf' > a = open('adobe.pdf', 'w') Try 'wb', just in case. S > for line in urllib2.urlopen(url): >a.write(line) > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: The future of "frozen" types as the number of CPU cores increases
On Feb 23, 2010, at 8:30 PM, Steven D'Aprano wrote: > On Tue, 23 Feb 2010 10:35:38 -0800, John Nagle wrote: > >> The issue being discussed was scaling Python for CPUs with many cores. >> With Intel shipping 4 cores/8 hyperthread CPUs, the 6/12 part working, >> and the 8/16 part coming along, this is more than a theoretical issue. > > Have you tried parallelpython? > > http://www.parallelpython.com/ I had not, have you used this successfully? Thanks, S -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dos2unix one liner
On Feb 27, 2010, at 10:01 AM, @ Rocteur CC wrote: > Nothing to do with Perl, Perl only takes a handful of characters to do this > and certainly does not require the creation an intermediate file Perl may be better for you for throw-away code. Use Python for the code you want to keep (and read and understand later). S -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dos2unix one liner
On Feb 27, 2010, at 12:27 PM, John Bokma wrote: > "sstein...@gmail.com" writes: > >> On Feb 27, 2010, at 10:01 AM, @ Rocteur CC wrote: >>> Nothing to do with Perl, Perl only takes a handful of characters to >>> do this and certainly does not require the creation an intermediate >>> file >> >> Perl may be better for you for throw-away code. Use Python for the >> code you want to keep (and read and understand later). > > Amusing how long those Python toes can be. In several replies I have > noticed (often clueless) opinions on Perl. When do people learn that a > language is just a tool to do a job? I'm not sure how "use it for what it's good for" has anything to do with toes. I've written lots of both Python and Perl and sometimes, for one-off's, Perl is quicker; if you know it. I sure don't want to maintain Perl applications though; even ones I've written. When all you have is a nail file, everything looks like a toe; that doesn't mean you want to have to maintain it. Or something. S -- http://mail.python.org/mailman/listinfo/python-list
Re: scope of generators, class variables, resulting in global na
On Feb 27, 2010, at 6:57 PM, dontspamleo wrote: > > > http://bioscreencastwiki.com/Python_Variable_scope_gymnastics Broken link: Site settings could not be loaded We were unable to locate the API to request site settings. Please see below for debugging information. HTTP Response Status Code: 0 -- http://mail.python.org/mailman/listinfo/python-list
Re: help with Python installation
>> I do not even >> know what to do next. I also tried Activepython. It installs but when >> I try to open it from Start->Programs->ActivePython 2.6, I get an >> error window saying - upgrade windows. > > Hmm, have you tried "upgrading windows, just a wild guess! Hey, not everyone can afford to upgrade Windows and some hardware just can't handle the "new, improved" versions. How about we all chip in to buy him a copy of Ubuntu? Oh, wait, it's free... S -- http://mail.python.org/mailman/listinfo/python-list
Re: cpan for python?
On Feb 28, 2010, at 9:28 AM, Someone Something wrote: > Is there something like cpan for python? I like python's syntax, but I use > perl because of cpan and the tremendous modules that it has. -- Please search the mailing list archives. This subject has been discussed to absolute death. Draw your own conclusions about what is currently and may, in the future, be available. S -- http://mail.python.org/mailman/listinfo/python-list
Re: python b.python 8 works on XP but not on Vista?
On Mar 6, 2010, at 8:23 PM, Isaac Gouy wrote: > On Mar 6, 4:53 pm, Chris Rebert wrote: >> On Sat, Mar 6, 2010 at 4:42 PM, Isaac Gouy wrote: >>> On Mar 6, 4:02 pm, Chris Rebert wrote: On Sat, Mar 6, 2010 at 3:53 PM, Isaac Gouy wrote: > At the command prompt: >> > python b.py 8 > works fine on both XP and Vista >> > python b.python 8 > works on XP (and Linux) >> > but on Vista >> > python b.python 8 >> > ImportError: No module named b >> > ? >> Code please. >> >>> It's the same code in both cases, I simply renamed "b.python" as >>> "b.py" as a test. >> >> The code in b.py matters. I /suspect/ it's importing itself somehow >> (probably indirectly), and Python doesn't look for ".python" files >> when importing, so it fails with an ImportError. But since you haven't >> shown the code, I can only guess. > > Yes the code in b.py matters. > > Why it matters is that there was another difference between XP and > Vista - the XP machine was single core but the Vista machine was multi > core - and the code behaves differently in each case. Yes, and the XP machine's case was blue, therefore case color is important, too. S -- http://mail.python.org/mailman/listinfo/python-list
Re: A "scopeguard" for Python
On Mar 8, 2010, at 7:28 AM, Steve Holden wrote: >> >> But your response, both the out of context quoting and your comment, >> seems solely designed to convey a negative impression instead of >> addressing any technical issue. >> > This isn't an isolated case, Alf. Physician, heal thyself. As far as I can tell, this happens on every thread Alf is involved in at one point or another. I'm sure it's "everyone else." S -- http://mail.python.org/mailman/listinfo/python-list
Re: Opportunity to author Python books- Packt Publishing.
On Mar 8, 2010, at 6:25 AM, Kshipra Singh wrote: I would be delighted to write a cookbook on the stuff I use every day: python for administering cloud servers. Thanks, S aka/Steve Steiner aka/ssteinerX > Hi All, > > I am writing to you for Packt Publishing, the publishers computer related > books. > > We are planning to extend our catalogue of cookbooks and are currently > inviting "Python" fanatics interested in writing a cookbook. So, if you love > "Python" and are interested in writing a cookbook, please contact us with > your book ideas ataut...@packtpub.com. Even if you do not have a book idea > and are simply interested in authoring a cookbook, we are keen to hear from > you. > > More details about the opportunity are available at: > http://authors.packtpub.com/content/python-fanatics-invited-write-packt > > Thanks > Kshipra Singh > Author Relationship Manager > Packt Publishing > www.PacktPub.com > > Skype: kshiprasingh15 > Twitter: http://twitter.com/kshipras > > Interested in becoming an author? Visit http://authors.packtpub.com for all > the information you need about writing for Packt. > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list