Re: variable declaration

2005-02-25 Thread Serge Orlov
Alexander Zatvornitskiy wrote: > Hello All! > > I'am novice in python, and I find one very bad thing (from my point > of view) in language. There is no keyword or syntax to declare > variable, like 'var' in > Pascal, or special syntax in C. It can > cause very ugly errors,like this: > > epsilon=0 >

Re: variable declaration

2005-02-10 Thread Nick Coghlan
Antoon Pardon wrote: I don't think that would be a big issue. Python uses '=' also differently from a number of languages. My preference would currently be for ':=' because I have the impression that if you don't leave spaces the period in '.=' tends to be obscured. x.=42 vsx:=42 seems a cl

Re: variable declaration

2005-02-10 Thread Antoon Pardon
Op 2005-02-10, Nick Coghlan schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> Well it seems you have some fair points. I'll just stop here stating >> that I would like to have it, even if it proved to be slower. Speed >> is not that big a factor in the things I write. > > Oh, certainly. I wasn

Re: variable declaration

2005-02-10 Thread Nick Coghlan
Antoon Pardon wrote: Well it seems you have some fair points. I'll just stop here stating that I would like to have it, even if it proved to be slower. Speed is not that big a factor in the things I write. Oh, certainly. I wasn't suggesting the speed hit was enough to kill the idea - I was just po

Re: variable declaration

2005-02-10 Thread Antoon Pardon
Op 2005-02-09, Nick Coghlan schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> Op 2005-02-08, Nick Coghlan schreef <[EMAIL PROTECTED]>: >>>The CPython *_FAST opcodes relate to functions' local variables. Behind the >>>scenes they are implemented as integer indexing operations into a pre-sized

Re: variable declaration

2005-02-10 Thread Antoon Pardon
Op 2005-02-08, Fredrik Lundh schreef <[EMAIL PROTECTED]>: > Peter Otten wrote: > >>> executed. the compiler handles "global" and "from __future__", everything >>> else is done at runtime. >> >> and __debug__, too, it seems: > > you left out the "python -O" line. > > __debug__ >> False > def

Re: variable declaration

2005-02-09 Thread Nick Coghlan
Antoon Pardon wrote: Op 2005-02-08, Nick Coghlan schreef <[EMAIL PROTECTED]>: The CPython *_FAST opcodes relate to functions' local variables. Behind the scenes they are implemented as integer indexing operations into a pre-sized C array. Operations don't come much faster than that :) I don't fo

Re: variable declaration

2005-02-08 Thread Eric Pederson
Arthur artfully argued: > What if: > > There was a well conducted market survey conclusive to the effect that > adding optional strict variable declaration would, in the longer run, > increase Python's market share dramatically. It's always good to examine one's objectives and motives. I am an

Re: variable declaration

2005-02-08 Thread Elspeth Thorne
Alexander Zatvornitskiy wrote: > You may say: give better names for your variables! Ha, I'am often don't > understand that they mean! They are written for me by an engineer! Hang on, though - if you don't understand what you are programming, then how can you check if it's correct? Regardless of va

Re: variable declaration

2005-02-08 Thread Arthur
On Sat, 5 Feb 2005 17:00:15 +0100, [EMAIL PROTECTED] (Alex Martelli) wrote: >Alexander Zatvornitskiy ><[EMAIL PROTECTED]> wrote: > ... >> AM> The fact that in Python there are ONLY statements, NO declarations, >> === >> def qq(): >> global z >> z=5 >> === >> What is "global"? Statement? Ok, I

Re: variable declaration

2005-02-08 Thread Caleb Hattingh
Jeff I fully agree. As I stated in a message to alexander, it is quick and easy even to write a simple project-specific tool for checking that only allowed variable names exist in all the project files. Compared to having to work with tons of effectively useless variable declarations foreve

Re: variable declaration

2005-02-08 Thread Caleb Hattingh
Alexander PowerOfGenerator=TakeFromSensor() if PowerOfGenerator>xxx: RecalcPower(PowerOfGenerator) PutToTheDatabase(PowerOfGenerator) Here, python will not help you. The worst thing is that in such calculations you often receive plausible results. (I think PyChecker has co

Re: variable declaration

2005-02-08 Thread Jeff Shannon
Alexander Zatvornitskiy wrote: Another example. Let say you have variable PowerOfGenerator in your program. But, it is only active power, so you have to (1)rename PowerOfGenerator to ActivePowerOfGenerator, (2)calculate ReactivePowerOfGenerator, and (3)calculate new PowerOfGenerator by formula Po

Re: variable declaration

2005-02-08 Thread Thomas Bartkus
"Alexander Zatvornitskiy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The worst thing is that in such calculations you often receive plausible results. Exactly so! An ordinary spelling error gets promoted to a logic error that is damn difficult to detect, let alone trace! Bef

Re: variable declaration

2005-02-08 Thread Alex Martelli
top <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > [snip] > > I disagree: compile time is when the compiler is running (for > example, > > the compiler is the component which diagnoses syntax errors, while > other > > errors are diagnosed ``at runtime''). > [snip] > > That thing about syntax

Re: variable declaration

2005-02-08 Thread Fredrik Lundh
"top" <[EMAIL PROTECTED]> wrote: > That thing about syntax errors is news to me. I thought they were > caught at runtime, since you can catch them as exceptions, as in: > > try: prijnt projnt > except SyntaxError: print "See, it gets caught" > > If this happens at compile-time, I'd like to know ho

Re: variable declaration

2005-02-08 Thread top
Alex Martelli wrote: [snip] > I disagree: compile time is when the compiler is running (for example, > the compiler is the component which diagnoses syntax errors, while other > errors are diagnosed ``at runtime''). [snip] That thing about syntax errors is news to me. I thought they were caught at

Re: variable declaration

2005-02-08 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2005-02-07 20:36: Steve Holden said unto the world upon 2005-02-07 17:51: The reason global is a wart can clearly be seen in the following example: >>> x = 3 >>> def f(tf, v): ... if tf: ... global x ... x = v ... >>> f(0, 5) >>> x 5 >>

Re: variable declaration

2005-02-08 Thread Antoon Pardon
Op 2005-02-08, Nick Coghlan schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> I have the impression you are looking at this too much from the view >> of the current implementation where putting a an entry in >> a directory is seen as an atomic operation. > > Yes and no. I *am* looking at it fr

Re: variable declaration

2005-02-08 Thread Fredrik Lundh
Peter Otten wrote: >> executed. the compiler handles "global" and "from __future__", everything >> else is done at runtime. > > and __debug__, too, it seems: you left out the "python -O" line. __debug__ > False def f(): > ... if __debug__: > ... global x > ... x = 4

Re: variable declaration

2005-02-08 Thread Nick Coghlan
Antoon Pardon wrote: I have the impression you are looking at this too much from the view of the current implementation where putting a an entry in a directory is seen as an atomic operation. Yes and no. I *am* looking at it from an implementation point of view, but dictionaries have nothing to do

Re: variable declaration

2005-02-08 Thread Nick Coghlan
Just wrote: In article <[EMAIL PROTECTED]>, Nick Coghlan <[EMAIL PROTECTED]> wrote: Antoon Pardon wrote:ons already existing. The compilor might generate a RESTORE instruction. Whether it is done as a LOAD/STORE or a RESTORE, it has to perform the same work - check the name exists in the local

Re: variable declaration

2005-02-08 Thread Antoon Pardon
Op 2005-02-08, Nick Coghlan schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote:ons already existing. >> The compilor might generate a RESTORE instruction. > > Whether it is done as a LOAD/STORE or a RESTORE, it has to perform the same > work > - check the name exists in the local namespace, and t

Re: variable declaration

2005-02-08 Thread Duncan Booth
Brian van den Broek wrote: > Can it then be further (truly :-) ) said that > > if False: > # thousands of lines of code here > > would effect the structure of the function object's bytecode, but not > its behaviour when run? Or, at most, would cause a performance effect > due to the bytec

Re: variable declaration

2005-02-08 Thread Peter Otten
Fredrik Lundh wrote: > executed. the compiler handles "global" and "from __future__", everything > else is done at runtime. and __debug__, too, it seems: >>> __debug__ False >>> def f(): ... if __debug__: ... global x ... x = 42 ... >>> f() >>> x Traceback (most recent call l

Re: variable declaration

2005-02-08 Thread Just
In article <[EMAIL PROTECTED]>, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote:ons already existing. > > The compilor might generate a RESTORE instruction. > > Whether it is done as a LOAD/STORE or a RESTORE, it has to perform the same > work > - check the name exists in the loc

Re: variable declaration

2005-02-08 Thread Nick Coghlan
Antoon Pardon wrote:ons already existing. The compilor might generate a RESTORE instruction. Whether it is done as a LOAD/STORE or a RESTORE, it has to perform the same work - check the name exists in the local namespace, and throw an exception if it doesn't. If it the name does exist, perform a

Re: variable declaration

2005-02-08 Thread Fredrik Lundh
Terry Reedy wrote: >>At compile time (by which I mean when the Python bytecode is built) > > Compile time is when the def statement is executed no, that's run time. "def" is an executable statement, just like "print", "for", assignments, "import", etc. the entire module is compiled (to bytecod

Re: variable declaration

2005-02-08 Thread Alex Martelli
Terry Reedy <[EMAIL PROTECTED]> wrote: > "Brian van den Broek" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Is the right way to understand it in this vicinity: > > In the vicinity, but not quite exact > > >At compile time (by which I mean when the Python bytecode is built)

Re: variable declaration

2005-02-07 Thread Terry Reedy
"Brian van den Broek" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is the right way to understand it in this vicinity: In the vicinity, but not quite exact >At compile time (by which I mean when the Python bytecode is built) Compile time is when the def statement is executed

Re: variable declaration

2005-02-07 Thread Brian van den Broek
Steve Holden said unto the world upon 2005-02-07 17:51: Alexander Zatvornitskiy wrote: Привет Alex! 05 февраля 2005 в 17:00, Alex Martelli в своем письме к All писал: AM> to all intents and purposes working "as if" AM> it was a declaration. If I had to vote about the one worst formal AM> defec

Re: variable declaration

2005-02-07 Thread Steve Holden
Alexander Zatvornitskiy wrote: Привет Alex! 05 февраля 2005 в 17:00, Alex Martelli в своем письме к All писал: >> AM> The fact that in Python there are ONLY statements, NO >> AM> declarations, >> What is "global"? Statement? Ok, I fill lack of "var" statement:) AM> 'global' is an ugly wart, O

Re: variable declaration

2005-02-07 Thread Alex Martelli
Alexander Zatvornitskiy <[EMAIL PROTECTED]> wrote: > ?? Alex! > > 05 ??? 2005 ? 17:00, Alex Martelli ? ? ?? ? All ?: > >> AM> The fact that in Python there are ONLY statements, NO > >> AM> declarations, > >> What is "global"? Statement? Ok, I fill lack of "var" statement:

Re: variable declaration

2005-02-07 Thread Antoon Pardon
Op 2005-02-07, Nick Coghlan schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> Op 2005-02-05, Nick Coghlan schreef <[EMAIL PROTECTED]>: >> >> >>>[ ... ] >>> >>>With a rebinding operator, the intent of the last line can be made explicit: >>> >>>def collapse(iterable): >>> it = iter(iterabl

Re: variable declaration

2005-02-07 Thread Nick Coghlan
Antoon Pardon wrote: Op 2005-02-05, Nick Coghlan schreef <[EMAIL PROTECTED]>: [ ... ] With a rebinding operator, the intent of the last line can be made explicit: def collapse(iterable): it = iter(iterable) lastitem = it.next() yield lastitem for item in it: if item != last

Re: variable declaration

2005-02-07 Thread Antoon Pardon
Op 2005-02-05, Roy Smith schreef <[EMAIL PROTECTED]>: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Alexander > Zatvornitskiy) wrote: > >> And, one more question: do you think code like this: >> >> var S=0 >> var eps >> >> for eps in xrange(10): >> S=S+ups >> >> is very bad? Please

Re: variable declaration

2005-02-07 Thread Antoon Pardon
Op 2005-02-05, Nick Coghlan schreef <[EMAIL PROTECTED]>: > [ ... ] > > With a rebinding operator, the intent of the last line can be made explicit: > > def collapse(iterable): > it = iter(iterable) > lastitem = it.next() > yield lastitem > for item in it: > if item !=

Re: variable declaration

2005-02-07 Thread Nick Coghlan
Roy Smith wrote: I'm not sure what that last sentence is supposed to mean, but I have visions (nightmares?) of someday having ANSI, ISO, IEEE, or some other such organization notice that something useful exists which they haven't yet standardized/broken and decide to form a committee to do it. S

Re: variable declaration

2005-02-06 Thread Arthur
On Sun, 06 Feb 2005 08:20:29 -0500, Jeremy Bowers <[EMAIL PROTECTED]> wrote: >On Sun, 06 Feb 2005 07:30:33 -0500, Arthur wrote: >> What if: >> >> There was a well conducted market survey conclusive to the effect that >> adding optional strict variable declaration would, in the longer run, >> incr

Re: variable declaration

2005-02-06 Thread Jeremy Bowers
On Sun, 06 Feb 2005 07:30:33 -0500, Arthur wrote: > What if: > > There was a well conducted market survey conclusive to the effect that > adding optional strict variable declaration would, in the longer run, > increase Python's market share dramatically. > > It just would. > > Why would it? Wha

Re: variable declaration

2005-02-06 Thread Alex Martelli
Roy Smith <[EMAIL PROTECTED]> wrote: > > which is good news for sellers of books, tools, training, consultancy > > services, and for Python programmers everywhere -- more demand always > > helps. *BUT* the price is eternal vigilance... > > I'm not sure what that last sentence is supposed to mean

Re: variable declaration

2005-02-06 Thread Roy Smith
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Alex Martelli) wrote: > This is a good development, overall. Against stupidity, the gods > themselves contend in vain; Python's entrance into stupid firms broadens > its potential appeal from less than 10% to around 100% of the market, > which i

Re: variable declaration

2005-02-06 Thread Arthur
On Sun, 6 Feb 2005 08:47:31 +0100, [EMAIL PROTECTED] (Alex Martelli) wrote: > >Even the various "success stories" we've collected (both on websites, >and, more impressive to PHBs, into paper booklets O'Reilly has printed) >play a role. ``NASA uses it for space missions, so of course we must >use

Re: variable declaration

2005-02-05 Thread Alex Martelli
Arthur <[EMAIL PROTECTED]> wrote: > Do the STUPID firms use Python as well. Yes, they're definitely starting to do so. > Why? The single most frequent reason is that some techie sneaked it in, for example "just for testing" or "to do a prototype" or even without any actual permission. Firms

Re: variable declaration

2005-02-05 Thread Alex Martelli
Nick Coghlan <[EMAIL PROTECTED]> wrote: ... > > _temp = x.y > > x.y = type(temp).__irebind__(temp, z) ... > I was thinking of something simpler: > >x.y >x.y = z > > That is, before the assignment attempt, x.y has to resolve to *something*, but > the interpreter isn't particu

Re: variable declaration

2005-02-05 Thread Nick Coghlan
Alex Martelli wrote: It's not clear to me what semantics, exactly, x.y := z would be defined to have (assuming := is the syntax sugar for ``rebinding''). Perhaps, by analogy with every other augmented operator, it should be equivalent to: _temp = x.y x.y = type(temp).__irebind__(temp, z) T

Re: variable declaration

2005-02-05 Thread Arthur
On Sat, 5 Feb 2005 20:02:44 +0100, [EMAIL PROTECTED] (Alex Martelli) wrote: >Arthur <[EMAIL PROTECTED]> wrote: > >> On Sat, 5 Feb 2005 17:00:15 +0100, [EMAIL PROTECTED] (Alex Martelli) >> wrote: >> > >> >I consider this one of the worst ideas to have been proposed on this >> >newsgroup over the ye

Re: variable declaration

2005-02-05 Thread Alex Martelli
Arthur <[EMAIL PROTECTED]> wrote: > On Sat, 5 Feb 2005 17:00:15 +0100, [EMAIL PROTECTED] (Alex Martelli) > wrote: > > > >I consider this one of the worst ideas to have been proposed on this > >newsgroup over the years, which _IS_ saying something. \ > > I would disagree, but only to the extent th

Re: variable declaration

2005-02-05 Thread Arthur
On Sat, 5 Feb 2005 17:00:15 +0100, [EMAIL PROTECTED] (Alex Martelli) wrote: > >I consider this one of the worst ideas to have been proposed on this >newsgroup over the years, which _IS_ saying something. \ I would disagree, but only to the extent that nothing that is only a request for an option t

Re: variable declaration

2005-02-05 Thread Alex Martelli
Nick Coghlan <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > 'global' is an ugly wart, to all intents and purposes working "as if" it > > was a declaration. If I had to vote about the one worst formal defect > > of Python, it would surely be 'global'. > > > > Fortunately, it's reasonably e

Re: variable declaration

2005-02-05 Thread Nick Coghlan
Alexander Zatvornitskiy wrote: var epsilon=0 var S S=0 while epsilon<10: S=S+epsilon epselon=epsilon+1#interpreter should show error here,if it's in "strict mode" print S It is easy, and clean-looking. Alexander, [EMAIL PROTECTED] An alternate proposal, where the decision to request rebinding s

Re: variable declaration

2005-02-05 Thread Nick Coghlan
Alex Martelli wrote: 'global' is an ugly wart, to all intents and purposes working "as if" it was a declaration. If I had to vote about the one worst formal defect of Python, it would surely be 'global'. Fortunately, it's reasonably easy to avoid the ugliness, by avoiding rebinding (within functio

Re: variable declaration

2005-02-05 Thread Nick Coghlan
Alexander Zatvornitskiy wrote: You wrote about "substantial cost" of var declarations. Yes, you are write. But think about the cost of lack of var declarations. Compare time that programmer will waste on search for the reason of bug caused by such typo, plus time what programmer will waste while re

Re: variable declaration

2005-02-05 Thread Alex Martelli
Alexander Zatvornitskiy <[EMAIL PROTECTED]> wrote: ... > AM> The fact that in Python there are ONLY statements, NO declarations, > === > def qq(): > global z > z=5 > === > What is "global"? Statement? Ok, I fill lack of "var" statement:) 'global' is an ugly wart, to all intents and purposes

Re: variable declaration

2005-02-05 Thread Peter Otten
Alexander Zatvornitskiy wrote: > ÐÑÐÐÐÑ Peter! > > 31 ÑÐÐÐÑÑ 2005 Ð 09:09, Peter Otten Ð Ñ ÐÐÑÑÐÐ Ð All > ÐÐÑÐÐ: > PO> pychecker may help you find misspelled variable names. You have to > PO> move the code into a function, though: > > PO> $ cat epsilon.py > ...skipped... > PO> $ pycheck

Re: variable declaration

2005-02-05 Thread Roy Smith
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Alexander Zatvornitskiy) wrote: > And, one more question: do you think code like this: > > var S=0 > var eps > > for eps in xrange(10): > S=S+ups > > is very bad? Please explain your answer:) Let me answer that by way of counter-example.

Re: variable declaration

2005-02-05 Thread Alex Martelli
Alexander Zatvornitskiy <[EMAIL PROTECTED]> wrote: > Hi, Alex! > > 31 jan 2005 at 13:46, Alex Martelli wrote: > > (sorry for the delay,my mail client don't highlight me your answer) > > AM> Since the lack of declarations is such a crucial design choice for > AM> Python, then, given that you'r

Re: variable declaration

2005-02-05 Thread Jorgen Grahn
On Mon, 31 Jan 2005 18:49:15 +0100, Alex Martelli <[EMAIL PROTECTED]> wrote: > Michael Tobis <[EMAIL PROTECTED]> wrote: > >> With all due respect, I think "so go away if you don't like it" is >> excessive, and "so go away if you don't like it and you obviously don't >> like it so definitely go awa

Re: variable declaration

2005-02-03 Thread Paddy McCarthy
Alexander Zatvornitskiy wrote: Hello All! I'am novice in python, and I find one very bad thing (from my point of view) in language. There is no keyword or syntax to declare variable, like 'var' in Pascal, or special syntax in C. It can cause very ugly errors,like this: epsilon=0 S=0 while epsilon<1

Re: variable declaration

2005-02-01 Thread Eric Pederson
"Thomas Bartkus" wrote > As has been pointed out, it's not a big deal for a programmer who's > been > there, done that. But the original posters example is a beginners trap > for > certain. > > *If* Python were a "beginners language", then it would be missing one > of > it's training wheels.

Re: variable declaration

2005-02-01 Thread Steve Holden
Thomas Bartkus wrote: "Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Thomas Bartkus wrote: "Carl Banks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] How common is it for a local variable to be bound in more than one place within a function? How common?

Re: variable declaration

2005-02-01 Thread Thomas Bartkus
"Michael Tobis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Since I'm very much a believer in Python as a beginner's language, that > doesn't satisfy me. "Declarations are impractical" would satisfy me, > but so far I'm not completely convinced of that. > As has been pointed out

Re: variable declaration

2005-02-01 Thread Christian Dieterich
On Dé Máirt, Feabh 1, 2005, at 12:19 America/Chicago, Alex Martelli wrote: Michael Tobis <[EMAIL PROTECTED]> wrote: ... I don't know that it's ever necessary to rebind, but it is, in fact, common, and perhaps too easy. In numeric Python, avoiding rebinding turns out to be a nontrivial skill. W

Re: variable declaration

2005-02-01 Thread Michael Tobis
> All in all, I fail to see what gains would be expected by making Python > into a single-assignment or single-binding language, even on a module by > module basis, to repay this kind of awkwardness. Just to be clear, if anyone was suggesting that, it wasn't me. It would be helpful on occasion in

Re: variable declaration

2005-02-01 Thread Nick Vargish
[EMAIL PROTECTED] (Aahz) writes: > It's kind of like having a guy who juggles chainsaws wearing body armor > arguing with a guy who juggles rubber chickens wearing a T-shirt about who's > in more danger." --Roy Smith, c.l.py, 2004.05.23 If it's Nethack, the guy in the T-shirt is in more danger

Re: variable declaration

2005-02-01 Thread Alex Martelli
Michael Tobis <[EMAIL PROTECTED]> wrote: ... > I don't know that it's ever necessary to rebind, but it is, in fact, > common, and perhaps too easy. In numeric Python, avoiding rebinding > turns out to be a nontrivial skill. Well, a for-statement is BASED on rebinding, for example. Maybe you d

Re: variable declaration

2005-02-01 Thread Jeremy Bowers
On Tue, 01 Feb 2005 09:13:36 -0600, Thomas Bartkus wrote: > *Is* there a reason why the interpreter couldn't/shouldn't require formal > variable declaration? You mean, other than the reasons already discussed at length in this thread, not to mention many many others? Your not *liking* the reasons

Re: variable declaration

2005-02-01 Thread Thomas Bartkus
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Thomas Bartkus wrote: > > > "Carl Banks" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > > > >>How common is it for a local variable to be bound in > >>more than one place within a function? > > > >

Re: variable declaration

2005-02-01 Thread Steve Holden
Thomas Bartkus wrote: "Carl Banks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] How common is it for a local variable to be bound in more than one place within a function? How common? It shouldn't happen at all and that was the point. This seems a little excessive to me. Sample us

Re: variable declaration

2005-02-01 Thread Michael Tobis
> How common is it for a local variable to be bound in > more than one place within a function? It's more natural for a beginner to read or write .mystr = "" .for snippet in snippets: . if ilike(snippet): . mystr = mystr + snippet than .mylist = [] .for snippet in snippets: . if ilike(

Re: variable declaration

2005-02-01 Thread Michael Tobis
Given the behavior, the documentation is gratifyingly correct. Given that the syntax is legal, though, the behavior is not what one would intuitively expect, and is therefore unPythonic by (rather dramatically) violating the principle of least surprise. It's also, to me, understandable why it's d

Re: variable declaration

2005-02-01 Thread Thomas Bartkus
"Carl Banks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How common is it for a local variable to be bound in > more than one place within a function? How common? It shouldn't happen at all and that was the point. The original posters code demonstrates how it can occur inadve

Re: variable declaration

2005-02-01 Thread Arthur
On 31 Jan 2005 19:41:27 -0800, "Michael Tobis" <[EMAIL PROTECTED]> wrote: >> You may call it a strawberry, if you wish, but that doesn't mean it >will >> taste good with fresh cream. It's nothing more and nothing less than >an >> arguably weird syntax for a perfectly executable statement: > >This

Re: variable declaration

2005-02-01 Thread Alex Martelli
Michael Tobis <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > Michael Tobis <[EMAIL PROTECTED]> wrote: > > > he can perfectly > > well correct his misexpression if he cares to -- not my job to try to > > read his mind and perform exegesis on his words. > > Well, I hate to try to tell you y

Re: variable declaration

2005-02-01 Thread Jacek Generowicz
"Michael Tobis" <[EMAIL PROTECTED]> writes: > In fact, I'd recommend a paragraph early in the Nutshell book saying > "there are no declarations, no use strict, no implicit none, sorry, > forget it", It would have to be a pretty long paragraph, if it were to list all the things that you do NOT fin

Re: variable declaration

2005-01-31 Thread Frans Englich
On Tuesday 01 February 2005 05:08, Cameron Laird wrote: > We learned long ago to treat you, Alex, as an exception. > While it's rather unpythonic to have implicit rules, let's > forgive Robert for failing to mention the one that regards > you as an outlier for inferential purposes. Excellent timi

Re: variable declaration

2005-01-31 Thread Fredrik Lundh
Michael Tobis wrote: > This is definitely a wart: > > ... z = 42.3 > ... > ... def f(): > ...if False: > ... global z > ...z = -666 > ... > ... f() > ... print z no, it's a declaration. from the documentation: http://docs.python.org/ref/global.html "The global statement i

Re: variable declaration

2005-01-31 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Alex Martelli <[EMAIL PROTECTED]> wrote: >Robert Brewer <[EMAIL PROTECTED]> wrote: > >> Bah. Nothing teaches you a new language like having your job depend upon >> it. People who study languages merely for "personal growth" learn 50% of >> the syntax and 1% of the co

Re: variable declaration

2005-01-31 Thread Michael Tobis
Alex Martelli wrote: > Michael Tobis <[EMAIL PROTECTED]> wrote: > he can perfectly > well correct his misexpression if he cares to -- not my job to try to > read his mind and perform exegesis on his words. Well, I hate to try to tell you your job, but it doesn't seem to be to be all that great of

Re: variable declaration

2005-01-31 Thread Michael Tobis
This is definitely a wart: ... z = 42.3 ... ... def f(): ...if False: ... global z ...z = -666 ... ... f() ... print z -- http://mail.python.org/mailman/listinfo/python-list

Re: variable declaration

2005-01-31 Thread Aahz
In article <[EMAIL PROTECTED]>, Alex Martelli <[EMAIL PROTECTED]> wrote: > >Some people claim a language should change the way you think -- a >frequent poster, excellent Python contributor, and friend, even has that >claim in his signature. Generally speaking, I change my .sig either when I get

Re: variable declaration

2005-01-31 Thread Carl Banks
Thomas Bartkus wrote: > Python *does* require that your variables be declared and initialized before > you use them. You did that with epsilon=0 and S=0 at the top. It is > unfortunate, however, that the statement epselon=epsilon+1 also declares a > new variable in the wrong place at the wrong ti

Re: variable declaration

2005-01-31 Thread Thomas Bartkus
"Alexander Zatvornitskiy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello All! > > I'am novice in python, and I find one very bad thing (from my point of view) in > language. There is no keyword or syntax to declare variable, like 'var' in > Pascal, or special syntax in C. It ca

Re: variable declaration

2005-01-31 Thread Steve Holden
Alex Martelli wrote: Michael Tobis <[EMAIL PROTECTED]> wrote: [...] Let me add that I remain unconvinced that a language cannot combine the best features of Python with very high performance, which is ultimately I'm also unconvinced. Fortunately, so is the EU, so they have approved very substanti

Re: variable declaration

2005-01-31 Thread Alex Martelli
Michael Tobis <[EMAIL PROTECTED]> wrote: > With all due respect, I think "so go away if you don't like it" is > excessive, and "so go away if you don't like it and you obviously don't > like it so definitely go away" is more so. The writer is obviously I disagree: I believe that, if the poster re

Re: variable declaration

2005-01-31 Thread Diez B. Roggisch
> A decorator is a modifier to a subsequent binding, and it modifies the > reference and not the referent. So how is it anythng but declarative? I learned the hard way that it still is simply interpreted - its a pretty straight forward syntactic sugaring, as this shows: foo = classmethod(foo) be

RE: variable declaration

2005-01-31 Thread Robert Brewer
Alex Martelli wrote: > > Robert Brewer <[EMAIL PROTECTED]> wrote: > > > Bah. Nothing teaches you a new language like having your > job depend upon > > it. People who study languages merely for "personal growth" > learn 50% of > > the syntax and 1% of the concepts, and then fritter that > learn

Re: variable declaration

2005-01-31 Thread DogWalker
"EP" <[EMAIL PROTECTED]> said: >> Original Message >> From: [EMAIL PROTECTED] (Alexander Zatvornitskiy) > >> >> Hello All! >> >> I'am novice in python, and I find one very bad thing (from my point of >> view) in >> language. There is no keyword or syntax to declare variab

re: variable declaration

2005-01-31 Thread ajsiegel
MT writes - >In summary, again with all due respect and gratitude for the >spectacularly excellent product that Python is today, I wonder *why* >this strong aversion to declarative statements, and *whether* decorator >syntax constitutes a violation of it. I'd appreciate any responses or >links

Re: variable declaration

2005-01-31 Thread Alex Martelli
Robert Brewer <[EMAIL PROTECTED]> wrote: > Bah. Nothing teaches you a new language like having your job depend upon > it. People who study languages merely for "personal growth" learn 50% of > the syntax and 1% of the concepts, and then fritter that learning away > on inconsequential newsgroups th

Re: variable declaration

2005-01-31 Thread Fredrik Lundh
Michael Tobis wrote: >> that's a nice theory, but since the decorator line is executed by the >> interpreter, it's a little weak. > > Well, uh, who else would process it? the compiler. from __future__ is a declaration. @expression is an executable statement. -- http://mail.python.org/mai

Re: variable declaration

2005-01-31 Thread Michael Tobis
> that's a nice theory, but since the decorator line is executed by the inter- > preter, it's a little weak. Well, uh, who else would process it? "use strict' and 'my epsilon' in perl are executed by the perl interpreter as well, but they have a declarative flavor. A decorator is a modifier to a

Re: variable declaration

2005-01-31 Thread Fredrik Lundh
Michael Tobis wrote: > Also, the assertion that "Python has no declarations whatsoever" is no > longer obviously true. In the 2.4 decorator syntax, a decorator line is > not executable that's a nice theory, but since the decorator line is executed by the inter- preter, it's a little weak. -

Re: variable declaration

2005-01-31 Thread Michael Tobis
With all due respect, I think "so go away if you don't like it" is excessive, and "so go away if you don't like it and you obviously don't like it so definitely go away" is more so. The writer is obviously neither a native speaker of English nor an accomplished user of Python, so there are two lang

RE: variable declaration

2005-01-31 Thread Robert Brewer
Alex Martelli wrote: > If Python doesn't fit YOUR brain, for example because your brain is > ossified around a craving for the declaration of variables, > then, unless > you're specifically studying a new language just for personal growth > purposes, I think you might well be better off with a lan

Re: variable declaration

2005-01-31 Thread Steve Holden
Alex Martelli wrote: Alexander Zatvornitskiy <[EMAIL PROTECTED]> wrote: Hello All! I'am novice in python, and I find one very bad thing (from my point of view) in language. There is no keyword or syntax to declare variable, like 'var' in [...] There are zillions of languages -- use another one. [

Re: variable declaration

2005-01-31 Thread Alex Martelli
Alexander Zatvornitskiy <[EMAIL PROTECTED]> wrote: > Hello All! > > I'am novice in python, and I find one very bad thing (from my point of > view) in language. There is no keyword or syntax to declare variable, like > 'var' in Since the lack of declarations is such a crucial design choice for Py

Re: variable declaration

2005-01-31 Thread Peter Otten
Alexander Zatvornitskiy wrote: > epsilon=0 > S=0 > while epsilon<10: > S=S+epsilon > epselon=epsilon+1 > print S > > It will print zero, and it is not easy to find such a bug! pychecker may help you find misspelled variable names. You have to move the code into a function, though: $ cat eps

Re: variable declaration

2005-01-30 Thread EP
> Original Message > From: [EMAIL PROTECTED] (Alexander Zatvornitskiy) > > Hello All! > > I'am novice in python, and I find one very bad thing (from my point of > view) in > language. There is no keyword or syntax to declare variable, like 'var' > in > Pascal, or special

RE: variable declaration

2005-01-30 Thread Robert Brewer
AlexanderZatvornitskiy wrote: > I'am novice in python, and I find one very bad thing (from my > point of view) in > language. There is no keyword or syntax to declare variable, > like 'var' in > Pascal, or special syntax in C. It can cause very ugly > errors,like this: > > epsilon=0 > S=0 > whi

  1   2   >