Re: Emacs vs. Eclipse vs. Vim
On Sat, 29 Nov 2008 12:44:14 -0800, Josh wrote: > If you were a beginning programmer and willing to make an investment in > steep learning curve for best returns down the road, which would you pick? > Honestly, I would invest my time and energy in someting more significant than editor skills. In twenty+ years of programming I have used all three environments and many others, and I never found them critically important for my job. Sure a good editor and/or IDE can make your life easier. And a bad one can make you suffer - but then you just switch ... But at the end of the day they are just tools, and IMO not the most important ones in the toolchain that you have to use to do your job. Ciao --- FB -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyhon (with wxPython) on Windows' cygwin: can it be done fully ?
On Nov 29, 3:31 pm, Lie <[EMAIL PROTECTED]> wrote: > Python's learning > curve shouldn't raise with time, it should get lower so more people > can join in the board. print function should give a newbie less to learn than a print statement, since statements have their own syntax (and the print statement had lots of peculiarities), whereas all function calls follow the same syntax. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: end of print = lower productivity ?
On Sat, 2008-11-29 at 17:51 -0600, Tim Chase wrote: > >> It's not so much "ridiculous" as a failure of your editor to > >> assist you. In Vim (my editor-of-choice), I'd do something > >> like > > > > seriously, I don't think anyone in Windows uses vim > > Are you just guessing, or do you have any sort of facts to > back this up? It's my editor of choice when I'm stuck in > Windows, and as a long-time member of the vim mailing list, > there's a pretty even split between platforms. Vim (and > similarly Emacs) has the additional benefits that I have the > same environment no matter what platform I'm on, and it's > usable over a ssh connection. I know vim is available in windows, but I know nobody but those that comes from unix-like world that use vim instead of Notepad, Notepad2, Notepad++, NoteTab, Programmer's Notepad, and multitude other Windows text editors/Notepad replacement. For a proof, let's see what Google has to say about this: "Windows text editor". Vim is on page 3, near the turning point where nobody is talking about text-editor anymore and more about text-editor reviews. Even worse is Emacs, on page 6, after many other popular text-editors have been mentioned several times. > > Since when is python becoming exclusive community for > > Linux/Unix-like/Cygwin users that Windows users who have > > nothing but Notepad is put aside. > > Never has been, nor will be. Python only requires a text > editor. If typing a few extra parens for "print"ing is the > worst of your efficiency concerns in Notepad, you need to go > out and see what productivity-enhancing features other > text-editors offer. On Win32, you *can* write Python code > using Notepad, Wordpad, edit.exe or edlin.exe all from a > virgin install. However, you can use *any* text-editor you > want, whether vim, emacs, Eclipse, WingIDE, Komodo, or any > of a multitude of others. If you develop on/for multiple > platforms, it helps to choose a cross-platform editor. I > wouldn't consider *any* of the stock Win32 editors even > remotely capable of long-term functionality (regardless of > py2.6 vs py3k), so downloading another editor is almost a > given -- whether that's vim, emacs, Eclipse, or whatever. I live amongst many Windows users and I was a Windows user (note the past tense). In the Windows world, when the operating system ships with a half-decent program, the way most people would go is to live with it (which is why everyone uses IE6 instead of installing a multitude of better alternative browsers). IDLE is installed with default Windows python installation because practically nobody cares to search for better text editors (IDLE is not perfect, but it is much better than Notepad). > > I, for instance, hates when my text editors tries to be > > smarter than me. > [snip] > >> Net gain: 5 characters in old-Python and 6 characters in > >> new-Python ;-) > > > > Is that supposed to be a joke? > > Keystroke golf is no more a joke than your obstinate > insistence against "smart editors" (i.e. "editors you can > configure to behave the way you want and make your life > easier"). I have nothing against smart editors, as long as it doesn't outsmart me. I like syntax editing, since it gives visual cues to things. But I hate autocompletion, since it takes control out of me. I much prefer it highlights the unclosed pair[1], and let me fix it myself. I like (though never missed) the so-called IntelliSense or omnicompletion since it only gives suggestions, instead of outsmarting me to complete what I'm typing without my permission. I like Firefox's default autocompletion which gives list of urls in a dropdown box, instead of replacing what I'm writing for the same reason. [1] but not popping error message like Visual Basic 6 Unix philosophy: Worse is better. Small is beautiful. KISS -- Keep It Simple and Stupid. Python's Zen: Simple is better than complex. Complex is better than complicated. And "less is more". ;) > Unless mandated by your job, use what makes you most > productive -- whether that's the programming language, the > version of the programming language, the operating system, > office furniture, music selection, or your text-editor/IDE. > > So when the language gives you newfound powers (ability to > redefine "print") at the cost of something a good editor > will readily expropriate, if you have problems, it's a > failure of your editor, not the language. I don't hate print-as-function, but when someone hates smart-ass editors as much as me coupled with their hate of print-function's use of more shift-key, they'll hate print-as-function with a reason and no possible fix. I am explaining their viewpoints. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any project whose patches are all available?
On Nov 28, 1:57 pm, ZelluX <[EMAIL PROTECTED]> wrote: > Hi, all > > I want to write a version-tracking tool for Python projects, and need > some sample projects whose even smallest modifications can be > downloaded from the internet. > > Could you recommend some to me? > Thanks for your reply When the project matures, why not have the project itself hosted on the version tracking tool? -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any library that can convert RGB colors to ANSI colors?
On Nov 30, 4:39 pm, ZelluX <[EMAIL PROTECTED]> wrote: > Convert RGB colors to the closest ANSI colors. For example, given RGB > color FF, it should print [31m. Maybe ... but you could write it yourself quickly enough; the code is a trivial loop over a list of the RGB values of the 8 possible colours, and would fit easily on a 24x80 terminal :-) Why don't you have a try at it and come back if you have any problems? Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
a regual expression problem
I have a url of image, and I want to get the filename and extension of the image. How to write in python? for example, the url is http://a.b.com/aaa.jpg?version=1.1 how can I get aaa and jpg by python? -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Nov 28, 12:28 pm, r <[EMAIL PROTECTED]> wrote: > To think...that I would preach freedom to the slaves and be lynched > for it...IS MADNESS! > > Not one vote for Python, not a care. I think everyone here should look > deep within their self and realize the damage that has been done > today! I hope Guido's eyes never see this thread, for he may lose all > hope in humanity. He only spent the last 18 years of his life pursuing > this thing called Python. Maybe 1,2,3, years from now someone will see > this thread and post a vote for Python. Maybe as simple as "I will > fight for Python" , "I am not scared to go up against the status quo". > For that day will be a glorious day. That day shall be Python Day! > I will never give UP! +1 for python to be used more +1 for python to be used as scripting language on another app +1 for python to be used as scripting langauge on a Google program +1 for python to be used as scripting language on Sketchup -4 for any sort of fanboyism -- http://mail.python.org/mailman/listinfo/python-list
Re: Exhaustive Unit Testing
Steven D'Aprano schreef: [..] Thank you for elaborate answer, Steven. I think I'm really starting to get it now. -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
On Nov 28, 1:52 pm, [EMAIL PROTECTED] wrote: > On Nov 27, 10:28 pm, r <[EMAIL PROTECTED]> wrote: > > > To think...that I would preach freedom to the slaves and be lynched > > for it...IS MADNESS! > > > Not one vote for Python, not a care. I think everyone here should look > > deep within their self and realize the damage that has been done > > today! I hope Guido's eyes never see this thread, for he may lose all > > hope in humanity. He only spent the last 18 years of his life pursuing > > this thing called Python. Maybe 1,2,3, years from now someone will see > > this thread and post a vote for Python. Maybe as simple as "I will > > fight for Python" , "I am not scared to go up against the status quo". > > For that day will be a glorious day. That day shall be Python Day! > > I will never give UP! > > r, i am with you! i will back Python!!! we MUST spread > Python throughout the world! sketchup is the first step, > only the first step. First step? Really? AFAIK, Python is already used in: OpenOffice.Org, Blender, GIMP, Inkscape, Scribus, etc. I've never used these tools, but I heard they also have python interface: AbiWord, Gnumeric. Definitely not first step. > it is really sad that the so-called > Python supporters on this list don't really care about > Python -- only money, and depravity. you and i and the > other few, pure of heart, must fight for Python!! > death to infidel ruby lovers!!! > long live Guido! > i pledge my life to Python and Guido!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
On Nov 29, 8:44 pm, Josh <[EMAIL PROTECTED]> wrote: > If you were a beginning programmer and willing to make an investment in > steep learning curve for best returns down the road, which would you pick? Personally I'd choose Vim for the following reasons: 1) Vim is ubiquitous on Linux/Unix servers. If you learn Vim you will be able to edit files on a server without doing the "FTP to local machine/edit locally/upload back by ftp" dance I see so many developers and even sys admins doing... 2) Vim is a proper editor. Eclipse is an IDE. They are really incomparable. I personally hate working in Eclipse, but the IDE features make it the obvious choice for Java development. I prefer Vim for Python development. I also have Vim set up as an external editor in Eclipse, so any repetitive or difficult editing in Eclipse is done in Vim. 3) Vim makes it simple to cut log files down to size. The g command is a godsend for this. :g/DEBUG/d will for example remove all debug lines from the file. :g!/My message/d will delete all lines other than lines containing "My message", and :g/./norm dt- will delete everything up until the first '-' (normal mode, delete 'till '-'). Combine these and you'll have the info you want, formatted in the way you want it very quickly. 4) Vim can be scripted in Python, and has a host of useful plugins. 5) Vim has close interaction with the command line (though no built-in console like emacs). Finished editing a file? type :!svn commit -m "Done fixing this" % and the current file (%) is committed into subversion. :%!sort will filter the current buffer through an external sort program, and change the buffer to the result. Now emacs will also satisfy points 2-5 (not sure how easy 3 is, but I'm certain it's comparable). In fact emacs will initially have a lower learning curve, since it its not modal, and so wihout learning any keystrokes, you can use it just like a basic editor and gradually learn the commands. (1) for me is a compelling reason to use vim all other things being equal. Also, if you touch type, or aspire to, then Vim makes more sense than emacs, since almost everything can be done from the main keys, rather than emacs CTL-ALT-SHIFT x u type key contortions... Certainly don't bother with Eclipse unless your starting as a Java programmer (and even then learn vim as well) - it is very good at inserting boilerplate code for you, but as an editor offers little more than Windows Notepad... I personally use Gvim for a great deal of my work, from those taskd -- http://mail.python.org/mailman/listinfo/python-list
Re: Python surpasses Perl in popularity?
2008-11-30, 06:11(+00), Tam Ha: > Stephane CHAZELAS wrote: >> There's a common confusion in this in the nature of /bin/sh. >> There's no standard (neither POSIX nor Unix) that specifies that >> /bin/sh should be any variant of the Bourne shell. > > Sure there is, POSIX. Or rather their Austin Group. And while they done > an extremely poor job of it the POSIX shell is still the Bourne shell, > /bin/sh as it's always been known, with a few enhancements such as tilde > expansion and such. No, saying that /bin/sh is the Bourne shell is as wrong as saying /bin/csh the Thomson shell. It's at best a very inaccurate approximation but it's true it's a very commonly made mistake. All you can say is that "sh" is meant to be a POSIX compliant shell (which the Bourne shell is not) or that /bin/sh (nowadays) is a Bourne-like shell. If you want to write a shell script for the /bin/sh of any modern Unix, you have to write it in the language that is the intersection of that of the Bourne shell and the POSIX shell syntax. As I said, the POSIX shell specification is based on a subset of ksh88, has incompatibilities with the Bourne shell. The Bourne shell, as can still be found on some systems either in some non-standard place (/bin on Solaris, /usr/old/bin on HPUX) or named differently (see http://www.in-ulm.de/~mascheck/various/shells/ for more details) is not conforming to that standard. On most commercial Unices, the "sh" utility is implemented by one version of the other of ksh88 (possibly slightly modified). That's the case at least of Solaris (where it is in /usr/xpg4/bin/sh, and you can see that /usr/xpg4/bin is before /bin in the output of "getconf PATH"), HPUX since at least 10.10, AIX since at least 4.3.2, IRIX... See on Tru64 http://nixdoc.net/man-pages/Tru64/sh.1.html: sh(1)> [Tru64 UNIX] Subsequent shells spawned from the initial sh(1)> shell depend on the value in the environment variable sh(1)> BIN_SH. If this variable is set to xpg4, the POSIX shell sh(1)> is started. If this variable is set to svr4, an SVR4 sh(1)> compliant version of the shell is started. If this sh(1)> variable is unset, the Bourne shell is started. If this sh(1)> variable is set to any other value, an error is sh(1)> reported and the results are unpredictable. See the sh(1)> EXAMPLES section for information on setting this sh(1)> variable. The POSIX one being ksh. On Linux and all the GNU OSes, it's generally bash. On BSDs, it initially was the Almquist shell, a public domain rewriting of the System V shell (the Bourne shell) with a few modifications, and nowadays FreeBSD and NetBSD have adapted that ash so as to become POSIX compliant, and OpenBSD is using pdksh. MacOS/X has been using zsh and now bash >> Over the years and on the different flavours of Unix, /bin/sh >> has been a Thomson shell, Mashey shell, Bourne shell and all its >> variants, Almquist shell, bash, ksh, zsh... > > Zsh? Seriously? Where? Some versions of MacOSX/Darwin. > used various poorly designed "compatiblity mode" hacks to circumvent > Bourne/POSIX regardless of compatibility consequences does not change > the fact that /bin/sh is still there in all distributions, is still the > cross-platform compatibility winner by a county mile, and can still be > relied on for shell scripts. Could you please clarify what you mean? Yes, most systems have a /bin/sh (for those that have a /bin directory), but as I said /bin/sh can be any of a Thomson, Mashey (only in museums nowadays), Almquist, Bourne, Korn, bash... Nowadays, they are most likely to be Bourne-like. If you want to write a portable script, today, the best advice to give is to write it in a syntax conforming to POSIX (note that of course that applies to the shell but also to the standard utilities). Then you'll be guaranteed to find a "sh" on any compliant Unix (most at least try to be nowadays) that will interpret it. It is a much better situations than a few decades ago where every vendor had its own variant of the Bourne shell and the utilities. >>should have somewhere (and the location is not specified but on >>most Unices except those quoted above is generally /bin) a >>command called "sh" that is an interpreter of the POSIX shell >>language it defines. > > Right, that's /bin/sh. Not always. As I said, on a few systems, the POSIX sh is not in /bin. That's the case of at least Solaris, where /bin/sh is a Bourne shell and therefore not a POSIX compliant sh. > It's common name is the Bourne shell even though > it is not the code that Mr Bourne wrote years ago, and even though > GNU/POSIX and ATT/David Korn want to remake it into a "POSIX shell" > regardless of the compatibility consequences. Saying that would be denying the reality. >>That shell language is based on a subset of the ksh88 language >>and the Bourne shell is not a conformant implementation. > > Only if you limit your use of the term "Bourne shell" to something > that the rest of us don't recognize as a Bourne s
Re: a regual expression problem
lookon <[EMAIL PROTECTED]> writes: > I have a url of image, and I want to get the filename and extension of > the image. How to write in python? > > for example, the url is http://a.b.com/aaa.jpg?version=1.1 > > how can I get aaa and jpg by python? Without res: >>> url=" http://a.b.com/aaa.jpg?version=1.1"; >>> url.rsplit('/', 1)[1].split('?')[0].split('.') ['aaa', 'jpg'] -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any library that can convert RGB colors to ANSI colors?
On Nov 30, 8:04 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Nov 30, 4:39 pm, ZelluX <[EMAIL PROTECTED]> wrote: > > > Convert RGB colors to the closest ANSI colors. For example, given RGB > > color FF, it should print [31m. > > Maybe ... but you could write it yourself quickly enough; the code is > a trivial loop over a list of the RGB values of the 8 possible > colours, and would fit easily on a 24x80 terminal :-) Why don't you > have a try at it and come back if you have any problems? > Ummm actually once you have got your rgb value as an integer (or a tuple of 3 integers) -- in the example, 0xff or (0xff, 0, 0) -- the answer can be obtained in one line with operations no more complicated than shifting, masking, and addition. -- http://mail.python.org/mailman/listinfo/python-list
Re: a regual expression problem
Arnaud Delobelle <[EMAIL PROTECTED]> writes: > lookon <[EMAIL PROTECTED]> writes: > >> I have a url of image, and I want to get the filename and extension of >> the image. How to write in python? >> >> for example, the url is http://a.b.com/aaa.jpg?version=1.1 >> >> how can I get aaa and jpg by python? > > Without res: > url=" http://a.b.com/aaa.jpg?version=1.1"; url.rsplit('/', 1)[1].split('?')[0].split('.') > ['aaa', 'jpg'] I forgot and re solution! >>> m=re.search(r'[^/?]*(?=\?|$)', url) >>> m.group() 'aaa.jpg' Use split('.') as above if you want name and extension separately. You could also use something like this: >>> url[url.rindex('/')+1:url.index('?')] But it won't work so easily if there is no '?' in the string. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
There is, as other people have pointed out, no "correct" answer to this question, other that "use a few different editors, and settle on what you like". I personally use emacs. In fact, I use emacs for a lot more than just editing code. The reason I found myself really liking emacs was because I'm the type of person who likes to be able to really customize whatever I'm using to my tastes - emacs is _meant_ to be customized, and although the learning curve is steep (especially if you have no previous exposure to lisps), it is possible to be tearing emacs apart to fit your tastes within a few weeks to a month of using it. If you're the same type of person, you'll probably enjoy emacs. I do advocate learning a powerful text editor, because the reward for spending a lot of time learning one is very great. The only editors I'm aware of that stand out from the crowd as being more powerful than the mass of other editors are emacs and vim - but then again, I don't have much experience with newer editors (for instance, Eclipse is a lot more extensible than I previously thought that it was). A word of warning is in order though - if you _do_ decide to spend the time learning a powerful text editor off the bat in your journey as a programmer, prepare to be _extremely_ frustrated for a while. It may be more prudent to stick with editors that have an interface that you're used to (but support syntax highlighting, auto-indentation, etc) than to jump into the unknown. A little bit of programming experience can make understanding editors like vim and emacs a lot easier than otherwise. -- http://mail.python.org/mailman/listinfo/python-list
Re: a regual expression problem
On Nov 30, 9:10 am, lookon <[EMAIL PROTECTED]> wrote: > I have a url of image, and I want to get the filename and extension of > the image. How to write in python? > > for example, the url ishttp://a.b.com/aaa.jpg?version=1.1 > > how can I get aaa and jpg by python? Something like... >>> from urlparse import urlsplit >>> from os.path import splitext >>> splitext(urlsplit('http://a.b.com/aaa.jpg?version=1.1').path[1:]) ('aaa', '.jpg') ...and then it should be fairly flexible instead of having to change splitting etc.. hth Jon. -- http://mail.python.org/mailman/listinfo/python-list
Unofficial Phone, , the most cheap mobile phones from china , 30 kinds today
Unofficial Phone, ,the most cheap mobile phones from china ,30 kinds today http://www.unofficialphone.cn/2008/11/android-phone-cottage-sciphone-dream-g2.html http://www.unofficialphone.cn/2008/11/unofficial-phone.html http://www.unofficialphone.cn/2008/11/amanilan.html http://www.unofficialphone.cn/2008/11/6191-pairs-of-mastercard-networks.html http://www.unofficialphone.cn/2008/11/absolute-all-round-champion-sanq-g28.html http://www.unofficialphone.cn/2008/11/taiwan-friends-of-walled-g-plus-ct680.html http://www.unofficialphone.cn/2008/11/hong-tianlei-zhensi-zh989-bone-nerve.html http://www.unofficialphone.cn/2008/11/1g-ram-gps-telsda-811-smartphone-new.html for more http://www.unofficialphone.cn -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycon 2009
On Sat, Nov 29, 2008 at 1:59 AM, r <[EMAIL PROTECTED]> wrote: > do you have any suggestions where? I am not as versed as you in Usenet. > -- > http://mail.python.org/mailman/listinfo/python-list > Try comp.lang.lisp -- http://mail.python.org/mailman/listinfo/python-list
Re: Python surpasses Perl in popularity?
2008-11-30, 06:11(+00), Tam Ha: > Stephane CHAZELAS wrote: >> There's a common confusion in this in the nature of /bin/sh. >> There's no standard (neither POSIX nor Unix) that specifies that >> /bin/sh should be any variant of the Bourne shell. > > Sure there is, POSIX. [...] And on this. First, POSIX has no juridiction on defining the Bourne shell, let alone its location as the Bourne shell is completely outside POSIX, it's a legacy shell and as been for years. Then, POSIX makes it clear that the location of its sh utility (again, which the Bourne shell is not) is unspecified, only that the lookup of "sh" via $PATH in a conformant environment should resolve to a conformant "sh". And if you need some examples to be convinced, see the different choices of those 4 different POSIX conformant Unices: Solaris (7, 8, 9 at least): /bin/sh: legacy Bourne/SVr4 shell /usr/xpg4/bin/sh: a POSIX compliant shell (actually ksh88) Solaris choice was to keep /bin/sh as the Bourne shell for backward compatibility (as changing it for a POSIX shell introduces a slight chance of breaking some existing scripts as there are a few corner-case areas where the POSIX shells are not backward compatible with the Bourne shell), and make /bin a non standard place. How to get a conformant environment (typically one where /usr/xpg4/bin/sh is before /bin) is described in standards(5). The default one is not, which makes Solaris a pain when porting scripts. HPUX (10.10 and newer at least): /usr/bin/sh (and /bin/sh if there's a symlink /bin -> usr/bin): a POSIX compliant shell (based on ksh88) /usr/old/bin/sh: the Bourne shell (though I think nowadays, it's part of an optional package). Tru64: /bin/sh can behave either as a Bourne shell or a POSIX shell (ksh88) depending on the environment most Linux based systems and most other Unices: /bin/sh is a POSIX compliant shell (bash generally for Linux) and there's no Bourne shell (either there has never been or it has been removed/replaced by a POSIX shell). -- Stéphane -- http://mail.python.org/mailman/listinfo/python-list
How to distribute a Python app together with its dependencies?
Hi, I have to distribute a Python application which relies on an external library, and I'm not very fluent in this kind of stuff with Python (I come from the Java world where I would have used the Maven build tool to create an "assembly with dependencies" of all it is needed to run the app), so I was wondering if someone here could give me some suggestions :-) The external library is generally not present on the machines where I have to distribute my app, and the set of machines on which I have to distribute this application is not known a priori (it is just known they are Unix systems). In fact by means of SSH I will have to copy (and install) the app+library and make it runnable onto the specified destination(s). My question is: how would you do that? At the moment my current solution is to make a tarball of the sources of my app + the "distutils" archive of the external library, copy all into the target machine, decompress and install via distutils(*) the external library, setup some PYTHONPATH stuff on the destination machine, and finally be able to launch the application. (*) specifying a prefix into the user home, as I'm not root there So in the end I was wondering if there is a more elegant way of doing this because, as I said before, I'm not very experienced in these kind of tasks in Python. Thanks in advance for any suggestion or comment. Alessio Pace. -- http://mail.python.org/mailman/listinfo/python-list
Re: a regual expression problem
In article <[EMAIL PROTECTED]>, lookon <[EMAIL PROTECTED]> wrote: > I have a url of image, and I want to get the filename and extension of > the image. How to write in python? > > for example, the url is http://a.b.com/aaa.jpg?version=1.1 > > how can I get aaa and jpg by python? Despite the subject line, this is *not* a regex problem. The right tool is Python's built-in urlparse module, which understands the full syntax of urls. Trying to roll your own from scratch using split() or regex is the wrong solution. -- http://mail.python.org/mailman/listinfo/python-list
Re: Exhaustive Unit Testing
On 27 Nov, 16:32, "Emanuele D'Arrigo" <[EMAIL PROTECTED]> wrote: > On Nov 27, 5:00 am, Steven D'Aprano > > <[EMAIL PROTECTED]> wrote: > > Refactor until your code is simple enough to unit-test effectively, then > > unit-test effectively. > > Ok, I've taken this wise suggestion on board and of course I found > immediately ways to improve the method. -However- this generates > another issue. I can fragment the code of the original method into one > public method and a few private support methods. But this doesn't > reduce the complexity of the testing because the number and complexity > of the possible path stays more or less the same. The solution to this > would be to test the individual methods separately, but is the only > way to test private methods in python to make them (temporarily) non > private? I guess ultimately this would only require the removal of the > appropriate double-underscores followed by method testing and then > adding the double-underscores back in place. There is no "cleaner" > way, is there? Difficult to say without seeing the code. You could post it, perhaps. On the other hand a general recommendation from Programming Pearls (Jon Bentley) is to convert code to data structures. Maybe you could convert some of the code to decision tables or similar. James -- http://mail.python.org/mailman/listinfo/python-list
Project structure - Best practices
This is first time that I am building python application that is larger than a single module and I would like to do it right. I google it a bit, finding some stuff about not using src directory (which I have seen so many times, that I believed it be standard) and using packages. Still, there are few things, that I would like to achieve with this structure: * being able to use pychecker a lot - catching all typos in one shot instead of running app many times really saves me a lot of time * being able to write some unit tests * having clean division of code among packages and modules (I have seen some projects, where modules are pretty large - I would like to keep them logically divided, event if they stay smaller) My project is a tool for people interested in role playing games. My current structure looks something like this: /src rpgDirectory.py (main script, running the app) src/rpg plans.py support.py gui.py iosystem.py src/rpg/character model.py sheet.py gui.py handlers.py requirements.py The problem is, that modules from src/rpg/character use classes defined in support.py. Therefore I have to use absolute paths to import it and this works only, when I run rpgDirectory.py. When I use pychecker, it can't import this module and fails. Any suggestions, how can I avoid this and what structure should I use? -- Filip Gruszczyński -- http://mail.python.org/mailman/listinfo/python-list
Re: Project structure - Best practices
On Sun, 30 Nov 2008 17:43:46 +0100, Filip Gruszczyński <[EMAIL PROTECTED]> wrote: This is first time that I am building python application that is larger than a single module and I would like to do it right. I google it a bit, finding some stuff about not using src directory (which I have seen so many times, that I believed it be standard) and using packages. Still, there are few things, that I would like to achieve with this structure: * being able to use pychecker a lot - catching all typos in one shot instead of running app many times really saves me a lot of time * being able to write some unit tests * having clean division of code among packages and modules (I have seen some projects, where modules are pretty large - I would like to keep them logically divided, event if they stay smaller) My project is a tool for people interested in role playing games. My current structure looks something like this: /src rpgDirectory.py (main script, running the app) src/rpg plans.py support.py gui.py iosystem.py src/rpg/character model.py sheet.py gui.py handlers.py requirements.py The problem is, that modules from src/rpg/character use classes defined in support.py. Therefore I have to use absolute paths to import it and this works only, when I run rpgDirectory.py. When I use pychecker, it can't import this module and fails. Any suggestions, how can I avoid this and what structure should I use? http://jcalderone.livejournal.com/39794.html Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
The "first step" simply meant..."within this movement"...Not that there exist no "other" Python API's. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with capturing error
Yes, you are absolutely right. I had open a file earlier and when it reach end of line with no new idea; it seems to have closed the file. I am not sure if this because I am using my own class to open and read a file or just a python behavior. I plan to test this out. On another note, is there a way for python to emulate a "tail -f" in Linux? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Project structure - Best practices
> http://jcalderone.livejournal.com/39794.html That's exactly what I have read before posting here ;-) -- Filip Gruszczyński -- http://mail.python.org/mailman/listinfo/python-list
Re: hello from colombia
2008/11/27 fel <[EMAIL PROTECTED]>: > that's a lot of bytes for "do your own homework" > but thanks, I'll do it. It also included "You haven't defined the issue precisely enough" :-) -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list
noob needs help
I decided that I want to learn python, and have no previous programming experience. I was reading the guide A byte of python and got to the part where you create and run the program helloworld.py I used kate to create this program and save it as helloworld.py. I then entered the command python helloworld.py into the terminal(I am using ubuntu 8.10) and I get this error: [EMAIL PROTECTED]:~$ python helloworld.py python: can't open file 'helloworld.py': [Errno 2] No such file or directory Am I saving the file in the wrong spot?(I saved it in documents) Should I use a different editor? Is there a better python book available online? -- http://mail.python.org/mailman/listinfo/python-list
Re: noob needs help
What i would use is emacs is better i think. On Sun, Nov 30, 2008 at 11:50 AM, toveysnake <[EMAIL PROTECTED]> wrote: > I decided that I want to learn python, and have no previous > programming experience. I was reading the guide A byte of python and > got to the part where you create and run the program helloworld.py I > used kate to create this program and save it as helloworld.py. I then > entered the command python helloworld.py into the terminal(I am using > ubuntu 8.10) and I get this error: > > [EMAIL PROTECTED]:~$ python helloworld.py > python: can't open file 'helloworld.py': [Errno 2] No such file or > directory > > Am I saving the file in the wrong spot?(I saved it in documents) > Should I use a different editor? Is there a better python book > available online? > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: noob needs help
Try "python documents/helloworld.py" or "cd documents" before "python helloworld.py". Kevin On Sun, Nov 30, 2008 at 11:50 AM, toveysnake <[EMAIL PROTECTED]> wrote: > I decided that I want to learn python, and have no previous > programming experience. I was reading the guide A byte of python and > got to the part where you create and run the program helloworld.py I > used kate to create this program and save it as helloworld.py. I then > entered the command python helloworld.py into the terminal(I am using > ubuntu 8.10) and I get this error: > > [EMAIL PROTECTED]:~$ python helloworld.py > python: can't open file 'helloworld.py': [Errno 2] No such file or > directory > > Am I saving the file in the wrong spot?(I saved it in documents) > Should I use a different editor? Is there a better python book > available online? > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode and hashlib
Jeff H wrote: ... > decode vs encode You decode from on character set to a unicode object You encode from a unicode object to a specifed character set Pretty close: encode: Think of characters a "conceptual" -- you encode a character string into a bunch of bytes (unicode -> bytes) in order to send the characters along a wire, into an e-mail, or put in a database. decode: You got the bytes from the wire, database, Morse code, whatever. You decode the byte stream into characters, and now you really have characters. Thinking of it this way makes it clear which name is which, unless (as I did once in this thread) you switch opposite concepts carelessly. Characters are content (understood by humans), bytes are gibberish carried by hardware which likes that kid of thing. You encode a message into nonsense for your carrier to carry to your recipient, and the recipient decodes the nonsense back into the message. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: segfault calling SSE enabled library from ctypes
I found an even simpler solution: use the -mstackrealign GCC option to build the shared library. -- Olivier -- http://mail.python.org/mailman/listinfo/python-list
Re: noob needs help
On Sun, 30 Nov 2008 09:50:32 -0800 (PST), toveysnake wrote: [snip] > I used kate to create this program and save it as > helloworld.py. I then entered the command python > helloworld.py into the terminal(I am using ubuntu 8.10) > and I get this error: > > [EMAIL PROTECTED]:~$ python helloworld.py > python: can't open file 'helloworld.py': [Errno 2] No such file or > directory > > Am I saving the file in the wrong spot?(I saved it in documents) > Should I use a different editor? Is there a better python book > available online? When you type "python helloworld.py", python looks for helloworld.py in the current "working" directory, which is probably your personal default directory ("~"). For better results, either save helloworld.py to this directory, or copy it to this directory ("cp Documents/helloworld.py ."), or tell python to look for it in the Documents directory ("python Documents/helloworld.py"). (I'm guessing that your directory structure looks something like /home/collin/Documents. If I've guessed wrong, some adjustment may be needed. Also, if you're feeling ambitious, you might want to consider putting this project in a directory of its own; that would involve the mkdir and cd commands.) -- To email me, substitute nowhere->spamcop, invalid->net. -- http://mail.python.org/mailman/listinfo/python-list
RE multiline
Hi, I try to figure out what gonna be the equivalent of : (.*?) For the same purpose on multiline basis. I would like completed the variable part of elements that I searching for. Example : align="center"> Is the begining of the variable element that I wanna completed... Is the end of the element, so, I would like to completed what between those two patterns. pattern1+r"(.*?)"+pattern2 Was working ok for a single line selection like : align="center">"variable element of the search" I hoped that I have been clear. Thanks Guy -- http://mail.python.org/mailman/listinfo/python-list
Re: RE multiline
Guy Doune schrieb: Hi, I try to figure out what gonna be the equivalent of : (.*?) For the same purpose on multiline basis. I would like completed the variable part of elements that I searching for. Example : align="center"> Is the begining of the variable element that I wanna completed... Is the end of the element, so, I would like to completed what between those two patterns. pattern1+r"(.*?)"+pattern2 Was working ok for a single line selection like : align="center">"variable element of the search" I hoped that I have been clear. See the flags of module re - especially re.DOTALL. However, you just experience that regular expresions aren't the proper tool for the job of dealing with HTML/XML. What would you do if for example a table was nested inside another? Instead, use tools like BeautifulSoup or lxml which provide error-tolerant HTML-parsers and expression/filter-based element extraction. That's much better suited for your task. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: noob needs help
On Sun, Nov 30, 2008 at 1:00 PM, packet <[EMAIL PROTECTED]>wrote: > What i would use is emacs is better i think. > Why are you telling a beginning programmer to use emacs? It takes more time to learn to use emacs (or vim) than it does to learn to program python. > > > On Sun, Nov 30, 2008 at 11:50 AM, toveysnake <[EMAIL PROTECTED]>wrote: > >> I decided that I want to learn python, and have no previous >> programming experience. I was reading the guide A byte of python and >> got to the part where you create and run the program helloworld.py I >> used kate to create this program and save it as helloworld.py. I then >> entered the command python helloworld.py into the terminal(I am using >> ubuntu 8.10) and I get this error: >> >> [EMAIL PROTECTED]:~$ python helloworld.py >> python: can't open file 'helloworld.py': [Errno 2] No such file or >> directory >> >> Am I saving the file in the wrong spot?(I saved it in documents) >> Should I use a different editor? Is there a better python book >> available online? >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Project structure - Best practices
On Nov 30, 11:55 am, "Filip Gruszczyński" <[EMAIL PROTECTED]> wrote: > >http://jcalderone.livejournal.com/39794.html > > That's exactly what I have read before posting here ;-) > > -- > Filip Gruszczyński I too would like to see a meatier discussion of best practices for python packagizing. I particularly object to jcalderone's suggestion that all tests should be within the package. Often my test cases are 100 times the size of the code, if you include sample data -- it doesn't make sense to install it, I think. Lately I tend to have something like root/ setup.py README.txt packagename/ main source modules submodules... test/ test code and submodules doc/ scripts/ testdata/ demos/ etcetera... I have no real idea if this is a good way to do it, but it works for me in isolation. I'm completely confused about any implications related to integrated system testing or "easyinstall"... Wise, pragmatic advice would be appreciated. (But if we could avoid the "buzzillion directories" approach prevalent in the java alternative universe, that would be nice.) -- Aaron Watters === Now we see the violence inherent in the system! Help! Help! I'm being repressed! -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
> > r, i am with you! i will back Python!!! we MUST spread > > Python throughout the world! sketchup is the first step, > > only the first step. > > First step? Really? AFAIK, Python is already used in: OpenOffice.Org, > Blender, GIMP, Inkscape, Scribus, etc. I've never used these tools, > but I heard they also have python interface: AbiWord, Gnumeric. > > Definitely not first step. On Nov 30, 10:45 am, r <[EMAIL PROTECTED]> wrote: > The "first step" simply meant..."within this movement"...Not that > there exist no "other" Python API's. That's circular: Sketchup is the first step within the Sketchup movement. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python surpasses Perl in popularity?
In comp.unix.shell Stephane CHAZELAS wrote: > The Bourne shell, as can still be found on some systems either in some > non-standard place (/bin on Solaris, /usr/old/bin on HPUX) or named > differently [...] What do you mean with "non-standard place" here? -- http://mail.python.org/mailman/listinfo/python-list
Do more imported objects affect performance
I have following question: if I use from module import * instead from module import Class am I affecting performance of my program? I believe, that all those names must be stored somewhere, when they are imported and then browsed when one of them is called. So am I putting a lot of "garbage" to this storage and make those searches longer? -- Filip Gruszczyński -- http://mail.python.org/mailman/listinfo/python-list
pydoc enforcement.
I've been thinking about implementing (although no idea yet *HOW*) the following features/extension for the python compile stage and would be interested in any thoughts/comments/flames etc. Basically I'm interested adding a check to see if: 1) pydoc's are written for every function/method. 2) There are entries for each parameter, defined by some predetermined syntax. My idea is that as much as I love dynamic typing, there are times when using some modules/API's that have less than stellar documentation. I was thinking that if it was possible to enable some switch that basically forced compilation to fail if certain documentation criteria weren't met. Yes, it should be up to developers to provide documentation in the first place. Or, the client developer might need to read the source (IF its available)... but having some "forced" documentation might at least ease the problem a little. For example (half borrowing from Javadoc). class Foo( object ): def bar( self, ui ): pass Would fail, since the bar method has an "unknown" parameter called "ui". What I think could be interesting is that the compiler forces some documentation such as: class Foo( object ): def bar( self, ui ): """ @Param: ui : blah blah blah. """ pass The compiler could check for @Param matching each parameter passed to the method/function. Sure, a lot of people might just not put a description in, so we'd be no better off. But at least its getting them *that* far, maybe it would encourage them to actually fill in details. Now ofcourse, in statically typed language, they might have the description as "Instance of UIClass" or something like that. For Python, maybe just a description of "Instance of abstract class UI" or "List of Dictionaries"... or whatever. Sure, precise class names mightn't be mentioned (since we mightn't know what is being used then), but having *some* description would certainly be helpful (I feel). Even if no-one else is interested in this feature, I think it could help my own development (and would be an interested "first change" into Python itself). Apart from bagging the idea, does anyone have a suggestion on where in the Python source I would start for implementing such an idea? Thanks Ken -- http://mail.python.org/mailman/listinfo/python-list
Re: Project structure - Best practices
Aaron Watters wrote: On Nov 30, 11:55 am, "Filip Gruszczyński" <[EMAIL PROTECTED]> wrote: http://jcalderone.livejournal.com/39794.html That's exactly what I have read before posting here ;-) -- Filip Gruszczyński I too would like to see a meatier discussion of best practices for python packagizing. I particularly object to jcalderone's suggestion that all tests should be within the package. Often my test cases are 100 times the size of the code, if you include sample data -- it doesn't make sense to install it, I think. I agree on that. But I like to add a couple of my thoughts :-) In my opinion the structuring of your project depends very much on what the project is itself. If it is a more a library sort of thing then I tend to keep it as small and simple as possible, with the main objective to be simple to understand when interfacing with it. I usually structure the package like how I think somebody else would expect it to be. When I am doing an application type of code for myself, I usually end up organizing my program the way it is the easiest to maintain, if necessary in this case I would sacrifice small and simple over robustness and maintainability. When I am starting a project which is either a payed contract job or I anticipate other participants, I orientate my project more around documentation and management, I have written an article in the past about that (generally written it was still more aimed to the client I was working at that moment). If anybody is interested you can get it here: http://dcuktec.googlecode.com/svn/trunk/documentation/best_practises/DITDD/deliverables/DITDD.pdf ymmv -- http://mail.python.org/mailman/listinfo/python-list
Google App Engine Code Challenge - write a tetris playing algorithm
Hi all, Here's my attempt to learn App Engine / python. It's a tetris code challenge, you write a tetris playing algorithm, and the app challenges your algorithm. You can write the algorithm in anything that can do cgi: php, asp.net, jsp, etc. I've provided a sample client that you can easily host on App Engine. Check it out here: http://tetrisapp.appspot.com/ - it will default to my sample algorithm.. You'll need a gmail/google account to log in. Read more on how to write your own algorithm here: http://tetrisapp.appspot.com/static/howto.html Its a bit rough at the moment.. If you struggle with any of the details let me know - i really need to get the documentation a bit more readable. I've got more features to add, depending on how popular it is.. Cheers, Russ -- http://mail.python.org/mailman/listinfo/python-list
Re: pydoc enforcement.
Hey! If you are interested, I have written a small tool for declaring variables and attributes. It's not very sophisticated, because I have written it solely for own use. It might be useful though. You can download it from you: http://code.google.com/p/pyver/downloads/list For a small example, it works like this: def foo(): a = 5 class Bar: def __init__(self): self.a = 5 Errors: Line 2: Variable a in function foo was not specified; Line 7: Field a in function __init__ was not specified; To have it working fine, you have to declare fields and variables like this: def foo(): #| a | a = 5 class Bar: #| a | def __init__(self): self.a = 5 But as soon as I finished I realized, I don't really need this since there are pychecker and pylint that do all what I need and I don't have to type all those declarations. But I have learned how to parse python code using tools from stdlib, so it wasn't really wasted time. Hope this helps :-) If you want to know something more about this, don't hesitate to ask. 2008/12/1 [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > I've been thinking about implementing (although no idea yet *HOW*) the > following features/extension for the python compile stage and would be > interested in any thoughts/comments/flames etc. > > Basically I'm interested adding a check to see if: > 1) pydoc's are written for every function/method. > 2) There are entries for each parameter, defined by some > predetermined syntax. > > My idea is that as much as I love dynamic typing, there are times when > using some modules/API's that have less than stellar documentation. I > was thinking that if it was possible to enable some switch that > basically forced compilation to fail if certain documentation criteria > weren't met. > > Yes, it should be up to developers to provide documentation in the > first place. Or, the client developer might need to read the source > (IF its available)... but having some "forced" documentation might at > least ease the problem a little. > > For example (half borrowing from Javadoc). > > class Foo( object ): > > def bar( self, ui ): > pass > > > Would fail, since the bar method has an "unknown" parameter called > "ui". > What I think could be interesting is that the compiler forces some > documentation such as: > > class Foo( object ): > > def bar( self, ui ): >""" >@Param: ui : blah blah blah. >""" > pass > > > The compiler could check for @Param matching each parameter passed to > the method/function. Sure, a lot of people might just not put a > description in, so we'd be no better off. But at least its getting > them *that* far, maybe it would encourage them to actually fill in > details. > > Now ofcourse, in statically typed language, they might have the > description as "Instance of UIClass" or something like that. For > Python, maybe just a description of "Instance of abstract class UI" or > "List of Dictionaries"... or whatever. Sure, precise class names > mightn't be mentioned (since we mightn't know what is being used > then), but having *some* description would certainly be helpful (I > feel). > > Even if no-one else is interested in this feature, I think it could > help my own development (and would be an interested "first change" > into Python itself). > > Apart from bagging the idea, does anyone have a suggestion on where in > the Python source I would start for implementing such an idea? > > Thanks > > Ken > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Filip Gruszczyński -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
Aaron Brady wrote: > That's circular: Sketchup is the first step within the Sketchup > movement. Dear God...I have entered the twilight zone! This is the Python movement(comp.lang.python)? get it? To move you must first take a step. Lest you never move. "I" am the BDFL of the SketchUp-Python integration, So "I" will name the movement. Unless Guido trumps me ;). step 1. get Python into SketchUp step 2. make stupidity painful step 3. ... PS At least you kept it short and sweet this time. =D -- http://mail.python.org/mailman/listinfo/python-list
Re: Do more imported objects affect performance
Filip Gruszczyński wrote: I have following question: if I use from module import * instead from module import Class am I affecting performance of my program? I believe, that all those names must be stored somewhere, when they are imported and then browsed when one of them is called. So am I putting a lot of "garbage" to this storage and make those searches longer? Importing many (or all) names will take longer than importing a few, but you probably won't notice the difference. You'll also be filling the namespace with a lot of unwanted names. Will it affect how long it takes to look up a name? No. -- http://mail.python.org/mailman/listinfo/python-list
Re: end of print = lower productivity ?
Lie Ryan <[EMAIL PROTECTED]> wrote: >On Sat, 2008-11-29 at 17:51 -0600, Tim Chase wrote: >> >> It's not so much "ridiculous" as a failure of your editor to >> >> assist you. In Vim (my editor-of-choice), I'd do something >> >> like >> > >> > seriously, I don't think anyone in Windows uses vim >> >> Are you just guessing, or do you have any sort of facts to >> back this up? > >I know vim is available in windows, but I know nobody but those that >comes from unix-like world that use vim instead of Notepad, Notepad2, >Notepad++, NoteTab, Programmer's Notepad, and multitude other Windows >text editors/Notepad replacement. You are falling into the very common trap of believing that everyone must be exactly like yourself. You are wrong. I don't claim that vim is the most popular Windows editor (I have to believe that Visual Studio is), but the vim community in Windows is strong, active, and well-populated. I suspect this is especially true in the Python world. Many Python devotees spend time in multiple operating systems, where vim and emacs proficiency is essential. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
On Sat, 2008-11-29 at 12:44 -0800, Josh wrote: > If you were a beginning programmer and willing to make an investment in > steep learning curve for best returns down the road, which would you pick? > > I know this topic has been smashed around a bit already, but 'learning > curve' always seems to be an arguement. If you feel that one is easier > or harder than the others to learn feel free to tell, but let's not make > that the deciding factor. Which one will be most empowering down the > road as a development tool? > > Thanks in advance, > > JR > The first real text editor I used was Vim, which I actually started using about a year ago. I've looked at Emacs and it just looks confusing. It has key commands with key modifiers to do simple tasks (such as moving the cursor to the left). I used Eclipse for a while, but for programming in Python it really has no advantage over Vim, so back I went. Vim doesn't really have a steep learning curve, of course I used vimtutor to help me learn it. Anyway, play around with all three, and see which you like best. --Ratfink -- http://mail.python.org/mailman/listinfo/python-list
Re: pydoc enforcement.
I support any idea that supports python. You have my vote friend! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Library to display detail hardware information
On Fri, Nov 28, 2008 at 7:51 AM, Hanny Wibisono <[EMAIL PROTECTED]> wrote: > Is there any python library that display very detailed hardware information > and it must run in linux environtment ? It's not Python, but you could run it using the `subprocess` module from Python: http://ezix.org/project/wiki/HardwareLiSter Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
Clay Hobbs <[EMAIL PROTECTED]> wrote: > The first real text editor I used was Vim, which I actually started > using about a year ago. I've looked at Emacs and it just looks > confusing. I've been using emacs for so many years (um let's see, it's got to be close to 25 years now; first saw it on Columbia's TOPS-20 systems in the early 80's) that my fingers know what they're doing without my even thinking about it. In fact, I used to work with another emacs nut. Every so often, one of use would watch the other do something and ask, "What was that?". Inevitably, neither of us could evoke the keystrokes we had just typed. We would just re-do it, and watch our fingers to see what we typed. It didn't even have to be on a keyboard; we could air-type it, and that was good enough. In any case, the basic logic behind emacs is pretty simple. C-F is forward one character. C-B is back one character. C-N is Next line. C-P is Previous line. The original concept was that changing the control modifier to meta, or shift-meta, or control-x, etc, would do the same basic thing but to increasingly larger units of text (forward one word, forward one sentence, forward one paragraph, and do on). So, you had a bunch of basic operations (cursor movements, deleting, transposing, and so on), and a bunch of orthogonal prefixes to change the scope of what they were operating one. But, the massive, fundamental, difference between emacs and the whole vi family, is that emacs is mode-less. In vi and its descendants, you hop back and forth between "command mode" and "insert mode". That drives me nuts. With emacs, what's on the screen is what's in the file. The other big thing that made emacs superior to vi was the scriptability, and all the add-on packages that gave rise to. I just can't imagine working on C/C++ code without M-X Compile. Likewise for the source control (CVS, SVN, P4, etc) integrations. As time has gone by, however, the choice of lisp as the scripting language has really shown its age. Not many people know lisp these days. I used to be OK with lisp, but these days I remember just enough to do some minor hacking on my .emacs file. I'd have to say that, today, lisp as the scripting language has become a significant barrier to entry for new emacs users. I can see why vim has become popular. (even if it is still saddled by the modal editing model). -- http://mail.python.org/mailman/listinfo/python-list
Re: how to find help/doc files ?
En Sat, 29 Nov 2008 19:30:50 -0200, Stef Mientki <[EMAIL PROTECTED]> escribió: For an IDE, I want to find the installed help files, either in the form of chm or html files. I'm specially interested in the files for: - python - wxpython - vpython but I fact I want link to all installed docs. Is there a general way to find (by code) these docs ? If not, are there standard ways to find the docs for the above programs, or is it pure random where these files are located ? On Windows, Python help files are in the Doc subdirectory: os.path.join(os.path.dirname(sys.executable), 'Doc') On Linux, usually on /usr/doc/python-X.Y or /usr/doc/python-docs-X.Y perhaps. But let the pydoc module do the search for you: import pydoc print pydoc.Helper(None,None).docdir (a missing docdir attribute means that the html help files could not be found) For the other programs consult their documentation (or ask in a specific forum) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Mathematica 7 compares to other languages
Wolfram Research's Mathematica Version 7 has just been released. See: http://www.wolfram.com/products/mathematica/index.html Among it's marketing material, it has a section on how mathematica compares to competitors. http://www.wolfram.com/products/mathematica/analysis/ And on this page, there are sections where Mathematica is compared to programing langs, such as C, C++, Java, and research langs Lisp, ML, ..., and scripting langs Python, Perl, Ruby... See: http://www.wolfram.com/products/mathematica/analysis/content/ProgrammingLanguages.html http://www.wolfram.com/products/mathematica/analysis/content/ResearchLanguages.html http://www.wolfram.com/products/mathematica/analysis/content/ScriptingLanguages.html Note: I'm not affliated with Wolfram Research Inc. Xah ∑ http://xahlee.org/ ☄ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to distribute a Python app together with its dependencies?
If Python for Windows you can use Py2Exe package. It works very well in simple cases and requires a few tweaks to make it recognize some dependencies. -- http://mail.python.org/mailman/listinfo/python-list
Beautiful soup tag attributes - Dictionary?
The documentation says I can find attributes of tags by using it as a dictionary. Ex: product = p.findAll('dd') print product['id'] However, when I try that python thinks I am slicing it. When I print product, it works but is a list. I am pretty sure I have the latest version. Any ideas? Reference: http://www.crummy.com/software/BeautifulSoup/documentation.html#The%20attributes%20of%20Tags -- http://mail.python.org/mailman/listinfo/python-list
Re: Beautiful soup tag attributes - Dictionary?
On Sun, Nov 30, 2008 at 8:51 PM, killsto <[EMAIL PROTECTED]> wrote: > The documentation says I can find attributes of tags by using it as a > dictionary. Ex: > > product = p.findAll('dd') .findAll() produces a *list* of tags The example in the docs is: firstPTag, secondPTag = soup.findAll('p') which is using *tuple unpacking*, so it's equivalent to: tags = soup.findAll('p') firstPTag = tags[0] #slicing the list to get individual item secondPTag = tags[1] So, you either need to use .find() instead of .findAll(), or treat the result of .findAll() correctly as a list of tags. Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com > print product['id'] > > However, when I try that python thinks I am slicing it. When I print > product, it works but is a list. I am pretty sure I have the latest > version. > > Any ideas? > > Reference: > http://www.crummy.com/software/BeautifulSoup/documentation.html#The%20attributes%20of%20Tags > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused about class relationships
On Sat, 29 Nov 2008, Carl Banks wrote: > On Nov 26, 11:20 pm, John O'Hagan <[EMAIL PROTECTED]> wrote: [...] > > > > class Bar(list): > > > > def __init__(self, a_bar, args, engine): > > list.__init__ (self, a_bar) > > self[:] = a_bar > > self.args = args > > self.engine = engine > > #more instance attributes... > > > > #methods... > > > > class Engine: > > > > def __init__(self, args): > > self.args = args > > #more instance attributes... > > > > def bar_builder(self): > > #body of method generates lists... > > yield Bar([generated_list], args, self) > > > > #more methods... > > > > #(other stuff...) > > > > def main(args): > > > > engine = Engine(args) > > bars = engine.bar_builder() > > for a_bar in bars: > > #play the music!... > > > > While this works (to my surprise!) and solves the problem which motivated > > it (i.e. Engine instances need to pass some attributes to Bar instances > > ), it seems too convoluted. Should one class inherit the other? > > No. (I wonder if you meant, "Should one class reference the other?", > as in, "Should Engines only reference bars or Bars only reference > engines, but not both?", in which case the answer is a non-commital, > "It depends.") > > Inheritance is not something you do because object A wants to access > the attributes/properties/etc. of B. Actually, that is something that > happens pretty often and when it does, there's a couple things you > should think about: > > 1. How you want A to access the attributes of B. Should you just let > A poke around in B, or should you define methods of B for A to call, > and those methods access the internals of B? It's a judgment call > most of the time. > > 2. Whether some behavior of B ought to be defined as part of A's class > instead, or vice versa. There is sometimes ambiguity over what class > a method that uses the attributes of two different objects should > belong to. > > Inheritance isn't something you need to think about here. > > Inheritance is something you consider when you have two objects, A and > B, that should act very similar or the same in certain situations. > Engines and Bars don't seem to share any behavior at all. Contrast > this to Bars and lists, which do share behavior. x[1] does pretty > much the same thing whether x is a Bar or a list, I'd imagine, so > there's reason for an inheritance relationship there. > > > If so, which way > > around? Or is it fine as is? > > One thing you might want to consider is whether Engine instance could > be simply passed into the Bar's play method (or whatever other method > accesses the Engine attributes), and whether the Engine needs to be > involved in generating bars at all. For instance: > > > class Bar(list): > def __init__(self, a_bar, args): > list.__init__(self, a_bar) > self[:] = a_bar > self.args = args > # etc. > def play(self, engine): > use(engine.time_signature).somehow() > # instead of use(self.engine.time_signature).somehow() > > > def bar_builder(self,args): > # plain function, not part of Engine class > # or perhaps a method of some other class > yield Bar([generated_list],args) > > > def main(): > engine = Engine(args) > bars = bar_builder(self,args) > for a_bar in bars: > a_bar.play(engine) > > > One benefit of doing it this way is that you've freed Bars and Engines > from each other. Conceivably you could create a second engine object > (maybe of a different type altogether), and play the very same Bar > objects with that engine instead. Thanks for such a detailed reply...I actually had bar_builder as a plain function originally, but because I didn't know how to pass attributes around like you have above, I was using globals to do it and was trying to solve that by classing everything in sight. Although the program doesn't work quite as you have deduced above, I can use the approach you suggest to simplify it immensely. (I hope.) > > > I'm hoping this is a common trap I've fallen into; I just haven't been > > able to get my head around it. (I'm a musician...) > > Well I think it looks pretty good for a musician newbie. There's a > few organizational decisions I'd make differently, but overall it's > clean and readable and not too complicated how you did it. At least > not what you've showed us. :) > [...] Believe me, the whole thing is more complicated and messy, but you don't want to see my dirty laundry! :) Regards, john -- http://mail.python.org/mailman/listinfo/python-list
incorrect line reported in traceback
Is there any reason why the last item in the traceback is one frame below the top of the stack? It would be great to show the real line in my editor... -- http://mail.python.org/mailman/listinfo/python-list
Re: incorrect line reported in traceback
On Dec 1, 4:47 pm, "Patrick Stinson" <[EMAIL PROTECTED]> wrote: > Is there any reason why the last item in the traceback is one frame > below the top of the stack? It would be great to show the real line in > my editor... Maybe your anonymous [HINT!] editor is confused. Do you get the same problem when you run your script at the shell prompt? -- http://mail.python.org/mailman/listinfo/python-list
Re: incorrect line reported in traceback
No, I've embedded the interpreter and an editor in my app, which might have something to do with it. I can't run the scripts at the command line because my app provides an API to built-ins that isn't availbel in the standard interpreter. I am simply calling a python method in the script module using PyObject_CallObject(), and fetching the traceback using PyErr_Fetch() and PyErr_Normalize(), like this: PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); PyErr_NormalizeException(&type, &value, &traceback); if(traceback) // traceback.tb_lineno *lineno = ((PyTracebackObject *) traceback)->tb_lineno; On Sun, Nov 30, 2008 at 8:59 PM, John Machin <[EMAIL PROTECTED]> wrote: > On Dec 1, 4:47 pm, "Patrick Stinson" <[EMAIL PROTECTED]> > wrote: >> Is there any reason why the last item in the traceback is one frame >> below the top of the stack? It would be great to show the real line in >> my editor... > > Maybe your anonymous [HINT!] editor is confused. Do you get the same > problem when you run your script at the shell prompt? > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: How to distribute a Python app together with its dependencies?
On 1 Dic, 05:23, Lev Elbert <[EMAIL PROTECTED]> wrote: > If Python for Windows you can use Py2Exe package. It works very well > in simple cases and requires a few tweaks to make it recognize some > dependencies. As I was saying above, the destination machines are all Unix. Thank you anyway for your suggestion, I'll keep it in mind if I can to deploy on Windows too. -- Alessio Pace. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python surpasses Perl in popularity?
2008-12-1, 01:10(+01), Sven Mascheck: > In comp.unix.shell Stephane CHAZELAS wrote: > >> The Bourne shell, as can still be found on some systems either in some >> non-standard place (/bin on Solaris, /usr/old/bin on HPUX) or named >> differently [...] > > What do you mean with "non-standard place" here? It's true it was vague and misleading, /bin is not the standard place to look for "sh" as far as the "POSIX" standard is concerned. That doesn't mean that standard commands (POSIX or not) cannot be found in /bin. But /bin/sh has been made a non-standard place for "sh". It's the "legacy" place. Those commands that have not undergone non-backward compatible changes with POSIX can still be found in /bin, the others are to be found in /usr/xpg/bin (for the standard versions). -- Stéphane -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
Clay Hobbs <[EMAIL PROTECTED]> writes: > It has key commands with key modifiers to do simple tasks (such as > moving the cursor to the left). Err - you move the cursor to the left by pressing the left arrow key (as you do with virtually every other editor), unless you've made some strange key bind customisations. -- http://mail.python.org/mailman/listinfo/python-list
Re: Mathematica 7 compares to other languages
On Nov 30, 7:30 pm, Xah Lee <[EMAIL PROTECTED]> wrote: > Wolfram Research's Mathematica Version 7 has just been released. > > See: http://www.wolfram.com/products/mathematica/index.html > > Among it's marketing material, it has a section on how mathematica > compares to competitors. http://www.wolfram.com/products/mathematica/analysis/ Stephen Wolfram has a blog entry about Mathematica 7. Quite amazing: http://blog.wolfram.com/2008/11/18/surprise-mathematica-70-released-today/ Mathematica today in comparsion to all other existing langs, can be perhaps compared to how lisp was to other langs in the say 1980s: Quite far beyond all. Seeing how lispers today still talking about how to do basic list processing with its unusable cons, and how they get giddy with 1980's macros (as opposed to full term rewriting), and still lack pattern matching, one feels kinda sad. see also: • Fundamental Problems of Lisp http://xahlee.org/UnixResource_dir/writ/lisp_problems.html Xah ∑ http://xahlee.org/ ☄ -- http://mail.python.org/mailman/listinfo/python-list
Cross platform desktop operations in Python
Hi I'm looking for a cross platform (Linux/Win/Mac) solution of common desktop operations like: * Getting system icon theme (icons for files, folders etc.) * Determine mimetype (better than mimetypes using mapped extension to mime) Under Unix/Linux there are freedesktop.org standards and pyxdg that can do that, but it won't work for example on Windows. Are there solutions for this, or do I have to implement a backed for every system? -- http://mail.python.org/mailman/listinfo/python-list