mirror of https://github.com/python/cpython.git
Use 'global' instead of struct kludge.
This commit is contained in:
parent
8fd7eee6db
commit
4a3a41f1bb
|
@ -11,11 +11,9 @@
|
||||||
template = '@'
|
template = '@'
|
||||||
|
|
||||||
|
|
||||||
# Kludge to hold mutable state
|
# Counter for generating unique names
|
||||||
|
|
||||||
class Struct: pass
|
counter = 0
|
||||||
G = Struct()
|
|
||||||
G.i = 0
|
|
||||||
|
|
||||||
|
|
||||||
# User-callable function
|
# User-callable function
|
||||||
|
@ -24,9 +22,10 @@ class Struct: pass
|
||||||
# XXX By all means, avoid a mess with four different functions like C...
|
# XXX By all means, avoid a mess with four different functions like C...
|
||||||
|
|
||||||
def mktemp():
|
def mktemp():
|
||||||
|
global counter
|
||||||
while 1:
|
while 1:
|
||||||
G.i = G.i+1
|
counter = counter+1
|
||||||
file = tempdir +'/'+ template + `posix.getpid()` +'.'+ `G.i`
|
file = tempdir+'/'+template+`posix.getpid()`+'.'+`counter`
|
||||||
if not path.exists(file):
|
if not path.exists(file):
|
||||||
break
|
break
|
||||||
return file
|
return file
|
||||||
|
|
Loading…
Reference in New Issue