Re: Efficient handling of fast, real-time hex data

2016-06-02 Thread alister
On Thu, 02 Jun 2016 18:50:34 +1200, Gregory Ewing wrote:

> [email protected] wrote:
>> One common data transmission error I've seen in other systems is
>> added/dropped bytes. I may add a CRC-8 error-checking byte in place of
>> the newline.
> 
> Also maybe add a start byte with a known value at the beginning of each
> packet to help resynchronise if you get out of step.

No maybe about it
if you are sending a binary stream you need to be able to reliably signal 
the start AND finish of the data stream (either send the length in the 
message start or have a fixed msg. length)

after a lot of experimenting to ensure reliability you will probably have 
reinvented something like intelhex or x-modem



-- 
The work [of software development] is becoming far easier (i.e. the tools
we're using work at a higher level, more removed from machine, peripheral
and operating system imperatives) than it was twenty years ago, and 
because
of this, knowledge of the internals of a system may become less 
accessible.
We may be able to dig deeper holes, but unless we know how to build taller
ladders, we had best hope that it does not rain much.
-- Paul Licker
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiple inheritance, super() and changing signature

2016-06-02 Thread Lawrence D’Oliveiro
On Wednesday, June 1, 2016 at 8:02:14 AM UTC+12, Ben Finney wrote:
> (Note that ‘__init__’ is not a constructor, because it operates on the
> *already constructed* instance, and does not return anything.

Believe it or not, that *is* what “constructor” means in every OO language. 
Technically it should be called the “initializer”, but “constructor” is the 
accepted term for the special method that is called to initialize a 
newly-allocated class instance.

> Python's classes implement the constructor as ‘__new__’, and you very rarely
> need to bother with that.)

Python’s “__new__” goes beyond the capabilities of “constructors” in 
conventional OO languages.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] Python 3.6.0a1 is now available

2016-06-02 Thread Lawrence D’Oliveiro
On Tuesday, May 24, 2016 at 8:10:48 PM UTC+12, Terry Reedy wrote:
> I don't know what will happen if 'Windows 10' continues indefinitely, 
> even as it mutates internally.

As Microsoft adds more and more Linux APIs, maybe you could migrate to using 
those. ;)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Do you think a DB based on Coroutine and AsyncIO is a good idea? I have written a demo on GitHub.

2016-06-02 Thread Lawrence D’Oliveiro
On Thursday, May 26, 2016 at 8:56:44 AM UTC+12, [email protected] wrote:
> I think in-process DB is quite popular in less serious development, e.g. 
> SQLite.

“less serious”!? It’s the world’s most popular DBMS! There’s likely a copy in 
your pocket or purse right now.
-- 
https://mail.python.org/mailman/listinfo/python-list


Storing data in mysql

2016-06-02 Thread Anup reni
How to store this 3 dimensional data in Mysql database for plotting on map?
​
-- 
https://mail.python.org/mailman/listinfo/python-list


Recommendation for GUI lib?

2016-06-02 Thread Jan Erik Moström
I want to write a few programs with a GUI but I don't want to use Tk. 
Instead I'm looking for some other library, I've tried to look around 
and also asked a few but I don't really know what to use.


Do you have any recommendations? Primary platforms are OS X and Linux.

I, of course, want to have "standard" widgets but a "calendar 
view"/"date picker" is a plus.


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


2d matrix into Nx3 column data

2016-06-02 Thread Anup reni
i would like to transform this:

  -1 0-0.8  0.64 -0.36-0.4  0.16 -0.84
 0.0 0 -1.00
 0.4  0.16 -0.84
 0.8  0.64 -0.36

to something like this:

 x  y  result
id1  -0.8 -10.642  -0.8  0   -0.363  -0.4 -1
0.164  -0.4  0   -0.845   0.0 -10.006   0.0  0   -1.007   0.4 -1
 0.168   0.4  0   -0.849   0.8 -10.6410  0.8  0   -0.36
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to create development Python environment on Linux.

2016-06-02 Thread Marc Brooks
I am pretty sure (but not 100%) that the pip that virtualenv installs when
it first creates the virtualenv is the version of pip installed on the
system.  Here's the process I used to bootstrap a new Python 2.7 dev
environment.

1. Download and install the latest version of pip as sudo so it's system
wide.
2. Install virtualenv and virtualenvwrapper (a collection of utilities
scripts/aliases for virtualenv).
3. Update my .bash_profile to source the virtualenvwrapper script.

Then for any new virtualenvs I just type 'mkvirtualenv '

I can update the version of pip in the virtualenv or run pip install for
any of my required libraries at that point.  One wrinkle that can come up
is if you want to use virtualenvwrapper and you are not using bash.  Fish
(another moderately popular shell) has an addon that mimics the macros that
virtualenvwrapper provides.

Mar

On Wed, Jun 1, 2016 at 8:17 PM, Lawrence D’Oliveiro 
wrote:

> On Tuesday, May 17, 2016 at 4:26:23 AM UTC+12, Zachary Ware wrote:
> > Not what you asked for, but I would encourage you to look into whether
> > it's possible for you to use Python 3 instead of Python 2 for what
> > you're doing.  If it's possible, starting with Python 3 will save you
> > several headaches in the future.
>
> Let me add my vote for this.
>
> > sys.prefix is baked in at compile time of the python interpreter ...
>
> ldo@theon:~> ~/virtualenv/jupyter/bin/python -c "import sys;
> print(sys.prefix)"
> /home/ldo/virtualenv/jupyter
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Just for fun: creating zombies with Python

2016-06-02 Thread Steven D'Aprano
Just for fun, I thought I'd create some zombie processes using Linux.

(This will probably only work on POSIX-compliant operating systems. I don't 
know that Windows has zombies.)

I started with the C code given here:

https://en.wikipedia.org/wiki/Zombie_process#Examples

and re-wrote it into Python:


steve@runes:~$ cat zombie.py 
import os, sys, time
pids = [None]*10
for i in range(9, -1, -1):
pids[i] = os.fork()
if pids[i] == 0:
time.sleep(i+1)
os._exit(0)
for i in range(9, -1, -1):
os.waitpid(pids[i], 0)



If you run that script on Linux, and watch the process list using (say) top, 
you will see the number of zombies grow up to a maximum of nine, then drop back 
down to (hopefully) zero.


-- 
Steve

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


Re: Just for fun: creating zombies with Python

2016-06-02 Thread Lawrence D’Oliveiro
On Thursday, June 2, 2016 at 8:57:13 PM UTC+12, Steven D'Aprano wrote:
> os.waitpid(pids[i], 0)

One of the first lessons you learn, when messing about with spawning processes 
on Linux(-compatible) systems in languages other than a shell, is

ALWAYS GOBBLE YOUR ZOMBIE CHILDREN!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Efficient handling of fast, real-time hex data

2016-06-02 Thread Gene Heskett
On Thursday 02 June 2016 04:13:51 alister wrote:

> On Thu, 02 Jun 2016 18:50:34 +1200, Gregory Ewing wrote:
> > [email protected] wrote:
> >> One common data transmission error I've seen in other systems is
> >> added/dropped bytes. I may add a CRC-8 error-checking byte in place
> >> of the newline.
> >
> > Also maybe add a start byte with a known value at the beginning of
> > each packet to help resynchronise if you get out of step.
>
> No maybe about it
> if you are sending a binary stream you need to be able to reliably
> signal the start AND finish of the data stream (either send the length
> in the message start or have a fixed msg. length)
>
> after a lot of experimenting to ensure reliability you will probably
> have reinvented something like intelhex or x-modem
>
Neither of which can handle that last packet well unless the last packet 
is padded out to be a fill packet and the filler bytes thrown away in 
the receiver.

For that reason alone, zmodem wins because it does both..

zmodem in its present linux implementation must have in window size set 
explicitely on the invocation command line to match the default packet 
size of the receiving device, which is usually the size of its disk 
sector.  That way, when its talking to rzsz on a 256 byte sector box, it 
will be forced to do the checksum checks to match what rzsz can do.

Otherwise the linux version of zmodem will only check the checksums every 
8 kilobytes.  That of course will fail if the line speed overruns the 
receiver, and of course the receiver is sending error restart requests, 
not a good way to make any real speed.  My target box is running nitros9 
and somehow bit rot has destroyed the 7 wire protocol flow controls, so 
I have to restrict the data rate to 4800 baud.  Doing both the window 
size limit and the low baud rate, I have moved an 80 track disk image 
built on this machine, to that machine without any errors several times. 
Slow, and hard on the coffee pot staying awake while effectively 
watching paint dry, but it worked.

Now we have a better method that works at 112 kbaud, much better.  You 
can load a program direct from a virtual disk image "mounted" for use 
with disk descriptors that point at the disk image on this hard drive at 
a load speed approaching loading it from a real floppy on that machine. 

> The work [of software development] is becoming far easier (i.e. the
> tools we're using work at a higher level, more removed from machine,
> peripheral and operating system imperatives) than it was twenty years
> ago, and because
> of this, knowledge of the internals of a system may become less
> accessible.
> We may be able to dig deeper holes, but unless we know how to build
> taller ladders, we had best hope that it does not rain much.
>   -- Paul Licker

Paul is absolutely correct.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recommendation for GUI lib?

2016-06-02 Thread John Pote

On 01/06/2016 18:13, Jan Erik Moström wrote:

I want to write a few programs with a GUI but I don't want to use Tk. 
Instead I'm looking for some other library, I've tried to look around 
and also asked a few but I don't really know what to use.
I've used wxPython (www.wxpython.org) for a few GUI projects and found 
it ok. It's a wrapper for the wxWidgets C++ library. There's even a 
reasonable free GUI builder, wxGlade, which I use as I prefer 
constructing GUI's that way rather than writing raw wxPython code. Never 
tried any of the paid for GUI builders.
Disadvantage is the download page only provides builds for Python 2.6 or 
2.7.


Does anyone know how Project Phoenix is coming on? 
http://wxpython.org/Phoenix/ItsAlive/ shows wxPython working with Python 
3.2.

Comments on how stable it is and how easy to install would be helpful.
John


Do you have any recommendations? Primary platforms are OS X and Linux.

I, of course, want to have "standard" widgets but a "calendar 
view"/"date picker" is a plus.


= jem


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


Re: Recommendation for GUI lib?

2016-06-02 Thread Nick Sarbicki
>
>
> >
> > Do you have any recommendations? Primary platforms are OS X and Linux.
> >
> > I, of course, want to have "standard" widgets but a "calendar
> > view"/"date picker" is a plus.
>

I generally use PyQt which is one of two (the other being pyside) python
wrappers for the Qt libraries.

PyQt is the only one I know which currently supports Qt5+ so gets my vote.
There are loads of resources around - works well on all operating systems
(with most Qt5 having some focus on mobile). It comes with a ton of
utilities and a really nice GUI editor (
https://en.wikipedia.org/wiki/Qt_Creator).

There are a lot of resources around and, as predicted, already has some
examples of date pickers:

http://www.eurion.net/python-snippets/snippet/Calendar_Date%20picker.html

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


Re: Storing data in mysql

2016-06-02 Thread Ben Finney
Anup reni  writes:

> How to store this 3 dimensional data in Mysql database for plotting on
> map?

You have not asked a question relevant to Python.

You have asked a question much more to do with MySQL. Perhaps take the
discussion to a discussion forum for MySQL instead?

-- 
 \  “I find the whole business of religion profoundly interesting. |
  `\ But it does mystify me that otherwise intelligent people take |
_o__)it seriously.” —Douglas Adams |
Ben Finney

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


Python on Windows with linux environment

2016-06-02 Thread Muhammad Ali

Hi,

I use windows regularly, however, I use linux for only my research work at 
supercomputer. In my research field (materials science) most of the scripts are 
being written in python with linux based system. Could I installed such linux 
based python on my window 7? So that I can use those linux based scripts 
written in python and I can also write my own scripts/code without entirely 
changing my operating system from windows to linux.

Looking for your valuable suggestions.

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


Re: Python on Windows with linux environment

2016-06-02 Thread Oscar Benjamin
On 2 June 2016 at 12:22, Muhammad Ali  wrote:
> I use windows regularly, however, I use linux for only my research work at 
> supercomputer. In my research field (materials science) most of the scripts 
> are being written in python with linux based system. Could I installed such 
> linux based python on my window 7? So that I can use those linux based 
> scripts written in python and I can also write my own scripts/code without 
> entirely changing my operating system from windows to linux.

Python code usually runs the same on Windows as it does on Linux. What
makes you think that you need Linux to run this code?


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


Re: Don't put your software in the public domain

2016-06-02 Thread Steven D'Aprano
On Thu, 2 Jun 2016 04:41 pm, Gregory Ewing wrote:

> Steven D'Aprano wrote:
> 
>> http://linuxmafia.com/faq/Licensing_and_Law/public-domain.html
> 
>  From that:
>> It might be ruled to create a global licence for unrestricted use. That
>  > licence might or might not then be adjudicated to be revocable by
>  > subsequent copyright owners (heirs, divorcing spouses, creditors).
> 
> If that's possible, then could said heirs, divorcing spouses
> and creditors also revoke supposedly permanent rights granted
> under an explicit licence? Or is putting the word "irrevocable"
> in the licence enough to prevent that?

Ask a real lawyer :-)

This is why we should use licences that have been written and vetted by
actual lawyers. They're the experts.



-- 
Steven

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


RE: Python on Windows with linux environment

2016-06-02 Thread Deborah Martin
Try Cygwin at http://www.cygwin.com

Regards,
Deborah

-Original Message-
From: Python-list 
[mailto:[email protected]] On Behalf 
Of Muhammad Ali
Sent: 02 June 2016 12:23
To: [email protected]
Subject: Python on Windows with linux environment


Hi,

I use windows regularly, however, I use linux for only my research work at 
supercomputer. In my research field (materials science) most of the scripts are 
being written in python with linux based system. Could I installed such linux 
based python on my window 7? So that I can use those linux based scripts 
written in python and I can also write my own scripts/code without entirely 
changing my operating system from windows to linux.

Looking for your valuable suggestions.

Thank you.
--
https://mail.python.org/mailman/listinfo/python-list
This e-mail and any files transmitted with it are strictly confidential and 
intended solely for the use of the individual or entity to whom they are 
addressed. If you are not the intended recipient, please delete this e-mail 
immediately. Any unauthorised distribution or copying is strictly prohibited.

Whilst Kognitio endeavours to prevent the transmission of viruses via e-mail, 
we cannot guarantee that any e-mail or attachment is free from computer viruses 
and you are strongly advised to undertake your own anti-virus precautions. 
Kognitio grants no warranties regarding performance, use or quality of any 
e-mail or attachment and undertakes no liability for loss or damage, howsoever 
caused.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Don't put your software in the public domain

2016-06-02 Thread Chris Angelico
On Thu, Jun 2, 2016 at 9:56 PM, Steven D'Aprano  wrote:
> On Thu, 2 Jun 2016 04:41 pm, Gregory Ewing wrote:
>
>> Steven D'Aprano wrote:
>>
>>> http://linuxmafia.com/faq/Licensing_and_Law/public-domain.html
>>
>>  From that:
>>> It might be ruled to create a global licence for unrestricted use. That
>>  > licence might or might not then be adjudicated to be revocable by
>>  > subsequent copyright owners (heirs, divorcing spouses, creditors).
>>
>> If that's possible, then could said heirs, divorcing spouses
>> and creditors also revoke supposedly permanent rights granted
>> under an explicit licence? Or is putting the word "irrevocable"
>> in the licence enough to prevent that?
>
> Ask a real lawyer :-)
>
> This is why we should use licences that have been written and vetted by
> actual lawyers. They're the experts.

I honestly don't see why people want to put their code into the public
domain, when the MIT license is pretty close to that anyway. What's
the point?

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


Re: Recommendation for Object-Oriented systems to study

2016-06-02 Thread Alan Evangelista



On 06/02/2016 02:44 AM, Lawrence D’Oliveiro wrote:

On Monday, May 30, 2016 at 7:17:47 AM UTC+12, Alan Evangelista wrote:

- Java forces everything to be implemented in OO model (classes)
After you have spend a few months battering your head against the rigidity and verbosity of Java, 
you will run back to Python with a sense of relief.


The point was which programming language was better to teach object oriented 
concepts,
rigidity and verbosity has nothing to do with this. Most of this discussion has 
leaned towards
other criteria beyond adherence to OO paradigm (eg static typing vs dynamic 
typing and
personal taste), so I have chosen to not continue it.

For some reason, Java still one of the most used programming languages to teach 
OO
in universities. In real life projects, people has the freedom to choose 
whatever they
prefer, though.  =)


Regards,
Alan Evangelista
--
https://mail.python.org/mailman/listinfo/python-list


Re: EuroPython 2016 Keynote: Paul Hildebrandt

2016-06-02 Thread Omar Abou Mrad
Quick note: blog and conference schedule links in the
europython.eu site's custom 404 page are incorrect.

https://ep2016.europython.eu/en/foobarbaz/

On Tue, May 31, 2016 at 4:22 PM, M.-A. Lemburg  wrote:

> We are pleased to announce our next keynote speaker for EuroPython
> 2016:
>
>
>*** Paul Hildebrandt ***
>
>
>
> About Paul Hildebrandt
> --
>
> Paul Hildebrandt has been a Senior Engineer with Walt Disney Animation
> Studios (WDAS) since 1996, and has worked in both Systems and Software
> engineering. His current title is Senior Software Engineer and Product
> Owner for the Playback tools among his primary duties is spending time
> working with the artists, understanding their needs, and designing
> tools to assist them. If he is lucky, he gets to write code.
>
> Hildebrandt was born and raised in Anaheim, California. He received
> his BSEE with a focus on Computing from California Polytechnic
> University Pomona. He resides outside of Los Angeles with his wife and
> three boys.
>
> The Keynote: Inside the Hat: Python @ Walt Disney Animation Studios
> ---
>
> The Walt Disney Animation Studios has a long history of creating
> acclaimed animated films and continues to be an industry leader with
> regards to artistic achievements, storytelling excellence, and
> cutting-edge innovations. Since the 1923 release of “Snow White”
> they’ve been pushing forward technology in the art of movie
> making. This push continues in the modern day with classics such as
> Oscar winning box office hits “Big Hero 6” and “Frozen” and Oscar
> nominated hits “Wreck-It Ralph”, “Tangled”, “Bolt”, “Treasure Planet”,
> and “Dinosaur”.
>
> One of the most common questions I get when attending Python
> conferences is “Why are you here?”  People seem confused that
> technology, especially Python is used in the making of animated
> films.
>
> Paul will give you some background on the Walt Disney Animation
> Studios and talk about where specifically Python comes into play.
>
>
> With gravitational regards,
> --
> EuroPython 2016 Team
> http://ep2016.europython.eu/
> http://www.europython-society.org/
>
>
> PS: Please forward or retweet to help us reach all interested parties:
> https://twitter.com/europython/status/737633789116088320
> Thanks.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Don't put your software in the public domain

2016-06-02 Thread Marko Rauhamaa
Chris Angelico :

> I honestly don't see why people want to put their code into the public
> domain, when the MIT license is pretty close to that anyway. What's
> the point?

Why did I put my book translation into the public domain (http://pacujo.net/esperanto/literaturo/juho/>)?

Because that's what I felt like doing. If the author has one right to
their work, it is relinquishing all rights to that work. All works will
eventually fall into the public domain anyway; all we are talking about
is the possibility of expediting the inevitable.


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


Re: Efficient handling of fast, real-time hex data

2016-06-02 Thread alister
On Thu, 02 Jun 2016 05:41:40 -0400, Gene Heskett wrote:

> On Thursday 02 June 2016 04:13:51 alister wrote:
> 
>> On Thu, 02 Jun 2016 18:50:34 +1200, Gregory Ewing wrote:
>> > [email protected] wrote:
>> >> One common data transmission error I've seen in other systems is
>> >> added/dropped bytes. I may add a CRC-8 error-checking byte in place
>> >> of the newline.
>> >
>> > Also maybe add a start byte with a known value at the beginning of
>> > each packet to help resynchronise if you get out of step.
>>
>> No maybe about it if you are sending a binary stream you need to be
>> able to reliably signal the start AND finish of the data stream (either
>> send the length in the message start or have a fixed msg. length)
>>
>> after a lot of experimenting to ensure reliability you will probably
>> have reinvented something like intelhex or x-modem
>>
> Neither of which can handle that last packet well unless the last packet
> is padded out to be a fill packet and the filler bytes thrown away in
> the receiver.

The examples quoted were for examples of binary transfer protocols & not 
intended to be an exhaustive list.

> 
>> The work [of software development] is becoming far easier (i.e. the
>> tools we're using work at a higher level, more removed from machine,
>> peripheral and operating system imperatives) than it was twenty years
>> ago, and because of this, knowledge of the internals of a system may
>> become less accessible.
>> We may be able to dig deeper holes, but unless we know how to build
>> taller ladders, we had best hope that it does not rain much.
>>  -- Paul Licker
> 
> Paul is absolutely correct.
> 
> Cheers, Gene Heskett
 like that quote




-- 
Under deadline pressure for the next week.  If you want something, it can 
wait.
Unless it's blind screaming paroxysmally hedonistic...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Don't put your software in the public domain

2016-06-02 Thread Robin Becker

On 02/06/2016 07:41, Gregory Ewing wrote:

Steven D'Aprano wrote:


http://linuxmafia.com/faq/Licensing_and_Law/public-domain.html


From that:

It might be ruled to create a global licence for unrestricted use. That
licence might or might not then be adjudicated to be revocable by subsequent
copyright owners (heirs, divorcing spouses, creditors).

.
I'm surprised the tax man doesn't have a say; if I disclaim any property/right 
in the UK it might be thought of as an attempt to evade death duties, taxes 
always outlive death :(


--
Robin Becker

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


Re: Python on Windows with linux environment

2016-06-02 Thread Paul Rudin
Deborah Martin  writes:

> Try Cygwin at http://www.cygwin.com
>

Or use the new windows subsystem for linux:
https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: EuroPython 2016 Keynote: Paul Hildebrandt

2016-06-02 Thread M.-A. Lemburg
On 02.06.2016 14:25, Omar Abou Mrad wrote:
> Quick note: blog and conference schedule links in the
> europython.eu site's custom 404 page are incorrect.
> 
> https://ep2016.europython.eu/en/foobarbaz/

Thanks. Should be fixed now.

> On Tue, May 31, 2016 at 4:22 PM, M.-A. Lemburg  wrote:
> 
>> We are pleased to announce our next keynote speaker for EuroPython
>> 2016:
>>
>>
>>*** Paul Hildebrandt ***
>>
>>
>>
>> About Paul Hildebrandt
>> --
>>
>> Paul Hildebrandt has been a Senior Engineer with Walt Disney Animation
>> Studios (WDAS) since 1996, and has worked in both Systems and Software
>> engineering. His current title is Senior Software Engineer and Product
>> Owner for the Playback tools among his primary duties is spending time
>> working with the artists, understanding their needs, and designing
>> tools to assist them. If he is lucky, he gets to write code.
>>
>> Hildebrandt was born and raised in Anaheim, California. He received
>> his BSEE with a focus on Computing from California Polytechnic
>> University Pomona. He resides outside of Los Angeles with his wife and
>> three boys.
>>
>> The Keynote: Inside the Hat: Python @ Walt Disney Animation Studios
>> ---
>>
>> The Walt Disney Animation Studios has a long history of creating
>> acclaimed animated films and continues to be an industry leader with
>> regards to artistic achievements, storytelling excellence, and
>> cutting-edge innovations. Since the 1923 release of “Snow White”
>> they’ve been pushing forward technology in the art of movie
>> making. This push continues in the modern day with classics such as
>> Oscar winning box office hits “Big Hero 6” and “Frozen” and Oscar
>> nominated hits “Wreck-It Ralph”, “Tangled”, “Bolt”, “Treasure Planet”,
>> and “Dinosaur”.
>>
>> One of the most common questions I get when attending Python
>> conferences is “Why are you here?”  People seem confused that
>> technology, especially Python is used in the making of animated
>> films.
>>
>> Paul will give you some background on the Walt Disney Animation
>> Studios and talk about where specifically Python comes into play.
>>
>>
>> With gravitational regards,
>> --
>> EuroPython 2016 Team
>> http://ep2016.europython.eu/
>> http://www.europython-society.org/
>>
>>
>> PS: Please forward or retweet to help us reach all interested parties:
>> https://twitter.com/europython/status/737633789116088320
>> Thanks.
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
> 

-- 
Marc-Andre Lemburg
Director
EuroPython Society
http://www.europython-society.org/
http://www.malemburg.com/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Beginner Question

2016-06-02 Thread Marcin Rak
That linked help clear up my confusion...yes you really have to know how things 
work internally to understand why things happen the way they happen.

Thanks again to all

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


Re: Beginner Question

2016-06-02 Thread Igor Korot
Steven,

On Thu, Jun 2, 2016 at 1:20 AM, Steven D'Aprano
 wrote:
> On Thursday 02 June 2016 14:21, Igor Korot wrote:
>
>> Hi, guys,
>>
>> On Wed, Jun 1, 2016 at 9:42 PM, boB Stepp  wrote:
>>> On Wed, Jun 1, 2016 at 7:55 PM, Marcin Rak 
>>> wrote:
 Hi to all

 I have a beginner question to which I have not found an answer I was able
 to understand.  Could someone explain why the following program:

 def f(a, L=[]):
 L.append(a)
 return L

 print(f(1))
 print(f(2))
 print(f(3))

 gives us the following result:

 [1]
 [1,2]
 [1,2,3]

 How can this be, if we never catch the returned L when we call it, and we
 never pass it on back to f???
>>
>> I think the OP question here is:
>>
>> Why it is printing the array?
>
> Because he calls the function, then prints the return result.
>
> print(f(1))
>
> calls f(1), which returns [1], then prints [1].
>
> Then he calls:
>
> print(f(2))
>
> which returns [1, 2] (but he expects [2]), then prints it. And so on.
>
>
>> There is no line like:
>>
>> t = f(1)
>> print t
>
> Correct. But there are lines:
>
> print(f(1))
> print(f(2))
> print(f(3))

I think you missed the point.

Compare:

def f(a, L=[]):
 L.append(a)
 return L

print(f(1))
print(f(2))
print(f(3))

vs.

def f(a, L=[]):
 L.append(a)
 return L

t = f(1)
print t
t = f(2)
print t
t = f(3)
print t

For people that comes from C/C++/Java, the first syntax is kind of weird:
you return a value from the function but the caller does not save it anywhere.
Especially since the return is not a basic type and most of them are
not familiar
with scalar vs list context (sorry for the Perl terminology here)

Thank you.


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


[Q] ImportError by __import__() on Python >= 3.4

2016-06-02 Thread Makoto Kuwata
Hi,

I have a trouble around __import__().
The following sample code works well on Python <= 3.3,
but it raises ImportError on Python >= 3.4.


## importtest.py
import sys, os, shutil

def test(name):
try:
## create 'foo/__init__.py' file
os.mkdir(name)
with open(name + "/__init__.py", 'w') as f:
f.write("X=1")
f.flush()
## ipmort 'foo' module
mod = __import__(name)
finally:
if os.path.isdir(name):
shutil.rmtree(name)

test("foo")# no errors
test("bar")# may raise error on Python >= 3.4. Why?


Output Example:

### No errors  (Python <= 3.3)
ubuntu$ export PYTHONPATH=.
ubuntu$ for x in 1 2 3 ; do /usr/bin/python3.3 importtest.py; done

### ImportError (Python >= 3.4)
ubuntu$ export PYTHONPATH=.
ubuntu$ for x in 1 2 3 ; do /usr/bin/python3.4 importtest.py; done
Traceback (most recent call last):
  File "tmp/importtest.py", line 19, in 
test("bar")# may raise error on Python >= 3.4. Why?
  File "tmp/importtest.py", line 13, in test
mod = __import__(name)
ImportError: No module named 'bar'


Please give me any advices or hints.
Thanks.

--
regards,
makoto
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python on Windows with linux environment

2016-06-02 Thread Marc Brooks
Others have mentioned Cygwin or the new subsystem.  The other two options a
number of Python develops that I work use are to (1) install
vmware/virtualbox and run linux in a vm or (2) install the packaged
binaries, such as Anaconda from Continuum Analytics.

One issue I had when using cygwin was that it was sometimes a bit more
annoying to get libraries installed, since it couldn't use any pre-compiled
binaries for Windows.  I don't know if that's still the case, since this
was a few years back and I'm doing my dev work on a mac nowadays.

Marc

On Thu, Jun 2, 2016 at 7:22 AM, Muhammad Ali 
wrote:

>
> Hi,
>
> I use windows regularly, however, I use linux for only my research work at
> supercomputer. In my research field (materials science) most of the scripts
> are being written in python with linux based system. Could I installed such
> linux based python on my window 7? So that I can use those linux based
> scripts written in python and I can also write my own scripts/code without
> entirely changing my operating system from windows to linux.
>
> Looking for your valuable suggestions.
>
> Thank you.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Q] ImportError by __import__() on Python >= 3.4

2016-06-02 Thread Michael Selik
On Thu, Jun 2, 2016 at 10:06 AM Makoto Kuwata  wrote:

> os.mkdir(name)
> with open(name + "/__init__.py", 'w') as f:
> f.write("X=1")
> f.flush()
>
> Please give me any advices or hints.
>

This wasn't your question, but you don't need to flush the file. The
``with`` statement will automatically flush and close your file for you
after you exit the block.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 2d matrix into Nx3 column data

2016-06-02 Thread Michael Selik
On Thu, Jun 2, 2016 at 4:57 AM Anup reni  wrote:

> i would like to transform this:
>
>   -1 0-0.8  0.64 -0.36-0.4  0.16 -0.84
>  0.0 0 -1.00
>  0.4  0.16 -0.84
>  0.8  0.64 -0.36
>
> to something like this:
>
>  x  y  result
> id1  -0.8 -10.642  -0.8  0   -0.363  -0.4 -1
> 0.164  -0.4  0   -0.845   0.0 -10.006   0.0  0   -1.007   0.4 -1
>  0.168   0.4  0   -0.849   0.8 -10.6410  0.8  0   -0.36
>

It's hard to read your example. Could you write it out more simply? Perhaps
with comma separators instead of spaces? It might help to also give some
context around why you want to make the transformation.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiple inheritance, super() and changing signature

2016-06-02 Thread Michael Selik
On Thu, Jun 2, 2016 at 4:26 AM Lawrence D’Oliveiro 
wrote:

> On Wednesday, June 1, 2016 at 8:02:14 AM UTC+12, Ben Finney wrote:
> > (Note that ‘__init__’ is not a constructor, because it operates on the
> > *already constructed* instance, and does not return anything.
>
> Believe it or not, that *is* what “constructor” means in every OO
> language. Technically it should be called the “initializer”, but
> “constructor” is the accepted term for the special method that is called to
> initialize a newly-allocated class instance.
>

Perhaps a Pythonista may have different jargon? Since we have two different
words (initializer, constructor), we may as well give them different
meanings so that they are maximally useful in conversation.
-- 
https://mail.python.org/mailman/listinfo/python-list


Matplotlib X-axis dates

2016-06-02 Thread Joaquin Alzola
Hi Guys

Have been all day looking for a solution on the x-axis and the time plot.

The output that I get is this with all the dates shift to the right overlapping 
each other. http://postimg.org/image/fs4tx83or/

I want the x-axis to start at 0 and to finish after the 3 entries on the DB.

X Axis should show (and it does but shift one over each other to the right):
2016-06-02 11:15:00
2016-06-02 11:20:00
2016-06-02 11:25:00

Data on the Cassandra DB:
cqlsh:lebara_diameter_codes> select * from nl_lebara_diameter_codes;

country | service | date| errorcode2001 | 
errorcode3056 | errorcode4010 | errorcode4012 | errorcode4998 | errorcode4999 | 
errorcode5012
-+-+-+---+---+---+---+---+---+---
  NL |gprs | 2016-06-02 11:15:00.00+ |  3061 |  
   0 | 1 | 0 | 0 |50 |  
 741
  NL |gprs | 2016-06-02 11:20:00.00+ |  3204 |  
   0 | 9 | 0 | 0 |56 |  
 725
  NL |gprs | 2016-06-02 11:25:00.00+ |  3044 |  
   0 | 8 | 0 | 0 |64 |  
 722


Code:
sql = country_sql("NL",ago.strftime('%Y-%m-%d %H:%M:%S'),"gprs")
result = sql.sql_statement_range()
for i in result:
country = i.country
service = i.service
x_list.append(i.date)
code_2001.append(i.errorcode2001)
code_4012.append(i.errorcode4012)
code_4998.append(i.errorcode4998)
code_4999.append(i.errorcode4999)
code_5012.append(i.errorcode5012)
code_3056.append(i.errorcode3056)
code_4010.append(i.errorcode4010)

print(x_list)   --> Output is [datetime.datetime(2016, 6, 2, 11, 15), 
datetime.datetime(2016, 6, 2, 11, 20), datetime.datetime(2016, 6, 2, 11, 25)]
#date_nump=date2num([i for i in x_list])
date_nump=date2num(x_list)
print(date_nump) --> output is [ 736117.46875 736117.4722  
736117.47569444]
fig = plt.figure(figsize=(12,6))
ax = fig.add_subplot(111)
ax.set_title(country.upper() + " " + service,fontsize=16, fontweight='bold')
plt.plot(np.array(code_2001),label="2001")
plt.plot(np.array(code_3056),label="3056")
plt.plot(np.array(code_4010),label="4010")
plt.plot(np.array(code_4012),label="4012")
plt.plot(np.array(code_4998),label="4998")
plt.plot(np.array(code_4999),label="4999")
plt.plot(np.array(code_5012),label="5012")
lgd = plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))
ax.set_xscale('linear')
ax.set_xticks(date_nump)
ax.set_xticklabels(num2date(date_nump))
#ax.xaxis.set_major_locator(HourLocator(byhour=range(0,24,2)))
ax.xaxis.set_major_formatter(DateFormatter('%Y-%m-%d %H:%M:%S'))
#ax.xaxis.set_minor_locator(MinuteLocator())
ax.grid(True,linestyle='-',color='0.75')
plt.gcf().autofmt_xdate(bottom=0.2, rotation=30, ha='right')
plt.ylabel('Total Amount',fontsize=12, fontweight='bold')
plt.xlabel('Date/Time',fontsize=12, fontweight='bold')
plt.gca().set_ylim(bottom=0)
plt.savefig('testplot.png',bbox_extra_artists=(lgd,), bbox_inches='tight')
plt.show()
This email is confidential and may be subject to privilege. If you are not the 
intended recipient, please do not copy or disclose its content but contact the 
sender immediately upon receipt.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python on Windows with linux environment

2016-06-02 Thread Wildman via Python-list
On Thu, 02 Jun 2016 04:22:45 -0700, Muhammad Ali wrote:

> Hi,
> 
> I use windows regularly, however, I use linux for only my research work at 
> supercomputer. In my research field (materials science) most of the scripts 
> are being written in python with linux based system. Could I installed such 
> linux based python on my window 7? So that I can use those linux based 
> scripts written in python and I can also write my own scripts/code without 
> entirely changing my operating system from windows to linux.
> 
> Looking for your valuable suggestions.
> 
> Thank you.

There is coLinux and andLinux.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python on Windows with linux environment

2016-06-02 Thread Eric S. Johansson
On 6/2/2016 12:38 PM, Wildman via Python-list wrote:
> On Thu, 02 Jun 2016 04:22:45 -0700, Muhammad Ali wrote:
>
>> Hi,
>>
>> I use windows regularly, however, I use linux for only my research work at 
>> supercomputer. In my research field (materials science) most of the scripts 
>> are being written in python with linux based system. Could I installed such 
>> linux based python on my window 7? So that I can use those linux based 
>> scripts written in python and I can also write my own scripts/code without 
>> entirely changing my operating system from windows to linux.
>>
>> Looking for your valuable suggestions.
>>
>> Thank you.
> There is coLinux and andLinux.

those are both mostly dead (it seems).  I went the cygwin route.  still
sucks but a bit less than straight windows.

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


Re: Multiple inheritance, super() and changing signature

2016-06-02 Thread Steven D'Aprano
On Thu, 2 Jun 2016 06:22 pm, Lawrence D’Oliveiro wrote:

> On Wednesday, June 1, 2016 at 8:02:14 AM UTC+12, Ben Finney wrote:
>> (Note that ‘__init__’ is not a constructor, because it operates on the
>> *already constructed* instance, and does not return anything.
> 
> Believe it or not, that *is* what “constructor” means in every OO
> language. 

I don't believe it. 

C# is an OO language, and it distinguishes constructors and initialisers:

https://msdn.microsoft.com/en-us/library/bb397680.aspx

(although they don't seem to mean quite the same as what they mean in
Python).


Objective C is also an OO language, and it calls `init` the initializer:

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/index.html#//apple_ref/occ/instm/NSObject/init

The documentation doesn't specifically give a name to the `alloc` method,
but since it allocates memory for the instance, "allocator" is the obvious
term.

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/index.html#//apple_ref/occ/clm/NSObject/alloc

And `new` merely calls alloc, then init. (Although I'm lead to understand
that in older versions of Cocoa, `new` handled both allocation and
initialisation.)

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/index.html#//apple_ref/occ/clm/NSObject/new

Smalltalk, the grand-daddy of OOP languages, doesn't even have constructors
(at least not in the modern OOP sense):

http://www.slideshare.net/SmalltalkWorld/stoop-008fun-withsmalltalkmodel
http://image.slidesharecdn.com/stoop-008-funwithsmalltalkmodel-101025144609-phpapp02/95/8-oop-smalltalk-model-3-638.jpg?cb=1422578644

Any method can be used to create an object, there is no reserved name for
such a method.

Python is an OO language, what does it say?

The glossary doesn't define *either* constructor or initialiser (or
initializer):

https://docs.python.org/3/glossary.html

and the docs for __new__ and __init__ don't refer to them by either name:

https://docs.python.org/3/reference/datamodel.html#basic-customization

The docs do refer to the "object constructor expression", but that's the
call to the class, not the special method. And the term "initialiser"
or "initializer" is frequently used by Python developers to refer to
__init__:

https://rosettacode.org/wiki/Classes#Python


> Technically it should be called the “initializer”, but 
> “constructor” is the accepted term for the special method that is called
> to initialize a newly-allocated class instance.

Not in Python circles it isn't.

But since the constructor/initialiser methods are so closely linked, many
people are satisfied to speak loosely and refer to "the constructor" as
either, unless they specifically wish to distinguish between __new__ and
__init__.



-- 
Steven

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


Re: Multiple inheritance, super() and changing signature

2016-06-02 Thread Ian Kelly
On Thu, Jun 2, 2016 at 11:36 AM, Steven D'Aprano  wrote:
> On Thu, 2 Jun 2016 06:22 pm, Lawrence D’Oliveiro wrote:
>
>> On Wednesday, June 1, 2016 at 8:02:14 AM UTC+12, Ben Finney wrote:
>>> (Note that ‘__init__’ is not a constructor, because it operates on the
>>> *already constructed* instance, and does not return anything.
>>
>> Believe it or not, that *is* what “constructor” means in every OO
>> language.
>
> I don't believe it.
>
> C# is an OO language, and it distinguishes constructors and initialisers:
>
> https://msdn.microsoft.com/en-us/library/bb397680.aspx
>
> (although they don't seem to mean quite the same as what they mean in
> Python).

Indeed. The "constructor" in that example is the equivalent of the
Python __init__ method. The "initializer" is not a part of the class
at all but just a syntactic sugar for creating an instance and setting
some of its properties at the same time in a single statement. It's
very similar to the C array initializer syntax, e.g.:

int myArray[] = {1, 2, 3, 4, 5};
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python on Windows with linux environment

2016-06-02 Thread Joel Goldstick
On Thu, Jun 2, 2016 at 1:04 PM, Eric S. Johansson  wrote:
> On 6/2/2016 12:38 PM, Wildman via Python-list wrote:
>> On Thu, 02 Jun 2016 04:22:45 -0700, Muhammad Ali wrote:
>>
>>> Hi,
>>>
>>> I use windows regularly, however, I use linux for only my research work at 
>>> supercomputer. In my research field (materials science) most of the scripts 
>>> are being written in python with linux based system. Could I installed such 
>>> linux based python on my window 7? So that I can use those linux based 
>>> scripts written in python and I can also write my own scripts/code without 
>>> entirely changing my operating system from windows to linux.
>>>
>>> Looking for your valuable suggestions.
>>>
>>> Thank you.
>> There is coLinux and andLinux.
>
> those are both mostly dead (it seems).  I went the cygwin route.  still
> sucks but a bit less than straight windows.
>
> --
> https://mail.python.org/mailman/listinfo/python-list

Although the OP is using Windows 7, according to recent articles,
Ubuntu is teaming with MS for Windows 10 to include a bash shell,
presumably with the package management of Ubuntu (debian), with pip
goodness and virtualenv and virtualenvwrapper.  That route should make
W10 and linux (ubuntu) nearly identical environments to deal with


-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Beginner Question

2016-06-02 Thread sohcahtoa82
On Thursday, June 2, 2016 at 6:38:56 AM UTC-7, Igor Korot wrote:
> Steven,
> 
> On Thu, Jun 2, 2016 at 1:20 AM, Steven D'Aprano
>  wrote:
> > On Thursday 02 June 2016 14:21, Igor Korot wrote:
> >
> >> Hi, guys,
> >>
> >> On Wed, Jun 1, 2016 at 9:42 PM, boB Stepp  wrote:
> >>> On Wed, Jun 1, 2016 at 7:55 PM, Marcin Rak 
> >>> wrote:
>  Hi to all
> 
>  I have a beginner question to which I have not found an answer I was able
>  to understand.  Could someone explain why the following program:
> 
>  def f(a, L=[]):
>  L.append(a)
>  return L
> 
>  print(f(1))
>  print(f(2))
>  print(f(3))
> 
>  gives us the following result:
> 
>  [1]
>  [1,2]
>  [1,2,3]
> 
>  How can this be, if we never catch the returned L when we call it, and we
>  never pass it on back to f???
> >>
> >> I think the OP question here is:
> >>
> >> Why it is printing the array?
> >
> > Because he calls the function, then prints the return result.
> >
> > print(f(1))
> >
> > calls f(1), which returns [1], then prints [1].
> >
> > Then he calls:
> >
> > print(f(2))
> >
> > which returns [1, 2] (but he expects [2]), then prints it. And so on.
> >
> >
> >> There is no line like:
> >>
> >> t = f(1)
> >> print t
> >
> > Correct. But there are lines:
> >
> > print(f(1))
> > print(f(2))
> > print(f(3))
> 
> I think you missed the point.
> 
> Compare:
> 
> def f(a, L=[]):
>  L.append(a)
>  return L
> 
> print(f(1))
> print(f(2))
> print(f(3))
> 
> vs.
> 
> def f(a, L=[]):
>  L.append(a)
>  return L
> 
> t = f(1)
> print t
> t = f(2)
> print t
> t = f(3)
> print t
> 
> For people that comes from C/C++/Java, the first syntax is kind of weird:
> you return a value from the function but the caller does not save it anywhere.
> Especially since the return is not a basic type and most of them are
> not familiar
> with scalar vs list context (sorry for the Perl terminology here)
> 
> Thank you.
> 
> 
> >
> >
> >
> > --
> > Steve
> >
> > --
> > https://mail.python.org/mailman/listinfo/python-list

I came from C/C++/Java, and the first syntax makes perfect sense to me.  You're 
just taking the result of a function and directly passing it as a parameter to 
another.  There's nothing confusing about that.  C/C++/Java let you do it.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Matplotlib X-axis dates

2016-06-02 Thread Joaquin Alzola
>plt.plot(np.array(code_2001),label="2001")

Simple solution:
ax.plot(date_nump,np.array(code_2001),label="2001")

Didn't see it until I took a rest.
This email is confidential and may be subject to privilege. If you are not the 
intended recipient, please do not copy or disclose its content but contact the 
sender immediately upon receipt.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for / while else doesn't make sense

2016-06-02 Thread Rob Gaddi
Lawrence D’Oliveiro wrote:

> On Friday, May 20, 2016 at 4:43:56 AM UTC+12, Herkermer Sherwood wrote:
>> Most keywords in Python make linguistic sense, but using "else" in for and
>> while structures is kludgy and misleading.
>
> My objection is not to the choice of keyword, it’s to the whole design of the 
> loop construct.
>
> It turns out C-style for-loops “for (init; test; incr) ...” are very 
> versatile. If my loop has more than one exit, I use the endless form “for 
> (;;)” and do an explicit “break” for every exit condition.
>
> Also, they let me declare a variable that is scoped to the loop, that is 
> initialized just once before the loop starts, e.g.
>
> for (int loopvar = initial_value;;)
>   {
> if (loopvar == limit)
> break;
> ... processing ...
> if (found_what_im_looking_for)
> break;
> ++loopvar;
>   } /*for*/
>
> I wish I could do this in Python...

loopvar = initial_value
while True:
do_your_loop_things
if you_want_to_break_then_just:
break
loopvar += 1

Although your loop is really the _canonical_ use case for

for loopvar in range(initial_value, limit+1):
processing
if found_what_im_looking_for:
break
else:
do_whatever_it_is_you_do_when_its_not_found

The limited variable scoping is the only thing missing, and you can get
around that by telling yourself you're not going to use that variable
again, and then believing you on the matter.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.


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


Re: Recommendation for GUI lib?

2016-06-02 Thread Rob Gaddi
Nick Sarbicki wrote:

>>
>>
>> >
>> > Do you have any recommendations? Primary platforms are OS X and Linux.
>> >
>> > I, of course, want to have "standard" widgets but a "calendar
>> > view"/"date picker" is a plus.
>>
>
> I generally use PyQt which is one of two (the other being pyside) python
> wrappers for the Qt libraries.
>
> PyQt is the only one I know which currently supports Qt5+ so gets my vote.
> There are loads of resources around - works well on all operating systems
> (with most Qt5 having some focus on mobile). It comes with a ton of
> utilities and a really nice GUI editor (
> https://en.wikipedia.org/wiki/Qt_Creator).
>
> There are a lot of resources around and, as predicted, already has some
> examples of date pickers:
>
> http://www.eurion.net/python-snippets/snippet/Calendar_Date%20picker.html
>
> - Nick.

I use PySide rather than PyQt, but definitely count me as another vote
for Qt as the toolkit of choice.  I started out on wx, but when I needed
to move to Python3 it wasn't able to come with me.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recommendation for GUI lib?

2016-06-02 Thread Igor Korot
Hi,

On Thu, Jun 2, 2016 at 4:13 PM, Rob Gaddi
 wrote:
> Nick Sarbicki wrote:
>
>>>
>>>
>>> >
>>> > Do you have any recommendations? Primary platforms are OS X and Linux.
>>> >
>>> > I, of course, want to have "standard" widgets but a "calendar
>>> > view"/"date picker" is a plus.
>>>
>>
>> I generally use PyQt which is one of two (the other being pyside) python
>> wrappers for the Qt libraries.
>>
>> PyQt is the only one I know which currently supports Qt5+ so gets my vote.
>> There are loads of resources around - works well on all operating systems
>> (with most Qt5 having some focus on mobile). It comes with a ton of
>> utilities and a really nice GUI editor (
>> https://en.wikipedia.org/wiki/Qt_Creator).
>>
>> There are a lot of resources around and, as predicted, already has some
>> examples of date pickers:
>>
>> http://www.eurion.net/python-snippets/snippet/Calendar_Date%20picker.html
>>
>> - Nick.
>
> I use PySide rather than PyQt, but definitely count me as another vote
> for Qt as the toolkit of choice.  I started out on wx, but when I needed
> to move to Python3 it wasn't able to come with me.

Phoenix - wxPython for python 3 is coming out soon (the official release).
But I believe you can already build pre-release Phoenix and start working
with it.

Of course its not ready yet, but a lot of stuff already been ported.

Thank you.

>
> --
> Rob Gaddi, Highland Technology -- www.highlandtechnology.com
> Email address domain is currently out of order.  See above to fix.
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for / while else doesn't make sense

2016-06-02 Thread Ian Kelly
On Thu, Jun 2, 2016 at 2:09 PM, Rob Gaddi
 wrote:
> The limited variable scoping is the only thing missing, and you can get
> around that by telling yourself you're not going to use that variable
> again, and then believing you on the matter.

Or you can actually limit the variable scope using a function:

def the_loop():
for loopvar in range(initial_value, limit+1):
processing
if found_what_im_looking_for:
return it
do_whatever_it_is_you_do_when_its_not_found

thing_i_was_looking_for = the_loop()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for / while else doesn't make sense

2016-06-02 Thread BartC

On 02/06/2016 21:09, Rob Gaddi wrote:

Lawrence D’Oliveiro wrote:


On Friday, May 20, 2016 at 4:43:56 AM UTC+12, Herkermer Sherwood wrote:

Most keywords in Python make linguistic sense, but using "else" in for and
while structures is kludgy and misleading.


My objection is not to the choice of keyword, it’s to the whole design of the 
loop construct.

It turns out C-style for-loops “for (init; test; incr) ...” are very versatile. 
If my loop has more than one exit, I use the endless form “for (;;)” and do an 
explicit “break” for every exit condition.

Also, they let me declare a variable that is scoped to the loop, that is 
initialized just once before the loop starts, e.g.


I've had plenty of discussions on c.l.c on how much I dislike C's 'for' 
statement!





for (int loopvar = initial_value;;)
  {
if (loopvar == limit)
break;
... processing ...
if (found_what_im_looking_for)
break;
++loopvar;
  } /*for*/

I wish I could do this in Python...


loopvar = initial_value
while True:
do_your_loop_things
if you_want_to_break_then_just:
break
loopvar += 1


One major objection was that C's 'for' isn't really a for-statement at 
all (as it is understood in most other languages that haven't just 
copied C's version), but is closer to a 'while' statement. Simple 
iterative for-loops are more of a DIY effort:


  for (i=0; i
The limited variable scoping is the only thing missing,


That's just part of a general feature of C where each block can have its 
own scope. So you can have dozens of 'i' variables within each function, 
provided each is defined in a separate block. (I couldn't see the point 
of that either!)


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


Re: Multiple inheritance, super() and changing signature

2016-06-02 Thread Random832
On Thu, Jun 2, 2016, at 13:36, Steven D'Aprano wrote:
> On Thu, 2 Jun 2016 06:22 pm, Lawrence D’Oliveiro wrote:
> 
> > On Wednesday, June 1, 2016 at 8:02:14 AM UTC+12, Ben Finney wrote:
> >> (Note that ‘__init__’ is not a constructor, because it operates on the
> >> *already constructed* instance, and does not return anything.
> > 
> > Believe it or not, that *is* what “constructor” means in every OO
> > language. 
> 
> I don't believe it. 
> 
> C# is an OO language, and it distinguishes constructors and initialisers:
> 
> https://msdn.microsoft.com/en-us/library/bb397680.aspx

The methods described on that page as "constructors" operate *precisely*
as Lawrence said.

An "initializer" as that page discusses is not a method but is a kind of
expression, with no analogue in Python, which compiles to multiple
operations and 'returns' a value to be assigned to a variable. A
hypothetical Python analogue to the C# expression 'new c() { a = 1, b =
2 }', an "initializer", might compile to the following bytecode:
LOAD_GLOBAL (c); CALL_FUNCTION 0; DUP_TOP; LOAD_CONST (1); ROT_TWO;
STORE_ATTR (a); DUP_TOP; LOAD_CONST (2); ROT_TWO; STORE_ATTR (b); i.e.
yielding into the surrounding expression context an instance of type 'c'
which has been constructed and then subsequently had two of its
attributes (in C#'s case, fields and/or properties) set (or .Add methods
called, in the case of collection initializers)

> > Technically it should be called the “initializer”, but 
> > “constructor” is the accepted term for the special method that is called
> > to initialize a newly-allocated class instance.
> 
> Not in Python circles it isn't.

I suspect that the basis on which people refuse to accept it is a
(completely incorrect) sense that "constructor" has an inherent meaning
as allocating a new object, when no-one's been able to document that it
is used *anywhere*, Python or otherwise, in that sense. (I also
inherently dislike the notion that any given language community should
get to unilaterally decide, even if there were any such agreement, what
a term means, denying us a common way to talk about concepts shared
between languages to no benefit)

Your "python circles" seem to consist of people who are ignorant of how
other languages actually work and who want to believe that python is
special [i.e. in this case that python's __init__ is somehow different
in operation from C++ or C#'s or Java's constructors] when it is not. I
think it's more or less the same crowd, and the same motivation, as the
"python doesn't have variables" folks, and should be likewise ignored.

> But since the constructor/initialiser methods are so closely linked, many
> people are satisfied to speak loosely and refer to "the constructor" as
> either, unless they specifically wish to distinguish between __new__ and
> __init__.

Where there is looseness, it comes from the fact that because __init__
is always called even if __new__ returns a pre-existing object people
often place code in __new__ which mutates the object to be returned,
acting somewhat like a traditional constructor by assigning attributes
etc.

But it is __init__ that acts like the thing that is called a constructor
in many languages, and no-one's produced a single example of a language
which uses "constructor" for something which allocates memory.

Now, where "constructor" *does* often get misused, it is for the
new-expression in other languages, and for type.__call__ in Python,
people speak as if they're "calling the constructor" (rather than
calling something which ultimately calls both __new__ and __init__). But
from a class-definition perspective, __init__ is the one and only thing
that should be called a constructor.

The fact that many languages don't have any way to override object
allocation, and therefore no analogue to __new__, also contributes to
this conclusion. In these languages, new-expressions (or the like) are
the only way to call a constructor, so people associate object
allocation with constructors.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiple inheritance, super() and changing signature

2016-06-02 Thread Marko Rauhamaa
Random832 :
> But from a class-definition perspective, __init__ is the one and only
> thing that should be called a constructor.

Not arguing agaist that, but from the *user's* perspective, I see the
class itself is the constructor function:

   class C: pass
   c = C()

You could say that the class statement in Python little else than
syntactic sugar for creating an object constructor.

For example, instead of:

   import math
   class Point:
   def __init__(self, x, y):
   self.x = x
   self.y = y
   def rotate(self, angle):
   self.x, self.y = (
   self.x * math.cos(angle) - self.y * math.sin(angle),
   self.x * math.sin(angle) + self.y * math.cos(angle))

you could write:

   import math, types
   def Point(x, y):
   def rotate(angle):
   nonlocal x, y
   x, y = (
   x * math.cos(angle) - y * math.sin(angle),
   x * math.sin(angle) + y * math.cos(angle))
   return types.SimpleNamespace(rotate=rotate)

> The fact that many languages don't have any way to override object
> allocation, and therefore no analogue to __new__, also contributes to
> this conclusion.

I see no point in Python having __new__, either. In fact, I can see the
point in C++ but not in Python.


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


Re: Python on Windows with linux environment

2016-06-02 Thread Eric S. Johansson
On 6/2/2016 2:03 PM, Joel Goldstick wrote:
> Although the OP is using Windows 7, according to recent articles,
> Ubuntu is teaming with MS for Windows 10 to include a bash shell,
> presumably with the package management of Ubuntu (debian), with pip
> goodness and virtualenv and virtualenvwrapper.  That route should make
> W10 and linux (ubuntu) nearly identical environments to deal with

had forgotten about that.  it should be released end of july and I am
looking forward to the update! in the meantime, I'm suffering with
cygwin :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recommendation for GUI lib?

2016-06-02 Thread Dietmar Schwertberger

On 02.06.2016 12:35, John Pote wrote:
I've used wxPython (www.wxpython.org) for a few GUI projects and found 
it ok. It's a wrapper for the wxWidgets C++ library. There's even a 
reasonable free GUI builder, wxGlade, which I use as I prefer 
constructing GUI's that way rather than writing raw wxPython code. 
Never tried any of the paid for GUI builders.
Disadvantage is the download page only provides builds for Python 2.6 
or 2.7.


Does anyone know how Project Phoenix is coming on? 
http://wxpython.org/Phoenix/ItsAlive/ shows wxPython working with 
Python 3.2.

Comments on how stable it is and how easy to install would be helpful.
I have been using Phoenix now for half a year and are very happy with 
it. A release is on its way. For most platforms there are snapshot 
builds which are easy to install.


See e.g. 
https://groups.google.com/d/msg/wxpython-users/soHFLOrerVs/MSijBTQ6KAAJ



The snapshot installation does not include the demo and the .chm help 
file (yet?). These and the book I found to be the most helpful resources 
(much more usable than online reference documentation as e.g. with Qt).



I think that wxGlade is the most promising Python GUI builder and I'm 
confident that it will see improvements to increase usability. I have 
tried some others from time to time, including also QtCreator, but none 
was really convincing.


Regards,

Dietmar


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


xlwt 1.1.1 released!

2016-06-02 Thread Chris Withers

Hi All,

I'm pleased to announce the release of xlwt 1.1.1.

This release contains the following:

- Fix SST BIFF record in Python 3.

- Fix for writing ExternSheetRecord in Python 3.

- Add the ability to insert bitmap images from buffers as well as files.

- Official support for Python 3.5.

Thanks to "thektulu" and Lele Gaifax for the Python 3 fixes.
Thanks to Ross Golder for the support for inserting images from buffers.

If you find any problems, please ask about them on the 
[email protected] list, or submit an issue on GitHub:


https://github.com/python-excel/xlwt/issues

There's also details of all things Python and Excel related here:

http://www.python-excel.org/

NB: If you would like to become the maintainer of xlwt, please get in 
touch! Neither myself nor John Machin have much time to drive things 
forward nowadays, hence the year or so between each release...


cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
 - http://www.simplistix.co.uk
--
https://mail.python.org/mailman/listinfo/python-list


Re: [Q] ImportError by __import__() on Python >= 3.4

2016-06-02 Thread Makoto Kuwata
On Thu, Jun 2, 2016 at 11:15 PM, Michael Selik 
wrote:

>
>
> On Thu, Jun 2, 2016 at 10:06 AM Makoto Kuwata  wrote:
>
>> os.mkdir(name)
>> with open(name + "/__init__.py", 'w') as f:
>> f.write("X=1")
>> f.flush()
>>
>> Please give me any advices or hints.
>>
>
> This wasn't your question, but you don't need to flush the file. The
> ``with`` statement will automatically flush and close your file for you
> after you exit the block.
>

Thanks. I'm sure that with-statement close file, but not sure whether it
flushes or not.


Any hints or advices for ogiginal question?

--
regards,
makoto
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Q] ImportError by __import__() on Python >= 3.4

2016-06-02 Thread MRAB

On 2016-06-02 15:04, Makoto Kuwata wrote:

Hi,

I have a trouble around __import__().
The following sample code works well on Python <= 3.3,
but it raises ImportError on Python >= 3.4.


## importtest.py
import sys, os, shutil

def test(name):
try:
## create 'foo/__init__.py' file
os.mkdir(name)
with open(name + "/__init__.py", 'w') as f:
f.write("X=1")
f.flush()
## ipmort 'foo' module
mod = __import__(name)
finally:
if os.path.isdir(name):
shutil.rmtree(name)

test("foo")# no errors
test("bar")# may raise error on Python >= 3.4. Why?


Output Example:

### No errors  (Python <= 3.3)
ubuntu$ export PYTHONPATH=.
ubuntu$ for x in 1 2 3 ; do /usr/bin/python3.3 importtest.py; done

### ImportError (Python >= 3.4)
ubuntu$ export PYTHONPATH=.
ubuntu$ for x in 1 2 3 ; do /usr/bin/python3.4 importtest.py; done
Traceback (most recent call last):
  File "tmp/importtest.py", line 19, in 
test("bar")# may raise error on Python >= 3.4. Why?
  File "tmp/importtest.py", line 13, in test
mod = __import__(name)
ImportError: No module named 'bar'


Please give me any advices or hints.
Thanks.


Things to try:

Does the order matter? If you try "bar" then "foo" does "foo" fail?

Does the directory matter?

Is there something called "bar" in the directory already?

What does the created "bar" directory contain? Does it really contain 
only "__init__.py"?


You're testing the script 3 times; on which iteration does it fail?

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


Re: for / while else doesn't make sense

2016-06-02 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 8:09:21 AM UTC+12, Rob Gaddi wrote:
> Although your loop is really the _canonical_ use case for
> 
> for loopvar in range(initial_value, limit+1):
> processing
> if found_what_im_looking_for:
> break
> else:
> do_whatever_it_is_you_do_when_its_not_found

The reason why I don’t like this is that there are two ways out of the Python 
for-statement, and they are written quite differently. Why the asymmetry? 
Logically, all ways out of a loop are of equal significance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for / while else doesn't make sense

2016-06-02 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote:
> One major objection was that C's 'for' isn't really a for-statement at 
> all (as it is understood in most other languages that haven't just 
> copied C's version), but is closer to a 'while' statement.

Apart from having local loop variables that get initialized just once. Not 
something you can fake with a “while” statement.

That’s what makes C’s for-statement so versatile.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Don't put your software in the public domain

2016-06-02 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 12:26:33 AM UTC+12, Marko Rauhamaa wrote:

> If the author has one right to their work, it is relinquishing all rights to
> that work.

In Europe, you don’t have that right.

> All works will eventually fall into the public domain anyway...

Not if certain large corporations have anything to say about it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recommendation for Object-Oriented systems to study

2016-06-02 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 12:16:02 AM UTC+12, Alan Evangelista wrote:

> The point was which programming language was better to teach object oriented
> concepts...

Object-orientation is not an end in itself. The point is what programming 
languages you should be exposed to, to get an idea of how to do PROGRAMMING.
-- 
https://mail.python.org/mailman/listinfo/python-list


xlrd 0.9.4 released!

2016-06-02 Thread Chris Withers

Hi All,

Well, I've finally called it and tagged current master of xlrd as 1.0.0:

http://pypi.python.org/pypi/xlrd/1.0.0

This release includes the following changes since the last release:

- Official support, such as it is, is now for 2.6, 2.7, 3.3+

- Fixes a bug in looking up non-lowercase sheet filenames by ensuring 
that the sheet targets are transformed the same way as the 
component_names dict keys.


- Fixes a bug for ragged_rows=False when merged cells increases the 
number of columns in the sheet. This requires all rows to be extended to 
ensure equal row lengths that match the number of columns in the sheet.


- Fixes to enable reading of SAP-generated .xls files.

- support BIFF4 files with missing FORMAT records.

- support files with missing WINDOW2 record.

- Empty cells are now always unicode strings, they were a bytestring on 
Python2 and a unicode string on Python3.


- Fix for  inlineStr attribute without  child.

- Fix for a zoom of None causes problems on Python 3.

- Fix parsing of bad dimensions.

- Fix xlsx sheet->comments relationship.

Thanks to the following for their contributions to this release:

- Lars-Erik Hannelius
- Deshi Xiao
- Stratos Moro
- Volker Diels-Grabsch
- John McNamara
- Ville Skyttä
- Patrick Fuller
- Dragon Dave McKee
- Gunnlaugur Þór Briem

If you find any problems, please ask about them on the 
[email protected] list, or submit an issue on GitHub:


https://github.com/python-excel/xlrd/issues

Full details of all things Python and Excel related can be found here:

http://www.python-excel.org/

NB: If you would like to become the maintainer of xlwt, please get in 
touch! Neither myself nor John Machin have much time to drive things 
forward nowadays, hence the year or so between each release...


cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
 - http://www.simplistix.co.uk
--
https://mail.python.org/mailman/listinfo/python-list


xlrd 1.0.0 released!

2016-06-02 Thread Chris Withers

Ugh, and once again, this time with a corrected title...


On 02/06/2016 18:56, Chris Withers wrote:

Hi All,

Well, I've finally called it and tagged current master of xlrd as 1.0.0:

http://pypi.python.org/pypi/xlrd/1.0.0

This release includes the following changes since the last release:

- Official support, such as it is, is now for 2.6, 2.7, 3.3+

- Fixes a bug in looking up non-lowercase sheet filenames by ensuring 
that the sheet targets are transformed the same way as the 
component_names dict keys.


- Fixes a bug for ragged_rows=False when merged cells increases the 
number of columns in the sheet. This requires all rows to be extended 
to ensure equal row lengths that match the number of columns in the 
sheet.


- Fixes to enable reading of SAP-generated .xls files.

- support BIFF4 files with missing FORMAT records.

- support files with missing WINDOW2 record.

- Empty cells are now always unicode strings, they were a bytestring 
on Python2 and a unicode string on Python3.


- Fix for  inlineStr attribute without  child.

- Fix for a zoom of None causes problems on Python 3.

- Fix parsing of bad dimensions.

- Fix xlsx sheet->comments relationship.

Thanks to the following for their contributions to this release:

- Lars-Erik Hannelius
- Deshi Xiao
- Stratos Moro
- Volker Diels-Grabsch
- John McNamara
- Ville Skyttä
- Patrick Fuller
- Dragon Dave McKee
- Gunnlaugur Þór Briem

If you find any problems, please ask about them on the 
[email protected] list, or submit an issue on GitHub:


https://github.com/python-excel/xlrd/issues

Full details of all things Python and Excel related can be found here:

http://www.python-excel.org/

NB: If you would like to become the maintainer of xlwt, please get in 
touch! Neither myself nor John Machin have much time to drive things 
forward nowadays, hence the year or so between each release...


cheers,

Chris



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


Re: for / while else doesn't make sense

2016-06-02 Thread Lawrence D’Oliveiro
On Friday, June 3, 2016 at 8:52:52 AM UTC+12, BartC wrote:
> Simple iterative for-loops are more of a DIY effort...

There is one case that Python handles more nicely than C. And that is iterating 
over a fixed set of values. E.g. in Python

for rendering in (False, True) :
...
#end for

versus the (slightly) more long-winded C:

for (bool rendering = false;;)
  {
...
if (rendering)
break;
rendering = true;
  } /*for*/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python on Windows with linux environment

2016-06-02 Thread Muhammad Ali
On Friday, June 3, 2016 at 6:27:50 AM UTC+8, Eric S. Johansson wrote:
> On 6/2/2016 2:03 PM, Joel Goldstick wrote:
> > Although the OP is using Windows 7, according to recent articles,
> > Ubuntu is teaming with MS for Windows 10 to include a bash shell,
> > presumably with the package management of Ubuntu (debian), with pip
> > goodness and virtualenv and virtualenvwrapper.  That route should make
> > W10 and linux (ubuntu) nearly identical environments to deal with
> 
> had forgotten about that.  it should be released end of july and I am
> looking forward to the update! in the meantime, I'm suffering with
> cygwin :-)


Please send me the link through which I can get regular updates about this new 
release.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recommendation for Object-Oriented systems to study

2016-06-02 Thread Bob Martin
in 760378 20160602 131534 Alan Evangelista  wrote:
>On 06/02/2016 02:44 AM, Lawrence D�Oliveiro wrote:
>> On Monday, May 30, 2016 at 7:17:47 AM UTC+12, Alan Evangelista wrote:
>>> - Java forces everything to be implemented in OO model (classes)
>> After you have spend a few months battering your head against the rigidity 
>> and verbosity of Java,
>> you will run back to Python with a sense of relief.
>
>The point was which programming language was better to teach object oriented 
>concepts,
>rigidity and verbosity has nothing to do with this. Most of this discussion 
>has leaned towards
>other criteria beyond adherence to OO paradigm (eg static typing vs dynamic 
>typing and
>personal taste), so I have chosen to not continue it.
>
>For some reason, Java still one of the most used programming languages to 
>teach OO
>in universities. In real life projects, people has the freedom to choose 
>whatever they
>prefer, though.  =)

Rarely; the employer usually decides which language(s) to use.
-- 
https://mail.python.org/mailman/listinfo/python-list