Re: [Python-Dev] pip enhancement

2014-08-27 Thread Neal Becker
Wow, I didn't know that existed.  Maybe needs to be more obvious.

But not quite.  It doesn't distinguish between locally installed files, and
globally installed.  Here, globally installed are maintained by the OS
vendor packaging, while locally (user, not virtualenv) installed are
managed by pip.

Really what's needed is for pip --user to apply to all pip commands, and
tell pip to ignore the system stuff.

Running pip list --outdated runs a long time, and gives me a very long list
of packages that are outdated, leaving me to still sort through which are
--user (and I might want to update via pip) and which are global (and I
can't really do anything about, other than filing a bug report requesting
an update).


On Wed, Aug 27, 2014 at 9:24 AM, Paul Moore  wrote:

> On 27 August 2014 13:58, Neal Becker  wrote:
> > At least, pip should have the ability to alert the user to potential
> updates,
> >
> > pip update
> >
> > could list which packages need updating, and offer to perform the
> update.  I
> > think this would go a long way to helping with this problem.
>
> Do you mean something like "pip list --outdated"?
> Paul
>



-- 
*Those who don't understand recursion are doomed to repeat it*
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] pip enhancement

2014-08-27 Thread Neal Becker
On systems where os-level packaging is available (e.g., fedora linux), it is 
not 
unusual to want a newer python package installed than available from the 
vendor.  
pip install --user can be used for this.

But then there is the danger that these pip installed packages are not 
maintained.

At least, pip should have the ability to alert the user to potential updates,

pip update

could list which packages need updating, and offer to perform the update.  I 
think this would go a long way to helping with this problem.

-- 
-- Those who don't understand recursion are doomed to repeat it

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] can't assign to function call

2013-03-18 Thread Neal Becker
def F(x):
return x

x = 2
F(x) = 3

F(x) = 3
SyntaxError: can't assign to function call

Do we really need this restriction?  There do exist other languages without it.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] SWIG (was Re: Ctypes and the stdlib)

2011-08-29 Thread Neal Becker
Then there is gccxml, although I'm not sure how active it is now.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Draft PEP: "Simplified Package Layout and Partitioning"

2011-07-20 Thread Neal Becker
I wonder if this fixes the long-standing issue in OS vendor's distributions.  
In 
Fedora, for example, there is both arch-specific and non-arch directories: 
/usr/lib/python2.7 + /usr/lib64/python2.7, for example.  Pure python goes into 
/usr/lib/python2.7, and code including binaries goes into /usr/lib64/python2.7. 
 
But if a package has both, it all has to go into /usr/lib64/python2.7, because 
the current loader can't find pieces in 2 different directories.

You can't have both /usr/lib/python2.7/site-packages/foo and 
/usr/lib64/python2.7/site-packages/foo.

So if this PEP will allow pieces of foo to be found in 2 different places, that 
would be helpful, IMO.


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Pathscale compilers open source

2011-06-14 Thread Neal Becker
Skip Montanaro wrote:

> One of my colleagues with a background in the high performance computing
> realm sent me this press release:
> 
> http://www.pathscale.com/ekopath4-open-source-announcement
> 
> I'm not personally familiar with the Pathscale compilers, but thought some
> folks here might be and might want to experiment with them.
> 
> Skip

I just rebuilt all my c++ (boost::python) modules using pathscale, and I notice 
many crash with double-free on exit.  According to valgrind, this comes from 
the 
pathscale stl:

Just a heads-up.

==1927== Invalid free() / delete / delete[]
==1927==at 0x4A0556E: free (vg_replace_malloc.c:366)
==1927==by 0xDA77622: operator delete(void*) (in 
/home/nbecker/ekopath-4.0.10/lib/4.0.10/x8664/64/libcxxrt.so)
==1927==by 0xD7BB91A: std::allocator::deallocate(char*, unsigned 
long) 
(in /home/nbecker/ekopath-4.0.10/lib/4.0.10/x8664/64/libstl.so)
==1927==by 0xD7BB99B: std::string::_C_unlink(char*) (in 
/home/nbecker/ekopath-4.0.10/lib/4.0.10/x8664/64/libstl.so)
==1927==by 0xD7C4309: std::basic_string, 
std::allocator >::~basic_string() (in 
/home/nbecker/ekopath-4.0.10/lib/4.0.10/x8664/64/libstl.so)
==1927==by 0x3D64438940: __run_exit_handlers (in /lib64/libc-2.14.so)


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Linus on garbage collection

2011-05-06 Thread Neal Becker
http://gcc.gnu.org/ml/gcc/2002-08/msg00552.html

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] [patch] fpconst for python3

2010-10-19 Thread Neal Becker
Where should I send this patch?

diff -u fpconst-0.7.2/fpconst.py fpconst-0.7.2.new/fpconst.py
--- fpconst-0.7.2/fpconst.py2005-02-24 12:42:03.0 -0500
+++ fpconst-0.7.2.new/fpconst.py2010-10-19 20:55:07.407765664 -0400
@@ -40,18 +40,18 @@
 ident = "$Id: fpconst.py,v 1.16 2005/02/24 17:42:03 warnes Exp $"
 
 import struct, operator
+from functools import reduce
 
 # check endianess
-_big_endian = struct.pack('i',1)[0] != '\x01'
-
+_big_endian = struct.pack('i',1)[0] != 1
 # and define appropriate constants
 if(_big_endian): 
-NaN= struct.unpack('d', '\x7F\xF8\x00\x00\x00\x00\x00\x00')[0]
-PosInf = struct.unpack('d', '\x7F\xF0\x00\x00\x00\x00\x00\x00')[0]
+NaN= struct.unpack('d', b'\x7F\xF8\x00\x00\x00\x00\x00\x00')[0]
+PosInf = struct.unpack('d', b'\x7F\xF0\x00\x00\x00\x00\x00\x00')[0]
 NegInf = -PosInf
 else:
-NaN= struct.unpack('d', '\x00\x00\x00\x00\x00\x00\xf8\xff')[0]
-PosInf = struct.unpack('d', '\x00\x00\x00\x00\x00\x00\xf0\x7f')[0]
+NaN= struct.unpack('d', b'\x00\x00\x00\x00\x00\x00\xf8\xff')[0]
+PosInf = struct.unpack('d', b'\x00\x00\x00\x00\x00\x00\xf0\x7f')[0]
 NegInf = -PosInf
 
 def _double_as_bytes(dval):

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] multi-version parallel-installed modules

2010-08-18 Thread Neal Becker
Is there any proposal to accommodate having parallel-installed multiple 
versions of modules?

I have client code in multiple projects using version x.y of a C-compiled 
module A.

I want to test a new version x.z of module A, but all client software needs 
to be recompiled against the new version.  If I just install the module, all 
the other client software breaks.

I know I could test using virtualenv, but there would be a lot of modules to 
install into virtualenv to run the tests, so this would be cumbersome.  I'd 
prefer to have multiple version co-exist so I could update projects to the 
new version at my convenience.

How does this situation happen?  I have lots of c++ code using pyublas, 
which allows c++ code written to the boost::ublas interface to operate on 
numpy vectors/matrixes.  pyublas is built against boost libs. pyublas 
installs a module, whose purpose is to register conversions.

When I update boost libs, I have to rebuild pyublas and install the updated 
module.  Then rebuild my client software modules.  If pyublas is built 
against a different boost version than my client modules, the conversions 
will fail.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] argparse suggestion

2010-04-26 Thread Neal Becker
steven.beth...@gmail.com made a very nice module for me to enhance argparse 
called argparse_bool.py, which contains ConfigureAction.  This will allow a 
boolean value to be set very like the gnu configure style:

--foo
--with-foo
--without-foo
--no-foo
--foo=yes
--foo=no

I've been happily using it, and I think it would be of sufficient general 
interest to include it with the standard library.

import argparse
import re


def boolean(string):
string = string.lower()
if string in ['0', 'f', 'false', 'no', 'off']:
return False
elif string in ['1', 't', 'true', 'yes', 'on']:
return True
else:
raise ValueError()


class ConfigureAction(argparse.Action):

def __init__(self,
 option_strings,
 dest,
 default=None,
 required=False,
 help=None,
 metavar=None,
 positive_prefixes=['--', '--with-', '--enable-'],
 negative_prefixes=['--no-', '--without-', '--disable-']):
strings = []
self.positive_strings = set()
self.negative_strings = set()
for string in option_strings:
assert re.match(r'--[A-z]+', string)
suffix = string[2:]
for positive_prefix in positive_prefixes:
self.positive_strings.add(positive_prefix + suffix)
strings.append(positive_prefix + suffix)
for negative_prefix in negative_prefixes:
self.negative_strings.add(negative_prefix + suffix)
strings.append(negative_prefix + suffix)
super(ConfigureAction, self).__init__(
option_strings=strings,
dest=dest,
nargs='?',
const=None,
default=default,
type=boolean,
choices=None,
required=required,
help=help,
metavar=metavar)

def __call__(self, parser, namespace, value, option_string=None):
if value is None:
value = option_string in self.positive_strings
elif option_string in self.negative_strings:
value = not value
setattr(namespace, self.dest, value)

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--fun', action=ConfigureAction)
assert parser.parse_args([]).fun == None
assert parser.parse_args(['--fun']).fun == True
assert parser.parse_args(['--with-fun']).fun == True
assert parser.parse_args(['--enable-fun']).fun == True
assert parser.parse_args(['--no-fun']).fun == False
assert parser.parse_args(['--without-fun']).fun == False
assert parser.parse_args(['--disable-fun']).fun == False
print parser.parse_args()

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] argparse ambiguity handling

2010-04-20 Thread Neal Becker
Steven Bethard wrote:

> On Tue, Apr 20, 2010 at 11:55 AM, Neal Becker  wrote:
>> I've noticed argparse ambiguity handling has changed a bit over last few
>> revisions.
>>
>> I have cases where 1 valid input is a prefix of another:
>>
>> e.g.:
>> '--string'
>> '--string2'
>>
>> With the most recent 1.1, the behavior is:
>>
>> --string=hello
>>
>> is accepted, while:
>>
>> --strin=hello
>>
>> is marked as ambiguous.
>>
>> I'm OK with this, but just want to know if there is agreement that this
>> is the behavior we want.
> 
> I don't have a strong feeling about this. What was the behavior before?
> 
> Steve

At least 1 earlier version said that even exact match was ambiguous.

I have a preference to allow at least exact matches to succeed even in the 
case of ambiguity - mainly because I accidentally created this already once, 
and I feel it's better to at least work somewhat.  Not sure if there is any 
more elegant solution.  OTOH, I feel this is somewhat inelegant, as it 
appears to treat exact match as a special case.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] argparse ambiguity handling

2010-04-20 Thread Neal Becker
I've noticed argparse ambiguity handling has changed a bit over last few 
revisions.

I have cases where 1 valid input is a prefix of another:

e.g.:
'--string'
'--string2'

With the most recent 1.1, the behavior is:

--string=hello

is accepted, while:

--strin=hello

is marked as ambiguous.

I'm OK with this, but just want to know if there is agreement that this is 
the behavior we want. 

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] C++

2010-03-13 Thread Neal Becker
Neil Hodgson wrote:

> Antoine Pitrou:
> 
>> Is this concern still valid? We are in the 2010s now.
>> I'm not saying I want us to put some C++ in the core interpreter, but
>> the portability argument sounds a little old...
> 
>There are still viable platforms which only support subsets of C++.
> IIRC, Android does not support exceptions in C++.
> 
>Neil

Does re2 require exceptions?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] interesting article on regex performance

2010-03-11 Thread Neal Becker
http://swtch.com/~rsc/regexp/regexp1.html

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Neal Becker
On Monday 08 March 2010, David Stanek wrote:
> On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard
> 
>  wrote:
> > In argparse, unlike optparse, actions are actually defined by objects
> > with a particular API, and the string is just a shorthand for
> > referring to that. So:
> > 
> >  parser.add_argument ('--plot', action='store_true')
> > 
> > is equivalent to:
> > 
> >  parser.add_argument('--plot', argparse._StoreTrueAction)
> > 
> > Because the names are so long and you'd have to import them, I've left
> > them as private attributes of the module, but if there's really
> > demand, we could rename them to argparse.StoreTrueAction, etc.
> 
> Any reason not to do something like:
> 
>   from argparse import actions
>   ...
>   parser.add_argument('--plot', actions.store_true)
> 
> Basically a small namespace for the constants.
+1
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] argparse ugliness

2010-03-07 Thread Neal Becker
Brian Curtin wrote:

> On Fri, Mar 5, 2010 at 12:51, Neal Becker  wrote:
> 
>> I generally enjoy argparse, but one thing I find rather
>> ugly and unpythonic.
>>
>>parser.add_argument ('--plot', action='store_true')
>>
>> Specifying the argument 'action' as a string is IMO ugly.
>>
> 
> What else would you propose?
> FWIW, this is the same in optparse.

I would have thought use the object itself, instead of a string that spells 
the object's name.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] argparse ugliness

2010-03-05 Thread Neal Becker
I generally enjoy argparse, but one thing I find rather
ugly and unpythonic.

parser.add_argument ('--plot', action='store_true')

Specifying the argument 'action' as a string is IMO ugly.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Pronouncement on PEP 389: argparse?

2009-12-15 Thread Neal Becker
Ian Bicking wrote:

> On Mon, Dec 14, 2009 at 6:34 PM, sstein...@gmail.com
>  wrote:
>>> Although I am of the people who think working modules shouldn't be
>>> deprecated, I also don't think adding compatibility aliases is a good
>>> idea. They only make the APIs more bloated and maintenance more tedious.
>>> Let's keep the new APIs clean of any unnecessary baggage.
>>
>> Agreed.  If you want to make an "adapter" to do things like convert 'int'
>> to int, then call the new API then fine, but don't start crufting up a
>> new API to make it 'easier' to convert.
>>
>> All crufting it up does is make it _less_ clear how to use the new API by
>> bring along things that don't belong in it.
> 
> The "new" API is almost exactly like the old optparse API.  It's not
> like it's some shining jewel of perfection that would be tainted by
> somehow being similar to optparse when it's almost exactly like
> optparse already.
> 
> If it wasn't like optparse, then fine, whatever; but it *is* like
> optparse, so these differences feel unnecessary.  Converting 'int' to
> int internally in argparse is hardly difficult or unclear.
> 
> If argparse doesn't do this, then I think at least it should give good
> error messages for all cases where these optparse-isms remain.  For
> instance, now if you include %prog in your usage you get: ValueError:
> unsupported format character 'p' (0x70) at index 1 -- that's simply a
> bad error message.  Giving a proper error message takes about as much
> code as making %prog work.  I don't feel strongly that one is better
> than the other, but at least one of those should be done.
> 
> 

I agree (and I've used both for quite a long time).  argparse has an api 
that is almost compatible with optparse in many common cases, but just 
renamed some things.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Howto handle multilib conflict?

2009-10-09 Thread Neal Becker
Sorry, sent to wrong list!  Please ignore.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Howto handle multilib conflict?

2009-10-09 Thread Neal Becker
Just received:
https://bugzilla.redhat.com/show_bug.cgi?id=528237

yum install libotf-devel.i586 libotf-devel.x86_64

yields:

Transaction Check Error:
  file /usr/bin/libotf-config from install of libotf-devel-0.9.8-2.fc11.i586
conflicts with file from package libotf-devel-0.9.8-2.fc11.x86_64
  file /usr/share/doc/libotf-devel-0.9.8/example/Makefile from install of
libotf-devel-0.9.8-2.fc11.i586 conflicts with file from package
libotf-devel-0.9.8-2.fc11.x86_64

What is the recommended way to resolve this?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP 389: argparse - new command line parsing module

2009-09-28 Thread Neal Becker
If the plan is to migrate from optparse to argparse, this could be made a 
bit easier.  If it weren't for the fact that some names are different in 
argparse than optparse, I believe many optparse usages could port with no 
change.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] typo in 8.1.3.1. Format Specification Mini-Language?

2009-05-07 Thread Neal Becker
"format_spec ::=  [[fill]align][sign][#][0][width][.precision][type]"
"The precision is ignored for integer values."

In [36]: '%3x' % 10
Out[36]: '  a'

In [37]: '%.3x' % 10
Out[37]: '00a'

Apparently, precision is _not_ ignored? 


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] What's missing from easy_install

2009-04-07 Thread Neal Becker
1. easy_remove!

2. Various utilities to provide query package management.
   - easy_install --list (list files installed)


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Evaluated cmake as an autoconf replacement

2009-04-06 Thread Neal Becker
David Cournapeau wrote:

> On Mon, Mar 30, 2009 at 2:59 AM, Antoine Pitrou 
> wrote:
...

> 
> Waf is definitely faster than scons - something like one order of
> magnitude. I am yet very familiar with waf, but I like what I saw -
> the architecture is much nicer than scons (waf core amount of code is
> almost ten times smaller than scons core), but I would not call it a
> mature project yet.
> 

I haven't tried waf, but IIUC it _solves_ the bootstrap issue.


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] multiprocessing not compatible with fu nctional.partial

2009-02-12 Thread Neal Becker
Is it possible to get a better error message (regarding the pickle-ability)?


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] multiprocessing not compatible with functional.partial

2009-02-12 Thread Neal Becker
Hrvoje Niksic wrote:

> Calvin Spealman wrote:
>> I don't think it would be unreasonable to consider either 1) making
>> functools.partial picklable (I don't know how feasible this is)
> 
> It's not only feasible, but quite easy and, I think, useful.  A
> "partial" instance is a simple triplet of (function, args, kwds), and it
> can be pickled as such.  For example:
> 
>  >>> import copy_reg, functools
>  >>> def _reconstruct_partial(f, args, kwds):
> ... return functools.partial(f, *args, **(kwds or {}))
> ...
>  >>> def _reduce_partial(p):
> ... return _reconstruct_partial, (p.func, p.args, p.keywords)
> ...
>  >>> copy_reg.pickle(functools.partial, _reduce_partial)
> 
> Test:
> 
>  >>> import operator, cPickle as cp
>  >>> p = functools.partial(operator.add, 3)
>  >>> p(10)
> 13
>  >>> cp.dumps(p)
> 
'c__main__\n_reconstruct_partial\np1\n(coperator\nadd\np2\n(I3\ntp3\nNtRp4\n.'
>  >>> p2 = cp.loads(_)
>  >>> p2(10)
> 13
> 
> Iedally this should be implemented in the functools.partial object itself.
Confirmed:

from multiprocessing import Pool

def power (x, pwr=2):
return x**pwr

import functools
run_test = functools.partial (power, pwr=3)

import copy_reg, functools
def _reconstruct_partial(f, args, kwds):
return functools.partial(f, *args, **(kwds or {}))

def _reduce_partial(p):
return _reconstruct_partial, (p.func, p.args, p.keywords)

copy_reg.pickle(functools.partial, _reduce_partial)

if __name__ == "__main__":

pool = Pool()
cases = [3,4,5]
results = pool.map (run_test, cases)
print results

$python test_multi.py
[27, 64, 125]


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] multiprocessing not compatible with functional.partial

2009-02-12 Thread Neal Becker
If the argument to pool.map (f, args)
is
f = functional.partial (my_func, some_keyword_arg=whatever)

I get:

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/multiprocessing-2.6.1.1-py2.5-linux-
self.run()
  File "/usr/lib/python2.5/site-packages/multiprocessing-2.6.1.1-py2.5-linux-
self._target(*self._args, **self._kwargs)
  File "/usr/lib/python2.5/site-packages/multiprocessing-2.6.1.1-py2.5-linux-
task = get()
  File "/usr/lib/python2.5/site-packages/multiprocessing-2.6.1.1-py2.5-linux-
return recv()
TypeError: type 'partial' takes at least one argument

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] improvements for mmap

2009-01-08 Thread Neal Becker
I'd like to suggest some improvements from mmap

1) mmap assign to slice only accepts a string.  This is unfortunate, because 
AFAIK a string can only be created by copying data, and this is wasteful for 
large data transfers.  mmap should accept any object supporting buffer protocol 
as well as string.

2) buffer (mmap_obj) gives a read_only buffer.  There should be a way to make 
this read_write.

3) mmap_obj does not support weak ref.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Invitation to try out open source code review tool

2008-05-01 Thread Neal Becker
It would be really nice to see support for some other backends, such as Hg
or bzr (which are both written in python), in addition to svn.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] enhanced ioctl?

2008-04-28 Thread Neal Becker
Benjamin Peterson wrote:

> On Mon, Apr 28, 2008 at 7:02 AM, Neal Becker <[EMAIL PROTECTED]> wrote:
>> IIUC, current ioctl is not capable of handling arbitrary argument types.
>>  This code will allow any arg type (such as structures with pointers to
>>  embedded structures).
> 
> Please submit this patch to the tracker.
> 
> 

issue 2712

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] enhanced ioctl?

2008-04-28 Thread Neal Becker
IIUC, current ioctl is not capable of handling arbitrary argument types.
This code will allow any arg type (such as structures with pointers to
embedded structures).

The code for _IOC is taken from linux and might not be portable.

from ctypes import *

libc = CDLL ('/lib/libc.so.6')
#print libc.ioctl

def set_ioctl_argtype (arg_type):
libc.ioctl.argtypes = (c_int, c_int, arg_type)

_IOC_WRITE = 0x1

_IOC_NRBITS=8
_IOC_TYPEBITS=  8
_IOC_SIZEBITS=  14
_IOC_DIRBITS=   2

_IOC_NRSHIFT=   0
_IOC_TYPESHIFT= (_IOC_NRSHIFT+_IOC_NRBITS)
_IOC_SIZESHIFT= (_IOC_TYPESHIFT+_IOC_TYPEBITS)
_IOC_DIRSHIFT=  (_IOC_SIZESHIFT+_IOC_SIZEBITS)


def _IOC (dir, type, nr, size):
return (((dir)  << _IOC_DIRSHIFT) | \
 ((type) << _IOC_TYPESHIFT) | \
 ((nr)   << _IOC_NRSHIFT) | \
 ((size) << _IOC_SIZESHIFT))

def ioctl (fd, request, args):
return libc.ioctl (fd, request, args)
---
Example usage:

from ioctl import *

set_ioctl_argtype (POINTER (eos_dl_args_t))

EOS_IOC_MAGIC = 0xF4
request = _IOC(_IOC_WRITE, EOS_IOC_MAGIC, 0x00, 0) # ignore size

err = ioctl (eos_file.fileno(), request, args)


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] mmap documentation error (2.5.1)

2008-04-25 Thread Neal Becker
Sorry, my mistake.  Acutally, I was trying to debug this:
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/eos", O_RDWR);
  void* m = mmap (NULL, 100, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
  std::cout << m << '\n';
}

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] mmap documentation error (2.5.1)

2008-04-25 Thread Neal Becker
mmap(  fileno, length[, flags[, prot[, access]]])
(Unix version) Maps length bytes from the file specified by the file
descriptor fileno, and returns a mmap object. If length is 0, the maximum
length of the map will be the current size of the file when mmap() is
called. 
flags specifies the nature of the mapping. MAP_PRIVATE creates a private
copy-on-write mapping, so changes to the contents of the mmap object will
be private to this process, and MAP_SHARED creates a mapping that's shared
with all other processes mapping the same areas of the file. The default
value is MAP_SHARED. 

Apparantly, this is wrong - the default is not MAP_SHARED, as I just found
out the hard way.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] segfault in 2.5.1

2008-04-25 Thread Neal Becker
Attempt to write to a mmap which was opened mmap.PROT_READ causes python to
segfault.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] pydoc works with eggs? (python-2.5.1)

2008-04-23 Thread Neal Becker
Neal Becker wrote:

> pydoc blew up when I tried to view doc for pytools module, which is an
> egg:
> 
> pydoc -p 8082
> pydoc server ready at http://localhost:8082/
> 
> Exception happened during processing of request from ('127.0.0.1', 52915)
> Traceback (most recent call last):
>   File "/usr/lib64/python2.5/SocketServer.py", line 222, in handle_request
> self.process_request(request, client_address)
>   File "/usr/lib64/python2.5/SocketServer.py", line 241, in
>   process_request
> self.finish_request(request, client_address)
>   File "/usr/lib64/python2.5/SocketServer.py", line 254, in finish_request
> self.RequestHandlerClass(request, client_address, self)
>   File "/usr/lib64/python2.5/SocketServer.py", line 522, in __init__
> self.handle()
>   File "/usr/lib64/python2.5/BaseHTTPServer.py", line 316, in handle
> self.handle_one_request()
>   File "/usr/lib64/python2.5/BaseHTTPServer.py", line 310, in
>   handle_one_request
> method()
>   File "/usr/lib64/python2.5/pydoc.py", line 1924, in do_GET
> self.send_document(describe(obj), html.document(obj, path))
>   File "/usr/lib64/python2.5/pydoc.py", line 321, in document
> if inspect.ismodule(object): return self.docmodule(*args)
>   File "/usr/lib64/python2.5/pydoc.py", line 672, in docmodule
> contents.append(self.document(value, key, name, fdict, cdict))
>   File "/usr/lib64/python2.5/pydoc.py", line 322, in document
> if inspect.isclass(object): return self.docclass(*args)
>   File "/usr/lib64/python2.5/pydoc.py", line 807, in docclass
> lambda t: t[1] == 'method')
>   File "/usr/lib64/python2.5/pydoc.py", line 735, in spill
> funcs, classes, mdict, object))
>   File "/usr/lib64/python2.5/pydoc.py", line 323, in document
> if inspect.isroutine(object): return self.docroutine(*args)
>   File "/usr/lib64/python2.5/pydoc.py", line 891, in docroutine
> getdoc(object), self.preformat, funcs, classes, methods)
>   File "/usr/lib64/python2.5/pydoc.py", line 79, in getdoc
> result = inspect.getdoc(object) or inspect.getcomments(object)
>   File "/usr/lib64/python2.5/inspect.py", line 521, in getcomments
> lines, lnum = findsource(object)
>   File "/usr/lib64/python2.5/inspect.py", line 510, in findsource
> if pat.match(lines[lnum]): break
> IndexError: list index out of range
> 
> 
I see that installing the egg unzipped fixes this.  It looks to me that
pydoc doesn't work with zipped eggs.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] pydoc works with eggs? (python-2.5.1)

2008-04-22 Thread Neal Becker
pydoc blew up when I tried to view doc for pytools module, which is an egg:

pydoc -p 8082
pydoc server ready at http://localhost:8082/

Exception happened during processing of request from ('127.0.0.1', 52915)
Traceback (most recent call last):
  File "/usr/lib64/python2.5/SocketServer.py", line 222, in handle_request
self.process_request(request, client_address)
  File "/usr/lib64/python2.5/SocketServer.py", line 241, in process_request
self.finish_request(request, client_address)
  File "/usr/lib64/python2.5/SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib64/python2.5/SocketServer.py", line 522, in __init__
self.handle()
  File "/usr/lib64/python2.5/BaseHTTPServer.py", line 316, in handle
self.handle_one_request()
  File "/usr/lib64/python2.5/BaseHTTPServer.py", line 310, in handle_one_request
method()
  File "/usr/lib64/python2.5/pydoc.py", line 1924, in do_GET
self.send_document(describe(obj), html.document(obj, path))
  File "/usr/lib64/python2.5/pydoc.py", line 321, in document
if inspect.ismodule(object): return self.docmodule(*args)
  File "/usr/lib64/python2.5/pydoc.py", line 672, in docmodule
contents.append(self.document(value, key, name, fdict, cdict))
  File "/usr/lib64/python2.5/pydoc.py", line 322, in document
if inspect.isclass(object): return self.docclass(*args)
  File "/usr/lib64/python2.5/pydoc.py", line 807, in docclass
lambda t: t[1] == 'method')
  File "/usr/lib64/python2.5/pydoc.py", line 735, in spill
funcs, classes, mdict, object))
  File "/usr/lib64/python2.5/pydoc.py", line 323, in document
if inspect.isroutine(object): return self.docroutine(*args)
  File "/usr/lib64/python2.5/pydoc.py", line 891, in docroutine
getdoc(object), self.preformat, funcs, classes, methods)
  File "/usr/lib64/python2.5/pydoc.py", line 79, in getdoc
result = inspect.getdoc(object) or inspect.getcomments(object)
  File "/usr/lib64/python2.5/inspect.py", line 521, in getcomments
lines, lnum = findsource(object)
  File "/usr/lib64/python2.5/inspect.py", line 510, in findsource
if pat.match(lines[lnum]): break
IndexError: list index out of range



___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Distutils] How we can get rid of eggs for 2.6 and beyond

2008-03-24 Thread Neal Becker
On Saturday 22 March 2008, Martin v. Löwis wrote:
> > In the case of Fedora rpms, the usual install uses setup.py.
>
> Ok. Does it then also package all files that get installed into
> the RPM file? If it produces multiple RPMs from a single source
> package, how does it know which files go into what RPM?
>
> Regards,
> Martin

Offhand, I can't think of any examples that produce multiple RPMS, but in 
general, it doesn't _know_ anything.  What goes in what rpm is either
1) Automated using
  python setup.py install -O1 --root 
$RPM_BUILD_ROOT --prefix %{_prefix} --record=%{name}.files

or

2) Manually listing the files that go into a package.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Distutils] How we can get rid of eggs for 2.6 and beyond

2008-03-22 Thread Neal Becker
"Martin v. Löwis" wrote:

>>> Essentially, one would have to contribute patches to all the
>>> distributions (we care about, at least), and then nag the respective
>>> maintainers to include these patches.
>> 
>> Not true.  You just need to make sure that "setup.py install" creates
>> that database.  With the proposed format of the database this is just
>> a file in the correct location - exactly for this reason.  Next time
>> the distribution will build the package that database file will be in
>> place.
> 
> How so? Are you /sure/ the packaging process even *runs* setup.py?
> And if they do, why do you think they will pick up the database
> file?
> 

In the case of Fedora rpms, the usual install uses setup.py.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] How we can get rid of eggs for 2.6 and beyond

2008-03-22 Thread Neal Becker
Another use case, which I find in my world, is that there are always
packages that interest me (found at pypi), that my vendor hasn't packaged
as rpms yet.

With finite resources, this will always be true.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] download python-2.6 docs?

2008-02-27 Thread Neal Becker
http://docs.python.org/dev/download.html

I want a pdf.  The above link says:
"To download an archive containing all the documents for this version of
Python in one of various formats, follow one of links in this table. "

But there are no links.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] can't set attributes of built-in/extension type

2008-02-24 Thread Neal Becker
Guido van Rossum wrote:

> On Sat, Feb 23, 2008 at 4:55 PM, Neal Becker <[EMAIL PROTECTED]> wrote:
>> There is some discussion on this subject, archived here:
>>  http://permalink.gmane.org/gmane.comp.python.general/560661
>>
>>  I wonder if anyone could shed some light on this subject?
>>
>>  (Or, help me understand, what is the difference between a type that I
>>  create using python C api and a python class?)
> 
> This is prohibited intentionally to prevent accidental fatal changes
> to built-in types (fatal to parts of the code that you never though
> of). Also, it is done to prevent the changes to affect different
> interpreters residing in the address space, since built-in types
> (unlike user-defined classes) are shared between all such
> interpreters.
> 

Thanks for the info.

I'm still curious.  What if I wanted to create a 'real' python class using
python c-api?  How is that done?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] can't set attributes of built-in/extension type

2008-02-23 Thread Neal Becker
There is some discussion on this subject, archived here:
http://permalink.gmane.org/gmane.comp.python.general/560661

I wonder if anyone could shed some light on this subject?

(Or, help me understand, what is the difference between a type that I create
using python C api and a python class?)

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] trunk-math

2008-02-18 Thread Neal Becker
There is a post on boost (http://boost.org) about floating point utilities
that are being considered for review.  This seems to have a lot of overlap
with python needs.  I haven't reviewed this myself, but boost code is meant
to be quite portable.  Here is the link:

http://tinyurl.com/2gg4z3





___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] trunk-math

2008-02-16 Thread Neal Becker
This sounds great!  Thank you for your effort.  Let me know if I can help
(perhaps some testing?)

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New math functions

2008-02-15 Thread Neal Becker
Mark Dickinson wrote:

> On Tue, Feb 12, 2008 at 1:52 AM, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> 
>> Also, it would be useful to have a new method, float.is_integer().  This
>> would be better than the current approach where we make the
>> test:  if x == floor(x).
>>
> 
> How common is this test?  Given the inexact nature of floating-point
> arithmetic, checking whether a float is exactly an integer seems like
> something that one might actually want to discourage, just like comparing
> two floats for equality.
> 
> Also, what about having float.is_finite, as a quicker way to spell "not
> isinf(x) and not isnan(x)"
> 
> +1 on making these methods of float;  they're fundamental properties.
> 
> Mark

Yes, and I don't know if this was mentioned, but should add to complex also.

isfinite (complex_x):
return isfinite (x.real) and isfinite (x.imag)

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Any Emacs tips for core developers?

2008-02-04 Thread Neal Becker
[EMAIL PROTECTED] wrote:

[...]
> Finally, for you Ubuntu developers, I'm also using the the pre-release
> XFT GNU emacs, which is very pretty.  So far, despite stern and dire
> warnings, it has had no stability issues:
> 
> http://www.emacswiki.org/cgi-bin/wiki/XftGnuEmacs
> 
> Look for the "PPA" deb lines there, and you get a nicely prepackaged,
> policy-compliant version of emacs with no need to build anything
> yourself.
> 

FYI, I have built xft gnu emacs, as well as xft xemacs for fedora F7/8.  I
can make the srpms available if anyone wants them.

I use xemacs all day every day and never see any problem (except for some
slight font droppings).

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Any Emacs tips for core developers?

2008-02-03 Thread Neal Becker
Guido van Rossum wrote:

> I believe recent versions of Emacs and Vim have Python support
> standard. At least, it's been years since I last had to do anything to
> install it.
> 
> I've heard that there are two independent Python modes for Emacs --
> though they are suppose to be pretty similar. I don't even know how to
> tell them apart.
> 
> --Guido
> 
The more functional one is called "python-mode.el", and if it's loaded
you'll have 2 python-related menus, one called "Python" and one
called "IM-Python".  The other is just called 'python.el' and results in
one menu.  It has far fewer features.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] ctypes issue

2008-01-30 Thread Neal Becker
In python 2.5.1:

from ctypes import *
c = c_int(4)
print c == 4
print c.value == 4

False
True

This seem unreasonable to me, and a big invitation to error.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP: Lazy module imports and post import hook

2008-01-08 Thread Neal Becker
Christian Heimes wrote:

> I've attached the first public draft of my first PEP. A working patch
> against the py3k branch is available at http://bugs.python.org/issue1576
> 
> Christian

Note also that mercurial has demandimport
http://www.selenic.com/mercurial/wiki/

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Improved dyn mod load debug

2007-12-17 Thread Neal Becker
I had mistakenly installed a module (Qsci.so) into the wrong directory. 
Debugging this was harder than it needed to be (c-level debug of shared
lib).

Currently, the only debug info is from importdl.c:
m = PyDict_GetItemString(PyImport_GetModuleDict(), name);
if (m == NULL) {
PyErr_SetString(PyExc_SystemError,
"dynamic module not initialized properly");
return NULL;
}

I wonder if it would be difficult to print out the name expected, and the
name actually loaded?  In this case, it would have said:

expected: PyQt4/Qsci
loaded: Qsci


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] python sphinx install?

2007-09-05 Thread Neal Becker
Georg Brandl wrote:

> Neal Becker schrieb:
>> I'm interested in trying out new style (python 2.6) documentation.  I see
>> we're using docutils + sphinx?
>> 
>> I did: svn co http://svn.python.org/projects/doctools/trunk/
>> 
>> How can I install this to try it with python-2.5?
> 
> What do you want to try with Python 2.5?
> 
> If you want to build the Python 2.6/3.0 docs, it's easiest to check the
> Python sources out from http://svn.python.org/projects/python/trunk, go to
> the Doc directory and do "make html". This will checkout sphinx and all
> other needed libraries into Doc/tools and build the docs.
> 
> Georg
> 

I want to document my own python code.  I figured I might as well start
using the new documentation system - but I'm using python-2.5.  I intend to
use epydoc.  I thought maybe I could just add sphinx to my docutils, but
maybe not?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] python sphinx install?

2007-09-05 Thread Neal Becker
I'm interested in trying out new style (python 2.6) documentation.  I see
we're using docutils + sphinx?

I did: svn co http://svn.python.org/projects/doctools/trunk/

How can I install this to try it with python-2.5?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] add bool type to optparse

2007-07-31 Thread Neal Becker
A.M. Kuchling wrote:

> On Mon, Jul 30, 2007 at 09:50:38AM -0400, Neal Becker wrote:
>> Subject says it all.
> 
> Why is boolean support needed, given that optparse has store_true and
> store_false actions?  Example usage:
> 
> parser.add_option('--confirm', action='store_true', dest='confirm')
> 
> --amk

So you can do:
--option=false

Otherwise you have to do something like:
(action='store_false', default=True)

and use:
--no-option

which is OK sometimes, but why not allow a choice?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] add bool type to optparse

2007-07-30 Thread Neal Becker
Subject says it all.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] The docs, reloaded

2007-05-22 Thread Neal Becker
[EMAIL PROTECTED] wrote:

> 
> It would appear that while we slept Jens Mortensen was busy at work on his
> rst2{latex,latexmath,mathml}.py scripts:
> 
> http://docutils.sourceforge.net/sandbox/jensj/latex_math/
> 
> Note the date on the files.  It seems to work pretty well, and as others
> have pointed out, LaTeX notation is probably more familiar to people
> interested in math display than anything else.
> 

I know almost nothing about docutils internals.  How do I 'install' the above?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] The docs, reloaded

2007-05-21 Thread Neal Becker
[EMAIL PROTECTED] wrote:

> 
> >>> What would be my choices for add math to the documentation?
> 
> >> Where in the current documentation is there any math notation /at
> >> all/?
> 
> Georg> There is exactly one instance of LaTeX math in the whole docs,
> Georg> it's in the description of audioop, AFAIR, an contains a sum
> over Georg> square roots...
> 
> Georg> So, that's not really a concern of mine ;)
> 
> You must realize that people will use the core tools to create
> documentation
> for third party packages which aren't in the core.  If you replace LaTeX
> with something else I think you need to keep math in mind whether it's
> used in the core documentation or not.
> 
Perhaps my comment was misunderstood.  I have no objection to a new system,
and it does not have to be based on latex.  I just hope there will be some
escape mechanism that allows math.  It happens that for math markup, there
isn't really anything better (or more familiar) than latex.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] The docs, reloaded

2007-05-20 Thread Neal Becker
Georg Brandl wrote:

> Scott Dial schrieb:
>> Neal Becker wrote:
>>> Sounds very interesting.  I just have one concern/question.  I hope that
>>> while moving away from latex, we are not precluding the ability to write
>>> math as part of the documentation.  What would be my choices for add
>>> math
>>> to the documentation?  Hopefully using latex, since there really isn't
>>> AFAIK any other competitor for this.
>>> 
>> 
>> Where in the current documentation is there any math notation /at all/?
>> In all my reading of it, I have not run across anything that appeared
>> like it was being used. Besides that question, is the full power of
>> LaTeX math notation really necessary here? I somehow doubt anything more
>> than simple expressions of runtime performance and container behaviors
>> are appropriate for any documentation we have.
> 
> There is exactly one instance of LaTeX math in the whole docs, it's in the
> description of audioop, AFAIR, an contains a sum over square roots...
> 
> So, that's not really a concern of mine ;)
> 
> Georg
> 

There is an effort as part of numpy to come up with a new system using
docstrings.  It seems to me it would be unfortunate if these two efforts
were not coordinated.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] The docs, reloaded

2007-05-20 Thread Neal Becker
Sounds very interesting.  I just have one concern/question.  I hope that
while moving away from latex, we are not precluding the ability to write
math as part of the documentation.  What would be my choices for add math
to the documentation?  Hopefully using latex, since there really isn't
AFAIK any other competitor for this.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] python3k change to slicing

2007-04-19 Thread Neal Becker
There is one thing I'd like to see changed in a future python.  I always
found it surprising, that
>>> x = [1,2,3,4,5]
>>> x[1:10]
[2, 3, 4, 5]

is not an error.  This is perhaps the only case (but a fundamental one!)
where an error is silently ignored.

I really can't think of a good justification for it.  If I really meant
x[1:]
I would have said so.


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] bool conversion wart?

2007-02-22 Thread Neal Becker
Mike Klaas wrote:

> On 2/22/07, Neal Becker <[EMAIL PROTECTED]> wrote:
> 
>> Well consider this:
>> >>>str (4)
>> '4'
>> >>>int(str (4))
>> 4
>> >>>str (False)
>> 'False'
>>
>> >>>bool(str(False))
>> True
>>
>> Doesn't this seem a bit inconsisent?
> 
> Virtually no python objects accept a stringified version of themselves
> in their constructor:
> 
>>>> str({})
> '{}'
>>>> dict('{}')
> Traceback (most recent call last):
>   File "", line 1, in 
> ValueError: dictionary update sequence element #0 has length 1; 2 is
> required
>>>> str([])
> '[]'
>>>> list('[]')
> ['[', ']']
> 
> Python is not Perl.
> 
Except, all the numeric types do, including int, float, and complex.  But
not bool.  In fact, this is not just academic.  The fact that other numeric
types act this way leaves a reasonable expectation that bool will. 
Instead, bool fails in _the worst possible way_: it silently gives a _wrong
result_.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] bool conversion wart?

2007-02-22 Thread Neal Becker
Jonathan Lange wrote:

> On 2/23/07, Neal Becker <[EMAIL PROTECTED]> wrote:
>> >>> bool ('False')
>> True
>>
> 
> Non-empty strings are considered True, empty strings are considered
> False. This is not a wart, as the behaviour matches that of other
> sequences.
> 

Well consider this:
>>>str (4)
'4'
>>>int(str (4))
4
>>>str (False)
'False'

>>>bool(str(False))
True

Doesn't this seem a bit inconsisent?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] bool conversion wart?

2007-02-22 Thread Neal Becker
>>> int ('4')
4

>>> bool ('False')
True


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Having trouble committing

2007-01-25 Thread Neal Becker
I've heard it claimed that men often have this problem.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] syntax misfeature (exception)

2007-01-20 Thread Neal Becker
Georg Brandl wrote:

> Neal Becker schrieb:
>> I accidentally wrote:
>> 
>> try:
>>  ...
>> except a,b:
>> 
>> rather than:
>> 
>> try
>>  ...
>> except (a,b):
>> 
>> It appears that the 1st example syntax is silently accepted, but doesn't
>> seem to work.  Is this true?  If so, I'd say it's a wart.
> 
> Both have a meaning: The first assigns the exception object to b, while
> the second catches exception types a and b.
> 
> BTW, in Python 3.0, the first will be spelled "except a as b".
> 
> Please post questions about using the language to the comp.lang.python
> group.
> 
It's not a question, it's a critique.  I believe this is a misfeature since
it's so easy to make this mistake.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] syntax misfeature (exception)

2007-01-20 Thread Neal Becker
I accidentally wrote:

try:
 ...
except a,b:

rather than:

try
 ...
except (a,b):

It appears that the 1st example syntax is silently accepted, but doesn't
seem to work.  Is this true?  If so, I'd say it's a wart.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Pydoc Improvements / Rewrite

2007-01-05 Thread Neal Becker
No time to review this now, but I'd just like to say that the 1 thing I'd
like to see is support for decent mathematical markup.  I think at this
point that support for latex markup is the way to achieve this.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-29 Thread Neal Becker
I have watched numpy with interest for a long time.  My own interest is to
possibly use the c-api to wrap c++ algorithms to use from python.

One thing that has concerned me, and continues to concern me with this
proposal, is that it seems to suffer from a very fat interface.  I
certainly have not studied the options in any depth, but my gut feeling is
that the interface is too fat and too complex.  I wonder if it's possible
to avoid this.  I wonder if this is an example of all the methods sinking
to the base class.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Proprietary code in python?

2006-10-10 Thread Neal Becker
http://www.google.com/codesearch?q=+doc:DxlBcBw4TXo+proprietary+confidential+show:DxlBcBw4TXo:BwgQSUaGDCc:1s0hP8rbIGE&sa=N&cd=1&ct=ri&cs_p=http://www.python.org/download/releases/binaries-1.3/python-IRIX-5.3-full.tar.gz&cs_f=lib/python/irix5/AWARE.py#a0

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] os.unlink() closes file?

2006-09-29 Thread Neal Becker
Ronald Oussoren wrote:

>  
> On Friday, September 29, 2006, at 02:22PM, Neal Becker
> <[EMAIL PROTECTED]> wrote:
> 
>>It seems (I haven't looked at source) that os.unlink() will close the
>>file?
>>
>>If so, please make this optional.  It breaks the unix idiom for making a
>>temporary file.
>>
>>(Yes, I know there is a tempfile module, but I need some behavior it
>>doesn't implement so I want to do it myself).
> 
> On what platform? Do you have a script that demonstrates your problem? If
> yes, please file a bug in the bugtracker at
> http://www.sf.net/projects/python.
> 
> AFAIK os.unlink doesn't close files, and I cannot reproduce this problem
> (python2.3 on Solaris 9).
> 
Sorry, my mistake.


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] os.unlink() closes file?

2006-09-29 Thread Neal Becker
It seems (I haven't looked at source) that os.unlink() will close the file?

If so, please make this optional.  It breaks the unix idiom for making a
temporary file.

(Yes, I know there is a tempfile module, but I need some behavior it doesn't
implement so I want to do it myself).


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-11 Thread Neal Becker
Guido van Rossum wrote:

> On 8/10/06, James Y Knight <[EMAIL PROTECTED]> wrote:
>> It makes just as much sense as assigning to an array access, and the
>> semantics would be pretty similar.
> 
> No. Array references (x[i]) and attribute references (x.a) represent
> "locations". Function calls represent values. This is no different
> than the distinction between lvalues and rvalues in C.
> 

Except this syntax is valid in c++ where X() is a constructor call:

X(whatever) += 2; is (or can be) valid c++

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-09 Thread Neal Becker
Terry Reedy wrote:

> 
> "Neal Becker" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> class X (object):
>>pass
>>
>> X() += 2
>>
>>> SyntaxError: can't assign to function call
>>
>> Suppose I actually had defined __iadd__ for class X.  Python says this
>> syntax is invalid.  I wish is wasn't.
> 
> If you translate to x() = x() +2, with x called just once, it does not
> make
> sense.  You can bind to names and slots in compound objects, but not to
> objects.
> 
>> Here's where I might use it.  Suppose I have a container class.  Suppose
>> I
>> could make a slice of this container, like so:
>>
>> c = Container()
>> s = Slice (c, 0, 10)
>>
>> where "Slice" is a class.  Then:
>>
>> s += 2
>>
>> Would perform iadd on the slice of the container.  A convenient syntax
>> would
>> be:
>>
>> Slice (c, 0, 10) += 2
> 
> If this were made to work, the unbound object you are making an
> 'assignment' to, purely for side effect, would disappear.  So if you don't
> want a separate object to be named and kept around, give your container a
> sliceadd method:
> c.sliceadd((0,10), 2)
> 
>>
>> Does anyone else think this would be a good addition to Python?
> 
> I don't.  Augmented assigment is confusing enough to many.
> 

I guess I confused things with the augmented assignment.  It's not a
question specific to augmented assignment.  There are 2 questions:

1) Should assignment to a temporary object be allowed?
2) Should the syntax for creation of a temporary object be a constructor
call?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] SyntaxError: can't assign to function call

2006-08-09 Thread Neal Becker
class X (object):
pass

X() += 2

> SyntaxError: can't assign to function call

Suppose I actually had defined __iadd__ for class X.  Python says this
syntax is invalid.  I wish is wasn't.

Here's where I might use it.  Suppose I have a container class.  Suppose I
could make a slice of this container, like so:

c = Container()
s = Slice (c, 0, 10)

where "Slice" is a class.  Then:

s += 2

Would perform iadd on the slice of the container.  A convenient syntax would
be:

Slice (c, 0, 10) += 2

Does anyone else think this would be a good addition to Python?


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Document performance requirements?

2006-07-25 Thread Neal Becker
On Friday 21 July 2006 7:49 am, Nick Coghlan wrote:
> Neal Becker wrote:
> > For a recent project I needed to select a container.  There are plenty of
> > python data structures to choose from.  It seems that information on
> > performance is missing (or not easy to find).
> >
> > I think Python should include performance in the documentation of common
> > data structures to help users select the appropriate types.  Something in
> > the style of c++ STL.
>
> Do you mean absolute performance, or do you mean algorithmic order
> guarantees? I thought the latter were already documented. . .
>

The latter.  Where are they documented?
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Document performance requirements?

2006-07-21 Thread Neal Becker
Nick Coghlan wrote:

> Neal Becker wrote:
>> For a recent project I needed to select a container.  There are plenty of
>> python data structures to choose from.  It seems that information on
>> performance is missing (or not easy to find).
>> 
>> I think Python should include performance in the documentation of common
>> data structures to help users select the appropriate types.  Something in
>> the style of c++ STL.
> 
> Do you mean absolute performance, or do you mean algorithmic order
> guarantees? I thought the latter were already documented. . .
> 

The latter.  Where is it documented?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Document performance requirements?

2006-07-21 Thread Neal Becker
For a recent project I needed to select a container.  There are plenty of
python data structures to choose from.  It seems that information on
performance is missing (or not easy to find).

I think Python should include performance in the documentation of common
data structures to help users select the appropriate types.  Something in
the style of c++ STL.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] High Level Virtual Machine

2006-06-14 Thread Neal Becker
I thought this announcement was interesting:

http://hlvm.org/

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] suggest: nowait option in subprocess.communicate

2006-04-05 Thread Neal Becker
I'd like to start several processes, each a pipe reading from my python main
process.  It looks like I want to write all my data to each process, then
use communicate(), but I don't want to wait for each process yet, since
then they would block each other.  Why not add a nowait option to
communicate?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Problem with module loading on multi-arch?

2006-03-17 Thread Neal Becker
"Martin v. Löwis" wrote:

> Neal Becker wrote:
>> Sorry, maybe I used confusing terminology.
>> 
>> A reference is here: http://fedoraproject.org/wiki/Packaging/Python
>> This is the current setup.  For example, this is a standard macro used by
>> Redhat in RPM SPEC files for python:
>> 
>> %define python_sitearch %(%{__python} -c "from distutils.sysconfig import
>> get_python_lib; print get_python_lib(1)")}
>> 
>> %define python_sitelib %(%{__python} -c "from distutils.sysconfig import
>> get_python_lib; print get_python_lib()")}
>> 
>> Clearly this practice is widespread.  It would seem that module search
>> needs some modification to fully support it.
> 
> Ah. That isn't supported at all, at the moment. Redhat should not be
> using it. Instead, there shouldn't be a difference between sitearch and
> sitelib.
> 

x86_64 is multiarch.  That means, we allow both i386 and x86_64 binaries to
coexits.  Is the proposal that python should not support this?  That would
be unfortunate.

I suspect is would not be that difficult to correctly support multiarch
platforms.  As it is, this usually works - but the example I gave above
shows where it seems to break.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Problem with module loading on multi-arch?

2006-03-17 Thread Neal Becker
"Martin v. Löwis" wrote:

> Neal Becker wrote:
>> 1. Does it make sense to have both
>> 
>> /app/subpackage
>>  and
>> /app/subpackage
>> ?
>> 
>> My answer: definitely yes.  We already agree that we should have both
>> site-dep for binary code and site-indep for python code, so there is no
>> way to avoid this.
> 
> I'm not sure I understand what you are talking about. What is site-dep
> and site-indep? Where do we have that for binary code and for python
> code? I know what prefix and exec_prefix are.
> 
>> 2. What should the module search do?
>> 
>> I don't know the details of the current algorithm, but clearly it's going
>> to have to deal correctly with the above.
> 
> It's very simple. Importing traverses sys.path.
> 
>> One possibility (and maybe this is how it already works?) is that the
>> module search doesn't know anything about site-dep/site-indep, it simply
>> has a list of paths to search.
> 
> Well, I don't know about site-dep/site-indep, so I wouldn't be surprised
> if module search didn't, either.
> 

Sorry, maybe I used confusing terminology.

A reference is here: http://fedoraproject.org/wiki/Packaging/Python
This is the current setup.  For example, this is a standard macro used by
Redhat in RPM SPEC files for python:

%define python_sitearch %(%{__python} -c "from distutils.sysconfig import
get_python_lib; print get_python_lib(1)")}

%define python_sitelib %(%{__python} -c "from distutils.sysconfig import
get_python_lib; print get_python_lib()")}

Clearly this practice is widespread.  It would seem that module search needs
some modification to fully support it.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Problem with module loading on multi-arch?

2006-03-16 Thread Neal Becker
"Martin v. Löwis" wrote:

> Neal Becker wrote:
>> I'm guessing that what's happening is that since there is an
>> /twisted, we never find the module /twisted/web. 
>> If my analysis (guess) is correct, I think we have a problem with the
>> module search.
> 
> That is quite possible. I keep applying patches from people who claim to
> know how things on AMD64 linux work, much without questioning them. It
> is quite possible that one of these patches broke something. I'm happy
> to revert or augment them if needed.
> 
> Somebody should define how things ought to work, implement a patch that
> both includes a documentation and an implementation of these decisions,
> and then keep an eye on patches that might break this design.
> 

OK, let's talk about it.

1. Does it make sense to have both 

/app/subpackage
 and
/app/subpackage
?

My answer: definitely yes.  We already agree that we should have both
site-dep for binary code and site-indep for python code, so there is no way
to avoid this.

2. What should the module search do?

I don't know the details of the current algorithm, but clearly it's going to
have to deal correctly with the above.

One possibility (and maybe this is how it already works?) is that the module
search doesn't know anything about site-dep/site-indep, it simply has a
list of paths to search.

If I did want to try to fix this myself, where would I find the code for it? 

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Problem with module loading on multi-arch?

2006-03-16 Thread Neal Becker
I just installed TwistedSumo-2006-02-12 on x86_64, and noticed a problem. 
It installs arch-dep stuff into 
/usr/lib64/python2.4/site-packages/twisted,
and arch-indep into
/usr/lib/python2.4/site-packages/twisted

as it should.  But:
from twisted.web import html
exceptions.ImportError: No module named web

I'm guessing that what's happening is that since there is an
/twisted, we never find the module /twisted/web.  If
my analysis (guess) is correct, I think we have a problem with the module
search.


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Help with inotify

2005-10-27 Thread Neal Becker
Bob Ippolito wrote:

> 
> On Oct 27, 2005, at 4:58 PM, Neal Becker wrote:
> 
>> Bob Ippolito wrote:
>>
>>
>>>
>>> On Oct 27, 2005, at 4:32 PM, Neal Becker wrote:
>>>
>>>
>>>> "Martin v. Löwis" wrote:
>>>>
>>>>
>>>>> I see. Python is making up the EISDIR, looking at the stat result.
>>>>> In Objects/fileobject.c:dircheck generates the EISDIR error, which
>>>>> apparently comes from posix_fdopen, PyFile_FromFile,
>>>>> fill_file_fields.
>>>>>
>>>>> Python simply does not support file objects which stat(2) as
>>>>> directories.
>>>>>
>>>>>
>>>>>
>>>>
>>>> OK, does python have a C API that would allow me to create a python
>>>> file
>>>> object from my C (C++) code?  Then instead of using python's fdopen
>>>> I could
>>>> just do it myself.
>>>>
>>>
>>> Why do you need a file object for something that is not a file
>>> anyway?  select.select doesn't require file objects for example, just
>>> objects that have a fileno() method.
>>>
>>>
>> Yes, that's a good point - the reason is I didn't want to restrict the
>> interface to only work with select.  Maybe I should rethink the
>> interface.
> 
> Well what would the interface do if you had a file object?  Are you
> supposed to be able to read/write/seek/tell/etc.?  I don't understand
> why you're trying to do what you're doing.  select.select was just an
> example, select.poll's register/unregister takes any object with a
> fileno also.
>

Yes, you are supposed to be able to read and get information.  However, I
have implemented fileno for it, so you can use select.select on it if you
just want to wait for something to happen - which is probably all that's
really needed.  I also implemented select as a method of my inotify object,
in case you prefer that.

Here's an excerpt from documentation/filesystems/inotify.txt:
-
Events are provided in the form of an inotify_event structure that is
read(2)
from a given inotify instance.  The filename is of dynamic length and
follows
the struct. It is of size len.  The filename is padded with null bytes to
ensure proper alignment.  This padding is reflected in len.

You can slurp multiple events by passing a large buffer, for example

size_t len = read (fd, buf, BUF_LEN);

Where "buf" is a pointer to an array of "inotify_event" structures at least
BUF_LEN bytes in size.  The above example will return as many events as are
available and fit in BUF_LEN.

Each inotify instance fd is also select()- and poll()-able.
-

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Help with inotify

2005-10-27 Thread Neal Becker
"Martin v. Löwis" wrote:


> I see. Python is making up the EISDIR, looking at the stat result.
> In Objects/fileobject.c:dircheck generates the EISDIR error, which
> apparently comes from posix_fdopen, PyFile_FromFile,
> fill_file_fields.
> 
> Python simply does not support file objects which stat(2) as directories.
> 

OK, does python have a C API that would allow me to create a python file
object from my C (C++) code?  Then instead of using python's fdopen I could
just do it myself.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Help with inotify

2005-10-27 Thread Neal Becker
Bob Ippolito wrote:

> 
> On Oct 27, 2005, at 4:32 PM, Neal Becker wrote:
> 
>> "Martin v. Löwis" wrote:
>>
>>> I see. Python is making up the EISDIR, looking at the stat result.
>>> In Objects/fileobject.c:dircheck generates the EISDIR error, which
>>> apparently comes from posix_fdopen, PyFile_FromFile,
>>> fill_file_fields.
>>>
>>> Python simply does not support file objects which stat(2) as
>>> directories.
>>>
>>>
>>
>> OK, does python have a C API that would allow me to create a python
>> file
>> object from my C (C++) code?  Then instead of using python's fdopen
>> I could
>> just do it myself.
> 
> Why do you need a file object for something that is not a file
> anyway?  select.select doesn't require file objects for example, just
> objects that have a fileno() method.
> 
Yes, that's a good point - the reason is I didn't want to restrict the
interface to only work with select.  Maybe I should rethink the interface.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Help with inotify

2005-10-27 Thread Neal Becker
"Martin v. Löwis" wrote:

> Neal Becker wrote:
>> Yes, tried that- learned nothing.
> 
> Please go back further in the trace file. There must be a return
> value of -1 (EISDIR) somewhere in the file, try to locate that.
> 
>> Here's strace.  The write of '4' is where my code writes the value of
>> fileno() to stdout, which is '4', which is correct - notice that
>> open("test-inotify.py") returned '3':
> 
> The fragment you quote only refers to the part where it tries to
> format the traceback. The value '4' is never written, instead,
> it writes 4 spaces (the second argument is the bytes, the third
> is the number of bytes).
> 
This 1st line is the syscall for inotify:

SYS_253(0, 0x7f88f0f0, 0x2dda3f00, 0x2ab4611b, 0x7) = 4
close(3)= 0
futex(0x502530, FUTEX_WAKE, 1)  = 0
futex(0x502530, FUTEX_WAKE, 1)  = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x2dc12000
write(1, "4\n", 2)  = 2
fcntl(4, F_GETFL)   = 0 (flags O_RDONLY)
fstat(4, {st_mode=S_IFDIR|0600, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x2dc13000
lseek(4, 0, SEEK_CUR)   = -1 ESPIPE (Illegal seek)
fstat(4, {st_mode=S_IFDIR|0600, st_size=0, ...}) = 0
close(4)= 0
munmap(0x2dc13000, 4096)= 0
write(2, "Traceback (most recent call last"..., 35) = 35
open("test-inotify.py", O_RDONLY)   = 3
write(2, "  File \"test-inotify.py\", line 6"..., 39) = 39
...

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Help with inotify

2005-10-27 Thread Neal Becker
"Martin v. Löwis" wrote:

> Neal Becker wrote:
>> Any ideas?  I'd rather not have to trace through python if I could avoid
>> it (I don't even have source installed here).
> 
> Use strace, then. Find out what precise system call gives you this
> error. If this is not enough clue, post the relevant fragment of the
> trace output. Usage would be
> 
> strace -o muell python test_notify.py
> (look into the file muell afterwards)
> 

Yes, tried that- learned nothing.

I suspect what's happening is that python's fdopen is using some stat call
to determine whether the file descriptor refers to a directory, and is
getting an answer that the inotify fd does.  Don't know what to do about
it.  Can I build a python file object in "C" from the fd?

Here's strace.  The write of '4' is where my code writes the value of
fileno() to stdout, which is '4', which is correct - notice that
open("test-inotify.py") returned '3':
...
open("test-inotify.py", O_RDONLY)   = 3
write(2, "  File \"test-inotify.py\", line 6"..., 39) = 39
fstat(3, {st_mode=S_IFREG|0664, st_size=87, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x2dc13000
read(3, "from inotify import *\nimport os\n"..., 4096) = 87
write(2, "", 4) = 4
write(2, "os.fdopen (i.fileno())\n", 23) = 23
close(3)= 0
munmap(0x2dc13000, 4096)= 0
write(2, "IOError", 7)  = 7
write(2, ": ", 2)   = 2
write(2, "[Errno 21] Is a directory", 25) = 25


___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Help with inotify

2005-10-27 Thread Neal Becker
I'm trying to make a module to support inotify (linux).  I put together a
module using boost::python.  Problem is, inotify uses a file descriptor. 
If I call python os.fdopen on it, I get an error:
Python 2.4.1 (#1, May 16 2005, 15:15:14)
[GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from inotify import *
>>> import os
>>> i=inotify()
>>> i.fileno()
4
>>> os.fdopen (i.fileno())
Traceback (most recent call last):
  File "", line 1, in ?
IOError: [Errno 21] Is a directory

Any ideas?  I'd rather not have to trace through python if I could avoid it
(I don't even have source installed here).

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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 allow the programmer to specify that a variable is constant, or that
a function is pure (having no side effects).

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] 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 defined as close to the point of usage as possible.

I don't know to what extent these kind of optimizations are available to
cpython.  For example, are constant calculations removed from loops?  How
about functions?  Is there a significant cost to putting a function def
inside a loop rather than outside?

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Fwd: Distributed RCS

2005-08-14 Thread Neal Becker
I encourage everyone to look at mercurial.  It is also written in Python.  I
am using it daily.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] complex I/O problem

2005-02-01 Thread Neal Becker
If I call "print" on a complex value, I may get this:
'(2+2j)'

But this is not acceptable as input:
complex ('(2+2j)')
Traceback (most recent call last):
  File "", line 1, in ?
ValueError: complex() arg is a malformed string

Whatever format is used for output should be accepted as input!

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com