Re: is this a valid import sequence ?

2007-06-25 Thread Steven D'Aprano
On Mon, 25 Jun 2007 05:08:00 +, Michele Simionato wrote: On Jun 24, 1:29 pm, Steven D'Aprano I would like to hear your opinion of whether the following two functions are equally as wrong: def f1(gizmo): global spam # holds the frommet needed for the gizmo

Re: is this a valid import sequence ?

2007-06-25 Thread Michele Simionato
On Jun 25, 1:46 pm, Steven D'Aprano [EMAIL PROTECTED] wrote: To me, this code is redundant but not wrong: def sin(x): return math.sin(x) It's not wrong, because it does everything that it is supposed to do, and nothing that it isn't supposed to do. I told you,

Re: is this a valid import sequence ?

2007-06-24 Thread Kay Schluehr
On Jun 24, 2:51 am, [EMAIL PROTECTED] (Alex Martelli) wrote: Since that global statement is utterly useless (it's impossible to read and understand any substantial amount of Python code without realizing that accessing a variable not locally assigned means you're accessing a global, so the

Re: is this a valid import sequence ?

2007-06-24 Thread Steven D'Aprano
On Sat, 23 Jun 2007 21:11:42 -0700, Alex Martelli wrote a lot, with lots of YELLING. Wow. What can I say? Given the amount of SHOUTING in your post, and the fact that you feel so strongly about the trivial question of the redundant use of the global statement that you would fail a student who

Re: is this a valid import sequence ?

2007-06-24 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Steven D'Aprano wrote: Perhaps you should consider writing a PEP to make the redundant use of the global statement a compile-time error? Sometimes I wished that it would be a compile time error or at least triggering a warning when ``global`` is used at module level. It

Re: is this a valid import sequence ?

2007-06-24 Thread Scott David Daniels
Steven D'Aprano wrote: On Sat, 23 Jun 2007 21:11:42 -0700, Alex Martelli wrote a lot, with lots of YELLING. Given the amount of SHOUTING in your post, and the fact that you feel so strongly about the trivial question of the redundant use of the global statement that you would fail a student

Re: is this a valid import sequence ?

2007-06-24 Thread Alex Martelli
Scott David Daniels [EMAIL PROTECTED] wrote: Steven D'Aprano wrote: On Sat, 23 Jun 2007 21:11:42 -0700, Alex Martelli wrote a lot, with lots of YELLING. Given the amount of SHOUTING in your post, and the fact that you feel so strongly about the trivial question of the redundant use of

Re: is this a valid import sequence ?

2007-06-24 Thread Michele Simionato
On Jun 24, 1:29 pm, Steven D'Aprano I would like to hear your opinion of whether the following two functions are equally as wrong: def f1(gizmo): global spam # holds the frommet needed for the gizmo gizmo.get_frommet(spam) def f2(gizmo): # global spam holds the frommet needed

Re: is this a valid import sequence ?

2007-06-23 Thread Stef Mientki
thanks Steven, Steven D'Aprano wrote: On Fri, 22 Jun 2007 21:43:40 +0200, Stef Mientki wrote: This might be a very weird construction, but it's the most easy way in translating another language into Python (for simulation). Although it works, I like to know if this a valid construction:

Re: is this a valid import sequence ?

2007-06-23 Thread Scott David Daniels
Stef Mientki wrote: ... I've defined a class, like this, ... class T6963_device (tDevice): def __init__ (self): global LCD LCD = self ... In the same module I've a function, that runs a method of the above class instance, ... def Write_LCD_Data ( data ): global

Re: is this a valid import sequence ?

2007-06-23 Thread Steven D'Aprano
On Sat, 23 Jun 2007 11:03:03 -0700, Scott David Daniels wrote: The global statement in Write_LCD_Data is completely unnecessary. The only time you need global is if you want to reassociate the global name to another object (such as LCD = LCD + 1 or whatever). That's technically true, but

Re: is this a valid import sequence ?

2007-06-23 Thread Stef Mientki
Steven D'Aprano wrote: On Sat, 23 Jun 2007 11:03:03 -0700, Scott David Daniels wrote: The global statement in Write_LCD_Data is completely unnecessary. The only time you need global is if you want to reassociate the global name to another object (such as LCD = LCD + 1 or whatever).

Re: is this a valid import sequence ?

2007-06-23 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote: On Sat, 23 Jun 2007 11:03:03 -0700, Scott David Daniels wrote: The global statement in Write_LCD_Data is completely unnecessary. The only time you need global is if you want to reassociate the global name to another object (such as LCD = LCD + 1

Re: is this a valid import sequence ?

2007-06-23 Thread Steven D'Aprano
On Sat, 23 Jun 2007 17:51:17 -0700, Alex Martelli wrote: Steven D'Aprano [EMAIL PROTECTED] wrote: On Sat, 23 Jun 2007 11:03:03 -0700, Scott David Daniels wrote: The global statement in Write_LCD_Data is completely unnecessary. The only time you need global is if you want to reassociate

Re: is this a valid import sequence ?

2007-06-23 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote: ... It's never _wrong_ to use the global statement, even if it is strictly unnecessary for the Python compiler. So, repeat that global statement ninetyseven times -- that's not wrong, either, in exactly the same sense in which it's not wrong

is this a valid import sequence ?

2007-06-22 Thread Stef Mientki
This might be a very weird construction, but it's the most easy way in translating another language into Python (for simulation). Although it works, I like to know if this a valid construction: I've defined a class, like this, attaching a not yet defined global to itself class T6963_device

Re: is this a valid import sequence ?

2007-06-22 Thread Steven D'Aprano
On Fri, 22 Jun 2007 21:43:40 +0200, Stef Mientki wrote: This might be a very weird construction, but it's the most easy way in translating another language into Python (for simulation). Although it works, I like to know if this a valid construction: Since it works, how can it NOT be a