Python Forum
converting arguments or input numbers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
converting arguments or input numbers
#1
i've been doing things like this to convert arguments or input numbers:
   number = int(sys.argv[1])
now i have found a different way that is more fun though it needs more coding:
    try:
        number = eval(sys.argv[1])
    except:
        print('oops!')
        error_count += 1
if you want the traceback info, don't use the try/except. then you don't have to calculate formulas to enter their values (though you might have to use quotes around many formulas for most command shells).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
converting arguments or input numbers - by Skaperen - Aug-20-2018, 01:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: Found input variables with inconsistent numbers of samples saoko 0 2,568 Jun-16-2022, 06:59 PM
Last Post: saoko
  Found input variables with inconsistent numbers of samples: [1000, 200] jenya56 2 3,003 Sep-15-2021, 12:48 PM
Last Post: jenya56
  converting user input to float troubles RecklessTechGuy 3 2,552 Aug-17-2020, 12:41 PM
Last Post: deanhystad
  square root of 5 input numbers mrityunjoy 1 2,085 Jun-10-2020, 11:08 AM
Last Post: perfringo
  square root of 6 input numbers mrityunjoy 3 2,707 Jun-07-2020, 06:35 AM
Last Post: ndc85430
  Trouble converting numbers to characters Involute 4 2,598 Sep-12-2019, 04:49 AM
Last Post: Involute
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,864 May-09-2019, 12:19 PM
Last Post: Pleiades
  converting python list to a list by user input Dante24 1 3,096 Nov-21-2017, 10:10 AM
Last Post: heiner55
  Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) Adelton 2 3,966 Mar-02-2017, 10:23 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020