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 9 1627
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?
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" <k0*****@kzoo.e du> escribió en el mensaje
news:ma******** *************** *************** @python.org... 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?
[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
"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>
I am doing my own interpreter with the Python languaje.
Do you understand me?
"Fredrik Lundh" <fr*****@python ware.com> escribió en el mensaje
news:ma******** *************** *************** @python.org... "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>
On 5/12/05, Ximo <el*****@yahoo. es> 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" <fr*****@python ware.com> escribió en el mensaje news:ma******** *************** *************** @python.org... "Ximo" wrote:
I am doing a interpret of lines and it show me a prompt, and I want ifI 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
Ximo wrote: I am doing my own interpreter with the Python languaje.
Do you understand me? "Fredrik Lundh" <fr*****@python ware.com> escribió en el mensaje news:ma******** *************** *************** @python.org...
"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
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.
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFChKUbJd0 1MZaTXX0RAunPAJ 0b3XM2Lo5fzLdVK vu9MFsc25vwrACf RM3c
QiLX2q0+qeof4uH Ja2Kq6K4=
=rkiZ
-----END PGP SIGNATURE----- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: KENNY L. CHEN |
last post by:
Dear experts,
I have two tables in my Oracle 8i database: TEST (COL1,COl2,REC_NO)
and TEST1 (COL1,COL2,REC_NO).
Both tables are unique-indexed on (COL1,COL2,REC_NO).
I think the following SQL commands will return the same result but one
of my friends don't think so. He said "QUERY 1" will return 1 unsorted
record (ROWNUM < 2 ) first then sort the result (ORDER BY COL1 ASC,
|
by: yingjian.ma1955 |
last post by:
When I want to disable the select functionality, Can I just use
onselectstart="return false"? I tried it and it works. But it seems
people always put onselectstart="return false" ondragstart="return
false" together. What is the use of the latter part?
|
by: Mike Machuidel |
last post by:
Hi,
I'm a game developer programming mostly in C and ASM for about 7 years.
Today at work a colleague (a C++ programmer) yelled at me I'm a bad C
programmer because I use "return(0);" instead of "return 0;".
He explained that "return" is not a function but a stament, like I
didn't know already. The other colleagues also argreed with him :(.
Can someone please explain what's so wrong about using "return" with
|
by: LaEisem |
last post by:
On-the-job, I have "inherited" a lot of old C language software.
A question or two about when "casting" of null pointer constants
is needed has occurred during behind-the-scenes cleanup
of some of that software. That subject seems not to be addressed,
at least not directly, in the C FAQ where FAQ 5.2 seems most relevant.
References:
* C FAQ 5.2 Null pointers
(Including conditions where "casting" of
null pointer...
|
by: Greenhorn |
last post by:
Hi,
when a function doesn't specify a return type ,value what value is
returned. In the below programme, the function sample()is returning the
value passed to 'k'.
sample(int);
main()
{
int i = 0,j;
j = sample(0);
| |
by: Joeyej |
last post by:
Hi -
I'm trying to move/use a web form (containing some javascript field
checks) previously hosted on a Windows 2000 server. However, the FORM
METHOD="post..." command in the form (shown below) now renders "Page
not Found" when launched on the new Windows 2003 server (ws-server1).
The form is designed to use the write.asp program to write to an
Acccess database and is successful on any Windows 2000 server. This is
frustrating because...
|
by: Holger (David) Wagner |
last post by:
Hi there,
we have an application which is built with several ASCX controls some of
which contain form elements (e.g. Textboxes, Buttons etc.)
For example: in the top section (one ascx-control), there is a
textbutton in which the user can enter a string to search for. There's
link button right next to that textbutton. Then, in the "content
section" (another ascx-control), there may be a login-dialog which
prompts the user for...
|
by: kurtj |
last post by:
Hello Gurus:
I have a validation script (below) that is somehow messed up. If the
Name field is blank, I get the alert message, then the browser window
goes to a blank document with the word "false" on it. What the ?!?!?!
To test, I commented out the 'return false;' code in the second IF
block, so now if there is a value in Name then I get the alert message
for Email and the page stays put.
|
by: Mark P |
last post by:
I'm implementing an algorithm and the computational flow is a somewhat
deep. That is, fcn A makes many calls to fcn B which makes many calls
to fcn C, and so on. The return value of the outermost fcn is a boolean
and there are certain places within the inner functions where it may
become apparent that the return value is false. In this case I'd like
to halt the computation immediately and return false.
My current approach is to have...
|
by: yaru22 |
last post by:
In one of the examples in the book I'm reading, it says:
def __init__(self):
...
...
...
return
It has nothing after "return". I expected it to have some number like 0
or 1.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |