Re: [Tutor] I Give Up. - Follow up post

2006-07-05 Thread Alan Gauld
> Comes from wanting to minimize how much stuff I have loaded into > memory, and my impression is, a dictionary of 2 elements (name:value > pairs) > takes up more space in memory than two single variables (name points > to value in memory), Dangerous assumption since Python ultimately uses dict

Re: [Tutor] I Give Up. - Follow up post

2006-07-05 Thread Brian Gustin
> > The other alternative is to provide a tool for editing the file in which > case the format is less important sionce hiumans "never" need to > touch it. > Heh. good analysis.. now I feel a little dumb- I should have thought of this *LONG* ago. yeah I knew about the xml parser , and how to do

[Tutor] I Give Up. - Follow up post

2006-07-05 Thread János Juhász
Dear Brian, The best parser is python itself :) let's make ports.py with your original content: http = 80 https = 443 http1 = 81 smtp = 25 smtp2 = 587 In this case, you can import ports.py with simple >>> import ports >>> ports.http 80 >>> You don't need to define a new file format, just use

Re: [Tutor] I Give Up. - Follow up post

2006-07-05 Thread Alan Gauld
>> >> ### machine_config.py >> machines = { 'apache': ('http', 80), >> ## fill me in with the config of other machines >> } >> >> >> could be used as your configuration file format. The value portion >> of a >

Re: [Tutor] I Give Up. - Follow up post

2006-07-04 Thread Brian Gustin
OK .. so far so good.. :) > ultimately want is not meshing well together. > > Let's clarify the requirement: you want to have a mapping from services > to their configurations. Ignoring the format of the configuration file > for the moment, it sounds like you ultimately want to parse the > con

Re: [Tutor] I Give Up. - Follow up post

2006-07-04 Thread Danny Yoo
> Now, if I want to iterate over a list of machines , and check each > machine for whatever it was set for (in the config file) > So the config file requires http to be the first part of the string , > followed by something to make it unique (I.E. http1, http2, http3) Hi Brian, Have you consi

Re: [Tutor] I Give Up. - Follow up post

2006-07-04 Thread Brian Gustin
Danny Yoo wrote: >> I tried it by opening a file , but could find no way to do variable >> variables > > > > Hi Brian, > > Look for the concept of dictionaries in Python. "Variable variables" in > languages like PHP and Perl are doable in Python, but a dictionary > usually handles such si

Re: [Tutor] I Give Up. - Follow up post

2006-07-04 Thread Danny Yoo
> I tried it by opening a file , but could find no way to do variable > variables Hi Brian, Look for the concept of dictionaries in Python. "Variable variables" in languages like PHP and Perl are doable in Python, but a dictionary usually handles such situations in a safer way. > and then

Re: [Tutor] I Give Up. - Follow up post

2006-07-04 Thread Brian Gustin
OK see, what I was doing originally (and I found time to finally get it partially working) I have a configuration file that may be edited by webmaster thus [Ports] http = 80 https = 443 http1 = 81 smtp = 25 smtp2 = 587 (the above is a small example, it could be *anything* ) Now I have a funct

Re: [Tutor] I Give Up.

2006-06-18 Thread Alan Gauld
> reference docs, they do not replace tutorial books like "Learning > Python" or "Learn to Program Using Python" (by Alan Gauld, who Thanks for the plug, but I'd be first to admit my tutor is way too basic to go near the ConfigParser modules etc. I had actually hoped that Mertz' "Text Processing i

Re: [Tutor] I Give Up.

2006-06-18 Thread Dave Kuhlman
On Sat, Jun 17, 2006 at 07:37:40PM -0400, Brian Gustin wrote: [snip] > > OK.. maybe another project to tackle.. I guess I just need to start > building the python documentation the way I think it outta be done... > and see how it goes over.. At the top of the table of contents of the library

Re: [Tutor] I Give Up.

2006-06-18 Thread learner404
On 18/06/06, Brian Gustin <[EMAIL PROTECTED]> wrote: The one amazing thing I found ridiculously funny:Python "official" forums- and they actually run phpBB forums?  You meanto tell me no one has written a solid, stable forum software in Python? OK.. maybe another project to tackle.. I guess I just

Re: [Tutor] I Give Up.

2006-06-17 Thread Ismael Garrido
Brian Gustin wrote: > I'll just go write it in Perl. Maybe some day when Python actually has > well structured documentation with *actual working code examples* > Indeed. I have always thought that the docs lacked working examples. I usually do a google search, hoping to find some script sho

Re: [Tutor] I Give Up.

2006-06-17 Thread Kent Johnson
Brian Gustin wrote: > I am thinking very seriously about building a new set of python > documentation with capability for user contributions and notes, etc, and > putting it online (with searchability to boot) .. maybe a project for > another day.. Maybe something like this: http://pyref.infoga

Re: [Tutor] I Give Up.

2006-06-17 Thread Brian Gustin
Thanks- I had to sit back and with the perl script running nicely, I took another shot at this to see if I could get it right.. so far so good, at least no more exceptions being raised.. The perl script runs on a cron, I am thinking I will write this in python and then wrap it up into a main f

Re: [Tutor] I Give Up.

2006-06-17 Thread Python
On Sat, 2006-06-17 at 16:44 -0400, Brian Gustin wrote: > Now can someone explan how exactly (preferrably with an actual real > world example) that I can read a configuration file in , say > /etc/local-config/myconfig.cfg into my python script running in > /usr/bin/localscripts , and able to act

Re: [Tutor] I Give Up.

2006-06-17 Thread Python
On Sat, 2006-06-17 at 16:44 -0400, Brian Gustin wrote: > I have had it. I give up. > > Python's documentation sucks beyond belief. A lot of it is excellent. The ConfigParser, that you are complaining about is woefully short on examples and does not make clear that you *must read* the other sectio

[Tutor] I Give Up.

2006-06-17 Thread Brian Gustin
I have had it. I give up. Python's documentation sucks beyond belief. all I want to do is parse a *SIMPLE* config file of name = value pairs and have python objects named by the name holding the value signified by value , and I want it to be able to work *WITHOUT* someone having to download an