Re: Is there a nice way to switch between 2 different packages providing the same APIs?

2018-07-05 Thread Mark via Python-list
On Thursday, July 5, 2018 at 6:24:09 PM UTC+1, Tim Williams wrote: > On Thu, Jul 5, 2018 at 9:02 AM Mark Summerfield via Python-list < > python-list@python.org> wrote: > > > For GUI programming I often use Python bindings for Qt. > > > > There are two competing bindings, PySide and PyQt. > > > > I

Re: Dealing with dicts in doctest

2018-07-05 Thread Peter Otten
Steven D'Aprano wrote: > On Fri, 06 Jul 2018 09:31:50 +1000, Cameron Simpson wrote: > >> On 05Jul2018 17:57, Steven D'Aprano >> wrote: >>>I have a function which returns a dict, and I want to use doctest to >>>ensure the documentation is correct. So I write a bunch of doctests: >>> >>>def func(a

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

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 16:09:52 +0200, Antoon Pardon wrote: >> This is not an innovation of Mypy. It's how type inference is supposed >> to work. If a particular type checker doesn't do that, it is doing it >> wrong. > > That is how type interference works in languages that have some kind of > stati

Re: about main()

2018-07-05 Thread Gregory Ewing
Steven D'Aprano wrote: Even the Eskimos and Inuit, living in some of the harshest environments on earth, managed to have a relatively wide variety of foods in their diet. They might be living on a very wide variety of berries. Or perhaps, in their language, "berry" simply means "food". -- Gr

Re: about main()

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 18:40:11 -0700, Jim Lee wrote: > On 07/05/18 18:25, Steven D'Aprano wrote: >> On Thu, 05 Jul 2018 11:27:09 -0700, Jim Lee wrote: >> >>> Take a village of people.  They live mostly on wild berries. >> Because of course a community of people living on one food is so >> realistic.

Re: RANT why the *%#&%^ does installing pip not install setuptools???

2018-07-05 Thread Steven D'Aprano
On Fri, 06 Jul 2018 11:58:08 +1000, Chris Angelico wrote: > On Fri, Jul 6, 2018 at 11:35 AM, Steven D'Aprano > wrote: >> On Fri, 06 Jul 2018 03:47:55 +1000, Chris Angelico wrote: >> >>> What's the output of: >>> >>> $ apt-cache show python3-pip >> >> Mysteriously, the output is repeated twice, in

Re: testing code

2018-07-05 Thread Cameron Simpson
On 05Jul2018 19:56, Sharan Basappa wrote: I have implemented my first program in python that uses ML to do some classification task. The whole code is in a single file currently. It contains executable code as well as functions. I presume when you write "executable code" you mean some kind of

Re: testing code

2018-07-05 Thread Chris Angelico
On Fri, Jul 6, 2018 at 12:56 PM, Sharan Basappa wrote: > Please let me know if the following understanding of mine is correct. > I need to put the program code in a separate file and organize every > executable code in some form of function. If any code exists outside of > function then it is no

testing code

2018-07-05 Thread Sharan Basappa
Hi All, I am new to Python though not new to programming. I have implemented my first program in python that uses ML to do some classification task. The whole code is in a single file currently. It contains executable code as well as functions. At the end of the program, I have series of calls

Re: Dealing with dicts in doctest

2018-07-05 Thread Cameron Simpson
On 06Jul2018 01:43, Steven D'Aprano wrote: On Fri, 06 Jul 2018 09:31:50 +1000, Cameron Simpson wrote: On 05Jul2018 17:57, Steven D'Aprano wrote: I have three ways of dealing with this. Which do you prefer? Option 4: >>> func(1) == {'a': 1, 'b': 2, 'c': 3} True Alas, in reality f

Re: RANT why the *%#&%^ does installing pip not install setuptools???

2018-07-05 Thread Chris Angelico
On Fri, Jul 6, 2018 at 11:35 AM, Steven D'Aprano wrote: > On Fri, 06 Jul 2018 03:47:55 +1000, Chris Angelico wrote: > >> What's the output of: >> >> $ apt-cache show python3-pip > > Mysteriously, the output is repeated twice, in every-so-slightly > different formats. It's the little details like t

Re: about main()

2018-07-05 Thread Gene Heskett
On Thursday 05 July 2018 21:25:31 Steven D'Aprano wrote: > On Thu, 05 Jul 2018 11:27:09 -0700, Jim Lee wrote: > > Take a village of people.  They live mostly on wild berries. > > Because of course a community of people living on one food is so > realistic. Even the Eskimos and Inuit, living in som

Re: Dealing with dicts in doctest

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 19:56:59 +0100, MRAB wrote: > What about sorting the items? > > def func(arg): > """blah blah blah > > >>> sorted(func(1).items()) > [('a', 1), ('b', 2), ('c', 3)] > """ Hmmm it still has the disadvantage of putting the emphasis on the sorted()

Re: Dealing with dicts in doctest

2018-07-05 Thread Steven D'Aprano
On Fri, 06 Jul 2018 09:31:50 +1000, Cameron Simpson wrote: > On 05Jul2018 17:57, Steven D'Aprano > wrote: >>I have a function which returns a dict, and I want to use doctest to >>ensure the documentation is correct. So I write a bunch of doctests: >> >>def func(arg): >>"""blah blah blah >> >>

Re: RANT why the *%#&%^ does installing pip not install setuptools???

2018-07-05 Thread Steven D'Aprano
On Fri, 06 Jul 2018 03:47:55 +1000, Chris Angelico wrote: > What's the output of: > > $ apt-cache show python3-pip Mysteriously, the output is repeated twice, in every-so-slightly different formats. It's the little details like that give us confidence in the quality of the software... Packa

Re: about main()

2018-07-05 Thread Jim Lee
On 07/05/18 18:25, Steven D'Aprano wrote: On Thu, 05 Jul 2018 11:27:09 -0700, Jim Lee wrote: Take a village of people.  They live mostly on wild berries. Because of course a community of people living on one food is so realistic. Even the Eskimos and Inuit, living in some of the harshest env

Re: about main()

2018-07-05 Thread Jim Lee
On 07/05/18 18:14, Michael Torrie wrote: On 07/05/2018 11:47 AM, Calvin Spealman wrote: That wasn't me, but I do agree with the sentiment in that its often silly to focus on them at the wrong time and without constraints that warrant that focus. Premature optimization is the root of all evil,

Re: about main()

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 11:27:09 -0700, Jim Lee wrote: > Take a village of people.  They live mostly on wild berries. Because of course a community of people living on one food is so realistic. Even the Eskimos and Inuit, living in some of the harshest environments on earth, managed to have a relat

Re: about main()

2018-07-05 Thread Michael Torrie
On 07/05/2018 11:47 AM, Calvin Spealman wrote: > That wasn't me, but I do agree with the sentiment in that its often silly > to focus on them at the wrong time and without constraints that warrant > that focus. Premature optimization is the root of all evil, the saying goes. I see this kind of th

Re: about main()

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 10:41:36 -0700, Jim Lee wrote: > The horde of > programmers a generation or two from now may have no clue how to do > these things. That's okay, the horde of programmers have never known how to do these things (optimization). They either don't do it at all, or they run riot

Re: Dealing with dicts in doctest

2018-07-05 Thread Cameron Simpson
On 05Jul2018 17:57, Steven D'Aprano wrote: I have a function which returns a dict, and I want to use doctest to ensure the documentation is correct. So I write a bunch of doctests: def func(arg): """blah blah blah >>> func(1) {'a': 1, 'b': 2, 'c': 3} """ which is correct, *except

Re: Is there a nice way to switch between 2 different packages providing the same APIs?

2018-07-05 Thread Cameron Simpson
On 05Jul2018 05:57, Mark Summerfield wrote: For GUI programming I often use Python bindings for Qt. There are two competing bindings, PySide and PyQt. Ideally I like to have applications that can use either. This way, if I get a problem I can try with the other bindings: if I still get the pr

Re: about main()

2018-07-05 Thread Cameron Simpson
On 05Jul2018 11:22, Rhodri James wrote: On 05/07/18 09:43, Abdur-Rahmaan Janhangeer wrote: just when to use main() in if __name__ == '__main__' : main() is far is it good in py? or should file intended to be run just not include it? It's a matter of taste. If your "file intended to be

[ANN] PyYAML-3.13: YAML parser and emitter for Python

2018-07-05 Thread Ingy dot Net
Announcing PyYAML-3.13 A new bug fix release of PyYAML is now available: http://pyyaml.org/wiki/PyYAML *** Important Note From Maintainers *** This is the first PyYAML release by the new maintainers. It was made critical because PyYAML-3.12

Re: RANT why the *%#&%^ does installing pip not install setuptools???

2018-07-05 Thread eryk sun
On Thu, Jul 5, 2018 at 5:37 PM, Steven D'Aprano wrote: > I'm trying to install pip on a Linux Mint box. The maintainers of Mint > (or possibly their upstream distro, Ubuntu) decided in their infinite > wisdom to remove the ensurepip package, so > > python3 -m ensurepip In Debian distros, a cu

Re: about main()

2018-07-05 Thread Jim Lee
On 07/05/18 14:15, MRAB wrote: On 2018-07-05 21:43, Jim Lee wrote: On 07/05/18 12:58, Chris Angelico wrote: On Fri, Jul 6, 2018 at 4:27 AM, Jim Lee wrote: On 07/05/18 10:47, Calvin Spealman wrote: You say "pitfall", but I say "allow developers to focus on higher-level problems and en

Re: about main()

2018-07-05 Thread MRAB
On 2018-07-05 21:43, Jim Lee wrote: On 07/05/18 12:58, Chris Angelico wrote: On Fri, Jul 6, 2018 at 4:27 AM, Jim Lee wrote: On 07/05/18 10:47, Calvin Spealman wrote: You say "pitfall", but I say "allow developers to focus on higher-level problems and enable developers to specialize among

Re: about main()

2018-07-05 Thread Jim Lee
On 07/05/18 12:58, Chris Angelico wrote: On Fri, Jul 6, 2018 at 4:27 AM, Jim Lee wrote: On 07/05/18 10:47, Calvin Spealman wrote: You say "pitfall", but I say "allow developers to focus on higher-level problems and enable developers to specialize among tasks so every single one of us does

Re: about main()

2018-07-05 Thread Chris Angelico
On Fri, Jul 6, 2018 at 4:27 AM, Jim Lee wrote: > > > On 07/05/18 10:47, Calvin Spealman wrote: >> >> >> >> You say "pitfall", but I say "allow developers to focus on higher-level >> problems and enable developers to specialize among tasks so every single one >> of us doesn't have to be a jack of a

Re: is there a problem with IDLE, python3.7.0, or my computer?

2018-07-05 Thread Chris Angelico
On Fri, Jul 6, 2018 at 4:20 AM, Bonn Mowae lazaga <2ndmo...@gmail.com> wrote: > hello, I would like to notify you that there may be a problem with IDLE or > Python3.7.0 > I installed python 3.7.0 for my 64 bit windows 10, and it was working fine, I > could also use turtle graphics using the comma

Re: about main()

2018-07-05 Thread Jim Lee
On 07/05/18 10:47, Calvin Spealman wrote: You say "pitfall", but I say "allow developers to focus on higher-level problems and enable developers to specialize among tasks so every single one of us doesn't have to be a jack of all trades just to build a todo list app". Sure, that's the

is there a problem with IDLE, python3.7.0, or my computer?

2018-07-05 Thread Bonn Mowae lazaga
hello, I would like to notify you that there may be a problem with IDLE or Python3.7.0 I installed python 3.7.0 for my 64 bit windows 10, and it was working fine, I could also use turtle graphics using the command:    from turtle import *    and:    forward(200)    and other control comman

Re: RANT why the *%#&%^ does installing pip not install setuptools???

2018-07-05 Thread Brian J. Oney via Python-list
On Stretch: ~ $ aptitude show python-pip Package: python-pip   Version: 9.0.1-2 ... Maintainer: Debian Python Modules Team ... Depends: ca-certificates, python-pip-whl (= 9.0.1-2), python:any (< 2.8), python:any (>= 2.7.5-5~) Recommends: build-essential, python-all-dev (>= 2.6

Re: Dealing with dicts in doctest

2018-07-05 Thread MRAB
On 2018-07-05 18:57, Steven D'Aprano wrote: I have a function which returns a dict, and I want to use doctest to ensure the documentation is correct. So I write a bunch of doctests: def func(arg): """blah blah blah >>> func(1) {'a': 1, 'b': 2, 'c': 3} """ which is correct,

Dealing with dicts in doctest

2018-07-05 Thread Steven D'Aprano
I have a function which returns a dict, and I want to use doctest to ensure the documentation is correct. So I write a bunch of doctests: def func(arg): """blah blah blah >>> func(1) {'a': 1, 'b': 2, 'c': 3} """ which is correct, *except* that dict keys have arbitrary order in t

Re: about main()

2018-07-05 Thread Calvin Spealman
On Thu, Jul 5, 2018 at 1:41 PM, Jim Lee wrote: > > > On 07/05/18 10:15, Calvin Spealman wrote: > > On Thu, Jul 5, 2018 at 12:59 PM, Jim Lee wrote: > >> >> >> On 07/05/18 05:14, Marko Rauhamaa wrote: >> >>> Abdur-Rahmaan Janhangeer : >>> * Create as many functions as you can > perfo

Re: RANT why the *%#&%^ does installing pip not install setuptools???

2018-07-05 Thread Chris Angelico
On Fri, Jul 6, 2018 at 3:37 AM, Steven D'Aprano wrote: > I'm trying to install pip on a Linux Mint box. The maintainers of Mint > (or possibly their upstream distro, Ubuntu) decided in their infinite > wisdom to remove the ensurepip package, so > > python3 -m ensurepip > > fails ("No module na

Re: about main()

2018-07-05 Thread Jim Lee
On 07/05/18 10:15, Calvin Spealman wrote: On Thu, Jul 5, 2018 at 12:59 PM, Jim Lee > wrote: On 07/05/18 05:14, Marko Rauhamaa wrote: Abdur-Rahmaan Janhangeer mailto:arj.pyt...@gmail.com>>: * Create as many functions as you can

RANT why the *%#&%^ does installing pip not install setuptools???

2018-07-05 Thread Steven D'Aprano
I'm trying to install pip on a Linux Mint box. The maintainers of Mint (or possibly their upstream distro, Ubuntu) decided in their infinite wisdom to remove the ensurepip package, so python3 -m ensurepip fails ("No module named ensurepip"). Okay, let's do this the hard way: sudo apt

Re: Is there a nice way to switch between 2 different packages providing the same APIs?

2018-07-05 Thread Tim Williams
On Thu, Jul 5, 2018 at 9:02 AM Mark Summerfield via Python-list < python-list@python.org> wrote: > For GUI programming I often use Python bindings for Qt. > > There are two competing bindings, PySide and PyQt. > > Ideally I like to have applications that can use either. This way, if I > get a prob

Re: about main()

2018-07-05 Thread Calvin Spealman
On Thu, Jul 5, 2018 at 12:59 PM, Jim Lee wrote: > > > On 07/05/18 05:14, Marko Rauhamaa wrote: > >> Abdur-Rahmaan Janhangeer : >> >>> * Create as many functions as you can >>> performance? >>> >> Python? >> >> Seriously, though. The principle of expressive encapsulation is one of >> the basi

Re: about main()

2018-07-05 Thread Jim Lee
On 07/05/18 05:14, Marko Rauhamaa wrote: Abdur-Rahmaan Janhangeer : * Create as many functions as you can performance? Python? Seriously, though. The principle of expressive encapsulation is one of the basic cornerstones of writing computer programs. Performance barely ever becomes a questi

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

2018-07-05 Thread Gene Heskett
On Thursday 05 July 2018 11:57:18 Mikhail V wrote: > Steven D'Aprano wrote: > > In Explorer and the open-file dialog of most applications, they will > > see paths like this: > > > > directory\file name with spaces > > > > with the extension (.jpg, .pdf, .docx etc) suppressed. So by your > > ar

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

2018-07-05 Thread Mikhail V
Steven D'Aprano wrote: > In Explorer and the open-file dialog of most applications, they will see > paths like this: > > directory\file name with spaces > > with the extension (.jpg, .pdf, .docx etc) suppressed. So by your > argument, Python needs to accept strings without quotes: > > open

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

2018-07-05 Thread Schachner, Joseph
It is interesting to contemplate how this could transform Python into nearly a statically typed language: x = 3 x = f(x) If you say the type checker should infer that x is an int, and then therefore complain about x=f(x) if f() does not return an int, then we have what in new C++ is auto type d

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

2018-07-05 Thread Antoon Pardon
On 05-07-18 15:07, Steven D'Aprano wrote: > On Thu, 05 Jul 2018 13:54:28 +0200, Antoon Pardon wrote: > >> On 05-07-18 11:59, Steven D'Aprano wrote: >>> On Thu, 05 Jul 2018 17:34:55 +1200, Gregory Ewing wrote: >>> >>> > Indeed, that's often the best way, except for the redundant type > hint,

Re: about main()

2018-07-05 Thread Chris Angelico
On Thu, Jul 5, 2018 at 10:47 PM, Abdur-Rahmaan Janhangeer wrote: > that's what happens when you type from mobile > > btw i have top posted since some days only in this thread > > as for my english well i got distinction in cambridge ucles in gp for high > school but practicality beats purity Ahh,

Re: about main()

2018-07-05 Thread Chris Angelico
On Thu, Jul 5, 2018 at 9:20 PM, Marko Rauhamaa wrote: > Rhodri James : >> I'm not a big fan of "main()" functions myself; creating a function >> which will be called exactly once seems rather wasteful. > > A function is the encapsulation of a distinct ... well ... function. > Functions that are ca

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

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 13:54:28 +0200, Antoon Pardon wrote: > On 05-07-18 11:59, Steven D'Aprano wrote: >> On Thu, 05 Jul 2018 17:34:55 +1200, Gregory Ewing wrote: >> >> Indeed, that's often the best way, except for the redundant type hint, which makes you That Guy: x: int = 0

Is there a nice way to switch between 2 different packages providing the same APIs?

2018-07-05 Thread Mark Summerfield via Python-list
For GUI programming I often use Python bindings for Qt. There are two competing bindings, PySide and PyQt. Ideally I like to have applications that can use either. This way, if I get a problem I can try with the other bindings: if I still get the problem, then it is probably me; but if I don't

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

2018-07-05 Thread Bart
On 05/07/2018 11:04, Steven D'Aprano wrote: On Thu, 05 Jul 2018 09:17:20 +0200, Christian Gollwitzer wrote: Not sure what point you are trying to make, but your example compiles in C, if you replace the '#' comment sign with '//'. Sometimes I wonder how C programmers manage to write a bug-f

Re: about main()

2018-07-05 Thread Abdur-Rahmaan Janhangeer
that's what happens when you type from mobile btw i have top posted since some days only in this thread as for my english well i got distinction in cambridge ucles in gp for high school but practicality beats purity Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ > > > -- https://ma

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

2018-07-05 Thread Mark Lawrence
On 05/07/18 11:26, Bart wrote: And at numerous other languages that are properly statically typed (Ada being one of the most rigorous, while C++ is a nightmare). I had to chuckle at that as friends of mine have had great fun rewriting Ada in C++ as it was just too damn slow. This was aft

Re: about main()

2018-07-05 Thread Mark Lawrence
On 05/07/18 11:39, Abdur-Rahmaan Janhangeer wrote: i once saw a python course (by academics) advertising main() in it's promotional flier that's put me in doubt as whether it's that recommended or not Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ I can remember back to the good

Re: about main()

2018-07-05 Thread Marko Rauhamaa
Abdur-Rahmaan Janhangeer : >> * Create as many functions as you can > performance? Python? Seriously, though. The principle of expressive encapsulation is one of the basic cornerstones of writing computer programs. Performance barely ever becomes a question, and even more rarely has anything to d

Re: about main()

2018-07-05 Thread Abdur-Rahmaan Janhangeer
no about wrapping everything in functions Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ On Thu, 5 Jul 2018, 15:55 Joel Goldstick, wrote: > On Thu, Jul 5, 2018 at 7:45 AM, Abdur-Rahmaan Janhangeer > wrote: > > performance? > > You are asking basic file layout questions in the learn

Re: about main()

2018-07-05 Thread Joel Goldstick
On Thu, Jul 5, 2018 at 7:45 AM, Abdur-Rahmaan Janhangeer wrote: > performance? You are asking basic file layout questions in the learning process of understand how to code in python. Performance should be very low on your list of concerns. The only thing that happens when the file is loaded is

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

2018-07-05 Thread Antoon Pardon
On 05-07-18 11:59, Steven D'Aprano wrote: > On Thu, 05 Jul 2018 17:34:55 +1200, Gregory Ewing wrote: > > >>> Indeed, that's often the best way, except for the redundant type hint, >>> which makes you That Guy: >>> >>> x: int = 0 # set x to the int 0 >> But you've shown in an earlier example th

Re: about main()

2018-07-05 Thread Abdur-Rahmaan Janhangeer
performance? Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ * Create as many functions as you can -- https://mail.python.org/mailman/listinfo/python-list

Re: about main()

2018-07-05 Thread Bart
On 05/07/2018 11:22, Rhodri James wrote: On 05/07/18 09:43, Abdur-Rahmaan Janhangeer wrote: just when to use main() in if __name__ == '__main__' : main() is far is it good in py? or should file intended to be run just not include it? It's a matter of taste.  If your "file intended to b

Re: about main()

2018-07-05 Thread Marko Rauhamaa
Rhodri James : > I'm not a big fan of "main()" functions myself; creating a function > which will be called exactly once seems rather wasteful. A function is the encapsulation of a distinct ... well ... function. Functions that are called just once are desirable. So I'm saying the opposite: * H

Re: about main()

2018-07-05 Thread Marko Rauhamaa
Abdur-Rahmaan Janhangeer : > just when to use main() in > > if __name__ == '__main__' : > main() > > is far is it good in py? > > or should file intended to be run just not include it? I think all Python programs should have it. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Using Python with a website

2018-07-05 Thread Alister via Python-list
On Wed, 04 Jul 2018 23:25:14 +, Adrian Taylor wrote: > G'day All, > > I have just discovered Python and thanks to a script by Ethan I can read > a foxpro database and change the required values. > However my next big step is to be able to use this python feature within > a website. > > Basic

Re: Vectorizing operation involving multiple DataFrames

2018-07-05 Thread Viswanath Potluri
On Wednesday, July 4, 2018 at 7:51:19 PM UTC-7, Viswanath Potluri wrote: > I've a dataframe all_paths with say 9000 rows, and i've another dataframe > Legs with 4000 rows. I need to filter all_paths dataframe based on a column > called 'itineraries' which contains a list of strings, for each row

Re: about main()

2018-07-05 Thread Abdur-Rahmaan Janhangeer
i once saw a python course (by academics) advertising main() in it's promotional flier that's put me in doubt as whether it's that recommended or not Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ > main() > > > > is far is it good in py? > > > > or should file intended to be ru

Re: about main()

2018-07-05 Thread Rhodri James
On 05/07/18 09:43, Abdur-Rahmaan Janhangeer wrote: just when to use main() in if __name__ == '__main__' : main() is far is it good in py? or should file intended to be run just not include it? It's a matter of taste. If your "file intended to be run" also contains things that might be

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

2018-07-05 Thread Bart
On 05/07/2018 10:59, Steven D'Aprano wrote: But it is redundant in *that* example. Your hint is not giving any more information that what the reader, or type checker, can already infer. These are useful: x: Any = 3 # x can be anything, but is currently an int x: int = None # x can

Re: Congrats to Chris for breaking his PEP curse

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 17:59:05 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Not everything in Python uses a strict left-to-right reading order. >> Just like English really. > > Well, English is read left to right, but it doesn't always mean things > in the order it says them. :-) "First

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

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 09:17:20 +0200, Christian Gollwitzer wrote: > Am 04.07.18 um 17:31 schrieb Steven D'Aprano: >> On Wed, 04 Jul 2018 13:48:26 +0100, Bart wrote: >> >>> Presumably one type hint applies for the whole scope of the variable, >>> not just the one assignment. >> >> You know how in C

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

2018-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2018 17:34:55 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: > >> but the type checker should infer that if you assign None to a variable >> which is declared int, you must have meant Optional[int] rather than >> just int. > > This seems to be equivalent to saying that *all*

about main()

2018-07-05 Thread Abdur-Rahmaan Janhangeer
just when to use main() in if __name__ == '__main__' : main() is far is it good in py? or should file intended to be run just not include it? 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-05 Thread Abdur-Rahmaan Janhangeer
he means too much of it Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Well you always mention how like english the if-expression in python is and > thus by implication readable. > > -- > Antoon. > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.o

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

2018-07-05 Thread Antoon Pardon
On 05-07-18 08:58, Steven D'Aprano wrote: > >> Optimize for readability, not writability. > And that is why we all hold COBOL up as the paragon of excellence for a > programming language! *wink* > > Or if you don't like COBOL, how about Hypertalk? Well you always mention how like english the if-e

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

2018-07-05 Thread Christian Gollwitzer
Am 04.07.18 um 17:31 schrieb Steven D'Aprano: On Wed, 04 Jul 2018 13:48:26 +0100, Bart wrote: Presumably one type hint applies for the whole scope of the variable, not just the one assignment. You know how in C you can write int x = 1; # the type applies for just this one assignment

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

2018-07-05 Thread Chris Angelico
On Thu, Jul 5, 2018 at 4:58 PM, Steven D'Aprano wrote: >> Optimize for readability, not writability. > > And that is why we all hold COBOL up as the paragon of excellence for a > programming language! *wink* > > Or if you don't like COBOL, how about Hypertalk? > > put 42 into x > ask file "Which f

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

2018-07-05 Thread Steven D'Aprano
On Wed, 04 Jul 2018 13:26:03 -0600, Ian Kelly wrote: [...] >> Note that None is a special case (because sometimes special cases *are* >> special enough to break the rules). > > > I don't think this case is special enough. As a person coming along > later and trying to read the code, I should be