How do I do this using httplib.HTTPConnection and
httplib.HTTPConnection.request()? The library reference only gives a
simple GET example with no header stuff. I tried this, but it didn't work:
conn.request("GET", "/somepage.html", None, {"AUTHORIZATION": "Basic
username:password"})
Thanks for t
John J. Lee wrote:
> Jonas Galvez <[EMAIL PROTECTED]> writes:
>
>> Christopher J. wrote:
>> > I tried this, but it didn't work:
>> > conn.request("GET", "/somepage.html", None,
>> > {"AUTHORIZATION": "Basic username:password"})
> [...]
>> import re, base64, urllib2
>>
>> userpass = ('user', 'p
First off, writing the blob. From what I gather on the internet, I'm
suppose to read the entire file into memory (a Python string), then create
a dbiRaw object with that string and use the dbiRaw object in an insert
statement?
That doesn't sound very efficient to me. What if my computer only has
I find myself doing the following very often:
class Struct:
pass
...
blah = Struct()
blah.some_field = x
blah.other_field = y
...
Is there a better way to do this? Is this considered bad programming
practice? I don't like using tuples (or lists) because I'd rather use
symbolic names, ra
I get this exception when I run the following code:
Exception exceptions.TypeError: 'super() argument 1 must be type, not None'
in > ignored
Here is the code:
class Txrposdn(PRI.BasicBatch):
def __init__(self, *argv):
super(Txrposdn, self).__init__(*argv)
def __del__(self):
super(T
Fredrik Lundh wrote:
> "Warning: Due to the precarious circumstances under which __del__()
> methods are invoked, exceptions that occur during their execution are
> ignored, and a warning is printed to sys.stderr instead. Also, when
> __del__() is invoked in response to a module be
Jeff Shannon wrote:
> Christopher J. Bottaro wrote:
>
>> 2 Questions...
>> 1) Why does this never happen in C++? Or does it, its just never
>> happened to me?
>> 2) I can understand random destruction of instantiated objects, but I
>> find it weir
Jeff Shannon wrote:
> Python's __del__() is not a C++/Java destructor.
Learn something new everyday... What is it then? Excuse my ignorance, but
what are you suppose to do if your object needs to clean up when its no
longer used (like close open file handles, etc)? Are you use supposed to
make
Batista, Facundo wrote:
> [Shawn Milo]
>
> #- I was just wondering what the best books were for learning Python.
> #-
> #- Which books are good for getting started, and which should
> #- be saved for
> #- later, or or not useful except as a reference for the learned?
>
> My particular process did
Hello,
I want to be able to say stuff like "import CJB.ClassA" and "import
CJB.ClassB" then say "c = CJB.ClassA()" or "c = CJB.ClassB()". CJB will be
a directory containing files "ClassA.py" and "ClassB.py".
Now that I think about it, that can't work because Python allows you
imp
Why don't this code work?
import PRI
class Poscdnld_PYIO(PRI.BasicBatch):
def __init__(self, *argv):
super(Poscdnld_PYIO, self).__init__(*argv)
x = Poscdnld_PYIO()
I get this exception:
File "poscdnld_pyio.py", line 52, in __init__
super(Poscdnld_PYIO, self).__init__(*argv)
Typ
Thank you everyone for the help, that cleared it up for me.
Andy Gross wrote:
>
> Florian,
>
> See: http://www.python.org/doc/newstyle.html
>
> /arg
>
>
> On Dec 7, 2004, at 5:38 AM, Florian Lindner wrote:
>
>> Steven Bethard schrieb:
>>> Chri
I have a generator that works like this:
for row in obj.ExecSQLQuery(sql, args):
# process the row
Now there are some querys that run where I know the result will only be a
single row. Is there anyway to get that single row from the generator
without having to use it in a for loop? I wa
Steven Bethard wrote:
> I don't do much with SQL/databases stuff, but if you really know the
> result will be a single row, you can take advantage of tuple unpacking
> and do something like:
>
> row, = obj.ExecSQLQuery(sql, args)
>
> or
>
> [row] = obj.ExecSQLQuery(sql, args)
>
> This has the a
I have a script with a class in it:
class Class:
def f(x, y):
# do something
I start up the debugger like this:
python /usr/lib/python2.3/pdb.py myscript.py
I want to set a conditional breakpoint:
b Class.f, x == 1 and y == 2
...but that doesn't work. How can I do what I
Colin J. Williams wrote:
> Christopher J. Bottaro wrote:
>> I have a script with a class in it:
>> class Class:
>> def f(x, y):
>> # do something
>>
>> I start up the debugger like this:
>> python /usr/lib/python2.3/pdb.py m
help.
Fredrik Lundh wrote:
> Christopher J. Bottaro wrote:
>
>>I installed Python-2.3.4 from source...
>> configure && make && make install
>>
>> Now I want to remove it, but make uninstall doesn't work. How do I
>> uninstall it?
>
>
I installed Python-2.3.4 from source...
configure && make && make install
Now I want to remove it, but make uninstall doesn't work. How do I
uninstall it?
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Python's base64 module encodes and decodes differently than PHP's. Python's
docs says that it ahere's to RFC1521 (sept 1993), while PHP's adheres to
RFC2045 (nov 1996). Is there any Python module that uses the new standard?
Why is Python using the old standard anyways?
Thanks.
--
http://mail.
Christopher J. Bottaro wrote:
> Python's base64 module encodes and decodes differently than PHP's.
> Python's docs says that it ahere's to RFC1521 (sept 1993), while PHP's
> adheres to
> RFC2045 (nov 1996). Is there any Python module that uses the new
&g
Fredrik Lundh wrote:
> Christopher J. Bottaro wrote:
>> Python's base64 module encodes and decodes differently than PHP's.
>
> really?
Yeah, weird, huh? Actually the problem is that Python puts newlines at
every 76th char. How do I stop Python from doing that? I
Christopher J. Bottaro wrote:
>
>
> Fredrik Lundh wrote:
>
>> Christopher J. Bottaro wrote:
>>> Python's base64 module encodes and decodes differently than PHP's.
>>
>> really?
>
> Yeah, weird, huh? Actually the problem is that Py
Hi,
I can't for the life of me figure out how to get the post vars when using
basehttpserver. Here's my code:
class MyHandler(BaseHTTPRequestHandler):
def do_POST(self):
print self.path, self.command
if self.rfile:
print self.rfile.read()
else:
print 'no
This post is just the culmination of my thoughts and discussions with my
coworkers on Python. If you are not interested, please skip over it.
At my work, we are developing a product from scratch. It is completely
modular and the modules communicate via SOAP. Because of that, we can
implement in
Christopher J. Bottaro wrote:
> ...blah blah blah...
Heh, silly me...there is already a huge thread about this...kinda.
The intricacies of the computing term "greedy" aside, yes I think the Python
documentation should generally be better. What that means, I have no idea.
All I k
[EMAIL PROTECTED] wrote:
> I think Python's doc really rock. It's odd, why do you refer to the
> tutorial when the lib API is what I'd consider "the docs".
I guess I mean Python needs a manual, which is basically what the tutorial
serves as, but its not comprehensive and organized like how (I thi
Steven Bethard wrote:
> Christopher J. Bottaro wrote:
>> After we were done, we talked about the pros and cons of the languages.
>> Funny, the con of Python (documentation) is PHP's strong point. The PHP
>> manual is extremely easy to navigate and its search feature wor
SÃbastien BoisgÃrault wrote:
>
> "Manual" == scope of the *Lib Reference* + informal style of the
> *Tutorial*,
>
> Right ?
Yes! That sounds good. "Informal style" yes, but "tutorial style" no. I
shouldn't be there to teach like the tutorial, but for reference. And of
course, the manual sho
rbt wrote:
> Christopher J. Bottaro wrote:
>> Christopher J. Bottaro wrote:
>>
>>
>>>...blah blah blah...
>>
>>
>> Heh, silly me...there is already a huge thread about this...kinda.
>>
>> The intricacies of the computing term "
Steven Bethard wrote:
> Ivan Van Laningham wrote:
>> The Python docs are not ideal. I can never remember, for instance,
>> where to find string methods (not methods in the string module, but
>> methods with '')
>
> Hmmm... Well going to http://docs.python.org/ and typing "string
> methods" into
Steven Bethard wrote:
> Christopher J. Bottaro wrote:
>> Contrast that with Python. First off there is no "search" mechanism
>> built into the documentation page (yes I know you can google it, but that
>> just doesn't feel right).
>
> Um, are you
I actually want all the parent classes too. So if D derives off C derives
off B derives off A, I ultimately want a tuple ('D', 'C', 'B', 'A').
For those of you following the Python Documentation thread, this is a good
example of how the PHP manual is "better". I found how to do this in a few
sec
Bengt Richter wrote:
> >>> type(obj)
>
> >>> type(obj).mro()
> [, , ,
> [, ]
> >>> tuple(x.__name__ for x in type(obj).mro())
> ('A', 'B1', 'B2', 'C', 'object')
Wow awesome, thats exactly what I was looking for. I hate to bring up the
documentation thing again...but.where the hell is
Christopher J. Bottaro wrote:
> Bengt Richter wrote:
>
>> >>> type(obj)
>>
>> >>> type(obj).mro()
>> [, , ,
>> [, ]
>> >>> tuple(x.__name__ for x in type(obj).mro())
>> ('A', 'B1', 'B2
Hello fellow Pythonists,
Is there such a thing? My work is thinking of maybe experimenting with
Ruby on Rails for some lesser projects. Naturally, I wonder if Python can
do as good a job or better...
Thanks for the info,
-- C
--
http://mail.python.org/mailman/listinfo/python-list
bruno modulix wrote:
> Christopher J. Bottaro wrote:
>> Hello fellow Pythonists,
>> Is there such a thing?
>
> As what ?
> Oops, sorry, the question is in the subject... May be helpful to repeat
> it in the body.
>
> You may want to have a look at Subwa
I want to get the name of the function from within the function. Something
like:
def myFunc():
print __myname__
>>> myFunc()
'myFunc'
Really what I want to do is to easily strip off the prefix of a function
name and call another function. Like this:
def prefix_myFunc(a, b, c):
name = __myn
Paul McGuire wrote:
> we just recently on
> this forum had someone ask about "polymorphism" when what they really
> meant was "overloaded method signatures." (It is even more unfortunate
> that language features such as overloaded method signatures and
> operator overloading get equated with OO
Steven Bethard wrote:
> Christopher J. Bottaro wrote:
>> I want to get the name of the function from within the function.
>> Something like:
>>
>> def myFunc():
>> print __myname__
>>
>>>>> myFunc()
>> 'myFunc'
>
&
Steven Bethard wrote:
[...snip...]
> Yes, has's suggestion is probably the right way to go here. I'm still
> uncertain as to your exact setup here. Are the functions you need to
> wrap in a list you have? Are they imported from another module? A
> short clip of your current code and what you wa
Steven Bethard wrote:
...snip...
> Something like this might work:
>
> py> class C(object):
> ... def func_a(self):
> ... print "func_a"
> ... def func_b_impl(self):
> ... print "func_b"
> ... raise Exception
> ... def __getattr__(self, name):
> ... f
Kent Johnson wrote:
...snip...
>> I guess I'm just lazy, but I don't want to write the wrapper func for
>> each
>> new func I want to add. I want it done automatically.
>
> You can do this almost automatically with a decorator:
>
> def in_try(func):
> def wrapper(*args, **kwargs):
>
Steven Bethard wrote:
> Christopher J. Bottaro wrote:
>> Kent Johnson wrote:
>>>class C(object):
>>>@in_try
>>>def func_a(self):
>>>print "func_a"
>>>
>>>@in_try
>>>def func_b(sel
flamesrock wrote:
> ok, so to my knowledge, object oriented means splitting something into
> the simplest number of parts and going from there.
That sounds like normal top down imperative (procedural) programming to me.
> But the question is- when is it enough?
Thats a judgment call on the prog
Hey again Steven,
I'm still having problems...
Steven Bethard wrote:
> Something like this might work:
>
> py> class C(object):
> ... def func_a(self):
> ... print "func_a"
> ... def func_b_impl(self):
> ... print "func_b"
> ... raise Exception
> ... def _
Christopher J. Bottaro wrote:
> The problem is:
>>>> c.func_b.__name__
> 'wrapper'
>
> That messes up SOAPpy's RegisterFunction() method which apparently depends
> on the __name__ of the function to publish it as an available SOAP
> function.
>
Hi,
Why is there no support for explicit transactions in the DB API? I mean
like transaction() to start the trans and commit() and rollback() would end
the trans or something.
The reason why I ask is because I wrote a daemon that interacts with a
Postgres DB. The value of CURRENT_TIMESTAMP accor
Magnus Lycka wrote:
> You might have spotted a fairly nasty bug there!
> PostgreSQL violates the SQL standards by running in autocommit mode
> unless you explicitly perform its non-standard BEGIN command. If you
> are right about the behaviour you describe, the PostgreSQL binding
> for Python t
48 matches
Mail list logo