Re: How return no return ?
At the interactive prompt, a result is printed when both these things are true: * The entered code is an expression, not any other kind of statement * The result of the expression is not 'None' If an expression occurs, information about it will be printed instead. So the interpreter won't print a result for a = 3# because it's an assignment statement def f(): return # because it's a 'def' statement None # because the result of the expression is 'None' f() # because the result of the expression is 'None' Your example int a is not Python, but if it was it would probably be a non-expression statement, and thus never print a result in the interpreter. Jeff pgpYRHXaq9ZxI.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
How return no return ?
Hello, I want that the return sentence don't return anything, how can I do it?. If i do only return it returns None, and pass don't run too. Can anyone help me?, thanks. XIMO -- http://mail.python.org/mailman/listinfo/python-list
Re: How return no return ?
Ximo wrote: Hello, I want that the return sentence don't return anything, how can I do it?. If i do only return it returns None, and pass don't run too. Can anyone help me?, thanks. XIMO Returning None is the same as returning nothing. What exactly are you trying to do? -- http://mail.python.org/mailman/listinfo/python-list
Re: How return no return ?
Ximo [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, I want that the return sentence don't return anything, how can I do it?. If i do only return it returns None, and pass don't run too. Can anyone help me?, thanks. XIMO Just don't use a return statement at all, or do something like [function body] if not val = None: return val [end of function] -- http://mail.python.org/mailman/listinfo/python-list
Re: How return no return ?
I am doing a interpret of lines and it show me a prompt, and I want if I write a declaration as int a my progrtam return de prompt and nothing more, for exemple: 2+2 4 int a Then I'm finding that de function which execute int a return me nothing, and no int a None Joseph Garvin [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] Ximo wrote: Hello, I want that the return sentence don't return anything, how can I do it?. If i do only return it returns None, and pass don't run too. Can anyone help me?, thanks. XIMO Returning None is the same as returning nothing. What exactly are you trying to do? -- http://mail.python.org/mailman/listinfo/python-list
Re: How return no return ?
[Ximo] I want that the return sentence don't return anything, how can I do it? `return' always return something (if we except the case of generators). Used without arguments, it returns None, as you discovered already. If a function falls through its end, None is implicitely returned. A function always have a value. I do not understand the need of not returning anything. What do you mean? What is the real need? [...] pass don't run too. `pass' surely runs. However, `pass' is not a `return' statement. -- François Pinard http://pinard.progiciels-bpi.ca -- http://mail.python.org/mailman/listinfo/python-list
Re: How return no return ?
On Thu, May 12, 2005 at 04:42:34PM +0100, Tim Williams wrote: Just don't use a return statement at all, or do something like [function body] if not val = None: return val [end of function] i didn't understood that. if you don't return nothing explicitly the function returns None. (or am i wrong?) c. -- Hi, I'm a .signature virus! Copy me to your .signature file and help me propagate, thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: How return no return ?
I am doing my own interpreter with the Python languaje. Do you understand me? Fredrik Lundh [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] Ximo wrote: I am doing a interpret of lines and it show me a prompt, and I want if I write a declaration as int a my progrtam return de prompt and nothing more, for exemple: 2+2 4 int a Then I'm finding that de function which execute int a return me nothing, and no int a None what Python version are you using? here's what a normal Python interpreter is supposed to do with your example: 2+2 4 int a File stdin, line 1 int a ^ SyntaxError: invalid syntax /F -- http://mail.python.org/mailman/listinfo/python-list
Re: How return no return ?
On 5/12/05, Ximo [EMAIL PROTECTED] wrote: I am doing my own interpreter with the Python languaje. Do you understand me? Well, to be frank, no. However, Frederik's point still stands; in the python langage, int a is syntactically invalid. If you're writing your own interpreter, it should still be syntactically invalid. Could you perhaps repeat your question with an example of what behavior is surprising you? Peace Bill Mill bill.mill at gmail.com Fredrik Lundh [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] Ximo wrote: I am doing a interpret of lines and it show me a prompt, and I want if I write a declaration as int a my progrtam return de prompt and nothing more, for exemple: 2+2 4 int a Then I'm finding that de function which execute int a return me nothing, and no int a None what Python version are you using? here's what a normal Python interpreter is supposed to do with your example: 2+2 4 int a File stdin, line 1 int a ^ SyntaxError: invalid syntax /F -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: How return no return ?
Ximo wrote: I am doing my own interpreter with the Python languaje. Do you understand me? Fredrik Lundh [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] Ximo wrote: I am doing a interpret of lines and it show me a prompt, and I want if I write a declaration as int a my progrtam return de prompt and nothing more, for exemple: You may be looking for the flags argument to the compile function: exec compile(int(3),console,single) 3 exec compile(int(3),console,exec) help(compile) Help on built-in function compile in module __builtin__: compile(...) compile(source, filename, mode[, flags[, dont_inherit]]) - code object Compile the source string (a Python module, statement or expression) into a code object that can be executed by the exec statement or eval(). The filename will be used for run-time error messages. The mode must be 'exec' to compile a module, 'single' to compile a single (interactive) statement, or 'eval' to compile an expression. The flags argument, if present, controls which future statements influence the compilation of the code. The dont_inherit argument, if non-zero, stops the compilation inheriting the effects of any future statements in effect in the code calling compile; if absent or zero these statements do influence the compilation, in addition to any features explicitly specified. Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: How return no return ?
Ximo a écrit : I am doing my own interpreter with the Python languaje. Do you understand me? I will do my best : I guess that you are about to write your own non python interpreter (I mean, it will interpret some language that is not Python) and your interpreter sadly writes None when there is none to write. Is that correct ? If yes, I suggest that you replace somewhere in your code: print result by if result is not None: print result I know that this is not the question but if it is right that your interpreter is not a python interpreter and that you build a console on top of it (I know many assumptions, ...), I would like to kindly suggest you to use something else that the Python prompt () - at least on this NG - I am afraid that _this_ didn't help anybody to understand what you meant. If by pure coincidence, this helped you, it would unexpectingly enlight my day ... and please don't tell me that my english is perfect, I know it perfectly well. -- http://mail.python.org/mailman/listinfo/python-list