Python-URL! - weekly Python news and links (Jun 25)
QOTW: [R]edundant/useless/misleading/poor code is worse than wrong. - Michele Simionato http://groups.google.com/group/comp.lang.python/msg/74adbb471826a245 Unit tests are not a magic wand that discover every problem that a program could possibly have. - Paul Rubin http://groups.google.com/group/comp.lang.python/msg/6e683105172b2ca7 Some tricks to automatically enter the debugger when an exception happens: http://groups.google.com/group/comp.lang.python/browse_thread/thread/3ffc25cbd3d1947/ A recurring topic: using uniform collections of objects: http://groups.google.com/group/comp.lang.python/browse_thread/thread/f7eebeb1ebe17a4/ Some concerns about eggs, the way they handle dependencies, and restrictive environments: http://groups.google.com/group/comp.lang.python/browse_thread/thread/50e06542f2452c9e/ Four different answers from four different persons to the same problem: how to modify a variable in an outer scope from inside the inner function http://groups.google.com/group/comp.lang.python/browse_thread/thread/9cdb4af5755e4daa/ A conspicuous Pythonista shows his italian temper discussing why redundant statements aren't any good: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a8c170e10c643f27/ A long thread about function annotations in Python 3.0 and its actual usefulness for argument type checking: http://groups.google.com/group/comp.lang.python/browse_thread/thread/1b2a416d6fbe5b61/ This lng thread started more than two weeks ago: still about macros, programmable syntax, and what is good for Scheme is not necesarily good for Python: http://groups.google.com/group/comp.lang.python/browse_thread/thread/e587471d08dbfcbb/ Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. The Python Papers aims to publish the efforts of Python enthusiats. http://pythonpapers.org/ Readers have recommended the Planet sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Many Python conferences around the world are in
Jython 2.2 RC1 is available
The Jython development team is pleased to announce that Jython 2.2rc1 is available for download: http://sourceforge.net/project/showfiles.php?group_id=12867package_id=12218release_id=518249 See http://jython.org/Project/installation.html for installation instructions. This release candidate features a new socket module with support for non-blocking sockets and SSL as well as many bug fixes. Enjoy! Charlie -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
EuroPython 2007: The final week of online registration!
The final week of EuroPython online registration is here, with registration via the conference Web site ending on Monday 2nd July. EuroPython 2007 will take place in Vilnius, Lithuania on Monday 9th, Tuesday 10th and Wednesday 11th July. More information on registration can be found here: * http://www.europython.org/sections/registration_issues/how-to-register It's not too late to plan your trip to Vilnius and to see influential figures from the Python community (and other communities) in action: * Keynotes, featuring Guido van Rossum (creator of Python), Simon Willison (co-creator of Django) and David Axmark (co-founder of MySQL): http://www.europython.org/sections/events/keynotes/ * Invited speakers, including Arlo Belshee (agile development expert): http://www.europython.org/sections/events/invited-speakers/ * A comprehensive programme of talks, panels, sprints, Open Space and Lightning Talks: http://www.europython.org/timetable http://www.europython.org/sections/sprints_and_wiki/ http://www.europython.org/sections/events/open_space http://www.europython.org/sections/events/lightning_talks See you in Vilnius! -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
SpamBayes 1.1a4
SpamBayes 1.1a4 (the fourth alpha release) is out. You can download it from SourceForge: http://spambayes.sourceforge.net/. This is currently a source only release. There is as yet no Outlook installer. What's New in 1.1a4? Version 1.1a4 introduces a new application, core_server.py. This application is tailored to provide spam filtering by non-mail applications such as Trac, Roundup, MoinMoin or your favorite blogging server. The external interface is XML-RPC. It also implements a plugin architecture so new protocol adapters can be added easily. What is SpamBayes? == The SpamBayes project is working on developing a statistical (commonly, although a little inaccurately, referred to as Bayesian) anti-spam filter, initially based on the work of Paul Graham. The major difference between this and other, similar projects is the emphasis on testing newer approaches to scoring messages. While most anti-spam projects are still working with the original graham algorithm, we found that a number of alternate methods yielded a more useful response. SpamBayes is not a single application. The core code is a message classifier, however there are several applications available as part of the SpamBayes project which use the classifier in specific contexts. For the most part, the current crop of applications all operate on the client side of things, however, a number of people have experimented with using SpamBayes on mail servers to classify incoming mail for multiple users. Contact, Help Feedback Please take the new alpha release out for a spin around the block. Report any feedback or problems you have with the new functionality to [EMAIL PROTECTED] To get general help with SpamBayes, send your questions to [EMAIL PROTECTED] -- Skip Montanaro - [EMAIL PROTECTED] - http://www.webfast.com/~skip/ -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: socket on cygwin python
On Jun 25, 1:26 pm, Martin v. Löwis [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schrieb: I've installed cygwin with latest python 2.5.1, but it seems that the socket lib file do NOT support IPv6(cygwin\lib\python2.5\lib-dynload \_socket.dll), what can I do if I want to use IPv6? Use the Python binaries from python.org. If that is not acceptable, recompile Python for Cygwin to use WinSock2. Regards, Martin Thanks Martin. But no VC/C++ tool installed on my PC, and I think recompile this file it seems necessary. :( So I tried to find a binary files on Python.org, but I can't find it. Could you tell me the binary location for the file? Thank you. BestRegards Ming -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Douglas Alan [EMAIL PROTECTED] writes: And likewise, good macro programming can solve some problems that no amount of linting could ever solve. I think Lisp is more needful of macros than other languages, because its underlying primitives are too, well, primitive. You have to write all the abstractions yourself. Python has built-in abstractions for a few container types like lists and dicts, and now a new and more general one (iterators), so it's the next level up. Haskell abstracts the concept of containers to something called monads, so operations like loops and list comprehensions fall out automatically (it took me a while to realize that--Haskell listcomps weren't a bright new idea someone thought of adding to an otherwise complete language: they were already inherently present in the list monad operations and their current syntax is just minor sugaring and is actually restricted on purpose to make the error messages less confusing). So, a bunch of stuff one needs macros to do conveniently in Lisp, can be done with Python's built-in syntax. And a bunch of stuff that Python could use macros for, are easily done in Haskell using delayed evaluation and monads. And Haskell is starting to grow its own macro system (templates) but that's probably a sign that an even higher level language (maybe with dependent types or something) would make the templates unnecessary. -- http://mail.python.org/mailman/listinfo/python-list
Re: Chroot Jail Not Secure for Sandboxing Python?
On Jun 25, 1:43 am, Martin v. Löwis [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schrieb: This wiki page suggests using a chroot jail to sandbox Python, but wouldn't running something like this in your sandboxed Python instance still break you out of the chroot jail: os.execle ('/usr/bin/python','-c','import os; os.execlp(/bin/sh)', {}) Depending on how the chroot jail is set up, this command might not work - in the jail, /bin/sh might not exist. This was my thought too. I just figured there was something special about this command that brought one to the real Python intrepreter and then to the real /bin/sh. That's odd, my ISP seem adament that this is a way to break out. I'll just have to put in the work to test to locally I guess. So is a chroot jail not adequate for sandboxing Python? You have to define your threat model. If the threat to prevent is a malicious user getting at your data, or spreading a virus through your files, then chroot is perfectly adequate. Yeah, sounds like my threat model. Maybe prevent someone sending spam, or DOS from my server too. -Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess.popen question
On Jun 23, 6:46 am, SPE - Stani's Python Editor [EMAIL PROTECTED] wrote: On Jun 23, 5:35 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Fri, 22 Jun 2007 10:08:49 -0300, [EMAIL PROTECTED] [EMAIL PROTECTED] escribió: I seemed to have it working sorta when I run it and save the results I am noticing that inspeit spaces correctly but when I save it to a file I can open it in wordpad there is only one line. when I open in up in WinXound (Acsoundeditor) it is double spaced. if I do it in a batch file the output file is spaced correctly.. when I do splitlines it is giving me one charecter down the page as output.. Do I need to do something or can I do something to put an end of line charecter in the output?? Try print repr(your_data) to see exactly what you got. -- Gabriel Genellina Did you take in account that line endings on Windows are '\r\n' and not '\n'? Stani --http://pythonide.stani.be- Hide quoted text - - Show quoted text - evedently when they converted awk from unix to windows (gawk) they left the formating the same.. python is working corectly then. gawk seems to return the original line and then the changed line unless I redirect it to a file Thanks for the help, at this point it is up to me to go through the different versions of awk to find out how they work with the data... (awke, gawk, mawk, nawk.. exc..) -- http://mail.python.org/mailman/listinfo/python-list
Re: What was that web interaction library called again?
On Jun 22, 8:04 pm, felciano [EMAIL PROTECTED] wrote: Maybe http://twill.idyll.org/ That was it! Thanks, I'd googled for hours. -- http://mail.python.org/mailman/listinfo/python-list
Re: socket on cygwin python
En Mon, 25 Jun 2007 03:03:45 -0300, [EMAIL PROTECTED] escribió: So I tried to find a binary files on Python.org, but I can't find it. Could you tell me the binary location for the file? Thank you. Go to http://www.python.org/ Click on DOWNLOAD on the left Choose the version/release/flavor you want. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
Robert Uhl [EMAIL PROTECTED] wrote: +--- | However, the only two which matter are GNU emacs and XEmacs. | Both have supported a GUI for 16 years now. I don't have | XEmacs installed, so I cannot tell you if it has the tutorial. | I would be truly surprised if it didn't. +--- It does. And the default startup splash screen tells you how to access it. -Rob - Rob Warnock [EMAIL PROTECTED] 627 26th Avenue URL:http://rpw3.org/ San Mateo, CA 94403 (650)572-2607 -- http://mail.python.org/mailman/listinfo/python-list
Re: automatical pdf generating
On 6/24/07, Jackie [EMAIL PROTECTED] wrote: Hi, all, There are 50 folders in my hard driver C: C:\01.c:\02,...,c:\50 There are 4 pictures in each folder: 1.jpg,2.jpg,3.jpg,4.jpg For each folder, I want to print the 4 pictures into a single-paged pdf file (letter sized; print horizontally). All together, I want to get 50 pdf files with names: 01.pdf,02.pdf,...,50.pdf. Is it possible to use Python to realized the above process? I know there is a module named reportlab. Is there any easy command in the module to do my job? It might be easier for you to use a simpler scripting language, like bash. I realize that you're on Windows, but I've done a lot of neat things to do PDF transformations in the past with bash and pdftk. In addition to pdftk, there are a number of other open source tools for manipulating pdfs (and I believe you can also use ImageMagick and treat them as images). It might be worthwhile to install Cygwin and explore this option. -- Evan Klitzke [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Paul Rubin http://[EMAIL PROTECTED] writes: Douglas Alan [EMAIL PROTECTED] writes: And likewise, good macro programming can solve some problems that no amount of linting could ever solve. I think Lisp is more needful of macros than other languages, because its underlying primitives are too, well, primitive. You have to write all the abstractions yourself. Well, not really beause you typically use Common Lisp with CLOS and a class library. If you ask me, the more things that can (elegantly) be moved out of the core language and into a standard library, the better. Python has built-in abstractions for a few container types like lists and dicts, and now a new and more general one (iterators), so it's the next level up. Common Lisp has had all these things for ages. And a bunch of stuff that Python could use macros for, are easily done in Haskell using delayed evaluation and monads. And Haskell is starting to grow its own macro system (templates) but that's probably a sign that an even higher level language (maybe with dependent types or something) would make the templates unnecessary. Alas, I can't comment too much on Haskell, as, although I am familiar with it to some extent, I am far from proficient in it. Don't worry -- it's on my to-do list. I think that first I'd like to take Gerry Sussman's new graduate class, first, though, and I'll find out how it can all be done in Scheme. |oug -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
Cor Gest [EMAIL PROTECTED] writes: Some entity, AKA JackT [EMAIL PROTECTED], wrote this mindboggling stuff: (selectively-snipped-or-not-p) We don't care about the 1970 version of Emacs, because of course back then there WAS NO GUI. But if you are blind as bat, any 2007's GUI is useless. Have you actually talked to a blind person about that? They often prefer the GUI applications since they tend to interact better with screen readers and the accessibility software available for the GUI's toolkits. Sounds crazy, I know. Anyway, Emacs plays in a league of its own for blind people due to Emacspeak. -- David Kastrup -- http://mail.python.org/mailman/listinfo/python-list
printing html document with internet explorer
I can print from all applications except explorer 7 which will automatically convert all documents to HTML script before printing. I am sure this is a simple setting but I can't find it. Frederick D. Terp 14985 Rivers Edge Court #135 Fort Myers, Florida 33908-7920 Phone: (239) 822-5439 Fax:(239) 415-8576 E-mail message checked by PC Tools Spyware Doctor (5.0.0.186) Database version: 5.07560 http://www.pctools.com/spyware-doctor/ -- http://mail.python.org/mailman/listinfo/python-list
automatically pdf files generating
Hi, all, There are 50 folders in my hard driver C: C:\01.c:\02,...,c:\50 There are 4 pictures in each folder: 1.jpg,2.jpg,3.jpg,4.jpg For each folder, I want to print the 4 pictures into a single-paged pdf file (letter sized; print horizontally). All together, I want to get 50 pdf files with names: 01.pdf,02.pdf,...,50.pdf. Is it possible to use Python to realized the above process? I know there is a module named reportlab. Is there any easy command in the module to do my job? Thanks Jackie - Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs
On Thu, 21 Jun 2007 13:02:18 -0400, [EMAIL PROTECTED] (Joel J. Adamson) wrote: David Kastrup [EMAIL PROTECTED] writes: You know you can use something like C-x C-f /su::/etc/fstab RET (or /sudo::/etc/fstab) in order to edit files as root in a normal Emacs session? I did not know that. That will save me huge amounts of time. You're my hero. If you like `C-x C-f /sudo::...', then it may also please you to know that Tramp supports other remote access methods too, i.e.: C-x C-f /ftp: C-x C-f /ssh: and it lets Emacs edit files in remote locations, as long as you have a valid set of username/password credentials for the remote host :-) -- http://mail.python.org/mailman/listinfo/python-list
convert hex to decimal - ala IBM Maniframe Assembly Language
In re: http://mail.python.org/pipermail/python-list/2006-March/371757.html Dear Peter Maas The Intel 80xxx architecture is horrible when compared to an IBM S/360, or S/370, or S/390 or Z machines. IBM mainframes performance is measured in Millions Of Instructions executed per second, and not on some clock speed, But rather, how many millions of completed instructions are executed in 1-second. Numbers like 428 are common MIPS rates. That's 428,000,000 instructions completed by the CPU per second. I can't relate to how many instructions get executed per second on a 2.8Ghz CPU because I can't find out how many cycles each Intel instruction takes.. I really don't care how fast a clock goes. I care about how many instructions are executed per second. As for converting a number from Hex to Decimal we do it this way, with one (1) CVD instruction, on IBM mainframes. START 0Tell the assembler to start this program at relative location zero ( 0 ). HEX2DEC BALR 6,0 Start the program USING *,6 Tell the assembler to use Register 6 as the base of this program B Step01 Branch to Step01 to get started Hexword DS FDefine a storage area of a 4-byte word. OutareaDS PL8 Define a storage area for an 8-byte packed decimal number, max = 999,999,999,999,999 * This is a comment i.e. 999 trillion, 999 billion, 999 million, 999 thousand, 999 ones. Visible DS CL15 Define a storage area for a 15-byte displayable characters area. Step01 EQU * L R5,Hexword Put the 4-byte hexadecimal number into General Purpose Register 5. CVDR5, Outarea Tell the CPU to convert the 4-byte number into a 15 digit signed number in displayable characters UNPK Visible(15),Outarea(8) Make the 15-digit number displayable OIVisible+14,X'F0 Correct the sign of the last digit. BR R14Return to the operating system END Define the end of the program to the assembler Of course you didn't need to know any of this, except that I am sick of hearing how great the Intel architecture is. Phooey ! IBM had INTEL beat into the ground in 1967, (way before the 8088 existed) and has not looked back since. Thanks for accepting a rant from a stranger. Dan McGarigle ( 36 years an IBM mainframe programmer and proud of it, thank you ! ) El Segundo, CA -- http://mail.python.org/mailman/listinfo/python-list
Re: Which XML?
[EMAIL PROTECTED] wrote: On Jun 24, 7:04 pm, Bruno Barberi Gnecco [EMAIL PROTECTED] wrote: I've found a lot of XML libraries for Python. Any advices on which one to use (or *not* to use)? My requirements are: support for XPath, stability (a must, segfaults are not an option), with DOM API and good performance desirable. I use the minidom module for most of my XML work, but I don't think it has much in the way of XPath. I think lxml might work better for that sort of thing and I think it's part of ElementTree: http://codespeak.net/lxml/dev/objectify.html lxml is not part of ElementTree (only mostly compatible), but it's a must if you want to have a simple API *and* XPath *and* good performance. http://codespeak.net/lxml/ The API is not W3C-DOM compatible, but that's rather a plus IMHO. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib interpretation of URL with ..
Martin v. Löwis [EMAIL PROTECTED] wrote: Is urllib wrong? I can't see how. HTTP 1.1 says that the parameter to the GET request should be an abs_path; RFC 2396 says that /../acatalog/shop.html is indeed an abs_path, as .. is a valid segment. That RFC also has a section on relative identifiers and normalization; it defines what .. means *in a relative path*. Section 4 is explicit about .. in absolute URIs: # The syntax for relative URI is a shortened form of that for absolute # URI, where some prefix of the URI is missing and certain path # components (. and ..) have a special meaning when, and only when, # interpreting a relative path. Notice the and only when: the browsers who modify above URL before sending it seem to be in clear violation of RFC 2396. Section 5.2 is also relevant here. In particular: g) If the resulting buffer string still begins with one or more complete path segments of .., then the reference is considered to be in error. Implementations may handle this error by retaining these components in the resolved path (i.e., treating them as part of the final URI), by removing them from the resolved path (i.e., discarding relative levels above the root), or by avoiding traversal of the reference. The common practice seems to be for client-side implementations to handle this using option 2 (removing them) and servers to use option 3 (avoiding traversal of the reference). urllib uses option 1 which is also correct but not as useful as it might be. -- http://mail.python.org/mailman/listinfo/python-list
Emacs topic should be stopped....
Hi guys, I was going through most of this topic, but I find this not relevant on THIS mailing list... A short summary: there are some people who are not disturbed by proven facts. They are mostly attackers of emacs/Xemacs or vim... Or even linux and open source. Quite funny, since this is a mailing list of an open source programming language. :- Arguments and logic are not working, it's been a 'religious' flame topic. I am open to discuss this issue further in private.. Gabor -- http://mail.python.org/mailman/listinfo/python-list
Professional Grant Proposal Writing Workshop (September 2007: Simon Fraser University)
The Grant Institute's Grants 101: Professional Grant Proposal Writing Workshop will be held at Simon Fraser University at Harbour Centre, September 12 - 14 , 2007. Interested development professionals, researchers, faculty, and graduate students should register as soon as possible, as demand means that seats will fill up quickly. Please forward, post, and distribute this e-mail to your colleagues and listservs. All participants will receive certification in professional grant writing from the Institute. For more information call (213) 817 - 5308 or visit The Grant Institute at www.thegrantinstitute.com. Please find the program description below: The Grant Institute Grants 101: Professional Grant Proposal Writing Workshop will be held at Simon Fraser University at Harbour Centre Vancouver, British Columbia September 12 - 14, 2007 8:00 AM - 5:00 PM The Grant Institute's Grants 101 course is an intensive and detailed introduction to the process, structure, and skill of professional proposal writing. This course is characterized by its ability to act as a thorough overview, introduction, and refresher at the same time. In this course, participants will learn the entire proposal writing process and complete the course with a solid understanding of not only the ideal proposal structure, but a holistic understanding of the essential factors, which determine whether or not a program gets funded. Through the completion of interactive exercises and activities, participants will complement expert lectures by putting proven techniques into practice. This course is designed for both the beginner looking for a thorough introduction and the intermediate looking for a refresher course that will strengthen their grant acquisition skills. This class, simply put, is designed to get results by creating professional grant proposal writers. Participants will become competent program planning and proposal writing professionals after successful completion of the Grants 101 course. In three active and informative days, students will be exposed to the art of successful grant writing practices, and led on a journey that ends with a masterful grant proposal. Grants 101 consists of three (3) courses that will be completed during the three-day workshop. (1) Fundamentals of Program Planning This course is centered on the belief that "it's all about the program." This intensive course will teach professional program development essentials and program evaluation. While most grant writing "workshops" treat program development and evaluation as separate from the writing of a proposal, this class will teach students the relationship between overall program planning and grant writing. (2) Professional Grant Writing Designed for both the novice and experienced grant writer, this course will make each student an overall proposal writing specialist. In addition to teaching the basic components of a grant proposal, successful approaches, and the do's and don'ts of grant writing, this course is infused with expert principles that will lead to a mastery of the process. Strategy resides at the forefront of this course's intent to illustrate grant writing as an integrated, multidimensional, and dynamic endeavor. Each student will learn to stop writing the grant and to start writing the story. Ultimately, this class will illustrate how each component of the grant proposal represents an opportunity to use proven techniques for generating support. (3) Grant Research At its foundation, this course will address the basics of foundation, corporation, and government grant research. However, this course will teach a strategic funding research approach that encourages students to see research not as something they do before they write a proposal, but as an integrated part of the grant seeking process. Students will be exposed to online and database research tools, as well as publications and directories that contain information about foundation, corporation, and government grant opportunities. Focusing on funding sources and basic social science research, this course teaches students how to use research as part of a strategic grant acquisition effort. Registration $597.00 USDtuition includes all materials and certificates. Each student will receive: *The Grant Institute Certificate in Professional Grant Writing *The Grant Institute's Guide to Successful Grant Writing *The Grant Institute Grant Writer's Workbook with sample proposals, forms, and outlines Registration Methods 1) On-Line- Complete the online registration form at www.thegrantinstitute.com under Register Now. We'll send your confirmation by e-mail. 2) By Phone - Call (213) 817 -5308 to register by phone. Our friendly Program Coordinators will be happy to assist you and answer your questions. 3) By E-mail - Send an e-mail with your name, organization, and basic contact information to [EMAIL PROTECTED] and we will reserve your slot and send your Confirmation
Re: comparing two lists and returning position
hiro wrote: bare in mind that I have a little over 10 million objects in my list (l2) and l1 contains around 4 thousand objects.. (i have enough ram in my computer so memory is not a problem) Glad to see you solved the problem with the trailing space. Just one minor point, I did say or probably less efficiently ... As far as i know, my suggestion's running time is proportional to len(l1)*len(l2), which gets quite big for your case where l1 and l2 are large lists. If I understand how python dictionaries work, Paul Rubin's suggestion from itertools import izip, count pos = map(dict(izip(l2, count())).__getitem__, l1) or the (I think) approximately equivalent from itertools import izip, count d = dict(izip(l2,count())) pos = [ d[i] for i in l1 ] or the more memory intensive d = dict(zip(l2,range(len(l2 pos = [ d[i] for i in l1 ] should all take take running time proportional to (len(l1)+len(l2))*log(len(l2)) For len(l1)=4,000 and len(l2)=10,000,000 Paul's suggestion is likely to take about 1/100th of the time to run, ie be about 100 times as fast. I was trying to point out a somewhat clearer and simpler (but slower) alternative. Charles -- http://mail.python.org/mailman/listinfo/python-list
multiple python versions of a 3rd party application/libarary
hi, I maintain applications/libraries which I upgrade often at a different location. For example if I maintain mercurial at /opt/sfw/mercurial/0.9.3 I have PYTHONPATH set to /opt/sfw/mercurial/0.9.3/lib/python2.4/site-packages. How can I get python to look into python2.4 and python2.4/site-packages automatically (assuming it is 2.4) and likewise for 2.5. That way I can keep them under the same directory. /kk -- http://mail.python.org/mailman/listinfo/python-list
Re: automatical pdf generating
Jackie [EMAIL PROTECTED] wrote: There are 50 folders in my hard driver C: C:\01.c:\02,...,c:\50 There are 4 pictures in each folder: 1.jpg,2.jpg,3.jpg,4.jpg For each folder, I want to print the 4 pictures into a single-paged pdf file (letter sized; print horizontally). All together, I want to get 50 pdf files with names: 01.pdf,02.pdf,...,50.pdf. ImageMagick eats this sort of thing for lunch. It is a set of command line tools for unix. You can get them with cygwin also Eg montage -geometry 1000x1000+100+100 1.jpg 2.jpg 3.jpg 4.jpg 01.pdf Which resizes each image to a max dimension of 1000 pixels and then tiles them into a PDF. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Chroot Jail Not Secure for Sandboxing Python?
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Jun 25, 1:43 am, Martin v. Löwis [EMAIL PROTECTED] wrote: You have to define your threat model. If the threat to prevent is a malicious user getting at your data, or spreading a virus through your files, then chroot is perfectly adequate. Yeah, sounds like my threat model. Maybe prevent someone sending spam, or DOS from my server too. It all depends on how much stuff you put in your chroot! If you don't put bin/sh in the chroot then you'll stop a lot of exploits from working. If you don't allow the chrooted user write permission to the chroot then you will anyone uploading a shell or any other binaries, just leaving you with the binaries in the chroot to worry about. Nothing stops someone running os.fork() from python and spawning processes to do bad stuff. However in order to do that they would have to have compromised your .py and sent some code to exec(), or found a buffer overflow within python. It is getting increasingly unlikely but not impossible. Note that root can break out of a chroot, so your users must not be root in the chroot. Chroots provide a reasonable level of security. If you are truly paranoid about security then you want to check out selinux (as made originally by the NSA). From the selinux FAQ :- The Security-enhanced Linux kernel enforces mandatory access control policies that confine user programs and system servers to the minimum amount of privilege they require to do their jobs. When confined in this way, the ability of these user programs and system daemons to cause harm when compromised (via buffer overflows or misconfigurations, for example) is reduced or eliminated. -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
ANN: YahooQuote 0.1.0
Hi, After a 3-year break from working with it, I've just released version 0.1.0 (the first formally packaged release) of YahooQuote. As the name implies, it's a stockmarket prices fetcher. Features: - easily fetch stock price quotes and histories - fetch bulk histories across one or more of the major stockmarket indexes - fast efficient automatic caching via a MetaKit database - pleasant object-oriented interface - thorough epydoc-generated API doco - simple examples This supersedes the unpackaged YahooQuote module of 2004, and brings YahooQuote up to date with the present Yahoo Finance web interface. http://www.freenet.org.nz/python/yahooquote License: LGPL Enjoy Cheers David -- http://mail.python.org/mailman/listinfo/python-list
Re: Portable general timestamp format, not 2038-limited
On Sun, 24 Jun 2007 18:14:08 -0700, [EMAIL PROTECTED] (Robert Maas, see http://tinyurl.com/uh3t) wrote, quoted or indirectly quoted someone who said : - Stick to astronomical time, which is absolutely consistent but which drifts from legal time? depends what you are measuring. IF you are doing astronomy, your advice would apply. If you are doing payrolls, you want effectively to pretend the leap seconds never happened, just as Java does. -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com -- http://mail.python.org/mailman/listinfo/python-list
Re: is this a valid import sequence ?
On Mon, 25 Jun 2007 05:08:00 +, Michele Simionato wrote: On Jun 24, 1:29 pm, Steven D'Aprano I would like to hear your opinion of whether the following two functions are equally as wrong: def f1(gizmo): global spam # holds the frommet needed for the gizmo gizmo.get_frommet(spam) def f2(gizmo): # global spam holds the frommet needed for the gizmo gizmo.get_frommet(spam) I'm sure they're both wrong, but I'd like to know if there are degrees of wrongness. I am not Alex Martelli, but I will tell you my opinion anyway. To me f2 is not wrong: at worse you can say that the comment is redundant since it is already clear from the code that spam is a global, but it is not a big deal. As a code reviewer I would not have had issues with f2. OTOH I would have had serious issues with f1. Since the global statement in correct Python code is solely used to declare that a global variable is being set in an inner scope, I would have to guess that: 1. function f1 wrong; maybe the author cut and pasted it from someplace, forgetting the line where the global variable spam was set; 2. maybe f1 is right, but then the author forgot to remove the global declaration after the cut paste; 3. the author does not know Python, and he believes that he has to use global to denote the fact that the method gizmo.get_frommet(spam) is setting a global variable. So I would have had to look at get_frommet to see that actually 'spam' is not set there, Why do you do that? I'm not arguing that you shouldn't, but I'm trying to understand your reasoning. Are you assuming (for the sake of the argument) that there's a bug somewhere in the code? If you're trying to track down a bug, you'll likely need to look at get_frommet regardless of the presence or absence of the global statement. Or are you trying to analyze the entire module? If so, you also have to dig into get_frommet. (I repeat, I'm not saying you shouldn't, but I'm trying to understand why you think the way you do.) and finally I would have reached the conclusion that 4. the author was completely wrong and used global without knowing its meaning. So you're with Alex that redundant == wrong? I still can't my head around that. To me, redundant and wrong are orthogonal, not synonyms. This code is wrong but not redundant (assuming you have a need for such a function): def sin_deg(x): Return the sine of x degrees. return math.sin(x/math.pi*180) # oops! should be x*math.pi/180 To me, this code is redundant but not wrong: def sin(x): return math.sin(x) It's not wrong, because it does everything that it is supposed to do, and nothing that it isn't supposed to do. Am I wrong? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs
David Kastrup [EMAIL PROTECTED] writes: I should think that version 2.3.1 would not even try ftp. Is that on Multics? Note that the GNU Emacs version jumped directly from 1.12 to 13. See etc/ONEWS.1. -- http://mail.python.org/mailman/listinfo/python-list
Re: is this a valid import sequence ?
On Jun 25, 1:46 pm, Steven D'Aprano [EMAIL PROTECTED] wrote: To me, this code is redundant but not wrong: def sin(x): return math.sin(x) It's not wrong, because it does everything that it is supposed to do, and nothing that it isn't supposed to do. I told you, redundant/useless/misleading/poor code is worse than wrong: wrong code speaks (you see the bug, you have no choice but to fix it) whereas redundant code is silent: you see how damaging it is only when doing maintenance, i.e. too late, so it tends to perpetuate itself forever (whereas a bug *has* to be fixed, otherwise the application does not work). Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: socket on cygwin python
[EMAIL PROTECTED] wrote: I've installed cygwin with latest python 2.5.1, but it seems that the socket lib file do NOT support IPv6(cygwin\lib\python2.5\lib-dynload \_socket.dll), what can I do if I want to use IPv6? I don't think Cygwin supports IPv6. Use the native Windows Python. -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list
Re: Which XML?
On 25 Jun, 02:04, Bruno Barberi Gnecco [EMAIL PROTECTED] wrote: I've found a lot of XML libraries for Python. Any advices on which one to use (or *not* to use)? My requirements are: support for XPath, stability (a must, segfaults are not an option), with DOM API and good performance desirable. You might be interested in libxml2dom: http://www.python.org/pypi/libxml2dom It uses libxml2 under the covers, meaning that it has good performance and supports XPath, but I can't always guarantee stability: libxml2 can get quite upset in some situations, but I've worked fairly hard to avoid triggering them. The module API is similar to PyXML/minidom and I've found some time to add minimal support for DOM events and SVG, although there's a long way to go in both of these areas. This is a project with just me as the developer, although there are a number of helpful users who have kindly provided bug reports and suggestions for improvements over the years. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Internationalised email subjects
I'm an idiot! Gabriel, you're right! Turns out the ISP was running Python 2.3, which has known issues with the GB2312 codec. They've upgraded to 2.4 and now everything runs smoothly! -- http://mail.python.org/mailman/listinfo/python-list
Re: Which XML?
On Jun 25, 3:47 am, Stefan Behnel [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Jun 24, 7:04 pm, Bruno Barberi Gnecco [EMAIL PROTECTED] wrote: I've found a lot of XML libraries for Python. Any advices on which one to use (or *not* to use)? My requirements are: support for XPath, stability (a must, segfaults are not an option), with DOM API and good performance desirable. I use the minidom module for most of my XML work, but I don't think it has much in the way of XPath. I think lxml might work better for that sort of thing and I think it's part of ElementTree: http://codespeak.net/lxml/dev/objectify.html lxml is not part of ElementTree (only mostly compatible), but it's a must if you want to have a simple API *and* XPath *and* good performance. http://codespeak.net/lxml/ The API is not W3C-DOM compatible, but that's rather a plus IMHO. Stefan Oops, sorry about the mis-information. I mis-read http://effbot.org/zone/element-index.htm Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing sound volume
And finally a way that might work using ctypes: http://mail.python.org/pipermail/python-win32/2006-March/004436.html Mike Hi, Thanks for your reply. I had already read about the Snack, but I can't use it since my program uses wxPython for the GUI and Snack requires tk. The best option was the ctypes method you told me about. I used the code in the sample, but I am getting the following error: exceptions.WindowsError Error 11 while setting volume The author of the code claims it works. What could be causing the above error? [ I am using Python 2.4.4 and ctypes 1.0.1 ] Regards, Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
Twisted wrote: The manuals came with the computers, at no additional charge. It was a different time. This isn't going to be true of any separately- purchased book or user-made printout concerning emacs. Also, the manuals provided a basic introduction for the beginning user. A traditional-unix-tool providing anything resembling that would genuinely shock me. Oh, so manuals are OK and you'll read them if they are dead trees that came in the same box as the software, but not if they're HOWTOs, online documentation or O'Reilly books? I distinctly remember Winword circa 2002 not being able to retroactively change all of a bunch of like-formatted paragraphs easily. Not without delving into VBscript or something, anyway. So you didn't read the free but thick and stodgy Word manual? Styles and style sheets have been in Word since Word for DOS 5. Changing a style sheet has always affected all documents that reference it. Oh, because the implementation (of reveal codes and of everything else) was awful, not because of any intrinsic flaw in the idea itself. If a word processor, which by definition is provides a WYSIWYG user interface, can't produce perfectly formatted text by editing a representation of the finished result then its a deeply flawed program and not fit for purpose. By providing 'Reveal codes' and by being designed in such a way as to force its regular use, Wordperfect reveals itself as being no better than nrof or tex - its like expecting a user to write postscript source with a text editor and providing a separate window with a Postscript viewer to see what the final result will look like. Would you want to edit a Web page without being able to hand-hack the HTML? Of course not, but HTML isn't anything to do with WYSIWYG and any system (Coldfusion, Front Page, HTML from Word) that pretends it is WYSIWG is both useless and perpetrating a fraud. What happened to the guys that did all this stuff after it became obsolete? It isn't obsolete despite going back a looong way. The hardware and software was originally developed as Future Series (intended S/360 replacement), was canned in 1970 but resurfaced in the late 80s as System/38. A second generation appeared as AS/400, was renamed to (I think) Z-series and are now known as iSeries servers. Its good, reliable kit and easy to work with if you don't mind programming in RPG. I know of no better one size fits all interface design than that provided by the OS/400 operating system. Its still called that. Its a pity the interface style hasn't been emulated by others. It would be nice if straightforward macro recording was standard in Windows though. It was standard with Win 3.1 and 3.11 and it was bloody useless. Most people I know tried it once or twice before giving up and writing .BAT files or putting up with RSI. The problem was that it recorded keystrokes and mouse clicks. Even minor changes to the screen layout made it fail and the macros couldn't be edited or parameterised nor made to prompt for filenames, etc. You can do better with Gnome, thanks to tcl, but I think most people go straight to Ruby or stick to plain vanilla shell scripts. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | -- http://mail.python.org/mailman/listinfo/python-list
Re: Setuptools, build and install dependencies
Robert Kern [EMAIL PROTECTED] writes: Harry George wrote: We need to know the dependencies, install them in dependency order, and expect the next package to find them. configure does this for hundreds of packages. cmake, scons, and others also tackle this problem. Python's old setup.py seems to be able to do it. No, generic setup.py scripts don't do anything of that kind. Ok, setup.py itself may not do the work, but from the end users' perspective it works that way. Setup.py runs a configure and a make, which in turn find the right already-installed libraries. The point is, setup.py plays well in such an environment. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- Harry George PLM Engineering Architecture -- http://mail.python.org/mailman/listinfo/python-list
Re: Portable general timestamp format, not 2038-limited
On Mon, 25 Jun 2007 11:17:27 GMT Roedy Green [EMAIL PROTECTED] wrote: On Sun, 24 Jun 2007 18:14:08 -0700, [EMAIL PROTECTED] (Robert Maas, see http://tinyurl.com/uh3t) wrote, quoted or indirectly quoted someone who said : - Stick to astronomical time, which is absolutely consistent but which drifts from legal time? depends what you are measuring. IF you are doing astronomy, your advice would apply. If you are doing payrolls, you want effectively to pretend the leap seconds never happened, just as Java does. Which leaves you about 30 seconds out by now - smelly. -- C:WIN | Directable Mirror Arrays The computer obeys and wins.| A better way to focus the sun You lose and Bill collects. |licences available see |http://www.sohara.org/ -- http://mail.python.org/mailman/listinfo/python-list
Capturing and sending keys {Esperanto}
Hello there! I've been googleing yet, and suppose it's hopeless to try, but better ask it... I want to write a program which turns Cx to Ĉ, cx to ĉ et al WHILE TYPING. (i.e. converting Esperanto x-system to real hats, for those who know about this.) Therefore I though will need to capture the last 2 typed characters (from any application), send a double backspace and after that send the correct letters (back to the same application)... However, it seems inpossible to capture those letters, and maybe to send them too... Or am I wrong? Greetings, LaPingvino (project: http://code.google.com/p/iksilo/ - SVN Repository is free viewable, project is GPL) -- Ĉar Dio tiel amis la mondon, ke Li donis Sian solenaskitan Filon, por ke ĉiu, kiu fidas al li, ne pereu, sed havu eternan vivon. -Johano 3:16, La sankta Biblio- Ĝoju ĉiam, preĝu senĉese, pri ĉio donu dankon. -1 Tesalonikanoj 5:16-18a, La sankta Biblio- -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading multiline values using ConfigParser
On Jun 21, 7:34 pm, John Krukoff [EMAIL PROTECTED] wrote: Is there anyway, I can include multi-line value in the configfile? I Following the link to RFC 822 (http://www.faqs.org/rfcs/rfc822.html) indicates that you can spread values out over multiple lines as long as there is a space or tab character imeediately after the CRLF. Thanks for the response. It did work! config = ConfigParser() config.read(Testcases.txt) ['Testcases.txt'] output = config.get(Information, Testcases) print output tct123 tct124 tct125 output '\ntct123\ntct124\ntct125' However, as I am going to provide Testcases.txt to be user editable, I cannot assume or ask users to provide value testcases surronded by spaces. I got to figure out a workaround here. Sounds like you're stuck modifying ConfigParser to do what you want, or writing your own configuration file parsing utilities. From looking through the ConfigParser source, looks like all the parsing work is inside the _read method, so shouldn't be too painful to make a subclass that does what you want. I took the approach of Subclassing ConfigParser to support multiline values without leading white-spaces, but am struct at which position in _read I should modify to accomodate the non-leading whitespace based multiline values. I can guess, this portion in the _read function will require change, any change to this affects the whole of parsing. :-( Can someone who has done this before or understands ConfigParser better help me? # Section I am talking about if line[0].isspace() and cursect is not None and optname: value = line.strip() if value: cursect[optname] = %s\n%s % (cursect[optname], value) # _read method def _read(self, fp, fpname): cursect = None optname = None lineno = 0 e = None while True: line = fp.readline() if not line: break lineno = lineno + 1 # comment or blank line? if line.strip() == '' or line[0] in '#;': continue if line.split(None, 1)[0].lower() == 'rem' and line[0] in rR: # no leading whitespace continue # continuation line print line:%s\tcursect:%s\toptname:%s%(line,cursect,optname) if line[0].isspace() and cursect is not None and optname: value = line.strip() if value: cursect[optname] = %s\n%s % (cursect[optname], value) # a section header or option header? else: # is it a section header? mo = self.SECTCRE.match(line) if mo: sectname = mo.group('header') if sectname in self._sections: cursect = self._sections[sectname] elif sectname == ConfigParser.DEFAULTSECT: cursect = self._defaults else: cursect = {'__name__':sectname} self._sections[sectname] = cursect # So sections can't start with a continuation line optname = None elif cursect is None: raise ConfigParser.MissingSectionHeaderError(fpname, lineno, line) # an option line? else: mo = self.OPTCRE.match(line) if mo: optname, vi, optval = mo.group('option','vi','value') if vi in ('=',':') and ';' in optval: # ';' is a comment delimiter only if it follows # a spacing character pos = optval.find(';') if pos != -1 and optval[pos-1].isspace(): optval = optval[:pos] optval =
New Thread- Supporting Multiline values in ConfigParser
Hi, Am starting a new thread as I fear the old thread which more than a week old can go unnoticed. Sorry for the multiple mails. I took the approach of Subclassing ConfigParser to support multiline values without leading white-spaces, but am struct at which position in _read I should modify to accomodate the non-leading whitespace based multiline values. I can guess, this portion in the _read function will require change, any change to this affects the whole of parsing. :-( Can someone who has done this before or understands ConfigParser better help me? # Section I am talking about if line[0].isspace() and cursect is not None and optname: value = line.strip() if value: cursect[optname] = %s\n%s % (cursect[optname], value) # _read method def _read(self, fp, fpname): cursect = None optname = None lineno = 0 e = None while True: line = fp.readline() if not line: break lineno = lineno + 1 # comment or blank line? if line.strip() == '' or line[0] in '#;': continue if line.split(None, 1)[0].lower() == 'rem' and line[0] in rR: # no leading whitespace continue # continuation line print line:%s\tcursect:%s\toptname:%s% (line,cursect,optname) if line[0].isspace() and cursect is not None and optname: value = line.strip() if value: cursect[optname] = %s\n%s % (cursect[optname], value) # a section header or option header? else: # is it a section header? mo = self.SECTCRE.match(line) if mo: sectname = mo.group('header') if sectname in self._sections: cursect = self._sections[sectname] elif sectname == ConfigParser.DEFAULTSECT: cursect = self._defaults else: cursect = {'__name__':sectname} self._sections[sectname] = cursect # So sections can't start with a continuation line optname = None elif cursect is None: raise ConfigParser.MissingSectionHeaderError(fpname, lineno, line) # an option line? else: mo = self.OPTCRE.match(line) if mo: optname, vi, optval = mo.group('option','vi','value') if vi in ('=',':') and ';' in optval: # ';' is a comment delimiter only if it follows # a spacing character pos = optval.find(';') if pos != -1 and optval[pos-1].isspace(): optval = optval[:pos] optval = optval.strip() # allow empty values if optval == '': optval = '' optname = self.optionxform(optname.rstrip()) cursect[optname] = optval else: if not e: e = ConfigParser.ParsingError(fpname) e.append(lineno, repr(line)) if e: raise e -- Senthil -- http://mail.python.org/mailman/listinfo/python-list
Re: What was that web interaction library called again?
Harald Korneliussen wrote: Hi, I remember I came across a python library that made it radically simple to interact with web sites, connecting to gmail and logging in with four or five lines, for example. I thought, that's interesting, I must look into it sometime. I was looking for something like this recently too. I don't believe there is anything in the Python world quite as staggeringly well-designed as the SimpleBrowser component nested within the SimpleTest framework for PHP. If there is, I would like to know. http://simpletest.sourceforge.net/en/web_tester_documentation.html Here is a code snippet: class TestOfLastcraft extends WebTestCase { ... function testContact() { $this-get('http://www.lastcraft.com/'); $this-clickLink('About'); $this-assertTitle(new PatternExpectation('/About Last Craft/')); } } -- http://mail.python.org/mailman/listinfo/python-list
Re: Collections of non-arbitrary objects ?
On Jun 24, 10:31 pm, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Especially since variables in python do not have to be explicitly assigned ??? I have probably expressed this incorrectly. What I meant was: a = [1,2,3] b = a a[1] = 'spam' Here, I have changed b, without an explicit assignment. After I assigned a to b, I never did another b = yet b changed anyway because I changed a. I am not saying there is anything wrong with this, I'm just explaining what I meant. So let's say I have list L, and I have a routine that expects every item in L to be a dictionary like: {'name':'joe', 'job':'dev', 'pay': min_wage}. Not only could the app crash if an incorrect item where inserted into L. But the app could crash if an incorrect item were inserted in lists X,Y, or Z. Of course, you can always work around this by just programming very carefully, and doing a lot of error checking. That is always true in any language. But, I think sometimes it's helpful to use a structure that is little more restrictive, to sort of enforce a degree of integrity. An example I have already given: why use tuples instead of a list? Tuples are actually a bit more restrictive. I don't think there is anything wrong with the data structures that exist in python. I was just wondering if there was a structure that would restrict a collection to only allow certain types. The restrictedlist class discussed in another thread may be the sort of thing I was looking for. BTW: I think polymorphism is great and all. But it does have (and IMO should have) it's limitations. For example, I don't think you can divide a string by another string. -- http://mail.python.org/mailman/listinfo/python-list
Re: comparing two lists and returning position
Charles Sanders [EMAIL PROTECTED] writes: from itertools import izip, count d = dict(izip(l2,count())) pos = [ d[i] for i in l1 ] or the more memory intensive d = dict(zip(l2,range(len(l2 pos = [ d[i] for i in l1 ] If you're itertools-phobic you could alternatively write d = dict((x,i) for i,x in enumerate(l2)) pos = [ d[i] for i in l1 ] dict access and update is supposed to take approximately constant time, btw. They are implemented as hash tables. -- http://mail.python.org/mailman/listinfo/python-list
Re: Capturing and sending keys {Esperanto}
On Jun 25, 8:26 am, AJK [EMAIL PROTECTED] wrote: Hello there! I've been googleing yet, and suppose it's hopeless to try, but better ask it... I want to write a program which turns Cx to Ĉ, cx to ĉ et al WHILE TYPING. (i.e. converting Esperanto x-system to real hats, for those who know about this.) Therefore I though will need to capture the last 2 typed characters (from any application), send a double backspace and after that send the correct letters (back to the same application)... However, it seems inpossible to capture those letters, and maybe to send them too... Or am I wrong? Greetings, LaPingvino (project:http://code.google.com/p/iksilo/- SVN Repository is free viewable, project is GPL) -- Ĉar Dio tiel amis la mondon, ke Li donis Sian solenaskitan Filon, por ke ĉiu, kiu fidas al li, ne pereu, sed havu eternan vivon. -Johano 3:16, La sankta Biblio- Ĝoju ĉiam, preĝu senĉese, pri ĉio donu dankon. -1 Tesalonikanoj 5:16-18a, La sankta Biblio- I've never done this before, but theoretically, you should be able to have a separate process monitor what you're typing and maybe do edits in real time. At least, I assume that that is how MS Word works. I have messed a little with sendkeys though. Here's the examples I found on the net: http://mail.python.org/pipermail/python-list/1999-May/003244.html http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/65107 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/4b032417-ebda-4d30-88a4-2b56c24affdd.asp The msdn one is just the MS docs for Sendkeys. One other alternative would be to type it all out and then run a script to parse your document and basically just do a search and replace. Hopefully that helps your out a little at least. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Chroot Jail Not Secure for Sandboxing Python?
On Jun 25, 1:43 am, Martin v. Löwis [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schrieb: This wiki page suggests using a chroot jail to sandbox Python, but wouldn't running something like this in your sandboxed Python instance still break you out of the chroot jail: os.execle ('/usr/bin/python','-c','import os; os.execlp(/bin/sh)', {}) Depending on how the chroot jail is set up, this command might not work - in the jail, /bin/sh might not exist. I followed up with my ISP. Here's the answer I got: The os.exec call prepends the chroot directory to the absolute path, but does NOT provide chroot for the child process. However, as long as the environment is maintained, which contains an LD_PRELOAD, the chroot will also be maintained. If LD_PRELOAD is removed or ignored, then the chroot is ineffective. Another way of saying it is that every process is responsible for providing and maintaining the chroot through the LD_PRELOAD variable. Those processes only maintain the chroot if that variable remains set. The only solution that would bypass this problem altogether would be a statically linked python. (is that possible?) It would have to be statically linked to a custom-modified glibc to provide the virtual chroot environment. -Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing sound volume
simon kagwe a écrit : Hi, I am playing sounds using the winsound module. Is there a way I can change the volume? Maybe with pyGame, but you may have to switch from winsound to pygame.mixer.music http://www.pygame.org/ http://www.pygame.org/docs/ref/music.html A+ Laurent. -- http://mail.python.org/mailman/listinfo/python-list
Re: Chroot Jail Not Secure for Sandboxing Python?
[EMAIL PROTECTED] wrote: On Jun 25, 1:43 am, Martin v. Löwis [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schrieb: This wiki page suggests using a chroot jail to sandbox Python, but wouldn't running something like this in your sandboxed Python instance still break you out of the chroot jail: os.execle ('/usr/bin/python','-c','import os; os.execlp(/bin/sh)', {}) Depending on how the chroot jail is set up, this command might not work - in the jail, /bin/sh might not exist. I followed up with my ISP. Here's the answer I got: The os.exec call prepends the chroot directory to the absolute path, but does NOT provide chroot for the child process. However, as long as the environment is maintained, which contains an LD_PRELOAD, the chroot will also be maintained. If LD_PRELOAD is removed or ignored, then the chroot is ineffective. Another way of saying it is that every process is responsible for providing and maintaining the chroot through the LD_PRELOAD variable. Those processes only maintain the chroot if that variable remains set. The only solution that would bypass this problem altogether would be a statically linked python. (is that possible?) It would have to be statically linked to a custom-modified glibc to provide the virtual chroot environment. It seems to me that if a (potentially malicious) process needs to behave itself in order for chroot to not allow the process access to the full system, then chroot is broken. But perhaps I don't understand the intent and scale of what chroot intends to do. - Josiah -- http://mail.python.org/mailman/listinfo/python-list
How to save initial configuration? (program installation)
I've written a program. To install this program, I'm going to need to initialize some stuff for the users environment, specifically the name/ location of an internal state file. Currently, I'm hard coding the location of this file, but that's in- elegant. What I'd like to do is just ask the user, with a suggested default. My question is how do I save this answer? It's kind of a chicken-and- egg problem. The only solution I've thought of is to write something that's self modifying, but that's ugly (go in, grep for this variable initialization, re-write that line with the new value, quit). Is there a better way to do this? There almost has to be... If not, are there some 'best practices' on how to do the self- modification? Thanks for any help; Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Collections of non-arbitrary objects ?
I don't think there is anything wrong with the data structures that exist in python. I was just wondering if there was a structure that would restrict a collection to only allow certain types. The restrictedlist class discussed in another thread may be the sort of thing I was looking for. Just remenber that if you write a library using such a thing, your (consenting adults) users will not be able to store objects in your list that implement (part of) the interface of the type that you restricted. -- EduardoOPadoan (eopadoan-altavix::com) Bookmarks: http://del.icio.us/edcrypt -- http://mail.python.org/mailman/listinfo/python-list
Re: How to save initial configuration? (program installation)
On Jun 25, 10:02 am, Jason Zapman II [EMAIL PROTECTED] wrote: I've written a program. To install this program, I'm going to need to initialize some stuff for the users environment, specifically the name/ location of an internal state file. Currently, I'm hard coding the location of this file, but that's in- elegant. What I'd like to do is just ask the user, with a suggested default. My question is how do I save this answer? It's kind of a chicken-and- egg problem. The only solution I've thought of is to write something that's self modifying, but that's ugly (go in, grep for this variable initialization, re-write that line with the new value, quit). Is there a better way to do this? There almost has to be... If not, are there some 'best practices' on how to do the self- modification? Thanks for any help; Jason I would think you could pop-up some dialog when the program is first run to ask where they want the file to be. On the first run though, you can just have the config file located in the current working directory with the script file itself. Then just move it or save a new copy to the new location and delete the original. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Chroot Jail Not Secure for Sandboxing Python?
On 2007-06-25, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Jun 25, 1:43 am, Martin v. Löwis [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] schrieb: This wiki page suggests using a chroot jail to sandbox Python, but wouldn't running something like this in your sandboxed Python instance still break you out of the chroot jail: os.execle ('/usr/bin/python','-c','import os; os.execlp(/bin/sh)', {}) Depending on how the chroot jail is set up, this command might not work - in the jail, /bin/sh might not exist. I followed up with my ISP. Here's the answer I got: The os.exec call prepends the chroot directory to the absolute path, but does NOT provide chroot for the child process. However, as long as the environment is maintained, which contains an LD_PRELOAD, the chroot will also be maintained. If LD_PRELOAD is removed or ignored, then the chroot is ineffective. Another way of saying it is that every process is responsible for providing and maintaining the chroot through the LD_PRELOAD variable. Those processes only maintain the chroot if that variable remains set. None of this makes any sense to me. Once an application is running inside a chroot, there is no easy manipulation the application can do to break out. The example you gave above executes a shell that is in the chroot dir. That's not really breaking out of the sandbox, it's just accessing something inside the sandbox. if your ISP is trying to enforce chroot through an LD_PRELOAD library, they might be using 'fakechroot' which doesn't look very good to me. Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: How to save initial configuration? (program installation)
On Jun 25, 11:10 am, [EMAIL PROTECTED] wrote: I would think you could pop-up some dialog when the program is first run to ask where they want the file to be. On the first run though, you can just have the config file located in the current working directory with the script file itself. Then just move it or save a new copy to the new location and delete the original. The 'pop-up' is easy. The problem is how does the program know where it's state file is the SECOND time it is run? I can't stash it in the state file, since the program won't know where it is if it's not in the CWD... (unless I'm missing something obvious). -- http://mail.python.org/mailman/listinfo/python-list
amara bugs
I tried to install amara according to the recommendations on this list. There were evidently compilation errors. The results are below Also the quick reference gives 404 not found errors Thanks $ sudo easy_install amara Searching for amara Best match: Amara 1.2.0.2 Processing Amara-1.2.0.2-py2.4.egg Amara 1.2.0.2 is already the active version in easy-install.pth Installing trimxml script to /usr/bin Installing flextyper script to /usr/bin Installing scimitar script to /usr/bin Using /usr/lib/python2.4/site-packages/Amara-1.2.0.2-py2.4.egg Processing dependencies for amara Searching for 4Suite-XML=1.0.2 Reading http://www.python.org/pypi/4Suite-XML/ Reading http://4suite.org/ Reading http://www.python.org/pypi/4Suite-XML/1.0.2 Best match: 4Suite-XML 1.0.2 Downloading http://cheeseshop.python.org/packages/source/4/4Suite-XML/4Suite-XML-1.0.2.zip#md5=b5515baa72c1b88613af71d2af0a539a Processing 4Suite-XML-1.0.2.zip Running 4Suite-XML-1.0.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-w9816x/4Suite-XML-1.0.2/egg-dist-tmp-xg9AOi Ft/Lib/src/number.c:7:20: error: Python.h: No such file or directory Ft/Lib/src/number.c:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token Ft/Lib/src/number.c:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token Ft/Lib/src/number.c:36: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token Ft/Lib/src/number.c:57: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token Ft/Lib/src/number.c:75: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'numberMethods' Ft/Lib/src/number.c:82: warning: return type defaults to 'int' Ft/Lib/src/number.c: In function 'DL_EXPORT': Ft/Lib/src/number.c:82: error: expected declaration specifiers before 'initnumber' Ft/Lib/src/number.c:99: error: expected '{' at end of input error: Setup script exited with error: command 'gcc' failed with exit status 1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Collections of non-arbitrary objects ?
On 2007-06-25, walterbyrd [EMAIL PROTECTED] wrote: BTW: I think polymorphism is great and all. But it does have (and IMO should have) it's limitations. For example, I don't think you can divide a string by another string. It might be a pointless new spelling for the .split method. x = 'Smith, Ted, 15 Smedly Rd. last, first, street = x / ', ' Tongue-in-cheekily-yours, -- Neil Cerutti Strangely, in slow motion replay, the ball seemed to hang in the air for even longer. --David Acfield -- http://mail.python.org/mailman/listinfo/python-list
server wide variables
I want to be able to save some server variables as long as Apache runs on the server (mod_python). How is that possible in Python? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to save initial configuration? (program installation)
[EMAIL PROTECTED] wrote: On Jun 25, 10:02 am, Jason Zapman II [EMAIL PROTECTED] wrote: I've written a program. To install this program, I'm going to need to initialize some stuff for the users environment, specifically the name/ location of an internal state file. Currently, I'm hard coding the location of this file, but that's in- elegant. What I'd like to do is just ask the user, with a suggested default. My question is how do I save this answer? It's kind of a chicken-and- egg problem. The only solution I've thought of is to write something that's self modifying, but that's ugly (go in, grep for this variable initialization, re-write that line with the new value, quit). Is there a better way to do this? There almost has to be... If not, are there some 'best practices' on how to do the self- modification? Thanks for any help; Jason I would think you could pop-up some dialog when the program is first run to ask where they want the file to be. On the first run though, you can just have the config file located in the current working directory with the script file itself. Then just move it or save a new copy to the new location and delete the original. Mike Or, better still, leave it in place to act as the defaults for the next user who wants to start using this package? 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: server wide variables
On Mon, Jun 25, 2007 at 03:29:25PM -, Jay Sonmez wrote: I want to be able to save some server variables as long as Apache runs on the server (mod_python). How is that possible in Python? Would setting environment variables help you? You'd use os.environ. http://docs.python.org/lib/os-procinfo.html -- Stephen R. Laniel [EMAIL PROTECTED] Cell: +(617) 308-5571 http://laniels.org/ PGP key: http://laniels.org/slaniel.key -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's only one way to do it philosophy isn't good?
Douglas Alan [EMAIL PROTECTED] writes: Python has built-in abstractions for a few container types like lists and dicts, and now a new and more general one (iterators), so it's the next level up. Common Lisp has had all these things for ages. Rubbish. Do you actually know any common lisp? There is precisely no way to express for x in xs: blah(x) or x = xs[key] in either scheme or CL, which is a major defect of both language (although there has been a recent and limited proposal for sequence iteration by c. rhodes which is implemented as an experimental extension in sbcl). This is stuff even C++, which is about the lowest-level language anyone uses for general purpose programming these days has been able to express for decades (modulo foreach syntax). In a decent scheme it's easy enough to define your own collection class/iteration protocol, which does allow you to do something like the above, but of course only for container abstractions that you have some control over yourself. Even in this limited sense you can forget about doing this in CL in a way that meshes nicely with the existing primitives (inter alia because of spurious inconsistencies between e.g. sequence and hash-access and under-specification of the exception hierachy) and anything as expressive as generators/coroutines in CL with reasonable effort and performance which won't even allow you to write LOOPs over custom container types (the nonstandard ITERATE package has limited support for this). 'as -- http://mail.python.org/mailman/listinfo/python-list
Re: How to save initial configuration? (program installation)
Jason Zapman II wrote: On Jun 25, 11:10 am, [EMAIL PROTECTED] wrote: I would think you could pop-up some dialog when the program is first run to ask where they want the file to be. On the first run though, you can just have the config file located in the current working directory with the script file itself. Then just move it or save a new copy to the new location and delete the original. The 'pop-up' is easy. The problem is how does the program know where it's state file is the SECOND time it is run? I can't stash it in the state file, since the program won't know where it is if it's not in the CWD... (unless I'm missing something obvious). The traditional choices are the registry for Windows, and the /etc subtree for the various, almost uncountable, flavors of Unix and nixalikes. You're right, it's much more difficult per-system than per-user, since there are so many conventions. 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 save initial configuration? (program installation)
On Jun 25, 11:37 am, Steve Holden [EMAIL PROTECTED] wrote: The traditional choices are the registry for Windows, and the /etc subtree for the various, almost uncountable, flavors of Unix and nixalikes. You're right, it's much more difficult per-system than per-user, since there are so many conventions. I forgot to mention that this is for Unix environments, so the registry isn't an option, unfortunately (never thought I'd say that... ;-) ). Is there anything in the distutils.* stuff that would be useful? This isn't going to be a python package (it's a standalone program). --Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Chroot Jail Not Secure for Sandboxing Python?
On 25 Jun, 16:48, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I followed up with my ISP. Here's the answer I got: The os.exec call prepends the chroot directory to the absolute path, but does NOT provide chroot for the child process. However, as long as the environment is maintained, which contains an LD_PRELOAD, the chroot will also be maintained. If LD_PRELOAD is removed or ignored, then the chroot is ineffective. So it appears that as long as LD_PRELOAD is set (possibly to link the process to some other libraries than is usually the case), any affected processes are effectively jailed. This doesn't really sound like a traditional chroot environment, though. Another way of saying it is that every process is responsible for providing and maintaining the chroot through the LD_PRELOAD variable. Those processes only maintain the chroot if that variable remains set. Right. The only solution that would bypass this problem altogether would be a statically linked python. (is that possible?) It would have to be statically linked to a custom-modified glibc to provide the virtual chroot environment. Some solutions depend on linking to restricted libraries, and the Wiki page you referenced probably talks about them as well. I was thinking that if I were to attempt to properly sandbox any current version of CPython, I'd start off linking it to restricted libraries which provide compatible interfaces for things like opening file handles; then I'd put various policy controls in those libraries so that you can have some control over what your programs do. Finally, you'd have to stop arbitrary (extension) module loading in order to prevent programs importing some nice modules and getting round the controls: for example, importing socket or os to get access to file handles (or to process creation which might get around the controls as suggested above). Eventually, this arrives more or less at where Brett Cannon is supposed to be right now with his sandboxed Python, perhaps by a different route and with some different outcomes. I notice that you've mailed me about a solution that I mentioned in the past, but I'll respond here in order to air the ideas in public. I looked into chroot jails and saw that some solutions exist for populating directories with enough files for things like daemons or services to be executed within the chroot environment. I also looked at ways to break out of chroot environments, and there's a fairly well- known trick involving open file handles which will do this effectively for non-root users. What I then considered was the possibility of avoiding population of a chroot filesystem by calling chroot and setuid on a minimal jailer process which then loads a jailed program after having imported a permitted set of modules. I don't have the details with me now, but I'll probably upload the code in the near future and post some kind of explanation of what it does here. I'm tempted to say that the better solution involves the restricted libraries solution mentioned above, and a nice side-effect of that could be a more modular CPython that would benefit people using the software in embedded environments: you'd have to insulate the virtual machine from even the most central modules, meaning that they could potentially be detached completely in places where memory and storage are better used on other things. Paul -- http://mail.python.org/mailman/listinfo/python-list
Talks presentations online
Hello, just wanted to let you know that we've put up a few of our conference talks and presentations on the web-site: http://www.egenix.com/library/presentations/ At EuroPython this year, we'll be giving talks on relational databases with Zope and show how mxTextTools can be put to good use for parsing languages. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jun 25 2007) Python/Zope Consulting and Support ...http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ 2007-07-09: EuroPython 2007, Vilnius, Lithuania13 days to go Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 -- http://mail.python.org/mailman/listinfo/python-list
Re: How to save initial configuration? (program installation)
On Jun 25, 10:58 am, Jason Zapman II [EMAIL PROTECTED] wrote: On Jun 25, 11:37 am, Steve Holden [EMAIL PROTECTED] wrote: The traditional choices are the registry for Windows, and the /etc subtree for the various, almost uncountable, flavors of Unix and nixalikes. You're right, it's much more difficult per-system than per-user, since there are so many conventions. I forgot to mention that this is for Unix environments, so the registry isn't an option, unfortunately (never thought I'd say that... ;-) ). Is there anything in the distutils.* stuff that would be useful? This isn't going to be a python package (it's a standalone program). --Jason Well, I don't know what your user file does, but couldn't you create a .ini type file to hold the user's choice for the other file's location and save the ini to the current working directory? Something like this: ini file usersChosenPath = /usr/Path/to/Config /ini file Kind of redundant, but I would think it would still work. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib interpretation of URL with ..
Duncan Booth wrote: Martin v. Löwis [EMAIL PROTECTED] wrote: Is urllib wrong? Section 5.2 is also relevant here. In particular: g) If the resulting buffer string still begins with one or more complete path segments of .., then the reference is considered to be in error. Implementations may handle this error by retaining these components in the resolved path (i.e., treating them as part of the final URI), by removing them from the resolved path (i.e., discarding relative levels above the root), or by avoiding traversal of the reference. The common practice seems to be for client-side implementations to handle this using option 2 (removing them) and servers to use option 3 (avoiding traversal of the reference). urllib uses option 1 which is also correct but not as useful as it might be. That's helpful. Thanks. In Python, of course, urlparse.urlparse, which is the main function used to disassemble a URL, has no idea whether it's being used by a client or a server, so it, reasonably enough, takes option 1. (Yet another hassle in processing real-world HTML.) John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Capturing and sending keys {Esperanto}
On Jun 25, 3:26 pm, AJK [EMAIL PROTECTED] wrote: Hello there! I've been googleing yet, and suppose it's hopeless to try, but better ask it... I want to write a program which turns Cx to , cx to et al WHILE TYPING. (i.e. converting Esperanto x-system to real hats, for those who know about this.) Therefore I though will need to capture the last 2 typed characters (from any application), send a double backspace and after that send the correct letters (back to the same application)... However, it seems inpossible to capture those letters, and maybe to send them too... Or am I wrong? Greetings, LaPingvino (project:http://code.google.com/p/iksilo/- SVN Repository is free viewable, project is GPL) -- ar Dio tiel amis la mondon, ke Li donis Sian solenaskitan Filon, por ke iu, kiu fidas al li, ne pereu, sed havu eternan vivon. -Johano 3:16, La sankta Biblio- oju iam, pre u sen ese, pri io donu dankon. -1 Tesalonikanoj 5:16-18a, La sankta Biblio- Under *nix it's easier to change xkb keymap. If you interested only in gtk applications then there is gtk-im-extra [1], which you can use to input cxapeloj. You can also look at scim [2] sources. It supports gtk, qt and standard x applications. Bonsxancon! [1] http://gtk-im-extra.sourceforge.net/ [2] http://www.scim-im.org/ -- http://mail.python.org/mailman/listinfo/python-list
listing all property variables of a class instance
Suppose I define a class with a number of variables defined as properties. Something like: class MyClass(object): def __init__(self): self.some_variable = 42 self._a = None self._b = pi def get_a(self): return self._a def set_a(self, value): self._a = value def get_b(self): return self._b def set_b(self, value): self._b = value a = property(get_a, set_a, None, a is a property) b = property(get_b, set_b, None, b is a property) Is there a way to write a method that would list automatically all the variables defined as a property (say by printing their docstring and/ or their value), and only those variables? André -- http://mail.python.org/mailman/listinfo/python-list
RE: Help With Better Design
IMHO ... untested class LightBulb: def __init__(self, on=False): self.IsOn = on def turnOn(self): self.switchIt(True) def turnOff(self):self.switchIt(False) def switchIt(self, turnon): if self.isOn==turnon: print The Switch is Already %s % ([ON, OFF][self.isOn]) else: self.isOn = turnon #or alternatively =!self.isOn def __repr__(self): return [ON, OFF][self.IsOn] --- [EMAIL PROTECTED] wrote: ON = ON OFF = OFF class LightBulb: def __init__(self, initial_state): self.state = initial_state def TurnOn(self): if self.state == OFF: self.state = ON else: print The Bulb Is Already ON! def TurnOff(self): if self.state == ON: self.state = OFF else: print The Bulb Is Aleady OFF! I've written code that looks a lot like that, and it's a perfectly acceptable pattern IMHO. I don't bother with the variables ON and OFF, though, as they add no clarity to simply using 'ON' and 'OFF' for the states. [...] The test portion of the code is actually longer than the class itself :-) That's usually a good thing! It means your code is concise, and your tests are exhaustive. (But that doesn't mean you can't also refactor your tests.) __ __ Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out. http://answers.yahoo.com/dir/?link=listsid=396545469 -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: socket on cygwin python
On Mon, Jun 25, 2007 at 01:53:18PM +0100, Michael Hoffman wrote: [EMAIL PROTECTED] wrote: I've installed cygwin with latest python 2.5.1, but it seems that the socket lib file do NOT support IPv6(cygwin\lib\python2.5\lib-dynload \_socket.dll), what can I do if I want to use IPv6? I don't think Cygwin supports IPv6. That was my impression too and seems to be substantiated by the following: http://win6.jp/Cygwin/index.html Jason -- PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6 -- http://mail.python.org/mailman/listinfo/python-list
How to change default behavior
Greetings, I am using pyuniit for my test cases. I want to change the default behavior to report the errors. I believe it calls TextTestRunner class before calling my test_class(which is child of TestCase class) to set up the framework for error reporting and so on. I can see that it makes the result variable of type _TextTestResult class. So while reporting errors, it calls functions of this class. I want to overload the TextTestRunner class and want to make result of type my class, so in further linage of function calls it should call functions of my class instead of _TextTestResult. But I was not able to find out how does python test framework calls TextTestRunner automatically. Somehow I want to make it call my overloaded class. Could anybody help me out. Thanks in anticipation. JD -- http://mail.python.org/mailman/listinfo/python-list
Re: listing all property variables of a class instance
On 2007-06-25, André [EMAIL PROTECTED] wrote: Suppose I define a class with a number of variables defined as properties. Something like: class MyClass(object): def __init__(self): self.some_variable = 42 self._a = None self._b = pi def get_a(self): return self._a def set_a(self, value): self._a = value def get_b(self): return self._b def set_b(self, value): self._b = value a = property(get_a, set_a, None, a is a property) b = property(get_b, set_b, None, b is a property) Is there a way to write a method that would list automatically all the variables defined as a property (say by printing their docstring and/ or their value), and only those variables? This is off the cuff. There's likely a better way. for k, v in MyClass.__dict__.iteritems(): if isinstance(v, property): print k, v.__doc__ -- Neil Cerutti 22 members were present at the church meeting held at the home of Mrs. Marsha Crutchfield last evening. Mrs. Crutchfield and Mrs. Rankin sang a duet, The Lord Knows Why. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list
Re: listing all property variables of a class instance
Neil Cerutti wrote: Is there a way to write a method that would list automatically all the variables defined as a property (say by printing their docstring and/ or their value), and only those variables? This is off the cuff. There's likely a better way. for k, v in MyClass.__dict__.iteritems(): if isinstance(v, property): print k, v.__doc__ The only way I could get this to work was to change the way the properties were defined/initalized: #!/usr/bin/python class MyClass(object): def __init__(self): self.some_variable = 42 self._a = None self._b = pi self.a = property(self.get_a, self.set_a, None, a is a property) self.b = property(self.get_b, self.set_b, None, b is a property) def get_a(self): return self._a def set_a(self, value): self._a = value def get_b(self): return self._b def set_b(self, value): self._b = value test = MyClass() for k,v in test.__dict__.iteritems(): if isinstance(v, property): print k, v.__doc__ -- http://mail.python.org/mailman/listinfo/python-list
Re: The Modernization of Emacs: terminology buffer and keybinding
Hi Twisted, Twisted == Twisted [EMAIL PROTECTED] writes: Twisted That's entirely orthogonal to the issue of interface learning curve OR Twisted interface ease-of-use. Emacs has deficiencies in both areas, if Twisted principally the former. (For an example of the latter, consider Twisted opening a file. Can't remember the exact spelling and capitalization Twisted of the file name? Sorry, bud, you're SOL. Wrong, ever heard about input completion? Twisted Go find it in some other app Twisted and memorize the name, then return to emacs. Wrong. Do you know dired? For even more ease of use use someting like ido, or icicles. It runs rings about Editors like Notepad. Twisted Now THAT is what I call Twisted disruptive context switching. Meanwhile even the lowly Notepad Twisted responds to open by displaying a list of text files and tools to Twisted navigate the folder hierarchy without having to do it blind, while Twisted still letting you blind-type a path if you remember it. And you can Twisted also paste the path in from the clipboard. You can do so in emacs as well. Twisted Unix systems don't even Twisted *have* a proper system-wide clipboard and copy/paste capability. Under Twisted X there's a weak, text-only imitation, which doesn't help you much Twisted when you want to copy a selection from an image in a paint program and Twisted paste it into a CAD or web-design or specialized image-manipulation Twisted tool or whatever...you have to save it to a file and load it, which is Twisted a pain in the butt and slowly clutters your hard drive with Twisted temporary files you occasionally forget to delete. You obviously have no clue about working under Unix either. 'Andreas -- Wherever I lay my .emacs, there's my $HOME. -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing sound volume
On Jun 25, 7:48 am, simon kagwe [EMAIL PROTECTED] wrote: And finally a way that might work using ctypes: http://mail.python.org/pipermail/python-win32/2006-March/004436.html Mike Hi, Thanks for your reply. I had already read about the Snack, but I can't use it since my program uses wxPython for the GUI and Snack requires tk. The best option was the ctypes method you told me about. I used the code in the sample, but I am getting the following error: exceptions.WindowsError Error 11 while setting volume The author of the code claims it works. What could be causing the above error? [ I am using Python 2.4.4 and ctypes 1.0.1 ] Regards, Simon I'm not sure what the deal is. I just tested that script on my workstation and it works fine for me. I think I have the latest ctypes, but I can't figure out how to get the version number off of it to be sure. I am running Python 2.4.3 on Windows XP SP2 though. You might try that pygames idea. I've never tried it, but you'd think that would work. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Portable general timestamp format, not 2038-limited
Steve O'Hara-Smith wrote: On Mon, 25 Jun 2007 11:17:27 GMT Roedy Green [EMAIL PROTECTED] wrote: On Sun, 24 Jun 2007 18:14:08 -0700, [EMAIL PROTECTED] (Robert Maas, see http://tinyurl.com/uh3t) wrote, quoted or indirectly quoted someone who said : - Stick to astronomical time, which is absolutely consistent but which drifts from legal time? depends what you are measuring. IF you are doing astronomy, your advice would apply. If you are doing payrolls, you want effectively to pretend the leap seconds never happened, just as Java does. Which leaves you about 30 seconds out by now - smelly. Easy solution: always read Zulu time directly from a recognized real-time clock and store the result in a database as a ccyymmddhhmmssfff ASCII string where fff is milliseconds). By recognized real-time clock) that I mean an atomic clock and distribution network such as GPS or (in the UK or Germany) an MSF low frequency radio broadcast. NTP using tier-1 sources may do the job too. The clock interface may need to be JINI because most suitable receivers have serial interfaces. This is certainly accurate for financial transactions: the UK CHAPS inter-bank network has a Rugby MSF receiver in each bank's gateway computer and uses that for all timestamps. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | -- http://mail.python.org/mailman/listinfo/python-list
Python-URL! - weekly Python news and links (Jun 25)
QOTW: [R]edundant/useless/misleading/poor code is worse than wrong. - Michele Simionato http://groups.google.com/group/comp.lang.python/msg/74adbb471826a245 Unit tests are not a magic wand that discover every problem that a program could possibly have. - Paul Rubin http://groups.google.com/group/comp.lang.python/msg/6e683105172b2ca7 Some tricks to automatically enter the debugger when an exception happens: http://groups.google.com/group/comp.lang.python/browse_thread/thread/3ffc25cbd3d1947/ A recurring topic: using uniform collections of objects: http://groups.google.com/group/comp.lang.python/browse_thread/thread/f7eebeb1ebe17a4/ Some concerns about eggs, the way they handle dependencies, and restrictive environments: http://groups.google.com/group/comp.lang.python/browse_thread/thread/50e06542f2452c9e/ Four different answers from four different persons to the same problem: how to modify a variable in an outer scope from inside the inner function http://groups.google.com/group/comp.lang.python/browse_thread/thread/9cdb4af5755e4daa/ A conspicuous Pythonista shows his italian temper discussing why redundant statements aren't any good: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a8c170e10c643f27/ A long thread about function annotations in Python 3.0 and its actual usefulness for argument type checking: http://groups.google.com/group/comp.lang.python/browse_thread/thread/1b2a416d6fbe5b61/ This lng thread started more than two weeks ago: still about macros, programmable syntax, and what is good for Scheme is not necesarily good for Python: http://groups.google.com/group/comp.lang.python/browse_thread/thread/e587471d08dbfcbb/ Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. The Python Papers aims to publish the efforts of Python enthusiats. http://pythonpapers.org/ Readers have recommended the Planet sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Many Python conferences around the world are in
Re: listing all property variables of a class instance
In [EMAIL PROTECTED], Jay Loden wrote: Neil Cerutti wrote: Is there a way to write a method that would list automatically all the variables defined as a property (say by printing their docstring and/ or their value), and only those variables? This is off the cuff. There's likely a better way. for k, v in MyClass.__dict__.iteritems(): if isinstance(v, property): print k, v.__doc__ The only way I could get this to work was to change the way the properties were defined/initalized: That's because you iterate over the instance's `__dict__` and not over the *class* `__dict__` like Neil does. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: eggs considered harmful
On 21 Jun., 14:10, Harry George [EMAIL PROTECTED] wrote: I've asked before, and I'll ask again: If you are doing a Python project, please make a self-sufficient tarball available as well. Alomost all projects I know of that provide eggs, also have a CVS or SVN repository. Just download a tagged release and then use python setup.py whatever or easy_install . in the checkout. easy_install can even do the checkout for you. You can have dependencies, as long as they are documented and can be obtained by separate manual download. Eggs document dependencies better (i.e with version numbers) than most other projects do, through the install_requires argument to the setup() call in setup.py. In an egg, this list is found in *-egg- info/requires.txt. Ok, setup.py itself may not do the work, but from the end users' perspective it works that way. Setup.py runs a configure and a make, which in turn find the right already-installed libraries. The point is, setup.py plays well in such an environment. Configure etc. may be able to detect an installed version number of a package/module because they include scripts to check for those. IMHO it's silly to place the burden for checking for version numbers on the developer who wants to distribute an app. The package/module should provide a standard way to query the version number itself. This is exactly one of things that setuptools is about. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing sound volume
simon kagwe wrote: And finally a way that might work using ctypes: http://mail.python.org/pipermail/python-win32/2006-March/004436.html Mike Hi, Thanks for your reply. I had already read about the Snack, but I can't use it since my program uses wxPython for the GUI and Snack requires tk. The best option was the ctypes method you told me about. I used the code in the sample, but I am getting the following error: exceptions.WindowsError Error 11 while setting volume The author of the code claims it works. What could be causing the above error? [ I am using Python 2.4.4 and ctypes 1.0.1 ] That module looks suspiciously like one I have laying around on my computer. That's okay since I had posted it somewhere. Try setting SPEAKER_LINE_FADER_ID to 0. Apparently my assumption that it is always 0 was wrong. If that works I have a more flexible version of the module which actually searches for the speak line fader id. It also has a GetSpeakerVolume function. --- Lenard Lindstrom [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Collections of non-arbitrary objects ?
On Jun 24, 2:12 pm, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: 7stud wrote: if hasattr(elmt, some_func): elmt.some_func() Personally, I prefer try: elmt.some_func() except AttributeError: # do stuff That also hides attribute errors that occur within some_func. I think I'd rather know when elmt has an implementation of some_func that is buggy. Thus I prefer the hasattr version. -- http://mail.python.org/mailman/listinfo/python-list
Re: listing all property variables of a class instance
En Mon, 25 Jun 2007 15:10:25 -0300, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] escribió: In [EMAIL PROTECTED], Jay Loden wrote: Neil Cerutti wrote: Is there a way to write a method that would list automatically all the variables defined as a property (say by printing their docstring and/ or their value), and only those variables? This is off the cuff. There's likely a better way. for k, v in MyClass.__dict__.iteritems(): if isinstance(v, property): print k, v.__doc__ The only way I could get this to work was to change the way the properties were defined/initalized: That's because you iterate over the instance's `__dict__` and not over the *class* `__dict__` like Neil does. I would iterate over dir(MyClass) instead - only because I prefer to hide such implementation details. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: pydoc with METH_VARGS
Stuart wrote: I'm asking if there's some sort of commenting or input file or something to customize the output pydoc generates. Thanks. AFAIK, there is no way to do this. However, you can edit the doc string for your function, which can include the argument list. I believe this is what most of Python's built-in functions do. -Farshid -- http://mail.python.org/mailman/listinfo/python-list
Re: How to save initial configuration? (program installation)
On Jun 25, 12:14 pm, [EMAIL PROTECTED] wrote: ini file usersChosenPath = /usr/Path/to/Config /ini file Kind of redundant, but I would think it would still work. Ok... How do I tell the program where the INI file lives? (What I want is to be able to ask the user Where do you want the datafile to live? [/usr/local/etc]: and save that answer somewhere, so future invocations of the program just *KNOW* the answer. I'm going to just have to write an 'install' program which just substitutes the default assignment for the new one in the code... almost a $PREFIX from ./configure or something like it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why isn't this query working in python?
On May 27, 11:06 pm, Steve Holden [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On May 27, 2007, at 4:01 PM, Steve Holden wrote: erikcwwrote: On May 26, 8:21 pm, John Machin [EMAIL PROTECTED] wrote: On May 27, 5:25 am,erikcw[EMAIL PROTECTED] wrote: On May 25, 11:28 am, Carsten Haese [EMAIL PROTECTED] wrote: On Fri, 2007-05-25 at 09:51 -0500, Dave Borne wrote: I'm trying to run the following query: ... member_id=%s AND expire_date NOW() AND completed=1 AND (product_id Shouldn't you be using the bind variable '?' instead of '%s' ? The parameter placeholder for MySQLdb is, indeed and unfortunately, %s. The OP is using parameter substitution correctly, though in an obfuscated fashion. 'sql' is a misnamed tuple containing both the query string *and* the parameters, which is being unpacked with '*' into two arguments to the execute call. The only problem I see is that the parameters should be a sequence, i.e. (self.uid,) instead of just (self.uid). HTH, -- Carsten Haesehttp://informixdb.sourceforge.net I tried adding the comma to make it a sequence - but now change. ('SELECT payment_id FROM amember_payments WHERE member_id=%s AND expire_date NOW() AND completed=1 AND (product_id 11 AND product_id 21)', (1608L,)) () What else could it be? Possibly a type mismatch. How is member_id declared in the CREATE TABLE? For diagnostic purposes, try passing in (1608,) and ('1608',). Here is a copy of the table schema and the first 2 rows. -- phpMyAdmin SQL Dump -- version 2.9.0.2 --http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: May 27, 2007 at 11:29 AM -- Server version: 5.0.27 -- PHP Version: 4.4.2 -- -- Database: `lybp_lybp` -- -- -- -- Table structure for table `amember_payments` -- CREATE TABLE `amember_payments` ( `payment_id` int(11) NOT NULL auto_increment, `member_id` int(11) NOT NULL default '0', `product_id` int(11) NOT NULL default '0', `begin_date` date NOT NULL default '-00-00', `expire_date` date NOT NULL default '-00-00', `paysys_id` varchar(32) NOT NULL default '', `receipt_id` varchar(32) NOT NULL default '', `amount` decimal(12,2) NOT NULL default '0.00', `completed` smallint(6) default '0', `remote_addr` varchar(15) NOT NULL default '', `data` text, `time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `aff_id` int(11) NOT NULL default '0', `payer_id` varchar(255) NOT NULL default '', `coupon_id` int(11) NOT NULL default '0', `tm_added` datetime NOT NULL default '-00-00 00:00:00', `tm_completed` datetime default NULL, `tax_amount` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`payment_id`), KEY `member_id` (`member_id`), KEY `payer_id` (`payer_id`), KEY `coupon_id` (`coupon_id`), KEY `tm_added` (`tm_added`,`product_id`), KEY `tm_completed` (`tm_completed`,`product_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11020 ; -- -- Dumping data for table `amember_payments` -- INSERT INTO `amember_payments` VALUES (423, 107, 1, '2004-10-01', '2004-10-21', 'authorize_aim', '5687944', 3.95, 1, '', NULL, '2004-11-30 19:21:43', 0, '', 0, '2004-11-30 19:21:43', '2004-11-30 19:21:43', 0.00); INSERT INTO `amember_payments` VALUES (422, 107, 1, '2004-10-22', '2004-11-21', 'authorize_aim', '5873225', 9.95, 1, '', NULL, '2004-11-30 19:22:18', 0, '', 0, '2004-11-30 19:20:13', '2004-11-30 19:20:13', 0.00); Thanks for your help! Erik I feel obliged to point out that there ARE no rows meeting the criteria you query specified! mysql SELECT expire_date, NOW() FROM amember_payments; +-+-+ | expire_date | NOW() | +-+-+ | 2004-10-21 | 2007-05-27 15:59:21 | | 2004-11-21 | 2007-05-27 15:59:21 | +-+-+ 2 rows in set (0.02 sec) mysql So I am not sure how you managed to get a manual query to work, but do be sure that the Python query you mentioned at the start of the thread sql = SELECT payment_id FROM amember_payments WHERE member_id=%s AND expire_date NOW() AND completed=1 AND (product_id 11 AND product_id 21), (self.uid) And doesn't the above comma, need to be a percent symbol? Nope. Dave doesn't stand a chance of returning any results unless you use a time machine to go back almost three years! 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 your way to fame!! holdenweb.blogspot.comsquidoo.com/pythonology tagged items:
Python SVN down?
Going to this URL: http://svn.python.org/view/ It gives me an error: Unable to connect Firefox can't establish a connection to the server at svn.python.org. And using SVN as so: $ svn checkout http://svn.python.org/projects/python/trunk/ ~/ python_work/ svn: PROPFIND request failed on '/projects/python/trunk' svn: PROPFIND of '/projects/python/trunk': could not connect to server (http://svn.python.org) Gives me the above error. Any ideas? I didn't see an announcement about this anywhere. -Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: getting the size of an object
On 6/18/07, filox [EMAIL PROTECTED] wrote: is there a way to find out the size of an object in Python? e.g., how could i get the size of a list or a tuple? mxTools includes a sizeof() function. Never used it myself, but MAL isn't notorious for getting things wrong, so I'm sure it does what it says on the tin. http://tinyurl.com/3ybdb3 Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues -- http://mail.python.org/mailman/listinfo/python-list
Re: Collections of non-arbitrary objects ?
walterbyrd a écrit : On Jun 24, 10:31 pm, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Especially since variables in python do not have to be explicitly assigned ??? I have probably expressed this incorrectly. What I meant was: a = [1,2,3] b = a a[1] = 'spam' Here, I have changed b, without an explicit assignment. You haven't changed b, you have changed the object bound to name 'b'. Which happens to be also bound to name 'a'. After I assigned a to b, Well, I guess the term assignment is misleading you then. binding would be more accurate - you bound names 'a' and 'b' to the same object. Then, whether you access this object via name 'a' or name 'b', you're still accessing the same object. I never did another b = yet b changed anyway Doing 'b = some_other_object' would still not 'change b' - you don't change a name - but rebind name 'b' to another object. You perhaps don't know this, but most statically typed languages have the notion of either pointers or references, that can cause similar - and usually worse - problems. because I changed a. I am not saying there is anything wrong with this, I'm just explaining what I meant. So let's say I have list L, and I have a routine that expects every item in L to be a dictionary like: {'name':'joe', 'job':'dev', 'pay': min_wage}. Not only could the app crash if an incorrect item where inserted into L. But the app could crash if an incorrect item were inserted in lists X,Y, or Z. Yes - assuming names L, X, Y and Z are bound to the same list. And it would also crash if one the dicts was modified between the moment it is added to the list and the moment you pass the list to your function. Which makes typed lists totally useless anyway. And even if you use a smarter 'correctness' test (like a callback function checking that every item added or inserted supports keying and has the correct keys), it would still be useless since you could still manage to modify one of the items of the list *after* it has been added to it. Of course, you can always work around this by just programming very carefully, You do program carefully, don't you ?-) and doing a lot of error checking. That's usually not even necessary - most of the time (ie: almost always), you'll have a nice traceback in the minutes following the moment you introduced the error. That is always true in any language. Nope. In Python, you seldom have to do error *checking* - the language do it for you (that's what exceptions are for). What you have to do is 1/ testing, and 2/ error *handling*. Now did you actually had any effective problem with Python's dynamism ? Or are you just scared ? You know, Python is now something like 17 years old, and is used by a *lot* of peoples for a *lot* of programs - some of them far from trivial. I think you can be confident in this experience. IOW, just write your code, and you'll find out that the kind of problems you seem to fear so much will not happens that often. But, I think sometimes it's helpful to use a structure that is little more restrictive, to sort of enforce a degree of integrity. Sometimes you do have to check the validity of the data you are supposed to work on, true - mostly when it comes to program inputs (be it wia files, sockets, forms, environment, whatever). Once this is done, you shouldn't have to worry too much - just let Python crash when there's something wrong, carefully read the traceback, and correct the offending code (which is very likely in the last modifications you made). An example I have already given: why use tuples instead of a list? Tuples are actually a bit more restrictive. You don't use tuples instead of lists. Lists are collections, tuples are structured data. I don't think there is anything wrong with the data structures that exist in python. I was just wondering if there was a structure that would restrict a collection to only allow certain types. Not builtin. You can roll your own if it makes you happy, but that would be a waste of time - been here, done that, you see... The restrictedlist class discussed in another thread may be the sort of thing I was looking for. So please take time to read the whole thread. BTW: I think polymorphism is great and all. But it does have (and IMO should have) it's limitations. Yes, indeed - if an object doesn't understand a message, then you have an exception. But since the only way to know if an object can handle a message is to send the message (please refer to my previous post), enforcing 'type'-based (with 'type'=='class') restriction in Python is not only useless, it's also harmful. IOW, stop fighting against the language - just use it. For example, I don't think you can divide a string by another string. No, because this operation is not implemented for strings - IOW, strings doesn't understand this message. What would be the meaning of dividing strings anyway ? (while
Re: Indenting in Emacs
Michael Hoffman [EMAIL PROTECTED] writes: John J. Lee wrote: Eugene Morozov [EMAIL PROTECTED] writes: Steven W. Orr пишет: Ok. I'm not stupid but I do not see a 4.78 anywhere even though I see refs from google. I have 4.75 The SVN tree doesn't seem to even have that. I checked the latest copy out from sourceforge and that was 4.75 too. Can someone please tell me where to find the latest? It's from Emacs 22. Note that's a different python-mode to the old one that lives on SF. Yes, there are now two of them. Which one is better? I've not noticed a big difference in usability. I find indentation with the new mode very mildly more annoying than the old mode. YMMV on that. There are probably annoyances with the old mode that I've now forgotten about. I'm told by an emacs developer at work that the new mode is more emacsy in its implementation -- I don't know in what ways exactly, but presumably that, plus the fact that the new mode is included with emacs 22, will mean that it's likely to work better with other emacs code (not that I ever had much problem with the old mode -- but then I didn't push it very far). John -- http://mail.python.org/mailman/listinfo/python-list
Re: eggs considered harmful
On Jun 21, 8:10 am, Harry George [EMAIL PROTECTED] wrote: [snip description of unacceptable behaviors] These are unacceptable behaviors. I am therefore dropping ZODB3 If you have bugs to report against ZODB, I sugest posting to zodb-dev (http://mail.zope.org/mailman/listinfo/zodb-dev). -- Benji York -- http://mail.python.org/mailman/listinfo/python-list
Installing python under the linux
Hello, I have problem with installing Python on the Linux platform.Can you tell me step by step how can I install python on linux ( please detailed ) , because I don't know anything about linux and I really don't understand python documentation about installing python on linux. Thanks!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: eggs considered harmful
Harry George [EMAIL PROTECTED] writes: [EMAIL PROTECTED] (John J. Lee) writes: [...] 2. You can run your own private egg repository. IIRC, it's as simple as a directory of eggs and a plain old web server with directory listings turned on. You then run easy_install -f URL package_name instead of easy_install package_name . The distutils-sig archives will have more on this. Again, not speaking for anyone else: With 500 OSS packages, all of which play by the same tarball rules, we don't have resources to handle eggs differently. You said earlier: The rules are that a) a very few authorized downloaders obtain tarballs and put them in a depot and b) other users get tarballs from the depot and build from source. Not sure how this differs significantly from running a repository, in the sense I use it above. John -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing python under the linux
On 2007-06-25, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have problem with installing Python on the Linux platform.Can you tell me step by step how can I install python on linux ( please detailed ) , because I don't know anything about linux and I really don't understand python documentation about installing python on linux. Virtually all general-purpose server or client Linux distros already have Python installed. If you've managed to find one that doesn't, then you've got two choices: 1) Install it using the package manager for the distro in question. 2) Build/Install it from source. For somebody who knows so little about Linux, I'd strongly recommend option 1. We can't give you step-by-step instructions unless you tell us what distro you're running. -- Grant Edwards grante Yow! I just remembered at something about a TOAD! visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing python under the linux
Greetings, Python is usally already installed on most distros. In a terminal window type python to see if something happens. Also please provide what distro you are running. Danyelle On 6/25/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I have problem with installing Python on the Linux platform.Can you tell me step by step how can I install python on linux ( please detailed ) , because I don't know anything about linux and I really don't understand python documentation about installing python on linux. Thanks!!! -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python SVN down?
Can confirm the same behavior from locations in California and Arizona. The machine responds to pings but sends resets on any connection to tcp port 80... Asked in IRC, no response. On Jun 25, 12:17 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Going to this URL:http://svn.python.org/view/ It gives me an error: Unable to connect Firefox can't establish a connection to the server at svn.python.org. And using SVN as so: $ svn checkouthttp://svn.python.org/projects/python/trunk/~/ python_work/ svn: PROPFIND request failed on '/projects/python/trunk' svn: PROPFIND of '/projects/python/trunk': could not connect to server (http://svn.python.org) Gives me the above error. Any ideas? I didn't see an announcement about this anywhere. -Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Python SVN down?
[EMAIL PROTECTED] wrote: Going to this URL: http://svn.python.org/view/ It gives me an error: Unable to connect Firefox can't establish a connection to the server at svn.python.org. [...] Any ideas? Clear case. $ nc -v svn.python.org 80 svn.python.org [82.94.237.220] 80 (www) : Connection refused $ It _is_ down. Probably server maintenance. Regards, Björn -- BOFH excuse #37: heavy gravity fluctuation, move computer to floor rapidly -- http://mail.python.org/mailman/listinfo/python-list
Re: Collections of non-arbitrary objects ?
In [EMAIL PROTECTED], Bruno Desthuilliers wrote: walterbyrd a écrit : For example, I don't think you can divide a string by another string. No, because this operation is not implemented for strings - IOW, strings doesn't understand this message. What would be the meaning of dividing strings anyway ? (while concatening string is a well-known operation). As someone else already mentioned dividing strings is splitting. The Pike language does this: http://pike.ida.liu.se/generated/manual/ref/chapter_4.html Scroll down to ``string / string``. The definition of ``string / float`` is neat too. Something I really miss in everyday programming in Python, not. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Setuptools, build and install dependencies
Harry George [EMAIL PROTECTED] writes: Robert Kern [EMAIL PROTECTED] writes: Harry George wrote: We need to know the dependencies, install them in dependency order, and expect the next package to find them. configure does this for hundreds of packages. cmake, scons, and others also tackle this problem. Python's old setup.py seems to be able to do it. No, generic setup.py scripts don't do anything of that kind. Ok, setup.py itself may not do the work, but from the end users' perspective it works that way. Setup.py runs a configure and a make, which in turn find the right already-installed libraries. The point is, setup.py plays well in such an environment. Some setuptools-based packages do that. Some pure-distutils packages do that. Some setuptools-based packages don't do that. Some pure-distutils packages don't do that. Regardless of that logic, it's true that, pragmatically, setuptools' support for dependency resolution encourages an increasing reliance on explicitly-declared dependencies on *Python* projects (project here meaning something with a setup.py -- a project may contain several Python packages / modules, and several projects may provide (parts of) a single Python package, as with zope.*). However, pre-setuptools, one rarely saw Python packages being discovered using autotools (configure c.). *System* features (presence/absence of libraries, c.) were indeed discovered that way. I don't know of any Python projects that previously used autotools and stopped doing so as part of a switch to setuptools). John -- http://mail.python.org/mailman/listinfo/python-list
finding an element in a string
Hi, I was wondering if you could help me with this: I want to make an if statement in which I would like to find a certain word in a sentence; here is what i have so far: x = raw_input("how are you?") if x == "fine": print "Good." But that, obviously, will only respond "good" when one writes "fine". I was looking for a way for the program to respond "good" to any sentence that would contain the word "fine" in it. I'm sure it's something ridiculously easy, but I have no idea how to do it! :) Thank you, Miguel :)MSN Busca: fácil, rápido, direto ao ponto. Encontre o que você quiser. Clique aqui. -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing python under the linux
Danyelle Gragsone je napisao/la: Greetings, Python is usally already installed on most distros. In a terminal window type python to see if something happens. Also please provide what distro you are running. Danyelle On 6/25/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I have problem with installing Python on the Linux platform.Can you tell me step by step how can I install python on linux ( please detailed ) , because I don't know anything about linux and I really don't understand python documentation about installing python on linux. Thanks!!! -- http://mail.python.org/mailman/listinfo/python-list Helo, Probably my distro is ubuntu --- I don't what is it, and ' want install/build python from source -- http://mail.python.org/mailman/listinfo/python-list