Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of order commands excecution? #39612

Closed
nadavhoresh mannequin opened this issue Nov 27, 2003 · 6 comments
Closed

Out of order commands excecution? #39612

nadavhoresh mannequin opened this issue Nov 27, 2003 · 6 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@nadavhoresh
Copy link
Mannequin

nadavhoresh mannequin commented Nov 27, 2003

BPO 850110
Nosy @mwhudson

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/mwhudson'
closed_at = <Date 2003-12-01.14:31:04.000>
created_at = <Date 2003-11-27.08:54:21.000>
labels = ['interpreter-core', 'invalid']
title = 'Out of order commands excecution?'
updated_at = <Date 2003-12-01.14:31:04.000>
user = 'https://bugs.python.org/nadavhoresh'

bugs.python.org fields:

activity = <Date 2003-12-01.14:31:04.000>
actor = 'nadavhoresh'
assignee = 'mwh'
closed = True
closed_date = None
closer = None
components = ['Interpreter Core']
creation = <Date 2003-11-27.08:54:21.000>
creator = 'nadavhoresh'
dependencies = []
files = []
hgrepos = []
issue_num = 850110
keywords = []
message_count = 6.0
messages = ['19155', '19156', '19157', '19158', '19159', '19160']
nosy_count = 3.0
nosy_names = ['mwh', 'nnorwitz', 'nadavhoresh']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue850110'
versions = ['Python 2.3']

@nadavhoresh
Copy link
Mannequin Author

nadavhoresh mannequin commented Nov 27, 2003

Consider the following:

>>> import string
>>> def test1():
	join = string.join

	
>>> def test2():
	join = string.join
	string = string.split

>> test1()
>> test2()

Traceback (most recent call last):
  File "<pyshell#9>", line 1, in -toplevel-
    test2()
  File "<pyshell#7>", line 2, in test2
    join = string.join
UnboundLocalError: local variable 'string' referenced
before assignment
>>> 

How the second statement in test2 generates an error in
first one?

Nadav.

@nadavhoresh nadavhoresh mannequin closed this as completed Nov 27, 2003
@nadavhoresh nadavhoresh mannequin added the invalid label Nov 27, 2003
@nadavhoresh nadavhoresh mannequin assigned mwhudson Nov 27, 2003
@nadavhoresh nadavhoresh mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 27, 2003
@nadavhoresh nadavhoresh mannequin closed this as completed Nov 27, 2003
@nadavhoresh nadavhoresh mannequin added the invalid label Nov 27, 2003
@nadavhoresh nadavhoresh mannequin assigned mwhudson Nov 27, 2003
@nadavhoresh nadavhoresh mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 27, 2003
@mwhudson
Copy link

Logged In: YES
user_id=6656

Well, that's just how it works. This must be documented
somewhere... see if

http://www.python.org/doc/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python

helps (and maybe the question before).

@nadavhoresh
Copy link
Mannequin Author

nadavhoresh mannequin commented Nov 30, 2003

Logged In: YES
user_id=75473

I've looked at the FAQ and it is not seems to sesolve the
issue: In test2 "string" becomes a local variable in the
second line, while in the first line (join = string.join)
"string" should point to the (global) string module.

Nadav.

@nnorwitz
Copy link
Mannequin

nnorwitz mannequin commented Dec 1, 2003

Logged In: YES
user_id=33168

If a variable is local in a function, it is local throughout
the whole function. It doesn't become local at the first
assignment, but from the beginning of the function. Does
that help?

@mwhudson
Copy link

mwhudson commented Dec 1, 2003

Logged In: YES
user_id=6656

Well, you reopened the bug, so you're obviously not happy.
What do you want to see changed? The behaviour? No chance.
Better documentation? Feel free to supply a patch (or just
suggest wording and a location, others can do the latex).

@nadavhoresh
Copy link
Mannequin Author

nadavhoresh mannequin commented Dec 1, 2003

Logged In: YES
user_id=75473

I understand that this is just a documentation issue. I
guess that probably the interpreter builds the variables
table before executing the first line of code. But, I afraid
that I am not familiar with the internal of python to raise
such statements.

Thank you very much for your help

Nadav.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

1 participant