Re: Should NoneType be iterable?

2023-06-19 Thread Neal Becker via Python-list
On Mon, Jun 19, 2023 at 12:42 PM Chris Angelico via Python-list < python-list@python.org> wrote: > On Tue, 20 Jun 2023 at 02:37, Peter Bona via Python-list > wrote: > > > > Hi > > > > I am wondering if there has been any discussion why NoneType is not > iterable My feeling is that it should be.

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.

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

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: >> >> ```

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] >> >>

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: >>

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

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

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: 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:

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: when is filter test applied?

2017-10-03 Thread Neal Becker
uition (and yours) 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 <ndbeck...@gmail.com> wrote: > > In the following code (pytho

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

Re: Buffers and pointers (Py3.4)

2017-04-18 Thread Neal Becker
When I worked on talking to some hardware in the past, the hardware was directly mapped to memory, and then numpy mmap worked great. Maybe not the same hardware interface you have. Rob Gaddi wrote: > So long as we're all feeling so concerned about speed lately... > > I've got a piece of

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 python3? Sorry if I was u

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

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

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

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: 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 file gets clos

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: [pythran] Pythran 0.7.4 is out!

2016-01-09 Thread Neal Becker
How do I build pythran3? On Thu, Jan 7, 2016 at 2:51 PM, serge guelton < serge.guel...@telecom-bretagne.eu> wrote: > (sorry for the double posting, if any) > > Dear pythraners and pythonists, > > The pythran team (a great total of 2 active developers) is delighted to > announce the release of

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:

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

Re: pip trouble

2015-10-30 Thread Neal Becker
Chris Warrick wrote: > On 30 October 2015 at 13:14, Neal Becker <ndbeck...@gmail.com> 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? >&

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 =

register cleanup handler

2015-07-24 Thread Neal Becker
I have code like: if (condition): do_something_needing_cleanup code_executed_unconditionally cleanup has to happen here if required, even if above did return, continue or exception Now, how can I make sure cleanup happens? Actually, what I really would like, is: if (condition):

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? I think so. Either that or I am

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 cleanup has to happen here if required, even if above did return, continue or exception Now, how can I make sure cleanup

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

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 ndbeck...@gmail.com 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

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

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: b 10, [1,2,3,4])): print

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

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 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 demo

__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: 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 test_prof.py Wrote profile results to test_prof.py.lprof Traceback (most recent call last): File /home/nbecker

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 instance of LineProfiler and insert it into the __builtins__ namespace with the name

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 module

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 before anything even ran 2. profile is not defined? kernprof -l

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

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 ran 2. profile is not defined? Well, is it defined? Where does it come

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 *

Re: help with pypeg2?

2015-02-06 Thread Neal Becker
Ian Kelly wrote: On Fri, Feb 6, 2015 at 7:55 AM, Neal Becker ndbeck...@gmail.com 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' are fine, but 'p3' fails SyntaxError

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__

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): handle(x) If you mean literally some_predicate

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): handle(x) I like this best, except probably even better

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

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

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

Re: which async framework?

2014-03-12 Thread Neal Becker
Grant Edwards wrote: On 2014-03-11, Antoine Pitrou solip...@pitrou.net wrote: Sturla Molden sturla.molden at gmail.com writes: Chris Withers chris at 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:

Re: gdb unable to read python frame information

2014-03-07 Thread Neal Becker
dieter wrote: Wesley nisp...@gmail.com 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 to read

Re:How security holes happen

2014-03-03 Thread Neal Becker
Charles R Harris charlesr.har...@gmail.com 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

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

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]

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 example, here's one of my programs: python3 test_freq3.py

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. In the help message, I'd like to automatically add the default values. What

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

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

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 ipython-input-2-2b94675a98f1, line 1 p = lambda (x): x ^

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. --

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 oscar.j.benja...@gmail.com wrote: On 28 August 2013 16:15, Neal Becker ndbeck...@gmail.com wrote: The change in integer division seems to be the most insidious source of silent errors in porting code from python2 - since

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:

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 race

Re: [OT?]gmane not updating

2013-04-06 Thread Neal Becker
breamore...@yahoo.co.uk 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 been

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

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: Immutability and Python

2012-10-30 Thread Neal Becker
rusi wrote: On Oct 29, 8:20 pm, andrea crotti andrea.crott...@gmail.com wrote: snipped 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?

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. --

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

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 ndbeck...@gmail.com 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 C is changed, perhaps

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): for s3 in xrange (n_syms

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

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

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

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 with a

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

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 d...@davea.name wrote: On 06/18/2012 09:19 AM, Neal Becker wrote: Am I correct that a module could never come from a file path

Re: mode for file created by open

2012-06-09 Thread Neal Becker
Cameron Simpson wrote: On 08Jun2012 14:36, Neal Becker ndbeck...@gmail.com 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't this be a good thing to have

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 Beckerndbeck...@gmail.com wrote: Doesn't anyone else think it would be a good addition to open to specify a file creation mode? Like posix open? Avoid all these nasty workarounds? I do,

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

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 there

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

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

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

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

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't you try it? py import pickle py class C: ... a = 23 ... py c

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 the

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 ndbeck...@gmail.com 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]: True What does: import numpy all is numpy.all

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: 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

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: 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 ideas? Do youmean hash like digest

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

  1   2   3   >