redirect and python

2006-02-01 Thread questions?
I am calling system command in python by os.system() I do, os.system("wget http://blah blah blah") then I run the program by ./programname >redirected file The things put to screen doesn't redirect to the file I want. What's the trick in here? Thanks -- http://mail.python.org/mailman/listinfo

Re: OO conventions

2006-02-01 Thread Fredrik Lundh
Terry Hancock wrote: > What Lundh is modeling this on is not standard OOP thinking, > but rather the standard way of opening files in Python. > > Or you could say he's using a "factory function". "open" is a factory function, and it picks the right class based on the file you're opening. anyone

Re: PIL and transparent GIFs

2006-02-01 Thread Fredrik Lundh
Terry Hancock wrote: > There was a patch published at one time that was supposed > to fix this. I remember doing some testing and not finding > it to work perfectly, but I may have been doing something > wrong. Can't recover it at the moment, but some search > engine work might turn it up. trans

Re: howto catch an Exception and still print the TraceBack?

2006-02-01 Thread Saizan
Thanks, I had completely missed the module traceback... I'll use traceback.print_exc(), it seems the most straightforward way. The only flaw is that the traceback starts in the method where i catch the exception and not from "__main__", but I guess it can't be helped. -- http://mail.python.org/ma

popen and stderr

2006-02-01 Thread Robert Deskoski
Hey all, Currently i'm trying to use popen3 to access stderr - i wanted to use it to output some text to the parent process, so it can display it (non-console, graphically is what I mean). Is it possible to write to stderr fromt he child process or, barring this, to attach another stream to the ch

Re: webbrowser module + urls ending in .py = a security hole?

2006-02-01 Thread Blair P. Houghton
>Would it be sufficient in your case merely to allow only .html files to >be loaded? Or URLs without .extensions? Or even just permit only the >http: protocol? Personally, I'm just noodling around with this right now. So "my case" is the abstract case. I think the solution if one was needed wou

Re: nDimensional sparse histogram in python.

2006-02-01 Thread Alex Martelli
KraftDiner <[EMAIL PROTECTED]> wrote: > Many thanks everyone. > > One last quick question... > The dictionary, I believe, is sorted by the key. Dictionaries are NOT sorted -- they're hashtables. > Is there a way to sort it by the value? > Say I wanted to put out a list of the frequency sorted b

Re: nDimensional sparse histogram in python.

2006-02-01 Thread Kirk McDonald
KraftDiner wrote: > Many thanks everyone. > > One last quick question... > The dictionary, I believe, is sorted by the key. > Is there a way to sort it by the value? > Say I wanted to put out a list of the frequency sorted by highest to > lowest? > The dictionary itself is actually unordered; a

Re: nDimensional sparse histogram in python.

2006-02-01 Thread KraftDiner
Many thanks everyone. One last quick question... The dictionary, I believe, is sorted by the key. Is there a way to sort it by the value? Say I wanted to put out a list of the frequency sorted by highest to lowest? -- http://mail.python.org/mailman/listinfo/python-list

[no subject]

2006-02-01 Thread hotcountrywench
I just got a new computer and pyton 2.2 is on it and I have never heard of it What is is for. Should I keep it on my puter??? -- http://mail.python.org/mailman/listinfo/python-list

Re: nDimensional sparse histogram in python.

2006-02-01 Thread rajasekaran . natarajan
Hi you can use has_key() to check whether the particular value is in the key set or not. >>> a = {} >>> a[1] = 22 >>> a[2] = 33 >>> a {1: 22, 2: 33} >>> a.has_key(3) False >>> a.has_key(1) True >>> -raj KraftDiner wrote: > Ok so this is nice.. Just one thing.. When you try to get a value from >

Re: nDimensional sparse histogram in python.

2006-02-01 Thread Kirk McDonald
KraftDiner wrote: > Ok so this is nice.. Just one thing.. When you try to get a value from > a dictionary > and it isn't found in the dictionary things go bad... > > Take this for example: > > class histogram(object): > def __init__(self): > self.histo = {} > > def upda

Re: nDimensional sparse histogram in python.

2006-02-01 Thread KraftDiner
Ok so this is nice.. Just one thing.. When you try to get a value from a dictionary and it isn't found in the dictionary things go bad... Take this for example: class histogram(object): def __init__(self): self.histo = {} def update(self, point): i

Re: nDimensional sparse histogram in python.

2006-02-01 Thread Kirk McDonald
KraftDiner wrote: > The dictionary is sorted by the point key. > Is there a way to sort the dictionary by the value? > Seems to me this goes against the purpose of a dictionary but > thats what I need to do.. > Well, it's probably not all that efficient, but it is simple code: sortedList = [

Re: nDimensional sparse histogram in python.

2006-02-01 Thread KraftDiner
The dictionary is sorted by the point key. Is there a way to sort the dictionary by the value? Seems to me this goes against the purpose of a dictionary but thats what I need to do.. -- http://mail.python.org/mailman/listinfo/python-list

Re: nDimensional sparse histogram in python.

2006-02-01 Thread Alex Martelli
KraftDiner <[EMAIL PROTECTED]> wrote: > Cool. > Ok so my histogram class had two methods 1) To increment a point and 2) > to get the point. > > def class histo: >def __init__(self): >histo = {} > def update(point): >'''searches the dictionary for point and if it exists increment t

Re: nDimensional sparse histogram in python.

2006-02-01 Thread John McMonagle
On Wed, 2006-02-01 at 19:06 -0800, KraftDiner wrote: > Cool. > Ok so my histogram class had two methods 1) To increment a point and 2) > to get the point. > > def class histo: >def __init__(self): >histo = {} > def update(point): >'''searches the dictionary for point and if it exis

Re: nDimensional sparse histogram in python.

2006-02-01 Thread KraftDiner
Cool. Ok so my histogram class had two methods 1) To increment a point and 2) to get the point. def class histo: def __init__(self): histo = {} def update(point): '''searches the dictionary for point and if it exists increment the value. if it doesn't exist set the value to 1'''

Re: nDimensional sparse histogram in python.

2006-02-01 Thread Alex Martelli
KraftDiner <[EMAIL PROTECTED]> wrote: ... > histo = {[0,0,0]:1, [0,0,1]:2} > Would indicate that there is one sample at 0,0,0 and two samples at > 0,0,1 > but python tells me TypeError: list objects are unhashable > > So any suggestions would be welcome. Use tuples, not lists, as your keys: h

nDimensional sparse histogram in python.

2006-02-01 Thread KraftDiner
Hi, I wrote a C++ class that implements an n dimensional histogram in C++, using stl maps and vectors. I want to code this up now in Python and would like some input from this group. The C++ class was VERY simple.. std::map, unsigned long> histo; Say for example I want a 3D histogram th

Re: How do I dynamically create functions without lambda?

2006-02-01 Thread Alex Martelli
Alan Morgan <[EMAIL PROTECTED]> wrote: ... > Excessive cleverness can lead to unmaintainable code. So can excessive > stupidity. +1 QOTW. > Since there are a lot more stupid people than clever people out there I > think the more likely scenario is having to maintain unmaintainable code > writ

Re: locals() and dictionaries

2006-02-01 Thread Alex Martelli
JerryB <[EMAIL PROTECTED]> wrote: ... > is it possible to access the individual members of a dictionary using % > locals() when creating a string? Not by using the built-in locals(); you'd have to override locals to mean someting different (not recommended). Alex -- http://mail.python.org/ma

Re: Why checksum? [was Re: Fuzzy Lookups]

2006-02-01 Thread Erik Max Francis
Steven D'Aprano wrote: > This isn't a criticism, it is a genuine question. Why do people compare > local files with MD5 instead of doing a byte-to-byte compare? Is it purely > a caching thing (once you have the checksum, you don't need to read the > file again)? Are there any other reasons? Becau

Re: cgi - secure sessions

2006-02-01 Thread Paul Rubin
"GazaM" <[EMAIL PROTECTED]> writes: > Paul: By server side include I mean simply calling upon the script from > an include line within the html, for example '' Try printing the contents of os.getenv() in your script and see if the cookie data is in there. -- http://mail.python.org/mailman/listinf

changing python script on-the-fly for ActiveX/COM object (win32com)

2006-02-01 Thread jd
I have implemented a COM object in Python and I would like to be able to change the script without stopping and restarting the application that's using the COM object. Is there a way to do this? (I can change the program that calls the COM object if needed.) Thanks... -- jeff -- http://mail.p

Re: cgi - secure sessions

2006-02-01 Thread GazaM
Kirk: I'm using the Cookie module to create/send/read the cookies. The problem is that I can't read session cookies when running the script from a server side include line. Paul: By server side include I mean simply calling upon the script from an include line within the html, for example '' Gaza

Re: cgi - secure sessions

2006-02-01 Thread Paul Rubin
"GazaM" <[EMAIL PROTECTED]> writes: > there will display a login form. Now, the big showstopper here is that, > because session cookies are stored in http headers sent by the client > (afaik) the cgi script can't get any, because the http headers are > passed onto the html file and any cgi scripts

Re: cgi - secure sessions

2006-02-01 Thread Kirk McDonald
GazaM wrote: > What I have is a cgi script run through a server > side include line in the html, which looks for the session cookie, if > it is present will say 'logged in as "user"' and if the cookie isn't > there will display a login form. Now, the big showstopper here is that, > because session

Re: cgi - secure sessions

2006-02-01 Thread GazaM
wow, those were some seriously quick replies, thanks. I understand that cookies is the best way to do things, but I didn't explain my problem well, sorry. Basically, I have a blog in the works and I want to have an online interface for posting. What I have is a cgi script run through a server side

Re: cgi - secure sessions

2006-02-01 Thread Paul Rubin
[EMAIL PROTECTED] writes: > I was just wondering if / how would it be possible to create secure > sessions for a website using Python CGI... I thought of using cookies, > and things looked promising for a while; I could login through a form > which pointed to a cgi script which created sent the use

Re: cgi - secure sessions

2006-02-01 Thread Kirk McDonald
[EMAIL PROTECTED] wrote: > Hey, > > I was just wondering if / how would it be possible to create secure > sessions for a website using Python CGI... I thought of using cookies, > and things looked promising for a while; I could login through a form > which pointed to a cgi script which created sen

Re: Python vs C for a mail server

2006-02-01 Thread Paul Rubin
Magnus Lycka <[EMAIL PROTECTED]> writes: > Sure, but on the other hand, you are really on your own when you > avoid the compile time type safety in C++. But it's almost impossible to avoid. Does *p point to a valid object, or to unallocated memory? C++ has no way to tell this at compile time. --

cgi - secure sessions

2006-02-01 Thread infini . g
Hey, I was just wondering if / how would it be possible to create secure sessions for a website using Python CGI... I thought of using cookies, and things looked promising for a while; I could login through a form which pointed to a cgi script which created sent the user cookies, but I found that

Re: Why checksum? [was Re: Fuzzy Lookups]

2006-02-01 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Sure. But if you are just comparing two files, is there any reason to > bother with a checksum? (MD5 or other.) No of course not, except in special situations, like some problem opening and reading both files simultaneously. E.g.: the files are on two

Re: Why checksum? [was Re: Fuzzy Lookups]

2006-02-01 Thread Paul Rubin
Tom Anderson <[EMAIL PROTECTED]> writes: > > The obvious way is make a list of hashes, and sort the list. > > Obvious, perhaps, prudent, no. To make the list of hashes, you have to > read all of every single file first, which could take a while. If your > files are reasonably random at the beginni

Re: OO conventions

2006-02-01 Thread Terry Hancock
On Wed, 1 Feb 2006 23:40:37 +0100 Daniel Nogradi <[EMAIL PROTECTED]> wrote: > I'm relatively new to object oriented programming, so get > confused about its usage once in a while. Suppose there is > a class Image that has a number of methods, rotate, open, > verify, read, close, etc. Then to use th

Re: PyGILState_Release + Python2.3 = Segmentation Fault

2006-02-01 Thread cadavis2k2
Kirill Simonov wrote: > Hi, > > Could someone tell me why my extension module works under Python 2.4, but > fails with Segmentation Fault under Python 2.3? Here is the stripped version: Maybe Python threads aren't initialized? Adding a call to PyEval_InitThreads() stops the seg fault for me in Py

Re: PIL and transparent GIFs

2006-02-01 Thread Terry Hancock
On 1 Feb 2006 14:41:05 -0800 "Kamilche" <[EMAIL PROTECTED]> wrote: > It can only read transparency, it can't write it. I went > looking and found that out a couple weeks ago. There was a patch published at one time that was supposed to fix this. I remember doing some testing and not finding it to

Re: Pulling numbers from ASCII filename not working

2006-02-01 Thread IamIan
Thanks for the help everyone (especially those that gave more answers than attitude). It's working perfectly! Ian -- http://mail.python.org/mailman/listinfo/python-list

A class with built-in doctest feature ?

2006-02-01 Thread Runsun Pan
I intend to use the doctect heavily. For this I am thinking of coding a class that comes with a built-in doctest functionality. I'd like to seek for input before I start. The idea is to have a class MyObj from where all my other classes will subclass. lets say: class C(MyObj): ''' Thi

Re: OO conventions

2006-02-01 Thread Daniel Nogradi
> > In this case, Image seems to be a python module, with the open function > defined, PIL's Image is not a class. > Thanks for the enlightening remarks, especially this last one, indeed, it's not a class. -- http://mail.python.org/mailman/listinfo/python-list

Re: OO conventions

2006-02-01 Thread Kirk McDonald
Daniel Nogradi wrote: > I'm relatively new to object oriented programming, so get confused > about its usage once in a while. Suppose there is a class Image that > has a number of methods, rotate, open, verify, read, close, etc. Then > to use this class my natural guess would be to have something l

Re: OO conventions

2006-02-01 Thread Claudio Grondi
Daniel Nogradi wrote: > I'm relatively new to object oriented programming, so get confused > about its usage once in a while. Suppose there is a class Image that > has a number of methods, rotate, open, verify, read, close, etc. Then > to use this class my natural guess would be to have something l

Re: OO conventions

2006-02-01 Thread Anthony Greene
On Wed, 01 Feb 2006 23:40:37 +0100, Daniel Nogradi wrote: > I'm relatively new to object oriented programming, so get confused > about its usage once in a while. Suppose there is a class Image that > has a number of methods, rotate, open, verify, read, close, etc. Then > to use this class my natur

Re: OO conventions

2006-02-01 Thread Anthony Greene
On Wed, 01 Feb 2006 23:40:37 +0100, Daniel Nogradi wrote: > I'm relatively new to object oriented programming, so get confused > about its usage once in a while. Suppose there is a class Image that > has a number of methods, rotate, open, verify, read, close, etc. Then > to use this class my natur

Re: locals() and dictionaries

2006-02-01 Thread JerryB
Rocco: thanks for your response. The examples were just made up. I don't normally use 'dict' and 'str'. I know I can create a dictionary with the variables I want, etc. My question is not how to solve the problem, or how to come up with a work-around (I'm getting pretty good at this one :), so my q

Re: PIL and transparent GIFs

2006-02-01 Thread Kamilche
It can only read transparency, it can't write it. I went looking and found that out a couple weeks ago. -- http://mail.python.org/mailman/listinfo/python-list

OO conventions

2006-02-01 Thread Daniel Nogradi
I'm relatively new to object oriented programming, so get confused about its usage once in a while. Suppose there is a class Image that has a number of methods, rotate, open, verify, read, close, etc. Then to use this class my natural guess would be to have something like image = Image( ) image.re

dependencies on subclassing Extensiontypes: tp_richcompare <--> tp_hash

2006-02-01 Thread Uwe Hoffmann
Hi, i have used Pyrex to build some python Extensionclasses. Now i stumbled over the fact that if a subclass has a __hash__ method the __richcmp__ of the base is not called. # pseudocode class Base: def __richcmp__(): print 'hi' class Immutable(Base): def __hash__()

Re: load module named "datetime" and change the directory of output file?

2006-02-01 Thread Lee Harr
> 1. How can I add a standard module named "datetime" in > Jython when the error happens :"Traceback (innermost > last): > File "C:\python\test.py", line 3, in ? > ImportError: no module named datetime " > The line 3 is writen: "from datetime import datetime, > tzinfor" > The datetime module wa

Re: import datetime

2006-02-01 Thread Lee Harr
>> I did look at the sys.path but the issue is that I dont see a module >> name datetime anywhere. Only datetime thing that is there is in include >> directory and it is datetime.h, which I think is for C interface. I >> have a python installed on my Windows desktop and it is working fine >> there.

Re: How do I dynamically create functions without lambda?

2006-02-01 Thread Alan Morgan
In article <[EMAIL PROTECTED]>, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >On Sat, 28 Jan 2006 00:13:28 -0800, Kay Schluehr wrote: > >[snip lambda calculus stuff] > >> In Python you can write: >> >> Y = lambda g: (lambda f: g(lambda arg: f(f)(arg))) (lambda f: g(lambda >> arg: f(f)(arg))) >> >>

PIL and transparent GIFs

2006-02-01 Thread toto
Hi, Does anybody know how to save an image in GIF format preserving transparent background ?? Here's what I tested : import Image, ImageDraw im = Image.open('/path/to/model.gif') # An image with transparent backgroung draw = ImageDraw.Draw(im) draw.polygon([153,106,186,225,340,193,315,81,304,167

Re: Sharing database connection from C to Python

2006-02-01 Thread Daniel Dittmar
[EMAIL PROTECTED] wrote: > I'm developing an application using the C language and Python for it's > plugins. The C program connects to a MySQL database and keeps that > connection active. Is it possible to 'share' this connection with the > Python plugins? If so, is there a "standard" way to do tha

Re: indentation messing up my tuple?

2006-02-01 Thread infidel
> i am using a tuple because i am building lists. I don't understand > if i just use (food + > drink) then while drink is unique food remains the same do i get this: > > (burger, coke) > (burger, 7up) > (burger, sprite) I don't understand what you're saying here. food and drink are both string

Re: Python vs C for a mail server

2006-02-01 Thread Donn Cave
In article <[EMAIL PROTECTED]>, "Randall Parker" <[EMAIL PROTECTED]> wrote: ... > More generally: One must keep in mind that advantages and disadvantages > of specific implementations of language concepts are not always > indications of flaws in those concepts. Sure. And of course, the nominal t

Re: locals() and dictionaries

2006-02-01 Thread Rocco Moretti
JerryB wrote: > Hi, > I have a dictionary, a string, and I'm creating another string, like > this: > > dict = {} > dict[beatles] = "need" > str = "love" > > mystr = """All you %(dict[beatles])s is %(str)s""" % locals() > > Why do I get > keyerror: 'dict[one]'? > > Is there a way to reference th

Re: indentation messing up my tuple?

2006-02-01 Thread localpricemaps
i am using a tuple because i am building lists. if i just use (food + drink) then while drink is unique food remains the same do i get this: (burger, coke) (burger, 7up) (burger, sprite) infidel wrote: > tuple is the name of the built-in type, so it's not a very good idea to > reassign it to som

Re: dynamic class instantiation

2006-02-01 Thread Ognen Duzlevski
Volker Grabsch <[EMAIL PROTECTED]> wrote: > Ognen Duzlevski wrote: > > Kent Johnson <[EMAIL PROTECTED]> wrote: > >> Ognen Duzlevski wrote: > >> > Say I got "page" as a string. How do I go about > >> > instantiating a class from this piece of information? To make it > >> > more obvious how do I cr

Re: Python vs C for a mail server

2006-02-01 Thread Randall Parker
Donn, More generally: One must keep in mind that advantages and disadvantages of specific implementations of language concepts are not always indications of flaws in those concepts. Real languages have real flaws from bad design choices which cause them to fall short of what those languages could

Re: urllib2 - My POST Request just isn't working right

2006-02-01 Thread Gregory Piñero
Thanks for all the help guys, it finally worked! I don't know if I ever would have figured this out on my own... skipping the url encoding is what did the trick. I didn't end up needing to do anything special for ssl. I guess urllib2 just handles that itself. Thanks again, -Greg -- http://ma

locals() and dictionaries

2006-02-01 Thread JerryB
Hi, I have a dictionary, a string, and I'm creating another string, like this: dict = {} dict[beatles] = "need" str = "love" mystr = """All you %(dict[beatles])s is %(str)s""" % locals() Why do I get keyerror: 'dict[one]'? Is there a way to reference the elements in a dictionary with locals() o

Re: calling a class method in a python module

2006-02-01 Thread Farshid Lashkari
> Can anybody tell me how to call "f" in my C code? Assuming you already have a handle to an instance of MyClass this should do the trick: PyObject *func = PyObject_GetAttrString(MyClassInst,"f"); if(func) { PyObject *result = PyObject_CallObject(func,NULL); if(result) { //Do

os.remove OSError: [Errno 13] Permission denied

2006-02-01 Thread Joram Agten
Please put me in CC When running the following program I get frequent errors like this one Exception in thread Thread-4: Traceback (most recent call last): File "C:\Python24\lib\threading.py", line 442, in __bootstrap self.run() File "os.remove.py", line 25, in run os.remove(filename)

Re: Python vs C for a mail server

2006-02-01 Thread Paul Boddie
Magnus Lycka wrote: > In C++ it's the opposite. By demanding a particular type, we restrain > ourself to using a set of values which is much smaller than the logic > calls for, or we can throw away all type checks by e.g. casting to void > pointers. The main reason for evading the type system in s

Re: unicodedata.name

2006-02-01 Thread Szabolcs Nagy
thank you (it's so obvious i don't know how i could misunderstand) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python vs C for a mail server

2006-02-01 Thread Donn Cave
In article <[EMAIL PROTECTED]>, ... > Granted, it is a pain to change type declarations. I see it is time for the bi-monthly reminder that C++ is not the ideal example of strong static typing, unless you just want to make it look bad. Cf. Hindley-Milner type inference. Donn Cave, [EMAIL PROTE

Re: simple perl program in python gives errors

2006-02-01 Thread Dan Lowe
On Feb 1, 2006, at 7:59 AM, Tim Roberts wrote: > Dan Lowe <[EMAIL PROTECTED]> wrote: >> >> Not sure if you typo'd that, but that should read: >> >> a += 20 * 14 >> print a > > Did you try to run that? Well, I did, but I had given 'a' a value first. And now I'm thinking that I may have

Re: import datetime

2006-02-01 Thread Fredrik Lundh
"shaboo" wrote: > It does say Python 2.4.2 > > Python 2.4.2 (#2, Jan 30 2006, 20:02:09) [C] on hp-ux11 > Type "help", "copyright", "credits" or "license" for more information. > >>> > > > I did look at the sys.path but the issue is that I dont see

Re: unicodedata.name

2006-02-01 Thread Fredrik Lundh
Szabolcs Nagy wrote: > the unicodedata manual sais: > " > name( unichr[, default]) > Returns the name assigned to the Unicode character unichr as a > string. If no name is defined, default is returned, or, if not given, > ValueError is raised. > " > what is the difference between "no name def

Re: urllib2 - My POST Request just isn't working right

2006-02-01 Thread Never Code Faster Than You Can See
Gregory Piñero wrote: > Ok, I tried the changes you guys suggested but same error still: > 1. Corrected spelling of referrer. errr, the other chap said the INcorrect spelling is correct for http. sorry about that. > Here is what they say my request should look like: > ---

Re: python printout format

2006-02-01 Thread Gary Herron
Yong Wang wrote: >Hi, > I have a data set like row = [[1,2,3,4,5], [6,7,8,9,10], [11,12,13,14,15]] > when I use loop to print out data, I got compile error in printout statment. > while j<24: > print ' ',string.ljust(str(units[0]), 5), > print ' ',string.ljust(str(ports[j], 3), >

Re: python printout format

2006-02-01 Thread Eric Nieuwland
Yong, Are you sure you indent with the same characters and there is no non-print code there? --eric On 1 feb 2006, at 17:36, Yong Wang wrote: > Hi, >I have a data set like row = [[1,2,3,4,5], [6,7,8,9,10], > [11,12,13,14,15]] >when I use loop to print out data, I got compile error in

python printout format

2006-02-01 Thread Yong Wang
Hi, I have a data set like row = [[1,2,3,4,5], [6,7,8,9,10], [11,12,13,14,15]] when I use loop to print out data, I got compile error in printout statment. while j<24: print ' ',string.ljust(str(units[0]), 5), print ' ',string.ljust(str(ports[j], 3), print ' ',string.l

Re: urllib2 - My POST Request just isn't working right

2006-02-01 Thread Fredrik Lundh
Gregory Piñero wrote: > 1 . One thing that is weird is that the data part just says "Your > FedEx Transaction". I know I put the XML here, but I also notice that > urllib2 is putting this as: > > request= > Can I have my xml placed here without that something= part? That > don't specify what par

Re: urllib2 - My POST Request just isn't working right

2006-02-01 Thread Eric Nieuwland
Don't forget to substitute the actual Content-length for %d! --eric On 1 feb 2006, at 17:34, Gregory Piñero wrote: > Correction: > --- > -- > POST /GatewayDC HTTP/1.0 > Referer: YourCompanyNameGoesHere > Host: SSLserver.fedex.c

unicodedata.name

2006-02-01 Thread Szabolcs Nagy
the unicodedata manual sais: " name( unichr[, default]) Returns the name assigned to the Unicode character unichr as a string. If no name is defined, default is returned, or, if not given, ValueError is raised. " what is the difference between "no name defined" and "not given"? eg. '\n' why g

Re: urllib2 - My POST Request just isn't working right

2006-02-01 Thread David Wahler
Gregory Piñero wrote: > Ok, I tried the changes you guys suggested but same error still: > 1. Corrected spelling of referrer. > 2. Don't specify host. > > Here is what they say my request should look like: > - > POST /GatewayDC

Re: urllib2 - My POST Request just isn't working right

2006-02-01 Thread Gregory Piñero
Correction: - POST /GatewayDC HTTP/1.0 Referer: YourCompanyNameGoesHere Host: SSLserver.fedex.com Accept: image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */* Content-Type: image/gif Content-length: %d Your FedEx Tra

Re: urllib2 - My POST Request just isn't working right

2006-02-01 Thread Gregory Piñero
Ok, I tried the changes you guys suggested but same error still: 1. Corrected spelling of referrer. 2. Don't specify host. Here is what they say my request should look like: - POST /GatewayDC HTTP/1.0 Referer: YourCompanyNameG

Re: urllib2 - My POST Request just isn't working right

2006-02-01 Thread Fuzzyman
That would certainly be an error. *Also*, urllib2 adds the host header for you, no need to set it. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib2 - My POST Request just isn't working right

2006-02-01 Thread Eric Nieuwland
Hi Greg, > values = {'request':xml_request} > headers = { 'Referer' : 'YourCompany', > 'Host':'https://gatewaybeta.fedex.com/GatewayDC', > 'Accept':'image/gif, image/jpeg, image/pjpeg, text/plain, > text/html, */*', > 'Content-Type':'image/gif' > }

Re: urllib2 - My POST Request just isn't working right

2006-02-01 Thread Don't Code Faster Than You Can See
(blogger.com gives the same error if you don't .strip() your password before using it to connect) i noticed one spelling mistake here: > headers = { 'Referer' : 'YourCompany', 'Referrer' could it be that simple? -- http://mail.python.org/mailman/listinfo/python-list

urllib2 - My POST Request just isn't working right

2006-02-01 Thread Gregory Piñero
Hi guys, I'm trying to write a program to get FedEx shipping rates, and I'm following their API as outlined in this document: http://www.fedex.com/us/solutions/wis/pdf/fsm_directmanual.pdf I need specifically to make a POST request to their server as shown on page 12. However I continually get s

Re: howto catch an Exception and still print the TraceBack?

2006-02-01 Thread Fabio Zadrozny
I find the following very good for most needs: try: raise RuntimeError('err') except: import traceback;traceback.print_exc() -- if you use Pydev, there's a template for that called printexc. Cheers, Fabio Saizan wrote: >In an event-driven application i'd like to keep the program alive

Re: import datetime

2006-02-01 Thread shaboo
It does say Python 2.4.2 Python 2.4.2 (#2, Jan 30 2006, 20:02:09) [C] on hp-ux11 Type "help", "copyright", "credits" or "license" for more information. >>> I did look at the sys.path but the issue is that I dont see a module name datetime anywhere.

Re: Capture Windows command line output - put in text file

2006-02-01 Thread Ernesto
Ernesto wrote: > I'm looking for a way to capture command line output from a cmd > session. Is there a way to use python to launch the application from > the beggining then stream all of the output to a text file ? Nevermind. This is a telnet question. I'm trying to get telnet localhost

Re: howto catch an Exception and still print the TraceBack?

2006-02-01 Thread Antoon Pardon
Op 2006-02-01, Saizan schreef <[EMAIL PROTECTED]>: > In an event-driven application i'd like to keep the program alive regardless > of any exceptions raised by the handlers, > but still be able to debug them by reading the appropriate TraceBack from > stderr. > I can put something like: > > try:

Re: howto catch an Exception and still print the TraceBack?

2006-02-01 Thread Diez B. Roggisch
Saizan wrote: > In an event-driven application i'd like to keep the program alive > regardless of any exceptions raised by the handlers, but still be able to > debug them by reading the appropriate TraceBack from stderr. I can put > something like: See sys.exc_info() The you can do: try: .

Re: Test driven programming, was Re: VB to Python migration

2006-02-01 Thread Grig Gheorghiu
Magnus, I've been writing TextTest tests lately for an application that will be presented at a PyCon tutorial on "Agile development and testing". I have to say that if your application does a lot of logging, then the TextTest tests become very fragile in the presence of changes. So I had to come u

Re: Parsing sizes

2006-02-01 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: > I want to be able to parse sizes in bytes in several formats, such as > "1048576", "1024K", "1024KB", "1M" etc. > > Is there a module that will help me with that? > > /David > Like this? import re units = {'B':0, 'k':10,'M':20,'G':30,'T':40} def parse(text):

Re: Python vs C for a mail server

2006-02-01 Thread Randall Parker
Magnus Lycka wrote: > Randall Parker wrote: > > Also, compile time errors get caught sooner. They get caught before > > tests even get written. > > Not if you do Test Driven Tevelopment. Then you write > the tests before you compile your target code! It's > also my experience that the write test -

Capture Windows command line output - put in text file

2006-02-01 Thread Ernesto
I'm looking for a way to capture command line output from a cmd session. Is there a way to use python to launch the application from the beggining then stream all of the output to a text file ? -- http://mail.python.org/mailman/listinfo/python-list

calling a class method in a python module

2006-02-01 Thread rtuhin
Hi I am trying to write a C code to call a class function in a python module. Here's my python module: def fib(n):# write Fibonacci series up to n a, b = 0, 1 while b < n: print b, a, b = b, a+b def fib2(n): # return Fibonacci series up to n result = [] a, b =

howto catch an Exception and still print the TraceBack?

2006-02-01 Thread Saizan
In an event-driven application i'd like to keep the program alive regardless of any exceptions raised by the handlers, but still be able to debug them by reading the appropriate TraceBack from stderr. I can put something like: try: self.call_handler(handler,*args) except Exception, e:

load module named "datetime" and change the directory of output file?

2006-02-01 Thread ye juan
Hi, all I have some questions to ask: 1. How can I add a standard module named "datetime" in Jython when the error happens :"Traceback (innermost last): File "C:\python\test.py", line 3, in ? ImportError: no module named datetime " The line 3 is writen: "from datetime import datetime, tzinfo

Re: Rur-ple lessons 0.36

2006-02-01 Thread André
Bonjour ! Je n'ai pas d'objections à ce que tu le fasse. La seule chose qui m'embête, c'est que les leçons ne sont qu'en anglais. C'est un peu pour moi une question de fierté ; au moins l'interface de rur-ple est traduite en français. André Roberge Méta-MCI wrote: > Bonjour ! > > Il me semble

Re: Rur-ple lessons 0.36

2006-02-01 Thread M�ta-MCI
Bonjour ! Il me semblerait sympathique que cette annonce soit dupliquée sur fr.comp.lang.python, et sur quelques autres newsgroups. Par exemple, puis-je répercuter l'annonce sur le newsgroup "programmation.python" de zoo-logique ? @-salutations -- Michel Claveau -- http://mail.python.org/

Re: Python vs C for a mail server

2006-02-01 Thread Magnus Lycka
Jens Theisen wrote: > Jay wrote: >> How much time in your C/C++ code is spent casting and trying to >>trick the compiler into doing something that it thinks you shouldn't be >>doing? > > Not much frankly. Though I have no doubt that there is a lot of code that > does, but more so in older C++ co

Re: Python vs C for a mail server

2006-02-01 Thread Magnus Lycka
Jay Parlar wrote: > Well guess what: The *only* code you'll have to change is inside the > function returning the object, none of the callers would have to change. > That's completely different from C++, where you'll have to change not > only the return type and the function, but you'll also hav

  1   2   >