Re: Concurrent writes to the same file

2013-07-11 Thread Neal Becker
Dave Angel wrote: > On 07/11/2013 12:57 AM, Jason Friedman wrote: >> Other than using a database, what are my options for allowing two processes >> to edit the same file at the same time? When I say same time, I can accept >> delays. I considered lock files, but I cannot conceive of how I avoid

Re: [OT] Simulation Results Managment

2012-07-14 Thread Neal Becker
moo...@yahoo.co.uk wrote: > Hi, > This is a general question, loosely related to python since it will be the > implementation language. I would like some suggestions as to manage simulation > results data from my ASIC design. > > For my design, > - I have a number of simulations testcases (TEST_X

Re: [OT] Simulation Results Managment

2012-07-15 Thread Neal Becker
Dieter Maurer wrote: > moo...@yahoo.co.uk writes: >> ... >> Does pickle have any advantages over json/yaml? > > It can store and retrieve almost any Python object with almost no effort. > > Up to you whether you see it as an advantage to be able to store > objects rather than (almost) pure data

Re: Google the video "9/11 Missing Links". 9/11 was a Jew Job!

2012-07-19 Thread Neal Becker
Google the video "Go fuck yourself" -- http://mail.python.org/mailman/listinfo/python-list

equiv of perl regexp grammar?

2012-09-13 Thread Neal Becker
I noticed this and thought it looked interesting: http://search.cpan.org/~dconway/Regexp- Grammars-1.021/lib/Regexp/Grammars.pm#DESCRIPTION I'm wondering if python has something equivalent? -- http://mail.python.org/mailman/listinfo/python-list

A little morning puzzle

2012-09-19 Thread Neal Becker
I have a list of dictionaries. They all have the same keys. I want to find the set of keys where all the dictionaries have the same values. Suggestions? -- http://mail.python.org/mailman/listinfo/python-list

howto handle nested for

2012-09-28 Thread Neal Becker
I know this should be a fairly basic question, but I'm drawing a blank. I have code that looks like: for s0 in xrange (n_syms): for s1 in xrange (n_syms): for s2 in xrange (n_syms): for s3 in xrange (n_syms): for s4 in range (n_syms):

Re: howto handle nested for

2012-09-28 Thread Neal Becker
Neal Becker wrote: > I know this should be a fairly basic question, but I'm drawing a blank. > > I have code that looks like: > > for s0 in xrange (n_syms): > for s1 in xrange (n_syms): > for s2 in xrange (n_syms): >

serialization and versioning

2012-10-12 Thread Neal Becker
I wonder if there is a recommended approach to handle this issue. Suppose objects of a class C are serialized using python standard pickling. Later, suppose class C is changed, perhaps by adding a data member and a new constructor argument. It would see the pickling protocol does not directly

Re: serialization and versioning

2012-10-12 Thread Neal Becker
Etienne Robillard wrote: > On Fri, 12 Oct 2012 06:42:03 -0400 > Neal Becker wrote: > >> I wonder if there is a recommended approach to handle this issue. >> >> Suppose objects of a class C are serialized using python standard pickling. >> Later, suppose class

simple string format question

2012-10-15 Thread Neal Becker
Is there a way to specify to format I want a floating point written with no more than e.g., 2 digits after the decimal? I tried {:.2f}, but then I get all floats written with 2 digits, even if they are 0: 2.35 << yes, that's what I want 2.00 << no, I want just 2 or 2. -- http://mail.python.o

Re: how to insert random error in a programming

2012-10-15 Thread Neal Becker
Debashish Saha wrote: > how to insert random error in a programming? Apparently, giving it to Microsoft will work. -- http://mail.python.org/mailman/listinfo/python-list

Re: Immutability and Python

2012-10-30 Thread Neal Becker
rusi wrote: > On Oct 29, 8:20 pm, andrea crotti wrote: > >> Any comments about this? What do you prefer and why? > > Im not sure how what the 'prefer' is about -- your specific num > wrapper or is it about the general question of choosing mutable or > immutable types? > > If the latter I would

Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes

2013-01-08 Thread Neal Becker
Did you intend to give anyone permission to use the code? I see only a copyright notice, but no permissions. -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: PyDTLS

2013-01-09 Thread Neal Becker
A bit OT, but the widespread use of rfc 6347 could have a big impact on my work. I wonder if it's likely to see widespread use? What are likely/possible use cases? Thank. -- http://mail.python.org/mailman/listinfo/python-list

surprising result all (generator) (bug??)

2012-01-31 Thread Neal Becker
I was just bitten by this unexpected behavior: In [24]: all ([i > 0 for i in xrange (10)]) Out[24]: False In [25]: all (i > 0 for i in xrange (10)) Out[25]: True -- http://mail.python.org/mailman/listinfo/python-list

Re: surprising result all (generator) (bug??)

2012-01-31 Thread Neal Becker
Mark Dickinson wrote: > On Jan 31, 6:40 am, Neal Becker wrote: >> I was just bitten by this unexpected behavior: >> >> In [24]: all ([i > 0 for i in xrange (10)]) >> Out[24]: False >> >> In [25]: all (i > 0 for i in xrange (10)) >> Out[25]: Tr

Re: [Perl Golf] Round 1

2012-02-05 Thread Neal Becker
Heiko Wundram wrote: > Am 05.02.2012 12:49, schrieb Alec Taylor: >> Solve this problem using as few lines of code as possible[1]. > > Pardon me, but where's "the problem"? If your intention is to propose "a > challenge", say so, and state the associated problem clearly. > But this really misses

pickle/unpickle class which has changed

2012-03-06 Thread Neal Becker
What happens if I pickle a class, and later unpickle it where the class now has added some new attributes? -- http://mail.python.org/mailman/listinfo/python-list

Re: pickle/unpickle class which has changed

2012-03-06 Thread Neal Becker
Peter Otten wrote: > Steven D'Aprano wrote: > >> On Tue, 06 Mar 2012 07:34:34 -0500, Neal Becker wrote: >> >>> What happens if I pickle a class, and later unpickle it where the class >>> now has added some new attributes? >> >> Why don&

cython + scons + c++

2012-03-08 Thread Neal Becker
Is there a version of cython.py, pyext.py that will work with c++? I asked this question some time ago, but never got an answer. I tried the following code, but it doesn't work correctly. If the commented lines are uncommented, the gcc command is totally mangled. Although it did build my 1 tes

argparse ConfigureAction problem

2012-03-24 Thread Neal Becker
I've been using arparse with ConfigureAction (which is shown below). But, it doesn't play well with positional arguments. For example: ./plot_stuff2.py --plot stuff1 stuff2 [...] plot_stuff2.py: error: argument --plot/--with-plot/--enable-plot/--no-plot/-- without-plot/--disable-plot: invalid b

set PYTHONPATH for a directory?

2012-05-04 Thread Neal Becker
I'm testing some software I'm building against an alternative version of a library. So I have an alternative library in directory L. Then I have in an unrelated directory, the test software, which I need to use the library version from directory L. One approach is to set PYTHONPATH whenever I

Re: Good data structure for finding date intervals including a given date

2012-05-12 Thread Neal Becker
Probably boost ITL (Interval Template Library) would serve as a good example. I noticed recently someone created an interface for python. -- http://mail.python.org/mailman/listinfo/python-list

Re: usenet reading

2012-06-03 Thread Neal Becker
Jon Clements wrote: > Hi All, > > Normally use Google Groups but it's becoming absolutely frustrating - not only > has the interface changed to be frankly impractical, the posts are somewhat > random of what appears, is posted and whatnot. (Ironically posted from GG) > > Is there a server out th

mode for file created by open

2012-06-08 Thread Neal Becker
If a new file is created by open ('xxx', 'w') How can I control the file permission bits? Is my only choice to use chmod after opening, or use os.open? Wouldn't this be a good thing to have as a keyword for open? Too bad what python calls 'mode' is like what posix open calls 'flags', and what

Re: mode for file created by open

2012-06-09 Thread Neal Becker
Cameron Simpson wrote: > On 08Jun2012 14:36, Neal Becker wrote: > | If a new file is created by open ('xxx', 'w') > | > | How can I control the file permission bits? Is my only choice to use chmod > | after opening, or use os.open? > | > | Wouldn&#x

Re: mode for file created by open

2012-06-09 Thread Neal Becker
Terry Reedy wrote: > On 6/9/2012 10:08 AM, Devin Jeanpierre wrote: >> On Sat, Jun 9, 2012 at 7:42 AM, Neal Becker wrote: >>> Doesn't anyone else think it would be a good addition to open to specify a >>> file >>> creation mode? Like posix open? Avoi

module name vs '.'

2012-06-18 Thread Neal Becker
Am I correct that a module could never come from a file path with a '.' in the name? -- http://mail.python.org/mailman/listinfo/python-list

Re: module name vs '.'

2012-06-18 Thread Neal Becker
I meant a module src.directory contains __init__.py neal.py becker.py from src.directory import neal On Mon, Jun 18, 2012 at 9:44 AM, Dave Angel wrote: > On 06/18/2012 09:19 AM, Neal Becker wrote: > > Am I correct that a module could never come from a file path with a '.'

writable iterators?

2011-06-22 Thread Neal Becker
AFAICT, the python iterator concept only supports readable iterators, not write. Is this true? for example: for e in sequence: do something that reads e e = blah # will do nothing I believe this is not a limitation on the for loop, but a limitation on the python iterator concept. Is thi

Re: writable iterators?

2011-06-22 Thread Neal Becker
Steven D'Aprano wrote: > On Wed, 22 Jun 2011 15:28:23 -0400, Neal Becker wrote: > >> AFAICT, the python iterator concept only supports readable iterators, >> not write. Is this true? >> >> for example: >> >> for e in sequence: >> do s

Re: writable iterators?

2011-06-23 Thread Neal Becker
Ian Kelly wrote: > On Wed, Jun 22, 2011 at 3:54 PM, Steven D'Aprano > wrote: >> Fortunately, that's not how it works, and far from being a "limitation", >> it would be *disastrous* if iterables worked that way. I can't imagine >> how many bugs would occur from people reassigning to the loop varia

Re: writable iterators?

2011-06-23 Thread Neal Becker
Chris Torek wrote: > In article I wrote, in part: >>Another possible syntax: >> >>for item in container with key: >> >>which translates roughly to "bind both key and item to the value >>for lists, but bind key to the key and value for the value for >>dictionary-ish items". Then ... the OP wo

'Use-Once' Variables and Linear Objects

2011-08-02 Thread Neal Becker
I thought this was an interesting article http://www.pipeline.com/~hbaker1/Use1Var.html -- http://mail.python.org/mailman/listinfo/python-list

argparse, tell if arg was defaulted

2011-03-15 Thread Neal Becker
Is there any way to tell if an arg value was defaulted vs. set on command line? -- http://mail.python.org/mailman/listinfo/python-list

Re: argparse, tell if arg was defaulted

2011-03-15 Thread Neal Becker
Robert Kern wrote: > On 3/15/11 9:54 AM, Neal Becker wrote: >> Is there any way to tell if an arg value was defaulted vs. set on command >> line? > > No. If you need to determine that, don't set a default value in the > add_argument() method. Then just check for

Re: argparse, tell if arg was defaulted

2011-03-15 Thread Neal Becker
Robert Kern wrote: > On 3/15/11 12:46 PM, Neal Becker wrote: >> Robert Kern wrote: >> >>> On 3/15/11 9:54 AM, Neal Becker wrote: >>>> Is there any way to tell if an arg value was defaulted vs. set on command >>>> line? >>> >>> N

argparse csv + choices

2011-03-30 Thread Neal Becker
I'm trying to combine 'choices' with a comma-seperated list of options, so I could do e.g., --cheat=a,b parser.add_argument ('--cheat', choices=('a','b','c'), type=lambda x: x.split(','), default=[]) test.py --cheat a error: argument --cheat: invalid choice: ['a'] (choose from 'a', 'b',

Re: argparse csv + choices

2011-03-31 Thread Neal Becker
Robert Kern wrote: > On 3/30/11 10:32 AM, Neal Becker wrote: >> I'm trying to combine 'choices' with a comma-seperated list of options, so I >> could do e.g., >> >> --cheat=a,b >> >> parser.add_argument ('--cheat'

Re: python ioctl

2011-04-14 Thread Neal Becker
Nitish Sharma wrote: > Hi PyPpl, > For my current project I have a kernel device driver and a user-space > application. This user-space application is already provided to me, and > written in python. I have to extend this application with some addition > features, which involves communicating with

Re: Get the IP address of WIFI interface

2011-05-15 Thread Neal Becker
Far.Runner wrote: > Hi python experts: > There are two network interfaces on my laptop: one is 100M Ethernet > interface, the other is wifi interface, both are connected and has an ip > address. > The question is: How to get the ip address of the wifi interface in a python > script without parsing

cPickle -> invalid signature

2011-05-17 Thread Neal Becker
What does it mean when cPickle.load says: RuntimeError: invalid signature Is binary format not portable? -- http://mail.python.org/mailman/listinfo/python-list

Re: cPickle -> invalid signature

2011-05-17 Thread Neal Becker
Gabriel Genellina wrote: > En Tue, 17 May 2011 08:41:41 -0300, Neal Becker > escribió: > >> What does it mean when cPickle.load says: >> RuntimeError: invalid signature >> >> Is binary format not portable? > > Are you sure that's the actual error me

when is filter test applied?

2017-10-03 Thread Neal Becker
In the following code (python3): for rb in filter (lambda b : b in some_seq, seq): ... some code that might modify some_seq I'm assuming that the test 'b in some_seq' is applied late, at the start of each iteration (but it doesn't seem to be working that way in my real code), so that if 'some

Re: when is filter test applied?

2017-10-03 Thread Neal Becker
urs) seems to be > wrong. Can you provide a reproducible test case? I'd be inclined to > run that through dis.dis to see what bytecode was produced. > > Paul > > On 3 October 2017 at 16:08, Neal Becker wrote: > > In the following code (python3): > > >

f-string syntax deficiency?

2023-06-06 Thread Neal Becker
The following f-string does not parse and gives syntax error on 3.11.3: f'thruput/{"user" if opt.return else "cell"} vs. elevation\n' However this expression, which is similar does parse correctly: f'thruput/{"user" if True else "cell"} vs. elevation\n' I don't see any workaround. Parenthesizi

Re: Recommendation for drawing graphs and creating tables, saving as PDF

2021-06-11 Thread Neal Becker
Jan Erik Moström wrote: > I'm doing something that I've never done before and need some advise for > suitable libraries. > > I want to > > a) create diagrams similar to this one > https://www.dropbox.com/s/kyh7rxbcogvecs1/graph.png?dl=0 (but with more > nodes) and save them as PDFs or some forma

best way to ensure './' is at beginning of sys.path?

2017-02-03 Thread Neal Becker
I want to make sure any modules I build in the current directory overide any others. To do this, I'd like sys.path to always have './' at the beginning. What's the best way to ensure this is always true whenever I run python3? -- https://mail.python.org/mailman/listinfo/python-list

Re: best way to ensure './' is at beginning of sys.path?

2017-02-04 Thread Neal Becker
Neal Becker wrote: > I want to make sure any modules I build in the current directory overide > any > others. To do this, I'd like sys.path to always have './' at the > beginning. > > What's the best way to ensure this is always true whenever I run python

profile guided optimization of loadable python modules?

2018-07-04 Thread Neal Becker
Has anyone tried to optimize shared libraries (for loadable python modules) using gcc with profile guided optimization? Is it possible? Thanks, Neal -- https://mail.python.org/mailman/listinfo/python-list

Re: clever exit of nested loops

2018-09-27 Thread Neal Becker
Christian Gollwitzer wrote: > Am 26.09.18 um 12:28 schrieb Bart: >> On 26/09/2018 10:10, Peter Otten wrote: >>> class Break(Exception): >>> pass >>> >>> try: >>> for i in range(10): >>> print(f'i: {i}') >>> for j in range(10): >>> print(f'\tj: {j}') >>> for k in range(10): >>> print(f'\t\tk: {k}')

I'd like to add -march=native to my pip builds

2016-04-08 Thread Neal Becker
I'd like to add -march=native to my pip builds. How can I do this? -- https://mail.python.org/mailman/listinfo/python-list

Re: I'd like to add -march=native to my pip builds

2016-04-08 Thread Neal Becker
Stefan Behnel wrote: > CFLAGS="-O3 -march=native" pip install --no-use-wheel Thanks, not bad. But no way to put this in a config file so I don't have to remember it, I guess? -- https://mail.python.org/mailman/listinfo/python-list

Just-in-Time Static Type Checking for Dynamic Languages

2016-04-20 Thread Neal Becker
I saw this article, which might interest some of you. It discusses application to ruby, but perhaps might have ideas useful for python. https://arxiv.org/abs/1604.03641 -- https://mail.python.org/mailman/listinfo/python-list

pickle and module versioning

2018-12-17 Thread Neal Becker
I find pickle really handy for saving results from my (simulation) experiments. But recently I realized there is an issue. Reading the saved results requires loading the pickle, which in turn will load any referenced modules. Problem is, what if the modules have changed? For example, I just

Re: How to force the path of a lib ?

2019-01-23 Thread Neal Becker
dieter wrote: > Vincent Vande Vyvre writes: >> I am working on a python3 binding of a C++ lib. This lib is installed >> in my system but the latest version of this lib introduce several >> incompatibilities. So I need to update my python binding. >> >> I'm working into a virtual environment (py37

exit 2 levels of if/else and execute common code

2019-02-11 Thread Neal Becker
I have code with structure: ``` if cond1: [some code] if cond2: #where cond2 depends on the above [some code] [ more code] else: [ do xxyy ] else: [ do the same xxyy as above ] ``` So what's the best style to handle this? As coded, it violates DRY. Try/except could be used with

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Neal Becker
Rhodri James wrote: > On 11/02/2019 15:25, Neal Becker wrote: >> I have code with structure: >> ``` >> if cond1: >>[some code] >>if cond2: #where cond2 depends on the above [some code] >> [ more code] >> >>else: >>

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Neal Becker
Chris Angelico wrote: > On Tue, Feb 12, 2019 at 2:27 AM Neal Becker wrote: >> >> I have code with structure: >> ``` >> if cond1: >> [some code] >> if cond2: #where cond2 depends on the above [some code] >> [ more code] >> >> els

Re: exit 2 levels of if/else and execute common code

2019-02-11 Thread Neal Becker
Chris Angelico wrote: > On Tue, Feb 12, 2019 at 3:21 AM Neal Becker wrote: >> >> Chris Angelico wrote: >> >> > On Tue, Feb 12, 2019 at 2:27 AM Neal Becker >> > wrote: >> >> >> >> I have code with structure: >> >> ``` &g

@staticmethod, backward compatibility?

2005-09-27 Thread Neal Becker
How can I write code to take advantage of new decorator syntax, while allowing backward compatibility? I almost want a preprocessor. #if PYTHON_VERSION >= 2.4 @staticmethod ... Since python < 2.4 will just choke on @staticmethod, how can I do this? -- http://mail.python.org/mailman/listinfo/p

Compile fails on x86_64

2005-09-30 Thread Neal Becker
In file included from scipy/base/src/multiarraymodule.c:44: scipy/base/src/arrayobject.c: In function 'array_frominterface': scipy/base/src/arrayobject.c:5151: warning: passing argument 3 of 'PyArray_New' from incompatible pointer type error: Command "gcc -pthread -fno-strict-aliasing -DNDEBUG -O2

compile fails on x86_64 (more)

2005-09-30 Thread Neal Becker
In file included from scipy/base/src/multiarraymodule.c:44: scipy/base/src/arrayobject.c:41: error: conflicting types for 'PyArray_PyIntAsIntp' build/src/scipy/base/__multiarray_api.h:147: error: previous declaration of 'PyArray_PyIntAsIntp' was here -- http://mail.python.org/mailman/listinfo/py

Can module access global from __main__?

2005-10-11 Thread Neal Becker
Suppose I have a main program, e.g., A.py. In A.py we have: X = 2 import B Now B is a module B.py. In B, how can we access the value of X? -- http://mail.python.org/mailman/listinfo/python-list

Re: Can module access global from __main__?

2005-10-11 Thread Neal Becker
Everything you said is absolutely correct. I was being lazy. I had a main program in module, and wanted to reorganize it, putting most of it into a new module. Being python, it actually only took a small effort to fix this properly, so that in B.py, what were global variables are now passed as a

1-liner to iterate over infinite sequence of integers?

2005-10-13 Thread Neal Becker
I can do this with a generator: def integers(): x = 1 while (True): yield x x += 1 for i in integers(): Is there a more elegant/concise way? -- http://mail.python.org/mailman/listinfo/python-list

Re: shared library search path

2005-11-03 Thread Neal Becker
Stefan Arentz wrote: > > Hi. I've wrapped a C++ class with Boost.Python and that works great. But, > I am now packaging my application so that it can be distributed. The > structure is basically this: > > .../bin/foo.py > .../lib/foo.so > .../lib/bar.py > > In foo.py I do the following: > >

Re: efficient 'tail' implementation

2005-12-08 Thread Neal Becker
[EMAIL PROTECTED] wrote: > hi > > I have a file which is very large eg over 200Mb , and i am going to use > python to code a "tail" > command to get the last few lines of the file. What is a good algorithm > for this type of task in python for very big files? > Initially, i thought of reading ev

Re: Recommendations for CVS systems

2005-08-10 Thread Neal Becker
[EMAIL PROTECTED] wrote: > I was wondering if anyone could make recomendations/comments about CVS > systems, their experiences and what perhaps the strengths of each. > > Currently we have 2 developers but expect to grow to perhaps 5. > > Most of the developement is Python, but some C, Javascrip

python optimization

2005-09-15 Thread Neal Becker
I use cpython. I'm accustomed (from c++/gcc) to a style of coding that is highly readable, making the assumption that the compiler will do good things to optimize the code despite the style in which it's written. For example, I assume constants are removed from loops. In general, an entity is de

Re: python optimization

2005-09-15 Thread Neal Becker
Reinhold Birkenfeld wrote: > David Wilson wrote: >> For the most part, CPython performs few optimisations by itself. You >> may be interested in psyco, which performs several heavy optimisations >> on running Python code. >> >> http://psyco.sf.net/ >> I might be, if it supported x86_64, but AFA

RE: [Python-Dev] python optimization

2005-09-16 Thread Neal Becker
One possible way to improve the situation is, that if we really believe python cannot easily support such optimizations because the code is too "dynamic", is to allow manual annotation of functions. For example, gcc has allowed such annotations using __attribute__ for quite a while. This would al

Re: Python:C++ interfacing. Tool selection recommendations

2005-09-16 Thread Neal Becker
[EMAIL PROTECTED] wrote: > Hi, > > I am embedding Python with a C++ app and need to provide the Python > world with access to objects & data with the C++ world. > > I am aware or SWIG, BOOST, SIP. Are there more? > > I welcome comments of the pros/cons of each and recommendations on when > it a

unusual exponential formatting puzzle

2005-09-21 Thread Neal Becker
Like a puzzle? I need to interface python output to some strange old program. It wants to see numbers formatted as: e.g.: 0.23456789E01 That is, the leading digit is always 0, instead of the first significant digit. It is fixed width. I can almost get it with '% 16.9E', but not quite. My sol

Re: unusual exponential formatting puzzle

2005-09-21 Thread Neal Becker
[EMAIL PROTECTED] wrote: > > [EMAIL PROTECTED] wrote: >> Neal Becker wrote: >> > Like a puzzle? I need to interface python output to some strange old >> > program. It wants to see numbers formatted as: >> > >> > e.g.: 0.23456789E01 >> >

Re: unusual exponential formatting puzzle

2005-09-22 Thread Neal Becker
Paul Rubin wrote: > Neal Becker <[EMAIL PROTECTED]> writes: >> Like a puzzle? I need to interface python output to some strange old >> program. It wants to see numbers formatted as: >> >> e.g.: 0.23456789E01 > > Yeah, that was normal with FORTRAN. &g

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
sohcahto...@gmail.com 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 > numpy-discuss...@scipy.org > 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

  1   2   3   4   >