decorator to prevent adding attributes to class?

2008-07-11 Thread Neal Becker
After spending the morning debugging where I had misspelled the name of an attribute (thus adding a new attr instead of updating an existing one), I would like a way to decorate a class so that attributes cannot be (easily) added. I guess class decorators are not available yet (pep 3129), but prob

profiling question

2008-07-10 Thread Neal Becker
Just to confirm, the profiling numbers (from cProfile) do include time spent inside my own C functions that I import as modules? -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamically load from module import xxx

2008-07-01 Thread Neal Becker
Guilherme Polo wrote: > On Tue, Jul 1, 2008 at 12:11 PM, Neal Becker <[EMAIL PROTECTED]> wrote: >> What is a good way to emulate: >> >> from module import xxx >> where 'module' is a dynamically generated string? >> >> __import__ ('modul

dynamically load from module import xxx

2008-07-01 Thread Neal Becker
What is a good way to emulate: from module import xxx where 'module' is a dynamically generated string? __import__ ('modulename', fromlist=['xxx']) seems to be what I want, but then it seems 'xxx' is not placed in globals() (which makes me wonder, what exactly did fromlist do?) -- http://mail.p

Re: [ctypes] convert pointer to string?

2008-05-21 Thread Neal Becker
[EMAIL PROTECTED] wrote: > Neal Becker napisał(a): >> In an earlier post, I was interested in passing a pointer to a structure >> to fcntl.ioctl. >> >> This works: >> >> c = create_string_buffer (...) >> args = struct.pack("iP", len(c), c

Re: [ctypes] convert pointer to string?

2008-05-21 Thread Neal Becker
[EMAIL PROTECTED] wrote: > Neal Becker napisał(a): >> In an earlier post, I was interested in passing a pointer to a structure >> to fcntl.ioctl. >> >> This works: >> >> c = create_string_buffer (...) >> args = struct.pack("iP", len(c), c

[ctypes] convert pointer to string?

2008-05-21 Thread Neal Becker
In an earlier post, I was interested in passing a pointer to a structure to fcntl.ioctl. This works: c = create_string_buffer (...) args = struct.pack("iP", len(c), cast (pointer (c), c_void_p).value) err = fcntl.ioctl(eos_fd, request, args) Now to do the same with ctypes, I have one problem. c

send gpg encrypted emails (properly mime formatted)

2008-05-01 Thread Neal Becker
Any ideas on python packages that could help with sending gpg encrypted (properly mime formatted) emails? My idea is to forward all my emails to a remote imap server, but gpg encrypt them to myself in the process. -- http://mail.python.org/mailman/listinfo/python-list

ioctl.py

2008-04-26 Thread Neal Becker
Gabriel Genellina wrote: > En Fri, 25 Apr 2008 09:30:56 -0300, Neal Becker <[EMAIL PROTECTED]> > escribió: > >> I need an ioctl call equivalent to this C code: >> >> my_struct s; >> s.p = p; << a pointer to an array of char >> s.im

problem with mmap

2008-04-25 Thread Neal Becker
On linux, I don't understand why: f = open ('/dev/eos', 'rw') m = mmap.mmap(f.fileno(), 100, prot=mmap.PROT_READ|mmap.PROT_WRITE, flags=mmap.MAP_SHARED) gives 'permission denied', but this c++ code works: #include #include #include #include #include int main() { int fd = open ("/dev/

ioctl, pass buffer address, howto?

2008-04-25 Thread Neal Becker
I need an ioctl call equivalent to this C code: my_struct s; s.p = p; << a pointer to an array of char s.image_size = image_size; return (ioctl(fd, xxx, &s)); I'm thinking to use python array for the array of char, but I don't see how to put it's address into the structure. Maybe

Re: How to factor using Python?

2008-03-11 Thread Neal Becker
Nathan Pinno wrote: > How do I factor a number? I mean how do I translate x! into proper > Python code, so that it will always do the correct math? > > Thanks in advance, > Nathan P. import os os.system('factor 25') -- http://mail.python.org/mailman/listinfo/python-list

Re: can't set attributes of built-in/extension type

2008-02-21 Thread Neal Becker
Steve Holden wrote: > Neal Becker wrote: >> Steve Holden wrote: >> >>> Neal Becker wrote: >>>> 7stud wrote: >>>> >>>>> On Feb 21, 11:19 am, Neal Becker <[EMAIL PROTECTED]> wrote: >>>>>> I'm workin

Re: can't set attributes of built-in/extension type

2008-02-21 Thread Neal Becker
Steve Holden wrote: > Neal Becker wrote: >> 7stud wrote: >> >>> On Feb 21, 11:19 am, Neal Becker <[EMAIL PROTECTED]> wrote: >>>> I'm working on a simple extension. Following the classic 'noddy' >>>> example. >>>>

Re: can't set attributes of built-in/extension type

2008-02-21 Thread Neal Becker
7stud wrote: > On Feb 21, 11:19 am, Neal Becker <[EMAIL PROTECTED]> wrote: >> I'm working on a simple extension.  Following the classic 'noddy' >> example. >> >> In [15]: cmplx_int32 >> Out[15]: >> >> Now I want to add an at

can't set attributes of built-in/extension type

2008-02-21 Thread Neal Becker
I'm working on a simple extension. Following the classic 'noddy' example. In [15]: cmplx_int32 Out[15]: Now I want to add an attribute to this type. More precisely, I want a class attribute. cmplx_int32.test = 0 --- TypeE

Re: ODF vs OOXML (was: Write ooxml .ods (spreadsheat) from python?)

2008-02-13 Thread Neal Becker
Ben Finney wrote: > Neal Becker <[EMAIL PROTECTED]> writes: > >> I'd like to output some data directly in .ods format. > > Presumably you mean the OpenDocument Spreadsheet format. That's not > OOXML, it's ODF, the international standard document forma

Re: Write ooxml .ods (spreadsheat) from python?

2008-02-13 Thread Neal Becker
Guilherme Polo wrote: > 2008/2/13, Neal Becker <[EMAIL PROTECTED]>: >> I'd like to output some data directly in .ods format. > > Do you want to output data from .ods file or do you want to input data > into an ods ? > >> This format appears >> to be

Re: Write ooxml .ods (spreadsheat) from python?

2008-02-13 Thread Neal Becker
Rolf van de Krol wrote: > Neal Becker wrote: >> I'd like to output some data directly in .ods format. This format >> appears >> to be quite complex. Is there any python software available to do this? >> I >> did look at pyuno briefly. It looks pretty com

Write ooxml .ods (spreadsheat) from python?

2008-02-13 Thread Neal Becker
I'd like to output some data directly in .ods format. This format appears to be quite complex. Is there any python software available to do this? I did look at pyuno briefly. It looks pretty complicated also, and it looks like it uses it's own private version of python, which would not help me.

Re: Turn off ZeroDivisionError?

2008-02-11 Thread Neal Becker
Mark Dickinson wrote: > On Feb 10, 3:10 pm, [EMAIL PROTECTED] wrote: >> What Python run on a CPU that doesn't handle the nan correctly? > > How about platforms that don't even have nans? I don't think either > IBM's hexadecimal floating-point format, or the VAX floating-point > formats > support

Re: use 'with' to redirect stdout

2008-02-11 Thread Neal Becker
Thanks! I understand this better now. This is really an example of a more general pattern: @contextmanager def rebind_attr(object_, attr, value): orig = getattr(object_, attr) setattr(object_, attr, value) yield setattr(object_, attr_, orig) -- http://mail.python.org/mailman/l

Re: use 'with' to redirect stdout

2008-02-11 Thread Neal Becker
This will work for stdout: from __future__ import with_statement from contextlib import contextmanager import sys @contextmanager def redirect(newfile): orig_stdout = sys.stdout sys.stdout = newfile yield sys.stdout = orig_stdout if __name__ == "__main__": with redirect (open

Re: use 'with' to redirect stdout

2008-02-11 Thread Neal Becker
Jean-Paul Calderone wrote: > On Mon, 11 Feb 2008 09:15:07 -0500, Neal Becker <[EMAIL PROTECTED]> > wrote: >>Is there a simple way to use a 'with' statement to redirect stdout in a >>block? > > Do you mean "without writing a context manager to do

use 'with' to redirect stdout

2008-02-11 Thread Neal Becker
Is there a simple way to use a 'with' statement to redirect stdout in a block? -- http://mail.python.org/mailman/listinfo/python-list

Re: Turn off ZeroDivisionError?

2008-02-10 Thread Neal Becker
Christian Heimes wrote: > Grant Edwards wrote: >> A more efficient implementation? Just delete the code that >> raises the exception and the HW will do the right thing. > > Do you really think that the hardware and the C runtime library will do > the right thing? Python runs on a lots platforms

Re: Turn off ZeroDivisionError?

2008-02-10 Thread Neal Becker
[EMAIL PROTECTED] wrote: > Would a wrapper function be out of the question here? > > def MyDivision(num, denom): > if denom==0: > return "NaN" > else > return num / denom I bought a processor that has hardware to implement this. Why do I want software to waste time on it

Turn off ZeroDivisionError?

2008-02-09 Thread Neal Becker
I'd like to turn off ZeroDivisionError. I'd like 0./0. to just give NaN, and when output, just print 'NaN'. I notice fpconst has the required constants. I don't want to significantly slow floating point math, so I don't want to just trap the exception. If I use C code to turn off the hardware s

index() of sequence type?

2008-02-07 Thread Neal Becker
I see list has index member, but is there an index function that applies to any sequence type? If not, shouldn't there be? -- http://mail.python.org/mailman/listinfo/python-list

checkpoint/restart python processes

2008-02-01 Thread Neal Becker
Hi numeric processing fans. I'm pleased to report that you can now have convenient checkpoint/restart, at least if you are running fedora linux. Example: python -i blcr_mod.py <<< this will start python, then checkpoint it c_int(2) (ignore this debug) >>> [quit] cr_restart checkpoint.nbecker1.2

MyHDL (was Re: Will Python on day replace MATLAB...)

2008-02-01 Thread Neal Becker
I was not aware of MyHDL, sounds interesting. But, last release was May 2006. I wonder if it still active? -- http://mail.python.org/mailman/listinfo/python-list

typename

2008-01-29 Thread Neal Becker
I want python code that given an instance of a type, prints the type name, like: typename (0) -> 'int' I know how to do this with the C-api, (o->tp_name), but how do I do it from python? type(0) prints "", not really what I wanted. -- http://mail.python.org/mailman/listinfo/python-list

Re: Index of maximum element in list

2008-01-25 Thread Neal Becker
Henry Baxter wrote: > Oops, gmail has keyboard shortcuts apparently, to continue: > > def maxi(l): > m = max(l) > for i, v in enumerate(l): > if m == v: > return i > > But it seems like something that should be built in - or at least I should > be able to write a lamb

index of min element of sequence

2008-01-21 Thread Neal Becker
What's a good/fast way to find the index of the minimum element of a sequence? (I'm fairly sure sorting the sequence is not the fastest approach) -- http://mail.python.org/mailman/listinfo/python-list

Re: Gui front-end to version control program

2008-01-19 Thread Neal Becker
David Delony wrote: > I spoke with Eric S. Raymond at a Linux user's group meeting a few days > ago about the need for version control for end users. > I thought that Python might be a good candidate for this. > > Luckily, Guido was there as well. I talked this over with him and he > suggested us

ucs2 or ucs4?

2008-01-14 Thread Neal Becker
How do I tell if my python-2.5 is build with ucs2 or ucs4? -- http://mail.python.org/mailman/listinfo/python-list

OpenOpt install

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

simple string formatting question

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

Recommendations for writing a user guide with examples?

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

Re: which configparse?

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

which configparse?

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

struct,long on 64-bit machine

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

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

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

Re: Which persistence is for me?

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

Which persistence is for me?

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

help with pyparsing

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

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

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

Re: getopt with negative numbers?

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

Re: getopt with negative numbers?

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

puzzled about floats

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

code check for modifying sequence while iterating over it?

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

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

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

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

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

interaction of 'with' and 'yield'

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

Re: problem with change to exceptions

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

problem with change to exceptions

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

Re: python extra

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

python extra

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

Is there a way to hook into module destruction?

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

Re: global destructor not called?

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

global destructor not called?

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

Re: block scope?

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

block scope?

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

MIME text attachment question

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

Re: Parallel Python

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

python on tivo (series2)?

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

Re: Find interface associated with default route?

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

Re: Find interface associated with default route?

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

Find interface associated with default route?

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

Re: iterator question

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

iterator question

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

Cool! A python course!

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

Re: [ANN] IronPython 1.0 released today!

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

Re: Boost Python Issue

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

Re: Boost Python Issue

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

Re: MinGW and Python

2006-04-26 Thread Neal Becker
Alex Martelli wrote: > sturlamolden <[EMAIL PROTECTED]> wrote: > >> Robert Kern wrote: >> >> > Dunno. Depends on the machine. Depends on the program. Depends on how >> > the interpreter and any extension modules and underlying libraries were >> > built. Depends on which Linux and which Windows.

Re: Missing interfaces in Python...

2006-04-19 Thread Neal Becker
[EMAIL PROTECTED] wrote: > I'm coming from a Java background, so please don't stone me... > > I see that Python is missing "interfaces". The concept of an interface > is a key to good programming design in Java, but I've read that they > aren't really necessary in Python. I am wondering what tech

Re: Automated Graph Plotting in Python

2006-04-10 Thread Neal Becker
Felipe Almeida Lessa wrote: > Em Sáb, 2006-04-08 às 20:08 -0700, [EMAIL PROTECTED] escreveu: >> My python program spits lot of data. I take that data and plot graphs >> using OfficeOrg spredsheet. I want to automate this task as this takes >> so much of time. I have some questions. > > You can tr

Re: Compleated Begginers Guide. Now What?

2006-04-08 Thread Neal Becker
Maybe find a spell checker? -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN] functional 0.5 released

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

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

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

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

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

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

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

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

@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

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

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

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

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

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

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

<    1   2   3