Re: Python handles globals badly.

2015-09-10 Thread random832
On Thu, Sep 10, 2015, at 12:48, Chris Angelico wrote: > Having assignment be a statement (and therefore illegal in a loop > condition) makes sense. Having it be an expression that yields a > useful or predictable value makes sense. Having it be an expression, > but not returning a value, doesn't.

Re: Python handles globals badly.

2015-09-10 Thread rurpy--- via Python-list
On Thursday, September 10, 2015 at 6:18:39 AM UTC-6, Steven D'Aprano wrote: > On Thu, 10 Sep 2015 05:18 am, Chris Angelico wrote: > > On Thu, Sep 10, 2015 at 5:14 AM, Laura Creighton wrote: > >> In a message of Thu, 10 Sep 2015 05:00:22 +1000, Chris Angelico writes: > >>>To get

Re: Python handles globals badly.

2015-09-10 Thread Jussi Piitulainen
Steven D'Aprano writes: > Or os.abort. The docs for that say: > > Help on built-in function abort in module posix: > > abort(...) > abort() -> does not return! > > Abort the interpreter immediately. This 'dumps core' or otherwise > fails in the hardest way possible on the hosting

Re: Python handles globals badly.

2015-09-10 Thread random832
On Thu, Sep 10, 2015, at 14:13, Steven D'Aprano wrote: > Because that's the definition of an expression in this context. An > expression is evaluated to either return a result, or raise an exception. Nonsense. An expression is something allowed within a larger expression. It's easy to imagine an

Re: Python handles globals badly.

2015-09-10 Thread Peter Pearson
On Wed, 9 Sep 2015 20:20:42 +0100, Mark Lawrence wrote: > On 09/09/2015 18:59, William Ray Wing wrote: >>> On Sep 9, 2015, at 1:22 PM, Steven D'Aprano wrote: [snip] >> Right. Note that the Arabs, who DID invent zero, still count from one. [snip] > Would you please provide a

Re: Python handles globals badly.

2015-09-09 Thread Antoon Pardon
Op 09-09-15 om 01:55 schreef Michael Torrie: > In any case, 0-based indexing in Python makes a lot of sense when you > bring in the slicing syntax. Especially if you think of slicing as > operating on the boundaries between cells as it were. Then you have never used slices with a negative step.

Re: Python handles globals badly.

2015-09-09 Thread Antoon Pardon
Op 09-09-15 om 05:27 schreef Steven D'Aprano: > >> Were those polls, like the poll he once did for the condtional expression? >> There the poll indicated no specific proposal had a majority, so for each >> specific proposal one could say it didn't have popular support, but the >> majority still

Re: Python handles globals badly.

2015-09-09 Thread Christian Gollwitzer
Am 09.09.15 um 05:23 schrieb Steven D'Aprano: And yes, the fellow Joe who completely missed the point of the blog post, and made the comment "You don’t think you’re wrong and that’s part of a much larger problem, but you’re still wrong" completely deserved to be called out on his lack of reading

Re: Python handles globals badly.

2015-09-09 Thread random832
On Wed, Sep 9, 2015, at 13:55, Steven D'Aprano wrote: > In fairness to the C creators, I'm sure that nobody back in the early > seventies imagined that malware and security vulnerabilities would be as > widespread as they have become. But still, the fundamental decisions made > by C are lousy.

Re: Python handles globals badly.

2015-09-09 Thread Chris Angelico
On Thu, Sep 10, 2015 at 4:26 AM, Sven R. Kunze wrote: >> Adoption of programming languages is driven by many things, technical >> excellence and careful design are not even in the top 10. Most of them are >> social in nature, particularly "what is everyone else using?". Network

Re: Python handles globals badly.

2015-09-09 Thread Chris Angelico
On Thu, Sep 10, 2015 at 3:22 AM, Steven D'Aprano wrote: > I think my favourite is the guy who claims that the reason natural languages > all count from 1 is because the Romans failed to invent zero. (What about > languages that didn't derive from Latin, say, Chinese?) And

Re: Python handles globals badly.

2015-09-09 Thread Laura Creighton
In a message of Thu, 10 Sep 2015 03:55:54 +1000, "Steven D'Aprano" writes: >(I wanted to link to the "Everything Is Broken" essay on The Medium, but the >page appears to be gone. This makes me sad. BTW, what's the point of >Google's cache when it just redirects to the original, missing, page?)

Re: Python handles globals badly.

2015-09-09 Thread William Ray Wing
> On Sep 9, 2015, at 1:22 PM, Steven D'Aprano wrote: > > [byte] > > I think my favourite is the guy who claims that the reason natural languages > all count from 1 is because the Romans failed to invent zero. (What about > languages that didn't derive from Latin, say,

Re: Python handles globals badly.

2015-09-09 Thread Laura Creighton
In a message of Thu, 10 Sep 2015 05:00:22 +1000, Chris Angelico writes: >To get started, you need some other sort of kick. Having Brian Kernighan write a really nice book about you, helps a lot. Laura -- https://mail.python.org/mailman/listinfo/python-list

Re: Python handles globals badly.

2015-09-09 Thread Mark Lawrence
On 09/09/2015 16:04, Antoon Pardon wrote: Op 09-09-15 om 05:27 schreef Steven D'Aprano: In the case of case/switch, there is no consensus on what the statement should do, how it should work, what purpose it has, or what syntax it should use. Rather than "there's no alternative to a case

Re: Python handles globals badly.

2015-09-09 Thread Sven R. Kunze
On 09.09.2015 19:55, Steven D'Aprano wrote: On Wed, 9 Sep 2015 11:09 am, Mario Figueiredo wrote: You know, it is a pointless exercise to try and downplay programming languages (any programming language) that has proven its worth by being generally adopted by the programming community. Adoption

Re: Python handles globals badly.

2015-09-09 Thread Emile van Sebille
On 9/9/2015 10:55 AM, Steven D'Aprano wrote: (I wanted to link to the "Everything Is Broken" essay on The Medium, but the page appears to be gone. Is this it? http://www.sott.net/article/280956-Everything-is-broken-on-the-Internet -- https://mail.python.org/mailman/listinfo/python-list

Re: Python handles globals badly.

2015-09-09 Thread Steven D'Aprano
On Thu, 10 Sep 2015 02:09 am, Christian Gollwitzer wrote: > Am 09.09.15 um 05:23 schrieb Steven D'Aprano: >> And yes, the fellow Joe who completely missed the point of the blog post, >> and made the comment "You don’t think you’re wrong and that’s part of a >> much larger problem, but you’re

Re: Python handles globals badly.

2015-09-09 Thread Steven D'Aprano
On Wed, 9 Sep 2015 11:09 am, Mario Figueiredo wrote: > You know, it is a pointless exercise to try and downplay programming > languages (any programming language) that has proven its worth by being > generally adopted by the programming community. Adoption is the sign of > a respected and well

Re: Python handles globals badly.

2015-09-09 Thread Mark Lawrence
On 09/09/2015 20:57, Mario Figueiredo wrote: On 09-09-2015 18:55, Steven D'Aprano wrote: On Wed, 9 Sep 2015 11:09 am, Mario Figueiredo wrote: You know, it is a pointless exercise to try and downplay programming languages (any programming language) that has proven its worth by being generally

Re: Python handles globals badly.

2015-09-09 Thread Chris Angelico
On Thu, Sep 10, 2015 at 5:14 AM, Laura Creighton wrote: > In a message of Thu, 10 Sep 2015 05:00:22 +1000, Chris Angelico writes: >>To get started, you need some other sort of kick. > > Having Brian Kernighan write a really nice book about you, helps a lot. It kinda does. And of

Re: Python handles globals badly.

2015-09-09 Thread Sven R. Kunze
On 09.09.2015 21:00, Chris Angelico wrote: Suppose it's possible, somehow, to design the perfect language. (It isn't, because the best language for a job depends on the job, but suppose it for the nonce.) It is simultaneously more readable than Python, more ugly than Perl, more functional than

Re: Python handles globals badly.

2015-09-09 Thread Mark Lawrence
On 09/09/2015 18:59, William Ray Wing wrote: On Sep 9, 2015, at 1:22 PM, Steven D'Aprano wrote: [byte] I think my favourite is the guy who claims that the reason natural languages all count from 1 is because the Romans failed to invent zero. (What about languages

Re: Python handles globals badly.

2015-09-09 Thread MRAB
On 2015-09-09 18:59, William Ray Wing wrote: On Sep 9, 2015, at 1:22 PM, Steven D'Aprano wrote: [byte] I think my favourite is the guy who claims that the reason natural languages all count from 1 is because the Romans failed to invent zero. (What about languages

Re: Python handles globals badly.

2015-09-09 Thread Chris Angelico
On Thu, Sep 10, 2015 at 5:20 AM, Mark Lawrence wrote: > On 09/09/2015 18:59, William Ray Wing wrote: >> Right. Note that the Arabs, who DID invent zero, still count from one. > > Would you please provide a citation to support your claim as this >

Re: Python handles globals badly.

2015-09-09 Thread Mark Lawrence
On 09/09/2015 20:14, Laura Creighton wrote: In a message of Thu, 10 Sep 2015 05:00:22 +1000, Chris Angelico writes: To get started, you need some other sort of kick. Having Brian Kernighan write a really nice book about you, helps a lot. Laura Who? Did he play left wing or right wing for

Re: Python handles globals badly.

2015-09-09 Thread Mario Figueiredo
On 09-09-2015 18:55, Steven D'Aprano wrote: > On Wed, 9 Sep 2015 11:09 am, Mario Figueiredo wrote: > >> You know, it is a pointless exercise to try and downplay programming >> languages (any programming language) that has proven its worth by being >> generally adopted by the programming

Re: Python handles globals badly.

2015-09-08 Thread Antoon Pardon
Op 04-09-15 om 02:47 schreef Mark Lawrence: > On 04/09/2015 01:06, Michael Torrie wrote: >> On 09/03/2015 01:05 PM, t...@freenet.de wrote: >> >>> [The same e.g. with switch statement: add it] >> >> Switch is a nice-to-have thing, but definitely not essential. A PEP here >> (probably already has

Re: Python handles globals badly.

2015-09-08 Thread Mark Lawrence
On 08/09/2015 09:59, Antoon Pardon wrote: Op 04-09-15 om 02:47 schreef Mark Lawrence: On 04/09/2015 01:06, Michael Torrie wrote: On 09/03/2015 01:05 PM, t...@freenet.de wrote: [The same e.g. with switch statement: add it] Switch is a nice-to-have thing, but definitely not essential. A PEP

Re: Python handles globals badly.

2015-09-08 Thread Antoon Pardon
Op 05-09-15 om 02:05 schreef Vladimir Ignatov: >> To me, marking a variable as global in a large number of functions is >> a code smell that indicates that you're probably overusing globals. >> Lua is an example of a language that takes the opposite approach: in >> Lua, every variable is global

Re: Python handles globals badly.

2015-09-08 Thread Antoon Pardon
Op 04-09-15 om 04:33 schreef Steven D'Aprano: > On Fri, 4 Sep 2015 05:05 am, t...@freenet.de wrote: > >> Would you remove this keyword if it would be technically possible > Absolutely not. > > I do not believe that it is technically possible, but even if it were, I > would still argue that the Zen

Re: Python handles globals badly.

2015-09-08 Thread Laura Creighton
In a message of Tue, 08 Sep 2015 10:59:01 +0200, Antoon Pardon writes: >Were those polls, like the poll he once did for the condtional expression? >There the poll indicated no specific proposal had a majority, so for each >specific proposal one could say it didn't have popular support, but the

Re: Python handles globals badly.

2015-09-08 Thread Antoon Pardon
Op 08-09-15 om 11:22 schreef Mark Lawrence: > On 08/09/2015 09:59, Antoon Pardon wrote: > >> There the poll indicated no specific proposal had a majority, so for >> each >> specific proposal one could say it didn't have popular support, but the >> majority still prefered to have a conditional

Re: Python handles globals badly.

2015-09-08 Thread Vladimir Ignatov
>> I had some experience programming in Lua and I'd say - that language >> is bad example to follow. >> Indexes start with 1 (I am not kidding) > > What is so bad about that? It's different from the rest 99.9% of languages for no particular reason. ( => perfect example of "design smell" => not

Re: Python handles globals badly.

2015-09-08 Thread Akira Li
Vladimir Ignatov writes: >>> I had some experience programming in Lua and I'd say - that language >>> is bad example to follow. >>> Indexes start with 1 (I am not kidding) >> >> What is so bad about that? > > It's different from the rest 99.9% of languages for no particular

Re: Python handles globals badly.

2015-09-08 Thread Mario Figueiredo
On 08-09-2015 12:55, Vladimir Ignatov wrote: I had some experience programming in Lua and I'd say - that language is bad example to follow. Indexes start with 1 (I am not kidding) What is so bad about that? It's different from the rest 99.9% of languages for no particular reason. ( =>

Re: Python handles globals badly.

2015-09-08 Thread Mark Lawrence
On 08/09/2015 18:41, MRAB wrote: On 2015-09-08 15:31, Ian Kelly wrote: On Tue, Sep 8, 2015 at 5:55 AM, Vladimir Ignatov wrote: I had some experience programming in Lua and I'd say - that language is bad example to follow. Indexes start with 1 (I am not kidding) What is

Re: Python handles globals badly.

2015-09-08 Thread MRAB
On 2015-09-08 23:41, Mark Lawrence wrote: On 08/09/2015 18:41, MRAB wrote: On 2015-09-08 15:31, Ian Kelly wrote: On Tue, Sep 8, 2015 at 5:55 AM, Vladimir Ignatov wrote: I had some experience programming in Lua and I'd say - that language is bad example to follow. Indexes

Re: Python handles globals badly.

2015-09-08 Thread Mark Lawrence
On 09/09/2015 00:20, MRAB wrote: On 2015-09-08 23:41, Mark Lawrence wrote: On 08/09/2015 18:41, MRAB wrote: On 2015-09-08 15:31, Ian Kelly wrote: On Tue, Sep 8, 2015 at 5:55 AM, Vladimir Ignatov wrote: I had some experience programming in Lua and I'd say - that language

Re: Python handles globals badly.

2015-09-08 Thread Michael Torrie
On 09/08/2015 09:56 AM, Steven D'Aprano wrote: > http://exple.tive.org/blarg/2013/10/22/citation-needed/ > > It's a wonderful read. I read this article, but I'm still uncertain to what his point actually is. It's a great review of the history of C, some batch computing, and IBM's CEO's penchant

Re: Python handles globals badly.

2015-09-08 Thread Steven D'Aprano
On Wed, 9 Sep 2015 12:31 am, Ian Kelly wrote: > On Tue, Sep 8, 2015 at 5:55 AM, Vladimir Ignatov > wrote: I had some experience programming in Lua and I'd say - that language is bad example to follow. Indexes start with 1 (I am not kidding) >>> >>> What is so

Re: Python handles globals badly.

2015-09-08 Thread Random832
MRAB writes: > If you're allowed to specify both bounds, why would you be forbidden > from negative ones? It makes it non-obvious what value should be returned from e.g. search methods that return a negative number on failure. .NET's IndexOf function returns -1, but

Re: Python handles globals badly.

2015-09-08 Thread Ben Finney
Mario Figueiredo writes: > Note: > You know, it is a pointless exercise to try and downplay programming > languages (any programming language) that has proven its worth by > being generally adopted by the programming community. Adoption is the > sign of a respected and well

Re: Python handles globals badly.

2015-09-08 Thread Mario Figueiredo
On 09-09-2015 01:25, Vladimir Ignatov wrote: It's different from the rest 99.9% of languages for no particular reason. ( => perfect example of "design smell" => not a good example to follow) Assuming that some programming language makes design choices "for no apparent reason" is your first

Re: Python handles globals badly.

2015-09-08 Thread Chris Angelico
On Wed, Sep 9, 2015 at 11:26 AM, Ben Finney wrote: > On the other hand, I think there is merit in an argument that runs the > other way: the quality of languages that a community adopts are > predictive of the quality of programs that community will produce. Broadly,

Re: Python handles globals badly.

2015-09-08 Thread Chris Angelico
On Wed, Sep 9, 2015 at 12:43 PM, Mario Figueiredo wrote: > I can't stand Java. I just don't think calling it a mistake. It's worth has > been proven by its level of adoption and by the usable software that has > been made with it. Javascript/ECMAScript is criticized by so many and

Re: Python handles globals badly.

2015-09-08 Thread Steven D'Aprano
On Tue, 8 Sep 2015 06:59 pm, Antoon Pardon wrote: > Op 04-09-15 om 02:47 schreef Mark Lawrence: >> On 04/09/2015 01:06, Michael Torrie wrote: >>> On 09/03/2015 01:05 PM, t...@freenet.de wrote: >>> [The same e.g. with switch statement: add it] >>> >>> Switch is a nice-to-have thing, but

Re: Python handles globals badly.

2015-09-08 Thread Mario Figueiredo
On 09-09-2015 02:26, Ben Finney wrote: Mario Figueiredo writes: Note: You know, it is a pointless exercise to try and downplay programming languages (any programming language) that has proven its worth by being generally adopted by the programming community. Adoption is the

Re: Python handles globals badly.

2015-09-08 Thread Steven D'Aprano
On Wed, 9 Sep 2015 09:55 am, Michael Torrie wrote: > On 09/08/2015 09:56 AM, Steven D'Aprano wrote: >> http://exple.tive.org/blarg/2013/10/22/citation-needed/ >> >> It's a wonderful read. > > I read this article, but I'm still uncertain to what his point actually > is. It's a great review of

Re: Python handles globals badly.

2015-09-08 Thread random832
On Tue, Sep 8, 2015, at 10:31, Ian Kelly wrote: > I believe this wart is fixed in VB .NET. This is apparently true, but the weird thing is it was done late enough in the design cycle that the .NET runtime still has features meant to support it. You can create such an array with the

Re: Python handles globals badly.

2015-09-08 Thread Ian Kelly
On Tue, Sep 8, 2015 at 5:55 AM, Vladimir Ignatov wrote: >>> I had some experience programming in Lua and I'd say - that language >>> is bad example to follow. >>> Indexes start with 1 (I am not kidding) >> >> What is so bad about that? > > It's different from the rest 99.9% of

Re: Python handles globals badly.

2015-09-08 Thread MRAB
On 2015-09-08 15:31, Ian Kelly wrote: On Tue, Sep 8, 2015 at 5:55 AM, Vladimir Ignatov wrote: I had some experience programming in Lua and I'd say - that language is bad example to follow. Indexes start with 1 (I am not kidding) What is so bad about that? It's different

Re: Python handles globals badly.

2015-09-08 Thread tdev
Before reflecting latest answers a short absolute last statement about that matter: Differ: globals (traditional, sharing vars app wide, NOT meant) globals (module vars outside functions, meant here at least when I mention this term) global (the keyword used inside

Re: Python handles globals badly.

2015-09-08 Thread Ian Kelly
On Tue, Sep 8, 2015 at 11:53 AM, wrote: > -- Comparison with Javscript: > Saying that Javascript and LUA does it samewise seems not correct > from reading the thread. > LUA is said it has it vice versa: local instead of a global > But Javascript does have neither local nor

Re: Python handles globals badly.

2015-09-08 Thread Chris Angelico
On Wed, Sep 9, 2015 at 4:09 AM, Ian Kelly wrote: >> I would rather say, this would enhance the power and flexibility of the >> Python language even further. >> Especially from the scripting point of view (without harm Python hardliner) >> And by the way, I still believe

Re: Python handles globals badly.

2015-09-08 Thread Ben Finney
Mario Figueiredo writes: > On 09-09-2015 02:26, Ben Finney wrote: > > Mario Figueiredo writes: > > > >> You know, it is a pointless exercise to try and downplay > >> programming languages (any programming language) that has proven > >> its worth by being

Re: Python handles globals badly.

2015-09-08 Thread Ian Kelly
On Tue, Sep 8, 2015 at 9:27 PM, Steven D'Aprano wrote: > Using if...then statement is too heavyweight, and cannot be used in an > expression. Using "flag and true_value or false_value" is buggy -- it fails > if true_value is itself false. Refactoring it to a function uses

Re: Program in or into (was Python handles globals badly)

2015-09-06 Thread Ian Kelly
On Sat, Sep 5, 2015 at 8:54 PM, MRAB wrote: > And C# follows what Java does. Except where the language designers recognized that the Java way was poorly conceived or implemented and did it better. Generally speaking, I would much prefer to work in C# over Java, if

Re: Python handles globals badly.

2015-09-06 Thread pepekbabi5
idiomatic Python programming.  Those that try to program Java style in  Python are going to be frustrated.  -- https://mail.python.org/mailman/listinfo/python-list

Re: Program in or into (was Python handles globals badly)

2015-09-05 Thread Steven D'Aprano
On Sat, 5 Sep 2015 01:18 pm, Rustom Mody wrote: > Here's mergesort written in various languages > http://rosettacode.org/wiki/Sorting_algorithms/Merge_sort > > You could look at the java if you like but I think C# takes the cake. > And of course also there's the python > > Now the thought

Re: Program in or into (was Python handles globals badly)

2015-09-05 Thread MRAB
On 2015-09-06 03:35, Steven D'Aprano wrote: On Sat, 5 Sep 2015 01:18 pm, Rustom Mody wrote: Here's mergesort written in various languages http://rosettacode.org/wiki/Sorting_algorithms/Merge_sort You could look at the java if you like but I think C# takes the cake. And of course also there's

Re: Program in or into (was Python handles globals badly)

2015-09-05 Thread Rustom Mody
On Sunday, September 6, 2015 at 8:05:28 AM UTC+5:30, Steven D'Aprano wrote: > On Sat, 5 Sep 2015 01:18 pm, Rustom Mody wrote: > > > Here's mergesort written in various languages > > http://rosettacode.org/wiki/Sorting_algorithms/Merge_sort > > > > You could look at the java if you like but I

Re: Program in or into (was Python handles globals badly)

2015-09-05 Thread random832
Steven D'Aprano writes: > That depends. Is the example C# code idiomatic for the language? Not in the least. My first clue was Int32 - nobody actually uses those names. > Or was it > written by somebody ignorant of C#, and consequently is a poor example of > badly-written

Re: Python handles globals badly.

2015-09-04 Thread tdev
Before responding (later) I have to add something additional first: Cause of complaints and while still exists and again and again: When I mentioned maybe OO first than for also this reason cause Python is a powerful language and supports procedural and OO features and many more. And cause a

Re: Python handles globals badly.

2015-09-04 Thread Sven R. Kunze
On 04.09.2015 18:55, t...@freenet.de wrote: From knowing e.g Java as OO language I had no need to set such a keyword "global" to get write access to class members. It is true and I really dislike Java for having this. Please consider this class MyClass: @classmethod def

Re: Python handles globals badly.

2015-09-04 Thread tdev
Now I want reflecting the latest answers: I think mostly everything is said. Maybe you skip directly to my conclusion on the end. -- Nevertheless I want grasp some points out where I think I could give a respective answer: "You are shifting declaration from one to another place" I would

Re: Python handles globals badly.

2015-09-04 Thread Ian Kelly
On Fri, Sep 4, 2015 at 1:11 PM, wrote: > 6- "include" script statement (extending namespace to another script, like > PHP) def include(filename): exec(open(filename).read()) > Last but not least: > Why does javascript, as sripting language too, need not such things like >

Re: Python handles globals badly.

2015-09-04 Thread Ian Kelly
On Fri, Sep 4, 2015 at 1:48 PM, Ian Kelly wrote: > On Fri, Sep 4, 2015 at 1:11 PM, wrote: >> 6- "include" script statement (extending namespace to another script, like >> PHP) > > def include(filename): > exec(open(filename).read()) Sorry, that

Re: Program in or into (was Python handles globals badly)

2015-09-04 Thread Chris Angelico
On Sat, Sep 5, 2015 at 1:18 PM, Rustom Mody wrote: > Now the thought experiment: > > For some reason you need to code in C# > [You need to do this part of the experiment honestly!!] > > Would you write the C# code? > Or would you write the python-ish code in C# ? As I'm

Program in or into (was Python handles globals badly)

2015-09-04 Thread Rustom Mody
On Saturday, September 5, 2015 at 7:24:47 AM UTC+5:30, Chris Angelico wrote: > Indeed. The key to being a good programmer is not "write your code > despite the language you're using", but "write the code in the > language you're using". > A thought experiment for you Chris! Here's mergesort

Re: Python handles globals badly.

2015-09-04 Thread Vladimir Ignatov
> To me, marking a variable as global in a large number of functions is > a code smell that indicates that you're probably overusing globals. > Lua is an example of a language that takes the opposite approach: in > Lua, every variable is global unless you explicitly mark it as local. > Lua is a

Re: Python handles globals badly.

2015-09-04 Thread Michael Torrie
On 09/04/2015 06:27 PM, Chris Angelico wrote: > If you want the first one, well, there are languages like that, and > you're welcome to use those. For the latter, it's easy enough to do > something like this: > > import types > _g = types.SimpleNamespace() > > def accumulate(x): > _g.accum

Re: Python handles globals badly.

2015-09-04 Thread Chris Angelico
On Sat, Sep 5, 2015 at 5:11 AM, wrote: > 1. optional keyword "global" (if technical possible) As we've been saying in this thread, the problem isn't the technicalities of implementation, but the ambiguity of syntax. To eliminate the global statement, you need to either (a)

Re: Python handles globals badly.

2015-09-04 Thread Chris Angelico
On Sat, Sep 5, 2015 at 11:42 AM, Michael Torrie wrote: > On 09/04/2015 06:27 PM, Chris Angelico wrote: >> If you want the first one, well, there are languages like that, and >> you're welcome to use those. For the latter, it's easy enough to do >> something like this: >> >>

Re: Python handles globals badly.

2015-09-03 Thread Chris Angelico
On Thu, Sep 3, 2015 at 11:22 PM, wrote: > Sample "Good": > module A >_x = 0 > >def y(): > _x=1 > > > why - this I have tried and try to explain in my and your posts > in the hope a PEP will arise which frees me and hopefully > a lot other developers

Re: Python handles globals badly.

2015-09-03 Thread tdev
Before responding (later) I have to add something additional first: About the OO comments (Note again for this 2nd main topic of this thread: the term "globals" - it is meant only as the vars of a module outside functions and not sharing vars throughout the app

Re: Python handles globals badly.

2015-09-03 Thread MRAB
On 2015-09-03 17:43, Michael Torrie wrote: On 09/03/2015 10:15 AM, Ian Kelly wrote: The only person whom I see talking about this in this thread is you disclaiming that you're not talking about it. (And I guess Skybuck is talking about it, but I don't see those.) I have a vague memory of

Re: Python handles globals badly.

2015-09-03 Thread tdev
Now I want reflecting the latest answers: I have the position of a high-level view (cause of lack of Python knowledge internals and compiler stuff, but also cause I think a language should be as far as possible user-friendly without knowing too much internals, and yes clearly cause of

Re: Python handles globals badly.

2015-09-03 Thread Ian Kelly
On Thu, Sep 3, 2015 at 7:22 AM, wrote: > I think this has lead to some confusing. I don't think so. > First topic: > "sharing globals between modules" > Where globals is meant as vars used throughout the app. > > This is the topic why Skybuck starts the thread. > And yes I

Re: Python handles globals badly.

2015-09-03 Thread Michael Torrie
On 09/03/2015 10:15 AM, Ian Kelly wrote: > The only person whom I see talking about this in this thread is you > disclaiming that you're not talking about it. (And I guess Skybuck is > talking about it, but I don't see those.) I have a vague memory of Skybuck talking about globals over a year

Re: Python handles globals badly.

2015-09-03 Thread Michael Torrie
On 09/03/2015 07:22 AM, t...@freenet.de wrote: > First topic: > "sharing globals between modules" > Where globals is meant as vars used throughout the app. > > This is the topic why Skybuck starts the thread. The answer to this is simple and elegant. Use a third module to store globals. Each

Re: Python handles globals badly.

2015-09-03 Thread Ian Kelly
On Thu, Sep 3, 2015 at 1:47 PM, Ian Kelly wrote: > On Thu, Sep 3, 2015 at 1:05 PM, wrote: > >> But then I ask you from high-level point of view >> (if my high level view is correct at all): >> Would you remove this keyword if it would be technically

Re: Python handles globals badly.

2015-09-03 Thread Ian Kelly
On Thu, Sep 3, 2015 at 1:05 PM, wrote: > If this would be under the developer responsibility than this > is simply achieved by giving well-written var names. So, adopt a rule whereby you prefix all your global variable names with "global" or "g_"? How is this superior

Re: Python handles globals badly.

2015-09-03 Thread Mark Lawrence
On 03/09/2015 20:47, Ian Kelly wrote: On Thu, Sep 3, 2015 at 1:05 PM, wrote: Or does anyone really name a global var xxx and a function var xxx? I am sure no one at all will do it. I dont want read such a code. Intentionally, it's probably rare. But if I'm adding

Re: Python handles globals badly.

2015-09-03 Thread Michael Torrie
On 09/03/2015 01:05 PM, t...@freenet.de wrote: > And a compiler can surely recognize if a defined var xxx outside is > not a var yyy inside a function. At issue here is the idea of Python namespaces and how Python uses them in a consistent way with your code. The consistency is that binding of a

Re: Python handles globals badly.

2015-09-03 Thread Sven R. Kunze
On 03.09.2015 00:25, t...@freenet.de wrote: It is the good idea of Python about modules which are singletons and therefore have already its state (so in some way they are already somehow like classes - except the bad annoying thing with the "global" statement). So, what you really want is a

Re: Python handles globals badly.

2015-09-03 Thread Ian Kelly
On Thu, Sep 3, 2015 at 4:13 PM, Mark Lawrence wrote: > On 03/09/2015 20:47, Ian Kelly wrote: >> >> On Thu, Sep 3, 2015 at 1:05 PM, wrote: >>> >>> Or does anyone really name a global var xxx and a function var xxx? >>> I am sure no one at all

Re: Python handles globals badly.

2015-09-03 Thread Mark Lawrence
On 04/09/2015 01:06, Michael Torrie wrote: On 09/03/2015 01:05 PM, t...@freenet.de wrote: [The same e.g. with switch statement: add it] Switch is a nice-to-have thing, but definitely not essential. A PEP here (probably already has been several) would at least be read anyway. However, there

Re: Python handles globals badly.

2015-09-03 Thread tdev
Reflecting the answers I want to add following first: I should have better started a new thread. But now it is here, I want just clarify something before I move on (later) with repsonding. I think this has lead to some confusing. There are now two main topics in this thread. First topic:

Re: Python handles globals badly.

2015-09-03 Thread Steven D'Aprano
On Fri, 4 Sep 2015 02:43 am, Michael Torrie wrote: > Sadly Skybuck probably ditched Python a long time ago "Sadly"? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python handles globals badly.

2015-09-03 Thread Steven D'Aprano
On Fri, 4 Sep 2015 05:05 am, t...@freenet.de wrote: > Or does anyone really name a global var xxx and a function var xxx? > I am sure no one at all will do it. I dont want read such a code. You should reflect on the purpose of namespaces and local variables. Some programming languages do not

Re: Python handles globals badly.

2015-09-03 Thread Steven D'Aprano
On Fri, 4 Sep 2015 05:05 am, t...@freenet.de wrote: > Would you remove this keyword if it would be technically possible Absolutely not. I do not believe that it is technically possible, but even if it were, I would still argue that the Zen of Python applies: Explicit is better than implicit.

Re: Python handles globals badly.

2015-09-02 Thread Ian Kelly
On Wed, Sep 2, 2015 at 12:47 PM, wrote: > Using the keyword global inside each(!) function only > to mark the global var writeable in each of the functions > is really an over-regulation and very annoying from my point of view. To me, marking a variable as global in a large

Re: Python handles globals badly.

2015-09-02 Thread MRAB
On 2015-09-02 21:08, Sven R. Kunze wrote: On 02.09.2015 20:47, t...@freenet.de wrote: I agree with Skybuck Flying. I am aware if a var is a module function var or a module global var. If I want read or write a global var. Using the keyword global inside each(!) function only to mark the global

Re: Python handles globals badly.

2015-09-02 Thread Mark Lawrence
On 02/09/2015 19:47, t...@freenet.de wrote: Even Java (type-safe language) need not such things for its static or member vars. By this comment are you stating that Python is not type safe? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our

Re: Python handles globals badly.

2015-09-02 Thread Vladimir Ignatov
Hi, my 0.02 I don't personally use globals. And don't like "object oriented" code (my code more inclined toward "functional" style). But sometimes I feel like passing various minor values (like settings) all around app via regular parameters is just too much work. So I use "pseudo-global"

Re: Python handles globals badly.

2015-09-02 Thread Mark Lawrence
On 03/09/2015 01:16, Vladimir Ignatov wrote: Hi, my 0.02 I don't personally use globals. And don't like "object oriented" code (my code more inclined toward "functional" style). But sometimes I feel like passing various minor values (like settings) all around app via regular parameters is just

Re: Python handles globals badly.

2015-09-02 Thread Steven D'Aprano
On Thu, 3 Sep 2015 04:47 am, t...@freenet.de wrote: > I agree with Skybuck Flying. > I am aware if a var is a module function var or a module global var. Congratulations! But you're not the Python compiler, which doesn't have your superior insight and intuition. Inside a function, how is the

Re: Python handles globals badly.

2015-09-02 Thread Mark Lawrence
On 02/09/2015 23:25, t...@freenet.de wrote: Therefore still hoping a new PEP will arise. @Mark Lawrence This response I have not checked. Can you provide arguments or clarify your statement? The over use of globals is never to be encouraged, which is precisely what this would do. You

Re: Python handles globals badly.

2015-09-02 Thread tdev
I agree with Skybuck Flying. I am aware if a var is a module function var or a module global var. If I want read or write a global var. Using the keyword global inside each(!) function only to mark the global var writeable in each of the functions is really an over-regulation and very annoying

<    1   2   3   >