Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Dan Stromberg
On Mon, Jul 2, 2018 at 5:51 PM, Tim Daneliuk  wrote:

> In particular, there is little interest in having programmers
> learn on the job, only that they be as productive as possible
> as fast they can.   Hiring specific languages skills - the theory
> goes - means that the individual will be fluent in the entire
> language ecosystem of libraries, tools, and so forth.  What gets
> lost in this factory model is that fewer and fewer people are able
> to stand back and ask, "Are we even using a good design, language,
> toolkit, ..."
>
One way of looking at it, is the employer doesn't want to hire someone and
see them fail to come up to speed.  It's not fun firing people - it may be
the worst part of being a manager.  Looked at this way, it's a kindness.

Another way of looking at it, is shortsightedness on the part of the
employer.   A good developer can (and should be allowed to) learn new
things.

I think the most pragmatic view might be that employers _hire_ for specific
skills, but when those skills are no longer needed as much, _then_ they
talk about training on something new instead of firing a good developer and
hiring another to fill a (somewhat?) similar role.  I've seen a this
happen.  I don't mean to claim that this is always what happens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multi-threading with a simple timer?

2018-07-03 Thread Robin Becker

On 03/07/2018 07:12, Gregory Ewing wrote:

import signal, sys

def timeout(*args):
 print("Too late!")
 sys.exit(0)

signal.signal(signal.SIGALRM, timeout)
signal.setitimer(signal.ITIMER_REAL, 15)
data = input("Enter something: ")
print("You entered: ", data)


This doesn't work in windows (SIGALRM not available see
https://stackoverflow.com/questions/6947065/right-way-to-run-some-code-with-timeout-in-python)

For completeness I think it needs the handler restoring; this seemed to work for me in linux; I did try using SIG_DFL, but 
apparently that just prints 'Alarm clock' and exits at least


import signal, sys, time

def timeout(*args):
print("Too late!")
sys.exit(0)

signal.signal(signal.SIGALRM, timeout)
signal.setitimer(signal.ITIMER_REAL, 15)
data = input("Enter something: ")
signal.signal(signal.SIGALRM,signal.SIG_IGN)
print("You entered: ", data)
for i in reversed(xrange(15)):
print i
time.sleep(1)

print 'finished!'


if I leave out the signal.signal(signal.SIGALRM,signal.SIG_IGN) then the 
timeout function gets called anyway.
--
Robin Becker

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Gregory Ewing

Steven D'Aprano wrote:

"Jack of all trades, master of none" sort of thing?

Or are you thinking more along the lines of one of those guys who masters 
a new language in an hour and reaches expert level in a week?


I'm not talking about someone who hasn't mastered anything.
I'm talking about someone who has mastered the art of
programming in general. Such a person can learn enough
about an unfamiliar language to do something useful with
it in quite a short time.

why pay somebody to 
learn the language at full senior rates when there are millions of senior 
developers who already know the language?


If they're truly a seasoned programmer, you'll get your
money's worth out of them long before they've mastered
every nook and cranny of the language.

Whereas if you hire a total greenhorn who knows Java
on paper but has no practical programming experience,
you'll be paying them for quite a while before they're
doing you more good than harm.

If you can find someone who's both a seasoned developer
*and* experienced in the particular language required,
that's a bonus, but only a small one.

Also, it assumes you can find two people who are both
equally experienced, except that one knows Java and the
other doesn't.

My conjecture is that given two people, who have been
programming for the same length of time, one of which
knows a wide variety of languages other than Java, and
one that knows *only* Java, the one that knows multiple
languages will almost certainly be a better programmer,
and will be better value for money *even though* it
will take him a little bit of time to pick up Java.

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Steven D'Aprano
On Mon, 02 Jul 2018 18:20:53 -0700, Jim Lee wrote:

> On 07/02/18 17:51, Steven D'Aprano wrote:
>>
>> For most of us mere mortals, the "ten thousand hours" rule of thumb
>> applies.
>>
>> Ten thousand hours should be read as an indefinitely large number
>>
>>> A truly good programmer will be able to learn about the language being
>>> used on the job.
>> Indeed, if you don't mind paying them for the couple of weeks it takes
>> them to come up to speed on the language and the couple of years it
>> takes to master it.
> 
> So we went from 10,000 hours, to infinite, and then back to a couple of
> years?

I said *indefinite* not infinite.

You did read the article I linked to, right? You know that people don't 
suddenly and instantly turn from "beginner" to "expert" when they exceed 
9,999 hours 59 minutes and 59 seconds? Quibbling over the exact number of 
hours is foolish.

Ten thousand hours is a nice round number, and should not be considered 
more precise than an order of magnitude estimate ("more than 1000 hours, 
less than 100,000 hours, on average").

But for what it's worth, if you estimate that the average dedicated 
developer programs 8 hours a day for 330 days a year, between paid work, 
overtime, private projects, and directed study, 10,000 hours works out at 
a bit less than four years.

Or as my wife would say, "did you mean an Aussie couple or an actual 
couple?" I meant an Aussie couple, which could be anything from two to 
four or five. Six at a stretch. As in, "no worries mate, it'll be ready 
in a coupla days."



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: File names with slashes [was Re: error in os.chdir]

2018-07-03 Thread Gregory Ewing

Mikhail V wrote:

  s= "\"s\""   ->
  s=  {"s"}


But now you need to find another way to represent set literals.

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


EuroPython 2018: Schedule available

2018-07-03 Thread M.-A. Lemburg
Over the last few weeks, our program WG has been working hard on
getting the schedule all lined up. Today, we’re releasing it to the
Python world.

 Schedule for EuroPython 2018

 * https://ep2018.europython.eu/en/events/schedule/ *

With 140 speakers and more than 150 sessions, we have a full packed
program waiting for you. Please note that the schedule may still
change in details, but the overall layout is fixed now.


Book your EuroPython 2018 Ticket


Please make sure you book your ticket in the coming days. We will
switch to late bird rates closer to the event.

If you want to attend the training sessions, please buy a training
pass. We only have very few left and will close sales for these later
this week.


Travel & accommodation tips
---

Since we’re close the conference and The Fringe is starting a week
later, Edinburgh is in high demand. If you’re having problems finding
a hotel, please also consider searching for apartments on the well
known booking sites.

For traveling to Edinburgh, we suggest also considering a combination
of plane and train or bus. London, Birmingham and Manchester all
provide train and bus lines going to Edinburgh and by booking a
combination, you can often save a lot, compared to a direct flight to
Edinburgh.


Help spread the word


Please help us spread this message by sharing it on your social
networks as widely as possible. Thank you !

Link to the blog post:

https://blog.europython.eu/post/175502948797/europython-2018-schedule-available

Tweet:

https://twitter.com/europython/status/1014097708536221696


Enjoy,
--
EuroPython Society
https://ep2018.europython.eu/
https://www.europython-society.org/

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


ANN: Python Meeting Düsseldorf - 04.07.2018

2018-07-03 Thread eGenix Team: M.-A. Lemburg
[This announcement is in German since it targets a local user group
 meeting in Düsseldorf, Germany]



ANKÜNDIGUNG

  Python Meeting Düsseldorf

   http://pyddf.de/

Ein Treffen von Python Enthusiasten und Interessierten
 in ungezwungener Atmosphäre.

   Mittwoch, 04.07.2018, 18:00 Uhr
   Raum 1, 2.OG im Bürgerhaus Stadtteilzentrum Bilk
 Düsseldorfer Arcaden, Bachstr. 145, 40217 Düsseldorf

Diese Nachricht ist auch online verfügbar:
https://www.egenix.com/company/news/Python-Meeting-Duesseldorf-2018-07-04


NEUIGKEITEN

 * Bereits angemeldete Vorträge:

Charlie Clark
"Managing package metadata and dynamically loading modules"

Tobey Announced
"Trading mit Python"

Charlie Clark
"Einleitung ins Testing"

   Weitere Vorträge können gerne noch angemeldet werden: [email protected]

 * Startzeit und Ort:

   Wir treffen uns um 18:00 Uhr im Bürgerhaus in den Düsseldorfer
   Arcaden.

   Das Bürgerhaus teilt sich den Eingang mit dem Schwimmbad und
   befindet sich an der Seite der Tiefgarageneinfahrt der Düsseldorfer
   Arcaden.

   Über dem Eingang steht ein großes "Schwimm' in Bilk" Logo. Hinter
   der Tür direkt links zu den zwei Aufzügen, dann in den 2. Stock
   hochfahren. Der Eingang zum Raum 1 liegt direkt links, wenn man aus
   dem Aufzug kommt.

   Google Street View: http://bit.ly/11sCfiw



EINLEITUNG

Das Python Meeting Düsseldorf ist eine regelmäßige Veranstaltung in
Düsseldorf, die sich an Python Begeisterte aus der Region wendet:

 * http://pyddf.de/

Einen guten Überblick über die Vorträge bietet unser YouTube-Kanal,
auf dem wir die Vorträge nach den Meetings veröffentlichen:

 * http://www.youtube.com/pyddf/

Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld,
in Zusammenarbeit mit Clark Consulting & Research, Düsseldorf:

 * http://www.egenix.com/
 * http://www.clark-consulting.eu/



PROGRAMM

Das Python Meeting Düsseldorf nutzt eine Mischung aus (Lightning)
Talks und offener Diskussion.

Vorträge können vorher angemeldet werden, oder auch spontan während
des Treffens eingebracht werden. Ein Beamer mit XGA Auflösung
steht zur Verfügung.

(Lightning) Talk Anmeldung bitte formlos per EMail an [email protected]



KOSTENBETEILIGUNG

Das Python Meeting Düsseldorf wird von Python Nutzern für Python
Nutzer veranstaltet. Um die Kosten zumindest teilweise zu
refinanzieren, bitten wir die Teilnehmer um einen Beitrag in Höhe von
EUR 10,00 inkl. 19% Mwst, Schüler und Studenten zahlen EUR 5,00
inkl. 19% Mwst.

Wir möchten alle Teilnehmer bitten, den Betrag in bar mitzubringen.



ANMELDUNG

Da wir nur für ca. 20 Personen Sitzplätze haben, möchten wir
bitten, sich per EMail anzumelden. Damit wird keine Verpflichtung
eingegangen. Es erleichtert uns allerdings die Planung.

Meeting Anmeldung bitte formlos per EMail an [email protected]



WEITERE INFORMATIONEN

Weitere Informationen finden Sie auf der Webseite des Meetings:

http://pyddf.de/

Mit freundlichen Grüßen,

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Jul 03 2018)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...   http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...   http://zope.egenix.com/


::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
  http://www.malemburg.com/

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


File names with slashes [was Re: error in os.chdir]

2018-07-03 Thread Mikhail V
Greg wrote:

> Mikhail V wrote:
> >   s= "\"s\""   ->
> >   s=  {"s"}
>
> But now you need to find another way to represent set literals.


I need to find? That comment was not about (current) Python but
rather how I think string should have been from the beginning.

So you already like it and want in Python ?  :-)
Fitting it into current Python would need some prefix e.g.

s = !{hello}
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: EXTERNAL: OSError: [Errno 48] Address already in use

2018-07-03 Thread Marko Rauhamaa
Gregory Ewing :

> Marko Rauhamaa wrote:
>> Nevertheless, the later socket object cannot unilaterally take over a
>> socket using SO_REUSEADDR. The earlier socket object must have set the
>> same option previously.
>
> I just did an experiment that suggests that's not the case.
> I created a socket without SO_REUSEADDR, made a connection to
> it, and killed it. Then I created another socket within the
> timeout period with SO_REUSEADDR, and it succeeded.
>
> This was on MacOSX -- it's possible that other systems
> behave differently.

I tried it, too, (on Linux) and it failed.

It's crucial that the killed party is the server for the situation to
arise.

That's why polite clients close their end of the connection before
the server. Whoever closes first will suffer the TIME-WAIT state.


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


Python 3.7 configuration issue

2018-07-03 Thread Robin Becker

On a Ubuntu trusty system I ran

./configure --prefix=/home/rptlab/PYTHON

make && make install

and get an error related to the ctypes module not being importable.

I needed to do

sudo apt-get install libffi-dev
./configure --prefix=/home/rptlab/PYTHON --with-system-ffi
make && make install

Something in setup.py seems to want ctypes irrespective of what I give to configure; I don't actually know what the alternative to 
--with-system-ffi does, but it didn't work for me.

--
Robin Becker

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


Re: Multi-threading with a simple timer?

2018-07-03 Thread Gregory Ewing

Robin Becker wrote:
if I leave out the signal.signal(signal.SIGALRM,signal.SIG_IGN) then the 
timeout function gets called anyway.


Yes, it needs some more stuff around it to make it useful.
Probably you also want the signal handler to raise an
exception and catch it somewhere rather than exiting
the process.

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Chris Angelico
On Tue, Jul 3, 2018 at 6:34 PM, Steven D'Aprano
 wrote:
> Or as my wife would say, "did you mean an Aussie couple or an actual
> couple?" I meant an Aussie couple, which could be anything from two to
> four or five. Six at a stretch. As in, "no worries mate, it'll be ready
> in a coupla days."

cf https://xkcd.com/1070/

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Bart

On 01/07/2018 18:06, Abdur-Rahmaan Janhangeer wrote:

was viewing pep526, so, finally, python cannot do without hinting the type
as other languages?
will python finally move to
int x = 3 where int is a pre annotation?

i am not arguing it's usefulness but rather, does it fit with python?


Not in my opinion. Just more of the kind of clutter that people turn to 
Python to avoid.


But it might suit a statically typed language with Python-like syntax, 
as some people prefer it to the syntax of their actual typed language.



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


Re: EXTERNAL: OSError: [Errno 48] Address already in use

2018-07-03 Thread Chris Angelico
On Tue, Jul 3, 2018 at 10:26 PM, Marko Rauhamaa  wrote:
> Gregory Ewing :
>
>> Marko Rauhamaa wrote:
>>> Nevertheless, the later socket object cannot unilaterally take over a
>>> socket using SO_REUSEADDR. The earlier socket object must have set the
>>> same option previously.
>>
>> I just did an experiment that suggests that's not the case.
>> I created a socket without SO_REUSEADDR, made a connection to
>> it, and killed it. Then I created another socket within the
>> timeout period with SO_REUSEADDR, and it succeeded.
>>
>> This was on MacOSX -- it's possible that other systems
>> behave differently.
>
> I tried it, too, (on Linux) and it failed.
>
> It's crucial that the killed party is the server for the situation to
> arise.
>
> That's why polite clients close their end of the connection before
> the server. Whoever closes first will suffer the TIME-WAIT state.

The same thing can happen with clients AND servers, but it's very
common with clients to allow an arbitrary port number to be chosen for
you. To trigger this problem from the client end, you would need to
use the same port. An attacker can do this easily.

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


Re: Multi-threading with a simple timer?

2018-07-03 Thread Marko Rauhamaa
Gregory Ewing :

> Robin Becker wrote:
>> if I leave out the signal.signal(signal.SIGALRM,signal.SIG_IGN) then
>> the timeout function gets called anyway.
>
> Yes, it needs some more stuff around it to make it useful. Probably
> you also want the signal handler to raise an exception and catch it
> somewhere rather than exiting the process.

My advice: stay away from (non-terminal) signals. They are a primitive
communication scheme that *might* have had uses in the early 1970's.

At the time signals were part of so-called "asynchronous programming."
The pattern called for the main routine to have:

for (;;)
pause()

and *everything* in the program was done in signal handlers.

Unless you do *everything* in signal handlers, you should do *nothing*
in signal handlers.


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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Grant Edwards
On 2018-07-03, Dan Stromberg  wrote:

> I used to write useful programs that ran in 256 bytes of RAM.

Me too.

Less than 10 years ago.

In a real product.

That's still shipping.

-- 
Grant Edwards   grant.b.edwardsYow! Are you mentally here
  at   at Pizza Hut??
  gmail.com

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


Re: Multi-threading with a simple timer?

2018-07-03 Thread Michael Vilain
Won't this code send a signal *regardless* of the user input to the process 
within 15 seconds. I don't see how it's tied to terminal input.

From what I can tell, you need to create your own version of input with a 
timeout option.  This doesn't do that.
--
Michael Vilain
650-322-6755

> On 02-Jul-2018, at 11:12 PM 🌙, Gregory Ewing  
> wrote:
> 
> David D wrote:
>> Is there a SIMPLE method that I can have a TIMER count down at a user input
>> prompt - if the user doesn't enter information within a 15 second period, it
>> times out.
> 
> import signal, sys
> 
> def timeout(*args):
>print("Too late!")
>sys.exit(0)
> 
> signal.signal(signal.SIGALRM, timeout)
> signal.setitimer(signal.ITIMER_REAL, 15)
> data = input("Enter something: ")
> print("You entered: ", data)
> 
> -- 
> Greg
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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


Re: EXTERNAL: OSError: [Errno 48] Address already in use

2018-07-03 Thread Marko Rauhamaa
Chris Angelico :

> On Tue, Jul 3, 2018 at 10:26 PM, Marko Rauhamaa  wrote:
>> It's crucial that the killed party is the server for the situation to
>> arise.
>>
>> That's why polite clients close their end of the connection before
>> the server. Whoever closes first will suffer the TIME-WAIT state.
>
> The same thing can happen with clients AND servers, but it's very
> common with clients to allow an arbitrary port number to be chosen for
> you. To trigger this problem from the client end, you would need to
> use the same port. An attacker can do this easily.

No, I mean that the TIME-WAIT state is triggered asymmetrically. See RFC
793 page 23. Whoever sends FIN first will end up in TIME-WAIT for 2*MSL.

A client that doesn't send FIN first will cause an accumulation of
connection objects (TCBs) at the server end. It can also prevent the
server from being restarted quickly.

The SO_REUSEADDR discussion has no direct relationship with computer or
network security. In fact, I don't see any reason why it's not always
on for TCP. Maybe it's done so UDP and TCP (and other protocols) would
work similarly.


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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Gene Heskett
On Tuesday 03 July 2018 09:32:52 Dennis Lee Bieber wrote:

> On Mon, 2 Jul 2018 19:51:29 -0500, Tim Daneliuk 
>
> declaimed the following:
> >Except that the current attempt is to use techniques like agile,
> >scrum, pair programming, and so forth to turn programming into
> >a factory activity.  High degrees of specialization are segmented
> >by architectural role (front end, back end, infrastructure,
> >DevOps ...), language, and even business unit.  In my view,
> >systems architecture, software design, and non functional
> >capabilities suffer thereby, but I am old and crabby :)
>
>   Where do I join the "old and crabby" club?

You become a member automatically when you've accumulated enough 
birthdays. I'm 83, and it just sorta sneaks up on you while you're busy 
with life.
>
>   After 30 years with a DOD contractor where things went through PDR,
> CDR (and often separate sets for requirements, followed by design,
> followed by implementation), my last four years were in an environment
> as you describe above -- where the requirements seemed to be written
> based upon what the implementation of the week performed...
>
Thats horrible, you never know what the true target is.  And realizing it 
makes you a member of the club.
> --
>   Wulfraed Dennis Lee Bieber AF6VN
>   [email protected]://wlfraed.home.netcom.com/



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


Re: EXTERNAL: OSError: [Errno 48] Address already in use

2018-07-03 Thread Grant Edwards
On 2018-07-01, Marko Rauhamaa  wrote:
> Gregory Ewing :
>
>> I don't see how the address-reuse timeout can be a security measure,
>> because the process trying to take over the address can easily
>> circumvent it by setting SO_REUSEADDR.
>
> [...]
>
> Nevertheless, the later socket object cannot unilaterally take over a
> socket using SO_REUSEADDR. The earlier socket object must have set the
> same option previously.

On what OS?  In my experience, that's not true on Linux or BSD Unix.

-- 
Grant Edwards   grant.b.edwardsYow! Yes, but will I
  at   see the EASTER BUNNY in
  gmail.comskintight leather at an
   IRON MAIDEN concert?

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


Re: EXTERNAL: OSError: [Errno 48] Address already in use

2018-07-03 Thread Grant Edwards
On 2018-07-03, Grant Edwards  wrote:
> On 2018-07-01, Marko Rauhamaa  wrote:
>> Gregory Ewing :
>>
>>> I don't see how the address-reuse timeout can be a security measure,
>>> because the process trying to take over the address can easily
>>> circumvent it by setting SO_REUSEADDR.
>>
>> [...]
>>
>> Nevertheless, the later socket object cannot unilaterally take over a
>> socket using SO_REUSEADDR. The earlier socket object must have set the
>> same option previously.
>
> On what OS?  In my experience, that's not true on Linux or BSD Unix.

I was wrong.  I just did a quick test on Linux, and it works the way
Marko Hauhamaa describes.  [Don't have handy access to a BSD system at
the moment.]

-- 
Grant Edwards   grant.b.edwardsYow! I'm wearing PAMPERS!!
  at   
  gmail.com

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


Re: EXTERNAL: OSError: [Errno 48] Address already in use

2018-07-03 Thread Grant Edwards
On 2018-07-03, Grant Edwards  wrote:
> On 2018-07-03, Grant Edwards  wrote:
>> On 2018-07-01, Marko Rauhamaa  wrote:
>>> Gregory Ewing :
>>>
 I don't see how the address-reuse timeout can be a security measure,
 because the process trying to take over the address can easily
 circumvent it by setting SO_REUSEADDR.
>>>
>>> [...]
>>>
>>> Nevertheless, the later socket object cannot unilaterally take over a
>>> socket using SO_REUSEADDR. The earlier socket object must have set the
>>> same option previously.
>>
>> On what OS?  In my experience, that's not true on Linux or BSD Unix.
>
> I was wrong.  I just did a quick test on Linux, and it works the way
> Marko Hauhamaa describes.

Um that was supposed to be Rauhamaa... sorry about that.

> [Don't have handy access to a BSD system at the moment.]

Found a NetBSD 7.1 system to test on...

After killing a server with an active connection, a new server can
bind to the same socket regardless of the SO_REUSEADDR setting in
either server.  I don't know if that's some sort of system
configuration setting or what...

-- 
Grant Edwards   grant.b.edwardsYow! Where's the Coke
  at   machine?  Tell me a joke!!
  gmail.com

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


Re: Multi-threading with a simple timer?

2018-07-03 Thread Chris Angelico
On Wed, Jul 4, 2018 at 12:05 AM, Marko Rauhamaa  wrote:
> Gregory Ewing :
>
>> Robin Becker wrote:
>>> if I leave out the signal.signal(signal.SIGALRM,signal.SIG_IGN) then
>>> the timeout function gets called anyway.
>>
>> Yes, it needs some more stuff around it to make it useful. Probably
>> you also want the signal handler to raise an exception and catch it
>> somewhere rather than exiting the process.
>
> My advice: stay away from (non-terminal) signals. They are a primitive
> communication scheme that *might* have had uses in the early 1970's.
>
> At the time signals were part of so-called "asynchronous programming."
> The pattern called for the main routine to have:
>
> for (;;)
> pause()
>
> and *everything* in the program was done in signal handlers.
>
> Unless you do *everything* in signal handlers, you should do *nothing*
> in signal handlers.

Yeah, signal handlers are utterly useless. You never want to use them
to receive messages from the operating system in a process-independent
way. The fact that it's possible to use them badly means that we
should abolish them completely and never use them, like ever. It's not
like they're a really effective way for you to be notified that you no
longer have a controlling terminal, thus permitting you to decide
whether to continue or terminate. It's not like they're a standard way
for the user to say "please interrupt this operation", thus allowing
you to cleanly break off what you're doing and return to the main
loop. No, signal handlers are utterly useless, and only MIGHT have had
uses forty years ago. They're completely and utterly outmoded by
modern systems that use HTTP and XML to send easy-to-use messages
between processes.

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


Re: Getting posts to sort chronologically in tree view

2018-07-03 Thread T Berger
On Monday, July 2, 2018 at 2:36:00 PM UTC-4, Dan Stromberg wrote:
> On Mon, Jul 2, 2018 at 11:02 AM, T Berger  wrote:
> 
> > Is there any way to set posts to appear chronologically in tree view? And
> > why is the tree view completely out of order? My last two posts in this
> > view are from 6/27 and 6/28.
> >
> 
> I'm thinking you may want to specify what software you're talking about.
> If it's software for reading python-list, we don't all use the same
> programs.

Hi Dan,

I'm posting directly to the forum (computer.lang.python, at this web address: 
https://groups.google.com/forum/#!topic/comp.lang.python/vWCvLYjOWUQ) and also 
following up on my posts here. And I have to apologize. The threads in my 
previous conversation, ERRNO 48: Address already in use, are so extensive and 
hierarchical, that they appear to be out of order. They're not. It's just that 
you guys continue talking amongst yourselves off my topic, so my last posts 
always get lost somewhere in the middle of the threads. Once I carefully 
followed the tree, I found that everything was listed chronologically. It would 
help if my conversations showed up in my gmail, but they don't. I thought that 
would happen when I chose the "Automatically subscribe me to email updates when 
I post to a topic" option in the forum settings. Am I wrong? And is there some 
way to have my conversations appear in both sites?

Thanks,

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Steven D'Aprano
On Tue, 03 Jul 2018 14:24:26 +, Grant Edwards wrote:

> On 2018-07-03, Dan Stromberg  wrote:
> 
>> I used to write useful programs that ran in 256 bytes of RAM.
> 
> Me too.
> 
> Less than 10 years ago.
> 
> In a real product.
> 
> That's still shipping.

Well don't be shy. Got a link?



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: File names with slashes [was Re: error in os.chdir]

2018-07-03 Thread Thomas Jollans
On 2018-07-03 14:06, Mikhail V wrote:
> Greg wrote:
> 
>> Mikhail V wrote:
>>>   s= "\"s\""   ->
>>>   s=  {"s"}
>>
>> But now you need to find another way to represent set literals.
> 
> 
> I need to find? That comment was not about (current) Python but
> rather how I think string should have been from the beginning.
> 
> So you already like it and want in Python ?  :-)
> Fitting it into current Python would need some prefix e.g.
> 
> s = !{hello}

Nothing new under the sun.

Our old frenemy Perl has
  q{abc""} == "abc\"\""
  q`{}` == "{}"

Perl's sexy Japanese alter-ego Ruby has %Q{}, %q{}.

I'm sure there are more.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Jim Lee



On 07/03/18 01:34, Steven D'Aprano wrote:

I said *indefinite* not infinite.


Yes, you did.  My bad.


You did read the article I linked to, right? You know that people don't
suddenly and instantly turn from "beginner" to "expert" when they exceed
9,999 hours 59 minutes and 59 seconds? Quibbling over the exact number of
hours is foolish.



Of course I know that.  I've been familiar with the concept for a long 
time.  I've taught several guitarists and have seen it first hand.  I've 
also trained several programmers.


Quibbling over the exact number of hours *is* foolish - but nobody was 
doing that.  I was simply pointing out that you used three vastly 
different numbers in almost the same breath to describe how long it 
takes a person to master something.


I think we both get the idea - let's back out of this rabbit trail 
before we get lost, ok? :)


-Jim

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Grant Edwards
On 2018-07-03, Steven D'Aprano  wrote:
> On Tue, 03 Jul 2018 14:24:26 +, Grant Edwards wrote:
>> On 2018-07-03, Dan Stromberg  wrote:
>> 
>>> I used to write useful programs that ran in 256 bytes of RAM.
>> 
>> Me too.
>> 
>> Less than 10 years ago.
>> 
>> In a real product.
>> 
>> That's still shipping.
>
> Well don't be shy. Got a link?

http://www.emerson.com/en-us/catalog/emerson-775-wireless-thum-adapter

One of the processors inside (there are three) is a low-end version
MSP430 with, either 128 or 256 bytes of RAM (I forget which).

-- 
Grant Edwards   grant.b.edwardsYow! I'm also pre-POURED
  at   pre-MEDITATED and
  gmail.compre-RAPHAELITE!!

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Jim Lee



On 07/03/18 06:32, Dennis Lee Bieber wrote:

On Mon, 2 Jul 2018 19:51:29 -0500, Tim Daneliuk 
declaimed the following:


Except that the current attempt is to use techniques like agile,
scrum, pair programming, and so forth to turn programming into
a factory activity.  High degrees of specialization are segmented
by architectural role (front end, back end, infrastructure,
DevOps ...), language, and even business unit.  In my view,
systems architecture, software design, and non functional
capabilities suffer thereby, but I am old and crabby :)


Where do I join the "old and crabby" club?

After 30 years with a DOD contractor where things went through PDR, CDR
(and often separate sets for requirements, followed by design, followed by
implementation), my last four years were in an environment as you describe
above -- where the requirements seemed to be written based upon what the
implementation of the week performed...


Welcome to the club, Dennis!  My last four years were also as Tim 
described, and that's what made me decide to retire early.


Another trend is that, with the high degree of compartmentalization, 
many of the programming jobs are now being farmed out overseas as black 
box bids.  After I retired, my team was sent to China to "train" a new 
group (read brain dump), and was then summarily disbanded.


-Jim


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


Re: Multi-threading with a simple timer?

2018-07-03 Thread David D
This works, but does not do exactly what I want. What I want to happen is : 
when the user enters in a correct answer, the program and threading stops.  Any 
ideas on what I should change? 

import time 
from threading import Thread 

class Answer(Thread): 
def run(self): 
a=input("What is your answer:") 
if a=="yes": 
print("yes you got it") 
finished() 
else: 
print("no") 

class myTimer(Thread): 
def run(self): 
print() 
for x in range(5): 

time.sleep(1) 

Answer().start() 
myTimer().start() 
print("you lost") 

def finished(): 
print("done")

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


Re: Multi-threading with a simple timer?

2018-07-03 Thread David D
This works, but does not do exactly what I want. When the user enters in a 
correct answer, the program and threading stops.  Any ideas on what I should 
change?

import time
from threading import Thread

class Answer(Thread):
def run(self):
a=input("What is your answer:")
if a=="yes":
print("yes you got it")
finished()
else:
print("no")

class myTimer(Thread):
def run(self):
print()
for x in range(5):

time.sleep(1)

Answer().start()
myTimer().start()
print("you lost")

def finished():
print("done")

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


Re: Getting posts to sort chronologically in tree view

2018-07-03 Thread Jim Lee




On 07/03/18 08:49, T Berger wrote:


  It would help if my conversations showed up in my gmail, but they don't. I thought that 
would happen when I chose the "Automatically subscribe me to email updates when I 
post to a topic" option in the forum settings. Am I wrong? And is there some way to 
have my conversations appear in both sites?

Thanks,

Tamara


For what it's worth, I don't get my own posts via email either, and I 
have that explicitly enabled in my subscription settings.


-Jim

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


Re: Getting posts to sort chronologically in tree view

2018-07-03 Thread Richard Damon
On 7/3/18 9:45 AM, Jim Lee wrote:
>
>
> On 07/03/18 08:49, T Berger wrote:
>>
>>   It would help if my conversations showed up in my gmail, but they
>> don't. I thought that would happen when I chose the "Automatically
>> subscribe me to email updates when I post to a topic" option in the
>> forum settings. Am I wrong? And is there some way to have my
>> conversations appear in both sites?
>>
>> Thanks,
>>
>> Tamara
>
> For what it's worth, I don't get my own posts via email either, and I
> have that explicitly enabled in my subscription settings.
>
> -Jim
>
Jim, That's a 'feature' of gmail, it automatically suppresses duplicate
copies of messages (even if not identical) and considers the version
back from the list to be a duplicate of the one you sent.

-- 
Richard Damon

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


Re: Multi-threading with a simple timer?

2018-07-03 Thread Akkana Peck
David D wrote:
> Is there a SIMPLE method that I can have a TIMER count down at a user input
> prompt - if the user doesn't enter information within a 15 second period, it
> times out.

Does this do what you want?

from threading import Timer
import sys
import os

def run_later():
print("Timed out!")

# sys.exit doesn't kill the main thread, but os._exit does.
os._exit(1)

if __name__ == '__main__':
t = Timer(15, run_later)
t.start()
ans = input("Enter something, or time out in 15 seconds: ")
print("You entered", ans)
t.cancel()
sys.exit(0)

The only problem with that is if you want to continue with execution
after the timeout (you didn't say what you want to do in that case).
I couldn't find any straightforward way to interrupt the main thread
in a way that interrupts the input(). There's something called
_thread.interrupt_main() but it doesn't seem to work with
threading.Timer threads; maybe it would work if you created the
timer thread using _thread. Or signals, of course, as already discussed.

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


Re: Multi-threading with a simple timer?

2018-07-03 Thread Michael Vilain
The way I've done the "input with timeout" requirement the OP requested is 
dependent on the operating system.  The current implementation of the input 
function doesn't offer that feature.

https://docs.python.org/3/library/functions.html#input

In another language, I used low-levelsystem calls to the OS to get terminal 
assigned to the process running the program, open the terminal for read, and 
set a time-out for that read.  This is by no means portable.

I looked at the os.open() method and it doesn't offer a timeout option.  Then I 
found curses.  That has a getch() function that can be setup with a halfdelay() 
timer.

https://docs.python.org/3/howto/curses.html

That's the closest I could find to getting input with a time-out from the 
terminal.  If it's to kludgy, you'll have to roll your own OS-specific version. 
 My guess is that Windows and Linux (and whatever else you choose to implement) 
are different.

Got code?

--
Anything invented before you were eighteen was there all along.
Anything invented before you’re thirty is exciting and will change the world 
forever.
Anything invented after that is an abomination and should be banned. -- Cory 
Doctorow



> On 03-Jul-2018, at 8:21 AM 🌞, Chris Angelico  wrote:
> 
> On Wed, Jul 4, 2018 at 12:05 AM, Marko Rauhamaa  wrote:
>> Gregory Ewing :
>> 
>>> Robin Becker wrote:
 if I leave out the signal.signal(signal.SIGALRM,signal.SIG_IGN) then
 the timeout function gets called anyway.
>>> 
>>> Yes, it needs some more stuff around it to make it useful. Probably
>>> you also want the signal handler to raise an exception and catch it
>>> somewhere rather than exiting the process.
>> 
>> My advice: stay away from (non-terminal) signals. They are a primitive
>> communication scheme that *might* have had uses in the early 1970's.
>> 
>> At the time signals were part of so-called "asynchronous programming."
>> The pattern called for the main routine to have:
>> 
>>for (;;)
>>pause()
>> 
>> and *everything* in the program was done in signal handlers.
>> 
>> Unless you do *everything* in signal handlers, you should do *nothing*
>> in signal handlers.
> 
> Yeah, signal handlers are utterly useless. You never want to use them
> to receive messages from the operating system in a process-independent
> way. The fact that it's possible to use them badly means that we
> should abolish them completely and never use them, like ever. It's not
> like they're a really effective way for you to be notified that you no
> longer have a controlling terminal, thus permitting you to decide
> whether to continue or terminate. It's not like they're a standard way
> for the user to say "please interrupt this operation", thus allowing
> you to cleanly break off what you're doing and return to the main
> loop. No, signal handlers are utterly useless, and only MIGHT have had
> uses forty years ago. They're completely and utterly outmoded by
> modern systems that use HTTP and XML to send easy-to-use messages
> between processes.
> 
> ChrisA
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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


django-raster rendering raster url

2018-07-03 Thread Xristos Xristoou
i want to add raster functionality in django using postgis database using 
django-raster package and this docs 
http://django-raster.readthedocs.io/en/latest/tms.html

here my code :

models.py

from django.contrib.gis.db import models
class RasterWithName(models.Model):
raster = models.RasterField()
name = models.TextField()
add raster using console :

from django.contrib.gis.gdal import GDALRaster
from myapp.models import RasterWithName
gdal_raster = GDALRaster('C:/Users/username/Desktop/image.tif')
rast = RasterWithName(name='one', raster=gdal_raster)
rast.save()
but i am very confused with Rendering tiles and urls.

docs say :

/raster/tiles/layer_id/{z}/{x}/{y}.png where the layer_id is the primary key of 
a raster layer. This structure can be used directly in online mapping software 
such as OpenLayers or Leaflet. An example request could look like this: 
/raster/tiles/23/8/536/143.png, returning a tile in png format of the layer 
with ID pk=23 at zoom level z=8 and indexes x=536 and y=143

but indexes x,y mean some random x,y coordinate in image ?anyway i using this 
url http://127.0.0.1:8000/raster/tiles/1/8/536/143.png or 
http://127.0.0.1:8000/raster/tiles/1/8/20/40.png(origin x,y in my image) and i 
take a black window in my browser,any idea where i have wrong in my url 
rendering ?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting posts to sort chronologically in tree view

2018-07-03 Thread Ben Finney
T Berger  writes:

> I'm posting directly to the forum (computer.lang.python, at this web
> address:
> https://groups.google.com/forum/#!topic/comp.lang.python/vWCvLYjOWUQ)

Thanks for being specific. So, from that description, you are using the
Google Groups web interface to read and send messages in this forum.

That is not “posting directly to the forum”, because this forum doesn't
have a single canonical direct location. (And if it did, that location
would certainly not be Google Groups.)

> And I have to apologize. The threads in my previous conversation,
> ERRNO 48: Address already in use, are so extensive and hierarchical,
> that they appear to be out of order. They're not.

Right. I gather, from many complaints by Google Groups users over many
years, that it is a terrible interface for interacting with any forum.

The lack of proper threading support is just one of many well-known bugs
that Google show no sign of correcting. They show every sign, in fact,
of having no interest in listening to the requests from users of that
software.

Given that history, you might want to avoid Google Groups for
interacting with forums, and choose software that works better with
discussion forums. I am told Mozilla Thunderbird is a good choice, but
there are likely others.

-- 
 \  “Earth gets its price for what Earth gives us.” —James Russell |
  `\Lowell |
_o__)  |
Ben Finney

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


Re: Multi-threading with a simple timer?

2018-07-03 Thread David D
I have some success with this.  I am not sure if this would work longer term, 
as in restarting it, but so far so good.  Any issue with this new code?

import time
from threading import Thread

th=Thread()
class Answer(Thread):
def run(self):
a=input("What is your answer:")
if a=="yes":
print("yes you got it")
th.daemon=False
else:
print("no")

class myTimer(Thread):
def run(self):
print()

for x in range(5):
if th.daemon==True:
print(x)
time.sleep(1)
else:
break

th.daemon=True

Answer().start()
myTimer().start()


def finished():
print("done")

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


Re: Python 3.7 Windows Help Behaviour

2018-07-03 Thread BlindAnagram
On 03/07/2018 03:41, Terry Reedy wrote:
> On 7/2/2018 8:57 PM, Steven D'Aprano wrote:
>> On Fri, 29 Jun 2018 12:53:15 -0400, Terry Reedy wrote:
>>
>>> On 6/29/2018 6:14 AM, BlindAnagram wrote:
 In Python 3.7.0 on Windows the help file (python370.chm) displays with
 a fixed line length and does not adjust its line length when the user
 expands the help window horizontally.  This behaviour is different to
 that of the Python 3.6 help file (python360.chm) which adjusts its text
 to fit the horizontal width of the help window.

 Is this a deliberate change or one that can be turned on or off in some
 way (I prefer the Python 3.6 behaviour)?
>>>
>>> I believe that this is a deliberate regression imposed by 'experts' who
>>> believe in form over function and 'controlling the user experience'.
>>> 3.6.6 has been 'fixated' also.
>>
>> I think that's been reverted:
>>
>> https://github.com/python/cpython/commit/580c7db172a41d6311c0f3a7aec321597576e214
>>
> 
> Yes, I wrote the blurb, merged it, and ordered and approved the backports.
>Thank you, Terry (and others who contributed), for your help with this -
I much appreciate all your efforts.

   Brian

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Steven D'Aprano
On Tue, 03 Jul 2018 09:14:37 -0700, Jim Lee wrote:

> On 07/03/18 01:34, Steven D'Aprano wrote:
>> I said *indefinite* not infinite.
> 
> Yes, you did.  My bad.

Thanks Jim, your acknowledgement is appreciated.


>> You did read the article I linked to, right? You know that people don't
>> suddenly and instantly turn from "beginner" to "expert" when they
>> exceed 9,999 hours 59 minutes and 59 seconds? Quibbling over the exact
>> number of hours is foolish.
> 
> 
> Of course I know that.  I've been familiar with the concept for a long
> time.  I've taught several guitarists and have seen it first hand.  I've
> also trained several programmers.

Okay, so you *do* understand that the "ten thousand hours" concept is a 
rough, order of magnitude, average figure. Great. Which makes your 
quibbling over whether it is 10,000 hours or five years or two years all 
the more mysterious.


> Quibbling over the exact number of hours *is* foolish - but nobody was
> doing that.

Ah nice to see the ol' "deny everything" debating tactic.


> I was simply pointing out that you used three vastly
> different numbers in almost the same breath to describe how long it
> takes a person to master something.

I love watching pedantically precise people panic and dig themselves into 
a hole. Since I'm an extremely pedantic person myself, I can recognise it 
in others -- especially when they're not as precisely correct as they 
think they're being.

It was two numbers, not three, and not even close to "vastly" different.

Both numbers I mentioned (ten thousand hours, a couple of years) are 
within the bounds of acceptable precision to each other: their 
(figurative) error bars overlap.

My first reference to the number was in quotation marks: "10,000 hours", 
not 10,000 hours. That was your first hint that I was not using it as a 
precise number, but as a "vague quantifier" (to give the technical name 
for the concept).

https://en.wikipedia.org/wiki/Indefinite_and_fictitious_numbers#Specific_numbers_used_as_indefinite

My second reference was to EXPLICITLY state the number was intended to be 
read as an imprecise quantity. No second number was mentioned.

And the third was to reference a number (a couple of years) which even if 
read literally rather than figuratively is within an order of magnitude 
of the original.

Even read as *different*, they're not "vastly" different (a vague 
quantifier which surely means more than merely a single order of 
magnitude: jumping from five to five billion would surely be a vast 
difference, not five to fifty).


> I think we both get the idea - let's back out of this rabbit trail
> before we get lost, ok? :)

Translation: 

"Yeah Steve, you're right, I was kinda a dick for pedantically telling 
you off for imprecision in numbers even though I knew full well that no 
greater precision was possible or desirable, but how 'bout you drop it and 
leave me with the last word, hmmm?"

No worries Jim, I totally agree.

*wink*




-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: .replace("a" or "b")

2018-07-03 Thread Steven D'Aprano
On Tue, 03 Jul 2018 07:52:42 +0400, Abdur-Rahmaan Janhangeer wrote:

> .replace("a" or "b")


Oh I *wish* Python accepted that syntax to mean what you thought it meant.

That's a common error: a surprising number of beginners are fooled by how 
close Python is to natural language and try writing things like:


   if x == 1 or 2:
   ...



Reading Python is sometimes close to reading English, but not *that* 
close.

There is currently no way to tell str.replace to replace "either this, or 
that".


-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Congrats to Chris for breaking his PEP curse

2018-07-03 Thread Steven D'Aprano
Congratulations to Chris Angelico for breaking the dreaded "any PEP 
written by Chris will be rejected" curse :-)

Guido has announced his intention to accept PEP 572 (assignment 
expressions) once the PEP has been cleaned up a bit.

https://www.python.org/dev/peps/pep-0572/

(The current version of the PEP doesn't quite match the proposal as 
nutted out over about a bazillion emails on two mailing lists starting in 
FEBRUARY!!!)


Summary:

Python 3.8 will allow an assignment-as-expression operator. The most 
common uses are expected to be if and while statements:

condition = expression
while condition:
do_something()
condition = expression

will become:

while condition := expression:
do_something()


Cascades of if statements, such as:

# the dreaded arrowhead anti-pattern
mo = re.match(pattern, text)
if mo:
...
else:
mo = re.match(another_pattern, text):
if mo:
...
else:
mo = re.match(third_pattern, text):
if mo:
...


will become flatter and easier to read:

if mo := re.match(pattern, text):
...
elif mo := re.match(another_pattern, text):
...
elif mo := re.match(third_pattern, text):
...


FAQs:

Q. Why Pascal's assignment operator := instead of regular = assignment?

A. To avoid the C bug magnet of mistakenly writing "if x = expr" when
   you intended to write "if x == expr".


Q. Why not use "as"?

A. There is an ambiguity due to with and except statements:

with expr as name

except Exception as name

   are already permitted and mean something different to ordinary
   assignment expressions.


Q. Oh no, Python is doomed! This is the end of the world!

A. That's not actually a question, is it?




-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: Congrats to Chris for breaking his PEP curse

2018-07-03 Thread Chris Angelico
On Wed, Jul 4, 2018 at 11:59 AM, Steven D'Aprano
 wrote:
> Congratulations to Chris Angelico for breaking the dreaded "any PEP
> written by Chris will be rejected" curse :-)

I'm actually somewhat astonished at that part. But thanks anyway.

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Jim Lee



On 07/03/18 16:51, Steven D'Aprano wrote:


I love watching pedantically precise people panic and dig themselves into
a hole. Since I'm an extremely pedantic person myself, I can recognise it
in others -- especially when they're not as precisely correct as they
think they're being.

It was two numbers, not three, and not even close to "vastly" different.


  Ah, I see we're not going to leave it alone.  In that case, 
"indefinite" is a "number", in that it was a quantity you cited along 
with the other two.  If you'd prefer to call it a "quantity", that's 
fine with me.  Talk about pedantic...



Both numbers I mentioned (ten thousand hours, a couple of years) are
within the bounds of acceptable precision to each other: their
(figurative) error bars overlap.


Who is defining acceptable here?  And you are once again creating a 
strawman argument.  My quibble was *not* with the difference between 
10,000 hours and 2 years.



I think we both get the idea - let's back out of this rabbit trail
before we get lost, ok? :)

Translation:

"Yeah Steve, you're right, I was kinda a dick for pedantically telling
you off for imprecision in numbers even though I knew full well that no
greater precision was possible or desirable, but how 'bout you drop it and
leave me with the last word, hmmm?"




Sigh.  I tried to give you a graceful way to end the pedantics. Now, I 
will gracefully allow you to have the last word as well.


-Jim

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Chris Angelico
On Wed, Jul 4, 2018 at 12:28 PM, Jim Lee  wrote:
>
>
> On 07/03/18 16:51, Steven D'Aprano wrote:
>>
>>
>> I love watching pedantically precise people panic and dig themselves into
>> a hole. Since I'm an extremely pedantic person myself, I can recognise it
>> in others -- especially when they're not as precisely correct as they
>> think they're being.
>>
>> It was two numbers, not three, and not even close to "vastly" different.
>
>
>   Ah, I see we're not going to leave it alone.  In that case, "indefinite"
> is a "number", in that it was a quantity you cited along with the other two.
> If you'd prefer to call it a "quantity", that's fine with me.  Talk about
> pedantic...

I've had debates with people about whether "infinity" is a number or
not, but I've never yet heard anyone say that "indefinite" is a
number. Hmm. This could be interesting.

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


Re: EXTERNAL: OSError: [Errno 48] Address already in use

2018-07-03 Thread Marko Rauhamaa
Grant Edwards :
> Found a NetBSD 7.1 system to test on...
>
> After killing a server with an active connection, a new server can
> bind to the same socket regardless of the SO_REUSEADDR setting in
> either server. I don't know if that's some sort of system
> configuration setting or what...

The question is, why shouldn't you be able to bind to an unbound socket
that has stale connections in TIME-WAIT?

Maybe the NetBSD people found the answer: there's no reason.


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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Jim Lee



On 07/03/18 19:31, Chris Angelico wrote:


I've had debates with people about whether "infinity" is a number or
not, but I've never yet heard anyone say that "indefinite" is a
number. Hmm. This could be interesting.

ChrisA


If you were to say John had 2 apples, Jane had 4 apples, and Joe had an 
indefinite number of apples, how many numbers are we talking about?


That's rhetorical by the way.  The other person is obviously focusing on 
pedantics in order to obfuscate the original (weak) argument.


-Jim

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Ben Finney via Python-list
Jim Lee  writes:

> If you were to say John had 2 apples, Jane had 4 apples, and Joe had
> an indefinite number of apples, how many numbers are we talking about?

Three numbers. And “indefinite” is not one of those numbers. So, no,
that doesn't support “"indefinite" is a number”.

-- 
 \“That's the essence of science: Ask an impertinent question, |
  `\and you're on the way to the pertinent answer.” —Jacob |
_o__) Bronowski, _The Ascent of Man_, 1973 |
Ben Finney

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Jim Lee



On 07/03/18 19:58, Ben Finney via Python-list wrote:

Jim Lee  writes:


If you were to say John had 2 apples, Jane had 4 apples, and Joe had
an indefinite number of apples, how many numbers are we talking about?

Three numbers. And “indefinite” is not one of those numbers. So, no,
that doesn't support “"indefinite" is a number”.


Exactly.  And you've just confirmed my original argument.  Thanks!

-Jim

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


Re: Getting posts to sort chronologically in tree view

2018-07-03 Thread T Berger
On Tuesday, July 3, 2018 at 4:00:03 PM UTC-4, Ben Finney wrote:
> T Berger  writes:
> 
> > I'm posting directly to the forum (computer.lang.python, at this web
> > address:
> > https://groups.google.com/forum/#!topic/comp.lang.python/vWCvLYjOWUQ)
> 
> Thanks for being specific. So, from that description, you are using the
> Google Groups web interface to read and send messages in this forum.
> 
> That is not “posting directly to the forum”, because this forum doesn't
> have a single canonical direct location. (And if it did, that location
> would certainly not be Google Groups.)

I don't have to tell you that I find this all very confusing.

> > And I have to apologize. The threads in my previous conversation,
> > ERRNO 48: Address already in use, are so extensive and hierarchical,
> > that they appear to be out of order. They're not.
> 
> Right. I gather, from many complaints by Google Groups users over many
> years, that it is a terrible interface for interacting with any forum.
> 
> The lack of proper threading support is just one of many well-known bugs
> that Google show no sign of correcting. They show every sign, in fact,
> of having no interest in listening to the requests from users of that
> software.

Ben, you may not have finished reading my post. It turns out that I
was wrong in thinking that the posts were out of order; they were just
so hard to follow because of all the side conversations. Once I
carefully followed the threads I saw that I had been wrong.

> Given that history, you might want to avoid Google Groups for
> interacting with forums, and choose software that works better with
> discussion forums. I am told Mozilla Thunderbird is a good choice, but
> there are likely others.

I don't think I want to try a mail list. I had subscribed to the
python-list a few weeks ago and then been forced to unsubscribe
because of the flood of irrelevant posts.

Ben, I tried responding to your email from gmail. I hit the reply button, and 
got the below message. Do you know why?

Mail Delivery Subsystem 
6:05 PM (5 hours ago)
Reply
to me 

Final-Recipient: rfc822; [email protected]
Action: failed
Status: 5.0.0
Diagnostic-Code: smtp; Posting by email is not allowed, to post to this group 
visit https://groups.google.com/forum/#!forum/comp.lang.python
Last-Attempt-Date: Tue, 03 Jul 2018 15:05:28 -0700 (PDT)

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


Re: Congrats to Chris for breaking his PEP curse

2018-07-03 Thread Abdur-Rahmaan Janhangeer
https://www.reddit.com/r/Python/comments/8vmq27/pep_572_assignment_expressions_is_officially/

XD nice feedbacks about the pep

Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ

On Wed, 4 Jul 2018, 06:02 Steven D'Aprano, <
[email protected]> wrote:

> Congratulations to Chris Angelico for breaking the dreaded "any PEP
> written by Chris will be rejected" curse :-)
>
> Guido has announced his intention to accept PEP 572 (assignment
> expressions) once the PEP has been cleaned up a bit.
>
> https://www.python.org/dev/peps/pep-0572/
>
> (The current version of the PEP doesn't quite match the proposal as
> nutted out over about a bazillion emails on two mailing lists starting in
> FEBRUARY!!!)
>
>
> Summary:
>
> Python 3.8 will allow an assignment-as-expression operator. The most
> common uses are expected to be if and while statements:
>
> condition = expression
> while condition:
> do_something()
> condition = expression
>
> will become:
>
> while condition := expression:
> do_something()
>
>
> Cascades of if statements, such as:
>
> # the dreaded arrowhead anti-pattern
> mo = re.match(pattern, text)
> if mo:
> ...
> else:
> mo = re.match(another_pattern, text):
> if mo:
> ...
> else:
> mo = re.match(third_pattern, text):
> if mo:
> ...
>
>
> will become flatter and easier to read:
>
> if mo := re.match(pattern, text):
> ...
> elif mo := re.match(another_pattern, text):
> ...
> elif mo := re.match(third_pattern, text):
> ...
>
>
> FAQs:
>
> Q. Why Pascal's assignment operator := instead of regular = assignment?
>
> A. To avoid the C bug magnet of mistakenly writing "if x = expr" when
>you intended to write "if x == expr".
>
>
> Q. Why not use "as"?
>
> A. There is an ambiguity due to with and except statements:
>
> with expr as name
>
> except Exception as name
>
>are already permitted and mean something different to ordinary
>assignment expressions.
>
>
> Q. Oh no, Python is doomed! This is the end of the world!
>
> A. That's not actually a question, is it?
>
>
>
>
> --
> Steven D'Aprano
> "Ever since I learned about confirmation bias, I've been seeing
> it everywhere." -- Jon Ronson
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Ben Finney
Jim Lee  writes:

> On 07/03/18 19:58, Ben Finney via Python-list wrote:
> > Jim Lee  writes:
> >
> >> If you were to say John had 2 apples, Jane had 4 apples, and Joe had
> >> an indefinite number of apples, how many numbers are we talking about?
> > Three numbers. And “indefinite” is not one of those numbers. So, no,
> > that doesn't support “"indefinite" is a number”.
> >
> Exactly.  And you've just confirmed my original argument.  Thanks!

Still no, because you're the only one who claimed "indefinite" is a number.

-- 
 \  “If you saw two guys named Hambone and Flippy, which one would |
  `\   you think liked dolphins the most? I'd say Flippy, wouldn't |
_o__) you? You'd be wrong, though. It's Hambone.” —Jack Handey |
Ben Finney

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Abdur-Rahmaan Janhangeer
list members have a nice way to wriggle out of the subject ^^_

apart from programming, other questions go like this :


asker : what do you think about this python thing?

next post : *on track*

next post : *on track*

next post : *on track* btw thon is the name of a fish in french

next post : a sea fish actually

next post : you don't need to tell *sea* it's obvious

next post : i've been a fisherman having caught several types of fish for
several years, and i can tell you those fish are easy to catch

next post : being a fisherman for several years does not make you a good
fisherman, you need to know how to implement fishing techniques

next post : me i managed to catch a fish using a net made of spider webs

next post : well several is a subset of infinity, you need to be precise

next post : infinity can be bounded, i've always told myself

next post : hey guys i've made a library called ton.py, you just reminded
me to complete it

next post : ton means yours in french

next post : it's actually only half true, in reality ton ...

*cut at this point*


Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting posts to sort chronologically in tree view

2018-07-03 Thread Ben Finney
T Berger  writes:

> On Tuesday, July 3, 2018 at 4:00:03 PM UTC-4, Ben Finney wrote:
> > Given that history [of ignoring user requests for improvement], you
> > might want to avoid Google Groups for interacting with forums, and
> > choose software that works better with discussion forums. I am told
> > Mozilla Thunderbird is a good choice, but there are likely others.
>
> I don't think I want to try a mail list.

Good news: you're already participating in one. That was easy! :-)

This is because the forum you're participating is distributed in many
media, *including* a mailing list. You may send some or all of your
messages using a different interface, but you're still participating in
the same forum as the rest of us and so you're participating on (among
other things) a mailing list.

> I had subscribed to the python-list a few weeks ago and then been
> forced to unsubscribe because of the flood of irrelevant posts.

Yes, this forum can sometimes host a high volume of discussion. You will
want to learn the “filter” feature (it may have a different name) of
whatever interface you use.

> Ben, I tried responding to your email from gmail. I hit the reply
> button, and got the below message. Do you know why?

I haven't got any insight to that error, no.

If you have an easy way to get official support for Google Groups, ask
there.

If you don't have an easy way to get support for the software, I'd say
that is a good hint to avoid using that software entirely.

-- 
 \“Members of the general public commonly find copyright rules |
  `\implausible, and simply disbelieve them.” —Jessica Litman, |
_o__)  _Digital Copyright_ |
Ben Finney

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Ben Finney
Abdur-Rahmaan Janhangeer  writes:

> apart from programming, other questions go like this :
>
> […]
> *cut at this point*

Ooh, I like that last step! How do we make that happen on demand?

-- 
 \   “Everything you read in newspapers is absolutely true, except |
  `\for that rare story of which you happen to have first-hand |
_o__) knowledge.” —Erwin Knoll |
Ben Finney

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Abdur-Rahmaan Janhangeer
conversation dies

it denotes the end of the picture i was painting

Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Jim Lee



On 07/03/18 21:25, Ben Finney wrote:

Jim Lee  writes:


On 07/03/18 19:58, Ben Finney via Python-list wrote:

Jim Lee  writes:


If you were to say John had 2 apples, Jane had 4 apples, and Joe had
an indefinite number of apples, how many numbers are we talking about?

Three numbers. And “indefinite” is not one of those numbers. So, no,
that doesn't support “"indefinite" is a number”.


Exactly.  And you've just confirmed my original argument.  Thanks!

Still no, because you're the only one who claimed "indefinite" is a number.

No, I claimed that Steven was using three different numbers to refer to 
the time it takes to master a subject:


10,000 hours
an indefinite number
2 years

Being pedantic about the meaning of "number" is just a way to get off 
the subject.  You yourself said we were talking about THREE numbers!


-Jim

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Jim Lee



On 07/03/18 21:35, Ben Finney wrote:

Abdur-Rahmaan Janhangeer  writes:


apart from programming, other questions go like this :

[…]
*cut at this point*

Ooh, I like that last step! How do we make that happen on demand?


You could start by not adding to the noise... :)

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


Re: Python 3.7 configuration issue

2018-07-03 Thread dieter
Robin Becker  writes:

> On a Ubuntu trusty system I ran
> ./configure --prefix=/home/rptlab/PYTHON
> make && make install
> and get an error related to the ctypes module not being importable.
>
> I needed to do
>
> sudo apt-get install libffi-dev
> ./configure --prefix=/home/rptlab/PYTHON --with-system-ffi
> make && make install
>
> Something in setup.py seems to want ctypes irrespective of what I give
> to configure; I don't actually know what the alternative to
> --with-system-ffi does, but it didn't work for me.

"libffi" contains the so called "foreign function interface"
(an interface that allows code written in one language to call
code written in another language). Likely, "ctypes" depends
on it.

Since some time, "ctypes" is part of Python's standard library.
It is likely, that the Python test suite contains tests verifying
that it could be build successfully.

Your observations seem to indicate that "ctypes" contains its
own "foreign function interface" specification and that this
specification does not fit to the libraries available on your
system. The "with-system-ffi" likely tells the Python generation
process to use the system "foreign function interface" rather
than its own.

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Ben Finney
Jim Lee  writes:

> I claimed that Steven was using three different numbers to refer to
> the time it takes to master a subject:
>
> 10,000 hours
> an indefinite number
> 2 years

Yes. He did so in the context of showing that *there is no precise
number* that universally applies for the amount of effort required.

Add as many numbers as you like, provided they're all in the same broad
range. That is the point, and showing there are multiple numbers in play
is *supporting* Steven's point.

I still don't know what point you had, but I'm not really interested any
more.

-- 
 \“This sentence contradicts itself — no actually it doesn't.” |
  `\   —Douglas Hofstadter |
_o__)  |
Ben Finney

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


Re: Congrats to Chris for breaking his PEP curse

2018-07-03 Thread Ian Kelly
Now that I've actually read the PEP (sorry, I just assumed it would
never fly), I have a couple of (tongue-in-cheek) observations about
it:

> group = re.match(data).group(1) if re.match(data) else None

The only problem with this example of doing more work to save a line
of code is that presumably the same programmer would now instead
write:

> group = match.group(1) if match := re.match(data) else None

This abomination serves to convince me that the people who said the
conditional expression should list the condition first were right.

Secondly, I believe the order of evaluation means that, much as I
would like to, I can't now write all my statements as:

f(f := lambda f: do_something())

Because the outer f will be evaluated before the argument expression
assigns it. Well, that's no fun. Is it too late to fix this? I'm only
half-joking here; if it worked, this would be a much better way to
pass a lambda to itself for recursion than the existing idiom:

(lambda f: lambda *a: f(f, *a))(lambda s, x: 1 if x==0 else x * s(s, x-1))(10)

That's a factorial function, in case you couldn't tell.

Oh well, at least now I'll be able to write exec(x := 'del x').
On Tue, Jul 3, 2018 at 8:04 PM Steven D'Aprano
 wrote:
>
> Congratulations to Chris Angelico for breaking the dreaded "any PEP
> written by Chris will be rejected" curse :-)
>
> Guido has announced his intention to accept PEP 572 (assignment
> expressions) once the PEP has been cleaned up a bit.
>
> https://www.python.org/dev/peps/pep-0572/
>
> (The current version of the PEP doesn't quite match the proposal as
> nutted out over about a bazillion emails on two mailing lists starting in
> FEBRUARY!!!)
>
>
> Summary:
>
> Python 3.8 will allow an assignment-as-expression operator. The most
> common uses are expected to be if and while statements:
>
> condition = expression
> while condition:
> do_something()
> condition = expression
>
> will become:
>
> while condition := expression:
> do_something()
>
>
> Cascades of if statements, such as:
>
> # the dreaded arrowhead anti-pattern
> mo = re.match(pattern, text)
> if mo:
> ...
> else:
> mo = re.match(another_pattern, text):
> if mo:
> ...
> else:
> mo = re.match(third_pattern, text):
> if mo:
> ...
>
>
> will become flatter and easier to read:
>
> if mo := re.match(pattern, text):
> ...
> elif mo := re.match(another_pattern, text):
> ...
> elif mo := re.match(third_pattern, text):
> ...
>
>
> FAQs:
>
> Q. Why Pascal's assignment operator := instead of regular = assignment?
>
> A. To avoid the C bug magnet of mistakenly writing "if x = expr" when
>you intended to write "if x == expr".
>
>
> Q. Why not use "as"?
>
> A. There is an ambiguity due to with and except statements:
>
> with expr as name
>
> except Exception as name
>
>are already permitted and mean something different to ordinary
>assignment expressions.
>
>
> Q. Oh no, Python is doomed! This is the end of the world!
>
> A. That's not actually a question, is it?
>
>
>
>
> --
> Steven D'Aprano
> "Ever since I learned about confirmation bias, I've been seeing
> it everywhere." -- Jon Ronson
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Jim Lee



On 07/03/18 22:03, Ben Finney wrote:

Jim Lee  writes:


I claimed that Steven was using three different numbers to refer to
the time it takes to master a subject:

10,000 hours
an indefinite number
2 years

Yes. He did so in the context of showing that *there is no precise
number* that universally applies for the amount of effort required.

Add as many numbers as you like, provided they're all in the same broad
range. That is the point, and showing there are multiple numbers in play
is *supporting* Steven's point.

I still don't know what point you had, but I'm not really interested any
more.

That's the problem with jumping in and arguing pedantics.  You lose the 
original argument.  Paraphrasing what you *thought* the argument was 
does not help (unless your aim is to confuse things even further).


-Jim


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


openstack connection

2018-07-03 Thread jayshankar nair via Python-list
 Hi,

I am trying to establish a connection to openstack cloud . I am able to 
establish a connection with the following statement
from openstack import connectionconn = 
connection.Connection(auth_url="http://192.168.0.19:5000/v3",                   
   project_name="admin",username="admin",                      
password="6908a8d218f843dd",                      user_domain_id="default",     
                 project_domain_id="default")

I am looking for exact Connection api argument match in below connection.py 
file. Also, i am looking for api to access the object store(list out 
files,creating backup) and network(creating subnet). I am able to create 
duplicate subnet in network. It doesn't prompt out any error.
Thanks,Jayshankar
# Licensed under the Apache License, Version 2.0 (the "License"); you mayb# not 
use this file except in compliance with the License. You may obtain# a copy of 
the License at##      http://www.apache.org/licenses/LICENSE-2.0## Unless 
required by applicable law or agreed to in writing, software# distributed under 
the License is distributed on an "AS IS" BASIS, WITHOUT# WARRANTIES OR 
CONDITIONS OF ANY KIND, either express or implied. See the# License for the 
specific language governing permissions and limitations# under the License.
"""The :class:`~openstack.connection.Connection` class is the primary 
interfaceto the Python SDK. It maintains a context for a connection to a region 
ofa cloud provider. The :class:`~openstack.connection.Connection` has 
anattribute to access each OpenStack service.
At a minimum, the :class:`~openstack.connection.Connection` class needs to 
becreated with a config or the parameters to build one.
While the overall system is very flexible, there are four main use casesfor 
different ways to create a :class:`~openstack.connection.Connection`.
* Using config settings and keyword arguments as described in  
:ref:`openstack-config`* Using only keyword arguments passed to the constructor 
ignoring config files  and environment variables.* Using an existing 
authenticated `keystoneauth1.session.Session`, such as  might exist inside of 
an OpenStack service operational context.* Using an existing 
:class:`~openstack.config.cloud_region.CloudRegion`.
Using config settings-
For users who want to create a :class:`~openstack.connection.Connection` 
makinguse of named clouds in ``clouds.yaml`` files, ``OS_`` environment 
variablesand python keyword arguments, the :func:`openstack.connect` factory 
functionis the recommended way to go:
.. code-block:: python
    import openstack
    conn = openstack.connect(cloud='example', region_name='earth1')
If the application in question is a command line application that should 
alsoaccept command line arguments, an `argparse.Namespace` can be passed 
to:func:`openstack.connect` that will have relevant arguments added to it 
andthen subsequently consumed by the construtor:
.. code-block:: python
    import argparse    import openstack
    options = argparse.ArgumentParser(description='Awesome OpenStack App')    
conn = openstack.connect(options=options)
Using Only Keyword Arguments
If the application wants to avoid loading any settings from ``clouds.yaml`` 
orenvironment variables, use the 
:class:`~openstack.connection.Connection`constructor directly. As long as the 
``cloud`` argument is omitted or ``None``,the 
:class:`~openstack.connection.Connection` constructor will not loadsettings 
from files or the environment.
.. note::
    This is a different default behavior than the :func:`~openstack.connect`    
factory function. In :func:`~openstack.connect` if ``cloud`` is omitted    or 
``None``, a default cloud will be loaded, defaulting to the ``envvars``    
cloud if it exists.
.. code-block:: python
    from openstack import connection
    conn = connection.Connection(        region_name='example-region',        
auth=dict(            auth_url='https://auth.example.com',            
username='amazing-user',            password='super-secret-password',           
 project_id='33aa1afc-03fe-43b8-8201-4e0d3b4b8ab5',            
user_domain_id='054abd68-9ad9-418b-96d3-3437bb376703'),        
compute_api_version='2',        identity_interface='internal')
Per-service settings as needed by `keystoneauth1.adapter.Adapter` such 
as``api_version``, ``service_name``, and ``interface`` can be set, as 
seenabove, by prefixing them with the official ``service-type`` name of 
theservice. ``region_name`` is a setting for the 
entire:class:`~openstack.config.cloud_region.CloudRegion` and cannot be set 
perservice.
From existing authenticated Session---
For applications that already have an authenticated Session, simply passingit 
to the :class:`~openstack.connection.Connection` constructor is all thatis 
needed:
.. code-block:: python
    from openstack import connection
    conn = connection.Connection(        session=session,        
region_name='exa

Infinity [was Re: PEP 526 - var annotations and the spirit of python]

2018-07-03 Thread Steven D'Aprano
On Wed, 04 Jul 2018 12:31:16 +1000, Chris Angelico wrote:

[...]
>> Ah, I see we're not going to leave it alone.  In that case,
>> "indefinite"
>> is a "number", in that it was a quantity you cited along with the other
>> two. If you'd prefer to call it a "quantity", that's fine with me. 
>> Talk about pedantic...
> 
> I've had debates with people about whether "infinity" is a number or
> not, but I've never yet heard anyone say that "indefinite" is a number.
> Hmm. This could be interesting.

What, haven't you ever raced somebody to see who can count to 100 fastest?

"One, two, skip a few, ninety-nine, one hundred!"

Clearly "indefinite" is just a synonym for "skip a few".


For what it's worth, in the ordinary real numbers we all know and love, 
infinity is absolutely not a number, full stop. There's no debate about 
that.

But there are a number (more than one, less than infinity *wink*) of 
areas of mathematics which treat one or more versions of infinity as 
entities which, for lack of a better name, I'll call "numbers".

E.g. cardinal numbers, hyperreals, surreal numbers, and others.

The mathematics of them is rather unintuitive. For instance, in the 
surreal numbers, ω is the smallest infinity; ω-1 is a separate infinity 
but one that you cannot get by counting up from 0, 1, 2, ... you have to 
start at ω and count down (by subtraction); 1+ω is just ω but ω+1 is 
larger than infinity.


(I'm not an expert on the surreals, I may have a couple of details wrong.)




-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Steven D'Aprano
On Sun, 01 Jul 2018 17:22:43 -0500, Tim Daneliuk wrote:

>> x: int = 3
[...]

> This strikes me as syntactic noise.  Python is dynamically typed and
> will remain so. Why clutter the language - even optionally - with stuff
> like this?

There's no need to declare x:int = 3 since any linter worth its salt 
ought to be able to infer that x is an int if it is assigned the value 3. 
Anyone writing that needs to be slapped with a clue-stick, it's not 1971 
any more, type inference ought to be considered bare minimum for even a 
halfway decent type checker or linter.

(If your linter doesn't, your linter sucks.)

A better example would be:

x: int = None

which ought to be read as "x is an int, or None, and it's currently None".

Better still would be something like this:

alist: [int] = []

which is read as "x is a list of ints, currently empty".



Guido believes that optional static typing is important and useful enough 
to dedicate syntax to it, so that editors, IDEs, linters and other tools 
can standardise on a single notation rather than every one picking their 
own:

alist: [int] = []

is much better than:

alist = []  # [int] List(Int) foolint:type=[integer]

so having one syntax which everyone can agree on is a good thing.

And as a general rule, using comments for semantically significant 
information is an anti-pattern.




-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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


Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Steven D'Aprano
On Tue, 03 Jul 2018 19:28:43 -0700, Jim Lee wrote:

> On 07/03/18 16:51, Steven D'Aprano wrote:
>>
>> I love watching pedantically precise people panic and dig themselves
>> into a hole. Since I'm an extremely pedantic person myself, I can
>> recognise it in others -- especially when they're not as precisely
>> correct as they think they're being.
>>
>> It was two numbers, not three, and not even close to "vastly"
>> different.
> 
>    Ah, I see we're not going to leave it alone.  In that case,
> "indefinite" is a "number", in that it was a quantity you cited along
> with the other two.

It would be nice if you consider the context of words rather than 
criticising them in isolation.

In isolation, "10,000" and "some vaguely indefinite number between 
roughly one thousand and one hundred thousand, give or take some 
unspecified quantity" *wink* are clearly not the same. Any fool can see 
that.

But in context, my description of the number as being "indefinite" was 
clarifying the meaning of the earlier use of 10,000 as a vague 
quantifier, not the specific number +1. It hardly counts as a 
separate reference to a number when it is explicitly referring back to 
the first mention of the term "10,000" to clarify that it shouldn't be 
read as a specific number.

Which you then treated as a specific number.


>> Both numbers I mentioned (ten thousand hours, a couple of years) are
>> within the bounds of acceptable precision to each other: their
>> (figurative) error bars overlap.
> 
> Who is defining acceptable here? 

You *did* read the article I linked to, right?

Given the factors that they mention -- the wide range in hours practiced, 
the lack of an upper limit, the variation between individuals, the lack 
of any hard dividing line between "expert" and "non-expert" -- what sort 
of precision do you think is acceptable?

10,000 ± 6 hours ?

If you want to argue for a specific level of precision, I look forward to 
hearing your reasoning. Until then, I'm going to consider "ten thousand 
hours" to be a hand-wavy figure, not much more precise than "a shit-ton 
of hours".


> And you are once again creating a
> strawman argument.  My quibble was *not* with the difference between
> 10,000 hours and 2 years.

Quote:

So we went from 10,000 hours, to infinite, and then back to
a couple of years?

followed by:

I was simply pointing out that you used three vastly
different numbers in almost the same breath to describe 
how long it takes a person to master something.

Perhaps I have misunderstood you. If so, apologies.

If you weren't complaining about them being "vastly different", what 
precisely was your complaint?



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

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