Re: Is it more CPU-efficient to read/write config file or read/write sqlite database?

2013-12-18 Thread dick
On Wed, 18 Dec 2013 21:50:00 +1100, Chris Angelico 
wrote:

>On Wed, Dec 18, 2013 at 9:31 PM, Cameron Simpson  wrote:
>> On 18Dec2013 14:35, Chris Angelico  wrote:
>>> An SQL database *is* a different form of storage. It's storing tabular
>>> data, not a stream of bytes in a file. You're supposed to be able to
>>> treat it as an efficient way to locate a particular tuple based on a
>>> set of rules, not a different way to format a file on the disk.
>>
>> Shrug. It's all just data to me. I don't _care_ about the particular
>> internal storage format.
>
>Then use a file, because you want file semantics. That's why you have
>both options available.
>
>> Commit() is a logical operation saying this SQL changeset is now
>> part of the global state.
>
>The global state is defined by what's on the disk. Specifically, by
>what would be read if the power failed right at that moment. In the
>case of PostgreSQL, a commit doesn't actually write the table pages -
>it just writes the WAL (Write-Ahead Log), which is used to recreate
>the transaction. If something fails hard, the WAL replay will apply
>the change perfectly. That's the global state. It's not there till the
>WAL's been fsync'd.
>
  
>
>> All that has happened after an fsync() is that the OS taken your
>> SQL changeset that you commited to the OS data abstraction and
>> pushed it one layer lower into the "disk" abstraction. There's more
>> going on in there.
>
>Not just pushed it one layer lower; the point of fsync is that it's
>been pushed all the way down. See its man page [1]:
>
>"""fsync() transfers ("flushes") all modified in-core data ... to the
>disk ... so that all changed information can be retrieved even after
>the system crashed or was rebooted."""
>
>It's fundamentally about crash recovery, not about "passing it to a
>lower abstraction". Of course, the OS isn't always *able* to guarantee
>things (NFS shares are notoriously hard to pin down), but the
>intention of fsync is that it won't return (and therefore the COMMIT
>operation won't finish) until the data can be read back reliably even
>in the event of a major failure.
>
>Databases protect against that. If you want that protection, use a
>database. If you don't, use a file. There's nothing wrong with either
>option.
>
>ChrisA
>
>[1] on the web here, for those who don't have them handy:
>http://linux.die.net/man/2/fsync

Don't forget that most hard disks have an option to cache the write
data. This is a 'feature' that allows the manufacturers to claim
better write performance. You can't be sure when the data is written
to the disk if that option is in play.

Dick
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is it more CPU-efficient to read/write config file or read/write sqlite database?

2013-12-18 Thread dick
On Wed, 18 Dec 2013 12:00:50 -0600, Tim Chase
 wrote:

>On 2013-12-18 09:49, dick wrote:
>> Don't forget that most hard disks have an option to cache the write
>> data. This is a 'feature' that allows the manufacturers to claim
>> better write performance. You can't be sure when the data is written
>> to the disk if that option is in play.
>
>However, my understanding is that they have a small on-drive
>battery/capacitor that stores sufficient energy for the cached
>write(s) to complete in the event the system's power abruptly cuts
>off.
>
>Granted, this is purely hearsay, as it's been a long time since I
>mucked around with hardware much.
>
>-tkc
>
>
The drives may have something like that now, but they didn't have any
power down flush capability when I was working for WD. Of course, that
was 15 years ago...

Dick
-- 
https://mail.python.org/mailman/listinfo/python-list


pyTTS com_error

2007-12-11 Thread Dick
I am trying to get the pyTTS module working. I have Python 2.4, the
Microsodt SAPI and pyTTS-3.0.win32-py2.4.exe installed.

When I run this script:

import pyTTS
tts = pyTTS.Create()

#set the speech rate
tts.Rate = 4

#set the speech volume percentage (0-100%)
tts.Volume = 40

#get a list of all the available voice actors
print tts.GetVoiceNames()

#explicitly set a voice
tts.SetVoiceByName('MSMary')

#speak the text
tts.Speak('This is the sound of my voice.')

I get this result

>>>
[u'MSMary', u'MSMike', u'MS-Anna-1033-20-DSK']

Traceback (most recent call last):
  File "C:/Python24/spelling/testspeech", line 17, in -toplevel-
tts.Speak('This is the sound of my voice.')
  File "C:\Python24\Lib\site-packages\pyTTS\sapi.py", line 213, in
Speak
self.speech.Speak(text, flagsum)
  File "C:\Python24\lib\site-packages\win32com\gen_py
\C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x3.py", line 2831, in Speak
, Flags)
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None,
0, -2147221164), None)
>>>

I am a brand-newby, and any help will be greatly appreciated.

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


Re: Windows vista

2009-02-16 Thread Dick
On Feb 16, 1:46 am, [email protected] wrote:
> Hi. My name is toru.
> I start learning python couple weeks ago.
>
> I install the compiler from python.org.
> but I cannot use the IDLE program.
> (command line works fine so far)
> the error screen says that the my personal fire wall is blocking the
> program to run.
> I am not sure how to fix this.
> By the way, I heard many people said that this is because I am using
> windows vista.
> Does anyone know how to use IDLE program on Windows Vista machine?
>
> thank you.

On my Vista machine I reply to a firewall popup the first time I run
IDLE and tell it to allow
IDLE to open a port. The next time I run IDLE, all is OK. I still have
the problem that
sometimes IDLE does not properly cleanup hung processes, which means
IDLE will not restart.

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


python\bluetooth / wsgi / apache 2.2

2012-12-13 Thread Barry Dick
I'm wanting to read from my bluetooth device (it just sends data/header with a 
checksum at the end, in a continuous mode "a biofeedback device") and I'm 
getting a weird error in my logs not allowing me to use multiple sockets. I 
guess with wsgi, I'm creating a link/module between the two apis (apache / 
python), and then lets apache manage the socket / port communication on the 
application layer. How ever, I'm not able to connect to my device. Is there 
something simple I'm missing? The test code is the following

#!/usr/bin/python

# Written by Yevgeniy Medynskiy ([email protected])
# Date modified: December 2006
#
# No copyright. No warranty. Distributed as-is.
#
# http://www.gvu.gatech.edu/ccg/resources/wearableRFID.html

import time
import bluetooth
import sys

class MyWriter:

def __init__(self, stdout, filename):
#self.stdout = stdout
self.logfile = file(filename, 'a')

def write(self, text):
#self.stdout.write(text)
self.logfile.write(text)

def close(self):
#self.stdout.close()
self.logfile.close()

writer = MyWriter(sys.stdout, 'logging.txt')
sys.stdout = writer

#
## Change to your device's Bluetooth address
#
device = "10:00:E8:AC:4D:D0"

port = 1

#
## Read command and request for acknowledgement.
#

socket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)

#print "Attempting to connect to " + device + ":" + str(port) + "...",
socket.connect((device, port))
#print "done."

#print "Receiving data..."


data = ""
try:
while True:
try:
data = socket.recv(255)
except bluetooth.BluetoothError, b:
print "Bluetooth Error: ", b

if len(data) > 0: print data

except KeyboardInterrupt:
#print "Closing socket...",
socket.close()
#print "done."

[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] mod_wsgi (pid=2780): 
Target WSGI script 'C:/Project/index.py' cannot be loaded as Python module.
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] mod_wsgi (pid=2780): 
Exception occurred processing WSGI script 'C:/Project/index.py'.
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] Traceback (most recent 
call last):
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1]   File 
"C:/Project/index.py", line 45, in 
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] 
socket.connect((device, port))
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1]   File 
"C:\\Python26\\lib\\site-packages\\bluetooth\\msbt.py", line 53, in connect
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] bt.connect 
(self._sockfd, addr, port)
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] IOError: Only one usage 
of each socket address (protocol/network address/port) is normally permitted.\r
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] 

I realize that in order for me to feed information back to apache and then onto 
my client, is I need to def application() but I wanted to make sure it was 
just that, and not something that I don't know about using sockets.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python parsing Bluetooth RFCOMM for 9 bytes

2012-12-13 Thread Barry Dick
My data looks like this when it comes from the device (biofeedback device). 
There are 9 bytes in total, and I need to buffer so much, and then poll it for 
new/recent packets. The start packet unfortunately starts with 0x00

So far the only thing I've found that looks like what I want to do is this, but 
I don't know how to implement it. http://code.activestate.com/recipes/408859/


Data:  [002d0270025e00]
Data:  [0001004a0006026547]
Data:  [0002004b000a026343]
Data:  [00]
Data:  [03004f0006025b4a00]
Data:  [046698000802569d00]
Data:  [3002830257f100]
Data:  [01004a000602585400]
Data:  [020048000a025b4e00]
Data:  [03004b0006025b4e00]
Data:  [046698000702579d00]
Data:  [2f027602480e00]
Data:  [01004a0006024b61]
Data:  [0002004a000a025552]
Data:  [0003004b0006025752]
Data:  [00046698000702569e]
Data:  [002c025b025321]
Data:  [00010048000602505e]

My code so far looks like this...

import bluetooth, sys, time, os, binascii, struct;

# Create the client socket
client_socket=BluetoothSocket( RFCOMM )

client_socket.connect(("10:00:E8:AC:4D:D0", 1))

data = ""
try:
while True:
try:
data = client_socket.recv(9)
except bluetooth.BluetoothError, b:
print "Bluetooth Error: ", b

if len(data) > 0:
print "Data:  [%s]" % binascii.hexlify(data)

except KeyboardInterrupt:
#print "Closing socket...",
client_socket.close()
#print "done."
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python parsing Bluetooth RFCOMM for 9 bytes

2012-12-13 Thread Barry Dick

> Is the following more like how you want it?
> 
> 
> 
> data = ""
> 
> try:
> 
>  while True:
> 
>  try:
> 
>  more = client_socket.recv(9)
> 
>  except bluetooth.BluetoothError, b:
> 
>  print "Bluetooth Error: ", b
> 
>  else:
> 
>  data += more
> 
> 
> 
>  while len(data) >= 9:
> 
>  print "Data:  [%s]" % binascii.hexlify(data[ : 9])
> 
>  data = data[9 : ]
> 
> except KeyboardInterrupt:
> 
>  #print "Closing socket...",
> 
>  client_socket.close()
> 
>  #print "done."
> 
> 
> 
> You could, of course, decide to recv more than 9 bytes at a time. It
> 
> could return less than you asked for (but it should block until at
> 
> least 1 byte is available), but it will never return more than you
> 
> asked for.

Thank you for your interest and quick reply. 

Its a great start, seeing as I'm a beginner with python, I was actually hoping 
to see an example of http://code.activestate.com/recipes/408859/ as it appears 
to be exactly what I need, but I haven't got a clue how to implement it. 
Basically as each byte perhaps gets read or 9 bytes at a time, that way I can 
seek out as much real data as possible

Data:  [002c025b025321]
Data:  [00010048000602505e]
Data:  [0002004a000a025552]
Data:  [0003004b0006025752]
Data:  [00046698000702569e]

(notice the header data[9:1] will always flow in this pattern 0 -> 4 and then 
back again, so I figure that might as well be my start)


And skip the errors...

Data:  [0002004b000a026343]
Data:  [00]
Data:  [03004f0006025b4a00]
Data:  [046698000802569d00]
Data:  [3002830257f100]
-- 
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
 wrote:


>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("", 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


setuptools for 64-bit 2.7.1 on 64-bit Windows 7?

2011-05-06 Thread Dick Bridges
Hi all,

 

Can someone provide some search terms I can use to find guidelines for
installing modules for my 'stock' 64-bit r 271:86832, Nov 27, 2010 [MSC
v.1500 64 bit (AMD)] on Win32. Host is 64-bit Windows 7.

 

My goal is to install suds. Period. That's all. So far I've spent the better
part of two days trying to figure out how to make

python setup.py install

actually work. Current error involves "...no module named setuptools" and,
of course all I can find is the 32-bit setuptools-0.6c11.win32-py2.7.exe
which fails with "Python version 2.7 required, which was not found in the
registry."

 

There's nothing new here - all of this has appeared in various forums over
the last few years - but none I have found contains an actual answer.

 

Simple question: Is it true that no setuptools (or any other module
installer) exists for 64-bit python 2.7.1? If there is an installer that
works, what terms might I use to Google for information on how to acquire
and install it?

 

 Regards,

   Dick Bridges

  (\(\ Western Digital

¸". ..  

 (  . .)  The opinions and data in this missive are my own and do not
necessarily

|   ° ¡  represent Western Digital positions, strategies, or opinions.

¿ ;  

c?".UJ"   Glenda: http://glenda.cat-v.org/gallery/
<http://glenda.cat-v.org/gallery/> 

 

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


RE: setuptools for 64-bit 2.7.1 on 64-bit Windows 7?

2011-05-09 Thread Dick Bridges
David,

Thanks for the link. I'd scanned but skipped it because it was
"third-party". This time I started following some of the links and finally
found the link for distutils:
http://pypi.python.org/pypi/distribute#installation-instructions. Works like
a charm.

Thanks for pointing me back to that link - I was clearly too hasty
dismissing it during my so-called "due diligence". 8-P

   Dick Bridges
  (\(\ Western Digital
 ¸". ..  
 (  . .)  The opinions and data in this missive are my own and do not
necessarily
 |   ° ¡  represent Western Digital positions, strategies, or opinions.
 ¿ ;  
c?".UJ"   Glenda: http://glenda.cat-v.org/gallery/


> -Original Message-
> From: David Robinow [mailto:[email protected]]
> Sent: Friday, May 06, 2011 3:25 PM
> To: Dick Bridges
> Cc: [email protected]
> Subject: Re: setuptools for 64-bit 2.7.1 on 64-bit Windows 7?
> 
> On Fri, May 6, 2011 at 1:43 PM, Dick Bridges 
> wrote:
> > Simple question: Is it true that no setuptools (or any other module
> > installer) exists for 64-bit python 2.7.1? If there is an installer
> that
> > works, what terms might I use to Google for information on how to
> acquire
> > and install it?
> Doesn't the installer at
> http://www.lfd.uci.edu/~gohlke/pythonlibs/
> work?
-- 
http://mail.python.org/mailman/listinfo/python-list


Installing tkinter on FreeBSD

2017-10-23 Thread Dick Holmes
I am trying to use tkinter on a FreeBSD system but the installed 
versions of Python (2.7 and 3.6) don't have thinter configured. I tried 
to download the source (no binaries available for FreeBSD) and build a 
new version of Python but the build reported that it couldn't install 
_tkinter. Despite this report, Python works for non-tkinter 
applications. Is there a magical formula for configuring tkinter during 
or after a build??

TIA!

--
Dick Holmes

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


Winpdb-reborn anomalies

2021-05-18 Thread Dick Holmes
I'm attempting to run winpdb-reborn, version 2.0.0.1, under MinGW. My 
first problem is that if I enter winpdb  in the directory 
containing , winpdb can't find rpdb2.py. I assume this is due 
to some path problem, but I don't know how to fix it.

My second problem occurs when I run winpdb from the 
/c/Python39/Lib/site-packages directory. The program runs correctly as 
far as I can tell, but it writes about 20-30 lines of what looks like 
debug information to the rpdb2 console window. The ourput starts with a 
get_namespace() call. It does this 
after each debug action (step over, step into, etc.) I haven't been able 
to find any way to turn off this output.

Any suggestions greatly appreciated!

Dick


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


Re: Winpdb-reborn anomalies - workaround

2021-05-18 Thread Dick Holmes
In article , encore1
@cox.net says...
> 
> I'm attempting to run winpdb-reborn, version 2.0.0.1, under MinGW. My 
> first problem is that if I enter winpdb  in the directory 
> containing , winpdb can't find rpdb2.py. I assume this is due 
> to some path problem, but I don't know how to fix it.
> 
> My second problem occurs when I run winpdb from the 
> /c/Python39/Lib/site-packages directory. The program runs correctly as 
> far as I can tell, but it writes about 20-30 lines of what looks like 
> debug information to the rpdb2 console window. The ourput starts with a 
> get_namespace() call. It does this 
> after each debug action (step over, step into, etc.) I haven't been able 
> to find any way to turn off this output.
> 
> Any suggestions greatly appreciated!
> 
> Dick

I found the code that forces debug info to be printed. The tests against 
the debug flag were commented out so debug info was written 
unconditionally. In case someone needs it, the file is rpdb/utils.py; 
look for fDebug.

This doesn't fix the path problem, but I can live with that.

Dick
-- 
https://mail.python.org/mailman/listinfo/python-list


Interacting with Subprocesses

2016-05-04 Thread Dick Holmes
I am attempting to write a Python program that will interact with
a (non-Python) process. The programs will run under MinGW. The
process can use stdin/stdout commands and responses and can work 
with pipes. The problem I'm having is that I can't find any
way in Python to have a continuing dialog with the process. I
have tried Popen communicate, but that protocol seems to be
limited to a single message/response pair, and the response
is not returned to the message originator until the process
terminates. Unfortunately I don't have access to the process'
source code so I can't change the communication medium.

Is there some feature that will allow me to initiate the process
and execute multiple message/response pairs between the Python
program and the process during a single execution of the process?

Thanks!

Dick


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


Subprocess Popen confusion

2020-05-13 Thread Dick Holmes
https://occovid19.ochealthinfo.com/coronavirus-in-oc I'm trying to 
communicate using a continuing dialog between two 
processes on the same system. I've looked at various mechanisms and the 
class that seems to fit my needs is Popen in the subprocess module, but 
I can't seem to get more than a single round-trip message through Popen. 
I first call Popen then poll using the identifier returned from the call 
and the poll seems to work. I then call the communicate function passing 
None as the value to send to the companion process stdin. I get the 
expected result, but I also get "Exception condition detected on fd 0
\\n" and "error detected on stdin\\n". Subsequent attempts to 
read/write/communicate with the subprocess fail because the file (stdxx 
PIPE) is closed.

I can't tell from the documentation if the communicate function is a 
one-time operation. I have tried using read but the read call doesn't 
return (I'm using winpdb-reborn to monitor the operations). 

I'm using Python 3.7, Windows 10, winpdb-reborn 2.0.0, rpdb2 1.5.0. If 
it makes any difference, I'm trying to communicate with GDB using the MI 
interpreter.

Thoughts and advice appreciated!

Dick
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Subprocess Popen confusion

2020-05-14 Thread Dick Holmes
In article , 
[email protected] says...
> 
> Dick Holmes wrote:
> 
> > https://occovid19.ochealthinfo.com/coronavirus-in-oc 
> 
> > I'm trying to
> > communicate using a continuing dialog between two
> > processes on the same system.
> 
> I think pexpect
> 
> https://pexpect.readthedocs.io/en/stable/index.html
> 
> does this naturally, but I don't know if Windows support is sufficient for 
> your needs.
> 
> > I've looked at various mechanisms and the
> > class that seems to fit my needs is Popen in the subprocess module, but
> > I can't seem to get more than a single round-trip message through Popen.
> > I first call Popen then poll using the identifier returned from the call
> > and the poll seems to work. I then call the communicate function passing
> > None as the value to send to the companion process stdin. I get the
> > expected result, but I also get "Exception condition detected on fd 0
> > \\n" and "error detected on stdin\\n". Subsequent attempts to
> > read/write/communicate with the subprocess fail because the file (stdxx
> > PIPE) is closed.
> > 
> > I can't tell from the documentation if the communicate function is a
> > one-time operation. 
> 
> Yes, communicate() is one-off, 
> 
> 
> """Interact with process: Send data to stdin and close it.
> Read data from stdout and stderr, until end-of-file is
> reached.  Wait for process to terminate.
> ...
> """
> 
> seems pretty clear. What would you improve?

Peter - thanks for the clarification. I'm using the 3.6.5 CHM 
documentation and it doesn't mention the phrase "and close it".
> 
> > I have tried using read but the read call doesn't
> > return (I'm using winpdb-reborn to monitor the operations).
> 
> Try readline(). Deadlocks may happen ;)
>  
> > I'm using Python 3.7, Windows 10, winpdb-reborn 2.0.0, rpdb2 1.5.0. If
> > it makes any difference, I'm trying to communicate with GDB using the MI
> > interpreter.
> > 


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


Re: Subprocess Popen confusion

2020-05-18 Thread Dick Holmes
In article , 
[email protected] says...
> 
> Dick Holmes wrote:
> 
> > https://occovid19.ochealthinfo.com/coronavirus-in-oc 
> 
> > I'm trying to
> > communicate using a continuing dialog between two
> > processes on the same system.
> 
> I think pexpect
> 
> https://pexpect.readthedocs.io/en/stable/index.html
> 
> does this naturally, but I don't know if Windows support is sufficient for 
> your needs.
> 
> > I've looked at various mechanisms and the
> > class that seems to fit my needs is Popen in the subprocess module, but
> > I can't seem to get more than a single round-trip message through Popen.
> > I first call Popen then poll using the identifier returned from the call
> > and the poll seems to work. I then call the communicate function passing
> > None as the value to send to the companion process stdin. I get the
> > expected result, but I also get "Exception condition detected on fd 0
> > \\n" and "error detected on stdin\\n". Subsequent attempts to
> > read/write/communicate with the subprocess fail because the file (stdxx
> > PIPE) is closed.
> > 
> > I can't tell from the documentation if the communicate function is a
> > one-time operation. 
> 
> Yes, communicate() is one-off, 
> 
> 
> """Interact with process: Send data to stdin and close it.
> Read data from stdout and stderr, until end-of-file is
> reached.  Wait for process to terminate.
> ...
> """
> 
> seems pretty clear. What would you improve?
> 
> > I have tried using read but the read call doesn't
> > return (I'm using winpdb-reborn to monitor the operations).
> 
> Try readline(). Deadlocks may happen ;)
>  
> > I'm using Python 3.7, Windows 10, winpdb-reborn 2.0.0, rpdb2 1.5.0. If
> > it makes any difference, I'm trying to communicate with GDB using the MI
> > interpreter.
> > 

Per Peter's suggestion I tried readline and it works "as expected". I 
also discovered that the reason the read operations were stalling was 
that they followed a write and the write doesn't actually occur until 
"flush" is called even though the function call returns. There are 
undoubtedly some subtleties lurking about, but at least I'm making good 
progress.

Thanks for the help!

Dick


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


[Tutor] New Python book

2005-10-05 Thread Dick Moores
Magnus Lie Hetland's new book, _Beginning Python: From Novice to
Professional_ was published by Apress on Sept. 26 (in the U.S.). My copy 
arrived in the mail a couple of days ago. Very much worth a look, IMHO. 
But what do the experts here think?

<http://www.bestbookdeal.com/book/compare/159059519X>

Dick Moores
[EMAIL PROTECTED]

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


New Python book

2005-10-05 Thread Dick Moores
(Sorry, my previous post should not have had "Tutor" in the subject header.)

Magnus Lie Hetland's new book, _Beginning Python: From Novice to
Professional_ was published by Apress on Sept. 26 (in the U.S.). My copy
arrived in the mail a couple of days ago. Very much worth a look, IMHO.
But what do the experts here think?

<http://www.bestbookdeal.com/book/compare/159059519X>

Dick Moores
[EMAIL PROTECTED]


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


Re: Book "Python and Tkinter Programming"

2005-10-08 Thread Dick Moores
DaveInSidney wrote at 15:55 10/8/2005:
>Check out BestBookBuys:
>http://www.bestwebbuys.com/Python_and_Tkinter_Programming-ISBN_1884777813.html?isrc=b-search

Or even better, BestBookDeal.com:
<http://www.bestbookdeal.com/book/compare/1884777813>

Dick Moores

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


Potential improvement on delegation via explicit calls and super

2004-12-17 Thread Robert Dick
Derived classes sometimes need to delegate portions of the work in overridden 
methods to methods in their base classes.  This was traditionally done with 
explicit calls in python, e.g.,

class Derived(Left, Right):
  def __init__(self, myarg, larg, rarg):
Left.__init__(self, larg)
Right.__init__(self, rarg)
self.data = myarg
print 'derived'

This worked great.  It was possible to grab the appropriate arguments and send 
them off to the right point.  However, there was a problem.

class Base:
  def __init__(self):
print 'base'

class Left(Base):
  def __init__(self, arg):
Base.__init__(self)
print 'left'

class Right(Base):
  def __init__(self, arg):
Base.__init__(self)
print 'right'

Now, when Derived(Left, Right) is initialized, Base.__init__ is called twice.  
Sometimes that's O.K.  Usually, it's a bad thing.  Along came new-style 
classes and 'super'.  Unfortunately, super-based delegation doesn't play 
nicely with traditional classes.
  http://www.ai.mit.edu/people/jknight/super-harmful/
Moreover, it undermines any attempts to control which subset of arguments go 
to which base class.  This second problem is serious.  In real life, base 
classes differ from each other: I need to be able to send the right arguments 
to each.

What I really want to do is explicitly delegate tasks to base classes, 
choosing the arguments to send to each, but avoid double-calls resulting from 
reconverging paths in the inheritance directed acyclic (pray it's acyclic) 
graph.

I think the appended code may solve this problem, play nicely with traditional 
classes, and allow the coder to send the right arguments to the right base 
classes.

However, I'm new to python so I need some help.

1) Is my thinking reasonable or is there an better way to solve the 
reconvergent path problem in python without undermining control over 
arguments?

2) What's the proper way to rewrite the appended code.  I'm sure it's 
dreadfully inefficient.  There are also probably ways to make its use more 
intuitive, but I'm new to the language so I don't know the tricks yet.

Thanks for any tips,

-Robert Dick-


'''See the example at the bottom.'''

import inspect

def flatten_tree(tree):
  '''Flatten a tree represented by nested lists'''
  if isinstance(tree, list):
return [j for i in tree for j in flatten_tree(i)]
  else:
return (tree,)

# Cache for delegation decisions.
call_cache = set()

def should_call(self, pos, supr):
  '''Examines the inheritance DAG (might work for DCGs, too... haven't
  checked) for 'self' to determine whether 'pos' is the leftmost derived
  for 'supr'.  Returns bool.  Caches results for performance.'''
  if (self.__class__, pos, supr) in call_cache: return True
  ct = flatten_tree(inspect.getclasstree(inspect.getmro(self.__class__), 
True))
# ct is a list of (class, (base classes)) tuples
# Find the first instance of the supr as a base class
  do_call = pos is [cls for cls, bases in ct if supr in bases][0]
  if do_call: call_cache.add((self.__class__, pos, supr))
  return do_call

def delegate(self, pos, s_call, *pargs, **kargs):
  '''If 'pos' is the leftmost derived for 's_call' in the 'self' inheritance
  DAG, call s_call with 'pargs' and 'kargs'.'''
  if inspect.ismethoddescriptor(s_call):
supr = s_call.__objclass__
  else:
supr = s_call.im_class
  if should_call(self, pos, supr):
s_call(self, *pargs, **kargs)

if __name__ == '__main__':
  class Base(object):
def __init__(self):
  delegate(self, Base, object.__init__)
  print 'base'

  class Left(Base):
def __init__(self):
  delegate(self, Left, Base.__init__)
  print 'left'

  class Right(Base):
def __init__(self):
  delegate(self, Right, Base.__init__)
  print 'right'

  class Der(Left, Right):
def __init__(self):
  delegate(self, Der, Left.__init__)
  delegate(self, Der, Right.__init__)
  print 'der'

  der = Der()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling __init__ with multiple inheritance

2005-03-28 Thread Robert Dick
jfj:
> In the case of Parent diamond inheritance, super() can avoid calling
> the __init__ of parent twice?  How?

Guido has a nice description of it: 
http://www.python.org/2.2.3/descrintro.html#cooperation.

It linearizes the graph.  Unfortunately, this means that super delegates to 
siblings.  This makes super incompatible with differences in positional 
arguments within a class hierarchy.  If you want a super that works with 
positional arguments, please see delegate.py at 
http://ziyang.ece.northwestern.edu/~dickrp/python/delegate.html (also in 
PyPI).  If others don't find problems with the approach, I hope it becomes 
standard.  I found it distracting that python's default argument passing 
approach conflicts with its default delegation approach.

Good luck,

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


Compute pi to base 12 using Python?

2005-04-13 Thread Dick Moores
I need to figure out how to compute pi to base 12, to as many digits as 
possible. I found this reference, 
<http://mathworld.wolfram.com/Base.html>, but I really don't understand 
it well enough. Could someone show me how to do what I need?

Thanks,
Dick Moores
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dick Moores
Bengt Richter wrote at 03:19 4/13/2005:
On Wed, 13 Apr 2005 02:06:11 -0700, Dick Moores <[EMAIL PROTECTED]> wrote:
>I need to figure out how to compute pi to base 12, to as many digits as
>possible. I found this reference,
><http://mathworld.wolfram.com/Base.html>, but I really don't understand
>it well enough. Could someone show me how to do what I need?
>
>Thanks,
>
>Dick Moores
>[EMAIL PROTECTED]
>
See if this is enough digits for homework? ;-)
This is not homework, nor am I a student, though I am trying to learn 
Python. I'm just trying to help an artist acquaintance who needs (I just 
learned) the first 3003 digits of pi to the base 12.

Hint: Lambert Meertens. Tweak the algorithm you find ;-)
Sorry. Your hint is beyond me.
Dick Moores
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dick Moores
Dan Bishop wrote at 04:07 4/13/2005:
(3) A function for converting numbers to their base-12 representation.
For integers, this can be done with:
DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def itoa(num, radix=10):
   is_negative = False
   if num < 0:
  is_negative = True
  num = -num
   digits = []
   while num >= radix:
  num, last_digit = divmod(num, radix)
  digits.append(DIGITS[last_digit])
   digits.append(DIGITS[num])
   if is_negative:
  digits.append("-")
   digits.reverse()
   return ''.join(digits)
I see this works perfectly for integers. Thanks!
For a floating-point number x, the representation with d "decimal"
places count be found by taking the representation of int(round(x *
radix ** d)) and inserting a "." d places from the right.
But I'm sorry, but I can't follow you. I do have the first 1 or so 
places of pi base 10 (<http://mathwithmrherte.com/pi_digits.htm>), but 
could you show me what to do with, say, just 3.14159?

I apologize for being so dense.
Dick Moores
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dick Moores
Bengt Richter wrote at 14:52 4/13/2005:
import sys
def main():
k, a, b, a1, b1 = 2L, 4L, 1L, 12L, 4L
while 1:
p, q, k = k*k, 2L*k+1L, k+1L
a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1
d, d1 = a/b, a1/b1
while d == d1:
output(d)
a, a1 = 10L*(a%b), 10L*(a1%b1)
d, d1 = a/b, a1/b1
def output(d):
sys.stdout.write(`int(d)`)
sys.stdout.flush()
main()
# Reading/writing Python source often gives me the impression of
# reading/writing a poem!
# Layout, indentation, rythm, I like the look and feel!
# What does this tiny program do? It is not a sonnet, even not a
# pi-sonnet, but it surely produces Pi!
It sure does. When I ran it my jaw dropped. I had 7,947 CORRECT digits in 
2 minutes 0 seconds (by my stopwatch)!

Now on to base 12.
Thanks!
Dick Moores
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dick Moores
Dan wrote at 18:02 4/13/2005:
On Wed, 13 Apr 2005 03:27:06 -0700, Dick Moores <[EMAIL PROTECTED]>
wrote:
> I'm just trying to help an artist acquaintance who needs (I just
>learned) the first 3003 digits of pi to the base 12.
Now you've got me curious.  Why would an artist want the first 3003
digits of pi to the base 12?
He says,
Do you know how I can get "base12 pi"?
Because the chromatic scale is base12.
c c# d d# e f f# g g# a a# b
Dick
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dick Moores
Paul Rubin wrote at 18:20 4/13/2005:
Dick Moores <[EMAIL PROTECTED]> writes:
> I need to figure out how to compute pi to base 12, to as many digits
> as possible. I found this reference,
> <http://mathworld.wolfram.com/Base.html>, but I really don't
> understand it well enough. Could someone show me how to do what I need?
Using the GNU "bc" utility:
  $ bc -l
  bc 1.06
  Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
  This is free software with ABSOLUTELY NO WARRANTY.
  For details type `warranty'.
  scale = 3000# number of output places wanted
  obase = 12  # output base
  print 4 * a(1)  # pi = 4*arctan(1)
I don't believe GNU "bc" is available for Windows, is it?
Thanks,
Dick Moores
[EMAIL PROTECTED] 

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


Re: Compute pi to base 12 using Python?

2005-04-13 Thread Dick Moores
Doug Schwarz wrote at 20:14 4/13/2005:
In article <[EMAIL PROTECTED]>,
 Dick Moores <[EMAIL PROTECTED]> wrote:
> Dan wrote at 18:02 4/13/2005:
> >On Wed, 13 Apr 2005 03:27:06 -0700, Dick Moores <[EMAIL PROTECTED]>
> >wrote:
> >
> > > I'm just trying to help an artist acquaintance who needs (I just
> > >learned) the first 3003 digits of pi to the base 12.
> >
> >Now you've got me curious.  Why would an artist want the first 3003
> >digits of pi to the base 12?
>
> He says,
> Do you know how I can get "base12 pi"?
> Because the chromatic scale is base12.
> c c# d d# e f f# g g# a a# b
>
> Dick
Does your artist friend have any idea what base 12 means?
The chromatic scale is based on one twelfth powers of two, i.e., if the
frequency of a note in the scale is f(n), then the frequency of the next
note is given by
  f(n+1) = f(n) * 2^(1/12)
so by the time you go all 12 notes in an octave you have doubled the
frequency.  There is nothing here involving base 12 or pi.
He's a friend of a friend. I don't know what he knows, but I'll forward 
this to MY friend. Thanks.

Dick

--
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-14 Thread Dick Moores
Steve Holden wrote at 22:29 4/13/2005:
Dick Moores wrote:
Steve Holden wrote at 19:12 4/13/2005:
Dick Moores wrote:
Dan wrote at 18:02 4/13/2005:
On Wed, 13 Apr 2005 03:27:06 -0700, Dick Moores <[EMAIL PROTECTED]>
wrote:
> I'm just trying to help an artist acquaintance who needs (I just
>learned) the first 3003 digits of pi to the base 12.
Now you've got me curious.  Why would an artist want the first 3003
digits of pi to the base 12?

He says,
Do you know how I can get "base12 pi"?
Because the chromatic scale is base12.
c c# d d# e f f# g g# a a# b
Dick
So it's, like, the guy is going to "play pi"? So why does the melody 
have 3003 notes?
Sorry, he's just a friend of a friend. If I find out I'll post. Here's 
his site if you want to poke around for yourself. Maybe his email 
address is there.
Dick
Where?
Sorry about that. <http://www.kenjikojima.com/>
Dick
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-14 Thread Dick Moores
Dick Moores wrote at 18:40 4/14/2005:
Sorry about that. <http://www.kenjikojima.com/>
I just listened to Kojima's
"NEW
Chorus Pi (Japanese) / 2:28
Chorus: MacinTalk Voices. The music was created from the constant PI."
on that page. The vocal is singing the digits of base-10 pi.
ten is . or decimal point
zero is 0
inchi is 1
ni is 2
san is 3
ta? is 4 (don't understand that "ta" or "tan", but it must be 4)
go is 5
roku is 6 -- in the music 6 sounds like "raku"
nana is 7
hachi is 8
ku is 9
Take a look/listen to
"String Quartet Pi / 5:06 and the process of data
The music was created from the constant PI (3.141592...) to 3,000 
decimal places by programming."

Lots of details there on the music.
Dick


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


Re: Compute pi to base 12 using Python?

2005-04-15 Thread Dick Moores
M.E.Farmer wrote at 23:18 4/14/2005:
Nice collection of unix tools, Cygwin not needed.
http://unxutils.sourceforge.net/
Thank you!
But a question. I've download both UnxUtils.zip and UnxUpdates.zip. I'm 
planning to put the contents of UnxUtils.zip in a directory and then move 
the contents of UnxUpdates.zip, which has many of the same filenames, to 
the same directory. Should I just let Windows replace the old files with 
the updated ones?

This seems obvious, but I wanted to make sure.
I'm using Win XP Pro.
Thanks,
Dick Moores

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


Re: Compute pi to base 12 using Python?

2005-04-17 Thread Dick Moores
Tim Roberts wrote at 22:05 4/16/2005:
Dick Moores <[EMAIL PROTECTED]> wrote:
>>
>># Reading/writing Python source often gives me the impression of
>># reading/writing a poem!
>># Layout, indentation, rythm, I like the look and feel!
>>
>># What does this tiny program do? It is not a sonnet, even not a
>># pi-sonnet, but it surely produces Pi!
>
>It sure does. When I ran it my jaw dropped. I had 7,947 CORRECT digits in
>2 minutes 0 seconds (by my stopwatch)!
How do you know?  I think the 7,912th digit is wrong.
;)
I suppose you're joshing, Tim, but I really did check by using my trusty

def compareSequences(seq1, seq2):
"""
find first index at which two sequences differ
"""
if s1 == s2:
print "Sequences are identical"
return None
if len(seq1) >= len(seq2):
shorterOrEqualSequence = seq2
else:
shorterOrEqualSequence = seq1
for index in range(len(shorterOrEqualSequence)):
if seq1[index] != seq2[index]:
print "sequences first differ at index", index
print "s1 at that index is", s1[index]
print "s2 at that index is", s2[index]
break
if index == len(shorterOrEqualSequence)-1:
print "sequences are identical thru end of shorter sequence at 
index", index
==

I got the "correct" pi from 
<http://www.ballandclaw.com/upi/pi.5.html>. By inspection of the text 
file I copied this to (removing the "3." of "3.1"), the 7,912th digit is 
"2" (I'm using Textpad). If you begin with "31", which what the speedy 
script does, the 7,912th digit is "6".

Now, I've shown you mine. Show me yours. ;-)
Dick 

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


Re: Compute pi to base 12 using Python?

2005-04-17 Thread Dick Moores
M.E.Farmer wrote at 23:18 4/14/2005:
> >Using the GNU "bc" utility:
> >
> >   $ bc -l
> >   bc 1.06
> >   Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation,
Inc.
> >   This is free software with ABSOLUTELY NO WARRANTY.
> >   For details type `warranty'.
> >   scale = 3000# number of output places wanted
> >   obase = 12  # output base
> >   print 4 * a(1)  # pi = 4*arctan(1)
Wow! this got me the 3003 (changed from 3000) digits of pi to base 12 in 
60.8 secs. No, I didn't count them yet, nor am I sure they're correct. 
But I'd bet on them..

Could someone remind me how to get the output of bc -l into a text file 
on Windows? (I've tried employing " > pi3003.txt" in various ways) OR, 
how to copy and paste from the command line window, or whatever that 
window is called? (Sorry for the OT question.)

BTW I found a nice set of SCO UNIX man pages at <http://www.rt.com/man/>.
Dick
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-17 Thread Dick Moores
Roel Schroeven wrote at 01:45 4/17/2005:
Dick Moores wrote:
M.E.Farmer wrote at 23:18 4/14/2005:
> >Using the GNU "bc" utility:
> >
> >   $ bc -l
> >   bc 1.06
> >   Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation,
Inc.
> >   This is free software with ABSOLUTELY NO WARRANTY.
> >   For details type `warranty'.
> >   scale = 3000# number of output places wanted
> >   obase = 12  # output base
> >   print 4 * a(1)  # pi = 4*arctan(1)
Wow! this got me the 3003 (changed from 3000) digits of pi to base 12 
in 60.8 secs. No, I didn't count them yet, nor am I sure they're 
correct. But I'd bet on them..
Could someone remind me how to get the output of bc -l into a text file 
on Windows? (I've tried employing " > pi3003.txt" in various ways) OR, 
how to copy and paste from the command line window, or whatever that 
window is called? (Sorry for the OT question.)
Works for me (using the Cygwin version though) when I do
C:\cygwin\bin\bc -l > pi12.txt
But how or when do you enter the lines
scale = 3000
obase = 12
print 4 * a(1)
Otherwise, to copy from the command prompt window: open the system menu
(icon in the top left corner of the window) and choose Edit->Mark. Then
select what you want to copy and press Enter or choose Edit->Copy in the
system menu.
Thanks! You've just relieved years of frustration.
Dick 

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


Re: Compute pi to base 12 using Python?

2005-04-17 Thread Dick Moores
Bengt Richter wrote at 02:26 4/17/2005:
>Could someone remind me how to get the output of bc -l into a text file
>on Windows? (I've tried employing " > pi3003.txt" in various ways) OR,
>how to copy and paste from the command line window, or whatever that
>window is called? (Sorry for the OT question.)
To copy from the command window to the clipboard:
1. Scroll top of desired stuff to make it visible near top
2. Hold down Alt
3. Tap Space Bar
4. Release Alt
5. Tap e
6. Tap k
7. Use mouse or arrow keys to place cursor on top left corner of desired box
8. Hold down Shift
9. Use arrow keys or mouse-with-left-button-pressed to go to bottom 
right character of desired box
9a. If the bottom is out of sight, keep holding  shift down and pretend 
you can cursor down below bottom.
the attempt should make the screen scroll up and select more 
desired material. If you overshoot, don't panic,
just keep holding down shift and use arrows (the are slower) or 
mouse-with-left-button-still-down to move to
desired bottom right corner.
10. Release mouse button if using that
11. Release Shift
12. Press Enter
That should copy to the clipboard and make the selection box revert to 
normal display.

Pasting from clipboard is up to you. Pasting into the command window 
from clipboard
is 2-5 above, and Tap p
Thanks for showing me another way. But Roel Schroeven's
"to copy from the command prompt window: open the system menu
(icon in the top left corner of the window) and choose Edit->Mark. Then
select what you want to copy and press Enter or choose Edit->Copy in the
system menu."
seems to be easier.

PS. Redirecting with > from a script whose interpreter was started by 
windows extension association
doesn't work on some version of windows. To be safe, invoke the 
interpreter explicitly, e.g.,
python myscript.py [whatever args here] > pi3003.txt
Thanks very much for this.
What kind of args could I use here?
Dick
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compute pi to base 12 using Python?

2005-04-17 Thread Dick Moores
Paul Rubin wrote at 02:35 4/17/2005:
Dick Moores <[EMAIL PROTECTED]> writes:
> >C:\cygwin\bin\bc -l > pi12.txt
>
> But how or when do you enter the lines
>
> scale = 3000
> obase = 12
> print 4 * a(1)
You could put them into a file, say pi.bc.  Then run
  bc -l pi.bc
OK, now that I've got Textpad trained to open .bc files, I'm thinking of 
things to store in them. I'm sure I'll want to put in some remarks as 
well. What should I use to mark the remarks. "#", "//", or what?

The bc man page at <http://www.rt.com/man/bc.1.html> is tough. Any 
suggestion for more easily understandable help?

And finally (maybe), is it possible to employ bc within a Python script?
Thanks,
Dick

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


wrappers for C/C++

2015-12-11 Thread Ginga, Dick
I have inherited a product build that uses SWIG to product wrapper libraries 
for our C/C++ code. It currently builds these wrappers for 2.5, 2.6, 3.1 and 
3.2.

Is it necessary to have version specific wrappers?


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


RE: wrappers for C/C++

2015-12-11 Thread Ginga, Dick
Thanks again for a very informative answer and these are windows wrappers.

-Original Message-
From: Python-list 
[mailto:[email protected]] On Behalf Of 
Chris Angelico
Sent: Friday, December 11, 2015 1:53 PM
Cc: [email protected]
Subject: Re: wrappers for C/C++

On Sat, Dec 12, 2015 at 5:40 AM, Ginga, Dick  wrote:
> Thank you Chris for this answer.  These are the _only_ versions the build 
> creates. Are you saying that wrappers for 3.5 "may" continue to support 
> future versions?

That's a Windows-specific concern; there've been changes made to how the 
Windows build process works, starting with 3.5. It's usually easiest to build 
against the exact Python that you want to run against; in the case of binaries 
downloaded from python.org, that basically means having one build for each 
version (major.minor) you want to support. (I'm not sure about other build 
concerns - you possibly need 32-bit and 64-bit builds for each version. Others 
will know more than I do on that.)

For non-Windows platforms, it's usually easiest to punt on the whole build 
process and just distribute source code. C compilers are more generally 
available on people's Linux systems than on their Windowses.

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


RE: wrappers for C/C++

2015-12-11 Thread Ginga, Dick
Thank you Chris for this answer.  These are the _only_ versions the build 
creates. Are you saying that wrappers for 3.5 "may" continue to support future 
versions?

-Original Message-
From: Python-list 
[mailto:[email protected]] On Behalf Of 
Chris Angelico
Sent: Friday, December 11, 2015 1:29 PM
Cc: [email protected]
Subject: Re: wrappers for C/C++

On Sat, Dec 12, 2015 at 4:21 AM, Ginga, Dick  wrote:
> I have inherited a product build that uses SWIG to product wrapper libraries 
> for our C/C++ code. It currently builds these wrappers for 2.5, 2.6, 3.1 and 
> 3.2.
>
> Is it necessary to have version specific wrappers?

Yes, it is, because of the way Python's internals work. But you can probably 
build them all from the same source code.

I'm not sure whether you mean that those four are the _only_ versions it's 
building for, or if you noted them as being particularly old versions still 
being built for. Either way, you should be in full control of your version 
support; if this is an internal project, you could simply stipulate that only 
one version of Python is supported (or maybe two - 2.7 and one 3.x), and save 
yourself some build hassles. If you're posting it on PyPI, you can put the 
source code out there and let Unix users build their own, and then you need 
only worry about Windows; I haven't seen confirmation yet (as there's no 
official
3.6 builds), but supporting "3.5+" should be possible from a single binary. 
(You would still need a separate binary for 2.7, though.)

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


Programming Python, 3rd ed.??

2006-01-02 Thread Dick Moores
Several months ago I saw an item on the O'Reilly site to the effect that 
the 3rd. ed. of Programming Python was in the works. I made a note to 
myself to check back in January. I just did, but could find nothing at 
all about a 3rd. edition. Anyone know?

Thanks,

Dick Moores

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


Need Python for Linux (Suse 10.1)

2006-08-31 Thread Dick Moores


I've got a friend interested in trying out Python. I sent him to

http://www.python.org/download/linux/ but he's uncertain as to what
to download. He's rather get a new download than use what was on his Suse
disk. His box is an x86.
Any chance
Python
2.4.3 compressed source tarball would be suitable for him?
Advice for him, please.
Thanks,
Dick Moores




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

Re: Looking for the Perfect Editor

2006-09-09 Thread Dick Moores
At 01:10 PM 9/8/2006, Doug Stell wrote:
>Try www.TextPad.com. I've used it for years and love it. It
>understands many programming language constructs and can be taught to
>understand python so that things show up in color.

Any tips on how to teach TextPad to understand python?

Thanks,

Dick Moores

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


Re: Looking for the Perfect Editor

2006-09-10 Thread Dick Moores
At 02:15 PM 9/10/2006, Kent Johnson wrote:
>Dick Moores wrote:
> > At 01:10 PM 9/8/2006, Doug Stell wrote:
> >> Try www.TextPad.com. I've used it for years and love it. It
> >> understands many programming language constructs and can be taught to
> >> understand python so that things show up in color.
> >
> > Any tips on how to teach TextPad to understand python?
>Download and install the Python syntax highlighting definition from the
>TextPad website.

Thanks very much, Kent. I've been using TextPad for 10 years and 
never considered using it for Python.

I downloaded Python (7) from 
http://www.textpad.com/add-ons/synn2t.html and put the file 
PythonV2.4.syn in C:\Program Files\TextPad 4\system .

>I make a tool to run the front window in Python. Here are the values
>from the preferences window for the tool:
>
>Command: C:\Python24\python.exe
>Parameters: -u $File
>Init fldr: $FileDir
>
>regex to match output:
>^.*"([^"]+)", *line ([0-9]+)
>
>with File: 1, Line: 2

After fumbling around, I believe I've made the tool, using your 
values, except I used E:\Python24\python.exe instead of 
C:\Python24\python.exe .

I also associated .py with TextPad. I'm now able to open a Python 
script with TextPad, and execute it with  Ctrl+4.

However, no syntax highlighting is showing up. so I must have done 
something wrong. Do I have to do something other than put 
PythonV2.4.syn in C:\Program Files\TextPad 4\system ?

Also, why do you use TextPad instead of IDLE?

Thanks,

Dick Moores


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


Re: Looking for the Perfect Editor

2006-09-10 Thread Dick Moores
At 06:30 PM 9/10/2006, Kent Johnson wrote:
>Dick Moores wrote:
>
> > I downloaded Python (7) from
> > http://www.textpad.com/add-ons/synn2t.html and put the file
> > PythonV2.4.syn in C:\Program Files\TextPad 4\system .
> >
> > However, no syntax highlighting is showing up. so I must have done
> > something wrong. Do I have to do something other than put
> > PythonV2.4.syn in C:\Program Files\TextPad 4\system ?
>
>One more step - make a new Document Class for Python (in the prefs).
>Associate it with *.py, turn on syntax highlighting and select the
>syntax file you downloaded.

OK. Done.

> > Also, why do you use TextPad instead of IDLE?
>
>You're kidding, right?

No. Tell me, please. Macros? Comparing files? What else?

Dick



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


Re: Looking for the Perfect Editor

2006-09-14 Thread Dick Moores
At 08:54 PM 9/13/2006, Jay wrote:
>I, too, am a hardcore fan of jEdit.  It's nice to finally see some user
>support on this forum.  :-)

I'm trying out jEdit and UliPad. I got UliPad going right away and 
I'm very pleased with it, but could I jump in here with a basic jEdit 
question? How do you run a script?

And one more. On the menus, the font is clear and large, but the 
equivalent key combinations are written so small they are very 
difficult for me to read. Is there a way to configure them to be 
slightly larger? (I'd ask on the jEdit support forum, but it doesn't 
seem to be very active.)

Thanks,

Dick Moores




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


Re: Looking for the Perfect Editor

2006-09-14 Thread Dick Moores
At 08:51 AM 9/14/2006, stu wrote:

>Dick Moores wrote:
> > I'm trying out jEdit and UliPad. I got UliPad going right away and
> > I'm very pleased with it, but could I jump in here with a basic jEdit
> > question? How do you run a script?
> >
> > And one more. On the menus, the font is clear and large, but the
> > equivalent key combinations are written so small they are very
> > difficult for me to read. Is there a way to configure them to be
> > slightly larger? (I'd ask on the jEdit support forum, but it doesn't
> > seem to be very active.)
> >
>
>to change jedits fonts, under utilities menu choose global options
>
>select appearance, this has font options for menus + other fields
>text area has the editing text font (I use dialogeinput for menus and
>such and
>andale mono for the text area...)

I afraid I still don't see how to use larger fonts for the problem I 
mentioned. I mean the tiny fonts used, for example, to the right of 
File | New, where it says, I'm guessing, "C+n".

>to run a script.. you can 'dock' jython in the sides of the editor or
>bottom, and import from the buffer or load it.. or fire jython up from
>the plugin menu

Doesn't sound easy. With UliPad (or IDLE, for that matter) just hit F5.

>there is also a colour scheme plugin that gives you colour defaults if
>you want it to look lke emacs or jbuilder or idea etc etc etc
>
>jedit is pretty rich with its plugins.

Thanks,

Dick



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


RPC client class?

2006-03-02 Thread Dick Watson
We have a legacy device that exposes an RPC server. We have an RPCL 
defininition of its interface. We want to develop an RPC client of this 
interface in Python that will be usable in both Win32 and open systems 
environments.

I can find some *very* dated references to a demo/rpc.py, but I can't find 
such a file on my Win Python install. There is an rpc.py in idle, but it 
doesn't seem to be a general purpose implementation. (I can find **lots** of 
references to xmlrpc.py, but the server predates all of this neato XML 
stuff. I also found the "Stackless" rpc.py; it wants to modify base Python. 
I'd rather not diverge from the stock Python.)

Is there a Python module suitable for RPC client creation? Where? Why is 
this not a standard class? Are we nuts to pursue this course? 


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


Re: RPC client class?

2006-03-03 Thread Dick Watson
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> if the RPC you're talking about is Sun RPC, the whole concept is pretty
> dated (the original RFCs are from the late eighties).

Just because it's dated doesn't meant it isn't still something that 
occasionally needs done. Thanks for the advice! 


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


Re: MRO problems with diamond inheritance?

2005-05-01 Thread Robert Dick
M.E.Farmer:
> Your answer lies somewhere in this page ;)
> http://www.python.org/2.2.2/descrintro.html
> M.E.Farmer

delegate.py (use PyPI) may also be useful.

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


Re: Problem with following python code

2007-06-11 Thread Dick Moores
At 09:52 PM 6/11/2007, Dan Hipschman wrote:
>On Tue, Jun 12, 2007 at 04:25:31AM -, why? wrote:
> > I've been having problem with the following code. It's supposed to
> > print the prime numbers  between 10 and 100. But i'm not getting any
> > output, i.e. i guess the outer 'for' loop is being traversed only
> > once. I would be greatful if you could help me out. Thanx!
> > >>> f=1
> > >>> for i in range(10,100):
> > ... for j in range(2,i):
> > ... if i%j==0:
> > ... f=0
> > ... break
> > ... else: continue
> > ... if f==1:
> > ... print i,
> > ...
>
>Move "f=1" inside the outer loop:
>
>for i in range(10,100):
> f=1
> for j in range(2,i):
> if i%j==0:
> f=0
> break
> else: continue
> if f==1:
> print i,
>
>It gets set to 0 in the first iteration and never has another chance to
>be set to 1 after that.

And of course the inner loop does too much work. Try:

for i in range(10,100):
 f=1
 max = int(i**.5 + 1)
 for j in range(2,max):
 if i%j==0:
 f=0
 break
 else: continue
 if f==1:
 print i,

Dick Moores

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


Looking for a wxPython GUI builder

2007-06-15 Thread Dick Moores
How about SPE?

Any others?

And which ones do people
actually use? Commercial or Freeware.

Thanks,

Dick Moores

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


Re: preferred windows text editor?

2007-05-10 Thread Dick Moores
At 11:06 AM 5/9/2007, T. Crane wrote:
>Right now I'm using Notepad++.  What are other people using?

Ulipad.

Dick Moores


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


Re: OOP in Python book?

2007-07-27 Thread Dick Moores
At 08:41 AM 7/27/2007, Bill wrote:
>Does anyone out there have any information about this book. It's
>listed on Amazon to be published in November of this year. A simple
>Google search (1st page only) doesn't show anything useful, and I
>can't find a reference on the web sites of the authors. Neither of the
>authors appears to be heavily into OOP theory, just some CS areas that
>I don't understand.
>
>I'm particularly interested in why this book is worth the $100 tag
>that Amazon shows.

Well, the publisher is Prentice Hall, "The world's leading 
educational publisher". Textbooks are typically expensive.

Here's the Amazon link: 
<http://www.amazon.com/Object-Oriented-Programming-Python-Michael-Goldwasser/dp/0136150314>

Dick Moores


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


Re: OOP in Python book?

2007-07-28 Thread Dick Moores
At 01:27 PM 7/28/2007, Dennis Lee Bieber wrote:
>On Fri, 27 Jul 2007 16:27:57 -0700, Dick Moores <[EMAIL PROTECTED]>
>declaimed the following in comp.lang.python:
>
>
> > Well, the publisher is Prentice Hall, "The world's leading
> > educational publisher". Textbooks are typically expensive.
> >
>
> Yeah... But at that price it should have hard-covers!

Should have, but look at this popular Cultural Anthropology text 
(paperback): <http://tinyurl.com/38ec5s>. List price is $120.95 USD. 
(BTW I just bought the 6th edition online for about $10.)

Then there's Calculus: Single Variable (Paperback) 
<http://tinyurl.com/2lqw9c> List price $123.95 USD.

And so it goes.

Dick


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


Re: the one python book

2007-08-08 Thread Dick Moores
At 10:22 AM 8/5/2007, vasudevram wrote:
> > On Aug 4, 7:23 am, "dhr" <[EMAIL PROTECTED]> wrote:
> >
> > > newbie question:
> >
> > > Is there a 'K&R" type of Python book? The book that you'd better have on
> > > your shelf if you are going into Python?
> >
>
>Python in a Nutshell, the Python Cookbook and Programming Python are
>all very good, IMO. Programming Python comes with a CD of all the
>source code in the book (at least the 2nd edition did, as well as
>Python language - this can save you some time keying in the examples.
>Of course, many of the O'Reilly books (and all 3 of these are from
>O'Reilly) have links to downloadable source code from them. Just
>Google for the name of the book, then in the results, hit the
>appropriate link to the O'Reilly site for the book, and look down the
>page for the link to the examples' source.
>
>Or (for Programming Python):
>
>http://www.oreilly.com/catalog/python2/
>http://www.oreilly.com/catalog/python3/

No CD with 3rd edition, but here are the examples: 
<http://examples.oreilly.com/python3/>

Dick Moores

==
   Bagdad Weather
<http://weather.yahoo.com/forecast/IZXX0008_f.html> 

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


WinPdb?

2007-08-08 Thread Dick Moores


The only debugging I've done so far is to put in print statements where I
want to see what's happening. But it's often "through a glass
darkly".
However, I just discovered that my excellent (IMO) Python editor, Ulipad,
comes with WinPdb, and I'm thinking it's about time I learned how to use
a debugger. 
But first, could I get some reviews here of WinPdb before I invest a lot
of time in learning it? I've found a couple links to tutorials on the
WinPdb website
(<
http://www.digitalpeers.com/pythondebugger/>, where you'll also
notice that version 1.2.0 came out August 6 (the latest svn revision of
Ulipad already has it:
<
http://ulipad.googlecode.com/svn/> (Ulipad's developer, Limodou,
is very responsive). 
Thanks,
Dick Moores

==
 
Bagdad Weather
<
http://weather.yahoo.com/forecast/IZXX0008_f.html>


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

Puzzled by "is"

2007-08-09 Thread Dick Moores
 >>> () is ()
True
 >>> (1,) is (1,)
False

Why?

Thanks,

Dick Moores

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


Re: Puzzled by "is"

2007-08-09 Thread Dick Moores
At 10:46 AM 8/9/2007, Bill Scherer wrote:
>Dick Moores wrote:
> >  >>> () is ()
> > True
> >  >>> (1,) is (1,)
> > False
> >
> > Why?
> >
>
> >>> a = ()
> >>> b = ()
> >>> c = (1,)
> >>> d = (1,)
> >>> a is b
>True
> >>> c is d
>False
> >>> id(a)
>3086553132
> >>> id(b)
>3086553132
> >>> id(c)
>3086411340
> >>> id(d)
>3086390892
>
>
>There is only one empty tuple.
>Does that clear it up for you?

But isn't that the same as saying, "That's just the reality of 
Python; it is what it is."? I want to know why there is only one 
empty tuple, but more than one (1,).

Also,
 >>> [] is []
False

Dick  

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


Re: Puzzled by "is"

2007-08-10 Thread Dick Moores
At 06:13 PM 8/9/2007, Ben Finney wrote:
>Content-Transfer-Encoding: base64Grzegorz 
>Słodkowicz <[EMAIL PROTECTED]  [EMAIL PROTECTED] 
>theorisation but I'd rather expect the interpreter
> > simply not to create a second tuple while there already is an
> > identical one.
>
>Others have already said that it's an implementation optimisation,
>which seems to partly answer your question.
>
>It's important to also realise that the language is *deliberately*
>non-committal on whether any given value will have this behaviour;
>that is, it's entirely left to the language implementation which
>optimisation trade-offs to make, and the language user (that's you and
>I) should *not* expect any particular behaviour to hold between
>different implementations.

I'm not clear on the meaning of "implementations" 
here.  Would 2.5 for Windows, Mac, Linux all be 
different implementations? Would Iron Python be another? ActivePython?

Thanks,

Dick


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


Re: Puzzled by "is"

2007-08-12 Thread Dick Moores
On 8/12/07, Ben Finney <[EMAIL PROTECTED]> wrote:
>
> Dick Moores <[EMAIL PROTECTED]> writes:
>
> > At 06:13 PM 8/9/2007, Ben Finney wrote:
> > >it's entirely left to the language implementation which
> > >optimisation trade-offs to make, and the language user (that's you
> > >and I) should *not* expect any particular behaviour to hold between
> > >different implementations.
> >
> > I'm not clear on the meaning of "implementations" here.  Would 2.5
> > for Windows, Mac, Linux all be different implementations? Would Iron
> > Python be another? ActivePython?
>
> For the purpose of the above statement, you should consider even the
> same Python on two different machines to be "different
> implementations". As a programmer writing Python code, you should not
> expect any "implementation-dependent" behaviour to operate in any
> particular way.


So would a programmer EVER use "is" in a script?

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

Re: Puzzled by "is"

2007-08-12 Thread Dick Moores
At 08:23 AM 8/12/2007, Steve Holden wrote:
>Dick Moores wrote:
> > So would a programmer EVER use "is" in a script?
>
>Sure. For example, the canonical test for None uses
>
>  x is None
>
>because there is only ever one instance of type Nonetype, so it's the
>fastest test. Generally speaking you use "is" to test for identity (do
>these two expressions reference the same object) rather than equality
>(do these two expressions evaluate to equivalent objects).

Off the top of your head, could you or others give me as many 
examples as you can think of?

Thanks again,

Dick


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


Re: Puzzled by "is"

2007-08-12 Thread Dick Moores
At 09:59 AM 8/12/2007, Steve Holden wrote:
>Dick Moores wrote:
> > At 08:23 AM 8/12/2007, Steve Holden wrote:
> >> Dick Moores wrote:
> >>> So would a programmer EVER use "is" in a script?
> >> Sure. For example, the canonical test for None uses
> >>
> >>  x is None
> >>
> >> because there is only ever one instance of type Nonetype, so it's the
> >> fastest test. Generally speaking you use "is" to test for identity (do
> >> these two expressions reference the same object) rather than equality
> >> (do these two expressions evaluate to equivalent objects).
> >
> > Off the top of your head, could you or others give me as many
> > examples as you can think of?
> >
>Occasionally it's necessary to test for a specific type (though in
>Python this is usually bad practice). Since types are also singletons
>the best way to do this is (e.g.):
>
>  type(x) is type([]) # test specifically for a list
>
>If you want to know whether you have been told to write to standard
>output, one possible test is
>
>  if f is not sys.stdout
>
>Similarly, of course, you can test for the other standard IO channels.
>
>The imputil module contains the test
>
>  if importer is not self
>
>to determine whether a reload() should be performed in the context of
>the current package.
>
>When you need to establish a specific sentinel value that can never be
>provided by an outside caller it's normal to create an instance of
>object (the simplest possible thing you can create in a Python program)
>and test for that instance, as in
>
>  sentinel = object()
>  ...
>  if value is sentinel:
>
>You can test whether a class is new-style as opposed to old-style, which
>can help to unify old-style and new-style objects:
>
>class MetaProperty(type):
>  def __new__(cls, name, bases, dct):
>  if bases[0] is object: # allow us to create class Property
>  return type.__new__(cls, name, bases, dct)
>  return property(dct.get('get'), dct.get('set'),
>  dct.get('delete'), dct.get('__doc__'))
>
>  def __init__(cls, name, bases, dct):
>  if bases[0] is object:
>  return type.__init__(cls, name, bases, dct)
>
>
>That gets you started ...

Sure does. Thanks very much, Steve.

Dick


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


A dumb question about a class

2007-08-12 Thread Dick Moores
I'm still trying to understand classes. I've made some progress, I 
think, but I don't understand how to use this one. How do I call it, 
or any of its functions? It's from the Cookbook, at 
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/523048>.

Thanks,

Dick Moores

=
class PrimeList:
def __init__(self, initial=0):
self.primelist = [2,3]
self.primelookup = [0,0,1,1]
self.max_prime = 3
self.grow_primelist(initial)

def grow_primelist(self,number):
newprimes = []
while self.max_prime <= number:
next = self.nextprime()
newprimes.append(next)
self.max_prime = next
size_difference = self.max_prime - 
len(self.primelookup) + 1
self.primelookup.extend([0] * size_difference)
for i in newprimes:
self.primelookup[i]=1

def contains(self,number):
if number < 2:
return 0
if number > len(self.primelookup) - 1:
self.grow_primelist(number)
return self.primelookup[number]
return self.primelookup[number]

def nextprime(self):
i = self.max_prime + 2
while 1:
isprime = True
for prime in self.primelist:
if i % prime == 0:
isprime = False
i += 2
break
if isprime:
self.primelist.append(i)
return(i)
==

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


Re: A dumb question about a class

2007-08-12 Thread Dick Moores
At 03:09 PM 8/12/2007, Steven Bethard wrote:

>Here's how I'd write the recipe::
>
>  import itertools
>
>  def iter_primes():
>  # an iterator of all numbers between 2 and +infinity
>  numbers = itertools.count(2)
>
>  # generate primes forever
>  while True:
>
>  # get the first number from the iterator (always a prime)
>  prime = numbers.next()
>  yield prime
>
>  # remove all numbers from the (infinite) iterator that are
>  # divisible by the prime we just generated
>  numbers = itertools.ifilter(prime.__rmod__, numbers)
>
>
>  class PrimeList(object):
>  def __init__(self):
>  # infinite iterator of primes
>  self._prime_iter = iter_primes()
>
>  # the last prime we've seen
>  self._last_prime = None
>
>  # all primes seen so far
>  self._prime_set = set()
>
>  # add the first prime (so that _last_prime is set)
>  self._add_prime()
>
>  def __contains__(self, n):
>  # add primes to the list until we exceed n
>  while n > self._last_prime:
>  self._add_prime()
>
>  # return True if n is one of our primes
>  return n in self._prime_set
>
>  def _add_prime(self):
>  # take a prime off the iterator and update the prime set
>      self._last_prime = self._prime_iter.next()
>  self._prime_set.add(self._last_prime)

I'm afraid my next question is "How do I run this"?

Dick


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


Re: A dumb question about a class

2007-08-12 Thread Dick Moores
At 03:35 PM 8/12/2007, Steven Bethard wrote:
>Note that if you just want to iterate over all the primes, there's no
>need for the class at all.  Simply write::
>
>  for prime in iter_primes():

Even if I want to test only 1 integer, or want the list of primes in 
a certain interval, I don't need the class at all:


import itertools

def iter_primes():
 # an iterator of all numbers between 2 and +infinity
 numbers = itertools.count(2)


 # generate primes forever
 while True:


 # get the first number from the iterator (always a prime)
 prime = numbers.next()
 yield prime


 # remove all numbers from the (infinite) iterator that are
 # divisible by the prime we just generated
 numbers = itertools.ifilter(prime.__rmod__, numbers)

def listPrimes(n,m):
 """
 Returns the list of primes in closed interval [n,m]
 """
 primes = []
 for prime in iter_primes():
 if prime > m:
 return primes
 if n <= prime <= m:
 primes.append(prime)


Thanks for your help. I didn't learn much about classes, but 
appreciated your iter_primes() a lot!

Dick Moores 

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


Re: Binary, Hex, and Decimal string conversions

2007-08-12 Thread Dick Moores


At 04:20 PM 8/12/2007, Robert Dailey wrote:
Well, I decided to implement my
own way of doing this. I've attached the source. You're all welcome
:)
On 8/12/07, Michael Bentley
<
[EMAIL PROTECTED]> wrote:


Hi Robert,

On Aug 11, 2007, at 3:59 PM, Robert Dailey wrote:

Hi, I was wondering if there is a built in module that supports
conversion in any direction between Binary, Hex, and Decimal strings?
Thanks. 

Shouldn't be too hard to build one.  Here's a little incantation
to convert from base 10 to another base:

import string

def to_base(number, base):

'converts base 10 integer to another base'

number = int(number)

base = int(base)

if base < 2 or base > 36:

raise ValueError, "Base must be between 2 and 36" 

if not number:

return 0

symbols = string.digits + string.lowercase[:26]

answer = []

while number:

number, remainder = divmod(number, base)

answer.append(symbols[remainder]) 

return ''.join(reversed(answer))

I've tried to figure out the correct indentation for this, and came up
with

import string
def to_base(n, base):
    'converts base 10 integer to another base, up thru
base 36'
    n = int(n)
    base = int(base) 
    if base < 2 or base > 36:
    raise ValueError, "Base
must be between 2 and 36" 
    if not n:
    return 0
    symbols = string.digits + string.lowercase[:26] 
    answer = []
    while n:
    n, remainder = divmod(n,
base)
   
answer.append(symbols[remainder]) 
    return ''.join(reversed(answer))
n = 12
base = 36
print to_base(n, base)
==
This seems to work fine for n >= base, but not for n < base. For
example, the code shown returns "c". Is my indentation wrong,
or the code? It seems to me that the code should work for the general
case, not just for n >= base.
Dick Moores


How 'bout you hack a from_base function and email it back to me?
(hint: type 'help(int)' in the python interpreter).

Peace,

Michael

---

Let the wookie win.



Content-Type: text/plain; name="baseconv.py"
Content-Disposition: attachment; filename="baseconv.py"
X-Attachment-Id: f_f5a5roa4

-- 

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



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

Re: Binary, Hex, and Decimal string conversions

2007-08-12 Thread Dick Moores
At 07:04 PM 8/12/2007, Michael Bentley wrote:

>On Aug 12, 2007, at 6:28 PM, Dick Moores wrote:
>
>>n = 12
>>base = 36
>>print to_base(n, base)
>>==
>>This seems to work fine for n >= base, but not for n < base. For 
>>example, the code shown returns "c". Is my indentation wrong, or 
>>the code? It seems to me that the code should work for the general 
>>case, not just for n >= base.
>
>Isn't 'c' the correct answer?

Yes, of course. Stupid of me.

Dick


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


Re: Binary, Hex, and Decimal string conversions

2007-08-13 Thread Dick Moores


At 07:35 AM 8/13/2007, Robert Dailey wrote:
Just curious Dick, why are you
making your own to_base method? Doesn't the source I provided in my
earlier email give you all that you need? I was hoping my source might be
useful to a few people, even though it's pretty trivial code.

I didn't roll my own. I just preferred "n" to
"number".  I greatly appreciated your code!
Dick

On 8/12/07, Dick Moores
<[EMAIL PROTECTED]> wrote:


At 07:04 PM 8/12/2007, Michael Bentley wrote:

>On Aug 12, 2007, at 6:28 PM, Dick Moores wrote:

>

>>n = 12

>>base = 36

>>print to_base(n, base)

>>== 

>>This seems to work fine for n >= base, but not for n <
base. For

>>example, the code shown returns "c". Is my
indentation wrong, or

>>the code? It seems to me that the code should work for the
general 

>>case, not just for n >= base.

>

>Isn't 'c' the correct answer?

Yes, of course. Stupid of me.

Dick


--


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




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

Opinions about this new Python book?

2007-08-14 Thread Dick Moores
I'd appreciate opinions about this new Python book.

Title: Python Power!: The Comprehensive Guide
Author:  Matt Telles
Publisher:  Course Technology
Pub. Date:  Jul 27, 2007
Edition:  1st edition
Binding:  Paperback
Pages:  508
ISBN:  1598631586
List Price:  34.99 USD

The book on the publisher's website: <http://tinyurl.com/2dkhzg>

And at BestBookDeal.com:
< http://www.bestbookdeal.com/book/compare/1598631586>

Thanks,

Dick Moores 

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


Re: Opinions about this new Python book?

2007-08-14 Thread Dick Moores
At 05:57 AM 8/14/2007, [EMAIL PROTECTED] wrote:
>On Aug 14, 7:05 am, Dick Moores <[EMAIL PROTECTED]> wrote:
> > I'd appreciate opinions about this new Python book.
> >
> > Title: Python Power!: The Comprehensive Guide
> > Author:  Matt Telles
> > Publisher:  Course Technology
> > Pub. Date:  Jul 27, 2007
> > Edition:  1st edition
> > Binding:  Paperback
> > Pages:  508
> > ISBN:  1598631586
> > List Price:  34.99 USD
> >
> > The book on the publisher's website: <http://tinyurl.com/2dkhzg>
> >
> > And at BestBookDeal.com:
> > <http://www.bestbookdeal.com/book/compare/1598631586>
> >
> > Thanks,
> >
> > Dick Moores
>
>I just got this book over the weekend. I'll start reading/skimming
>through it this week and hopefully remember to get back to you.

Thanks!

>  By the
>way, why do you want to know?

If the experts like it, I'll buy it.

Dick


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


Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Dick Moores
At 02:47 AM 8/19/2007, Sébastien wrote:
>Hi folks,
>
>I am currently using Eclipse+PyDev when developping Python projects but
>I lack a fast, simple editor for tiny bit of scripts. So here is my
>question: what is, for you, the current best ( but still kind of light!
>) Python editor/IDE ? A tiny precision, I am on Ubuntu so I am looking
>for a linux compatible editor.

I thought Ulipad WAS linux-compatible. Isn't it?

Dick Moores
XP, Python 2.5, editor is Ulipad



==
   Bagdad Weather
<http://weather.yahoo.com/forecast/IZXX0008_f.html>  

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


Re: A problem with Time

2007-08-19 Thread Dick Moores
At 08:30 AM 8/16/2007, special_dragonfly wrote:
>Hello,
>
>I need to return the date yesterday in the form DDMM. I looked through
>the modules: time, datetime and calendar but can't find anything that leaps
>out at me.
>
>The problem I'm having is that although I can use time.localtime and get a
>tuple of the year, month, day and so forth, I don't believe I can just minus
>1 from the day, because I don't think it's cyclic, also, I can't see the
>date being linked in with the month.
>
>So is there any way of getting yesterdays date?

The question has already been well-answered, but since I've found 
using the datetime module to be tough going, I was wondering if 
either of these would be easier to understand and use:
1. <http://www.egenix.com/products/python/mxBase/mxDateTime/>
I see that mxDateTime comes with a 55-page manual as a PDF.

2. <http://labix.org/python-dateutil>

Dick Moores




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


Re: 'REPL' style IDE

2007-08-22 Thread Dick Moores
At 10:50 AM 8/20/2007, beginner wrote:
>Hi Everyone,
>
>I am using the Wing IDE. It works great when developing applications,
>but the workflow is like Visual Studio -- after you execute it or
>debug it, the python script ends.
>
>What I want is an interactive interpreting environment. I want the IDE
>to execute a boot script to initialize my environment and create some
>basic data objects. And then I want to be able to type in command on
>the command line using these objects. The IDLE that comes with Python
>does this, but compared with Wing, it does not have a lot of the
>convenient features.
>
>I am wondering if there is anything more powerful than IDLE that can
>do this.

Are you sure you can't do this with Wing? Have you asked support, 
<[EMAIL PROTECTED]>?

Dick Moores



==
   Bagdad Weather
<http://weather.yahoo.com/forecast/IZXX0008_f.html> 

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


Re: IDE for Python

2007-08-22 Thread Dick Moores
At 06:55 AM 8/21/2007, limodou wrote:
>On 8/21/07, king kikapu <[EMAIL PROTECTED]> wrote:
> > On Aug 21, 12:00 pm, Joel Andres Granados <[EMAIL PROTECTED]>
> > wrote:
> > > Hello list:
> > >
> > > I have tried various times to use an IDE for python put have always been
> > > disapointed.
> >
> >
> > I have also tried a lot of them (IDEs) in the last year. I was finally
> > happy with Eclipse/Pydev but i was always wanted a more "true" IDE for
> > Python.
> > I think i found it in Eric4 http://www.die-offenbachs.de/eric/index.html
> > You can download from here 
> http://www.riverbankcomputing.co.uk/pyqt/download.php
> > (binary installer for Windows that contains Eric and PyQt)
> > and have a look at it!
> >
>Maybe someone can try UliPad, I just release 3.7 version a few days before.

I'm a longtime, very satisfied Ulipad user, and heartily recommend 
Ulipad. <http://code.google.com/p/ulipad/>.

Limodou, although sometimes busy with other projects, is very 
responsive to requests for help with Ulilpad, and very open to 
suggestions for new features. He's Chinese, in Beijing, so is on 
Beijing time, but during his day he seems to check his mail often. 
(Gmail users can see when he's using his Gmail account.) If you do 
become a Ulipad user, I strongly suggest you subscribe to the Ulipad 
list at Google Groups, <http://groups.google.com/group/ulipad>.

Dick Moores
XP, Python 2.5, editor is Ulipad



>--
>I like python!
>UliPad <>: http://code.google.com/p/ulipad/
>My Blog: http://www.donews.net/limodou
>--
>http://mail.python.org/mailman/listinfo/python-list

==
   Bagdad Weather
<http://weather.yahoo.com/forecast/IZXX0008_f.html> 

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


Re: Speed of Python

2007-09-11 Thread Dick Moores
At 09:42 AM 9/7/2007, wang frank wrote:
>Are there any way to speed it up?

How about psyco?

Dick Moores
XP, Python 2.5.1, editor is Ulipad


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


Re: number generator

2007-03-10 Thread Dick Moores
At 07:17 AM 3/9/2007, cesco wrote:
>On Mar 9, 3:51 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
> > "cesco" <[EMAIL PROTECTED]> writes:
> > > I have to generate a list of N random numbers (integer) whose sum is
> > > equal to M. If, for example, I have to generate 5 random numbers whose
> > > sum is 50 a possible solution could be [3, 11, 7, 22, 7]. Is there a
> > > simple pattern or function in Python to accomplish that?
> >
> > Erm, yes, lots of ways, there are probably further constraints on the
> > problem, such as the size of the integers, how the lists are supposed
> > to be distributed, etc.  Can you be more specific?  Is this for an
> > application?  If it's a homework problem, that's fine, but it's better
> > in that case for respondents to suggest hints rather than full solutions.
>
>Given two positive integers, N and M with N < M, I have to generate N
>positive integers such that sum(N)=M. No more constraints.

So why not just repeatedly call a function to generate lists of 
length N of random integers within the appropriate range (the closed 
interval [1,M-N-1]), and return the first list the sum of which is M? 
I don't understand what all the discussion is about. Time is not one 
of the constraints.

Dick Moores 

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


Re: number generator

2007-03-12 Thread Dick Moores
At 06:38 AM 3/10/2007, Steven D'Aprano wrote:
>On Sat, 10 Mar 2007 02:32:21 -0800, Dick Moores wrote:
>
> > So why not just repeatedly call a function to generate lists of
> > length N of random integers within the appropriate range (the closed
> > interval [1,M-N-1]), and return the first list the sum of which is M?
> > I don't understand what all the discussion is about. Time is not one
> > of the constraints.
>
>Time is always a constraint. The sun will expand and destroy the Earth in
>a couple of billion years, it would be nice to have a solutions before
>then...
>
>*wink*
>
>Seriously, almost all programming problems have two implicit constraints:
>it must run as fast as practical, using as little computer resources (e.g.
>memory) as practical. Naturally those two constraints are usually in
>opposition, which leads to compromise algorithms that run "fast enough"
>without using "too much" memory.

OK, points well-taken.

The problem posed by the OP is "Given two positive integers, N and M 
with N < M, I have to generate N
positive integers such that sum(N)=M. No more constraints."

But let's say there is one more constraint--that for each n of the N 
positive integers, there must be an equal chance for n to be any of 
the integers between 1 and M-N+1, inclusive. Thus for M == 50 and N 
== 5, the generated list of 5 should be as likely to be [1,46,1,1,1] 
as [10,10,10,10,10] or [14, 2, 7, 1, 26].

Wouldn't sumRndInt() be THE solution?:
=
def sumRndInt(M, N):
 import random
 while True:
 lst = []
 for x in range(N):
 n = random.randint(1,M-N+1)
 lst.append(n)
 if sum(lst) == M:
 return lst

if __name__ == '__main__':

 N = 5
 M = 50

 lst = sumRndInt(M, N)

 print "N is %d, M is %d, lst is %s, sum(lst) is %d" % (N, M, 
lst, sum(lst))
==

I hope I don't seem querulous--I really want to know.

Thanks,

Dick Moores



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


Re: number generator

2007-03-13 Thread Dick Moores
At 02:52 AM 3/13/2007, Duncan Booth wrote:
>Dick Moores <[EMAIL PROTECTED]> wrote:
>
> > But let's say there is one more constraint--that for each n of the N
> > positive integers, there must be an equal chance for n to be any of
> > the integers between 1 and M-N+1, inclusive. Thus for M == 50 and N
> >== 5, the generated list of 5 should be as likely to be [1,46,1,1,1]
> > as [10,10,10,10,10] or [14, 2, 7, 1, 26].
>
>I don't think what you wrote actually works. Any combination including a 46
>must also have four 1s, so the digit 1 has to be at least 4 times as likely
>to appear as the digit 46, and probably a lot more likely than that.

Yes, I see you're right. Thanks.

>On the other hand, making sure that each combination occurs equally often
>(as your example might imply) is doable but still leaves the question
>whether the order of the numbers matters: are [1,46,1,1,1] and [1,1,46,1,1]
>the same or different combinations?

If the added constraint is instead that the probability of generating 
a given list of length N be the same as that of generating any other 
list of length N, then I believe my function does the job. Of course, 
[1,46,1,1,1] and [1,1,46,1,1], as Python lists, are distinct. I ran 
this test for M == 8 and N == 4:
==
def sumRndInt(M, N):
 import random
 while True:
 lst = []
 for x in range(N):
 n = random.randint(1,M-N+1)
 lst.append(n)
 if sum(lst) == M:
 return lst

A = []
B = []
for x in range(10):
 lst = sumRndInt(8,4)
 if lst not in A:
 A.append(lst)
 B.append(1)
 else:
 i = A.index(lst)
 B[i] += 1

A.sort()
print A
print B
print len(A), len(B)
===
a typical run produced:
[[1, 1, 1, 5], [1, 1, 2, 4], [1, 1, 3, 3], [1, 1, 4, 2], [1, 1, 5, 
1], [1, 2, 1, 4], [1, 2, 2, 3], [1, 2, 3, 2], [1, 2, 4, 1], [1, 3, 1, 
3], [1, 3, 2, 2], [1, 3, 3, 1], [1, 4, 1, 2], [1, 4, 2, 1], [1, 5, 1, 
1], [2, 1, 1, 4], [2, 1, 2, 3], [2, 1, 3, 2], [2, 1, 4, 1], [2, 2, 1, 
3], [2, 2, 2, 2], [2, 2, 3, 1], [2, 3, 1, 2], [2, 3, 2, 1], [2, 4, 1, 
1], [3, 1, 1, 3], [3, 1, 2, 2], [3, 1, 3, 1], [3, 2, 1, 2], [3, 2, 2, 
1], [3, 3, 1, 1], [4, 1, 1, 2], [4, 1, 2, 1], [4, 2, 1, 1], [5, 1, 1, 1]]

[2929, 2847, 2806, 2873, 2887, 2856, 2854, 2825, 2847, 2926, 2927, 
2816, 2816, 2861, 2919, 2820, 2890, 2848, 2898, 2883, 2820, 2820, 
2829, 2883, 2873, 2874, 2891, 2884, 2837, 2853, 2759, 2761, 2766, 2947, 2875]

35 35

Dick Moores




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


Re: number generator

2007-03-13 Thread Dick Moores
At 06:59 AM 3/13/2007, Anton Vredegoor wrote:
>Dick Moores wrote:
>
> > If the added constraint is instead that the probability of generating
> > a given list of length N be the same as that of generating any other
> > list of length N, then I believe my function does the job. Of course,
> > [1,46,1,1,1] and [1,1,46,1,1], as Python lists, are distinct. I ran
> > this test for M == 8 and N == 4:
>
>Yes, I believe your function is OK. But the 'fencepost' method posted
>earlier in this thread also does this and it's faster AND it's only two
>line of code ...

Yes, I tested that after posting mine. Paul Rubin's fencepost method 
is about 14 times faster than mine for the same M == 8 and N == 4!  :(

> > A = []
> > B = []
> > for x in range(10):
> >  lst = sumRndInt(8,4)
> >  if lst not in A:
> >  A.append(lst)
> >  B.append(1)
> >  else:
> >  i = A.index(lst)
> >  B[i] += 1
> >
> > A.sort()
>
>Doesn't sorting break the correspondence between A and B?

Yes, but I thought that it would be easier to see that all the 
permutations are represented. It seemed clear enough that with larger 
num, all counts would approach num/35..

>  Also, a more
>pythonic way to count would be to convert the lst into a tuple and then
>do something with a dictionary. Dictionaries have faster lookup. For
>example:
>
>T = tuple(lst)
>D[T] = D.get(T,0) + 1
>
>in the loop in order to count the occurrences.

Sorry, I don't understand this. Could you spell it out for me by 
rewriting my above test to use it? Thanks!

Dick Moores


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


Re: number generator

2007-03-13 Thread Dick Moores
At 05:47 PM 3/10/2007, Paul Rubin wrote:

>The fencepost method still seems to be simplest:
>
> t = sorted(random.sample(xrange(1,50), 4))
> print [(j-i) for i,j in zip([0]+t, t+[50])]

=
M = 50
N = 4
def sumRndIntRubin(M, N):
 import random
 t = sorted(random.sample(xrange(1,M), N-1))
 lst = [(j-i) for i,j in zip([0]+t, t+[M])]

 print t
 print t + [M]
 print [0] + t
 print lst
 print sum(lst)

sumRndIntRubin(M, N)

[6, 20, 31]
[6, 20, 31, 50]
[0, 6, 20, 31]
[6, 14, 11, 19]
50

I understand what zip() and random.sample() are doing, and the above 
helps me get inside the fencepost method, but I don't understand WHY 
it works, or how in the world anyone could have devised it. It is 
truly magical to me!

BTW I did see this in this thread, "Suppose you have a fixed 
telegraph pole at N and a fixed telegraph pole at M, and you're given 
5 more telegraph poles..." (Gerard Flanagan), but even now I can't 
take it anywhere. I guess I'm just a dim bulb. (I thought I was a 
fairly smart guy until I took up Python.)

Dick Moores

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


Re: number generator

2007-03-13 Thread Dick Moores
At 06:20 PM 3/13/2007, Paul Rubin wrote:
>Dick Moores <[EMAIL PROTECTED]> writes:
> > I understand what zip() and random.sample() are doing, and the above
> > helps me get inside the fencepost method, but I don't understand WHY
> > it works, or how in the world anyone could have devised it. It is
> > truly magical to me!
>
>It's Gerald Flanagan's telegraph pole method that you quoted (I
>misremembered it as "fencepost"):
>
> "Suppose you have a fixed telegraph pole at N and a fixed telegraph
> pole at M, and you're given 5 more telegraph poles..." (Gerard Flanagan),
>
>Consider this diagram for the numbers from 1 to 50:
>
>   |--|
>
>The vertical bar at the left represents 0 and the vertical bar
>at the right represents 51.  The fifty dashes represent 1,2,3...50.
>You can also view the fifty dashes as a line segment of length 50.
>
>The fencepost method is to simply chop the line segment into smaller
>pieces.  You do that by choosing some random points inside the segment:
>
> >>> import random
> >>> random.sample(xrange(1,50), 4)
> [49, 37, 22, 5]
>
>so mark those points with plus signs (let's see if I got this right)
>and label the points from left to right, calling them p0,p1,p2,p3:
>
> |++--+---+-|
>  p0   p1 p2  p3
>
>So the length of the leftmost small segment is p0-0, the length of the
>second segment is p1-p0, the third is p2-p1, the fourth is p3-p2, and
>the fifth is 50-p3.  So those lengths are the numbers you want.
>
>The zip thing was just a way to avoid using messy subscripts to
>compute the lengths.  Another way to do it is (untested):
>
>t2 = [0] + t + [50]
>lst = [(t2[i] - t2[i-1]) for i in xrange(1, len(t2))]

Works fine!

>I'm not sure which is better from a Python stylistic perspective.

I'm not sure, but I think if you had written it this way at first, I 
would have understood it.  But I'm glad to have learned the zip way!

>Using zip that way is fairly natural in Haskell, which I've been
>fooling around with lately.  All you're doing is subtracting adjacent
>elements by making two versions of the list, one of them shifted over
>one place, then subtracting element by element, instead of jumping
>around inside a single list, with more ways to make off-by-one errors.
>It looked more symmetrical in the Python code so I did it that way.

Thank you, thank you! You've made it very clear up to this point. 
I'll worry about the Haskell approach later, much later. ;)

Dick Moores

>FWIW, the actual Haskell approach would translate to something more like:
>
>from itertools import chain, izip
>lst = [(j-i) for i,j in izip(chain([0],t), chain(t,[50]))]
>
>which avoids making the intermediate zipped list.


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


Re: Weekly Python Patch/Bug Summary

2007-03-16 Thread Dick Moores


May I ask a dumb question here? It isn't clear to me what to do with
these patches. For most of them there is something like, "Committed
as r54386 and r54387". I'm familiar with updating the editor Ulipad
to the latest revision, using software such as TortoiseSVN and RapidSVN.
Is that what is meant? And if so, what's the URL of the trunk?
Thanks,
Dick Moores




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

Re: Weekly Python Patch/Bug Summary

2007-03-17 Thread Dick Moores
At 01:32 AM 3/17/2007, Terry Reedy wrote:

>"Dick Moores" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]
>| May I ask a dumb question here? It isn't clear to me what to do with
>these patches. For most of them there is something like, "Committed as
>r54386 and r54387". I'm familiar with updating the editor Ulipad to the
>latest revision, using software such as TortoiseSVN and RapidSVN. Is that
>what is meant? And if so, what's the URL of the trunk?
>-
>
>Yes, those are svn revision numbers.  Start at svn.python.org.

I thought I'd give 
<http://svn.python.org/projects/python/branches/release25-maint/> 
(the latest release (plus bug fixes) of Python) a try. I first backed 
up my Python25 folder (I'm using Win XP). Then with Python 25 open I 
opened the Explorer context menu for the folder and then the 
TortoiseSVN sub-menu. There doesn't seem to have a menu item that 
will enable me to update. I tried Export... and entered 
<http://svn.python.org/projects/python/branches/release25-maint/> as 
"URL of repository", but that choice seems to expect the Python25 
folder to be empty. Can you tell me what to do to just update?

Dick 

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


Re: SPE question

2007-03-27 Thread Dick Moores
At 01:39 AM 3/27/2007, alain wrote:
>Hi,
>
>Could someone tell me how to uninstall SPE under windows?

Well, mine is in E:\Python25\Lib\site-packages\_spe, so I'd try 
deleting that folder.

Dick Moores 

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


Re: SPE question

2007-03-27 Thread Dick Moores
At 03:37 AM 3/27/2007, [EMAIL PROTECTED] wrote:
>On Mar 27, 11:39 am, "alain" <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > Could someone tell me how to uninstall SPE under windows?
> >
> > Alain
>
>Dunno about SPE, but most Python modules I've installed can
>be uninstalled from control panel/add remove programs.

SPE doesn't show up on my win XP add/remove programs list.

Dick Moores


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


Welch essential for learning Tkinter well?

2007-04-05 Thread Dick Moores
In a couple of places recently I've seen Brent Welch's _Practical 
Programming in Tcl & Tk_ (<http://tinyurl.com/ynlk8b>) recommended 
for learning Tkinter well.

So a couple of questions:

1) Is it really good for learning Tkinter, even though it doesn't 
mention Tkinter at all (in the 4th edition at least)?

2) If it is good for learning Tkinter, can I get by with a cheaper, 
used copy of the 3rd edition?

Thanks,

Dick Moores

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


Re: Welch essential for learning Tkinter well?

2007-04-07 Thread Dick Moores
At 10:36 AM 4/6/2007, Russell E. Owen wrote:
>In article <[EMAIL PROTECTED]>,
>  Kevin Walzer <[EMAIL PROTECTED]> wrote:
>
> > James Stroud wrote:
> > >This begs the
> > > question, is anyone truly an expert in Tkinter?
> >
> > Frederick Lundh is, if anyone is.
> >
> > http://www.pythonware.com/library/tkinter/introduction/index.htm (outdated)
> > http://effbot.org/tkinterbook/ (new but incomplete)
>
>I agree that this is an excellent resource.
>
>I find Welch's book and the on-line tcl/tk help very helpful for Tkinter
>programming--especially some of the more obscure details. But to use
>either of these resources comfortably you must learn the basics of
>Tkinter first (including understanding the simple mapping between
>Tkinter and Tcl/Tk).

Where can I get this mapping spelled out?

>For learning the basics of Tkinter I suggest the links that Kevin listed
>above and/or Alex Martelli's "Python in a Nutshell" (an excellent
>reference in any case).

Although owning the 2nd ed. of "Python is a Nutshell", I hadn't 
thought of looking into it for Tkinker. There's a whole chapter, 
"Tkinter GUIs" (46 pages!).

>  Grayson's book is another reasonable alternative
>(and includes enough reference material to keep you from having to refer
>to the tcl/tk documentation very often).

One web tutorial that looks good to me is "Thinking in Tkinter", by 
Stephen Ferg (<http://www.ferg.org/thinking_in_tkinter/index.html>).

My thanks to all who responded.

Dick Moores


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


Saving output of Turtle Graphics?

2007-04-07 Thread Dick Moores
I accidentally stumbled across the Turtle Graphics module (turtle.py) 
the other day and have been having some fun with it.

Now I'm wondering if there is a way to build into a script the saving 
of each window just before it is cleared. For example, here are a 
couple that I've saved by screen capture:
<http://www.rcblue.com/Misc/RandomTriangles.jpg>
<http://www.rcblue.com/Misc/RandomTriangles2.jpg>

They were produced by this script:

=
# randomTriangles.py

import turtle as T
from random import *

def twoRndN(low=0, high=1):
 """
 generate two random floats x, y in the range [low, high) such that x <= y
 """
 x, y = uniform(low, high), uniform(low, high)
 if x <= y:
 return x, y
 else:
 return y, x

T.setup(width=1000, height=700, startx=0, starty=0)
T.title("Random Triangles with random R,G,B")

colorRange = "all"
if colorRange == "random":
 lowR, highR = twoRndN()
 lowG, highG = twoRndN()
 lowB, highB = twoRndN()

count = 0
for n in range(300):
 wdth = randrange(0,7,3)
 T.width(wdth)
 T.speed("fastest")
 if colorRange == "dark":
 R = uniform(.1, .5)
 G = uniform(.1, .5)
 B = uniform(.1, .5)
 elif colorRange == "pastel":
 R = uniform(.5, .9)
 G = uniform(.5, .9)
 B = uniform(.5, .9)
 elif colorRange == "all":
 R = uniform(0, 1)
 G = uniform(0, 1)
 B = uniform(0, 1)
 # set RGB for one color of your choice
 elif colorRange == "manual":
 R = .45
 G = .2
 B = .2
 elif colorRange == "random":
 R = uniform(lowR, highR)
 G = uniform(lowG, highG)
 B = uniform(lowB, highB)

 T.color(R,G,B)
 T.begin_fill()
 # 2 connected lines will fill as a triangle
 for x in range(2):
 coord = (randint(-500,500), randint(-350,350))
 T.goto(coord)
 T.end_fill()

 count += 1
 if count > 5:
 clr = randint(0,5)
 if clr == 0:
 T.clear()
 count = 0
T.done()
==
(The docs for Turtle graphics for Tk are at 
<http://www.python.org/doc/2.5/lib/module-turtle.html>)

But how could I have saved them "automatically"?

The script as shown will clear (T.clear() -- the 3rd line from the 
bottom) the window after producing 6 to maybe 15 superimposed 
triangles, so clearing will take place maybe 30 times. How can I save 
as images each of the 30 windows just before they are cleared?

Thanks,

Dick Moores

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


Re: Welch essential for learning Tkinter well?

2007-04-07 Thread Dick Moores
At 03:43 AM 4/7/2007, James Stroud wrote:
>Dick Moores wrote:
> > At 10:36 AM 4/6/2007, Russell E. Owen wrote:
> >> I find Welch's book and the on-line tcl/tk help very helpful for Tkinter
> >> programming--especially some of the more obscure details. But to use
> >> either of these resources comfortably you must learn the basics of
> >> Tkinter first (including understanding the simple mapping between
> >> Tkinter and Tcl/Tk).
> >
> > Where can I get this mapping spelled out?
>
>Grayson Appendix A. $25 pdf--well worth it in your time.

Terrific! Thank you.

Dick

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


Re: Saving output of Turtle Graphics?

2007-04-07 Thread Dick Moores
At 06:50 AM 4/7/2007, =?ISO-8859-2?Q?Wojciech_Mu=B3a?= wrote:
>Dick Moores wrote:
> > I accidentally stumbled across the Turtle Graphics module (turtle.py)
> > the other day and have been having some fun with it.
> >
> > Now I'm wondering if there is a way to build into a script the saving of
> > each window just before it is cleared. For example, here are a couple
> > that I've saved by screen capture:
> > <http://www.rcblue.com/Misc/RandomTriangles.jpg>
> > <http://www.rcblue.com/Misc/RandomTriangles2.jpg>
>
>Turtle module uses Tk canvas element to draw graphics ('_canvas'
>attribute). I've written module, that exports canvas graphics to SVG
>file: http://wmula.republika.pl/proj/canvas2svg/ -- it may be useful
>for you.

I afraid I'm totally unfamiliar with SVG. Would it be possible for 
you or someone else on the list to show how to use your module to 
export the simple product of this simple script to an SVG file?

===
import turtle as T
from random import randint
T.setup(width=1000, height=700, startx=0, starty=0)
T.color(1, .5, .5)
T.begin_fill()
# 2 connected lines will fill as a triangle
for x in range(2):
 coord = (randint(-500,500), randint(-350,350))
 T.goto(coord)
T.end_fill()

T.done()


Thanks,

Dick Moores
Win XP Pro SP2
Python 2.5
Python IDE: Ulipad 3.6


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


Re: Saving output of Turtle Graphics?

2007-04-07 Thread Dick Moores
At 08:48 AM 4/7/2007, =?ISO-8859-2?Q?Wojciech_Mu=B3a?= wrote:
>Dick Moores wrote:
> >> Turtle module uses Tk canvas element to draw graphics ('_canvas'
> >> attribute). I've written module, that exports canvas graphics to SVG
> >> file: http://wmula.republika.pl/proj/canvas2svg/ -- it may be useful
> >> for you.
> >
> > I afraid I'm totally unfamiliar with SVG. Would it be possible for you
> > or someone else on the list to show how to use your module to export the
> > simple product of this simple script to an SVG file?
> >
> > ===
> > import turtle as T
>import canvasvg
> > from random import randint
> > T.setup(width=1000, height=700, startx=0, starty=0)
> > T.color(1, .5, .5)
> > T.begin_fill()
> > # 2 connected lines will fill as a triangle
> > for x in range(2):
> > coord = (randint(-500,500), randint(-350,350))
> > T.goto(coord)
> > T.end_fill()
>
>canvasvg.saveall("image.svg", T._canvas)
>
> > T.done()
> > 

OK, thanks, now I've got

===
http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>http://www.w3.org/2000/svg";>


What do I do to see this?

Dick

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


Re: Saving output of Turtle Graphics?

2007-04-07 Thread Dick Moores
At 09:31 AM 4/7/2007, =?ISO-8859-2?Q?Wojciech_Mu=B3a?= wrote:
>Dick Moores wrote:
> > What do I do to see this?
>
>For example Opera 9 and Firefox 1.5+ are able to view SVG files;
>there is a free plugin for IrfanView.

Ha. I had tried it with Firefox 2 already, but I stupidly changed the 
extension to HTM first. I'll also get the IrfanView plugin.

Thanks for all the help, and especially for your canvasvg.py module.

Dick


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


Where's the Starship's crew?

2007-10-05 Thread Dick Moores
<http://starship.python.net/crew/index.html>

I didn't check on all of them, but the only one I found was Mark 
Hammond <http://starship.python.net/crew/mhammond/>.

Dick Moores

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


Re: Where's the Starship's crew?

2007-10-05 Thread Dick Moores
At 04:54 AM 10/5/2007, Thomas Heller wrote:
>Dick Moores schrieb:
> > <http://starship.python.net/crew/index.html>
> >
> > I didn't check on all of them, but the only one I found was Mark
> > Hammond <http://starship.python.net/crew/mhammond/>.
> >
> > Dick Moores
> >
>
>There are more. Think of it as a game you have to solve.

Yeah, a mind numbing game!

http://starship.python.net/crew/ewalstad/ Eric Walstad
http://starship.python.net/crew/piers/ Piers Lauder
http://starship.python.net/crew/jae/ --> http://zhar.net/  John Eikenberry
http://starship.python.net/crew/mwh/
http://starship.python.net/crew/manus/ Manus Hand
http://starship.python.net/crew/bhoel/ Berthold Höllmann
http://starship.python.net/crew/marduk/ ("Server Error")
http://starship.python.net/crew/schorsch/
http://starship.python.net/crew/dni/ David Niergarth
http://starship.python.net/crew/jcooley/ James Cooley
http://starship.python.net/crew/sdrees/ Stefan Drees
http://starship.python.net/crew/jwt/ Jim Tittsler
http://starship.python.net/crew/theller/ Thomas Heller
http://starship.python.net/crew/gherman/ Dinu Gherman
http://starship.python.net/crew/mhammond/ Mark Hammond
http://starship.python.net/crew/atuining/
http://starship.python.net/crew/hooft/ Rob W.W. Hooft
http://starship.python.net/crew/lemburg/ --> http://www.egenix.com/
http://starship.python.net/crew/goodger/ David Goodger
http://starship.python.net/crew/mmuller/ Mike Muller
http://starship.python.net/crew/skippy/ same as 
http://starship.python.net/crew/mhammond/ Mark Hammond

BTW How could I have done this with Python script?

Dick Moores

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


Top Programming Languages of 2013

2007-10-06 Thread Dick Moores
<http://www.redcanary.ca/view/top-programming>

Dick Moores

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


Matplotlib axis control problem

2007-10-16 Thread Dick Crepeau
I would like to control the y axis of a plot.  The following code does 
exactly what I want it to!  On my linux computer it sets the y axis 
limits to 18.0 minimum, 58.0 maximum, plots some points on y=x, provides 
ticks at 20,30,40,50 and horizontal tick lines that intersect the 
plotted points.

All very good, but if I change the upper y axis limit to 54.0, 
(ax.set_ylim(18.0, 54.0)), it fails, plotting the ticks at some strange 
values.

Ultimately I want to uncomment the set scale to log and use this to 
label semi log plots that by default are only labeled on powers of 10.  
My data falls within one decade so I don't want the full 10-100 limits.

I'm rather new at matplotlib so if I'm making trivial errors please feel 
free to criticize.

Thanks
Dick C

from pylab import *
from matplotlib.ticker import MaxNLocator

x=[10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0]
y=x
figure(1)
ax=subplot(111)
ax.plot(array(x), array(y), 'x')
#ax.set_yscale('log')
ax.set_ylim(18.0, 58.0)
ax.yaxis.set_major_locator(MaxNLocator(5))
ax.set_yticklabels(('10', '20','30','40','50','60','70','80','90','100'))
ax.yaxis.grid(True, linestyle='-', which='major')
show()


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


why doesn't have this list a "reply-to" ?

2007-10-16 Thread Dick Crepeau
It seems to me the original question was how can I reply to a posted 
message.

I'm new here and see that while there are replies to several messages, 
many times, like with this note, the issue is brought up as if it is new.

I don't know how to do a reply, can someone tell me how?  This note was 
sent to: [email protected] with the subject copied from an earlier 
note.

No need to discuss the politics of the choice.

Dick C



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


Matlab axis control problem - solved

2007-10-16 Thread Dick Crepeau
I don't understand my earlier problem but the following code works no 
matter what the ylim is set to:

I reworked the example major_minor_demo1.py to find the answer.

thanks
Dick C

ps: I still can't post a reply since I read the list with my mozilla or 
konqueror browser and email separately with thunderbird - the reply 
address is not obvious.

from pylab import *
from matplotlib.ticker import MaxNLocator, MultipleLocator, 
FormatStrFormatter

x=[10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0]
y=x
figure(1)
ax=subplot(111)
ax.plot(array(x), array(y), 'x')

ymajorLocator   = MultipleLocator(5)
ymajorFormatter = FormatStrFormatter('%d')

ax.set_yscale('log')

ax.set_ylim(18.0, 58.0)

ax.yaxis.set_major_locator(ymajorLocator)
ax.yaxis.set_major_formatter(ymajorFormatter)

ax.yaxis.grid(True, linestyle='-', which='major')
show()

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


Using msvcrt (in Windows), how to catch Enter key?

2007-10-29 Thread Dick Moores
Windows XP Pro, Python 2.5.1

import msvcrt
while True:
 if msvcrt.kbhit():
 key = msvcrt.getch()
 if key == 'Enter'
 do something

Is there a way to catch the pressing of the 'Enter' key?

Thanks,

Dick Moores

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


  1   2   >