Solutions for finding the 1000th prime

2010-05-21 Thread Neal
I'm doing the MIT OpenCourseWare class that this assignment hails from and I don't doubt that its a relatively common assignment. Upon searching for it for some ideas of why my program wouldn't work one of the top results is this a thread from this group full of derision and sarcasm. Believe me I u

Re: Solutions for finding the 1000th prime

2010-05-21 Thread Neal
You did provide a very constructive answer and I do apologize for generalizing the group or all the posts. And while the original poster did not seem to have made much of an effort, the tone of the initial response of that thread turns off anyone else who may be willing to make that effort. I also

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
[email protected] 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: > [email protected] 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
(although haven't really thought through the details). Thanks, Neal -- https://mail.python.org/mailman/listinfo/python-list

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

Re: isatty() for file-like objects: Implement or not?

2005-10-04 Thread Neal Norwitz
HOWARD GOLDEN wrote: > The standard documentation for isatty() says: > > "Return True if the file is connected to a tty(-like) device, else > False. Note: If a file-like object is not associated with a real file, > this method should not be implemented." > > In his book, "Text Processing in

Re: Python 2.4.2 HPUX-PARISC compile issues

2005-10-05 Thread Neal Norwitz
[EMAIL PROTECTED] wrote: > When compiling HPUX for PARISC with the following environemnt variables > I get the following errors. > > CFLAGS=+DD64 -fast > CC=aCC > LDFLAGS=+DD64 > > What do I need to do in order to get this to compile? This info should be in the README file for 2.4.2: + To b

Re: Idle bytecode query on apparently unreachable returns

2005-10-09 Thread Neal Norwitz
Tom Anderson wrote: > Evening all, > > Here's a brief chat with the interpretator: [snip] > What puzzles me, though, are bytecodes 17, 39 and 42 - surely these aren't > reachable? Does the compiler just throw in a default 'return None' > epilogue, with routes there from every code path, even when

Re: Python reliability

2005-10-09 Thread Neal Norwitz
Ville Voipio wrote: > > The software should be running continously for > practically forever (at least a year without a reboot). > Is the Python interpreter (on Linux) stable and > leak-free enough to achieve this? Jp gave you the answer that he has done this. I've spent quite a bit of time since

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

Re: Can module access global from __main__?

2005-10-11 Thread Neal Norwitz
Steve Holden wrote: > Neal Becker wrote: > > > > Still curious about the answer. If I know that I am imported from __main__, > > then I can do access X as sys.modules[__main__].X. In general, I don't > > know how to determine who is importing me. > > > I

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

2005-10-13 Thread Neal Norwitz
g.franzkowiak wrote: > Hi everybody, > > my interest is for the internals of the Python interpreter. > > I've used up to now FORTH for something and this indirect interpreter is > very smart. > --- ASM --- > > Where can I find information

Re: Python script produces "sem_trywait: Permission denied"

2005-10-18 Thread Neal Norwitz
Mark E. Hamilton wrote: > Sorry, I probably should have re-stated the problem: > > We're using Python 2.3.5 on AIX 5.2, and get the follow error messages > from some of our code. I haven't yet tracked down exactly where it's > coming from: > > sem_trywait: Permission denied > sem_wait: Permission d

Re: make: circular dependency for Modules/signalmodule.o

2005-10-18 Thread Neal Norwitz
James Buchanan wrote: > Hi group, > > I'm preparing Python 2.4.2 for the upcoming Minix 3.x release, and I > have problems with make. configure runs fine and creates the makefile, > but right at the end ends with an error about a circular dependency in > Modules/signalmodule.o. I've never heard o

Re: Extention Woes

2005-10-19 Thread Neal Norwitz
Tuvas wrote: > Forgot, var declartions > > int can_han; > int com; > char len; > char dat[8]; That should probably be: int len; char *dat; IIRC, "z" returns the internal string pointer. "#" is definitely not going to return a char. I'm pretty sure it r

Re: python gc performance in large apps

2005-10-22 Thread Neal Norwitz
Jp Calderone wrote: > On Fri, 21 Oct 2005 16:13:09 -0400, Robby Dermody <[EMAIL PROTECTED]> wrote: > > > > [snip - it leaks memory] > > One thing to consider is that the process may be growing in size, not because > garbage objects are not being freed, but because objects which should be > garbag

Re: dictionary that have functions with arguments

2005-11-02 Thread Neal Norwitz
Ron Adam wrote: > > Eval or exec aren't needed. Normally you would just do... > > execfunc['key1'](**args) > > If your arguments are stored ahead of time with your function... > > Committed revision 41366. > > You could then do... > > func, args = execfunc['key1'] > func(**args)

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: best way to discover this process's current memory usage, cross-platform?

2005-11-14 Thread Neal Norwitz
Alex Martelli wrote: > > So, I thought I'd turn to the "wisdom of crowds"... how would YOU guys > go about adding to your automated regression tests one that checks that > a certain memory leak has not recurred, as cross-platform as feasible? > In particular, how would you code _memsize() "cross-pl

Re: best way to discover this process's current memory usage, cross-platform?

2005-11-15 Thread Neal Norwitz
Alex Martelli wrote: > matt <[EMAIL PROTECTED]> wrote: > > > Perhaps you could extend Valgrind (http://www.valgrind.org) so it works > > with python C extensions? (x86 only) > > Alas, if it's x86 only I won't even look into the task (which does sound > quite daunting as the way to solve the appare

Re: Any college offering Python short term course?

2005-11-21 Thread Neal Norwitz
There is the BayPiggies user group: [EMAIL PROTECTED] It meets monthly alternating between Mt. VIew (Google) and San Bruno (IronPort). n -- bruce wrote: > hey... > > i'm looking for classes (advanced) in python/php in the bay area as well... > actually i'm looking for the students/teachers/prof

Re: 2.4.2 on AIX 4.3 make fails on threading

2005-11-22 Thread Neal Norwitz
Paul Watson wrote: > When I try to build 2.4.2 on AIX 4.3, it fails on missing thread > objects. I ran ./configure --without-threads --without-gcc. > > Before using --without-threads I had several .pthread* symbols missing. Perhaps you need to add -lpthread to the link line. This should be able

Re: Singleton and C extensions

2005-11-25 Thread Neal Norwitz
Emmanuel Briot wrote: > > I am not really good at python, but I was trying to implement the > singleton design pattern in C, so that for instance calling the constructor > >ed = Editor ("foo") > > would either return an existing instance of Editor currently editing > "foo", or would create a ne

Re: A bug in struct module on the 64-bit platform?

2005-11-30 Thread Neal Norwitz
[EMAIL PROTECTED] wrote: > Hi, > > I have a user who complained about how "struct" module computes C > struct data size on Itanium2 based 64-bit machine. I wouldn't be surprised, but I don't understand the problem. >>>struct.calcsize('idi') >16 >>>struct.calcsize('idid') >24 >

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: tkinter socket client ?

2005-01-21 Thread Neal Norwitz
(self, sd, mask): data = self.sd.recv(SIZE) (Sorry if the formatting is busted, blame google groups.) HTH, Neal -- http://mail.python.org/mailman/listinfo/python-list

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

PyChecker lives, version 0.8.15 released

2005-08-31 Thread Neal Norwitz
rce Forge: Web page: http://pychecker.sourceforge.net/ Project page: http://sourceforge.net/projects/pychecker/ Mailing List: [EMAIL PROTECTED] Neal -- [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Design Principles

2005-09-09 Thread Neal Norwitz
[EMAIL PROTECTED] wrote: > > But I am still puzzled by the argument that has been given for why > methods that operate on mutable types should return None, namely, that > the designers of python didn't want the users to shoot themselves in > the foot by thinking a method simply returned a result an

Re: Simplifying imports?

2005-09-12 Thread Neal Norwitz
[EMAIL PROTECTED] wrote: > I like to keep my classes each in a separate file with the same name of > the class. The problem with that is that I end up with multiple imports > in the beginning of each file, like this: > > from foo.Bar import Bar > from foo.Blah import Blah > from foo.Zzz import Zzz

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

  1   2   3   4   >