[issue4249] HTTPResponse instance has no attribute 'code'

2008-11-02 Thread Jon Perez

New submission from Jon Perez [EMAIL PROTECTED]:

In http_response in HTTPErrorProcessor, the following line

code, msg, hdrs = response.code, response.msg, response.info()

results in an error because response.code is not a valid
attribute, changing it to response.status works, but is
this the correct bug fix?



See
http://www.linuxquestions.org/questions/linux-newbie-8/problem-with-yum-fedora-9-670586/

Traceback (most recent call last):
File /usr/bin/yum, line 30, in module
yummain.main(sys.argv[1:])
File /usr/share/yum/yummain.py, line 233, in main
clientStuff.get_package_info_from_servers(serverlist, HeaderInfo)
File /usr/share/yum/clientStuff.py, line 846, in
get_package_info_from_servers
progress_obj=None)
File /usr/share/yum/clientStuff.py, line 1327, in grab
bandwidth, conf.retries, retrycodes, checkfunc)
File /usr/share/yum/urlgrabber.py, line 237, in retrygrab
progress_obj, throttle, bandwidth)
File /usr/share/yum/urlgrabber.py, line 314, in urlgrab
fo = urllib2.urlopen(url)
File /usr/lib/python2.5/urllib2.py, line 121, in urlopen
return _opener.open(url, data)
File /usr/lib/python2.5/urllib2.py, line 380, in open
response = meth(req, response)
File /usr/lib/python2.5/urllib2.py, line 487, in http_response
code, msg, hdrs = response.code, response.msg, response.info()
AttributeError: HTTPResponse instance has no attribute 'code'

--
components: Library (Lib)
messages: 75454
nosy: jbperz808
severity: normal
status: open
title: HTTPResponse instance has no attribute 'code'
type: behavior
versions: Python 2.4, Python 2.5

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4249
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4250] urllib2.py: HTTPResponse instance has no attribute 'code'

2008-11-02 Thread Jon Perez

New submission from Jon Perez [EMAIL PROTECTED]:

In http_response() in HTTPErrorProcessor in urllib2.py, the following line

code, msg, hdrs = response.code, response.msg, response.info()

results in an error because response.code is not a valid
attribute, changing it to response.status works, but is
this the correct bug fix?



See
http://www.linuxquestions.org/questions/linux-newbie-8/problem-with-yum-fedora-9-670586/

Traceback (most recent call last):
File /usr/bin/yum, line 30, in module
yummain.main(sys.argv[1:])
File /usr/share/yum/yummain.py, line 233, in main
clientStuff.get_package_info_from_servers(serverlist, HeaderInfo)
File /usr/share/yum/clientStuff.py, line 846, in
get_package_info_from_servers
progress_obj=None)
File /usr/share/yum/clientStuff.py, line 1327, in grab
bandwidth, conf.retries, retrycodes, checkfunc)
File /usr/share/yum/urlgrabber.py, line 237, in retrygrab
progress_obj, throttle, bandwidth)
File /usr/share/yum/urlgrabber.py, line 314, in urlgrab
fo = urllib2.urlopen(url)
File /usr/lib/python2.5/urllib2.py, line 121, in urlopen
return _opener.open(url, data)
File /usr/lib/python2.5/urllib2.py, line 380, in open
response = meth(req, response)
File /usr/lib/python2.5/urllib2.py, line 487, in http_response
code, msg, hdrs = response.code, response.msg, response.info()
AttributeError: HTTPResponse instance has no attribute 'code'

--
components: Library (Lib)
messages: 75455
nosy: jbperz808
severity: normal
status: open
title: urllib2.py: HTTPResponse instance has no attribute 'code'
type: behavior
versions: Python 2.4, Python 2.5

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4250
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Indentation/whitespace

2006-01-14 Thread Jon Perez
Joe wrote:

 As for me, I'm not suggesting that braces are better than indentation.
 In fact, requiring indentation is a good idea, and I agree that braces
 can be quite ugly. It is the lack of visible block closing when there's
 more than one level that I dislike.

 ... I'm talking about double un-indent at the end of a nested loop,
 where the inner-most code is long enough that the end is a double
 dedent. It is especially bad because one persons single dedent can be as
 big as another persons double dedent. I agree with dislikes for brace
 notation, but I think it goes against the argument that Python's way is
 natural and right.

For me, I just feel Python's approach is simple and works.

 If one includes an end-thing for every start-thing, I think it is more
 natural, and still far better than C, but also more verbose.

Indeed.  I don't like unnecessary verbosity.

 In Python, one can use comments where needed, like below, which is what
 I eventually started doing. But, Python is supposed to require 'easy to
 read' code.

if ...
  for x...
for y...
  ... lots of code ...
#end for
  #end for
#end if

Well doesn't that mean that in Python, you get the best of both worlds?
You can make it verbose if you need the security of closing tokens,
but it is not necessary.

I suspect you may still have some sort of hangover from using C-style
indentation in that you are subliminally not confident that a block
is properly closed unless there is a visible closing token.


 The main thing that I just don't get is why Python promoters are so
 sure that everyone will like the Python syntax once they get used to it.

I myself would never assume that 100% of people will like Python syntax.  But
I know I took to it (including and *especially* the enforced indentation)
like a duck to water, and apparently so do many people.  But then that's
why there are other languages out there. ;-)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation/whitespace

2006-01-11 Thread Jon Perez
Joe wrote:
 Is Python going to support s syntax the does not use it's infamous
 whitespace rules? I recall reading that Python might include such a
 feature. Or, maybe just a brace-to-indentation preprocessor would be
 sufficient.

Nope never.

Because that would destroy one of the most important things
about Python. *Enforced* indentation is one of the reasons why
we love Python.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation/whitespace

2006-01-11 Thread Jon Perez
Ilias Lazaridis wrote:

Is Python going to support s syntax the does not use it's infamous
whitespace rules? 
 
 
 Of course.
 
 I estimate it will take around 1 to 2 years from now, until this 
 whitespace-concept will become optionally.
 
 Backwards-compatibility will be kept, thus those who love this feature 
 will remain happy python users.

If enforced indentation ever became optional, it would
completely defeat its purpose, because it would then
make 'creatively' indented python code possible which
would be an absolute nightmare to maintain.

 Python accepts the diversity of its userbase - at least where
 technically possible.

 And in this case it is.

Don't forget Python is also very much about language feature
aesthetics, and non-enforced indentation violates Python's
creator's design sensibilities completely.




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation/whitespace

2006-01-11 Thread Jon Perez
thakadu wrote:

 While I have no doubt that there are lousy browsers out there, the
 problem is not only with browsers, but also I agree with you its not
 Python's fault. The issue is that the code I am pasting may have used a
 DIFFERENT indentation scheme, so lets say I used four spaces and the
 code I am pasting used two spaces, or worse yet, a tab, that is where
 the problem arises. Now assuming that the browser and the copy and
 paste buffers dont screw up the indentation, when I paste that code
 into my editor that is where the problem arises. Sure if everyone stuck
 to the recommended 4 spaces in the style guide it would help. But even
 then in the context of your program you may be a further level of
 indentation.

Although the below does work, I believe:

def fun1():
  print I use two space indentation
  while (1):
  print but
  print four space works just as well
  print and can coexist


It just has to be consistent within a *single* block.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitching about the documentation...

2005-12-07 Thread Jon Perez
Tony Meyer wrote:

 This makes no sense.  If you want to complain about Python, try a  
 Perl list.  Why would a list dedicated to discussion about/help with  
 a language need complaints about the language?

Huh?!?  Usually people complain because they need help or feel
that things can be improved.

 You might want to consider the difference between complaining and  
 constructive criticism and suggestions, and which are likely to get  
 better responses.

In the case of programming languages, I don't see any real difference
between something being a 'constructive criticism' and a 'complaint'.

Why, oh why, do so many programmers insist on elevating software tools
they are using to the status of a *religion* such that they feel personally
offended when someone badmouths the language or tool they are using???

Anyone can badmouth Python and things associated with all they want, the
only time it would even begin to bother me is only if these were false
accusations or there is a dishonest agenda behind it.

If the complaints are untrue, then I'd just be laughing at others'
ignorance, not be offended by it.  If it is an honest complaint
arising out of personal experience with the language, then certainly
there is a need to examine what can be improved.

I generally don't see any need to feel uncomfortable with strident
whining against Python because the only thing being attacked here is a
software tool, not persons.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitching about the documentation...

2005-12-07 Thread Jon Perez
[EMAIL PROTECTED] wrote:

 FWIW I find Python's docs to be OK at best, with some horrible
 parts, and a lot of mediochre to poor parts.

I myself have no big beef about Python's docs, but you're certainly
not the first one to complain about them.  Xah Lee rants very
heavily against the quality against Python's docs and considers
many sections of it as written in a manner more to show-off one's
knowledge of jargon rather than to explain things properly.

I don't really notice that but this could be because I'm already
quite comfortable with jargon at the level it is used in the
Python docs (or maybe I'm one of those highfalutin' chaps as well
;-D).  Seriously though, sometimes jargon is necessary in order to
put across a point concisely and accurately so its use cannot always
be considered gratuitous.

The only problem I have with Python docs is that for most of
the the standard library API documentation, the function calls
are not organized very well (i.e. I don't believe they are
alphabetized or ordered in any intutive manner).

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite flavor of Linux? (for python or anything else)

2005-12-06 Thread Jon Perez
Ivan Shevanski wrote:
 Looking to replace my older flavor of linux with something new. . .What
 are some of your favorites for python programming and anything else?

Still Slackware for me.  Slackware is the 'true' Linux.  To paraphrase
the Brooke Shields Calvin Klein ad - Nothing comes between me and my kernel
(and utilities).

;-)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Most SHAMEFUL one-liner:

2005-12-06 Thread Jon Perez
Jeremy Moles wrote:
 I was looking through some code of my today and noticed this little gem
 I wrote a few days back that I had totally forgot about:
 
 fill = [(%%-%ds\n % (columns - 1)) %   for i in range(yoffset - 2)]
 
 ...and then I went on to do:
 
 .join(fill)
 
 Talk about using the wrong tool for the job... :(
 
 All I needed was:
 
   * (columns - 1) * (yoffset - 2)
 
 Anyone else remember any shameful one-liners like this? :) I'm just
 curious to see what kinda mistakes people make you think about a
 solution WAY TO HARD... :)

So TIMTOWTDI after all in Python!!



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Xah's Edu Corner: Examples of Quality Technical Writing

2005-12-06 Thread Jon Perez
Sherm Pendley wrote:

 Xah's a pretty well-known troll in these parts. I suppose he thinks someone
 is going to take the bait and rush to defend the other languages or some
 such nonsense.

Actually, I think Xah often has a point, except he can't
seem to express it without resorting to profanity and
a controlled manner, thus giving the impression he's a
troll.

Also, he seems to be blissfully unaware of the concept
of netiquette. ;-)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: p2exe using wine/cxoffice

2005-10-26 Thread Jon Perez
James Stroud wrote:

 better. The only reason I want this functionality is to make my software
 available to windoze users--despite their unfortunate ignorance, they are
 people too. That's what I always say.

Actually, I think it's many unix/linux users who are ignorant of just
how nice, stable and productive Windows can be as a desktop environment.

... and I really mean that.  ;-).



Ever since Win2K got rid of the constant blue screens, the reasons for
switching over to Linux have grown less and less urgent.

The 'Nix desktop environments are growing visibly more mature with each
passing year, but device support in Linux is still decidedly inferior and
it still takes far too much time to do some things you take for granted
under Windoze.

I'm experienced enough with Linux that I can customize a distribution
like Slackware to a fair extent, but for desktop work, I stay in Windows
almost exclusively.

I have this bunch of Linux zealots in a mailing list to thank for
encouraging me to realize how good Windows can be.

-- 
http://mail.python.org/mailman/listinfo/python-list


putting the output of a print statement into a string

2005-03-27 Thread Jon Perez
There are objects whose repr() is not the same
as what gets printed out when you apply the
print statement to them.  Usually these are
complex objects like exceptions.

Example:

 import smtplib

 server=smtplib.SMTP(smtp.yourisp.com)

 try:
  server.sendmail([EMAIL PROTECTED],
  [EMAIL PROTECTED],message)

except smtplib.SMTPRecipientsRefused, senderrs:
  exc_obj=senderrs

 repr(exc_obj)
'smtplib.SMTPRecipientsRefused instance at 0x00EA7C60'

 print exc_obj
{'[EMAIL PROTECTED]': (550, 'Verification failed for [EMAIL 
PROTECTED]\nunrouteable mail domain in88validdomain.com\nSender
verify failed')}


Question:

Is there a way to somehow put the output of 'print exc_obj' into
a string?




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: putting the output of a print statement into a string

2005-03-27 Thread Jon Perez
Thanks, man!  That was one fast reply...

Marc 'BlackJack' Rintsch wrote:
 In [EMAIL PROTECTED], Jon Perez wrote:


Question:

Is there a way to somehow put the output of 'print exc_obj' into
a string?


 There are ways to do even that, but maybe ``str(exc_obj)`` is enough for
 your needs!?

 Ciao,
   Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: huygens lands on titan

2005-01-17 Thread Jon Perez
I sure as hell bet it didn't too.
Fuzzyman wrote:
John Thingstad wrote:
--
huygens lands on titan
Using M2, Opera's revolutionary e-mail client:
http://www.opera.com/m2/
I bet it didn't...
Regards,
Fuzzy
http://www.voidspace.org.uk/python/index.shtml
--
http://mail.python.org/mailman/listinfo/python-list


Re: Integration with java (Jpype vs. JPE)

2005-01-15 Thread Jon Perez
Can someone summarize in a nutshell what is the
difference between JPype and JPE?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Producer/consumer Queue trick

2005-01-15 Thread Jon Perez
I don't get it.
If the consumer and the producer are separate threads,
why does the consumer thread block when the producer
thread is generating a new board?  Or why does it
take forever for the producer thread to be pre-empted?
Also, I don't understand why the solution works.
How does sleeping for .001 seconds right after putting
a new board on the queue solve the problem?
Evan Simpson wrote:
WEBoggle needs a new game board every three minutes.  Boards take an 
unpredictable (much less than 3min, but non-trivial) amount of time to 
generate. The system is driven by web requests, and I don't want the 
request that happens to trigger the need for the new board to have to 
pay the time cost of generating it.

I set up a producer thread that does nothing but generate boards and put 
them into a length-two Queue (blocking).  At the rate that boards are 
pulled from the Queue, it's almost always full, but my poor consumer 
thread was still being blocked for a long time each time it fetched a 
board.

At this point I realized that q.get() on a full Queue immediately wakes 
up the producer, which has been blocked waiting to add a board to the 
Queue.  It sets about generating the next board, and the consumer 
doesn't get to run again until the producer blocks again or is preempted.

The solution was simple: have the producer time.sleep(0.001) when 
q.put(board) returns.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org, Website of Satan

2005-01-12 Thread Jon Perez
This would be funny except for the fact that there are
actually people out there who will take this seriously.
http://rmitz.org/freebsd.daemon.html
Don't forget Python == Snake == Serpent == ...
;-D

[EMAIL PROTECTED] wrote:
 python.org = 194.109.137.226

 194 + 109 + 137 + 226 = 666

 What is this website with such a demonic name and IP address?  What
 evils are the programmers who use this language up to?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Another look at language comparisons

2005-01-12 Thread Jon Perez
Max M wrote:
Jan Dries wrote:
[EMAIL PROTECTED] wrote:
And there is hope for Python, as Guido has recently been seen with a 
beard :-)
http://www.tbray.org/ongoing/When/200x/2004/12/08/-big/IMG_3061.jpg

LOL, he is working on linux, isn't he?
So it was about bloody time.
Guido Van Rossum is now working on linux??
--
http://mail.python.org/mailman/listinfo/python-list


Re: Architecture of Python was removed ?

2005-01-12 Thread Jon Perez
Skip Montanaro wrote:
Yes, perhaps.  Note that it doesn't appear that the Wayback Machine contains
the meat of the essay, just the front page.  It came from a wiki.  Perhaps
Most of the text seems to be there, but there are some critical
diagrams (images) which the Wayback Machine did not archive.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Another look at language comparisons

2005-01-12 Thread Jon Perez
Anyone know of a cached copy where the photos are present?
The whole thing makes little sense with the photos gone.
Pierre Quentel wrote:
http://khason.biz/blog/2004/12/why-microsoft-can-blow-off-with-c.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: Another look at language comparisons

2005-01-12 Thread Jon Perez
Terry Reedy wrote:
It would hardly make more sense with the photos.
The photos would be graphic evidence and would make
it more entertaining to read through.

Not the law is clear? There is a beard - there is a success.
 There is no beard - you are guilty. 
Terry J. Reedy
And what about the moustache issue and Grace
Hopper (COBOL is/was a very popular language but
very much maligned and criticized like Perl and
BASIC whose creators had moustaches instead of
beards) ?
Also, what about C#?  AFAIK, Heljsberg has neither
beard nor moustache, or is he sprouting one now (no
pic to confirm...)?
--
http://mail.python.org/mailman/listinfo/python-list


Re: a new Perl/Python a day

2005-01-11 Thread Jon Perez
Bob Smith wrote:
With terms such as blabbering Unix donkeys and sloppy perl monkeys 
I would say that the monkey-mind is indeed one that is enamoured
with obfuscation and complicated gadgetry for its own sake.
Ever wonder why no one has ever considered using the phrase
Zen of Perl?  (yes, it sounds completely off-kilter)
... or why 'Perl monkey' is an oft-heard term whereas 'Python
monkey' just doesn't seem to be appropriate?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Windows GUIs from Python

2005-01-11 Thread Jon Perez
Wow, Venster looks cool and to think I've never
heard of it before.  I knew following this
newsgroup would pay off one day...
Luke Skywalker wrote:
On Tue, 11 Jan 2005 22:15:36 +0100, Thomas Heller [EMAIL PROTECTED]
wrote:
Well, venster.  Although it is most certainly alpha.  But with some
work...

Thx, I'll keep an eye on it.
http://venster.sourceforge.net/
Luke.
--
http://mail.python.org/mailman/listinfo/python-list


Re: The best way to do web apps with Python?

2005-01-09 Thread Jon Perez
worzel wrote:
What is the best way to web developemnt with Python? Is there anything 
close to PHP style in-page script placement that can create and use 
other Python objects? 
Spyce ( http://spyce.sf.net )  is what you're looking for.  I
was looking exactly for the same thing as you are - a PHP workalike -
and tried around half a dozen or so alternatives before I settled
upon Spyce as the best one.
If Spyce's [[ and ]] delimiters are not to your liking, you can
actually switch to using % and % without any problem.  Spyce
also handles the Python indent issue quite nicely and elegantly,
imo, while you can use the free and open source SciTE text editor
to separately syntax highlight Spyce source code + Javascript + HTML
very nicely (config file tweaking required).
what is the expectataion of Python for this kind of 
stuff? Would one use Python for certain other things but turn to PHP for 
web apps - or would one use their Python skills in place of PHP?
Python can be a full (and superior) replacement for PHP.  The only
caveat would be third party hosting support.
The following post by on the Spyce mailing list (by Andy of
Neotitans.com web development) explains why:
One major roadblock to Spyce and other Python server side
technologies seeing acceptance on the scale of PHP is the
fact that mod_python deployment on 3rd party shared hosting
solutions is more complex and involved than mod_php.  Apparently,
security considerations mean that each mod_python user will need
to get their own instance of an Apache server acting as a proxy
behind a central instance of an Apache server (which is what's
responsible for accepting requests at the shared server's http port).
A per-shared user Spyce proxy server approach would likely be
more economical (of server resources) and more easily set up than
multiple mod_python-enabled Apache server instances.
If your hosting solution will permit you to have your own
long-running processes (afaik, most won't :-( ), and if they
are willing make the necessary httpd.conf mods to pass Spyce
page requests over to your own instance of the Spyce proxy
server or their .htaccess setup allows you to do that yourself,
then you're all set.
I'm also happy to report that Spyce CGI works great on any
hosting solution that supports CGI and has Python installed.
This means that virtually all Linux-based hosting solutions
(including those ultra-cheap shared server ones) will support
Spyce CGI.
It would seem that FastCGI support is probably the hardest to
come by.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Continuations Based Web Framework - Seaside.

2005-01-02 Thread Jon Perez
none wrote:
Does Python really need yet another framework? Apart from the 
intellectual excersise, wouldn't it be nice if Python would get a 
framework for the rest of us (meaning: mere mortals) which would focus 
 upon getting work done in a simple manner instead of creating yet 
another, new, hip, exciting, way of creating dynamic websites? If Python 
cannot deliver a PHP clone, at least you would expect a Rails lookalike. 
Spyce (http://spyce.sf.net) would be the superior Python-based PHP clone
you are looking for.
--
http://mail.python.org/mailman/listinfo/python-list


Re: PHP vs. Python (speed-wise comparison)

2004-12-27 Thread Jon Perez
[EMAIL PROTECTED] wrote:
Anyone know which is faster?  I'm a PHP programmer but considering
getting into Python ... did searches on Google but didn't turn much up
on this.
Thanks!
Stephen
If you're talking about usage as a server side scripting
language, then PHP will likely give better page serving
throughput for the same hardware configuration versus
even something that is mod_python based (but I believe
the speed diff would be well under 100%).
However, Python is just so much superior as a language (I
was deep into PHP before I tried out Python and I always hate
having to go back to PHP nowadays in the cases where it is
unavoidable) that you will still want to use Python even if
PHP requires lower server specs to handle the same throughput.
Also, if you have a more complex application for which
pooled variable reuse is an important performance-determining
factor, Python-based server-side scripting solutions might
offer better control of this aspect and may thus yield
superior performance to a PHP-based one.
The real problem with Python is not speed but _availability_.
The number of hosting services out there supporting mod_php
completely outstrips those supporting mod_python.  Moreover, they
are significantly cheaper, and offer a lot more features
(Fantastico, etc...).  The python-based hosting solutions
out there tend to be dedicated to Python and thus do not
offer these solutions.
If this is not an issue (i.e. you will be running your
own server), then I highly recommend going the Python
route using something like Spyce (which is the closest
thing to PHP in the Python world).
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python vs. Perl

2004-12-13 Thread Jon Perez
Michael McGarry wrote:
I intend to use a scripting language for GUI development and front end 
code for my simulations in C. I want a language that can support SQL, 
Sockets, File I/O, and shell interaction.
In my experience, Python is definitely much more suitable than Perl
for the first four areas mentioned in the last sentence.  For the
last area, I'm not sure, but Python's capabilities in this area are
also quite good.
For GUI development and front end, Python most likely has better
facilities than Perl, but still leaves a lot to be desired (after
getting a taste of Delphi 3rd party VCL components, all other RAD
environments pale in comparison).
--
http://mail.python.org/mailman/listinfo/python-list