How to detect whether two files are identical in Python
Is making system call to "md5sum file1" and "md5sum file2" and compare two return values enough in this case? ...
Is making system call to "md5sum file1" and "md5sum file2" and compare two return values enough in this case? ...
Hello, I've got a simple class that I am pickling(dumping) to a file. On OS X this works fine, and on Windows this works fine. However, while on windows I can load/unpickle the object fine - when windows then pickles this file and saves it back to disk, it becomes unreadable on OS X (although in Windows it still behaves as normal). Th...
I'm trying to create a two-way communication channel between two programs (one in Python and another in C#) When I create a named pipe between two C# programs or two Python programs, everything is OK, but when I try to (for example) connect to the C# server from Python code, it does not work: C# code: NamedPipeServerStream server = ne...
i try to setup a ubuntu server with web service that create by django/python , anyone have an resource/tutorial/example code ...
Hi Alls, I'd like to remove one char from a string like this: string = "ASDFVGHFJHRSFDZFDJKUYTRDSEADFDHDS" print len(string) (33) So i would like to remove one random char in this string, and then have a len = 32 What's the best way to do so ? EDIT: thanks for your answers, but i forgot something: i'd like to print the char remove...
I am trying to work on a Python library that is already installed on my (Ubuntu) system. I checked out that library, edited some files, and wrote a small script to test my changes. Even though I put my script in the same folder as that of the library, it seems Python is using the installed version instead (the one in /usr/share/pyshared/...
Given a text-string of unknown source, how does one best rewrite it to have a known lineend-convention? I usually do: lines = text.splitlines() text = '\n'.join(lines) ... but this doesn't handle "mixed" text-files of utterly confused conventions (Yes, they still exist!). Edit The oneliner of what I'm doing is of course: '\n'.join...
I try to log all the output of a program written in Python and C. However, printing from Python causes IOError: [Errno 9] Bad file descriptor Please, does anyone know what the problem is and how to fix it? PS: It's on Windows XP, Python 2.6 and MinGW GCC #include <windows.h> #include <fcntl.h> #include "Python.h" int main() { int...
I have a script that creates a folder called "videos" on a USB drive, moves 6,500 WMV files over to the "videos" folder. Then it's suppose to create an HTML page with hyperlinks to each file. Here is my current example that's broken. I'm trying to have it crawl the videos directory and create an HTML page with hyperlinks only to the loca...
What experiences do you have with Stackless Python and PyQt? Issues i would be happy if people address: Compilation of PyQt for Stackless: does PyQt need to be compiled especially for Stackless? is the compilation smooth? problems with bindings etc. Stability: any unexpected crashes, freezes, pauses and other weirdities? Memory Manage...
Hi Everyones, I would like to remove one null byte in a string, and sometime replace it with another char. Like that : string = "41 00 36 00 36 00 00 00 57 00 46 00 42 00 41 00 61 00 62 00 73 00 20 00 36 00" i was thinking about using random and replace, but replace always start by the first one: replace("00","B",1) So it's not ran...
The python statvfs module is marked as deprecated, but I haven't been able to figure out what new apps are supposed to use if they want to get information about a disk, specifically how to check the capacity and free space of a given path. Anybody have any idea? This is on os x, if that makes a difference, although being cross platform w...
I'm trying to upload an MSI binary distribution of my project to the cheeseshop. I'm doing setup.py bdist_msi register upload. It builds the project and the setup script finishes, but then I get: error: garlicsim-0.1: No such file or directory And no .msi file is uploaded to PyPi. Any clue? ...
I'm trying to upload my package to PyPI. It asks me to identify, I do, it gives an OK response (which doesn't happen unless the identification is right), but then it claims I didn't identify! Why? [...] removing 'build\bdist.win32\egg' (and everything under it) running register We need to know who you are, so please choose either: 1. u...
I am in a position where relatively low resolution images are provided (via an API, higher resolution images are not available) and high resolution images need to be generated. I've taken a look at PIL and it's just great for about everything... Except scaling up images. It has the common resizing algorithms: Nearest Neighbor Bilinea...
There's a 1 Gigabyte string of arbitrary data which you can assume to be equivalent to something like: 1_gb_string=os.urandom(1*gigabyte) We will be searching this string, 1_gb_string, for an infinite number of fixed width, 1 kilobyte patterns, 1_kb_pattern. Every time we search the pattern will be different. So caching opportunities ...
I am trying to implement a wrapper/proxy class for a java object (baseClient) in jython v2.1. Everything seems to be working ok except when the following statement is encountered: if __client != None # __client is an instance of the ClientProxy class raise AttributeError(attr) is called in __getattr__(), because self.__baseClient does...
Hi, I wonder if we can do that in python, let's suppose we have 3 differents functions to processing datas like this: def main(): def process(data): ..... def process1(data): ..... def process2(data): ..... def run(): test = choice([process,process1,process2]) test(data) run() main() Can we choice...
so.. let's say i have this C function: PyObject* Foo(PyObject* pSelf, PyObject* pArgs) { MessageBox(NULL, "Foo was called!", "Info", MB_OK); return PyInt_FromLong(0); } and then, I have to do this: static PyMethodDef Methods[] = { {"Foo", Foo, METH_NOARGS, "Dummy function"}, {NULL, NULL, 0, NULL} }; Py_InitModule("ba...
I want to write python script that acts as a time calculator. For example: Suppose the time is now 13:05:00 I want to add 1 hour, 23 minutes, and 10 seconds to it. and I want to print the answer out. How do I do this in Python? What if date is also involved? ...