Re: exit from Tkinter mainloop Python 2.7

2016-02-24 Thread Dave Farrance
kevind0...@gmail.com wrote:

>from Tkinter import *
>
>def butContinue():
>root1.destroy()

As Christian said, you're destroying the root window and its children,
so instead use root1.quit() here.

> ...
>
>root1.mainloop()
>
>print entryName.get("1.0", "end-1c" )
>print entryPWord.get("1.0", "end-1c" )

And your root1.destroy() goes here instead. (The root window would
normally be destroyed on the script exit, but some IDE debuggers will
leave it open.) 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Problem with matplotlib

2016-02-20 Thread Dave Farrance
Dave Farrance  wrote:

>It occurs to me now that the trackback might misidentify the module in
>use, if say, you'd named a file "numbers.py" then got rid of it later
>leaving a "numbers.pyc" somewhere. If so, see where it is:
>
>import numbers
>print numbers.__file__

I seem to have "numbers" on the brain. Replace with "decimal", of
course.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Problem with matplotlib

2016-02-20 Thread Dave Farrance
It occurs to me now that the trackback might misidentify the module in
use, if say, you'd named a file "numbers.py" then got rid of it later
leaving a "numbers.pyc" somewhere. If so, see where it is:

import numbers
print numbers.__file__
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Problem with matplotlib

2016-02-20 Thread Dave Farrance
jenswaelk...@gmail.com wrote:

>  File "/usr/lib/python2.7/decimal.py", line 3744, in 
>_numbers.Number.register(Decimal)
>AttributeError: 'module' object has no attribute 'Number'

Your decimal module seems broken. Confirm that in the Python shell:

import numbers
print numbers.Number

I'm guessing you'll get:
AttributeError: 'module' object has no attribute 'Number'

It appears to be the usual decimal module of the current linux system
python 2.7, so a corrupt hard disk?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter problem: TclError> couldn't connect to display ":0

2016-02-05 Thread Dave Farrance
gemjack...@gmail.com wrote:

>This fixed my problem with thkinter.   sudo cp ~/.Xauthority ~root/

Which means that you were creating a GUI window with Python as root,
which is to be avoided if you can. If you can't avoid it and you're
running it with sudo in a bash console, rather than a root console, then
I'd suggest adding the line...

XAUTHORITY=$HOME/.Xauthority

...to the root's .bashrc which avoids putting a specific user's
xauthority file in the root directory.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Install Numba on Debian

2016-01-23 Thread Dave Farrance
Dave Farrance  wrote:

>I'd like to install Numba on Debian Jessie to work with the system
>Python 2.7.9 (rather than installing Anaconda).

OK, never mind. Fixed.

By Googling the first error code, finding a suggested fix for that,
running again, Googling the new error, and several repeats of that, and
I've now got a working solution.

This recipe that somebody put on Github overcomes the main hurdle:
https://gist.github.com/sshillo/62955e46cb05e2b47ad3

The main issue seems to be that contrary to the instructions on the
Numba website, it's now a requirement to have  LLVM 3.6 installed, not
LLVM 3.5 which is in the Debian repository, and not LLVM 3.7 which is
the latest release at llvm.org.  Fortunately, a prebuilt LLVM 3.6 is
available at llvm.org.

Also I needed to install this lot from the Debian repository:

python-pip python-setuptools build-essential
python-enum34 libedit-dev python-dev
-- 
https://mail.python.org/mailman/listinfo/python-list


Install Numba on Debian

2016-01-23 Thread Dave Farrance
I'd like to install Numba on Debian Jessie to work with the system
Python 2.7.9 (rather than installing Anaconda).

When I follow the instructions at
https://github.com/numba/numba#custom-python-environments

...I get errors when trying to install Numba either with the git clone
method or installing it with pip.

I'll put the error log on Pastebin since its so large:
http://pastebin.com/gbrj0iHw

I've Googled for recipes for installing numba on Debian, installed every
Debian package suggested as a possible dependency, and still no luck.

Anybody know a working method for installing Numba on Debian Jessie
without Anaconda?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help

2016-01-15 Thread Dave Farrance
sam Rogers  wrote:

>  I have downloaded python 2.7  with no problem. It works. I am trying to get 
>pyserial to work. I have tried many different solutions. I am not  sure if it 
>works or not. How can I be sure? I am using windows 7.  I did not see any help 
>at python.org. Can you help?
>PS my goal is make this adafruit project work.
>https://learn.adafruit.com/arduino-lesson-17-email-sending-movement-detector/overview

Before using Python, have you verified that the IDE talks on the serial
port OK -- and that you can upload the simple blink sketch from its
provided examples and that you can change the blink rate of the LED?

Having done that, can you establish 2 way communication with Python?
What happens if you try the simple test script below? You will need to
change the "dev" line to whichever port you're using.


// Arduino sketch to echo serial port strings
char buf[81]; // max 80 chars + null
int siz = 0;  // size of input string
void setup(){
   Serial.begin(9600);
   Serial.setTimeout(100);
}
void loop(){
  siz = Serial.readBytesUntil('\n',buf,80); // get input string
  if (siz == 0) return;  // if timeout, loop again
  Serial.print("I heard: "); // reply with some text and
  buf[siz] = 0;  // must add null terminator
  Serial.println(buf);   // return original string
}


#!/usr/bin/env python2
import serial,time
# LINUX PORT -- change to "COM1" or whatever for Windows
dev = "/dev/ttyACM0"
ser = serial.Serial(dev, 9600, timeout=1)
time.sleep(2)   # Arduino starts in ~1.6s
while True:
  mystr = raw_input("Enter text max 80 chars: ")
  if mystr == '': break # terminate prog with 
  ser.flushInput()  # flush input just in case
  ser.write(mystr + '\n')   # send newline-terminated string
  txt = ser.readline(80)# read newline-terminated string
  print len(txt),"chars: ",txt, # \r\n included so add final comma
ser.close() # close port
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Turtle

2016-01-15 Thread Dave Farrance
Stallone Carl  wrote:

>I am currently using python 3.5.0 and I have been trying to write a program
>using turtle but is not seem to be working. I have followed all tutarial on
>the web and when i compare it with my code my am duing everything the same
>way but it still don't seems to be working I tryed repairen python but
>still no difference. Please help me.

OK.  Which tutorial?  What did you try?  What went wrong?  Was there an
error message?  If there was, what was it?

When learning something on a computer, start with the simplest possible
example.  Only when that's working do you move on to more complex stuff.
So with turtle graphics, start by writing a program that draws just one
line.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unicode failure (Solved)

2015-12-06 Thread Dave Farrance
"D'Arcy J.M. Cain"  wrote:

>On Fri, 4 Dec 2015 18:28:22 -0500
>Terry Reedy  wrote:
>> Tk widgets, and hence IDLE windows, will print any character from
>> \u to \u without raising, even if the result is blank or ?.
>> Higher codepoints fail, but allowing the entire BMP is better than
>> any Windows codepage.
>
>Thanks to all.  Following up on the various posts brought me to
>information that solved my problem.  Basicall I added "export
>PYTHONIOENCODING=utf8" to my environment and "SetEnv PYTHONIOENCODING
>utf8" in my Apache config and now things are working as they should.
>
>Thanks all.

Hmmm. I hadn't seen this post before replying to the original because my
newsreader put this post in a later thread because:

(a) The subject header was changed
(b) The reference header is for a post that's not present in Usenet

That raises another question.  I'm seeing a number of broken threads
because people reply to posts that are not present in Usenet.  It's not
just my main news-server because my newreader can gather posts from
several Usenet servers and those posts are nowhere on Usenet.

Case in point:  The post by Terry Reedy quoted above, reference
. I presume that it's on the list server
even though it's not on Usenet.  Anybody know what's going on?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unicode failure

2015-12-06 Thread Dave Farrance
I was taking it for granted that you knew how to set environment
variables, but just in case you don't: In the shell, (are you using
BASH?), put this:

export PYTHONIOENCODING=UTF-8

...then run your script.

Remember that this is *not* a permanent fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unicode failure

2015-12-06 Thread Dave Farrance
"D'Arcy J.M. Cain"  wrote:

>...
>utf-8
>Traceback (most recent call last):
>  File "./g", line 5, in 
>print(u"\N{TRADE MARK SIGN}")
>UnicodeEncodeError: 'ascii' codec can't encode character '\u2122' in
>position 0: ordinal not in range(128)

I *presume* that you're using Linux since you've got a hashbang, so...

You can *check* that it's the local environment that's the issue with
the *test* of setting the PYTHONIOENCODING environment variable. But if
that works, then it tells you must then fix the underlying environment's
character encoding to give a permanent fix.

$ PYTHONIOENCODING=UTF-8 python3 -c 'print(u"\u00A9")'
©

$ PYTHONIOENCODING=ascii python3 -c 'print(u"\u00A9")'
Traceback (most recent call last):
  File "", line 1, in 
UnicodeEncodeError: 'ascii' codec can't encode character '\xa9' in
position 0: ordinal not in range(128)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Object identity has no necessary connection to memory location (was: What is a function parameter =[] for?)

2015-11-26 Thread Dave Farrance
Ben Finney  wrote:

>Dave Farrance  writes:
>
>> Marko Rauhamaa  wrote:
>>
>> >Dave Farrance :
>> >
>> >> (Conversely, I see that unlike CPython, all PyPy's numbers have
>> >> unchanging ids, even after exiting PyPy and restarting, so it seems
>> >> that PyPy's numerical ids are "faked".)
>> >
>> >What's a faked id?
>>
>> You can figure out what I'm getting at -- i.e. I presume that the ids
>> are not pointers to stored numbers in memory (as with CPython) but are
>> a translation of the numerical variable's value.
>
>Why refer to that as “faked”? That's what I can't figure out about what
>you're getting at. Perhaps Marko shares my uncomprehension.

Hence

https://en.wikipedia.org/wiki/Scare_quotes
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is a function parameter =[] for?

2015-11-26 Thread Dave Farrance
Marko Rauhamaa  wrote:

>Dave Farrance :
>
>> (Conversely, I see that unlike CPython, all PyPy's numbers have
>> unchanging ids, even after exiting PyPy and restarting, so it seems
>> that PyPy's numerical ids are "faked".)
>
>What's a faked id?

You can figure out what I'm getting at -- i.e. I presume that the ids
are not pointers to stored numbers in memory (as with CPython) but are a
translation of the numerical variable's value.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help needed with compiling python

2015-11-26 Thread Dave Farrance
Cecil Westerhof  wrote:

>On Wednesday 25 Nov 2015 23:58 CET, Laura Creighton wrote:
>>
>> Your Suse system probably wants to use python for something. If your
>> system python is damaged, you badly need to fix that, using the
>> system package managers tools, before Suse does some sort of update
>> on you, using the broken python, which damages more of your system.
>
>I tried that. But it installs only things in /usr/lib and /usr/lib64,
>nothing in /usr/bin, but at the same time it is adamant that it
>installed python. I wanted a quick fix, but it looks like that is not
>going to work. :'-( I'll have to find a way to get things fixed.

A complete reinstall of Suse (after saving your home directory and work)
might be quickest if you're in the dark about what's broken.

But you might be able to fix it.  If you can figure out which packages
contain the damaged files, then do forced reinstalls of those.  I've not
used Suse, but a quick Google tells me that the syntax is:

zypper in -f 

So you'll want to try package names like "python" and "python2.7".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is a function parameter =[] for?

2015-11-26 Thread Dave Farrance
Alan Bawden  wrote:

>Chris Angelico  writes:
> ...
>> Python 2.7.8 (2.4.0+dfsg-3, Dec 20 2014, 13:30:46)
>> [PyPy 2.4.0 with GCC 4.9.2] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> tuple([]) is tuple([])
>> False
>
>I said I wouldn't be suprised if it was always true, but that doesn't
>imply that I need to be suprised if it is sometimes false!
>
>Having said that, I _am_ curious whether that remains False for various
>other variant expressions.  "tuple([])" is actually a rather perverse
>way to obtain an empty tuple.  How about plain "() is ()"? ...

Still false in PyPy it seems

[PyPy 2.6.1 with GCC 4.9.2] on linux2
 id(())
139836165383760L
 id(())
139836165383776L

(Conversely, I see that unlike CPython, all PyPy's numbers have
unchanging ids, even after exiting PyPy and restarting, so it seems that
PyPy's numerical ids are "faked".)

[PyPy 2.6.1 with GCC 4.9.2] on linux2
 id(1+2j)
679900119843984469027190799480815353863L

[PyPy 2.6.1 with GCC 4.9.2] on linux2
 id(1+2j)
679900119843984469027190799480815353863L
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there any reason to introduce this intermediate variable (sz)?

2015-11-18 Thread Dave Farrance
fl  wrote:

>Hi,
>I find the following code snippet, which is useful in my project:
> ...
>correctly. Could you see something useful with variable 'sz'?

So that's example code in "An Introduction to the Kalman Filter" by Greg
Welch and Gary Bishop, and no, that construct was unnecessary. As you've
figured out, you can use the integer directly.

It's the usual problem that people get when they switch from using
Octave/Matlab to numpy/scipy/matplotlib. The former are better in an
interactive maths-oriented environment, but people then often then
switch to Python for more complex algorithms to take advantage of the
features of an advanced general-purpose programming language. The
problem that people then run into is that although there are equivalents
in the Python libraries for most of the Matlab functions, this happens
to be an area where the documentation is particularly uneven.

"Pylab" is a project that attempted to be a Python equivalent of Matlab,
but has now become a depreciated appendix to matplotlib. There have been
attempts to restart it as a feature of Ipython, but although it mostly
works, the documentation is almost nonexistent. The only way to figure
out what it can do is to try it yourself with a lot of trial and error.

Anyway, don't be surprised if you see unnecessary elaborations in
maths/science Python code because it's what you expect when people are
arriving at code that works from reading poor documentation, trial and
error, and Googling other peoples code snippets. Just try it yourself
and save yourself time rather than asking for hand-holding.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problems using struct pack/unpack in files, and reading them.

2015-11-17 Thread Dave Farrance
Steven D'Aprano  wrote:

>On Mon, 16 Nov 2015 05:15 pm, Gregory Ewing wrote:
>
>> Ints are not the only thing that // can be applied to:
>> 
>>  >>> 1.0//0.01
>> 99.0
>
>Good catch!

Hmmm. I see that the float for 0.01 _is_ slightly larger than 0.01

>>> Decimal(0.01)
Decimal('0.0120816681711721685132943093776702880859375')

But it seems that 1.0 // 0.01 is not directly equivalent to:

>>> int(1.0 / 0.01)
100

And I see that:

>>> Decimal(1.0 / 0.01)
Decimal('100')
>>> floor(1.0 / 0.01)
100
>>> 0.01 * 100.0 - 1.0
0.0

So I guess that the // operator is _very_ strict in its "floor division"
of floats, but that the "/" operator returns the nearest float value.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is '@' for

2015-11-14 Thread Dave Farrance
fl  wrote:

>I read the following code snippet. A question is here about '@'.
>I don't find the answer online yet.

I recommend this:

"Understanding Python Decorators in 12 Easy Steps!"

http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: don't understand matrix-multiplication should be reversed in python?

2015-11-13 Thread Dave Farrance
PythonDude  wrote:

>On Thursday, 12 November 2015 22:57:21 UTC+1, Robert Kern  wrote:

>> He simply instantiated the two vectors as row-vectors instead of 
>> column-vectors, 
>> which he could have easily done, so he had to flip the matrix expression.
>
>Thank you very much Robert - I just had to be sure about it :-)

Yep, he's evidently used to the Matlab/Octave way of defining "vectors"
which is somewhat easier for a math-oriented interactive environment.

It's just a *bit* more laborious to append columns in numpy.

>>> from numpy import *
>>> v1=vstack([0,1,2])
>>> v2=vstack([3,4,5])
>>> c_[v1,v2]
array([[0, 3],
   [1, 4],
   [2, 5]])
>>> append(v1,v2,axis=1)
array([[0, 3],
   [1, 4],
   [2, 5]])
>>> v3=mat('4;5;6')
>>> v4=mat('7;8;9')
>>> c_[v3,v4]
matrix([[4, 7],
[5, 8],
[6, 9]])
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unbuffered stderr in Python 3

2015-11-04 Thread Dave Farrance
Random832  wrote:

>The opposite of line buffering is not no buffering, but full
>(i.e. block) buffering, that doesn't get flushed until it runs
>out of space. TextIOWrapper has its own internal buffer, and its
>design apparently doesn't contemplate the possibility of using
>it with a raw FileIO object (which may mean that the posted code
>isn't guaranteed to work) or disabling buffering.

Hmmm. That even seems to cause trouble for sys.stderr.write
(in Python3 with a non-tty e.g. a piped output):

$ python2 -c 'import sys;sys.stderr.write("1\n");print("2")' 2>&1 | tee
1
2
$ python3 -c 'import sys;sys.stderr.write("1\n");print("2")' 2>&1 | tee
2
1
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python doesn't install

2015-11-02 Thread Dave Farrance
Tim Golden  wrote:

>I'm afraid you've been bitten by the fact that we no longer support 
>Windows XP and haven't communicated this very well. We have a new 
>version of the installer almost ready for release which indicates this 
>much earlier (and more obviously). I'm afraid if you're on XP you're 
>limited to Python 3.4 and earlier, all of which are perfectly usable I'm 
>happy to say!

I've been reading the comments about Python and XP on this group -- and
I must say that I'm thinking: Doesn't pretty much every other Windows
software package tell you the minimum requirements -- because that's the
first thing you'd want to know?

So I've Googled for "python 3.5 minimum requirements":

1st hit: "Using Python on Windows -- Python 3.5.0 documentation"
and a few paragraphs down that page there's:
"Python on XP --  7 Minutes to Hello World by Richard Dooling, 2006"
which says how easy it is to install on XP.

2nd hit: "Download Python -- Python.org"
There's download links but nothing about XP, but there's a link for
"Information about specific ports" -- so click on "Windows"
and no information actually, just more download links.

3rd hit: "Welcome to Python.org"
There's download links and no info about minimum requirements.

And so on down the page of Google hits.

Yes, I've read the justifications. Why list all the non-supported OSs?
And the explanation about each version of Python being supported just
for the supported versions of Windows upon its release is in the
documentation -- somewhere.  But it still seems to me that stating the
minimum requirements in a place that people would tend to look for it is
a... minimum requirement.

If the developers really are determined not to mention specific versions
of Windows (If it was me, I'd have probably mentioned that the most
recent version required Vista somewhere on the download page), then
maybe adding the comment about matching the release date of Python to
the supported versions of Windows to the download pages would give
people some sort of clue as to what's going on.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-07 Thread Dave Farrance
Rob Gaddi  wrote:

>So, this is odd.  I'm running Ubuntu 14.04, and my system did a kernel 
>upgrade from the repository from 3.13.0-63-generic to 3.13.0-65-generic.  
>And pyserial (2.7, installed through pip) stopped working.

When KDE's "Plasma 5" appeared with Kubuntu 15.04, I found it to be too
new and have too many dysfunctions, so I reverted to Kubuntu 14.04 LTS.

Now this problem.  Looking at the Ubuntu 14.04 repository, I found that
it contained a backported version of the kernel used in 15.04.  So...

Remove "meta" packages that have latest 3.13 kernel as dependencies:

sudo apt-get purge linux-generic linux-signed-generic

Install meta packages that pull in the latest 3.19 kernel:

sudo apt-get install linux-generic-lts-vivid
  linux-signed-generic-lts-vivid

Serial now works fine. The later kernel introduces no functional changes
in (K)ubuntu 14.04 that I can discern.  I presume that since it is a
"backported" version of the 3.19 kernel, that its video drivers have
been matched to Ubuntu 14.04's version of X.Org, and so on.

Anyway, that's what works for me. I could've put a "hold" on the
3.13.0-63 kernel, but this seems a better fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: matplotlib timer

2015-10-01 Thread Dave Farrance
Laura Creighton  wrote:

>In a message of Thu, 01 Oct 2015 20:03:26 +0100, Dave Farrance writes:
>>Laura Creighton  wrote:
>>
>>>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
>>>>Yet the documentation says that it's mandatory for the GUI backend base
>>>>to implement stop() but that single_shot is optional. Ho hum.
>>>
>>>report as a bug.  its a doc bug at least, but I think its a real bug,
>>>and your code should have worked.
>>>
>>>https://github.com/matplotlib/matplotlib/issues
>>
>>OK, done.
>>
>
>Thank you.
>
>Can you add how you got it to work, and the doc you read
>that seems wrong?

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


Re: matplotlib timer

2015-10-01 Thread Dave Farrance
Laura Creighton  wrote:

>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
>>Yet the documentation says that it's mandatory for the GUI backend base
>>to implement stop() but that single_shot is optional. Ho hum.
>
>report as a bug.  its a doc bug at least, but I think its a real bug,
>and your code should have worked.
>
>https://github.com/matplotlib/matplotlib/issues

OK, done.

https://github.com/matplotlib/matplotlib/issues/5163
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: matplotlib timer

2015-10-01 Thread Dave Farrance
Laura Creighton  wrote:

>In a message of Thu, 01 Oct 2015 17:36:50 +0100, Dave Farrance writes:
>>I'm trying to set up the basics of a timer-scheduled function in
>>matplotlib and I can't figure out how to stop the timer. Maybe the
>>stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the
>>syntax wrong.
>>
>>If anybody's got matplotlib installed, can you try this code and tell me
>>if it stops after one tick as it should -- or does it continue printing
>>every second without stopping as mine does?
>>
>>#!/usr/bin/env python
>>import matplotlib.pyplot as P
>>def fn():
>>  timer.stop()
>>  print("tick")
>>fig, ax = P.subplots()
>>timer = fig.canvas.new_timer(interval=1000)
>>timer.add_callback(fn)
>>timer.start()
>>P.show()
>> 
>
>debian unstable
>Python 3.4.3+ (default, Jul 28 2015, 13:17:50)
>
>mine ticks forever, too.

Thanks. I've just figured out how to stop the timer.

replace "timer.stop()" with
timer.single_shot = True

Yet the documentation says that it's mandatory for the GUI backend base
to implement stop() but that single_shot is optional. Ho hum.

http://matplotlib.org/api/backend_bases_api.html#matplotlib.backend_bases.TimerBase
-- 
https://mail.python.org/mailman/listinfo/python-list


matplotlib timer

2015-10-01 Thread Dave Farrance
I'm trying to set up the basics of a timer-scheduled function in
matplotlib and I can't figure out how to stop the timer. Maybe the
stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the
syntax wrong.

If anybody's got matplotlib installed, can you try this code and tell me
if it stops after one tick as it should -- or does it continue printing
every second without stopping as mine does?

#!/usr/bin/env python
import matplotlib.pyplot as P
def fn():
  timer.stop()
  print("tick")
fig, ax = P.subplots()
timer = fig.canvas.new_timer(interval=1000)
timer.add_callback(fn)
timer.start()
P.show()
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pygame basic question

2015-09-08 Thread Dave Farrance
"ast"  wrote:

>DISPLAYSURF = pygame.display.set_mode((400, 300))
>pygame.display.set_caption('Hello World!')
>
>The first line opens a 400x300 pygame window.
>The second one writes "Hello World" on top of it.
>
>I am just wondering how function set_caption finds the windows
>since the window's name DISPLAYSURF  is not passed as
>an argument

https://www.pygame.org/docs/ref/display.html

As it says, there is only *one* display surface, and any non-displayed
surface must be blitted (copied) onto the display surface for
visibility.  So all "pygame.display" methods refer to that one display
surface.  Non displayed surfaces, on the other hand, do need to be
instantiated with "pygame.Surface"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "no module named kivy" import error in ubuntu 14.04

2015-08-16 Thread Dave Farrance
shiva upreti  wrote:

>Hi
>I am new to linux. I tried various things in attempt to install kivy. I 
>installed python 2.7.10

Just to make clear what others have said -- replacing Ubuntu 14.04's
system Python 2.7.6 is a bad idea and will break stuff, so if you really
must have the latest version of Python2, then you install it separately,
leaving the system Python in place. That in turn means that you can no
longer use Ubuntu's normal method of installing libraries via its own
software management.

> Then i downloaded kivy from
> https://pypi.python.org/packages/source/K/Kivy/Kivy-1.9.0.tar.gz

I suggest that you DON'T install from tarfiles unless your understanding
of Python is of near python-developer level. You really need to know
what you're doing regarding dependencies and the search path for
modules.

If you do want to install a separate instance of the latest version of
Python, then the PIP package management is best, and use it to install
the libraries separately, NOT in the /usr/ directory -- see the other
posts. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I'm a newbie and I'm still stumped...

2015-08-03 Thread Dave Farrance
Dwight GoldWinde  wrote:

>Here are the results I got below, showing the same error. The first line
>says, 
>"2.7.6 (default, Sep 9 2014, 15:04:36)”. Does that mean I am running the
>old Python? How could that be since I am SURE I downloaded 3.4.3 (it even
>gives the folder name as “Python 3.4” in the Applications folder on my Mac.

Yes, that's Python2.  I've never used MAC OS, but I understand that it
has the BASH shell, so you can use "which" try to figure out where
python is being found on the path:

$ echo $PATH

$ which python

Use the above to also check for the position of python2 and python3.

You can check for aliases and links with the "type" and "file" commands.
Do this for python, python2 and python3:

$ type $(which python)

$ file $(which python)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to Calculate NPV?

2015-07-30 Thread Dave Farrance
ryguy7272  wrote:

>PERFECT!!  SO SIMPLE!!
>I don't know why the author didn't do that in the book.

The book is evidently giving you code snippets to enter into Python's
own interactive interpreter, i.e., you enter "python" at the command
line, then you manually type each command which immediately displays any
returned value.  I assume that the book shows each command with three
chevrons ">>>" in front of them.  If you're using Spyder then you need
to enter the commands into its interactive interpreter (which I think is
bottom right). It sounds, instead, as though you're using Spyder's text
editor to create a file containing the commands, and then using the
"run" icon to run the file -- which is maybe skipping ahead because the
book hasn't told you how to do that yet (?). If you do skip ahead, the
book probably has a forthcoming chapter called "writing programs with a
text editor" or something.  I'd guess from the code snippets that you've
shown us that the book is finance oriented, and the author seems to be
more interested in introducing the features useful for finance than
teaching the basics of Python.  Maybe you should search out a simple
Python primer on the web, work through that, and only then return to
your book.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to construct matrix from vectors?

2015-06-21 Thread Dave Farrance
Fabien  wrote:

>another solution with less "(([[]]))", and less ";". There are way too 
>many ";" in Matlab ;)
>
>import numpy as np
>v1 = [1, 2, 3]
>v2 = [4, 5, 6]
>v3 = [7, 8, 9]
>v4 = [10, 11, 12]
>np.hstack([[v1, v2], [v3, v4]]).T
>Out[]:
>array([[ 1,  4],
>[ 2,  5],
>[ 3,  6],
>[ 7, 10],
>[ 8, 11],
>[ 9, 12]])

Neat. And if the OP wants "vectors" in np array form to start with, and
to stack them together without transposing at that point, he could do it
like this:

>>> v1=np.vstack([1,2,3])
>>> v2=np.vstack([4,5,6])
>>> v3=np.vstack([7,8,9])
>>> v4=np.vstack([10,11,12])
>>> np.r_[np.c_[v1,v2],np.c_[v3,v4]]
array([[ 1,  4],
   [ 2,  5],
   [ 3,  6],
   [ 7, 10],
   [ 8, 11],
   [ 9, 12]])

And since he seems to want a Matlab-like environment, then the somewhat
depreciated pylab was intended to dump a Matlab-like set of functions
into the namespace, which is OK for an interactive environment, an not
too much of a problem for a short program in a single module. Probably
best to do that with iPython, though.

>>> from matplotlib.pylab import *
>>> v1=vstack([1,2,3])
>>> v2=vstack([4,5,6])
>>> v3=vstack([7,8,9])
>>> v4=vstack([10,11,12])
>>> r_[c_[v1,v2],c_[v3,v4]]
array([[ 1,  4],
   [ 2,  5],
   [ 3,  6],
   [ 7, 10],
   [ 8, 11],
   [ 9, 12]])

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


Re: Can Python function return multiple data?

2015-06-05 Thread Dave Farrance
Rustom Mody  wrote:

>On Saturday, June 6, 2015 at 10:20:49 AM UTC+5:30, Steven D'Aprano wrote:
>> On Sat, 6 Jun 2015 01:20 pm, Rustom Mody wrote:
>> > As a parallel here is Dijkstra making fun of AI-ers use of the word
>> > 'intelligent'
>> >  http://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/EWD618.html
>> 
>> Nice rant, but as is typical of so many rants by Dijkstra, it's overflowing
>> with smugness at his own cleverness, and very light on actual reasoning or
>> sense.
>
>The cleverness and smugness has made you miss the point:
>Post-computers 'intelligent' has a new meaning on account of abuse of langauge

Hmm.  I've just read that and I have to say that I've no idea what point
the author was trying to make -- presumably because I'm not intelligent
enough.  I get that he's doing his best to make "Artificial
Intelligentsia" a pejorative term for some reason, but exactly what he's
got against this (imagined?) community or exactly what he imagines their
sin to be is hard to figure out.  I'll note that my own observation of
the common usage of the term "intelligent" in the mentioned context is
that you might indeed describe a terminal an "intelligent terminal" if
it has processor functions, but if you were to describe it as a
"terminal with artificial intelligence", then that would imply a whole
lot more -- which is indeed a language oddity, but that seems to be the
way it is now.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Zero [was Re: What is considered an "advanced" topic in Python?]

2015-06-01 Thread Dave Farrance
Skip Montanaro  wrote:

>P.S., Dave, your "omitthis" and "andthis" kind of sucks for the rest of us.
>And I just invalidated your attempts at
>obscurity by replying to your correct email address. I suggest you just
>omit that stuff going forward. Unfortunately,
>I now I have a crap address in my Gmail contacts I have to hunt down and
>remove. Maybe you should just install
>a decent spam filter  or switch to Gmail, which
>has a functioning spam filter (unlike Yahoo...)

I've had that as my Usenet address since 2000 when Usenet was the prime
spam harvesting source and the spammers were actively using
anti-address-munging techniques.  That's no longer so much of a problem,
given Usenet's obscurity for today's average Internet user, but I'm
still wary of posting email addresses directly to Usenet.  I've changed
the "from" address to end with ".invalid" which is the RFC way, and
should be stopped at the Email client, if that helps.

Since this is "comp.lang.python", I'm assuming that it should be treated
primarily as a Usenet group in which you'd normally reply to the group
-- rather than by personal email as you might do if this was primarily a
Listserv group.  I dunno what the group thinks about that.  A quick
header check tells me that the posters here are split about 50/50
between posting via Usenet or the list server.
  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Zero [was Re: What is considered an "advanced" topic in Python?]

2015-06-01 Thread Dave Farrance
Steven D'Aprano  wrote:

>On Mon, 1 Jun 2015 07:36 pm, Marko Rauhamaa wrote:
>
>> However, I constantly run into engineers who don't understand what
>> zero means.
>
>Okay, I'll bite.
>
>What does zero mean, and how do engineers misunderstand it?

There are two hard things in computer science: cache invalidation,
naming things, and off-by-one errors.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is considered an "advanced" topic in Python?

2015-06-01 Thread Dave Farrance
Laura Creighton  wrote:

>If you are giving a talk about Decimal -- and trying to stamp out the
>inappropriate use of floats you have to first inform people that
>what they learned as 'decimals' as children was not floating point,
>despite the fact that we write them the same way. ...

To be fair, prior to electronic computers, they were essentially
synonymous.  It's a bit like finance experts chiding people for mixing
"cost" with "price".

>>> Decimal('0.3')
Decimal('0.3')
>>> Decimal(0.3)
Decimal('0.299988897769753748434595763683319091796875')
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Minus operator versus unary minus

2015-05-30 Thread Dave Farrance
Peter Otten <__pete...@web.de> wrote:

>so both +0.0 and -0.0 would be skipped anyway.

Maybe the coder was simply aiming for visibility.  The unary minus can
be hard to spot in some circumstances.  e.g.: I've sneaked a unary minus
into this maths proof, which makes it horrible (although correct):

u and v are vectors (so have an anti-commutative cross-product)
Show that (u - v) x (u + v) = 2u x v

u x (u + v) - v x (u + v)
u x u + u x v - v x u - v x v
u x v - v x u  [ because u x u = 0, v x v = 0]
u x v - (u x -v)
u x v - (-1)(u x v)
u x v + u x v
2(u x v)
2u x v
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Survey -- Move To Trash function in Python?

2015-05-14 Thread Dave Farrance
Steven D'Aprano  wrote:

>I'd like to do a little survey, and get a quick show of hands.
>
>How many people have written GUI or text-based applications or scripts where
>a "Move file to trash" function would be useful?
>
>Would you like to see that in the standard library, even if it meant that
>the library had feature-freeze and could gain no more functionality?

It's bad enough when things are filesystem-dependent but this is
OS-dependent or even desktop-version-dependent in the case of Linux
distros, so not easy.

E.g. in the case of KDE4, the command-line is:
$ kioclient move  trash:/

...and for KDE3 it was:
$ kfmclient  move  trash:/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Best GUI for Python

2015-04-28 Thread Dave Farrance
Christian Gollwitzer  wrote:

>Yes, the default theme is terrible on Linux (Mac & Windows uses native 
>widgets). There are additional themes available, which are buried in 
>some packages and a bit difficult to install, but give reasonable 
>approximations to the QT look; I'm talking about plastik, for instance 
>http://wiki.tcl.tk/24094 (1st picture - the layout of the test is 
>terrible, but the widgets do look good). For some reason I've got no 
>insights, these themes are very slow (they are based on displaying 
>pre-rendered PNG images for the widget bits and pieces).
>Yet another possibility are the tileQT and tileGTK packages, which 
>render the widgets using QT and GTK, but of course this introduces these 
>dependencies and it might be simpler to just use QT or GTK natively.

Yes, in the case of a more complex control-panel interface, it becomes
worthwhile to design it with a GUI designer like Glade anyway, so that
would give it the "gi" GTk3 widget set which looks fine.

Tkinter is OK if you want to make something utilitarian like an
oscilloscope interface and it does seem to be the easiest way to build
an interface without a GUI builder.

Kivy isn't bad, being fairly easy to use without a GUI designer, and
having a modern flat smartphone-style widget set, if you like that sort
of thing. You're expected to give the buttons logos and different
colours.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Matplotlib] Ploting an exponential distribution frequency curve

2015-04-26 Thread Dave Farrance
Mario Figueiredo  wrote:

>Other than replacing the random module with the probability density
>function for the exponential distribution, do you have a suggestion of
>how I could smooth the curve?

Moving average. Try:

def movingaverage(interval, window_size):
window= numpy.ones(int(window_size))/float(window_size)
return numpy.convolve(interval, window, 'same')

y_av = movingaverage(y,10)

Note that you'd get problems at the start and end of the curve if it's
non-zero there, which is difficult to avoid with noise-reduction.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python as shell

2015-04-22 Thread Dave Farrance
Cecil Westerhof  wrote:

>I am working again with Python and I am impressed again. ;-)
>
>I thought there was a Python shell that could be used instead of Bash
>(or whichever shell you are using), but I can not find anything about
>it. Am I wrong, or are my search engine skills so bad?

You're probably thinking of IPython which has some shell-like commands,
like ls and cd, and you can execute system commands by prefixing them
with "!".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem running Python 2.7 on Ubuntu 10.04

2015-04-20 Thread Dave Farrance
David Aldrich  wrote:

>Hi
>
>I wonder if someone could help me with this problem please?
>
>On an Ubuntu 10.04 platform, I want to run the latest version of Meld, which 
>is a Python program.
>
>Ubuntu 10.04 runs Python 2.6 as standard.  Meld requires Python 2.7.  So I 
>have installed Python 2.7 under /usr/local/bin and Python 2.7 runs ok there.
>
>But when I try to run Meld I see:
>
>-> /usr/local/bin/python2.7 ~/meld/bin/meld
>Cannot import: GTK+
>No module named gi

My understanding is that "gi" is GTk3 and I suspect that you're not
going to successfully install that on Ubuntu 10 which is a GTk2 distro.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: find all multiplicands and multipliers for a number

2015-04-11 Thread Dave Farrance
$ python2
Python 2.7.8 (default, Oct 20 2014, 15:05:19) 
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 256
>>> b = 256
>>> a is b
True
>>> a = 257
>>> b = 257
>>> a is b
False
>>> 

It's not safe to use 'is' to compare integers.

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


Re: Newbie looking for elegant solution

2015-03-24 Thread Dave Farrance
otaksoftspamt...@gmail.com wrote:

>I have a list containing 9600 integer elements - each integer is either 0 or 1.
>Starting at the front of the list, I need to combine 8 list elements into 1 by 
>treating them as if they were bits of one byte with 1 and 0 denoting bit 
>on/off (the 8th element would be the rightmost bit of the first byte).
>The end result should be a new list that is 8 x shorter than the original list 
>containing integers between 0 and 255.
>Speed is not of utmost importance - an elegant solution is. Any suggestions?
>Thanks for all input,

Here's another way. Works in Python 2 and 3.

>>> x = [1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1]
>>> [int(''.join( str(y) for y in x[z:z+8]),2) for z in range(0, len(x), 8)]
[177, 105, 117]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python+Glade+Gtk tutorial?

2015-03-17 Thread Dave Farrance
Jason Heeris  wrote:

>In terms of toolkit bindings, (a) I prefer GTK, but (b) it's impossible to
>tell what the greater proportion of people using one vs. the other is. Or
>if they're wise to do so. Are there more Google hits/SO questions because
>it's harder to use? Or because everyone loves to use it? (And so on...)
>
>A recent comment on my SO answer to a similar question claims PyQT/PySide
>is a good way to go, with a couple of links there you might find
>interesting: http://stackoverflow.com/a/3290724/188535
>
>I wouldn't stress over it though; you can give yourself a headache trying
>to decide between frameworks you've never developed in. Try one, commit to
>developing at least some proficiency in it, and then try the other.

OK, thanks.  I'll continue with Glade for now, and maybe try PyQT another
time.  Thanks for your answers to my questions.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python+Glade+Gtk tutorial?

2015-03-16 Thread Dave Farrance
In the past, I've used Visual-C++ for creating dialog-based interfaces for
controlling equipment and displaying data, and I'm looking for something
of similar ease-of-use in Python since that's now my preferred language.
A web-search told me that Glade seems to be most peoples choice (over
QT-Designer) for a GUI builder.  So even though I use a KDE desktop
(Kubuntu 14.10), I decided to try Glade.

So I web-searched for a Glade "hello world" example to get me started. The
top Google hit for that gave me a tutorial that only took a short time to
work through, and did convince me of Glade's ease-of-use, but the Python
code crashed.  Searching on the error-message told me that I needed to
select Glade's "libglade" output format instead of its "gtkbuilder" output
format to work with that tutorial.  Glade doesn't offer that option any
more -- you just get XML for "gtkbuilder".

So... I searched on "gtkbuilder hello world", which gave me the "Python
GTK+3 Tutorial" at readthedocs.org, and the Python code examples there
gave a somewhat different syntax, from which I was able to figure out how
to fix the tutorial, and then the code worked fine.

So am I understanding this correctly:  If I use this include line:

"from gi.repository import Gtk, Gdk, GObject, Pango" etc...

... I get, in effect, the libraries used in Gnome-3 even with python2?
Whatever "gi.repository" is?  It's a bit hard to figure this out from the
complexity of differing versions that I've turned up from Google searches.

Am I on the right track now?  Glade is a good choice for GUI building? And
even though I'm using Python2, I should be ignoring all examples turned up
by searching for "PyGTK" because they all seem to be GTK+2 and obsolete?
Is that "Python GTK+3 Tutorial" as good as any for me to work through?

https://python-gtk-3-tutorial.readthedocs.org/en/latest/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PSF news - BBC launches MicroBit

2015-03-15 Thread Dave Farrance
Mark Lawrence  wrote:

>http://pyfound.blogspot.co.uk/2015/03/bbc-launches-microbit.html may be 
>of interest to some of you.

"Python is one of the three languages that work with the device."

That's cool, and the article says that the Raspberry Pi Foundation is
involved in creating learning content for it, which I presume would
emphasise Python, given that Python was the RPi Foundation's first choice
for controlling the Pi. The RPi has helped to raise the profile of Python,
so hopefully this new device will add to that.

I wonder what the other two languages are?  I'd guess a C++ subset for
one, like the Arduino.  Not sure about the other.  HTML/Javascript is
becoming popular in education because it's the easiest way put shapes and
animation on the screen, but I don't think it's suited to an embedded
device.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do not run this code.

2015-03-04 Thread Dave Farrance
Ben Finney  wrote:

>Chris Angelico  writes:
>
>> import base64; exec(…)
>
>That's all I need to know. Code with ‘exec()’ calls, I consider unsafe
>by default.

Indeed. replacing exec with print...

>>> print(base64.b64decode(b"eD0neD0lcjsgZXhlYyh4JSV4KSc7IGV4ZWMoeCV4KQ=="))
x='x=%r; exec(x%%x)'; exec(x%x)

so, discarding that second exec...

>>> x='x=%r; exec(x%%x)'
>>> print(x)
x=%r; exec(x%%x)

So it recurses, and if that second exec had been left in then it would be
a fork bomb.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of Pypy?

2015-02-23 Thread Dave Farrance
Dave Cook  wrote:

>On 2015-02-22, Dave Farrance  wrote:
>
>> It's still quicker to do a re-write in the more cumbersome C
>
>You should try Cython.

I did try Cython when I was trying to figure out what to do about the slow
speed.  My initial attempt showed no speedup at all.  The documentation
told me that I needed to change the data types to special C-like types, so
it seemed to me that it would become half way between Python and C and
would be as cumbersome to develop as C.  So at that point, I just rewrote
it in C.

Anyway, now that I've been told how to install libraries in PyPy, I'll
probably be able to use PyPy if I need speedups in future.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of Pypy?

2015-02-23 Thread Dave Farrance
Laura Creighton  wrote:

>Good news  -- it seems to be working fine with PyPy.
>https://travis-ci.org/hugovk/Pillow/builds
>
>for me, not extensively tested, it just seems to be working.
>
>I have several pypy's floating around here, each within its own
>virtualenv.  If you aren't familiar with virtualenv, read all
>about it here:
>http://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/

OK, thanks. I had to do a bit of experimenting to find something that
worked.  The "virtualenv" that came with Ubuntu failed in various ways if
used with PyPy.  But after downloading this and that via the PyPy download
webpage, I found that "Squeaky's portable Linux binaries" contained
'virtualenv-pypy' which worked OK, then Pillow installed OK with "pip".

It does seem that the PyPy that you get from the Ubuntu repository (and
presumably as packaged in most Linux distros) is rather limited.  Other
than the core libraries included with the PyPy package itself, all that's
in the repository for PyPy is Tk and an ImageMagick interface and that's
it.  CPython, on the other hand, has more repository packages than I can
count -- hundreds, I think.  So as a non-developer linux-user, I had just
installed Python packages from the repository, rather than using pip, as
would most linux users I would guess.  So that's why I got the impression
that PyPy had almost no library support.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of Pypy?

2015-02-22 Thread Dave Farrance
Dave Farrance  wrote:

>Steven D'Aprano  wrote:
>
>>I assume you're talking about drawing graphics rather than writing text. Can
>>you tell us which specific library or libraries won't run under PyPy?
>
>Yes, mainly the graphics.  I'm a hardware engineer, not a software
>engineer, so I might well be misunderstanding PyPy's current capability.
>
>For easy-to-use vector graphics output, like 1980s BASIC computers, I've
>settled on Pygame.  CPython libraries that I've used for other reasons
>include Scipy, Matplotlib, PIL, CV2, and Kivy.

I see that PyPy's website says that PIL (Pillow) works.  I have so far
only used Python libraries that were readily available as binaries for
Windows, or were already available in Linux distro repositories.  In
Ubuntu, for example, Pillow is available for CPython but not PyPy.  Is
there a guide to tell me (in non-developer language, hopefully) how to
install Pillow for PyPy on Ubuntu?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of Pypy?

2015-02-22 Thread Dave Farrance
Steven D'Aprano  wrote:

>I assume you're talking about drawing graphics rather than writing text. Can
>you tell us which specific library or libraries won't run under PyPy?

Yes, mainly the graphics.  I'm a hardware engineer, not a software
engineer, so I might well be misunderstanding PyPy's current capability.

For easy-to-use vector graphics output, like 1980s BASIC computers, I've
settled on Pygame.  CPython libraries that I've used for other reasons
include Scipy, Matplotlib, PIL, CV2, and Kivy.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of Pypy?

2015-02-22 Thread Dave Farrance
Laura Creighton  wrote:

>I don't understand 'an interpreter rather than a JIT'.  PyPy has a
>JIT, that sort of is the whole point.

Yes.  I meant that from my end-user, non-software-engineer perspective, it
looked as though CPython was proceeding with leaps and bounds and that
PyPy remained mostly a proof-of-concept after several years.

But thanks for your description of the issues.  So once the core issues
are sorted out, if enough people can be found to work on it, then
hopefully the library conversions will follow apace.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Future of Pypy?

2015-02-22 Thread Dave Farrance
jkn  wrote:

> I'm curious what ...behavioural... models you are creating quickly in
> Python that then need rewriting in C for speed. SPICE? some other CAD?
> Might be interesting to learn more about what and how you are actually
> doing.

The convert-to-C cases were complex filtering functions.  I do make good
use of spice-based tools, but I often find it useful to make a more
abstract model, usually before completing the design.  This helps with
component selection, finalizing the design, and making sure that I
understood the what the circuit would do.

I started work 1980ish, had an early 6502-based home computer, and my then
place of work had some 6502-based Pet computers, so I gained the ability
to quickly write BASIC programs as an engineering aid.  Later, when BASIC
dropped into obscurity, I switched to C and C++, although I always found
that cumbersome compared to the old BASIC.  Later still, when I found that
my Google queries for code examples started returning more Python than C,
I tried that -- and discovered that Python was like BASIC, only better.

But that's just me.  Other hardware engineers use a variety of modeling
applications.  Or don't need to because they're just that clever?  Or they
give the modeling work to system engineers who will use whatever apps that
system engineers use, and will return a result a few weeks later.
Personally, I've tended to get used to writing code in just one
general-purpose language, and it seems to me that I get a useful result
relatively quickly.

> How about running your front end (simulation) work in PyPy, and the
> backend display work on CPython, if there are some missing features in
> PyPy that you need. This may be more or less easy depending on your
> requirements and any intermediate format you have.

Maybe I should look at that again.  In the case of the filter models,
their usefulness had grown to the point that requiring support by other
people was a possibility, so converting them to C seemed better than
writing something that bridged between two language implementations.

> Or you could offer to assist in the PyPy porting? Or express an interest
> in specific libraries being ported?

I'm a hardware engineer not a software engineer, so I have to plead lack
of ability there.  I do appreciate the work that's done on Python, and
have to be grateful for what is available, since I'm not paying for it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Future of Pypy?

2015-02-22 Thread Dave Farrance
As an engineer, I can quickly knock together behavioural models of
electronic circuits,  complete units, and control systems in Python, then
annoyingly in a few recent cases, have to re-write in C for speed.

I've tried PyPy, the just-in-time compiler for Python, and that is
impressively, hugely fast in comparison, but it's no good making these
models if I can't display the results in a useful way, and at the moment
PyPy just doesn't have the huge range of useful time-saving libraries that
CPython has.  It's still quicker to do a re-write in the more cumbersome C
than try to work with PyPy because C, like CPython, also has many useful
libraries.

A few years back, I recall people saying that PyPy was going to be the
future of Python, but it seems to me that CPython still has the lion's
share of the momentum, is developing faster and has ever more libraries,
while PyPy is struggling to get enough workers to even get Numpy
completed.

Maybe there's not enough people like me that have really felt the need for
the speed.  Or maybe it's simply the accident of the historical
development path that's set-in-stone an interpreter rather than a JIT.
Anybody got a useful perspective on this?
-- 
https://mail.python.org/mailman/listinfo/python-list