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
On 02/04/2013 10:48, Dave Angel wrote:
BTW, can you tell me how you get the #the-namespace-object part of your
link? Is there some technique (without actually looking in the source
code for the page) for finding the nearest id= ? I've now figured out
how to do it for pages like this one with a
On Tue, Apr 2, 2013 at 5:48 AM, Dave Angel wrote:
>
> BTW, can you tell me how you get the #the-namespace-object part of your
> link? Is there some technique (without actually looking in the source code
> for the page) for finding the nearest id= ?
16.4.4.6. The Namespace object
On 04/01/2013 10:28 PM, ke...@kendy.org wrote:
You guys are awesome! You make it look easy and I learn every time.
Once you've got the two dicts, take a look into the update method. It
may make any loops unnecessary, except for debugging.
--
DaveA
_
On 04/01/2013 10:34 PM, Mark Lawrence wrote:
On 02/04/2013 02:37, Dave Angel wrote:
On 04/01/2013 09:31 PM, Mark Lawrence wrote:
for a in vars(parser.parse_args()):
print('This arg is %s' % a)
http://docs.python.org/3/library/argparse.html#the-namespace-object
Please don't ask me for an
On 02/04/2013 03:28, ke...@kendy.org wrote:
You guys are awesome! You make it look easy and I learn every time.
Thank you
Ken
Think yourself lucky, I'm currently on the wagon or it'd cost you a
couple of pints :)
--
If you're using GoogleCrap™ please read this
http://wiki.python.org/moin/G
On 02/04/2013 02:37, Dave Angel wrote:
On 04/01/2013 09:31 PM, Mark Lawrence wrote:
for a in vars(parser.parse_args()):
print('This arg is %s' % a)
http://docs.python.org/3/library/argparse.html#the-namespace-object
Please don't ask me for an explanation as it took me long enough to work
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
On Apr 1, 2013, at 8:31 PM, wrote:
>
>
> print("But this doesn't iter through a b and c:")
> for k,v in parser.parse_args():
>print('This arg is %s %s' % k, k[str(v)])
> $
> -
>
> My error:
> $ h.py -a -b hi -c 42
>
On 04/01/2013 09:31 PM, Mark Lawrence wrote:
On 02/04/2013 01:31, ke...@kendy.org wrote:
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
On 02/04/2013 01:31, ke...@kendy.org wrote:
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:
--
#!/usr/bin/python
import argparse
parser = argparse.ArgumentParser(description='Short sample app')
parser.add_argument('-a', action="store_true", default=False)
parser.add_argument('-b', action="store", dest="b")
parser.add_argument('-c', action="store", dest="c", type=int)
parser.parse_args()
for
12 matches
Mail list logo