Re: Don't Want Visitor To See Nuttin'

2011-03-10 Thread Ian Kelly
On Wed, Mar 9, 2011 at 2:01 PM, Victor Subervi  wrote:
> Maya 2012: Transform At the Source

Yow.  You're designing a Maya 2012 website to help some travel company
bilk gullible people out of thousands of dollars?  I would be ashamed
to have anything to do with this.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use-cases for alternative iterator

2011-03-10 Thread Hrvoje Niksic
Steven D'Aprano  writes:

> I've never seen this second form in actual code. Does anyone use it,
> and if so, what use-cases do you have?

Since APIs that signal end-of-iteration by returning a sentinel have
fallen out of favor in Python (with good reason), this form is rare, but
still it's sometimes useful.  I've used it in actual code for reading a
file in fixed-size chunks, like this:

for chunk in iter(lambda: f.read(CHUNK_SIZE), ''):
...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread n00m
On Mar 11, 8:35 am, Grigory Javadyan 
wrote:
> > Moreover I'm often able to keep in mind 2 (or more) opposite ideas or
> > opinions of mine.
>
> """
> To know and not to know, to be conscious of complete truthfulness
> while telling carefully constructed lies, to hold simultaneously two
> opinions which cancelled out, knowing them to be contradictory and
> believing in both of them, to use logic against logic, to repudiate
> morality while laying claim to it, to believe that democracy was
> impossible and that the Party was the guardian of democracy...
> """



The test of a first-rate intelligence is the ability to hold two
opposed
ideas in the mind at the same time, and still retain the ability to
function.


 --- F. Scott
Fitzgerald


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


Use-cases for alternative iterator

2011-03-10 Thread Steven D'Aprano
The iter() built-in takes two different forms, the familiar 
iter(iterable) we all know and love, and an alternative form:

iter(callable, sentinel)

E.g.:

>>> T = -1
>>> def func():
... global T
... T += 1
... return T
...
>>> it = iter(func, 3)
>>> next(it)
0
>>> next(it)
1
>>> next(it)
2
>>> next(it)
Traceback (most recent call last):
  File "", line 1, in 
StopIteration



I've never seen this second form in actual code. Does anyone use it, and 
if so, what use-cases do you have?



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


Re: Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread Grigory Javadyan
> Moreover I'm often able to keep in mind 2 (or more) opposite ideas or
> opinions of mine.
>

"""
To know and not to know, to be conscious of complete truthfulness
while telling carefully constructed lies, to hold simultaneously two
opinions which cancelled out, knowing them to be contradictory and
believing in both of them, to use logic against logic, to repudiate
morality while laying claim to it, to believe that democracy was
impossible and that the Party was the guardian of democracy...
"""
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread Dan Stromberg
On Thu, Mar 10, 2011 at 6:05 PM, alex23  wrote:

> On Mar 11, 11:58 am, n00m  wrote:
> > http://docs.python.org/py3k/whatsnew/3.0.html
> >
> > What's the fuss abt it? Imo all is ***OK*** with 3k (in the parts I
> > understand).
> > I even liked print as a function **more** than print as a stmt
> >
> > Now I think that Py3k is better than all prev pythons and cobras.
>
> So are you a troll or just incredibly fickle? It's barely been two
> weeks since your proud proclamation that Python 2.5 was BEST PYTHON
> EVAR and that "Python 3 is a tempor. lapse of reason":
>

"A foolish consistency is the hobgoblin of little minds, adored by little
statesmen and philosophers and divines."

http://www.bartleby.com/100/420.47.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread n00m
On Mar 11, 7:45 am, Terry Reedy  wrote:
> On 3/10/2011 8:58 PM, n00m wrote:
>
> >http://docs.python.org/py3k/whatsnew/3.0.html
>
> > What's the fuss abt it? Imo all is ***OK*** with 3k (in the parts I
> > understand).
> > I even liked print as a function **more** than print as a stmt
>
> > Now I think that Py3k is better than all prev pythons and cobras.
>
> I agree ;-). Now read What's New for 3.1 and 3.2 and load and use 3.2
> with numberous fixes and improvements to doc and code. 3.3 will be
> better yet.
>
> --
> Terry Jan Reedy

I'm still keeping opened in FF tab "What’s New In Python 3.0" :)
5 cups of coffee. None wiser. I wonder why am I so unluckily stupid?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What do you use with Python for GUI programming and why?

2011-03-10 Thread Dan Stromberg
You're probably best off with Pyjamas.  Then you get something that runs on
the web and on the desktop, from the same code - similar to GWT, but for
Python.  The desktop version runs overtop of CPython, the web version is
AJAX and is automatically translated from a very 2.x-ish dialect of Python
to Javascript.  Programming an AJAX app this way feels just like programming
to a set of desktop widgets - because they are also desktop widgets.

But what OSes are you using?

On Thu, Mar 10, 2011 at 6:25 PM, Robert  wrote:

> Is there a push to one toolkit or the other?
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread Terry Reedy

On 3/10/2011 8:58 PM, n00m wrote:

http://docs.python.org/py3k/whatsnew/3.0.html

What's the fuss abt it? Imo all is ***OK*** with 3k (in the parts I
understand).
I even liked print as a function **more** than print as a stmt

Now I think that Py3k is better than all prev pythons and cobras.


I agree ;-). Now read What's New for 3.1 and 3.2 and load and use 3.2 
with numberous fixes and improvements to doc and code. 3.3 will be 
better yet.


--
Terry Jan Reedy

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


Re: What do you use with Python for GUI programming and why?

2011-03-10 Thread Algis Kabaila
On Friday 11 March 2011 14:13:52 Paul Rubin wrote:
> Robert  writes:
> > Is there a push to one toolkit or the other?
> 
> Tkinter or a simple web app with cgihttpserver.  I haven't
> ever had occasion to write a fancy desktop app and I think
> of them as a mostly-obsolete medium, though I guess there
> are still some useful ones.
> 
> I have some interest in programming mobile phone apps in
> python, though haven't tried it yet.  I guess that would be
> with some QT toolkit (for Maemo/Meego) or some kind of Java
> bridge (for Android).

Start with PySide, which is a Nokia version of PyQt.  As such it 
has a Meego package as part of PySide (called by some "Pythton 
for Qt", a rather misleading name).

Al.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What do you use with Python for GUI programming and why?

2011-03-10 Thread Paul Rubin
Robert  writes:
> Is there a push to one toolkit or the other?

Tkinter or a simple web app with cgihttpserver.  I haven't ever had
occasion to write a fancy desktop app and I think of them as a
mostly-obsolete medium, though I guess there are still some useful ones.

I have some interest in programming mobile phone apps in python, though
haven't tried it yet.  I guess that would be with some QT toolkit (for
Maemo/Meego) or some kind of Java bridge (for Android).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread n00m
On Mar 11, 4:05 am, alex23  wrote:
> On Mar 11, 11:58 am, n00m  wrote:
>
> >http://docs.python.org/py3k/whatsnew/3.0.html
>
> > What's the fuss abt it? Imo all is ***OK*** with 3k (in the parts I
> > understand).
> > I even liked print as a function **more** than print as a stmt
>
> > Now I think that Py3k is better than all prev pythons and cobras.
>
> So are you a troll or just incredibly fickle? It's barely been two
> weeks since your proud proclamation that Python 2.5 was BEST PYTHON
> EVAR and that "Python 3 is a tempor. lapse of reason":
>
> http://groups.google.com/group/comp.lang.python/browse_frm/thread/76e...

The latter ("incredibly fickle").
Moreover I'm often able to keep in mind 2 (or more) opposite ideas or
opinions of mine.
But I am not a troll by any means. It's out of my interests.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What do you use with Python for GUI programming and why?

2011-03-10 Thread Littlefield, Tyler

Is there a push to one toolkit or the other?


TKInter from what I understand comes with Python already. There is also 
PYGui and WXPython; it really depends on what you want and what you like 
the best.


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


What do you use with Python for GUI programming and why?

2011-03-10 Thread Robert
Is there a push to one toolkit or the other?

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


Re: Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread MRAB

On 11/03/2011 02:05, alex23 wrote:

On Mar 11, 11:58 am, n00m  wrote:

http://docs.python.org/py3k/whatsnew/3.0.html

What's the fuss abt it? Imo all is ***OK*** with 3k (in the parts I
understand).
I even liked print as a function **more** than print as a stmt

Now I think that Py3k is better than all prev pythons and cobras.


So are you a troll or just incredibly fickle? It's barely been two
weeks since your proud proclamation that Python 2.5 was BEST PYTHON
EVAR and that "Python 3 is a tempor. lapse of reason":

http://groups.google.com/group/comp.lang.python/browse_frm/thread/76ec656df2353738#


He's come to his senses. :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: attach to process by pid?

2011-03-10 Thread Nobody
On Thu, 10 Mar 2011 23:55:51 +0100, Alexander Kapps wrote:

>>> I think he wants to attach to another process's stdin/stdout and
>>> read/write from/to them.
>>> I don't know if this is possible but it would be a great addition for
>>> psutil.
>>
>> It's not even a meaningful concept, let alone possible.
> 
> Unless I misunderstand something,

You do ...

> it is possible (at least on Linux):
> 
> Two terminal windows:
> 
> 1:
> alex@frittenbude:~$ grep foobar
> 
> 2:
> alex@frittenbude:~$ ps ax|grep 'grep foobar'
> 13075 pts/4S+ 0:00 grep --color=auto grep foobar
> alex@frittenbude:~$ echo foobar > /proc/13075/fd/0

The /proc//fd/ pseudo-files are just aliases for whatever "object"
(file, device, socket, ...) is attached to that descriptor. Writing to the
pseudo-file writes to the file, not to the descriptor. E.g.:

$ > foo.txt
$ sleep 100 < foo.txt &
[1] 17380
$ cat foo.txt
$ echo hello > /proc/17380/fd/0
$ cat foo.txt
hello

Similarly, if the process' standard input is a terminal, writing to
/proc//fd/0 will write to the terminal. It will not cause the data to
appear on the process' standard input.

There are a few situations where it will work (for some values of "work").

E.g. in the case where standard input is a file, writing to .../fd/0 will
write to the file. If you open .../fd/0 in append mode (or if the process
hasn't started reading it yet), the next time the process reads from the
file, it will read the data which was just written. Of course, this
assumes that you have write permission on the file and don't mind
modifying it (and, if you *don't* use append mode, overwriting it).

Also, if .../fd/0 is a pipe (named or otherwise), opening it for write
will get you the write end of the pipe, while the process' standard input
has the read end. This is the one case which will usually work as expected.

Essentially, you can read or write files (pipes, devices, etc). You can't
read or write to another process' descriptors.

In the case of a pipe, writing to the pipe itself Does The Right Thing. In
some other cases, you could write to some other object to get the desired
result; e.g. if the process' stdin is a pseudo-terminal, writing to the
corresponding master device would cause the data to appear on the process'
stdin (but I don't know if that's actually possible with Unix98-style
ptys).

In other cases, there's no way to achieve the desired result. E.g. if the
process' stdin is a physical terminal, the only way to cause the
device to generate data is by pressing keys on the terminal.

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


Re: Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread alex23
On Mar 11, 11:58 am, n00m  wrote:
> http://docs.python.org/py3k/whatsnew/3.0.html
>
> What's the fuss abt it? Imo all is ***OK*** with 3k (in the parts I
> understand).
> I even liked print as a function **more** than print as a stmt
>
> Now I think that Py3k is better than all prev pythons and cobras.

So are you a troll or just incredibly fickle? It's barely been two
weeks since your proud proclamation that Python 2.5 was BEST PYTHON
EVAR and that "Python 3 is a tempor. lapse of reason":

http://groups.google.com/group/comp.lang.python/browse_frm/thread/76ec656df2353738#
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Don't Want Visitor To See Nuttin'

2011-03-10 Thread alex23
Benjamin Kaplan  wrote:
> Typically, people developing web applications use a framework such as
> Django or TurboGears (or web.py or CherryPy or any of a dozen others)
> rather than just having the CGI scripts print stuff out.

You're fighting an uphill battle with that suggestion, it's been made
many, _many_ times before:

Tim Chase wrote:
> 4) Don't be afraid to reuse existing technologies:  could installing
> osCommerce on a $3/month web-server and tweaking the PHP code have sufficed
> for what you need?  Could you have used Django+Satchmo to get yourself up
> and running with proven code, tweaking what you need?  I remember you
> dismissing the suggestion to use existing web-frameworks.

Victor Subervi wrote:
> 
> Bringing that up again, are you? I was all but done with the shopping cart
> when you suggested I re-invent the wheel based on another technology. Yeah,
> sure, throw out 10,000 lines of the 12,000 line program so I can rebuild on
> a new technology. Brilliant, that. Thanks for the suggestion. Now, can we
> get back to my question?
> 

Once again: Victor Subervi has been crowd sourcing code for paid
projects on this list for 2-3 years now. He's made it very clear he
doesn't care about good practices, as anyone who ever engaged in the
pointless debate to get him to use bound parameters in his SQL
statements will recall.

He's comp.lang.python's version of Sisyphus. Or maybe Sisyphus'
boulder...I forget where I was going with this.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Passing Functions

2011-03-10 Thread MRAB

On 11/03/2011 01:13, yoro wrote:

Hi,

I am having an issue with passing values from one function to another
- I am trying to fill a list in one function using the values
contained in other functions as seen below:

infinity = 100
invalid_node = -1
startNode = 0

#Values to assign to each node
class Node:
  distFromSource = infinity
  previous = invalid_node
  visited = False

#read in all network nodes
def network():
 f = open ('network.txt', 'r')
 theNetwork = [[int(node) for node in line.split(',')] for line in
f.readlines()]
 print theNetwork

 return theNetwork

#for each node assign default values
def populateNodeTable():
 nodeTable = []
 index = 0
 f = open('network.txt', 'r')
 for line in f:
   node = map(int, line.split(','))
   nodeTable.append(Node())

   print "The previous node is " ,nodeTable[index].previous
   print "The distance from source is
" ,nodeTable[index].distFromSource
   index +=1
 nodeTable[startNode].distFromSource = 0

 return nodeTable

#find the nearest neighbour to a particular node
def nearestNeighbour(currentNode, theNetwork):
  nearestNeighbour = []
  nodeIndex = 0
  for node in nodeTable:
   if node != 0 and currentNode.visited == false:
  nearestNeighbour.append(nodeIndex)
  nodeIndex +=1

  return nearestNeighbour

if __name__ == "__main__":
 nodeTable = populateNodeTable()
 theNetwork = network()
 nearestNeighbour(currentNode, theNetwork, )

So, I am trying to look at the values provided by the network
function,  set all nodes to 'visited = false' in populateNodeTable
function and then determine the nodes' nearest neighbour by looking at
the values provided in the previous function, though I get this error
message:

if node != 0 and currentNode.visited == false:
AttributeError: 'int' object has no attribute 'visited'

I'm not sure what to try next


In nearestNeighbour, 'currentNode' is an int because that's what you're
passing in ... except that you aren't.

You're passing in the value of the global 'currentNode', which doesn't
exist. Perhaps you meant 'startNode'?

When I run the above program I get:

Traceback (most recent call last):
  File "C:\Documents and Settings\Administrator\Desktop\network.py", 
line 49, in 

nearestNeighbour(currentNode, theNetwork, )
NameError: name 'currentNode' is not defined
--
http://mail.python.org/mailman/listinfo/python-list


Just finished reading of "What’s New In Python 3.0"

2011-03-10 Thread n00m
http://docs.python.org/py3k/whatsnew/3.0.html

What's the fuss abt it? Imo all is ***OK*** with 3k (in the parts I
understand).
I even liked print as a function **more** than print as a stmt

Now I think that Py3k is better than all prev pythons and cobras.

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


Re: Passing Functions

2011-03-10 Thread alex23
On Mar 11, 11:13 am, yoro  wrote:
> Hi,
>
> I am having an issue with passing values from one function to another
> - I am trying to fill a list in one function using the values
> contained in other functions as seen below:
>
> infinity = 100
> invalid_node = -1
> startNode = 0
>
> #Values to assign to each node
> class Node:
>      distFromSource = infinity
>      previous = invalid_node
>      visited = False
>
> #read in all network nodes
> def network():
>     f = open ('network.txt', 'r')
>     theNetwork = [[int(node) for node in line.split(',')] for line in
> f.readlines()]
>     print theNetwork
>
>     return theNetwork
>
> #for each node assign default values
> def populateNodeTable():
>     nodeTable = []
>     index = 0
>     f = open('network.txt', 'r')
>     for line in f:
>       node = map(int, line.split(','))
>       nodeTable.append(Node())
>
>       print "The previous node is " ,nodeTable[index].previous
>       print "The distance from source is
> " ,nodeTable[index].distFromSource
>       index +=1
>     nodeTable[startNode].distFromSource = 0
>
>     return nodeTable
>
> #find the nearest neighbour to a particular node
> def nearestNeighbour(currentNode, theNetwork):
>      nearestNeighbour = []
>      nodeIndex = 0
>      for node in nodeTable:
>           if node != 0 and currentNode.visited == false:
>              nearestNeighbour.append(nodeIndex)
>              nodeIndex +=1
>
>      return nearestNeighbour
>
> if __name__ == "__main__":
>     nodeTable = populateNodeTable()
>     theNetwork = network()
>     nearestNeighbour(currentNode, theNetwork, )
>
> So, I am trying to look at the values provided by the network
> function,  set all nodes to 'visited = false' in populateNodeTable
> function and then determine the nodes' nearest neighbour by looking at
> the values provided in the previous function, though I get this error
> message:
>
> if node != 0 and currentNode.visited == false:
> AttributeError: 'int' object has no attribute 'visited'
>
> I'm not sure what to try next

Well, for starters, you're not actually instantiating any Nodes:

> theNetwork = [[int(node) for node in line.split(',')] for line in 
> f.readlines()]

You're returning a list of integers, none of which have the visited
attribute.

At the very least, you need a constructor on your Node class:

class Node:
  def __init__(self, distFromSource=infinity, previous=invalid_node,
visited=False):
self.distFromSource = distFromSource
self.previous = previous
self.visited = False

Now, I'm _assuming_ your network.txt file consists of 3 number
separated by commas, so in network() it should probably be something
like:

def network():
  with open('network.txt', 'r') as f:
network_data = ([int(node) for node in line.split(',')] for line
in f.readlines())
theNetwork = [Node(*data) for data in network_data]
  return theNetwork

The with statement ensures the file is closed at the end of the block.
'network_data' is a generator that reads each line and splits it into
a list of ints: '[x, y, z]'
'Node(*data)' takes a list of ints and creates a node from those
values.

Since both populateNodeTable and nearestNeighbour relay on nodeTable,
you might be better off making a NodeTable class.

None of this is tested, sorry, but hopefully it'll set you in the
right direction.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-10 Thread MRAB

On 11/03/2011 00:58, Justin Ezequiel wrote:

Greetings,

We have an old barcode program (MSDOS and source code unavailable.)
I've figured out how to populate the fields (by hacking into one of
the program's resource files.)
However, we still need to hit the following function keys in sequence.
F5, F2, F7
Is there a way to pipe said keys into the program?

I know it's not really a python problem but I got nowhere else to go.
I've tried other barcode solutions but none give the same output.


One (hacky) solution is to use the sendkeys module:

http://www.rutherfurd.net/python/sendkeys/

First enumerate the windows and get the title and handle of each:

import win32gui

def enum_windows(accept=None):
def callback(handle, data):
title = win32gui.GetWindowText(handle)
windows.append((title, handle))
windows = []
win32gui.EnumWindows(callback, None)
return windows

Identify the target window's handle by its title and give that window
the input focus:

win32gui.SetForegroundWindow(handle)

Then use the sendkeys module to simulate the keypresses.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Don't Want Visitor To See Nuttin'

2011-03-10 Thread Victor Subervi
On Thu, Mar 10, 2011 at 8:50 PM, Benjamin Kaplan
wrote:

> >   print "Content-Type: text/html"
> >   print
> >   print '''
> >  > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> > 
> > 
> >
> > and this has worked in the past, so I'm surprised it doesn't work here.
> > Don't understand what I've done wrong, nor why it prints the first line
> to
> > screen.
> > TIA,
> > Beno
> >
>
> Typically, people developing web applications use a framework such as
> Django or TurboGears (or web.py or CherryPy or any of a dozen others)
> rather than just having the CGI scripts print stuff out. Rather than
> having your Python script just print out a page, you make a template
> and then have a templating engine fill in the blanks with the values
> you provide. They'll also protect you from things like Injection
> attacks and cross-site scripting (if you don't know what those are,
> you're probably vulnerable to them).
>
> ok. I'm looking into Django. I'm ok for injections and I think most of my
data is sanitized. Now, can someone please address my question? See above.
TIA,
Beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Passing Functions

2011-03-10 Thread yoro
Hi,

I am having an issue with passing values from one function to another
- I am trying to fill a list in one function using the values
contained in other functions as seen below:

infinity = 100
invalid_node = -1
startNode = 0

#Values to assign to each node
class Node:
 distFromSource = infinity
 previous = invalid_node
 visited = False

#read in all network nodes
def network():
f = open ('network.txt', 'r')
theNetwork = [[int(node) for node in line.split(',')] for line in
f.readlines()]
print theNetwork

return theNetwork

#for each node assign default values
def populateNodeTable():
nodeTable = []
index = 0
f = open('network.txt', 'r')
for line in f:
  node = map(int, line.split(','))
  nodeTable.append(Node())

  print "The previous node is " ,nodeTable[index].previous
  print "The distance from source is
" ,nodeTable[index].distFromSource
  index +=1
nodeTable[startNode].distFromSource = 0

return nodeTable

#find the nearest neighbour to a particular node
def nearestNeighbour(currentNode, theNetwork):
 nearestNeighbour = []
 nodeIndex = 0
 for node in nodeTable:
  if node != 0 and currentNode.visited == false:
 nearestNeighbour.append(nodeIndex)
 nodeIndex +=1

 return nearestNeighbour

if __name__ == "__main__":
nodeTable = populateNodeTable()
theNetwork = network()
nearestNeighbour(currentNode, theNetwork, )

So, I am trying to look at the values provided by the network
function,  set all nodes to 'visited = false' in populateNodeTable
function and then determine the nodes' nearest neighbour by looking at
the values provided in the previous function, though I get this error
message:

if node != 0 and currentNode.visited == false:
AttributeError: 'int' object has no attribute 'visited'

I'm not sure what to try next

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


send function keys to a legacy DOS program

2011-03-10 Thread Justin Ezequiel
Greetings,

We have an old barcode program (MSDOS and source code unavailable.)
I've figured out how to populate the fields (by hacking into one of
the program's resource files.)
However, we still need to hit the following function keys in sequence.
F5, F2, F7
Is there a way to pipe said keys into the program?

I know it's not really a python problem but I got nowhere else to go.
I've tried other barcode solutions but none give the same output.


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


Re: Python Tools for Visual Studio from Microsoft - Free & Open Source

2011-03-10 Thread Patty


- Original Message - 
From: "Dino Viehland" 
To: "Patty" ; ; "roland garros" 
; 

Sent: Thursday, March 10, 2011 3:01 PM
Subject: RE: Python Tools for Visual Studio from Microsoft - Free & Open 
Source





Patty wrote:
Thanks so much for this reference - and the detailed further explanation! 
I

have a Windows 7 system and recently installed Visual Studio 2010 for the
SQL Server, Visual C/C++ and Visual Basic.  I would love to have this 
Python
tool installed under Visual Studio but a few questions:   1)  I have 
regular
Python installed not Cpython or Jpython or any other variant (have both 
2.6

and 3.2 versions) so would that be a problem and it won't install or won't
work?  2) I saw that this was a beta, would there be an automatic 
notification

that there are upgrades (I mean within the software itself) or would it be
advisable for me to wait until it goes final because I am relatively newer 
to

Python and maybe shouldn't be mucking with a beta of
something   3) there is a message bar at the top right corner of the web
page that a certain number of people are 'following this project' Is that
where you would rely on for upgrades notifications or what exactly would
you be following as far as a 'project' of this type?


CPython is actually regular Python - the C just clarifies that it's the 
implementation

written in C (vs. C#, Java, or Python).

Oh!  :)

There won't be any notification of updates via the software it's self but 
given
that you heard about the 1st release within days of it coming out my guess 
is

you'll hear about the updates as well.

You're right.

I'm not actually certain if following a project on CodePlex will give you 
e-mail
notifications or not.  I typically subscribe to CodePlex's RSS feed for 
projects
I'm implemented in - for example this feed 
http://pytools.codeplex.com/project/feeds/rss
includes all changes to the project.  There's other feeds below the RSS 
button

which track just new releases or other things.

I see - I am on a diff computer right now but want to check out this 
CodePlex site further

from the Windows 7 system later.  It looks interesting.

Thanks,

Patty 


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


Re: Compile time evaluation of dictionaries

2011-03-10 Thread Steven D'Aprano
On Thu, 10 Mar 2011 16:27:17 -0800, Chris Rebert wrote:


> 3. %-formatting is "obsolete and may go away in future versions of
> Python." (See
> http://docs.python.org/py3k/library/stdtypes.html#old-string-formatting-
operations
> )

There is an awful lot of opposition to that. If it ever happens, it 
probably won't happen until Python4, but even if it happens sooner, you 
could replace

"one:%(one)s two:%(two)s" % \
{"one": "is the loneliest number", "two": "can be as bad as one"}

with the format string equivalent, still using literals, and the same 
constant-folding optimization could occur.

"one:{one} two:{two}".format(
**{"one": "is the loneliest number", "two": "can be as bad as one"})

Admittedly, it would require a significantly smarter peephole optimizer 
to recognise this as a constant, which pushes up the complexity for no 
additional gain, but the principle still applies.



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


Re: Don't Want Visitor To See Nuttin'

2011-03-10 Thread Benjamin Kaplan
On Thu, Mar 10, 2011 at 6:48 PM, Victor Subervi  wrote:
> On Wed, Mar 9, 2011 at 5:33 PM, Ian  wrote:
>>
>> On 09/03/2011 21:01, Victor Subervi wrote:
>>>
>>> The problem is that it prints "Content-Type: text/html" to the screen
>>
>> If you can see what is intended to be a header, then it follows that you
>> are not sending the header correctly.
>>
>> Sorry - can't tell you how to send a header. You don't say what framework
>> you are using.
>
> Framework? Python on CentOS, if that's what you're asking. From what I know
> of python, one always begins a web page with something like this:
>
>   print "Content-Type: text/html"
>   print
>   print '''
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> 
> 
>
> and this has worked in the past, so I'm surprised it doesn't work here.
> Don't understand what I've done wrong, nor why it prints the first line to
> screen.
> TIA,
> Beno
>

Typically, people developing web applications use a framework such as
Django or TurboGears (or web.py or CherryPy or any of a dozen others)
rather than just having the CGI scripts print stuff out. Rather than
having your Python script just print out a page, you make a template
and then have a templating engine fill in the blanks with the values
you provide. They'll also protect you from things like Injection
attacks and cross-site scripting (if you don't know what those are,
you're probably vulnerable to them).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compile time evaluation of dictionaries

2011-03-10 Thread Chris Rebert
On Thu, Mar 10, 2011 at 4:15 PM, Steven D'Aprano
 wrote:
> On Thu, 10 Mar 2011 17:40:40 -0500, Terry Reedy wrote:
>> On 3/10/2011 11:23 AM, Gerald Britton wrote:
>>> Today I noticed that an expression like this:
>>>
>>> "one:%(one)s two:%(two)s" % {"one": "is the loneliest number", "two":
>>> "can be as bad as one"}
>>>
>>> could be evaluated at compile time, but is not:
>>
>> In fact, it could be evaluated at writing time ;-).
>
> True, but why do stuff when the compiler can do it for you?

> I don't see any reason why Python couldn't optimize the above at compile-
> time, and I can only think of two reasons why it won't:
>
> - lack of interest from anyone willing and able to write a patch;
> - the added complexity may be more than the benefit gained.

3. %-formatting is "obsolete and may go away in future versions of Python."
(See 
http://docs.python.org/py3k/library/stdtypes.html#old-string-formatting-operations
)

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


Re: Compile time evaluation of dictionaries

2011-03-10 Thread Steven D'Aprano
On Thu, 10 Mar 2011 17:40:40 -0500, Terry Reedy wrote:

> On 3/10/2011 11:23 AM, Gerald Britton wrote:
>> Today I noticed that an expression like this:
>>
>> "one:%(one)s two:%(two)s" % {"one": "is the loneliest number", "two":
>> "can be as bad as one"}
>>
>> could be evaluated at compile time, but is not:
> 
> In fact, it could be evaluated at writing time ;-). 

True, but why do stuff when the compiler can do it for you? Any constant 
folding could be done at writing time, but readability and maintenance 
dictates that we write something like:

C = 1.0/7

rather than

C = 0.14285714285714285


> This would be an
> example of constant folding, except that a dict is not, in itself, a
> constant.

Nevertheless, since the dict only exists for a single operation, it might 
as well be a constant. In general, Python can't safely make many 
assumptions about compile-time behaviour, since nearly anything can be 
modified at run-time, but the behaviour of built-in literals is one thing 
that can't change. 

I don't see any reason why Python couldn't optimize the above at compile-
time, and I can only think of two reasons why it won't:

- lack of interest from anyone willing and able to write a patch;
- the added complexity may be more than the benefit gained.


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


Madam Bovary

2011-03-10 Thread n00m
Just let you know: I'm on her (Emma's) side.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: attach to process by pid?

2011-03-10 Thread James Mills
On Fri, Mar 11, 2011 at 9:30 AM, Grant Edwards  wrote:
> No it doesn't.  Try writing something other than "foobar".

You've demonstrated a case where this doesn't work :)

cheers
James

-- 
-- James Mills
--
-- "Problems are solved by method"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Don't Want Visitor To See Nuttin'

2011-03-10 Thread Victor Subervi
On Wed, Mar 9, 2011 at 5:33 PM, Ian  wrote:

> On 09/03/2011 21:01, Victor Subervi wrote:
>
>> The problem is that it prints "Content-Type: text/html" to the screen
>>
> If you can see what is intended to be a header, then it follows that you
> are not sending the header correctly.
>
> Sorry - can't tell you how to send a header. You don't say what framework
> you are using.
>

Framework? Python on CentOS, if that's what you're asking. From what I know
of python, one always begins a web page with something like this:

  print "Content-Type: text/html"
  print
  print '''
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>



and this has worked in the past, so I'm surprised it doesn't work here.
Don't understand what I've done wrong, nor why it prints the first line to
screen.
TIA,
Beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: attach to process by pid?

2011-03-10 Thread Grant Edwards
On 2011-03-10, James Mills  wrote:
> On Fri, Mar 11, 2011 at 8:55 AM, Alexander Kapps  wrote:
>> On 10.03.2011 23:25, Nobody wrote:
>> Unless I misunderstand something, it is possible (at least on Linux):
>>
>> Two terminal windows:
>>
>> 1:
>> alex@frittenbude:~$ grep foobar
>>
>> 2:
>> alex@frittenbude:~$ ps ax|grep 'grep foobar'
>> 13075 pts/4 ?? ??S+ ?? ?? 0:00 grep --color=auto grep foobar
>> alex@frittenbude:~$ echo foobar > /proc/13075/fd/0
>
> This works fine on the Linux platform

No it doesn't.  Try writing something other than "foobar".

-- 
Grant Edwards   grant.b.edwardsYow! An INK-LING?  Sure --
  at   TAKE one!!  Did you BUY any
  gmail.comCOMMUNIST UNIFORMS??
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: attach to process by pid?

2011-03-10 Thread Grant Edwards
On 2011-03-10, Alexander Kapps  wrote:
> On 10.03.2011 23:25, Nobody wrote:
>> On Thu, 10 Mar 2011 20:22:11 +0100, Giampaolo Rodol?? wrote:
>>
>>> I think he wants to attach to another process's stdin/stdout and
>>> read/write from/to them. I don't know if this is possible but it
>>> would be a great addition for psutil.
>>
>> It's not even a meaningful concept, let alone possible.
>
> Unless I misunderstand something, it is possible (at least on Linux):

Sometimes.  [See below.]

> Two terminal windows:
>
> 1:
> alex@frittenbude:~$ grep foobar
>
> 2:
> alex@frittenbude:~$ ps ax|grep 'grep foobar'
> 13075 pts/4S+ 0:00 grep --color=auto grep foobar
> alex@frittenbude:~$ echo foobar > /proc/13075/fd/0
>
> That this is *highly* system dependent, problematic in many regards 
> and just terrible hackery is another issue.

That doesn't work for me:

Terminal 1:

   $ grep foobar
   asdf

Terminal 1:
   $ ps axf | grep "grep foobar"
7203 pts/4S+ 0:00  \_ grep foobar
7205 pts/5S+ 0:00  \_ grep grep foobar

   $ echo "asdf" >/proc/7203/fd/0

What the echo did was write to the tty device from which the "grep" is
reading.  The string "asdf" went directly to the tty.  It didn't go to
grep's stdin (grep wouldn't have displayed it).


It _does_ work on processes who's stdin is an anonymous pipe:

terminal window 1:

   $ (while sleep 1; do date; done) | grep foobar
   foobar
   asdffoobarqwer

terminal window 2:

   $ ps axf | grep "grep foobar"
7229 pts/4S+ 0:00  \_ grep foobar
7268 pts/5S+ 0:00  \_ grep grep foobar
   $ echo "asdf" >/proc/7229/fd/0
   $ echo "foobar" >/proc/7229/fd/0
   $ echo "qwer" >/proc/7229/fd/0
   $ echo "asdffoobarqwer" >/proc/7229/fd/0

We know that the data written to /proc/7229/fd/0 was going to grep's
stdin, since lines with foobar were printed and lines without weren't.
   
I'll do an 'echo "hi there" >/proc/fd/7346/fd/0 where 7346 is the pid
of the instance of the "jed" text editor that I'm using to edit this
post. The "hi there" string showed up in my terminal window, but it
didn't actually get inserted in the file, because "jed" didn't see it.

/proc/fd/7346/fd/0 points to /dev/pts/0.  Writing to /dev/pts/0 sends
data to the terminal window, _not_ to process 7346's stdin.  Writing
to /proc/fd/7346/fd/1 does the same thing.  Writing to
/proc/fd/7346/fd/2 sends the data to the tty where the write was done,
since /proc/fd/7346/fd/2 points to /dev/tty, and /dev/tty points to
different things depending on who's doing the writing.

There are _some_ cases where you can write to /proc//fd/0 and the
program specified by  sees the data on it's stdin. But, it doesn't
work in many common cases.

-- 
Grant Edwards   grant.b.edwardsYow! Did an Italian CRANE
  at   OPERATOR just experience
  gmail.comuninhibited sensations in
   a MALIBU HOT TUB?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Tools for Visual Studio from Microsoft - Free & Open Source

2011-03-10 Thread Terry Reedy

On 3/10/2011 5:51 PM, Patty wrote:


Thanks so much for this reference - and the detailed further
explanation! I have a Windows 7 system and recently installed Visual
Studio 2010 for the SQL Server, Visual C/C++ and Visual Basic. I would
love to have this Python tool installed under Visual Studio but a few
questions: 1) I have regular Python installed not Cpython


CPython *is* regular Python!
Which is to say, 'python*' binaries are compiled from the CPython codebase.

--
Terry Jan Reedy

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


Re: attach to process by pid?

2011-03-10 Thread James Mills
On Fri, Mar 11, 2011 at 8:55 AM, Alexander Kapps  wrote:
> On 10.03.2011 23:25, Nobody wrote:
> Unless I misunderstand something, it is possible (at least on Linux):
>
> Two terminal windows:
>
> 1:
> alex@frittenbude:~$ grep foobar
>
> 2:
> alex@frittenbude:~$ ps ax|grep 'grep foobar'
> 13075 pts/4    S+     0:00 grep --color=auto grep foobar
> alex@frittenbude:~$ echo foobar > /proc/13075/fd/0

This works fine on the Linux platform (perhaps other UNIX-like
platforms have similar concepts). You're simply writing to
the processes's stdin (file descriptor of 0)

Probably not a portable solution.

cheers
James

-- 
-- James Mills
--
-- "Problems are solved by method"
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python Tools for Visual Studio from Microsoft - Free & Open Source

2011-03-10 Thread Dino Viehland


Patty wrote:
> Thanks so much for this reference - and the detailed further explanation!  I
> have a Windows 7 system and recently installed Visual Studio 2010 for the
> SQL Server, Visual C/C++ and Visual Basic.  I would love to have this Python
> tool installed under Visual Studio but a few questions:   1)  I have regular
> Python installed not Cpython or Jpython or any other variant (have both 2.6
> and 3.2 versions) so would that be a problem and it won't install or won't
> work?  2) I saw that this was a beta, would there be an automatic notification
> that there are upgrades (I mean within the software itself) or would it be
> advisable for me to wait until it goes final because I am relatively newer to
> Python and maybe shouldn't be mucking with a beta of
> something   3) there is a message bar at the top right corner of the web
> page that a certain number of people are 'following this project' Is that
> where you would rely on for upgrades notifications or what exactly would
> you be following as far as a 'project' of this type?

CPython is actually regular Python - the C just clarifies that it's the 
implementation
written in C (vs. C#, Java, or Python).  

There won't be any notification of updates via the software it's self but given
that you heard about the 1st release within days of it coming out my guess is
you'll hear about the updates as well.  

I'm not actually certain if following a project on CodePlex will give you e-mail
notifications or not.  I typically subscribe to CodePlex's RSS feed for projects
I'm implemented in - for example this feed 
http://pytools.codeplex.com/project/feeds/rss 
includes all changes to the project.  There's other feeds below the RSS button
which track just new releases or other things.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: attach to process by pid?

2011-03-10 Thread Alexander Kapps

On 10.03.2011 23:25, Nobody wrote:

On Thu, 10 Mar 2011 20:22:11 +0100, Giampaolo Rodolà wrote:


I think he wants to attach to another process's stdin/stdout and
read/write from/to them.
I don't know if this is possible but it would be a great addition for psutil.


It's not even a meaningful concept, let alone possible.


Unless I misunderstand something, it is possible (at least on Linux):

Two terminal windows:

1:
alex@frittenbude:~$ grep foobar

2:
alex@frittenbude:~$ ps ax|grep 'grep foobar'
13075 pts/4S+ 0:00 grep --color=auto grep foobar
alex@frittenbude:~$ echo foobar > /proc/13075/fd/0

That this is *highly* system dependent, problematic in many regards 
and just terrible hackery is another issue.


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


Re: Python Tools for Visual Studio from Microsoft - Free & Open Source

2011-03-10 Thread Patty


- Original Message - 
From: 

To: "roland garros" ; 
Sent: Thursday, March 10, 2011 2:03 AM
Subject: Re: Python Tools for Visual Studio from Microsoft - Free & Open 
Source




Roland,


http://pytools.codeplex.com


Looks very impressive! Thank you for sharing this work.

For others following this thread

- this add-in to Visual Studio works with CPython 2.5 - 3.2 and is not
dependent on .NET or IronPython

- this project also brings HPC (high performance computing) and MPI
support to CPython using the latest Microsoft API's for large scale data
and computing

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




Thanks so much for this reference - and the detailed further explanation!  I 
have a Windows 7 system and recently installed Visual Studio 2010 for the 
SQL Server, Visual C/C++ and Visual Basic.  I would love to have this Python 
tool installed under Visual Studio but a few questions:   1)  I have regular 
Python installed not Cpython or Jpython or any other variant (have both 2.6 
and 3.2 versions) so would that be a problem and it won't install or won't 
work?  2) I saw that this was a beta, would there be an automatic 
notification that there are upgrades (I mean within the software itself) or 
would it be advisable for me to wait until it goes final because I am 
relatively newer to Python and maybe shouldn't be mucking with a beta of 
something   3) there is a message bar at the top right corner of the web 
page that a certain number of people are 'following this project' Is that 
where you would rely on for upgrades notifications or what exactly would you 
be following as far as a 'project' of this type?


Regards,

Patty 


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


Re: Compile time evaluation of dictionaries

2011-03-10 Thread Terry Reedy

On 3/10/2011 11:23 AM, Gerald Britton wrote:

Today I noticed that an expression like this:

"one:%(one)s two:%(two)s" % {"one": "is the loneliest number", "two":
"can be as bad as one"}

could be evaluated at compile time, but is not:


In fact, it could be evaluated at writing time ;-).
This would be an example of constant folding, except that a dict is not, 
in itself, a constant.



dis(compile(

... '"one:%(one)s two:%(two)s" % {"one": "is the loneliest number",
"two": "can be as bad as one"}',
... '','exec'))
  1   0 LOAD_CONST   0 ('one:%(one)s two:%(two)s')
  3 BUILD_MAP2
  6 LOAD_CONST   1 ('is the loneliest number')
  9 LOAD_CONST   2 ('one')
 12 STORE_MAP
 13 LOAD_CONST   3 ('can be as bad as one')
 16 LOAD_CONST   4 ('two')
 19 STORE_MAP
 20 BINARY_MODULO
 21 POP_TOP
 22 LOAD_CONST   5 (None)
 25 RETURN_VALUE




Any idea why Python works this way?


Because that is how the language is defined.


 I see that, in 3.2, an
optimization was done for sets (See "Optimizations" at
http://docs.python.org/py3k/whatsnew/3.2.html) though I do not see
anything similar for dictionaries.


I presume you mean this:

"Python’s peephole optimizer now recognizes patterns such x in {1, 2, 3} 
as being a test for membership in a set of constants. The optimizer 
recasts the set as a frozenset and stores the pre-built constant.


Now that the speed penalty is gone, it is practical to start writing 
membership tests using set-notation. This style is both semantically 
clear and operationally fast:


extension = name.rpartition('.')[2]
if extension in {'xml', 'html', 'xhtml', 'css'}:
handle(name)

(Patch and additional tests contributed by Dave Malcolm; issue 6690)."

This is possible because: sets have a frozen counterpart, and cpython 
*sometimes* follows an 'as if' rule for optimizations. There is no 
frozendict, so the same pattern could not be followed.


Note first that the optimization is *not* an example of constant 
folding, but recognition that an unbound mutable cannot be mutated, and 
therefore, if all its contents are fixed, can be 'cast' to constant form 
at compile time.


Note second that the optimization does not apply to all such set 
instances, but only to this particular 'in' context. It follows a 
similar optimization for turning lists into tuples (although in this 
latter case, the programmer could have remembered to use () instead of []).


The optimization *did* happen because various people started an issue, 
wrote a patch, reviewed the patch, and committed it to the cpython 
source. You might read the issue if you have not:


http://bugs.python.org/issue6690

Terry Jan Reedy


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


Re: attach to process by pid?

2011-03-10 Thread Nobody
On Thu, 10 Mar 2011 20:22:11 +0100, Giampaolo Rodolà wrote:

> I think he wants to attach to another process's stdin/stdout and
> read/write from/to them.
> I don't know if this is possible but it would be a great addition for psutil.

It's not even a meaningful concept, let alone possible.

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


Re: how to read the last line of a huge file???

2011-03-10 Thread tkp...@hotmail.com
There is a problem, and it's a Python 3.2 problem. All the solutions
presented here work perfectly well in Python 2.7.1, and they all fail
at exactly the same point in Python 3.2 - it's the line that tries to
seek from the end. e.g.
f.seek(offset, os.SEEK_END)

I'll register this as a Python bug. Thank you, everyone, for the help
and guidance.

Sincerely


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


Re: Python Tools for Visual Studio from Microsoft - Free & Open Source

2011-03-10 Thread Verde Denim
On Thu, Mar 10, 2011 at 12:54 AM, roland garros
wrote:

>
> FYI...
>
> http://pytools.codeplex.com
>
> Enjoy!
> --
> http://mail.python.org/mailman/listinfo/python-list
>

There goes the neighborhood...:P
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tk MouseWheel Support

2011-03-10 Thread Alexander Kapps

On 10.03.2011 21:28, Richard Holmes wrote:

I am trying to use the mouse wheel to scroll a list box, but I'm not
getting the event. When I bind "" to the listbox I get the
event and I'm able to scroll using yview_scroll. I've tried binding
"MouseWheel" and"", and I've also tried"" and
"" even though I'm using Windows (XP, if that makes a
difference). None of these works (I'm using print to see if I got to
an event handler, and there's no printout).

TIA for any help!

Dick


Can you post your code please (if it's too long, strip it down to 
the smallest program which still shows the problem.)


On Ubuntu 10.04, Python 2.6.5, the Listbox already recognizes the 
mouse wheel. Listbox aside, the following works here:



import Tkinter as tk

def wheel_up(event):
print "wheel_up", event

def wheel_down(event):
print "wheel_down", event

root = tk.Tk()
root.bind("", wheel_up)
root.bind("", wheel_down)
root.mainloop()
--
http://mail.python.org/mailman/listinfo/python-list


Re: Tk MouseWheel Support

2011-03-10 Thread MRAB

On 10/03/2011 20:28, Richard Holmes wrote:

I am trying to use the mouse wheel to scroll a list box, but I'm not
getting the event. When I bind "" to the listbox I get the
event and I'm able to scroll using yview_scroll. I've tried binding
"MouseWheel" and"", and I've also tried"" and
"" even though I'm using Windows (XP, if that makes a
difference). None of these works (I'm using print to see if I got to
an event handler, and there's no printout).

TIA for any help!

Dick


Google found this:

Using the Mouse Wheel with Tkinter (Python)
http://www.daniweb.com/software-development/python/code/217059

which I adapted to get this (tested on XP with Python 2.7):

import Tkinter as tk

def mouse_wheel(event):
dir = 0
# respond to Linux or Windows wheel event
if event.num == 5 or event.delta == -120:
dir = 1
if event.num == 4 or event.delta == 120:
dir = -1
listbox.yview_scroll(dir, "units")

root = tk.Tk()
root.title('turn mouse wheel')
root['bg'] = 'darkgreen'

# with Windows OS
root.bind("", mouse_wheel)
# with Linux OS
root.bind("", mouse_wheel)
root.bind("", mouse_wheel)

listbox = tk.Listbox(root)
listbox.pack()
for i in range(100):
listbox.insert(tk.END, str(i))

root.mainloop()
--
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-10 Thread Martin Gregorie
On Thu, 10 Mar 2011 20:31:11 +, Grant Edwards wrote:

> You tricked me by saying only DEC VAX/VMS programmers would know what it
> was.  In fact, many, many Unix programmers knew about curses (and still
> do) and very few VMS programmers ever did.  C wasn't very widely used
> under VMS, and VMS had it's own screen formatting and form handling
> libraries.
>
>From the context the "only DEC VAX/VMS programmers" remark applied to the 
VT-100. However, the OP is wrong about that - VT-100s were well-known and 
popular devices in the 8-bit microprocessor world too, together with 
assorted clones. In addition, many other terminals had a VT-100 emulation 
mode. IIRC all the Wyse terminals had that.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org   |
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tk MouseWheel Support

2011-03-10 Thread Corey Richardson
On 03/10/2011 03:35 PM, Corey Richardson wrote:
> Middle button is Button-3 IIRC, and I think it'd be MouseUp and
> MouseDown. I'm really not sure though.

It's Button-2 rather.

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


Re: Tk MouseWheel Support

2011-03-10 Thread Corey Richardson
On 03/10/2011 03:28 PM, Richard Holmes wrote:
> I am trying to use the mouse wheel to scroll a list box, but I'm not
> getting the event. When I bind "" to the listbox I get the
> event and I'm able to scroll using yview_scroll. I've tried binding
> "MouseWheel" and "", and I've also tried "" and
> "" even though I'm using Windows (XP, if that makes a
> difference). None of these works (I'm using print to see if I got to
> an event handler, and there's no printout).
> 
> TIA for any help!
> 
> Dick

Middle button is Button-3 IIRC, and I think it'd be MouseUp and
MouseDown. I'm really not sure though.


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


Re: Purely historic question: VT200 text graphic programming

2011-03-10 Thread Grant Edwards
On 2011-03-10, GrayShark  wrote:
> On Thu, 10 Mar 2011 18:02:41 +, Grant Edwards wrote:
>
>> On 2011-03-10, Adam Tauno Williams  wrote:
>>> On Thu, 2011-03-10 at 00:38 -0600, GrayShark wrote:
 Once, many, many, years ago, I programmed some type of 'graphical'
 interface on a VT200 terminal (only DEC VAX/VMS programmers are going
 to know what this is). Question. What was the library I linked
 against? Yes, you remember, painting boxes with ascii and the superset
 of ascii.
>>>
>>> It was curses [ these days people typically use "ncurses" ].
>> 
>> Curses that can't be what the OP is referring to.
>> 
>> Curses wasn't a VAX/VMS thing, it was a Unix thing (that has been ported
>> to other platforms as well).
[...]

> Actually it was curses;

You tricked me by saying only DEC VAX/VMS programmers would know what
it was.  In fact, many, many Unix programmers knew about curses (and
still do) and very few VMS programmers ever did.  C wasn't very widely
used under VMS, and VMS had it's own screen formatting and form
handling libraries.

> it came with the C compiler.

Yep, along with a bunch of other libraries that originated in the Unix
world.  For the full dose of surrealism, you could install DECShell
and have a pretty complete Bourne shell command-line environment with
the whole suite of v7 utilities.  The process-creation overhead on VMS
was _brutal_ and shell scripts ran dog-slow -- but they ran.

> What was more entertaining was that I using a legacy Fortran program,
> DEC Fortran (actually had pointers!) and linking to a C curses
> interface.
>
> Most exciting. The rest of the project was about realtime data
> collect and processing on a microvax III. In the mid-90, that wasn't
> doable at 1 milliscond time steps. VMS was just not realtime aware.

-- 
Grant Edwards   grant.b.edwardsYow! I'm receiving a coded
  at   message from EUBIE BLAKE!!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Tk MouseWheel Support

2011-03-10 Thread Richard Holmes
I am trying to use the mouse wheel to scroll a list box, but I'm not
getting the event. When I bind "" to the listbox I get the
event and I'm able to scroll using yview_scroll. I've tried binding
"MouseWheel" and "", and I've also tried "" and
"" even though I'm using Windows (XP, if that makes a
difference). None of these works (I'm using print to see if I got to
an event handler, and there's no printout).

TIA for any help!

Dick

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


Re: Purely historic question: VT200 text graphic programming

2011-03-10 Thread Grant Edwards
On 2011-03-10, Charles Turner  wrote:
> On Thu, 10 Mar 2011 00:38:11 -0600, GrayShark 
> declaimed the following in gmane.comp.python.general:
>
>> Once, many, many, years ago, I programmed some type of 'graphical'
>> interface on a VT200 terminal
>
> A wild guess: Prestel? Bildschirmtext? Telidon? Teletex? NAPLPS?

Eh?  Those are viddotex/teletext systems aren't they?

I thought the OP was talking about a character-based windowing and
form-handling library used by applications that ran under VAX/VMS on
vt200 terminals.  The vt200 wasn't a TV.  It was a character-based,
mostly-ANSI-escape-sequence, computer terminal connected via async
serial (RS-232 typically) to a mini/mainframe computer (a DEC VAX
running VMS in this context).

-- 
Grant Edwards   grant.b.edwardsYow! Gibble, Gobble, we
  at   ACCEPT YOU ...
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-10 Thread GrayShark
On Thu, 10 Mar 2011 18:02:41 +, Grant Edwards wrote:

> On 2011-03-10, Adam Tauno Williams  wrote:
>> On Thu, 2011-03-10 at 00:38 -0600, GrayShark wrote:
>>> Once, many, many, years ago, I programmed some type of 'graphical'
>>> interface on a VT200 terminal (only DEC VAX/VMS programmers are going
>>> to know what this is). Question. What was the library I linked
>>> against? Yes, you remember, painting boxes with ascii and the superset
>>> of ascii.
>>
>> It was curses [ these days people typically use "ncurses" ].
> 
> Curses that can't be what the OP is referring to.
> 
> Curses wasn't a VAX/VMS thing, it was a Unix thing (that has been ported
> to other platforms as well).  VMS did have it's own text-screen-widget
> library sort of like curses+panel, but I don't remember what it was
> called.  Some googling coughs up FMS and DECforms.  I vageuly remember
> using one or the other, but that was a long time ago (25 years).
> 
> At first first I thought he was talking about ReGIS, but that wasn't
> available on the vt200 (it was on vt240/330/340).

Actually it was curses; it came with the C compiler. What was more 
entertaining was that I using a legacy Fortran program, DEC Fortran 
(actually had pointers!) and linking to a C curses interface.

Most exciting. The rest of the project was about realtime data collect
and processing on a microvax III. In the mid-90, that wasn't doable at
1 milliscond time steps. VMS was just not realtime aware.

GrayShark.



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


Re: Tcl wasn't installed properly

2011-03-10 Thread Steve
On Mar 10, 11:30 am, Steve  wrote:
> On Mar 10, 11:00 am, MRAB  wrote:
>
>
>
>
>
>
>
>
>
> > On 10/03/2011 15:39, Steve wrote:
>
> > > I'm a frequent user of matplotlib on my Windows XP machine.  I
> > > recently attempted to install a program that modified my Tcl
> > > installation, and I now get an error message when I attempt to plot
> > > anything in matplotlib.  Here is the error message:
> > > ---
> > > Traceback (most recent call last):
> > >    File "", line 1, in
> > >    File "C:\Python25\lib\lib-tk\Tkinter.py", line 3758, in _test
> > >      root = Tk()
> > >    File "C:\Python25\lib\lib-tk\Tkinter.py", line 1647, in __init__
> > >      self.tk = _tkinter.create(screenName, baseName, className,
> > > interactive, want
> > > objects, useTk, sync, use)
> > > _tkinter.TclError: Can't find a usable init.tcl in the following
> > > directories:
> > >      {C:\Program Files\Tcl\lib\tcl8.3} {C:\Program Files\Tcl\lib
> > > \tcl8.3} {C:/Prog
> > > ram Files/Tcl/lib/tcl8.4} C:/Python25/lib/tcl8.4 C:/lib/tcl8.4 C:/
> > > library
>
> > > This probably means that Tcl wasn't installed properly.
> > > ---
> > > I attempted a complete reinstall of python (hoping it would reinstall
> > > Tcl with correct file paths), but I get the same error.  Any
> > > suggestions would be appreciated.
> > > Thanks!
>
> > In my installation Tcl is in "C:\Python25\tcl", if that helps.
>
> That is where my installation is located too.  Why is it insisting on
> looking in "C:\Python25\lib\tcl8.4"?  Can I change where it is looking?

I figured out the solution.  The program I installed must have changed
my windows path names.  I changed TCL_LIBRARY and TK_LIBRARY to the
location of my tcl installation, and it works fine now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: attach to process by pid?

2011-03-10 Thread Giampaolo Rodolà
I think he wants to attach to another process's stdin/stdout and
read/write from/to them.
I don't know if this is possible but it would be a great addition for psutil.


--- Giampaolo
http://code.google.com/p/pyftpdlib/
http://code.google.com/p/psutil/




2011/3/10 Miki Tebeka :
>> Is there any way to attach to an already running process by pid? I want to 
>> send
>> commands from python to an application that is already running. I don't want 
>> to
>> give the command name to subprocess.Popen.
> We probably need more information. What do you mean by "send commands"? (What 
> was your work flow if you could give the command name to Popen?)
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: attach to process by pid?

2011-03-10 Thread bobicanprogram
On Mar 9, 1:28 pm, Danny Shevitz  wrote:
> > Have a look at the SIMPL toolkit.
>
> http://www.icanprogram.com/06py/lesson1/lesson1.html
>
>
>
> > This should be able to do exactly what you want.
>
> > bob
>
> Does this work on Mac OS X?
>
> thanks,
> Danny


I'm not aware of any ports of the SIMPL toolkit to the MacOSX.
However, the core SIMPL library doesn't depend on anything facier than
a named pipe or fifo and shared memory.   If you'd like to be the test
bed I can ask around the SIMPL project to see if anyone wants to take
a crack at porting the SIMPL-Python stuff to MacOSX.

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


Re: Purely historic question: VT200 text graphic programming

2011-03-10 Thread Charles Turner

On Thu, 10 Mar 2011 00:38:11 -0600, GrayShark 
declaimed the following in gmane.comp.python.general:


Once, many, many, years ago, I programmed some type of 'graphical'
interface on a VT200 terminal


A wild guess: Prestel? Bildschirmtext? Telidon? Teletex? NAPLPS?

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


Re: Purely historic question: VT200 text graphic programming

2011-03-10 Thread Grant Edwards
On 2011-03-10, Adam Tauno Williams  wrote:
> On Thu, 2011-03-10 at 00:38 -0600, GrayShark wrote: 
>> Once, many, many, years ago, I programmed some type of 'graphical' 
>> interface on a VT200 terminal (only DEC VAX/VMS programmers are going to 
>> know what this is). Question. What was the library I linked against?
>> Yes, you remember, painting boxes with ascii and the superset of ascii. 
>
> It was curses [ these days people typically use "ncurses" ].

Curses that can't be what the OP is referring to.

Curses wasn't a VAX/VMS thing, it was a Unix thing (that has been
ported to other platforms as well).  VMS did have it's own
text-screen-widget library sort of like curses+panel, but I don't
remember what it was called.  Some googling coughs up FMS and
DECforms.  I vageuly remember using one or the other, but that was a
long time ago (25 years).

At first first I thought he was talking about ReGIS, but that wasn't
available on the vt200 (it was on vt240/330/340).

-- 
Grant Edwards   grant.b.edwardsYow! I didn't order any
  at   WOO-WOO ... Maybe a YUBBA
  gmail.com... But no WOO-WOO!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I found some very odd behaviour in Python's very basic types

2011-03-10 Thread John Roth
On Mar 9, 10:47 pm, Sunjay Varma  wrote:
> For some reason, sub-classing and overwriting a built-in type does not
> change the behavior of the literal. Logically speaking, overwriting a
> name, such as str, should delete the basic str type, and replace it
> with the new class or object put in its place. For some reason though,
> even though the interpreter says that str == type("hello"),
> overwriting the str name changes nothing in the literal. Is this a
> bug? I'm not sure.
>
> -Sunjay03

This is neither a bug nor a feature, it's simply the way that
Python works. Literals are handled during compilation; the built-in
types are run-time objects.

Python is not a language where a script can change compile-time
behavior. Doing that would make it a very different language, and
would put it into a very different niche in the language ecology.

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


Re: Tcl wasn't installed properly

2011-03-10 Thread Steve
On Mar 10, 11:00 am, MRAB  wrote:
> On 10/03/2011 15:39, Steve wrote:
>
>
>
>
>
>
>
>
>
> > I'm a frequent user of matplotlib on my Windows XP machine.  I
> > recently attempted to install a program that modified my Tcl
> > installation, and I now get an error message when I attempt to plot
> > anything in matplotlib.  Here is the error message:
> > ---
> > Traceback (most recent call last):
> >    File "", line 1, in
> >    File "C:\Python25\lib\lib-tk\Tkinter.py", line 3758, in _test
> >      root = Tk()
> >    File "C:\Python25\lib\lib-tk\Tkinter.py", line 1647, in __init__
> >      self.tk = _tkinter.create(screenName, baseName, className,
> > interactive, want
> > objects, useTk, sync, use)
> > _tkinter.TclError: Can't find a usable init.tcl in the following
> > directories:
> >      {C:\Program Files\Tcl\lib\tcl8.3} {C:\Program Files\Tcl\lib
> > \tcl8.3} {C:/Prog
> > ram Files/Tcl/lib/tcl8.4} C:/Python25/lib/tcl8.4 C:/lib/tcl8.4 C:/
> > library
>
> > This probably means that Tcl wasn't installed properly.
> > ---
> > I attempted a complete reinstall of python (hoping it would reinstall
> > Tcl with correct file paths), but I get the same error.  Any
> > suggestions would be appreciated.
> > Thanks!
>
> In my installation Tcl is in "C:\Python25\tcl", if that helps.

That is where my installation is located too.  Why is it insisting on
looking in "C:\Python25\lib\tcl8.4"?  Can I change where it is looking?
-- 
http://mail.python.org/mailman/listinfo/python-list


Compile time evaluation of dictionaries

2011-03-10 Thread Gerald Britton
Today I noticed that an expression like this:

"one:%(one)s two:%(two)s" % {"one": "is the loneliest number", "two":
"can be as bad as one"}

could be evaluated at compile time, but is not:

>>> dis(compile(
... '"one:%(one)s two:%(two)s" % {"one": "is the loneliest number",
"two": "can be as bad as one"}',
... '','exec'))
 1           0 LOAD_CONST               0 ('one:%(one)s two:%(two)s')
             3 BUILD_MAP                2
             6 LOAD_CONST               1 ('is the loneliest number')
             9 LOAD_CONST               2 ('one')
            12 STORE_MAP
            13 LOAD_CONST               3 ('can be as bad as one')
            16 LOAD_CONST               4 ('two')
            19 STORE_MAP
            20 BINARY_MODULO
            21 POP_TOP
            22 LOAD_CONST               5 (None)
            25 RETURN_VALUE
>>>

Any idea why Python works this way?  I see that, in 3.2, an
optimization was done for sets (See "Optimizations" at
http://docs.python.org/py3k/whatsnew/3.2.html) though I do not see
anything similar for dictionaries.

--
Gerald Britton



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


Re: Tcl wasn't installed properly

2011-03-10 Thread MRAB

On 10/03/2011 15:39, Steve wrote:

I'm a frequent user of matplotlib on my Windows XP machine.  I
recently attempted to install a program that modified my Tcl
installation, and I now get an error message when I attempt to plot
anything in matplotlib.  Here is the error message:
---
Traceback (most recent call last):
   File "", line 1, in
   File "C:\Python25\lib\lib-tk\Tkinter.py", line 3758, in _test
 root = Tk()
   File "C:\Python25\lib\lib-tk\Tkinter.py", line 1647, in __init__
 self.tk = _tkinter.create(screenName, baseName, className,
interactive, want
objects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following
directories:
 {C:\Program Files\Tcl\lib\tcl8.3} {C:\Program Files\Tcl\lib
\tcl8.3} {C:/Prog
ram Files/Tcl/lib/tcl8.4} C:/Python25/lib/tcl8.4 C:/lib/tcl8.4 C:/
library



This probably means that Tcl wasn't installed properly.
---
I attempted a complete reinstall of python (hoping it would reinstall
Tcl with correct file paths), but I get the same error.  Any
suggestions would be appreciated.
Thanks!


In my installation Tcl is in "C:\Python25\tcl", if that helps.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-10 Thread GrayShark
Yes, Curses, how could I forget that. Thanks

Steven


On Thu, 10 Mar 2011 05:34:35 -0500, Adam Tauno Williams wrote:

> On Thu, 2011-03-10 at 00:38 -0600, GrayShark wrote:
>> Once, many, many, years ago, I programmed some type of 'graphical'
>> interface on a VT200 terminal (only DEC VAX/VMS programmers are going
>> to know what this is). Question. What was the library I linked against?
>> Yes, you remember, painting boxes with ascii and the superset of ascii.
> 
> It was curses [ these days people typically use "ncurses" ].  There
> really isn't anything historic about it, it is used in many current
> projects/products - basically anything that will run in a gnome-terminal
> [such as YaST] uses ncurses.  It works very well from Python.  [for
> example:
> http://www.whitemiceconsulting.com/2010/01/python-curses-in-action-even-
on-aix.html
> ] There are several higher level 'wrappers' for ncurses these days.
> 
> Docs @ 

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


Tcl wasn't installed properly

2011-03-10 Thread Steve
I'm a frequent user of matplotlib on my Windows XP machine.  I
recently attempted to install a program that modified my Tcl
installation, and I now get an error message when I attempt to plot
anything in matplotlib.  Here is the error message:
---
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\lib-tk\Tkinter.py", line 3758, in _test
root = Tk()
  File "C:\Python25\lib\lib-tk\Tkinter.py", line 1647, in __init__
self.tk = _tkinter.create(screenName, baseName, className,
interactive, want
objects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following
directories:
{C:\Program Files\Tcl\lib\tcl8.3} {C:\Program Files\Tcl\lib
\tcl8.3} {C:/Prog
ram Files/Tcl/lib/tcl8.4} C:/Python25/lib/tcl8.4 C:/lib/tcl8.4 C:/
library



This probably means that Tcl wasn't installed properly.
---
I attempted a complete reinstall of python (hoping it would reinstall
Tcl with correct file paths), but I get the same error.  Any
suggestions would be appreciated.
Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I found some very odd behaviour in Python's very basic types

2011-03-10 Thread scattered
On Mar 10, 12:47 am, Sunjay Varma  wrote:
> For some reason, sub-classing and overwriting a built-in type does not
> change the behavior of the literal. Logically speaking, overwriting a
> name, such as str, should delete the basic str type, and replace it
> with the new class or object put in its place. For some reason though,
> even though the interpreter says that str == type("hello"),
> overwriting the str name changes nothing in the literal. Is this a
> bug? I'm not sure.
>
> I also have just started this very discussion (although in more words)
> on Python-Forum.org. Check it out there as 
> well:http://python-forum.org/pythonforum/viewtopic.php?f=18&t=24542&p=113404
>
> I know a lot of very experienced Python programmers view these mailing
> lists. It would be fantastic if this could get fixed. Python would get
> momentously more powerful if this feature was implemented. People
> would be able to apply new methods and attributes to strings, lists,
> dictionaries, sets, and all the built-in types. Improving them when
> needed and allowing for extended functionality.
>
> If you prefer to email me directly, just use this email:
> haimunt(at)yahoo(dot)com
>
> Thanks for your help! I hope we can discuss this (possible) bug. :)
>
> -Sunjay03

I agree with the others that this is a desirable feature rather than a
bug. For one thing, most nontrivial scripts import at least one
module. Those modules will implicitly assume that, e.g., string
literals mean what the language specification says that they mean. If
you were able to change the built-in meaning of strings then how would
these modules function? If you say that they are in their own
namespace and wouldn't be effected by your renaming of str - then you
would still have what you call the odd behavior of the original
meaning of built-in types leaking through your attempt to redefine
them. On the other hand - if the change in basic types *did* apply to
the code in imported modules - that would almost certainly break a lot
of modules. At best you would have some of the murky semantics of
dynamic typing, where the actual meaning of code can't be determined
lexically but would depend on the calling sequence.

In any event - why would you want to change the meaning of built-in
types? I've always thought of OOP as a means to extend a language, not
rewrite it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I found some very odd behaviour in Python's very basic types

2011-03-10 Thread rusi
On Mar 10, 10:47 am, Sunjay Varma  wrote:
> For some reason, sub-classing and overwriting a built-in type does not
> change the behavior of the literal.

Have you looked through this?
http://www.python.org/download/releases/2.2/descrintro/#subclassing

[Dunno exactly how current it is -- This was at 2.2, most people are
likely to be at 2.6 now or later. Maybe others can say...]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Deadlock and a rather weird stacktrace

2011-03-10 Thread Ian

On 10/03/2011 09:48, Vincent wrote:

Can nobody explain this? Please. how can a sleep() continue in a
__bootstrap() ?

Regards,
Vincent

On 4 feb, 13:39, Vincent van Beveren
wrote:

Hi everyone,

I'm currently working on a multithreaded GUI system in Python 2.6. In this 
system I use conditions to coordinate synchronization. However, one condition 
suddenly locks, without any cause. As a last resort I have written a small 
routine to dump all the stack traces.

 def dumpAllStacks(self):
 for threadId, stack in sys._current_frames().items():
 print "Thread with Id: %s" % threadId
 traceback.print_stack(stack)

When the system is dead-locked, I invoke this method. One stack-trace strikes 
me as odd:

Thread with Id: 1568
   File "c:\PYTHON26\lib\threading.py", line 497, in __bootstrap
 self.__bootstrap_inner()
   File "c:\PYTHON26\lib\threading.py", line 525, in __bootstrap_inner
 self.run()
   File "c:\PYTHON26\lib\threading.py", line 477, in run
 self.__target(*self.__args, **self.__kwargs)
   File "c:\PYTHON26\lib\site-packages\magnum\gui\autogui.py", line 2558, in 
__sendDataLoop
 self.__sendDataCondition.wait(1)
   File "c:\PYTHON26\lib\threading.py", line 256, in wait
 _sleep(delay)
   File "c:\PYTHON26\lib\threading.py", line 497, in __bootstrap
 self.__bootstrap_inner()<<= What?
   File "c:\PYTHON26\lib\threading.py", line 525, in __bootstrap_inner
 self.run()
   File "c:\PYTHON26\lib\site-packages\magnum\subsys\__init__.py", line 2242, 
in run
 self.updateTask()
   File "c:\PYTHON26\lib\site-packages\magnum\subsys\__init__.py", line 2214, 
in updateTask
 
self.statusServerModule.updateTaskWithConnection(self.statusServerConnection)
   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\modules.py", line 
2450, in updateTaskWithConnection
 self.updateDataWithConnection(connection, updateAll)
   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\modules.py", line 
2488, in updateDataWithConnection
 self.updateVariableData(varDataDict, frozenset(varDataDict))
   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\modules.py", line 
796, in updateVariableData
 self.cmdMgr.updateVariableData(self.moduleId, varDataDict, forceVarIdSet) 
# after this varMgr makes deepcopy
   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\managers.py", line 
441, in updateVariableData
 self.notifyUpdateReport(updatedData)
   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\managers.py", line 
493, in notifyUpdateReport
 with self.updateReportCondition:
   File "c:\PYTHON26\lib\threading.py", line 205, in __enter__
 return self.__lock.__enter__()
   File "c:\PYTHON26\lib\threading.py", line 121, in acquire
 rc = self.__block.acquire(blocking)

Can someone tell me how the sleep of one thread can continue as the 'run' of 
another? Is this normal? Thanks in advance!

Regards,Vincentvan Beveren

___
Ing. V. van Beveren
Software Engineer, FOM Rijnhuizen
T: +31 (0) 30-6096769
E: v.vanbeve...@rijnhuizen.nl

Hi Vincent,

I can't explain it, - I am no expert - but I did have some thoughts that 
I put forward anyway.


It would appear from the stack trace that self.run() is being called 
within self.run().  Did you perhaps start a third thread from within a 
second thread?


The first thread is the only one with a stack at start-up, and therefore 
it has to be the thread that sets up the stack swapping needed for 
multi-threading.  If a background thread later starts to create threads, 
it is doing so from an unusual situation, and its stack could result in 
the sort of double run() stack you see above.


I don't think it matters - the thread will die or return to the pool 
when its run() exits, and the extra stack is used only by the creating 
thread, and

not the new threads.

It might also be that anything above the first run() call is reported 
incorrectly when dumped from another thread.


Have you checked the caveats at the bottom of 
http://docs.python.org/library/thread.html#module-thread  You might be 
tripping up on one of those.


Regards

Ian












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


Re: Purely historic question: VT200 text graphic programming

2011-03-10 Thread Adam Tauno Williams
On Thu, 2011-03-10 at 00:38 -0600, GrayShark wrote: 
> Once, many, many, years ago, I programmed some type of 'graphical' 
> interface on a VT200 terminal (only DEC VAX/VMS programmers are going to 
> know what this is). Question. What was the library I linked against?
> Yes, you remember, painting boxes with ascii and the superset of ascii. 

It was curses [ these days people typically use "ncurses" ].  There
really isn't anything historic about it, it is used in many current
projects/products - basically anything that will run in a gnome-terminal
[such as YaST] uses ncurses.  It works very well from Python.  [for
example:
http://www.whitemiceconsulting.com/2010/01/python-curses-in-action-even-on-aix.html
 ]
There are several higher level 'wrappers' for ncurses these days.

Docs @ 

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


Re: Python Tools for Visual Studio from Microsoft - Free & Open Source

2011-03-10 Thread python
Roland,

> http://pytools.codeplex.com

Looks very impressive! Thank you for sharing this work.

For others following this thread 

- this add-in to Visual Studio works with CPython 2.5 - 3.2 and is not
dependent on .NET or IronPython

- this project also brings HPC (high performance computing) and MPI
support to CPython using the latest Microsoft API's for large scale data
and computing

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


Re: Deadlock and a rather weird stacktrace

2011-03-10 Thread Vincent
Can nobody explain this? Please. how can a sleep() continue in a
__bootstrap() ?

Regards,
Vincent

On 4 feb, 13:39, Vincent van Beveren 
wrote:
> Hi everyone,
>
> I'm currently working on a multithreaded GUI system in Python 2.6. In this 
> system I use conditions to coordinate synchronization. However, one condition 
> suddenly locks, without any cause. As a last resort I have written a small 
> routine to dump all the stack traces.
>
>     def dumpAllStacks(self):
>         for threadId, stack in sys._current_frames().items():
>             print "Thread with Id: %s" % threadId
>             traceback.print_stack(stack)
>
> When the system is dead-locked, I invoke this method. One stack-trace strikes 
> me as odd:
>
> Thread with Id: 1568
>   File "c:\PYTHON26\lib\threading.py", line 497, in __bootstrap
>     self.__bootstrap_inner()
>   File "c:\PYTHON26\lib\threading.py", line 525, in __bootstrap_inner
>     self.run()
>   File "c:\PYTHON26\lib\threading.py", line 477, in run
>     self.__target(*self.__args, **self.__kwargs)
>   File "c:\PYTHON26\lib\site-packages\magnum\gui\autogui.py", line 2558, in 
> __sendDataLoop
>     self.__sendDataCondition.wait(1)
>   File "c:\PYTHON26\lib\threading.py", line 256, in wait
>     _sleep(delay)
>   File "c:\PYTHON26\lib\threading.py", line 497, in __bootstrap
>     self.__bootstrap_inner()                     <<= What?
>   File "c:\PYTHON26\lib\threading.py", line 525, in __bootstrap_inner
>     self.run()
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\__init__.py", line 2242, 
> in run
>     self.updateTask()
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\__init__.py", line 2214, 
> in updateTask
>     
> self.statusServerModule.updateTaskWithConnection(self.statusServerConnection)
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\modules.py", line 
> 2450, in updateTaskWithConnection
>     self.updateDataWithConnection(connection, updateAll)
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\modules.py", line 
> 2488, in updateDataWithConnection
>     self.updateVariableData(varDataDict, frozenset(varDataDict))
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\modules.py", line 
> 796, in updateVariableData
>     self.cmdMgr.updateVariableData(self.moduleId, varDataDict, forceVarIdSet) 
> # after this varMgr makes deepcopy
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\managers.py", line 
> 441, in updateVariableData
>     self.notifyUpdateReport(updatedData)
>   File "c:\PYTHON26\lib\site-packages\magnum\subsys\shared\managers.py", line 
> 493, in notifyUpdateReport
>     with self.updateReportCondition:
>   File "c:\PYTHON26\lib\threading.py", line 205, in __enter__
>     return self.__lock.__enter__()
>   File "c:\PYTHON26\lib\threading.py", line 121, in acquire
>     rc = self.__block.acquire(blocking)
>
> Can someone tell me how the sleep of one thread can continue as the 'run' of 
> another? Is this normal? Thanks in advance!
>
> Regards,Vincentvan Beveren
>
> ___
> Ing. V. van Beveren
> Software Engineer, FOM Rijnhuizen
> T: +31 (0) 30-6096769
> E: v.vanbeve...@rijnhuizen.nl

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


Re: A question about Cmd Class

2011-03-10 Thread yuan zheng
As you said, I am not writting a linux shell. Our requirements
need this kind of commands.

Certernly,  the convert_table can sovle the command problem.
But it cannot complete correctly when using "TAB". It will complete
"show_info".

My first email expains my problem: I can implement commands with '-',
but I can't let completion works well.


thanks,
yuanzheng.

2011/3/10 Dave Angel 

> On 03/10/2011 01:38 AM, yuan zheng wrote:
>
>> Thanks for your help.
>>
>>
>> thanks,
>> yuanzheng.
>>
>> 2011/3/8 Dave Angel
>>
>>  On 01/-10/-28163 02:59 PM, yuan zheng wrote:
>>>
>>>  Hello, everyone:

 I encouter a question when implementing a commmand line(shell).
 I have implemented some commands, such as "start", "stop", "quit",
 they are easily implemented by "do_start", "do_stop" and "do_quit".
 there are no troubles.
  But I want to implement some commands like these "list-modules",
 "show-info". There is a character "-" among the string. So I can't
 easily
 use "do_list-modules", because the name is invalid. I attempt another
 ways, add a sentense in function "cmd.onecmd":
 ---
def onecmd(self, line):
 line = line.replace("-", "_") # I add
 ...
 ---
 Then, I can use "do_list_modules" to mach "list-modules" command. But in
 this way, completion cannot work correctly. If I input "list-", and then
 "tab",
 it would not complete.

 If my way is correct when encoutering commands with "-" ?
 If it's correct, how can I implement completion to work correctly?



 thanks,
 yuanzheng.


  The problem with the replace() is that if there are any other dashes in
>>> the
>>> command, you'll replace them as well.  Further, there are lots of other
>>> characters that are legal in program names that are not legal in variable
>>> names.
>>>
>>> My commands have just one '-', so I don't worry this problem.
>>>
>>
>>
> So what are these commands, and how is the shell used?  Could you give us
> more than a trivial fragment of working code?  Since you say you're running
> Linux, are you saying users of your shell wouldn't be able to use a command
> like
>ls -l
>
> in your shell, because it has a dash in the argument string?
>
> BTW, when adding your own comments to quoted text, always use a new line,
> so your own comments do not have a leading ">" character. Otherwise it gets
> quite confusing.
>
> Maybe you're not writing a Linux shell at all, but a shell just to run
> other python "commands" that you've written.  If that's the case, why not
> select names that python will like, and run them directly?  For that matter,
> why have a do_ prefix at all?  If the command is called list_modules, let
> them type list_modules, and call the function list_modules().
>
> If that's just not feasible, you could just make a map converting the names
> they type to the actual function objects.  If you like your present names,
> the map might look like:
>
> convert_table = { "start": do_start, "stop": do_stop, "quit", do_quit,
> "show-info": do_show_info }
>
> Then your dispatch would be something like
>  cmd = lines.split()[0]
>  convert_table[cmd] (arg1, arg2)
>
> DaveA
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A question about Cmd Class

2011-03-10 Thread Dave Angel

On 03/10/2011 01:38 AM, yuan zheng wrote:

Thanks for your help.


thanks,
yuanzheng.

2011/3/8 Dave Angel


On 01/-10/-28163 02:59 PM, yuan zheng wrote:


Hello, everyone:

 I encouter a question when implementing a commmand line(shell).
I have implemented some commands, such as "start", "stop", "quit",
they are easily implemented by "do_start", "do_stop" and "do_quit".
there are no troubles.
  But I want to implement some commands like these "list-modules",
"show-info". There is a character "-" among the string. So I can't easily
use "do_list-modules", because the name is invalid. I attempt another
ways, add a sentense in function "cmd.onecmd":
---
def onecmd(self, line):
 line = line.replace("-", "_") # I add
 ...
---
Then, I can use "do_list_modules" to mach "list-modules" command. But in
this way, completion cannot work correctly. If I input "list-", and then
"tab",
it would not complete.

If my way is correct when encoutering commands with "-" ?
If it's correct, how can I implement completion to work correctly?



thanks,
yuanzheng.



The problem with the replace() is that if there are any other dashes in the
command, you'll replace them as well.  Further, there are lots of other
characters that are legal in program names that are not legal in variable
names.

My commands have just one '-', so I don't worry this problem.




So what are these commands, and how is the shell used?  Could you give 
us more than a trivial fragment of working code?  Since you say you're 
running Linux, are you saying users of your shell wouldn't be able to 
use a command like

ls -l

in your shell, because it has a dash in the argument string?

BTW, when adding your own comments to quoted text, always use a new 
line, so your own comments do not have a leading ">" character. 
Otherwise it gets quite confusing.


Maybe you're not writing a Linux shell at all, but a shell just to run 
other python "commands" that you've written.  If that's the case, why 
not select names that python will like, and run them directly?  For that 
matter, why have a do_ prefix at all?  If the command is called 
list_modules, let them type list_modules, and call the function 
list_modules().


If that's just not feasible, you could just make a map converting the 
names they type to the actual function objects.  If you like your 
present names, the map might look like:


convert_table = { "start": do_start, "stop": do_stop, "quit", do_quit, 
"show-info": do_show_info }


Then your dispatch would be something like
  cmd = lines.split()[0]
  convert_table[cmd] (arg1, arg2)

DaveA

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