Re: end of print = lower productivity ?
In message
<[EMAIL PROTECTED]>,
[EMAIL PROTECTED] wrote:
> Now the print statement disappeared, and I have to write print("f")
> instead. These parentheses not only take time to write, they also make
> me think twice about using print for debugging purposes.
Trouble is, print defaulted to printing to stdout, and I usually wanted
debug messages to go to stderr. So print saved me nothing, which is why I
never got into the habit of using it.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
In message <[EMAIL PROTECTED]>, Roy Smith wrote: > Likewise for the source control (CVS, SVN, P4, etc) integrations [in > emacs]. Discovered that by accident today. Had a conflicted update in Subversion, fixed it up, saved the file, switched to a terminal window, typed "svn status", and lo and behold, the conflict had vanished (along with the .mine and .rnn files). I assume it was Emacs doing that, and not a side-effect of the "svn status" command. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: pydoc enforcement.
On Dec 1, 7:27 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > 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 As long as it uses RST (reStructuredText) it could be interesting. Maybe as a wrapper on epydoc or something? I have been simply generating my docs and reading through them. This is fine for catching areas which are totally missing, but gets very time consuming to maintain small changes. What would be really great, is something which ties in to subversion to display an easy to see and find alert in the docs when the source has been updated. It would then require some manual action to hide the alert (hopefully someone would read the doc again before killing the alert). - Rafe -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
Roy Smith <[EMAIL PROTECTED]> writes: > 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. It's worth pointing out to people making "loony" signs here that the arrow keys work too -- http://mail.python.org/mailman/listinfo/python-list
Re: Do more imported objects affect performance
On Dec 1, 7:26 am, "Filip Gruszczyński" <[EMAIL PROTECTED]> 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? > > -- > Filip Gruszczyński Why use it if you don't need it? Your post implies a choice and the '*' import can really make things muddy if it isn't actually necessary (rare). Why not just import the module and use what you need? It is way easier to read/debug and maintains the name-space. - Rafe -- http://mail.python.org/mailman/listinfo/python-list
Re: Mathematica 7 compares to other languages
I did some image processing in Mathematica once. It allocated 2GB of memory to do display a normal size image. The professor (not of my university) who gave the course I was following then, was a big Mathematica fan. He also used lots of sentences containing "quite striking", "highly efficient", "extreme" and other power-terms. I know see whom he got it from. When I hear a person talk like that for long enough, everything he says starts to sound like lies. One good example was the bold statement that Mathematica is MUCH faster than Matlab. Clearly, when considering low level task like convolution both programs will use efficient C implementations, and I can't imagine one being faster than the other. Personally, I liked Mathematica for symbolic calculations, but for numerical stuff, frankly, it sucks. Glad to get that off my chest. Cheers, Almar 2008/12/1 Xah Lee <[EMAIL PROTECTED]> > 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 > -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter question
On Oct 26, 7:02 am, "Chuckk Hubbard" <[EMAIL PROTECTED]>
wrote:
> Hello.
> How about this? I changed the if statements so the coordinates are
> always updated, but only changed if within the right limits, otherwise
> updated to the existing value. Now if you drag outside the limits of
> one dimension, it still moves in the other dimension. Not sure if
> that's what you want. I'm amazed that this can be so simple, I came
> up with an intricate system for my app, not realizing I could bind
> events to canvas items!
> BTW, I've never come across csoundroutines, can you give me a synopsis
> of what it's for? I'm using thePythonCsoundAPI. This is why I
> commented out all the references to csoundroutines, I don't have it
> installed at the moment.
> -Chuckk
>
> #!/usr/bin/python
> from Tkinter import *
> #import csoundroutines as cs
>
> root = Tk()
>
> global canv
> xx = {}
>
> def makeFrame(root):
> global canv
> # test = cs.csdInstrumentlist3('bay-at-night.csd')
> canv = Canvas (root, height = 200, width = 350)
>
> # for i in range (0, len(test.instr_number)):
> for i in range (0, 4):
> # canv.create_text(10, i *10, text=str(test.instr_number[i]) +
> canv.create_text(10, i *10, text=str(i) +
> '...', tags=('movable'))
> xx[i] = canv.tag_bind('movable', '', slide) #B1-motion
> is a drag with left button down
> canv.pack()
>
> def slide (event):
> '''
> triggered when something is dragged on the canvas - move thing
> under
> mouse ('current') to new position
> '''
> if 0 < event.x < 200:
> newx = event.x
> else: newx = canv.coords('current')[0]
> if 0 < event.y < 100:
> newy = event.y
> else: newy = canv.coords('current')[1]
> canv.coords('current', newx, newy)
>
> makeFrame(root)
> root.mainloop()
>
>
>
>
>
> On Fri, Oct 3, 2008 at 3:44 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > I saw this (close to this anyway) lieing around on the internet and
> > was wanting to use it to define a start point exc but I need the
> > graphics to stay within a set y coords and I am not realy sure how to
> > do that. I have no idea on how to bind a min/max y to it. (the
> > concept is inspired by the javacsoundblue).
>
> > #!/usr/bin/python
> > from Tkinter import *
> > import csoundroutines as cs
>
> > root = Tk()
>
> > global canv
> > xx = {}
>
> > def makeFrame(root):
> > global canv
> > test = cs.csdInstrumentlist3('bay-at-night.csd')
> > canv = Canvas (root, height = 200, width = 350)
>
> > for i in range (0, len(test.instr_number)):
> > canv.create_text(10, i *10, text=str(test.instr_number[i]) +
> > '...', tags=('movable'))
> > xx[i] = canv.tag_bind('movable', '', slide) #B1-motion
> > is a drag with left button down
> > canv.pack()
>
> > def slide (event):
> > '''
> > triggered when something is dragged on the canvas - move thing
> > under
> > mouse ('current') to new position
> > '''
> > newx = event.x
> > if event.y < 10 and event.y > 0:
> > newy = event.y
> > canv.coords('current', newx, newy)
>
> > makeFrame(root)
> > root.mainloop()
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> --http://www.badmuthahubbard.com- Hide quoted text -
>
> - Show quoted text -
sorry to take so long to reply... You should be able to find the
latest version of csound routines in the csound blog.. an older
version is in dex tracker available on source forge..
--
http://mail.python.org/mailman/listinfo/python-list
Re: tkinter question
On Oct 26, 7:02 am, "Chuckk Hubbard" <[EMAIL PROTECTED]>
wrote:
> Hello.
> How about this? I changed the if statements so the coordinates are
> always updated, but only changed if within the right limits, otherwise
> updated to the existing value. Now if you drag outside the limits of
> one dimension, it still moves in the other dimension. Not sure if
> that's what you want. I'm amazed that this can be so simple, I came
> up with an intricate system for my app, not realizing I could bind
> events to canvas items!
> BTW, I've never come across csoundroutines, can you give me a synopsis
> of what it's for? I'm using thePythonCsoundAPI. This is why I
> commented out all the references to csoundroutines, I don't have it
> installed at the moment.
> -Chuckk
>
> #!/usr/bin/python
> from Tkinter import *
> #import csoundroutines as cs
>
> root = Tk()
>
> global canv
> xx = {}
>
> def makeFrame(root):
> global canv
> # test = cs.csdInstrumentlist3('bay-at-night.csd')
> canv = Canvas (root, height = 200, width = 350)
>
> # for i in range (0, len(test.instr_number)):
> for i in range (0, 4):
> # canv.create_text(10, i *10, text=str(test.instr_number[i]) +
> canv.create_text(10, i *10, text=str(i) +
> '...', tags=('movable'))
> xx[i] = canv.tag_bind('movable', '', slide) #B1-motion
> is a drag with left button down
> canv.pack()
>
> def slide (event):
> '''
> triggered when something is dragged on the canvas - move thing
> under
> mouse ('current') to new position
> '''
> if 0 < event.x < 200:
> newx = event.x
> else: newx = canv.coords('current')[0]
> if 0 < event.y < 100:
> newy = event.y
> else: newy = canv.coords('current')[1]
> canv.coords('current', newx, newy)
>
> makeFrame(root)
> root.mainloop()
>
>
>
>
>
> On Fri, Oct 3, 2008 at 3:44 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > I saw this (close to this anyway) lieing around on the internet and
> > was wanting to use it to define a start point exc but I need the
> > graphics to stay within a set y coords and I am not realy sure how to
> > do that. I have no idea on how to bind a min/max y to it. (the
> > concept is inspired by the javacsoundblue).
>
> > #!/usr/bin/python
> > from Tkinter import *
> > import csoundroutines as cs
>
> > root = Tk()
>
> > global canv
> > xx = {}
>
> > def makeFrame(root):
> > global canv
> > test = cs.csdInstrumentlist3('bay-at-night.csd')
> > canv = Canvas (root, height = 200, width = 350)
>
> > for i in range (0, len(test.instr_number)):
> > canv.create_text(10, i *10, text=str(test.instr_number[i]) +
> > '...', tags=('movable'))
> > xx[i] = canv.tag_bind('movable', '', slide) #B1-motion
> > is a drag with left button down
> > canv.pack()
>
> > def slide (event):
> > '''
> > triggered when something is dragged on the canvas - move thing
> > under
> > mouse ('current') to new position
> > '''
> > newx = event.x
> > if event.y < 10 and event.y > 0:
> > newy = event.y
> > canv.coords('current', newx, newy)
>
> > makeFrame(root)
> > root.mainloop()
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> --http://www.badmuthahubbard.com- Hide quoted text -
>
> - Show quoted text -
haven't tried this yet but I look foward to trying it out..
--
http://mail.python.org/mailman/listinfo/python-list
Re: pydoc enforcement.
On Sun, 30 Nov 2008 16:27:07 -0800, [EMAIL PROTECTED] wrote: > Basically I'm interested adding a check to see if: > 1) pydoc's are written for every function/method. Pylint warns for missing docstrings. > 2) There are entries for each parameter, defined by some predetermined syntax. But which syntax? There are several in use out there. Even the (I think) popular epydoc allows at least three, its own, something JavaDoc like, and ReST. And I dislike forcing to document every parameter. There's lots of code that is clear just by the names of the parameters and one or two usage examples in the docs. Forcing to state the obvious again does not add information for the user and is annoying for the programmer. > 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. But that doesn't enforce good or even real documentation either. Even worse, you can't spot the undocumented parts of the code anymore, because now every "docable" object has "documentation" like this just to make the compiler happy: def spam(foo, bar): """ :param foo: a foo object. :param bar: a bar object. """ Which basically tells the same as no documentation at all. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Python surpasses Perl in popularity?
Stephane CHAZELAS <[EMAIL PROTECTED]> writes: >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). The proper place is "`getconf PATH`". POSIX doesn't list any pathnames. Of course, the problem is then "where did getconf come from?". Casper -- Expressed in this posting are my opinions. They are in no way related to opinions held by my employer, Sun Microsystems. Statements on Sun products included here are not gospel and may be fiction rather than truth. -- http://mail.python.org/mailman/listinfo/python-list
Re: Project structure - Best practices
On Nov 30, 11:43 pm, "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? > > -- > Filip Gruszczyński Hi, I have read in many places that relative imports aren't recommend as a standard. This includes PEP 8 (http://www.python.org/dev/peps/ pep-0008/) which states: " - Relative imports for intra-package imports are highly discouraged. Always use the absolute package path for all imports. Even now that PEP 328 [7] is fully implemented in Python 2.5, its style of explicit relative imports is actively discouraged; absolute imports are more portable and usually more readable." ...and I completely agree. I always use the standard import form unless absolutely necessary. However, I use 'as' to shorten the path to the last module. For example: >>> import app.foo.bar as bar >>> instance = bar.Class() The only "relative" import I use when I am getting another module in the same package. If I have: app/ __init__.py constants.py foo/ __init__.py bar.py here.py utils/ __init__.py ... and I am inside app/foo/here.py, I might have some imports at the top of the module which look like this... import app.constants as appC import app.utils import bar Python will look for 'bar' in the local package before looking through the python path. I could have imported constants as just "c", but single letter variables are dangerous and I work with an application where it is common in the community to use 'c' for 'constants' (regardless of the danger). Lastly, I could import 'app.utils' as 'utils', but this is such a common module name that I like to preserve the name-space or at least prefix it (so I suppose something like 'apputils' would be acceptable, but I'd only be saving one character, the '.', so what's the point?). I find that no matter how well I plan what my structure will be, I end up making small changes such as flattening a sub-package or converting a module to a sub-package to break things down further. As someone who recently started learning python, I would recommend that you just make a quick sketch of what you think might work and then just begin coding. Adjust to logic along the way. At some point planning begins to eat time rather than save it. get through the fastest initial 80%, maybe push for a few more %, then just go for it (I assume you have this luxury. If not then you probably have a team that can help refine the plan anyway.) Hope this helps. - Rafe -- http://mail.python.org/mailman/listinfo/python-list
Re: noob needs help
On Dec 1, 12: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? if you go to the directory where you put the file and run the python command, it should work (or supply the full path and not just 'helloworld.py') - Rafe -- http://mail.python.org/mailman/listinfo/python-list
Re: How to distribute a Python app together with its dependencies?
Alessio Pace wrote: > 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). I have never used it myself, but bbfreeze claims to create packaged versions of an application, for windows and Unix : http://pypi.python.org/pypi/bbfreeze/0.95.2 cheers, Philippe -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
Roy Smith <[EMAIL PROTECTED]> wrote: > 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. > I also started using Emacs about 25 years ago, but then when I moved to using DOS machines which at the time weren't capable of running Emacs I suffered withdrawal symptoms until I found Epsilon (http://lugaru.com) which started life as an Emacs style editor on DOS. I still use Epsilon today, even when I'm using Linux: it isn't free software in any sense of the word, but I find that a lot of the things I use it for it actually does better than Emacs. If you are willing to consider paying for an editor then download the evaluation copy of Epsilon and give it a go. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
Don't feed the troll. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python surpasses Perl in popularity?
On 2008-11-30, Stephane Chazelas <[EMAIL PROTECTED]> wrote: > 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 How does it decide ? argv[0] ? isatty (STDIN_FILENO) ? > 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). Two other Unixen I know of that have a non-POSIX sh are SCO Open Server and UnixWare. I'm not sure they even provide a POSIX-compliant alternative like Solaris does. On the other hand, their utilities (awk, grep, sed et al.) seem to be POSIX-compliant, at least to the extent that I've always managed. Unlike Solaris where I've often had to use the ones in /usr/xpg4/bin. Many people assume "standard" equates "portable". As far as shell programming is concerned, the safest way to get portability is to ignore the standard and code for the Bourne shell. -- André Majorel http://www.teaser.fr/~amajorel/> "After 15 minutes, I wanted to marry her. After a half hour, I completely gave up the idea of snatching her purse." -- _Take the Money and Run_ -- http://mail.python.org/mailman/listinfo/python-list
Re: Mathematica 7 compares to other languages
Mathematica is a great language, but: 1. it is too slow 2. It is often hard to read 3. It gives sence to every keystroke. You press escape by occasion and it goes in a code as a new symbol, w/o error. Nasty. 3. I know 5-th version. It does not allow to track the source as SLIME does. This feature as absolutely necessary for serious development So, in fact, Mathematica do not scale well IMO. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to dynamically get an attribute from a module from within the same module
> 3) using the bare name: > whatever > 1) and 2) are useful when the desired name is variable, not a constant like > "whatever". I thought that went without saying. > > I have been using #1 for two reasons. First, I will never run this > > module directly, so __name__ will always be the module name and not > > "__main__". > > (note that it works even with __main__) Nice. Thanks. > > Second, I can use this in a class to decide whether I want > > the module where the class came from or, if I make the class a base > I don't completely understand your use case. In the expression: > getattr(some_module, attribute_name) > you may use any module as the first argument (the current module, or any > other). Right, I was just confused about the effects of inheritance and scope. If I put a method in a baseclass, which is inherited in another module, and then run the method from an instance of the sub-class... - "sys.modules[__name__]" returns the baseclass module. - "sys.modules[self.__class__.__module__]" returns the subclass module. in the end I found it felt more logical to put the code in a module- level function and call it from the class. All of this was part of a fairly large factory method implementation. I now know that globals() refers to module-level names. The pros and cons were the main point of this thread and so far I have... 1) getattr(module, "whatever") seems the most pythonic way to do it but it takes more than one line and requires a little more thought about scope and inheritance. 2) globals()["whatever"] is concise, but it seems a little like a shortcut which requires special knowledge (though a very small amount). I did a quick benchmark test: < tmp2.py > import time import sys import tmp class A(tmp.A): pass class B(tmp.A): pass class C(tmp.A): pass class D(tmp.A): pass class E(tmp.A): pass class F(tmp.A): pass class G(tmp.A): pass class H(tmp.A): pass class I(tmp.A): pass class J(tmp.A): pass def test_globals_vs_gettattr(): t1 = time.time() for i in range(0, 100): H = globals()["H"] t2 = time.time() print "globals() too %s seconds." % str(t2-t1) t1 = time.time() mod = sys.modules[__name__] for i in range(0, 100): H = getattr(mod, "H") t2 = time.time() print "getattr() too %s seconds." % str(t2-t1) < /tmp2.py > tmp.py just has a simple class in it. I just wanted to add some complexity, but I doubt this had any affect on the times. >>> import tmp2 >>> tmp2.test_globals_vs_gettattr() globals() too .146900010109 seconds. getattr() too .43423515 seconds. Just to see how much the call to sys.modules was affecting the test, I moved it outside the loop and reloaded the module for a second test. >>> reload(tmp2) >>> tmp2.test_globals_vs_gettattr() globals() too .13913242 seconds. getattr() too .25460381 seconds. This second test is pointless in practice since I would be calling sys.modules each time anyway. Even though the getattr() way is around 3.5 times slower, I had to run the code 1,000,000 times before the difference became humanly recognizable. I also realize benchmarks should be taken with a grain of salt since my setup may differ greatly from others'. I guess, in the end, I'd use getattr() because it feels more pythonic, and more basic. I got pretty deep in to learning python before I had to learn what the globals() dict could do for me. Cheers, - Rafe -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any library that can convert RGB colors to ANSI colors?
ZelluX wrote:
> Convert RGB colors to the closest ANSI colors. For example, given RGB
> color FF, it should print [31m.
from functools import partial
def to_rgb(color):
return (color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF
target_colors = {
0x00: "\33[30m",
0xFF: "\33[31m",
# ...
0xFF: "\33[37m",}
def euclidian(c1, c2):
r, g, b = to_rgb(c1)
s, h, c = to_rgb(c2)
r -= s
g -= h
b -= c
return r*r+g*g+b*b
def closest_color(color, target_colors=target_colors, dist=euclidian):
return min(target_colors, key=partial(dist, color))
if __name__ == "__main__":
black = target_colors[0]
for color in 0xff, 0x00ff00, 0x808080, 0x008000:
bestmatch = closest_color(color)
code = target_colors[bestmatch]
print "#%06x --> %sSAMPLE%s" % (color, code, black)
If the results are not good enough for your application you can convert to
another colorspace before calculating the distance.
Peter
--
http://mail.python.org/mailman/listinfo/python-list
What about a decorator module version 3.0?
I am thinking about releasing a new version of the decorator module, completely rewritten from scratch. The new implementation takes half the lines of the original one and it is much more general, so I like it more. However, there is an issue of compatibility with the past and I am asking here for feedback from my users. I have already broken backward compatibility in the past, with version 2.0 of the module, and I could break it again in version 3.0. However, the breakage in version 2.0 was very minor and at the time the module had very few users so that nobody ever complained. Nowadays there are a lot of people using it and there are frameworks relying on it (such as Pylons) so I am relectant to break compatibility, even in minor ways. I want to ask people how do they use the module. If you just use the decorator function, that will continue to work as before and I do not think I will ever break that functionality - actually I am thinking of enhancing it. However, over the time I have added other utilities to the module - I am referring to getinfo and new_wrapper - and I would like to get rid of them. Actually I would like to deprecate them in decorator 3.0 and to remove them in decorator 3.1 or later on, after a grace period of one year or so. Also, I would like to remove a new feature introduced in version 2.3, i.e. the direct support to decorator factories. I added it in haste and now I have changed my mind. Is there anybody using that functionality? I want to offer an alternative which does not involve magically adding a __call__ method to a class. In general I want to remove a few things because I feel they add to the learning curve without offering a compelling benefit, or because I think the new implementation offer better ways to do the same job. If nobody uses those features I will remove them; on the other hand, if this is too much of a breakage, I will just start a new project with a different name. The old decorator module will continue to live forever, but the developement on it will stop and the new things will go in the new module. Personally, I would like to keep the name, and to add some support for Python 3.0: decorator 3.0 sounds good for Python 3.0, and the change I have in mind is the same kind of change which happened for Python 3.0, i.e. a simplification more than an addition of new features. What do you people think? -- http://mail.python.org/mailman/listinfo/python-list
Re: distinct fcntl flags for stdin and stdout
mbuna <[EMAIL PROTECTED]> wrote: > Hello, > when I set non blocking flag with fcntl on sys.stdin, then sys.stdout > turns into non blocking mode too. Is it normal behaviour? How can I > turn stdin into non blocking mode but not stdout? Thanks. > > This is a quick program that shows the (my?) problem: > > import fcntl > import os > import sys > > print "STDIN", sys.stdin, "fd=%d" % sys.stdin.fileno() > print "STDOUT", sys.stdout, "fd=%d" % sys.stdout.fileno() > print "os.O_NDELAY=%04x" % os.O_NDELAY > def state(): > flag = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL) > print "stdin: flag=%04x" % flag > flag = fcntl.fcntl(sys.stdout.fileno(), fcntl.F_GETFL) > print "stdout: flag=%04x" % flag > state() > print "setting non blocking on stdin..." > flag = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL) > fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, flag | os.O_NDELAY) > state() > print "removing non blocking on stdin..." > flag = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL) > fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, flag & ~os.O_NDELAY) > state() > > > RESULT > STDIN ', mode 'r' at 0x2aacd120> fd=0 > STDOUT ', mode 'w' at 0x2aacd198> fd=1 > os.O_NDELAY=0800 > stdin: flag=8002 > stdout: flag=8002 > setting non blocking on stdin... > stdin: flag=8802 > stdout: flag=8802 > removing non blocking on stdin... > stdin: flag=8002 > stdout: flag=8002 If you try this with output redirected to a file, you get this (under linux) STDIN ', mode 'r' at 0xb7d03020> fd=0 STDOUT ', mode 'w' at 0xb7d03068> fd=1 os.O_NDELAY=0800 stdin: flag=0002 stdout: flag=8001 setting non blocking on stdin... stdin: flag=0802 stdout: flag=8001 removing non blocking on stdin... stdin: flag=0002 stdout: flag=8001 So I suspect your result is because stdin and stdout refer to the same file (eg /dev/tty0 or /dev/pts/25). No idea whether this is correct behaviour or not though! -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Do more imported objects affect performance
Rafe <[EMAIL PROTECTED]> wrote: > On Dec 1, 7:26?am, "Filip Gruszczy?ski" <[EMAIL PROTECTED]> 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? > > Why use it if you don't need it? Your post implies a choice and the > '*' import can really make things muddy if it isn't actually necessary > (rare). Why not just import the module and use what you need? It is > way easier to read/debug and maintains the name-space. Importing the module is actualy slower... If you import the name into your namespace then there is only one lookup to do. If you import the module there are two. $ python -m timeit -s 'from timeit import Timer' 'Timer' 1000 loops, best of 3: 0.0784 usec per loop $ python -m timeit -s 'import timeit' 'timeit.Timer' 100 loops, best of 3: 0.243 usec per loop I'm not suggestion you should ever use "from module import *" only ever import the things you actually need, eg "from module import MyClass, my_function" And here is the test again, actually calling something with the same difference in execution speed :- $ python -m timeit -s 'from os import nice' 'nice(0)' 100 loops, best of 3: 1.21 usec per loop $ python -m timeit -s 'import os' 'os.nice(0)' 100 loops, best of 3: 1.48 usec per loop -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: What about a decorator module version 3.0?
On Mon, Dec 1, 2008 at 9:16 AM, Michele Simionato <[EMAIL PROTECTED]> wrote: > I am thinking about releasing a new version of the decorator module, > [...] Just FYI, the module being discussed here is http://www.phyast.pitt.edu/~micheles/python/documentation.html I dont use it myself, but given how much I use decorators, I probably should. -- Eduardo de Oliveira Padoan http://djangopeople.net/edcrypt/ "Distrust those in whom the desire to punish is strong." -- Goethe, Nietzsche, Dostoevsky -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to dynamically get an attribute from a module from within the same module
Rafe wrote: > I guess, in the end, I'd use getattr() because it feels more pythonic, > and more basic. I got pretty deep in to learning python before I had > to learn what the globals() dict could do for me. Why not store your individual classes inside another class or keep them in a dict? That would be clearer, would not mess around with global namespace, and more pythonic IMHO. Jeremy -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python surpasses Perl in popularity?
2008-12-01, 08:51(+00), Casper H.S Dik: > Stephane CHAZELAS <[EMAIL PROTECTED]> writes: > >>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). > > The proper place is "`getconf PATH`". POSIX doesn't list any > pathnames. > > Of course, the problem is then "where did getconf come from?". [...] Sorry, I was specifically speaking of Solaris 7, 8, 9. "getconf PATH" is not enough, you have to pick the correct getconf, and that getconf be called in the relevant environment. For instance, in later versions of Solaris, I beleive you get /usr/xpg6/bin or /usr/xpg4/bin first depending on the environment. Also, PATH is not necessarily the only thing needed to get you the conformant utilities. See BIN_SH on Tru64, POSIXLY_CORRECT on GNU... I beleive the only thing POSIX requires is that how to get into the proper environment be documented (but it is unspecified). On Solaris, I beleive it's in the standards(5) man page. -- Stéphane -- http://mail.python.org/mailman/listinfo/python-list
finding the difference between the two version of the python program...
is there a tool which, given two version of programs, finds the difference like set of classes added, deleted and modified? assuming the python program is written in oops way. -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
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? IMHO I'd want these features * Keyboard macros * Regular expression search and replace * Integration with version control * Infinite undo * Syntax colouring (not essential) * Bracket matching (useful but not essential) * Integration with compiler with error throwback (essential for C code work) * Automatic indenting (a great time saver) I know that emacs (my choice) and vim have all these features, don't know about Eclipse. In fact if I had to pick one feature that a programmer's editor must have it would be keyboard macros. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: How to distribute a Python app together with its dependencies?
On Sun, Nov 30, 2008 at 2:22 PM, Alessio Pace <[EMAIL PROTECTED]> wrote: > 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 > Hi, I was reading Learning Python yesterday and I think this was mentioned: http://peak.telecommunity.com/DevCenter/PythonEggs I don't have experience either so no guarantees cheers /mikko/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to distribute a Python app together with its dependencies?
On 1 Dic, 10:37, BlueBird <[EMAIL PROTECTED]> wrote: > Alessio Pace wrote: > > 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). > > I have never used it myself, but bbfreeze claims to create packaged > versions of an application, for windows and Unix : > > http://pypi.python.org/pypi/bbfreeze/0.95.2 > Thank you. What's the difference with "Freeze" shipped with Python, or with PyInstaller ? Do you have experiences with any of them? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to distribute a Python app together with its dependencies?
On 1 Dic, 10:37, BlueBird <[EMAIL PROTECTED]> wrote: > Alessio Pace wrote: > > 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). > > I have never used it myself, but bbfreeze claims to create packaged > versions of an application, for windows and Unix : > > http://pypi.python.org/pypi/bbfreeze/0.95.2 > Thank you. What's the difference with "Freeze" shipped with Python, or with PyInstaller ? Do you have experiences with any of them? -- http://mail.python.org/mailman/listinfo/python-list
How to instantiate in a lazy way?
Hi comp.lang.python, I am a novice Python programmer working on a project where I deal with large binary files (>50 GB each) consisting of a series of variable sized data packets. Each packet consists of a small header with size and other information and a much large payload containing the actual data. Using Python 2.5, struct and numpy arrays I am capable of parsing such a file quite efficiently into Header and Payload objects which I then manipulate in various ways. The most time consuming part of the parsing is the conversion of a proprietary form of 32 bit floats into the IEEE floats used internally in Python in the payloads. For many use cases I am actually not interested in doing the parsing of the payload right when I pass through it, as I may want to use the attributes of the header to select the 1/1000 payload which I actually have to look into the data for and do the resourceful float conversion. I would therefore like to have two variants of a Payload class. One which is instantiated right away with the payload being parsed up in the float arrays available as instance attributes and another variant, where the Payload object at the time of instantiation only contains a pointer to the place (f.tell()) in file where the payload begins. Only when the non-existing attribute for a parsed up module is actully accessed should the data be read, parsed up and the attribute created. In pseudocode: class PayloadInstant(object): """ This is a normal Payload, where the data are parsed up when instantiated """ @classmethod def read_from_file(cls, f, size): """ Returns a PayloadInstant instance with float data parsed up and immediately accessible in the data attribute. Instantiation is slow but after instantiation, access is fast. """ def __init___(self, the_data): self.data = the_data class PayloadOnDemand(object): """ Behaves as a PayloadInstant object, but instantiation is faster as only the position of the payload in the file is stored initially in the object. Only when acessing the initially non-existing data attribute are the data actually read and the attribure created and bound to the instance. This will actually be a little slower than in PayloadInstant as the correct file position has to be seeked out first. On later calls the object has as efficient attribute access as PayloadInstant """ @classmethod def read_from_file(cls, f, size): pos = f.tell() f.seek(pos + size) #Skip to end of payload return cls(pos) # I probably need some __getattr__ or __getattribute__ magic here...?? def __init__(self, a_file_position): self.file_position = a_file_position My question is this a a pyhtonic way to do it, and they I would like a hint as to how to make the hook inside the PayloadOnDemand class, such that the inner lazy creation of the attribute is completely hidden from the outside. I guess I could also just make a single class, and let an OnDemand attribute decide how it should behave. My real application is considerably more complicated than this, but I think the example grasps the problem in a nutshell. -- Slaunger -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
In article <[EMAIL PROTECTED]>, Richard Riley <[EMAIL PROTECTED]> wrote: > Roy Smith <[EMAIL PROTECTED]> writes: > > > 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. > > It's worth pointing out to people making "loony" signs here that the > arrow keys work too Yeah, I guess. I use the arrows keys to mindlessly scroll around in a file, especially when I just want to show some code to somebody. It serves two purposes. First, I can lean way back from the keyboard and reach out with one hand (giving the other person better visibility). Second, it makes it easier for a non-emacs person to jump in and drive for a while (they saw me use the arrow keys and do the same, no explanations needed). For any serious editing, however, it's strictly the keys on the main part of the keyboard. It's just so much faster when your hands never have to leave their home position. To use the arrow keys, I need to pick my hand up and move it over to the arrow key cluster. Slow, slow, slow. -- http://mail.python.org/mailman/listinfo/python-list
SQLObject 0.9.8
Hello! I'm pleased to announce version 0.9.8, a minor bug fix release of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject == Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.9.8 News and changes: http://sqlobject.org/News.html What's New == News since 0.9.7 * Changed interpretation of strings in the DB URI for boolean parameters: '0', 'no', 'off' and 'false' are now interpreted as False. * Fixed a bug with incorrect handling of calls like connectionForURI(dburi, cache=False) when dburi already contains some parameters in the URI. * Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2; see http://mail.python.org/pipermail/python-dev/2008-March/078189.html * Added test_default_style.py. * Fixed a minor bug in SQLiteConnection that fails to parse Enum columns. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. -- http://mail.python.org/mailman/listinfo/python-list
SQLObject 0.10.3
Hello! I'm pleased to announce version 0.10.3, a minor bugfix release of 0.10 branch of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject == Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.10.3 News and changes: http://sqlobject.org/News.html What's New == News since 0.10.2 - * Changed interpretation of strings in the DB URI for boolean parameters: '0', 'no', 'off' and 'false' are now interpreted as False. * Fixed a bug with incorrect handling of calls like connectionForURI(dburi, cache=False) when dburi already contains some parameters in the URI. * Convert decimal.to_eng_string() to str to work around a bug in Python 2.5.2; see http://mail.python.org/pipermail/python-dev/2008-March/078189.html * Added test_default_style.py. * Fixed a minor bug in SQLiteConnection that fails to parse Enum columns. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
In article <[EMAIL PROTECTED]>, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > * Syntax colouring (not essential) I never used to use syntax coloring, until somebody turned me on to it a couple of years ago. I was griping on a company mailing list that some previous code monkey had commented out a big swath (more than a screenfull) of C++ code by sticking a "/*" at the beginning and a "*/" at the end. I had just wasted a bunch of time trying to debug a problem, not noticing that the code I was looking at was commented out. Somebody pointed out that if I turned on syntax coloring, it would be obvious. I've been hooked ever since. -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode and hashlib
Jeff H wrote:
[...] So once I have character strings transformed
internally to unicode objects, I should encode them in 'utf-8' before
attempting to do things that guess at the proper way to encode them
for further processing.(i.e. hashlib)
It looks like hashlib in Python 3 will not even attempt to digest a
unicode object. Trying to hash 'abcdefg' in in Python 3.0rc3 I get:
TypeError: object supporting the buffer API required
I think that's good behavior, except that the error message is likely to
send beginners to look up the obscure buffer interface before they find
they just need mystring.decode('utf8') or bytes(mystring, 'utf8').
a='André'
b=unicode(a,'cp1252')
b
u'Andr\xc3\xa9'
hashlib.md5(b.encode('utf-8')).hexdigest()
'b4e5418a36bc4badfc47deb657a2b50c'
Incidentally, MD5 has fallen and SHA-1 is falling. Python's hashlib also
includes the stronger SHA-2 family.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
Python introspection and namespace weird question
Hello everybody, Is there an easy way to do something like this in python ? >>> red_car = MyVehicleClass() >>> car = red_car >>> car.labels() ['red_car' , 'car' ] In other words, does an instance has access to its name pointers ? Thanks in advance, Rayene -- http://mail.python.org/mailman/listinfo/python-list
Re: How to instantiate in a lazy way?
Slaunger wrote: > > class PayloadOnDemand(object): > """ > Behaves as a PayloadInstant object, but instantiation is faster > as only the position of the payload in the file is stored > initially in the object. > Only when acessing the initially non-existing data attribute > are the data actually read and the attribure created and bound to > the instance. > This will actually be a little slower than in PayloadInstant as > the correct file position > has to be seeked out first. > On later calls the object has as efficient attribute access as > PayloadInstant > """ > > @classmethod > def read_from_file(cls, f, size): > pos = f.tell() > f.seek(pos + size) #Skip to end of payload > return cls(pos) Extend with ref to file instead: return cls(f, pos) > > # I probably need some __getattr__ or __getattribute__ magic > # there...?? To answer my own rethorical question I guess I should do something like this def __getattr__(self, attr_name): """ Only called if attr_name is not in the __dict__ for the instance """ if attr_name == 'data': self.__dict__[attr_name] = read_data(self.f, self.file_position) > > def __init__(self, a_file_position): > self.file_position = a_file_position > and then I need to also store a reference to the file in the constructor... def __init__(self, a_file, a_file_position): self.f = a_file self.file_position = a_file_position Have I understood correctly how to to it the on demand way? -- Slaunger -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
Roy Smith <[EMAIL PROTECTED]> writes: > In article <[EMAIL PROTECTED]>, > Richard Riley <[EMAIL PROTECTED]> wrote: > >> Roy Smith <[EMAIL PROTECTED]> writes: >> >> > 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. >> >> It's worth pointing out to people making "loony" signs here that the >> arrow keys work too > > Yeah, I guess. I use the arrows keys to mindlessly scroll around in a > file, especially when I just want to show some code to somebody. It serves > two purposes. First, I can lean way back from the keyboard and reach out > with one hand (giving the other person better visibility). Second, it > makes it easier for a non-emacs person to jump in and drive for a while > (they saw me use the arrow keys and do the same, no explanations needed). > > For any serious editing, however, it's strictly the keys on the main part > of the keyboard. It's just so much faster when your hands never have to > leave their home position. To use the arrow keys, I need to pick my hand > up and move it over to the arrow key cluster. Slow, slow, slow. Have to disagree. I could never use C-f etc. If I want to navigate the cursor its generally to browse and the 10th of a second it takes to rest hand on the cursor pad is immaterial in the time compared to sit back and read the code. I find the reference to using control keys to naviaget code character and line at time leads to more people abandoning emacs than you would believe. All it needs is a "cursor keys or, for hardcore types, the following key sequences". Still. all to their own. -- important and urgent problems of the technology of today are no longer the satisfactions of the primary needs or of archetypal wishes, but the reparation of the evils and damages by the technology of yesterday. ~Dennis Gabor, Innovations: Scientific, Technological and Social, 1970 -- http://mail.python.org/mailman/listinfo/python-list
Re: pydoc enforcement.
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > On Sun, 30 Nov 2008 16:27:07 -0800, [EMAIL PROTECTED] wrote: > >> Basically I'm interested adding a check to see if: >> 1) pydoc's are written for every function/method. > > Pylint warns for missing docstrings. > >> 2) There are entries for each parameter, defined by some >predetermined syntax. > > But which syntax? There are several in use out there. Even the (I > think) popular epydoc allows at least three, its own, something JavaDoc > like, and ReST. > > And I dislike forcing to document every parameter. There's lots of code > that is clear just by the names of the parameters and one or two usage > examples in the docs. Forcing to state the obvious again does not add > information for the user and is annoying for the programmer. > >> 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. > > But that doesn't enforce good or even real documentation either. Even > worse, you can't spot the undocumented parts of the code anymore, because > now every "docable" object has "documentation" like this just to make the > compiler happy: > > def spam(foo, bar): > """ > :param foo: a foo object. > :param bar: a bar object. > """ > > Which basically tells the same as no documentation at all. > > Ciao, > Marc 'BlackJack' Rintsch +1. Agreed 100%. There is nothing worse than auto generate "useless" documentation or over commenting of "obvious" variables/members. If anything it leads to problems later during maintenance. -- important and urgent problems of the technology of today are no longer the satisfactions of the primary needs or of archetypal wishes, but the reparation of the evils and damages by the technology of yesterday. ~Dennis Gabor, Innovations: Scientific, Technological and Social, 1970 -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
[EMAIL PROTECTED] writes: > Don't feed the troll. > Yet you did and made the previous post visible to me. If you don't want people to feed the troll, do not do it yourself. -- http://mail.python.org/mailman/listinfo/python-list
Re: Do more imported objects affect performance
I see. Thanks for a really good explanation, I like to know, how to do things in the proper way :) 2008/12/1 Nick Craig-Wood <[EMAIL PROTECTED]>: > Rafe <[EMAIL PROTECTED]> wrote: >> On Dec 1, 7:26?am, "Filip Gruszczy?ski" <[EMAIL PROTECTED]> 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? >> >> Why use it if you don't need it? Your post implies a choice and the >> '*' import can really make things muddy if it isn't actually necessary >> (rare). Why not just import the module and use what you need? It is >> way easier to read/debug and maintains the name-space. > > Importing the module is actualy slower... If you import the name into > your namespace then there is only one lookup to do. If you import the > module there are two. > > $ python -m timeit -s 'from timeit import Timer' 'Timer' > 1000 loops, best of 3: 0.0784 usec per loop > > $ python -m timeit -s 'import timeit' 'timeit.Timer' > 100 loops, best of 3: 0.243 usec per loop > > I'm not suggestion you should ever use "from module import *" only > ever import the things you actually need, eg > "from module import MyClass, my_function" > > And here is the test again, actually calling something with the same > difference in execution speed :- > > $ python -m timeit -s 'from os import nice' 'nice(0)' > 100 loops, best of 3: 1.21 usec per loop > > $ python -m timeit -s 'import os' 'os.nice(0)' > 100 loops, best of 3: 1.48 usec per loop > > -- > Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick > -- > http://mail.python.org/mailman/listinfo/python-list > -- Filip Gruszczyński -- http://mail.python.org/mailman/listinfo/python-list
Re: How to distribute a Python app together with its dependencies?
On Nov 30, 6:22 am, Alessio Pace <[EMAIL PROTECTED]> wrote: > 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. I recommend GUI2Exe, a nice wrapper to py2exe, py2app, PyInstaller, cx_Freeze and bbFreeze: http://code.google.com/p/gui2exe/ I've only used the py2exe portion of the program, but it works great and the developers behind the project are very responsive and helpful. Mike -- http://mail.python.org/mailman/listinfo/python-list
11001, 'getaddrinfo failed' : Error in httplib but not in urllib2
Hi all,
I am trying to connect to localhost via httplib, but it fails.
To check whether it is a firewall problem etc, I tried to connect
via urllib2, but it went through fine.
Could some one help me out on this? I cannot use urllib2 in the
program because I have to send files via post to a url, and urllib2
doesn't support it (Python2.4)
Please see the code below:
-->HTTPLIB<--
h = httplib.HTTPConnection("http://127.0.0.1:8000";)
h.request('GET', "/accounts/")
res = h.getresponse()
-->URLLIB2<--
req = urllib2.Request("http://127.0.0.1:8000/accounts/";)
fd = urllib2.urlopen(req)
Regards
Raj
--
http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
On 29 Nov., 21:44, 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? > > 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 Many have written that they have no experience with using Eclipse. Well, I have a little, and I just want to add my experience. I am a novice Python programmer and I use Eclipse with the PyDev and SubClipse extensions which gives me a Python environment and integration with Subversion, which is the version control system I use. My OS is Windows XP and Server 2003. Other people are working on the same project using either eclipse on a linux box or another editor of choice. Eclipse works very well for me. The facilities I like are: * A handy object browser which lets be jump into the part of the code I am interested in (I work with several, quite large modules). * Autocompletion: When I write . it gives me a suggestion of the methods/attributes available and the doc string (if available) is shown as a tool tip. It can autogenerate a generic signature for a method call with the attribute names prefilled. Very handy as I quite often forget the order of arguments. * Unit tests: It is quite convenient to write and run unit tests in the environment (unittest run targets) * Refactoring: Intelligent rename for instance is handy for renaming methods and attributes across modules * Debugger: I debugger environment which works well for me with watchlists, step-into, step over. * Chroma-coded * Auto-indentation * Macros for block commenting, indenting and unindenting. * Nice integrated diff toll which integrates well with subversion. * And tons of other things which I have not explored yet. Like a coverage run target for instance. * Some Syntax checking I am personally satisfied with the startup time and overall responsiveness of Eclipse, but users of Emacs/Vim may have other bars for responsiveness than me. Sometimes I experience some problems with cascading inexplicable errors ocurring in the IDE when running unit test suites. This is annoying and they do not occur when I run the tests stand- alone outside on the command line. This IDE works well for me. I do not have an opinion about how it works in comparison with Emacs and Vim, just wanted to give my opinion on Eclipse and Python as this had not been discussed so much. On the prestige level it is certainly not considered as "cool" to use Eclipse as Emacs/Vim where I am working. I often hear the opinion that you are not a proper coder/hacker is you do not master any of these classic editors. I also think it depends much upon your coding style. Personally I spend much more time thinking on "how" to implement this-and-that, than actually coding. That may reflect that I am still a novice Python Programmer. -- Slaunger -- http://mail.python.org/mailman/listinfo/python-list
Re: 11001, 'getaddrinfo failed' : Error in httplib but not in urllib2
RajNewbie wrote:
Hi all,
I am trying to connect to localhost via httplib, but it fails.
To check whether it is a firewall problem etc, I tried to connect
via urllib2, but it went through fine.
Could some one help me out on this? I cannot use urllib2 in the
program because I have to send files via post to a url, and urllib2
doesn't support it (Python2.4)
Please see the code below:
-->HTTPLIB<--
h = httplib.HTTPConnection("http://127.0.0.1:8000";)
h.request('GET', "/accounts/")
res = h.getresponse()
Which aspect of the documentation:
http://docs.python.org/library/httplib.html
leads you to think that the first parameter to
httplib.HTTPConnection should be a URL?
import httplib
httplib.HTTPConnection ("127.0.0.1")
httplib.HTTPConnection ("localhost")
TJG
--
http://mail.python.org/mailman/listinfo/python-list
setuptools - library dependencies
I try to write setup.py which compiles C Extenstion (A). The problem is the fact, that my C Extension depends on another C lib (B). I've digged it setuptools sources a bit and found "libraries" option for setuptools.setup. Now it compile B library at build_clib stage and A Extenstion at build_ext stage. But it doesn't pack B library in final egg file, only A one. Even more, it compiles B as static lib, but links it to A as dynamic, it leads to undefined symbols in A. How could I either: 1) link A with B staticaly? 2) put B in final egg in same dir as A? -- http://mail.python.org/mailman/listinfo/python-list
Re: finding the difference between the two version of the python program...
Hi, Piyush Anonymous wrote: is there a tool which, given two version of programs, finds the difference like set of classes added, deleted and modified? assuming the python program is written in oops way. diff for example can do this. There is also an difflib in python which you can use to roll your own diff. Regards TIno smime.p7s Description: S/MIME Cryptographic Signature -- http://mail.python.org/mailman/listinfo/python-list
Re: How to instantiate in a lazy way?
Slaunger <[EMAIL PROTECTED]> wrote: > Slaunger wrote: > > > > class PayloadOnDemand(object): > > ? ? """ > > ? ? Behaves as a PayloadInstant object, but instantiation is faster > > ? ? as only the position of the payload in the file is stored > > initially in the object. > > ? ? Only when acessing the initially non-existing data attribute > > ? ? are the data actually read and the attribure created and bound to > > the instance. > > ? ? This will actually be a little slower than in PayloadInstant as > > the correct file position > > ? ? has to be seeked out first. > > ? ? On later calls the object has as efficient attribute access as > > PayloadInstant > > ? ? """ > > > > ? ? @classmethod > > ? ? def read_from_file(cls, f, size): > > ? ? ? ? pos = f.tell() > > ? ? ? ? f.seek(pos + size) #Skip to end of payload > > ? ? ? ? return cls(pos) > > Extend with ref to file instead: >return cls(f, pos) > > > > ? ? # I probably need some __getattr__ or __getattribute__ magic > > # there...?? > > To answer my own rethorical question I guess I should do something > like this > > def __getattr__(self, attr_name): > """ > Only called if attr_name is not in the __dict__ for the > instance > """ > if attr_name == 'data': > self.__dict__[attr_name] = read_data(self.f, > self.file_position) > > > > > ? ? def __init__(self, a_file_position): > > ? ? ? ? self.file_position = a_file_position > > > and then I need to also store a reference to the file in the > constructor... > > def __init__(self, a_file, a_file_position): > self.f = a_file > self.file_position = a_file_position > > Have I understood correctly how to to it the on demand way? I wouldn't use __getattr__ unless you've got lots of attributes to overload. __getattr__ is a recipe for getting yourself into trouble in my experience ;-) Just do it like this... class PayloadOnDemand(object): def __init__(self, a_file, a_file_position): self._data = None self.f = a_file self.file_position = a_file_position @property def data(self): if self._data is None: self._data = self.really_read_the_data() return self._data then you'll have a .data attribute which when you read it for the first time it will populate itself. If None is a valid value for data then make a sentinel, eg class PayloadOnDemand(object): sentinel = object() def __init__(self, a_file, a_file_position): self._data = self.sentinel self.f = a_file self.file_position = a_file_position @property def data(self): if self._data is self.sentinel: self._data = self.really_read_the_data() return self._data -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: 11001, 'getaddrinfo failed' : Error in httplib but not in urllib2
On Dec 1, 7:43 pm, Tim Golden <[EMAIL PROTECTED]> wrote:
> RajNewbie wrote:
> > Hi all,
> > I am trying to connect to localhost via httplib, but it fails.
> > To check whether it is a firewall problem etc, I tried to connect
> > via urllib2, but it went through fine.
>
> Could some one help me out on this? I cannot use urllib2 in the
>
> > program because I have to send files via post to a url, and urllib2
> > doesn't support it (Python2.4)
>
> > Please see the code below:
> > -->HTTPLIB<--
> > h = httplib.HTTPConnection("http://127.0.0.1:8000";)
> > h.request('GET', "/accounts/")
> > res = h.getresponse()
>
> Which aspect of the documentation:
>
> http://docs.python.org/library/httplib.html
>
> leads you to think that the first parameter to
> httplib.HTTPConnection should be a URL?
>
> >>> import httplib
> >>> httplib.HTTPConnection ("127.0.0.1")
>
> >>> httplib.HTTPConnection
> ("localhost")
>
>
>
>
>
>
>
> TJG
oops.
My mistake. I am sorry to post such a braindead question here.
I mistook the host for the url here. Sorry.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Two attributes! Why?
On Nov 29, 5:21 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > This is a side-effect of name-mangling. Double-underscore names are only > mangled when they are referred to directly as attributes, not when they > are passed to setattr, getattr etc. Those functions don't do any name > mangling. Ah! That make sense! Thank you! It's a bit of an obscure thing right now. I don't see mention of it in the description of the setattr/getattr built-ins: http://docs.python.org/library/functions.html Wouldn't be good to have a hint of the issue there? Manu -- http://mail.python.org/mailman/listinfo/python-list
Re: end of print = lower productivity ?
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. That's a pretty malformed "proof": http://www.google.com/search?q=people%20you%20should%20listen%20to%20regarding%20choice%20of%20text-editor You don't appear anywhere in the top *10* pages...QED ;-) However, if you want to play that game, vim.org appears on page #1 of http://www.google.com/search?q=best+text+editor Use what editor works for you -- but if evolution in the language's features makes difficulties for you but not for users of other editors, it's your editor that's the problem, not the language. Viva-la-print-function'ly yers, -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Project structure - Best practices
In article <[EMAIL PROTECTED]>, Rafe <[EMAIL PROTECTED]> wrote: > >...and I completely agree. I always use the standard import form >unless absolutely necessary. However, I use 'as' to shorten the path >to the last module. For example: import app.foo.bar as bar instance = bar.Class() Why bother with ``as`` in this case? from app.foo import bar -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan -- http://mail.python.org/mailman/listinfo/python-list
Re: pydoc enforcement.
On Sun, 2008-11-30 at 16:27 -0800, [EMAIL PROTECTED] wrote: > 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 For the reasons already stated, I think it's probably a bad idea to enforce this at compile time. I think it's a great idea to make sure that this information is present in all your code, but unless you want to see useless stubs, the correct time to enforce this is at commit time. Don't accept any improperly documented patches. Syntax is not enough to ensure what you want to ensure. The semantics have to be right as well. Cheers, Cliff -- http://mail.python.org/mailman/listinfo/python-list
Re: Python surpasses Perl in popularity?
2008-12-1, 10:16(+00), Andre Majorel: [...] >> Tru64: >> /bin/sh can behave either as a Bourne shell or a POSIX shell >> (ksh88) depending on the environment > > How does it decide ? argv[0] ? isatty (STDIN_FILENO) ? That was answered in another article with a quote of the sh man page on Tru64: via an environment variable: BIN_SH. >> 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). > > Two other Unixen I know of that have a non-POSIX sh are SCO Open > Server and UnixWare. I'm not sure they even provide a > POSIX-compliant alternative like Solaris does. Again, see http://www.in-ulm.de/~mascheck/various/shells/ [...] > Many people assume "standard" equates "portable". As far as > shell programming is concerned, the safest way to get portability > is to ignore the standard and code for the Bourne shell. Yes, it's enough and relatively safe in most cases. It's the only option if you want to be portable to systems over 15 years old. But nowadays, especially since the specifications have been made public, I find that it is sufficiently widespread to make POSIX a safer bet. At least having a specification gives you some sort of guarantee: if you write your script by the rules that are clearly (most of the time) specified, then it should work on any compliant system. If it doesn't work, then it's not your fault (though it's true in many case, you'll still be the one who'll have to do something about it). -- Stéphane -- http://mail.python.org/mailman/listinfo/python-list
Re: double import protection - how to ?
Peter Otten wrote: Helmut Jarausch wrote: Peter Otten wrote: Helmut Jarausch wrote: Then it's a problem with a problem with a webserver written in Python (Karrigell-3.0) and probably related to multi-threading (the statements in my module get definitely executed more than once). Maybe you have the reload_modules* option switched on? That would defeat Python's caching in order to ease development. (*) see http://karrigell.sourceforge.net/en/configuration.htm Thanks Peter for the hint. Indeed, I am trying to port my application to Karrigell-3.0, where Python's caching is bypassed and the statements in the module get executed each time. So, I have to install a trap door using a global variable. Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyhon (with wxPython) on Windows' cygwin: can it be done fully ?
On Sat, 2008-11-29 at 13:31 -0800, Lie wrote:
> pdb and logging is too much for beginners, which most likely does not
> yet understand the workings of the debugger and logger (and pdb's many
> quirks). Don't forget that we're all beginners once. Python's learning
> curve shouldn't raise with time, it should get lower so more people
> can join in the board.
>>> import logging
>>> logging.basicConfig(level=logging.DEBUG)
>>>
>>> logging.debug("HERE!")
DEBUG:root:HERE!
>>> logging.debug("THERE!")
DEBUG:root:THERE!
>>> logging.info("abc")
INFO:root:abc
Ooh. Tough one.
The only thing that's missing is to have this clearly documented in
tutorials. (Maybe level 2, once you've learned the basics).
And if that's too hard for you, you can still use print("HERE!"). But
why sweat the "productivity loss" of the two parens when robust logging
is really that easy, and can be turned on or off at one place?
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to instantiate in a lazy way?
On 1 Dec., 16:30, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > I wouldn't use __getattr__ unless you've got lots of attributes to > overload. __getattr__ is a recipe for getting yourself into trouble > in my experience ;-) > > Just do it like this... > > class PayloadOnDemand(object): > def __init__(self, a_file, a_file_position): > self._data = None > self.f = a_file > self.file_position = a_file_position > > @property > def data(self): > if self._data is None: > self._data = self.really_read_the_data() > return self._data > > then you'll have a .data attribute which when you read it for the > first time it will populate itself. > > If None is a valid value for data then make a sentinel, eg > > class PayloadOnDemand(object): > sentinel = object() > > def __init__(self, a_file, a_file_position): > self._data = self.sentinel > self.f = a_file > self.file_position = a_file_position > > @property > def data(self): > if self._data is self.sentinel: > self._data = self.really_read_the_data() > return self._data > > -- > Nick Craig-Wood <[EMAIL PROTECTED]> --http://www.craig-wood.com/nick- Skjul > tekst i anførselstegn - > > - Vis tekst i anførselstegn - OK, I get it. In my case I have four attributes to create when one of them is accessed, I do not know if that is a lot of attributes;-) One thing I like about the __getattr__ is that it is only called that one single time where an attempt to read a data attribute fails because the attribute name is not defined in the __dict__ of the object. With the property methology you do the value check on each get, which does not look as "clean". The property methology is also a little less arcane I guess for less experienced Python programmers to understand when re-reading the code. What kind of trouble are you referring to in __getattr__? Is it recursive calls to the method on accessing object attributes in that method itself or other complications? On a related issue, thank you for showing me how to use @property as a decorator - I was not aware of that possibility, just gotta understand how to decorate a setter and delete method as well, but I should be able to look that up by myself... -- Slaunger -- http://mail.python.org/mailman/listinfo/python-list
Import of egg packages installed with easy_install
Hi. There's an already installed with easy_install packet, let's say flup, to the home catalog: $ ls -la ~/python/lib/python2.5/site-packages/ total 176 drwxr-xr-x 3 4096 Nov 29 18:57 . drwxr-xr-x 3 4096 Nov 29 18:51 .. -rw-r--r-- 1 208 Nov 29 18:57 easy-install.pth -rw-r--r-- 1 134573 Nov 29 18:51 flup-1.0.1-py2.5.egg -rw-r--r-- 1 2362 Nov 29 18:51 site.py -rw-r--r-- 1 1853 Nov 29 18:51 site.pyc $ cat ~/python/lib/python2.5/site-packages/easy-install.pth import sys; sys.__plen = len(sys.path) ./flup-1.0.1-py2.5.egg import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new) $ echo $PYTHONPATH /usr/lib64/portage/pym:/home/username/python/lib64/python2.5/site-packages $ python Python 2.5.2 (r252:60911, Nov 13 2008, 15:01:36) [GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import flup No errors. Then I create a simple CGI script: #!/usr/bin/python print "Content-type: text/plain"; print import sys sys.path.insert (0, '/home/username/python/lib64/python2.5/site-packages') print sys.path import flup Browser says: ['/home/username/python/lib64/python2.5/site-packages', '/home/username/http', '/usr/lib64/python25.zip', '/usr/lib64/python2.5', '/usr/lib64/python2.5/plat-linux2', '/usr/lib64/python2.5/lib-tk', '/usr/lib64/python2.5/lib-dynload', '/usr/lib64/python2.5/site-packages'] in error log: [Sat Nov 29 19:41:15 2008] [error] Traceback (most recent call last): [Sat Nov 29 19:41:15 2008] [error] File "path.cgi", line 9, in [Sat Nov 29 19:41:15 2008] [error] import flup [Sat Nov 29 19:41:15 2008] [error] ImportError: No module named flup If you start it with console, you get the same, but there appears also another path: /home/username/python/lib64/python2.5/site-packages/flup-1.0.1-py2.5.egg As I understand it is the problem actually, but I can't get why sys.path doesn't contain this path when I request with HTTP. -- BRGDS. Alexey Vlasov. -- http://mail.python.org/mailman/listinfo/python-list
python 2.5.2 or Python 2.6 compilation problem on AIX 5.3
Hello: I am trying to compile Python 2.5.2 on AIX 5.3 with gcc 4.2.3. I am getting following error. (I also tried Python 2.6 with same error) creating build/temp.aix-5.3-2.5/share/tmhsdsd2/tmp/Python-2.5.2/ Modules gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall - Wstrict-prototypes -I. -I/share/tmhsdsd2/tmp/Python-2.5.2/./Include - I. -IInclude -I./Include -I/usr/local/include -I/share/tmhsdsd2/tmp/ Python-2.5.2/Include -I/share/tmhsdsd2/tmp/Python-2.5.2 -c /share/ tmhsdsd2/tmp/Python-2.5.2/Modules/_struct.c -o build/temp.aix-5.3-2.5/ share/tmhsdsd2/tmp/Python-2.5.2/Modules/_struct.o creating build/lib.aix-5.3-2.5 ./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp build/ temp.aix-5.3-2.5/share/tmhsdsd2/tmp/Python-2.5.2/Modules/_struct.o -L/ usr/local/lib -lpython2.5 -o build/lib.aix-5.3-2.5/_struct.so collect2: library libpython2.5 not found *** WARNING: renaming "_struct" since importing it failed: 0509-022 Cannot load module build/lib.aix-5.3-2.5. 0509-026 System error: A file or directory in the path name does not exist. error: No such file or directory make: 1254-004 The error code from the last command is 1. Stop. I am not able to find the problem. I would appreciate, if you could help. I used following command line options to confugure. ./configure --prefix=/home/hci/dinakar/python25 -enable-shared --with- gcc Thank you. Dinakar -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyhon (with wxPython) on Windows' cygwin: can it be done fully ?
At first I also disliked print's new syntax, but later I realised it
could be useful.
However, I agree that the parentheses are annoying. Not because of the
parens theirselves, but because of the Shift key.
Why programmers stilll can't have special keyboards with parens keys
that doesn't need pressing "shift"? Isn't time C programmers have a
"&" key and perl programmers a $ one? And why the heck we need shift
for "(" and not for "[" or "{", since the first one is much more used
(even outside programming)?
Really, we don't need to change our syntax, we need to change our
keyboards. We are so blinded by tradition that we are losing
productivity.
--
http://mail.python.org/mailman/listinfo/python-list
Re: HTML File Parsing
On Oct 28, 3:18 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> Felipe De Bene wrote:
> > I'm having problems parsing an HTML file with the following syntax :
>
> >
> > User ID
> > Name > BGCOLOR='#c0c0c0'>Date
> > and so on
>
> > whenever I feed the parser with such file I get the error :
>
> > HTMLParser.HTMLParseError: bad end tag: "", at
> > line 515, column 45
>
> Your HTML page is not HTML, i.e. it is broken. Python's HTMLParser is not made
> for parsing broken HTML. However, you can use the parse of lxml.html to fix up
> your HTML for you.
>
> http://codespeak.net/lxml/
>
> Stefan
It doesn't just choke on bad HTML, it also chokes on javascript that
writes HTML, e.g. document.write('http://mail.python.org/mailman/listinfo/python-list
Re: How to distribute a Python app together with its dependencies?
On 1 Dic, 15:21, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Nov 30, 6:22 am, Alessio Pace <[EMAIL PROTECTED]> wrote: > > > > > 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. > > I recommend GUI2Exe, a nice wrapper to py2exe, py2app, PyInstaller, > cx_Freeze and bbFreeze: > > http://code.google.com/p/gui2exe/ > > I've only used the py2exe portion of the program, but it works great > and the developers behind the project are very responsive and helpful. > > Mike Hi all and thanks for the replies. Apparenlty I managed to make the standalone application with bbfreeze (used directly), I still have to tune a little bit how it can pack in it also classes which are loaded dynamically, and which from a static examination of the code are not found then... I'll try to give a look at GUI2Exe also, thank you for the suggestion. Regards, Alessio Pace. -- http://mail.python.org/mailman/listinfo/python-list
optimization
I noticed in some profiling, that it seems that: def Func (): def something(): ... It appears that if Func is called many times, this nested func definition will cause significant overhead. Is this true? I guess I've become accustomed to decent compilers performing reasonable transformations and so have tended to write code for clarity. -- http://mail.python.org/mailman/listinfo/python-list
Re: optimization
Neal> I noticed in some profiling, that it seems that: Neal> def Func (): Neal> def something(): Neal> ... Neal> It appears that if Func is called many times, this nested func Neal> definition will cause significant overhead. Is this true? I Neal> guess I've become accustomed to decent compilers performing Neal> reasonable transformations and so have tended to write code for Neal> clarity. It could. OTOH, the code object which implements the something body is stored as a local var (or a constant, can't remember off the top of my head), so it's not compiled over and over again. -- Skip Montanaro - [EMAIL PROTECTED] - http://smontanaro.dyndns.org/ -- http://mail.python.org/mailman/listinfo/python-list
Chmod to a group only
How to chmod a file to: o-rwx ? (to change only the others mode) os.chmod(fname, ) I was reading this [1], but the truth is that anything as 'S_IRUSR' doesn't help enought. [1] http://www.python.org/doc/2.5.2/lib/os-file-dir.html -- http://mail.python.org/mailman/listinfo/python-list
Reg: PIL2.4 Error: AttributeError: pixel_access
Hi all,
I am facing the following problem in PIL 2.4:
Code:
img = ImageGrab.grab()
img.save("image2.jpg")
Error:
img.save("image2.jpg")
File "C:\Python24\Lib\site-packages\PIL\Image.py", line 1372, in
save
self.load()
File "C:\Python24\Lib\site-packages\PIL\Image.py", line 599, in load
return self.im.pixel_access(self.readonly)
AttributeError: pixel_access
When I googled this error, I saw that such an error could be because
of some botched installation. So, I re-installed PIL. But still this
error persists.
The version is
>>> print Image.VERSION
1.1.6
I had installed PIL in Python2.5 earlier and had done image capture
also. But I need to go back to Python2.4 (because pymedia exe is
available for only python2.4) and now I am facing this issue.
I am pretty new to application programming, so if someone can help me
out, it would be very helpful.
Regards,
Kottiyath
--
http://mail.python.org/mailman/listinfo/python-list
Re: Debugging in Python
Scott David Daniels wrote: Stef Mientki wrote: I'm not completely satisfied with even the "best" debuggers, most of the good ones are too difficult, so I want to wrap rpdb2 and don't want to miss any great features ;-) I think ActiveState has a free 21-day trial, so you could check it out yourself if you are willing to spend the concentrated time to check it out. That is correct. Also the Python debugging docs are here, if that might help: http://docs.activestate.com/komodo/5.0/debugpython.html Their license terms are reasonable (the license is attached to _you_, not a particular machine you run it on, as I remember. Also correct: with a Komodo IDE license you can use Komodo on any machine that you use. Trent -- Trent Mick trentm at activestate.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python introspection and namespace weird question
On Mon, Dec 1, 2008 at 6:04 AM, Rayene Ben Rayana <[EMAIL PROTECTED]> wrote: > Hello everybody, > > Is there an easy way to do something like this in python ? > red_car = MyVehicleClass() car = red_car car.labels() > ['red_car' , 'car' ] > > In other words, does an instance has access to its name pointers ? In short, No. (Cue another debate over whether Python uses call-by-X semantics...) Typically people who want to do such things actually want/should use a dictionary mapping string keys to instance values instead. Note that in certain limited cases, voodoo involving the locals() or globals() built-in functions or the `inspect` module can work, but not in the common general case. But generally these techniques are considered bad style and kludgey unless you're writing a debugger or something equally meta, with using a dictionary as explained previously being much preferred. For example, for your particular code above, the following happens to work: [name for name, obj in locals().iteritems() if obj is car] #==> ['red_car' , 'car' ] But this will only give the names in the current function of the particular car object. Likewise, globals() works only for module-level names, and the `inspect` module's magic only works for names in calling functions (i.e. those below the current one in the callstack). Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com > > Thanks in advance, > > Rayene > > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
What I have done is skipped the whole Vim/Emacs obscure editor thing and opted for PyScripter (see http://mmm-experts.com/Products.aspx?ProductID=4 ). It might not be as complete/complex as these other editors but it is easy to use and just lets me get on with the task of cutting code. As a fall-back I also use EditPlus (see http://www.editplus.com/index.html ). Its only for Windows and its shareware so you need to pay for it. Its clip library makes it a VERY GOOD text editor. It's a real shame there are NO text editors with such a comprehensive and easy to modify clip library function (I would be really pleased to be proven wrong on this last point :-) ). However, the best advice I think that can be given about editors is keep trying them until you find the one YOU like. We all like different things, especially when it comes to editors. Regards, Peter -- *Peter Anderson* There is nothing more difficult to take in hand, more perilous to conduct, or more uncertain in its success, than to take the lead in the introduction of a new order of things—Niccolo Machiavelli, /The Prince/, ch. 6 -- http://mail.python.org/mailman/listinfo/python-list
Re: optimization
[EMAIL PROTECTED] wrote: Neal> I noticed in some profiling, that it seems that: Neal> def Func (): Neal> def something(): Neal> ... Neal> It appears that if Func is called many times, this nested func Neal> definition will cause significant overhead. Is this true? I Neal> guess I've become accustomed to decent compilers performing Neal> reasonable transformations and so have tended to write code for Neal> clarity. It could. OTOH, the code object which implements the something body is stored as a local var (or a constant, can't remember off the top of my head), so it's not compiled over and over again. Constant. With 3.0... >>> def f(): def g(): pass >>> import dis >>> dis.dis(f) 2 0 LOAD_CONST 1 (0x0137D920, file "", line 2>) 3 MAKE_FUNCTION0 6 STORE_FAST 0 (g) 9 LOAD_CONST 0 (None) 12 RETURN_VALUE If the inner function is constant and does not directly access outer function locals, and if every last tick of speed is a concern, then it can be move out and given a name like _outer_helper. I would go for clarity and correctness first, but I would also wonder whether an inner function that is independent of its setting and therefore movable might be turned into something of more general use and usefully moved out for purposes other than just speed. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5.2 or Python 2.6 compilation problem on AIX 5.3
[EMAIL PROTECTED] wrote: Hello: I am trying to compile Python 2.5.2 on AIX 5.3 with gcc 4.2.3. I am getting following error. (I also tried Python 2.6 with same error) creating build/temp.aix-5.3-2.5/share/tmhsdsd2/tmp/Python-2.5.2/ Modules gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall - Wstrict-prototypes -I. -I/share/tmhsdsd2/tmp/Python-2.5.2/./Include - I. -IInclude -I./Include -I/usr/local/include -I/share/tmhsdsd2/tmp/ Python-2.5.2/Include -I/share/tmhsdsd2/tmp/Python-2.5.2 -c /share/ tmhsdsd2/tmp/Python-2.5.2/Modules/_struct.c -o build/temp.aix-5.3-2.5/ share/tmhsdsd2/tmp/Python-2.5.2/Modules/_struct.o creating build/lib.aix-5.3-2.5 ./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp build/ temp.aix-5.3-2.5/share/tmhsdsd2/tmp/Python-2.5.2/Modules/_struct.o -L/ usr/local/lib -lpython2.5 -o build/lib.aix-5.3-2.5/_struct.so collect2: library libpython2.5 not found Have you checked all the directories on PATH to see if any contain libpython2.5? *** WARNING: renaming "_struct" since importing it failed: 0509-022 Cannot load module build/lib.aix-5.3-2.5. 0509-026 System error: A file or directory in the path name does not exist. error: No such file or directory make: 1254-004 The error code from the last command is 1. Stop. I am not able to find the problem. I would appreciate, if you could help. I used following command line options to confugure. ./configure --prefix=/home/hci/dinakar/python25 -enable-shared --with- gcc Thank you. Dinakar -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Import of egg packages installed with easy_install
Alexey Vlasov wrote:
> Hi.
>
> There's an already installed with easy_install packet, let's say flup,
> to the home catalog:
> $ ls -la ~/python/lib/python2.5/site-packages/
> total 176
> drwxr-xr-x 3 4096 Nov 29 18:57 .
> drwxr-xr-x 3 4096 Nov 29 18:51 ..
> -rw-r--r-- 1 208 Nov 29 18:57 easy-install.pth
> -rw-r--r-- 1 134573 Nov 29 18:51 flup-1.0.1-py2.5.egg
> -rw-r--r-- 1 2362 Nov 29 18:51 site.py
> -rw-r--r-- 1 1853 Nov 29 18:51 site.pyc
>
>
> $ cat ~/python/lib/python2.5/site-packages/easy-install.pth
> import sys; sys.__plen = len(sys.path)
> ./flup-1.0.1-py2.5.egg
> import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:];
> p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert =
> p+len(new)
>
> $ echo $PYTHONPATH
> /usr/lib64/portage/pym:/home/username/python/lib64/python2.5/site-packages
>
> $ python
> Python 2.5.2 (r252:60911, Nov 13 2008, 15:01:36)
> [GCC 4.1.2 (Gentoo 4.1.2 p1.1)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
import flup
>
> No errors.
>
> Then I create a simple CGI script:
>
> #!/usr/bin/python
>
> print "Content-type: text/plain";
> print
>
> import sys
> sys.path.insert (0,
> '/home/username/python/lib64/python2.5/site-packages')
> print sys.path
> import flup
>
>
> Browser says:
> ['/home/username/python/lib64/python2.5/site-packages',
> '/home/username/http', '/usr/lib64/python25.zip',
> '/usr/lib64/python2.5', '/usr/lib64/python2.5/plat-linux2',
> '/usr/lib64/python2.5/lib-tk', '/usr/lib64/python2.5/lib-dynload',
> '/usr/lib64/python2.5/site-packages']
>
> in error log:
> [Sat Nov 29 19:41:15 2008] [error] Traceback (most recent call last):
> [Sat Nov 29 19:41:15 2008] [error] File "path.cgi", line 9, in
> [Sat Nov 29 19:41:15 2008] [error] import flup
> [Sat Nov 29 19:41:15 2008] [error] ImportError: No module named flup
>
>
> If you start it with console, you get the same, but there appears also
> another path:
> /home/username/python/lib64/python2.5/site-packages/flup-1.0.1-py2.5.egg
>
> As I understand it is the problem actually, but I can't get why sys.path
> doesn't contain this path when I request with HTTP.
It's not sufficient to add simply your local site-packages, you must install
it using the module site's addsitedir-function, like this:
import site
site.addsitedir("/home/username/python/lib/python2.5/site-packages")
The reason is that otherwise the *.pth-files in the site-packages aren't
picked up.
Diez
--
http://mail.python.org/mailman/listinfo/python-list
Re: end of print = lower productivity ?
I actually trust that the developers had good reasons for this change, but I think it is silly to argue that it is costless. The question is, what is the cost-benefit trade-off? One obvious cost is that working at the interpreter prompt is now slightly less convenient. Just because the cost is small does not mean it should not be offset by a benefit. I am less sympathetic to the suggestion that there is an inconvenience when working in an editor, but clearly some people find one. My preferred transition would have been to retain the `print` statement but add a `printf` function (i.e., the new `print` function). Presumably many would find this a repulsive redundancy and a needless maintenance headache. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Dec 1st Python Meeting Cancellation
Hi all! Sorry for the very short notice, but the Python Programming group is canceling tonight's meeting due to inclement weather, lack of interest and sickness. We hope to see you at our next meeting, which will be Monday, January 5th, 2009. Happy holidays! Mike Driscoll http://www.pyowa.org -- http://mail.python.org/mailman/listinfo/python-list
Checking a string against multiple matches
I've been trying to read up on this, but I'm not sure what the simplest way to do it is. I have a list of string. I'd like to check to see if any of the strings in that list matches another string. Pseudocode: if "two" in ["one", "two", "three", "four"]: return True Is there any built-in iteration that would do such a thing, or do I have to write a function to check for me? I was using .index on the list, but it would return True for strings that contained the search string rather than match it exactly, leading to false positives in my code. -- http://mail.python.org/mailman/listinfo/python-list
Spring Python 0.9.0 is released
Spring Python, the python version of the Spring Framework, has just released version 0.9.0. This release includes a key update to springpython.security.web module, where authorization has been patched to support CherryPy 3.1. To download the 0.9.0 release, or an archived release, and for access to sample applications use http://www.springsource.com/download/community?project=Spring%20Extensions Please visit the website at http://springpython.webfactional.com for information about features, releases, source code, licensing, and official documentation. == Release Notes - Spring Python - Version 0.9 Bug * [SESPRINGPYTHONPY-81] - Fix AccessDecisionManager based on CherryPy 3 upgrade Task * [SESPRINGPYTHONPY-76] - Convert sample applications to new XMLConfig format. == Key Features of Spring Python include: * Inversion Of Control - The idea is to decouple two classes at the interface level. This lets you build many reusable parts in your software, and your whole application becomes more pluggable. You can use either the XmlApplicationContext or the DecoratorBasedApplicationContext. * Aspect-oriented Programming - Spring Python provides great ways to wrap advice around objects. It is utilized for remoting. Another use is for debug tracers and performance tracing. * DatabaseTemplate - Reading from the database requires a monotonous cycle of opening cursors, reading rows, and closing cursors, along with exception handlers. With this template class, all you need is the SQL query and row-handling function. Spring Python does the rest. * Database Transactions - Wrapping multiple database calls with transactions can make your code hard to read. This module provides multiple ways to define transactions without making things complicated. * Security - Plugin security interceptors to lock down access to your methods, utilizing both authentication and domain authorization. * Remoting - It is easy to convert your local application into a distributed one. If you have already built your client and server pieces using the IoC container, then going from local to distributed is just a configuration change. * Samples - to help demonstrate various features of Spring Python, some sample applications have been created: o PetClinic - Everybody's favorite Spring sample application has been rebuilt from the ground up using various web containers including: CherryPy. Go check it out for an example of how to use this framework. o Spring Wiki - Wikis are powerful ways to store and manage content, so we created a simple one as a demo! o Spring Bot - Use Spring Python to build a tiny bot to manage the IRC channel of your open source project. -- http://mail.python.org/mailman/listinfo/python-list
Re: Checking a string against multiple matches
On Mon, Dec 1, 2008 at 2:31 PM, Aaron Scott <[EMAIL PROTECTED]> wrote: > Pseudocode: > > if "two" in ["one", "two", "three", "four"]: > return True That works, just like you wrote it: >>> "two" in ["one", "two", "three", "four"] True >>> "two" in ["one", "twofer", "three", "four"] False If that doesn't answer your question, maybe you could give some examples. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re: Checking a string against multiple matches
Aaron Scott wrote:
> I've been trying to read up on this, but I'm not sure what the
> simplest way to do it is.
>
> I have a list of string. I'd like to check to see if any of the
> strings in that list matches another string.
>
> Pseudocode:
>
> if "two" in ["one", "two", "three", "four"]:
> return True
Why /pseudo/ ?
>>> if "two" in ["one", "two", "three", "four"]:
... print "match"
... else:
... print "no match"
...
match
>>> if "seven" in ["one", "two", "three", "four"]:
... print "match"
... else:
... print "no match"
...
no match
> Is there any built-in iteration that would do such a thing, or do I
> have to write a function to check for me? I was using .index on the
> list, but it would return True for strings that contained the search
> string rather than match it exactly, leading to false positives in my
> code.
You didn't check carefully. list.index() gives you a value error when no
matching item is found:
>>> ["one", "two", "three", "four"].index("seven")
Traceback (most recent call last):
File "", line 1, in
ValueError: list.index(x): x not in list
Peter
--
http://mail.python.org/mailman/listinfo/python-list
Re: Two attributes! Why?
Emanuele D'Arrigo wrote: On Nov 29, 5:21 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: This is a side-effect of name-mangling. Double-underscore names are only mangled when they are referred to directly as attributes, not when they are passed to setattr, getattr etc. Those functions don't do any name mangling. Even as attributes, they are only mangled within the class definition. "__* Class-private names. Names in this category, when used within the context of a class definition, are re-written to use a mangled form to help avoid name clashes between “private” attributes of base and derived classes. See section Identifiers (Names). " Class-private is intended to mean 'private', not known and not used outside the class definition. I believe the 'mangled' form is intentionally not documented. Ah! That make sense! Thank you! It's a bit of an obscure thing right now. I don't see mention of it in the description of the setattr/getattr built-ins: http://docs.python.org/library/functions.html Wouldn't be good to have a hint of the issue there? I think not. The functions tell the truth when they say 'no such attribute' Any mention might suggest that trying to access private names from outside the class is a sensible thing to do. Perhaps the __* doc quoted above could be improved. Is anything there unclear? Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Chmod to a group only
On 1 dic, 18:17, Kless <[EMAIL PROTECTED]> wrote: > How to chmod a file to: o-rwx ? (to change only the others mode) > > os.chmod(fname, ) > > I was reading this [1], but the truth is that anything as 'S_IRUSR' > doesn't help enought. > > [1]http://www.python.org/doc/2.5.2/lib/os-file-dir.html I have tried: mode = os.stat(fname).st_mode os.chmod(fname, mode | stat.S_IRWXO) => Changes to o+rwx and if is used: os.chmod(fname, mode & stat.S_IRWXO) => Delete all modes Any help? please -- http://mail.python.org/mailman/listinfo/python-list
Re: What about a decorator module version 3.0?
Michele Simionato wrote: What do you people think? I am not a user yet, but my opinion anyway... Release a final 2.x version with whatever internal changes but with external api unchanged or at least backward compatible. Mark items to be deleted as deprecated. Keep that available indefinately. Then release a 3.0 version with Py3.0 support and deprecated items deleted. -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
Peter Anderson wrote: What I have done is skipped the whole Vim/Emacs obscure editor thing and opted for PyScripter (see http://mmm-experts.com/Products.aspx?ProductID=4 ). It might not be as complete/complex as these other editors but it is easy to use and just lets me get on with the task of cutting code. if it works it's a fair good editor, but if it doesn't (I have to restart the editor about each hour) ... As a fall-back I also use EditPlus (see http://www.editplus.com/index.html ). Its only for Windows but PyScripter is also only for windows ;-) and its shareware so you need to pay for it. Its clip library makes it a VERY GOOD text editor. It's a real shame there are NO text editors with such a comprehensive and easy to modify clip library function (I would be really pleased to be proven wrong on this last point :-) ). What so great about it ? I use a template manager, written in pure python, works under any OS (where Python is installed) and can be used with any text editor and is open source and completely free. I think it has at least the same capabilities as the Komodo clip library. Somewhere in the middle of the following page are a few notes: http://mientki.ruhosting.nl/data_www/pylab_works/pw_code_editor.html and you can find the sources here: http://code.google.com/p/pylab-works/downloads/list However, the best advice I think that can be given about editors is keep trying them until you find the one YOU like. We all like different things, especially when it comes to editors. +1 cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: Python introspection and namespace weird question
Thanks Chris, Yeah it is kinda meta thing. My app allows to create a scene (a set of GUI objects). A scene can be saved as a python script. And, it can be loaded again using execfile(). each GUI object has a label. So, in the script scene, declaring an object in a scene file should look like this: red_car = MyVehicleClass(*label* = 'red_car') But, I wanted to simplify the syntax of scene files and avoid repetition so it would look like red_car = MyVehicleClass() with the *label* attribute automatically set to the name of the corresponding variable. I tried your locals().iteritems tip and it works perfectly. The question now is: Given what I just explained, do you still think it is bad programming to do that ? Should I better use the first syntax ? Cheers, Rayene, I want to use that to simplify the syntax of the On Mon, Dec 1, 2008 at 7:37 PM, Chris Rebert <[EMAIL PROTECTED]> wrote: > On Mon, Dec 1, 2008 at 6:04 AM, Rayene Ben Rayana > <[EMAIL PROTECTED]> wrote: > > Hello everybody, > > > > Is there an easy way to do something like this in python ? > > > red_car = MyVehicleClass() > car = red_car > car.labels() > > ['red_car' , 'car' ] > > > > In other words, does an instance has access to its name pointers ? > > In short, No. (Cue another debate over whether Python uses call-by-X > semantics...) > > Typically people who want to do such things actually want/should use a > dictionary mapping string keys to instance values instead. > > Note that in certain limited cases, voodoo involving the locals() or > globals() built-in functions or the `inspect` module can work, but not > in the common general case. But generally these techniques are > considered bad style and kludgey unless you're writing a debugger or > something equally meta, with using a dictionary as explained > previously being much preferred. > > For example, for your particular code above, the following happens to work: > [name for name, obj in locals().iteritems() if obj is car] #==> > ['red_car' , 'car' ] > > But this will only give the names in the current function of the > particular car object. Likewise, globals() works only for module-level > names, and the `inspect` module's magic only works for names in > calling functions (i.e. those below the current one in the callstack). > > Cheers, > Chris > -- > Follow the path of the Iguana... > http://rebertia.com > > > > > Thanks in advance, > > > > Rayene > > > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP!...Google SketchUp needs a Python API
Rome is Burning! Pay particular attention to the second paragraph. Narcissistic culture Main article: The Culture of Narcissism Historian and social critic Christopher Lasch described this topic in his book, "The Culture of Narcissism",[3] published in 1979. He defines a narcissistic culture as one in which every activity and relationship is defined by the hedonistic need to acquire the symbols of spiritual wealth, this becoming the only expression of rigid, yet covert, social hierarchies. It is a culture where liberalism only exists insofar as it serves a consumer society, and even art, sex and religion lose their liberating power. In such a society of constant competition, there can be no allies, and little transparency. The threats to acquisitions of social symbols are so numerous, varied and frequently incomprehensible, that defensiveness, as well as competitiveness, becomes a way of life. Any real sense of community is undermined -- or even destroyed -- to be replaced by virtual equivalents that strive, unsuccessfully, to synthesize a sense of community. It can mean also many other things. Contrary to Lasch, Bernard Stiegler argues in his book, Aimer, s’aimer, nous aimer: Du 11 septembre au 21 avril, that consumer capitalism is in fact destructive of what he calls primordial narcissism, without which it is not possible to extend love to others. -food for thought- -- http://mail.python.org/mailman/listinfo/python-list
Re: Checking a string against multiple matches
Damn you, Python, and your loose documentation! It never occurred to me to actually TRY my pseudocode, since I couldn't find anything on that type of statement. Anyway, feel free to ignore me from now on. -- http://mail.python.org/mailman/listinfo/python-list
Re: end of print = lower productivity ?
Alan G Isaac wrote: I actually trust that the developers had good reasons for this change, but I think it is silly to argue that it is costless. Guido ever argued that. The question is, what is the cost-benefit trade-off? Uniformity of language, flexibility, and removal of the >> hack that Guido hated after adding. Check the pydev discussions. One obvious cost is that working at the interpreter prompt is now slightly less convenient. But neither 'print' nor 'print()' is needed at the interpreter prompt. > Just because the cost is small does not mean it should not be offset by a benefit. I am less sympathetic to the suggestion that there is an inconvenience when working in an editor, but clearly some people find one. That is the only time 'print' or 'print()' is needed. I find it a minor nuisance also, but then I should learn to touch-type () better anyway for all the other uses. My preferred transition would have been to retain the `print` statement but add a `printf` function (i.e., the new `print` function). Presumably many would find this a repulsive redundancy and a needless maintenance headache. Yes. tjr -- http://mail.python.org/mailman/listinfo/python-list
newbie question: parse a variable inside an RE?
Hi All,
How do I parse a variable inside an RE?
What is the re.search() syntax when your
search string is a variable?
It's easy to parse hardcoded RE's but not
if you use a variable.
Here is my code, input and runtime:
$ cat test45.py
#!/usr/bin/python
import re
resp = raw_input('Selection: ')
newresp = resp.strip()
print "you chose ", newresp
fname = open('test44.in')
for I in fname:
#if re.search('^newresp', "%s"%(I)): # returns nothing
#if re.search(^newresp, "%s"%(I)): # syntax error
if re.search("^newresp", "%s"%(I)): # returns nothing
print I,
[EMAIL PROTECTED] work]$ cat test44.in
a1
b1
g1
g2
h1
h4
4g
5g
h5
$ python test45.py
Selection: g
you chose g
$
Thanks...
--
http://mail.python.org/mailman/listinfo/python-list
Re: Checking a string against multiple matches
On Mon, Dec 1, 2008 at 3:29 PM, Aaron Scott <[EMAIL PROTECTED]> wrote: > Damn you, Python, and your loose documentation! It never occurred to > me to actually TRY my pseudocode, since I couldn't find anything on > that type of statement. Anyway, feel free to ignore me from now on. I'm not sure where you think the "in" operator should be documented. It's in the documentation for sequence types: http://docs.python.org/library/stdtypes.html#sequence-types-str-unicode-list-tuple-buffer-xrange The tutorial points there too, in its discussion of strings. It's also in the language reference, in the section on comparision operators: http://docs.python.org/reference/expressions.html#id12 Was there someplace you were looking that you expected to find something about the containment operator and couldn't find it? Maybe it would be worth adding a "See Also" someplace? -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re: Emacs vs. Eclipse vs. Vim
Peter Anderson <[EMAIL PROTECTED]> writes: > What I have done is skipped the whole Vim/Emacs obscure editor thing > and opted for PyScripter PyScripter is not obscure, compared to Emacs and Vim? I think I need a new ironometer. -- \ “I went to a garage sale. ‘How much for the garage?’ ‘It's not | `\for sale.’” —Steven Wright | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5.2 or Python 2.6 compilation problem on AIX 5.3
On Dec 1, 1:06 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Hello: > > I am trying to compile Python 2.5.2 on AIX 5.3 with gcc 4.2.3. I am > > getting following error. (I also tried Python 2.6 with same error) > > > creating build/temp.aix-5.3-2.5/share/tmhsdsd2/tmp/Python-2.5.2/ > > Modules > > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall - > > Wstrict-prototypes -I. -I/share/tmhsdsd2/tmp/Python-2.5.2/./Include - > > I. -IInclude -I./Include -I/usr/local/include -I/share/tmhsdsd2/tmp/ > > Python-2.5.2/Include -I/share/tmhsdsd2/tmp/Python-2.5.2 -c /share/ > > tmhsdsd2/tmp/Python-2.5.2/Modules/_struct.c -o build/temp.aix-5.3-2.5/ > > share/tmhsdsd2/tmp/Python-2.5.2/Modules/_struct.o > > creating build/lib.aix-5.3-2.5 > > > ./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp build/ > > temp.aix-5.3-2.5/share/tmhsdsd2/tmp/Python-2.5.2/Modules/_struct.o -L/ > > usr/local/lib -lpython2.5 -o build/lib.aix-5.3-2.5/_struct.so > > collect2: library libpython2.5 not found > > Have you checked all the directories on PATH to see if any contain > libpython2.5? > Thanks for your response. libpython2.5.a is in the current directory same as Makefile. Thank you. Dinakar -- http://mail.python.org/mailman/listinfo/python-list
Is it safe to modify the dict returned by vars() or locals()
Hi, I am looking for an elegant way to solve the following problem: Within a function def Foo(**parms) I have a list of names, say VList=['A','B','C1'] and I like to generate abbreviation _A identical to parms['A'] for that I could write def Foo(**parms) : for N in VList : if N in parms : vars()[N]= parms[N] else : vars()[N]= None Does this work, is it typical Python? Many thanks for a hint, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list
Re: Chmod to a group only
Kless wrote: > On 1 dic, 18:17, Kless <[EMAIL PROTECTED]> wrote: >> How to chmod a file to: o-rwx ? (to change only the others mode) >> >> os.chmod(fname, ) >> >> I was reading this [1], but the truth is that anything as 'S_IRUSR' >> doesn't help enought. >> >> [1]http://www.python.org/doc/2.5.2/lib/os-file-dir.html > > I have tried: > > mode = os.stat(fname).st_mode > os.chmod(fname, mode | stat.S_IRWXO) => Changes to o+rwx How did the result of the above differ from what you want? The way I read your original post something like the above would have been my answer... Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie question: parse a variable inside an RE?
2008/12/1 <[EMAIL PROTECTED]>
> Hi All,
>
> How do I parse a variable inside an RE?
> What is the re.search() syntax when your
> search string is a variable?
> It's easy to parse hardcoded RE's but not
> if you use a variable.
>
> Here is my code, input and runtime:
>
> $ cat test45.py
> #!/usr/bin/python
>
> import re
>
> resp = raw_input('Selection: ')
> newresp = resp.strip()
> print "you chose ", newresp
>
> fname = open('test44.in')
> for I in fname:
> #if re.search('^newresp', "%s"%(I)): # returns nothing
> #if re.search(^newresp, "%s"%(I)): # syntax error
>if re.search("^newresp", "%s"%(I)): # returns nothing
>print I,
>
> [EMAIL PROTECTED] work]$ cat test44.in
> a1
> b1
> g1
> g2
> h1
> h4
> 4g
> 5g
> h5
>
> $ python test45.py
> Selection: g
> you chose g
> $
>
> Thanks...
> --
> http://mail.python.org/mailman/listinfo/python-list
>
It doesn't seem very robust, but it can be made work, try e.g.:
for item in fname:
if re.search("^"+newresp, "%s" % (item,)):
print item,
(prints: g1 g2 in a similar code)
(if you know, that item is a string, the %s interpolation is not needed; you
can also use re match, without hte need for "^" .
hth
vbr
--
http://mail.python.org/mailman/listinfo/python-list
Thread always alive
Hi, I have thread that the isAlive() method is always returning True even the last finally(..) clause is executed. I am suspecting some kind of a leak on a IO object like a file or socket descriptor is still open. Could this lead to this kind of problem? If yes, how can I debug this issue efficiently to see the leak? Thanks, -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it safe to modify the dict returned by vars() or locals()
On Mon, Dec 1, 2008 at 1:01 PM, Helmut Jarausch <[EMAIL PROTECTED]> wrote: > Hi, > > I am looking for an elegant way to solve the following problem: > > Within a function > > def Foo(**parms) > > I have a list of names, say VList=['A','B','C1'] > and I like to generate abbreviation > _A identical to parms['A'] Could you explain what you mean by that? Your sample code doesn't seem to do any "abbreviation"... Otherwise I don't see why you don't just have a proper parameter list. > > for that I could write > > def Foo(**parms) : > for N in VList : >if N in parms : > vars()[N]= parms[N] >else : > vars()[N]= None > > Does this work, is it typical Python? >From the docs (http://docs.python.org/library/functions.html): locals() Update and return a dictionary representing the current local symbol table. *Warning*: The contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter. Free variables are returned by locals() when it is called in a function block. Modifications of free variables may not affect the values used by the interpreter. Free variables are not returned in class blocks. As the warning states, it modifying the dict doesn't really work (except at the module level, but that's an implementation detail IIRC) For example: >>> def foo(): ... a = 3 ... l = locals() ... l['a'] = 5 ... print a ... >>> foo() 3 In any case, it'd be considered a bit of a hack. Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com > > Many thanks for a hint, > Helmut. > > -- > Helmut Jarausch > > Lehrstuhl fuer Numerische Mathematik > RWTH - Aachen University > D 52056 Aachen, Germany > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Why doesn't doc has predifined name and location ?
hello, I'm very satisfied about the great standardization of doc strings in python. Now in contrast to that, the general documentation of libraries, either in plain text, html, pdf, chm, ... doesn't have a standarized name nor location. Why is that ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it safe to modify the dict returned by vars() or locals()
Helmut Jarausch wrote:
> I am looking for an elegant way to solve the following problem:
>
> Within a function
>
> def Foo(**parms)
>
> I have a list of names, say VList=['A','B','C1']
> and I like to generate abbreviation
> _A identical to parms['A']
>
> for that I could write
>
> def Foo(**parms) :
>for N in VList :
> if N in parms :
>vars()[N]= parms[N]
> else :
>vars()[N]= None
>
> Does this work, is it typical Python?
locals() gives you a copy of the local namespace. No changes to the copy are
written back to that namespace.
In idiomatic python you'd just use the dictionary. If you are bothered with
the non-existent keys, make a copy
>>> parms = dict(a=1, c=3)
>>> p = dict.fromkeys(["a", "b", "c"])
>>> p.update(parms)
>>> p["a"], p["b"], p["c"]
(1, None, 3)
>>> p["x"]
Traceback (most recent call last):
File "", line 1, in
KeyError: 'x'
or, setting any non-existent key to None:
>>> from collections import defaultdict
>>> parms = dict(a=1, c=3)
>>> p = defaultdict(lambda: None)
>>> p.update(parms)
>>> p["a"], p["b"], p["c"]
(1, None, 3)
If you insist on manipulating the namespace you can use exec:
>>> def foo(**parms):
... exec "\n".join("%s = parms.get(%r)" % (n, n) for n in
["a", "b", "c"])
... return a, b, c
...
>>> foo(a=1, c=3)
(1, None, 3)
>>> foo(b=20)
(None, 20, None)
Peter
--
http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't doc has predifined name and location ?
On Mon, Dec 1, 2008 at 1:22 PM, Stef Mientki <[EMAIL PROTECTED]> wrote: > hello, > > I'm very satisfied about the great standardization of doc strings in python. > Now in contrast to that, > the general documentation of libraries, > either in plain text, html, pdf, chm, ... > doesn't have a standarized name nor location. > > Why is that ? I suppose the need for such standardization has just never arisen. Googling for docs, checking the library's website, or doing `locate library-name-here | grep doc` in bash seems to work well enough for people that no one has found it necessary to pursue the creation of such a standard. Sidenote: what Python projects publish their docs in CHM besides possibly Win32 GUI programs? Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com > > thanks, > Stef Mientki > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread always alive
> I am suspecting some kind of a leak on a IO object like a file or socket > descriptor is still open. Are you sure you're closing them all? You mentioned a finally clause so is it possible that your code is throwing an exception before you clean everything up? -- http://mail.python.org/mailman/listinfo/python-list
