Re: binary file compare...

2009-04-17 Thread SpreadTooThin
On Apr 17, 4:54 am, Nigel Rantor wrote: > Adam Olsen wrote: > > On Apr 16, 11:15 am, SpreadTooThin wrote: > >> And yes he is right CRCs hashing all have a probability of saying that > >> the files are identical when in fact they are not. > > > Here'

Re: binary file compare...

2009-04-16 Thread SpreadTooThin
On Apr 16, 3:16 am, Nigel Rantor wrote: > Adam Olsen wrote: > > On Apr 15, 12:56 pm, Nigel Rantor wrote: > >> Adam Olsen wrote: > >>> The chance of *accidentally* producing a collision, although > >>> technically possible, is so extraordinarily rare that it's completely > >>> overshadowed by the

Re: binary file compare...

2009-04-15 Thread SpreadTooThin
On Apr 15, 8:04 am, Grant Edwards wrote: > On 2009-04-15, Martin wrote: > > > > > Hi, > > > On Mon, Apr 13, 2009 at 10:03 PM, Grant Edwards wrote: > >> On 2009-04-13, SpreadTooThin wrote: > > >>> I want to compare two binary files and se

binary file compare...

2009-04-14 Thread SpreadTooThin
I want to compare two binary files and see if they are the same. I see the filecmp.cmp function but I don't get a warm fuzzy feeling that it is doing a byte by byte comparison of two files to see if they are they same. What should I be using if not filecmp.cmp? -- http://mail.python.org/mailman/li

Re: binary file compare...

2009-04-13 Thread SpreadTooThin
On Apr 13, 2:37 pm, Grant Edwards wrote: > On 2009-04-13, Grant Edwards wrote: > > > > > On 2009-04-13, SpreadTooThin wrote: > > >> I want to compare two binary files and see if they are the same. > >> I see the filecmp.cmp function but I don't get

Re: binary file compare...

2009-04-13 Thread SpreadTooThin
On Apr 13, 2:03 pm, Grant Edwards wrote: > On 2009-04-13, SpreadTooThin wrote: > > > I want to compare two binary files and see if they are the same. > > I see the filecmp.cmp function but I don't get a warm fuzzy feeling > > that it is doing a byte by byte compariso

Re: binary file compare...

2009-04-13 Thread SpreadTooThin
On Apr 13, 2:00 pm, Przemyslaw Kaminski wrote: > SpreadTooThin wrote: > > I want to compare two binary files and see if they are the same. > > I see the filecmp.cmp function but I don't get a warm fuzzy feeling > > that it is doing a byte by byte comparison of two fi

Convert to C/C++?

2007-06-14 Thread SpreadTooThin
I am wondering if someone who knows the implemention of python's time could help converting this to c/c++ nanoseconds = int(time.time() * 1e9) # 0x01b21dd213814000 is the number of 100-ns intervals between the # UUID epoch 1582-10-15 00:00:00 an

Re: scared about refrences...

2006-11-02 Thread SpreadTooThin
Bruno Desthuilliers wrote: > SpreadTooThin a écrit : > > Bruno Desthuilliers wrote: > > > >>Nick Vatamaniuc a écrit : > >>(snip) > >> > >>>In Python all the primitives are copied and all other entities are > >>>references. > &

Re: scared about refrences...

2006-11-01 Thread SpreadTooThin
Bruno Desthuilliers wrote: > Nick Vatamaniuc a écrit : > (snip) > > In Python all the primitives are copied and all other entities are > > references. > > Plain wrong. There's no "primitives" (ie : primitive data types) in > Python, only objects. And they all get passed the same way. so.. def fn

Re: scared about refrences...

2006-10-31 Thread SpreadTooThin
J. Clifford Dyer wrote: > SpreadTooThin wrote: > > J. Clifford Dyer wrote: > >> SpreadTooThin wrote: > >>> Steven D'Aprano wrote: > >>>> On Mon, 30 Oct 2006 13:10:47 -0800, SpreadTooThin wrote: > >>>> > >>>> > &g

Re: scared about refrences...

2006-10-30 Thread SpreadTooThin
J. Clifford Dyer wrote: > SpreadTooThin wrote: > > Steven D'Aprano wrote: > >> On Mon, 30 Oct 2006 13:10:47 -0800, SpreadTooThin wrote: > >> > >>>>> How do I specify or create deep copies of objects that may contain > >>>>>

Re: scared about refrences...

2006-10-30 Thread SpreadTooThin
Steven D'Aprano wrote: > On Mon, 30 Oct 2006 13:10:47 -0800, SpreadTooThin wrote: > > >> > How do I specify or create deep copies of objects that may contain > >> > other objects that may contain other object that may contain other > >> > objects

Re: scared about refrences...

2006-10-30 Thread SpreadTooThin
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, SpreadTooThin > wrote: > > > I'm really worried that python may is doing some things I wasn't > > expecting... but lets see... > > Expect that Python never copies something if don'

Re: scared about refrences...

2006-10-30 Thread SpreadTooThin
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, SpreadTooThin > wrote: > > > I'm really worried that python may is doing some things I wasn't > > expecting... but lets see... > > Expect that Python never copies something if don'

scared about refrences...

2006-10-30 Thread SpreadTooThin
I'm really worried that python may is doing some things I wasn't expecting... but lets see... if I pass a list to a function def fn(myList): and in that function I modify an element in the list, then does the callers list get modied as well. def fn(list): list[1] = 0 myList = [1, 2, 3] print

Re: mean ans std dev of an array?

2006-10-24 Thread SpreadTooThin
Paul Rubin wrote: > "SpreadTooThin" <[EMAIL PROTECTED]> writes: > > print a.mean() > > print a.std_dev() > > > > Is there a way to calculate the mean and standard deviation on array data? > > Well, you could use numpy or whatever. If you want to

mean ans std dev of an array?

2006-10-23 Thread SpreadTooThin
import array a = array.array('f', [1,2,3]) print a.mean() print a.std_dev() Is there a way to calculate the mean and standard deviation on array data? Do I need to import it into a Numeric Array to do this? -- http://mail.python.org/mailman/listinfo/python-list

Komodo

2006-10-19 Thread SpreadTooThin
Why is it that (On MAC OS X) in Komodo 3.5 Professional, if I try to find something in my script, I am unable to change the text it is searching for? -- http://mail.python.org/mailman/listinfo/python-list

loop iterators?

2006-10-17 Thread SpreadTooThin
Hi I need to get a for loop to give me an element from a list and an index number... for example: i = 0 l = ['a','b','c'] for e in l: print l, i i = i + 1 Is there a way to get rid of the i processing in this script? Sorry I'm still trying to learn python tricks here... -- http://mail.pyt

making a valid file name...

2006-10-17 Thread SpreadTooThin
Hi I'm writing a python script that creates directories from user input. Sometimes the user inputs characters that aren't valid characters for a file or directory name. Here are the characters that I consider to be valid characters... valid = ':./,^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM

Re: Need a strange sort method...

2006-10-16 Thread SpreadTooThin
Tim Chase wrote: > > for example: > > a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order > > > > def cmp(i,j): #to be defined in this thread. > > Well, if you're willing to give up doing it in a cmp() method, > you can do it as such: > > >>> a.sort() > >>> chunk_size = 3 > >>> [a[i:

Re: Need a strange sort method...

2006-10-16 Thread SpreadTooThin
SpreadTooThin wrote: > Simon Brunning wrote: > > On 10/16/06, Simon Brunning <[EMAIL PROTECTED]> wrote: > > > >>> a = [1,2,3,4,5,6,7,8,9,10] > > > >>> a.sort(key=lambda item: (((item-1) %3), item)) > > > >>> a > > > [1,

Re: Need a strange sort method...

2006-10-16 Thread SpreadTooThin
Simon Brunning wrote: > On 10/16/06, Simon Brunning <[EMAIL PROTECTED]> wrote: > > >>> a = [1,2,3,4,5,6,7,8,9,10] > > >>> a.sort(key=lambda item: (((item-1) %3), item)) > > >>> a > > [1, 4, 7, 10, 2, 5, 8, 3, 6, 9] > > Re-reading the OP's post, perhaps sorting isn't what's required: > > >>> a[::3]

Re: Need a strange sort method...

2006-10-16 Thread SpreadTooThin
Fredrik Lundh wrote: > SpreadTooThin wrote: > > > I have a list and I need to do a custom sort on it... > > > Its more like > > 1 4 7 10 > > 2 5 8 > > 3 6 9 > > that's trivial to do with slicing, of course. what makes you think you > need to

Need a strange sort method...

2006-10-16 Thread SpreadTooThin
I have a list and I need to do a custom sort on it... for example: a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order def cmp(i,j): #to be defined in this thread. a.sort(cmp) print a [1,4,7,10, 2,5,8, 3,6,9] So withouth making this into an IQ test. Its more like 1 4 7 10 2 5 8 3 6

Re: operator overloading + - / * = etc...

2006-10-08 Thread SpreadTooThin
Daniel Nogradi wrote: > > Can these operators be overloaded? > > If so. How? > > > > http://www.python.org/doc/ref/numeric-types.html > > HTH, > Daniel Thanks everyone. -- http://mail.python.org/mailman/listinfo/python-list

operator overloading + - / * = etc...

2006-10-07 Thread SpreadTooThin
Can these operators be overloaded? If so. How? -- http://mail.python.org/mailman/listinfo/python-list

class print?

2006-10-07 Thread SpreadTooThin
Hi... Many python object can be printed simpy by saying: print obj what method(s) need to be implemented in my own classes such that print dumps the object? -- http://mail.python.org/mailman/listinfo/python-list

Re: socket client server... simple example... not working...

2006-10-05 Thread SpreadTooThin
Jean-Paul Calderone wrote: > On 5 Oct 2006 07:01:50 -0700, SpreadTooThin <[EMAIL PROTECTED]> wrote: > > [snip] > > > >Jean-Paul many thanks for this and your effort. > >but why is it every time I try to do something with 'stock' python I > >nee

Re: socket client server... simple example... not working...

2006-10-05 Thread SpreadTooThin
Jean-Paul Calderone wrote: > On 4 Oct 2006 19:31:38 -0700, SpreadTooThin <[EMAIL PROTECTED]> wrote: > >client: > > > >import socket > >s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > >s.connect(("192.168.1.101", 8080)) > >print 

socket client server... simple example... not working...

2006-10-04 Thread SpreadTooThin
client: import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("192.168.1.101", 8080)) print 'Connected' s.send('ABCD') buffer = s.recv(4) print buffer s.send('exit') server: serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serversocket.bind(("192.168.1.1

Re: Need help with syntax on inheritance.

2006-10-04 Thread SpreadTooThin
Peter Otten wrote: > SpreadTooThin wrote: > > > If you are deriving a new class from another class, > > that you must (I assume) know the initializer of the other class. > > > > So in myClass > > > > import array > > class myClass(arrary.array):

Need help with syntax on inheritance.

2006-10-03 Thread SpreadTooThin
If you are deriving a new class from another class, that you must (I assume) know the initializer of the other class. So in myClass import array class myClass(arrary.array): def __init__(self, now here I need to put array's constructor parameters..., then mine): array.array.__init__(self

Re: array tofile fromfile tosocket? fromsocket?

2006-10-03 Thread SpreadTooThin
Thomas Jollans wrote: > On Tue, 03 Oct 2006 10:29:00 -0700, "SpreadTooThin" <[EMAIL PROTECTED]> > let this slip: > > > I was under the impression that a file and socket were interchangable > > (like a file descriptor). Does anyone have an idea that might

array tofile fromfile tosocket? fromsocket?

2006-10-03 Thread SpreadTooThin
Hi I am using arrays in an application. They have been working very well for me as I have been using them for reading and writing data to and from files whose endianisms can be big or little endian. However now I need handle data that can be transferred over a socket. I would rather not have to go

Re: Need help with an array problem.

2006-10-02 Thread SpreadTooThin
Robert Kern wrote: > [EMAIL PROTECTED] wrote: > > To your question on casting long to short. This is how: > > a=1234L # long > > b=int(a) # int (short) > > No, a Python int is a C long. A Python long is an arbitrary-precision number > and > does not correspond to any C type. > > -- So

Need help with an array problem.

2006-10-02 Thread SpreadTooThin
Basically I think the problem is in converting from a 32 bit integer to a 16 bit integer. I have two arrays: import array a = array.array('L', [65537]) b = array.array('H', [0]) b[0] = a[0] Which gives an overflow message So can't I truncate the long by discaring the upper bits .. Like b[0

how do you know if open failed?

2006-09-28 Thread SpreadTooThin
f = open('myfile.bin', 'rb') How do I know if there was an error opening my file? -- http://mail.python.org/mailman/listinfo/python-list

How do I define a global constant...

2006-09-20 Thread SpreadTooThin
How do I define a constant that I can use in my script... For example lets say I have a file called constants.py and in there I have PI = 3.14 in my test script I do: from constants import * How do I access PI later on? Pardon my newbie questions... -- http://mail.python.org/mailman/listinfo

get process id...

2006-09-20 Thread SpreadTooThin
How does one get the process id? Is there a method for windows and unix (mac os x etc...) -- http://mail.python.org/mailman/listinfo/python-list

Re: how do you convert and array of doubles into floats?

2006-09-15 Thread SpreadTooThin
Tim Peters wrote: > [Marc 'BlackJack' Rintsch] > >> What about: > >> > >> b = array.array('f', a) > > [Diez B. Roggisch] > > AFAIK d and f are synonym for arrays, as python doesn't distinguish > > between these two on a type-level. And double it is in the end. > > While Python has no type of its o

how do you convert and array of doubles into floats?

2006-09-15 Thread SpreadTooThin
I have some code... import array a = array.array('d') f = open('file.raw') a.fromfile(f, 10) now I need to convert them into floats (32 bit...) what do i do? -- http://mail.python.org/mailman/listinfo/python-list