You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using cli.CountOf, if the parser does not find any instances of the flag (and so should return a value of zero), then it returns a single-element list, with the single element being zero.
Here's a quick program which illustrates the problem:
from plumbum import cli
class HelloApp(cli.Application):
'''A simple app to say "Hello!"'''
PROGNAME = 'HelloApp'
VERSION = '1.0'
verbosity = cli.CountOf('-v', help="Verbosity Level")
def main(self, who='CLI World'):
print self.verbosity
print type(self.verbosity)
if self.verbosity >= 1:
print "I'm about to say hello."
msg = 'Hello {!s}!'.format(who)
print msg
if __name__ == "__main__":
HelloApp.run()
Note that if you do not provide a -v flag, the value of self.verbosity will always be: [0]
If you give any other number of -v flags, CountOf returns the appropriate integer.
The text was updated successfully, but these errors were encountered:
khorn
changed the title
CountOf returns a list instead of zero
cli.CountOf returns a list instead of zero
Apr 18, 2014
When using cli.CountOf, if the parser does not find any instances of the flag (and so should return a value of zero), then it returns a single-element list, with the single element being zero.
Here's a quick program which illustrates the problem:
Note that if you do not provide a
-v
flag, the value of self.verbosity will always be:[0]
If you give any other number of
-v
flags,CountOf
returns the appropriate integer.The text was updated successfully, but these errors were encountered: