Re: netCDF4 variable manipulation

2012-02-21 Thread Sheldon
On Feb 21, 12:53 am, Steven D'Aprano wrote: > On Mon, 20 Feb 2012 12:37:22 -0800, Sheldon wrote: > > Hi, > > > I'm trying to read a netCDF4 variable from a file (no problem) and then > > scale it before writing over the original variable in the file. > &g

netCDF4 variable manipulation

2012-02-20 Thread Sheldon
Hi, I'm trying to read a netCDF4 variable from a file (no problem) and then scale it before writing over the original variable in the file. I'm using python 2.7 and the latest netCDF4 module. It's not that I keep getting an error message but I want to do this without using for loops and all the m

RE: Password prompt with mask

2008-08-05 Thread Neuberger, Sheldon N.
> Could I write my own if one does not exist? Take a look at the getpass.py module. It's very short. The windows version of the getpass function can be trivially modified to echo something. The unix version is just as short but a bit more complicated. def win_getpass(prompt='Password: ', stream=N

ntlm authentication

2008-07-21 Thread Neuberger, Sheldon N.
Is there any way to make urllib2 handle NTLM authentication? Sheldon Neuberger -- http://mail.python.org/mailman/listinfo/python-list

RE: Writing a program under GNU/Linux for MS Windows.

2008-07-18 Thread Neuberger, Sheldon N.
If you're just writing Python code then it will run unmodified on his Windows machine. Are you planning on using other languages too? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Levi Campbell Sent: Friday, July 18, 2008 4:27 PM To: python-list@python.

urllib2 http authentication/redirection/cookie issue

2008-07-14 Thread Neuberger, Sheldon N.
get an HTTP 401 exception. Any help would be much appreciated. Code and traceback follows. Regards, Sheldon Neuberger -- cj = cookielib.LWPCookieJar() cookie_handler = urllib2.HTTPCookieProcessor(cj) passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm() passmgr.add_password

Re: PyType_IsSubtype ()

2007-01-05 Thread Sheldon
Martin v. Löwis skrev: > Sheldon schrieb: > > Can anyone tell me what this error mean: > > #0 0x4008376e in PyType_IsSubtype () from /usr/lib/libpython2.3.so.1.0 > > It's not an error. It is just a frame from the backtrace. > > To understand the crash better, o

PyType_IsSubtype ()

2007-01-05 Thread Sheldon
d for /usr/lib/python2.3/site-packages/Numeric/ranlib.so Symbols already loaded for /usr/lib/python2.3/site-packages/Numeric/lapack_lite.so Symbols already loaded for /usr/lib/python2.3/lib-dynload/time.so Symbols already loaded for /data/proj_ns1/safworks/sheldon/MSG_PPS_COMP/c_codes/msgppsarea.

Re: Py_BuildValue or PyList_SetItem()

2007-01-03 Thread Sheldon
Jack Diederich skrev: > On Wed, Jan 03, 2007 at 01:16:38PM -0800, Sheldon wrote: > > I have a function that creates python objects out of C arrays and > > returns them to Python. Below is a working example that I later want to > > expand to return 12 arrays back to Python

Py_BuildValue or PyList_SetItem()

2007-01-03 Thread Sheldon
a,i,op) !=0) { fprintf(stderr,"Error in creating python va object\n"); exit(EXIT_FAILURE); } Py_DECREF(op); op = 0; return Py_BuildValue("N",Rva); } Results in Python: , , , , , , , , , , , Any help is appreciated! /Sheldon -- http://mail.pyth

Re: Cpoying a PyList to a C string array

2006-12-19 Thread Sheldon
Klaas skrev: > Sheldon wrote: > > The code below is a rookie attempt to copy a python list of strings to > > a string array in C. It works to some extent but results in memory > > problems when trying to free the C string array. Does anyone know how > > to do this prop

Re: Core dump revisited

2006-12-19 Thread Sheldon
Nick Craig-Wood skrev: > Sheldon <[EMAIL PROTECTED]> wrote: > > Man. You are good. This is most insight I have had from anyone. > > :-) > > > I did initialize the arrays with PyObjects and today, after hours of > > debugging and now with your insight, I t

Re: Core dump revisited

2006-12-19 Thread Sheldon
Duncan Booth skrev: > "Sheldon" <[EMAIL PROTECTED]> wrote: > > > I am new to this and copied this code from a colleague. So, it > > corrupts the pointer. How do I do this properly? > > > Here is at least part of your problem: > > msgop = PyLi

Cpoying a PyList to a C string array

2006-12-19 Thread Sheldon
Hi, The code below is a rookie attempt to copy a python list of strings to a string array in C. It works to some extent but results in memory problems when trying to free the C string array. Does anyone know how to do this properly? *** /*Re

Re: Core dump revisited

2006-12-19 Thread Sheldon
Nick Craig-Wood skrev: > Sheldon <[EMAIL PROTECTED]> wrote: > > Sheldon skrev: > > > Wonderful! Now I know how to used gdb with python. > > Good! > > > > The are results area posted below. Since I am new at this I could > > > used some

Re: Core dump revisited

2006-12-18 Thread Sheldon
Nick Craig-Wood skrev: > Sheldon <[EMAIL PROTECTED]> wrote: > > gdb msgppscomp.py core.3203 > > Run > > gdb python > > Then type > > run msgppscomp.py > > at the gdb prompt. > > When it crashes, type "bt" for a back trace. This

Re: Core dump revisited

2006-12-18 Thread Sheldon
Nick Craig-Wood skrev: > Sheldon <[EMAIL PROTECTED]> wrote: > > gdb msgppscomp.py core.3203 > > Run > > gdb python > > Then type > > run msgppscomp.py > > at the gdb prompt. > > When it crashes, type "bt" for a back trace. This

Core dump revisited

2006-12-17 Thread Sheldon
Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i586-mandrake-linux-gnu"..."/data/proj_ns1/safworks/sheldon/msgppscomp.py": not in executable format: File fo

function for allocating memory for string array

2006-11-17 Thread Sheldon
if(array == NULL) { // Memory for the Col fprintf(stderr, "Failed to allocate memory\n"); exit(EXIT_FAILURE); } } return array; } static void MemoryFreeStr(int Col, char*** array) { int i; for (i = 0; i < 15; i++) { free((*array)[i]); } free(*array); }

Re: C extensions and memory leakage

2006-11-17 Thread Sheldon
Fredrik Lundh wrote: > Sheldon wrote: > > > I am very new at this C extensions in Python so my term wrapper was > > probably a misnomer. Perhaps glue is better or the interface that > > allows the exchange of data between Python and C. > > Yes, I am using py

Re: C extensions and memory leakage

2006-11-17 Thread Sheldon
Fredrik Lundh wrote: > Sheldon wrote: > > > I am very new at this C extensions in Python so my term wrapper was > > probably a misnomer. Perhaps glue is better or the interface that > > allows the exchange of data between Python and C. > > Yes, I am using py

Re: C extensions and memory leakage

2006-11-17 Thread Sheldon
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Sheldon wrote: > > > Now I am wondering if the problem is in Python and the wrapper? Does > > anybody have any idea or experience with this? I am running on > > Mandrake10 using python 2.3. I

C extensions and memory leakage

2006-11-16 Thread Sheldon
person. thanks in advance, /Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: C wrapper

2006-11-07 Thread Sheldon
Gabriel Genellina skrev: > At Tuesday 7/11/2006 17:27, Sheldon wrote: > > >Here is the file/module name: _msgpps_functions.c > >Here is the initfunction: > > > >PyMODINIT_FUNC init_msgpps_functions(void) { > > PyObject* m; > > m=Py_InitModule(&q

Re: C wrapper

2006-11-07 Thread Sheldon
module to do some number crunching. Now I just need to "connect" it to my python program. Should the initmsgpps_functions() be the only function in the file? Then how do I "connect" my C module to my Python program? /Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: C wrapper

2006-11-07 Thread Sheldon
Robert Kern skrev: > Sheldon wrote: > > > This function is there and is called init_mymodule() but I have other > > functions that are not static. > > Is the module's name "_mymodule"? Or is it "mymodule"? > > -- > Robert Kern > &

Re: C wrapper

2006-11-07 Thread Sheldon
Farshid Lashkari skrev: > Sheldon wrote: > > Can anyone give me some idea as to what this error means? > > > > "ImportError: dynamic module does not define init function " > > > > I am new at this and there is still a lot to learn. > > &g

C wrapper

2006-11-07 Thread Sheldon
Hi, Can anyone give me some idea as to what this error means? "ImportError: dynamic module does not define init function " I am new at this and there is still a lot to learn. Any help is appreciated, /Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: Resuming a program's execution after correcting error

2006-10-04 Thread Sheldon
MRAB wrote: > Sheldon wrote: > > MRAB wrote: > > > Sheldon wrote: > > > > Hi. > > > > > > > > Does anyone know if one can resume a python script at the error point > > > > after the error is corrected? > > > > I ha

Re: Resuming a program's execution after correcting error

2006-10-03 Thread Sheldon
MRAB wrote: > Sheldon wrote: > > Hi. > > > > Does anyone know if one can resume a python script at the error point > > after the error is corrected? > > I have a large program that take forever if I have to restart from > > scratch everytime. The error w

Re: Resuming a program's execution after correcting error

2006-10-03 Thread Sheldon
would like to create an exception that saves all the current variables when there is an error. I think pickle is the answer but I never got it to work. My program is very large and it is being modified often. Any advice on how to save the variables. /Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Resuming a program's execution after correcting error

2006-09-28 Thread Sheldon
recalculated again. Sincerely, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Continuing after error

2006-09-28 Thread Sheldon
Hi, Does anyone know if it is possible to resume the execution of a program after it stops at an error in the code and the error was corrected? Sincerely, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Printing UTF-8

2006-09-21 Thread sheldon . regular
I am new to unicode so please bear with my stupidity. I am doing the following in a Python IDE called Wing with Python 23. >>> s = "äöü" >>> print s äöü >>> print s äöü >>> s '\xc3\xa4\xc3\xb6\xc3\xbc' >>> s.decode('utf-8') u'\xe4\xf6\xfc' >>> u = s.decode('utf-8') >>> u u'\xe4\xf6\xfc' >>>

Concatenating arrays

2006-08-24 Thread Sheldon
1 does it horizontally. But the results does not reflect this. What am I missing here? I am using Numeric. Any help is appreciated, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: concatenate Numeric

2006-07-10 Thread Sheldon
Robert Kern skrev: > Sheldon wrote: > > Thanks again for showing me this. I have been trying to read up on > > reduce() as I have never used it before. I would like to know what it > > does. So far my search has found nothing that I can grasp. The > > reference lib

Re: concatenate Numeric

2006-07-10 Thread Sheldon
Robert Kern wrote: > Sheldon wrote: > > Hi, > > > > I am trying to build a large array using concatenate function in > > python. > > So as I loop over the number of arrays, of which there are 12 (4 down > > and 3 across), I create 3 long arrays by concat

Re: concatenate Numeric

2006-07-09 Thread Sheldon
Robert Kern skrev: > Sheldon wrote: > > Hi, > > > > I am trying to build a large array using concatenate function in > > python. > > So as I loop over the number of arrays, of which there are 12 (4 down > > and 3 across), I create 3 long arrays by concat

Re: concatenate Numeric

2006-07-09 Thread Sheldon
Sheldon skrev: > Hi, > > I am trying to build a large array using concatenate function in > python. > So as I loop over the number of arrays, of which there are 12 (4 down > and 3 across), I create 3 long arrays by concatenating them at the > bottom and then concatenat

concatenate Numeric

2006-07-09 Thread Sheldon
ck it in the python program and they are correct at the end but the max(max(ppslon)) values is incorrect. Does anyone knows why this is so? If I was doing something wrong then Matlab would not have returned correct values. Any help is appreciated! /Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: Classes and global statements

2006-07-03 Thread Sheldon
Scott David Daniels skrev: > Sheldon wrote: > > Hi, > > > > I have a series of classes that are all within the same file. Each is > > called at different times by the main script. Now I have discovered > > that I need several variables returned to the main script

Re: Classes and global statements

2006-07-03 Thread Sheldon
Simon Forman skrev: > Sheldon wrote: > > Hi, > > > > I have a series of classes that are all within the same file. Each is > > called at different times by the main script. Now I have discovered > > that I need several variables returned to the main script. Si

Classes and global statements

2006-07-03 Thread Sheldon
that will be needed later instead of passing them back and forth. After trying this it did work! My question is why? Another way to solve this problem is to make the variable I need global in the class that they are created. Does anyone have a better way in mind? Sincerely, Sheldon -- http://mail.py

Re: Numeric help!

2006-07-03 Thread Sheldon
Carl Banks wrote: > Sheldon wrote: > > average(compress(ravel(equal(wk,z)),ravel(sattmp)),axis=None) > > This is much more compact and elegant. Thanks for pointing this out. > > I don't know why average() returned a divide by zero error and to avoid > > this I inse

Re: Numeric help!

2006-06-30 Thread Sheldon
Carl Banks wrote: > Sheldon wrote: > >Carl Banks wrote: > >> I'm not sufficiently sure this isn't a homework problem, so here's a > >> partial answer. > [snip] > > > > My days as a student is over for the most part. I am learning python on

Re: Numeric help!

2006-06-29 Thread Sheldon
e where I going wrong. I am not using the original arrays, only the copies and when a new z is chosen then these are recreated. Care to help out with this? /Sheldon Carl Banks wrote: > Sheldon wrote: > > Hi, > > > > I have the following loop that I think can be written to run f

Numeric help!

2006-06-28 Thread Sheldon
the sum of the values count += 1 # count the occurrences tmp_array[0,index] = round(mbias/count,1) # store the mean tmp_array[1,index] = z index += 1 Any help would be greatly appreciated! Sincerely, Sheldon -- http://mail.python.org

Re: array manipulation without for loops

2006-06-25 Thread Sheldon
27;t understand this part: >>> print x [10 1 30 3 50] >>> putmask(x, [1,0,1,0,1], [-1,-2]) >>> print x [-1 1 -1 3 -1] Can you explain why the -2 didn't factor in? /Sheldon Sheldon wrote: > Hi Alex, > > I will code this in a little while and get back to

Re: array manipulation without for loops

2006-06-25 Thread Sheldon
into it when I get back to work tomorrow. Bye for now, Sheldon Alex Martelli wrote: > Sheldon <[EMAIL PROTECTED]> wrote: > > > Alex, > > > > I am using Numeric and have created 3 arrays: zero((1215,1215),Float) > > Two arrays are compared and one is used to hold

Re: array manipulation without for loops

2006-06-25 Thread Sheldon
these arrays at the same time. I cannot install Numpy due to my working conditions. Sorry I should have made it clear that is was Numeric I was working with. /Sheldon Alex Martelli wrote: > Sheldon <[EMAIL PROTECTED]> wrote: > > > Hi Gary, > > > > I am really trying

Re: array manipulation without for loops

2006-06-25 Thread Sheldon
Hi Gary, I am really trying to cut the time down as I have 600+ arrays with dimensions (1215,1215) to compare and I do a lot more things with the arrays. If I understand you correctly, there is no way around a for loop? /Sheldon Gary Herron wrote: > Sheldon wrote: > > Hi, > >

array manipulation without for loops

2006-06-25 Thread Sheldon
this without using for loops? Sincerely, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: OverflowError: math range error...

2006-06-23 Thread Sheldon
stead. /Sheldon Robert Kern skrev: > Sheldon wrote: > > Hi, > > > > I have a written a script that will check to see if the divisor is zero > > before executing but python will not allow this: > > > > if statistic_array[0:4] > 0.0: > > statistic_a

Re: OverflowError: math range error...

2006-06-23 Thread Sheldon
Thanks for the tips! I am going to look into this some more. /Sheldon Simon Forman skrev: > Sheldon wrote: > > Hi, > > > > I have a written a script that will check to see if the divisor is zero > > before executing but python will not allow this: > > &

OverflowError: math range error...

2006-06-22 Thread Sheldon
hon is complaining: "statistic_array[0,0:4] = int(multiply(divide(statistic_array[0,0:4],statistic_array[0,4]),1.0))/100.0 OverflowError: math range error" and how do I get around this problem? This stupid because there is a if statement preventing this "dividing by zero&quo

Re: comparing two arrays

2006-06-22 Thread Sheldon
Thanks Diez, It will take a little while for this one to sink in but it gets the job done now and will for future cases. /Sheldon Diez B. Roggisch skrev: > >> print [i for i, _ in enumerate((None for x, y in zip(a, b) where x == > >> y))] > >> > >> ins

Re: comparing two arrays

2006-06-22 Thread Sheldon
Thanks Diez, It will take a little while for this one to sink in but it gets the job done now and will for future cases. /Sheldon Diez B. Roggisch skrev: > >> print [i for i, _ in enumerate((None for x, y in zip(a, b) where x == > >> y))] > >> > >> ins

Re: comparing two arrays

2006-06-20 Thread Sheldon
enumerate((None for x, y in zip(a, b) where x == y))] > > instead. > > Diez Hi Diez, I wish I say that I understood what you wrote here but I can't. Do you mind explaining a little more? /sheldon -- http://mail.python.org/mailman/listinfo/python-list

comparing two arrays

2006-06-19 Thread Sheldon
;> Numeric.logical_and(a==6,b==6) 0 >>> Numeric.where(a==b,1,0) 0 >>> Numeric.where(a==6 and b==6,1,0) 0 The where() statement is also worhtless here. Does anyone have any suggestion on how to do this? Thanks in advance, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: python and HDF

2006-06-15 Thread Sheldon
Marc 'BlackJack' Rintsch skrev: > In <[EMAIL PROTECTED]>, Sheldon wrote: > > > I am using a HLHDF C wrapper to extract data from HDF (version 5) > > files. > > I can view the contents with IDL, for example, and read the attributes > > in the HDF fil

python and HDF

2006-06-15 Thread Sheldon
which is called "baseline" but when python reads it, it returns "baselin" instead. Does anyone have any idea why this is happening? Sincerely, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: printing all variables

2006-06-12 Thread Sheldon
Duncan Booth skrev: > Sheldon wrote: > > > Good day, > > > > I would like to know if there is a way to print all the variables set > > in a python program with having to write > > "print variable" on all? > > > Not all the variables in a p

printing all variables

2006-06-12 Thread Sheldon
Good day, I would like to know if there is a way to print all the variables set in a python program with having to write "print variable" on all? sincerely, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: ftputil.py

2006-05-24 Thread Sheldon
Thanks! Sheldon -- http://mail.python.org/mailman/listinfo/python-list

ftputil.py

2006-05-24 Thread Sheldon
27;) # file-like object target = host.file('newdir/index.html', 'w') # file-like object host.copyfileobj(source, target) # similar to shutil.copyfileobj Any help would be greatly appreciated! Sincerely, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

GRIB to images

2006-04-24 Thread Sheldon
Hi, I am interesseted on reading some GRIB files using python and then converting the fields to gif images. Does anyone know if this is possible or have a program that does this? /Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: reading binary data written in C

2006-03-22 Thread Sheldon
Thanks, I later discovered that it was a big edian binary as well. Sheldon -- http://mail.python.org/mailman/listinfo/python-list

reading binary data written in C

2006-03-22 Thread Sheldon
e? Thanks, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: writing arrays to binary file

2006-01-25 Thread Sheldon
Thanks Travis, I don't have the new NumPy yet but this tofile() method should work fine. /Sheldon -- http://mail.python.org/mailman/listinfo/python-list

writing arrays to binary file

2006-01-25 Thread Sheldon
ith open("filename", 'wb'), I lose the decimals that are vital. The input data is float with about 4 decimal places. Does anyone have any ideas of how to improve this by writing the 2D array in binary form? Thanks, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading from input file.

2006-01-13 Thread Sheldon
Sorry Mike, after seeing so many "experts" beat up others for not being as "smart" as they are, I intrepreted your words incorrectly - my apologies. I am not in the least bit against impproving my programming. I liked what you did and thanks for the pointers. Sheldon -- ht

Re: Exception Handling

2006-01-12 Thread Sheldon
was executed without error or -1 for an error. We have not tried to catch the error from the C-code. Sorry. Perhaps some else knows how. cheers, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading from input file.

2006-01-12 Thread Sheldon
So Mike if you can do better then do it then! There are many ways do solve a problem, perhaps you have not learned that yet. At first this guy didn't know what to do, so he had to begin somewhere. Now you can take him much further, I am sure but the journey might not be so pleasant. Your attitude r

Re: Exception Handling

2006-01-12 Thread Sheldon
error handling using the function RAISE: try: Call C except: raise my_error. A catch-all error is RuntimeError; try this first. try: call C except RuntimeError, r: print r You can read up on it here: http://docs.python.org/api/standardExceptions.html Cheers, Sheldon -- http://mail.pytho

Re: Reading from input file.

2006-01-12 Thread Sheldon
a much easier way so lets hope that this is so. I hope this was more clear and helpful this time around. Cheers Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading from input file.

2006-01-11 Thread Sheldon
eve that it should work. Sincerely, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax error

2006-01-10 Thread Sheldon
Hi Fredrik, I am using python 2.3.3 I am checking now the previous lines for errors. Thanks, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax error

2006-01-10 Thread Sheldon
Hi Rod, You were right. The error was on the previous line. I will remember that. Thanks for your help! Sheldon -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax error

2006-01-10 Thread Sheldon
Hi Rod, This sounds very interesting. I am checking the previous lines and will get back to you. Thanks, Sheldon -- http://mail.python.org/mailman/listinfo/python-list

syntax error

2006-01-10 Thread Sheldon
something else. Can anyone point me in the right direction? What triggers such erroneous errors in Python? Sincerely, Sheldon -- http://mail.python.org/mailman/listinfo/python-list