¡@

Home 

python Programming Glossary: unix

Python: What OS am I running on?

http://stackoverflow.com/questions/1854/python-what-os-am-i-running-on

on What do I need to look at to see if I'm on Windows Unix etc python share improve this question import os print..

Can I use Python as a bash replacement?

http://stackoverflow.com/questions/209470/can-i-use-python-as-a-bash-replacement

shell has several sets of features. The Essential Linux Unix commands. All of these are available through the subprocess..

Why do people write #!/usr/bin/env python on the first line of a Python script?

http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script

usr bin python or the like that's OK but less flexible. In Unix an executable file that's meant to be interpreted must indicate..

Python datetime to Unix timestamp

http://stackoverflow.com/questions/2775864/python-datetime-to-unix-timestamp

datetime to Unix timestamp I have to create an Expires value 5 minutes in the..

Permanently add a directory to PYTHONPATH

http://stackoverflow.com/questions/3402168/permanently-add-a-directory-to-pythonpath

by a colon from previous contents thereof. In any form of Unix you can do that in a startup script appropriate to whatever..

raw_input in python without pressing enter

http://stackoverflow.com/questions/3523174/raw-input-in-python-without-pressing-enter

to be pressed. etc see the docs I just pointed to . For Unix see e.g. this recipe for a simple way to build a similar getch..

How to reliably guess the encoding between MacRoman, CP1252, Latin1, UTF-8, and ASCII

http://stackoverflow.com/questions/4198804/how-to-reliably-guess-the-encoding-between-macroman-cp1252-latin1-utf-8-and

the 8 bit encodings. Because we ™re running in a mixed Unix environment Solaris Linux Darwin with most desktops being Macs.. it ™s in so long as it comes in full source runs on Unix and is fully unencumbered. Has anyone else had this problem..

Locking a file in Python

http://stackoverflow.com/questions/489861/locking-a-file-in-python

but most fail for my purposes as they are often only Unix based or Windows based. python file locking share improve..

Monitoring files/directories with python [duplicate]

http://stackoverflow.com/questions/597903/monitoring-files-directories-with-python

usung pywin32 and there are packages working on Linux Unix but does anyone know about a cross platform one python file.. filesystems monitoring share improve this question For Unix Linux based systems you should use File Alteration Monitor Python..

Correct way to write line to file in Python

http://stackoverflow.com/questions/6159900/correct-way-to-write-line-to-file-in-python

Regarding all those answers with n ...is this universal or Unix specific IE should I be doing r n on Windows python file io..

How do I duplicate sys.stdout to a log file in python?

http://stackoverflow.com/questions/616645/how-do-i-duplicate-sys-stdout-to-a-log-file-in-python

your code you could use tee itself. I don't know of any Unix system calls that do exactly what tee does. import subprocess..

Terminating a Python script

http://stackoverflow.com/questions/73663/terminating-a-python-script

specific exit codes but these are generally underdeveloped Unix programs generally use 2 for command line syntax errors and..

Is there a portable way to get the current username in Python?

http://stackoverflow.com/questions/842059/is-there-a-portable-way-to-get-the-current-username-in-python

import getpass getpass.getuser 'kostya' Availability Unix Windows p.s. Per comment below this function looks at the values..

Python - time.clock() vs. time.time() - accuracy?

http://stackoverflow.com/questions/85451/python-time-clock-vs-time-time-accuracy

this question According to the time module docs clock On Unix return the current processor time as a floating point number..

What is the reason for performing a double fork when creating a daemon?

http://stackoverflow.com/questions/881388/what-is-the-reason-for-performing-a-double-fork-when-creating-a-daemon

of these cases apply then one fork should be sufficient. Unix Network Programming Stevens has a good section on this. share..

Shared-memory objects in python multiprocessing

http://stackoverflow.com/questions/10721915/shared-memory-objects-in-python-multiprocessing

that uses copy on write fork semantics like any common unix then as long as you never alter your data structure it will..

What is the simplest way to SSH using Python?

http://stackoverflow.com/questions/1233655/what-is-the-simplest-way-to-ssh-using-python

not install anything on the remote server. python linux unix ssh share improve this question I haven't tried it but this..

fuzzy timestamp parsing with Python

http://stackoverflow.com/questions/1258712/fuzzy-timestamp-parsing-with-python

to interpret fuzzy timestamps like the date command in unix date d 2 minutes ago Tue Aug 11 16 24 05 EST 2009 The closest..

Showing the stack trace from a running Python application

http://stackoverflow.com/questions/132058/showing-the-stack-trace-from-a-running-python-application

irreproducable reasons. Its a bit hacky and only works on unix requires signals import code traceback signal def debug sig..

Django Static Files results in 404

http://stackoverflow.com/questions/14799835/django-static-files-results-in-404

use a absolute path to your static files ie. on a mac or unix system it should look something like this ' Users cupcake Documents..

Force Python to forego native sqlite3 and use the (installed) latest sqlite3 version

http://stackoverflow.com/questions/1545479/force-python-to-forego-native-sqlite3-and-use-the-installed-latest-sqlite3-ver

build pysqlite2 manually. The following recipe assumes a unix y system and the lastest version of pysqlite2 which as of this..

What is the best way to open a file for exclusive access in Python?

http://stackoverflow.com/questions/186202/what-is-the-best-way-to-open-a-file-for-exclusive-access-in-python

I don't think there is a fully crossplatform way. On unix the fcntl module will do this for you. However on windows which..

How to make a python, command-line program autocomplete arbitrary things NOT interpreter

http://stackoverflow.com/questions/187621/how-to-make-a-python-command-line-program-autocomplete-arbitrary-things-not-int

of python objects in the python interpreter on unix . Google shows many hits for explanations on how to do this... it to work on windows or mac just linux. python linux unix command line autocomplete share improve this question Use..

Python datetime to Unix timestamp

http://stackoverflow.com/questions/2775864/python-datetime-to-unix-timestamp

that does the timestamp conversion for me python datetime unix timestamp share improve this question Another way is to..

Print in terminal with colors using Python?

http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python

frommets remain. Continue bcolors.ENDC This will work on unix linux including macOS and window provided you enable ansi.sys..

Converting unix timestamp string to readable date in Python

http://stackoverflow.com/questions/3682748/converting-unix-timestamp-string-to-readable-date-in-python

unix timestamp string to readable date in Python I have a string.. to readable date in Python I have a string representing a unix timestamp i.e. 1284101485 in Python and I'd like to convert.. sequence not str Any help is appreciated python datetime unix timestamp strftime share improve this question Use datetime..

overload print python

http://stackoverflow.com/questions/550470/overload-print-python

you could just pipe your script through the the unix tee command. python yourscript.py tee output.txt will print..

How to check if there exists a process with a given pid?

http://stackoverflow.com/questions/568271/how-to-check-if-there-exists-a-process-with-a-given-pid

import os def check_pid pid Check For the existence of a unix pid. try os.kill pid 0 except OSError return False else return..

How do I run Selenium in Xvfb?

http://stackoverflow.com/questions/6183276/how-do-i-run-selenium-in-xvfb

I get this Error cannot open display 0 python linux gui unix selenium share improve this question open a terminal and..

Python multiprocessing: sharing a large read-only object between processes?

http://stackoverflow.com/questions/659865/python-multiprocessing-sharing-a-large-read-only-object-between-processes

shared memory as it would be if I spawned a process in unix c or does each process load its own copy of the big object Update..

How do you validate a URL with a regular expression in Python?

http://stackoverflow.com/questions/827557/how-do-you-validate-a-url-with-a-regular-expression-in-python

be www.somename.somedomain Do you want the path to look unix like Or windows like Do you want to remove the query string..

What is the reason for performing a double fork when creating a daemon?

http://stackoverflow.com/questions/881388/what-is-the-reason-for-performing-a-double-fork-when-creating-a-daemon

without the second fork What are the repercussions python unix share improve this question Looking at the code referenced..

How to do “hit any key” in python?

http://stackoverflow.com/questions/1394956/how-to-do-hit-any-key-in-python

try # Win32 from msvcrt import getch except ImportError # UNIX def getch import sys tty termios fd sys.stdin.fileno old termios.tcgetattr..

Differences between Framework and non-Framework builds of Python on Mac OS X

http://stackoverflow.com/questions/1444543/differences-between-framework-and-non-framework-builds-of-python-on-mac-os-x

a Framework build and a non Framework build i.e. standard UNIX build of Python on Mac OS X Also what are the advantages and..

Convert datetime fields in Chrome history file (sqlite) to readable format

http://stackoverflow.com/questions/2141537/convert-datetime-fields-in-chrome-history-file-sqlite-to-readable-format

3 history is kept in a sqlite file and stamps are in UNIX epoch time... getting them and converting to readable format..

Timeout function if it takes too long to finish

http://stackoverflow.com/questions/2281850/timeout-function-if-it-takes-too-long-to-finish

once that timer expires. Note that this will only work on UNIX. Here's an implementation that creates a decorator save the..

Python snippet to remove C and C++ comments

http://stackoverflow.com/questions/241327/python-snippet-to-remove-c-and-c-comments

question I don't know if you're familiar with sed the UNIX based but Windows available text parsing program but I've found..

Python datetime to Unix timestamp

http://stackoverflow.com/questions/2775864/python-datetime-to-unix-timestamp

value 5 minutes in the future but I have to supply it in UNIX Timestamp format. I have this so far but it seems like a hack... so far but it seems like a hack. def expires '''return a UNIX style timestamp representing 5 minutes from now''' epoch datetime.datetime..

Test if executable exists in Python?

http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python

i.e. which bin ls . This mimics the behavior of the UNIX 'which' command. Edit Updated to use os.path.isfile instead..

Which Python async library would be best suited for my code? Asyncore? Twisted?

http://stackoverflow.com/questions/4384360/which-python-async-library-would-be-best-suited-for-my-code-asyncore-twisted

into a library that can be connected via SSH or SSL or a UNIX socket or a pipe only by changing the one connectTCP listenTCP..

When to use os.name, sys.platform, or platform.system?

http://stackoverflow.com/questions/4553129/when-to-use-os-name-sys-platform-or-platform-system

platforms e.g. time.clock on Windows v.s. time.time on UNIX . My question is why 3 different ways of doing this When should..

What's the bad magic number error?

http://stackoverflow.com/questions/514371/whats-the-bad-magic-number-error

share improve this question The magic number comes from UNIX type systems where the first few bytes of a file held a marker.. them and let the interpreter re compile the py files. On UNIX type systems that could be something as simple as rm .pyc or..

How to get console window width in python

http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python

some shells export for that. This will probably work on UNIX only. def getTerminalSize import os env os.environ def ioctl_GWINSZ..

Run a program from python, and have it continue to run after the script is killed

http://stackoverflow.com/questions/6011235/run-a-program-from-python-and-have-it-continue-to-run-after-the-script-is-kille

a function that does the job def spawnDaemon func # do the UNIX double fork magic see Stevens' Advanced # Programming in the.. fork magic see Stevens' Advanced # Programming in the UNIX Environment for details ISBN 0201563177 try pid os.fork if pid..

Vim failing to compile with python on OS X

http://stackoverflow.com/questions/6490513/vim-failing-to-compile-with-python-on-os-x

#define PACKAGE_BUGREPORT #define PACKAGE_URL #define UNIX 1 #define STDC_HEADERS 1 #define HAVE_SYS_WAIT_H 1 #define FEAT_HUGE..

How would you implement a basic event-loop?

http://stackoverflow.com/questions/658403/how-would-you-implement-a-basic-event-loop

break What is a Waitable Well it's system dependant. On UNIX it's called a file descriptor and waitOnAll is the select system.. system call. The so called vector Waitable is a fd_set on UNIX and whatHappened is actually queried via FD_ISSET . The actual..

Get a list of installed Python modules

http://stackoverflow.com/questions/739993/get-a-list-of-installed-python-modules

list of Python modules which are in my Python installation UNIX server . How can you get a list of Python modules installed..