Re: [Tutor] argparse iterable

2013-04-02 Thread kendy
I forgot about update. It's nice and clean: a.update(b) However, when 'a' has values and 'b' is None, the 'a' item gets clobbered with None. I found this on stackoverflow.com: -- old = {1: 'one', 2: 'two'} new = {1: 'newone', 2: None, 3: 'new'} old.update( (k,v) for k,v in n

Re: [Tutor] argparse iterable

2013-04-01 Thread kendy
You guys are awesome! You make it look easy and I learn every time. Thank you Ken ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] argparse iterable

2013-04-01 Thread kendy
Dear Tutor I want to compare command line options, to options in a dictionary from a YAML file. The command line will over-ride the options in my file. (The YAML file, and its dictionary are not shown. That part works.) My distilled code:

Re: [Tutor] Fixing Globals

2013-03-17 Thread kendy
Thanks to everyone who responded. I learned from each person's response. The example code that I emailed was representative of many large programs that I've written in other languages. I've written many small Python scripts and I'm about to write a more complex Python script, much like the example

Re: [Tutor] Fixing Globals

2013-03-16 Thread kendy
Wow! Quick response. I'll study the responses. THANK YOU! Ken ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Fixing Globals

2013-03-16 Thread kendy
Dear Tutor Global constants and variables are bad. But what's better? I've heard some suggestions, but haven't seen much actual code showing how to improve globals. I don't like: * Passing a lot of individual arguments. * Creating a structure with unrelated elements. * Passing a structure, as an

Re: [Tutor] encrypt a file in Python3

2012-11-10 Thread kendy
Thank you Mark and eryksun! You've put me back on the road to success! I'll start saving up for your bill. :-) Ken ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] encrypt a file in Python3

2012-11-09 Thread kendy
Hello! I want to encrypt a file, then decrypt it. I prefer to do it without adding any packages. I found http://eli.thegreenplace.net/2010/06/25/aes-encryption-of-files-in-python-with-pycrypto/ which seems like a good approach. How can I get the import to work for python 3? Here's what I get:

Re: [Tutor] python varying mulitple inheritance

2012-06-19 Thread kendy
Thank you Steve and Alan! I'll keep studying and practicing. Ken >Back to basics. a class is a definition of a *type* of thing, not a >particular case. A Pocket is a general purpose container. Each instance >can hold many things. So you would normally expect one pocket class and >6 instances

Re: [Tutor] python varying mulitple inheritance

2012-06-18 Thread kendy
Hmmm. No need to write the whole thing written out. Just how not to code: class Pocket1(Wallet, Keys, Comb, Usb, CellPhone, WorkBadge): class Pocket2(Wallet, Keys, Comb, Usb, CellPhone): class Pocket3(Wallet, Keys, Comb, Usb,WorkBadge): class Pocket4(Wallet, Keys, Comb, Usb): class Poc

Re: [Tutor] python varying mulitple inheritance

2012-06-18 Thread kendy
Thank you Steve, for the pointing me in a smarter direction! My immediate homework is: - Practice consistent conventions for naming things -- pep-0008. - Learn composition/has-a. I thought of a better way to think of my problem. A list element would contain the things that Bob has in his pockets

[Tutor] python varying mulitple inheritance

2012-06-17 Thread kendy
Hello I'm new to classes. And I hope the my question isn't too big. I have electronic test equipment, but thought that a boat example would be easier. Can you help me untangle my class design? My problem is basically multiple inheritance, but I want to be flexible for how many will inherit. I'll