Announcing Wing IDE 101 for teaching intro programming courses
Hi, We're pleased to announce the first public beta release of Wing IDE 101, a free scaled back edition of Wing IDE that was designed for teaching introductory programming courses. We are releasing Wing IDE 101 to the general public in the hopes that it may help others teach with or learn Python. Wingware also offers educational pricing for Wing IDE Professional, including steep discounts for class room use. If you are interested in teaching Python with Wing IDE, please email [EMAIL PROTECTED] for more information. Key features of Wing IDE 101 include: * Powerful Editor -- Syntax highlighting, goto-definition, navigation menus, error indicators, auto-indent, and keyboard emulation for Visual Studio, VI/Vim, Emacs, and Brief. * Python Shell -- Evaluate files and selections in the integrated Python shell. * Graphical Debugger -- Set breakpoints and view stack and program data. Note that Wing IDE 101 omits auto-completion and most other code intelligence features found in the other Wing IDE products. This was by design, so that students are more conscious of the details of the language and the modules that they are learning about. Wing IDE 101 is available on Windows, Linux, and Mac OS X. It is free for all non-commercial uses and does not require a license code to run. Wing 101 is not, however, open source. The current release is 3.0 beta1 and is available here: http://wingware.com/downloads/wingide-101 General information for beta testers is here: http://wingware.com/wingide/beta More details on Wing 101's features are here: http://wingware.com/wingide-101 http://wingware.com/wingide/features Please direct bug reports and suggestions to [EMAIL PROTECTED] Thanks! The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Website data-mining.
Hello, I'm using Python for the first time to make a plug-in for Firefox. The goal of this plug-in is to take the source code from a website and use the metadata and body text for different kinds of analysis. My question is: How can I retrieve data from a website? I'm not even sure if this is possible through Python. Any help? Have a look at http://www.myinterestingfiles.com/2007/03/playboy-germany-ads.html for getting the data and at http://www.crummy.com/software/BeautifulSoup/ for handling it. HTH. -- Miki Tebeka [EMAIL PROTECTED] http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Help: GIS
On 8 3 , 9 34 , [EMAIL PROTECTED] wrote: On Aug 2, 10:46 pm, zxo102 [EMAIL PROTECTED] wrote: Hi, I am new in GIS area and need your suggestions for where I can start from. I have a python based web application with a database. Now I would like to add a GIS map into my application. When a user clicks a certain area in the GIS map, it can grab the data from the database via my python based application. Do I have to use MapServer or Grass or some other backends for this purpose? Thanks a lot. Ouyang While I am not a part of our GIS department, they use ArcGIS which has Python support built in. If that's what you're using, you should be able to use the examples given on ESRI's website:http://www.spatialvision.com.au/html/tips-python-arc9.htm Hmmm...not much there. Here are some other links I found: http://nrm.salrm.uaf.edu/~dverbyla/arcgis_python/index.htmlhttp://www.ollivier.co.nz/publication/uc2004/python_workshop/sld008.htmhttp://www.3dartist.com/WP/python/pycode.htm I don't know if these will be much help. You really need to just dig in and start coding. I would recommend Programming Python 3rd Ed. by Lutz if you want something in hard copy. Dive Into Python is a free book that's online that I'm told is very good. Both have good examples, some of which are involved. All the web oriented Python books are a few years old, but the code in them still works, for the most part. Mike Mike, Thanks for your suggestion. I am looking for a python GIS package (without any other GIS backends like mapserver) which can be simply imported into my current python web application. I am not sure if it is available. So far, the close one I found is Python Cartographic Lab. But I can not find any examples for PCL. Anyway, I am still on the way of the deep learning curve for GIS. Ouyang Ouyang -- http://mail.python.org/mailman/listinfo/python-list
Re: How to pass a reference to the current module
Paul Rubin wrote: Hmm, it's a pain that there's no clean way to get at the current module. PEP 3130 shows some icky and unreliable ways, e.g. func = getattr(sys.modules[__name__], 'f') PEP 3130's goal was to add a clean way to do this. Unfortunately it was rejected. Yes, this is the essence of the problem. At least I'm not the only one to have needed (or at least wanted) this. James -- http://mail.python.org/mailman/listinfo/python-list
Re: Website data-mining.
Miki wrote: Hello, I'm using Python for the first time to make a plug-in for Firefox. The goal of this plug-in is to take the source code from a website and use the metadata and body text for different kinds of analysis. My question is: How can I retrieve data from a website? I'm not even sure if this is possible through Python. Any help? Have a look at http://www.myinterestingfiles.com/2007/03/playboy-germany-ads.html Well, it's certainly interesting, but I'm not sure how it might help the OP get data from a website... for getting the data and at http://www.crummy.com/software/BeautifulSoup/ for handling it. HTH. -- Miki Tebeka [EMAIL PROTECTED] http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Registration is open for the 5th Python game challenge!
The fifth PyWeek is only a month away. Come along and join the fun: write a video game in a week! There's some really interesting new libraries that have popped up recently. Have a gander on the pyweek message board for more info. REGISTRATION IS OPEN Visit the PyWeek website for more information: http://pyweek.org/ THE PYWEEK CHALLENGE: - Invites all Python programmers to write a game in one week from scratch either as an individual or in a team, - Is intended to be challenging and fun, - Will hopefully increase the public body of python game tools, code and expertise, - Will let a lot of people actually finish a game, and - May inspire new projects (with ready made teams!) Entries must be developed during the challenge, and must incorporate some theme decided at the start of the challenge. The rules for the challenge are at: http://media.pyweek.org/static/rules.html Richard -- Visit the PyWeek website: http://pyweek.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Help: GIS
On Aug 3, 11:46 am, zxo102 [EMAIL PROTECTED] wrote: Hi, I am new in GIS area and need your suggestions for where I can start from. I have a python based web application with a database. Now I would like to add a GIS map into my application. When a user clicks a certain area in the GIS map, it can grab the data from the database via my python based application. Do I have to use MapServer or Grass or some other backends for this purpose? Thanks a lot. Ouyang another link, http://code.djangoproject.com/wiki/GeoDjango, talk about many python tools about GIS, hope help to u. -- http://mail.python.org/mailman/listinfo/python-list
Auto run/Timer
Hello, I would like my script to run once a week with out any external interference. More like a timer. Can it be done in python or should some other shell scripting be used. If anyone knows anything please let me know. -- http://mail.python.org/mailman/listinfo/python-list
Re: Auto run/Timer
On Sat, 04 Aug 2007 08:27:05 +, Rohan wrote: Hello, I would like my script to run once a week with out any external interference. More like a timer. Can it be done in python or should some other shell scripting be used. If anyone knows anything please let me know. `cron` should be your way to go, IMO. `/etc/cron.weekly/` might be a starting point (copy your script into this directoy). And, yes, it can be done using pure Python (but I wouldn't do it). See `threading.Timer http://docs.python.org/lib/module- threading.html#l2h-3422`_. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to pass a reference to the current module
Steven D'Aprano wrote: I suggest you're falling for the anti-pattern of Big Design Up Front, and are overly complicating your system just in case it's useful. Why not just _insist_ that main.py and UserDefined1.py must be different modules? You're the application developer, you're allowed to do that. The idea of the module I'm writing is to allow the user to define functions where they want and to create single-file python scripts that can make use of my API. The point of the module is to be beginner friendly, but maybe that is asking too much as user friendliness might be a potentially useful but provably unnecessary attribute. 2. foo is defined in `main` Maybe you should just prohibit that? Do you really want to allow users to call arbitrary code in your main application at arbitrary times and places? It would be the user's main and they would be importing my module. I would like my module to be aware of the contents of the user's module. I thought such a thing would be possible because it seems like something similar is happening in distutils py2app. But in any case, it shouldn't matter. main is the program running -- it has to be, because you can't import it from another program -- so globals()['foo'] will work. Possibility two (even when it is a properly named module) sets the stage for a circular import, but I believe in python this is not entirely worrisome. However, the combination above makes it difficult to pass a reference to the `main` namespace without some sort of introspection. That's what globals() is for. On second thought this might not be horribly bad: FunctionUser.do_something_with(globals(), 'doit', 7) or FunctionUser.do_something_with(UserDefined1.globals(), 'foo', 7) From a beginner-user's perspective (i.e. potential users of my module), it seems a little awkward, but might be more natural on the whole than the alternatives. However, if I had my druthers, I would rather have some way to pass a reference to the current module in the former case and have do_something_with() call globals(). I really like the idea of having the module or its namespace as an optional argument and implicitly using the calling global namespace if its left out. But perhaps this is bad design from an explicit is better than implicit perspective. [foo] param1 = float param2 = 4 [option1] __module__ = 'UserDefined1' __function__ = 'doit' I'm not sure why you need the quotation marks around the module and function names. What else could UserDefined1 be, other than a string? Yes, those were typos. And to be consistent, the whole listing of the configuration file should be (note: 'doit'-do_something_with): [foo] param1 = float param2 = 4 [option1] __module__ = UserDefined1 __function__ = do_something_with param1 = str param2 = 30.0 [doit] param1 = float param2 = float [etc.] With the user's main having the following in it: from UserDefined1 import some_function def foo(): [etc.] def doit(): [etc.] I'm afraid my previous listing of the config file could cause confusion. James -- http://mail.python.org/mailman/listinfo/python-list
Re: How to pass a reference to the current module
James Stroud wrote: Yes, those were typos. And to be consistent, the whole listing of the configuration file should be (note: 'doit'-do_something_with): [foo] param1 = float param2 = 4 [option1] __module__ = UserDefined1 __function__ = do_something_with param1 = str param2 = 30.0 [doit] param1 = float param2 = float [etc.] With the user's main having the following in it: from UserDefined1 import some_function def foo(): [etc.] def doit(): [etc.] Why don't you just let your userse write def foo(param1=float, param2=4): ... and dump the config file? Alternatively you can devise a decorator @declare(float, int) def foo(param1, param2=4): ... The problem of mapping names to values, be they modules or functions, will magically vanish. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: How to pass a reference to the current module
James Stroud [EMAIL PROTECTED] writes: FunctionUser.do_something_with(globals(), 'doit', 7) How about instead of import FunctionUser, require from FunctionUser import do_something In FunctionUser.py, write: frob = (some object that gets necessary stuff from module environment) def do_something(*user_args, __frob = frob): # use __frob to access FunctionUser module contents as needed # ... (func, args) = getattr(FunctionUser, user_args[0]), user_args[1:] func(*args) -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp problem in Python
On 4 A ustos, 00:41, Ehsan [EMAIL PROTECTED] wrote: I want to find http://www.2shared.com/download/1716611/e2000f22/ Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11 or 3gp instead of wmv in the text file like this : html some code function reportAbuse() { var windowname=abuse; var url=/abuse.jsp?link= + http://www.2shared.com/file/1716611/ e2000f22/Jadeed_Mlak14.html; OpenWindow = window.open(url,windowname,'toolbar=no,scrollbars=no,resizable=no,width=500,height=500,left=50,top=50'); OpenWindow.focus(); } function startDownload(){ window.location = http://www.2shared.com/download/1716611/ e2000f22/Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11; //document.downloadForm.submit(); } /script /head /htmlhttp://www.2shared.com/download/1716611/e2000f22/ Jadeed_Mlak14.3gp?tsid=20070803-164051-9d637d11sfgsfgsfgv I use this pattern : http.*?\.(wmv|3gp).* but it returns only 'wmv' and '3gp' instead of http://www.2shared.com/ download/1716611/e2000f22/Jadeed_Mlak14.wmv? tsid=20070803-164051-9d637d11 what can I do? what's wrong whit this pattern? thanx for your comments You could use r'window.location = (.*?\.(wmv|3gp);' as your regex string, I guess.. -- http://mail.python.org/mailman/listinfo/python-list
how to run os.execv() to run command pslq dbname gen.command
hello all , i need to run psql from my py file,, for that i am using : os.execv(path for psql ,['psql dbname gen.command']) but its not working .. the command wht i want to run from this py file is :psql dbname gen.command where gen.command file contain some command to create csv file from database \o temp.csv \a \f , select * from temp if u have any idea plz help me,, -- http://mail.python.org/mailman/listinfo/python-list
Re: bias in random.normalvariate??
Robert Kern wrote: [EMAIL PROTECTED] wrote: I'm a Python newbie and certainly no expert on statistics, but my wife was taking a statistics course this summer and to illustrate that sampling random numbers from a distribution and taking an average of the samples gives you a random number as the result (bigger sample - smaller variance in the calculated random number, converging in on the mean of the original distribution), I threw together this program: #! /usr/bin/python import random; i=1 samplen=100 mean=130 lo=mean hi=mean sd=10 sum=0 while(i=samplen): x=random.normalvariate(mean,sd) #print x if xlo: lo=x if xhi: high=x sum+=x i+=1 print 'sample mean=', sum/samplen, '\n' print 'low value =', lo print 'high value=', high Your code has an error. In the middle of your code, you changed hi to high. Which very nicely makes the point that you can test algorithms driven by random data using statistical functions on the output! regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: how to run os.execv() to run command pslq dbname gen.command
Sonu wrote: hello all , i need to run psql from my py file,, for that i am using : os.execv(path for psql ,['psql dbname gen.command']) but its not working .. I want to watch my TV, but it's not working. Can you tell me how to fix it? ... the command wht i want to run from this py file is :psql dbname gen.command where gen.command file contain some command to create csv file from database \o temp.csv \a \f , select * from temp if u have any idea plz help me,, Perhaps you could post your code, and a copy of the error messages you see when you run this program? That will give a much better idea of what the problem is. You do realise that the snippet you posted isn't even legal Python, right? regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - -- http://mail.python.org/mailman/listinfo/python-list
Re: Website data-mining.
Jay Loden wrote: Miki wrote: Have a look at http://www.myinterestingfiles.com/2007/03/playboy-germany-ads.html Well, it's certainly interesting, but I'm not sure how it might help the OP get data from a website... A case of the Freudian clipboard, perhaps? ;-) Paul -- http://mail.python.org/mailman/listinfo/python-list
the one python book
newbie question: Is there a 'KR type of Python book? The book that you'd better have on your shelf if you are going into Python? -- http://mail.python.org/mailman/listinfo/python-list
Re: the one python book
On 4 Sie, 15:23, dhr [EMAIL PROTECTED] wrote: newbie question: Is there a 'KR type of Python book? The book that you'd better have on your shelf if you are going into Python? There are actually two of them: How to Think Like a Computer Scientist: Learning with Python by Allen B. Downey, Jeffrey Elkner and Chris Meyers http://www.ibiblio.org/obp/thinkCSpy/ and Dive Into Python by Mark Pilgrim http://diveintopython.org/toc/index.html Hope this helps :-) Cheers and good luck, Marek -- http://mail.python.org/mailman/listinfo/python-list
[DISLIN] Polar Grid
Hi, in a polar graph if I define the position of the first label TOP or BOTTOM,the grid doesn't show. Is this a bug? e.g. dislin.polmod('top', 'clockwise') dislin.polar (1.,0., 0.2, 0., 30.) dislin.grdpol(3,16) -- http://mail.python.org/mailman/listinfo/python-list
Re: the one python book
In article [EMAIL PROTECTED], dhr [EMAIL PROTECTED] wrote: newbie question: Is there a 'KR type of Python book? The book that you'd better have on your shelf if you are going into Python? There really aren't any, assuming you're comfortable reading web-based material. If it's important to you to have a reference book, probably _Python in a Nutshell_ would be best. If you're looking for a tutorial, I'll plug my own _Python for Dummies_. ;-) -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ This is Python. We don't care much about theory, except where it intersects with useful practice. -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp problem in Python
On Aug 4, 1:22 pm, Sönmez Kartal [EMAIL PROTECTED] wrote: On 4 A ustos, 00:41, Ehsan [EMAIL PROTECTED] wrote: I want to find http://www.2shared.com/download/1716611/e2000f22/ Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11 or 3gp instead of wmv in the text file like this : html some code function reportAbuse() { var windowname=abuse; var url=/abuse.jsp?link= + http://www.2shared.com/file/1716611/ e2000f22/Jadeed_Mlak14.html; OpenWindow = window.open(url,windowname,'toolbar=no,scrollbars=no,resizable=no,width=500,height=500,left=50,top=50'); OpenWindow.focus(); } function startDownload(){ window.location = http://www.2shared.com/download/1716611/ e2000f22/Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11; //document.downloadForm.submit(); } /script /head /htmlhttp://www.2shared.com/download/1716611/e2000f22/ Jadeed_Mlak14.3gp?tsid=20070803-164051-9d637d11sfgsfgsfgv I use this pattern : http.*?\.(wmv|3gp).* but it returns only 'wmv' and '3gp' instead of http://www.2shared.com/ download/1716611/e2000f22/Jadeed_Mlak14.wmv? tsid=20070803-164051-9d637d11 what can I do? what's wrong whit this pattern? thanx for your comments You could use r'window.location = (.*?\.(wmv|3gp);' as your regex string, I guess..- Hide quoted text - - Show quoted text - I didn't get what do you mean? i think i must just change the pattern but I don't know how to find bestfit pattern -- http://mail.python.org/mailman/listinfo/python-list
Re: Relative-importing *
[EMAIL PROTECTED] writes: Yes, I'm importing * for a reason, a good one, I think. Reading your description, I must say I don't see a good reason. I have a set of modules (the number planned to reach about 400) that would be dynamically loaded by my program as needed, and they're somewhat similar to each other. I wish each of them to import * from a certain parent module, so that they'll receive whatever functions and variables I want all of them to share (using the parent module's __all__), which may be overrided by the child modules at their discretion. Sort of like class inheritance, but I'm not doing that because implementing that would be a lot more tedious and less elegant. It seems to me, based only on this description, that class inheritance would be far *more* elegant, and much easier to follow when reading the code. If all these functions and other objects are so closely-related that they form the core of some inheritance-like system, what's so inelegant about wrapping them in a class so that the inheritance is explicit in the module where it happens? -- \ The only tyrant I accept in this world is the still voice | `\ within. -- Mahatma Gandhi | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: the one python book
newbie question: Is there a 'KR type of Python book? The book that you'd better have on Official Python Tutorial and all Library reference document is somewhat similar to KR for C. You cannot expect the same kind of book, although a variety of good books are available in Python. Depending on your level there are lot of good books available in Python. Go to www.python.org Beginners Tutorials and take up any of the Book for Programmers and Non Programmers list. Read more than one book and know for yourself as which one you will find it useful. Btw, do not miss to read Official Python Tutorial written by Guido. -- O.R.Senthil Kumaran http://uthcode.sarovar.org -- http://mail.python.org/mailman/listinfo/python-list
Re: the one python book
On Aug 4, 8:23 am, dhr [EMAIL PROTECTED] wrote: newbie question: Is there a 'KR type of Python book? The book that you'd better have on your shelf if you are going into Python? I second the comment about the Official Python Tutorial, however you did say, on the shelf in which case I would recommend: Python Essential Reference, David Beazley, 3rd edition Feb 2006 great, esp. if you already know some other programming language. http://tinyurl.com/38f5mh rd -- http://mail.python.org/mailman/listinfo/python-list
Re: the one python book
On 2007-08-04, dhr [EMAIL PROTECTED] wrote: newbie question: Is there a 'KR type of Python book? The book that you'd better have on your shelf if you are going into Python? C is such a small language that the same slim volume can be both a great tutorial and an awesome language reference. With Python, you won't find anything like that. Python is too huge. So get used to the idea of needing several books. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: the one python book
On Aug 4, 9:32 am, Neil Cerutti [EMAIL PROTECTED] wrot With Python, you won't find anything like that. Python is too huge. That's silly. Python is small in the sense that C is small. The Python standard library is probably much bigger than the C standard library, but Kernghan and Richie don't cover it. KR is a unique book. I have never seen anything comparable for any language. The closest Python equivalent is the official docs: http://docs.python.org/ I think the core Python bookshelf is: Learning Python (Lutxz Ascher) and/or Dive Into Python (Pilgrim) for tutorial Python in a Nutshell (Martelli) AND Python Essential Reference (Beazley) for reference The latter two books are not perfect (both indexes are infuriating) but I usually find that I can find what I am looking for in one or the other. Like most people I eventually plan to read Moby Dick, War and Peace, and Lutz's Programming Python. Maybe when I retire. mt -- http://mail.python.org/mailman/listinfo/python-list
Re: (no) fast boolean evaluation ?
On Aug 2, 10:47 pm, Stef Mientki [EMAIL PROTECTED] wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler switch to turn it on/off ? thanks, Stef Mientki The following program shows a(clumsy)? way to defeat the short- circuiting: def f(x): print f(%s)=%s % ('x',x), return x def g(x): print g(%s)=%s % ('x',x), return x print \nShort circuit for i in (True, False): for j in (True, False): print i,j,:, f(i) and g(j) print \nShort circuit defeated for i in (True, False): for j in (True, False): print i,j,:, g(j) if f(i) else (g(j) and False) The output is: Short circuit True True : f(x)=True g(x)=True True True False : f(x)=True g(x)=False False False True : f(x)=False False False False : f(x)=False False Short circuit defeated True True : f(x)=True g(x)=True True True False : f(x)=True g(x)=False False False True : f(x)=False g(x)=True False False False : f(x)=False g(x)=False False - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Problems with headers in email.message
Hi, python newbie, struggling to learn here. I'm trying to write a simple program which posts messages to my google group (via email). I'm using smtplib, email and email.message to build and send a message, but all the header attributes are appearing in the message body, so my messages are arriving with loads of junk in the body, no subject line and only the skinniest of headers. I know I'm doing something wrong, but I don't know what... Here's a simplification of what I'm doingessentially, I've taken from what I've learned at http://codeidol.com/python/python3/Client-Side-Scripting/pymail-A-Console-Based-Email-Client/ -Snip Here-Snip Here-Snip Here- import smtplib, email from email.message import Message m = Message( ) m['From'] = 'Slippy [EMAIL PROTECTED]' m['To'] = '[EMAIL PROTECTED]' m['Subject'] = 'A Test Message' m.set_payload('This is a test email. Please ignore') s = smtplib.SMTP('smtp.myemail.com') failed = s.sendmail('[EMAIL PROTECTED]','[EMAIL PROTECTED]',str(m)) if failed: print 'Message sending failed.' else: print 'Message sent.' print 'Bye.' -Snip Here-Snip Here-Snip Here- Now, I get all the right responses, and the message sends ok. I go and check my inbox, and the message is there, but the From, To and Subject lines I created (as well as a preceding blank line and a From nobody line) are in the message body, followed by the body text. How do I assign values to the header? I'd appreciate any help anyone can give me with this. -- http://mail.python.org/mailman/listinfo/python-list
Re: I am giving up perl because of assholes on clpm -- switching to Python
On Jul 25, 12:45 pm, [EMAIL PROTECTED] wrote: Python is a better language, with php support, anyway, but I am fed up with attitudes of comp.lang.perl.misc. Assholes in this newsgroup ruin Perl experience for everyone. Instead of being helpful, snide remarks, back-biting, scare tactings, and so on proliferate and self reinforce. All honest people have left this sad newsgroup. Buy bye, assholes, I am not going to miss you!!! Martha In the beginning there was Mathematics And all was good Then one day God said Let there be the Lambda Calculus And hence the Lambda Calculus was born. However, God felt the the Lambda Calculus needed a mate So god said Let there be Lisp And thus, Lisp was born. As the years went on, god became depressed by how impure the Lisp had become. For from the Lisp, came Emacs Lisp, Java, Perl, Ruby, and Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: the one python book
On 2007-08-04, Michael Tobis [EMAIL PROTECTED] wrote: On Aug 4, 9:32 am, Neil Cerutti [EMAIL PROTECTED] wrot With Python, you won't find anything like that. Python is too huge. That's silly. Python is small in the sense that C is small. What way of measuring makes that true? The Python standard library is probably much bigger than the C standard library, but Kernghan and Richie don't cover it. The complete standard library, plus some Unix-centered stuff is covered in KR. Python compares closely to C++ in the scope of its built-in features. KR is a unique book. I have never seen anything comparable for any language. That's partly because C is so small, though. Also Kernighan is a good technical writer. I'm not sure of Ritchie's contribution, as I haven't read any other books he wrote. The closest Python equivalent is the official docs: http://docs.python.org/ I think the core Python bookshelf is: Learning Python (Lutxz Ascher) and/or Dive Into Python (Pilgrim) for tutorial Python in a Nutshell (Martelli) AND Python Essential Reference (Beazley) for reference The latter two books are not perfect (both indexes are infuriating) but I usually find that I can find what I am looking for in one or the other. That's an excellent list. Like most people I eventually plan to read Moby Dick, War and Peace, and Lutz's Programming Python. Maybe when I retire. Don't forget Rarnaby Budge, by Charles Dikkens, the well known Dutch author. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
something wrong with wxPython list ?
hello, All my posts to [EMAIL PROTECTED] seems to be rejected since today ? Is there anything wrong with that list ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: the one python book
On Aug 4, 8:23 am, dhr [EMAIL PROTECTED] wrote: newbie question: Is there a 'KR type of Python book? The book that you'd better have on your shelf if you are going into Python? I would recommend Programming Python 3rd Ed. by Lutz or Core Python Programming by Chun. Lutz has more examples than Chun, but Chun has lots of good information about the language's history. Both authors share interesting facts about the language, some of which are pretty obscure. Lutz has good case studies though, so it may be slightly more valuable. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: the one python book
On Sat, 2007-08-04 at 15:10 +, Michael Tobis wrote: Like most people I eventually plan to read Moby Dick, War and Peace, and Lutz's Programming Python. Maybe when I retire. LOL. Lutz's Programming Python is actually how I learned Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with headers in email.message
On 04/08/07, Slippy [EMAIL PROTECTED] wrote: Hi, python newbie, struggling to learn here. I'm trying to write a simple program which posts messages to my google group (via email). I'm using smtplib, email and email.message to build and send a message, but all the header attributes are appearing in the message body, so my messages are arriving with loads of junk in the body, no subject line and only the skinniest of headers. I know I'm doing something wrong, but I don't know what... Here's a simplification of what I'm doingessentially, I've taken from what I've learned at http://codeidol.com/python/python3/Client-Side-Scripting/pymail-A-Console-Based-Email-Client/ -Snip Here-Snip Here-Snip Here- import smtplib, email from email.message import Message m = Message( ) m['From'] = 'Slippy [EMAIL PROTECTED]' m['To'] = '[EMAIL PROTECTED]' m['Subject'] = 'A Test Message' m.set_payload('This is a test email. Please ignore') s = smtplib.SMTP('smtp.myemail.com') failed = s.sendmail('[EMAIL PROTECTED]','[EMAIL PROTECTED]',str(m)) if failed: print 'Message sending failed.' else: print 'Message sent.' print 'Bye.' -Snip Here-Snip Here-Snip Here- Now, I get all the right responses, and the message sends ok. I go and check my inbox, and the message is there, but the From, To and Subject lines I created (as well as a preceding blank line and a From nobody line) are in the message body, followed by the body text. How do I assign values to the header? I'd appreciate any help anyone can give me with this. Your script (as posted) works fine for me. I did need to change one import line to: from email.Message import Message (note the capitalization), but that was all - originally it stopped the script dead, so it wasn't the cause of your problem. -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with headers in email.message
On Sat, 2007-08-04 at 15:38 +, Slippy wrote: [...] import smtplib, email from email.message import Message m = Message( ) m['From'] = 'Slippy [EMAIL PROTECTED]' m['To'] = '[EMAIL PROTECTED]' m['Subject'] = 'A Test Message' m.set_payload('This is a test email. Please ignore') s = smtplib.SMTP('smtp.myemail.com') failed = s.sendmail('[EMAIL PROTECTED]','[EMAIL PROTECTED]',str(m)) if failed: print 'Message sending failed.' else: print 'Message sent.' print 'Bye.' -Snip Here-Snip Here-Snip Here- Now, I get all the right responses, and the message sends ok. I go and check my inbox, and the message is there, but the From, To and Subject lines I created (as well as a preceding blank line and a From nobody line) are in the message body, followed by the body text. How do I assign values to the header? The way you're doing it is fine as far as assigning headers goes. My semi-educated guess is that either your mail-transfer agent or Google Groups' MTA is being confused by the Unix From envelope (that's the From nobody... you're seeing) that is included by str(m). Try m.as_string() instead, which doesn't include the Unix From envelope. I'd also like to point out that email.message is overkill for your simple use case. An email message is simply a series of headers followed by a blank line followed by the message body, which you can easily build manually if the headers aren't too long and the body is plain text: email_message = \ From: %s To: %s Subject: %s %s % (email_from, email_to, email_subject, email_body) HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: something wrong with wxPython list ?
On Aug 4, 11:01 am, Stef Mientki [EMAIL PROTECTED] wrote: hello, All my posts to [EMAIL PROTECTED] seems to be rejected since today ? Is there anything wrong with that list ? thanks, Stef Mientki Somehow I doubt the people on this list will know. I checked the ASPN archives, but they only show stuff from the 3rd. Not sure how often they update anyway. Here's the link for future reference though: http://aspn.activestate.com/ASPN/Mail/Browse/Plain/wxPython-users/3545288 I haven't received any of the wxPython digest since yesterday, so it could be that it's down right now. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with headers in email.message
On Sat, 2007-08-04 at 17:10 +0100, Tim Williams wrote: Your script (as posted) works fine for me. I did need to change one import line to: from email.Message import Message (note the capitalization) The modules inside the email package appear to have changed from capitalized names to lowercase names for Python 2.5. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: (no) fast boolean evaluation ?
On Aug 4, 4:18 pm, Paddy [EMAIL PROTECTED] wrote: On Aug 2, 10:47 pm, Stef Mientki [EMAIL PROTECTED] wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler switch to turn it on/off ? thanks, Stef Mientki The following program shows a(clumsy)? way to defeat the short- circuiting: def f(x): print f(%s)=%s % ('x',x), return x def g(x): print g(%s)=%s % ('x',x), return x print \nShort circuit for i in (True, False): for j in (True, False): print i,j,:, f(i) and g(j) print \nShort circuit defeated for i in (True, False): for j in (True, False): print i,j,:, g(j) if f(i) else (g(j) and False) The output is: Short circuit True True : f(x)=True g(x)=True True True False : f(x)=True g(x)=False False False True : f(x)=False False False False : f(x)=False False Short circuit defeated True True : f(x)=True g(x)=True True True False : f(x)=True g(x)=False False False True : f(x)=False g(x)=True False False False : f(x)=False g(x)=False False - Paddy. And here are the bits for boolean OR: print \n\nShort circuit: OR for i in (True, False): for j in (True, False): print i,j,:, f(i) or g(j) print \nShort circuit defeated: OR for i in (True, False): for j in (True, False): print i,j,:, (g(j) or True) if f(i) else g(j) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Re: Auto run/Timer
Rohan wrote: Hello, I would like my script to run once a week with out any external interference. More like a timer. Can it be done in python or should some other shell scripting be used. If anyone knows anything please let me know. Have a look at my 'kronos' task scheduler, available from: http://www.razorvine.net/downloads.html Things like this do require a Python process to be running all the time, for obvious reasons. If you don't want that, you'll have to use a task scheduler tool that your operating system provides (cron, for instance). --irmen -- http://mail.python.org/mailman/listinfo/python-list
sqlite3 create table col width?
PY help, Using sqlite3 v3.1.3 When I create a table collumn using; newcollum VARCHAR(35), I get a default of 10 spaces. No matter what I set the size to I get 10 spqces, even using varchar(0) defaults to 10 spaces. I would appreciae the help if someone could tell me what I'm missing, I want to varry the column sizes. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp problem in Python
Il Fri, 03 Aug 2007 14:41:52 -0700, Ehsan ha scritto: maybe you can use this to solve your prob: myurl = http://www.2shared.com/download/1716611/e2000f22/ Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11 if myurl.startswith('http') and ('wmv' in myurl or '3pg' in myurl): # myurl is the complete address you want print myurl # about re, I'm waiting for someone enlightening all us, bye Fabio -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp problem in Python
On 4 A ustos, 17:10, Ehsan [EMAIL PROTECTED] wrote: On Aug 4, 1:22 pm, Sönmez Kartal [EMAIL PROTECTED] wrote: On 4 A ustos, 00:41, Ehsan [EMAIL PROTECTED] wrote: I want to find http://www.2shared.com/download/1716611/e2000f22/ Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11 or 3gp instead of wmv in the text file like this : html some code function reportAbuse() { var windowname=abuse; var url=/abuse.jsp?link= + http://www.2shared.com/file/1716611/ e2000f22/Jadeed_Mlak14.html; OpenWindow = window.open(url,windowname,'toolbar=no,scrollbars=no,resizable=no,width=500,height=500,left=50,top=50'); OpenWindow.focus(); } function startDownload(){ window.location = http://www.2shared.com/download/1716611/ e2000f22/Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11; //document.downloadForm.submit(); } /script /head /htmlhttp://www.2shared.com/download/1716611/e2000f22/ Jadeed_Mlak14.3gp?tsid=20070803-164051-9d637d11sfgsfgsfgv I use this pattern : http.*?\.(wmv|3gp).* but it returns only 'wmv' and '3gp' instead of http://www.2shared.com/ download/1716611/e2000f22/Jadeed_Mlak14.wmv? tsid=20070803-164051-9d637d11 what can I do? what's wrong whit this pattern? thanx for your comments You could use r'window.location = (.*?\.(wmv|3gp);' as your regex string, I guess..- Hide quoted text - - Show quoted text - I didn't get what do you mean? i think i must just change the pattern but I don't know how to find bestfit pattern If you append window.location = and ';' to your pattern, it would be more clear to detect it. r'window.location = (.*?);' ... I have used this and it gave me ... data = html ... some code ... function reportAbuse() { ... var windowname=abuse; ... var url=/abuse.jsp?link= + http://www.2shared.com/file/ 1716611/e2000f22/Jadeed_Mlak14.html; ... OpenWindow = ... window.open(url,windowname,'toolbar=no,scrollbars=no,resizable=no,width=500,height=500,left=50,top=50'); ... OpenWindow.focus(); ... } ... function startDownload(){ ... window.location = http://www.2shared.com/download/1716611/ e2000f22/Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11; ... //document.downloadForm.submit(); ... } ... /script ... /head ... /html re.findall(r'window.location = (.*?);', data) ['http://www.2shared.com/download/1716611/e2000f22/Jadeed_Mlak14.wmv? tsid=20070803-164051-9d637d11'] print 'It works! :-)' It works! :-) Happy coding -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite3 create table col width?
On Aug 4, 6:51 pm, jim-on-linux [EMAIL PROTECTED] wrote: PY help, Using sqlite3 v3.1.3 When I create a table collumn using; newcollum VARCHAR(35), I get a default of 10 spaces. No matter what I set the size to I get 10 spqces, even using varchar(0) defaults to 10 spaces. I would appreciae the help if someone could tell me what I'm missing, I want to varry the column sizes. jim-on-linux Hi Jim, You need to create a new thread for this new question so it gets maximum visibility and so is more likely to be answered. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite3 create table col width?
On Sat, 2007-08-04 at 13:51 -0400, jim-on-linux wrote: PY help, Using sqlite3 v3.1.3 When I create a table collumn using; newcollum VARCHAR(35), I get a default of 10 spaces. No matter what I set the size to I get 10 spqces, even using varchar(0) defaults to 10 spaces. I would appreciae the help if someone could tell me what I'm missing, I want to varry the column sizes. What you're missing is that sqlite columns are type-less. Column type and size are irrelevant: import sqlite3 conn = sqlite3.connect(:memory) cur = conn.cursor() cur.execute(create table t1 (c1 varchar(35))) sqlite3.Cursor object at 0xb7f6dbf0 cur.executemany(insert into t1(c1) values(?), ... [ (X*i*10,) for i in range(10) ] ) cur.execute(select * from t1) sqlite3.Cursor object at 0xb7f6dbf0 for row in cur: print row ... (u'',) (u'XX',) (u'',) (u'XX',) (u'',) (u'XX',) (u'',) (u'XX',) (u'',) (u'XX',) Even though the column was created to be 35 characters wide, it'll happily accept 100-character strings. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Website data-mining.
Hello, I'm using Python for the first time to make a plug-in for Firefox. The goal of this plug-in is to take the source code from a website and use the metadata and body text for different kinds of analysis. My question is: How can I retrieve data from a website? I'm not even sure if this is possible through Python. Any help? Have a look athttp://www.myinterestingfiles.com/2007/03/playboy-germany-ads.html Well, it's certainly interesting, but I'm not sure how it might help the OP get data from a website... Ouch, let there be a lesson to me to *read* my posts before sending them :) Should have been http://wwwsearch.sourceforge.net/mechanize/. -- Miki (who can't paste) Tebeka [EMAIL PROTECTED] http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Efficient Rank Ordering of Nested Lists
On Aug 3, 8:38 am, [EMAIL PROTECTED] (Alex Martelli) wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: A naive approach to rank ordering (handling ties as well) of nested lists may be accomplished via: def rankLists(nestedList): def rankList(singleList): sortedList = list(singleList) sortedList.sort() return map(sortedList.index, singleList) return map(rankList, nestedList) unranked = [ [ 1, 2, 3, 4, 5 ], [ 3, 1, 5, 2, 4 ], [ -1.1, 2.2, 0, -1.1, 13 ] ] print rankLists(unranked) [[0, 1, 2, 3, 4], [2, 0, 4, 1, 3], [0, 3, 2, 0, 4]] This works nicely when the dimensions of the nested list are small. It is slow when they are big. Can someone suggest a clever way to speed it up? Each use of sortedList.index is O(N) [where N is len(singleList)], and you have N such uses in the map in the inner function, so this approach is O(N squared). Neil's suggestion to use bisect replaces the O(N) .index with an O(log N) search, so the overall performance is O(N log N) [[and you can't do better than that, big-O wise, because the sort step is also O(N log N)]]. beginner's advice to use a dictionary is also good and may turn out to be faster, just because dicts are SO fast in Python -- but you need to try and measure both alternatives. One way to use a dict (warning, untested code): def rankList(singleList): d = {} for i, item in reversed(enumerate(sorted(singleList))): d[item] = i return [d[item] for item in singleList] If you find the for-clause too rich in functionality, you can of course split it up a bit; but note that you do need the 'reversed' to deal with the corner case of duplicate items (without it, you'd end up with 1s instead of 0s for the third one of the sublists in your example). If speed is of the essence you might try to measure what happens if you replace the returned expression with map(d.__getitem__, singleList), but I suspect the list comprehension is faster as well as clearer. Another potential small speedup is to replace the first 3 statements with just one: d = dict((item,i) for i,item in reversed(enumerate(sorted(singleList but THIS density of functionality is a bit above my personal threshold of comfort (sparse is better than dense:-). Alex Thanks for breaking it down so thoroughly. I try the different recipes and see which gives the best trade offs between readability and performance. Agreed that dict() approach looks promising. -- http://mail.python.org/mailman/listinfo/python-list
Re: Efficient Rank Ordering of Nested Lists
On Aug 3, 9:20 am, [EMAIL PROTECTED] wrote: On Aug 2, 10:20 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: A naive approach to rank ordering (handling ties as well) of nested lists may be accomplished via: def rankLists(nestedList): def rankList(singleList): sortedList = list(singleList) sortedList.sort() return map(sortedList.index, singleList) return map(rankList, nestedList) unranked = [ [ 1, 2, 3, 4, 5 ], [ 3, 1, 5, 2, 4 ], [ -1.1, 2.2, 0, -1.1, 13 ] ] print rankLists(unranked) [[0, 1, 2, 3, 4], [2, 0, 4, 1, 3], [0, 3, 2, 0, 4]] This works nicely when the dimensions of the nested list are small. It is slow when they are big. Can someone suggest a clever way to speed it up? Isn't there something wrong with the ordering? Pablo's answers are: [ 1, 2, 3, 4, 5 ] == [0, 1, 2, 3, 4] correct [ 3, 1, 5, 2, 4 ] == [2, 0, 4, 1, 3] wrong? [ -1.1, 2.2, 0, -1.1, 13 ] == [0, 3, 2, 0, 4] wrong? Doing it in my head I get: [ 3, 1, 5, 2, 4 ] == [ 1, 3, 0, 4, 2 ] [ -1.1, 2.2, 0, -1.1, 13 ] == [0, 3, 2, 1, 4] What gives? Did I misunderstand what rank ordering (handling ties as well) means? There are many ways to skin this cat. I am considering the following approach: http://en.wikipedia.org/wiki/Rank_order#Standard_competition_ranking_.28.221224.22_ranking.29 -- http://mail.python.org/mailman/listinfo/python-list
Re: Efficient Rank Ordering of Nested Lists
On Aug 3, 5:53 am, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-08-03, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: A naive approach to rank ordering (handling ties as well) of nested lists may be accomplished via: def rankLists(nestedList): def rankList(singleList): sortedList = list(singleList) sortedList.sort() return map(sortedList.index, singleList) return map(rankList, nestedList) unranked = [ [ 1, 2, 3, 4, 5 ], [ 3, 1, 5, 2, 4 ], [ -1.1, 2.2, 0, -1.1, 13 ] ] print rankLists(unranked) [[0, 1, 2, 3, 4], [2, 0, 4, 1, 3], [0, 3, 2, 0, 4]] This works nicely when the dimensions of the nested list are small. It is slow when they are big. Can someone suggest a clever way to speed it up? Use binary search instead of linear. import bisect import functools def rankLists(nestedList): def rankList(singleList): sortedList = list(sorted(singleList)) return map(functools.partial(bisect.bisect_left, sortedList), singleList) return map(rankList, nestedList) -- Neil Cerutti Facts are stupid things. --Ronald Reagan Very clean and precisely what I was looking for. Thanks for expanding my knowledge of the language. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with headers in email.message
Carsten, changing to m.as_string() worked perfectly - Thanks for the help. The actual project I'm working on is a lot more complex than the simple case I've shown you, and does warrant the use of the message parser, honest! :-) On Aug 4, 5:14 pm, Carsten Haese [EMAIL PROTECTED] wrote: On Sat, 2007-08-04 at 15:38 +, Slippy wrote: [...] import smtplib, email from email.message import Message m = Message( ) m['From'] = 'Slippy [EMAIL PROTECTED]' m['To'] = '[EMAIL PROTECTED]' m['Subject'] = 'A Test Message' m.set_payload('This is a test email. Please ignore') s = smtplib.SMTP('smtp.myemail.com') failed = s.sendmail('[EMAIL PROTECTED]','[EMAIL PROTECTED]',str(m)) if failed: print 'Message sending failed.' else: print 'Message sent.' print 'Bye.' -Snip Here-Snip Here-Snip Here- Now, I get all the right responses, and the message sends ok. I go and check my inbox, and the message is there, but the From, To and Subject lines I created (as well as a preceding blank line and a From nobody line) are in the message body, followed by the body text. How do I assign values to the header? The way you're doing it is fine as far as assigning headers goes. My semi-educated guess is that either your mail-transfer agent or Google Groups' MTA is being confused by the Unix From envelope (that's the From nobody... you're seeing) that is included by str(m). Try m.as_string() instead, which doesn't include the Unix From envelope. I'd also like to point out that email.message is overkill for your simple use case. An email message is simply a series of headers followed by a blank line followed by the message body, which you can easily build manually if the headers aren't too long and the body is plain text: email_message = \ From: %s To: %s Subject: %s %s % (email_from, email_to, email_subject, email_body) HTH, -- Carsten Haesehttp://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: frequency analysis of a DB column
Just wanted to thank the Posters for the help! Thanks. Lee G. -- http://mail.python.org/mailman/listinfo/python-list
pyweek is happening august 02 - august 09
00:00 UTC 2007-09-02 to 00:00 UTC 2007-09-09 exactly. See www.pyweek.org PyconUK is happening. http://www.pyconuk.org/ 8th and 9th September. This means that those of us who generally do not see each other but are going to PyconUK could put together an entry and then sprint together on it before PyCon UK. There would be this terrible torment -- do I attend the con or get my game to work -- but it is still the best chance some of us have to work together yet. Talk to me if you are interested in maybe making a PyconUK pygame team. I think that this could be a lot of fun. Sign up on www.pyweek.org if you think so, as well. But mail me. John -- assuming we want to meet up _before_ PyConUK -- can that work? Can you point us at a cheap hostel for a few days? Laura Creighton -- http://mail.python.org/mailman/listinfo/python-list
Re: I am giving up perl because of assholes on clpm -- switching to Python
On Jul 22, 2:20 am, Bruno Desthuilliers [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] a écrit : Python is a better language, with php support, Python has php support ? My, I'm a professional web developper using both, and I didn't knew this. As an aside, perl DOES support PHP: http://search.cpan.org/~gschloss/PHP-Interpreter/ trwww -- http://mail.python.org/mailman/listinfo/python-list
Encoding DeprecationWarning
Hey There, Sorry if I am missing something here, but I get a DeprecationWarning when importing a list which has some unicode characters in it (it's a list of countries -- it's being raised on Åland), and I am left wondering why. I am using the syntax u' to denote a unicode string. If anyone would be so kind; what am I doing wrong? Many Thanks, Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding DeprecationWarning
On Sat, 2007-08-04 at 12:07 -0700, [EMAIL PROTECTED] wrote: Hey There, Sorry if I am missing something here, but I get a DeprecationWarning when importing a list which has some unicode characters in it Please copy and paste the full text of the warning. -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: [pygame] pyweek is happening august 02 - august 09
Laura Creighton wrote: 00:00 UTC 2007-09-02 to 00:00 UTC 2007-09-09 exactly. See www.pyweek.org PyconUK is happening. http://www.pyconuk.org/ 8th and 9th September. This means that those of us who generally do not see each other but are going to PyconUK could put together an entry and then sprint together on it before PyCon UK. There would be this terrible torment -- do I attend the con or get my game to work -- but it is still the best chance some of us have to work together yet. Talk to me if you are interested in maybe making a PyconUK pygame team. I think that this could be a lot of fun. Sign up on www.pyweek.org if you think so, as well. But mail me. John -- assuming we want to meet up _before_ PyConUK -- can that work? Can you point us at a cheap hostel for a few days? Laura Creighton Laura - Pyweek is happening the first week in September, not august. Thanks for giving me a good scare, thinking i missed the first half already! -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite3 create table col width?
On Saturday 04 August 2007 14:05, Carsten Haese wrote: On Sat, 2007-08-04 at 13:51 -0400, jim-on-linux wrote: PY help, Using sqlite3 v3.1.3 When I create a table collumn using; newcollum VARCHAR(35), I get a default of 10 spaces. No matter what I set the size to I get 10 spqces, even using varchar(0) defaults to 10 spaces. I would appreciae the help if someone could tell me what I'm missing, I want to varry the column sizes. What you're missing is that sqlite columns are type-less. Column type and size are irrelevant: import sqlite3 conn = sqlite3.connect(:memory) cur = conn.cursor() cur.execute(create table t1 (c1 varchar(35))) sqlite3.Cursor object at 0xb7f6dbf0 cur.executemany(insert into t1(c1) values(?), ... [ (X*i*10,) for i in range(10) ] ) cur.execute(select * from t1) sqlite3.Cursor object at 0xb7f6dbf0 for row in cur: print row ... (u'',) (u'XX',) (u'',) (u'XX',) (u'',) (u' XX',) (u' ',) (u' XX',) (u' ',) (u' XX', ) Even though the column was created to be 35 characters wide, it'll happily accept 100-character strings. HTH, -- Carsten Haese http://informixdb.sourceforge.net Right, the data is there. My question is framed wrong. Your answer pointed out the flaw in the question. Since I'm on linux, the database can be opened with Knoda. Once opened the table collumns are always 10 spaces so all the data is not readable as presented. Not quite a python problem. I can Tk a display for the data, just thought I could save time by letting the user open the table and read the data right from the table. Thanks for the help. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Submit web form only client-side with Python? COM?
Say I have have an HTML form , the user hits the submit button and I what text they enetered into a HTML form field is written to a file. But I don't have PHP, JAVA the usual client or server sided layers to write the data to a file, and I'm not to keen on JavaScript. Note: I can not add or download anything, I must use what I have. But I have Python 2.1 and I'm on a WinXP desktop with the win32.com, and usual active-x objects, MS-Office ect - what'd normally locally on an XP work station. So I can present the user with an HTML form in it - but how can I write the form data to a local file on my work station? If there isn't a web form way, could there be another way to get a box to come up with input fields with the capability to submit the data to a file? Thanks, Lee G. -- http://mail.python.org/mailman/listinfo/python-list
Re: Trying to find zip codes/rest example
Jay Loden wrote: I don't remember the demo, but a little creative googling turned up http://bitworking.org/news/132/REST-Tips-URI-space-is-infinite Which matches the description above perfectly, so I assume it's what you were after :-) That is exactly what I was trying to find! I bow down before your superior google-fu. Thanks, VanL -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython with python 2.5
On Aug 2, 9:34 am, Chris Mellon [EMAIL PROTECTED] wrote: On 8/2/07, G [EMAIL PROTECTED] wrote: Any help in getting wxpython to run in 2.5 would be greatly appreciated. Have you tried posting a request for help on the wx list? -- http://mail.python.org/mailman/listinfo/python-list
Question -- Running Programming Python Examples
Here is a newbie question: how do I get the server examples in the Preview chapter of Progamming Python (Lutz) to run? The code is supposed to be a little webserver on which to run examples, but when I run it it I get permission denied. Running it as root gets address already in use. Here is the code (it's example 2.32); comments are from Lutz, not me: webdir = '.' # where your html files and cgi-bin script directory live port = 80# default http://localhost/, else use http://localhost:/ import os, sys from BaseHTTPServer import HTTPServer from CGIHTTPServer import CGIHTTPRequestHandler # hack for Windows: os.environ not propogated [deleted, I'm running linux] . . . os.chdir(webdir) # run in html root dir srvraddr = (, port) # my hostname, portnumber srvrobj = HTTPServer(srvraddr, CGIHTTPRequestHandler) srvrobj.serve_forever()# run as perpetual demon END CODE My other python scripts run fine. I'm running linux (debian). I'm not running an webserver (that I know of anyway). I've fiddled with adding the subdirectory with the code to the python path, but this doesn't seem to help either. I'm new to all this, but I've been able to make the other stuff work, and I can't even find the beginning of what I'm supposed to research to fix this. Any help would be greatly appreciated, and thanks for your time and patience. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question -- Running Programming Python Examples
[EMAIL PROTECTED] wrote: Here is a newbie question: how do I get the server examples in the Preview chapter of Progamming Python (Lutz) to run? The code is supposed to be a little webserver on which to run examples, but when I run it it I get permission denied. Running it as root gets address already in use. The first error is because non-root users cannot bind to ports lower than 1024. The second error means just what it says: The address is already in use, so you can't bind to port 80. Something else is already bound to it; probably you have an HTTP server already running as part of your default software installation and don't realize it. Choose another port. -- Erik Max Francis [EMAIL PROTECTED] http://www.alcyone.com/max/ San Jose, CA, USA 37 20 N 121 53 W AIM, Y!M erikmaxfrancis If love is the answer, could you rephrase the question? -- Lily Tomlin -- http://mail.python.org/mailman/listinfo/python-list
Client-side HTML form processing with Python?
I want to have an HTML form from a local local html file write a text field's data to a local text file. I have no client or server side tools like PHP, JAVA. I don't know JavaScript. I can not add anything to the workstation I am using. It's going to have to be a client-side solution - there's no CGI on the server, no PHP. It's XP with MS-Office, so I guess I have the usual active-x, and I have Python 2.1. Is there a way? Thanks, Lee G. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question -- Running Programming Python Examples
[EMAIL PROTECTED] wrote: Here is a newbie question: how do I get the server examples in the Preview chapter of Progamming Python (Lutz) to run? The code is supposed to be a little webserver on which to run examples, but when I run it it I get permission denied. Running it as root gets address already in use. Here is the code (it's example 2.32); comments are from Lutz, not me: webdir = '.' # where your html files and cgi-bin script directory live port = 80# default http://localhost/, else use http://localhost:/ There's the trouble. You need special permission to open any of the ports up through 1023. As root, you have permission, but apparently some process already has that port opened, almost certainly a web server you start up at boot time, probably apache. So either kill off the web server that has port 80 opened, or better yet, just change the port to something else. A common choice is port 8080. This does not require superuser permission, and is probably free. port = 8080 If you do that, then you access the server on port 8080 with url's that look like this: http://localhost:8080/what/ever/..., or http://machine-name:8080/what/ever/..., Gary Herron import os, sys from BaseHTTPServer import HTTPServer from CGIHTTPServer import CGIHTTPRequestHandler # hack for Windows: os.environ not propogated [deleted, I'm running linux] . . . os.chdir(webdir) # run in html root dir srvraddr = (, port) # my hostname, portnumber srvrobj = HTTPServer(srvraddr, CGIHTTPRequestHandler) srvrobj.serve_forever()# run as perpetual demon END CODE My other python scripts run fine. I'm running linux (debian). I'm not running an webserver (that I know of anyway). I've fiddled with adding the subdirectory with the code to the python path, but this doesn't seem to help either. I'm new to all this, but I've been able to make the other stuff work, and I can't even find the beginning of what I'm supposed to research to fix this. Any help would be greatly appreciated, and thanks for your time and patience. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to capture output from an exec'ed (or such) script?
On Aug 3, 11:14 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Aug 2, 7:32 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: If your web server is multithreaded (or you use some other way to process many simultaneous requests) you have to be more careful - remember that sys.stdout is global, you must find a way to distinguish between output from different processes all going into the same collector. Any ideas on how to do this? Is it even possible? -Greg I'm actually worried about this now. Does anyone know of any potential solutions? Anything to at least get me started? -Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: the one python book
dhr [EMAIL PROTECTED] writes: Is there a 'KR type of Python book? The book that you'd better have on your shelf if you are going into Python? I don't think so, at least not if you are starting Python with experience in other languages. There are some books that are useful but none are really crucial. It's enough to just read the online documentation, which will let you transfer your experience onto Python, and then hang out here on clpy to soak up Python culture. If you're less experienced in programming but not a complete beginner, Dive Into Python looks pretty good and Python in a Nutshell also is supposed to be excellent. If you're a complete beginner, I'm not sure what to suggest. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question -- Running Programming Python Examples
That fixed it, and Gary's item on pointing my browser to the proper port answered the next question percolating in my mind. It now runs as advertised. Thanks to you both! -- http://mail.python.org/mailman/listinfo/python-list
Re: Submit web form only client-side with Python? COM?
goldtech [EMAIL PROTECTED] writes: So I can present the user with an HTML form in it - but how can I write the form data to a local file on my work station? The simplest way is with the cgi and CGIHTTPServer modules. You'd write your form in an html file, with the target set to a Python script that you'd write as a cgi. Then you'd write a trivial CGI HTTP server (look at the example code in the comments) with CGIHTTPServer. The user would point their browser at your server (you could make a desktop shortcut for that), the browser shows the html file, and the submit button sends the form contents to your cgi. This is very basic, old-school web programming, not as flexible or high-performance as using the fancy frameworks, but a lot simpler for limited applications like what you're describing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Client-side HTML form processing with Python?
goldtech [EMAIL PROTECTED] writes: I have no client or server side tools like PHP, JAVA. I don't know JavaScript. I can not add anything to the workstation I am using. It's going to have to be a client-side solution - there's no CGI on the server, no PHP. Oh wait, you're trying to write html on a remote web server that saves files on the client? Hmm, what browser? Anyway you're going to have to use browser scripting and use browser-dependent mechanisms to get the user's permission to access the file system. It is messy but necessary. Granting arbitrary file system access to remote web servers would be a huge security hole. -- http://mail.python.org/mailman/listinfo/python-list
Re: the one python book
Michael Tobis [EMAIL PROTECTED] writes: On Aug 4, 9:32 am, Neil Cerutti [EMAIL PROTECTED] wrot With Python, you won't find anything like that. Python is too huge. That's silly. Python is small in the sense that C is small. The Python standard library is probably much bigger than the C standard library, but Kernghan and Richie don't cover it. KR is a unique book. I have never seen anything comparable for any That's very true. language. The closest Python equivalent is the official docs: http://docs.python.org/ I think the core Python bookshelf is: Learning Python (Lutxz Ascher) and/or Dive Into Python (Pilgrim) for tutorial I can recommend (for a big fat reference at a good price) Programming Python by Mark Lutz from O'Reilly. Python in a Nutshell (Martelli) AND Python Essential Reference (Beazley) for reference The latter two books are not perfect (both indexes are infuriating) but I usually find that I can find what I am looking for in one or the other. Like most people I eventually plan to read Moby Dick, War and Peace, and Lutz's Programming Python. Maybe when I retire. Aha. You heard of it :-; mt -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Client-side HTML form processing with Python?
goldtech wrote: I want to have an HTML form from a local local html file write a text field's data to a local text file. I have no client or server side tools like PHP, JAVA. I don't know JavaScript. I can not add anything to the workstation I am using. It's going to have to be a client-side solution - there's no CGI on the server, no PHP. It's XP with MS-Office, so I guess I have the usual active-x, and I have Python 2.1. Is there a way? Thanks, Lee G. Even if serving a local page, some kind of web server would be necessary in order to process the request from the submitted form, and execute the Python CGI script. I know you said you can't add anything to the workstation, but you must be able to at least add Python scripts and html files, so perhaps you can get away with adding a self-contained web server? I recommend TinyWeb ( http://www.ritlabs.com/en/products/tinyweb/ ). It's only 53k and supports all the basic webserver functions, including CGI. You can drop TinyWeb in your working directory, start it up with a simple shortcut or batch file, and then have your local HTML form submit to a CGI script processed through TinyWeb. I've used it for a very similar project before, it's so tiny and lightweight that it really doesn't get in the way, and the CGI portion works just fine with Python. If you really can't add anything at all (not even Python packages??), the only other way to do this that I can come up with would be to implement your own simplistic web server in Python that receives the incoming request. Twisted has a CGI-enabled web server in it, and CGIHTTPServer also offers one. However, CGIHTTPServer uses os.fork and is not available on Windows: http://www.python.org/doc/1.5.2p2/lib/module-CGIHTTPServer.html - but you could possibly use it as a starting point. Other than the above the only suggestion I can give would be to search for another way to approach your problem. For instance, using an hta http://msdn2.microsoft.com/en-us/library/ms536496.aspx or using a Tkinter/wxWidgets GUI instead of an html form. -Jay -- http://mail.python.org/mailman/listinfo/python-list
Re: Submit web form only client-side with Python? COM?
Paul Rubin wrote: goldtech [EMAIL PROTECTED] writes: So I can present the user with an HTML form in it - but how can I write the form data to a local file on my work station? The simplest way is with the cgi and CGIHTTPServer modules. You'd write your form in an html file, with the target set to a Python script that you'd write as a cgi. Then you'd write a trivial CGI HTTP server (look at the example code in the comments) with CGIHTTPServer. The user would point their browser at your server (you could make a desktop shortcut for that), the browser shows the html file, and the submit button sends the form contents to your cgi. This is very basic, old-school web programming, not as flexible or high-performance as using the fancy frameworks, but a lot simpler for limited applications like what you're describing. CGIHTTPServer is not available on Windows (OP said they are on Win XP) due to use of fork and exec to execute the CGI. I suggested a few other options in my reply, but unfortunately CGIHTTPServer is not an option for this task. -Jay -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding DeprecationWarning
from wt.lib.misc_lists import all_countries __console__:1: DeprecationWarning: Non-ASCII character '\xc3' in file / Django/wt/../wt/lib/misc_lists.py on line 141, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details -- http://mail.python.org/mailman/listinfo/python-list
Re: Client-side HTML form processing with Python?
Looks like Tkinter is the way to do it. There's always a way with Python - good stuff! -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding DeprecationWarning
On Aug 4, 11:43 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: from wt.lib.misc_lists import all_countries __console__:1: DeprecationWarning: Non-ASCII character '\xc3' in file / Django/wt/../wt/lib/misc_lists.py on line 141, but no encoding declared; seehttp://www.python.org/peps/pep-0263.htmlfor details OK, well; no matter. Perhaps I should try actually reading the article it recommended and add: # -*- coding: utf-8 -*- To the file! What a doofus! Thanks, Oliver -- http://mail.python.org/mailman/listinfo/python-list
Re: Eclipse/PyDev question.
News (or, news to me :) ) The creator of PyDev, contacted me and told me that latest version of PyDev need not require the whole SDK but only the Runtime Platfom is OK. That means that we download only the 40MB file (and not the 120 one) and this does not include all the Java stuff that we see in SDK. So, combined with PyDev, we have an editor just for Python! I test it a few hours now and it is really fast! -- http://mail.python.org/mailman/listinfo/python-list
Re: Eclipse/PyDev question.
Ah, and i think that the working set of Eclipse is smaller now... -- http://mail.python.org/mailman/listinfo/python-list
Re: how to run os.execv() to run command pslq dbname gen.command
Steve Holden [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Sonu wrote: hello all , I want to watch my TV, but it's not working. Can you tell me how to fix it? ... I can help you... but only with a couple of channels :-). i need to run psql from my py file,, for that i am using : os.execv(path for psql ,['psql dbname gen.command']) but its not working .. I assume the problem relies in the execution pathes, but as Steve has mentioned: without further details nobody will be able to help you. ./alex -- .w( the_mindstorm )p. -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite3 create table col width?
jim-on-linux [EMAIL PROTECTED] writes: PY help, Using sqlite3 v3.1.3 You made this message a reply to an existing discussion, so your message is now part of that existing discussion. Please start a new discussion thread by composing a new message. -- \ True greatness is measured by how much freedom you give to | `\ others, not by how much you can coerce others to do what you | _o__) want. --Larry Wall | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Formatting Results so that They Can be Nicely Imported into a Spreadsheet.
Hi All. Let's say I have some badly formatted text called doc: doc= friendid Female 23 years old Los Gatos United States friendid Male 24 years old San Francisco, California United States How would I get these results to be displayed in a format similar to: friendid;Female;23 years old;Los Gatos;United States friendid;Male; 24 years old;San Francisco, California;United States The latter is a lot easier to organize and can be quickly imported into Excel's column format. Thanks Much, Sam -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding DeprecationWarning
On Sat, 2007-08-04 at 15:52 -0700, [EMAIL PROTECTED] wrote: On Aug 4, 11:43 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: from wt.lib.misc_lists import all_countries __console__:1: DeprecationWarning: Non-ASCII character '\xc3' in file / Django/wt/../wt/lib/misc_lists.py on line 141, but no encoding declared; seehttp://www.python.org/peps/pep-0263.htmlfor details OK, well; no matter. Perhaps I should try actually reading the article it recommended Right, that's why I asked you to post the full warning message, to get you to take another look at it. Mission accomplished ;) -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: [pygame] pyweek is happening august 02 - august 09
In a message of Sat, 04 Aug 2007 14:25:29 CDT, Luke Paireepinart writes: Laura Creighton wrote: 00:00 UTC 2007-09-02 to 00:00 UTC 2007-09-09 exactly. See www.pyweek.org PyconUK is happening. http://www.pyconuk.org/ 8th and 9th September. This means that those of us who generally do not see each other but are going to PyconUK could put together an entry and then sprint together on it before PyCon UK. There would be this terrible torment -- do I attend the con or get my game to work -- but it is still the best chance some of us have to work together yet. Talk to me if you are interested in maybe making a PyconUK pygame team. I think that this could be a lot of fun. Sign up on www.pyweek.org if you think so, as well. But mail me. John -- assuming we want to meet up _before_ PyConUK -- can that work? Can you point us at a cheap hostel for a few days? Laura Creighton Laura - Pyweek is happening the first week in September, not august. Thanks for giving me a good scare, thinking i missed the first half alrea dy! You are welcome to the scare, but pyconUK is happening first week of Sept too! So my plan of a 'would not meet but for pyconUK team' is still very alive. Laura -- http://mail.python.org/mailman/listinfo/python-list
Re: Formatting Results so that They Can be Nicely Imported into a Spreadsheet.
On Aug 5, 9:35 am, SMERSH009 [EMAIL PROTECTED] wrote: Hi All. Let's say I have some badly formatted text called doc: doc= friendid Female 23 years old Los Gatos United States friendid Male 24 years old San Francisco, California United States How would I get these results to be displayed in a format similar to: friendid;Female;23 years old;Los Gatos;United States friendid;Male; 24 years old;San Francisco, California;United States The latter is a lot easier to organize and can be quickly imported into Excel's column format. You write a script to read your input file and write it out either in CSV format, using the Python csv module, or just use ';'.join(output_row) if you are sure that there are no ';' characters in the data. Is this a homework question? -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: keyboard shortcuts pain
The following article a extended version of previous post. A HTML version can be found at http://xahlee.org/emacs/emacs_kb_shortcuts_pain.html --- WHY EMACS'S KEYBOARD SHORTCUTS ARE PAINFUL Xah Lee, 2007-07 A important aspect in designing a keyboard shortcut set, for a application that has intensive, repetitive, prolonged human-machine interaction (such as coding and text editing), is to consider ergonomic principles. Specifically: allocate keyboard shortcuts for the most frequently used commands, and, the top most frequently used commands should have most easily-pressed keystrokes. For example, they should be on the home row. This article shows why Emacs's keyboard shortcut set are the most ergonomically unsound. THE SWAPPING OF CONTROL AND META MODIFIERS Emacs's keyboard shortcuts is very inefficient. The primary cause is because, emacs's keyboard shortcuts are designed with a keyboard that practically has the Ctrl and Alt key positions swapped. Space Cadet keyboard above: The Space-cadet keyboard (Source↗, 2007-07) . The common keyboard used around emacs era in the 1980s are those keyboards from Lisp Machines↗. (see Space-cadet keyboard↗) The keyboard on lisp machines have the Control key right besides the space bar (similar to the position of Alt keys on PC keyboards), and Meta to the left of Control. So, the Control key is right under the thumb, and the Meta is secondary to Control. This is why, the shortcuts for the most used commands in emacs involve the Control key instead of the Meta key. (e.g. The cursor movements: C-p, C-n, C-f, C-b, C-a, C-e, the cut/paste/undo C-w, C-y, C-/, the kill-line C-k, the mark C-SPC, the search C-s.) Lisp Machine's keyboards fell out of use alone with Lisp Machines. Since the 1990s, the IBM PC keyboard↗ (and its decedents) becomes the most popular and is used by more than 99% of personal computers today. The PC keyboard does not have Meta key but have Alt instead, which is practically used as Meta for emacs. The Ctrl and Alt key's position are essentially swapped from the Control and Meta on the Lisp Machine's keyboards. Emacs however, did not change its keyboard shortcut set by switching the commands that are mapped to the Control and Meta keys. This makes emacs keyboard shortcuts very painful, and the frequent need to press the far-away Control key makes the Emacs Pinky syndrome. (Many emacs-using programer celebrities have injured their hands with emacs. (e.g. Richard Stallman↗, Jamie Zawinski↗), and emacs's Ctrl and Meta combinations are most cited as the major turn-off to potential users among programers) THE CHOICE OF KEYS The shortcut's key choices are primarily based on first letter of the commands, not based on key position and finger strength or ease of pressing the key. For example, the single char cursor moving shortcuts (C-p previous-line ↑, C-n next-line ↓, C-b backward-char ←, C-f forward-char →) are scattered around the keyboard with positions that are most difficult to press. (these shortcuts all together accounts for 43% of all commands executed by a keyboard shortcut) Of these, the most frequently used is C-n (next-line), which accounts for 20% of all shortcut calls, but is assigned to the letter n, positioned in the middle of the keyboard, which is one of the most costy key to press. Similarly, the second most used among these is the C-p (previous- line), accounting for 16% of all shortcut command calls, is located in a position above the rigth hand's pinky, also one of the most costy key to press. (Here we assumes the QWERTY keyboard layout. On the Dvorak layout, it is about as bad.) OUTDATED COMMANDS A significant portion of emacs's major shortcuts (those with M-«key» or C-«key») are mapped to commands that are almost never used today. Some of these occupies the most precious space (Home row with Meta: e.g. M-s (center-line), M-j (indent-new-comment-line), M-k (kill- sentence)). Most programer who have used emacs for years never use these commands. For example: digit-argument, M-1 to M-9 negative-argument, M-- move-to-window-line, M-r center-line, M-s transpose-words, M-t tab-to-tab-stop, M-i M-g prefix, M-g indent-new-comment-line, M-j tmm-menubar, M-' zap-to-char, M-z back-to-indentation, M-m tags-loop-continue, M-, find-tag, M-. NO EMPLOYMENT OF THE SHIFT KEY For historical reasons, emacs do not use any keybindings involving the Shift with a letter. (e.g. there's no “meta shift a”, or “control shift a”) This is so because in early computing environment, such key combination cannot be distinguished, due to a practical combination of ASCII↗, Computer terminal↗, telnet↗. Today, however, employing the Shift key as part of a shortcut with other modifiers is common and convenient. For example, on Mac OS X, Undo and Redo are Cmd+Z and Cmd+Shift+Z, Save and Save As are Cmd+S and Cmd+Shift+S. On Mac and Windows, moving to next/previous field/ window/application often use the Shift key for reversing
Re: os.listdir path error
[EMAIL PROTECTED] wrote: I get SyntaxError: EOL while scanning single-quoted string, which is what should happen when you escape the double-quotes at the end. Not sure how you're getting that WindowsErrors. If I do os.listdir('c:\python24') instead, it works fine. Yes, but only by accident. It will fail again if you try to do os.listdir('c:\tmp'). You need to use the right quoting. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Formatting Results so that They Can be Nicely Imported into a Spreadsheet.
On Aug 4, 6:35?pm, SMERSH009 [EMAIL PROTECTED] wrote: Hi All. Let's say I have some badly formatted text called doc: doc= friendid Female 23 years old Los Gatos United States friendid Male 24 years old San Francisco, California United States How would I get these results to be displayed in a format similar to: friendid;Female;23 years old;Los Gatos;United States friendid;Male; 24 years old;San Francisco, California;United States The latter is a lot easier to organize and can be quickly imported into Excel's column format. Thanks Much, Sam d = doc.split('\n') f = [i.split() for i in d if i] g = [' '.join(i) for i in f] rec = [] temprec = [] for i in g: if i: if i == 'friendid': rec.append(temprec) temprec = [i] else: temprec.append(i) rec.append(temprec) output = [';'.join(i) for i in rec if i] for i in output: print i ##friendid;Female;23 years old;Los Gatos;United States ##friendid;Male;24 years old;San Francisco, California;United States -- http://mail.python.org/mailman/listinfo/python-list
Re: libpq.dll for pgdb
ekzept [EMAIL PROTECTED] wrote: the module PGDB which gives Python access to PostgreSql currently wants for a copy of a properly located or proper libpq.dll library, on Windows. anyone know what the current story on this is? The story? libpq.dll is the Postgres API interface library on Windows. pgdb is a relatively thin Python wrapping of this generic API. Pgdb is ordinarily distributed as part of Postgres, so when you build it, you are also building libpq.dll. There are better choices than pgdb. You might go searching for psycopg. You'll still need libpq. Here's one place to get it: http://www.tksql.org/dll/ -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Efficient Rank Ordering of Nested Lists
beginner's advice to use a dictionary is also good and may turn out to be faster, just because dicts are SO fast in Python -- but you need to try and measure both alternatives. One way to use a dict ( warning, untested code ) : def rank_list( single_list ) : d = { } for i , item in reversed( enumerate( sorted( single_list ) ) ) : d[ item ] = i return [ d[ item ] for item in single_list ] Alex I tested it but I don't know how to fix it :-) Both Pablo's original version and Neil's version work but I get the following traceback from your version Traceback (most recent call last): File list_nested_rank.py, line 100, in module test_01( list_source ) File list_nested_rank.py, line 87, in test_01 list_print( this_func( list_source ) ) File list_nested_rank.py, line 62, in rank_lists_02 return map( rank_list , nested_list ) File list_nested_rank.py, line 56, in rank_list for i , item in reversed( enumerate( sorted( single_list ) ) ) : TypeError: argument to reversed() must be a sequence -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Formatting Results so that They Can be Nicely Imported into a Spreadsheet.
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Aug 4, 6:35?pm, SMERSH009 [EMAIL PROTECTED] wrote: Hi All. Let's say I have some badly formatted text called doc: doc= friendid Female 23 years old Los Gatos United States friendid Male 24 years old San Francisco, California United States How would I get these results to be displayed in a format similar to: friendid;Female;23 years old;Los Gatos;United States friendid;Male; 24 years old;San Francisco, California;United States The latter is a lot easier to organize and can be quickly imported into Excel's column format. Thanks Much, Sam d = doc.split('\n') f = [i.split() for i in d if i] g = [' '.join(i) for i in f] rec = [] temprec = [] for i in g: if i: if i == 'friendid': rec.append(temprec) temprec = [i] else: temprec.append(i) rec.append(temprec) output = [';'.join(i) for i in rec if i] for i in output: print i ##friendid;Female;23 years old;Los Gatos;United States ##friendid;Male;24 years old;San Francisco, California;United States also, I would suggest you use CSV format. CSV stands for Comma Seperated Variable and Excel can load such a sheet directly. Instead of seperating using ; seperate using , Of course, this provides a problem when there is a , in a string. Resolution is to quote the string. Being such, you can just go ahead and quote all strings. So you would want the output to be: friendid,Female,23 years old,Los Gatos,United States friendid,Male,24 years old,San Francisco, California,United States Numbers should not be quoted if you wish to treat them as numeric and not text. -- http://mail.python.org/mailman/listinfo/python-list
Re: Efficient Rank Ordering of Nested Lists
Cousin Stanley [EMAIL PROTECTED] wrote: ... for i , item in reversed( enumerate( sorted( single_list ) ) ) : ... TypeError: argument to reversed() must be a sequence Oops, right. Well then, aux_seq = list(enumerate(sorted(single_list))) for i, item in reversed(aux_seq): ... or the like. Alex -- http://mail.python.org/mailman/listinfo/python-list
Comparing RFC1123 based Dates
I would like to parse RFC 1123 date format and compare two dates. I find that datetime module does not specifically confirms to any RFC. Any suggestions as how I can handle the RFC 1123 date format using standard libraries before I go to re based parsing? Thanks, Senthil -- http://mail.python.org/mailman/listinfo/python-list
Re: Efficient Rank Ordering of Nested Lists
Cousin Stanley [EMAIL PROTECTED] wrote: ... for i , item in reversed( enumerate( sorted( single_list ) ) ) : ... TypeError: argument to reversed() must be a sequence Oops, right. Well then, aux_seq = list(enumerate(sorted(single_list))) for i, item in reversed(aux_seq): ... Alex That fixed it. Thanks -- Stanley C. Kitching Human Being Phoenix, Arizona == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Formatting Results so that They Can be Nicely Imported into a Spreadsheet.
On Aug 4, 9:21?pm, Jim Langston [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Aug 4, 6:35?pm, SMERSH009 [EMAIL PROTECTED] wrote: Hi All. Let's say I have some badly formatted text called doc: doc= friendid Female 23 years old Los Gatos United States friendid Male 24 years old San Francisco, California United States How would I get these results to be displayed in a format similar to: friendid;Female;23 years old;Los Gatos;United States friendid;Male; 24 years old;San Francisco, California;United States The latter is a lot easier to organize and can be quickly imported into Excel's column format. Thanks Much, Sam d = doc.split('\n') f = [i.split() for i in d if i] g = [' '.join(i) for i in f] rec = [] temprec = [] for i in g: if i: if i == 'friendid': rec.append(temprec) temprec = [i] else: temprec.append(i) rec.append(temprec) output = [';'.join(i) for i in rec if i] for i in output: print i ##friendid;Female;23 years old;Los Gatos;United States ##friendid;Male;24 years old;San Francisco, California;United States also, I would suggest you use CSV format. Well, the OP asked for a specific format. One is not always at liberty to change it. CSV stands for Comma Seperated Variable and Excel can load such a sheet directly. And Excel can load the shown format directly also, just specify the delimiter. Instead of seperating using ; seperate using , Of course, this provides a problem when there is a , in a string. Which explains the popularity of using tabs as delimiters. The data deliverable specification I use at work uses the pipe character | which never appears as data in this particular application. Resolution is to quote the string. Which makes the file bigger and isn't necessary when tabs and pipes are used as delimiters. Being such, you can just go ahead and quote all strings. So you would want the output to be: friendid,Female,23 years old,Los Gatos,United States friendid,Male,24 years old,San Francisco, California,United States Which I would do if I had a specification that demanded it or was making files for others. For my own use, I wouldn't bother as it's unnecessary work. Numbers should not be quoted if you wish to treat them as numeric and not text. A good reason not to use quotes at all. Besides which, Excel can handle that also. -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing RFC1123 based Dates
Phoe6 wrote: I would like to parse RFC 1123 date format and compare two dates. I find that datetime module does not specifically confirms to any RFC. Any suggestions as how I can handle the RFC 1123 date format using standard libraries before I go to re based parsing? Well, import time timeobj = time.strptime(Thu, 01 Dec 1994 16:00:00 GMT,%a, %d %b %Y %H:%M:%S %Z) was easy. Thanks, Senthil -- http://mail.python.org/mailman/listinfo/python-list
[ python-Bugs-1753891 ] subprocess raising No Child Process OSError
Bugs item #1753891, was opened at 2007-07-14 03:06 Message generated for change (Comment added) made by gbrandl You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1753891group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Threads Group: Python 2.4 Status: Open Resolution: Duplicate Priority: 5 Private: No Submitted By: slowfood (slowfood) Assigned to: Nobody/Anonymous (nobody) Summary: subprocess raising No Child Process OSError Initial Comment: The program below demostrates a No Child Process OSError on a multi-cpu systems. This is extracted from a large system where we are trying to manage many sub-processes, some of which end up having little/no real work to do so they return very fast, here emulated by having the sub-process be an invocation of: Executable=/bin/sleep 0 Seems like some race condition, since if you make the child process take some time (sleep 0.1) the frequency of errors decreeses. Error only shows up when there are more threads than have real CPU's by at least a factor of two, on dual core machines up NumThreads to 18 to get the failures. Same error on both Python 2.4.3 with: Linux 2.6.18-gentoo-r3 Gentoo and Python 2.4.4 with: Linux 2.6.20-gentoo-r8 Any help appreciated - = = = = Start code example === % python subprocess_noChildErr.py Exception in thread Thread-3: Traceback (most recent call last): File /usr/lib64/python2.4/threading.py, line 442, in __bootstrap self.run() File testCaseA.py, line 14, in run subprocess.call(Executable.split()) File /usr/lib64/python2.4/subprocess.py, line 413, in call return Popen(*args, **kwargs).wait() File /usr/lib64/python2.4/subprocess.py, line 1007, in wait pid, sts = os.waitpid(self.pid, 0) OSError: [Errno 10] No child processes Test finished % cat subprocess_noChildErr.py import subprocess, threading # Params Executable=/bin/sleep 0 NumThreads = 18 NumIterations = 10 class TestClass(threading.Thread): def __init__(self, threadNum): self.threadNum = threadNum threading.Thread.__init__(self) def run(self): for i in range(NumIterations): subprocess.call(Executable.split()) def test(): allThreads = [] for i in range(NumThreads): allThreads.append(TestClass(i)) for i in range(NumThreads): allThreads[i].start() for i in range(NumThreads): allThreads[i].join() print Test finished if __name__ == '__main__': test() % python -V Python 2.4.4 % uname -a Linux 2.6.20-gentoo-r8 #2 SMP PREEMPT Sun Jul 1 13:22:56 PDT 2007 x86_64 Dual-Core AMD Opteron(tm) Processor 2212 AuthenticAMD GNU/Linux % % date Fri Jul 13 19:26:44 PDT 2007 % = = = = End code example === -- Comment By: Georg Brandl (gbrandl) Date: 2007-08-04 07:25 Message: Logged In: YES user_id=849994 Originator: NO Closing too. Tying bugs is not supported by SF. -- Comment By: slowfood (slowfood) Date: 2007-08-03 20:07 Message: Logged In: YES user_id=1844537 Originator: YES Managed to mark it as a duplicate, but not able to tie it to 1731717. Sorry - ;;slowfood -- Comment By: slowfood (slowfood) Date: 2007-08-03 20:01 Message: Logged In: YES user_id=1844537 Originator: YES I agree with abo that this looks to be a dup of 1731717, will try to mark it as such. -- Comment By: Donovan Baarda (abo) Date: 2007-08-03 19:37 Message: Logged In: YES user_id=10273 Originator: NO Bugs 1754642 and 1753891 both look like duplicates of bug 1731717 to me. I suggest marking them both as dups of 1731717 because that one has info on the race-condition that causes this and discussions on how to fix it. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1753891group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1753395 ] struni: assertion in Windows debug build
Bugs item #1753395, was opened at 2007-07-13 13:35 Message generated for change (Comment added) made by doerwalter You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1753395group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Python 3000 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Thomas Heller (theller) Assigned to: Thomas Heller (theller) Summary: struni: assertion in Windows debug build Initial Comment: When running Lib/test/test_descr.py with a Windows debug build, I get an assertion in the MS runtime lib, in the isalpha(*p) call, file typeobject.c, line 1582. The value of '*p' at the time of the call is 4660. The assertion reported is: File: istype.c Line: 68 Expression; (unsigned)(c + 1) = 256 -- Comment By: Walter Dörwald (doerwalter) Date: 2007-08-04 09:42 Message: Logged In: YES user_id=89016 Originator: NO Right, this should have been *p 255, even better would be *p 127. Thomas, can you try that on Windows? -- Comment By: Guido van Rossum (gvanrossum) Date: 2007-08-03 22:37 Message: Logged In: YES user_id=6380 Originator: NO I wonder if the test i 255 wasn't meant to be *p 255? Please try that, and submit if it works. Looks like Walter Doerwald introduced this bug in r55892. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1753395group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1767511 ] SocketServer.DatagramRequestHandler
Bugs item #1767511, was opened at 2007-08-04 11:21 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1767511group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.5 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Alzheimer (alzheimer) Assigned to: Nobody/Anonymous (nobody) Summary: SocketServer.DatagramRequestHandler Initial Comment: I seem to have misunderstood SocketServer completely, maybe someone can tell me if I was using the wrong thing after all. I wanted to implement an UDP protocol in Python. For sending and receiving UDP packets, I chose SocketServer.UDPSocketServer along with the DatagramRequestHandler. It is probably implied, but did not become clear to me just by reading the documentation, that apparently a server is meant to send back a packet for every packet it receives, no matter what. Which in turn means that you can't have servers talk to other servers, because they'd be sending packets back and forth endlessly then. At least, that's what the DatagramRequestHandler is doing. It issues a socket.sendto in its finish() routine. Took me a while to find out where all the empty packets where coming from... Does it make sense at all for an UDP server to do this? Sure, it works for simple protocols that do nothing but query/answer. But it's really useless for anything else. The documentation could be more verbose on this behaviour, in any case. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1767511group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1753395 ] struni: assertion in Windows debug build
Bugs item #1753395, was opened at 2007-07-13 13:35 Message generated for change (Comment added) made by theller You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1753395group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Python 3000 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Thomas Heller (theller) Assigned to: Martin v. Löwis (loewis) Summary: struni: assertion in Windows debug build Initial Comment: When running Lib/test/test_descr.py with a Windows debug build, I get an assertion in the MS runtime lib, in the isalpha(*p) call, file typeobject.c, line 1582. The value of '*p' at the time of the call is 4660. The assertion reported is: File: istype.c Line: 68 Expression; (unsigned)(c + 1) = 256 -- Comment By: Thomas Heller (theller) Date: 2007-08-04 22:58 Message: Logged In: YES user_id=11105 Originator: YES I confirm that the assertion in the windows debug build is gone now. -- Comment By: Guido van Rossum (gvanrossum) Date: 2007-08-04 18:44 Message: Logged In: YES user_id=6380 Originator: NO I've committed the *p 127 patch. Committed revision 56737. However, we'll need to change this again now that we accept Unicode identifiers. Assigning to MvL. -- Comment By: Walter Dörwald (doerwalter) Date: 2007-08-04 09:42 Message: Logged In: YES user_id=89016 Originator: NO Right, this should have been *p 255, even better would be *p 127. Thomas, can you try that on Windows? -- Comment By: Guido van Rossum (gvanrossum) Date: 2007-08-03 22:37 Message: Logged In: YES user_id=6380 Originator: NO I wonder if the test i 255 wasn't meant to be *p 255? Please try that, and submit if it works. Looks like Walter Doerwald introduced this bug in r55892. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=105470aid=1753395group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com