Steve Dower added the comment:
You should start by posting this to python-list or StackOverflow, and I'd
suggest including code that can actually be run - it's far more precise than
pseudocode.
(Functions and modules get used a lot. It's far more likely there's a bug in
your code than in
New submission from arthur:
defined global var, glob.myVar, in separated module
imported module containing glob.myVar
in function1, func1():
glob.myVar =
func1Var = func2()
in function2, func2():
if (...):
glob.myVar+= abc
func2() # call func2() again - recursive
else:
return glob.myVar
I
In message mailman.2771.1273327690.23598.python-l...@python.org, Alex Hall
wrote:
... I have about fifteen vars in a function which have to be
global.
Why not make them class variables, e.g.
class my_namespace :
var1 = ...
var2 = ...
#end my_namespace
def
Hi all,
I am sorry if this is the second message about this you get; I typed
this and hit send (on gmail website) but I got a 404 error, so I am
not sure if the previous message made it out or not.
Anyway, I have about fifteen vars in a function which have to be
global. Is there a faster and more
Alex Hall wrote:
Hi all,
I am sorry if this is the second message about this you get; I typed
this and hit send (on gmail website) but I got a 404 error, so I am
not sure if the previous message made it out or not.
Anyway, I have about fifteen vars in a function which have to be
global. Is there
On 8 May, 15:08, Alex Hall mehg...@gmail.com wrote:
Hi all,
I am sorry if this is the second message about this you get; I typed
this and hit send (on gmail website) but I got a 404 error, so I am
not sure if the previous message made it out or not.
Anyway, I have about fifteen vars in a
On 5/8/10, Jon Clements jon...@googlemail.com wrote:
On 8 May, 15:08, Alex Hall mehg...@gmail.com wrote:
Hi all,
I am sorry if this is the second message about this you get; I typed
this and hit send (on gmail website) but I got a 404 error, so I am
not sure if the previous message made it
On Sun, May 9, 2010 at 12:08 AM, Alex Hall mehg...@gmail.com wrote:
Hi all,
I am sorry if this is the second message about this you get; I typed
this and hit send (on gmail website) but I got a 404 error, so I am
not sure if the previous message made it out or not.
Anyway, I have about
On 8 May, 16:03, Alex Hall mehg...@gmail.com wrote:
On 5/8/10, Jon Clements jon...@googlemail.com wrote:
On 8 May, 15:08, Alex Hall mehg...@gmail.com wrote:
Hi all,
I am sorry if this is the second message about this you get; I typed
this and hit send (on gmail website) but I got a 404
On Sat, 08 May 2010 10:08:08 -0400, Alex Hall wrote:
Hi all,
I am sorry if this is the second message about this you get; I typed
this and hit send (on gmail website) but I got a 404 error, so I am not
sure if the previous message made it out or not. Anyway, I have about
fifteen vars in a
I have a main module doStuff.py and another module utility.py. At the
start of doStuff.py I call
import utility.py
Then I also proceed to initiallize some global variables
sName =
Then I create a class, some methods etc. In one of the methods I assign
a value to my variable sName.
RgeeK wrote:
I have a main module doStuff.py and another module utility.py. At the
start of doStuff.py I call
import utility.py
that tries to import a module named py from the package utility.
Then I also proceed to initiallize some global variables
sName =
Within my utility.py
Fredrik Lundh wrote:
import utility.py
that tries to import a module named py from the package utility.
oops - that was just a typo in my post - I meant of course import utility
Python doesn't have program-wide global variables; if you need that,
create a support module and import that
Fredrik Lundh wrote:
import utility.py
that tries to import a module named py from the package utility.
oops - that was just a typo in my post - I meant of course import utility
Python doesn't have program-wide global variables; if you need that,
create a support module and import that
Dennis Lee Bieber wrote:
On Wed, 27 Aug 2008 16:21:03 -0400, RgeeK [EMAIL PROTECTED]
declaimed the following in comp.lang.python:
I have a main module doStuff.py and another module utility.py. At the
start of doStuff.py I call
import utility.py
I hope not... import utility
Bruno Ferreira wrote:
I wrote a very simple python program to generate a sorted list of
lines from a squid access log file.
Now that your immediate problem is solved it's time to look at the heapq
module. It solves the problem of finding the N largest items in a list
much more efficiently. I
Hello all,
Amazing :)
The program is working properly now, the code is much better and I
learned a bit more Python.
Thank you all, guys.
Bruno.
2008/1/4, Peter Otten [EMAIL PROTECTED]:
Bruno Ferreira wrote:
I wrote a very simple python program to generate a sorted list of
lines from a
Hi,
I wrote a very simple python program to generate a sorted list of
lines from a squid access log file.
Here is a simplified version:
##
1 logfile = open (squid_access.log, r)
2 topsquid = [[0, 0, 0, 0, 0, 0, 0]]
3
4 def add_sorted (list):
5 for i in
Bruno Ferreira wrote:
Hi,
I wrote a very simple python program to generate a sorted list of
lines from a squid access log file.
Here is a simplified version:
##
1 logfile = open (squid_access.log, r)
2 topsquid = [[0, 0, 0, 0, 0, 0, 0]]
3
4 def
Bruno Ferreira wrote:
Hi,
I wrote a very simple python program to generate a sorted list of
lines from a squid access log file.
Here is a simplified version:
##
1 logfile = open (squid_access.log, r)
2 topsquid = [[0, 0, 0, 0, 0, 0, 0]]
3
4 def
Bruno Ferreira wrote:
Hi,
I wrote a very simple python program to generate a sorted list of
lines from a squid access log file.
Here is a simplified version:
##
1 logfile = open (squid_access.log, r)
2 topsquid = [[0, 0, 0, 0, 0, 0, 0]]
3
4 def
Bruno Ferreira wrote:
When I execute the program _without_ the lines 10 and 11:
10 if len(topsquid) 50:
11 topsquid = topsquid[0:50]
it runs perfectly.
But if I execute the program _with_ those lines, this exception is thrown:
[EMAIL PROTECTED]:~$ python topsquid.py
On Thu, 03 Jan 2008 11:38:48 -0300, Bruno Ferreira wrote:
Hi,
I wrote a very simple python program to generate a sorted list of lines
from a squid access log file.
Here is a simplified version:
##
1 logfile = open (squid_access.log, r)
2 topsquid =
Méta-MCI [EMAIL PROTECTED] wrote:
Example, with meta-data (attributs of function) :
def ff(this):
try:
this.count=this.count+1
except:
this.count=1
a=1
b=2
c=a+b
ff(ff)
fa=ff
ff(ff)
fa(fa)
print ff.count
How to improve that?
If I've
Re!
I can do :
def ff():
this=ff
try:
this.count=this.count+1
except:
this.count=1
a=1
b=2
c=a+b
ff()
fa=ff
ff()
fa()
print ff.count
But that use, inside the function, the litteral name of the function; and I
want no use litteral name (inside)
@+
Méta-MCI wrote:
Example, with meta-data (attributs of function) :
Apart from asking what counting nb call of a function means, I
wonder why you didn't use an iterator?
@-salutations
@-less Regards,
Björn
--
BOFH excuse #65:
system needs to be rebooted
--
Re!
why you didn't use an iterator?
If the iterator is extern (to the function), it's like decorator, or global
var.
If it is internal, it's huge, compare to this.count=this.count+1 (or
this.count+=1)
@+
Michel Claveau
--
http://mail.python.org/mailman/listinfo/python-list
Méta-MCI wrote:
If the iterator is extern (to the function), it's like decorator,
or global var.
Please excuse me, I don't understand your point. I'm not even sure
if both of us speak of the same iterators.
If it is internal, it's huge, compare to this.count=this.count+1
(or this.count+=1
Nick Coghlan wrote:
Michael Hoffman wrote:
raver2046 wrote:
How to have a global var in python ?
global var will give you a global variable named var.
Whether this advice is correct or not depends greatly on what the OP
means by 'global' :)
Module global, it's right, application global it's
Michael Hoffman wrote:
raver2046 wrote:
How to have a global var in python ?
global var will give you a global variable named var.
Whether this advice is correct or not depends greatly on what the OP means by
'global' :)
Module global, it's right, application global it's wrong. Given the nature
hello,
How to have a global var in python ?
thank you.
raver2046
http://raver2046.ath.cx
--
http://mail.python.org/mailman/listinfo/python-list
raver2046 wrote:
How to have a global var in python ?
global var will give you a global variable named var.
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/python-list
raver2046 wrote:
How to have a global var in python ?
You can, but you probably don't want to. What's your use case? Example
code and what you'd like it to do would be helpful.
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
33 matches
Mail list logo