¡@

Home 

python Programming Glossary: file

How do I watch a file for changes using Python?

http://stackoverflow.com/questions/182197/how-do-i-watch-a-file-for-changes-using-python

do I watch a file for changes using Python I have a log file being written by.. do I watch a file for changes using Python I have a log file being written by another process which I want to watch for changes... sort of hook from the PyWin32 library. I've found the win32file.FindNextChangeNotification function but have no idea how to..

How do I protect Python code?

http://stackoverflow.com/questions/261638/how-do-i-protect-python-code

the usage of the software with a time restricted license file. If we distribute the .py files or even .pyc files it will be.. a time restricted license file. If we distribute the .py files or even .pyc files it will be easy to decompile and remove.. license file. If we distribute the .py files or even .pyc files it will be easy to decompile and remove the code that checks..

Import a module from a relative path

http://stackoverflow.com/questions/279237/import-a-module-from-a-relative-path

are real python packages do have the __init__.py file inside them here is a safe solution for inclusion of modules.. os.path.realpath os.path.abspath os.path.split inspect.getfile inspect.currentframe 0 if cmd_folder not in sys.path sys.path.insert.. os.path.abspath os.path.join os.path.split inspect.getfile inspect.currentframe 0 subfolder if cmd_subfolder not in sys.path..

Short Description of Python Scoping Rules

http://stackoverflow.com/questions/291978/short-description-of-python-scoping-rules

choices include the list above In the enclosing source file In the class namespace In the function definition In the for.. module . Names assigned at the top level of a module file or declared global in a def within the file. B. Built in Python.. of a module file or declared global in a def within the file. B. Built in Python . Names preassigned in the built in names..

What does `if __name__ == “__main__”:` do?

http://stackoverflow.com/questions/419163/what-does-if-name-main-do

answer... When the Python interpreter reads a source file it executes all of the code found in it. Before executing the.. the python interpreter is running that module the source file as the main program it sets the special __name__ variable to.. __name__ variable to have a value __main__ . If this file is being imported from another module __name__ will be set to..

How can you profile a Python script?

http://stackoverflow.com/questions/582336/how-can-you-profile-a-python-script

can you profile a Python script I've seen a quite a few questions on the Project.. euler share improve this question Python includes a profiler called cProfile. It not only gives the total running time but.. this question Python includes a profiler called cProfile. It not only gives the total running time but also times each..

How to do relative imports in Python?

http://stackoverflow.com/questions/72852/how-to-do-relative-imports-in-python

regardless of where the module is actually located on the file system. In Python 2.6 they're adding the ability to reference..

Class method differences in Python: bound, unbound and static

http://stackoverflow.com/questions/114214/class-method-differences-in-python-bound-unbound-and-static

Test a_test.method_two Traceback most recent call last File stdin line 1 in module TypeError method_two takes no arguments..

The meaning of a single- and a double-underscore before an object name in Python

http://stackoverflow.com/questions/1301346/the-meaning-of-a-single-and-a-double-underscore-before-an-object-name-in-python

print mc.__superprivate Traceback most recent call last File stdin line 1 in module AttributeError myClass instance has no..

Python - How do I pass a string into subprocess.Popen (using the stdin argument)?

http://stackoverflow.com/questions/163542/python-how-do-i-pass-a-string-into-subprocess-popen-using-the-stdin-argument

n' .communicate 0 I get Traceback most recent call last File stdin line 1 in File build toolchain mac32 python 2.4.3 lib.. I get Traceback most recent call last File stdin line 1 in File build toolchain mac32 python 2.4.3 lib python2.4 subprocess.py.. subprocess.py line 533 in __init__ p2cread p2cwrite File build toolchain mac32 python 2.4.3 lib python2.4 subprocess.py..

Evaluating a mathematical expression in a string

http://stackoverflow.com/questions/2371436/evaluating-a-mathematical-expression-in-a-string

the following error Traceback most recent call last File stdin line 1 in module ValueError invalid literal for int with..

Python UnicodeDecodeError - Am I misunderstanding encode?

http://stackoverflow.com/questions/368805/python-unicodedecodeerror-am-i-misunderstanding-encode

'latin 1' 'ignore' Traceback most recent call last File interactive input line 1 in UnicodeDecodeError 'ascii' codec..

Lazy Method for Reading Big File in Python?

http://stackoverflow.com/questions/519633/lazy-method-for-reading-big-file-in-python

Method for Reading Big File in Python I have a very big file 4GB and when I try to read..

TypeError: 'str' does not support the buffer interface

http://stackoverflow.com/questions/5471158/typeerror-str-does-not-support-the-buffer-interface

giving me following error Traceback most recent call last File C Users Ankur Gupta Desktop Python_works gzip_work1.py line.. gzip_work1.py line 33 in module compress_string File C Users Ankur Gupta Desktop Python_works gzip_work1.py line.. line 15 in compress_string f_out.write string File C Python32 lib gzip.py line 312 in write self.crc zlib.crc32..

Monitoring files/directories with python [duplicate]

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

question For Unix Linux based systems you should use File Alteration Monitor Python bindings to libfam . For Windows based..

Using MultipartPostHandler to POST form-data with Python

http://stackoverflow.com/questions/680305/using-multipartposthandler-to-post-form-data-with-python

print response.geturl except urllib2.URLError e print File upload failed... EDIT1 Thanks for your response. I'm aware of..

Why are Python's 'private' methods not actually private?

http://stackoverflow.com/questions/70528/why-are-pythons-private-methods-not-actually-private

obj.__myPrivateMethod Traceback most recent call last File line 1 in AttributeError MyClass instance has no attribute '__myPrivateMethod'.. obj.__myPrivateMethod Traceback most recent call last File line 1 in AttributeError MyClass instance has no attribute '__myPrivateMethod'..

Syntax error on print with Python 3

http://stackoverflow.com/questions/826948/syntax-error-on-print-with-python-3

credits or license for more information. print hello World File stdin line 1 print hello World ^ SyntaxError invalid syntax..

Making a flat list out of list of lists in Python [duplicate]

http://stackoverflow.com/questions/952914/making-a-flat-list-out-of-list-of-lists-in-python

x.extend y l Error message Traceback most recent call last File line 1 in File line 1 in AttributeError 'NoneType' object has.. message Traceback most recent call last File line 1 in File line 1 in AttributeError 'NoneType' object has no attribute..

Adding a Method to an Existing Object

http://stackoverflow.com/questions/972/adding-a-method-to-an-existing-object

barFighters a.barFighters Traceback most recent call last File stdin line 1 in module TypeError barFighters takes exactly 1.. affected a2.barFighters Traceback most recent call last File stdin line 1 in module AttributeError A instance has no attribute..

Command Line Arguments In Python

http://stackoverflow.com/questions/1009860/command-line-arguments-in-python

f file dest filename help write report to FILE metavar FILE parser.add_option q quiet action store_false dest.. f file dest filename help write report to FILE metavar FILE parser.add_option q quiet action store_false dest verbose default..

Parsing large (20GB) text file with python - reading in 2 lines as 1

http://stackoverflow.com/questions/10220862/parsing-large-20gb-text-file-with-python-reading-in-2-lines-as-1

easy to reproduce because it depends both on the internal FILE buffer size and the number of chars passed to fread . In the..

Mixing read() and write() on Python files in Windows

http://stackoverflow.com/questions/14279658/mixing-read-and-write-on-python-files-in-windows

would behave #include cstdio int main char buffer 5 0 FILE fp fopen D Temp test1.txt rb fread buffer sizeof char 4 fp printf..

Detect and alter strings in PDFs

http://stackoverflow.com/questions/19414763/detect-and-alter-strings-in-pdfs

and defined file and defined csv or die nUsage perl 0 f FILE p LIST c w n n t f t tFILE t PDF file to annotate n t p t tLIST.. csv or die nUsage perl 0 f FILE p LIST c w n n t f t tFILE t PDF file to annotate n t p t tLIST t comma separated patterns..

Which is best in Python: urllib2, PycURL or mechanize?

http://stackoverflow.com/questions/2385855/which-is-best-in-python-urllib2-pycurl-or-mechanize

curl does FTP FTPS HTTP HTTPS GOPHER TELNET DICT FILE and LDAP bad news not updated since Sep 9 2008 7.19.0 New possibilities..

Python and csv help

http://stackoverflow.com/questions/2930673/python-and-csv-help

row #SEARCH ON HOSTNAME AND RETURN UID #REPLACE VALUE IN FILE WITH UID #import fileinput #for line in fileinput.FileInput..

Debugging (displaying) SQL command sent to the db by SQLAlchemy

http://stackoverflow.com/questions/2950385/debugging-displaying-sql-command-sent-to-the-db-by-sqlalchemy

commands parser.add_option l logfile dest logfile metavar FILE help log to FILE. if not set no logging will be done parser.add_option.. l logfile dest logfile metavar FILE help log to FILE. if not set no logging will be done parser.add_option level..

How can I “watch” a file for modification / change?

http://stackoverflow.com/questions/3274334/how-can-i-watch-a-file-for-modification-change

notifier pyinotify.Notifier wm handler wdd wm.add_watch FILE pyinotify.IN_CLOSE_WRITE notifier.loop This is more efficient..

How to implement a minimal server for AJAX in Python?

http://stackoverflow.com/questions/336866/how-to-implement-a-minimal-server-for-ajax-in-python

webbrowser import BaseHTTPServer import SimpleHTTPServer FILE 'frontend.html' PORT 8080 class TestHandler SimpleHTTPServer.SimpleHTTPRequestHandler.. _open_browser webbrowser.open 'http localhost s s' PORT FILE thread threading.Timer 0.5 _open_browser thread.start def start_server.. webbrowser from wsgiref.simple_server import make_server FILE 'frontend.html' PORT 8080 def test_app environ start_response..

How do I run a python file that is read into a std::string using PyRun

http://stackoverflow.com/questions/4028681/how-do-i-run-a-python-file-that-is-read-into-a-stdstring-using-pyrun

python_script H CRAW craw script craw.py content.c_str FILE fp fp fopen H CRAW craw script craw.py r PyRun_SimpleFileEx..

Python code genration with pyside-uic

http://stackoverflow.com/questions/4442286/python-code-genration-with-pyside-uic

number and exit h help show this help message and exit oFILE output FILE write generated code to FILE instead of stdout x.. exit h help show this help message and exit oFILE output FILE write generated code to FILE instead of stdout x execute generate.. message and exit oFILE output FILE write generated code to FILE instead of stdout x execute generate extra code to test and..

Understanding A Chain of Imports in Python

http://stackoverflow.com/questions/5226893/understanding-a-chain-of-imports-in-python

def write text print text src pack _ init _.py EMPTY FILE When I run python pack.py from the src pack directory it works..

How do I copy a file to a remote server in python using scp or ssh?

http://stackoverflow.com/questions/68335/how-do-i-copy-a-file-to-a-remote-server-in-python-using-scp-or-ssh

it's flushed to disk from Python. import os os.system scp FILE USER@SERVER PATH #e.g. os.system scp foo.bar joe@srvr.net path..

Why is reading lines from stdin much slower in C++ than Python?

http://stackoverflow.com/questions/9371238/why-is-reading-lines-from-stdin-much-slower-in-c-than-python

are typically relatively expensive. However since the FILE based stdio and iostreams often have separate implementations..