Deutsch   English   Français   Italiano  
<message-20230826002855@ram.dialup.fu-berlin.de>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: eternal-september.org!news.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Collecting unassigned Expressions
Date: 25 Aug 2023 23:31:06 GMT
Organization: Stefan Ram
Lines: 30
Expires: 1 Sep 2024 11:59:58 GMT
Message-ID: <message-20230826002855@ram.dialup.fu-berlin.de>
References: <mailman.251.1692876209.23016.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de aNymjt0oA7YMZ3lBwS7aWgF3IsOEPPNUybAaw1u5PHcEqu
Cancel-Lock: sha1:nm45jf0GdKqIxGT7hwDXaQ/9nvo= sha256:SaHh9CcBX4B4HIGIvv50AAQTTIJIFaTdAt9oTp/azic=
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
	Distribution through any means other than regular usenet
	channels is forbidden. It is forbidden to publish this
	article in the Web, to change URIs of this article into links,
        and to transfer the body without this notice, but quotations
        of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
	services to mirror the article in the web. But the article may
	be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR

Guenther Sohler <guenther.sohler@gmail.com> writes:
>I am wondering If an embedded Python Interpreter can detect unassigned
>Expressions. Cases where functions Return values but they are Not
>assignwd. E.g.
>Calc_square(4)
>Or
>3*4-myval()

  1. If "Calc_square(4)" appears in the context "n=Calc_square(4)",
  then its value is assigned. So, it is not necessarily an example
  of a function call expression the value of which is not assigned.

  2. In Python function call expressions always have a value.

  3. If you can modify the the interpreter, you surely can make it
  emit an expression such as "Info: The value of the function call
  expression 'Calc_square(4)' was not bound to an identifier.".

  4. You also can use the parser library that comes with Python to
  parse source code and detect such situations yourself. E.g.,

import ast
....
parse = ast.parse( source, filename ) 
for entry in ast.walk( parse ):
....

  .