redirect stdout

2005-04-08 Thread Neal Becker
I'd like to build a module that would redirect stdout to send it to a logging module. I want to be able to use a python module that expects to print results using "print" or "sys.stdout.write()" and without modifying that module, be able to redirect it's stdout to a logger which will send the

Oh look, another language (ceylon)

2013-11-13 Thread Neal Becker
http://ceylon-lang.org/documentation/1.0/introduction/ -- https://mail.python.org/mailman/listinfo/python-list

argparse feature request

2013-11-22 Thread Neal Becker
I use arparse all the time and find it serves my needs well. One thing I'd like to see. In the help message, I'd like to automatically add the default values. For example, here's one of my programs: python3 test_freq3.py --help usage: test_freq3.py [-h] [--size SIZE] [--esnodB ESNODB] [--tau

Re: argparse feature request

2013-11-22 Thread Neal Becker
Robert Kern wrote: > On 2013-11-22 14:56, Neal Becker wrote: >> I use arparse all the time and find it serves my needs well. One thing I'd >> like >> to see. In the help message, I'd like to automatically add the default >> values. >> >> For ex

Re: argparse feature request

2013-11-22 Thread Neal Becker
Robert Kern wrote: > On 2013-11-22 16:52, Neal Becker wrote: >> Robert Kern wrote: >> >>> On 2013-11-22 14:56, Neal Becker wrote: >>>> I use arparse all the time and find it serves my needs well. One thing I'd >>>> like >>>> to see

proposal: bring nonlocal to py2.x

2014-01-13 Thread Neal Becker
py3 includes a fairly compelling feature: nonlocal keywork But backward compatibility is lost. It would be very helpful if this was available on py2.x. -- https://mail.python.org/mailman/listinfo/python-list

object() can't have attributes

2015-12-23 Thread Neal Becker
I'm a bit surprised that an object() can't have attributes: In [30]: o = object() In [31]: o.x = 2 --- AttributeErrorTraceback (most recent call last) in () > 1 o.x = 2 AttributeError: 'objec

context managers inline?

2016-03-10 Thread Neal Becker
Is there a way to ensure resource cleanup with a construct such as: x = load (open ('my file', 'rb)) Is there a way to ensure this file gets closed? -- https://mail.python.org/mailman/listinfo/python-list

Re: context managers inline?

2016-03-10 Thread Neal Becker
[email protected] wrote: > On Thursday, March 10, 2016 at 10:33:47 AM UTC-8, Neal Becker wrote: >> Is there a way to ensure resource cleanup with a construct such as: >> >> x = load (open ('my file', 'rb)) >> >> Is there a way to ensure this

Is there a more elegant way to spell this?

2015-01-27 Thread Neal Becker
Is there a more elegant way to spell this? for x in [_ for _ in seq if some_predicate]: -- -- Those who don't understand recursion are doomed to repeat it -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a more elegant way to spell this?

2015-01-27 Thread Neal Becker
Jussi Piitulainen wrote: > Neal Becker writes: > >> Is there a more elegant way to spell this? >> >> for x in [_ for _ in seq if some_predicate]: > > If you mean some_predicate(_), then possibly this. > > for x in filter(some_predicate, seq): >

Re: Is there a more elegant way to spell this?

2015-01-27 Thread Neal Becker
Jussi Piitulainen wrote: > Neal Becker writes: > >> Is there a more elegant way to spell this? >> >> for x in [_ for _ in seq if some_predicate]: > > If you mean some_predicate(_), then possibly this. > > for x in filter(some_predicate, seq): >

basic generator question

2015-02-04 Thread Neal Becker
I have an object that expects to call a callable to get a value: class obj: def __init__ (self, gen): self.gen = gen def __call__ (self): return self.gen() Now I want gen to be a callable that repeats N times. I'm thinking, this sounds perfect for yield class rpt: def __init__ (se

help with pypeg2?

2015-02-06 Thread Neal Becker
Trying out pypeg2. The below grammar is recursive. A 'Gen' is an ident followed by parenthesized args. args is a csl of alphanum or Gen. The tests 'p' and 'p2' are fine, but 'p3' fails SyntaxError: expecting u')' from __future__ import unicode_literals, print_function from pypeg2 import * i

Re: help with pypeg2?

2015-02-06 Thread Neal Becker
Ian Kelly wrote: > On Fri, Feb 6, 2015 at 7:55 AM, Neal Becker wrote: >> Trying out pypeg2. The below grammar is recursive. A 'Gen' is an ident >> followed by parenthesized args. args is a csl of alphanum or Gen. >> >> The tests 'p' and 'p2

line_profiler: what am I doing wrong?

2015-02-10 Thread Neal Becker
I inserted @profile def run(...) into a module-level global function called 'run'. Something is very wrong here. 1. profile results were written before anything even ran 2. profile is not defined? kernprof -l ./test_unframed.py --lots --of --args ... Wrote profile results to test_unframed.py.

Re: line_profiler: what am I doing wrong?

2015-02-10 Thread Neal Becker
Ethan Furman wrote: > On 02/10/2015 04:06 PM, Neal Becker wrote: >> I inserted >> @profile >> def run(...) >> >> into a module-level global function called 'run'. Something is very wrong >> here. 1. profile results were written befo

Re: line_profiler: what am I doing wrong?

2015-02-10 Thread Neal Becker
Steven D'Aprano wrote: > Neal Becker wrote: > >> I inserted >> @profile >> def run(...) >> >> into a module-level global function called 'run'. Something is very wrong >> here. 1. profile results were written before anything even r

Re: line_profiler: what am I doing wrong?

2015-02-13 Thread Neal Becker
Robert Kern wrote: > On 2015-02-11 01:17, Steven D'Aprano wrote: >> Neal Becker wrote: >> >> >>> To quote from https://pypi.python.org/pypi/line_profiler/ >>> >>> $ kernprof -l script_to_profile.py >>> kernprof will create an in

Re: line_profiler: what am I doing wrong?

2015-02-13 Thread Neal Becker
Robert Kern wrote: > @profile > def run(): > pass > > run() No, this doesn't work either. Same failure kernprof -l test_prof.py Wrote profile results to test_prof.py.lprof Traceback (most recent call last): File "/home/nbecker/.local/bin/kernprof", line 9, in load_entry_point('line-pro

Re: line_profiler: what am I doing wrong?

2015-02-16 Thread Neal Becker
Robert Kern wrote: > On 2015-02-13 13:35, Neal Becker wrote: >> Robert Kern wrote: >> >>> @profile >>> def run(): >>> pass >>> >>> run() >> >> No, this doesn't work either. Same failure >> >> kernprof -l t

Re:How security holes happen

2014-03-03 Thread Neal Becker
Charles R Harris Wrote in message: > ___ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion > Imo the lesson here is never write in low level c. Use modern languages with well design

Re: gdb unable to read python frame information

2014-03-07 Thread Neal Becker
dieter wrote: > Wesley writes: > >> I wanna use gdb to attach my running python scripts. >> Successfully import libpython in gdb, but seems all py operations failed to >> read python information. >> >> Here is the snippet: >> (gdb) python >>>import libpython >>>end >> (gdb) py-bt >> #3 (unable t

Re: which async framework?

2014-03-12 Thread Neal Becker
Grant Edwards wrote: > On 2014-03-11, Antoine Pitrou wrote: >> Sturla Molden gmail.com> writes: >>> >>> Chris Withers simplistix.co.uk> wrote: >>> > Hi All, >>> > >>> > I see python now has a plethora of async frameworks and I need to try >>> > and pick one to use from: >>> > >>> > - asyncio

help with memory leak

2014-05-27 Thread Neal Becker
I'm trying to track down a memory leak in a fairly large code. It uses a lot of numpy, and a bit of c++-wrapped code. I don't yet know if the leak is purely python or is caused by the c++ modules. At each iteration of the main loop, I call gc.collect() If I then look at gc.garbage, it is empt

c# async, await

2013-08-22 Thread Neal Becker
So my son is now spending his days on c# and .net. He's enthusiastic about async and await, and said to me last evening, "I don't think python has anything like that". I'm not terribly knowledgeable myself regarding async programming (since I never need to use it). I did look at this: http:

python3 integer division debugging

2013-08-28 Thread Neal Becker
The change in integer division seems to be the most insidious source of silent errors in porting code from python2 - since it changes the behaviour or valid code silently. I wish the interpreter had an instrumented mode to detect and report such problems. -- http://mail.python.org/mailman/lis

Re: python3 integer division debugging

2013-08-28 Thread Neal Becker
Chris Angelico wrote: > On Thu, Aug 29, 2013 at 1:21 AM, Oscar Benjamin > wrote: >> On 28 August 2013 16:15, Neal Becker wrote: >>> The change in integer division seems to be the most insidious source of >>> silent errors in porting code from python2 - since i

why syntax change in lambda

2013-09-11 Thread Neal Becker
In py2.7 this was accepted, but not in py3.3. Is this intentional? It seems to violate the 'principle' that extraneous parentheses are usually allowed/ignored In [1]: p = lambda x: x In [2]: p = lambda (x): x File "", line 1 p = lambda (x): x ^ SyntaxError: invalid syntax

pip won't ignore system-installed files

2013-10-22 Thread Neal Becker
IIUC, it is perfectly legitimate to do install into --user to override system- wide installed modules. Thus, I should be able to do: pip install --user --up blah even though there is already a package blah in /usr/lib/pythonxxx/site_packages/... But even with -I (ignore installed) switch, pip

__iadd__ with 2 args?

2015-03-20 Thread Neal Becker
I can write a member F.__iadd__ (self, *args) and then call it with 2 args: f = F() f.__iadd__ (a, b) And then args is: (a, b) But it seems impossible to spell this as f += a, b That, instead, results in args = ((a, b),) So should I just abandon the idea that += could be used this way?

Re: PiCxx

2015-03-25 Thread Neal Becker
π wrote: > Hello Python people, > > I've made a C++ wrapper for Python. > I've called it PiCxx and put it up here: https://github.com/p-i-/PiCxx > > > That project runs out of the box on OS X and should be pretty easy to > adapt for other OS. Any help providing d

heapq - why no key= arg?

2015-04-27 Thread Neal Becker
Looking at heapq, I see only nlargest/nsmallest provide a key= arg. What about other operations, such as heapify? Am I not understanding something? I suppose for other ops, such as heapify, I can only customize comparison by customizing the object comparison operators? -- Those who fail to

why would this print 'True'?

2015-05-11 Thread Neal Becker
from itertools import ifilter if all (hasattr (b, 'test') for b in ifilter (lambda b: b < 10, [1,2,3,4])): print 'True' same result using filter instead of ifilter. hasattr (b, 'test') where b is 1, 2, 3... should all be False. So why does this print True? -- Those who fail to understand

Re: why would this print 'True'?

2015-05-11 Thread Neal Becker
Nevermind - I found the answer. I was trying this in ipython with pylab: http://stackoverflow.com/questions/7491951/python-builtin-all-with-generators Neal Becker wrote: > from itertools import ifilter > > if all (hasattr (b, 'test') for b in ifilter (lambda b:

enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Neal Becker
One of the most annoying problems with py2/3 interoperability is that the pickle formats are not compatible. There must be many who, like myself, often use pickle format for data storage. It certainly would be a big help if py3 could read/write py2 pickle format. You know, backward compatibil

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Neal Becker
Chris Warrick wrote: > On Tue, Jun 9, 2015 at 8:08 PM, Neal Becker wrote: >> One of the most annoying problems with py2/3 interoperability is that the >> pickle formats are not compatible. There must be many who, like myself, >> often use pickle format for data storage. >

thinking with laziness

2015-06-18 Thread Neal Becker
http://begriffs.com/posts/2015-06-17-thinking-with-laziness.html -- https://mail.python.org/mailman/listinfo/python-list

register cleanup handler

2015-07-24 Thread Neal Becker
I have code like: if (condition): do_something_needing_cleanup code_executed_unconditionally Now, how can I make sure cleanup happens? Actually, what I really would like, is: if (condition): do_something_needing_cleanup register_scoped_cleanup (cleanup_fnc) code_executed_unconditiona

Re: register cleanup handler

2015-07-24 Thread Neal Becker
Laura Creighton wrote: > In a message of Fri, 24 Jul 2015 10:57:30 -0400, Neal Becker writes: >>I know we have try/finally, but I don't think that helps here, because >>code_executed_unconditionally couldn't be inside the try. Or am I missing >>something obvious? &

Re: register cleanup handler

2015-07-24 Thread Neal Becker
Irmen de Jong wrote: > On 24-7-2015 16:57, Neal Becker wrote: >> I have code like: >> >> if (condition): >> do_something_needing_cleanup >> >> code_executed_unconditionally >> >> > continue or exception> >> >> Now, how ca

regex recursive matching (regex 2015.07.19)

2015-08-18 Thread Neal Becker
Trying regex 2015.07.19 I'd like to match recursive parenthesized expressions, with groups such that '(a(b)c)' would give group(0) -> '(a(b)c)' group(1) -> '(b)' but that's not what I get import regex #r = r'\((?>[^()]|(?R))*\)' r = r'\(([^()]|(?R))*\)' #r = r'\((?:[^()]|(?R))*\)' m = regex.m

pip trouble

2015-10-30 Thread Neal Becker
I have a custom-compiled numpy 1.10.0. But as you see, pip wants to install a new numpy, even though the requirement (numpy>=1.6) was already satisfied. WTF? All are installed into --user. This is on fedora 22 linux. pip install --up --user matplotlib Collecting matplotlib Using cached ma

Re: pip trouble

2015-10-30 Thread Neal Becker
Chris Warrick wrote: > On 30 October 2015 at 13:14, Neal Becker wrote: >> I have a custom-compiled numpy 1.10.0. But as you see, pip wants to >> install a new numpy, even though the requirement (numpy>=1.6) was already >> satisfied. WTF? >> >> All are ins

can I get 0./0. to return nan instead of exception?

2014-06-19 Thread Neal Becker
Can I change behavior of py3 to return nan for 0./0. instead of raising an exception? -- https://mail.python.org/mailman/listinfo/python-list

Re: Dabo 0.9.4 Released!

2011-10-06 Thread Neal Becker
Ed Leafe wrote: > Yes, it's been over a year, but today we're finally releasing Dabo 0.9.4! > > What can I say? While we've been actively developing Dabo all along, and > committing improvements and fixes regularly, we don't seem to get around to > doing releases as often as we should. Since Dabo

order independent hash?

2011-11-30 Thread Neal Becker
I like to hash a list of words (actually, the command line args of my program) in such a way that different words will create different hash, but not sensitive to the order of the words. Any ideas? -- http://mail.python.org/mailman/listinfo/python-list

Re: order independent hash?

2011-12-01 Thread Neal Becker
Gelonida N wrote: > On 11/30/2011 01:32 PM, Neal Becker wrote: >> I like to hash a list of words (actually, the command line args of my >> program) in such a way that different words will create different hash, but >> not sensitive >> to the order of the words. Any i

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-21 Thread Neal Becker
Clarification: where can packing/unpacking syntax be used? It would be great if it were valid essentially anywhere (not limited to parameter passing). What about constructs like: a, @tuple tail, b = sequence? -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-22 Thread Neal Becker
I agree with the OP that the current syntax is confusing. The issue is, the meaning of * is context-dependent. Why not this: Func (*args) == Func (unpack (args)) def Func (*args) == Func (pack (args)) That seems very clear IMO -- http://mail.python.org/mailman/listinfo/python-list

unzip function?

2012-01-18 Thread Neal Becker
python has builtin zip, but not unzip A bit of googling found my answer for my decorate/sort/undecorate problem: a, b = zip (*sorted ((c,d) for c,d in zip (x,y))) That zip (*sorted... does the unzipping. But it's less than intuitively obvious. I'm thinking unzip should be a builtin function,

Re: [OT?]gmane not updating

2013-04-06 Thread Neal Becker
[email protected] wrote: > The gmane site is online but none of the Python lists I subscribe to have been > updated for over 24 hours. I fired off an email yesterday evening to larsi + > gmane at gnus dot org but I've no idea whether there's anybody to read it, or > even if it's actually be

Re: Spiritual Programming (OT, but Python-inspired)

2006-01-02 Thread Neal Becker
Steven D'Aprano wrote: > On Mon, 02 Jan 2006 13:38:47 -0800, UrsusMaximus wrote: > >> It seems to me that, if anything of a person survives death in any way, >> it must do so in some way very different from that way in which we >> exist now. > [snip] > > I don't dare ask where your evidence for

Re: Standard Forth versus Python: a case study

2006-10-12 Thread Neal Bridges
"John Doty" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [snip] > Here's a K&R C function I wrote almost 20 years ago. [code snipped] John, 'man indent' right away! -- Neal Bridges http://quartus.net Home of Quartus Forth for the Palm OS

Find interface associated with default route?

2006-11-12 Thread Neal Becker
Any thoughts on howto find the interface associated with the default route (this is on linux)? -- http://mail.python.org/mailman/listinfo/python-list

Re: Find interface associated with default route?

2006-11-12 Thread Neal Becker
Fredrik Lundh wrote: > Neal Becker wrote: > >> Any thoughts on howto find the interface associated with the default >> route (this is on linux)? > > are you sure you sent this to the right newsgroup ? > > is this what you want ? > > >>> impor

Re: Find interface associated with default route?

2006-11-12 Thread Neal Becker
Neal Becker wrote: > Fredrik Lundh wrote: > >> Neal Becker wrote: >> >>> Any thoughts on howto find the interface associated with the default >>> route (this is on linux)? >> >> are you sure you sent this to the right newsgroup ? >> >&g

Re: Boost Python Issue

2006-08-31 Thread Neal Becker
JDJMSon wrote: > I was wondering if someone here could help me with a problem I'm having > building Python extensions with the Boost.Python library. > Basically, if I have a wrapper class with something like this: > > string TestFunc() > { > return "Hello World"; > } > > BOOST_PYTHON_MODULE(Test

Re: Boost Python Issue

2006-08-31 Thread Neal Becker
JDJMSon wrote: > > Neal Becker wrote: > >> Shouldn't that be: >> .def("TestFunction",&TestClass::TestFunction) >> > ; > > > Yes, you're right, but I'm still getting the error. I'm using a > prebuilt python library,

Re: [ANN] IronPython 1.0 released today!

2006-09-05 Thread Neal Becker
Will it run with mono? -- http://mail.python.org/mailman/listinfo/python-list

Cool! A python course!

2006-09-11 Thread Neal Becker
http://www.epp.jhu.edu/schedule/courseinfo.php?deptid=525&coursenum=492 -- http://mail.python.org/mailman/listinfo/python-list

iterator question

2006-09-26 Thread Neal Becker
Any suggestions for transforming the sequence: [1, 2, 3, 4...] Where 1,2,3.. are it the ith item in an arbitrary sequence into a succession of tuples: [(1, 2), (3, 4)...] In other words, given a seq and an integer that specifies the size of tuple to return, then for example: seq = [a,b,c,d,e,f

Re: iterator question

2006-09-27 Thread Neal Becker
George Sakkis wrote: > [EMAIL PROTECTED] wrote: > >> def transform(seq, size): >> i = 0 >> while i < len(seq): >> yield tuple(seq[i:i+size]) >> i += size > > Or for arbitrary iterables, not just sequences: > > from itertools import islice > def transform(iterable, size):

python on tivo (series2)?

2006-11-17 Thread Neal Becker
I'd like to find python for my tivo (series 2). I believe it runs linux on mips. Google found one, but it complained about shared libs when I tried to run python. (Unfortunately, it didn't say which libs, and tools like ldd seem to be missing on the tivo). I'd rather not have to setup a cross-c

Re: MySQLdb, lots of columns and newb-ness

2006-12-19 Thread Todd Neal
Andrew Sackville-West wrote: > > I can successfully connect to mysql and do stuff to my tables my > specific problem is how to efficiently put those 132 fields into the > thing. All I have been able to figure out is really ugly stuff like: > build the mysql statement out of various pieces with appr

Re: list1.append(list2) returns None

2006-12-20 Thread Todd Neal
Pyenos wrote: > def enlargetable(table,col): > return table.append(col) > > def removecolfromtable(table,col): > return table.remove(col) > > print enlargetable([[1],[2],[3]],[4]) # returns None > > Why does it return None instead of [[1],[2],[3],[4]] which I expected? append modifies the

[ANN] PyChecker 0.8.17 released

2006-02-03 Thread Neal Norwitz
. * Support ROT_THREE and ROT_FOUR opcodes PyChecker is available on Source Forge: Web page: http://pychecker.sourceforge.net/ Project page: http://sourceforge.net/projects/pychecker/ Mailing List: [EMAIL PROTECTED] Enjoy and don't forget to provide feedback!

Re: [ANN] functional 0.5 released

2006-02-11 Thread Neal Becker
I just installed from .tar.gz on fedora FC5 x86_64. I ran into 1 small problem: sudo python setup.py install --verbose running install running bdist_egg running egg_info writing functional.egg-info/PKG-INFO writing top-level names to functional.egg-info/top_level.txt reading manifest file 'functi

Re: porting help

2005-05-21 Thread Neal Norwitz
You may need to write your own dynload_vxworks.c. Notice there are various OS specific dynload_*.c files. You can try to use dynload_stub.c to see if you can get it to compile. You may also need to muck with Include/pyport.h and configure to get things going. Good Luck! n -- http://mail.pytho

Re: Binding the names in a module in a class instance

2005-05-23 Thread Neal Norwitz
Jacob H wrote: > Hello all, > > I would like to be able to take a module full of class instances, > functions, etc and bind all its names to a separate container class in > a different module. I have come up with the following way to do it.. [snip] > I feel uneasy about this method. I foresee bad

Re: any macro-like construct/technique/trick?

2005-06-02 Thread Neal Norwitz
Andrew's approach is good, but you could so something a little simpler/more flexible. Untested of course. :-) Every callable object is followed by the args to pass it. So this: debug_emit(DbgObjFoo(a, b, costly_function(c))) becomes: debug_emit(DbgObjFoo, (a, b, costly_function, (c,)))

global destructor not called?

2007-06-15 Thread Neal Becker
To implement logging, I'm using a class: class logger (object): def __init__ (self, name): self.name = name self.f = open (self.name, 'w') def write (self, stuff): self.f.write (stuff) def close (self): self.f.close() def flush (self): self.f.

Re: global destructor not called?

2007-06-15 Thread Neal Becker
Bruno Desthuilliers wrote: > Neal Becker a écrit : >> To implement logging, I'm using a class: > > If I may ask : any reason not to use the logging module in the stdlib ? Don't exactly recall, but needed some specific behavior and it was just easier this way. &

Is there a way to hook into module destruction?

2007-06-16 Thread Neal Becker
Code at global scope in a module is run at module construction (init). Is it possible to hook into module destruction (unloading)? -- http://mail.python.org/mailman/listinfo/python-list

python extra

2007-07-08 Thread Neal Becker
Just a little python humor: http://www.amazon.com/Vitamin-Shoppe-Python-Extra-tablets/dp/B00012NJAK/ref=sr_1_14/103-7715091-4822251?ie=UTF8&s=hpc&qid=1183917462&sr=1-14 -- http://mail.python.org/mailman/listinfo/python-list

Re: python extra

2007-07-08 Thread Neal Becker
Danyelle Gragsone wrote: > Nope.. not a one.. > > > On 7/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> On Jul 8, 12:59?pm, Neal Becker <[EMAIL PROTECTED]> wrote: >> > Just a little python humor: >> > >> > http://www.a

problem with change to exceptions

2007-07-27 Thread Neal Becker
import exceptions class nothing (exceptions.Exception): def __init__ (self, args=None): self.args = args if __name__ == "__main__": raise nothing Traceback (most recent call last): File "", line 1, in File "/usr/tmp/python-3143hDH", line 5, in __init__ self.args = args T

Re: problem with change to exceptions

2007-07-27 Thread Neal Becker
Alex Popescu wrote: > Neal Becker <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > >> import exceptions >> >> class nothing (exceptions.Exception): >> def __init__ (self, args=None): >> self.args = args >> >> if __na

interaction of 'with' and 'yield'

2007-07-31 Thread Neal Becker
I'm wondering if a generator that is within a 'with' scope exits the 'with' when it encounters 'yield'. I would like to use a generator to implement RAII without having to syntactically enclose the code in the 'with' scope, and I am hoping that the the yield does not exit the 'with' scope and rele

re: mmm-mode, python-mode and doctest-mode?

2007-08-08 Thread Neal Becker
Anyone testing on xemacs? I tried it, and C-c C-c sent xemacs into an infinite loop (apparantly). -- http://mail.python.org/mailman/listinfo/python-list

Re: mmm-mode, python-mode and doctest-mode?

2007-08-09 Thread Neal Becker
Edward Loper wrote: >> Anyone testing on xemacs? I tried it, and C-c C-c sent xemacs into an >> infinite loop (apparantly). > > It works fine for me in XEmacs 21.4 (patch 17) (i386-debian-linux, > Mule). If you could answer a few questions, it might help me track down > the problem: > > - What

code check for modifying sequence while iterating over it?

2007-08-31 Thread Neal Becker
After just getting bitten by this error, I wonder if any pylint, pychecker variant can detect this error? -- http://mail.python.org/mailman/listinfo/python-list

block scope?

2007-04-06 Thread Neal Becker
One thing I sometimes miss, which is common in some other languages (c++), is idea of block scope. It would be useful to have variables that did not outlive their block, primarily to avoid name clashes. This also leads to more readable code. I wonder if this has been discussed? -- http://mail.

Re: block scope?

2007-04-07 Thread Neal Becker
James Stroud wrote: > Paul Rubin wrote: >> John Nagle <[EMAIL PROTECTED]> writes: >>> In a language with few declarations, it's probably best not to >>> have too many different nested scopes. Python has a reasonable >>> compromise in this area. Functions and classes have a scope, but >>> "if

puzzled about floats

2007-09-24 Thread Neal Becker
from math import modf class nco (object): def __init__ (self, delta): self.delta = delta self.phase = 0.0 def __call__ (self): self.phase += self.delta f,i = modf (self.phase) print modf (self.phase) if (self.phase > 1.0): self.p

Re: getopt with negative numbers?

2007-09-27 Thread Neal Becker
Casey wrote: > On Sep 27, 2:21 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: >> If you can access the argument list manually, you could scan it for a >> negative integer, and then insert a '--' argument before that, >> if needed, before passing it to getopt/optparse. Then you wouldn't have >>

Re: getopt with negative numbers?

2007-09-28 Thread Neal Becker
Ben Finney wrote: > Casey <[EMAIL PROTECTED]> writes: > >> Well, it is a hack and certainly not as clean as having getopt or >> optparse handle this natively (which I believe they should). > > I believe they shouldn't because the established interface is that a > hyphen always introduced an opti

Re: [Tutor] data from excel spreadsheet to csv and manipulate

2007-10-03 Thread Neal Becker
look at xlrd module and also csv module. -- http://mail.python.org/mailman/listinfo/python-list

help with pyparsing

2007-10-31 Thread Neal Becker
I'm just trying out pyparsing. I get stack overflow on my first try. Any help? #/usr/bin/python from pyparsing import Word, alphas, QuotedString, OneOrMore, delimitedList first_line = '[' + delimitedList (QuotedString) + ']' def main(): string = '''[ 'a', 'b', 'cdef']''' greeting = fi

Which persistence is for me?

2007-11-01 Thread Neal Becker
I need to organize the results of some experiments. Seems some sort of database is in order. I just took a look at DBAPI and the new sqlite interface in python2.5. I have no experience with sql. I am repulsed by e.g.: c.execute("""insert into stocks values ('2006-01-05','BUY','RHAT',1

Re: Which persistence is for me?

2007-11-01 Thread Neal Becker
Neal Becker wrote: > I need to organize the results of some experiments. Seems some sort of > database is in order. > > I just took a look at DBAPI and the new sqlite interface in python2.5. I > have no experience with sql. I am repulsed by e.g.: > c.execute(&qu

Re: Parallel Python

2007-01-12 Thread Neal Becker
[EMAIL PROTECTED] wrote: > Has anybody tried to run parallel python applications? > It appears that if your application is computation-bound using 'thread' > or 'threading' modules will not get you any speedup. That is because > python interpreter uses GIL(Global Interpreter Lock) for internal > b

MIME text attachment question

2007-01-25 Thread Neal Becker
I want to send a file (plain text) as an attachment. I'm using MIMEText. This attaches text OK, but I would like to have a filename attached to it, so that the recipient could save it without having to specify a filename. Any suggestions? -- http://mail.python.org/mailman/listinfo/python-list

Re: Auto locate Python's .so on Linux (for cx_Freeze's --shared-lib-name)

2007-11-18 Thread Neal Becker
robert wrote: > In a makefile I want to locate the .so for a dynamically linked > Python on Linux. (for cx_Freeze's --shared-lib-name) > e.g. by running a small script with that Python. How to? > > Robert How about run python -v yourscript and filter the output? -- http://mail.python.org/mailm

struct,long on 64-bit machine

2007-11-19 Thread Neal Becker
What's wrong with this? type(struct.unpack('l','\00'*8)[0]) Why I am getting 'int' when I asked for 'long'? This is on python-2.5.1-15.fc8.x86_64 -- http://mail.python.org/mailman/listinfo/python-list

which configparse?

2007-12-06 Thread Neal Becker
I have all my options setup with optparse. Now, I'd like to be able to parse an ini file to set defaults (that could be overridden by command line switches). I'd like to make minimal change to my working optparse setup (there are lots of options - I don't want to duplicate all the cmdline parsing

Re: which configparse?

2007-12-06 Thread Neal Becker
Martin Marcher wrote: > Hi, > > On 12/6/07, Neal Becker <[EMAIL PROTECTED]> wrote: >> configparse looks like what I want, but it seems last commit was >2years >> ago. >> >> What is the best choice? > > that seems like configparse is the best c

Recommendations for writing a user guide with examples?

2007-12-08 Thread Neal Becker
I'm looking for recommendations for writing a user manual. It will need lots of examples of command line inputs and terminal outputs. I'd like to minimize the effort to integrate the terminal input/output into my document. I have lots of experience with latex, but I wonder if there may be some o

simple string formatting question

2007-12-14 Thread Neal Becker
I have a list of strings (sys.argv actually). I want to print them as a space-delimited string (actually, the same way they went into the command line, so I can cut and paste) So if I run my program like: ./my_prog a b c d I want it to print: './my_prog' 'a' 'b' 'c' 'd' Just print sys.argv wil

OpenOpt install

2007-12-16 Thread Neal Becker
What do I need to do? I have numpy, scipy (Fedora F8) cd openopt/ [EMAIL PROTECTED] openopt]$ python setup.py build running build running config_cc unifing config_cc, config, build_clib, build_ext, build commands --compiler options running config_fc unifing config_fc, config, build_clib, build_

<    1   2   3   4   >