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
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
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:
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
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
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
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
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:
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
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
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
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
12 matches
Mail list logo