Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-19 Thread breamoreboy
On Monday, February 19, 2018 at 1:07:02 PM UTC, Anders Wegge Keller wrote:
> På Mon, 19 Feb 2018 04:39:31 + (UTC)
> Steven D'Aprano skrev:
> > On Mon, 19 Feb 2018 04:26:32 +0100, Anders Wegge Keller wrote:
> > 
> > > På Mon, 19 Feb 2018 08:47:14 +1100
> > > Tim Delaney skrev:  
> > >> On 18 February 2018 at 22:55, Anders Wegge Keller 
> > >> wrote:  
> > > 
> > >   
> >  [...]  
> > >   
> > >> You couldn't have got the above much more wrong.  
> > >
> > >> As others have said, typing is about how the underlying memory is
> > >> treated.  
> > > 
> > >  And that is exactly my point. Python does not have a typed list. It
> > >  have a list that takes whatever is thrown into it.
> > > 
> > >  I'll skip the rest, as you totally missed the point.  
> > 
> > I think its actually you have totally missed the point. What you want is 
> > a homogeneous list, a list which only accepts items of the same type. The 
> > built-in list is not that data structure, but Python already has 
> > something similar: see the array module.
> 
>  Given that I'm the one making a point about the unwarranted smugness, I
> know that I'm not missing anything. Array is not even close to providing a
> strongly typed container. For all of the yakking about other languages
> weak, blah, BCPL, blah, I still wonder where that need to feel superior to
> anything else comes from.  
> 
>  Python isn't particular strong typed. In fact, apart from asking an object
> what type it is, types are not that important. It's the interface that
> matters. I wonder why this is a sore point for Python developers?
> 
> 
> -- 
> //Wegge

Congratulations, you're the first new person I've had on my Dream Team for some 
months, fresh blood is always so welcome.

--
Kindest regards.

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


Re: Gmane seems to be gone

2018-02-19 Thread breamoreboy
On Sunday, February 18, 2018 at 8:23:03 PM UTC, Mark Lawrence wrote:
> On 18/02/18 18:03, Grant Edwards wrote:
> > On 2018-02-18, Dennis Lee Bieber wrote:
> >> On Sun, 18 Feb 2018 17:26:54 + (UTC), Grant Edwards
> >>  declaimed the following:
> >>
> >>>
> >>> It was Yomura who picked up the archive and continued the gateway
> >>> service a couple years ago, and they just renewed the domain for
> >>> another year, so perhaps it's just a temporary DNS problem?
> >>
> >>Looks like the DNS update is propagating -- I can now reach gmane; but
> >> it hasn't shown any new traffic on any of the groups/lists I follow.
> > 
> > Yay!
> > 
> > Gmane.org just started resolving again, and I'm posting this followup
> > from slrn via news.gmane.org.  I really should donate some money to
> > gmane's operators...
> > 
> 
> Great stuff :)  Of course as gmane wasn't working I posted earlier today 
> on gg but I believe you've opted out of that so wouldn't have seen it :( 
>   What the hell, normal service is resumed :)
> 
> -- 
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
> 
> Mark Lawrence

Blast, seems like it's down again.  Can somebody confirm that I'm correct 
please, cheers :(

--
Kindest regards.

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


Re: could use some help with this problem! I've been working on it for days but cant seem to get it right !

2018-02-19 Thread breamoreboy
On Tuesday, February 20, 2018 at 5:08:49 AM UTC, Marc Cohen wrote:
> USING PYTHON 2:
> 
> Write a program to play this game. This may seem tricky, so break it down 
> into parts. Like many programs, we have to use nested loops (one loop inside 
> another). In the outermost loop, we want to keep playing until we are out of 
> stones.
> 
> Inside that, we want to keep alternating players. You have the option of 
> either writing two blocks of code, or keeping a variable that tracks the 
> current player. The second way is slightly trickier since we haven't learned 
> lists yet, but it's definitely do-able!
> 
> Finally, we might want to have an innermost loop that checks if the user's 
> input is valid. Is it a number? Is it a valid number (e.g. between 1 and 5)? 
> Are there enough stones in the pile to take off this many? If any of these 
> answers are no, we should tell the user and re-ask them the question
> 
> So, the basic outline of the program should be something like this:
> 
> totalStones = 100
> 
> maxStones = 5
> 
> pile = TOTAL # all stones are in the pile to start
> 
> while [pile is not empty]:
> 
> while [player 1's answer is not valid]:
> 
> [ask player 1]
> 
> [execute player1’s move]
> 
> Do the same for player 2…. (this can be achieved by a for loop)
> 
> Note how the important numbers 100 and 5 are stored in a single variable at 
> the top. This is good practice -- it allows you to easily change the 
> constants of a program. For example, for testing, you may want to start with 
> only 15 or 20 stones.
> 
> Be careful with the validity checks. Specifically, we want to keep asking 
> player 1 for their choice as long as their answer is not valid, BUT we want 
> to make sure we ask them at least ONCE. So, for example, we will want to keep 
> a variable which tracks whether their answer is valid, and set it to False 
> initially.
> 
> Hint: the final number of stones can’t be negative. The game automatically 
> stops when the number of stones reach zero.

Sorry old bean but we don't write code for you.  So you show us the code that 
you've been working on for days and tell us what's wrong with it, and we'll 
point you in the right direction.

--
Kindest regards.

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


Re: Gmane seems to be gone

2018-02-18 Thread breamoreboy
On Sunday, February 18, 2018 at 9:16:26 AM UTC, Chris Green wrote:
> Grant Edwards  wrote:
> > I've been dreading this moment for a couple years: it looks like
> > gmane.org is gone.  The original operator/maintainer gave up a couple
> > years ago and pulled the plug. Somebody else took over at that point.
> > The Web UI was never revived, but the basic NNTP<->mailing-list gateway
> > continue to work -- until tonight.  Now the domain is gone.  Perhaps
> > it's just an oversight, but I've got a bad feeling...
> > 
> I think it was a short term hiccough, a posting of mine got bounced
> yesterday but subsequent ones worked OK.
> 
> -- 
> Chris Green
> ·

Nothing from this thread is showing on gmane and nothing from the gnucash 
users' mailing list has come through since around 18:00 17/02/2018 UTC.  I've 
just sent an email to the gmane.discuss list asking them to take a look, got an 
"Authorization required" response which I duly replied to and promptly got 
"Delivery Status Notification (Failure)", the guts of which are "DNS Error: 
2475639 DNS type 'mx' lookup of auth.gmane.org responded with code NXDOMAIN 
Domain name not found: auth.gmane.org".  Bah humbug :(

--
Kindest regards.

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


Re: Gmane seems to be gone

2018-02-18 Thread breamoreboy
On Sunday, February 18, 2018 at 1:18:20 AM UTC, Grant Edwards wrote:
> I've been dreading this moment for a couple years: it looks like
> gmane.org is gone.  The original operator/maintainer gave up a couple
> years ago and pulled the plug. Somebody else took over at that point.
> The Web UI was never revived, but the basic NNTP<->mailing-list gateway
> continue to work -- until tonight.  Now the domain is gone.  Perhaps
> it's just an oversight, but I've got a bad feeling...
> 
> I really, really prefer using slrn and an NNTP server to follow
> mailing lists, and I was using gmane to follow about a dozen of them
> (including the Python list).  At least for python, there's still a
> Usenet gateway.  Unfortunately, that's not true for any of the other
> lists that I used to follow on gmane.org.
> 
> Does anybody have any idea what it would take to set up a private NNTP
> server that served articles from a dozen or so IMAP mailboxes?
> 
> How hard would it be to write something like that in Python?  I've got
> a pretty good handle on the IMAP end of things, but I've got no clue
> about the NNTP server end.
> 
> -- 
> Grant

I can still see it.  I subscribe to gwene.com.stackoverflow.feeds.julia-lang 
and I received the last two questions at 02:05 and 03:33 UTC.  I recall that 
when things used to go up the creek on the Python side of things I'd email 
larsi at gnus dot org and he'd restart things.  I've no idea what to do 
nowadays, sorry.

--
Kindest regards.

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


Re: This newsgroup (comp.lang.python) may soon be blocked by Google Gro

2018-02-08 Thread breamoreboy
On Sunday, February 4, 2018 at 12:15:16 AM UTC, pyotr filipivich wrote:

> Those of us who do not use google-groups may not notice the loss
> of the google groupies.
> --
> pyotr filipivich
> Next month's Panel: Graft - Boon or blessing?

This topic has been hidden because you reported it for abuse. (+39 more)
Re: This newsgroup (comp.lang.python) may soon be blocked by Google Gro (2)
By pyotr filipivich
4 posts 14 views
5:48 PM
How to set/update value in a xml file using requests in python (5)
By Sum J
5 posts 21 views
4:45 PM
EuroPython 2018: Getting ready (1)
By M.-A. Lemburg
1 post 3 views
3:40 PM
How to work on a package (11)
By Roel Schroeven
11 posts 34 views
3:19 PM
This topic has been hidden because you reported it for abuse. (+25 more)
Benchmarking Django on PyPy with unittest? (1)
By Etienne Robillard
6 posts 18 views
9:33 AM
This topic has been hidden because you reported it for abuse. (+18 more)
Does anyone know ni? (6)
By Roel Schroeven
6 posts 17 views
12:15 AM
This topic has been hidden because you reported it for abuse. +1 more 

The above is taken from my small laptop screen showing just how useless google 
groups is, so it might as well be blown away completely, or is it impossible 
for the PSF to take on google?

The most that I've ever whacked in one hit was +55 more, all of it the Case 
Solutions/Test Bank crap.

Just saying.

--
Kindest regards.

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


Re: Where is _sre.SRE_Match?

2018-02-07 Thread breamoreboy
On Wednesday, February 7, 2018 at 5:20:42 PM UTC, Chris Angelico wrote:
> On Thu, Feb 8, 2018 at 4:15 AM, Peng Yu wrote:
> > Hi,
> >
> > I see _sre.SRE_Match is returned by re.match. But I don't find where
> > it is defined. Does anybody know how to get its help page within
> > python command line? Thanks.
> >
>  import re
>  m = re.match('a', 'abc')
>  print type(m)
> > 
>  _sre.SRE_Match
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > NameError: name '_sre' is not defined
> >
> 
> You can "import _sre" if you want access to that module, but the
> leading underscore is a strong indication that this isn't something
> you should be looking at - it's an implementation detail.
> 
> Python 3 makes this type public:
> 
> >>> import re
> >>> re.match('a', 'abc')
> 
> >>> re.Match
> 
> 
> So if you truly need to examine this type, I suggest switching to a
> newer Python.
> 
> ChrisA

I'm confused:-

Python 3.6.3 (default, Oct  3 2017, 21:45:48) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.match('a', 'abc')
<_sre.SRE_Match object; span=(0, 1), match='a'>
>>> 

Perhaps not, https://bugs.python.org/issue30397 so 3.7 only.

--
Kindestregards.

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


Re: From recovery.js to recoveryjsonlz4

2018-02-05 Thread breamoreboy
On Monday, February 5, 2018 at 1:28:16 PM UTC, Cecil Westerhof wrote:
> I have a script to get the number of windows and tabs that firefox
> uses. It always used a file recovery.js, but it changed to
> recovery.jsonlz4.
> 
> Looking at the extension I would think it is an lz4 compressed file.
> But when I use:
> import lz4
> 
> I see that it is deprecated. How should I work with this file?
> 
> -- 
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof

I can't see anything here http://python-lz4.readthedocs.io/en/stable/lz4.html 
to indicate that the package is deprecated, although the lz4version function 
has been since version 0.14.  Further the latest 0.21.6 was released just 
yesterday, 04/02/2018, so I'm guessing that you've just misread something.

--
Kindest regards.

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


Re: This newsgroup (comp.lang.python) may soon be blocked by Google Groups

2018-02-03 Thread breamoreboy
On Thursday, February 1, 2018 at 5:01:58 PM UTC, superchromix wrote:
> Our own programming discussion newsgroup, located at comp.lang.idl-pvwave, 
> started receiving spam messages several months ago.
> 
> Two weeks ago, access to comp.lang.idl-pvwave was blocked by Google Groups.  
> 
> When trying to access comp.lang.idl-pvwave, a message is now displayed, 
> stating that the group owner needs to remove the spam, and can then apply to 
> Google in order to have access reinstated.
> 
> However, old public Usenet groups like this have no owner.  The 
> comp.lang.idl-pvwave group is more than 20 years old.  Hence, there is no way 
> to unblock the group.
> 
> This is a serious problem, since the entire collection of postings going back 
> many years has been blocked, no just the spam.  This resource is frequently 
> used by IDL programmers.
> 
> Seeing the spam postings in this newsgroup, I expect something similar may 
> happen to comp.lang.python, soon.

That's no big deal as this list used to have a wonderful signal to noise ratio, 
now it would be better to report the noise to signal ratio.  I've just finished 
flagging up 45 consecutive messages on the group as spam, all of them from 
today and all of them from the "Case Solutions" crew.

The downside of this list being blocked is that you'd all no doubt miss my 
wonderful contributions :)  Unless of course a new list is opened, properly 
moderated, with a really original name like python-users.

--
Kindest regards.

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


Re: Help to debug my free library

2018-01-31 Thread breamoreboy
On Wednesday, January 31, 2018 at 7:41:50 PM UTC, Victor Porton wrote:
> wxjmfa...@gmail.com wrote:
> 
> > Le mercredi 31 janvier 2018 20:13:06 UTC+1, Chris Angelico a écrit :
> >> On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton wrote:
> >> > LibComCom is a C library which passes a string as stdin of an OS
> >> > command and stores its stdout in another string.
> >> 
> >> Something like the built-in subprocess module does?
> >> 
> >> ChrisA
> > 
> > Do you mean the buggy subprocess module (coding of characters) ?
> 
> Please elaborate: which bugs it has? in which versions?
> 
> > Yes, there is a working workaround : QtCore.QProcess().
> -- 
> Victor Porton - http://portonvictor.org

You've now met the RUE, the Resident Unicode Expert.  For years he's been 
stating that the Python 3 Flexible String Representation is buggy, to the 
extent that Python 3.6.2 is unusable on Windows.  Strangely he cannot produce a 
shred of evidence to support his case so feel free to ignore him.

--
Kindest regards.

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


Re: Please help on print string that contains 'tab' and 'newline'

2018-01-27 Thread breamoreboy
On Saturday, January 27, 2018 at 8:16:58 PM UTC, Jason Qian wrote:
> HI
> 
>I am a string that contains \r\n\t
> 
>[Ljava.lang.Object; does not exist*\r\n\t*at com.livecluster.core.tasklet
> 
>I would like it print as :
> 
> [Ljava.lang.Object; does not exist
>   tat com.livecluster.core.tasklet

Unless I've missed something just call print on the string.

>>> print('[Ljava.lang.Object; does not exist*\r\n\t*at 
>>> com.livecluster.core.tasklet')
[Ljava.lang.Object; does not exist*
*at com.livecluster.core.tasklet

--
Kindest regards.

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


Re: How to use asyncore with SSL?

2018-01-22 Thread breamoreboy
On Thursday, January 18, 2018 at 11:25:58 PM UTC, Grant Edwards wrote:
> I've been trying to use the secure smtpd module from
> https://github.com/bcoe/secure-smtpd, but the SSL support seems to be
> fundamentally broken.  That module simply wraps a socket and then
> expects to use it in the normal way via asyncore.
> 
> Of course that fails the first time an ssl-wrapped-socket's send or
> recv method raises SSLWantReadError or SSLWantWriteError.  Those
> exceptions aren't handled and it crashes.
> 
> That makes the SSL support pretty much useless.
> 
> I'm trying to fix that, but I can't find any information or
> documentation about using asyncore with SSL.
> 
> Alternatively, a pointer to a simpler smtp server library that
> supports SSL would be great. The use of asyncore and multiprocessing
> process pools by this module is _way_ overkill for my needs and
> results in something that 1) doesn't work, and 2) can't be debugged.
> 
> -- 
> Grant Edwards   grant.b.edwardsYow! Pardon me, but do you
>   at   know what it means to be
>   gmail.comTRULY ONE with your BOOTH!

I haven't tried it myself but I've just stumbled across this 
https://github.com/aio-libs/aiosmtpd.

--
Kindest regards.

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


Re: Installing "kitchen" module

2018-01-22 Thread breamoreboy
On Monday, January 22, 2018 at 3:37:44 PM UTC, codyda...@gmail.com wrote:
> So here's the situation. I am unfamiliar with Python but need it to export a 
> wiki, so I have been following this tutorial, using the latest version of 
> Python 2 on Windows 7:
> 
> https://github.com/WikiTeam/wikiteam/wiki/Tutorial#I_have_no_shell_access_to_server
> 
> I have everything working up to the point where I run it and it tells me this:
> 
> "Please install the Kitchen module.
> Please install or update the Requests module."
> 
> One suggestion was that I try "import kitchen", but that gives me this error:
> 
> "Traceback :
>   File "", line 1, in 
> ImportError: No module named kitchen"
> 
> So I went to https://pypi.python.org/pypi/kitchen/ to download it, but that 
> hasn't helped. Maybe it needs to be in a specific folder to work?
> 
> Any help would be appreciated.
> 
> P.S. Here is someone else running into the same problem but they seemed to 
> have fixed it through a solution that didn't work for me (it doesn't 
> recognise a command called sudo in the first place when I type it): 
> https://github.com/WikiTeam/wikiteam/issues/252

Forget sudo as that's a *nix command.  From the command line you should be able 
to run:-

pip install kitchen
pip install requests

--
Kindest regards.

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


Re: error message by installation

2018-01-19 Thread breamoreboy
On Friday, January 19, 2018 at 8:47:52 PM UTC, i.na...@yahoo.com wrote:
> kindly inform me what to do.

Please read this http://www.catb.org/esr/faqs/smart-questions.html and then try 
asking again.

--
Kindest regards.

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


Re: Where are the moderators?

2018-01-18 Thread breamoreboy
On Thursday, January 18, 2018 at 10:38:18 PM UTC, Mike Driscoll wrote:
> Hi,
> 
> What happened to the moderators? I have always liked this forum, but there's 
> so much spam now. Is there a way to become a moderator so this can be cleaned 
> up?
> 
> Thanks,
> Mike

Simply point your email client at news.gmane.org and take your pick from 
hundreds of Python lists and thousands of other technical lists that are all 
spam free.

--
Kindest regards.

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


Re: Speeding up the implementation of Stochastic Gradient Ascent in Python

2018-01-17 Thread breamoreboy
On Wednesday, January 17, 2018 at 2:30:13 PM UTC, Leo wrote:
> Hello everyone, 
> 
> I am implementing a time-dependent Recommender System which applies BPR 
> (Bayesian Personalized Ranking), where Stochastic Gradient Ascent is used to 
> learn the parameters of the model. Such that, one iteration involves sampling 
> randomly the quadruple (i.e. userID, positive_item, negative_item, 
> epoch_index) for n times, where n is the total number of positive feedbacks 
> (i.e. the number of ratings given to all items). But, as my implementation 
> takes too much time for learning the parameters (since it requires 100 
> iterations to learn the parameters), I was wondering if there is a way to 
> improve my code and speed up the learning process of the parameters.
> 
> Please find the code of my implementation (the update function named as 
> updateFactors is the one that learns the parameters, and such that I guess is 
> the one that should be improved in order to speed up the process of learning 
> the parameter values) in the following link: 
> https://codereview.stackexchange.com/questions/183707/speeding-up-the-implementation-of-stochastic-gradient-ascent-in-python

You have a fair chunk of code so I've only taken a quick glance so this could 
just be the tip of the iceberg.

You're clearly using Python 2 as you have print statements, not functions.  If 
you can upgrade to Python 3 is it is superior, see e.g. 
https://www.youtube.com/watch?v=f_6vDi7ywuA

for i in range(1, len(self.userItems[userID])):

is a code smell, consider using

for userItem in self.userItems[userID]:

if len(pos_per_user[userID]) == 0:

is written

if pos_per_user[userID]:

if userID == None:

should be

if userID is None:

Profile your code with https://docs.python.org/3/library/profile.html to find 
where the hot spots are.

Read https://wiki.python.org/moin/PythonSpeed/PerformanceTips for tips on how 
to up your code performance.

--
Kindest regards.

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


Re: Why does pylint give this warning?

2018-01-14 Thread breamoreboy
On Sunday, January 14, 2018 at 10:32:44 PM UTC, Skip Montanaro wrote:
> > I cannot replicate this with
> >
> > $ pylint --version
> > Using config file /home/petto/.pylintrc
> > pylint 1.8.1,
> > astroid 1.6.0
> > Python 3.4.0 (default, Apr 11 2014, 13:05:11)
> > [GCC 4.8.2]
> >
> > $ cat pylint_fodder.py
> > class FooBar:
> > def __len__(self):
> > return 42
> > def __repr__(self):
> > return "FooBar(length={})".format(len(self))
> >
> > $ pylint pylint_fodder.py
> > Using config file /home/petto/.pylintrc
> > * Module pylint_fodder
> > C:  1, 0: Missing module docstring (missing-docstring)
> > C:  1, 0: Missing class docstring (missing-docstring)
> > R:  1, 0: Too few public methods (0/2) (too-few-public-methods)
> 
> Ditto. Mark, do you have any tweaks in your .pylintrc file which might
> affect it?
> 
> Skip

Having followed Peter's advice everything worked a treat once I'd put my 
changes  into the new configuration file.  Having compared it to the old one it 
looks as if I'd upgraded pylint but didn't regenerate the config file, as there 
were a number of obvious changes.  Thanks for the help guys, and if nothing 
else this is on the record for anyone with the same or similar problems.

--
Kindest regards.

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


Why does pylint give this warning?

2018-01-14 Thread breamoreboy
The warning is 'C0103:Method name "__len__" doesn't conform to 
'_?_?[a-z][A-Za-z0-9]{1,30}$' pattern' but it doesn't complain about __repr__ 
or __str__.  If there is an explanation out in the wild my search fu has missed 
it :-(

My setup on Ubuntu 17.10 is:-

$ pylint --version
Using config file /home/mark/.pylintrc
pylint 1.8.1, 
astroid 1.6.0
Python 3.6.3 (default, Oct  3 2017, 21:45:48) 
[GCC 7.2.0]

--
Kindest regards.

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


Re: Simple graphic library for beginners

2018-01-12 Thread breamoreboy
On Friday, January 12, 2018 at 6:52:32 AM UTC, Steven D'Aprano wrote:
> On Fri, 12 Jan 2018 12:45:04 +1300, Gregory Ewing wrote:
> 
> > Seems to me it would help if pip were to announce which version of
> > Python it's installing things into. And instead of just saying "not
> > compatible with this version of Python", say "not compatible with Python
> > X.Y.Z". That would make these kinds of problems much easier to diagnose.
> 
> This.
> 
> If pip is joined at the hip to a specific version of Python, I think that 
> we ought to be able to specify the version number like we can with Python.
> 
> Something like:
> 
> pip ...  # use whichever version of pip comes first on the PATH
> pip3.6 ...  # use the pip installed with Python 3.6
> pip2.7 ...  # use the pip installed with Python 2.7

The time machine has struck again.  The scripts directory on Windows always 
gives you three executables.  pip.exe is always one of them, and then (say) 
pip3.exe and pip3.6.exe.

> etc.
> 
> And don't say "use a venv" :-)
> -- 
> Steven D'Aprano

--
Kindest regards.

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


Re: Simple graphic library for beginners

2018-01-11 Thread breamoreboy
On Thursday, January 11, 2018 at 8:34:30 PM UTC, bartc wrote:
> On 11/01/2018 20:12, Chris Angelico wrote:
> > On Fri, Jan 12, 2018 at 7:02 AM, bartc  wrote:
> >> On 11/01/2018 19:41, Paul Moore wrote:
> >>>
> >>> On 11 January 2018 at 18:33, bartc  wrote:
> >>
> >>
> >>>   python -m pip install XXX
> >>>
> >>> just works, for 99% of things anyone wants. In particular it works for
> >>> pygame.
> >>>
> >>> Continuing to complain about a situation that has been resolved for a
> >>> year or more
> >>
> >>
> >> I tried that on my brand-new, just installed Python 3.7. It didn't work as
> >> detailed in my other post.
> >>
> >> Please don't assume that because it works for you, that it MUST work for
> >> everyone, and that they must be doing something wrong if it doesn't.
> >>
> >> Apparently it's missing a file called 'Setup'. Is it my fault if it can't
> >> find it? Or if it insists on continuing to install something even when some
> >> vital component is missing.
> >>
> > 
> > Most people would use the latest STABLE RELEASE of a language, if they
> > expect it to be stable. Unreleased versions, alphas, and so on, may be
> > very useful, but should not be expected to work perfectly with all
> > third-party modules.
> 
> 
>  >> I downloaded Python 3.7. It didn't work.
>  >
>  > Where from?
> 
> I found it at www.python.org. (in /downloads/windows). Although it said 
> 'latest' release was 3.6.4, it didn't say anything about 3.7 being alpha 
> or beta release.
> 

>From [1] the title is "[RELEASE] Python 3.7.0a4 is now available for testing".

The full text is:-


Python 3.7.0a4 is the last of four planned alpha releases of Python 3.7,
the next feature release of Python.  During the alpha phase, Python 3.7
remains under heavy development: additional features will be added
and existing features may be modified or deleted.  Please keep in mind
that this is a preview release and its use is not recommended for
production environments.  The next preview release, 3.7.0b1, is planned
for 2018-01-29. You can find Python 3.7.0a4 and more information here:

https://www.python.org/downloads/release/python-370a4/


The link is dated Tue Jan 9 10:48:01 EST 2018, two whole days ago.

[1]https://mail.python.org/pipermail/python-list/2018-January/729985.html

--
Kindest regards.

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


Re: Simple graphic library for beginners

2018-01-10 Thread breamoreboy
On Wednesday, January 10, 2018 at 12:42:07 PM UTC, Jan Erik Moström wrote:
> I'm looking for a really easy to use graphic library. The target users 
> are teachers who have never programmed before and is taking a first (and 
> possible last) programming course.
> 
> I would like to have the ability to draw lines, circles, etc. Nothing 
> fancy, as little window management as possible (possible buttons), 
> perhaps simple events like button presses or clicks on canvas - think: 
> making simple diagrams or simple figures. Cross-platform
> 
> 
> Yes, I know about tkinter.
> 
> Yes, I know about various block languages like Scratch but they are not 
> relevant in this case.
> 
> Any suggestions?
> 
> = jem

Take a look at https://python-sfml.org/, https://www.ogre3d.org/about or 
mcsp.wartburg.edu/zelle/python/graphics.py

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


Re: Plot map wit a white and black box

2018-01-08 Thread breamoreboy
On Monday, January 8, 2018 at 1:16:08 PM UTC, jorge@cptec.inpe.br wrote:
> Hi,
> 
> Please, I woudl like to plot a map like this figure. How can I do this 
> using Python2.7
> 
> Thanks,
> 
> Conrado

Figures don't get through and you've all ready asked this question, possibly on 
another forum.  What was wrong with the replies that you got then?

--
Kindest regards.

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


Re: Why does __ne__ exist?

2018-01-07 Thread breamoreboy
On Monday, January 8, 2018 at 12:02:09 AM UTC, Ethan Furman wrote:
> On 01/07/2018 12:33 PM, Chris Angelico wrote:
> > On Mon, Jan 8, 2018 at 7:13 AM, Thomas Jollans wrote:
> >> On 07/01/18 20:55, Chris Angelico wrote:
> >>> Under what circumstances would you want "x != y" to be different from
> >>> "not (x == y)" ?
> >>
> >> In numpy, __eq__ and __ne__ do not, in general, return bools.
> >>
> > a = np.array([1,2,3,4])
> > b = np.array([0,2,0,4])
> > a == b
> >> array([False,  True, False,  True], dtype=bool)
> > a != b
> >> array([ True, False,  True, False], dtype=bool)
> >
> > Thanks, that's the kind of example I was looking for. Though numpy
> > doesn't drive the core language development much, so the obvious next
> > question is: was this why __ne__ was implemented, or was there some
> > other reason? This example shows how it can be useful, but not why it
> > exists.
> 
> Actually, I think it is why it exists.  If I recall correctly, the addition 
> of the six comparative operators* was added 
> at the behest of the scientific/numerical community.
> 
> --
> ~Ethan~
> 
> * Yeah, I can't remember the cool name for those six operators at the moment. 
>  :(

The six rich comparison methods were added to 2.1 as a result of PEP 207, which 
confirms that you're correct, they were added at the request of the numpyites.

--
Kindest regards.

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


Re: Why does __ne__ exist?

2018-01-07 Thread breamoreboy
On Sunday, January 7, 2018 at 7:55:57 PM UTC, Chris Angelico wrote:
> Whoops, premature send. Picking up from the last paragraph.
> 
> This is good. This is correct. For inequalities, you can't assume that
> >= is the exact opposite of < or the combination of < and == (for
> example, sets don't behave like numbers, so "x <= y" is very different
> from "x < y or x == y"). But the one that confuses me is != or __ne__.
> If you don't create it, you get default behaviour:
> 
> >>> class Ham:
> ... def __eq__(self, other):
> ... print("%s equals %s" % (self, other))
> ... return True
> ...
> >>> Ham() == 1
> <__main__.Ham object at 0x7fb7557c0278> equals 1
> True
> >>> 2 == Ham()
> <__main__.Ham object at 0x7fb7557c0278> equals 2
> True
> >>> Ham() != 3
> <__main__.Ham object at 0x7fb7557c0278> equals 3
> False
> >>> 4 != Ham()
> <__main__.Ham object at 0x7fb7557c0278> equals 4
> False
> >>> x = Ham()
> >>> x == x
> <__main__.Ham object at 0x7fb7557b80f0> equals <__main__.Ham object at
> 0x7fb7557b80f0>
> True
> >>> x != x
> <__main__.Ham object at 0x7fb7557b80f0> equals <__main__.Ham object at
> 0x7fb7557b80f0>
> False
> 
> Under what circumstances would you want "x != y" to be different from
> "not (x == y)" ? How would this make for sane behaviour? Even when
> other things go weird with equality checks, that basic parallel is
> always maintained:
> 
> >>> z = float("nan")
> >>> z == z
> False
> >>> z != z
> True
> 
> Python gives us a "not in" operator that uses __contains__ and then
> negates the result. There is no way for "x not in y" to be anything
> different from "not (x in y)", as evidenced by the peephole optimizer:
> 
> >>> dis.dis("x not in y")
>   1   0 LOAD_NAME0 (x)
>   2 LOAD_NAME1 (y)
>   4 COMPARE_OP   7 (not in)
>   6 RETURN_VALUE
> >>> dis.dis("not (x in y)")
>   1   0 LOAD_NAME0 (x)
>   2 LOAD_NAME1 (y)
>   4 COMPARE_OP   7 (not in)
>   6 RETURN_VALUE
> 
> So why isn't != done the same way? Is it historical?
> 
> ChrisA

I'd say this is certainly historical, remembering that in Python 2 you used to 
be able to compare all sorts of things, whereas in Python 3 you'll get:-

>>> 1 < "a"
Traceback (most recent call last):
  File "", line 1, in 
TypeError: '<' not supported between instances of 'int' and 'str'
>>> 

This seems to be confirmed by the following.  From the third paragraph at 
https://docs.python.org/2/reference/datamodel.html#object.__ne__ "There are no 
implied relationships among the comparison operators. The truth of x==y does 
not imply that x!=y is false. Accordingly, when defining __eq__(), one should 
also define __ne__() so that the operators will behave as expected...".  
Compare that with the Python 3 equivalent "By default, __ne__() delegates to 
__eq__() and inverts the result unless it is NotImplemented. There are no other 
implied relationships among the comparison operators, for example, the truth of 
(xhttps://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: stop prohibition of comp.lang.python ! D'Oliveiro should wear this as a badge of honour.

2018-01-01 Thread breamoreboy
On Monday, January 1, 2018 at 11:06:30 PM UTC, P. timoriensis wrote:
> >> stop prohibition of comp.lang.python !
> >>
> >> it is childish to do this prohibition business !
> >>
> >> don't you have spam filters ?
> > 
> > The prohibition part of the subject line is added by Lawrence D'Oliveiro 
> > when he posts on google groups as he's been banned from the mailing list.  
> > Most people won't see it until someone replies to his post via their email 
> > to the list.
> 
> > Mark Lawrence.
>  
> these cases are always the same: the censors in 99% of the cases are utterly 
> wrong.
> 
> 
> D'Oliveiro must be a good man, proof is here. 
> I know what to think about python-list censorship already.

Like the case of the guy who was banned as he was using the list to spread 
antisemitic drivel through his signatures?

If you don't like this facility you are perfectly welcome to leave and never 
come back.

--
Kindest regards.

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


Re: ✨🍰✨ python 2018 wiki - a piece of cake ✨🍰✨

2018-01-01 Thread breamoreboy
On Monday, January 1, 2018 at 2:54:26 PM UTC, S. I. wrote:
> https://practical-scheme.net/wiliki/wiliki.cgi?python
> 
> no register, no nothing !   just edit.
> 
> ✨🍰✨  python - a piece of cake  ✨🍰✨
> 
> just edit or enter acode.py   entry with 
>  
> {{{
> 
> print(" oh yes, 2018   ")
> 
> }}}

From the link "Look at those scumbag admins over at the py wiki.", "what utter 
pieces of s., man: 
https://mail.python.org/pipermail/pydotorg-www/2017-June/004316.html";, "the 
scum admins are waging another wiki war, follow it here: 
https://mail.python.org/pipermail/pydotorg-www/";, "more Lemburg-type bs:" and 
"Nothing but scum in the py wiki".  Were you the author of "How To Win Friends 
And Influence People"?

--
Kindest regards.

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


Re: stop prohibition of comp.lang.python !

2018-01-01 Thread breamoreboy
On Monday, January 1, 2018 at 3:00:19 PM UTC, S. I. wrote:
> stop prohibition of comp.lang.python !
> 
> it is childish to do this prohibition business !
> 
> don't you have spam filters ?

The prohibition part of the subject line is added by Lawrence D'Oliveiro when 
he posts on google groups as he's been banned from the mailing list.  Most 
people won't see it until someone replies to his post via their email to the 
list.

--
Kindest regards.

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


Re: ... (Posting On Python-List Prohibited)

2018-01-01 Thread breamoreboy
On Monday, January 1, 2018 at 9:28:01 PM UTC, Wu Xi wrote:
> > Blocking of spamming and trolling prevents oppression of people who want to 
> > use the list, funded by PSF, for its purpose, discussion of Python.
> 
> why are PSF funds privileged over anybody else's fund, which has zero 
> privilege?

Congratulations, after just a couple of days you're all ready pushing for a 
place in my dream team.

--
Kindest regards.

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


Re: ... (Posting On Python-List Prohibited)

2018-01-01 Thread breamoreboy
On Monday, January 1, 2018 at 10:21:15 PM UTC, P. timoriensis wrote:
> >>> Blocking of spamming and trolling prevents oppression of people who want 
> >>> to use the list, funded by PSF, for its purpose, discussion of Python.
> >>
> >> why are PSF funds privileged over anybody else's fund, which has zero 
> >> privilege?
> > 
> > Congratulations, after just a couple of days you're all ready pushing for a 
> > place in my dream team.
> 
> you sure would make for just another one of those self-appointed censors, who 
> won't react to legit questions, when they realize how dangerous they are.

I don't see a legitimate question, I see a completely stupid question.  The PSF 
pays the money, the PSF takes their choice.  If you don't like that you're 
perfectly free to use reddit, stackoverflow or any other forum.

--
Kindest regards.

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


Re: Goto (Posting On Python-List Prohibited)

2018-01-01 Thread breamoreboy
On Monday, January 1, 2018 at 9:35:06 PM UTC, Chris Angelico wrote:
> On Tue, Jan 2, 2018 at 7:16 AM, Chris Green wrote:
> > Dennis Lee Bieber wrote:
> >>
> >> Well... "break" does bypass the rest of the block, but it still 
> >> exits
> >> via the end of the block. I have a tendency to try for one "return" per
> >> procedure (so I'm more likely to have an "if ...: break" then "if ...:
> >> return").
> >
> > I have always tried to enforce 'only one return per function'.  If
> > there are multiple returns it makes maintenance very difficult as
> > 'clear up' code can get bypassed.
> >
> 
> Isn't that why try/finally exists? No matter how many 'return'
> statements you have, there's always exceptions to bypass any naive
> cleanup code; and no matter how many returns you have, 'finally'
> blocks still execute before return.
> 
> ChrisA

What happened to context managers?

--
Kindest regards.

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


Re: Copy-on-write friendly Python garbage collection

2018-01-01 Thread breamoreboy
On Monday, January 1, 2018 at 12:53:03 PM UTC, Wu Xi wrote:
> breamoreboy:
> > On Sunday, December 31, 2017 at 6:19:13 PM UTC, Wu Xi wrote:
> >> 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
> >>
> >> Appearantly, Erlang is the way to go, when it comes to web frameworks.
> > 
> > What has that got to do with the subject of this thread?
> 
> Well, a little implicitly. Pointing out Erlang superiority in a pythonic 
> newsgroup is, of course, heresy.

Python is fourth in the latest TIOBE index, Erlang doesn't even make the top 
20, so in what way is it superior?

Python doesn't need Pinky and the Brain in its quest to take over the world.

--
Kindest regards.

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


Re: Goto (Posting On Python-List Prohibited)

2018-01-01 Thread breamoreboy
On Sunday, December 31, 2017 at 6:56:16 PM UTC, bartc wrote:
> On 31/12/2017 17:01, breamoreboy wrote:
> 
> >Further I've never once in 17 years of using Python been tearing my hair out 
> >over the lack of goto
> 
> Neither have I over all the advanced features of Python I never use, and 
> for double that number of years.

I suggest that you steer well clear of all of Python's advanced features until 
you understand the Python philosophy as laid down in the Zen of Python.  
However I cannot see that happening as you seem to dispute everything about 
Python, flying in the face of any advice that you get from all the very 
experienced Pythonistas who frequent this place.  You must have access to the 
PSU's time machine if you've 34 years experience of Python as it hasn't been 
out that long.

> 
> Yet for some they will be as indispensable as they are incomprehensible 
> to others.

Let's all go back to machine code.

--
Kindest regards.

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


Re: Copy-on-write friendly Python garbage collection

2018-01-01 Thread breamoreboy
On Sunday, December 31, 2017 at 6:19:13 PM UTC, Wu Xi wrote:
> 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
> 
> Appearantly, Erlang is the way to go, when it comes to web frameworks.

What has that got to do with the subject of this thread?

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


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

2017-12-28 Thread breamoreboy
On Friday, December 29, 2017 at 3:28:23 AM UTC, Ben Finney wrote:
> Tim Chase writes:
> 
> > [third-party website]
> > Gives you […]
> 
> So, it's not in Python, it's a third-party (joke) package. Hence is
> probably not what Duram is asking about as “goto in Python”.
> 
> I'm still open to learning what Duram meant by “goto in Python”. Rather
> than everyone else piling on with suggestions, can we let Duram answer?
> 
> -- 
>  \  “Think for yourselves and let others enjoy the privilege to do |
>   `\  so too.” —Voltaire, _Essay On Tolerance_ |
> _o__)  |
> Ben Finney

Did you miss Tim's wink, which you've cut from your reply, or did you get out 
of bed on the wrong side this morning, or what?

--
Kindest regards.

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


Re: Goto

2017-12-28 Thread breamoreboy
On Thursday, December 28, 2017 at 7:40:14 PM UTC, alister wrote:
> On Thu, 28 Dec 2017 00:58:48 -0200, Duram wrote:
> 
> > How to use goto in python?
> > 
> > ---
> > This email has been checked for viruses by AVG.
> > http://www.avg.com
> 
> Dont!
> actually you cant - there isn't one*
> 
> *at least not in the core language no doubt some sick person will have 
> manager to hack together some sort of dodgy code to simulate it if you 
> look hard enough)
> 

This http://entrian.com/goto/ has been around for almost 14 years.

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


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


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


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


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


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: 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: 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: 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&R2", 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: 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: 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: 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: Lies in education [was Re: The "loop and a half"]

2017-10-04 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: 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: 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: 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: 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: Textwrap doesn't honour NO-BREAK SPACE

2017-09-29 Thread breamoreboy
On Friday, September 29, 2017 at 6:46:31 AM UTC+1, Frank Millman wrote:
> "Steve D'Aprano"  wrote
> 
> I don't have Python 3.6 installed, can somebody check to see whether or not 
> it
> shows the same (wrong) behaviour?
> 
> [...]
> 
> C:\Users\User>python
> Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit 
> (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import textwrap
> >>> text = ('Lorum ipsum dolor sit amet, consectetur adipiscing'
> ... ' elit ZZZ\xa0ZZZ sed do euismod tempor incididunt'
> ... ' ut labore et dolore magna aliqua.')
> >>> print(textwrap.fill(text, 59))
> Lorum ipsum dolor sit amet, consectetur adipiscing elit
> ZZZ ZZZ sed do euismod tempor incididunt ut labore et
> dolore magna aliqua.
> >>>
> 
> It seems to have been fixed.
> 
> Frank Millman

FTR https://bugs.python.org/issue20491

--
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: Research paper "Energy Efficiency across Programming Languages: How does energy, time, and memory relate?"

2017-09-18 Thread breamoreboy
On Monday, September 18, 2017 at 10:21:55 PM UTC+1, John Ladasky wrote:
> On Saturday, September 16, 2017 at 11:01:03 PM UTC-7, Terry Reedy wrote:
> > On 9/16/2017 7:04 PM, b...@g...com wrote:
> 
> > The particular crippler for CLBG problems is the non-use of numpy in 
> > numerical calculations, such as the n-body problem.  Numerical python 
> > extensions are over two decades old and give Python code access to 
> > optimized, compiled BLAS, LinPack, FFTPack, and so on.  The current one, 
> > numpy, is the third of the series.  It is both a historical accident and 
> > a continuing administrative convenience that numpy is not part of the 
> > Python stdlib.
> 
> OK, I found this statement intriguing.  Honestly, I can't function without 
> Numpy, but I have always assumed that many Python programmers do so.  
> Meanwhile: most of the time, I have no use for urllib, but that module is in 
> the standard library.
> 
> I noticed the adoption of the @ operation for matrix multiplication.  I have 
> yet to use it myself.
> 
> So is there a fraction of the Python community that thinks that Numpy should 
> in fact become part of the Python stdlib?  What is the "administrative 
> convenience" to which you refer?

My very opinionated personnal opinion is that many third party libraries are 
much better off outside of the stdlib, numpy particulary so as it's one of the 
most used, if not the most used, such libraries.

My rationale is simple, the authors of the libraries are not tied into the 
(c)Python release cycle, the PEP process or anything else, they can just get on 
with it.

Consider my approach many blue moons ago when I was asking when the "new" regex 
module was going to be incorporated into Python, and getting a bit miffed in my 
normal XXXL size hat autistic way when it didn't happen.  I am now convinved 
that back then I was very firmly wrong, and that staying out of the stdlib has 
been the best thing that could have happened to regex.  No doubt MRAB will 
disagree :)

--
Kindest regards.

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


Re: Old Man Yells At Cloud

2017-09-17 Thread breamoreboy
On Sunday, September 17, 2017 at 2:16:48 PM UTC+1, bartc wrote:
> 
> print can also be used for debugging, when it might be written, deleted 
> and added again hundreds of times. So writing all those brackets becomes 
> irksome. 'print' needs to be easy to write.
> 
> -- 
> bartc

Experienced Python programmers use the logging module for debugging, write 
once, delete (maybe) never.

--
Kindest regards.

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


Research paper "Energy Efficiency across Programming Languages: How does energy, time, and memory relate?"

2017-09-16 Thread breamoreboy
I thought some might find this 
https://sites.google.com/view/energy-efficiency-languages/ interesting.

--
Kindest regards.

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


CPython has hit 100,000 commits

2017-09-16 Thread breamoreboy
Looks as if people have been busy over the years.  Read all about it 
https://github.com/python/cpython

--
Kindest regards.

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


Re: Python dress

2017-09-13 Thread breamoreboy
On Wednesday, September 13, 2017 at 10:43:47 PM UTC+1, Sean DiZazzo wrote:
> On Tuesday, September 12, 2017 at 9:18:12 AM UTC-7, larry@gmail.com wrote:
> > Not too many females here, but anyway:
> > 
> > https://svahausa.com/collections/shop-by-interest-1/products/python-code-fit-flare-dress
> > 
> > (And if any guys want to wear this, there's nothing wrong with that.)
> 
> I'm going to buy it for my girl wear it to all of my work parties.  :)

What is she going to wear? :)

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

2017-09-09 Thread breamoreboy
On Saturday, September 9, 2017 at 4:09:24 AM UTC+1, boB Stepp wrote:
> On Fri, Sep 8, 2017 at 9:54 PM, Michael Torrie wrote:
> > On 09/08/2017 08:35 PM, V Vishwanathan wrote:
> >> Hi, From what I see in the recent 4/5 digests, this forum seems to be for 
> >> advanced
> >>
> >> and professional programmers.
> >>
> >> So wondering if a newbie can post some questions to understand errors in 
> >> his code
> >>
> >> or will it look silly?
> >
> > Yes you may indeed post here.  There's also a beginners list called
> > python-help, which may seem less intimidating.
> 
> That would be Python Tutor.  Subscription information may be found at
> 
> https://mail.python.org/mailman/listinfo/tutor
> 
> It is a moderated list, so there may be a short delay before your
> first post(s) may come through.
> 
> -- 
> boB

No, there is a help list at https://mail.python.org/mailman/listinfo/python-help

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: 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: No importlib in Python 3 64 bit ?

2017-09-06 Thread breamoreboy
On Wednesday, September 6, 2017 at 2:42:06 PM UTC+1, Andrej Viktorovich wrote:
> Found that pythons have different paths. It might be related?

Definitely :)

> 
> 64 bit
> 
> C:\Users\me\AppData\Local\Programs\Python\Python36-32
> C:\Users\me\AppData\Local\Programs\Python\Python36-32\DLLs
> C:\Users\me\AppData\Local\Programs\Python\Python36-32\Lib
> C:\Program Files\Python36\python36.zip
> C:\Program Files\Python36\DLLs
> C:\Program Files\Python36\lib
> C:\Program Files\Python36
> C:\Program Files\Python36\lib\site-packages

The "C:\Program..." indicates installed for all users, but you're also pulling 
in the 32 bit libs.  Remove them from the path and you're good to go.

> 
> 32bit
> 
> C:\Users\me\AppData\Local\Programs\Python\Python36-32
> C:\Users\me\AppData\Local\Programs\Python\Python36-32\DLLs
> C:\Users\me\AppData\Local\Programs\Python\Python36-32\Lib
> C:\Users\me\AppData\Local\Programs\Python\Python36-32\python36.zip
> C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages

This is a good install for a single user.

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


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


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


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


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


  1   2   3   >