Questions tagged [sys]

For questions about the Python module named sys. This tag is also used for questions relating to the Sys namespace - the root namespace for the Microsoft AJAX Library, which contains all fundamental classes and base classes.

1100 questions
2
votes
1 answer

Terminating a program within python

Hi I embeded a time constraint in to my python code which is running a fortran code with a function. However I realized that the function that puts a time constraint on the other function doesn't terminates the code, just leaves it in background and…
jackaraz
  • 291
  • 1
  • 12
2
votes
2 answers

Can I sign .hlkx file manually using EV certificate to submit on the Microsoft website

I have completed all the tests with my usb device in Hardware Lab Kit and now can prepare the .hlkx driver package to submit on the Microsoft website. The problem is EV certificate is required for Windows 10 driver. EV certificate is provided with…
Evgeniy
  • 403
  • 1
  • 8
  • 18
2
votes
1 answer

How to get text to display as typing in cmd

if someone could help with my problem i would really be grateful, I'm not an expert when it comes to python 3 but I know a thing or too since I'm learning. My problem is I'm trying to have text display on a python program in the command line that…
killerbee
  • 21
  • 2
2
votes
1 answer

Python sys.stdin.read() accept input condition print prompt twice

I wrote a function that accepts a character (without hitting enter), and checks for validation, and returns the key pressed. But the problem is, the prompt I am printing is printing it two times if the value is not matched. Here is my code. def…
nohup
  • 3,105
  • 3
  • 27
  • 52
2
votes
2 answers

Import functions from Python script in remote directory via a custom module

So this problem is a bit convoluted, but I will try to explain. I have written a script script.py that is located in /my/directory/script.py. This contains many helpful functions that I would like to make available to users of Python on this…
invoker
  • 507
  • 3
  • 7
  • 18
2
votes
1 answer

Python: catch uncaught Exception but not exit immediately

from the standard library for sys module sys.excepthook(type, value, traceback) This function prints out a given traceback and exception to sys.stderr. When an exception is raised and uncaught, the interpreter calls sys.excepthook with three…
mike rodent
  • 14,126
  • 11
  • 103
  • 157
2
votes
1 answer

Login to a website using python

I am trying to login to this page using Python.Here is my code from urllib2 import urlopen from bs4 import BeautifulSoup import requests import sys URL= 'http://coe2.annauniv.edu/result/index.php' soup =…
Emil George James
  • 1,181
  • 1
  • 10
  • 20
2
votes
2 answers

How to poll a file in /sys

I am stuck reading a file in /sys/ which contains the light intensity in Lux of the ambient light sensor on my Nokia N900 phone. See thread on talk.maemo.org here I tried to use pyinotify to poll the file but this looks some kind of wrong to me…
Bjoern
  • 21
  • 3
2
votes
2 answers

TypeError: an integer is required python

This is my code: today = datetime.date.today() if len(sys.argv) > 1: arg_month = sys.argv[1] arg_year = sys.argv[2] print arg_month print arg_year lastMonth = datetime.date(day=1, month=arg_month, year=arg_year) first =…
Lelan Calusay
  • 51
  • 2
  • 9
2
votes
1 answer

Continue reading on sys.stdin

Is it possible to continue reading input on sys.stdin? I'm trying to continuously execute a function based on input. (My function only prints to sys.stdout and sys.stderr, and doesn't return anything.) My Code: def prime(number): number =…
Zizouz212
  • 4,908
  • 5
  • 42
  • 66
2
votes
2 answers

Strange output sys.getsizeof()

I just ran these codes: v = [1,2,'kite',100**100] for x,y in enumerate(v): print ("{} size is: {}".format(y,sys.getsizeof(v[x]))) print ("Total size is: {} ".format(sys.getsizeof(v))) Output: 1 size is: 14 2 size is: 14 kite size is:…
user4302114
2
votes
2 answers

writing output into files within subdirectory locations according to a list of input filename paths

I have a txt file that contains a list of filenames with various subdirectories in this name format: ./A_blurb/test.txt ./B_foo/bar.txt ./B_foo/bric.txt etc.. I also have script that loops through the lines in the filenames list and produces an…
oaklander114
  • 3,143
  • 3
  • 16
  • 24
2
votes
1 answer

Python not printing all the sys.argv

I'm getting a list out of range error from sys.argv[1] and I tried making a simple script with this code. import sys print sys.argv I get this on cmd: C:\...\...\...\py>back.py exampleargv ['C:\\...\\...\\...\\py\\back.py'] I don't know why I…
biosr
  • 65
  • 3
2
votes
1 answer

Python, reference a file in the same directory as the running file

If I have a Python file called example.py that says with open('%s/data.csv' % sys.path[0]) as var_name: and data.csv is in the same directory as example.py, it works fine if I run example.py from the terminal, but when using unittest it does not…
tscizzle
  • 11,191
  • 15
  • 54
  • 88
2
votes
3 answers

Remove brackets from argv string

I am new to Python. I'm running Raspbian and calling a Python script this way: python testarguments.py "Here is a test parameter" My script: import sys print sys.argv[1:] Output: ['Here is a test parameter'] Question: What is the most efficient…
JamieHoward
  • 693
  • 2
  • 11
  • 27