Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #108935

Re: what is new with int conversion in Python 3

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: what is new with int conversion in Python 3
Date 2016-05-22 17:51 +1000
Message-ID <mailman.91.1463903520.27390.python-list@python.org> (permalink)
References <648b46dc-c962-4f95-83bc-faa65ae3c51a@googlegroups.com> <CAPTjJmqHATYTMe0HiMKpXpDgkseWyS_D-U_XKcYKkz_ZEwVg=Q@mail.gmail.com>

Show all headers | View raw


On Sun, May 22, 2016 at 5:26 PM, Sayth Renshaw <flebber.crue@gmail.com> wrote:
> However when I run this I get a valuerror. So either something has changed with int or datetime I cannot google a consistent answer.
>
>
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
> <ipython-input-8-a54a878f293d> in <module>()
>      37    return c
>      38
> ---> 39 size = int(sys.argv[1])
>      40
>      41 start = datetime.now()
>
> ValueError: invalid literal for int() with base 10: '-f'
>
> Had this before?

Look carefully at the error, and the line that it's coming up on.
Firstly, you can rule out datetime, as nothing has been done with
datetime except import it. Secondly, the invalid literal doesn't look
like a decimal number at all; in fact, it looks to me like a flag of
some sort. Try adding this above the failing line:

print(sys.argv)

And also, try running this at the terminal:

$ file /usr/bin/env/python

How are you invoking Python? The shebang looks wrong; perhaps it
should be "/usr/bin/env python" (note the space where you have an
additional slash), but perhaps it's not even being significant here.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

what is new with int conversion in Python 3 Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-22 00:26 -0700
  Re: what is new with int conversion in Python 3 Chris Angelico <rosuav@gmail.com> - 2016-05-22 17:51 +1000
  Re: what is new with int conversion in Python 3 Steven D'Aprano <steve@pearwood.info> - 2016-05-22 17:55 +1000
  Re: what is new with int conversion in Python 3 Peter Otten <__peter__@web.de> - 2016-05-22 10:32 +0200
  Re: what is new with int conversion in Python 3 Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-22 03:59 -0700

csiph-web