Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79921 > unrolled thread

optional types

Started byKiuhnm <gandalf23@mail.com>
First post2014-10-29 09:17 -0700
Last post2014-10-29 16:25 +0000
Articles 16 — 7 participants

Back to article view | Back to comp.lang.python


Contents

  optional types Kiuhnm <gandalf23@mail.com> - 2014-10-29 09:17 -0700
    Re: optional types Peter Otten <__peter__@web.de> - 2014-10-29 17:51 +0100
      Re: optional types Kiuhnm <gandalf23@mail.com> - 2014-10-29 10:18 -0700
        Re: optional types Chris Angelico <rosuav@gmail.com> - 2014-10-30 04:25 +1100
        Re: optional types Ethan Furman <ethan@stoneleaf.us> - 2014-10-29 10:46 -0700
        Re: optional types Chris Angelico <rosuav@gmail.com> - 2014-10-30 05:03 +1100
          Re: optional types Marko Rauhamaa <marko@pacujo.net> - 2014-10-29 20:18 +0200
            Re: optional types Chris Angelico <rosuav@gmail.com> - 2014-10-30 05:43 +1100
            Re: optional types Kiuhnm <gandalf23@mail.com> - 2014-10-29 12:03 -0700
              Re: optional types Marko Rauhamaa <marko@pacujo.net> - 2014-10-29 21:07 +0200
              Re: optional types Kiuhnm <gandalf23@mail.com> - 2014-10-29 12:09 -0700
              Re: optional types Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-10-29 19:22 +0000
                Re: optional types Marko Rauhamaa <marko@pacujo.net> - 2014-10-29 21:44 +0200
                  Re: optional types Kiuhnm <gandalf23@mail.com> - 2014-10-29 13:43 -0700
                Re: optional types Kiuhnm <gandalf23@mail.com> - 2014-10-29 13:40 -0700
    Re: optional types Nick Cash <nick.cash@npcinternational.com> - 2014-10-29 16:25 +0000

#79921 — optional types

FromKiuhnm <gandalf23@mail.com>
Date2014-10-29 09:17 -0700
Subjectoptional types
Message-ID<99399d4a-902d-42d9-86c8-7bdcd2a766cc@googlegroups.com>
I must say that the lack of static types in Python is a pain in the neck especially when I'm exploring new libraries.
Recently, I learned a new language called Dart which have optional typing and I had a lot of fun with it. Basically, you use type annotations as documentation and to give useful information to the IDE or editor. That makes the IDE look *very* smart!
I'm using PyCharm and more often than not I want to see the list of methods and attributes of an object, but the editor won't show them to me because it doesn't know the dynamic type of the variable whose value was just returned by a function.
That's irritating!
Am I the only one who'd like to see optional types introduced in Python?

[toc] | [next] | [standalone]


#79923

FromPeter Otten <__peter__@web.de>
Date2014-10-29 17:51 +0100
Message-ID<mailman.15302.1414601774.18130.python-list@python.org>
In reply to#79921
Kiuhnm wrote:

> I must say that the lack of static types in Python is a pain in the neck
> especially when I'm exploring new libraries. Recently, I learned a new
> language called Dart which have optional typing and I had a lot of fun
> with it. Basically, you use type annotations as documentation and to give
> useful information to the IDE or editor. That makes the IDE look *very*
> smart! I'm using PyCharm and more often than not I want to see the list of
> methods and attributes of an object, but the editor won't show them to me
> because it doesn't know the dynamic type of the variable whose value was
> just returned by a function. That's irritating! Am I the only one who'd
> like to see optional types introduced in Python?

Personally I am skeptical, but there is an effort underway:

http://www.mypy-lang.org/
https://mail.python.org/pipermail/python-ideas/2014-August/028742.html

Nothing that your search engine of choice could not have found you...

[toc] | [prev] | [next] | [standalone]


#79924

FromKiuhnm <gandalf23@mail.com>
Date2014-10-29 10:18 -0700
Message-ID<18fa60be-225e-422d-82de-902c4a0c66da@googlegroups.com>
In reply to#79923
On Wednesday, October 29, 2014 5:57:13 PM UTC+1, Peter Otten wrote:
> Kiuhnm wrote:
> 
> > I must say that the lack of static types in Python is a pain in the neck
> > especially when I'm exploring new libraries. Recently, I learned a new
> > language called Dart which have optional typing and I had a lot of fun
> > with it. Basically, you use type annotations as documentation and to give
> > useful information to the IDE or editor. That makes the IDE look *very*
> > smart! I'm using PyCharm and more often than not I want to see the list of
> > methods and attributes of an object, but the editor won't show them to me
> > because it doesn't know the dynamic type of the variable whose value was
> > just returned by a function. That's irritating! Am I the only one who'd
> > like to see optional types introduced in Python?
> 
> Personally I am skeptical, but there is an effort underway:
> 
> http://www.mypy-lang.org/
> https://mail.python.org/pipermail/python-ideas/2014-August/028742.html
> 
> Nothing that your search engine of choice could not have found you...

In fact, I did find it, but that didn't stop me from asking :)

You can find something similar for almost any dynamic language out there.
If it isn't an official feature of the language, it's useless, IMHO.

It seems that PyCharm supports some kind of type annotations:
http://www.jetbrains.com/pycharm/webhelp/using-docstrings-to-specify-types.html
Unfortunately, again, if almost no one uses them, they're not very useful.

[toc] | [prev] | [next] | [standalone]


#79925

FromChris Angelico <rosuav@gmail.com>
Date2014-10-30 04:25 +1100
Message-ID<mailman.15303.1414603509.18130.python-list@python.org>
In reply to#79924
On Thu, Oct 30, 2014 at 4:18 AM, Kiuhnm <gandalf23@mail.com> wrote:
>> Personally I am skeptical, but there is an effort underway:
>>
>> http://www.mypy-lang.org/
>> https://mail.python.org/pipermail/python-ideas/2014-August/028742.html
>>
>> Nothing that your search engine of choice could not have found you...
>
> In fact, I did find it, but that didn't stop me from asking :)
>
> You can find something similar for almost any dynamic language out there.
> If it isn't an official feature of the language, it's useless, IMHO.

As you'll see from the python-ideas thread, there's a proposal
under-way to *make* this an official feature. However, it's massively
open to bikeshedding :) If you feel strongly about this, come join us
on python-ideas and weigh in; all input will be warmly received, and
that doesn't mean we respond with flames... not usually, anyway!

ChrisA

[toc] | [prev] | [next] | [standalone]


#79927

FromEthan Furman <ethan@stoneleaf.us>
Date2014-10-29 10:46 -0700
Message-ID<mailman.15304.1414604765.18130.python-list@python.org>
In reply to#79924
On 10/29/2014 10:18 AM, Kiuhnm wrote:
> On Wednesday, October 29, 2014 5:57:13 PM UTC+1, Peter Otten wrote:
>> Kiuhnm wrote:
>>
>>> I must say that the lack of static types in Python is a pain in the neck
>>> especially when I'm exploring new libraries. Recently, I learned a new
>>> language called Dart which have optional typing and I had a lot of fun
>>> with it. Basically, you use type annotations as documentation and to give
>>> useful information to the IDE or editor. That makes the IDE look *very*
>>> smart! I'm using PyCharm and more often than not I want to see the list of
>>> methods and attributes of an object, but the editor won't show them to me
>>> because it doesn't know the dynamic type of the variable whose value was
>>> just returned by a function. That's irritating! Am I the only one who'd
>>> like to see optional types introduced in Python?
>>
>> Personally I am skeptical, but there is an effort underway:
>>
>> http://www.mypy-lang.org/
>> https://mail.python.org/pipermail/python-ideas/2014-August/028742.html
>>
>> Nothing that your search engine of choice could not have found you...
>
> In fact, I did find it, but that didn't stop me from asking :)
>
> You can find something similar for almost any dynamic language out there.
> If it isn't an official feature of the language, it's useless, IMHO.
>
> It seems that PyCharm supports some kind of type annotations:
> http://www.jetbrains.com/pycharm/webhelp/using-docstrings-to-specify-types.html
> Unfortunately, again, if almost no one uses them, they're not very useful.

Even if it becomes official, which seems likely, it will still be optional -- hence, only useful if folks actually use 
it.  ;)

--
~Ethan~

[toc] | [prev] | [next] | [standalone]


#79929

FromChris Angelico <rosuav@gmail.com>
Date2014-10-30 05:03 +1100
Message-ID<mailman.15305.1414605822.18130.python-list@python.org>
In reply to#79924
On Thu, Oct 30, 2014 at 4:46 AM, Ethan Furman <ethan@stoneleaf.us> wrote:
> Even if it becomes official, which seems likely, it will still be optional
> -- hence, only useful if folks actually use it.  ;)

Yes, but if it's official, the standard library (large parts of it, at
least) will use it, which will make it a lot more useful than it
currently is.

ChrisA

[toc] | [prev] | [next] | [standalone]


#79930

FromMarko Rauhamaa <marko@pacujo.net>
Date2014-10-29 20:18 +0200
Message-ID<87vbn268oc.fsf@elektro.pacujo.net>
In reply to#79929
Chris Angelico <rosuav@gmail.com>:

> Yes, but if it's official, the standard library (large parts of it, at
> least) will use it, which will make it a lot more useful than it
> currently is.

I doubt it. Python should decide if it wants to stay Python or become
another Java. I don't really believe in this "be everything for
everybody" thing. You'll only become nothing for anybody.


Marko

[toc] | [prev] | [next] | [standalone]


#79931

FromChris Angelico <rosuav@gmail.com>
Date2014-10-30 05:43 +1100
Message-ID<mailman.15306.1414608221.18130.python-list@python.org>
In reply to#79930
On Thu, Oct 30, 2014 at 5:18 AM, Marko Rauhamaa <marko@pacujo.net> wrote:
> Chris Angelico <rosuav@gmail.com>:
>
>> Yes, but if it's official, the standard library (large parts of it, at
>> least) will use it, which will make it a lot more useful than it
>> currently is.
>
> I doubt it. Python should decide if it wants to stay Python or become
> another Java. I don't really believe in this "be everything for
> everybody" thing. You'll only become nothing for anybody.

Mebbe. More likely, Python wants to lift ideas from anyone and
everyone. List comprehensions came from the functional world, flexible
string representation came from Pike or bash (or was independently
invented), etc, etc.

Python won't turn into Java. The biggest philosophical difference
between the languages, as I see it, is Java's rigidity of boundaries
versus Python's consenting-adults policy. In Java, you write getters
and setters for everything, you lock your class up and make sure
people use it ONLY in the ways you've specified, you declare
parameters/return values/exceptions so people know exactly what to
expect, etc. Python gets out of your way and lets you write a single
application as a concerted whole; if you want to "reach in" and fiddle
with another class's members, go for it. I'm not saying that either
philosophy is *wrong*, of course, but just adding type hints to Python
isn't going to change the underlying philosophical model.

ChrisA

[toc] | [prev] | [next] | [standalone]


#79933

FromKiuhnm <gandalf23@mail.com>
Date2014-10-29 12:03 -0700
Message-ID<07aadf0c-3e9f-4a17-bcca-3e57dcddf31d@googlegroups.com>
In reply to#79930
On Wednesday, October 29, 2014 7:19:11 PM UTC+1, Marko Rauhamaa wrote:
> Chris Angelico <rosuav@gmail.com>:
> 
> > Yes, but if it's official, the standard library (large parts of it, at
> > least) will use it, which will make it a lot more useful than it
> > currently is.
> 
> I doubt it. Python should decide if it wants to stay Python or become
> another Java. I don't really believe in this "be everything for
> everybody" thing. You'll only become nothing for anybody.
> 
> 
> Marko

1) Java is not optionally typed.
2) Having optional types is not "being everything for everybody", it's just being smart.

[toc] | [prev] | [next] | [standalone]


#79934

FromMarko Rauhamaa <marko@pacujo.net>
Date2014-10-29 21:07 +0200
Message-ID<87lhny66fb.fsf@elektro.pacujo.net>
In reply to#79933
Kiuhnm <gandalf23@mail.com>:

> 2) Having optional types is not "being everything for everybody", it's
> just being smart.

We'll see, we'll see...


Marko

[toc] | [prev] | [next] | [standalone]


#79936

FromKiuhnm <gandalf23@mail.com>
Date2014-10-29 12:09 -0700
Message-ID<4be9d891-711c-45cd-81e4-1da523c18b8a@googlegroups.com>
In reply to#79933
On Wednesday, October 29, 2014 8:03:16 PM UTC+1, Kiuhnm wrote:
> On Wednesday, October 29, 2014 7:19:11 PM UTC+1, Marko Rauhamaa wrote:
> > Chris Angelico <rosuav@gmail.com>:
> > 
> > > Yes, but if it's official, the standard library (large parts of it, at
> > > least) will use it, which will make it a lot more useful than it
> > > currently is.
> > 
> > I doubt it. Python should decide if it wants to stay Python or become
> > another Java. I don't really believe in this "be everything for
> > everybody" thing. You'll only become nothing for anybody.
> > 
> > 
> > Marko
> 
> 1) Java is not optionally typed.
> 2) Having optional types is not "being everything for everybody", it's just being smart.

...where "smart" is referred to IDEs, etc...

[toc] | [prev] | [next] | [standalone]


#79937

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-10-29 19:22 +0000
Message-ID<mailman.15308.1414610585.18130.python-list@python.org>
In reply to#79933
On 29/10/2014 19:03, Kiuhnm wrote:
> On Wednesday, October 29, 2014 7:19:11 PM UTC+1, Marko Rauhamaa wrote:
>> Chris Angelico <rosuav@gmail.com>:
>>
>>> Yes, but if it's official, the standard library (large parts of it, at
>>> least) will use it, which will make it a lot more useful than it
>>> currently is.
>>
>> I doubt it. Python should decide if it wants to stay Python or become
>> another Java. I don't really believe in this "be everything for
>> everybody" thing. You'll only become nothing for anybody.
>>
>>
>> Marko
>
> 1) Java is not optionally typed.
> 2) Having optional types is not "being everything for everybody", it's just being smart.
>

Regarding 2) Python has somehow managed without optional types for over 
20 years so it's my belief that they're not the panacea that so many 
people think they are.  Sure if they get implemented and if they improve 
Python then I'm all for them, but I'm not holding my breath.

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

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#79940

FromMarko Rauhamaa <marko@pacujo.net>
Date2014-10-29 21:44 +0200
Message-ID<87h9ym64p4.fsf@elektro.pacujo.net>
In reply to#79937
Mark Lawrence <breamoreboy@yahoo.co.uk>:

> Regarding 2) Python has somehow managed without optional types for
> over 20 years so it's my belief that they're not the panacea that so
> many people think they are. Sure if they get implemented and if they
> improve Python then I'm all for them, but I'm not holding my breath.

I'm afraid of stylistic chaos and optional types turning into de-facto
mandatory types as modules interface each other.


Marko

[toc] | [prev] | [next] | [standalone]


#79942

FromKiuhnm <gandalf23@mail.com>
Date2014-10-29 13:43 -0700
Message-ID<b0ad9e23-e1bc-4a53-bf58-d188c2ae0e71@googlegroups.com>
In reply to#79940
On Wednesday, October 29, 2014 8:45:08 PM UTC+1, Marko Rauhamaa wrote:
> Mark Lawrence <breamoreboy@yahoo.co.uk>:
> 
> > Regarding 2) Python has somehow managed without optional types for
> > over 20 years so it's my belief that they're not the panacea that so
> > many people think they are. Sure if they get implemented and if they
> > improve Python then I'm all for them, but I'm not holding my breath.
> 
> I'm afraid of stylistic chaos and optional types turning into de-facto
> mandatory types as modules interface each other.

The only problem I see is that Python's type system might become too complex (Scala anyone???)
If you start adding covariance, contravariance, F-bounded types, etc..., the type system becomes more of a hindrance, IMHO.
But if you keep it simple (like Dart) it shouldn't get in your way.

[toc] | [prev] | [next] | [standalone]


#79941

FromKiuhnm <gandalf23@mail.com>
Date2014-10-29 13:40 -0700
Message-ID<823b7ef6-ebc4-4718-b862-d9d16f8c4aa8@googlegroups.com>
In reply to#79937
On Wednesday, October 29, 2014 8:23:30 PM UTC+1, Mark Lawrence wrote:
> On 29/10/2014 19:03, Kiuhnm wrote:
> > On Wednesday, October 29, 2014 7:19:11 PM UTC+1, Marko Rauhamaa wrote:
> >> Chris Angelico <rosuav@gmail.com>:
> >>
> >>> Yes, but if it's official, the standard library (large parts of it, at
> >>> least) will use it, which will make it a lot more useful than it
> >>> currently is.
> >>
> >> I doubt it. Python should decide if it wants to stay Python or become
> >> another Java. I don't really believe in this "be everything for
> >> everybody" thing. You'll only become nothing for anybody.
> >>
> >>
> >> Marko
> >
> > 1) Java is not optionally typed.
> > 2) Having optional types is not "being everything for everybody", it's just being smart.
> >
> 
> Regarding 2) Python has somehow managed without optional types for over 
> 20 years so it's my belief that they're not the panacea that so many 
> people think they are.  Sure if they get implemented and if they improve 
> Python then I'm all for them, but I'm not holding my breath.

The only thing I know is that I programmed in ASM and C++ for many years and I liked it. Then I moved to C#, Haskell, Scala, and many other languages. Then I learned Python and I liked it. Then I tried Dart (with optional static typing) and liked it very much. Finally, I've come back to Python and I don't like it anymore like I used to. Dart's syntax is not on par with Python's but its type system is so lightweight and non intrusive that it's a joy to work with it and I miss it.

[toc] | [prev] | [next] | [standalone]


#79932

FromNick Cash <nick.cash@npcinternational.com>
Date2014-10-29 16:25 +0000
Message-ID<mailman.15307.1414609058.18130.python-list@python.org>
In reply to#79921
> Am I the only one who'd like to see optional types introduced in Python?

Nope! Some dude named "Guido" would like to see them as well:
https://mail.python.org/pipermail/python-ideas/2014-August/028742.html

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web