473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Decorators and static typing.

Well, the decorator war is over (Python lost IMO!) and now we've got the
static typing war to fight!

Both of these seem like syntax sugar to avoid writing good code! One has
already introduced ugly coding and the 2nd is likely to do the same!

Ok, so how do you do keywords and default values?
def myFunc(a=1: int, b="hi": string, people=[]: array[person]): int:
yadda
yadda
yadda
So, what is the int or string? the default value or the label? (Of
course it's obvious to an experienced programmer - is that the intened
audience for Python now and the python in education initiative dead?).
The last parameter is particularly arcane (and ugly!).

If this mistake looking for a place to happen has to happen, at least
put the type before the horse!:
def myFunc(int a=1, string b="hi" array[person] people) int: #note lack
of first : after "("
yadda
yadda
yadda

Of course, one could not change the language at all!:
def myFunc(a, b):
assert(type(a) == "int")
assert(type(b) == "string")
#aggrigates lose here - how do you check the type of every element?
(ensure that array[person].__add__ makes sure the rhs is of type person
so the problem never comes up in the first place!)
yadda
yadda
yadda
I know: this doesn't save you from yourself when calling myFunc from
somewhere else, but it does ensure that parameters are of the expected
type where it really counts! (People who need saiving from themselves
ought not to be programmers in the first place!)

Of course, decorators might have been done this last way too - with
predefined functions and no needed changes to the language, but maybe
that's not as cool for the dev guys. That brings up the larger problem,
as alluded to by the "python evolution: unease" thread: the dev guys
seem intent on more breadth without focusing on the depth of the language!

At some point, someone has to decide that python is feature complete!

Lua is looking better and better! ;=)
Jul 18 '05 #1
0 913

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael Sparks | last post by:
Anyway... At Europython Guido discussed with everyone the outstanding issue with decorators and there was a clear majority in favour of having them, which was good. From where I was sitting it...
17
by: daishi | last post by:
For what it's worth: As far as I know, the proposed @decorator syntax will be the first time that two logical lines of python with the same indentation will not be independent of one another....
4
by: Doug Holton | last post by:
First let me say please see the wiki page about python decorators if you haven't already: http://www.python.org/cgi-bin/moinmoin/PythonDecorators I propose (and others have) that built-in...
2
by: gohaku | last post by:
Hi everyone, The discussion on Python Decorators and "@" has piqued my interest on this "feature?" in programming languages such as Python and Java. can anybody what is the point in using...
8
by: Paul Morrow | last post by:
I like many am not wild about the <at> operator. I also don't think that the decorator syntax should be so directly attached to the method, since what we're trying to do is to say something about...
2
by: Guido van Rossum | last post by:
Robert and Python-dev, I've read the J2 proposal up and down several times, pondered all the issues, and slept on it for a night, and I still don't like it enough to accept it. The only reason...
0
by: Anthony Baxter | last post by:
To go along with the 2.4a3 release, here's an updated version of the decorator PEP. It describes the state of decorators as they are in 2.4a3. PEP: 318 Title: Decorators for Functions and...
13
by: km | last post by:
Hi all, was going thru the new features introduced into python2.4 version. i was stuck with 'decorators' - can someone explain me the need of such a thing called decorators ? tia KM
9
by: Bengt Richter | last post by:
;-) We have @deco def foo(): pass as sugar (unless there's an uncaught exception in the decorator) for def foo(): pass foo = deco(foo) The binding of a class name is similar, and class...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.