Re: Switching between Python releases under Windows
I've written a script to do just this, called switchpy.bat. It's described here: http://apipes.blogspot.com/2010/10/switchpy.html Or you can just grab the latest version at: https://bitbucket.org/tlesher/mpath/src/3edcff0e8197/switchpy.bat -- http://mail.python.org/mailman/listinfo/python-list
Re: how to get bit info
On Jun 17, 3:51 pm, Back9 wrote: > Hi, > > I have one byte data and want to know each bit info, > I mean how I can know each bit is set or not? You want the bitwise-and operator, &. For example, to check the least significant bit, bitwise-and with 1: >>> 3 & 1 1 >>> 2 & 1 0 -- http://mail.python.org/mailman/listinfo/python-list
Re: Regarding coding style
On Mar 9, 2:04 am, "Ryan Ginstrom" <[EMAIL PROTECTED]> wrote: > > On Behalf Of Grant Edwards > > I think docstrings are a great idea. What's needed is a way > > to document the signature that can't get out-of-sync with > > what the fucntion really expects. > > Like doctests? (I know, smart-ass response) > > Regards, > Ryan Ginstrom Not a smart-ass response at all--a _smart_ response. Doctests are one of the few mechanisms I've ever seen that even attempt to make this happen. -- Tim Lesher [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i profile every line of code
On Feb 21, 3:27 pm, Tim Lesher <[EMAIL PROTECTED]> wrote: > On Feb 21, 10:06 am, scsoce <[EMAIL PROTECTED]> wrote: > > > I want to profile a function which has some lines of statement. It seem > > that profile module only report function's stats instead of every line > > of code, how can i profile every line of code? > > thanks. > > Use the hotshot profiler, and when creating the profiler instance, > specify linetimings=True: > > http://docs.python.org/lib/module-hotshot.html Err, that should be "lineevents=True", not linetimings. -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i profile every line of code
On Feb 21, 10:06 am, scsoce <[EMAIL PROTECTED]> wrote: > I want to profile a function which has some lines of statement. It seem > that profile module only report function's stats instead of every line > of code, how can i profile every line of code? > thanks. Use the hotshot profiler, and when creating the profiler instance, specify linetimings=True: http://docs.python.org/lib/module-hotshot.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Iterating over marshal
On Oct 6, 4:19 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Tim Lesher wrote: > > I'm using the marshal library to unmarshal a file containing one or > > more objects. The canonical way seems to be: > > > objs = [] > > while 1: > > try: > > objs.append(marshal.load(fobj)) > > except EOFError: > > breakthe canonical way to do this is to put the objects in a > > sequence > container *before* marshalling them. That makes sense; unfortunately, I'm unmarshalling from an external data source I don't control (the Perforce version control client). -- Tim Lesher [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Iterating over marshal
I'm using the marshal library to unmarshal a file containing one or more objects. The canonical way seems to be: objs = [] while 1: try: objs.append(marshal.load(fobj)) except EOFError: break Maybe it's just me, but it seems as if this should be iterable. I can get the behavior I want by writing: def itermarshal(fobj): while 1: try: yield marshal.load(fobj) except EOFError: raise StopIteration objs = [obj for obj in itermarshal(fobj)] But it seems that this should be built-in somewhere. Given that the marshal library has been around since roughly forever, is it just that no one's bothered to add iteration support to it, or am I missing something? Thanks. -- Tim Lesher [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem of function calls from map()
Dasn wrote: > So how to put '\t' argument to split() in map() ? How much is the lambda costing you, according to your profiler? Anyway, what you really want is a list comprehension: l = [line.split('\t') for line in lines] -- http://mail.python.org/mailman/listinfo/python-list
Re: What is your favorite Python web framework?
I was using CherryPy quite a bit until recently, but I've since switched to Spyce: http://spyce.sf.net (and blogged it at http://apipes.blogspot.com/2005/07/first-taste-of-spyce.html). Spyce has been around since 2002 (so it's fairly stable and mature) but it's also under active development--a new version just came out a few weeks ago (so it's not going away). The main reason I switched was the Spyce templating engine--more powerful than CherryTemplate, and tons more readable than Cheetah, in my opinion. -- Tim Lesher [EMAIL PROTECTED] http://apipes.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK or wxPython (not a flame war) on Windows
Yes, it's not that hard to get the native file dialogs, as described in the FAQ: http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq21.013.htp It would be nice if PyGTK had a knob for making it use win32 dialogs by default, though. -- http://mail.python.org/mailman/listinfo/python-list
Re: what's wrong with my code using subprocess?
I see the same behavior as you do. On Windows, the wait() isn't hanging--what's happening is that the subprocess just never receives anything. I don't quite understand why, but it works fine when I change the "if" clause in receiver.py to this: if count >= 1000: p.communicate('exit') p.wait() break Note the final break: if this isn't here, the next for iteration raises an exception, as p.stdout has been closed by p.communicate. -- http://mail.python.org/mailman/listinfo/python-list
python-dev Summary for 2005-04-01 through 2005-04-15
[The HTML version of this Summary is available at http://www.python.org/dev/summary/2005-04-01_2005-04-15.html] == Summary Announcements == --- New python-dev summary team --- This summary marks the first by the team of Steve Bethard, Tim Lesher, and Tony Meyer. We're trying a collaborative approach to the summaries: each fortnight, we'll be getting together in a virtual smoke-filled back room to divide up the interesting threads. Then we'll stitch together the summaries in roughly the same form as you've seen in the past. We'll mark each editor's entries with his initials. Thanks to Brett Cannon for sixty-one excellent python-dev summaries. Also, thanks for providing scripts to help get the new summaries off the ground! We're looking forward to the contributions you'll make to the Python core, now that the summaries aren't taking up all your time. [TDL] = Summaries = --- Acceptable diff formats --- Nick Coghlan asked if context diffs are still favoured for patches. Historically, context diffs were preferred, but it appears that unified diffs are the today's choice. Raymond Hettinger made the sensible suggestion that whichever is most informative for the particular patch should be used, and Bob Ippolito pointed out that if CVS is replaced with subversion, unified diffs will have better support. The `patch submission guidelines`_ will be updated at some point to reflect the preference for unified diffs, although if your diff program doesn't support '-u', then context diffs are ok - plain patches are, of course, not. Contributing threads: - `Unified or context diffs? <http://mail.python.org/pipermail/python-dev/2005-April/052657.html>`__ .. _patch submission guidelines: http://www.python.org/patches/ [TAM] --- Developers List --- Raymond Hettinger has started a `project to track developers`_ and the (tracker and commit) privileges they have, and who gave them the privileges, and why (for example, was it for a one-shot project). Removing inactive developers should improve clarity, institutional memory, security, and makes everything tidier. Raymond has begun contacting recently inactive developers to check whether they still require the privileges they have. Contributing threads: - `Developer list update <http://mail.python.org/pipermail/python-dev/2005-April/052540.html>`__ .. _project to track developers: http://cvs.sourceforge.net/viewcvs.py/*checkout*/python/python/dist/src/Misc/developers.txt [TAM] -- Right Operator Methods -- Greg Ewing explored an issue with new-style classes that define only right operator methods (__radd__, __rmul__, etc.) Instances of such a class cannot be added/multiplied/etc. together as Python raises a TypeError. Armin Rigo explained the rule: if the instances on both sides of an operator are of the same class, only the non-reversed method is ever called. Armin also explained that an __add__ or __mul__ method that returns NotImplemented may be called twice when Python attempts to differentiate between numeric and sequence operations. Contributing threads: - `New style classes and operator methods <http://mail.python.org/pipermail/python-dev/2005-April/052577.html>`__ [SJB] -- Hierarchical groups in regular expressions -- Chris Ottrey demoed his `pyre2 project`_ that can extract a hierarchy of strings when nested groups match in a regular expression. The current re module (in the stdlib) only matches the last occurrence of a group in the string, throwing away any preceding matches. People discussed some of pyre2's proposed API, with the main suggestion being to extend the API to support unnamed (positional) groups in addition to named groups. Though a number of people expressed interest in the idea, it was not clear whether the functionality should be included in the standard library. However, most agreed that if it was included, it should be integrated with the existing re module. Gustavo Niemeyer offered to perform this integration if an API could be agreed upon. Further discussion was moved to the pyre2 `development wiki`_ and `mailing list`_. Contributing threads: - `hierarchicial named groups extension to the re library <http://mail.python.org/pipermail/python-dev/2005-April/052508.html>`__ .. _pyre2 project: http://pyre2.sourceforge.net/ .. _development wiki: http://py.redsoft.be/pyre2/wiki/ .. _mailing list: http://lists.sourceforge.net/lists/listinfo/pyre2-devel [SJB] --- Security capabilities in Python --- The issue of security came up again, and Ka-Ping Yee suggested that in Python's rest
Status of Chaco?
I recently had reason to look up Chaco again, but after searching the SciPy and Enthought websites, I see it seems to have gone missing. Looking over c.l.p, I can find only one quasi-recent message from Eric about at, from almost a year ago: > Chaco has moved to a new package. We hope to have it released within > the next few weeks. Is Chaco dead? Or just pining? -- Tim Lesher <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list