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
1
vote
3 answers

How to properly patch sys.argv using mock patch in python unit test

I have a file seed_dynamodb.py whose code is below. I want to write a unit test for it using mock patch. I am successfully able to patch boto3. Now I need to patch sys.argv as well. I have tried with below test code but it is giving an…
Deepak Gupta
  • 387
  • 2
  • 17
1
vote
0 answers

When the input is changed from integers to text, json_encode doesn't work

I am trying to get some data in a php file to a python file in the JSON format. Right now everything works like it's supposed to when I use an array of integers, but when I change the array to an array of strings (uncommenting line 3 below and…
Shahroz
  • 11
  • 3
1
vote
1 answer

How can i create a stop button to stop my running python code

Problem - I have a Python function that reads values from an Excel sheet, performs some calculations, and writes back the data to the Excel sheet. Let's say this entire function takes 1 minute to complete. Now, I have converted my Python file to an…
Akash
  • 11
  • 3
1
vote
1 answer

How works with sys.stdin.readline() without open?

I'm trying to resolve an exercise in python. It has an platform with some pre-code part and I have to enter some code to complete. But usually, I like to try the code in VS Code as well, to understand a little more about the problem. In this case,…
Pedro Lobo
  • 11
  • 1
1
vote
2 answers

sys.path.append which main.py will be imported

If I have a project with two files main.py and main2.py. In main2.py I do import sys; sys.path.append(path), and I do import main, which main.py will be imported? The one in my project or the one in path (the question poses itself only if there are…
1
vote
1 answer

Pycharm does not show output in console, but displays "import sys; print('Python %s on %s' % (sys.version, sys.platform))"

When I am running a Python program file, Pycharm does not show the program output. Instead each time the following message appears in the screen: C:\Data\Courses\Udemy\Triangular_Arbitrage\LexPythonScripts\Poloniex\venv\Scripts\python.exe…
1
vote
1 answer

how to make playwright to type in each character in a variable in to a search bar

there is a website (company website - cant share login) which has a search box containing locations i was using fill to type in a randomly selected location from a dictionary playwright fill in the entire location all at once --- but the website…
noob
  • 33
  • 6
1
vote
1 answer

serial in sys.version_info of python

The sys.version_info output is ('major', 'minor', 'micro', 'releaselevel', 'serial'). I find that most of the explanations of this function outputs serial=0. I really don't understand what is this 'serial'? What does it mean? Why is it always 0?
liaoming999
  • 769
  • 8
  • 14
1
vote
2 answers

Python script not executed with docker compose

I have got the following Docker file FROM jupyter/scipy-notebook COPY . ./work RUN pip install -r ./work/requirements.txt WORKDIR /work CMD ["python", "./work/append_dependencies.py"] and the following docker-compose.yml version:…
JohnK
  • 45
  • 7
1
vote
2 answers

Stop current pytest execution but continue to run other cases

I am running tests using pytest on python. In the tested code, some conditions trigger a sys.exit(non_zero_code), using pytest, we want to make sure that sys.exit is called under those conditions, but obviously we do not want the system to really…
Milan
  • 1,547
  • 1
  • 24
  • 47
1
vote
0 answers

How do I avoid creating multiple python process w/ os.system?

When the 2 consecutive if statements executes, my python program shuts down. But that's not what I want. I want it to loop again and not exit the script. The problem that I found with simply looping is that python processes are created every time…
c0nfluks
  • 53
  • 5
1
vote
1 answer

How to simulate an enter key press in python code?

I am building a math game similar to Zeta Mac and have nearly everything working perfectly. The only thing that I would like to change is for the next problem to show up right after the user inputs the correct answer, instead of them needing to…
SDC123
  • 45
  • 6
1
vote
0 answers

Python AttributeError: module 'cv2' has no attribute 'cv'

I am trying to create a face detection model using OpenCV, Python. This is the code: import cv2 import sys # Get user supplied values imagePath = "elon_musk.jpg" cascPath = "haarcascade_frontalface_default.xml" # Create the haar…
John Mathew
  • 11
  • 1
  • 1
1
vote
0 answers

There is an announcement button but it shows undefined

I created a page for playing videos, there is a button to play videos, and there is a button to switch the screen, There is also a video playback button on the second page, But the problem is if the play key of the second page is empty (I will…
1
vote
1 answer

Import multi-nested subfolders in python neatly

I have the following directory structure: . ├── main.py └── subfolder1 ├── file1.py # def hello(): print("hello") ├── __init__.py └── subfolder2 ├── file2.py # def world(): print("world") └── __init__.py I'm trying to…
Michael Moreno
  • 947
  • 1
  • 7
  • 24