Re: [Python-ideas] allow line break at operators

2011-09-03 Thread Yingjie Lan
I agree that long lines of code are not very common in many projects, though it 
might be the case with some heavily involved in math. For some reason, when the 
feature of free line breaking came about in computer languages, it is welcomed 
and generally well accepted. Python uses indentation for blocks, and by the 
same mechanism, line breaking can be accommodated without requiring parenthesis 
or ending backslashes.

For the tuning, yes, people would disagree on how to split expressions/code. 
The continue-by-indentation would allow people to break a line in whatever way 
that pleases their aesthetic taste, as long as there is an indentation. Most 
people seems to like an indentation on the continuing lines, probably for a 
visual indication of a continuation line. Some general guidelines may be 
provided, but there is no need for other hard rules on breaking lines, except 
that an identifier should never be split apart.

For the implementation, I don't have much clue. At least on the parser, it 
needs to look beyond the linefeed to determine if a line is completed. If the 
indentation is defined as a single symbol, then it would only require a 
one-step look-ahead, and that should not be hard.

Again, my apology for top posting.



>
>From: Stephen J. Turnbull 
>To: Yingjie Lan 
>Cc: Gabriel AHTUNE ; Matt Joiner ; 
>"python-list@python.org" ; python-ideas 
>
>Sent: Saturday, September 3, 2011 2:10 PM
>Subject: Re: [Python-ideas] allow line break at operators
>
>Yingjie Lan writes:
>
>> Have you considered line continuation by indentation? It seems to
>> meet the design principle. I think it is the most natural way to
>> allow free line breaking in Python.
>
>Briefly, yes, and I think it would need a lot of tuning and probably
>complex rules.  Unlike statements, where everybody (except the judges
>of the Obfuscated C Contest) agrees on a simple rule: "In a control
>structure, the controlled suite should be uniformly indented one
>level", line breaking and indentation of long expressions is an art,
>and people have different opinions on "readability" and "beauty."
>Achieving a compromise that is workable even for a few major styles is
>likely to be annoying and bug-prone.
>
>Pretty much every program I write seems to have a continued list of
>data or a multi-line dictionary display as data.  It's not unusual for
>me to comment the formal arguments in a function definition, or the
>parent classes of a class definition.  The exception for parenthesized
>objects is something I depend on for what I consider good style.  Of
>course I could use explicit continuation, but in a long table that's
>ugly and error-prone.
>
>Long expressions that need to be broken across lines, on the other
>hand, often indication that I haven't thought carefully enough about
>that component of the program, and an extra pair of parentheses or a
>terminal backslash just isn't that "heavy" or ugly in the context of
>such long expressions.  For me, they're also pretty rare; many
>programs I write have no explicit continuations in them at all.
>
>YMMV, of course, but I find the compromise that Python arrived at to
>be very useful, and I must suppose that it was substantially easier to
>implement than "fully free" line breaking (whatever that means to you).
>
>
>-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Detecting Ctrl-Alt-Del in Windows

2011-09-03 Thread Nobody
On Fri, 02 Sep 2011 17:55:41 +1000, Chris Angelico wrote:

>> That's why you have to hit CAD to get to the login form in some versions
>> of Windows. The whole point of that secure sequence is that the OS and
>> only the OS responds.
> 
> Although I heard somewhere that that's more gimmick than guarantee,
> and that it IS possible for an app to hook CAD

It's possible to configure how CAD is handled, but this requires
Administrator privilege, so it's not exploitable (i.e. it doesn't gain you
anything you can't obtain by other means).

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


Re: sqlite3 with context manager

2011-09-03 Thread Carl Banks
On Friday, September 2, 2011 11:43:53 AM UTC-7, Tim Arnold wrote:
> Hi,
> I'm using the 'with' context manager for a sqlite3 connection:
> 
> with sqlite3.connect(my.database,timeout=10) as conn:
>  conn.execute('update config_build set datetime=?,result=?
> where id=?',
>(datetime.datetime.now(), success,
> self.b['id']))
> 
> my question is what happens if the update fails? Shouldn't it throw an
> exception?

If you look at the sqlite3 syntax documentation, you'll see it has a SQL 
extension that allows you to specify error semantics.  It looks something like 
this:

UPDATE OR IGNORE
UPDATE OR FAIL
UPDATE OR ROLLBACK

I'm not sure exactly how this interacts with pysqlite3, but using one of these 
might help it throw exceptions when you want it to.


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


Re: Why doesn't threading.join() return a value?

2011-09-03 Thread Alain Ketterlin
Adam Skutt  writes:

> On Sep 2, 2:23 pm, Alain Ketterlin 
> wrote:
>> Sorry, you're wrong, at least for POSIX threads:
>>
>> void pthread_exit(void *value_ptr);
>> int pthread_join(pthread_t thread, void **value_ptr);
>>
>> pthread_exit can pass anything, and that value will be retrieved with
>> pthread_join.
>
> No, it can only pass a void*, which isn't much better than passing an
> int.

We'll have to disagree. A void* simply can point to anything you want.
Since thread stacks disappear at end of thread, only dynamically
allocated memory can be used to store the result. That's why you get a
pointer. There is no restriction on that pointer provided it doesn't
point to memory that has been deallocated.

> Passing a void* is not equivalent to passing anything, not even in C.
> Moreover, specific values are still reserved, like PTHREAD_CANCELLED.

Thread cancellation is program logic (pthread_cancel), it doesn't mean
you thread crashed, it means your program decided to cancel the thread.
If you still care about the return value after having called
pthread_cancel(), 

> Yes, it was strictly inappropriate for me to say both return solely
> integers, but my error doesn't meaningful alter my description of the
> situation. The interface provided by the underlying APIs is not
> especially usable for arbitrary data transfer.

Again, I may misunderstand your wording, but there is no "data transfer"
at all, since memory is shared between threads.

> Doubly so when we're discussing something like Python's threading
> module.

The OP was clearly discussing the case where a thread has a result, and
how to get it back. POSIX threads let you do that. There are of course
tons of other ways to do the same thing. Win32 will force you to use
some other way.

>> I'm not sure what you are talking about here. Maybe you confuse threads
>> with processes?
>
> Windows threads have exit codes, just like processes.  At least one
> code is reserved and cannot be used by the programmer.

Is that STILL_ACTIVE that we are talking about? That's an artefact of
the design of GetExitCodeThread, which will return either the thread
exit code or its own error code. The python lib could easily hide this,
and use run()'s return value to store the (python) result somewhere.

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


json: python 2.5: error in browser

2011-09-03 Thread Vineet Deodhar
> Any idea on converting list to json in python 2.5?
http://pypi.python.org/pypi/simplejson/
Cheers,
Chris
=
Now I built json from simplejson.
While trying to render the same in browser, nothing is displayed.
Opera Dragonfly shows this error:--
 
Uncaught exception: SyntaxError: JSON.parse: Unable to parse value: A,B,C
Error thrown at line 3, column 0 in http://127.0.0.1:8000/mywheels/test/cat:
    var ctg = JSON.parse(["A", "B", "C"]);

I validated this json --  ["A", "B", "C"]   in jsonlint.com
It is valid json.
 
Why the method "JSON.parse" is unable to parse JSON?
 
--Vineet-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't threading.join() return a value?

2011-09-03 Thread Alain Ketterlin
Alain Ketterlin  writes:

>> Passing a void* is not equivalent to passing anything, not even in C.
>> Moreover, specific values are still reserved, like PTHREAD_CANCELLED.
>
> Thread cancellation is program logic (pthread_cancel), it doesn't mean
> you thread crashed, it means your program decided to cancel the thread.
> If you still care about the return value after having called
> pthread_cancel(), 

Sotry, forgot to end this sentence... What I mean is:

If you still care about the return value after having called
pthread_cancel(), your program logic is unnecessarily complex, and
you should find some other way to handle this case.

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


Re: json: python 2.5: error in browser

2011-09-03 Thread Chris Rebert
On Sat, Sep 3, 2011 at 1:58 AM, Vineet Deodhar  wrote:
> Opera Dragonfly shows this error:--
>
> Uncaught exception: SyntaxError: JSON.parse: Unable to parse value: A,B,C
> Error thrown at line 3, column 0 in http://127.0.0.1:8000/mywheels/test/cat:
>     var ctg = JSON.parse(["A", "B", "C"]);
> 
> I validated this json --  ["A", "B", "C"]   in jsonlint.com
> It is valid json.
>
> Why the method "JSON.parse" is unable to parse JSON?

It takes a *string* containing JSON. You want:
var ctg = JSON.parse('["A", "B", "C"]');// note outer quotes!

Think about it: If you already had ["A", "B", "C"] in the first place,
then you could just do:
var ctg = ["A", "B", "C"];
And JSON would never enter into the discussion.

Your issue is akin to confusing the following two outputs:
Python 2.6.6 (r266:84292, Jan 12 2011, 13:35:00)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 'foo' # expression resulting in the string
'foo'
>>> print 'foo' # contents of the string
foo

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


Re: [Python-ideas] allow line break at operators

2011-09-03 Thread Yingjie Lan
Ambiguity: yes, when the last line of a suite is a continued line, it would 
require double dedentations to end the line and the suite. I noticed a similar 
case in current Python language as well:

==
#BEGIN CODE 1
if condition:
for i in range(5):
triangulate(i)
else: #double dedentations
for body in space:
triangulate(body)
#double dedentations again
log('triangulation done')
#END CODE 1
==



If lines can be continued by indentation, similar situation would rise:

==
#BEGIN CODE 2
if condition:
result = [sin(i) for i in range(5)]
+ [cos(i) for i in range(5)]
else:

result = [cos(i) for i in range(5)]
+ [sin(i) for i in range(5)]

log('triangulation done')
#END CODE 2
==


Generating text example: right, this is a case that can't be handled by 
standard indentation, unless we only consider full dedentation (dedentation to 
the exact level of the initial indentation) as the signal of ending the line. 
Whether to accommodate for such a case might be an issue of debate, but at 
least we can have such 'freedom' :)




>
>From: Stephen J. Turnbull 
>To: Yingjie Lan 
>Cc: Gabriel AHTUNE ; Matt Joiner ; 
>python-ideas 
>Sent: Saturday, September 3, 2011 5:29 PM
>Subject: Re: [Python-ideas] allow line break at operators
>
>Yingjie Lan writes:
>
>> Python uses indentation for blocks, and by the same mechanism, line
>> breaking can be accommodated without requiring parenthesis or
>> ending backslashes.
>
>Possibly, but now you have a problem that a dedent has ambiguous
>meaning.  It might mean that you're ending a suite, or it might mean
>you're ending a continued expression.  This probably can be
>disambiguated, but I don't know how easy that will be to do perfectly,
>including in reporting ill-formed programs.
>
>> Most people seems to like an indentation on the continuing lines,
>
>Most of the time, yes, but sometimes not.  For example, in generating
>text, it's often useful to dedent substantially so you can have a
>nearly normal length line in the literal strings being concatenated.
>Or you might have a pattern like this:
>
>    x = long_named_variable_a
>            - long_named_variable_a_base
>        + long_named_variable_b
>            - long_named_variable_b_base
>
>which your parser would raise an error on, I presume.  That's not
>freedom!
>
>
>
>-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] allow line break at operators

2011-09-03 Thread Yingjie Lan
Oops, the generating text part of my reply is referring to your last code 
example. For literal texts, it is is not governed by this proposal, nor are 
expressions within brackets and backslash continued lines. In a word, this 
proposal is fully backward compatible.



>
>From: Yingjie Lan 
>To: Stephen J. Turnbull 
>Cc: python list ; Gabriel AHTUNE ; 
>python-ideas ; Matt Joiner 
>Sent: Saturday, September 3, 2011 6:33 PM
>Subject: Re: [Python-ideas] allow line break at operators
>
>
>Ambiguity: yes, when the last line of a suite is a continued line, it would 
>require double dedentations to end the line and the suite. I noticed a similar 
>case in current Python language as well:
>
>
>==
>#BEGIN CODE 1
>if condition:
>for i in range(5):
>triangulate(i)
>else: #double dedentations
>for body in space:
>triangulate(body)
>#double dedentations again
>log('triangulation done')
>#END CODE 1
>==
>
>
>
>If lines can be continued by indentation, similar situation would rise:
>
>
>==
>#BEGIN CODE 2
>if condition:
>result = [sin(i) for i in range(5)]
>+ [cos(i) for i in range(5)]
>else:
>
>result = [cos(i) for i in range(5)]
>+ [sin(i) for i in range(5)]
>
>
>log('triangulation done')
>#END CODE 2
>==
>
>
>
>Generating text example: right, this is a case that can't be handled by 
>standard indentation, unless we only consider full dedentation (dedentation to 
>the exact level of the initial indentation) as the signal of ending the line. 
>Whether to accommodate for such a case might be an issue of debate, but at 
>least we can have such 'freedom' :)
>
>
>
>
>
>>
>>From: Stephen J. Turnbull 
>>To: Yingjie Lan 
>>Cc: Gabriel AHTUNE ; Matt Joiner ; 
>>python-ideas 
>>Sent: Saturday, September 3, 2011 5:29 PM
>>Subject: Re: [Python-ideas] allow line break at operators
>>
>>Yingjie Lan writes:
>>
>>> Python uses indentation for blocks, and by the same mechanism, line
>>> breaking can be accommodated without requiring parenthesis or
>>> ending backslashes.
>>
>>Possibly, but now you have a problem that a dedent has ambiguous
>>meaning.  It might mean that you're ending a suite, or it might mean
>>you're ending a continued expression.  This probably can be
>>disambiguated, but I don't know how easy that will be to do
 perfectly,
>>including in reporting ill-formed programs.
>>
>>> Most people seems to like an indentation on the continuing lines,
>>
>>Most of the time, yes, but sometimes not.  For example, in generating
>>text, it's often useful to dedent substantially so you can have a
>>nearly normal length line in the literal strings being concatenated.
>>Or you might have a pattern like this:
>>
>>    x = long_named_variable_a
>>            - long_named_variable_a_base
>>        + long_named_variable_b
>>            - long_named_variable_b_base
>>
>>which your parser would raise an error on, I presume.  That's not
>>freedom!
>>
>>
>>
>>
>-- 
>http://mail.python.org/mailman/listinfo/python-list
>
>
>-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't threading.join() return a value?

2011-09-03 Thread Carl Banks
On Friday, September 2, 2011 11:01:17 AM UTC-7, Adam Skutt wrote:
> On Sep 2, 10:53 am, Roy Smith  wrote:
> > I have a function I want to run in a thread and return a value.  It
> > seems like the most obvious way to do this is to have my target
> > function return the value, the Thread object stash that someplace, and
> > return it as the return value for join().
> > > Yes, I know there's other ways for a thread to return values (pass the
> > target a queue, for example), but making the return value of the
> > target function available would have been the most convenient.  I'm
> > curious why threading wasn't implemented this way.
> 
> I assume it is because the underlying operating system APIs do not
> support it.

Nope.  This could easily be implemented by storing the return value in the 
Thread object.

It's not done that way probably because no one thought of doing it.


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


Re: Why doesn't threading.join() return a value?

2011-09-03 Thread Carl Banks
On Friday, September 2, 2011 11:53:43 AM UTC-7, Adam Skutt wrote:
> On Sep 2, 2:23 pm, Alain Ketterlin 
> wrote:
> > Sorry, you're wrong, at least for POSIX threads:
> >
> > void pthread_exit(void *value_ptr);
> > int pthread_join(pthread_t thread, void **value_ptr);
> >
> > pthread_exit can pass anything, and that value will be retrieved with
> > pthread_join.
> 
> No, it can only pass a void*, which isn't much better than passing an
> int.  Passing a void* is not equivalent to passing anything, not even
> in C.  Moreover, specific values are still reserved, like
> PTHREAD_CANCELLED. Yes, it was strictly inappropriate for me to say
> both return solely integers, but my error doesn't meaningful alter my
> description of the situation.  The interface provided by the
> underlying APIs is not especially usable for arbitrary data transfer.

I'm sorry, but your claim is flat out wrong.  It's very common in C programming 
to use a void* to give a programmer ability to pass arbitrary data through some 
third-party code.

The Python API itself uses void* in this way in several different places.  For 
instance, ake a look at the Capsule API 
(http://docs.python.org/c-api/capsule.html).  You'll notice it uses a void* to 
let a user pass in opaque data.  Another case is when declaring properties in 
C: it's common to define a single get or set function, and only vary some piece 
of data for the different properties.  The API provides a void* so that the 
extension writer can pass arbitrary data to the get and set functions.


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


Need advice on Web / Database framework...

2011-09-03 Thread Benjamin Schollnick
Folks,

I need some advice on a python web & database framework to use...?

I have handcrafted a sqllite3 python script, that is a basic web application, 
interfacing with a sqlite3 database...

But I am concerned at the thought of handcrafting a administration interface, 
and so forth.

Are there any recommendations on a python toolkit / framework that could help 
deal with the realities of this?
The main issue is hand crafting all the forms and html web pages...  

I have done a little cheetah templating...  So that might be a partial 
solution, but I'm concerned with someone trying to craft a malicious payload in 
the fields, and so forth...  

I have thought about an out of the box solution, for example, using a wordpress 
install for the front-end, but I haven't been able to think of a good way to 
bridge this gap.

Would Zope be a good solution possibly?  Any suggestions would be appreciated...

- Ben

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


Reading pen drive data

2011-09-03 Thread mukesh tiwari
Hello all
I am trying to write a python script which can mount a pen drive and
read the data from pen drive. I am using pyudev [
http://packages.python.org/pyudev/api/index.html ] and wrote a small
python code

import pyudev, sys
if __name__ =="__main__":
context = pyudev.Context()
devices = context.list_devices(subsystem="usb")
for device in devices :
print device

which prints

Device(u'/sys/devices/pci:00/:00:1a.0/usb3')
Device(u'/sys/devices/pci:00/:00:1a.0/usb3/3-0:1.0')
Device(u'/sys/devices/pci:00/:00:1a.1/usb4')
Device(u'/sys/devices/pci:00/:00:1a.1/usb4/4-0:1.0')
Device(u'/sys/devices/pci:00/:00:1a.2/usb5')
Device(u'/sys/devices/pci:00/:00:1a.2/usb5/5-0:1.0')
Device(u'/sys/devices/pci:00/:00:1a.7/usb1')
Device(u'/sys/devices/pci:00/:00:1a.7/usb1/1-0:1.0')
Device(u'/sys/devices/pci:00/:00:1d.0/usb6')
Device(u'/sys/devices/pci:00/:00:1d.0/usb6/6-0:1.0')
Device(u'/sys/devices/pci:00/:00:1d.0/usb6/6-2')
Device(u'/sys/devices/pci:00/:00:1d.0/usb6/6-2/6-2:1.0')
Device(u'/sys/devices/pci:00/:00:1d.1/usb7')
Device(u'/sys/devices/pci:00/:00:1d.1/usb7/7-0:1.0')
Device(u'/sys/devices/pci:00/:00:1d.2/usb8')
Device(u'/sys/devices/pci:00/:00:1d.2/usb8/8-0:1.0')
Device(u'/sys/devices/pci:00/:00:1d.7/usb2')
Device(u'/sys/devices/pci:00/:00:1d.7/usb2/2-0:1.0')

My problem is,  how to know  out of these usb which one to read . The
other solution I got is whenever I insert the pen drive , my system
mounts  it in /media  directory so I can read the /media directory  to
check if its empty or not but this does not seems promising to me
because it may be possible that my system is not able to mount the pen
drive so I have to manually do it .  Kindly some one please tell me
how to solve this problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Functions vs OOP

2011-09-03 Thread William Gill
During some recent research, and re-familiarization with Python, I came 
across documentation that suggests that programming using functions, and 
programming using objects were somehow opposing techniques.


It seems to me that they are complimentary.  It makes sense to create 
objects and have some functions that take those objects as arguments. 
Are they suggesting that any function that takes an object as an 
argument should always be a method of that object?  Conversely I can see 
creating functions that take raw input (e.g. strings) and return it in a 
format compatible with an object's constructor, rather than have objects 
accept any conceivable format for its constructor.


Am I missing something, or am I taking things too literally?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Functions vs OOP

2011-09-03 Thread MRAB

On 03/09/2011 17:15, William Gill wrote:

During some recent research, and re-familiarization with Python, I
came across documentation that suggests that programming using
functions, and programming using objects were somehow opposing
techniques.

It seems to me that they are complimentary.


I think you mean "complementary". :-)


It makes sense to create objects and have some functions that take
those objects as arguments. Are they suggesting that any function
that takes an object as an argument should always be a method of that
object? Conversely I can see creating functions that take raw input
(e.g. strings) and return it in a format compatible with an object's
constructor, rather than have objects accept any conceivable format
for its constructor.

Am I missing something, or am I taking things too literally?


I think that it's all about "state".

In functional programming, there's no state; a function's result
depends solely on its arguments, so it will always return the same
result for the same given arguments.

In OOP, on the other hand, an object often has a state; a method may
return a different result each time it's called, even for the same
given arguments.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Reading pen drive data

2011-09-03 Thread mukesh tiwari
On Sep 3, 7:40 pm, mukesh tiwari  wrote:
> Hello all
> I am trying to write a python script which can mount a pen drive and
> read the data from pen drive. I am using pyudev 
> [http://packages.python.org/pyudev/api/index.html] and wrote a small
> python code
>
> import pyudev, sys
> if __name__ =="__main__":
>         context = pyudev.Context()
>         devices = context.list_devices(subsystem        ="usb")
>         for device in devices :
>                 print device
>
> which prints
>
> Device(u'/sys/devices/pci:00/:00:1a.0/usb3')
> Device(u'/sys/devices/pci:00/:00:1a.0/usb3/3-0:1.0')
> Device(u'/sys/devices/pci:00/:00:1a.1/usb4')
> Device(u'/sys/devices/pci:00/:00:1a.1/usb4/4-0:1.0')
> Device(u'/sys/devices/pci:00/:00:1a.2/usb5')
> Device(u'/sys/devices/pci:00/:00:1a.2/usb5/5-0:1.0')
> Device(u'/sys/devices/pci:00/:00:1a.7/usb1')
> Device(u'/sys/devices/pci:00/:00:1a.7/usb1/1-0:1.0')
> Device(u'/sys/devices/pci:00/:00:1d.0/usb6')
> Device(u'/sys/devices/pci:00/:00:1d.0/usb6/6-0:1.0')
> Device(u'/sys/devices/pci:00/:00:1d.0/usb6/6-2')
> Device(u'/sys/devices/pci:00/:00:1d.0/usb6/6-2/6-2:1.0')
> Device(u'/sys/devices/pci:00/:00:1d.1/usb7')
> Device(u'/sys/devices/pci:00/:00:1d.1/usb7/7-0:1.0')
> Device(u'/sys/devices/pci:00/:00:1d.2/usb8')
> Device(u'/sys/devices/pci:00/:00:1d.2/usb8/8-0:1.0')
> Device(u'/sys/devices/pci:00/:00:1d.7/usb2')
> Device(u'/sys/devices/pci:00/:00:1d.7/usb2/2-0:1.0')
>
> My problem is,  how to know  out of these usb which one to read . The
> other solution I got is whenever I insert the pen drive , my system
> mounts  it in /media  directory so I can read the /media directory  to
> check if its empty or not but this does not seems promising to me
> because it may be possible that my system is not able to mount the pen
> drive so I have to manually do it .  Kindly some one please tell me
> how to solve this problem.

I got this link and its working fine [ 
http://packages.python.org/pyudev/api/monitor.html
]
>>> context = pyudev.Context()
>>> monitor = pyudev.Monitor.from_netlink(context)
>>> monitor.filter_by(subsystem='input')
>>> for action, device in monitor:
... print('{0}: {1}'.format(action, device))

but when I am trying to execute code [ 
http://packages.python.org/pyudev/api/toolkit.html
]

import pyudev, sys

context = pyudev.Context()
monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by(subsystem='usb')
observer = QUDevMonitorObserver(monitor)
def device_connected(device):
 print('{0!r} added'.format(device))
observer.deviceAdded.connect(device_connected)
monitor.start()

I am getting
Traceback (most recent call last):
  File "Mount.py", line 7, in 
observer = QUDevMonitorObserver(monitor)
NameError: name 'QUDevMonitorObserver' is not defined

Could any one please tell me how to avoid this error .
Thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Functions vs OOP

2011-09-03 Thread Steven D'Aprano
William Gill wrote:

> During some recent research, and re-familiarization with Python, I came
> across documentation that suggests that programming using functions, and
> programming using objects were somehow opposing techniques.
> 
> It seems to me that they are complimentary.  It makes sense to create
> objects and have some functions that take those objects as arguments.

Python is a mixed paradigm language, with object, functional and imperative
paradigms.


> Are they suggesting that any function that takes an object as an
> argument should always be a method of that object?

Yes.

http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html

[...]
> Am I missing something, or am I taking things too literally?

No, it is the OO purists who are missing something.



-- 
Steven

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


Re: [Python-ideas] allow line break at operators

2011-09-03 Thread Stephen Hansen
On 9/3/11 3:33 AM, Yingjie Lan wrote:
> but at least we can have such 'freedom' :)

Freedom is not and never has been, IMHO, a virtue or goal or even desire
in Python. Where it occurs, it is at best a happy coincidence, and even
if that happy coincidence happens often, it is not a design feature, IMHO.

Simplicity and readability are virtues in Python. Freedom is even
declared a vice to be avoided by the Zen, that holy document which
defines all things Pythonic in clear and unambiguously absolute terms*.

Looking over this whole thread at the various examples -- they add
complication (a vice!). Complication to the parser, complication to the
language itself and worse, understanding of code (as your head has to
parse things too), all for what?

So you don't have to use parens, which quite explicitly (another
virtue!) do the job, to wrap around a long expression? Escaping newlines
is arguably a bit on the ugly side (a vice!), so maybe the proposal has
a little weight there, but since you can just avoid that by using
parens, that's pretty much nullified. (Since it is also a virtue to
offer only the Dutch way of doing things -- at least without hiding the
alternatives in modules with a little bit of shame -- and this is
clearly a case of the Dutch liking limited use of grouping parens).

There just isn't even vaguely enough justification based on
Python-virtues (readability, simplicity, explicitness, things like that)
to even kind of make it worth the complication.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

* Obvious exaggeration :P



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't threading.join() return a value?

2011-09-03 Thread Roy Smith
In article ,
 Chris Torek  wrote:

> For that matter, you can use the following to get what the OP asked
> for.  (Change all the instance variables to __-prefixed versions
> if you want them to be Mostly Private.)
> 
> import threading
> 
> class ValThread(threading.Thread):
> "like threading.Thread, but the target function's return val is captured"
> def __init__(self, group=None, target=None, name=None,
> args=(), kwargs=None, verbose=None):
> super(ValThread, self).__init__(group, None, name, None, None, 
> verbose)
> self.value = None
> self.target = target
> self.args = args
> self.kwargs = {} if kwargs is None else kwargs
> 
> def run(self):
> "run the thread"
> if self.target:
> self.value = self.target(*self.args, **self.kwargs)
> 
> def join(self, timeout = None):
> "join, then return value set by target function"
> super(ValThread, self).join(timeout)
> return self.value

Yeah, that's pretty much what I had in mind.  I'm inclined to write up a 
PEP proposing that this become the standard behavior of 
threading.Thread.  It seems useful, and I can't see any way it would 
break any existing code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] allow line break at operators

2011-09-03 Thread Roy Smith
In article ,
 Matt Joiner  wrote:

> I guess the issue here is that you can't tell if an expression is
> complete without checking the indent of the following line. This is
> likely not desirable.

I wrote a weird bug the other day.  I had a function that returned a 
4-tuple and wanted to unpack it, so I wrote:

var1,
var2,
var3,
var4 = my_function()

which isn't a syntax error, but also isn't what I meant.  Depending on 
whether var[123] have pre-existing values, this doesn't even produce a 
run-time error.  Emacs encouraged me in this crime by merrily 
auto-indenting the code the way I expected :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading pen drive data

2011-09-03 Thread Jerry Hill
On Sat, Sep 3, 2011 at 12:21 PM, mukesh tiwari  wrote:

> I am getting
> Traceback (most recent call last):
>  File "Mount.py", line 7, in 
>observer = QUDevMonitorObserver(monitor)
> NameError: name 'QUDevMonitorObserver' is not defined
>
> Could any one please tell me how to avoid this error .
>

It looks to me like that should be pyudev.QUDevMonitorObserver, shouldn't
it?

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


Re: Reading pen drive data

2011-09-03 Thread MRAB

On 03/09/2011 17:21, mukesh tiwari wrote:

On Sep 3, 7:40 pm, mukesh tiwari  wrote:

Hello all
I am trying to write a python script which can mount a pen drive and
read the data from pen drive. I am using pyudev 
[http://packages.python.org/pyudev/api/index.html] and wrote a small
python code

import pyudev, sys
if __name__ =="__main__":
 context = pyudev.Context()
 devices = context.list_devices(subsystem="usb")
 for device in devices :
 print device

which prints

Device(u'/sys/devices/pci:00/:00:1a.0/usb3')
Device(u'/sys/devices/pci:00/:00:1a.0/usb3/3-0:1.0')
Device(u'/sys/devices/pci:00/:00:1a.1/usb4')
Device(u'/sys/devices/pci:00/:00:1a.1/usb4/4-0:1.0')
Device(u'/sys/devices/pci:00/:00:1a.2/usb5')
Device(u'/sys/devices/pci:00/:00:1a.2/usb5/5-0:1.0')
Device(u'/sys/devices/pci:00/:00:1a.7/usb1')
Device(u'/sys/devices/pci:00/:00:1a.7/usb1/1-0:1.0')
Device(u'/sys/devices/pci:00/:00:1d.0/usb6')
Device(u'/sys/devices/pci:00/:00:1d.0/usb6/6-0:1.0')
Device(u'/sys/devices/pci:00/:00:1d.0/usb6/6-2')
Device(u'/sys/devices/pci:00/:00:1d.0/usb6/6-2/6-2:1.0')
Device(u'/sys/devices/pci:00/:00:1d.1/usb7')
Device(u'/sys/devices/pci:00/:00:1d.1/usb7/7-0:1.0')
Device(u'/sys/devices/pci:00/:00:1d.2/usb8')
Device(u'/sys/devices/pci:00/:00:1d.2/usb8/8-0:1.0')
Device(u'/sys/devices/pci:00/:00:1d.7/usb2')
Device(u'/sys/devices/pci:00/:00:1d.7/usb2/2-0:1.0')

My problem is,  how to know  out of these usb which one to read . The
other solution I got is whenever I insert the pen drive , my system
mounts  it in /media  directory so I can read the /media directory  to
check if its empty or not but this does not seems promising to me
because it may be possible that my system is not able to mount the pen
drive so I have to manually do it .  Kindly some one please tell me
how to solve this problem.


I got this link and its working fine [ 
http://packages.python.org/pyudev/api/monitor.html
]

context = pyudev.Context()
monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by(subsystem='input')
for action, device in monitor:

... print('{0}: {1}'.format(action, device))

but when I am trying to execute code [ 
http://packages.python.org/pyudev/api/toolkit.html
]

import pyudev, sys

context = pyudev.Context()
monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by(subsystem='usb')
observer = QUDevMonitorObserver(monitor)
def device_connected(device):
  print('{0!r} added'.format(device))
observer.deviceAdded.connect(device_connected)
monitor.start()

I am getting
Traceback (most recent call last):
   File "Mount.py", line 7, in
 observer = QUDevMonitorObserver(monitor)
NameError: name 'QUDevMonitorObserver' is not defined

Could any one please tell me how to avoid this error .
Thank you


I think you need to import it from pyudev.pyqt4.
--
http://mail.python.org/mailman/listinfo/python-list


framework suggestions for Ben

2011-09-03 Thread Vineet Deodhar
>Folks,
>I need some advice on a python web & database framework to use...?
>I have handcrafted a sqllite3 python script, that is a basic web application, 
>interfacing with a >sqlite3 database...

It depends on whether you want to develop desktop apps or browser-based apps.
I will suggest 2 frameworks with their urls.
I will not enumerate the features here, because their websites contain loads of 
advocacy about them.
 
=
For desktop apps, my STRONG advise to you is DABO.
http://dabodev.com/
It is developed by the experts in data-centric business apps.
It contains the features which I haven't seen in any other framework except MS 
VFP & cursor adapter (if at all you are familiar with them).

For browser based apps, I found web2py very simple yet powerful.
http://web2py.com/
 
It requires no installation (not even python).
Everything works out of the box.
No dependencies.
=
 
Hope this helps.
:)
Vineet
..
>- Ben
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] Pyflakes 0.5.0

2011-09-03 Thread Tristan Seligmann
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

It is my unexpected pleasure to announce the release of Pyflakes
0.5.0, the first release in several years, and available now from
PyPI[1].

Highlights of this release include the use of the built-in AST instead
of the compiler module, and support for various new syntax constructs
in Python 2.7. Note that development of Pyflakes (as well as the other
divmod.org projects) has moved to Launchpad[2] since the last release.

[1] 
http://pypi.python.org/packages/source/p/pyflakes/pyflakes-0.5.0.tar.gz#md5=568dab27c42e5822787aa8a603898672

[2] https://launchpad.net/pyflakes
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.18 (GNU/Linux)

iQIcBAEBCgAGBQJOYmL+AAoJEFjA+xzeO3YAme4P/AxLuy0WJN2zG97my1oEwky9
VT79BwnxOqR4NB7I1dRKE3PG4Llgl6frAa0SouM12Dr0QZj9Ug3qHAmmf+TZFrF6
OIQcBUGkZW7EanBhCbjmfqo+0atJ8toAcj9uyF7Db/0A7gCDw160JIMnmTmxu8z6
3r5xRLNSnxs4jj6OSViv9oHNs2r2lpU/RObkGXy6EHxMgezYqw84FbA61fxquK4p
+J1n++vzfiasqgcQFFU3R67T0P2gWUe0C6pv/D+CurSCOdgQJv4LeRtNeYgKhw/W
rN0/3cERXGyRMa4JYDbFyP2G8lrpOuWo2F+jFtEGAxgziK8EqCK58ZSeqMBsodJ9
slAZobSQkrUj6GfpNKdW5mjYRqymBmUhPFc+sUI2poGb3zvMnWmUa2tiSfwl9uxO
9Di82XXAztKba8++cGJQCbuONiLRPgW5kArz5dRz3jFVdAZYL7xUvah4uznwfazc
CA8Q0tiXXoL7X1sT6heNu4VRtnJfEh5LojFdizA4nJEpNssZrPFkSZMv+eSR4Sow
8u2n4f07od6EBzHMhEyqFN7goaniW05VL+EvMdC5px+brnyKOIoLSAGWptBL5EYL
aaAb2zRrebyr/u5vGa+sKEXcoW2TEsc9qO8p/nNSetcoIcNfDwnd3cdyJPU+lYbn
Wctc68Y+xNWChiuTYa3e
=kKgi
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


IDLE from python 3.2 constantly crashes

2011-09-03 Thread Joshua Miller
Ok i've been using IDLE on my home computer and everytime i try and
open a file that i saved to my hdd instead of my flashdrive(because
it's a school project) by accident, it opens for a second and i try to
do something else like open another file and it crashes. Is there
anyway to remedy this error?

By the way i'm running python 3.2 on windows 7 if it makes a difference
-- 
http://mail.python.org/mailman/listinfo/python-list


SSL module needs issuer information

2011-09-03 Thread John Nagle

  The SSL module still doesn't return much information from the
certificate.  SSLSocket.getpeercert only returns a few basic items
about the certificate subject.  You can't retrieve issuer information,
and you can't get the extensions needed to check if a cert is an EV cert.

  With the latest flaps about phony cert issuers, it's worth
having issuer info available.  It was available in the old M2Crypto
module, but not in the current Python SSL module.

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


Re: Functions vs OOP

2011-09-03 Thread Ian Kelly
On Sat, Sep 3, 2011 at 10:15 AM, William Gill  wrote:
> During some recent research, and re-familiarization with Python, I came
> across documentation that suggests that programming using functions, and
> programming using objects were somehow opposing techniques.
>
> It seems to me that they are complimentary.  It makes sense to create
> objects and have some functions that take those objects as arguments. Are
> they suggesting that any function that takes an object as an argument should
> always be a method of that object?  Conversely I can see creating functions
> that take raw input (e.g. strings) and return it in a format compatible with
> an object's constructor, rather than have objects accept any conceivable
> format for its constructor.
>
> Am I missing something, or am I taking things too literally?

I think you may be confusing "functional programming" and "programming
using functions".  These are not the same thing.

Functional programming is about using functions in the *mathematical*
sense.  A mathematical function maps one value (or tuple of values) to
another value.  The mapped value never varies; if it did, it would be
a different function.  So functional programming eschews the use of
functions where the results depend on any internal or external state
beyond the values of the passed-in arguments, such as the variable
state of the object the method is being called on.

Functional programming and OOP are not entirely opposed -- for
example, string methods in Python such as str.upper are perfectly
functional, since strings are immutable.  Many functional languages
such as Common LISP also have powerful OOP facilities.  Still,
functional programming does not fit well with the traditional OOP
model of objects passing messages to other objects, which generally
implies statefulness.

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


Re: Need advice on Web / Database framework...

2011-09-03 Thread Paul Kölle

Hi,

Am 03.09.2011 16:11, schrieb Benjamin Schollnick:

Folks,

I need some advice on a python web&  database framework to use...?

Hardest question ever ;)



I have handcrafted a sqllite3 python script, that is a basic web
application, interfacing with a sqlite3 database...

But I am concerned at the thought of handcrafting a administration
interface, and so forth.
If you are not familiar with the various pitfalls of web security I'd 
recomment a framework which has all the layers already integrated. Take 
a look at http://www.web2py.com, I think it's quite powerful and has 
good documentation.
If you want to get your hands dirty you can compose your own "framework" 
cherrypy+sqlalchemy+cheetah might be a good combination.


hth
 Paul

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


Re: [Python-ideas] allow line break at operators

2011-09-03 Thread Terry Reedy

On 9/3/2011 3:51 AM, Yingjie Lan wrote:

I agree that long lines of code are not very common in many projects,
though it might be the case with some heavily involved in math. For some
reason, when the feature of free line breaking came about in computer
languages, it is welcomed and generally well accepted.


Every language with blocks needs some mechanism to indicate the 
beginning and ending of blocks and of statements within blocks. If 
visible fences ('begin/end' or '{}') and statement terminators (';') are 
used, then '\n' can be treated as merely a space, as it is in C, for 
instance.



Python uses indentation for blocks,


and it uses unescaped '\n' (with two escapement options) to terminate 
statements. This is fundamental to Python's design and goes along with 
significant indents.


> and by the same mechanism, line breaking can be

accommodated without requiring parenthesis or ending backslashes.


You need proof for your claim that indentation can be used for both jobs 
in the form of a grammar that works with Python's parser. I am dubious 
that you can do that with an indents *after* the newline.


Even if you could, it would be confusing for human readers. There would 
then be three ways to escape newline, with one doing double duty. And 
for what? Merely to avoid using either of the two methods already available.


--
Terry Jan Reedy

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


Re: Functions vs OOP

2011-09-03 Thread Terry Reedy

On 9/3/2011 12:25 PM, Steven D'Aprano wrote:

William Gill wrote:


During some recent research, and re-familiarization with Python, I came
across documentation


Ours, or someone else's?


that suggests that programming using functions, and
programming using objects were somehow opposing techniques.

It seems to me that they are complimentary.  It makes sense to create
objects and have some functions that take those objects as arguments.


Python is a mixed paradigm language, with object, functional and imperative
paradigms.


Are they suggesting that any function that takes an object as an
argument should always be a method of that object?


Or of the class of the object.


Yes.
http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html


Since in Python, everything is an object, that would mean that every 
function has to be a method, which would mean creating classes just to 
have a class to attach functions to. How awful. (Oh, right, I believe I 
just described Java.)



Am I missing something, or am I taking things too literally?


No, it is the OO purists who are missing something.


Yes, Python.

--
Terry Jan Reedy

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


Re: IDLE from python 3.2 constantly crashes

2011-09-03 Thread Terry Reedy

On 9/3/2011 1:54 PM, Joshua Miller wrote:

Ok i've been using IDLE on my home computer and everytime i try and
open a file that i saved to my hdd instead of my flashdrive(because
it's a school project) by accident, it opens for a second and i try to
do something else like open another file and it crashes. Is there
anyway to remedy this error?

By the way i'm running python 3.2 on windows 7 if it makes a difference


Since I and others am using the same (3.2 on Win 7) quite successfully, 
it is hard to know what the problem is with your setup. Start with more 
details of exactly what you do and what 'it crashes' means.


--
Terry Jan Reedy

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


Re: SSL module needs issuer information

2011-09-03 Thread Terry Reedy

On 9/3/2011 2:10 PM, John Nagle wrote:

The SSL module still doesn't return much information from the
certificate. SSLSocket.getpeercert only returns a few basic items
about the certificate subject. You can't retrieve issuer information,
and you can't get the extensions needed to check if a cert is an EV cert.

With the latest flaps about phony cert issuers, it's worth
having issuer info available. It was available in the old M2Crypto
module, but not in the current Python SSL module.


Check the tracker to see if there is an issue about this already. If 
not, open one with a specific feature request.


--
Terry Jan Reedy

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


Re: Functions vs OOP

2011-09-03 Thread William Gill

On 9/3/2011 12:29 PM, MRAB wrote:

I think you mean "complementary". :-)
How polite of you to point out my spelling deficiency.  I guess 
shouldn't be watching football while typing (I'm sure the beer didn't 
help either).



I think that it's all about "state".

In functional programming, there's no state; a function's result
depends solely on its arguments, so it will always return the same
result for the same given arguments.

In OOP, on the other hand, an object often has a state; a method may
return a different result each time it's called, even for the same
given arguments.


I think you mean "it [sic, a function] will "return the same result for 
the same given values..."


x=1
y= myFn(x)

will return the same result as

y= myFn(1)

A method may use an attribute as an implicit argument, and that 
attribute's value change, just like the value of x (above) may change. 
It may or may not return anything (it may just modify an attribute).


The question wasn't about encapsulation, it was about programming 
paradigms, and if they conflict.


As was pointed out elsewhere, I may have just confused "functional 
programming" with "programming using functions".



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


Re: Functions vs OOP

2011-09-03 Thread William Gill

On 9/3/2011 2:50 PM, Ian Kelly wrote:


I think you may be confusing "functional programming" and "programming
using functions".  These are not the same thing.



I think you may be right, Ian.  It didn't make much sense


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


Re: Functions vs OOP

2011-09-03 Thread William Gill

On 9/3/2011 3:15 PM, Terry Reedy wrote:

William Gill wrote:


During some recent research, and re-familiarization with Python, I came
across documentation


Ours, or someone else's?


Python.



Since in Python, everything is an object, that would mean that every
function has to be a method, which would mean creating classes just to
have a class to attach functions to. How awful.


Exactly why I asked, but I realize the the mistake was mine.  I think 
they were talking about "functional programming" not "using functions in 
an OO program."


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


Re: Functions vs OOP

2011-09-03 Thread Ben Finney
William Gill  writes:

> On 9/3/2011 3:15 PM, Terry Reedy wrote:
> >> William Gill wrote:
> >>
> >>> During some recent research, and re-familiarization with Python, I
> >>> came across documentation
> >
> > Ours, or someone else's?
>
> Python.

Can you show exactly where in the Python documentation you found the
passage which confused you?

-- 
 \   “If you're a cowboy and you're dragging a guy behind your |
  `\  horse, I bet it would really make you mad if you looked back |
_o__)and the guy was reading a magazine.” —Jack Handey |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Functions vs OOP

2011-09-03 Thread William Gill

On 9/3/2011 5:39 PM, Ben Finney wrote:

William Gill  writes:


On 9/3/2011 3:15 PM, Terry Reedy wrote:

William Gill wrote:


During some recent research, and re-familiarization with Python, I
came across documentation


Ours, or someone else's?


Python.


Can you show exactly where in the Python documentation you found the
passage which confused you?

Sorry, no.  I tried to locate the exact reference again, and couldn't 
remember where I read it (short term memory problems).

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


Tkinter label height to fit content

2011-09-03 Thread Bart Kastermans

I have a label into which I am going to put content of different
sizes. I would like to know how high I need to make the label so that I
can size the window so it can stay the same for the different content
sizes. I have a strategy, but it seems more complicated then it should
be.

I want to set a label to a given width and wraplength:

l = Label(root)
l['width'] = 30
l['wraplength'] = 244
l['text'] = "testing this"

Now I want to query the label to find how many lines are
used. l['height'] stays at 0, so the best I have been able to come up
with is to use l.winfo_height() and convert the height given in pixels
to the number of lines used. Nothing in dir(l) seems to give me the
information directly, but this strategy is fragile to font changes and
other changes.

Any suggestions?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing WebDAV server

2011-09-03 Thread Thomas 'PointedEars' Lahn
Fokke Nauta wrote:

> "Thomas 'PointedEars' Lahn" […]:
>> Fokke Nauta wrote:
>>> "Thomas 'PointedEars' Lahn" […] wrote:
 The Python shell executes Python code.  The above obviously is not
 Python
 code, but *system* shell commands.  So let the *system* command shell
 execute them (as indicated by the `$' prompt, which is customary for a
 sh-based UNIX/Linux shell prompt).
>>> I know. I worked with SCO Unix and various sorts of Linux.
>>> But never with Python, so I hadn't got a clue about the prompt.
>> Come on, with that experience you see a `$' and those commands and don't
>> realize it is (ba)sh?
> 
> Ofcourse I realized it was Unix/Linux. I already could tell that as the
> packages I downloaded were tar.gz files.

For *Windows*?

> So I unpacked them and expected to run a Python installer script from the
> Python command line.

Again, given all that experience you claim to have, how come it did not 
occur to you that the `$' was meant to be a *command* *shell* prompt?  Other 
OSes have command shells, too, you know; they are just named and run 
differently.

> Tried to run the Python installer script from the DOS command line but
> that resulted in an error.

"There was an error" is no error report at all.
 
 However, you appear to have found the *UNIX/Linux* README (and the
 corresponding version?) of that server: the second command is usually
 how you would run a program as daemon on Unices (run through an init
 script), while on Windows NT (like XP) you would have a setup program
 install a service for you (maybe to execute that command when the
 service is started).  Look for the Windows version.
>>> There is no other Windows version except the packages I mentioned,
>>> PyWebDAV and PyXML. The only Windows thing I got was the Python
>>> interpreter itself.
>> Has it not occurred to you to STFW for "easy_install" first?
> 
> What do you mean by STFW?

Search The Fing Web.

> I wasn't aware that easy_install was a utility. Downloaded and installed
> the Windows version and run easy_install pywebdav.
> It downloaded something, installed something and finished something.
> But, once again, don't know how to proceed.

RTFM.

> And there is no easy_install script in the PyXML-0.8.4
> directory, only a setup.py and ez_setup.py script. I guess the latter
> is
> the one to use. But how?
 RTFM.
>>> Which fucking manual?
>> That of the server, on Windows-related information.  Or that of
>> easy_install.  Or Python.  Whichever comes first.
> 
> It's my own server and I didn't write a manual for it.

No, the people providing it for you obviously did, but you do not seem to 
care to read it.

> In the manual of Easy_install it says how to install packaged etc and I
> did sucessfully.
> There is no furter information as how to proceed.

Either you are lying, or you are really forgetful, or you are simply not 
smart enough for this.  You yourself told me/us before what the next step 
is:

> How do I proceed next?
 Look for the Windows version.  If there is none, get easy_install and
 use
 it as described.
> 
> I did and it worked. What's next?

Start the now-installed server, for goodness' sake!

Observing this, be reminded that playing stupid does not work with me:



And please get rid of that attribution novel and trim your quotes to the 
relevant minimum.  I am asking you the last time here.  If you cannot find 
it within you to think about your readers when you post, you are not worth 
my attention or (free) time.

-- 
PointedEars

Bitte keine Kopien per E-Mail. / Please do not Cc: me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] allow line break at operators

2011-09-03 Thread Yingjie Lan
> Every language with blocks needs some mechanism to indicate the beginning and 
>ending of blocks and of statements within blocks. If visible fences 
>('begin/end' or '{}') and statement terminators (';') are used, then '\n' can 
>be treated as merely a space, as it is in C, for instance. 

> and it uses unescaped '\n' (with two escapement options) to terminate 
>statements. This is fundamental to Python's design and goes along with 
>significant indents.

Agreed. Currently indentation in Python starts a new block, but if you view it 
from the perspective of line breaking, it also functions as if the line is 
continued. The line of code below

if condition: do_a(); do_b()

can be  written as:

if condition: #line breaks
do_a(); # ';' is optional here 
do_b() # continue

That indentation can be also employed for line breaking is quite evident to me. 
During the open email correspondence with Stephen, it seems to be a tenable 
point. 

> There would then be three ways to escape newline, with one doing double duty. 
>And for what? Merely to avoid using either of the two methods already 
>available.

I believe the other two ways are not as good as this new way. As the proposal 
is fully backward compatible, people may choose whatever way they prefer. 


>
>From: Terry Reedy 
>To: python-list@python.org
>Cc: python-id...@python.org
>Sent: Sunday, September 4, 2011 3:01 AM
>Subject: Re: [Python-ideas] allow line break at operators
>
>On 9/3/2011 3:51 AM, Yingjie Lan wrote:
>> I agree that long lines of code are not very common in many projects,
>> though it might be the case with some heavily involved in math. For some
>> reason, when the feature of free line breaking came about in computer
>> languages, it is welcomed and generally well accepted.
>
>Every language with blocks needs some mechanism to indicate the beginning and 
>ending of blocks and of statements within blocks. If visible fences 
>('begin/end' or '{}') and statement terminators (';') are used, then '\n' can 
>be treated as merely a space, as it is in C, for instance.
>
>> Python uses indentation for blocks,
>
>and it uses unescaped '\n' (with two escapement options) to terminate 
>statements. This is fundamental to Python's design and goes along with 
>significant indents.
>
>> and by the same mechanism, line breaking can be
>> accommodated without requiring parenthesis or ending backslashes.
>
>You need proof for your claim that indentation can be used for both jobs in 
>the form of a grammar that works with Python's parser. I am dubious that you 
>can do that with an indents *after* the newline.
>
>Even if you could, it would be confusing for human readers. There would then 
>be three ways to escape newline, with one doing double duty. And for what? 
>Merely to avoid using either of the two methods already available.
>
>-- Terry Jan Reedy
>
>-- http://mail.python.org/mailman/listinfo/python-list
>
>
>-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSL module needs issuer information

2011-09-03 Thread Gelonida N
Hi John,

On 09/03/2011 08:10 PM, John Nagle wrote:
>   The SSL module still doesn't return much information from the
> certificate.  SSLSocket.getpeercert only returns a few basic items
> about the certificate subject.  You can't retrieve issuer information,
> and you can't get the extensions needed to check if a cert is an EV cert.
> 
>   With the latest flaps about phony cert issuers, it's worth
> having issuer info available.  It was available in the old M2Crypto
> module, but not in the current Python SSL module.

Your phrasing 'old M2Crypto' disturbs me slightly.

I am using Python 2.6. Is M2Crypto also obsolete for python 2.6?

Is there any serious alternative if I want to verify the server
certificate in a safe way (and if I want to send a client certificate)??


I am in search for a set of libraries, which allows me to:

- verify the server certificate (ideally via a custom call back, which
can inspect the certificate data and then decide whether the certificate
shall be accepted or not)

- send a client certificate

- use https with a cookie jar (ideally even persistent, but session
cookies are enough)

- do XMLRPC calls (but send cookies in the headers)

Would m2crypto be the right choice?


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


Re: Need advice on Web / Database framework...

2011-09-03 Thread Gelonida N
Hi Paul,

On 09/03/2011 08:59 PM, Paul Kölle wrote:
> Am 03.09.2011 16:11, schrieb Benjamin Schollnick:
>> Folks,
>>
>> I need some advice on a python web&  database framework to use...?
> Hardest question ever ;)
. . .
>> But I am concerned at the thought of handcrafting a administration
>> interface, and so forth.
> If you are not familiar with the various pitfalls of web security I'd
> recomment a framework which has all the layers already integrated. Take
> a look at http://www.web2py.com, I think it's quite powerful and has
> good documentation.
> If you want to get your hands dirty you can compose your own "framework"
> cherrypy+sqlalchemy+cheetah might be a good combination.
> 

How does web2py compare to django? I just started playing with django,
but don't know web2py


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


Re: Tkinter label height to fit content

2011-09-03 Thread rantingrick
On Sep 3, 5:15 pm, Bart Kastermans  wrote:

> Any suggestions?

Yeah, have you considered using the "linespace()" method of tk.Font
objects to calculate the height? Although i must say it "feels" as if
your doing something you should not need to do, however i cannot be
sure without knowing more about this GUI. Sounds a lot like trying to
put socks on a rooster.

http://infohost.nmt.edu/tcc/help/pubs/tkinter/std-attrs.html#fonts
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Functions vs OOP

2011-09-03 Thread Terry Reedy

On 9/3/2011 5:34 PM, William Gill wrote:

On 9/3/2011 3:15 PM, Terry Reedy wrote:

William Gill wrote:


During some recent research, and re-familiarization with Python, I came
across documentation


Ours, or someone else's?


Python.



Since in Python, everything is an object, that would mean that every
function has to be a method, which would mean creating classes just to
have a class to attach functions to. How awful.


Exactly why I asked, but I realize the the mistake was mine. I think
they were talking about "functional programming" not "using functions in
an OO program."


It is possible that our doc was less than crystal clear. We are 
constantly improving it where we can see fixable faults. If you run 
across whatever it was and it still seems a bit muddy, post something again.


--
Terry Jan Reedy

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


Re: [Python-ideas] allow line break at operators

2011-09-03 Thread MRAB

On 04/09/2011 00:22, Yingjie Lan wrote:

 Every language with blocks needs some mechanism to indicate the

beginning and ending of blocks and of statements within blocks. If
visible fences ('begin/end' or '{}') and statement terminators (';') are
used, then '\n' can be treated as merely a space, as it is in C, for
instance.

 and it uses unescaped '\n' (with two escapement options) to terminate

statements. This is fundamental to Python's design and goes along with
significant indents.

Agreed. Currently indentation in Python starts a new block, but if you
view it from the perspective of line breaking, it also functions as if
the line is continued. The line of code below

if condition: do_a(); do_b()

can be written as:

if condition: #line breaks
do_a(); # ';' is optional here
do_b() # continue

That indentation can be also employed for line breaking is quite evident
to me. During the open email correspondence with Stephen, it seems to be
a tenable point.

 > There would then be three ways to escape newline, with one doing
double duty. And for what? Merely to avoid using either of the two
methods already available.

I believe the other two ways are not as good as this new way. As the
proposal is fully backward compatible, people may choose whatever way
they prefer.


I think that the rules would be:

If a line ends with a colon and the next line is indented, then it's
the start of a block, and the following lines which belong to that
block have the same indent.

If a line doesn't end with a colon but the next line is indented, then
it's the start of a continuation, and the following lines which belong
to that continuation have the same indent.

In both cases there could be blocks nested in blocks and possibly
continuations nested in continuations, as well as blocks nested in
continuations and continuations nested in blocks.

I'm not sure what the effect would be if you had mis-indented lines.
For example, if a line was accidentally indented after a comment, then
it would be treated as part of the comment. It's in cases like those
that syntax colouring would be helpful. It would be a good idea to use
an editor which could indicate in some way when a line is a
continuation.



*From:* Terry Reedy 
*To:* python-list@python.org
*Cc:* python-id...@python.org
*Sent:* Sunday, September 4, 2011 3:01 AM
*Subject:* Re: [Python-ideas] allow line break at operators

On 9/3/2011 3:51 AM, Yingjie Lan wrote:
 > I agree that long lines of code are not very common in many projects,
 > though it might be the case with some heavily involved in math.
For some
 > reason, when the feature of free line breaking came about in computer
 > languages, it is welcomed and generally well accepted.

Every language with blocks needs some mechanism to indicate the
beginning and ending of blocks and of statements within blocks. If
visible fences ('begin/end' or '{}') and statement terminators (';')
are used, then '\n' can be treated as merely a space, as it is in C,
for instance.

 > Python uses indentation for blocks,

and it uses unescaped '\n' (with two escapement options) to
terminate statements. This is fundamental to Python's design and
goes along with significant indents.

 > and by the same mechanism, line breaking can be
 > accommodated without requiring parenthesis or ending backslashes.

You need proof for your claim that indentation can be used for both
jobs in the form of a grammar that works with Python's parser. I am
dubious that you can do that with an indents *after* the newline.

Even if you could, it would be confusing for human readers. There
would then be three ways to escape newline, with one doing double
duty. And for what? Merely to avoid using either of the two methods
already available.



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


Re: Functions vs OOP

2011-09-03 Thread William Gill

On 9/3/2011 9:51 PM, Terry Reedy wrote:


It is possible that our doc was less than crystal clear. We are
constantly improving it where we can see fixable faults. If you run
across whatever it was and it still seems a bit muddy, post something
again.


Will do.

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


Re: Algorithms Library - Asking for Pointers

2011-09-03 Thread Travis Parks
On Sep 3, 12:35 am, Chris Torek  wrote:
> In article <18fe4afd-569b-4580-a629-50f6c7482...@c29g2000yqd.googlegroups.com>
> Travis Parks   wrote:
>
> >[Someone] commented that the itertools algorithms will perform
> >faster than the hand-written ones. Are these algorithms optimized
> >internally?
>
> They are written in C, so avoid a lot of CPython interpreter
> overhead.  Mileage in Jython, etc., may vary...
> --
> In-Real-Life: Chris Torek, Wind River Systems
> Intel require I note that my opinions are not those of WRS or Intel
> Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W)  +1 801 277 2603
> email: gmail (figure it out)      http://web.torek.net/torek/index.html

I thought I would point out that many of the itertools functions
change between 2.x and 3.x versions. Since 2.7 is supposed to be the
last 2.x language, I suppose I will wait until 3.2 becomes the norm
before I incorporate some of these changes. In the mean time, I will
starting working on algorithms that work against Sequences.

I think a really important lesson is that Python really doesn't need
an algorithms library, like many others do. A lot of the common
algorithms are supported by the syntax itself. All my library did was
allow for easier function composition.
-- 
http://mail.python.org/mailman/listinfo/python-list


my suggestions for framework

2011-09-03 Thread Vineet Deodhar
> recomment a framework which has all the layers already integrated. Take
> a look at http://www.web2py.com, I think it's quite powerful and has
> good documentation.
> If you want to get your hands dirty you can compose your own "framework"
> cherrypy+sqlalchemy+cheetah might be a good combination.
> 

How does web2py compare to django? I just started playing with django,
but don't know web2py



IMHO, django is suitable for CMS kind of apps.
AFAIK, originally it was written for a newspaper website, subsequently it has 
grown over the time.
I have tried turbogears(TG), django & web2py.

TG is like picking all good eggs from different open source projects. It 
integrates sqlalchemy, genshi, cheetah, pylons, for sql abstraction layer, 
templating system, web server respectively.
One can choose other options also, if desired.
-1 for TG is its complexity and not-so-good docs, too many dependencies.
 
django has very good docs & active community.
It is better in terms of simplicity & dependency as compared to TG.
 
web2py is vastly flexible, no dependencies, no installation required, just plug 
& play, very good community & docs.
Honestly, I did not find any -1 for web2py.
 
Of course, one has to form his/her own opinion.
On stackoverflow.com, there are plenty of threads which compare the python 
frameworks.
 
:-)
---Vineet-- 
http://mail.python.org/mailman/listinfo/python-list