Re: numpy not working any more

2017-08-15 Thread breamoreboy
On Tuesday, August 15, 2017 at 5:23:29 PM UTC+1, Poul Riis wrote:
> Den tirsdag den 15. august 2017 kl. 07.29.05 UTC+2 skrev dieter:
> > Poul Riis writes:
> > > ...
> > > For some time I have been using python 3.6.0 on a windows computer.
> > > Suddenly, my numpy does not work any more.
> > > This one-liner program:
> > > import numpy as np
> > > results in the long error message below.
> > > ...
> > > Traceback (most recent call last):
> > >   File 
> > > "C:\Users\pr\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\__init__.py",
> > >  line 16, in 
> > > from . import multiarray
> > > ImportError: DLL load failed: Den angivne procedure blev ikke fundet.
> > 
> > Apparently, the module "multiarry" is implemented in a separate
> > DLL (= "Dynamically Loaded Library") and loading this DLL failed.
> > 
> > There can be several reasons for such a failure, among others:
> > 
> >  * the DLL is missing
> > 
> >  * the DLL is corrupted
> > 
> >  * the DLL depends on something which is missing or corrupted
> > 
> >  * there is a version mismatch (e.g. between the DLL and the Python
> >trying to load it)
> > 
> > 
> > An initial step could be to try to reinstall "numpy" and
> > see whether the problem goes away.
> 
> I have reinstalled numpy several times - doesn't help.

The short answer is you need to upgrade Python, not numpy.

For the long answer please see 
https://stackoverflow.com/questions/44537131/numpy-library-importerror-dll-load-failed-the-specified-procedure-could-not-be
 which in turn refers to https://bugs.python.org/issue29943.

Kindest regards.

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


Re: numpy not working any more

2017-08-15 Thread breamoreboy
On Tuesday, August 15, 2017 at 8:13:19 PM UTC+1, Poul Riis wrote:
> Den tirsdag den 15. august 2017 kl. 19.19.15 UTC+2 skrev bream...@gmail.com:
> > On Tuesday, August 15, 2017 at 5:23:29 PM UTC+1, Poul Riis wrote:
> > > Den tirsdag den 15. august 2017 kl. 07.29.05 UTC+2 skrev dieter:
> > > > Poul Riis writes:
> > > > > ...
> > > > > For some time I have been using python 3.6.0 on a windows computer.
> > > > > Suddenly, my numpy does not work any more.
> > > > > This one-liner program:
> > > > > import numpy as np
> > > > > results in the long error message below.
> > > > > ...
> > > > > Traceback (most recent call last):
> > > > >   File 
> > > > > "C:\Users\pr\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\core\__init__.py",
> > > > >  line 16, in 
> > > > > from . import multiarray
> > > > > ImportError: DLL load failed: Den angivne procedure blev ikke fundet.
> > > > 
> > > > Apparently, the module "multiarry" is implemented in a separate
> > > > DLL (= "Dynamically Loaded Library") and loading this DLL failed.
> > > > 
> > > > There can be several reasons for such a failure, among others:
> > > > 
> > > >  * the DLL is missing
> > > > 
> > > >  * the DLL is corrupted
> > > > 
> > > >  * the DLL depends on something which is missing or corrupted
> > > > 
> > > >  * there is a version mismatch (e.g. between the DLL and the Python
> > > >trying to load it)
> > > > 
> > > > 
> > > > An initial step could be to try to reinstall "numpy" and
> > > > see whether the problem goes away.
> > > 
> > > I have reinstalled numpy several times - doesn't help.
> > 
> > The short answer is you need to upgrade Python, not numpy.
> > 
> > For the long answer please see 
> > https://stackoverflow.com/questions/44537131/numpy-library-importerror-dll-load-failed-the-specified-procedure-could-not-be
> >  which in turn refers to https://bugs.python.org/issue29943.
> > 
> > Kindest regards.
> > 
> > Mark Lawrence.
> 
> I mentioned in my original question that I have tried Python 3.6.2 and that 
> it indeed had no problems with numpy but that it on the other hand gave rize 
> to another problem, namely failing installation of vtk (pip says 'Couldn't 
> find a version that satisfies the requirement vtk'.
> 
> Poul Riis

Pip won't know anything about VTK, you have to download it yourself from 
http://www.vtk.org/.

Kindest regards.

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


Re: A small quiz question

2017-08-16 Thread breamoreboy
On Wednesday, August 16, 2017 at 12:45:13 PM UTC+1, Steve D'Aprano wrote:
> On Wed, 16 Aug 2017 09:06 pm, Stefan Ram wrote:
> 
> >   I wrote my first Python quiz question!
> > 
> >   It goes like this:
> > 
> >   Can you predict (without trying it out) what the Python
> >   console will output after the following three lines have
> >   been entered?
> > 
> > def f(i): print(i); return i;
> > 
> > f(4)**f(1)**f(2)
> 
> My initial prediction was:
> 
> 
> 4
> 1
> 2
> 16
> 
> 
> which is embarrassing. Fortunately my supper arrived in the nick of time 
> to distract me from hitting Send, just long enough to remember that 1*1
> is 1, not 2.
> 
> So how about:
> 
> 4
> 1
> 2
> 4
> 
> Unless its a syntax error... I can't remember if the REPL allows multiple
> semi-colon separated statements after a colon declaration. I know it gets mad
> at this:
> 
> py> def a(): pass; def b(): pass
>   File "", line 1
> def a(): pass; def b(): pass
>  ^
> SyntaxError: invalid syntax
> 
> 
> So my wild guess is that this is a trick question and the actual answer is 
> that
> its a SyntaxError.
> 
> Otherwise, I'm sticking with
> 
> 4
> 1
> 2
> 4
> 
> 
> 
> -- 
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.

How do you expect to get four lines of output from the three function calls?

Kindest regards.

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


Re: A small quiz question

2017-08-16 Thread breamoreboy
On Wednesday, August 16, 2017 at 2:52:09 PM UTC+1, Steve D'Aprano wrote:
> On Wed, 16 Aug 2017 10:29 pm, breamoreboy wrote:
> 
> > How do you expect to get four lines of output from the three function calls?
> 
> In the REPL (the interactive interpreter) the result of evaluating the line is
> printed.
> 
> -- 
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.

*face palm* but of course.

Kindest regards.

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


ActiveState recipes now on github

2017-08-13 Thread breamoreboy
FYI - please see 
https://www.activestate.com/blog/2017/08/code-recipes-now-github-5000-recipes-python-perl-ruby-and-more

Kindest regards.

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


Re: Is this PEP viable?

2017-07-17 Thread breamoreboy
On Monday, July 17, 2017 at 3:41:12 PM UTC+1, Evan Adler wrote:
> I would like to submit the following proposal. In the logging module, I
> would like handlers (like file handlers and stream handlers) to have a
> field for exc_info printing. This way, a call to logger.exception() will
> write the stack trace to the handlers with this flag set, and only print
> the message and other info to handlers without the flag set. This allows a
> single logger to write to a less detailed console output, a less detailed
> run log, and a more detailed error log.

What PEP?  If you had it as an attachment it won't get through.

Kindest regards.

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


Re: Recent Spam problem

2017-07-26 Thread breamoreboy
On Wednesday, July 26, 2017 at 8:29:07 AM UTC+1, Tim Golden wrote:
> On 25/07/2017 06:13, Rustom Mody wrote:
> > Of late there has been an explosion of spam
> > Thought it was only a google-groups (USENET?) issue and would be barred 
> > from the mailing list.
> >
> > But then find its there in the mailing list archives as well
> > Typical example: 
> > https://mail.python.org/pipermail/python-list/2017-July/724085.html
> >
> > What gives??
> 
> I almost never look at the GG mirror (or Usenet) so it wasn't until the 
> post which started this thread that I realised just how much spam is 
> being thrown at the newsgroup.
> 

Hence why I asked a couple of weeks back why we don't just bin the existing 
group and start afresh with a new, properly moderated group.  I suggest a 
really innovative name like python-users :)

Kindest regards.

Mark Lawrence.

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


Re: how to make this situation return this result?

2017-07-01 Thread breamoreboy
On Saturday, July 1, 2017 at 1:46:21 PM UTC+1, Ho Yeung Lee wrote:
> just want to compare tuples like index (0,1), (0,2), (1,2) without duplicate
>  such as (2,0), (1,0) etc
> 

I'm still not entirely sure what you're asking, but can't you just generate 
what you want with itertools combinations, something like:-

>>> import itertools
>>> tuples = list(itertools.combinations(range(3), 2))
>>> tuples
[(0, 1), (0, 2), (1, 2)]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: urllib

2017-06-30 Thread breamoreboy
On Friday, June 30, 2017 at 1:30:10 PM UTC+1, Rasputin wrote:
> good luck with that, mate !

Please don't change the subject line and also provide some context when you 
reply, we're not yet mindreaders :)

Kindest regards.

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


Re: why are these 2 fucking clowns in here ?

2017-06-30 Thread breamoreboy
On Friday, June 30, 2017 at 1:45:00 PM UTC+1, Rasputin wrote:
> C. Angelico and Mark Lawrence,
> 
> who the fuck does this twin-scum think they are ?
> 
> you better stfu right now.
>  
> these guys are responsible for turning the pythonWiki into a pile of
> rubbish.

pythonWiki???

> 
> fuck off and never return !
> 

One strike and you're out.

*plonk*

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


Can we please dump google groups completely?

2017-07-02 Thread breamoreboy
Yes I know it's daft that it's where I'm posting from, but I'm still banned 
from using the main mailing list.  I've reported over 80 posts today alone, 
meaning that it's less than useless for anybody who is seriously interested in 
Python.  wxpython did the same years ago, why can't we?

Kindest regards.

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


Re: how to make this situation return this result?

2017-07-02 Thread breamoreboy
On Saturday, July 1, 2017 at 6:55:59 PM UTC+1, Ho Yeung Lee wrote:
> My situation is a dictionary with tuple key
> I think dictionary.values()[index]
> Is correct
> 

This is the second time you've said this and it makes no more sense now than it 
did the first time.  Please explain exactly what you are trying to achieve.

Kindest regards.

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


Re: pythonhosted.org status?

2017-07-02 Thread breamoreboy
On Sunday, July 2, 2017 at 10:03:34 AM UTC+1, Irmen de Jong wrote:
> Hi,
> I'm using pythonhosted.org to host the docs for various projects but it has 
> either been
> very slow or unavailable over the past week. Anyone else having the same 
> problems?
> Should I perhaps consider putting my docs on readthedocs.org instead?
> 
> Irmen

I get:-

"Service Unavailable

The service is temporarily unavailable. Please try again later."

http://downforeveryoneorjustme.com says it's down.

Kindest regards.

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


Re: how to create this dependency table from ast?

2017-07-02 Thread breamoreboy
On Sunday, July 2, 2017 at 2:32:36 PM UTC+1, ad...@python.org wrote:
> ad...@python.org:
> > Hi, Ho!
> 
> 
> it is crucial that you dump that fucking Windows of yours and become
> real pythonic under Linux !

Isn't this spammer, or is it spanner, cute?

I'm rather upset that he's been duplicating my name and that of Chris Angelico 
on the dread Python google groups, so do I have to keep asking for this scumbag 
to be locked out?  Of course I'm a very naughty boy myself, but accepting my 
autism doesn't fit in with with the crap code of conduct here I've got used to. 
  I still can't reply on the main list, showing the dual standards that the 
moderators show.

Why do I bother?  Because I care about the community.

Yours most upsettingly.

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


Re: Quote of the week

2017-04-25 Thread breamoreboy
On Wednesday, April 26, 2017 at 12:03:09 AM UTC+1, Ben Finney wrote:
> > "If it's not important enough to require tests it's not important
> > enough to be in Python." -- Ethan Furman
> 
> Ethan Furman writes:
> 
> > Yes, the smiley was acknowledgement that testing is hard, will never
> > be perfect, and we only have so much time -- but thorough tests should
> > still be the goal.
> 
> I agree with the statement in full. I wonder what Terry disagrees with
> in that statement.
> 
> -- 
>  \  “A hundred times every day I remind myself that […] I must |
>   `\   exert myself in order to give in the same measure as I have |
> _o__)received and am still receiving” —Albert Einstein |
> Ben Finney

Terry actually said "In the context of debating how to improve python from 
where it is now, I do not find the quote very helpful, as it glosses over real 
difficulties of testing.  I will try to explain in the original thread." 
referring to 
https://mail.python.org/pipermail/python-committers/2017-April/004436.html so 
if you pop over there I'm sure that you'll get your answer.

Kindest regards.

Mark Lawrence.


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


Re: Bigotry (you win, I give up)

2017-04-25 Thread breamoreboy
On Friday, April 21, 2017 at 4:19:25 PM UTC+1, Ethan Furman wrote:
> On 04/21/2017 06:33 AM, Ethan Furman wrote:
> > On 04/21/2017 03:38 AM, breamoreboy wrote:
> 
> >> Talking of signatures another of Robert L's beauties landed three or so 
> >> hours ago.  He really is a right little
> >> charmer :-(
> >
> > Not on the Python Mailing List.
> 
> I see one of them made it through.  My apologies (human error).
> 
> --
> Python List Moderator

The only person who never makes a mistake is the person who never does anything 
:)

Kindest regards.

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


Re: Bigotry (you win, I give up)

2017-04-25 Thread breamoreboy
On Tuesday, April 25, 2017 at 5:41:11 PM UTC+1, Rhodri James wrote:
> On 25/04/17 15:26, Rustom Mody wrote:
> >
> > Astrology is bunk…
> >
> > Or is it 'fake-news' ?
> >  
> > https://www.washingtonpost.com/national/health-science/can-a-full-moon-really-affect-our-behavior/2016/01/15/8de3018e-b940-11e5-99f3-184bc379b12d_story.html
> >
> > Maybe the idea that tides are controlled by the moon
> > and that people awake and sleep with the sun is also fake?
> >
> > The influence of Jupiter, Saturn, etc is — for astrology-buffs at least — 
> > just a
> > refinement of the influence of the sun, moon
> 
> Mostly it's irrelevant.  Kindly stop.
> 
> -- 
> Rhodri James *-* Kynesim Ltd

I'll second that, people come here to discuss Python specifically and computing 
generally, not this kind of complete dross.

Kindest regards.

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


Re: Array column separations for beginners

2017-04-27 Thread breamoreboy
On Thursday, April 27, 2017 at 8:10:33 PM UTC+1, katari...@gmail.com wrote:
> Thanks a lot, it helped me. 
> 
> I have new question..maybe very easy but I am trying to search on web and I 
> have no clue.
> I have array(table) with 3 rows - x, y, y. I would like to plot graph with 
> double y axis from that table. Should I use twinxs? or does exist easier way?
> Thanks!

http://matplotlib.org/examples/api/two_scales.html

Kindest regards.

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


Re: plot graph from data

2017-04-24 Thread breamoreboy
On Monday, April 24, 2017 at 12:51:26 PM UTC+1, Prasenjit Dutta wrote:
> Hi All,
> 
> I have a exported data as below:
> 
>  [2J [HNAME CPU %   MEM USAGE / 
> LIMIT
> goofy_wozniak0.53%   256.8 MiB / 7.64 GiB
> kibana.1.i5shzj5kc7ck4x6s6s3m3wxjl   0.00%   597.2 MiB / 7.64 GiB
> agitated_bhaskara0.00%   2.883 MiB / 7.64 GiB
> influxsrv0.09%   21.83 MiB / 7.64 GiB
> artifactoryTemp  0.16%   866.7 MiB / 7.64 GiB
> artifactory-5.0.00.43%   548 MiB / 7.64 GiB
> naughty_allen0.10%   94.55 MiB / 7.64 GiB
>  [2J [HNAME CPU %   MEM USAGE / 
> LIMIT
> goofy_wozniak0.53%   256.8 MiB / 7.64 GiB
> kibana.1.i5shzj5kc7ck4x6s6s3m3wxjl   0.00%   597.2 MiB / 7.64 GiB
> agitated_bhaskara0.00%   2.883 MiB / 7.64 GiB
> influxsrv0.09%   21.83 MiB / 7.64 GiB
> artifactoryTemp  0.16%   866.7 MiB / 7.64 GiB
> artifactory-5.0.00.43%   548 MiB / 7.64 GiB
> naughty_allen0.10%   94.55 MiB / 7.64 GiB
>  [2J [HNAME CPU %   MEM USAGE / 
> LIMIT
> goofy_wozniak0.53%   256.8 MiB / 7.64 GiB
> kibana.1.i5shzj5kc7ck4x6s6s3m3wxjl   0.00%   597.2 MiB / 7.64 GiB
> agitated_bhaskara0.00%   2.883 MiB / 7.64 GiB
> influxsrv0.03%   21.83 MiB / 7.64 GiB
> artifactoryTemp  0.37%   866.7 MiB / 7.64 GiB
> artifactory-5.0.00.75%   548 MiB / 7.64 GiB
> naughty_allen0.10%   94.55 MiB / 7.64 GiB
>  [2J [HNAME CPU %   MEM USAGE / 
> LIMIT
> goofy_wozniak1.30%   256.8 MiB / 7.64 GiB
> kibana.1.i5shzj5kc7ck4x6s6s3m3wxjl   0.00%   597.2 MiB / 7.64 GiB
> agitated_bhaskara0.00%   2.883 MiB / 7.64 GiB
> influxsrv0.03%   21.83 MiB / 7.64 GiB
> artifactoryTemp  0.37%   866.7 MiB / 7.64 GiB
> artifactory-5.0.00.75%   548 MiB / 7.64 GiB
> naughty_allen0.28%   94.55 MiB / 7.64 GiB
> 
> 
> Want to plot graph from this. Issue what i am facing is header name " [2J 
> [HNAME CPU %   MEM USAGE / LIMIT" 
> repeating in between and also data is in text not in csv/xls
> 
> Can anyone help?
> 
> Thanks,
> Prasenjit

Open the file, loop to read it line by line and ignore any lines holding the 
header.  It seems to be fixed width data so it should be easy be read the data 
taking slices of the line and using string methods, maybe a regex if you prefer 
that kind of thing.  matplotlib https://matplotlib.org/ will do the plotting. 

Kindest regards.

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


Re: Rosetta: Range extraction

2017-04-24 Thread breamoreboy
On Tuesday, April 25, 2017 at 12:13:42 AM UTC+1, Gregory Ewing wrote:
> bartc wrote:
> > On 24/04/2017 09:20, Robert L. wrote:
> > 
> >> old = list[0]
> >> list.slice_before{|n| [n-old>1,old=n][0]}.
> >> map{|a| a.size<3 ? a.join(",") : [a[0],a[-1]].join("-")}.
> >> join ","
> > 
> > Is this supposed to be Python code?
> 
> I think it's Ruby. Maybe posted to the wrong group?
> 
> -- 
> Greg

Whatever the case his revolting antisemitic signatures are not welcome here.  
I'll not repeat it here but you can see the original on gg that bartc has 
obviously snipped.

Kindest regards.

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


py-backwards - Python to python compiler that allows you to use Python 3.6 features in older versions.

2017-04-28 Thread breamoreboy
Hi folks, I've no idea if you could be interested in this beastie 
https://github.com/nvbn/py-backwards but if you don't know about it, you can't 
be :)

Kindest regards.

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


The tragic tale of the deadlocking Python queue

2017-08-17 Thread breamoreboy
I found it interesting, possibly some of you may feel the same way so here it 
is https://codewithoutrules.com/2017/08/16/concurrency-python/

Kindest regards.

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


Re: EXTERNAL: How to update python from 3.5.2 to 3.5.3 on Linux

2017-05-03 Thread breamoreboy
On Wednesday, May 3, 2017 at 3:50:01 PM UTC+1, Joaquin Henriquez wrote:
> >Hi, I am using Python 3.5.2 on Linux Mint (X64) at the moment, and
> >wondering how to update it to 3.5.3. Are there some simple commands to do
> >that?
> 
> If available on the Mint repository you should be able to upgrade it manyally.
> 
> Centos: yum upgrade
> Debian: apt-get upgrade
> 
> Then for Mint you should have a similar command to do that.

Why have you put the EXTERNAL: into the header, hence destroying the threading 
that I, and presumably others, see?

Kindest regrads.

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


Re: Iterating through a list. Upon condition I want to move on to next item in list

2017-05-10 Thread breamoreboy
On Wednesday, May 10, 2017 at 8:25:25 PM UTC+1, aaron.m@gmail.com wrote:

You've all ready had some answers, but are you after something like this?

for elem in mylist:
if someThing(elem) is True:
continue.

Kindest regards.

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


What if range did not exist?

2017-05-18 Thread breamoreboy
Here it is 
https://aroberge.blogspot.co.uk/2017/05/what-if-range-did-not-exist.html.  I 
found it interesting as it gives background into the Python community's 
development philosophy.  I read it from start to finish but some of you may 
simply wish to jump to the punch line.

Kindest regards.

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


Re: New to python and programming

2017-05-18 Thread breamoreboy
On Wednesday, May 17, 2017 at 9:00:08 PM UTC+1, BT wrote:
> Hi guys,
> I am fairly new to programming. I was just trying to understand how this 
> group works. Am i allowed to ask any questions that I may have when i get 
> stuck? I mean is this group for new programmers as well..?
> Thanks

You can ask here or you could try the tutor list 
https://mail.python.org/mailman/listinfo/tutor which is targetted at newbies.  
It doesn't really matter.  If you show that you've made an effort Python people 
will always help.  As everyone replying is a volunteer you might like to read 
http://www.catb.org/esr/faqs/smart-questions.html and http://sscce.org/ first 
as it saves everybody, yourself included, time and trouble.

Kindest regards.

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


Re: How to install Python package from source on Windows

2017-05-18 Thread breamoreboy
On Wednesday, May 17, 2017 at 8:32:40 PM UTC+1, bartc wrote:
> On 17/05/2017 17:23, Chris Angelico wrote:
> > On Thu, May 18, 2017 at 1:37 AM, bartc  wrote:
> >> On 17/05/2017 15:13, Chris Angelico wrote:
> 
> > [1] Does work on Windows. Install bash for Windows, or (on a
> > recent-enough Windows) just use the subsystem that Microsoft provides.
> 
> So the answer is, switch to Linux. In other words, a cop-out.
> 
> -- 
> bartc

Poor old Chris seems to be getting a little frustrated so I'll just repeat what 
I said previously.


What is the problem with the documentation given here 
https://docs.python.org/devguide ?

Specifically:-

"and on Windows use:

PCbuild\build.bat -e -d"


That is 24 key strokes, including ENTER, to do the build on Windows.  What is 
so difficult about this?

Kindest regards.

Mark Lawrence. 

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


Re: How to install Python package from source on Windows

2017-05-18 Thread breamoreboy
On Wednesday, May 17, 2017 at 9:27:58 PM UTC+1, bartc wrote:
> On 17/05/2017 21:05, Mark Lawrence wrote:
> > On Wednesday, May 17, 2017 at 8:32:40 PM UTC+1, bartc wrote:
> >> On 17/05/2017 17:23, Chris Angelico wrote:
> >>> On Thu, May 18, 2017 at 1:37 AM, bartc  wrote:
>  On 17/05/2017 15:13, Chris Angelico wrote:
> >>
> >>> [1] Does work on Windows. Install bash for Windows, or (on a
> >>> recent-enough Windows) just use the subsystem that Microsoft provides.
> >>
> >> So the answer is, switch to Linux. In other words, a cop-out.
> >>
> >> --
> >> bartc
> >
> > Poor old Chris seems to be getting a little frustrated so I'll just repeat 
> > what I said previously.
> >
> > 
> > What is the problem with the documentation given here 
> > https://docs.python.org/devguide ?
> >
> > Specifically:-
> >
> > "and on Windows use:
> >
> > PCbuild\build.bat -e -d"
> > 
> >
> > That is 24 key strokes, including ENTER, to do the build on Windows.  What 
> > is so difficult about this?
> 
> I'll repeat what I said before: I don't want to build CPython with 
> VS2015. I wanted to build it with Tiny C.

Okay, so when you get it working please provide all the patches needed so that 
other people can do the same.  You'll have to learn a few git commands to do 
that, but that should be a piece of cake for someone with 40 years programming 
experience.  Incidentally which source control systems have you used during 
your career?

> 
> The purpose of doing the latter was to evaluate what the performance 
> might be, if for example Tiny C became the bundled C compiler so as to 
> quickly get a source distribution going. Bundling VS2015 with CPython 
> sources is not going to happen.
> 

What makes you think that VS2015 needs to be bundled with cPython sources?

Kindest regards.

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


Python, Unicode, utf-16, utf-32.

2017-05-18 Thread breamoreboy
For those of you who share my extremely dry sense of humour you might like to 
take a look at this 
https://groups.google.com/forum/#!topic/comp.lang.python/-58lTkBBZU4.  I've not 
shared directly as it's the latest from the RUE.  Apparantly Python 3 is the 
buggiest ever, despite the huge build infrastructure.

Kindest regards.

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


Re: How to install Python package from source on Windows

2017-05-18 Thread breamoreboy
On Thursday, May 18, 2017 at 1:19:48 AM UTC+1, Steve D'Aprano wrote:
> On Thu, 18 May 2017 07:47 am, Ian Kelly wrote:
> 
> > Because, as has already been stated, there's no way to make such a simple
> > process cross-platform.
> 
> Please understand that Bart's understanding of cross-platform and the Python
> community's understanding of cross-platform are different.
> 
> Bart's understanding of cross-platform is:
> 
> "I have a Windows box, or maybe two of them, and a Linux VM, and so long as
> my code will compile and run a few simple scripts on each of them with no
> obvious bugs, I'm going to assume we're done!"
> 
> The Python community's understanding is:
> 
> "We have to support literally tens of thousands of different combinations
> and permutations of hardware, operating system version, variations in how
> the OS and user's environment are configured, and variations in C compilers
> and how they are configured; we have to support hundreds of different
> flavours of Linux alone, plus FreeBSD, OpenBSD, NetBSD, and other Unixes,
> plus multiple versions of Windows and MacOS, and possibly a few others; we
> have to support machines with different floating point capabilities, and as
> much as possible abstract those differences away so that they're not
> visible to the end user; and importantly, we want to halt the build process
> with a comprehensible[1] error message if some essential feature is lacking
> on your platform."
> 
> 
> When I first started using Python in version 1.5, among the many Unixes
> supported were:
> 
> - VAX;
> - VMS;

VAX and VMS are Unixes, you learn something new every day ;)

> - Sun OS/Solaris (technically a Unix);
> - HP UX (also technically a Unix);
> - Windows 95/98;
> - Windows NT;
> - Windows CE;
> - OS/2;
> - classic Mac OS ("system 6", I think, or possibly 7).
> 
> My memory is a little fuzzy on the following, so don't quote me, but I think
> the following were also officially supported:
> 
> - IBM AS/400 ("System i" or "iSeries");
> - BeOS;
> - MS DOS;
> - Z/OS (OS 390);
> - Acorn RISC;

PEP 11 https://www.python.org/dev/peps/pep-0011/ gives quite a list of OSes 
that were but are no longer supported.

> 
> although some of them may not have been official ports. (Most of these are
> still available through third-parties.)
> 
> Support for a lot of those have been dropped, but it still leaves its traces
> in the build system. The most important of which is the use of configure
> and make in the first place: even if every Linux and Windows system in the
> world today uses exactly the same configuration (which they don't), make
> still tests for each of those features because you never know when you
> might be running on some exotic mainframe or embedded device with radically
> different features.
> 
> So tell us Bart, what do you think are the chances that your Q compiler will
> *just work* with no modifications at all if somebody tried to build it on
> an IBM AS/400, or under BeOS? Or for something a little more current, how
> about Android?

Perhaps Bart can also tell us why the developers have so many buildbots to 
support https://www.python.org/dev/buildbot/.

> 
> [1] Comprehensible to the core devs, not necessarily the end user.
>
> -- 
> Steve
> Emoji: a small, fuzzy, indistinct picture used to replace a clear and
> perfectly comprehensible word.

Kindest regards.

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


Re: How to install Python package from source on Windows

2017-05-17 Thread breamoreboy
On Tuesday, May 16, 2017 at 5:09:34 PM UTC+1, bartc wrote:
> On 16/05/2017 08:53, Chris Angelico wrote:
> > On Tue, May 16, 2017 at 5:14 PM, Christian Gollwitzer wrote:
> >> Am 15.05.17 um 23:58 schrieb Chris Angelico:
> >>>
> >>> On Tue, May 16, 2017 at 7:01 AM, Deborah Swanson wrote:
> 
>  But I'm a little more mystified that official Python builds are leaning
>  on Visual C++ (and that's what the crutch comment was primarily aimed
>  at).
> >>>
> >>> You seem to be of the opinion that some day, binary executables will
> >>> be compiled using pure Python code. Maybe that's true; maybe it's not.
> >>
> >>
> >> More likely would be the option to ship a C compiler with Python written in
> >> C. For C++ this is way too big, but a pure C compiler can be as small as
> >> 1MB. tcc has a liberal license, supports many platforms and gives 
> >> reasonable
> >> (unoptimized) code. AFAIK Mathworks does that, they ship tcc on Windows so
> >> that you can build .mex files without installing additional software, 
> >> though
> >> they recommend to get a decent compiler for performance reasons
> >>
> >
> > To do that, Python would itself have to be compiled with tcc, or else
> > all memory de/allocation would have to be funneled through a
> > Python-provided API. And that's going to kill performance, I suspect.
> 
> I can't test with Python because it's too complicated to compile, 
> especially on Windows.
> 
> -- 
> bartc

What is the problem with the documentation given here 
https://docs.python.org/devguide ?

Specifically:-

"and on Windows use:

PCbuild\build.bat -e -d"

Kindest regards.

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


Re: How to install Python package from source on Windows

2017-05-17 Thread breamoreboy
On Tuesday, May 16, 2017 at 10:19:06 PM UTC+1, Chris Angelico wrote:
> On Wed, May 17, 2017 at 7:14 AM, bartc wrote:
> > That PCbuild line is step 3 of Quick Start. You have to get past steps 1 and
> > 2 first. It talks about something called Git; I don't know what that is or
> > what I'm supposed to do with it, but it's a 35MB download. (Not that that is
> > very big these days, but 35MB (compressed size and there may be more to
> > come) suggests complexity that I don't want to get into.)
> 
> It's 2017 and you're a programmer. Are you unfamiliar with source
> control, or just unfamiliar with git? Either way, you should look into
> correcting that.
> 
> ChrisA

Please, be fair.  Assuming of course that you can find out what "git" is, your 
50 bps X25 link is going to take some time to download 35MB as broadband hasn't 
yet reached the UK.  Then you've got to get Visual Studio Community Edition and 
follow the horrendously complicated instructions that I gave previously.  It is 
impossible to do this unless you have at least five PhDs, all of which must be 
in completely different subjects.  Come on you lot, own up, who didn't realise 
I was that smart?

Kindest regards.

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


Re: How to install Python package from source on Windows

2017-05-16 Thread breamoreboy
On Sunday, May 14, 2017 at 10:36:37 PM UTC+1, Deborah Swanson wrote:
> I want to install the recordclass package:
> https://pypi.python.org/pypi/recordclass
>  
> But they've only released wheel files for two platforms, macosx and
> win_amd64, neither of which will install on my system. I need win_x86 or
> intel_x86, which they don't provide.
>  
> The only alternative to pip install that I know of is to install from
> source, and the source I need is at:
> https://bitbucket.org/intellimath/recordclass/src
>  
> I've never done this, so any help would be appreciated.
> Deborah

Not that it helps in this case but my first port of call if I can't install 
using pip is http://www.lfd.uci.edu/~gohlke/pythonlibs/

Kindest regards.

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


Re: Instagram: 40% Py3 to 99% Py3 in 10 months (Posting On Python-List Prohibited)

2017-06-20 Thread breamoreboy
On Tuesday, June 20, 2017 at 12:18:50 PM UTC+1, wxjm...@gmail.com wrote:
> Le mardi 20 juin 2017 11:48:03 UTC+2, Steven D'Aprano a écrit :
> 
> Python (3) on Windows just does not work. Period.

Complete drivel from the RUE.  I, and many others, use Python3 on Windows on a 
daily basis with not problems at all.  Clearly just a case of a bad workman 
always blames his tools.

Kindest regards.

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


Re: matplotlib change?

2017-06-22 Thread breamoreboy
On Thursday, June 22, 2017 at 3:33:36 PM UTC+1, Michael F. Stemper wrote:
> I have some scripts running as cronjobs that capture the status
> of some long-term processes and then periodically plot the data.
> The box where they normally run went down yesterday for some
> unknown reason, so I ran them manually on another box so that
> others on the project could continue to watch progress.
> 
> I was surprised to see that the lines on the plot no longer went
> all of the way to its border. Investigating showed me that this
> is box-dependent.
> 
> Samples showing the difference:
> 
> good
>   
> 
> bad
>   
> 
> The names of the differing plots are based on the fact that one
> was done on a box with python 2.7.12 and one with python 2.7.13.
> (Note that the 2.7.12 box is running Ubuntu, while the 2.7.13 box
> is running straight Debian.)
> 
> Is it likely that the difference in plots due to something that
> changed in matplotlib between 2.7.12 and 2.7.13? If so, is there
> some argument that I could specify in one of the functions to
> prevent this padding/margin/waste? Is there a separate function
> to call?
> 
> If the difference isn't due to a change in matplotlib, would it be
> something OS-dependent? How can I track it down?
> 
> Thanks for any suggestions.
> 
> Appendix: Functions currently called
> 
> import matplotlib.pyplot as plt
> plt.figure()
> plt.plot()
> plt.gca().xaxis.set_major_formatter()
> plt.gca().xaxis.set_major_locator()
> plt.legend()
> plt.ylabel()
> plt.savefig()
> 
> -- 
> Michael F. Stemper
> I feel more like I do now than I did when I came in.

Id check to see which matplotlib versions you have rather than the Python 
version.  Either:-

C:\python
Python 3.6.2rc1 (heads/3.6:268e1fb, Jun 17 2017, 19:01:44) [MSC v.1900 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'2.0.0'
>>>

or:-

C:\python -c "import matplotlib;print(matplotlib.__version__)"
2.0.0

Kindest regards.

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


Re: how to write add frequency in particular file by reading a csv file and then making a new file of multiple csv file by adding frequency

2017-06-22 Thread breamoreboy
On Thursday, June 22, 2017 at 12:16:28 PM UTC+1, kishan.samp...@gmail.com wrote:
> I want to write a common file in which It can add the frequency by adding 
> multiple csv file and if the same words are repeated in python then it should 
> add the frequency in the common file can any one help me please
> 
> 
> import re
> import operator
> import string
> 
> class words:
> def __init__(self,fh):
> self.fh = fh
> def read(self):
> for line in fh:
> yield line.split()
> 
> if __name__ == "__main__":
> frequency = {}
> document_text = open('data_analysis.csv', 'r')
> common1_file = open("common_file1.csv", "r")
> 
> text_string = document_text.read().lower()
> match_pattern = re.findall(r'\b[a-z]{3,15}\b', text_string)
> 
> text_string_one = common1_file.read().lower()
> match_pattern_one = re.findall(r'\b[a-z]{3,15}\b', text_string_one)
> #print("match_pattern"+(str(match_pattern)))
> for word in match_pattern:
> for word1 in match_pattern_one:
> count = frequency.get(word,0)
> count1 = frequency.get(word1,0)
> if word1 == word:
> frequency[word] = count + count1
> else:
> frequency[word] = count 
> 
> 
> frequency_list = frequency.keys()
> text_file = open("common_file1.csv", "w")
> for words in frequency_list:
> data = (words, frequency[words])
> print (data)
> #text_file = open("common_file1.csv", "w")
> #for i in data:
> #store_fre = (str(data)+"\n")
> text_file.write(str(data)+"\n")
> 
> 
> text_file.close()
> 
> 
> this is my code written by me til now but not getting satisfied results

A quick glance suggests you need to close common_file1.csv in before you open 
it in WRITE mode.

You can simplify your code by using a Counter 
https://docs.python.org/3/library/collections.html#collections.Counter

Kindest regards.

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


[Distutils] ANNOUNCE: Sunsetting of uploading to the legacy PyPI/TestPyPI

2017-06-22 Thread breamoreboy
Things are moving on in the pypi world 
https://mail.python.org/pipermail/distutils-sig/2017-June/030766.html

--
Kindest regards.

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


Re: argparse epilog call function?

2017-06-27 Thread breamoreboy
On Tuesday, June 27, 2017 at 3:25:10 PM UTC+1, Chris Angelico wrote:
> On Wed, Jun 28, 2017 at 12:09 AM, Fox  wrote:
> > what  " -h " are you even talkin bout ?
> >
> >
> >
> >
> > def Examples():
> > text = """Lots of examples"""
> > print(text.format())
> >
> >
> >
> > epilog='where the heck to put a -h ?? '
> >
> > epilog=Examples()
> 
> List admins, this person has been abusing the pydotorg-www list for
> several days. Can he please be banned?
> 
> ChrisA

I'll second that, the wxpython lists have been suffering similar abuse for 
several days.

Kindest regards.

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


Re: How to install Python package from source on Windows

2017-05-20 Thread breamoreboy
On Thursday, May 18, 2017 at 8:32:18 PM UTC+1, bartc wrote:
> On 18/05/2017 18:11, Steve D'Aprano wrote:
> 
> > Seems a bit hypocritical, don't you think? Expecting people to go spelunking
> > into your undocumented mystery language source code to work out how to
> > build it from source, and then turning around and complaining that Python's
> > build process:
> >
> > PCbuild\build.bat -e -d
> >
> >
> > is too complicated.
> 
> 
> You're right of course. But it makes you wonder then why they bother 
> making available binary builds of Python for Windows, when someone just 
> needs to enter a simple command and it will effortlessly build you a 
> customised version from source.
> 
> 
> -- 
> bartc

Enough is enough.  It is quite clear to me and has been ever since he started 
on this list that he knows squat about programming.  Please can we get rid of 
this troll.  He knows as much about Python and/or programming as the RUE knows 
about PEP 393.

Kindest regards.

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


Re: How to install Python package from source on Windows

2017-05-20 Thread breamoreboy
On Friday, May 19, 2017 at 1:41:02 AM UTC+1, Michael Torrie wrote:
> On 05/18/2017 05:15 PM, Steve D'Aprano wrote:
> > Oh but this is Bart we're talking about. Of course his code generator is
> > perfect, it is unthinkable that it emits incorrect code.
> 
> I think we've picked on Bart enough for one day.  Fortunately he seems
> rather good natured, but this is bordering on the ad hominem in my
> opinion.  Sure Bart's posts often reflect a bit of confrontation in
> regards to his own programming languages vs Python.  But I don't think
> an attack ("of course his code generator is perfect") is called for.
> 

I disagree entirely.  For a person who claims to have 40 years programming 
experience I say he's completely clueless.  Until such time as he can show that 
he understands source code control, the difficulties in building cross platform 
code and the other 1,000,001 problems that people who have to work in teams 
have to put up with on a daily basis, I will not be changing my opinion.  Run 
time speed, which he is completely obsessed with, is for 99.99% of programmers 
in the 21st century irrelevant.

Kindest regards.

Mark Lawrence.

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


Re: Scala considering significant indentation like Python

2017-05-22 Thread breamoreboy
On Monday, May 22, 2017 at 3:34:07 PM UTC+1, Serhiy Storchaka wrote:
> 22.05.17 17:24, Skip Montanaro пише:
> > On Mon, May 22, 2017 at 9:14 AM, bartc  wrote:
> >> I think 'end' can be used in Python too:
> >>
> >>   if (cond):
> >>   stmts
> >>   end
> >>
> >> But:
> >>
> >> - You need to define a dummy variable 'end'
> > 
> > Interesting idea. You can avoid the dummy variable part by just using
> > '#end', however:
> > 
> > if cond:
> >  stmts
> > #end
> 
> See pindent.py.

To save others looking it's in C:\Program Files\Python36\Tools\scripts on my 
setup.

Kindest regards.

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


SweetRegex

2017-05-29 Thread breamoreboy
Hi folks,

First poor old Ethan Furman loses his job as a vastly superior Enum is set into 
the wild, but now it looks as if MRAB is out owing to this 
https://github.com/ac1235/python-SweetRegex.  I believe tht we need to have a 
whip round to ensure that neither Ethan or MRAB lose out finacially.

Kindest regards.

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


Re: How to install Python package from source on Windows

2017-05-25 Thread breamoreboy
On Thursday, May 25, 2017 at 10:32:56 PM UTC+1, Deborah Swanson wrote:
> > Michael Torrie wrote, on Thursday, May 25, 2017 1:57 PM
> > > I didn't see a traceback where you tried to upgrade pip to
> > > 9.0.1.  
> 
> It's a long thread. You just didn't find it.
> 

You've never attempted to upgrade pip that I can see.  You were invited to do 
so https://www.mail-archive.com/python-list@python.org/msg426173.html but 
apparently didn't bother.

Kindest regards.

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


Re: How to install Python package from source on Windows

2017-05-25 Thread breamoreboy
On Friday, May 26, 2017 at 12:11:41 AM UTC+1, Deborah Swanson wrote:
> breamoreboy wrote, on Thursday, May 25, 2017 3:23 PM
> > 
> > On Thursday, May 25, 2017 at 10:32:56 PM UTC+1, Deborah Swanson wrote:
> > > > Michael Torrie wrote, on Thursday, May 25, 2017 1:57 PM
> > > > > I didn't see a traceback where you tried to upgrade pip 
> > to 9.0.1.
> > > 
> > > It's a long thread. You just didn't find it.
> > > 
> > 
> > You've never attempted to upgrade pip that I can see.  You 
> > were invited to do so 
> > https://www.mail-archive.com/python-list@python.org/msg426173.
> html but apparently didn't bother.
> 
> Kindest regards.
> 
> Mark Lawrence.
> 
> I apologize. I wrote it up, with the traceback, but the group had moved
> on and I decided not to send it.
> 
> Unfortunately I deleted that message and now I no longer have a pip to
> run
> 
> python -m pip install --upgrade pip
> 
> So I can't make another traceback. But the upgrade attempt did uninstall
> the old pip, which is why I don't have one now, and it died trying to
> install Visual Studio 2015.
> 
> Deborah

As others have suggested either your setup is screwed, or you have a file that 
is masking one in the stdlib.  Certainly there is no way that you should be 
seeing any reference to Visual Studio.  Does Anaconda give you a repair option 
that you could try?  Failing that how about installing Python 3.4 from here 
https://www.python.org/downloads/release/python-344/ in parallel with the 
Anaconda setup?  It least it would give you a chance to make progress.

Kindest regards.

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


Verifiably better, validated Enum for Python

2017-05-23 Thread breamoreboy
Well that's what is says here https://github.com/ofek/venum so it must be true. 
 Please move over Ethan, your time is up :-)

Kindest regards.

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


Re: Concatenating files in order

2017-05-23 Thread breamoreboy
On Tuesday, May 23, 2017 at 8:29:57 PM UTC+1, Mahmood Naderan wrote:
> Hi,
> There are some text files ending with _chunk_i where 'i' is an integer. For 
> example,
> 
> XXX_chunk_0
> XXX_chunk_1
> ...
> 
> I want to concatenate them in order. Thing is that the total number of files 
> may be variable. Therefore, I can not specify the number in my python script. 
> It has to be "for all files ending with _chunk_i".
> 
> Next, I can write
> 
> with open('final.txt', 'w') as outf:
> for fname in filenames:
> with open(fname) as inf:
> for line in inf:
> outf.write(line)
>  
> 
> How can I specify the "filenames"?
> Regards,
> Mahmood

https://docs.python.org/3/library/glob.html seems a good place to start.

Kindest regards.

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


Re: Where is pydlna-server?

2017-05-30 Thread breamoreboy
On Friday, May 26, 2017 at 9:22:10 PM UTC+1, MoonKid wrote:
> I have read about a project called "pydlna-server". But it looks like 
> that it is gone. Does anyone know about that project, the source or have 
> contact to the last maintainer.
> 
> There is an google archive page about it
> 

If you follow links at the archive page you'll find that there is no source 
code.  The same applies if you try https://www.openhub.net/p/pydlna-server.  
Gilmeh Serda has all ready suggested that "it might be easier using/tweaking 
something that actually exists" and I must agree, so the best of luck :)

Kindest regards.

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


Re: How to install Python package from source on Windows

2017-05-30 Thread breamoreboy
On Tuesday, May 30, 2017 at 11:32:46 PM UTC+1, Deborah Swanson wrote:
> I really don't get it how all of you have latched onto this idea that I
> said pip tried to install Visual Studio. I said it happened when I tried
> to upgrade pip, and I agreed with someone else who wondered if it might
> have been Anaconda3 that did it.
> 

Quoting you Wed May 24 20:18:03 EDT 2017 "When I tried to upgrade pip it failed 
because it could neither find nor install Visual Studio 2015."  That is 
certainly strong enough in my book for people to latch onto an idea.  I simply 
think that you are mistaken, in just the same way that you've admitted 
previously in this thread that you believe that you've done something, but 
actually haven't.  I put that down to your poor health, something with which I 
can sympathise, as I suffer from a combination of anxiety, depression, chronic 
fatigue syndrome, insomnia, autism and, last and thankfully least, diplopia.

Kindest regards.

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


Re: json to access using python

2017-06-18 Thread breamoreboy
On Sunday, June 18, 2017 at 7:50:10 PM UTC+1, Xristos Xristoou wrote:
> hello
> 
> 
> I have a json url and i want from this url to update my table in microsoft 
> access,how to do that using python or some tool of microsoft access ?

You need to do some research first.  Then you run an editor and type some code 
in.  Then you run the code.  If it does not work and you do not understand why 
you then ask a question here.  You might like to reference this 
http://www.catb.org/esr/faqs/smart-questions.html and this http://sscce.org/ 
first.

Kindest regards.

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


Re: How to store some elements from a list into another

2017-06-13 Thread breamoreboy
On Monday, June 12, 2017 at 7:33:03 PM UTC+1, José Manuel Suárez Sierra wrote:
> Hello,
> I am stuck with a (perhaps) easy problem, I hope someone can help me:
> 
> My problem is:
> I have a list of lists like this one:
> [[55, 56, 57, 58, 83, 84, 85, 86, 89, 90, 91, 92, 107, 108, 109, 110, 111, 
> 117, 118, 119, 120, 128, 129, 130, 131, 135, 136, 137, 138, 184, 185, 186, 
> 187, 216, 217, 218, 219, 232, 233, 234, 235, 236, 237, 238, 267, 268, 269, 
> 270, 272, 273, 274, 275], [2, 3, 4, 5, 9, 10, 11, 12, 21, 22, 23, 24, 29, 30, 
> 31, 32, 56, 57, 58, 59, 65, 66, 67, 68, 74, 75, 76, 77, 78, 89, 90, 91, 92, 
> 98, 99, 100, 101, 102, 125, 126, 127, 128, 131, 132, 133, 134, 135]]
> 
> And what I want is to store some of these datum into another list according 
> to the next conditions:
> 1. I just want to store data if these values are consecutive (four in four), 
> for instance, for first element I would like to store into the new list: 
> [[[55,58],[83,86],[n,n+3]]] and so on.
>  I tried something like this:
> 
> x=0
> y=0
> while list6[x][y] == list6[x][y+1]-1 and list6[x][y] == 
> list6[x][y+1]-2 and list6[x][y] == list6[x][y+1]-3 or list6[x][0]:
> 
> list7.append(list6[x][y])
> list7.append(list6[x][y+3])
> y = y+1
> if (list6[x][y])%(list6[x][len(list6[x])-1]) == 0:
> x= x+1
> 
> if len(list6[x]) == x and len(list6[x][y]) == y:
> break
> 
> 
> It does not work
> 
> I appreciate your help 
> Thank you

Perhaps use the recipe for consecutive numbers from here 
https://docs.python.org/2.6/library/itertools.html#examples  It will have to be 
modified for Python 3, I'll leave that as an exercise.

Kindest regards.

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


Re: I want to learn Python and how to benefit from the great Data Science packages - have some questions.

2017-05-07 Thread breamoreboy
On Saturday, May 6, 2017 at 8:33:57 PM UTC+1, Rahim Shamsy wrote:
> Hi, 
> 
> Hope you are well. I am currently in the process of learning the basics of 
> programming in Python, and was just checking if I am in the right direction. 
> I have experience programming in C++ and Java, and want to learn Python for 
> research work that I am doing. The research is regarding application of 
> Machine Learning as a Data Analysis tool for application in the domain of 
> smart infrastructure. 
> 
> I have the following questions:
> 
> - I have been following this pdf for practice exercises (Learn Python The 
> Hard Way) and the following online tutorial for guidance: 
> 
> https://campus.datacamp.com/courses/intro-to-python-for-data-science/
> 
> Is there a better and faster way? I need more problem solving experience 
> (keeping in mind Data Science) with python.
> 
> - What resources can I use so that I can leverage my knowledge of Java (just 
> know it from class), so that I can learn Python fast?
> 
> Thanks for the help. 
> 
> Rahim

You may find these helpful 
http://dirtsimple.org/2004/12/python-is-not-java.html and 
http://dirtsimple.org/2004/12/java-is-not-python-either.html

Kindest regards.

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


Re: I want to learn Python and how to benefit from the great Data Science packages - have some questions.

2017-05-07 Thread breamoreboy
On Sunday, May 7, 2017 at 8:21:01 AM UTC+1, Shivangi Motwani wrote:
> Hey!
> 
> Learn Python The Hard Way is good

I cannot recommend LPTHW after the author had this 
https://learnpythonthehardway.org/book/nopython3.html to say late last year.  
The best of the rebuttals is here 
https://eev.ee/blog/2016/11/23/a-rebuttal-for-python-3/

Kindest regards.

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


Re: Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread breamoreboy
On Sunday, April 30, 2017 at 12:23:19 AM UTC+1, Erik wrote:
> On 29/04/17 23:40, Ned Batchelder wrote:
> > For creating your own class that acts like
> > a dict, you should derive from collections.abc.MutableMapping, which
> > only requires implementing __getitem__, __setitem__, __delitem__,
> > __iter__, and __len__.
> 
> Or, I could derive from collections.OrderedDict and just implement the 
> two methods that I actually want to change the behavior of (did you read 
> the rest of my post?) ;)
> 
> That's one of the points I'm trying to make - why is it harder than it 
> needs to be to do something this simple?
> 
> The other is that the documentation of collections.OrderedDict seems to 
> be lacking (it is talking in terms of being a "dict" subclass, but it 
> actually isn't one).
> 
> E.

Could have fooled me.

C:\python  
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from collections import OrderedDict
>>> o = OrderedDict()
>>> isinstance(o, dict)
True

Kindest regards.

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


Re: Inconsistency between dict() and collections.OrderedDict() methods.

2017-04-29 Thread breamoreboy
On Sunday, April 30, 2017 at 2:30:25 AM UTC+1, Erik wrote:
> On 30/04/17 01:17, breamoreboy wrote:
> > On Sunday, April 30, 2017 at 12:23:19 AM UTC+1, Erik wrote:
> >> The other is that the documentation of collections.OrderedDict seems to
> >> be lacking (it is talking in terms of being a "dict" subclass, but it
> >> actually isn't one).
> >>
> >> E.
> >
> > Could have fooled me.
> >
> > C:\python
> > Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit 
> > (AMD64)] on win32
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> from collections import OrderedDict
> >>>> o = OrderedDict()
> >>>> isinstance(o, dict)
> > True
> 
> OK, so technically it is a subclass, I didn't notice that, but where 
> does the documentation explain all of the differences in behaviour? It 
> doesn't. It states "it's a subclass of dict that does  and " 
> (by which I mean "order the keys") and it's not unreasonable to 
> therefore believe that's _all_ it does differently. If if it actually 
> does ", , , , " (by which I mean 
> "order the keys and implement very different behavior for other methods 
> such as __init__ and __update__") then the documentation is lacking 
> (because it doesn't mention it). Isn't that what I said?
> 
> E.

So provide a documentation patch on the bug tracker.

Once you've done that how about subclassing UserDict 
https://docs.python.org/3.5/library/collections.html#collections.UserDict, 
pinching any code from OrderedDict as needed?

Kindest regards.

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


Re: getting memory usage of varaibles

2017-05-02 Thread breamoreboy
On Tuesday, May 2, 2017 at 8:54:46 PM UTC+1, larry@gmail.com wrote:
> I have a script that consumes more and more memory as it runs. It has
> no globals and the large data structures go out of scope often so
> should be garbage collected. I've looked at the most likely suspects
> with sys.getsizeof and they are not growing in size. I did this:
> 
> sum([sys.getsizeof(o) for o in gc.get_objects()])
> 
> And I can see it getting larger and larger. But I want to see what it
> is that is causing this. My thought was to put all the objects in a
> dict with their sizes and compare them as the program runs and report
> on the one that are growing. But I can't get the name of the object
> from gc.get_objects only the id.
> 
> Anyone have any thoughts on how I can monitor the variables' memory
> usage as the script runs?

Haven't tried them but how about https://pypi.python.org/pypi/memory_profiler 
or  https://pythonhosted.org/Pympler/muppy.html.

Kindest regards.

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


Re: Rosetta: Sequence of non-squares

2017-05-02 Thread breamoreboy
On Tuesday, May 2, 2017 at 12:15:02 PM UTC+1, Tim Golden wrote:
> On 02/05/2017 11:18, Rhodri James wrote:
> > On 02/05/17 08:20, Mark Summerfield via Python-list wrote:
> >>
> >> (The posts are already filtered out of the official comp.lang.python
> >> list, but they can't do this for the Google Groups version.)
> >
> > Careful! The posts are filtered out of the official Python mailing list,
> > but the comp.lang.python newsgroup is unmoderated and cannot do such
> > filtering.
> >
> 
> True -- it's easy to get confused especially since Google Groups (which 
> operates like a combined web forum / mailing list) is gatewayed to the 
> newsgroup while Gmane (which operates like a newsgroup / web archive) is 
> gatewayed to the mailing list!
> 
> TJG

A problem at the moment is that although the gmane side works, you can't get 
onto the website to flag anything that is undesirable, 
http://news.gmane.org/gmane.comp.python.general just gives a "Page Not Found" 
message, nothing else at all :(

Kindest regards.

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


Re: How to install Python package from source on Windows

2017-05-31 Thread breamoreboy
> > -Original Message-
> > From: Python-list
> > Sent: Tuesday, May 30, 2017 5:06 PM
> > To: python-list
> > Subject: Re: How to install Python package from source on Windows
> >  
> > On Tuesday, May 30, 2017 at 11:32:46 PM UTC+1, Deborah Swanson wrote:
> > > I really don't get it how all of you have latched onto this 
> > idea that 
> > > I said pip tried to install Visual Studio. I said it 
> > happened when I 
> > > tried to upgrade pip, and I agreed with someone else who 
> > wondered if 
> > > it might have been Anaconda3 that did it.
> > > 
> > 
> > Quoting you Wed May 24 20:18:03 EDT 2017 "When I tried to 
> > upgrade pip it failed because it could neither find nor 
> > install Visual Studio 2015."  That is certainly strong enough 
> > in my book for people to latch onto an idea.  I simply think 
> > that you are mistaken, in just the same way that you've 
> > admitted previously in this thread that you believe that 
> > you've done something, but actually haven't.  I put that down 
> > to your poor health, something with which I can sympathise, 
> > as I suffer from a combination of anxiety, depression, 
> > chronic fatigue syndrome, insomnia, autism and, last and 
> > thankfully least, diplopia.
> > 
> > Kindest regards.
> > 
> > Mark Lawrence.
> > -- 
> > https://mail.python.org/mailman/listinfo/python-list
> >
On Wednesday, May 31, 2017 at 5:42:35 AM UTC+1, Deborah Swanson wrote:
> You are correct. My health is at it's lowest ebb in many years. Quite
> possibly I forgot that I'd deleted the post with the traceback instead
> of sending it because I was overwhelmed with pain at the time, and with
> the difficulties in doing even the smallest things.
> 
> However, in your opening quote of what I said, I still meant that "it"
> meant Anaconda3 and/or Python 3.4.3 and/or pip itself. The attempt to
> install Visual Studio 2015 occurred during my attempt to upgrade pip.
> Which component of the installation exactly did it, I don't know, all I
> know is that it happened and that's when it broke. I assumed you all
> would know that installations of this type have many components, but
> once again I underestimated you.
> 
> I suppose you can impale me for writing quickly, without spelling out
> what each and every pronoun stands for. I didn't realize that the crime
> I'm being burned at the stake for was/is impugning the mighty pip until
> this evening. Sorry, but after I said that no one could say anything
> more that would be useful (and I was right) I'd archived the thread
> until someone revived it by addressed me personally. And that turned out
> to be for my imaginary presence in a discussion I was ignoring. 
> 
> So good job. Are you proud of the mess you've made?
> 
> Oh, and I don't suppose anyone knows how to build recordclass from
> source, which was my original question.
> 
> Deborah
> 

Well that attempt at smoothing the waters went down like a lead balloon.

It's now quite clear that this forum is not suited to your needs so I suggest 
you try reddit, stackoverflow, quora or something similar.

Kindest regards.

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


Re: Lies in education [was Re: The "loop and a half"]

2017-10-05 Thread breamoreboy
On Thursday, October 5, 2017 at 4:22:26 AM UTC+1, Steve D'Aprano wrote:
> On Thu, 5 Oct 2017 01:21 pm, Stefan Ram wrote:
> 
> >>- Germany was the aggressor in World War 2;
> >>- well, Germany and Japan;
> >>- *surely* it must be Germany, Italy and Japan;
> > 
> >   This listing style reminds me of of a listing style used in
> >   »Falsehoods Programmers Believe About Names«:
> 
> Yes.
> 
> For the record:
> 
> The USSR and Germany invaded Poland simultaneously, and the two countries
> divided Poland between them. Churchill himself wrote about having difficulty
> convincing people to care, since Poland had earlier invaded Czechoslovakia
> (opportunistically while the Germans were seizing the Sudetenland) and many
> people in England thought that Poland deserved their fate. Likewise the USSR
> had invaded Finland.

Germany had all ready grabbed Austria and pretty much all of Czechoslovakia.  
The USSR invaded Poland 16 days after Germany did.  You've missed out Rumania 
and Hungary grabbing bits of central Europe while they had a chance.

> 
> The UK invaded and occupied neutral Iceland in 1940, handing over control to
> the USA in 1941. Despite signing an agreement in 1948 to leave within 6
> months, US military forces actually did not finally leave Iceland, and return
> full sovereignty to the Icelander government, until 2006.

The Icelandic government quite happily worked with the UK government as their 
ruler, the King of Denmark, was preoccupied with the state of affairs at home.  
The USA has a habit of hanging around but they disliked European colonialists.  
Pot, kettle, black?

> 
> In the East, while Japan did take the first overtly military action against
> the US, the US had (in some sense) first engaged in hostile behaviour against
> Japan by unilaterally imposing, and enforcing, sanctions on Japan.
> 
> (I make no comment on whether such sanctions were justified or not, only that
> they can be seen as a form of aggressive economic warfare.)

Japan had been in control of Korea since 1905, had been involved in China from 
1931 and been in all out war with the Chinese from 1937.  As the USA had a 
strong relationship with China it does not surprise me that they took such 
action.

> -- 
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.

--
Kindest regards.
Mark Lawrence.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Finding Old Posts on Python

2017-10-08 Thread breamoreboy
On Sunday, October 8, 2017 at 12:42:19 AM UTC+1, Cai Gengyang wrote:
> Hello,
> 
> Does anyone know of a way to find all my old posts about Python ? Thanks a 
> lot!
> 
> GengYang

Make a site specific search for your name here 
https://mail.python.org/pipermail/python-list/

--
Kindest regards.

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


Re: The "loop and a half"

2017-10-04 Thread breamoreboy
On Wednesday, October 4, 2017 at 9:34:09 AM UTC+1, alister wrote:
> On Wed, 04 Oct 2017 20:16:29 +1300, Gregory Ewing wrote:
> 
> > Steve D'Aprano wrote:
> >> On Wed, 4 Oct 2017 01:40 pm, Chris Angelico wrote:
> >> 
> >>>You know, you don't HAVE to economize on letters. It's okay to call
> >>>your parameters "prompt" instead of "prmt". Remember, that's part of
> >>>your API.
> >> 
> >> Whn u wste vwels lik that, dn't b srprsd whn u run ot n hav shrtg of
> >> vwel wth nt nuff 4 vrybdy.
> > 
> > I blame the Dutch. They're clearly using more than their fair share of
> > the world's vowels.
> 
> but that is compensated for by the welsh which don't seem to use any 
> 

Careful lad, that's my late mum's nation you're talking about.

Of course I take it that you know the definition of a Welshman?  It's an 
Irishman who couldn't swim.  That is also a joke.
 
> -- 
> Never trust an operating system.

--
Kindest regards.
Mark Lawrence.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why does memory consumption keep growing?

2017-10-05 Thread breamoreboy
On Thursday, October 5, 2017 at 10:07:05 PM UTC+1, Fetchinson . wrote:
> Hi folks,
> 
> I have a rather simple program which cycles through a bunch of files,
> does some operation on them, and then quits. There are 500 files
> involved and each operation takes about 5-10 MB of memory. As you'll
> see I tried to make every attempt at removing everything at the end of
> each cycle so that memory consumption doesn't grow as the for loop
> progresses, but it still does.
> 
> import os
> 
> for f in os.listdir( '.' ):
> 
> x = [ ]
> 
> for ( i, line ) in enumerate( open( f ) ):
> 
> import mystuff
> x.append( mystuff.expensive_stuff( line ) )
> del mystuff
> 
> import mystuff
> mystuff.some_more_expensive_stuff( x )
> del mystuff
> del x
> 
> 
> What can be the reason? I understand that mystuff might be leaky, but
> if I delete it, doesn't that mean that whatever memory was allocated
> is freed? Similary x is deleted so that can't possibly make the memory
> consumption go up.
> 
> Any hint would be much appreciated,
> Daniel
> 
> -- 
> Psss, psss, put it down! - http://www.cafepress.com/putitdown

Nothing stands out so I'd start by closing all the file handles.  As you don't 
need the call to `enumerate` as you don't use the `i` something like:-

with open(f) as g:
for line in g:
...

--
Kindest regards.

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


Re: Introducing the "for" loop

2017-10-05 Thread breamoreboy
On Friday, October 6, 2017 at 2:05:58 AM UTC+1, Irv Kalb wrote:
>  
> The range function is discussed after that.
>  

FWIW range isn't a function in Python 3.  From 
https://docs.python.org/3/library/functions.html#func-range "Rather than being 
a function, range is actually an immutable sequence type, as documented in 
Ranges and Sequence Types — list, tuple, range.".

--
Kindest regards.

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


Re: OT: MPC-HC project ending? [Re: Lies in education [was Re: The "loop and a half"]]

2017-10-12 Thread breamoreboy
On Thursday, October 12, 2017 at 12:33:09 PM UTC+1, Chris Angelico wrote:
> On Thu, Oct 12, 2017 at 8:12 PM, Thomas Jollans wrote:
> > On 2017-10-12 02:51, Chris Angelico wrote:
> >> If it wants new life, it's probably going to need a Linux version,
> >> because that's where a lot of developers hang out. The reality is that
> >> open source developers are much more likely to develop on Linux than
> >> on Windows; you can maintain a Windows port of a Linux program with
> >> fewer Windows experts than maintaining the entire program on Windows.
> >>
> >> The other option, though, would be for the useful parts to become
> >> feature suggestions for VLC.
> >
> >
> > It's the year of the Linux desktop!
> >
> > (No, actually, that was a few years ago, but nobody noticed at the time)
> 
> I'm typing this up from my primary Linux system. Beside me, my laptop
> also runs Linux. I use these computers for basically everything -
> coding, testing, work, gaming, the lot. Just finished playing an
> episode of The Walking Dead, streamed to Twitch.tv; yes, that game
> wasn't released for Linux, but thanks to Wine, I can run the Windows
> version, and it's flawless.
> 
> It's the year of the Linux desktop alright. Has been for some time,
> gonna still be for a while yet.
> 
> ChrisA

I have to agree as I've now moved to Linux, Ubuntu as it happens.  I wish I'd 
done it years ago as it feels as if I've had a major hardware upgrade as it's 
so much more responsive.  The most noticeable thing is that when watching 
videos from YouTube the sound and picture always stay in sync.  Not a chance of 
that with Windows 10.

--
Kindest regards.

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


Re: how to replace maltipal char from string and substitute new char

2017-10-12 Thread breamoreboy
On Thursday, October 12, 2017 at 10:46:03 AM UTC+1, Iranna Mathapati wrote:
> Hi Team,
> 
> 
> How to replace multipal char from string and substitute with new char with
> one line code
> 
> Ex:
> 
> str = "9.0(3)X7(2) "  ===>  9.0.3.X7.2
> 
> need to replace occurrence of '(',')' with dot(.) chars
> 
> output:
> 
>  9.0.3.X7.2
> 
> 
> Thanks,

>>> help(str.replace)
replace(...)
S.replace(old, new[, count]) -> str

Return a copy of S with all occurrences of substring
old replaced by new.  If the optional argument count is
given, only the first count occurrences are replaced.

Hence:-

>>> '9.0(3)X7(2)'.replace('(','.').replace(')', '.')
'9.0.3.X7.2.'

--
Kindest regards.

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


Re: Using Python 2

2017-09-08 Thread breamoreboy
On Friday, September 8, 2017 at 5:19:36 PM UTC+1, Steve D'Aprano wrote:
> On Sat, 9 Sep 2017 12:41 am, Chris Angelico wrote:
> 
> >> I ran 2to3 on some code that worked under 2.6.6. and 3.6.2. 2to3 broke it
> >> for both versions and it was a fairly trivial script.
> > 
> > Show the code that it broke? I've never seen this, unless it's
> > something like "now you need to install third-party package X in
> > Python 3". The 2to3 transformations are fine for everything in the
> > stdlib.
> 
> Chris, I don't think it is controversial that 2to3 occasionally breaks code, 
> or
> fails to translate every feature. Even today, there are still the occasional
> bug report or feature request for 2to3.
> 
> Even human beings can't always translate 2 to 3 flawlessly, and there are some
> code bases that actually are tricky to migrate to 3. We shouldn't expect an
> automated tool to handle *all* code bases perfectly without human review.
>

I asked earlier this year why there were still so many 2to3 bug reports 
outstanding.  Regrettably the vast majority are edge cases for which there is 
no  simple solution that will keep everybody happy, so I doubt that they will 
ever get fixed.  I do not believe that to be too important as some of the 
reports are over six years old, so I suspect that workarounds have been found 
with the aid of the MkI eyeball :-)

Kindest regards.

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


Re: Using Python 2 (was: Design: method in class or general function?)

2017-09-08 Thread breamoreboy
On Friday, September 8, 2017 at 11:12:50 AM UTC+1, Leam Hall wrote:
> 
> I've read comments about Python 3 moving from the Zen of Python. I'm a 
> "plain and simple" person myself. Complexity to support what CompSci 
> folks want, which was used to describe some of the Python 3 changes, 
> doesn't help me get work done.
> 

Here https://mail.python.org/pipermail/python-3000/ are the bulk of the 
discussions regarding the move to Python 3.  Which specifics do you disagree 
with and why?

Kindest regards.

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


Re: Please improve these comprehensions (was meaning of [ ])

2017-09-04 Thread breamoreboy
On Monday, September 4, 2017 at 9:14:24 PM UTC+1, Ben Bacarisse wrote:
> Rustom Mody  writes:
> 
> > Here is some code I (tried) to write in class the other day
> >
> > The basic problem is of generating combinations
> 
> > Now thats neat as far as it goes but combinations are fundamentally sets
> > not lists
> >
> > So I thought python would do a better job
> > I tried translating it to python and sets but it turned out more annoying 
> > than
> > helpful
> > Can someone improve it??
> >

[lots of code snipped]

> -- 
> Ben.

Here's my take 
https://docs.python.org/3/library/itertools.html#itertools.combinations

Kindest regards.

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


Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-10 Thread breamoreboy
On Sunday, September 10, 2017 at 6:07:00 AM UTC+1, Ben Finney wrote:
> Gene Heskett writes:
> 
> > On Saturday 09 September 2017 21:48:44 Chris Angelico wrote:
> >
> > > The Python Secret Underground emphatically does not exist.
> >
> > Humm. here all this time I thought you were a charter member. :)
> 
> With all the authority vested in me as a charter member, I can
> categorically say the Python Secret Underground does not exist.
> 
> -- 
>  \   “Pinky, are you pondering what I'm pondering?” “Well, I think |
>   `\ so, Brain, but first you'd have to take that whole bridge |
> _o__) apart, wouldn't you?” —_Pinky and The Brain_ |
> Ben Finney

How has Python managed world domination without the aid of Pinky and the Brain?

--
Kindest regards.

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


Re: A question on modification of a list via a function invocation

2017-09-06 Thread breamoreboy
On Wednesday, September 6, 2017 at 1:12:22 PM UTC+1, Rustom Mody wrote:
> On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote:
> > On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote:
> > 
> > 
> > > Can you explain what "id" and "is" without talking of memory?
> > 
> > Yes.
> > 
> > id() returns an abstract ID number which is guaranteed to be an integer, and
> > guaranteed to be distinct for all objects which exist at the same time. 
> > When an
> > object ceases to exist, its ID number may be re-used.
> > 
> > `is` compares the two operands for identity. If the two operands are the 
> > same
> > object, `is` returns True, if they are distinct objects, `is` returns False.
> 
> >>> a = (1,2)
> >>> b = (1,2)
> >>> a is b
> False
> >>> x = 1
> >>> y = 1
> >>> x is y
> True
> 
> a seems to be as 'same' to b as x is to y
> Python seems to think otherwise
> 
> Evidently your ‘same’ is not the same as mine??
> 

This shows your complete ignorance of Python.  One would often suggest putting 
the shovel down, but it is far too late for that.

Kindest regards.

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


Re: merits of Lisp vs Python

2017-09-30 Thread breamoreboy
On Saturday, September 30, 2017 at 9:03:32 PM UTC+1, Stephan Houben wrote:
> Op 2017-09-27, Robert L. schreef :
> > (sequence-fold + 0 #(2 3 4))
> > ===>
> > 9
> >
> > In Python?
> 
> >>> sum([2, 3, 4])
> 9

Dow you have to keep replying to this out and out racist, as none of his posts 
have any relevance to Python?

--
Kindest regards.

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


Re: newb question about @property

2017-10-01 Thread breamoreboy
On Sunday, October 1, 2017 at 6:47:34 PM UTC+1, MRAB wrote:
> On 2017-10-01 02:52, Stefan Ram wrote:
> > MRAB writes:
> >>raise ValueError("Temperature below -273 is not possible")
> > 
> >-273.15
> > 
> I think you've trimmed a little too much. In my reply I was only copying 
> what someone else had written.

At least it doesn't contain the bloody irritating » and « which drive my 
autistic head right up the wall.

--
Kindest regards.

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


Re: Pyhton

2017-09-27 Thread breamoreboy
On Wednesday, September 27, 2017 at 3:10:30 PM UTC+1, darwi...@gmail.com wrote:
> Whats the reason that python is growing fast?

It would be growing faster but it is only the second best language in the 
world.  Please see 
https://mail.python.org/pipermail/python-list/2002-November/141486.html

--
Kindest regards.

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


Re: requests.{get,post} timeout

2017-08-24 Thread breamoreboy
On Thursday, August 24, 2017 at 5:02:12 PM UTC+1, Chris Angelico wrote:
> 
> (Caveat: I have no idea how this works on Windows. I do expect,
> though, that it will abort the connection without terminating the
> process, just like it does on Unix.)
> 
> ChrisA

There was a big thread "cross platform alternative for signal.SIGALRM?" 
https://mail.python.org/pipermail/python-list/2015-November/698968.html which 
you might find interesting.

Kindest regards.

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


Re: A question on modification of a list via a function invocation

2017-08-19 Thread breamoreboy
On Saturday, August 19, 2017 at 11:59:41 AM UTC+1, Steve D'Aprano wrote:

> Consider that in my family, one of our most precious heirlooms is the axe of 
> my
> great-great-great grandfather, which we have passed down from eldest son to
> eldest son for generations.
> 
> The axe is now almost 200 years old. Of course, occasionally the handle has
> broken and we've had to replace it, and from time to time the axe head itself
> was so worn out that it had to be replaced, but apart from those repairs the
> axe is the same one that my great-great-great grandfather used almost two
> centuries ago.
> 
> https://plato.stanford.edu/entries/identity-time/
> 
> -- 
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.

Rather like Trigger's roadsweeping broom 
https://www.youtube.com/watch?v=s1VNNbSYdt0

Kindest regards.

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


Re: A question on modification of a list via a function invocation

2017-09-04 Thread breamoreboy
On Monday, September 4, 2017 at 3:20:22 AM UTC+1, Chris Angelico wrote:
> On Mon, Sep 4, 2017 at 12:05 PM, Steve D'Aprano wrote:
> > On Mon, 4 Sep 2017 04:15 am, Stephan Houben wrote:
> >
> >> Needless to say, according to the definition in Plotkin's paper, Python
> >> is "call-by-value".
> >
> > According to Plotkin's definition, when you pass a value like a 100MB 
> > string:
> >
> > "This is a long string of text..."  # continues on for millions more 
> > characters
> >
> > does the interpreter make a copy of the 100MB string?
> >
> > If not, then it isn't pass (call) by value.
> 
> This is another proof that you can't divide everything into "pass by
> value" vs "pass by reference", unless you mess around with "passing a
> reference by value" or other shenanigans. In C, a string is not an
> entity; it's simply an array of characters. Arrays are never passed by
> value; yet everything in C is passed by value. So you pass a
> pointer... by value.
> 
> What would you define LISP's semantics as? Pass by value? Pass by
> reference? Pass by name? Pass by immutability? Pass the salt?
> 
> ChrisA

I can't say that I'm too bothered about all this what with "Practicality beats 
purity" and all that.  Still for the definitive guides to Python I always go 
back to http://effbot.org/zone/call-by-object.htm and 
https://jeffknupp.com/blog/2012/11/13/is-python-callbyvalue-or-callbyreference-neither/

Kindest regards.

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


Re: Easier way to do this?

2017-10-04 Thread breamoreboy
On Wednesday, October 4, 2017 at 8:29:26 PM UTC+1, 20/20 Lab wrote:
> Looking for advice for what looks to me like clumsy code.
> 
> I have a large csv (effectively garbage) dump.  I have to pull out sales 
> information per employee and count them by price range. I've got my code 
> working, but I'm thinking there must be a more refined way of doing this.
> 
> ---snippet of what I have---
> 
> EMP1 = [0,0]
> EMP2 = [0,0]
> EMP3 = [0,0]
> 
> for line in (inputfile):
>      content = line.split(",")
>      if content[18] == "EMP1":
>      if float(content[24]) < 99.75:
>      EMP1[0] += 1
>      elif float(content[24]) > 99.74:
>      EMP1[1] += 1
>      if content[18] == "EMP2":
>      if float(content[24]) < 99.75:
>      EMP2[0] += 1
>      elif float(content[24]) > 99.74:
>      EMP2[1] += 1
>      if content[18] == "EMP3":
>      if float(content[24]) < 99.75:
>      EMP3[0] += 1
>      elif float(content[24]) > 99.74:
>      EMP3[1] += 1
> 
> and repeat if statements for the rest of 25+ employees.  I can make a 
> list of the employees, but I'd prefer to pull them from the csv, as our 
> turnover is rather high (however this is not important).  I'm thinking 
> another "for employee in content[18]" should be there, but when I tried, 
> my numbers were incorrect.
> 
> Any help / advice is appreciated,
> 
> Matt

Use the csv module https://docs.python.org/3/library/csv.html to read the file 
with a Counter 
https://docs.python.org/3/library/collections.html#collections.Counter.  I'm 
sorry but I'm too knackered to try writing the code for you :-(

--
Kindest regards.

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


Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread breamoreboy
On Wednesday, October 11, 2017 at 4:47:43 PM UTC+1, bartc wrote:
> On 11/10/2017 15:52, wrote:
> > On Wednesday, October 11, 2017 at 3:14:51 PM UTC+1, bartc wrote:
> >> On 11/10/2017 14:16, Marko Rauhamaa wrote:
> >>
> >>> Python and C don't try to protect you. In return, you get syntactic
> >>> convenience that probably enhances the quality of your programs.
> >>
> >> Python, maybe. C syntax isn't as painful as C++ but I still have a lot
> >> of trouble with it. (Eg. the variable declaration 'char(*(*x[3])())[5]'.
> >> The name of the variable can be found lurking in that lot somewhere, but
> >> what's the type?) Not so convenient.
> 
> > https://cdecl.org/ tells me that your variable declaration is a syntax 
> > error so maybe not much of an example.
> 
> Perhaps you didn't write or paste it properly. The site tells me that:
> 
> char(*(*x[3])())[5]
> 
> (with or without a trailing semicolon) means:
> 
> declare x as array 3 of pointer to function returning pointer to
> array 5 of char
> 
> (Example taken from page 122 of the C book "K", in a section about 
> writing a program to make sense of complex declarations.)
> 
> Anyway that fact you either tripped up on typing it, or that you had to 
> use a special tool to find out what it meant, sort of reinforces my point...
> 
> -- 
> bartc

Don't know what happened there but what the heck.  More importantly is the fact 
that due to your magnificent performance recently you have been promoted to be 
the General Manager of my Dream Team.  You can of course cement your place when 
you explain how, in your language, converting an invalid piece of user input, 
which should be an integer, is always converted to zero, and how you handle the 
inevitable divide by zero errors that will always, eventually, occur.

--
Kindest regards.

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


Re: Lies in education [was Re: The "loop and a half"]

2017-10-11 Thread breamoreboy
On Wednesday, October 11, 2017 at 3:14:51 PM UTC+1, bartc wrote:
> On 11/10/2017 14:16, Marko Rauhamaa wrote:
> 
> > Python and C don't try to protect you. In return, you get syntactic
> > convenience that probably enhances the quality of your programs.
> 
> Python, maybe. C syntax isn't as painful as C++ but I still have a lot 
> of trouble with it. (Eg. the variable declaration 'char(*(*x[3])())[5]'. 
> The name of the variable can be found lurking in that lot somewhere, but 
> what's the type?) Not so convenient.
> 
> -- 
> bartc

https://cdecl.org/ tells me that your variable declaration is a syntax error so 
maybe not much of an example.

--
Kindest regards.

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


Re: Windows - py363 crashes with "vonLöwis.py"

2017-11-15 Thread breamoreboy
On Wednesday, November 15, 2017 at 8:53:44 AM UTC, wxjm...@gmail.com wrote:
> Sorry, to have to say it.
> 
> Have a nice day.

Do you mean it segfaults or simply provides a traceback?  If the latter is your 
environment set correctly?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: nospam ** infinity?

2017-11-28 Thread breamoreboy
On Tuesday, November 28, 2017 at 1:14:51 AM UTC, Skip Montanaro wrote:
> > I'm 99.5% certain it's not gate_news.
> 
> A funny thing. All messages I have looked at so far with the "nospam"
> thing have a Message-ID from binkp.net. (They are also all Usenet
> posts.) For example:
> 
> Newsgroups: comp.lang.python
> Subject: Re: I have anaconda, but Pycharm can't find it
> Date: Sun, 26 Nov 2017 22:40:00 +1200
> Organization: Agency BBS, Dunedin - New Zealand | bbs.geek.nz
> Message-ID: <1783215...@f38.n261.z1.binkp.net>
> Mime-Version: 1.0
> 
> Any ideas how to investigate further?

Sorry, hardly my area of expertise :-(

> 
> Skip

If it's any help there's now a message on the announce list/group subject 
"TatSu v4.2.5. released" with a nospam entry.

--
Kindest regards.

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


Re: nospam ** infinity?

2017-11-27 Thread breamoreboy
On Monday, November 27, 2017 at 1:19:38 AM UTC, Chris Angelico wrote:
> On Mon, Nov 27, 2017 at 12:14 PM, Skip Montanaro wrote:
> >> There seems to be a gateway loop of some sort going on.
> >> I'm seeing multiple versions of the same posts in
> >> comp.lang.python with different numbers of "nospam"s
> >> prepended to the email address.
> >
> > This is the second thread about this. I was thinking it might be
> > related to recent changes to the gate_news process on mail.python.org,
> > but this fingerprint looks nothing like what gate_news does.
> >
> > Looking at a somewhat long-ish thread:
> >
> > https://groups.google.com/d/topic/comp.lang.python/YoxLtkzlt_o/discussion
> >
> > I see a couple posts from Chris Angelico, only some of which have a
> > "nospam" preface. It would seem that someone was trying to mark
> > certain posters as "not spammy," (I'm sure Chris is flattered) and
> > somehow posts with that private marking leaked out of the user's
> > system starting in the past twelve hours or so.
> >
> > Newsreader configuration problem?
> 
> More likely, someone was trying to obscure the email addresses, but
> managed to tag my name instead. Definitely looks like some sort of
> automation failure. The only question is, whose? If it's not from
> gate_news, there's someone here on the list/ng that is (probably
> accidentally) reposting everything.
> 
> ChrisA

I suspect that it's a big own goal as even stuff from the RUE is getting 
through.

--
Kindest regards.

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


Re: Benefits of unicode identifiers (was: Allow additional separator in identifiers)

2017-11-24 Thread breamoreboy
On Thursday, November 23, 2017 at 6:50:29 PM UTC, Mikhail V wrote:
> Chris A wrote:
> 
> >> On Fri, Nov 24, 2017 at 1:10 AM, Mikhail V wrote:
> >>
> >>> Chris A wrote:
> >>>
> >>> Fortunately for the world, you're not the one who decided which
> >>> characters were permitted in Python identifiers. The ability to use
> >>> non-English words for function/variable names is of huge value; the
> >>> ability to use a hyphen is of some value, but not nearly as much.
> >>
> >> Fortunately for the world we have Chris A. Who knows what is
> >> fortunate and of huge values.
> >> So is there any real world projects example of usage of non-latin scripts
> >> in identifiers? Or is it still only a plan for the new world?
> 
> 
> > Yes, I've used them personally. And I know other people who have.
> 
> 
> Oh, I though it would be more impressive showcase for 'huge value'.
> If we drop the benefit of the bare fact that you can do it, or you just
> don't know English, how would describe the practical benefit?
> If you don't know english, then programming at all will be just too hard.
> (or one must define a new whole language specially for some local script)
> 
> I mean for a real practical situation - for example for an average
> Python programmer or someone who seeks a programmer job.
> And who does not have a 500-key keyboard, and who has
> a not enough high threshold of vision sensitivity to bear the look
> of various scripts in one small text piece?
> 
> Ok, I personally could find some practical usage for that, but
> merely for fun. I doubt though that someone with less
> typographical experience and overall computer literacy could
> really make benefits even for personal usage.
> 
> So - fun is one benefit. And fun is important. But is that the
> idea behind it?
> 
> 
> Mikhail

Your normal rubbish.  Do you ever give up with wasting our time?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Benefits of unicode identifiers (was: Allow additional separator

2017-11-27 Thread breamoreboy
On Monday, November 27, 2017 at 10:08:06 PM UTC, wxjmfauth wrote:
> Le lundi 27 novembre 2017 14:52:19 UTC+1, Rustom Mody a ÄCcritâ :
> > On Monday, November 27, 2017 at 6:48:56 PM UTC+5:30, Rustom Mody wrote:
> > > Having said that I should be honest to mention that I saw your post first
> on
> > > my phone where the î, showed but the gØÜ« showed as a rectangle something
> like âî$
> > >
> > > I suspect that îö OTOH would have workedâ | dunno
> >
> > Yeah îö shows whereas gØÜ« doesn't (on my phone)
> > And âî$ does show but much squatter than the replacement char the phone 
> > shows
> > when it cant display a char
> 
> It is a least unicode.
> 
> Much better than what this idotic and buggy Flexible String Representation is
> presenting to the eyes of users.

Why is this drivel now getting through onto the main mailing list/gmane?

--
Kindest regards.

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


Re: why won't slicing lists raise IndexError?

2017-12-04 Thread breamoreboy
On Monday, December 4, 2017 at 7:10:01 PM UTC, Jason Maldonis wrote:
> I was extending a `list` and am wondering why slicing lists will never
> raise an IndexError, even if the `slice.stop` value if greater than the
> list length.
> 
> Quick example:
> 
> my_list = [1, 2, 3]
> my_list[:100]  # does not raise an IndexError, but instead returns the full
> list
> 
> Is there any background on why that doesn't raise an IndexError? Knowing
> that might help me design my extended list class better. For my specific
> use case, it would simplify my code (and prevent `if isinstance(item,
> slice)` checks) if the slicing raised an IndexError in the example I gave.

This is explained in the Python tutorial for strings 
https://docs.python.org/3/tutorial/introduction.html#strings, as a list is a 
sequence just like a string it will act in exactly the same way.

--
Kindest regards.

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


Let your code type-hint itself: introducing open source MonkeyType

2017-12-14 Thread breamoreboy
Seeing that type hinting is one of the big new features of Python I thought 
folks might find this 
https://engineering.instagram.com/let-your-code-type-hint-itself-introducing-open-source-monkeytype-a855c7284881
 of interest.

Kindest regards.

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


Re: Windows - py363 crashes with "vonLöwis.py"

2017-11-16 Thread breamoreboy
On Thursday, November 16, 2017 at 8:43:24 AM UTC, wxjm...@gmail.com wrote:
> Le mercredi 15 novembre 2017 23:43:46 UTC+1, Terry Reedy a écrit :
> > On 11/15/2017 6:58 AM, breamoreboy wrote:
> > > On Wednesday, November 15, 2017 at 8:53:44 AM UTC, wxjm...@gmail.com 
> > > wrote:
> > >> Sorry, to have to say it.
> > >>
> > >> Have a nice day.
> > > 
> > > Do you mean it segfaults or simply provides a traceback?  If the latter 
> > > is your environment set correctly?
> > 
> > Why bother?  Anyway, for the obvious interpretation of the message, 
> > given f:/python/a/vonLöwis.py containing 'print("works")'"
> > 
> > C:\Users\Terry>py -3.6 f:/python/a/vonLöwis.py
> > works
> > 
> > -- 
> > Terry Jan Reedy
> 
> Do you remember stringbench.py ? Years later, I still do
> not understand how it is possible to write a test module,
> which is supposed to test Unicode and does not even
> contain a non ascii char...

What has benchmarking (I assume) code got to do with your claim in the subject 
that Python 3.6 crashes?  I have never known any other person make this claim.

> 
> -
> 
> Quick experiment
> 
> 1) Download Py363, the embeded version. This just
> avoid a Python installation.
> 2) Unpacked it in a dir.
> 2) Put "café.py" in python36.zip
> 3) Launch python.exe

So I'll repeat my question, does it segfault or does it give a traceback?

> 
> -
> 
> You do not imagine how this language is problematic
> as soon as one leaves the ascii world (all platforms).
> It is better to not speak about the Flexible String
> Representation...

The thing that works perfectly all around the world except for one user, you.

> 
> Do not take this msg badly. It's only illustrating,
> some people are still living on an another planet.

It's quite clear that you're in another universe.  Unless of course you'd 
actually, for the first time ever, like to produce some evidence to support 
your claims.  I know that hell will freeze over before that happens.

> 
> Regards.

So how many bug reports have you raised over the years to report the dreadful 
state of Python's unicode implementation?  What is the difference between you 
running vonLöwis.py and Terry Reedy running it?  What is the difference between 
you running vonLöwis.py and café.py?  Why are you incapable of running code 
that tens of thousands of users all around the world are quite content with, to 
the extent that Python 3.6 is widely recognised as the best ever version of 
Python?
-- 
https://mail.python.org/mailman/listinfo/python-list


Dropbox releases PyAnnotate -- auto-generate type annotations for mypy

2017-11-16 Thread breamoreboy
As type annotations seem to be taking off in a big way I thought that 
http://mypy-lang.blogspot.co.uk/2017/11/dropbox-releases-pyannotate-auto.html 
would be of interest, to some of you anyway.

--
Kindest regards.

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


Re: replacing `else` with `then` in `for` and `try`

2017-11-02 Thread breamoreboy
On Wednesday, November 1, 2017 at 9:14:05 PM UTC, Alexey Muranov wrote:
> Hello,
> 
> what do you think about the idea of replacing "`else`" with "`then`" in 
> the contexts of `for` and `try`?
> 
> It seems clear that it should be rather "then" than "else."  Compare 
> also "try ... then ... finally" with "try ... else ... finally".
> 
> Currently, with "else", it is almost impossible to guess the meaning 
> without looking into the documentation.
> 
> Off course, it should not be changed in Python 3, maybe in Python 4 or 
> 5, but in Python 3 `then` could be an alias of `else` in these contexts.
> 
> Alexey.

It has been discussed before.  I believe the chances of it ever happening are 
roughly zero.

There's a good write up on the subject here 
http://python-notes.curiousefficiency.org/en/latest/python_concepts/break_else.html

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

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


Re: How to use a regexp here

2017-12-04 Thread breamoreboy
On Monday, December 4, 2017 at 9:44:27 AM UTC, Cecil Westerhof wrote:
> I have a script that was running perfectly for some time. It uses:
> array = [elem for elem in output if 'CPU_TEMP' in elem]
> 
> But because output has changed, I have to check for CPU_TEMP at the
> beginning of the line. What would be the best way to implement this?
> 
> -- 
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Use https://docs.python.org/3/library/stdtypes.html#str.startswith instead of 
the test for `in`.

--
Kindest regards.

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


Re: Python script

2017-12-07 Thread breamoreboy
On Thursday, December 7, 2017 at 2:06:46 PM UTC, prvn...@gmail.com wrote:
> Hi All,
> I am new to python need help to write a script in python
> my requirement is :-
> write a python script to print sentence from a txt file to another txt file
> 
> Regards,
> Praveen

Read this https://docs.python.org/3/tutorial/inputoutput.html.  Run your 
favourite editor, type your code and save it.  Try running the script and when 
you hit problems show us your code, the input, the expected output and state 
exactly what happened.  Then we'll happily help you.

--
Kindest regards.

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


Re: why won't slicing lists raise IndexError?

2017-12-08 Thread breamoreboy
On Monday, December 4, 2017 at 7:10:01 PM UTC, Jason Maldonis wrote:
> I was extending a `list` and am wondering why slicing lists will never
> raise an IndexError, even if the `slice.stop` value if greater than the
> list length.
>
> Quick example:
>
> my_list = [1, 2, 3]
> my_list[:100]  # does not raise an IndexError, but instead returns the full
> list
>
> Is there any background on why that doesn't raise an IndexError? Knowing
> that might help me design my extended list class better. For my specific
> use case, it would simplify my code (and prevent `if isinstance(item,
> slice)` checks) if the slicing raised an IndexError in the example I gave.

This is explained in the Python tutorial for strings
https://docs.python.org/3/tutorial/introduction.html#strings, as a list is a
sequence just like a string it will act in exactly the same way.

--
Kindest regards.

Mark Lawrence.

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


Re: How to use a regexp here

2017-12-08 Thread breamoreboy
On Monday, December 4, 2017 at 9:44:27 AM UTC, Cecil Westerhof wrote:
> I have a script that was running perfectly for some time. It uses:
> array = [elem for elem in output if 'CPU_TEMP' in elem]
>
> But because output has changed, I have to check for CPU_TEMP at the
> beginning of the line. What would be the best way to implement this?
>
> --
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Use https://docs.python.org/3/library/stdtypes.html#str.startswith instead of
the test for `in`.

--
Kindest regards.

Mark Lawrence.

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


Copy-on-write friendly Python garbage collection

2017-12-31 Thread breamoreboy
An interesting write up on something that is incorporated into Python 3.7 
https://engineering.instagram.com/copy-on-write-friendly-python-garbage-collection-ad6ed5233ddf

--
Kindest regards.

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


Re: Goto (Posting On Python-List Prohibited)

2017-12-31 Thread breamoreboy
On Sunday, December 31, 2017 at 3:02:41 PM UTC, Ben Bacarisse wrote:
> bartc  writes:
> 
> > On 31/12/2017 12:41, Chris Angelico wrote:
> >> On Sun, Dec 31, 2017 at 11:33 PM, bartc  wrote:
> >>> On 30/12/2017 23:54, Chris Angelico wrote:
> >
>  I've written code that uses dirty tricks like that to avoid
>  duplication. It's at least as much of a problem as actual duplication
>  is. Generally, the 'goto' solution results in subsequent programmers
>  (such as my future selves) staring at the code for 30-60 seconds to
>  figure out what it's doing. I don't like to do that to myself, much
>  less to people I actually admire and respect.
> >>>
> >>> The problem is having to stare at the code for even longer to figure out 
> >>> the
> >>> even dirtier tricks you had to use to avoid gotos.
> >>
> >> Dirtier tricks like... named functions?
> >
> > I like to write clean and readable code. If I thought introducing
> > functions, whether local or not, as a way of avoiding goto was worth
> > doing, I would do so.
> 
> I think there's a problem with that.  Standard C does not have them, you
> said your language does not implement them properly and I think you are
> new(ish) to Python.  What language did you try them in?  It may be that
> it was overly complex in that language.  The idea is clean and simple.
> 
> > So in this case I disagree with dragging in named functions and
> > introducing an extra level of control flow just to avoid duplicating
> > half a dozen lines of code. I would just duplicate those lines (with a
> > comment that they have to match the other set so that they are
> > maintained in sync).
> 
> The suggestion was to use them to avoid gotos.  If duplicating is a good
> idea (and it's a hard line to draw) then we are not talking about the
> same cases.  Given the choice of "dragging in named functions" and
> dragging in named blocks and gotos, I would choose the functions every
> time.
> 
> 
> -- 
> Ben.

I would use functions every time as a modern compiler can inline them, 
something described here https://en.wikipedia.org/wiki/Inline_expansion for the 
benefit of newbies.  Further I've never once in 17 years of using Python been 
tearing my hair out over the lack of goto as there are numerous examples of how 
to avoid them.  This thread is yet another storm in a thimble.

--
Kindest regards.

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


Re: Native object exposing buffer protocol

2018-01-05 Thread breamoreboy
On Saturday, January 6, 2018 at 12:02:18 AM UTC, Rob Gaddi wrote:
> I'd like to create a native Python object that exposes the buffer 
> protocol.  Basically, something with a ._data member which is a 
> bytearray that I can still readinto, make directly into a numpy array, etc.
> 
> I can do it by inheriting the entire thing from bytearray directly, but 
> that gives me a whole lot of methods that are unsuitable for what I'm 
> doing with it, which is reading the contents of a binary file, allowing 
> them to be lightly malleable in memory, and then sending them on to a 
> device.
> 
> Not the end of the world (the file's less than 2KB), but it seems like 
> something that should be doable easily without having to throw around a 
> lot of extraneous copies.
> 
> -- 
> Rob Gaddi, Highland Technology -- www.highlandtechnology.com
> Email address domain is currently out of order.  See above to fix.

Could you use memoryviews instead of making the copies?

--
Kindest regards.

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


Re: Python bug report

2017-12-23 Thread breamoreboy
On Friday, December 22, 2017 at 1:28:17 PM UTC, Ranya wrote:
> Hi,
> Am trying to use clr.AddReference and clr.AddReferenceToFile, but
> python(2.7) keeps making this error:
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> clr.AddReference("UnityEngine")AttributeError: 'module' object has
> no attribute 'AddReference'
> 
> How can I fix this?
> Thanks in advance.

Are you actually using the IronPython clr module, have you downloaded by 
mistake the module of the same name from pypi, or do you have a module of the 
same name on your path?

--
Kindest regards.

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


Re: co-ordianate transformation with astropy

2017-12-23 Thread breamoreboy
On Friday, December 22, 2017 at 9:36:29 PM UTC, hemanta phurailatpam wrote:
> I want to do co-ordinate transformation from earth-frame to equatorial frame. 
> By entering date and time, I want to get RA(right ascension) and 
> Dec(declination) wrt to equatorial frame. How do I do it?

It looks as if you need astropy, specifically 
http://docs.astropy.org/en/stable/coordinates/transforming.html

--
Kindest regards.

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


Re: plot map wit box axes

2017-12-24 Thread breamoreboy
On Friday, December 22, 2017 at 3:42:58 PM UTC, jorge@cptec.inpe.br wrote:
> Hi,
> 
> I use the PYTHON and IDL. In IDL I can plot a grid map like a this 
> figure (mapa.png). Please, I would like know how can I plot my figure 
> using PYTHON with the box around the figure. Like this that I plot using 
> the IDL.
> 
> Thanks

Sorry but we can't see the image as it gets stripped off this text only mailing 
list.  What are you using to do the plot, matplotlib or smething else?  Can you 
show us the code you've used or your interactive session in IDLE?

--
Kindest regards.

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


Re: Tips or strategies to understanding how CPython works under the hood

2018-01-09 Thread breamoreboy
On Tuesday, January 9, 2018 at 3:22:30 PM UTC, Robert O'Shea wrote:
> Hey all,
> 
> Been subscribed to this thread for a while but haven't contributed much.
> One of my ultimate goals this year is to get under the hood of CPython and
> get a decent understanding of mechanics Guido and the rest of you wonderful
> people have designed and implemented.
> 
> I've been programming in python for nearly 10 years now and while I can
> write a mean Python script, I've been becoming more and more interested in
> low level operations or complex C programs so I thought I could spread my
> love of both to make a difference for me and others.
> 
> So besides just grabbing a chunk of CPython source code and digesting it, I
> was wondering if those of you have read and understood the source code, do
> you have any tips or good starting points?
> 
> Robert

Hopefully you'll find this http://pgbovine.net/cpython-internals.htm of 
interest.

--
Kindest regards.

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


Re: Native object exposing buffer protocol

2018-01-08 Thread breamoreboy
On Saturday, January 6, 2018 at 12:02:18 AM UTC, Rob Gaddi wrote:
> I'd like to create a native Python object that exposes the buffer 
> protocol.  Basically, something with a ._data member which is a 
> bytearray that I can still readinto, make directly into a numpy array, etc.
> 
> I can do it by inheriting the entire thing from bytearray directly, but 
> that gives me a whole lot of methods that are unsuitable for what I'm 
> doing with it, which is reading the contents of a binary file, allowing 
> them to be lightly malleable in memory, and then sending them on to a 
> device.
> 
> Not the end of the world (the file's less than 2KB), but it seems like 
> something that should be doable easily without having to throw around a 
> lot of extraneous copies.
> 
> -- 
> Rob Gaddi, Highland Technology -- www.highlandtechnology.com
> Email address domain is currently out of order.  See above to fix.

Curiosity having got the better of me I did some searching and found this 
"Implementing the buffer protocol" 
http://cython.readthedocs.io/en/latest/src/userguide/buffer.html, any use to 
you?  Note that at the bottom of the link the final section "References" states 
"The buffer interface used here is set out in PEP 3118, Revising the buffer 
protocol.", i.e. it is the new protocol and not the old Python 2 one.
--

Kindest regards.

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


<    1   2   3   >