Python Forum
the return statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
the return statement
#1
SyntaxError: 'return' outside function

IMHO, they should have made return outside of a function be allowed and do the same as exit().
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
No way jose!
Reply
#3
I'm very glad it's a syntax error because it's so much more likely to be an accident than intentional. If you actually want to exit, you can just call exit.
Reply
#4
(May-26-2018, 09:53 PM)micseydel Wrote: I'm very glad it's a syntax error because it's so much more likely to be an accident than intentional. If you actually want to exit, you can just call exit.
conceptually, i just want to go back to where i came from. if i had designed computer languages "end" would not have been paired with "begin". it would have been a run time directive. it would have ended whatever it was in.

ok, ok, it's my C/assembly thinking where the return/goback things really were the same in the main program. main is just a function.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#5
No way, it's syntactically wrong, has the wrong meaning and Python is not like C.
One wrong indentation and your program just exits.

If you want to do really a change, read the mailinglist python-dev and/or work with other people on a pep and you'll see the process how the language is extended. But this needs hard work, acceptance of the Community and Guido has the last word, which is good.


Here an example how the process works

Quote:> >
> > Comments, suggestions are welcome.
> >
>
> One comment.
>
> I'm not interested in downloading a PDF. Can you rework your document
> to be in a more textual format like Markdown or reStructuredText?
> Since you're hosting on GitHub anyway, the rendering can be done
> automatically.
>
> ChrisA


What against PDF?
Anyway, I have reloaded files with most recent corrections in various formats:

PDF
https://github.com/Mikhail22/Documents/b...ks-v01.pdf

TXT
https://github.com/Mikhail22/Documents/b...ks-v01.txt

HTML(direct preview link)
http://htmlpreview.github.io/?https://ra...s-v01.html


"Markdown" is too vague - there dozens of markdown styles and
also they include subsets of HTML. It is just plain text with tags -
it cannot represent syntax in civilized form (unless I embed images
for every source example - but then it is too inconvenient for editing).
Source examples on Github will force a crappy font and replace tabs.

I suggest you just view HTML or PDF - it looks better and if you need
source - just download TXT - it has tabs preserved at least.

He is working on the pep and the discussion goes on. This came from python-list.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#6
when using Python, think Python.
After all this time, you're still trying to turn Python into 'C'.
'C' is 'C', Python is Python
If you are so in love with 'C', go back to 'C' and leave Python alone!

I was a 'C' and 'C++' programmer for a long, long time.

I rarely think about C when using Python anymore, just as I didn't think of Lisp once I started to use 'C'.

Frankly, I'd wish you stop!
Reply
#7
i certainly am trying to think python for python code. but i also have done the "design a programming language" thing and that co-routine still like to run in my head. i know i can never get rid of it, much like i still do "think like C" because i still code in C. i've pretty much ended most of my assembly code but i do still run into it for many architecture from ARM (BE and LE) to S/370 (haven't done any new S/390 instructions, yet, and hope not to). last i did was SPARC stuff.

the only major change i've made is going from "rewrite all bash scripts into python" to "i'll have a mix of python and bash". but i am making a few things in python to use in bash. i have not decided what i will do with pike, yet, but i have not coded anything in pike for about 6 years. between C and python, there is no gap for pike. for someone that is dead set against blocking code by indentation i'll tell them to do java or pike.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020