Re: [Tutor] set locals

2013-12-18 Thread Peter Otten
spir wrote: > Hello, > > is it at all possible to set new vars (or any symbol) into an existing > scope (typically locals())? locals() normally contains a copy of the current namespace as a dict. Setting items is possible but only alters the dict and has no effect on the original namespace: >

[Tutor] Saving files in Python, IDE's & editors

2013-12-18 Thread Keith Winston
On Tue, Dec 17, 2013 at 7:26 PM, wrote: > What else do I need to do to make this version of Python an actually > usable programming environment? > > Chris Acreman > Chris, I'm also a noob, but I would recommend you install/use an IDE, such as IDLE which comes free with all (I think) Python insta

Re: [Tutor] set locals

2013-12-18 Thread spir
On 12/18/2013 10:02 AM, Peter Otten wrote: spir wrote: [...] Like Steven I have no idea how you produced the mappingproxy. Are you trying to use a class as a namespace (in Python 3.3)? class A: pass ... A.__dict__["foo"] = "bar" Traceback (most recent call last): File "", line 1, in Type

Re: [Tutor] set locals

2013-12-18 Thread eryksun
On Tue, Dec 17, 2013 at 10:52 AM, spir wrote: > is it at all possible to set new vars (or any symbol) into an existing scope > (typically locals())? > > scope[name] = value > raises by me an error like: > TypeError: 'mappingproxy' object does not support item assignment > > I guess 'mappin

Re: [Tutor] set locals

2013-12-18 Thread eryksun
On Wed, Dec 18, 2013 at 5:40 AM, spir wrote: > C.__setattr__(C, "baz", "BAZ") > which fails, for any reason, with > TypeError: can't apply this __setattr__ to type object You need __setattr__ from the metaclass: >>> class C: pass ... >>> type(C).__setattr__(C, "baz", "BAZ")

Re: [Tutor] Saving files in Python, IDE's & editors

2013-12-18 Thread spir
On 12/18/2013 03:28 AM, Keith Winston wrote: On Tue, Dec 17, 2013 at 7:26 PM, wrote: What else do I need to do to make this version of Python an actually usable programming environment? Chris Acreman Chris, I'm also a noob, but I would recommend you install/use an IDE, such as IDLE which c

Re: [Tutor] Built In Functions

2013-12-18 Thread spir
On 12/17/2013 11:30 PM, Dave Angel wrote: On Wed, 18 Dec 2013 02:39:43 +1100, Steven D'Aprano wrote: if a > 0 and b > 0 and c > 0: if all(x for x in (a, b, c): Er, perhaps it should be: if all (x> 0 for x in (a, b, c): I saw the missing paren at once (maybe a few months progr lisp

Re: [Tutor] set locals

2013-12-18 Thread spir
On 12/18/2013 12:07 PM, eryksun wrote: On Wed, Dec 18, 2013 at 5:40 AM, spir wrote: C.__setattr__(C, "baz", "BAZ") which fails, for any reason, with TypeError: can't apply this __setattr__ to type object You need __setattr__ from the metaclass: >>> class C: pass ...

Re: [Tutor] Built In Functions

2013-12-18 Thread eryksun
On Tue, Dec 17, 2013 at 10:51 AM, Rafael Knuth wrote: > Got it. I just wanted to make sure I get a better understanding of how > to use any() and all() even though I already had a solution at hand. > So far, I worked through 24 out of 68 built-in functions 68 is the total for types (26) and funct

Re: [Tutor] set locals

2013-12-18 Thread spir
On 12/18/2013 11:51 AM, eryksun wrote: On Tue, Dec 17, 2013 at 10:52 AM, spir wrote: is it at all possible to set new vars (or any symbol) into an existing scope (typically locals())? scope[name] = value raises by me an error like: TypeError: 'mappingproxy' object does not support it

Re: [Tutor] Saving files in Python, IDE's & editors

2013-12-18 Thread Ken G.
For what it may be worth, I use Geany on my Ubuntu OS, 12.04 LTS. I also have IDLE installed and I can use the Terminal Window in running Command Line. Ken On 12/17/2013 09:28 PM, Keith Winston wrote: On Tue, Dec 17, 2013 at 7:26 PM, > wrote: What else do I

Re: [Tutor] Saving files in Python, IDE's & editors

2013-12-18 Thread Reuben
Keep caution while using geany. It causes indentation problems On 18-Dec-2013 10:34 PM, "Ken G." wrote: > For what it may be worth, I use Geany on my Ubuntu > OS, 12.04 LTS. I also have IDLE installed and I > can use the Terminal Window in running Command > Line. > > Ken > > On 12/17/2013 09:28

Re: [Tutor] set locals

2013-12-18 Thread Mark Lawrence
On 18/12/2013 11:16, spir wrote: On 12/18/2013 12:07 PM, eryksun wrote: On Wed, Dec 18, 2013 at 5:40 AM, spir wrote: C.__setattr__(C, "baz", "BAZ") which fails, for any reason, with TypeError: can't apply this __setattr__ to type object You need __setattr__ from the metaclass:

Re: [Tutor] Getting Started

2013-12-18 Thread Mark Lawrence
On 17/12/2013 19:47, Chris Acreman wrote: I have programming experience using Fortran, Pascal, Modula 2, and some training in C++. My nephew told me about Python and it sounded intriguing. I downloaded Python 3.3.0 from this website (www.python.org ) and installed it with

Re: [Tutor] Saving files in Python, IDE's & editors

2013-12-18 Thread spir
On 12/18/2013 06:35 PM, Reuben wrote: Keep caution while using geany. It causes indentation problems ??? (funny assertion ;-) doesn't it raise an AssertionError, perhaps?) Denis ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscri

Re: [Tutor] set locals

2013-12-18 Thread Alan Gauld
On 18/12/13 17:45, Mark Lawrence wrote: Can I be so bold as to ask how discussing metaclasses and __setattr__ on a tutor mailing list is going to help the newbie who's having problems with their "hello world" program? It won't, but the tutor list is also for experienced programmers new to Pyth

Re: [Tutor] Getting Started

2013-12-18 Thread Alan Gauld
On 18/12/13 19:21, Mark Lawrence wrote: languages such as Java and C++. For example, I use Eclipse and Pydev and have the static code checker Pylint automatically look at my code as I type. Ooh! that's a new one, how do you set that up? I use Eclipse/PyDev from time to time but I've never see

Re: [Tutor] Getting Started

2013-12-18 Thread Mark Lawrence
On 18/12/2013 20:47, Alan Gauld wrote: On 18/12/13 19:21, Mark Lawrence wrote: languages such as Java and C++. For example, I use Eclipse and Pydev and have the static code checker Pylint automatically look at my code as I type. Ooh! that's a new one, how do you set that up? I use Eclipse/Py

Re: [Tutor] Getting Started

2013-12-18 Thread Walter Prins
Hi, On 18 December 2013 21:25, Mark Lawrence wrote: > Go to window->preferences->pydev->pylint. > > It works beautifully :) Type something like this as the first two lines in > an editor window:- > > if a == 1: > print('a == 1') > > and it gives you a red bar on the right and a red circle wi

Re: [Tutor] set locals

2013-12-18 Thread Steven D'Aprano
On Wed, Dec 18, 2013 at 05:45:02PM +, Mark Lawrence wrote: > Can I be so bold as to ask how discussing metaclasses and __setattr__ on > a tutor mailing list is going to help the newbie who's having problems > with their "hello world" program? It's not just newbies who need tutoring. Sometim

Re: [Tutor] Saving files in Python, IDE's & editors

2013-12-18 Thread Steven D'Aprano
On Tue, Dec 17, 2013 at 09:28:14PM -0500, Keith Winston wrote: > On Tue, Dec 17, 2013 at 7:26 PM, wrote: > > > What else do I need to do to make this version of Python an actually > > usable programming environment? > > > > Chris Acreman > > > > Chris, I'm also a noob, but I would recommend you

Re: [Tutor] Getting Started

2013-12-18 Thread Chris Acreman
Amit and Alan, Thank your for your prompt responses to my questions. If you don't mind I will try to merge your questions into a single, hopefully comprehensive response. *** *** *** "But to go further we need to know which OS you are using?" -- Alan I'm using Windows 7. The boo

Re: [Tutor] Getting Started

2013-12-18 Thread Alan Gauld
On 19/12/13 00:11, Chris Acreman wrote: "But to go further we need to know which OS you are using?" -- Alan I'm using Windows 7. The book assumes a Windows environment, but includes instructions for installing on other systems. OK, I'd recommend getting Activestate's free Python distribution

Re: [Tutor] Getting Started

2013-12-18 Thread eryksun
On Wed, Dec 18, 2013 at 9:28 PM, Alan Gauld wrote: >> The "Python Screen" is what opens up when I click the Python button on >> the desktop. The book calls it a "console window, > > Yes, it's worth getting familiar with it. It provides the ultimate authority > on things like error messages etc. I

Re: [Tutor] set locals

2013-12-18 Thread eryksun
On Wed, Dec 18, 2013 at 6:16 AM, spir wrote: > On 12/18/2013 12:07 PM, eryksun wrote: >> >> You need __setattr__ from the metaclass: >> >> >>> class C: pass >> ... >> >>> type(C).__setattr__(C, "baz", "BAZ") >> >>> C.baz >> 'BAZ' > > Oh, that makes sense: so, __setattr__ o