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
3
votes
1 answer

How can I print the rows of a 2D-array in one line?

I need to print a 2D array like [[A,B],[C,D]] like A B C D. I've seen lots of ways to print a 1D array using ''.join() but nothing for 2d arrays. How can I do this?
Demetri Pananos
  • 6,770
  • 9
  • 42
  • 73
3
votes
2 answers

sys.exitfunc not working in python

I am trying to run following simple code import sys print("Starting Test Python Module"); def testmethod(): print("From test method") sys.exitfunc = testmethod print("Terminating Test Python Module"); and it…
Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289
3
votes
0 answers

Pass arabic parameter to python script from c#

I want to pass Arabic string to python script from c#. And then I will write output to txt file. But my arabic string parameter couldn't pass correctly. It transforms to "????" question marks. I tried some code, like unicode, but it doesn't work if…
jakobiyem
  • 107
  • 1
  • 5
  • 15
3
votes
2 answers

Is __subclasses__() cached?

I have three models in three different files. The modules are all in sys.path a.py: class A(object): pass b.py: class B(A): passs c.py: class C(A): pass Now I want to get the subclasses of A: print A.__subclasses__() >> [
ilse2005
  • 11,189
  • 5
  • 51
  • 75
3
votes
1 answer

Sys.stdout.write not working as expected

I've got a test script that iterates through two string arrays, and I want to use sys.stdout.write to provide the user a simple 'progress bar'. My current script: import sys from time import sleep names = ['Serv1', 'Serv2', 'Serv3', 'Serv4',…
Luke Willmer
  • 327
  • 2
  • 6
  • 14
3
votes
3 answers

Why is this the output of this python program?

Someone from #python suggested that it's searching for module "herpaderp" and finding all the ones listed as its searching. If this is the case, why doesn't it list every module on my system before raising ImportError? Can someone shed some light…
amoffat
  • 696
  • 4
  • 12
3
votes
1 answer

Overwrite printed line in python 3.x on mac

I'm attempting to write a program that involves the use of a coin flip, heads or tails, but so that it will print 'heads' then be replaced by 'tails' and continue doing this until it decides on an answer. At the moment, when I run the program, it…
revolve
  • 33
  • 3
3
votes
1 answer

python sys.path implementation

today, I checked how sys.path got implemented by python. i found it points to sys.pi file(python 2.7.8 in windows). see code argv = [] __stdout__ = file(__file__) __name__ = 'sysoverride' __stderr__ = file(__file__) dllhandle = 0 exitfunc =…
cppython
  • 1,209
  • 3
  • 20
  • 30
3
votes
1 answer

How to extract a file within a folder within a zip?

I need to extract a file called Preview.pdf from a folder called QuickLooks inside of a zip file. Right now my code looks a little like this: with ZipFile(newName, 'r') as newName: newName.extract(\QuickLooks\Preview.pdf) …
evamvid
  • 831
  • 6
  • 18
  • 40
3
votes
1 answer

Recursion in python, python crashes everytime it is run

I am trying to write a program that uses recursion to solve for the velocity of an object shot straight into the air and calculates when it hits the ground while accounting for gravity changing with altitude with this equation g(s) = G∙ME / (RE +…
user3282276
  • 3,674
  • 8
  • 32
  • 48
3
votes
2 answers

How to add modules from a custom repository that isn't a package? python

I have tried to use sys.path.append() with os.getcwd() but it didn't work. The source was from here and I've downloaded and extracted them as such: alvas@ubi:~/test$ wget https://github.com/alvations/DLTK/archive/master.zip alvas@ubi:~/test$ tar…
alvas
  • 115,346
  • 109
  • 446
  • 738
3
votes
3 answers

Confused about an if statement in Learn Python the Hard Way ex41?

I've been working through Learn Python the Hard Way, and I'm having trouble understanding what's happening in this part of the code from Example 41 (full code at http://learnpythonthehardway.org/book/ex41.html). PHRASE_FIRST = False if len(sys.argv)…
Rachel
  • 113
  • 2
  • 6
3
votes
2 answers

File descriptors redirecting is stuck

In the daemon class example, which I implement, is used descriptors redirecting. sys.stdout.flush() sys.stderr.flush() si = file(self.stdin, 'r') so = file(self.stdout, 'a+') …
I159
  • 29,741
  • 31
  • 97
  • 132
2
votes
1 answer

Cannot locate find function called in a procedure

I am quite new to SQL Server. I have an issue where we have a stored procedure called sys.sp_MSallocate_new_identity_range (see part of logic below). It makes reference to two functions neither of which I can locate. if…
2
votes
1 answer

sys.exc_info or sys.last_*?

Should I prefer sys.exc_info() over sys.last_value and friends (sys.last_type, sys.last_traceback)?
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526