Python Ireland Pub Meetup - Wed, 10th Aug, 7pm - Bull Castle

2011-08-05 Thread Vicky Twomey-Lee
Hi All,

When:  Wed, 10th Aug, 7pm

No talks this month, pub meetup at The Bull  Castle.

Event is free and all are welcome.

Details:
http://www.python.ie/meetup/2011/python-ireland-pub-meetup-august-2011/

Cheers,

/// Vicky

~
~~ http://irishbornchinese.com ~~
~~   http://www.python.ie ~~
~
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: JSON Strict Mode

2011-08-05 Thread Chris Rebert
On Thu, Aug 4, 2011 at 8:25 PM, John Riselvato jdriselv...@gmail.com wrote:
 I am working on a license verification script. I am rather new to the
 concept and to JSON files in general.

Based on your questions, reading a programming tutorial might be a
good idea. Here's one that uses Python and that I've heard praise for:
http://openbookproject.net/thinkcs/python/english3e/
The official tutorial is also worth reading:
http://docs.python.org/dev/tutorial/

Once you understand Python's basic datatypes, JSON is a breeze; they
are extremely similar.

 This is what my pseudocode looks like:

 licenses = meta['license']
 for x in licenses:
 if licenses[x]['terms'] is not valid opensource license

I would probably instead write that as:

for license_name, license in licenses.items():
if not is_open_source(license['terms']):
# rest same as before

 if in strict mode
 raise nonfree exception

 How would i go about checking if its in strict mode

You would have a boolean* variable somewhere indicating whether or not
the program is in strict mode. Its value would presumably be set based
on user input, or a configuration file, or whatever is applicable to
your program; e.g.:
strict = True
strict = False

config = parse_configuration_file()
if config.strict:
# whatever

 and what does raise nonfree exception mean?

I regret that the Wikipedia article on the topic of exceptions isn't
too approachable. So, I'll instead refer you to the relevant section
of the Python tutorial:
http://docs.python.org/dev/tutorial/errors.html#errors-and-exceptions

(Disclaimer: The following is oversimplified and somewhat Python-specific.)
In a nutshell, an exception is type of object** used to indicate that
a program has encountered an error; it contains details about the
error and its cause.
When a program encounters an error, it stores information about the
error into a new exception object and then raises (using, in Python,
the raise statement) this object so that the program can properly
react to the error. By virtue of the raise, normal execution of the
program stops, and control is transferred to another part of the
program which previously registered itself as being capable of
handling the kind of error in question. The code in that part of the
program then examines the exception object that was raised and takes
appropriate action to deal with the error. If no part of the program
registered itself as capable of handling the kind of error in
question, a detailed error message is output and the program exits.

In your specific example, the non-pseudo-code would look something like:

# a declaration somewhere:
class NonFreeLicenseError(ValueError):
License is not free according to the Open Source Definition.

# ... back in the part of your code corresponding to your pseudocode:
if strict:
raise NonFreeLicenseError(The '%s' license is nonfree and thus
impermissible. % x)

As written, I have NonFreeLicenseError as a kind of ValueError. This
may or may not be appropriate depending on your program; a list of
built-in types of exceptions can be found at
http://docs.python.org/dev/library/exceptions.html#bltin-exceptions

Cheers,
Chris
--
http://rebertia.com

* http://en.wikipedia.org/wiki/Boolean_data_type
** http://en.wikipedia.org/wiki/Object_%28computer_science%29
-- 
http://mail.python.org/mailman/listinfo/python-list


Observations on the three pillars of Python execution

2011-08-05 Thread Eric Snow
In Python, three types of objects have special syntax and mechanics
for their instantiation, during which a code object is generated:
modules, classes, and functions.  Each has its own role to play and
the differences between them mostly reflect that.  Here are some
observations (based on default behavior):


Object creation relative to code object creation:
(M) before
(C) after
(F) after

Object creation relative to code object execution:
(M) before
(C) after
(F) before

Object available during code object execution:
(M) no
(C) no
(F) no

Code object destiny:
(M) executed once at definition time, then discarded
(C) executed once at definition time, then discarded
(F) not executed at definition time, stored on the function
 object for execution with each __call__() invocation.

Execution locals is available during code object execution:
(M) as globals()
(C) as locals()
(F) as locals()

Object namespace is execution locals of code object:
(M) yes
(C) more or less
(F) completely distinct

Unique syntax:
(M) 'import' statement
(C) 'class' statement
(F) 'def' statement

Mechanism triggered by respective syntax:
(M) import machinery (import.c/importlib)
(C) internal, but partially exposed via metaclasses and the
 __build_class__ builtin
(F) internal, nothing exposed

Override capability:
(M) complete capability through builtin __import__ and PEP
  302 import hooks
(C) partial capability, before code object execution through
 metaclass __prepare__() and after through __build_class__()
 and metaclass __call__(), __new__(), and __init__()
(F) no capability

Post instantiation modification capability:
(M) yes
(C) yes
(F) mostly (some attributes are read-only)

Mechanism to instantiate outside of respective unique syntax:
(M) imp.new_module(), types.ModuleType(), type(module)()
(C) type()
(F) types.FunctionType(), type(f)()

Type extensibility:
(M) Not relative to 'import' syntax (by default)
(C) Complete
(F) No

Name available during definition execution:
(M) as __name__
(C) only through metaclass __prepare__()
(F) through inspect.currentframe().f_code.co_name

Name available on object as __name__:
(M) yes
(C) yes
(F) yes


Corrections, additions, and comment are welcome.

-eric
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Observations on the three pillars of Python execution

2011-08-05 Thread Thomas Jollans
On 05/08/11 09:20, Eric Snow wrote:
 Object available during code object execution:
 (M) no
 (C) no
 (F) no
(F) yes.

cf. recursion.

-- 
http://mail.python.org/mailman/listinfo/python-list


Python - C api related - Concurrent Script Execution

2011-08-05 Thread Silver Interactive
Dear All,

I have developed a C++ server application which handles requests coming in
from my web server. The server application is capable of handling multiple
users at a time. Each user has a session object. Each user also has some
variables associated with it. These variables are maintained in the c++ side
as python dictionaries as they will be processed by executing scripts by the
function PyRun_SimpleString() with each request. What i realised half-way
through the implementation is that I will probably not be able to execute
python scripts in parallel from the c++ end. Is this thinking correct? One
user makes a request and the c++ code calls the python script which has to
fetch information from a remote server (takes some seconds), but I cannot
have other users script execution wait till this first script returns. Am i
missing a point here. Please let me know if there is a way out of this as I
am stuck big time.

Do let me know if you require any more information.

Help will be appreciated. Thanks!!!

Regards
Diana
-- 
http://mail.python.org/mailman/listinfo/python-list


__set__ method is not called for class attribute access

2011-08-05 Thread Ryan
In the context of descriptors, the __set__ method is not called for
class attribute access. __set__ is only
called to set the attribute on an instance instance of the owner class
to a new value, value. WHY? Is there some other mechanism for
accomplishing this outcome. This subtle difference from __get__cost me
some time to track down. Might think about pointing that out the
documentation.


class RevealAccess(object):
A data descriptor that sets and returns values
   normally and prints a message logging their access.


def __init__(self, initval=None, name='var'):
self.val = initval
self.name = name

def __get__(self, obj, objtype):
print 'Retrieving', self.name
return self.val

def __set__(self, obj, val):
print 'Updating' , self.name
self.val = val

class MyClass(object):
x = RevealAccess(10, 'var x')
y = 5

print MyClass.x
MyClass.x = 20
print MyClass.x
MyClass.x = 30
print MyClass.x

Retrieving var x
10
20
30

I am at a lost on how to intercept class attribute sets. Can anyone
help :-/

Ryan
-- 
http://mail.python.org/mailman/listinfo/python-list


Recursive functions (was Re: Observations on the three pillars of Python execution)

2011-08-05 Thread Chris Angelico
On Fri, Aug 5, 2011 at 9:22 AM, Thomas Jollans t...@jollybox.de wrote:
 On 05/08/11 09:20, Eric Snow wrote:
 Object available during code object execution:
 (M) no
 (C) no
 (F) no
 (F) yes.

 cf. recursion.

Is it? As I understand it, a Python function is not able to reference
itself but must reference its own name. This means that assigning
that function to something else stops it being recursive:

#
 def foo(x):
print(x)
if x3: foo(x-1)

 foo(5)
5
4
3
 bar=foo
 bar(5)
5
4
3
 def foo(x):
print(Foo,x)
if x3: foo(x-1)

 foo(5)
Foo 5
Foo 4
Foo 3
 bar(5)
5
Foo 4
Foo 3
#

bar() is not a recursive function, even though foo() was and is. I've
just played around with a decorator, though; this appears to work:

 def recursive(f):
l=list(f.__defaults__)
l[-1]=f
f.__defaults__=tuple(l)
return f
 @recursive
def quux(x,quux=None):
print(Quux,x)
if x3: quux(x-1)
 foo=quux
 def quux(x):
print(Stopping.)
 quux(5)
Stopping.
 foo(5)
Quux 5
Quux 4
Quux 3

Effectively, the decorator binds the function's own self to its last
default parameter, thus holding a cyclic reference (unlikely to be an
issue - people won't be creating and destroying functions frequently,
so GC issues shouldn't arise). The last parameter doesn't have to have
the name of the function; this works with lambdas:

 recursive(lambda x,_=None: print(Lambda,x) or (x3 and _(x-1) or None))(5)
Lambda 5
Lambda 4
Lambda 3

Yes, this is a pretty stupid example. But is this sort of decorator
useful? It's not like people regularly want recursive lambdas.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __set__ method is not called for class attribute access

2011-08-05 Thread Peter Otten
Ryan wrote:

 In the context of descriptors, the __set__ method is not called for
 class attribute access. __set__ is only
 called to set the attribute on an instance instance of the owner class
 to a new value, value. WHY? Is there some other mechanism for
 accomplishing this outcome. This subtle difference from __get__cost me
 some time to track down. Might think about pointing that out the
 documentation.
 
 
 class RevealAccess(object):
 A data descriptor that sets and returns values
normally and prints a message logging their access.
 
 
 def __init__(self, initval=None, name='var'):
 self.val = initval
 self.name = name
 
 def __get__(self, obj, objtype):
 print 'Retrieving', self.name
 return self.val
 
 def __set__(self, obj, val):
 print 'Updating' , self.name
 self.val = val
 
 class MyClass(object):
 x = RevealAccess(10, 'var x')
 y = 5
 
 print MyClass.x
 MyClass.x = 20
 print MyClass.x
 MyClass.x = 30
 print MyClass.x
 
 Retrieving var x
 10
 20
 30
 
 I am at a lost on how to intercept class attribute sets. Can anyone
 help :-/

A class is just an instance of its metaclass, so you could move the 
descriptor into the metaclass to see the expected behaviour in the class:

 class A:
... class __metaclass__(type):
... x = RevealAccess(10, 'var x')
...
 A.x = 42
Updating var x
 A.x
Retrieving var x
42

However:

 A().x
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'A' object has no attribute 'x'

So you'd need two descriptors if you want to intercept variable access on 
both the instance and class level.


-- 
http://mail.python.org/mailman/listinfo/python-list


stopping a thread with _Thread__stop

2011-08-05 Thread Eli Bendersky
This recipe: 
http://code.activestate.com/recipes/576780-timeout-for-nearly-any-callable/

Claims that a Python thread can be stopped by executing the private
method Thread._Thread__stop. I don't think this is true, since
_Thread__stop doesn't really stop or kill the thread. In conformance
to theory, the timelimited method this recipe defines leaves a
thread running in the background if the function it's given is
long-running (or infinite). Is there something I'm missing?

Eli
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __set__ method is not called for class attribute access

2011-08-05 Thread Duncan Booth
Ryan heni...@yahoo.com wrote:

 In the context of descriptors, the __set__ method is not called for
 class attribute access. __set__ is only
 called to set the attribute on an instance instance of the owner class
 to a new value, value. WHY? Is there some other mechanism for
 accomplishing this outcome. This subtle difference from __get__cost me
 some time to track down. Might think about pointing that out the
 documentation.
 
 
 class RevealAccess(object):
 A data descriptor that sets and returns values
normally and prints a message logging their access.
 
 
 def __init__(self, initval=None, name='var'):
 self.val = initval
 self.name = name
 
 def __get__(self, obj, objtype):
 print 'Retrieving', self.name
 return self.val
 
 def __set__(self, obj, val):
 print 'Updating' , self.name
 self.val = val
 
 class MyClass(object):
 x = RevealAccess(10, 'var x')
 y = 5
 
 print MyClass.x
 MyClass.x = 20
 print MyClass.x
 MyClass.x = 30
 print MyClass.x
 
 Retrieving var x
 10
 20
 30
 
 I am at a lost on how to intercept class attribute sets. Can anyone
 help :-/

The descriptor protocol only works when a value is being accessed or set 
on an instance and there is no instance attribute of that name so the 
value is fetched from the underlying class.

Classes are instances too, so you may get some of what you want from:

class MyMeta(type):
x = RevealAccess(10, 'var x')

class MyClass(object):
__metaclass__ = MyMeta
y = 5

 MyClass.x = 20
Updating var x
 MyClass.x
Retrieving var x
20

However note that if you do this you can access x only directly on the 
class not on an instance of the class:

 MyClass().x

Traceback (most recent call last):
  File pyshell#16, line 1, in module
MyClass().x
AttributeError: 'MyClass' object has no attribute 'x'


-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __set__ method is not called for class attribute access

2011-08-05 Thread Peter Otten
Duncan Booth wrote:

 The descriptor protocol only works when a value is being accessed or set
 on an instance and there is no instance attribute of that name so the
 value is fetched from the underlying class.

Unlike normal class attributes a descriptor is not shaded by an instance 
attribute:

 class A(object):
... def set_x(self, value): self.__dict__[x] = value/2.0
... def get_x(self): return self.__dict__[x] * 2.0
... x = property(get_x, set_x)
...
 a = A()
 a.x = 42
 a.__dict__[x]
21.0
 a.x
42.0
 A.x = something completely different
 a.x
21.0

-- 
http://mail.python.org/mailman/listinfo/python-list


Fwd: Sockets: Receiving C Struct

2011-08-05 Thread Johnny Venter
I was not sure if this message was sent before my membership was accepted.

Please disregard if it's a duplicate.

Thanks

Begin forwarded message:

 From: Johnny Venter johnny.ven...@zoho.com
 Date: August 5, 2011 8:15:53 AM EDT
 To: python-list@python.org
 Subject: Sockets: Receiving C Struct
 
 New to python and would like to test network/sockets with it.
 
 I am having a problem where I have setup the following:
 
 import socket, sys, struct
 
 HOST = '1.1.1.1'
 PORT = 153
 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 s.connect((HOST, PORT))
 
 data = struct.unpack('!I',s.recv(4))[0]
 
 s.close()
 
 print data
 
 
 What I would like to do is take the input from the server, and store it in an 
 array.  The type of data is int.
 
 Can someone help?
 
 
 Thanks, Johnny
 



PGP.sig
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyWhich

2011-08-05 Thread Steven D'Aprano
Tim Chase wrote:

 On 08/04/2011 07:34 PM, Steven D'Aprano wrote:
 Billy Mays wrote:
 #!/usr/bin/python

 I believe the recommended, platform independent hash-bang line is

 #!/usr/bin/which python
 
 I think you mean
 
#!/usr/bin/env python


Doh! I *always* conflate env and which. Thank you for the correction.



-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyWhich

2011-08-05 Thread Tim Golden

On 05/08/2011 14:51, Steven D'Aprano wrote:

Tim Chase wrote:


On 08/04/2011 07:34 PM, Steven D'Aprano wrote:

Billy Mays wrote:

#!/usr/bin/python


I believe the recommended, platform independent hash-bang line is

#!/usr/bin/which python


I think you mean

#!/usr/bin/env python



Doh! I *always* conflate env and which. Thank you for the correction.


And there I was thinking you were making a sly and ironic point
about using a utility to find something on the path in order to
run a utility which finds something on the path...

TJG
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyWhich

2011-08-05 Thread John Gordon
In 4e3bf554$0$29976$c3e8da3$54964...@news.astraweb.com Steven D'Aprano 
steve+comp.lang.pyt...@pearwood.info writes:

 Doh! I *always* conflate env and which. Thank you for the correction.

Way to say conflate!  :-)

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Observations on the three pillars of Python execution

2011-08-05 Thread Steven D'Aprano
Eric Snow wrote:

 In Python, three types of objects have special syntax and mechanics
 for their instantiation, during which a code object is generated:
 modules, classes, and functions.  

I believe you are labouring under a misapprehension. Modules and classes
don't generate code objects.

The simplest possible module just has a name:

 import sys
 module = type(sys)
 module(name)
module 'name' (built-in)

Or if you prefer to do it the normal way by importing from source code,
the simplest source code of all is just an empty file.

A module is an object with a __dict__, a __name__, and a __docstring__ which
defaults to None. That's it. No code objects, unless you populate the
__dict__ with functions, but it is the *functions* that have the code
objects, not the module itself. The module is just a container.

Classes are similar. The simplest class:

class K:
pass

or if you prefer:

 type('K', (), {})
class '__main__.K'


Again, no code objects unless you populate the dict with functions (which
get turned into methods). Again, the class object is just a container. A
more complex container than modules, with a richer set of inherited
behaviour, but still just a container.

The signature for creating a function is very different:

help(type(lambda: None)) = 

class function(object)
 |  function(code, globals[, name[, argdefs[, closure]]])
 |
 |  Create a function object from a code object and a dictionary.
 |  The optional name string overrides the name from the code object.
 |  The optional argdefs tuple specifies the default argument values.
 |  The optional closure tuple supplies the bindings for free variables.


The simplest function I can think of:

 co = compile('pass', '', 'single')
 f = type(lambda: None)(co, {})

Even simpler than

def f():
pass

Can you see why?

If you inspect a function object, you will see that it always has a code
object, even if the code object does nothing but return None:

 import dis
 dis.dis(f.func_code)
  1   0 LOAD_CONST   0 (None)
  3 RETURN_VALUE


There may be some other obscure built-in type that includes code objects,
but I can't imagine what it would be. I feel confident in saying that
functions, and functions alone, contain code. Even methods are just
wrappers around functions. Even built-in functions like len don't contain
code! (Or at least, their code isn't accessible from Python.) Which makes
sense, if you think about it: their code is part of the Python virtual
machine, not the object.


-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyWhich

2011-08-05 Thread Billy Mays

On 08/04/2011 10:03 PM, Chris Angelico wrote:

On Fri, Aug 5, 2011 at 1:34 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info  wrote:

Especially for a tool aimed at programmers (who else would be interested in
PyWhich?)


The use that first springs to my mind is debugging import paths etc.
If you have multiple pythons installed and aren't sure that they're
finding the right modules, you could fire up PyWhich on an innocuous
module like math or sys, and see if it's loading it from the right
path. People doing this might not necessarily be programmers, they
might be sysadmins; but you're right that it's most likely this will
be used by competent Python programmers.

ChrisA


I am trying to do debugging.  I have had some trouble with multiple 
python installs with virtualenv, and I was trying to see where given 
modules came from.  I knew about the code execution, but I couldn't 
think of a clean way to just find out the location rather than load it.


The reason I used stdout was because I was going to be using it in a 
tool chain where the stdout might need to be formatted for another 
program to read in.  Thats also why I was catching ImportError since a 
later version of this script might need to do something special with it.


This is also useful to see if python is really using the module you 
think it is.


--
Bill
--
http://mail.python.org/mailman/listinfo/python-list


Re: Recursive functions (was Re: Observations on the three pillars of Python execution)

2011-08-05 Thread Steven D'Aprano
Chris Angelico wrote:

 On Fri, Aug 5, 2011 at 9:22 AM, Thomas Jollans t...@jollybox.de wrote:
 On 05/08/11 09:20, Eric Snow wrote:
 Object available during code object execution:
 (M) no
 (C) no
 (F) no
 (F) yes.

 cf. recursion.
 
 Is it? As I understand it, a Python function is not able to reference
 itself but must reference its own name.

That is correct. Recursion in Python is implemented simply by name lookup.


 This means that assigning 
 that function to something else stops it being recursive:

An easier way to demonstrate the process:

 def f(x):
... print x
... if x  0: f(x-1)
...
 f(3)
3
2
1
0
 g = f
 del f
 g(3)
3
Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 3, in f
NameError: global name 'f' is not defined


-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyWhich

2011-08-05 Thread Steven D'Aprano
Billy Mays wrote:

 The reason I used stdout was because I was going to be using it in a
 tool chain where the stdout might need to be formatted for another
 program to read in.

print writes to sys.stdout unless you tell it different.

 import sys
 import StringIO
 capture = StringIO.StringIO()
 sys.stdout = capture
 print spam
 sys.stdout = sys.__stdout__  # Restore the real file.
 capture.getvalue()
'spam\n'

Syntax for printing elsewhere is ugly as sin in Python 2, but it works:

 print sys.stderr, spam
spam
 print capture, ham
 capture.getvalue()
'spam\nham\n'




 Thats also why I was catching ImportError since a 
 later version of this script might need to do something special with it.

Well you better also catch SyntaxError, because a later version of your
script might need to do something special with it too :)

Also RuntimeError, ValueError, TypeError... *wink*


-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sockets: Receiving C Struct

2011-08-05 Thread Dan Stromberg
First, s.recv(4) is not guaranteed to always return 4 bytes.  It could
return 0, 1, 2, 3, or 4, wtih 4 being the most likely.  To deal with this, I
tend to use http://stromberg.dnsalias.org/~dstromberg/bufsock.html - but I
suspect that Twisted has a way of dealing with it too.

Then, to put your data into a list, just create an empty list with [] and
use list_.append(integer).

Or was there more to your question, like perhaps a traceback you haven't
shared with us?

On Fri, Aug 5, 2011 at 6:05 AM, Johnny Venter johnny.ven...@zoho.comwrote:

 I was not sure if this message was sent before my membership was accepted.

 Please disregard if it's a duplicate.

 Thanks

 Begin forwarded message:

 *From: *Johnny Venter johnny.ven...@zoho.com
 *Date: *August 5, 2011 8:15:53 AM EDT
 *To: *python-list@python.org
 *Subject: **Sockets: Receiving C Struct*

 New to python and would like to test network/sockets with it.

 I am having a problem where I have setup the following:

 import socket, sys, struct

 HOST = '1.1.1.1'
 PORT = 153
 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 s.connect((HOST, PORT))

 data = struct.unpack('!I',s.recv(4))[0]

 s.close()

 print data


 What I would like to do is take the input from the server, and store it in
 an array.  The type of data is int.

 Can someone help?


 Thanks, Johnny



 --
 http://mail.python.org/mailman/listinfo/python-list


-- 
http://mail.python.org/mailman/listinfo/python-list


scrape text from web

2011-08-05 Thread 守株待兔
python-list@python.org:
hi ,everyone,
i want to scrap something from
http://search.dangdang.com/search_pub.php?key=python
my code is :

import urllib
import lxml.html
down='http://search.dangdang.com/search_pub.php?key=python'
file=urllib.urlopen(down).read()
root=lxml.html.fromstring(file)
tnodes = root.xpath(//div[@class='listitem 
detail']//li[@class='maintitle']//a)
for i,x in  enumerate(tnodes):
   print i,  ,x.get('name'),x.get('href'),x.get('onclick'),x.text,\n

the output is :
0p_name 
http://product.dangdang.com/product.aspx?product_id=20872365ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','20872365_1_22591_p','','','');
 None

1p_name 
http://product.dangdang.com/product.aspx?product_id=20255354ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','20255354_2_12605_p','','','');
 None

2p_name 
http://product.dangdang.com/product.aspx?product_id=20836565ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','20836565_3_2361_p','','','');
 None

3p_name 
http://product.dangdang.com/product.aspx?product_id=21004615ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','21004615_4_3387_p','','','');
 None

4p_name 
http://product.dangdang.com/product.aspx?product_id=21063086ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','21063086_5_18815_p','','','');
 None

5pr_name 
http://product.dangdang.com/product.aspx?product_id=20678461ref=search-1-pub 
s('click','python','01.54.04.03,01.54.06.18','','86_1_25','','','20678461_6_3967_p','','','RECO');
 None

6pr_name 
http://product.dangdang.com/product.aspx?product_id=20650363ref=search-1-pub 
s('click','python','01.54.19.00','','86_1_25','','','20650363_7_62_p','','','RECO');
 黑客之道:漏洞发掘的艺术(原书第二版)(赠1CD)(电子制品CD-ROM)(

7pr_name 
http://product.dangdang.com/product.aspx?product_id=20767932ref=search-1-pub 
s('click','python','01.54.19.00','','86_1_25','','','20767932_8_4475_p','','','RECO');
 Binary Hacks――黑客秘笈100选

8p_name 
http://product.dangdang.com/product.aspx?product_id=20596189ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','20596189_9_639_p','','','');
 None

9p_name 
http://product.dangdang.com/product.aspx?product_id=20947680ref=search-1-pub 
s('click','python','01.54.24.00,01.54.06.18','','86_1_25','','','20947680_10_7295_p','','','');
 None

10p_name 
http://product.dangdang.com/product.aspx?product_id=21050368ref=search-1-pub 
s('click','python','01.54.19.00','','86_1_25','','','21050368_11_7039_p','','','');
 None

11p_name 
http://product.dangdang.com/product.aspx?product_id=20667966ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','20667966_12_383_p','','','');
 None

12p_name 
http://product.dangdang.com/product.aspx?product_id=21022493ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','21022493_13_5183_p','','','');
 None

13pr_name 
http://product.dangdang.com/product.aspx?product_id=479654ref=search-1-pub 
s('click','python','01.54.06.08,01.54.06.18','','86_1_25','','','479654_14_2095_p','','','RECO');
 Perl语言编程(第三版)

14pr_name 
http://product.dangdang.com/product.aspx?product_id=20999855ref=search-1-pub 
s('click','python','01.54.10.00','','86_1_25','','','20999855_15_6715_p','','','RECO');
 程序员的思维修炼:开发认知潜能的九堂课

15pr_name 
http://product.dangdang.com/product.aspx?product_id=20696203ref=search-1-pub 
s('click','python','01.54.06.08','','86_1_25','','','20696203_16_31615_p','','','RECO');
 Perl语言入门(第五版)(原书名:Learning Perl,5/e)

16p_name 
http://product.dangdang.com/product.aspx?product_id=20670643ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','20670643_17_24_p','','','');
 可爱的

17p_name 
http://product.dangdang.com/product.aspx?product_id=20362210ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','20362210_18_32_p','','','');
 学习

18p_name 
http://product.dangdang.com/product.aspx?product_id=9053236ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','9053236_19_4_p','','',''); 
学习

19p_name 
http://product.dangdang.com/product.aspx?product_id=20850780ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','20850780_20_1055_p','','','');
 None

20pr_name 
http://product.dangdang.com/product.aspx?product_id=20449068ref=search-1-pub 
s('click','python','01.54.06.08','','86_1_25','','','20449068_21_38_p','','','RECO');
 精通Perl

21p_name 
http://product.dangdang.com/product.aspx?product_id=21127816ref=search-1-pub 
s('click','python','01.54.24.00,01.54.06.18','','86_1_25','','','21127816_22_12545_p','','','');
 None

22p_name 
http://product.dangdang.com/product.aspx?product_id=21107633ref=search-1-pub 
s('click','python','01.54.06.18','','86_1_25','','','21107633_23_19245_p','','','');
 Hadoop权威指南(第2版)修订升级版

23None  http://bang.dangdang.com/product_redirect.php?product_id=9317290 
None None

24p_name 

Re: problem with bcd and a number

2011-08-05 Thread Chris Angelico
On Fri, Aug 5, 2011 at 1:40 AM, Dan Stromberg drsali...@gmail.com wrote:
 print int(hex(0x72).replace('0x', ''))
 72

Or simpler: int(hex(0x72)[2:])

Although if you have it as a string, you need to ord() the string.

It's probably better to just do the bitwise operations though.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem with bcd and a number

2011-08-05 Thread Peter Otten
Chris Angelico wrote:

 On Fri, Aug 5, 2011 at 1:40 AM, Dan Stromberg drsali...@gmail.com wrote:
 print int(hex(0x72).replace('0x', ''))
 72
 
 Or simpler: int(hex(0x72)[2:])
 
 Although if you have it as a string, you need to ord() the string.

Or use str.encode():

 int(\x72.encode(hex))
72
 int(\x12\x34\x56.encode(hex))
123456

 It's probably better to just do the bitwise operations though.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem with bcd and a number

2011-08-05 Thread Peter Pearson
On Thu, 04 Aug 2011 21:52:45 +0200, Christoph Hansen c...@radamanthys.de 
wrote:
 MRAB schrieb:

 The value is MSB * 100 + (LSB  4) * 10 + (LSB  0xF)

 i would say

 (MSB  4)*100 + (MSB  0xF)*10 + (LSB  4)

 but who knows

I concur.  I think the documentation is trying to say that the
low-order nibble of the LSB is garbage.

-- 
To email me, substitute nowhere-spamcop, invalid-net.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: geany-pyflakes 1.0

2011-08-05 Thread Filip Gruszczyński
Hello everyone,

I have just published a small plugin for Geany IDE that adds Pyflakes
error detection to the editor. If there are people using Geany for
Python development I would be very grateful for opinions and
suggestions.

The plugin can be found here: http://code.google.com/p/geany-pyflakes/

-- 
Filip Gruszczyński
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Observations on the three pillars of Python execution

2011-08-05 Thread Eric Snow
On Fri, Aug 5, 2011 at 8:36 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Eric Snow wrote:

 In Python, three types of objects have special syntax and mechanics
 for their instantiation, during which a code object is generated:
 modules, classes, and functions.

 I believe you are labouring under a misapprehension. Modules and classes
 don't generate code objects.

Sorry for any confusion.  I was talking specifically about the their
instantiation through their respective special syntax.  During that
process a code object is generated for each.  For classes and modules
the code object is executed and then discarded.  I covered this
explicitly in one of the observations.


 The simplest possible module just has a name:

 import sys
 module = type(sys)
 module(name)
 module 'name' (built-in)

 Or if you prefer to do it the normal way by importing from source code,
 the simplest source code of all is just an empty file.

 A module is an object with a __dict__, a __name__, and a __docstring__ which
 defaults to None. That's it. No code objects, unless you populate the
 __dict__ with functions, but it is the *functions* that have the code
 objects, not the module itself. The module is just a container.

 Classes are similar. The simplest class:

 class K:
    pass

 or if you prefer:

 type('K', (), {})
 class '__main__.K'


 Again, no code objects unless you populate the dict with functions (which
 get turned into methods). Again, the class object is just a container. A
 more complex container than modules, with a richer set of inherited
 behaviour, but still just a container.

 The signature for creating a function is very different:

 help(type(lambda: None)) =

 class function(object)
  |  function(code, globals[, name[, argdefs[, closure]]])
  |
  |  Create a function object from a code object and a dictionary.
  |  The optional name string overrides the name from the code object.
  |  The optional argdefs tuple specifies the default argument values.
  |  The optional closure tuple supplies the bindings for free variables.


 The simplest function I can think of:

 co = compile('pass', '', 'single')
 f = type(lambda: None)(co, {})

 Even simpler than

 def f():
    pass

 Can you see why?

 If you inspect a function object, you will see that it always has a code
 object, even if the code object does nothing but return None:

 import dis
 dis.dis(f.func_code)
  1           0 LOAD_CONST               0 (None)
              3 RETURN_VALUE


 There may be some other obscure built-in type that includes code objects,
 but I can't imagine what it would be. I feel confident in saying that
 functions, and functions alone, contain code. Even methods are just
 wrappers around functions. Even built-in functions like len don't contain
 code! (Or at least, their code isn't accessible from Python.) Which makes
 sense, if you think about it: their code is part of the Python virtual
 machine, not the object.

Agreed that [non-builtin] functions are the only objects that have a
code object attribute.  However, they are not the only objects for
which a code object is generated and executed.

I've always found your frequent responses very insightful and
thoughtful, Steven, and I appreciate that.  In this case I can only
imagine that my opening statement was unclear enough that you did not
continue to read the rest, where the context of my point was more
clear (I hope :).  Regardless, thanks for taking a look.

-eric



 --
 Steven

 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: geany-pyflakes 1.0

2011-08-05 Thread Emile van Sebille

On 8/5/2011 9:14 AM Filip Gruszczyński said...

Hello everyone,

I have just published a small plugin for Geany IDE that adds Pyflakes
error detection to the editor. If there are people using Geany for
Python development I would be very grateful for opinions and
suggestions.

The plugin can be found here: http://code.google.com/p/geany-pyflakes/



fyi - the downloaded geany-pyflakes-1.0.tar.gz is in fact not gzipped 
and should either be gizzped or simply named geany-pyflakes-1.0.tar.


However, after activating the plugin, asking geany for a new file breaks 
geany and it rudely closes so I'm unable to actually do anything with it.


Emile




--
http://mail.python.org/mailman/listinfo/python-list


Re: Observations on the three pillars of Python execution

2011-08-05 Thread Steven D'Aprano
Eric Snow wrote:

 On Fri, Aug 5, 2011 at 8:36 AM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 Eric Snow wrote:

 In Python, three types of objects have special syntax and mechanics
 for their instantiation, during which a code object is generated:
 modules, classes, and functions.

 I believe you are labouring under a misapprehension. Modules and classes
 don't generate code objects.
 
 Sorry for any confusion.  I was talking specifically about the their
 instantiation through their respective special syntax.  During that
 process a code object is generated for each.


Do you believe that this process of generating a code object and throwing it
away is a part of the Python language specification, which any compiler
must do in order to call itself Python, or a mere implementation detail?

Is this documented somewhere? If it is not documented, what makes you think
that it happens at all? You are writing as if it were self-evidently true,
but I don't believe it is self-evident at all. I think you need to
demonstrate the truth of two of those three pillars, not just take them for
granted.


 For classes and modules 
 the code object is executed and then discarded.  I covered this
 explicitly in one of the observations.

I think your definition of explicitly and mine differ here.


 Agreed that [non-builtin] functions are the only objects that have a
 code object attribute.  However, they are not the only objects for
 which a code object is generated and executed.

Are you talking about the fact that importing a module, class statements and
function statements all involve executing a block of code?

How does that differ from executing any other fragment of code?

Modules are special, of course, because they can get compiled to byte-code,
but I trust you're not talking about .pyc files. 



-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Community Involvement

2011-08-05 Thread Sells, Fred
After the completion of most training courses, the students are not yet
ready to make a meaningful contribution to the community.  

 

Yet your goal of getting them involved in the community is worthwhile.
I would think learning to use the community as a resource to solve a
problem that is not based on the standard modules would be a good one.

 

I liked the recipe suggestion as well, but I think you would need to
post a list of  items to choose and remove the item when the recipe has
been posted.  Otherwise you could get a gazillion examples of sorting a
dictionary...

 

Just my 2 cents FWIW

 

Fred Sells

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Community Involvement

2011-08-05 Thread Chris Angelico
On Fri, Aug 5, 2011 at 6:31 PM, Sells, Fred
fred.se...@adventistcare.org wrote:
 After the completion of most training courses, the students are not yet
 ready to make a meaningful contribution to the community.

That's quite possibly true, but they may very well be in a position to
recognize a documentation error/omission and assist, or alternatively,
to triage some bugs. There are plenty of OSS projects that could do
with a hand there; does it have to be Python specifically? Python's
docs are pretty good, but I'm sure there will always be value in
people spending time on http://bugs.python.org/ and seeing if they can
reproduce the bugs.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Table Driven GUI Definition?

2011-08-05 Thread Tim Daneliuk
I have a task where I want to create pretty simple one page visual
interfaces (Graphical or Text, but it needs to run across Windows,
Cygwin, Linux,*BSD, OSX ...).  These interfaces are nothing more
than option checklists and text fields.  Conceptually something like:

Please Select Your Installation Options:

   Windows Compatibility Services  _
   Linux Compatibility Services_
   TRS-DOS Compatibility Services  _

   What Is Your email Address: ___

What I'm looking for is a way to describe such forms in a text
file that can then be fed into a tool to generate the necessary
pyGUI, Tkinter, (or whatever) code.   The idea is that it should
be simple to generate a basic interface like this and have it
only record the user's input.  Thereafter, the python code 
would act on the basis of those selection without any further
connection to the GUI.

An added bonus would be a similar kind of thing for generating
web interfaces to do this.  This might actually be a better model
because then I only have to worry about a single presentation
environment.

Ideas anyone?
-- 

Tim Daneliuk
tun...@tundraware.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Question about encoding, I need a clue ...

2011-08-05 Thread Geoff Wright
Hi,

I use Mac OSX for development but deploy on a Linux server.  (Platform details 
provided below).

When the locale is set to FR_CA, I am not able to display a u circumflex 
consistently across the two machines even though the default encoding is set to 
ascii on both machines.  Specifically, calendar.month_name[8] returns a ? 
(question mark) on the Linux server whereas it displays properly on the Mac OSX 
system.  However, if I take the result from calendar.month_name[8] and run it 
through the following function  unicode(calendar.month_name[8],latin1) 
... then the u circumflex displays correctly on the Linux server but does not 
display correctly on my Mac.

Of course, I could work around this problem with a relatively simple if 
statement but these issues are going to show up all over my application so even 
a simple if statement will start to get cumbersome.

I guess what it boils down to is that I would like to get a better handle on 
what is going on so that I will know how best to work through future encoding 
issues.  Thanks in advance for any advice.

Here are the specifics of my problem.

On my Mac:

Python 2.6.7 (r267:88850, Jul 30 2011, 23:46:53) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin

 import locale
 locale.setlocale(locale.LC_ALL,'fr_CA')
'fr_CA'
 import sys
 sys.getdefaultencoding()
'ascii'
 import calendar
 calendar.month_name[8]
'ao\xc3\xbbt'
 print calendar.month_name[8]
août
 print unicode(calendar.month_name[8],latin1)
août

On the linux server:

uname -a
Linux alhena 2.6.32.8-grsec-2.1.14-modsign-xeon-64 #2 SMP Sat Mar 13 00:42:43 
PST 2010 x86_64 GNU/Linux

Python 2.5.2 (r252:60911, Jan 24 2010, 17:44:40) 
[GCC 4.3.2] on linux2

 import locale,sys,calendar
 locale.setlocale(locale.LC_ALL,'fr_CA')
'fr_CA'
 sys.getdefaultencoding()
'ascii'
 calendar.month_name[8]
'ao\xfbt'
 print calendar.month_name[8]
ao?t
 print unicode(calendar.month_name[8],latin1)
août






-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Observations on the three pillars of Python execution

2011-08-05 Thread Mel
Steven D'Aprano wrote:

 There may be some other obscure built-in type that includes code objects,
 but I can't imagine what it would be. I feel confident in saying that
 functions, and functions alone, contain code. Even methods are just
 wrappers around functions. Even built-in functions like len don't contain
 code! (Or at least, their code isn't accessible from Python.) Which makes
 sense, if you think about it: their code is part of the Python virtual
 machine, not the object.

Interesting question.  Iterators seem to have code objects:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type help, copyright, credits or license for more information.
 a = [1, 2, 3]
 b = (x for x in a)
 dir(b)
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', 
'__hash__', '__init__', '__iter__', '__name__', '__new__', '__reduce__', 
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', 
'__subclasshook__', 'close', 'gi_code', 'gi_frame', 'gi_running', 'next', 
'send', 'throw']
 for name in dir(b):
...   print name, type (getattr (b, name))
... 
__class__ type 'type'
__delattr__ type 'method-wrapper'
__doc__ type 'NoneType'
__format__ type 'builtin_function_or_method'
__getattribute__ type 'method-wrapper'
__hash__ type 'method-wrapper'
__init__ type 'method-wrapper'
__iter__ type 'method-wrapper'
__name__ type 'str'
__new__ type 'builtin_function_or_method'
__reduce__ type 'builtin_function_or_method'
__reduce_ex__ type 'builtin_function_or_method'
__repr__ type 'method-wrapper'
__setattr__ type 'method-wrapper'
__sizeof__ type 'builtin_function_or_method'
__str__ type 'method-wrapper'
__subclasshook__ type 'builtin_function_or_method'
close type 'builtin_function_or_method'
gi_code type 'code'
gi_frame type 'frame'
gi_running type 'int'
next type 'method-wrapper'
send type 'builtin_function_or_method'
throw type 'builtin_function_or_method'


in the form of the gi_code attribute.  No idea what it's for, although no 
reason to believe it shouldn't be there.  (Very interesting demo you gave of 
primitive object creation.  I' awed.)

Mel.
-- 
http://mail.python.org/mailman/listinfo/python-list


Get the name of a function

2011-08-05 Thread gervaz
Hi all, is there a way to retrive the function name like with
self.__class__.__name__?

Using self.__dict__.__name__ I've got

 def test():
... print(self.__dict__.__name__)
...
 test
function test at 0x0178DDF8

But I really just want the function name, so 'test'

Any help?

Thanks,

Mattia
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: geany-pyflakes 1.0

2011-08-05 Thread Filip Gruszczyński
 fyi - the downloaded geany-pyflakes-1.0.tar.gz is in fact not gzipped and
 should either be gizzped or simply named geany-pyflakes-1.0.tar.

 However, after activating the plugin, asking geany for a new file breaks
 geany and it rudely closes so I'm unable to actually do anything with it.

I have posted a gzipped version with a fix. Would you care to take a look?

-- 
Filip Gruszczyński
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Table Driven GUI Definition?

2011-08-05 Thread Irmen de Jong

On 05-08-11 19:53, Tim Daneliuk wrote:

I have a task where I want to create pretty simple one page visual
interfaces (Graphical or Text, but it needs to run across Windows,
Cygwin, Linux,*BSD, OSX ...).  These interfaces are nothing more
than option checklists and text fields.  Conceptually something like:

 Please Select Your Installation Options:

Windows Compatibility Services  _
Linux Compatibility Services_
TRS-DOS Compatibility Services  _

What Is Your email Address: ___

What I'm looking for is a way to describe such forms in a text
file that can then be fed into a tool to generate the necessary
pyGUI, Tkinter, (or whatever) code.   The idea is that it should
be simple to generate a basic interface like this and have it
only record the user's input.  Thereafter, the python code
would act on the basis of those selection without any further
connection to the GUI.

An added bonus would be a similar kind of thing for generating
web interfaces to do this.  This might actually be a better model
because then I only have to worry about a single presentation
environment.

Ideas anyone?


Yeah, HTML being the text file and a web browser being the tool to 
transform it into a GUI...


You can hook this up with a simple web server or web framework running 
locally to grab the submitted form results when the form is complete and 
process them in a piece of python code.


Wouldn't that work?


Irmen
--
http://mail.python.org/mailman/listinfo/python-list


Replace all references to one object with references to other

2011-08-05 Thread Jack Bates
I have two objects, and I want to replace all references to the first
object - everywhere - with references to the second object. What can I
try?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: geany-pyflakes 1.0

2011-08-05 Thread Emile van Sebille

On 8/5/2011 11:58 AM Filip Gruszczyński said...

fyi - the downloaded geany-pyflakes-1.0.tar.gz is in fact not gzipped and
should either be gizzped or simply named geany-pyflakes-1.0.tar.

However, after activating the plugin, asking geany for a new file breaks
geany and it rudely closes so I'm unable to actually do anything with it.


I have posted a gzipped version with a fix. Would you care to take a look?



OK - it no longer crashes, but it doesn't appear to do anything.  Is 
there something further I need to do to configure it?  The Pyflakes tab 
does appear in the message window and I've created a new testpyflakes.py 
with code similar to your example.


Also, just FYI, the plugin manager now shows the version as 1.0.1 while 
the tar file name indicates 1.0.2.


Emile

--
http://mail.python.org/mailman/listinfo/python-list


Re: Table Driven GUI Definition?

2011-08-05 Thread Emile van Sebille

On 8/5/2011 10:53 AM Tim Daneliuk said...

I have a task where I want to create pretty simple one page visual
interfaces (Graphical or Text, but it needs to run across Windows,
Cygwin, Linux,*BSD, OSX ...).  These interfaces are nothing more
than option checklists and text fields.


I'm not happened across an automated tool exactly, but I'd look into 
pyjamas or pygui.


Emile


--
http://mail.python.org/mailman/listinfo/python-list


Re: Table Driven GUI Definition?

2011-08-05 Thread Tim Daneliuk
On 8/5/2011 2:05 PM, Irmen de Jong said this:
 On 05-08-11 19:53, Tim Daneliuk wrote:
 I have a task where I want to create pretty simple one page visual
 interfaces (Graphical or Text, but it needs to run across Windows,
 Cygwin, Linux,*BSD, OSX ...).  These interfaces are nothing more
 than option checklists and text fields.  Conceptually something like:

  Please Select Your Installation Options:

 Windows Compatibility Services  _
 Linux Compatibility Services_
 TRS-DOS Compatibility Services  _

 What Is Your email Address: ___

 What I'm looking for is a way to describe such forms in a text
 file that can then be fed into a tool to generate the necessary
 pyGUI, Tkinter, (or whatever) code.   The idea is that it should
 be simple to generate a basic interface like this and have it
 only record the user's input.  Thereafter, the python code
 would act on the basis of those selection without any further
 connection to the GUI.

 An added bonus would be a similar kind of thing for generating
 web interfaces to do this.  This might actually be a better model
 because then I only have to worry about a single presentation
 environment.

 Ideas anyone?
 
 Yeah, HTML being the text file and a web browser being the tool to transform 
 it into a GUI...
 
 You can hook this up with a simple web server or web framework running 
 locally to grab the submitted form results when the form is complete and 
 process them in a piece of python code.
 
 Wouldn't that work?
 
 
 Irmen

Yup, although I'd probably use a central apache instance.  But
I'm still curious ... is there a way to do this with a full
GUI tool on a thick client?


-- 

Tim Daneliuk
tun...@tundraware.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Get the name of a function

2011-08-05 Thread Emile van Sebille

On 8/5/2011 11:52 AM gervaz said...

Hi all, is there a way to retrive the function name like with
self.__class__.__name__?


yes, but not reliably:

Python 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:55:11)
[GCC 4.4.1] on linux2
Type help, copyright, credits or license for more information.
 def test():pass
...
 test.__name__
'test'
 b=test
 b.__name__
'test'



Emile


--
http://mail.python.org/mailman/listinfo/python-list


Re: Replace all references to one object with references to other

2011-08-05 Thread Ken Watford
On Fri, Aug 5, 2011 at 3:37 PM, Jack Bates ms...@freezone.co.uk wrote:
 I have two objects, and I want to replace all references to the first
 object - everywhere - with references to the second object. What can I
 try?

If using PyPy instead of CPython is an option, the thunk object
space's become function can apparently do this:
http://doc.pypy.org/en/latest/objspace-proxies.html#the-thunk-object-space

In CPython, this might be a tad difficult. At the C level, a reference
to a python object is just a pointer to it. You could iterate through
the entire address space looking for values that equal a particular
pointer, but changing them would be dangerous, since memory isn't
labeled by type - you can't tell if the memory is a pointer to your
object or an important part of some other data structure.

If you could narrow down what you want to accomplish, this might be
easier. For instance, if all you need is to replace module-level
references to the object, that can be done.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replace all references to one object with references to other

2011-08-05 Thread Emile van Sebille

On 8/5/2011 12:37 PM Jack Bates said...

I have two objects, and I want to replace all references to the first
object - everywhere - with references to the second object. What can I
try?


Start with a proxy to your first and have it swap in to the second?

EMile


--
http://mail.python.org/mailman/listinfo/python-list


Re: Table Driven GUI Definition?

2011-08-05 Thread Philip Semanchuk

On Aug 5, 2011, at 4:10 PM, Tim Daneliuk wrote:

 On 8/5/2011 2:05 PM, Irmen de Jong said this:
 On 05-08-11 19:53, Tim Daneliuk wrote:
 I have a task where I want to create pretty simple one page visual
 interfaces (Graphical or Text, but it needs to run across Windows,
 Cygwin, Linux,*BSD, OSX ...).  These interfaces are nothing more
 than option checklists and text fields.  Conceptually something like:
 
 Please Select Your Installation Options:
 
Windows Compatibility Services  _
Linux Compatibility Services_
TRS-DOS Compatibility Services  _
 
What Is Your email Address: ___
 
 What I'm looking for is a way to describe such forms in a text
 file that can then be fed into a tool to generate the necessary
 pyGUI, Tkinter, (or whatever) code.   The idea is that it should
 be simple to generate a basic interface like this and have it
 only record the user's input.  Thereafter, the python code
 would act on the basis of those selection without any further
 connection to the GUI.
 
 An added bonus would be a similar kind of thing for generating
 web interfaces to do this.  This might actually be a better model
 because then I only have to worry about a single presentation
 environment.
 
 Ideas anyone?

Hi Tim
This looks pretty straightforward to me; maybe I'm missing something. It 
doesn't look trivial, but the steps seem pretty clear. Is there some part in 
particular that's giving you trouble?

Cheers
Philip



 
 Yeah, HTML being the text file and a web browser being the tool to transform 
 it into a GUI...
 
 You can hook this up with a simple web server or web framework running 
 locally to grab the submitted form results when the form is complete and 
 process them in a piece of python code.
 
 Wouldn't that work?
 
 
 Irmen
 
 Yup, although I'd probably use a central apache instance.  But
 I'm still curious ... is there a way to do this with a full
 GUI tool on a thick client?
 
 
 -- 
 
 Tim Daneliuk
 tun...@tundraware.com
 -- 
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replace all references to one object with references to other

2011-08-05 Thread John Gordon
In mailman.1937.1312573077.1164.python-l...@python.org Jack Bates 
ms...@freezone.co.uk writes:

 I have two objects, and I want to replace all references to the first
 object - everywhere - with references to the second object. What can I
 try?

The simplest answer to your question is to assign object2 to object1
at the very beginning of your code, but that is a very naive solution
and can easily fail based on lots of factors.

What's your context:  A single source file?  Many source files?  A live
application with persistent data?

What are your two objects?  Do they provide an identical interface?

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Replace all references to one object with references to other

2011-08-05 Thread John Gordon
In j1hl5v$9gj$1...@reader1.panix.com John Gordon gor...@panix.com writes:

 In mailman.1937.1312573077.1164.python-l...@python.org Jack Bates 
 ms...@freezone.co.uk writes:

  I have two objects, and I want to replace all references to the first
  object - everywhere - with references to the second object. What can I
  try?

 The simplest answer to your question is to assign object2 to object1

I think I have that backwards, but the intent should be clear:

  object1 = object2

  # many references to object1 follow, which will now reference object2

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Observations on the three pillars of Python execution

2011-08-05 Thread Terry Reedy

On 8/5/2011 4:22 AM, Thomas Jollans wrote:

On 05/08/11 09:20, Eric Snow wrote:

Object available during code object execution:
(M) no
(C) no
(F) no

(F) yes.

cf. recursion.


Recursion only happens through runtime name resolution, not through 
direct access to the function or code object from within the code.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


ctypes LoadLibrary search path

2011-08-05 Thread Santoso Wijaya
Hi,

Can anyone enlighten me to the search path mechanism in ctypes' LoadLibrary?
I have a DLL that resides elsewhere that is not in any default search path.
I tried adding the path to `sys.path` before attempting to load said DLL but
I still get WindowsError: [Error 126] The specified module could not be
found.

Thanks,

~/santa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ctypes LoadLibrary search path

2011-08-05 Thread Santoso Wijaya
Nevermind. I figured it out (d'oh!).

I had to append to `os.environ['PATH']`, not `sys.path`!


~/santa


On Fri, Aug 5, 2011 at 2:13 PM, Santoso Wijaya santoso.wij...@gmail.comwrote:

 Hi,

 Can anyone enlighten me to the search path mechanism in ctypes'
 LoadLibrary? I have a DLL that resides elsewhere that is not in any default
 search path. I tried adding the path to `sys.path` before attempting to load
 said DLL but I still get WindowsError: [Error 126] The specified module
 could not be found.

 Thanks,

 ~/santa

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Get the name of a function

2011-08-05 Thread Chris Rebert
On Fri, Aug 5, 2011 at 11:52 AM, gervaz ger...@gmail.com wrote:
 Hi all, is there a way to retrive the function name like with
 self.__class__.__name__?

 Using self.__dict__.__name__ I've got

 def test():
 ...     print(self.__dict__.__name__)
 ...

Er, where did `self` magically come from?

 test
 function test at 0x0178DDF8

 But I really just want the function name, so 'test'

 Any help?

Courtesy of the Observations on the three pillars of Python execution thread:

from inspect import currentframe

def foobar():
my_name = currentframe().f_code.co_name
print(my_name)

I would recommend against a function knowing its own name though,
unless it's for debugging or necessary metaprogramming purposes.

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about encoding, I need a clue ...

2011-08-05 Thread Chris Rebert
On Fri, Aug 5, 2011 at 11:07 AM, Geoff Wright geoffwright...@gmail.com wrote:
 Hi,

 I use Mac OSX for development but deploy on a Linux server.  (Platform 
 details provided below).

 When the locale is set to FR_CA, I am not able to display a u circumflex 
 consistently across the two machines even though the default encoding is set 
 to ascii on both machines.

ASCII can't represent a circumflex anyway, and I think the default
encoding is distinct from the locale-set encoding, so I don't think
the default encoding matters here.

 Specifically, calendar.month_name[8] returns a ? (question mark) on the Linux 
server whereas it displays properly on the Mac OSX system.  However, if I take 
the result from calendar.month_name[8] and run it through the following 
function  unicode(calendar.month_name[8],latin1) ... then the u 
circumflex displays correctly on the Linux server but does not display 
correctly on my Mac.

 Of course, I could work around this problem with a relatively simple if 
 statement but these issues are going to show up all over my application so 
 even a simple if statement will start to get cumbersome.

 I guess what it boils down to is that I would like to get a better handle on 
 what is going on so that I will know how best to work through future encoding 
 issues.  Thanks in advance for any advice.

 Here are the specifics of my problem.

 On my Mac:

 Python 2.6.7 (r267:88850, Jul 30 2011, 23:46:53)
 [GCC 4.2.1 (Apple Inc. build 5664)] on darwin
snip
 calendar.month_name[8]
 'ao\xc3\xbbt'
 print calendar.month_name[8]
 août
 print unicode(calendar.month_name[8],latin1)
 août

 On the linux server:

 uname -a
 Linux alhena 2.6.32.8-grsec-2.1.14-modsign-xeon-64 #2 SMP Sat Mar 13 00:42:43 
 PST 2010 x86_64 GNU/Linux

 Python 2.5.2 (r252:60911, Jan 24 2010, 17:44:40)
 [GCC 4.3.2] on linux2
snip
 calendar.month_name[8]
 'ao\xfbt'
 print calendar.month_name[8]
 ao?t
 print unicode(calendar.month_name[8],latin1)
 août

Some quick experimentation seems to indicate that your month names are
Latin-1-encoded on Linux and UTF-8-encoded on Mac.
Perhaps try using a locale that specifies a specific encoding? e.g. fr_CA.UTF-8

Cheers,
Chris
--
http://rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Sockets: Receiving C Struct

2011-08-05 Thread Johnny Venter
New to python and would like to test network/sockets with it.

I am having a problem where I have setup the following:

import socket, sys, struct

HOST = '1.1.1.1'
PORT = 153
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

data = struct.unpack('!I',s.recv(4))[0]

s.close()

print data


What I would like to do is take the input from the server, and store it in an 
array.  The type of data is int.

Can someone help?


Thanks, Johnny



PGP.sig
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Get the name of a function

2011-08-05 Thread Grant Edwards
On 2011-08-05, gervaz ger...@gmail.com wrote:

 Hi all, is there a way to retrive the function name like with
 self.__class__.__name__?

Not really.  There may not be any such thing as the function name. A
function may have zero names, it may have a dozen names.  It may have
names but only in namespaces that aren't accessible.

This question comes up at least once a month, so look back through the
group for threads about finding an object's name, finding a
parameter's name, etc.

Here's a nice article on introspection, but what it talks about as a
function name probably isn't what you're interested in:

  http://www.ibm.com/developerworks/library/l-pyint/index.html

Here's a stack-overflow question similar to yours:

  
http://stackoverflow.com/questions/1538342/how-can-i-get-the-name-of-an-object-in-python

-- 
Grant Edwards   grant.b.edwardsYow! But they went to MARS
  at   around 1953!!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Observations on the three pillars of Python execution

2011-08-05 Thread Eric Snow
On Fri, Aug 5, 2011 at 11:29 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Eric Snow wrote:

 On Fri, Aug 5, 2011 at 8:36 AM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 Eric Snow wrote:

 In Python, three types of objects have special syntax and mechanics
 for their instantiation, during which a code object is generated:
 modules, classes, and functions.

 I believe you are labouring under a misapprehension. Modules and classes
 don't generate code objects.

 Sorry for any confusion.  I was talking specifically about the their
 instantiation through their respective special syntax.  During that
 process a code object is generated for each.


 Do you believe that this process of generating a code object and throwing it
 away is a part of the Python language specification, which any compiler
 must do in order to call itself Python, or a mere implementation detail?

That's a great point which I hadn't considered.  Honestly, I only used
my experience with CPython in making these observations.  After
reviewing the language reference I see that I missed out on a bunch of
nomenclature that would have made things more clear, and I got a few
points wrong, which you pointed out.  :)

Regarding code objects and classes, your are right.  The language
reference indicates the following:

The class’s suite is then executed in a new execution frame...When
the class’s suite finishes execution, its execution frame is discarded
but its local namespace is saved. [1]

So the use of code objects for execution is an implementation detail.
Instead of code object I should have referred to the code executed
in the execution frame or just to the frame.  Incidently, I had not
realized that the builtin __build_class__() is also an implementation
detail[3].

For modules, the language reference doesn't say anything about how
execution is accomplished, which only matters when execution is
involved in the creation of the module object.  It does refer to
importlib as a reference implementation[4].  The order-of-operations
observations I made are based on that reference implementation.


 Is this documented somewhere? If it is not documented, what makes you think
 that it happens at all? You are writing as if it were self-evidently true,
 but I don't believe it is self-evident at all. I think you need to
 demonstrate the truth of two of those three pillars, not just take them for
 granted.


 For classes and modules
 the code object is executed and then discarded.  I covered this
 explicitly in one of the observations.

 I think your definition of explicitly and mine differ here.


 Agreed that [non-builtin] functions are the only objects that have a
 code object attribute.  However, they are not the only objects for
 which a code object is generated and executed.

 Are you talking about the fact that importing a module, class statements and
 function statements all involve executing a block of code?

 How does that differ from executing any other fragment of code?

The difference is that modules, classes, and functions (really the
function body) are code blocks tied to syntax that results in module,
type, and function objects.  There are other code blocks but none of
them have a unique syntax, much less one that results in an object of
the corresponding type[5].  This is relevant for trying to find the
object that corresponds to an execution frame, which is what led me to
my original post and drove the direction of the observations I made.

Anyway, I appreciate the feedback!  I'm going to have to revisit my
observations with the language definition in hand.  You've been really
insightful, as usual.

-eric


[1] http://docs.python.org/dev/reference/compound_stmts.html#class-definitions
[2] http://docs.python.org/dev/reference/datamodel.html#metaclasses
[3] http://mail.python.org/pipermail/python-3000/2007-March/006338.html
[4] http://docs.python.org/dev/reference/simple_stmts.html#the-import-statement
[5] http://docs.python.org/dev/reference/executionmodel.html#naming



 Modules are special, of course, because they can get compiled to byte-code,
 but I trust you're not talking about .pyc files.



 --
 Steven

 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: geany-pyflakes 1.0

2011-08-05 Thread Filip Gruszczyński
 OK - it no longer crashes, but it doesn't appear to do anything.  Is there
 something further I need to do to configure it?  The Pyflakes tab does
 appear in the message window and I've created a new testpyflakes.py with
 code similar to your example.

OK, so there must be something wrong. Do you have pyflakes installed?
Where are they installed?

 Also, just FYI, the plugin manager now shows the version as 1.0.1 while the
 tar file name indicates 1.0.2.

Yeah, I should make a configure file with version and use it in c
code, to never make that mistake again, but I really, really don't
wanto to touch autotools again.

-- 
Filip Gruszczyński
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Table Driven GUI Definition?

2011-08-05 Thread Tim Daneliuk

On 8/5/2011 3:42 PM, Philip Semanchuk wrote:


On Aug 5, 2011, at 4:10 PM, Tim Daneliuk wrote:


On 8/5/2011 2:05 PM, Irmen de Jong said this:

On 05-08-11 19:53, Tim Daneliuk wrote:

I have a task where I want to create pretty simple one page visual
interfaces (Graphical or Text, but it needs to run across Windows,
Cygwin, Linux,*BSD, OSX ...).  These interfaces are nothing more
than option checklists and text fields.  Conceptually something like:

 Please Select Your Installation Options:

Windows Compatibility Services  _
Linux Compatibility Services_
TRS-DOS Compatibility Services  _

What Is Your email Address: ___

What I'm looking for is a way to describe such forms in a text
file that can then be fed into a tool to generate the necessary
pyGUI, Tkinter, (or whatever) code.   The idea is that it should
be simple to generate a basic interface like this and have it
only record the user's input.  Thereafter, the python code
would act on the basis of those selection without any further
connection to the GUI.

An added bonus would be a similar kind of thing for generating
web interfaces to do this.  This might actually be a better model
because then I only have to worry about a single presentation
environment.

Ideas anyone?


Hi Tim
This looks pretty straightforward to me; maybe I'm missing something. It 
doesn't look trivial, but the steps seem pretty clear. Is there some part in 
particular that's giving you trouble?

Cheers
Philip



I want to take a text definition file that looks something this:

  Title Please Select Your Installation Options:


  Checkbox  Windows Compatibility Services
  Checkbox  Linux Compatibility Services
  Checkbox  TRS-DOS Compatibility Services

  Inputbox   What Is Your email Address:


And have that aut-generate the GUI interface described above for the
selected GUI toolkit and/or an equivalent HTML page.

I know I can write a program to do this, but it seems that someone else
may have already solved this problem.

Appearance isn't terribly important.  I want a Quick-And-Dirty configuration
manager interface (for configuring new operating system VMs).  The reason
that I want a simple text file definition is to make it easy to add new
options to the display as they become available.  For example, suppose
it becomes possible to work with a new OS, then all I'd have to do is
add the following to the text definition file, and regenerate the interface:

  Checkbox  MVS Compatibility Services

The idea is to not have to touch the code base as the options of the GUI
evolve, but rather to modify the data file that describes it.  In some sense,
this is a variation of HTML templating except I want to do it (potentially)
with a thick client GUI.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Table Driven GUI Definition?

2011-08-05 Thread Philip Semanchuk

On Aug 5, 2011, at 6:20 PM, Tim Daneliuk wrote:

 On 8/5/2011 3:42 PM, Philip Semanchuk wrote:
 
 On Aug 5, 2011, at 4:10 PM, Tim Daneliuk wrote:
 
 On 8/5/2011 2:05 PM, Irmen de Jong said this:
 On 05-08-11 19:53, Tim Daneliuk wrote:
 I have a task where I want to create pretty simple one page visual
 interfaces (Graphical or Text, but it needs to run across Windows,
 Cygwin, Linux,*BSD, OSX ...).  These interfaces are nothing more
 than option checklists and text fields.  Conceptually something like:
 
 Please Select Your Installation Options:
 
Windows Compatibility Services  _
Linux Compatibility Services_
TRS-DOS Compatibility Services  _
 
What Is Your email Address: ___
 
 What I'm looking for is a way to describe such forms in a text
 file that can then be fed into a tool to generate the necessary
 pyGUI, Tkinter, (or whatever) code.   The idea is that it should
 be simple to generate a basic interface like this and have it
 only record the user's input.  Thereafter, the python code
 would act on the basis of those selection without any further
 connection to the GUI.
 
 An added bonus would be a similar kind of thing for generating
 web interfaces to do this.  This might actually be a better model
 because then I only have to worry about a single presentation
 environment.
 
 Ideas anyone?
 
 Hi Tim
 This looks pretty straightforward to me; maybe I'm missing something. It 
 doesn't look trivial, but the steps seem pretty clear. Is there some part in 
 particular that's giving you trouble?
 
 Cheers
 Philip
 
 
 I want to take a text definition file that looks something this:
 
  Title Please Select Your Installation Options:
 
 
  Checkbox  Windows Compatibility Services
  Checkbox  Linux Compatibility Services
  Checkbox  TRS-DOS Compatibility Services
 
  Inputbox   What Is Your email Address:
 
 
 And have that aut-generate the GUI interface described above for the
 selected GUI toolkit and/or an equivalent HTML page.
 
 I know I can write a program to do this, but it seems that someone else
 may have already solved this problem.

Oh, I see. I didn't realize you were looking for a most canned solution. I 
agree that it's a problem that's been solved many times.

I've used Mako before as an HTML templating engine, but ISTR that it points out 
that it's agnostic to what it's templating. In other words, it only cares about 
what's between the Mako escape tags, it doesn't care if the surrounding text is 
HTML or XML or Python or whatever. 

So you could have a Mako template that consists mostly of Python code that 
builds a wxPython window (if wxPython is your cup of tea) and then some Mako 
commands in the middle that reads your text definition file and adds 
checkboxes, textboxes, etc. as appropriate. It's not a canned solution, but it 
does allow you to separate the boilerplate stuff from the variants.

Hope this helps
Philip

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about encoding, I need a clue ...

2011-08-05 Thread Vlastimil Brom
2011/8/5 Geoff Wright geoffwright...@gmail.com:
 Hi,

 I use Mac OSX for development but deploy on a Linux server.  (Platform 
 details provided below).

 When the locale is set to FR_CA, I am not able to display a u circumflex 
 consistently across the two machines even though the default encoding is set 
 to ascii on both machines.  ...


 --
 http://mail.python.org/mailman/listinfo/python-list


Hi,
I believe, sys.getdefaultencoding() isn't relevant here;
you could try to determine the locale encoding via locale.getlocale()
- it should return a tuple with language code and the encoding name
http://docs.python.org/library/locale.html#locale.getlocale
I suppose, you get the respective encodings on both of your different systems.

I somehow can't find the Canadian locale on my OS (win XP, Czech), but
hopefully the results are equivalent with French, I checked: cf

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit
(Intel)] on win32
Type copyright, credits or license() for more information.
 import locale
 import calendar
 locale.setlocale(locale.LC_ALL,'French')
'French_France.1252'
 locale.getlocale()
('fr_FR', 'cp1252')
 calendar.month_name[8]
'ao\xfbt'
 print calendar.month_name[8]
aoűt
 unicode(calendar.month_name[8], locale.getlocale()[1])
u'ao\xfbt'
 print unicode(calendar.month_name[8], locale.getlocale()[1])
août




The above are the results in Idle and wx pyshell, i.e. unicode-enabled
shells; on non-unicode cmd shell in windows I get:
 print calendar.month_name[8]
aout

and even:
 print unicode(calendar.month_name[8], locale.getlocale()[1])
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\Python27\lib\encodings\cp852.py, line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\xfb' in position 2
: character maps to undefined


hth,
   vbr
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Table Driven GUI Definition?

2011-08-05 Thread Tim Daneliuk

On 8/5/2011 5:51 PM, Philip Semanchuk wrote:


On Aug 5, 2011, at 6:20 PM, Tim Daneliuk wrote:


On 8/5/2011 3:42 PM, Philip Semanchuk wrote:


On Aug 5, 2011, at 4:10 PM, Tim Daneliuk wrote:


On 8/5/2011 2:05 PM, Irmen de Jong said this:

On 05-08-11 19:53, Tim Daneliuk wrote:

I have a task where I want to create pretty simple one page visual
interfaces (Graphical or Text, but it needs to run across Windows,
Cygwin, Linux,*BSD, OSX ...).  These interfaces are nothing more
than option checklists and text fields.  Conceptually something like:

 Please Select Your Installation Options:

Windows Compatibility Services  _
Linux Compatibility Services_
TRS-DOS Compatibility Services  _

What Is Your email Address: ___

What I'm looking for is a way to describe such forms in a text
file that can then be fed into a tool to generate the necessary
pyGUI, Tkinter, (or whatever) code.   The idea is that it should
be simple to generate a basic interface like this and have it
only record the user's input.  Thereafter, the python code
would act on the basis of those selection without any further
connection to the GUI.

An added bonus would be a similar kind of thing for generating
web interfaces to do this.  This might actually be a better model
because then I only have to worry about a single presentation
environment.

Ideas anyone?


Hi Tim
This looks pretty straightforward to me; maybe I'm missing something. It 
doesn't look trivial, but the steps seem pretty clear. Is there some part in 
particular that's giving you trouble?

Cheers
Philip



I want to take a text definition file that looks something this:

  Title Please Select Your Installation Options:


  Checkbox  Windows Compatibility Services
  Checkbox  Linux Compatibility Services
  Checkbox  TRS-DOS Compatibility Services

  Inputbox   What Is Your email Address:


And have that aut-generate the GUI interface described above for the
selected GUI toolkit and/or an equivalent HTML page.

I know I can write a program to do this, but it seems that someone else
may have already solved this problem.


Oh, I see. I didn't realize you were looking for a most canned solution. I 
agree that it's a problem that's been solved many times.

I've used Mako before as an HTML templating engine, but ISTR that it points out 
that it's agnostic to what it's templating. In other words, it only cares about 
what's between the Mako escape tags, it doesn't care if the surrounding text is 
HTML or XML or Python or whatever.

So you could have a Mako template that consists mostly of Python code that 
builds a wxPython window (if wxPython is your cup of tea) and then some Mako 
commands in the middle that reads your text definition file and adds 
checkboxes, textboxes, etc. as appropriate. It's not a canned solution, but it 
does allow you to separate the boilerplate stuff from the variants.

Hope this helps
Philip



Something like this is more what I had in mind (but this seems to
not be actively supported):

http://pythoncard.sourceforge.net/documentation.html

--
http://mail.python.org/mailman/listinfo/python-list


Re: Replace all references to one object with references to other

2011-08-05 Thread Steven D'Aprano
Jack Bates wrote:

 I have two objects, and I want to replace all references to the first
 object - everywhere - with references to the second object. What can I
 try?

Another way of solving your *actual* problem.

Replace all references to object1 with object2 instead is a means to an
end, not the end itself. What are you trying to solve? Focus on *that*
problem, not your supposed solution, because replace all... is doomed to
fail.

There is no master list of objects available to you. All you have is one
or more namespaces containing objects. Many of those objects themselves
will contain other objects, and so on. All you can do is walk through each
namespace in turn, recursively into each object, searching for the object
you want to replace. But that may not help you, because there's no
guarantee that having found it you can replace it safely, *or at all*.

While Python does allow code to reach deeply into the internals of a wide
range of objects -- very little is truly private in Python -- do you
*really* want to be taking responsibility for safely replacing objects from
within arbitrary other objects? If so, Python gives you the tools to shoot
yourself in the foot, although it won't necessarily be easy, or pretty, or
fast.

So, tell us what your real problem is, the end towards which you
think replace all... is the solution, and we'll see if we can help.

-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inconsistent SMTP/Gmail connection drop

2011-08-05 Thread BJ Swope
The best tool to debug this is tcpdump.

Running a packet capture whilst sending the mail will most likely shed the
most light on the subject.


--
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Complex sort on big files

2011-08-05 Thread sturlamolden
On Aug 1, 5:33 pm, aliman aliman...@googlemail.com wrote:

 I understand that sorts are stable, so I could just repeat the whole
 sort process once for each key in turn, but that would involve going
 to and from disk once for each step in the sort, and I'm wondering if
 there is a better way.

I would consider using memory mapping the file and sorting it inline.
Sorting a binary file of bytes with NumPy is as easy as this:

import numpy as np
f = np.memmap(filename, mode='rwb', dtype=np.uint8)
f.sort(kind='quicksort')
del f

(You can define dtype for any C data type or struct.)

If the file is really big, use 64-bit Python.

With memory mapping you don't have to worry about processing the file
in chunks, because the operating
systems will take care of those details.

I am not sure how to achieve this (inline file sort) with standard
library mmap and timsort, so I'll leave that out.


Sturla
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Observations on the three pillars of Python execution

2011-08-05 Thread Steven D'Aprano
Mel wrote:

 Steven D'Aprano wrote:
 
 There may be some other obscure built-in type that includes code objects,
 but I can't imagine what it would be. I feel confident in saying that
 functions, and functions alone, contain code. Even methods are just
 wrappers around functions. Even built-in functions like len don't contain
 code! (Or at least, their code isn't accessible from Python.) Which makes
 sense, if you think about it: their code is part of the Python virtual
 machine, not the object.
 
 Interesting question.  Iterators seem to have code objects:
[...]

Generators. But nice catch, thank you!

Iterators are *any* object which obeys the iterator protocol, that is, have
a next() method and an __iter__() method which behave in the expected way.
Iterators are a duck-type. Generators, whether created from a generator
expression or a generator function, are an actual type.

 type(x for x in (1,2))
class 'generator'


-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Observations on the three pillars of Python execution

2011-08-05 Thread Steven D'Aprano
Eric Snow wrote:

 On Fri, Aug 5, 2011 at 11:29 AM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
[...]
 Do you believe that this process of generating a code object and throwing
 it away is a part of the Python language specification, which any
 compiler must do in order to call itself Python, or a mere
 implementation detail?
 
 That's a great point which I hadn't considered.  Honestly, I only used
 my experience with CPython in making these observations.  After
 reviewing the language reference I see that I missed out on a bunch of
 nomenclature that would have made things more clear, and I got a few
 points wrong, which you pointed out.  :)
 
 Regarding code objects and classes, your are right.  The language
 reference indicates the following:
 
 The class’s suite is then executed in a new execution frame...When
 the class’s suite finishes execution, its execution frame is discarded
 but its local namespace is saved. [1]


It turns out that in CPython 2.5 at least, I'm strictly wrong and you got it
right, at least for classes:

 code = compile(class K: pass, '', 'exec')
 dis.dis(code)
  1   0 LOAD_CONST   0 ('K')
  3 LOAD_CONST   3 (())
  6 LOAD_CONST   1 (code object K at 0xb7e8ad10,
file , line 1)
  9 MAKE_FUNCTION0
 12 CALL_FUNCTION0
 15 BUILD_CLASS
 16 STORE_NAME   0 (K)
 19 LOAD_CONST   2 (None)
 22 RETURN_VALUE


So a code object is compiled, turned into a function, executed, the results
turned into a class, and the code object and function thrown away.

Is this an implementation detail? I would say so. The semantics of Python
the language are different from the details of it's virtual machine. Surely
we would be allowed to call something Python if it executed the body of the
class statement *without* creating a code object first? The important part
is *execute the body of the class statement*, not building the code object.
The later is merely a means to an end.


 So the use of code objects for execution is an implementation detail.
 Instead of code object I should have referred to the code executed
 in the execution frame or just to the frame.

Unless you really intend to talk about implementation details, I think you
should keep the discussion as high-level as possible. I'd talk about
executing blocks of code, and not even mention execution frames unless you
need to understand the role of frames during execution.


-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Complex sort on big files

2011-08-05 Thread Roy Smith
Wow.

I was going to suggest using the unix command-line sort utility via 
popen() or subprocess.  My arguments were that it's written in C, has 30 
years of optimizing in it, etc, etc, etc.  It almost certainly has to be 
faster than anything you could do in Python.

Then I tried the experiment.  I generated a file of 1 million random 
integers in the range 0 to 5000.  I wrote a little sorting program:

numbers = [int(line) for line in open('numbers')]
numbers.sort()
for i in numbers:
print i

and ran it on my MacBook Pro (8 Gig, 2 x 2.4 GHz cores), Python 2.6.1.

$ time ./sort.py   py-sort
real  0m2.706s
user  0m2.491s
sys   0m0.057s

and did the same with the unix utility:

$ time sort -n numbers   cli-sort
real  0m5.123s
user  0m4.745s
sys   0m0.063s

Python took just about half the time.  Certainly knocked my socks off.  
Hard to believe, actually.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Complex sort on big files

2011-08-05 Thread Dan Stromberg
Yup.  Timsort is described as supernatural, and I'm inclined to believe
it.

On Fri, Aug 5, 2011 at 7:54 PM, Roy Smith r...@panix.com wrote:

 Wow.



 Python took just about half the time.  Certainly knocked my socks off.
 Hard to believe, actually.
 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inconsistent SMTP/Gmail connection drop

2011-08-05 Thread Dan Stromberg
Well, a sniffer is one of many, and one worth mentioning.  Though I'd
recommend wireshark over tcpdump, pretty much any day.

http://stromberg.dnsalias.org/~dstromberg/Problem-solving-on-unix-linux-systems.html

On Fri, Aug 5, 2011 at 6:29 PM, BJ Swope bigbluesw...@gmail.com wrote:

 The best tool to debug this is tcpdump.

 Running a packet capture whilst sending the mail will most likely shed the
 most light on the subject.


 --






 --
 http://mail.python.org/mailman/listinfo/python-list


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about encoding, I need a clue ...

2011-08-05 Thread Steven D'Aprano
Geoff Wright wrote:

 Hi,
 
 I use Mac OSX for development but deploy on a Linux server.  (Platform
 details provided below).
 
 When the locale is set to FR_CA, I am not able to display a u circumflex
 consistently across the two machines even though the default encoding is
 set to ascii on both machines.

As somebody else already pointed out, û (u circumflex) is not an ASCII
character, so why would you expect to be able to use it with the ASCII
encoding?

Essential reading:

http://www.joelonsoftware.com/articles/Unicode.html

Drop everything and go read that!

Using Python 2.x, so-called strings are byte strings, which complicates
matters greatly. The month name you get:

'ao\xc3\xbbt'

is a string of five bytes with hex values:

x61 x6f xc3 xbb x74

Depending on how your terminal is set up, that MAY be interpreted as the
characters a o û t but you could end up with anything:

 print s
ao羶t

(In theory, even the a, o and t could change, but I haven't found any
terminal settings *that* wacky.)


 Specifically, calendar.month_name[8] 
 returns a ? (question mark) on the Linux server whereas it displays
 properly on the Mac OSX system.

That could mean either:

(1) the terminal on the Linux server is set to a different default encoding
from that on the Mac; or

(2) the two terminals have the same encoding, but the font used on the Linux
server doesn't include the right glyph to display û.

Of the two, I expect (1) is more likely.

The solution is to avoid relying on lucky accidents of the terminal
encoding, and deal with this the right way. The right way is nearly always
to use UTF-8 everywhere you can, not Latin 1. Make sure your terminal is
set to use UTF-8 as well (I believe this is the default for Mac OS's
terminal app, but I have no idea about the many different Linux terminals).
Then:

 bytes = 'ao\xc3\xbbt'  # From calendar.month_name[8] 
 s = bytes.decode('utf-8')  # Like unicode(bytes, 'utf-8')
 s
u'ao\xfbt'
 print s
août


Provided your Linux server terminal also is set to use UTF-8, this should
just work.




-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Complex sort on big files

2011-08-05 Thread Steven D'Aprano
Roy Smith wrote:

 Wow.
 
 I was going to suggest using the unix command-line sort utility via
 popen() or subprocess.  My arguments were that it's written in C, has 30
 years of optimizing in it, etc, etc, etc.  It almost certainly has to be
 faster than anything you could do in Python.
 
 Then I tried the experiment.  I generated a file of 1 million random
 integers in the range 0 to 5000.  I wrote a little sorting program:
[...]
 Python took just about half the time.  Certainly knocked my socks off.
 Hard to believe, actually.

One million integers isn't very big. If each integer can fit in four-byte
long, that's less than 4MB. That's almost small enough to fit in your CPU's
cache, with room left over for the first few chapters of War And Peace
*wink*

So you're comparing Python's timsort, which is Awesome with a capital AWE
but only works on data that fits in memory, versus something which can also
work on files too big to fit into memory.

Try generating a twenty gigabyte file of data, and sort that. Actually,
don't, because just *reading it in* to Python will probably fail, and very
possibly lock your PC up for the duration.

Unix sort does an external R-Way merge sort: if you have more data than
memory, it slices the data up into a bunch of smaller pieces, each of which
will fit in memory, sorts each one to a temporary file, then merges the
lot. It does a lot more work on such big files, because it *takes* a lot
more work.

For something as small as one million numbers, chances are the Unix sort
falls back on a heapsort or a quicksort, which will be pretty fast, but it
ain't no timsort.

So yes, Python's timsort is awesome, but so is Unix's sort, just in
different ways.



-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: JSON Strict Mode

2011-08-05 Thread Chris Rebert
 On Fri, Aug 5, 2011 at 2:19 AM, Chris Rebert c...@rebertia.com wrote:
 On Thu, Aug 4, 2011 at 8:25 PM, John Riselvato jdriselv...@gmail.com
 wrote:
  I am working on a license verification script. I am rather new to the
  concept and to JSON files in general.
snip
  This is what my pseudocode looks like:
 
  licenses = meta['license']
  for x in licenses:
      if licenses[x]['terms'] is not valid opensource license

 I would probably instead write that as:

 for license_name, license in licenses.items():
    if not is_open_source(license['terms']):
 # rest same as before

          if in strict mode
              raise nonfree exception
 
  How would i go about checking if its in strict mode
snip
  and what does raise nonfree exception mean?
snip
 In your specific example, the non-pseudo-code would look something like:

 # a declaration somewhere:
 class NonFreeLicenseError(ValueError):
    License is not free according to the Open Source Definition.

 # ... back in the part of your code corresponding to your pseudocode:
 if strict:
    raise NonFreeLicenseError(The '%s' license is nonfree and thus
 impermissible. % x)

 As written, I have NonFreeLicenseError as a kind of ValueError. This
 may or may not be appropriate depending on your program; a list of
 built-in types of exceptions can be found at
 http://docs.python.org/dev/library/exceptions.html#bltin-exceptions

On Fri, Aug 5, 2011 at 3:44 PM, John Riselvato jdriselv...@gmail.com wrote:
 Thanks for this mate.I took what you said and made this.

         licenseCheck = Syn.policy.metafile.LICENSE_CLEAN
         licenses = meta['license']
         for i in licenses:
                 if licenses[i]['terms'] in licenseCheck == False:

More conventionally written:
if licenses[i]['terms'] not in licenseCheck:

For that matter, I would rename `licenseCheck` to something clearer
like `acceptableLicenses`.

                         try:
                                 raise Exception(licenses[i]['terms'])
                         except Exception as inst:
                                 errors = errors + 1
                                 Syn.log.l(Syn.log.CRITICAL, Doesn't meet
 License requirement!!!)
                                 Syn.log.l(Syn.log.CRITICAL, License %s
 is **NOT** marked as clean!! % license[i]['terms'])

It's pretty pointless to catch the exception right after you raise it
like this. Exceptions are intended to communicate the error to the
caller, which you're not doing here, so they may not be necessary.
Also, one typically raises a more specific exception than just
Exception, which is the most general and vague exception possible; see
my prior post for an example of using a custom exception class.

 the licenseCheck main infromation you need to know is:

 LICENSE_CLEAN = [
 GPL,
 GPL-1,
 GPL-2,
 GPL-3,
 X11,
 MIT,
 PSFL-2
 ]

If you have a recent version of Python, I'd recommend using a set instead:

LICENSE_CLEAN = set([
GPL,
GPL-1,
# etc...
])

This is more conceptually accurate and should be faster too.

 The JSON file information is set up practically like this:

 license : {
 * : {
terms  : GPL-3,
author : Joe Shmo, et. al
}
 }

 Is what i programmed close to what I was trying to explain?

More or less. If * is the only entry in license, then the for-loop
is unnecessary and you can just use reference licenses['*']['terms']
(and similar) directly; one would need a specification of the your
data format (or at least more examples) to be sure. And your use of
exceptions doesn't really match the pseudocode, although your
underlying logic is entirely reasonable, even moreso if you were to
not use exceptions.

Cheers,
Chris
--
http://rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue12540] Restart Shell command leaves pythonw.exe processes running

2011-08-05 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset cc86f4ca5020 by Ned Deily in branch '3.2':
Issue #12540: Prevent zombie IDLE processes on Windows due to changes
http://hg.python.org/cpython/rev/cc86f4ca5020

New changeset c2fd1ce1c6d4 by Ned Deily in branch 'default':
Issue #12540: Prevent zombie IDLE processes on Windows due to changes
http://hg.python.org/cpython/rev/c2fd1ce1c6d4

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12540
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12540] Restart Shell command leaves pythonw.exe processes running

2011-08-05 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

With Eli's concurrence, I have applied the updated patch to 3.2 (for 3.2.2) and 
to default (for 3.3).

--
assignee:  - ned.deily
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12540
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12692] test_urllib2net is triggering a ResourceWarning

2011-08-05 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

Relevant: http://mail.python.org/pipermail/python-dev/2011-July/112551.html

--
nosy: +nadeem.vawda

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12692
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12692] test_urllib2net is triggering a ResourceWarning

2011-08-05 Thread Nadeem Vawda

Changes by Nadeem Vawda nadeem.va...@gmail.com:


--
versions: +Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12692
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12694] crlf.py script from Tools doesn't work with Python 3.2

2011-08-05 Thread Alexander Belchenko

New submission from Alexander Belchenko bia...@ukr.net:

Attempt to use crlf.py script from standard windows install always fail with 
traceback:

C:\Python32\Tools\ScriptsC:\Python32\python.exe crlf.py 2to3.py
Traceback (most recent call last):
  File crlf.py, line 23, in module
main()
  File crlf.py, line 12, in main
if '\0' in data:
TypeError: Type str doesn't support the buffer API

C:\Python32\Tools\ScriptsC:\Python32\python.exe -V
Python 3.2

--
messages: 141650
nosy: bialix
priority: normal
severity: normal
status: open
title: crlf.py script from Tools doesn't work with Python 3.2
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12694
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12326] Linux 3: code should avoid using sys.platform == 'linux2'

2011-08-05 Thread Martin von Gagern

Changes by Martin von Gagern martin.vgag...@gmx.net:


--
nosy: +gagern

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12326
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12326] Linux 3: code should avoid using sys.platform == 'linux2'

2011-08-05 Thread Sandro Tosi

Sandro Tosi sandro.t...@gmail.com added the comment:

On Mon, Jul 25, 2011 at 13:50, Éric Araujo rep...@bugs.python.org wrote:
 Éric Araujo mer...@netwok.org added the comment:

 FTR, for Debian and derivatives, doko chose to use 'linux2' when building on 
 linux3.

Luckily that has just been reverted.

--
nosy: +sandro.tosi

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12326
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12680] cPickle.loads is not thread safe due to non-thread-safe imports

2011-08-05 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 PyImport_ExecCodeModuleEx adds the module to sys.modules *before*
 actually executing the code. This is a design flaw (can it really be
 changed? )

I guess it is done so to allow for circular imports.

 The second bug: in cPickle.c: func_class() 
 cPickle 'manually' checks if a module is in sys.modules instead of
 letting the import mechanism do it for him (hence breaking the import
 lock's defense here).

I would guess it is an optimization shortcut. A solution (while keeping the 
optimization) would be to take the import lock before checking sys.modules.

Note that the _pickle module in 3.x has the same kind of logic, and therefore 
probably the same issue too (haven't tested).

--
nosy: +pitrou
versions: +Python 3.2, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12680
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12695] subprocess.Popen: OSError: [Errno 9] Bad file descriptor

2011-08-05 Thread Martin von Gagern

New submission from Martin von Gagern martin.vgag...@gmx.net:

suprocess.Popen on POSIX (using _posixsubprocess Module) has a good chance of 
repeatedly closing the same file descriptor if the descriptor for stdin is also 
used for stdout and/or stderr. Only stdout and stderr are checked for equality 
with one another.

This breaks webbrowser.open for me, as the browser remote has all three 
descriptors redirected from/to /dev/null. This breaks pydoc -p. I've taken 
this scenario and turned it into a unit test, which you find attached together 
with a proposed fix.

On my currently installed Python 3.2, the unit tests results in this traceback 
(and two more like it for other test classes):

ERROR: test_inouterr_fileobj (__main__.ProcessTestCase)
--
Traceback (most recent call last):
  File Lib/test/test_subprocess.py, line 630, in test_inouterr_fileobj
stderr = devnull)
  File /usr/lib64/python3.2/subprocess.py, line 736, in __init__
restore_signals, start_new_session)
  File /usr/lib64/python3.2/subprocess.py, line 1330, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 9] Bad file descriptor

--
components: Library (Lib)
files: subprocess.patch
keywords: patch
messages: 141653
nosy: gagern
priority: normal
severity: normal
status: open
title: subprocess.Popen: OSError: [Errno 9] Bad file descriptor
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file22836/subprocess.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12695
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12695] subprocess.Popen: OSError: [Errno 9] Bad file descriptor

2011-08-05 Thread Martin von Gagern

Martin von Gagern martin.vgag...@gmx.net added the comment:

Sorry, this is a duplicate of issue #11432. Failed to find that, and also 
failed to realize that python is now using hg and my svn checkout might be 
outdated. Sorry there.

--
resolution:  - duplicate
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12695
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12693] test.support.transient_internet prints to stderr when verbose is false

2011-08-05 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

I'm pretty sure this was intentional.  It is analogous to Skip messages and the 
messages issued when a resource hasn't been enabled, which also print when 
verbose is not true: the test wasn't run, and it lets you know why.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12693
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12032] Tools/Scripts/crlf.py needs updating for python 3+

2011-08-05 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
title: Tools/Scripts/crlv.py needs updating for python 3+ - 
Tools/Scripts/crlf.py needs updating for python 3+
type: crash - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12694] crlf.py script from Tools doesn't work with Python 3.2

2011-08-05 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
resolution:  - duplicate
stage:  - committed/rejected
superseder:  - Tools/Scripts/crlf.py needs updating for python 3+

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12694
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12540] Restart Shell command leaves pythonw.exe processes running

2011-08-05 Thread Eli Bendersky

Eli Bendersky eli...@gmail.com added the comment:

On Fri, Aug 5, 2011 at 09:43, Ned Deily rep...@bugs.python.org wrote:


 Ned Deily n...@acm.org added the comment:

 With Eli's concurrence, I have applied the updated patch to 3.2 (for 3.2.2)
 and to default (for 3.3).

 --


Tested this on Windows XP with Python 3.2 installed into Program Files.
Works fine (including shell restart).

It would be great to get more people to test it though, especially people
who ran into the problem originally - Peter? Terry? Anish? Qiang Sun?

--
Added file: http://bugs.python.org/file22837/unnamed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12540
___div dir=ltrdiv class=gmail_quoteOn Fri, Aug 5, 2011 at 09:43, Ned Deily 
span dir=ltrlt;a 
href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;/span 
wrote:brblockquote class=gmail_quote style=margin:0 0 0 
.8ex;border-left:1px #ccc solid;padding-left:1ex;

div class=imbr
Ned Deily lt;a href=mailto:n...@acm.org;n...@acm.org/agt; added the 
comment:br
br
/divWith Eli#39;s concurrence, I have applied the updated patch to 3.2 (for 
3.2.2) and to default (for 3.3).br
br
--br/blockquote/divbrTested this on Windows XP with Python 3.2 
installed into quot;Program Filesquot;. Works fine (including shell 
restart).brbrIt would be great to get more people to test it though, 
especially people who ran into the problem originally - Peter? Terry? Anish? 
Qiang Sun?br

brbrbr/div
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10570] curses.tigetstr() returns bytes, but curses.tparm() expects a string

2011-08-05 Thread Tobias Klausmann

Tobias Klausmann klaus...@gentoo.org added the comment:

This bug is still not fixed and basically makes the curses module unusable 
except for very narrow use cases. Unfortunately, my C-fu is very weak, 
otherwise I'd try to make a patch.

--
nosy: +klausman

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10570
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12696] pydoc error page due to lacking permissions on ./*

2011-08-05 Thread Martin von Gagern

New submission from Martin von Gagern martin.vgag...@gmx.net:

I'd like to be able to run pydoc -b in whatever directory I'm currently in. 
Most of the time that would be the root of my home directory, which is an 
ext4fs mount. So it has a subdirectory called lost+found for which I don't 
have any access permissions. As a result, the main pydoc info page will simply 
print an error message:

OSError: [Errno 13] Permission denied: './lost+found'

I'm not sure how best to address this. There are several possibilities that 
come to my mind:

 1. Provide a command line switch to strip '.' from sys.path.
 2. Skip any sys.path elements which cause exceptions, possibly
printing a warning in addition to the remaining page content.
 3. Skip any single subdirectry which causes an exception,
as this more closely models what importing by name would do.
 4. Explicitely skip lost+found, or perhaps any directory name which
would be invalid as a module name.

Obviously, the workaround is to change to a sufficiently empty directory before 
starting pydoc. So this is a minor issue, but annoying nevertheless.

--
components: Library (Lib)
messages: 141658
nosy: gagern
priority: normal
severity: normal
status: open
title: pydoc error page due to lacking permissions on ./*
type: feature request
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12696
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12326] Linux 3: code should avoid using sys.platform == 'linux2'

2011-08-05 Thread James Y Knight

James Y Knight f...@users.sourceforge.net added the comment:

Oh wow, so it depends on the *build* time major version? That's really not 
useful at all for linux 2.x and 3.x; there is nothing useful anyone can 
possibly do with the distinction between platform == linux2 and platform == 
linux3. All it could possibly do is to break apps.

Given that:
a) old versions of Python won't even build without a patch and
b) changing platform to linux3 will break a lot of python apps that check 
sys.platform. 
c) It's completely useless to change it, as the change contains no actual 
information.

Why is forcing sys.platform to remain linux2 not the *obviously right thing to 
do*?

--
nosy: +foom

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12326
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9338] argparse optionals with nargs='+' can't be followed by positionals

2011-08-05 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

There is.  Someone wanting to help could reply to the question I asked :)

--
type: feature request - behavior
versions: +Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9338
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12641] Remove -mno-cygwin from distutils

2011-08-05 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

The necessity of walking on eggs with the distutils codebase restrains me.  
I’ve read the thread on sourceforge (thanks Ruben) but don’t have enough 
information yet to decide whether to do a version check, call gcc -dumpspecs or 
remove the option altogether.

BTW, there’s no need to use re.search if you’re not using a regular expression: 
“'no-cygwin' in output” will work.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12641
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12641] Remove -mno-cygwin from distutils

2011-08-05 Thread Jon

Jon jon.for...@gmail.com added the comment:

shortly after opening this issue i removed -mno-cygwin from my 2.7.2 install 
and have had no issues on win7 32bit. but i understand you're hesitation.

regardless what you decide, please consider placing a summary note in the 
source comments as a safety net.

if you'd like me to try building a limited set of extensions to help with your 
decision, let me know.  i have the following mingw toolchains on my win7 32bit 
system:

* tdm gcc 4.5.2 - http://tdm-gcc.tdragon.net/
* mingw-w64 prefix-stripped gcc 4.5.4 - 
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Automated%20Builds/
* Ruben's gcc 4.6.2 personal build - 
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/4.6.2-1/

i'm not speaking for Ruben, but as he maintains 
https://github.com/rubenvb/MinGW-w64-build-scripts you might try cajoling him 
if you feel you need more test results ;)

re: re.search, understood, thanks...quick-testing.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12641
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12697] timeiot documention still refers to the timeit.py script

2011-08-05 Thread Alexis Metaireau

New submission from Alexis Metaireau ale...@notmyidea.org:

The example section of the timeit documentation still refers to timeit.py, 
and isn't using the python -m timeit syntax used above.
http://docs.python.org/library/timeit.html#examples

I'm not sure when and if the timeit.py script has been removed from the python 
installation (and I'm not sure on where to look for this).

The timeit.py docstring also refers to this old syntax. Should we update it?

All credit for this report goes to Boris Feld.

--
assignee: alexis
components: Library (Lib)
messages: 141663
nosy: alexis
priority: low
severity: normal
status: open
title: timeiot documention still refers to the timeit.py script
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12697
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12697] timeiot documention still refers to the timeit.py script

2011-08-05 Thread Alexis Metaireau

Changes by Alexis Metaireau ale...@notmyidea.org:


--
nosy: +Boris.FELD

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12697
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12698] urllib does not use no_proxy when it has blanks

2011-08-05 Thread jimmi

New submission from jimmi ch...@computersalat.de:

if you define your no_proxy var as mentioned in /etc/sysocnfig/proxy

# Example: NO_PROXY=www.me.de, do.main, localhost

then python's urllib will never make use of it, cause there are blanks.
urllib does not remove blanks.

Reproducible: Always

Steps to Reproduce:
1.try it out

Actual Results:  
proxy will not be bypassed

Expected Results:  
proxy should be bypassed

you can also review this bug:
https://bugzilla.novell.com/show_bug.cgi?id=710736

--
components: Library (Lib)
files: python-2.7-urllib-no_proxy.patch
keywords: patch
messages: 141664
nosy: jimmi.pip.verisignlabs.com.
priority: normal
severity: normal
status: open
title: urllib does not use no_proxy when it has blanks
versions: Python 2.7
Added file: http://bugs.python.org/file22838/python-2.7-urllib-no_proxy.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12698
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12697] timeit documention still refers to the timeit.py script

2011-08-05 Thread Alexis Metaireau

Changes by Alexis Metaireau ale...@notmyidea.org:


--
title: timeiot documention still refers to the timeit.py script - timeit 
documention still refers to the timeit.py script

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12697
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12191] Add shutil.chown to allow to use user and group name (and not only uid/gid)

2011-08-05 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

You should replace the v5 file (or even remove all files, for clarity) with the 
actual output of hg diff, not hg status ;-)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12191
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12662] Add support for duplicate options in configparser

2011-08-05 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Thanks for the report.  Could you tell us more about the use cases?  Are you 
aware of some config files using this form?

--
nosy: +eric.araujo
title: Allow configparser to process suplicate options - Add support for 
duplicate options in configparser

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12662
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12661] Add a new shutil.cleartree function to shutil module

2011-08-05 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

It looks like this new function would just replace a loop using os.walk and 
fnmatch.  Is it really needed?

--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12661
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12666] map semantic change not documented in What's New

2011-08-05 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

(HTTPS repos are not supported)

--
hgrepos: +51
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12666
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12666] map semantic change not documented in What's New

2011-08-05 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Can you provide a public URI?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12666
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12666] map semantic change not documented in What's New

2011-08-05 Thread Jason R. Coombs

Changes by Jason R. Coombs jar...@jaraco.com:


--
keywords: +patch
Added file: http://bugs.python.org/file22839/bc362109eed8.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12666
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >