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

2011-03-11 Thread n00m
Fitzgerald had been an alcoholic since his college days, and became
notorious during the 1920s for his extraordinarily heavy drinking,
leaving him in poor health by the late 1930s. According to Zelda's
biographer, Nancy Milford, Scott claimed that he had contracted
tuberculosis, but Milford dismisses it as a pretext to cover his
drinking problems. However, Fitzgerald scholar Matthew J. Bruccoli
contends that Fitzgerald did in fact have recurring tuberculosis, and
Nancy Milford reports that Fitzgerald biographer Arthur Mizener said
that Scott suffered a mild attack of tuberculosis in 1919, and in 1929
he had what proved to be a tubercular hemorrhage. It has been said
that the hemorrhage was caused by bleeding from esophageal varices.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use-cases for alternative iterator

2011-03-11 Thread Peter Otten
Steven D'Aprano wrote:

 The iter() built-in takes two different forms, the familiar
 iter(iterable) we all know and love, and an alternative form:
 
 iter(callable, sentinel)
 
 I've never seen this second form in actual code. Does anyone use it, and
 if so, what use-cases do you have?

I found 36 examples (7% of all iter() calls) on my Kubuntu:

/usr/lib/pymodules/python2.6/multiprocessing/pool.py
iter(taskqueue.get, None)
/usr/lib/pymodules/python2.6/multiprocessing/tests.py
iter(self.child_conn.recv, None)
iter(q.get, None)
iter(conn.recv_bytes, SENTINEL)
iter(conn.recv, None)
iter(conn.recv, 'STOP')
/usr/lib/pymodules/python2.6/multiprocessing/examples/mp_workers.py
iter(input.get, 'STOP')
/usr/lib/pymodules/python2.6/pychecker2/util.py
iter(Parents(obj), None)
/usr/lib/pymodules/python2.6/processing/pool.py
iter(inqueue.get, None)
iter(taskqueue.get, None)
iter(get, None)
/usr/lib/pymodules/python2.6/processing/tests/__init__.py
iter(self.child_conn.recv, None)
iter(conn.recvBytes, '')
iter(conn.recv, None)
iter(conn.recv, 'STOP')
/usr/lib/pymodules/python2.6/IPython/Extensions/ipipe.py
iter(self, obj)
iter(self, obj)
iter(self, obj)
/usr/lib/pymodules/python2.6/nose/plugins/multiprocess.py
iter(get, 'STOP')
/usr/lib/pymodules/python2.6/django/db/models/sql/query.py
iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)), 
self.connection.features.empty_fetchmany_value)
iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)), sentinel)
/usr/lib/pymodules/python2.6/httplib2/__init__.py
iter(self, domain)
/usr/lib/pymodules/python2.6/MySQLdb/cursors.py
iter(self.fetchone, None)
/usr/lib/pymodules/python2.6/MoinMoin/server/server_wsgi.py
iter(lambda: fileobj.read(bufsize), '')
/usr/lib/python2.6/mailbox.py
iter(self.readline, )
iter(self.next, None)
iter(self.next, None)
/usr/lib/python2.6/multiprocessing/pool.py
iter(taskqueue.get, None)
/usr/lib/python2.6/dist-packages/mutagen/id3.py
iter(iter(parts).next, None)
/usr/lib/python2.6/dist-packages/twisted/python/zipstream.py
iter(lambda : self.read(1), )
/usr/lib/python2.6/dist-packages/twisted/web2/test/test_stream.py
iter(s.read, None)
/usr/lib/python2.6/dist-packages/twisted/test/test_compat.py
iter(IterableCounter(20).next, 10)
/usr/lib/python2.6/dist-packages/setuptools/command/sdist.py
iter(f.readline, '')
/usr/lib/python2.6/dist-packages/lxml/cssselect.py
iter(self.next, None)
/usr/lib/python2.6/dist-packages/bzrlib/smart/protocol.py
iter(_body_decoder.read_next_chunk, None)
/usr/lib/python2.6/dist-packages/bzrlib/tests/test_smart_transport.py
iter(decoder.read_next_chunk, None)
467 36
7.15705765408

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


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Anssi Saari
Grant Edwards invalid@invalid.invalid writes:

 C wasn't very widely used under VMS, and VMS had it's own screen
 formatting and form handling libraries.

Just curious, what language was widely used in VMS? My VMS experience
is limited to running Maple for a math course in the university in
early 1990s. Didn't know how to do much more than start Maple,
probably just dir, logout (or was it logoff?) and ftp :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread GrayShark
On Fri, 11 Mar 2011 11:17:08 +0200, Anssi Saari wrote:

 Grant Edwards invalid@invalid.invalid writes:
 
 C wasn't very widely used under VMS, and VMS had it's own screen
 formatting and form handling libraries.
 
 Just curious, what language was widely used in VMS? My VMS experience is
 limited to running Maple for a math course in the university in early
 1990s. Didn't know how to do much more than start Maple, probably just
 dir, logout (or was it logoff?) and ftp :)

I used Fortran and C. Pascal was pretty popular then as was BASIC; likely 
included. I know there was an Ada compiler as well; required by DOD, as it 
was the 'language of choice'.

Some days the DOD is just foolish, dictating what must work better on 
hardware. Sort of like the need to push Java or C-Sharp on everything. Ada 
always reminded me of Cobol. Oh yes, Cobol also worked on VMS (yikes! the 
columns just right issues!).

I remember a Properties officer, upset that I wanted pricing data included 
in the printout. Adding that was beyond the 132 character output of the 
page. She seemed quite upset when I asked just for the 4 of 18 columns I 
was interested in, be printed. By 1998, Cobol programs were rare (although 
the language was pretty easy to learn).

So: Fortran, C, Pascal, Cobol, Ada and ... APL. Let's see how many 
remember that very fun language (and I mean fun).

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


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread GrayShark
On Fri, 11 Mar 2011 00:26:37 -0800, Dennis Lee Bieber wrote:

 On Thu, 10 Mar 2011 19:55:02 + (UTC), Grant Edwards
 invalid@invalid.invalid declaimed the following in
 gmane.comp.python.general:
 
 vt200 terminals.  The vt200 wasn't a TV.  It was a character-based,
 mostly-ANSI-escape-sequence, computer terminal connected via async
 
   I think the order went the other way -- I think most of the ANSI
 sequences were inherited from the VT52/VT100 terminals.

Are you implying ascii came after the VT52/VT110 terminals? VT52 is a ascii 
code based piece of shit, including the backspace/return character set 
(which Windows still honors like it's a deity). 

Working from the old days, the ascii set used 0-127 (zero - seventh bit) 
to represent special keys and sounds, letters, numbers and common 
punctuations. The eight bit was reserved for error correct. Remember this 
was a serial 'printer' console language. It need updating as much as the 
QWERTY keyboard does. 

Sometime after 1975, graphical glyphs were added, using the eighth bit.
Some VT models supported the extended ascii, as did IBM-DOS.

Strange the history one remembers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Jorgen Grahn
On Thu, 2011-03-10, Martin Gregorie wrote:
 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.

But he wrote VT-200, not VT-100. I assumed he meant those (vt200) had
some exotic graphics mode. The VT-xxx series was pretty heterogenous,
although most of us think of them as more or less fancy VT-100s.

/Jorgen

-- 
  // Jorgen Grahn grahn@  Oo  o.   .  .
\X/ snipabacken.se   O  o   .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Martin Gregorie
On Fri, 11 Mar 2011 04:39:02 -0600, GrayShark wrote:

  I think the order went the other way -- I think most of the ANSI
 sequences were inherited from the VT52/VT100 terminals.
 
 Are you implying ascii came after the VT52/VT110 terminals? VT52 is a
 ascii code based piece of shit, including the backspace/return character
 set (which Windows still honors like it's a deity).

He said ANSI, not ASCII. Any, yes I think VT100 preceeded ANSI escape 
codes too. ANSI codes are very similar to VT100 escape codes. I don't 
remember seeing ANSI codes before the MS-DOS ANSI driver was introduced 
but I'd used VT100s long before that on assorted minis and 8-bit micros.

 
 Working from the old days, the ascii set used 0-127 (zero - seventh
 bit) to represent special keys and sounds, letters, numbers and common
 punctuations. The eight bit was reserved for error correct. Remember
 this was a serial 'printer' console language. It need updating as much
 as the QWERTY keyboard does.
 
 Sometime after 1975, graphical glyphs were added, using the eighth bit.
 Some VT models supported the extended ascii, as did IBM-DOS.
 
 Strange the history one remembers.



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


PyCon

2011-03-11 Thread Rita
Hello,

I noticed the old presentations at PyCon aren't avaliable anymore.
http://us.pycon.org/2010/ http://us.pycon.org/2009/

Does anyone know where else I can get these presentations?

-- 
--- Get your facts first, then you can distort them as you please.--
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyCon

2011-03-11 Thread Nick Stinemates
http://blip.tv/search?q=pycon

http://blip.tv/search?q=pyconHTH
Nick

On Fri, Mar 11, 2011 at 4:45 AM, Rita rmorgan...@gmail.com wrote:

 Hello,

 I noticed the old presentations at PyCon aren't avaliable anymore.
 http://us.pycon.org/2010/ http://us.pycon.org/2009/

 Does anyone know where else I can get these presentations?

 --
 --- Get your facts first, then you can distort them as you please.--

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


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


Python SIG for Healthcare IT

2011-03-11 Thread Brad Allen
For those seeking to work with Python-based tools in the healthcare
IT industry, this SIG (special interest group) can provide a forum to
discuss challenges and hopefully foster knowledge sharing and tools
development. Relevant topics include tools for working with healthcare
standard data formats, industry news items, professional development,
and success stories about Python and open source in the healthcare
industry. Along the way, this SIG page can be updated with links to
relevant projects and resources.

If this interests you, please join this discussion on the mailing list:

  http://mail.python.org/mailman/listinfo/healthcare

This is a new list, so it has no archives as of yet.

If you're attending PyCon today, please join us in a face to face meeting
at 1pm in the Hanover A open space room. As with all open space
meetings, all are welcome, including those with no healthcare IT
background interested in joining the industry.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Charles Turner

On 2011-03-10 14:55:02 -0500, Grant Edwards said:


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


NAPLPS isn't, but you're correct about the others. NAPLPS had character 
encoded graphics as well as vector drawing codes. It was based on an 
earlier ANSI x.500 protocol that was used in Teleltex, etc., but I've 
forgotten the exact name/designation.


In the US, most of the Teletex work was done on DEC hardware, AFAIK...

Best, Charles

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


Re: Passing Functions

2011-03-11 Thread yoro
On Mar 11, 2:00 am, MRAB pyt...@mrabarnett.plus.com wrote:
 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 module
      nearestNeighbour(currentNode, theNetwork, )
 NameError: name 'currentNode' is not defined

I've found the error, I had to type in:

for node in nodeTable:
  if node != 0 and Node.visited == False:
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-03-11 Thread Westley Martínez
On Thu, 2011-03-10 at 17:58 -0800, 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.
 

n00m: GET A BLOG.

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


Grabbing user's agent and OS type

2011-03-11 Thread Νικόλαος Κούρας
Hello,

I use

os.environ[HTTP_USER_AGENT] and is very convenient to retrieve the
user's agent type

but how could we also retrieve the user's OS type?

OS type and agent type and version do appear in the same string.
I somehow have to grab the 'OS' type(Windows) and the user's agent/
version(Chrome 11)


The string is:
[code]
Mozilla/5.0 (Windows; Windows NT 6.1) AppleWebKit/534.23 (KHTML, like
Gecko) Chrome/11.0.686.0 Safari/534.23
[/code]

How am i supposed to filter the string since the subsparts of the
string isn't always the same and maybe also in different positions
within the each time different returned string?

For example from he above string i only need to know that the OS type
is 'Windows' and that the agent type is 'Chrome 11'

But those strings vary in each case.

If it cant be done by filtering the value of
os.environ[HTTP_USER_AGENT] is there any other easier way that i can
retrive those values?
-- 
http://mail.python.org/mailman/listinfo/python-list


Creating a very simple revision system for photos in python

2011-03-11 Thread Thomas W
I`m thinking about creating a very simple revision system for photos
in python, something like bazaar, mercurial or git, but for photos.
The problem is that handling large binary files compared to plain text
files are quite different. Has anybody done something like this or
have any thoughts about it, I`d be very grateful. If something like
mercurial or git could be used and/or extended/customized that would
be even better.

We are talking about large numbers of photos and some of them are
large in size as well, but the functionality does not have to be a
full fledged revision system, just handle checking out, checking in,
handling conflicts, rollbacks etc, preferrably without storing
complete copies of the files in question for every operation.

Thanks for any input. :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Grabbing user's agent and OS type

2011-03-11 Thread Steven D'Aprano
On Fri, 11 Mar 2011 06:37:42 -0800, Νικόλαος Κούρας wrote:

 Hello,
 
 I use
 
 os.environ[HTTP_USER_AGENT] and is very convenient to retrieve the
 user's agent type
 
 but how could we also retrieve the user's OS type?

 sys.platform
'linux2'
 os.name
'posix'

 
 OS type and agent type and version do appear in the same string. I
 somehow have to grab the 'OS' type(Windows) and the user's agent/
 version(Chrome 11)
 
 
 The string is:
 [code]
 Mozilla/5.0 (Windows; Windows NT 6.1) AppleWebKit/534.23 (KHTML, like
 Gecko) Chrome/11.0.686.0 Safari/534.23 [/code]

 How am i supposed to filter the string since the subsparts of the string
 isn't always the same and maybe also in different positions within the
 each time different returned string?

useragent = Mozilla/5.0 blah blah blah
agent = useragent.lower()
if mozilla in agent:
print user-agent claims to be Mozilla compatible
if chrome in agent:
print user-agent claims to be Chrome compatible
if safari in agent:
print user-agent claims to be Safari compatible
if python in agent:
print user-agent claims to be a Python program, module or script
if lynx in agent:
print user-agent claims to be the Lynx browser
if links in agent:
print user-agent claims to be the Links browser
if windows in agent:
print user-agent claims that the operating system is Windows
# and so on
print remember that user-agents can, and frequently do, lie


I think you give the user-agent string too much credit. Despite what some 
people think, including some browser developers, it's a free-form string 
and can contain anything the browser wants. There's no guarantee that 
fields will appear in a particular order, or even appear at all. If 
you're doing feature detection by parsing the UA string, you're in a 
state of sin.



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


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Tim Chase

On 03/11/2011 04:24 AM, GrayShark wrote:

Oh yes, Cobol also worked on VMS (yikes! the columns just
right issues!).


  IDENTIFICATION DIVISION.
  PROGRAM-ID. PAIN-PAIN-PAIN.
  PROCEDURE DIVISION.
  DISPLAY 'Thanks for dredging up painful memories'.
  DISPLAY 'I've spent 15 years working to suppress'.
  STOP RUN.

:)

-tkc



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


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread GrayShark
Aw! to stray down memory lane. Well enough straying. Back to work.

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


Re: PyCon

2011-03-11 Thread Ken Seehart

On 3/11/2011 7:45 AM, Rita wrote:

http://us.pycon.org/2010/ http://us.pycon.org/2009/

Try the wayback machine:

http://replay.waybackmachine.org/20100701160843/http://us.pycon.org/2010/about/
--
http://mail.python.org/mailman/listinfo/python-list


How to get python class serializable and well parsed by JSON

2011-03-11 Thread Arthur Mc Coy
Hi people,

I've created very nice post here:
http://stackoverflow.com/questions/5274690/how-to-get-python-class-serializable-and-well-parsed-by-json-custom-encoder-deco

Yes, there are solutions over the internet, but nothing works for my
custom types.
If you could answer, please read it.

Be happy!
Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Grant Edwards
On 2011-03-11, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
 On Thu, 10 Mar 2011 19:55:02 + (UTC), Grant Edwards
invalid@invalid.invalid declaimed the following in
 gmane.comp.python.general:

 vt200 terminals.  The vt200 wasn't a TV.  It was a character-based,
 mostly-ANSI-escape-sequence, computer terminal connected via async

 I think the order went the other way -- I think most of the ANSI
 sequences were inherited from the VT52/VT100 terminals.

Ah. I didn't mean to imply order, only that the vt200 used ANSI escape
sequences with some extensions.

-- 
Grant Edwards   grant.b.edwardsYow! I am a jelly donut.
  at   I am a jelly donut.
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Grant Edwards
On 2011-03-11, Anssi Saari a...@sci.fi wrote:
 Grant Edwards invalid@invalid.invalid writes:

 C wasn't very widely used under VMS, and VMS had it's own screen
 formatting and form handling libraries.

 Just curious, what language was widely used in VMS?

From what I remember, FORTRAN what probably the most popular.  Pascal
was also well supported and somewhat widely used (especially in
academia).  Then there was BLISS-32 for the low-level stuff.  C seemed
to be an afterthought and had a very kludged feel to it.  VMS's file
I/O didn't correspond very will with the C byte stream model, and C's
view of line-termination didn't play well with everything else.

 My VMS experience is limited to running Maple for a math course in
 the university in early 1990s. Didn't know how to do much more than
 start Maple, probably just dir, logout (or was it logoff?) and ftp :)

-- 
Grant Edwards   grant.b.edwardsYow! Is it NOUVELLE
  at   CUISINE when 3 olives are
  gmail.comstruggling with a scallop
   in a plate of SAUCE MORNAY?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Grabbing user's agent and OS type

2011-03-11 Thread Νικόλαος Κούρας
Thanks a lot Steven!

The following code worked like a charm!

**
agent = os.environ['HTTP_USER_AGENT']

# determination of user browser
agent = agent.lower()
if 'chrome' in agent:
agent = 'Chrome'
if 'firefox' in agent:
agent = 'Firefox'
if 'opera' in agent:
agent = 'Opera'
if 'safari' in agent:
agent = 'Safari'
if 'msie' in agent:
agent = 'IE'
***

I just want to have an idea of what browser a guest is using when
hitting my webpage.

http://www.superhost.gr/?show=log

now includes also that filed in the logging process.

But if i wanted the OS also?

sys.platform is for retrieving the host OS type that the script is
running and not the guest OS type.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a very simple revision system for photos in python

2011-03-11 Thread Chris Hulan
On Mar 11, 9:56 am, Thomas W thomas.weh...@gmail.com wrote:
 I`m thinking about creating a very simple revision system for photos
 in python, something like bazaar, mercurial or git, but for photos.
 The problem is that handling large binary files compared to plain text
 files are quite different. Has anybody done something like this or
 have any thoughts about it, I`d be very grateful. If something like
 mercurial or git could be used and/or extended/customized that would
 be even better.

 We are talking about large numbers of photos and some of them are
 large in size as well, but the functionality does not have to be a
 full fledged revision system, just handle checking out, checking in,
 handling conflicts, rollbacks etc, preferrably without storing
 complete copies of the files in question for every operation.

 Thanks for any input. :-)

Most traditional revision systems excel at managing text, but suck at
binary.
I recall that Picassa has a revision system

It occurs to me you could use Uuencoding to make binaries more
amendable to
handling by text-oriented revision systems
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a very simple revision system for photos in python

2011-03-11 Thread Tim Golden

On 11/03/2011 16:05, Chris Hulan wrote:

On Mar 11, 9:56 am, Thomas Wthomas.weh...@gmail.com  wrote:

I`m thinking about creating a very simple revision system for photos
in python, something like bazaar, mercurial or git, but for photos.
The problem is that handling large binary files compared to plain text
files are quite different. Has anybody done something like this or
have any thoughts about it, I`d be very grateful. If something like
mercurial or git could be used and/or extended/customized that would
be even better.

We are talking about large numbers of photos and some of them are
large in size as well, but the functionality does not have to be a
full fledged revision system, just handle checking out, checking in,
handling conflicts, rollbacks etc, preferrably without storing
complete copies of the files in question for every operation.

Thanks for any input. :-)


Most traditional revision systems excel at managing text, but suck at
binary.
I recall that Picassa has a revision system

It occurs to me you could use Uuencoding to make binaries more
amendable to
handling by text-oriented revision systems


I'm not sure there's much point in doing that. Certainly Subversion,
and I imagine the other main RCS, handle binary data perfectly well;
I mean, they don't stop when they come across a NUL byte or anything
like that. You can't do much with the result except retrieve it, but
I'm not sure that uuencodeing (or any other encoding) adds anything
there, either.

FWIW TortoiseSvn offers an image-diff utility which superimposes the
two versions of an image with an alpha blend (if that's what it's
called). It's basically the electronic equivalent of holding two
sheets of paper up to the light. Don't know if this helps the OP,
mind you.

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


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread GrayShark
On Fri, 11 Mar 2011 15:58:20 +, Grant Edwards wrote:

 On 2011-03-11, Anssi Saari a...@sci.fi wrote:
 Grant Edwards invalid@invalid.invalid writes:

 C wasn't very widely used under VMS, and VMS had it's own screen
 formatting and form handling libraries.

 Just curious, what language was widely used in VMS?
 
 From what I remember, FORTRAN what probably the most popular.  Pascal
 was also well supported and somewhat widely used (especially in
 academia).  Then there was BLISS-32 for the low-level stuff.  C seemed
 to be an afterthought and had a very kludged feel to it.  VMS's file
 I/O didn't correspond very will with the C byte stream model, and C's
 view of line-termination didn't play well with everything else.
 
 My VMS experience is limited to running Maple for a math course in the
 university in early 1990s. Didn't know how to do much more than start
 Maple, probably just dir, logout (or was it logoff?) and ftp :)

I don't remember much of any language being that portable. I do remember 
it was very easy to take DEC Fortran and compile it without much issue on 
SGI/Irix. Much more scary was a program converted to C from Fortran (there 
were precompiler for that) ran slow on Irix then straight Fortran. 

That was godsend for simulation engineers.

I agree, VAX/VMS's i/o model was slow in C. In fortran it was fast as they 
did all the opens when the program started, regardless of where the open 
statement was in the code. I even had a legacy program, open and close a 
file in a subroutine (a no no) that ran fast; debugging code. DEC fortran 
only opened the file once. Had some way of deciding if a write was an 
overwrite or an append. The program ran fast as 'normal' (that being 
without the open and close).

When I ported the program to an Moto 88000 daughter processor board, the 
program ran slow as hell. The 88000 board used a Fortran-C compiler, that 
obeyed the open and close statements. Each time the program ran that 
subroutine, It opened, then closed a log file. Each statement required the 
daughter board to call, via the q-bus, the host OS (VMS), stop, wait for 
VMS to open a file, continue, then stop, wait for VMS to close the file.

The correction was easy, get rid of the legacy debug code. The coder had 
never used the debugger program or a profiler; amazing! Well after both, 
debugging code removed and a run through a profile, the code ran fast as 
hell. 20 sims in the time the microvax III did one. That was probably the 
only reason we didn't move off VAX/VMS (that and old programmer inertia).

Inertia, friend and foe.

Otherwise I worked with a host of government contractors, each with their 
own version of C; each used their specialized version to prevent tax payer 
contracts from going to another contractor.

Thank goodness for standardization. Finally the DOD could drop CSC or EDS 
over priced contracts to maintain code. Unfortunately, could, should and 
did don't have the same meaning at the end of the day.

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


Re: Grabbing user's agent and OS type

2011-03-11 Thread Benjamin Kaplan
2011/3/11 Νικόλαος Κούρας nikos.kou...@gmail.com:
 Thanks a lot Steven!

 The following code worked like a charm!

 **
 agent = os.environ['HTTP_USER_AGENT']

 # determination of user browser
 agent = agent.lower()
 if 'chrome' in agent:
        agent = 'Chrome'
 if 'firefox' in agent:
        agent = 'Firefox'
 if 'opera' in agent:
        agent = 'Opera'
 if 'safari' in agent:
        agent = 'Safari'
 if 'msie' in agent:
        agent = 'IE'
 ***


For compatibility reasons (and because it's also WebKit based), Chrome
also identifies itself as Safari. Just look at the User-Agent string
you posted in the original message:

Mozilla/5.0 (Windows; Windows NT 6.1) AppleWebKit/534.23 (KHTML, like
Gecko) Chrome/11.0.686.0 Safari/534.23



Because of the order of your checks here (and because you're using if
instead of elif), Chrome will be reported as Safari. I suppose you can
fix it for now, but what happens when another browser comes along and
claims to be MSIE-compatible?

Notice that Chrome, like every other browser, introduces itself as
Netscape 5 (Mozilla). After giving you the platform, Chrome correctly
identifies itself as using WebKit as the rendering engine but then
name-drops KHTML (which Webkit was forked from) and Gecko (Firefox's
rendering engine) so that it will get the  version of sites optimized
for those engines (if they haven't identified webkit yet) before
identifying itself as Chrome and then Safari (for the same reason).
Like Steven said, User-Agent strings aren't all that useful for
identifying the browser.

 I just want to have an idea of what browser a guest is using when
 hitting my webpage.

 http://www.superhost.gr/?show=log

 now includes also that filed in the logging process.

 But if i wanted the OS also?


I don't think anyone fakes the OS, unless some website is being really
stupid and claims Windows-only instead of IE-only. Just check for
the OS name.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get python class serializable and well parsed by JSON

2011-03-11 Thread Arthur Mc Coy
Common guys, help me, sweet heart to finish my job and go with my
friend in the bar. Today we have a blues night :) Love it!

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


Re: Grabbing user's agent and OS type

2011-03-11 Thread Tim Chase

On 03/11/2011 09:59 AM, Νικόλαος Κούρας wrote:

**
agent = os.environ['HTTP_USER_AGENT']

# determination of user browser
agent = agent.lower()
if 'chrome' in agent:
agent = 'Chrome'
if 'firefox' in agent:
agent = 'Firefox'
if 'opera' in agent:
agent = 'Opera'
if 'safari' in agent:
agent = 'Safari'
if 'msie' in agent:
agent = 'IE'
***

I just want to have an idea of what browser a guest is using when
hitting my webpage.

http://www.superhost.gr/?show=log

now includes also that filed in the logging process.


I now have a sudden urge to use Firefox's User-Agent Switcher 
add-on to change my UA string to something like Chrome Firefox 
MSIE Opera Safari Mozilla Lynx Links Dillo Win32 Windows Linux 
OpenBSD Mac OS X and browse your site :)


-tkc



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


Re: How to get python class serializable and well parsed by JSON

2011-03-11 Thread Arthur Mc Coy
Currently trying to pick up my ava http://en.gravatar.com/christinasanders21
for StackOverflow, which site I found very good for my questions,
didn't I?
Yes, and there are problem when adding a picture. Web admins should be
careful.
Can anyone explain me my problem ? :

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


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

2011-03-11 Thread Nobody
On Thu, 10 Mar 2011 17:58:50 -0800, 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).

Some of use Python 2.x as a general-purpose Unix scripting language. For
that purpose, Python 3.x's obsession with Unicode is a sufficient reason
to avoid it.

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


Re: Creating a very simple revision system for photos in python

2011-03-11 Thread Thomas W
On 11 Mar, 17:23, Tim Golden m...@timgolden.me.uk wrote:
 On 11/03/2011 16:05, Chris Hulan wrote:









  On Mar 11, 9:56 am, Thomas Wthomas.weh...@gmail.com  wrote:
  I`m thinking about creating a very simple revision system for photos
  in python, something like bazaar, mercurial or git, but for photos.
  The problem is that handling large binary files compared to plain text
  files are quite different. Has anybody done something like this or
  have any thoughts about it, I`d be very grateful. If something like
  mercurial or git could be used and/or extended/customized that would
  be even better.

  We are talking about large numbers of photos and some of them are
  large in size as well, but the functionality does not have to be a
  full fledged revision system, just handle checking out, checking in,
  handling conflicts, rollbacks etc, preferrably without storing
  complete copies of the files in question for every operation.

  Thanks for any input. :-)

  Most traditional revision systems excel at managing text, but suck at
  binary.
  I recall that Picassa has a revision system

  It occurs to me you could use Uuencoding to make binaries more
  amendable to
  handling by text-oriented revision systems

 I'm not sure there's much point in doing that. Certainly Subversion,
 and I imagine the other main RCS, handle binary data perfectly well;
 I mean, they don't stop when they come across a NUL byte or anything
 like that. You can't do much with the result except retrieve it, but
 I'm not sure that uuencodeing (or any other encoding) adds anything
 there, either.

 FWIW TortoiseSvn offers an image-diff utility which superimposes the
 two versions of an image with an alpha blend (if that's what it's
 called). It's basically the electronic equivalent of holding two
 sheets of paper up to the light. Don't know if this helps the OP,
 mind you.

 TJG

Hmm ... encoding my photos using uuencoding will just eat up space, it
adds about 40% or so ( if I remember correctly ) to the total size of
the encoded file, a file which may allready be 10+ MB. That`s the
problem using git and friends as well; it creates full copies of the
files and that`s part of the thing I want to avoid, if possible.

Sounds like this is a task for more experienced users than me, but I`m
gonna take a stab at it anyway, allthough my ideas for a solution is
pretty basic and simple.

Anyway, thanks a lot for your input :-)

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


Re: Passing Functions

2011-03-11 Thread John Nagle

On 3/11/2011 5:49 AM, yoro wrote:


I've found the error, I had to type in:

for node in nodeTable:
   if node != 0 and Node.visited == False:


  That's just your first error.
(Also, you shouldn't have anything but Node items in
nodeTable, so you don't need the node != 0.)

  The biggest problem is at

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

   Those are variables of the entire class.  Every
instance of Node shares the same variables. You
need

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

John Nagle

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


Re: Compile time evaluation of dictionaries

2011-03-11 Thread John Nagle

On 3/10/2011 8: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:


   CPython barely evaluates anything at compile time.

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


Re: Grabbing user's agent and OS type

2011-03-11 Thread Νικόλαος Κούρας
On 11 Μαρ, 18:39, Tim Chase python.l...@tim.thechases.com wrote:
 On 03/11/2011 09:59 AM, Νικόλαος Κούρας wrote:









  **
  agent = os.environ['HTTP_USER_AGENT']

  # determination of user browser
  agent = agent.lower()
  if 'chrome' in agent:
     agent = 'Chrome'
  if 'firefox' in agent:
     agent = 'Firefox'
  if 'opera' in agent:
     agent = 'Opera'
  if 'safari' in agent:
     agent = 'Safari'
  if 'msie' in agent:
     agent = 'IE'
  ***

  I just want to have an idea of what browser a guest is using when
  hitting my webpage.

 http://www.superhost.gr/?show=log

  now includes also that filed in the logging process.

 I now have a sudden urge to use Firefox's User-Agent Switcher
 add-on to change my UA string to something like Chrome Firefox
 MSIE Opera Safari Mozilla Lynx Links Dillo Win32 Windows Linux
 OpenBSD Mac OS X and browse your site :)

 -tkc

ROFLMAO !!!

I guess the previous code that i corrected after seeing Benjamin's
response:

==
# determination of user browser
agent = agent.lower()
if 'chrome' in agent:
agent = 'Chrome'
elif 'firefox' in agent:
agent = 'Firefox'
elif 'opera' in agent:
agent = 'Opera'
elif 'safari' in agent:
agent = 'Safari'
elif 'msie' in agent:
agent = 'Explorer'
else:
agent = 'Other'


would still be failing since it seems that it is a matter of order
what response will be presented.

So if you use firefox for browser with the UA string tweaker on with a
string of Chrome Firefox
MSIE Opera Safari Mozilla Lynx Links Dillo Win32 Windows Linux OpenBSD
Mac OS X and browse my site the result will always be 'Chrome'
since the 1st match will always be TRUE and nothing else get
checked. :-)

But in a real example if a UA string contains the substring 'Chrome'
then the browser must be Chrome(there is no point containing the
substring 'Firefox' in UA when the browser is 'Chrome', unlike Mozilla
which is a common subtring to both of the browsers UA)
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-03-11 Thread Rafe Kettler
On Mar 10, 9:25 pm, Robert sigz...@gmail.com wrote:
 Is there a push to one toolkit or the other?

 --
 Robert

I've mainly used Tkinter for a few reasons:

 - It's what I already know
 - It's pretty simple
 - Most people who have Python have it too, so there's no crazy
dependencies
 - It looks decent on Gnome and KDE, good on Winodws and Mac
 - I can develop a full featured GUI in a few hours, no sweat (partly
because it's simple, partly because I know it)

I've tried PyGTK and PyQt before, but they were both more complicated
than I'd like. I decided to stick with Tkinter because I was
proficient with it.

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


Re: Don't Want Visitor To See Nuttin'

2011-03-11 Thread Victor Subervi
On Fri, Mar 11, 2011 at 3:54 AM, Ian Kelly ian.g.ke...@gmail.com wrote:

 On Wed, Mar 9, 2011 at 2:01 PM, Victor Subervi victorsube...@gmail.com
 wrote:
  titleMaya 2012: Transform At the Source/title

 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.


Um...just for the record, these guys have ben featured on the FRONT PAGES
OF:
The Wall Street Journal
The Los Angeles Times
The San Francisco Chronicle
and have appeared on:
Eye-To-Eye with Connie Chung
CNN's Travel Guide
and National Geographic's Travel Magazine called them the graddaddy of
metaphysical tours.
If you'll go to the About Us page you'll see their photo with the Dalai
Lama.

They're ligit :)
Beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Don't Want Visitor To See Nuttin'

2011-03-11 Thread Victor Subervi
On Fri, Mar 11, 2011 at 4:26 AM, Dennis Lee Bieber wlfr...@ix.netcom.comwrote:

 On Thu, 10 Mar 2011 18:00:10 -0800 (PST), alex23 wuwe...@gmail.com
 declaimed the following in gmane.comp.python.general:

  He's comp.lang.python's version of Sisyphus. Or maybe Sisyphus'
  boulder...I forget where I was going with this.

 The boulder -- given that we are the ones suffering... G


OK, fine, don't respond. The page works. I'm changing names and email
addresses. CU as someone else.
Bye,
Beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Grant Edwards
On 2011-03-11, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
 On Fri, 11 Mar 2011 11:17:08 +0200, Anssi Saari a...@sci.fi declaimed
 the following in gmane.comp.python.general:

 Grant Edwards invalid@invalid.invalid writes:
 
  C wasn't very widely used under VMS, and VMS had it's own screen
  formatting and form handling libraries.
 
 Just curious, what language was widely used in VMS? My VMS experience
 is limited to running Maple for a math course in the university in
 early 1990s. Didn't know how to do much more than start Maple,
 probably just dir, logout (or was it logoff?) and ftp :)

 The system language was BLISS; though I don't know of any end-users
 programming in it.

I think I did, once, when I need to do something involving 128-bit
integers.  Or maybe I just used assembly language -- BLISS wasn't much
higher level than assembly.  I also seem to remember occasionally
seeing stuff written in BLISS on DECUS tapes, but it wasn't at all
common.

 My 20 years on VMS was primarily F77, with some Pascal and some C.

-- 
Grant Edwards   grant.b.edwardsYow! But was he mature
  at   enough last night at the
  gmail.comlesbian masquerade?
-- 
http://mail.python.org/mailman/listinfo/python-list


IDLE doesn't start

2011-03-11 Thread Ceonn Bobst
Hi,
 
I just installed Python 3.1.1 via link in the book Python Programming for the 
absolute beginner third edition. But IDLE won't start. When I try to open IDLE 
the Windows hourglass just flashes briefly but nothing happens after that. No 
error messages.

My operating system is XP Professional Version 2002 Service Pack 3.

I have uninstalled and reinstalled several times but nothing changes. I select 
Install for All Users during the installation.

I have also tried installing instead the 3.2 version from the python.org 
website but the same issue arises - IDLE doesn't launch. 

When I open a command prompt, and type:
   c:\python32\python.exe -m idlelib.idle
 
The message that comes is as follows:
 
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Ceonnc:\python32\python.exe -m idlelib.idle
Traceback (most recent call last):
  File c:\python32\lib\runpy.py, line 160, in _run_module_as_main
    __main__, fname, loader, pkg_name)
  File c:\python32\lib\runpy.py, line 73, in _run_code
    exec(code, run_globals)
  File c:\python32\lib\idlelib\idle.py, line 11, in module
    idlelib.PyShell.main()
  File c:\python32\lib\idlelib\PyShell.py, line 1374, in main
    root = Tk(className=Idle)
  File c:\python32\lib\tkinter\__init__.py, line 1674, 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:\IBMTOOLS\Python22\tcl\tcl8.4} C:/IBMTOOLS/Python22/tcl/tcl8.5 c:/python3
2/lib/tcl8.5 c:/lib/tcl8.5 c:/lib/tcl8.5 c:/library c:/library c:/tcl8.5.9/libra
ry c:/tcl8.5.9/library
C:/IBMTOOLS/Python22/tcl/tcl8.4/init.tcl: version conflict for package Tcl: ha
ve 8.5.9, need exactly 8.4
version conflict for package Tcl: have 8.5.9, need exactly 8.4
    while executing
package require -exact Tcl 8.4
    (file C:/IBMTOOLS/Python22/tcl/tcl8.4/init.tcl line 19)
    invoked from within
source C:/IBMTOOLS/Python22/tcl/tcl8.4/init.tcl
    (uplevel body line 1)
    invoked from within
uplevel #0 [list source $tclfile]
 
Someone told me: “You certainly have a TCL_LIBRARY environment variable set on 
your system,
it should be removed”. 
 
How do I remove TCL_LIBRARY, or do I change some numbers somewhere, and isn’t 
it risky to tinker with the Python settings already on my computer?
 
Thanks for any help, I really would like to get going with Python!


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


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Martin Gregorie
On Fri, 11 Mar 2011 11:52:13 +, Jorgen Grahn wrote:

 On Thu, 2011-03-10, Martin Gregorie wrote:
 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.
 
 But he wrote VT-200, not VT-100. I assumed he meant those (vt200) had
 some exotic graphics mode. The VT-xxx series was pretty heterogenous,
 although most of us think of them as more or less fancy VT-100s.

You're right - he did say VT-200. Can't remember using one. However, I 
did buy a used VT-103 at some point and dumped it fairly rapidly as it 
had no manuals and I couldn't get it to work as a terminal (no wonder - 
I've since found out that it was really a standalone box with an LSI-11/23 
crammed into the VT-100 box). It got swapped for a Wyse 120 - an 
excellent terminal with a white phosphor rather than green. 

Grayshark was right too: the ANSI control code standard preceded the 
VT-100 - I live and learn - and because of that there was no commonality 
between VT-50/52 and VT-100 escape codes. Details here:
http://vt100.net/vt_history

BTW, there was no such thing as a VT-200 - there was a VT-220 text 
terminal (which I think the OP was remembering) and the VT-240 and 241 
terminals, which were totally different graphics terminals that accepted 
Tektronics  graphics commands: comparing a VT-220 to a VT-240/241 would 
be like comparing an Epson dot-matric printer to an HP 7485 plotter!


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


Re: send function keys to a legacy DOS program

2011-03-11 Thread jr
On Mar 10, 7:58 pm, Justin Ezequiel justin.mailingli...@gmail.com
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?


Use expect on unix or pexpect if you're looking for the python
implementation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Martin Gregorie
On Fri, 11 Mar 2011 15:53:20 +, Grant Edwards wrote:

 I think the order went the other way -- I think most of the ANSI
 sequences were inherited from the VT52/VT100 terminals.
 
 Ah. I didn't mean to imply order, only that the vt200 used ANSI escape
 sequences with some extensions.

I got that wrong: ANSI defined the VT-100 control codes. See above.


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


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

2011-03-11 Thread Dan Stromberg
On Thu, Mar 10, 2011 at 11:59 PM, n00m n...@narod.ru wrote:

 Fitzgerald had been an alcoholic since his college days, and became
 notorious during the 1920s for his extraordinarily heavy drinking,
 leaving him in poor health by the late 1930s. According to Zelda's
 biographer, Nancy Milford, Scott claimed that he had contracted
 tuberculosis, but Milford dismisses it as a pretext to cover his
 drinking problems. However, Fitzgerald scholar Matthew J. Bruccoli
 contends that Fitzgerald did in fact have recurring tuberculosis, and
 Nancy Milford reports that Fitzgerald biographer Arthur Mizener said
 that Scott suffered a mild attack of tuberculosis in 1919, and in 1929
 he had what proved to be a tubercular hemorrhage. It has been said
 that the hemorrhage was caused by bleeding from esophageal varices.

N00m?  That's an ad-hominem against your own quote.  :)  You're illustrating
your point?

Yes, being able to maintain two or more competing, and sometimes even
conflicting, hypotheses in one's mind at the same time is crucial to the
scientific method.  Whether one person did so while drinking too much or
not.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-11 Thread Emile van Sebille

On 3/10/2011 4:58 PM Justin Ezequiel said...

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.



WSH sendkeys?

Emile


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


Two random lists from one list

2011-03-11 Thread noydb
Hello All,

I am just looking to see if there is perhaps a more efficient way of
doing this below (works -- creates two random teams from a list of
players).  Just want to see what the experts come up with for means of
learning how to do things better.

Thanks for any responses!

###
import random
players = [jake, mike, matt, rich, steve, tom, joe,
jay]
teamA = random.sample(players, 4)
print teamA
teamB = []
for p in players:
if p not in teamA:
teamB.append(p)
print teamB
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Two random lists from one list

2011-03-11 Thread Miki Tebeka
You can use sets:

teamA = set(random.sample(players, 4))
teamB = set(players) - teamA

HTH
--
Miki Tebeka miki.teb...@gmail.com
http://pythonwise.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-03-11 Thread Miki Tebeka
I used wxPython in several occasion, was very happy with it.
Free, great docs, great community.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get python class serializable and well parsed by JSON

2011-03-11 Thread Sophie Sperner
Ok, guys. I used my bro account. Now I'm here. By the way is anybody
going to be in Paris Sunday night ?
I invite you if you would help :))) Kiss, well yet 30 minutes at work
and I'm free...

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


Re: Creating a very simple revision system for photos in python

2011-03-11 Thread Dan Stromberg
On Fri, Mar 11, 2011 at 6:56 AM, Thomas W thomas.weh...@gmail.com wrote:

 I`m thinking about creating a very simple revision system for photos
 in python, something like bazaar, mercurial or git, but for photos.
 The problem is that handling large binary files compared to plain text
 files are quite different. Has anybody done something like this or
 have any thoughts about it, I`d be very grateful. If something like
 mercurial or git could be used and/or extended/customized that would
 be even better.

 We are talking about large numbers of photos and some of them are
 large in size as well, but the functionality does not have to be a
 full fledged revision system, just handle checking out, checking in,
 handling conflicts, rollbacks etc, preferrably without storing
 complete copies of the files in question for every operation.

 Thanks for any input. :-)


Check out the rolling_checksum portion of backshift, and pyrabinf:
http://stromberg.dnsalias.org/svn/backshift/trunk/
http://stromberg.dnsalias.org/svn/pyrabinf/

You could probably use a variable-length, shift-resistant blocking to chop
the inputs into binary chunks, and then make a checkin consist of a series
pointers (pathnames in a filesystem trie or keys into something like
mongodb) to those chunks, to avoid duplications.  Actually, something like
this could probably be wrapped around Mercurial or SVN or whatever,
depending on what your needs are.

I originally set up pyrabinf as a wrapper for a preexisting C++ Rabin
Fingerprinting algorithm; this is probably the more traditional way of doing
such blocking.

However, I've been playing around with rolling my own algorithm in pure
python (and also with Cython) using something that boils down to a rolling
(boxcar) sum of the bytes, so it'll work in pypy.  So far, it seems to be
working fine.  Rabin Fingerprinting should be less subject to generating the
same blocking for a file that has two adjacent bytes swapped, but in my
project, and I suspect in yours, that doesn't really matter.

But also check out http://mercurial.selenic.com/wiki/BfilesExtension - this
might be less time consuming for you, better leveraging an existing tool.

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


Re: Two random lists from one list

2011-03-11 Thread Chris Hulan
On Mar 11, 1:21 pm, noydb jenn.du...@gmail.com wrote:
 Hello All,

 I am just looking to see if there is perhaps a more efficient way of
 doing this below (works -- creates two random teams from a list of
 players).  Just want to see what the experts come up with for means of
 learning how to do things better.

 Thanks for any responses!

 ###
 import random
 players =
 teamA = random.sample(players, 4)
 print teamA
 teamB = []
 for p in players:
     if p not in teamA:
         teamB.append(p)
 print teamB

How about:

players = [jake, mike, matt, rich, steve, tom, joe,
jay]
random.shuffle(players)
teamA, TeamB = players[:4],players[4:]

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


Re: Two random lists from one list

2011-03-11 Thread Peter Otten
noydb wrote:

 Hello All,
 
 I am just looking to see if there is perhaps a more efficient way of
 doing this below (works -- creates two random teams from a list of
 players).  Just want to see what the experts come up with for means of
 learning how to do things better.
 
 Thanks for any responses!
 
 ###
 import random
 players = [jake, mike, matt, rich, steve, tom, joe,
 jay]
 teamA = random.sample(players, 4)
 print teamA
 teamB = []
 for p in players:
 if p not in teamA:
 teamB.append(p)
 print teamB

How about

 random.shuffle(players)
 teamA = players[:4]
 teamB = players[4:]
 teamA, teamB
(['tom', 'mike', 'jay', 'rich'], ['jake', 'matt', 'joe', 'steve'])

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


Re: Two random lists from one list

2011-03-11 Thread Dan Stromberg
Catenate the lists into a new list.  Then randomize the order of the new
list by iterating over each element in turn, swapping it with a random
element elsewhere in the same list (optionally including swapping it with
itself - that's easier and still gives good randomization).  This gives
linear time (n+m).

On Fri, Mar 11, 2011 at 10:21 AM, noydb jenn.du...@gmail.com wrote:

 Hello All,

 I am just looking to see if there is perhaps a more efficient way of
 doing this below (works -- creates two random teams from a list of
 players).  Just want to see what the experts come up with for means of
 learning how to do things better.

 Thanks for any responses!

 ###
 import random
 players = [jake, mike, matt, rich, steve, tom, joe,
 jay]
 teamA = random.sample(players, 4)
 print teamA
 teamB = []
 for p in players:
if p not in teamA:
teamB.append(p)
 print teamB
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Two random lists from one list

2011-03-11 Thread Tim Chase

On 03/11/2011 12:21 PM, noydb wrote:

I am just looking to see if there is perhaps a more efficient way of
doing this below (works -- creates two random teams from a list of
players).  Just want to see what the experts come up with for means of
learning how to do things better.

###
import random
players = [jake, mike, matt, rich, steve, tom, joe,
jay]
teamA = random.sample(players, 4)
print teamA
teamB = []
for p in players:
 if p not in teamA:
 teamB.append(p)
print teamB


I'd be tempted to do

  temp = players[:] # copy players
  random.shuffle(temp) # you could directly shuffle players
   # if you don't care about mangling it
  team_a = temp[:4]
  team_b = temp[4:]
  del temp # optional

This assumes you want balanced-ish teams.

-tkc


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


Re: How to get python class serializable and well parsed by JSON

2011-03-11 Thread Gennadiy Zlobin
I can not open your link. Are you sure you provided the correct link?


- Gennadiy gennad.zlo...@gmail.com


On Fri, Mar 11, 2011 at 10:36 PM, Arthur Mc Coy 1984docmc...@gmail.comwrote:

 Currently trying to pick up my ava
 http://en.gravatar.com/christinasanders21
 for StackOverflow, which site I found very good for my questions,
 didn't I?
 Yes, and there are problem when adding a picture. Web admins should be
 careful.
 Can anyone explain me my problem ? :

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

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


Using MSW GUI DLLS: PYWIN32, WMI, WINSHELL

2011-03-11 Thread Ray Pasco


  
  
I'm using MSW DLL calls thru the 3 packages listed as well as ctypes
calls on Win7 64-bit. I believe all the packages were developed in
the XP days. Some calls just don't seem to work consistently on
Win7. Specifically, I'm trying to reposition and resize application
main windows and change their minimized or zoomed state to "normal".
Sometimes the calls work, some time they just don't.

I've scoured all the DLL library calls and haven't found any
unobvious dependencies. Foe example, the calls to IsIconic always
returns True even when the app window has been restored. Another: A
call to ctypes.windll.user32.ShowWindow( hwnd, win32con.SW_MAXIMIZE
) *must* be made just before a call to
ctypes.windll.user32.ShowWindow( hwnd, win32con.SW_NORMAL ) to
consistently get it to go NORMAL from a different state. But, then
there is an annoying full screen-sized flash of white that happens.
This never happens when manually clicking on the iconized Taskbar
button. Obviously, Win7 is doing something different from the
obvious. 

Are there any insights to this behaviors ?



  

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


How to use python JSON custom parser in example ?

2011-03-11 Thread Sophie Sperner
Hi all,

I reuploaded my message.
http://stackoverflow.com/questions/5277180/how-to-use-python-json-custom-parser-in-example

From now no brother accounts. Huh :)

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


Re: IDLE doesn't start

2011-03-11 Thread Gennadiy Zlobin
It seems that you have already had Python 2.2 installed in the directory
C:/IBMTOOLS/Python22

Can you open the console and type there next commands and provide the
output?
echo %TCL_LIBRARY%
echo %TK_LIBRARY%
echo %PYTHONPATH%

You can unset environment variable in 'my computer' properties, more details
are, for example, here
http://vlaurie.com/computers2/Articles/environment.htm

- Gennadiy gennad.zlo...@gmail.com


On Fri, Mar 11, 2011 at 11:58 PM, Ceonn Bobst ceonnbo...@yahoo.com wrote:

 Hi,



 I just installed Python 3.1.1 via link in the book Python Programming for
 the absolute beginner third edition. But IDLE won't start. When I try to
 open IDLE the Windows hourglass just flashes briefly but nothing happens
 after that. No error messages.

 My operating system is XP Professional Version 2002 Service Pack 3.

 I have uninstalled and reinstalled several times but nothing changes. I
 select Install for All Users during the installation.

 I have also tried installing instead the 3.2 version from the 
 python.orgwebsite but the same issue arises - IDLE doesn't launch.

 When I open a command prompt, and type:
c:\python32\python.exe -m idlelib.idle



 The message that comes is as follows:



 Microsoft Windows XP [Version 5.1.2600]
 (C) Copyright 1985-2001 Microsoft Corp.
 C:\Documents and Settings\Ceonnc:\python32\python.exe -m idlelib.idle
 Traceback (most recent call last):
   File c:\python32\lib\runpy.py, line 160, in _run_module_as_main
 __main__, fname, loader, pkg_name)
   File c:\python32\lib\runpy.py, line 73, in _run_code
 exec(code, run_globals)
   File c:\python32\lib\idlelib\idle.py, line 11, in module
 idlelib.PyShell.main()
   File c:\python32\lib\idlelib\PyShell.py, line 1374, in main
 root = Tk(className=Idle)
   File c:\python32\lib\tkinter\__init__.py, line 1674, 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:\IBMTOOLS\Python22\tcl\tcl8.4} C:/IBMTOOLS/Python22/tcl/tcl8.5
 c:/python3
 2/lib/tcl8.5 c:/lib/tcl8.5 c:/lib/tcl8.5 c:/library c:/library
 c:/tcl8.5.9/libra
 ry c:/tcl8.5.9/library
 C:/IBMTOOLS/Python22/tcl/tcl8.4/init.tcl: version conflict for package
 Tcl: ha
 ve 8.5.9, need exactly 8.4
 version conflict for package Tcl: have 8.5.9, need exactly 8.4
 while executing
 package require -exact Tcl 8.4
 (file C:/IBMTOOLS/Python22/tcl/tcl8.4/init.tcl line 19)
 invoked from within
 source C:/IBMTOOLS/Python22/tcl/tcl8.4/init.tcl
 (uplevel body line 1)
 invoked from within
 uplevel #0 [list source $tclfile]



 Someone told me: “You certainly have a TCL_LIBRARY environment variableset on 
 your system,
 it should be removed”.



 How do I remove TCL_LIBRARY, or do I change some numbers somewhere, and
 isn’t it risky to tinker with the Python settings already on my computer?



 Thanks for any help, I really would like to get going with Python!



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


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


Re: IDLE doesn't start

2011-03-11 Thread Kev Dwyer
Ceonn Bobst wrote:

snip
 
 When I open a command prompt, and type:
 c:\python32\python.exe -m idlelib.idle
 
 The message that comes is as follows:
 
 Microsoft Windows XP [Version 5.1.2600]
 (C) Copyright 1985-2001 Microsoft Corp.
 C:\Documents and Settings\Ceonnc:\python32\python.exe -m 
idlelib.idle
 Traceback (most recent call last):
 File c:\python32\lib\runpy.py, line 160, in _run_module_as_main
 __main__, fname, loader, pkg_name)
 File c:\python32\lib\runpy.py, line 73, in _run_code
 exec(code, run_globals)
 File c:\python32\lib\idlelib\idle.py, line 11, in module
 idlelib.PyShell.main()
 File c:\python32\lib\idlelib\PyShell.py, line 1374, in main
 root = Tk(className=Idle)
 File c:\python32\lib\tkinter\__init__.py, line 1674, 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:\IBMTOOLS\Python22\tcl\tcl8.4}
 C:/IBMTOOLS/Python22/tcl/tcl8.5 c:/python3 2/lib/tcl8.5 
c:/lib/tcl8.5
 c:/lib/tcl8.5 c:/library c:/library c:/tcl8.5.9/libra ry
 c:/tcl8.5.9/library C:/IBMTOOLS/Python22/tcl/tcl8.4/init.tcl: 
version
 conflict for package Tcl: ha ve 8.5.9, need exactly 8.4
 version conflict for package Tcl: have 8.5.9, need exactly 8.4
 while executing
 package require -exact Tcl 8.4
 (file C:/IBMTOOLS/Python22/tcl/tcl8.4/init.tcl line 19)
 invoked from within
 source C:/IBMTOOLS/Python22/tcl/tcl8.4/init.tcl
 (uplevel body line 1)
 invoked from within
 uplevel #0 [list source $tclfile]
 
 Someone told me: “You certainly have a TCL_LIBRARY environment 
variable
 set on your system, it should be removed”.
 
 How do I remove TCL_LIBRARY, or do I change some numbers somewhere, 
and
 isn’t it risky to tinker with the Python settings already on my 
computer?
 
 Thanks for any help, I really would like to get going with Python!

Hello,

You have an older version of Python on your machine in C:/IBMTOOLS.  
It's likely that the TCL_LIBRARY is pointing to the version of TCL 
installed there, and this is causing problems for your more modern 
Python install.

You change change Windows environment variables using the instructions 
here: http://support.microsoft.com/kb/310519.  Changing the 
environment variable is the documented solution for this - see 
http://bugs.python.org/issue5528.

If you keep a note of the environment variable you can always 
reinstate it later.

You can find some comments about the purpose of the IBMTOOLS folder at 
http://forum.thinkpads.com/viewtopic.php?f=8t=216.

All the best,

Kev

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


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Grant Edwards
On 2011-03-11, Martin Gregorie martin@address-in-sig.invalid wrote:

 BTW, there was no such thing as a VT-200 - there was a VT-220 text 
 terminal (which I think the OP was remembering) and the VT-240 and
 241 terminals, which were totally different graphics terminals that
 accepted Tektronics graphics commands: comparing a VT-220 to a
 VT-240/241 would be like comparing an Epson dot-matric printer to an
 HP 7485 plotter!

The 220 and 240/241 weren't fundamentally different display
technologies they way a dot-matrix differs from a pen-plotter.  Both
were raster-scan CRT tubes (AFAICT, they used identical CRT tubes and
driver hardwar). When used in text mode, the 240 wasn't really any
different than the 220.  But, the 240 also supported a graphics mode
that allowed apps to draw using vector commands).  I remember writing
an app using the ReGIS command set to draw a clock with a moving
second hand on a 240.

Comparing a vt220 to a vt240 is like comparing a black-and-white epson
9-pin dot-matrix printer that can't do graphics with a balck-and-white
epson 9-pin dot-matrix printer than can do graphics.

-- 
Grant Edwards   grant.b.edwardsYow! I've got a COUSIN
  at   who works in the GARMENT
  gmail.comDISTRICT ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tk MouseWheel Support

2011-03-11 Thread Dick Holmes
On Thu, 10 Mar 2011 21:56:52 +0100, Alexander Kapps
alex.ka...@web.de wrote:

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

First, thanks to MRAB for showing me how to get the wheel working.

In the following code (Windows only), rolling the wheel doesn't invoke
the event method. If I change the mouse wheel binding to
self.master.bind... the event gets called and the scrolling works.
Note that the scrolling occurs even when the mouse is outside the
listbox. I guess I'll have to look at the mouse position when I enter
the wheel_event method to see if the mouse is over the listbox.

# mouse wheel in listbox
import Tkinter as tk

class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.grid()

self.button = tk.Button(self, text='Button')
self.button.grid(row=0, column=0)

self.yscroll = tk.Scrollbar(self, orient=tk.VERTICAL)
self.yscroll.grid(row=1, column=1, sticky=tk.N+tk.S)
self.list = tk.Listbox(self, selectmode=tk.SINGLE, width=40,
height=5,
yscrollcommand=self.yscroll.set)
self.list.grid(row=1, column=0, sticky=tk.N+tk.S+tk.E+tk.W)
self.yscroll[command] = self.list.yview
self.list.bind(MouseWheel, self.wheel_event)
for i in xrange(10):
self.list.insert(tk.END, 'line ' + str(i))

def wheel_event(self, evt):
lines = evt.delta // 120
self.list.yview_scroll(-lines, tk.UNITS)

root = tk.Tk()
root.geometry('300x300+400+200')
root.title('  Wheel Test')
app = Application(master = root)
root.mainloop()

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


Re: Use-cases for alternative iterator

2011-03-11 Thread Terry Reedy

On 3/11/2011 1:43 AM, Steven D'Aprano wrote:

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 stdin, line 1, inmodule
StopIteration



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


Looking through Peter's nice list of real use cases, I see two 
categories: adapting an iterator-like function to Python's protocol; 
stopping an iterator before its normal exhaustion.


An example of the latter: suppose a file consists of header and body 
separated by a blank line. An opened file is an iterable, but its 
iterator only stops at eof. To process the two parts separately (using 
example from Peter's list):


for l in iter(f.readline,''):
  process header line
for l in f:
  process body line

(I am pretty sure that there are no buffer screwups with stop and 
restart since f iterator should call f.readline internally.)

Alternative is explicit if l == '': break in first loop.

I suspect the two param form, still rather new and unusual, is used less 
that is could, and perhaps should be. I am glad you raised the question 
to get me thinking about it.


--
Terry Jan Reedy

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


Re: IDLE doesn't start

2011-03-11 Thread Terry Reedy

On 3/11/2011 12:58 PM, Ceonn Bobst wrote:


Someone told me: “You certainly have a TCL_LIBRARY environment variable
set on your system, it should be removed”.


Someone else posted this week about the same problem (though from a 
different cause) and solution.



How do I remove TCL_LIBRARY, or do I change some numbers somewhere, and


Open Windows help, search 'environmental variable' and it should offer 
you Add or change the value of ...



isn’t it risky to tinker with the Python settings already on my computer?


That is not a Python setting. If you use any of the IBM utility programs 
that use the old Python2.2 and tcl/tk installation, and if any such 
program requires the TCL_LIBRARY setting (which it really ought not to, 
since a proper Python installation does not, at least not now), then you 
will have to work around the conflict with .bat files. But I would first 
write down the current setting before deleting it, so you could restore 
it if necessary.


I once had a similar py2.2 installation on my HP, but I deleted it 
several years ago as I never used any program that used it.


--
Terry Jan Reedy


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


Re: Creating a very simple revision system for photos in python

2011-03-11 Thread John Nagle

On 3/11/2011 6:56 AM, Thomas W wrote:

I`m thinking about creating a very simple revision system for photos
in python, something like bazaar, mercurial or git, but for photos.
The problem is that handling large binary files compared to plain text
files are quite different. Has anybody done something like this or
have any thoughts about it, I`d be very grateful. If something like
mercurial or git could be used and/or extended/customized that would
be even better.


   Alienbrain (http://www.alienbrain.com/) does this.  That's
what game companies use for revision control, where data includes
images, motion capture files, game levels, and music, as well as
code.  There's also Autodesk Vault, which does a similar job for
engineering data.

   One key to doing this well is the ability to talk about a
group of revisions across multiple files as an entity, without
having to be the owner of those files.  You need to say what
goes into a build of a game, or a revision of a manufactured
product.

   You also need really good tools to show the differences
between revisions.

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


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

2011-03-11 Thread Fred Pacquier
Robert sigz...@gmail.com said :

 Is there a push to one toolkit or the other?

If you are just now getting started, I would honestly suggest you save a 
whole lot of time and dive straight into PyQt. I've tried most 'em over the 
years (including some now discontinued), and in my experience Qt is way 
above the rest, especially as far as consistency and productivity are 
concerned. The Python bindings are very mature and well maintained, and go 
a long way attenuating the evil C++ roots.

I havent tried Nokia's equivalent (PySide). I'm not sure what its fate will 
turn out, given the company's change of heart and Microsoft honeymoon. At 
least PyQt is't going anywhere soon.

YMMV, of course :)
-- 
http://mail.python.org/mailman/listinfo/python-list


enhanced map function

2011-03-11 Thread Patrick
Hi,

The build-in map functions looks quite nice but it requests the
iterables to be of the same length or otherwises will file with None
(most of time fails the function). Just wondering if there are already
enhancement work done with it?

I did some simple code but it will handle list without nesting only.
I am looking for examples that could hand input of a = [2,3], b=4
and a=[1,[2,3],4], b=[5,[6,7,8],9,10]. That means if the nesting
structure is the same, enhanced map function will automatically extend
the shorter list using the last element. Or if the input is a constant
at the first point, then it feeds constant value to all other iterable
combinations.

Any tip is appreciated.
-Patrick.



def Add (x,y):
return x+y


def Bmap(function, *args):
num = 0
for iter in args[0:]:
if num  len(iter):
num = len(iter)

nlist=[]
for i in range(0,num,1):
fargs = []
for iter in args[0:]:
if len(iter)  i:
fargs.append(iter[i])
continue
fargs.append(iter[-1])

nlist.append(function(*fargs))
return nlist

if __name__ == '__main__':
a = [2,3]
b = [4,5,8]
print Bmap (Add, a, b)
-- 
http://mail.python.org/mailman/listinfo/python-list


Calling C++ Modules in Python

2011-03-11 Thread Patrick
Hi,

I saw in the Beginner document that •Is easily extended by adding new
modules implemented in a compiled language such as C or C++. .

While to my investigation, it seems not that easy or did I miss
something?

boost python (C++ libraries need to be re-compiled with written
wrappers again?).
SWIG  (It works by taking the declarations found in C/C++ header and
using them to generate the wrapper code that scripting languages need
to access the underlying C/C++ code).

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


Re: Calling C++ Modules in Python

2011-03-11 Thread Benjamin Kaplan
On Mar 11, 2011 4:23 PM, Patrick zxpat...@gmail.com wrote:

 Hi,

 I saw in the Beginner document that •Is easily extended by adding new
 modules implemented in a compiled language such as C or C++. .

 While to my investigation, it seems not that easy or did I miss
 something?

 boost python (C++ libraries need to be re-compiled with written
 wrappers again?).
 SWIG  (It works by taking the declarations found in C/C++ header and
 using them to generate the wrapper code that scripting languages need
 to access the underlying C/C++ code).

 Thanks
 -Patrick
 --

I believe the document was referring to writing your  own python modules in
C, not wrapping existing libraries.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling C++ Modules in Python

2011-03-11 Thread Sophie Sperner
Hi Patrick,


I'm using SWIG in my project. C++ code is wrapped and can be used in
python as custom module.
You should create a swig module.i file to describe headers upon which
that module will be built.

You should be certain about what you are going to use - boost library,
swig or something else, try it and if any problems post here :)


Yours,
Sophie

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


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

2011-03-11 Thread Dan Stromberg
On Fri, Mar 11, 2011 at 12:54 PM, Fred Pacquier xne...@fredp.lautre.netwrote:

 Robert sigz...@gmail.com said :

  Is there a push to one toolkit or the other?

 If you are just now getting started, I would honestly suggest you save a
 whole lot of time and dive straight into PyQt. I've tried most 'em over the
 years (including some now discontinued), and in my experience Qt is way
 above the rest, especially as far as consistency and productivity are
 concerned. The Python bindings are very mature and well maintained, and go
 a long way attenuating the evil C++ roots.

 I havent tried Nokia's equivalent (PySide). I'm not sure what its fate will
 turn out, given the company's change of heart and Microsoft honeymoon. At
 least PyQt is't going anywhere soon.


Didn't Nokia acquire Trolltech (and hence the rights to much if not all of
Qt) in 2008?

I'm not at all sure Qt's future is as bright as one might wish for.  They've
already declared that Qt will not be ported to Windows Mobile in any
official way, and of course mobile (not necessarily Windows Mobile) is where
just about everything is headed.

Actually, for something that's very cross-platform, you might check this
out: http://radicalbreeze.com/  Bryan can be a bit of a goober, but it
sounds like he's successfully implemented a great idea for quickly and
easily writing cross-platform applications.

Illumination even gives you the full Adobe Flex, Android Java, iOS Obj-C
and Python source code to the projects you create.  Making it a great way to
prototype new projects, or learn new languages.

I've still got a soft spot for Pyjamas though - it's opensource.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-03-11 Thread OKB (not okblacke)
Robert wrote:

 Is there a push to one toolkit or the other?

I use Dabo, which wraps wxPython.

-- 
--OKB (not okblacke)
Brendan Barnwell
Do not follow where the path may lead.  Go, instead, where there is
no path, and leave a trail.
--author unknown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling C++ Modules in Python

2011-03-11 Thread Dan Stromberg
On Fri, Mar 11, 2011 at 1:15 PM, Patrick zxpat...@gmail.com wrote:

 Hi,

 I saw in the Beginner document that •Is easily extended by adding new
 modules implemented in a compiled language such as C or C++. .

 While to my investigation, it seems not that easy or did I miss
 something?

 boost python (C++ libraries need to be re-compiled with written
 wrappers again?).
 SWIG  (It works by taking the declarations found in C/C++ header and
 using them to generate the wrapper code that scripting languages need
 to access the underlying C/C++ code).


I guess it should be asked: easy for who?  easy is always relative to
some context.

If you're planning to stay with CPython and C++ forevermore, then Cython is
a nice way of gluing the two.   Cython looks like Python code, but it gives
you access to C and C++ code and data as well as CPython code and data.

If you're planning to support your C++ code with more languages than
CPython, you might be better off with SWIG.

If you really do want to do the task the old way, you're probably best off
copying some preexisting module with a maximize-the-developers-rights
license (like Apache, MIT or 3 clause BSD), and modifying that.

If you want to be able to move easily to pypy, I might suggest coming up
with a C wrapper for your C++ code, and then accessing the C code using
ctypes.  That should work in CPython and pypy, and it looks like jython
might support this soon as well.
-- 
http://mail.python.org/mailman/listinfo/python-list


PEP for module naming conventions

2011-03-11 Thread Tim Johnson
I need to be better informed on naming conventions for modules.  For
instance, I need to create a new module and I want to make sure that
the module name will not conflict with any future or current python
system module names.

There may be a PEP for this, if so, a URL to such a PEP would
suffice for my inquiry. Also, if there is an index of PEPs, a link
to such would also be appreciated.

thanks
-- 
Tim 
tim at johnsons-web.com or akwebsoft.com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling C++ Modules in Python

2011-03-11 Thread Patrick
Thanks Sophie for the information. Yes, right now I am not certain
about what I am going to use for I was hoping for a non-intrusive
way to expose existing C++ libraries to python. However, both
solutions (BOOST, SWIG) listed here require the recompilation of
libraries?! It is ok for small applications but will be hard for big
software from big companies. The reason is that even companies are
willing to rebuild their own libraries with those wrappers or
decorations added(though needs approves from all sorts of
departments :)), they can't force their 3rd-party developers/users.
Correct me if I am wrong.

Cheers,
-Patrick.

On Mar 11, 4:32 pm, Sophie Sperner sophie.sper...@gmail.com wrote:
 Hi Patrick,

 I'm using SWIG in my project. C++ code is wrapped and can be used in
 python as custom module.
 You should create a swig module.i file to describe headers upon which
 that module will be built.

 You should be certain about what you are going to use - boost library,
 swig or something else, try it and if any problems post here :)

 Yours,
 Sophie

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


Re: PEP for module naming conventions

2011-03-11 Thread David Marek
Hi,

Have you read PEP 8? http://python.org/dev/peps/pep-0008/
I don't think it's possible to be sure that the name of your module
won't conflict with system module name (if you'll follow conventions).

You can find the list of all PEPs at http://python.org/dev/peps/

-- 
David Marek
dav...@atrey.karlin.mff.cuni.cz
http://davidmarek.cz


On Fri, Mar 11, 2011 at 10:52 PM, Tim Johnson t...@johnsons-web.com wrote:
 I need to be better informed on naming conventions for modules.  For
 instance, I need to create a new module and I want to make sure that
 the module name will not conflict with any future or current python
 system module names.

 There may be a PEP for this, if so, a URL to such a PEP would
 suffice for my inquiry. Also, if there is an index of PEPs, a link
 to such would also be appreciated.

 thanks
 --
 Tim
 tim at johnsons-web.com or akwebsoft.com
 http://www.akwebsoft.com
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Re: Calling C++ Modules in Python

2011-03-11 Thread zxpatric

Dan,

Thanks for the info. Really I was hoping for a non-intrusive way to  
expose existing C++ libraries to python. However, both solutions (BOOST,  
SWIG) listed here require the recompilation of libraries?! Seems Cython is  
doing the similar way? It is ok for small applications but will be hard for  
big software from big companies. The reason is that even companies are  
willing to rebuild their own libraries with those wrappers or decorations  
added(though needs approves from all sorts of departments :)), they can't  
force their 3rd-party developers/users.

Correct me if I am wrong.

Rg,
-Patrick

On Mar 11, 2011 4:59pm, Dan Stromberg drsali...@gmail.com wrote:


On Fri, Mar 11, 2011 at 1:15 PM, Patrick zxpat...@gmail.com wrote:




Hi,







I saw in the Beginner document that •Is easily extended by adding new




modules implemented in a compiled language such as C or C++. .







While to my investigation, it seems not that easy or did I miss




something?







boost python (C++ libraries need to be re-compiled with written




wrappers again?).




SWIG (It works by taking the declarations found in C/C++ header and




using them to generate the wrapper code that scripting languages need




to access the underlying C/C++ code).


I guess it should be asked: easy for who? easy is always relative to  
some context.


If you're planning to stay with CPython and C++ forevermore, then Cython  
is a nice way of gluing the two. Cython looks like Python code, but it  
gives you access to C and C++ code and data as well as CPython code and  
data.




If you're planning to support your C++ code with more languages than  
CPython, you might be better off with SWIG.


If you really do want to do the task the old way, you're probably best  
off copying some preexisting module with a maximize-the-developers-rights  
license (like Apache, MIT or 3 clause BSD), and modifying that.




If you want to be able to move easily to pypy, I might suggest coming up  
with a C wrapper for your C++ code, and then accessing the C code using  
ctypes. That should work in CPython and pypy, and it looks like jython  
might support this soon as well.










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


Inserting record into postgresql database

2011-03-11 Thread Meszaros, Stacy
Hello all,

I am using python 2.6 and the psycopg2 module for the postgres connection
The following code is supposed to insert a record into a table with a bytea 
field. (bytearray)
I am having difficulty getting to field inserted properly.  The snippet below 
inserts the first 8 bit hex value, which is 0xA5, correctly I believe - as \245
Not sure why, but the rest of the 'string' is not inserted into the db table.
Any ideas?

commandString = 
re.escape(A500046898000AC73D228B0B018040003BF9)
insert = INSERT INTO profile_commands(command_id, profile_id, 
execution_order, command, command_type) VALUES(%s, %s, 0, %s, 1); 
self.cur.execute(insert, (command_id, profileID,commandString,))
self.conn.commit()

Thanks for any ideas you can give me
Stacy


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


Re: Re: Calling C++ Modules in Python

2011-03-11 Thread Dan Stromberg
I've not tried Boost, but I don't think SWIG or Cython require modified
libraries.  You just compile your wrapper, and then import it.

On Fri, Mar 11, 2011 at 2:16 PM, zxpat...@gmail.com wrote:

 Dan,

 Thanks for the info. Really I was hoping for a non-intrusive way to
 expose existing C++ libraries to python. However, both solutions (BOOST,
 SWIG) listed here require the recompilation of libraries?! Seems Cython is
 doing the similar way? It is ok for small applications but will be hard for
 big software from big companies. The reason is that even companies are
 willing to rebuild their own libraries with those wrappers or decorations
 added(though needs approves from all sorts of departments :)), they can't
 force their 3rd-party developers/users.
 Correct me if I am wrong.

 Rg,
 -Patrick

 On Mar 11, 2011 4:59pm, Dan Stromberg drsali...@gmail.com wrote:
 
  On Fri, Mar 11, 2011 at 1:15 PM, Patrick zxpat...@gmail.com wrote:
 
 
  Hi,
 
 
 
 
 
  I saw in the Beginner document that •Is easily extended by adding new
 
 
  modules implemented in a compiled language such as C or C++. .
 
 
 
 
 
  While to my investigation, it seems not that easy or did I miss
 
 
  something?
 
 
 
 
 
  boost python (C++ libraries need to be re-compiled with written
 
 
  wrappers again?).
 
 
  SWIG  (It works by taking the declarations found in C/C++ header and
 
 
  using them to generate the wrapper code that scripting languages need
 
 
  to access the underlying C/C++ code).
 
  I guess it should be asked: easy for who?  easy is always relative to
 some context.
 
  If you're planning to stay with CPython and C++ forevermore, then Cython
 is a nice way of gluing the two.   Cython looks like Python code, but it
 gives you access to C and C++ code and data as well as CPython code and
 data.
 
 
 
  If you're planning to support your C++ code with more languages than
 CPython, you might be better off with SWIG.
 
  If you really do want to do the task the old way, you're probably best
 off copying some preexisting module with a maximize-the-developers-rights
 license (like Apache, MIT or 3 clause BSD), and modifying that.
 
 
 
  If you want to be able to move easily to pypy, I might suggest coming up
 with a C wrapper for your C++ code, and then accessing the C code using
 ctypes.  That should work in CPython and pypy, and it looks like jython
 might support this soon as well.
 
 
 
 
 
 
 
 
 

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


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


Re: PEP for module naming conventions

2011-03-11 Thread Tim Johnson
* David Marek dav...@atrey.karlin.mff.cuni.cz [110311 13:20]:
 Hi,
 
 Have you read PEP 8? http://python.org/dev/peps/pep-0008/
 I don't think it's possible to be sure that the name of your module
 won't conflict with system module name (if you'll follow conventions).
 
 You can find the list of all PEPs at http://python.org/dev/peps/
  Thank you for the links David.

 -- 
 David Marek
 dav...@atrey.karlin.mff.cuni.cz
 http://davidmarek.cz
 And interesting web site. The future is with us. 

 
 On Fri, Mar 11, 2011 at 10:52 PM, Tim Johnson t...@johnsons-web.com wrote:
  I need to be better informed on naming conventions for modules.  For
  instance, I need to create a new module and I want to make sure that
  the module name will not conflict with any future or current python
  system module names.
 
  There may be a PEP for this, if so, a URL to such a PEP would
  suffice for my inquiry. Also, if there is an index of PEPs, a link
  to such would also be appreciated.
 
  thanks
  --
  Tim
  tim at johnsons-web.com or akwebsoft.com
  http://www.akwebsoft.com
  --
  http://mail.python.org/mailman/listinfo/python-list
 

-- 
Tim 
tim at johnsons-web.com or akwebsoft.com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-03-11 Thread Octavian Rasnita
From: OKB (not okblacke) brennospamb...@nobrenspambarn.net
 Robert wrote:
 
 Is there a push to one toolkit or the other?
 
I use Dabo, which wraps wxPython.
 
 -- 


What's the advantage of using Dabo instead of wxPython directly?

Thanks.

Octavian

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


How should I handle socket receiving?

2011-03-11 Thread Hans
I'm thinking to write a code which to:
1. establish tons of udp/tcp connections to a server
2. send packets from each connections
3. receive packets from each connections and then do something based
on received content and connection statues.
4. repeat step 2 and step 3.

my question is how should I handle receiving traffic from each
connection respectively?  two ways I'm thinking are:
1. setup connections one by one, put socket handler into an
array(dictionary?), array also record each handler's status. then in a
big loop, keep using select to check sockets, if any socket get
something received, then find the socket in the array, based on the
socket status to do things should be done.  this one is like single-
thread?

2. (I don't know if this one works, but I prefer this one if it do
works. ) Setup connection object, write codes in the object to handle
sending/receiving and status. let each object to check/receive its
socket by itslef(I don't know how yet).  Then In the main proc, I just
initiate those objects.

 Any responses would be very welcome, thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


OT: processes, terminals and file descriptors on *nix (was: Re: attach to process by pid?)

2011-03-11 Thread Alexander Kapps

On 11.03.2011 03:18, Nobody wrote:

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


Many thanks for the correction and lesson (to Grand Edwards too)!

I still try to digest your explanations. I thought, that processes 
just do something like dup()'ing the file descriptors of their 
terminal but after some strace experiments, I think that is totally 
wrong.


I'd like to learn more about this (how processes, their controlling 
terminals and the std file descriptors relate)


Do you know any links to deeper material (tried Google but what I've 
found is to shallow)

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


Re: How should I handle socket receiving?

2011-03-11 Thread Dan Stromberg
On Fri, Mar 11, 2011 at 3:30 PM, Hans hans...@gmail.com wrote:

 I'm thinking to write a code which to:
 1. establish tons of udp/tcp connections to a server
 2. send packets from each connections
 3. receive packets from each connections and then do something based
 on received content and connection statues.
 4. repeat step 2 and step 3.

 my question is how should I handle receiving traffic from each
 connection respectively?  two ways I'm thinking are:
 1. setup connections one by one, put socket handler into an
 array(dictionary?), array also record each handler's status. then in a
 big loop, keep using select to check sockets, if any socket get
 something received, then find the socket in the array, based on the
 socket status to do things should be done.  this one is like single-
 thread?

This should work, except you perhaps don't need to keep the sockets in an
array or find them in that array, because select is going to return a list
of the ones that are ready for I/O.


 2. (I don't know if this one works, but I prefer this one if it do
 works. ) Setup connection object, write codes in the object to handle
 sending/receiving and status. let each object to check/receive its
 socket by itslef(I don't know how yet).  Then In the main proc, I just
 initiate those objects


Each instance of your object(s) could select on just one socket.  Start each
object doing its thing in parallel.  How you do that depends on what kind of
concurrency you choose, but there tend to be lots of nice example programs
that you can readily locate using google, showing how.

CPython's threading is not strong (not sure how much it's improved in 3.2),
so for concurrency, you'd probably best use the multiprocessing module or
CPython 3.2's futures - or an alternative python implementation that
threads well, like Jython.  Oh, and you could try greenlets.

In a way this is simpler than #1, in a way it's not.

Supposedly tornado gets lots of great performance -because- it's single
threaded.  And it makes sense that this would be fast, up to a point,
because you eliminate lots of context switching.

However, on a system with lots of cores, and perhaps to future-proof your
code (most likely individual cores aren't getting much faster anymore, but
the number of cores is most likely going up), you're probably better off
with something concurrent like your #2.

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


Re: OT: processes, terminals and file descriptors on *nix (was: Re: attach to process by pid?)

2011-03-11 Thread Dan Stromberg
On Fri, Mar 11, 2011 at 3:49 PM, Alexander Kapps alex.ka...@web.de wrote:

 On 11.03.2011 03:18, Nobody wrote:

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


 Many thanks for the correction and lesson (to Grand Edwards too)!

 I still try to digest your explanations. I thought, that processes just do
 something like dup()'ing the file descriptors of their terminal but after
 some strace experiments, I think that is totally wrong.

Usually, file descriptors are inherited across fork() (and maybe Windows'
startprocess), as is the contents of any buffers corresponding to them - so
when flushing you can get two copies of the same output, or two copies of
the same input.

There's no need to dup to just inherit a filedescriptor from a parent
process to a child.


 I'd like to learn more about this (how processes, their controlling
 terminals and the std file descriptors relate)

I'm not sure controlling terminals are that relevant.

The standard filedescriptors are just 0, 1, and 2 for stdin, stdout and
stderr.  They're pretty much like any other filedescriptors, except they
tend to be open already when a program starts.  Oh, and the buffering might
be different from one filedes to another, of course.


 Do you know any links to deeper material (tried Google but what I've found
 is to shallow)


Check this out; you can pass a filedescriptor through a unix domain socket,
though I've never tried it myself in C, let alone Python:
http://stackoverflow.com/questions/909064/portable-way-to-pass-file-descriptor-between-different-processes
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inserting record into postgresql database

2011-03-11 Thread MRAB

On 11/03/2011 22:08, Meszaros, Stacy wrote:

Hello all,

I am using python 2.6 and the psycopg2 module for the postgres connection
The following code is supposed to insert a record into a table with a bytea 
field. (bytearray)
I am having difficulty getting to field inserted properly.  The snippet below 
inserts the first 8 bit hex value, which is 0xA5, correctly I believe - as \245
Not sure why, but the rest of the 'string' is not inserted into the db table.
Any ideas?

 commandString = 
re.escape(A500046898000AC73D228B0B018040003BF9)
 insert = INSERT INTO profile_commands(command_id, profile_id, 
execution_order, command, command_type) VALUES(%s, %s, 0, %s, 1); 
 self.cur.execute(insert, (command_id, profileID,commandString,))
 self.conn.commit()

Thanks for any ideas you can give me
Stacy


Does this help?

http://stackoverflow.com/questions/3103242/inserting-text-string-with-hex-into-postgresql-as-a-bytea
--
http://mail.python.org/mailman/listinfo/python-list


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread Martin Gregorie
On Fri, 11 Mar 2011 19:32:53 +, Grant Edwards wrote:

 On 2011-03-11, Martin Gregorie martin@address-in-sig.invalid wrote:
 
 BTW, there was no such thing as a VT-200 - there was a VT-220 text
 terminal (which I think the OP was remembering) and the VT-240 and 241
 terminals, which were totally different graphics terminals that
 accepted Tektronics graphics commands: comparing a VT-220 to a
 VT-240/241 would be like comparing an Epson dot-matric printer to an HP
 7485 plotter!
 
 The 220 and 240/241 weren't fundamentally different display technologies
 they way a dot-matrix differs from a pen-plotter.  Both were raster-scan
 CRT tubes (AFAICT, they used identical CRT tubes and driver hardwar).
 When used in text mode, the 240 wasn't really any different than the
 220.  But, the 240 also supported a graphics mode that allowed apps to
 draw using vector commands).  I remember writing an app using the ReGIS
 command set to draw a clock with a moving second hand on a 240.
 
 Comparing a vt220 to a vt240 is like comparing a black-and-white epson
 9-pin dot-matrix printer that can't do graphics with a balck-and-white
 epson 9-pin dot-matrix printer than can do graphics.

Sorry if I wasn't clear: I was intending to compare APIs rather than the 
display mechanisms - I am aware that both text terminals and vector 
graphics terminals are raster devices, not vector like oscilloscopes.  
What I was getting at is that the API used to cause graphics or text to 
be output on a dot-matrix printer is totally unlike that used to draw to 
same representations on a pen plotter.


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


Re: enhanced map function

2011-03-11 Thread Steven D'Aprano
On Fri, 11 Mar 2011 13:00:23 -0800, Patrick wrote:

 Hi,
 
 The build-in map functions looks quite nice but it requests the
 iterables to be of the same length or otherwises will file with None
 (most of time fails the function). Just wondering if there are already
 enhancement work done with it?


That has been fixed in Python 3.1:

 from operator import add
 list(map(add, [1,2,3], [1,2,3,4,5]))
[2, 4, 6]

Starting from Python 2.3, the itertools module has had a function imap 
with the same behaviour:

 from operator import add
 list(itertools.imap(add, [1,2,3], [1,2,3,4,5]))
[2, 4, 6]


 
 I did some simple code but it will handle list without nesting only. 

Surely that is a good thing. If you have a mix of nested and non-nested 
data, that tells me your data is badly organized and needs to be fixed.


 I am looking for examples that could hand input of a = [2,3], b=4 

Using a small helper function:

import itertools

def make_iterable(obj):
try:
iter(obj)
except TypeError:
obj = itertools.cycle([obj])
return obj

def enhanced_map(func, *args):
args = map(make_iterable, args)
return list(itertools.imap(func, *args))


WARNING: this is dangerous. If none of the arguments are iterable, e.g. 
you call enhanced_map(operator.add, 2, 3), this will happily loop forever 
building a larger and larger list, until you run out of memory or kill 
the Python process.


 and a=[1,[2,3],4], b=[5,[6,7,8],9,10]. That means if the nesting
 structure is the same, enhanced map function will automatically extend
 the shorter list using the last element.

It isn't clear what you want here. Are you expecting this enhanced map to 
recursively drop down into each layer of sub-sequences? That is:

enhanced_map([1, [2,3, [4,5], 6], 7], [8, [7,6, [5,4], 3], 2])

should be the same as 

map([1, 2, 3, 4, 5, 6, 7], [8, 7, 6, 5, 4, 3, 2])

or something different?


What do you expect to happen if the sub-sequences don't match up exactly? 
E.g. a = [1, 2, [3, 4]]; b = [1, [2, 3], 4]

What do you expect to happen if the shorter list is empty?
E.g. a = [1, 2, [3, 4], 5]; b = [1, 2, [], 3]

This will get really messy fast. My advice is to forget about this as a 
bad idea, and instead concentrate on making sure your data isn't so badly 
arranged in the first place.



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


Re: my computer is allergic to pickles

2011-03-11 Thread Bob Fnord
Peter Otten __pete...@web.de wrote:

 Bob Fnord wrote:

  I started by using cPickle to save the instance of the class that
  contained this dict, but the pickling process started to write
  the file but ate so much memory that my computer (4 GB RAM)
  crashed so badly that I had to press the reset button. I've never
  seen out-of-memory errors do this before. Is this normal?
snipped myself
  Any comments, suggestions?
 
 Have you seen that one?
 
 http://mail.python.org/pipermail/python-list/2008-July/1139855.html

Not until now, but that's interesting. But I didn't even get a
backtrace, just a totally locked up computer!

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


Re: my computer is allergic to pickles

2011-03-11 Thread Bob Fnord
Miki Tebeka miki.teb...@gmail.com wrote:

  From looking at the shelve info in the library reference, I get
  the impression it's tricky to change the values in the dict for
  existing keys and be sure they get changed on disk.
 You can use writeback=True or call sync at the right places.
 
 
  How can you convert a tuple of strings to a string and back in a
  reliable deterministic way? The original strings may have '  ,
  in them.
 You can use marshal, json or any other serializing library.

Thanks for the tips. I guess I'll use json if I ever need to be
able to read the file with something else besides python, but
marshal seems fine for now.

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


Re: How should I handle socket receiving?

2011-03-11 Thread n00m
I'm abs not sure but maybe you'll need to put
each client into separate thread; like this

def Client_func(s2, cn):
 while 1:
 data = cn.recv(4096)
 if not data:
 s2.shutdown(1)
 return
 s2.sendall(data)



cn, addr = s1.accept()
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.connect((the_server_host, the_server_port))
thread.start_new_thread(Client_func, (s2, cn,))
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-03-11 Thread OKB (not okblacke)
Octavian Rasnita wrote:

 From: OKB (not okblacke) brennospamb...@nobrenspambarn.net
 Robert wrote:
 
 Is there a push to one toolkit or the other?
 
I use Dabo, which wraps wxPython.
 
 -- 
 
 
 What's the advantage of using Dabo instead of wxPython directly?

Dabo gives you a much more intuitive and Pythonic API.  There's 
also a GUI designer for building apps graphically, although I haven't 
really used that.

-- 
--OKB (not okblacke)
Brendan Barnwell
Do not follow where the path may lead.  Go, instead, where there is
no path, and leave a trail.
--author unknown
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-03-11 Thread Robert

On 2011-03-11 01:14:01 -0500, Dan Stromberg said:



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 sigz...@gmail.com wrote:
Is there a push to one toolkit or the other?


I am mostly on OSX...but I would target at least the big three 
(Windows, Linux, OSX).


--
Robert


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


Re: Calling C++ Modules in Python

2011-03-11 Thread Terry Reedy

On 3/11/2011 4:15 PM, Patrick wrote:

Hi,

I saw in the Beginner document that •Is easily extended by adding new
modules implemented in a compiled language such as C or C++. .

While to my investigation, it seems not that easy or did I miss
something?

boost python (C++ libraries need to be re-compiled with written
wrappers again?).
SWIG  (It works by taking the declarations found in C/C++ header and
using them to generate the wrapper code that scripting languages need
to access the underlying C/C++ code).


cytpes does not require recompilation. Not as fast either. But good 
enough for many purposes.


--
Terry Jan Reedy


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


Re: Purely historic question: VT200 text graphic programming

2011-03-11 Thread rzed
Anssi Saari a...@sci.fi wrote in
news:vg3hbba6mp7@pepper.modeemi.fi: 

 Grant Edwards invalid@invalid.invalid writes:
 
 C wasn't very widely used under VMS, and VMS had it's own screen
 formatting and form handling libraries.
 
 Just curious, what language was widely used in VMS? My VMS
 experience is limited to running Maple for a math course in the
 university in early 1990s. Didn't know how to do much more than
 start Maple, probably just dir, logout (or was it logoff?) and
 ftp :) 

Did you say was? The last time I did any programming on a VMS system 
was ... about 5 1/2 hours ago. Our shop runs OpenVMS now, programs 
mostly in C and BASIC. I've quietly insinuated Python into the mix 
over the last few months, and that has helped my sanity considerably.

I did use the curses library with Vax C years ago, though online data 
entry programs used the SMG library. 

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


organizing many python scripts, in a large corporate environment.

2011-03-11 Thread Phat Fly Alanna
We've been doing a fair amount of Python scripting, and now we have a
directory with almost a hundred loosely related scripts. It's
obviously time to organize this, but there's a problem. These scripts
import freely from each other and although code reuse is  generally a
good thing it makes it quite complicated to organize them into
directories.

There's a few things that you should know about our corporate
environment:

1) I don't have access to the users' environment. Editing the
PYTHONPATH is out, unless it happens in the script itself.
2) Users don't install things. Systems are expected to be *already*
installed and working, so setup.py is not a solution.

I'm quite willing to edit my import statements and do some minor
refactoring, but the solutions I see currently require me to divide
all  the code strictly between user runnable scripts and
libraries, which isn't feasible, considering the amount of code.

Has anyone out there solved a similar problem? Are you happy with it?

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


organizing many python scripts, in a large corporate environment.

2011-03-11 Thread bukzor
We've been doing a fair amount of Python scripting, and now we have a
directory with almost a hundred loosely related scripts. It's
obviously time to organize this, but there's a problem. These scripts
import freely from each other and although code reuse is  generally a
good thing it makes it quite complicated to organize them into
directories.

There's a few things that you should know about our corporate
environment:

1) I don't have access to the users' environment. Editing the
PYTHONPATH is out, unless it happens in the script itself.
2) Users don't install things. Systems are expected to be *already*
installed and working, so setup.py is not a solution.

I'm quite willing to edit my import statements and do some minor
refactoring, but the solutions I see currently require me to divide
all the code strictly between user runnable scripts and libraries,
which isn't feasible, considering the amount of code.

Has anyone out there solved a similar problem? Are you happy with it?
--Buck
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: attach to process by pid?

2011-03-11 Thread John Nagle

On 3/9/2011 5:38 PM, Miki Tebeka wrote:

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


There are ways under Windows to attach to a running process and do 
things to it.  Look up CreateRemoteThread.  There's a way to
do this under Linux, too.  See 
http://www.codeproject.com/KB/DLL/code_injection.aspx;.


It is very unlikely that a Python programmer would use either of
these.  The original poster needs to express more clearly what
they really want to do.  I suspect they want to create a server
that client programs can talk to.  There are good ways to do that,
both on the same machine and across a network.

John Nagle

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


Re: organizing many python scripts, in a large corporate environment.

2011-03-11 Thread eryksun ()
I'm not an expert at Python packaging, but assuming a structure such as

folder1
   \
__init__.py
module1.py
folder2
   \
__init__.py
module2.py

Then from the root folder I can run 

python -m folder1.module1

and within module1, I can import from module2, e.g.:

from folder2.module2 import foo

The __init__.py files are empty. They make Python treat the folder as a package 
namespace from which you can import, or execute a module directly with the -m 
option.

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


Re: Compile time evaluation of dictionaries

2011-03-11 Thread Steven D'Aprano
On Thu, 10 Mar 2011 11:23:32 -0500, 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:
[...]
 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.

Python is a language, what you are looking at is an implementation of 
that language. Although I have never used it myself, apparently Cesare Di 
Mauro's WPython does more constant folding optimizations than CPython. 
See pages 21-24 of 

http://wpython2.googlecode.com/files/Beyond%20Bytecode%20-%20A%20Wordcode-based%20Python.pdf



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


[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

fold-0.patch looks good to me, but why do you include tests only for the float 
case (-0.0) and not the integer case (-0)?

Style nitpick:  def negzero(): return -(1.0-1.0) should be on two source 
lines, not one.

--

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



  1   2   3   >