Re: Updated blog post on how to use super()

2011-06-01 Thread Brian J Mingus
On Tue, May 31, 2011 at 8:44 PM, Raymond Hettinger pyt...@rcn.com wrote:

 I've tightened the wording a bit, made much better use of keyword
 arguments instead of kwds.pop(arg), and added a section on defensive
 programming (protecting a subclass from inadvertently missing an MRO
 requirement).  Also, there is an entry on how to use assertions to
 validate search order requirements and make them explicit.

  http://bit.ly/py_super
 or
  http://rhettinger.wordpress.com/2011/05/26/super-considered-super/

 Any further suggestions are welcome.  I'm expecting this to evolve
 into how-to guide to be included in the regular Python standard
 documentation.  The goal is to serve as a reliable guide to using
 super and how to design cooperative classes in a way that lets
 subclasses compose and extent them.


 Raymond Hettinger

 
 follow my python tips on twitter: @raymondh
 --
 http://mail.python.org/mailman/listinfo/python-list


I would recommend a more constructive introduction that has less
meta-analysis of what the post is about and just digs in.

*If you aren’t wowed by Python’s super() builtin, chances are you don’t
really know what it is capable of doing or how to use it effectively.*

This strikes me as a thinly veiled dis..

*Much has been written about super() and much of that writing has been a
failure.
*

I'm having a hard time seeing how this supremely condescending bit is
helpful? If *your* writing is not a failure time will tell.
*

 This article seeks to improve on the situation by:

   - providing practical use cases
   - giving a clear mental model of how it works
   - showing the tradecraft for getting it to work every time
   - concrete advice for building classes that use super()
   - solutions to common issues
   - favoring real examples over abstract ABCD diamond
diagramshttp://en.wikipedia.org/wiki/Diamond_problem
   .

*

These strikes me as notes by the author for the author. You could easily
extract the gist of the above points and convert them into a sentence or
two.

Overall, take everything up to the end of the last bullet point and convert
it into a 2-3 sentence intro paragraph.

-- 
Brian Mingus
Graduate student
Computational Cognitive Neuroscience Lab
University of Colorado at Boulder
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is list comprehension necessary?

2010-11-21 Thread Brian J Mingus
On Tue, Oct 26, 2010 at 3:31 AM, Xah Lee xah...@gmail.com wrote:

 ...


No, list comprehensions are not nececessary, just like the plethora of
expletives in the majority of your OPs on this list are not necessary. The
question is are they useful, and the answer is the case of list
comprehensions is obviously yes, whereas in the case of the expletives you
love to spew everywhere the answer is no. Framing, young grasshopper.
Framing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why is this group being spammed?

2010-07-24 Thread Brian J Mingus
On Sat, Jul 17, 2010 at 11:01 PM, be.krul be.k...@gmail.com wrote:

 why is this group being spammed?
 --
 http://mail.python.org/mailman/listinfo/python-list


Here's a few of theories:

1) This isn't a strong enough community to warrant a group of people who
moderate the list and make sure spam doesn't come through
2) Thousands of python hackers aren't smart enough to figure out how to stop
spam
3) Whenever people post threads asking why this list is getting spammed they
get heckled
4) Uber leet old skool script kiddies read the list through some mechanism
that allows them to get rid of the spam, unlike the other 99% of us.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-26 Thread Brian J Mingus
On Sat, Jun 26, 2010 at 10:06 AM, Christian Heimes li...@cheimes.de wrote:

 Am 26.06.2010 17:59, schrieb Stefan Reich:
  The main problem is that Python 3 is incompatible with almost all
  scripts written for Python 2 (if they use print). And it gets worse:
  Python 3 scripts are incompatible with Python 2! (If they use print
  variants, like writing to a file.)

 Seems like you don't know that you can easily migrate your scripts with
 the tool 2to3. Also you can write Python 3 compatible scripts in
 Python 2.6 and newer: from __future__ import print_function.

 Christian


This comment and many others in this thread fail to address the substance of
the OP's point. Languages such as Python and Perl have adopted the strange
practice of making new versions of the language backwards incompatible. Many
other languages such as Java remain backwards compatible and thus do not
alienate their userbase.

I would also like to point out in this thread a bit of evidence that this
was a bad idea: Python 3 adoption has been extremely slow and it is still
not a sure bet that it will ever become very popular. I am not alone in
having tens of thousands of lines of python 2 code, and you can bet that all
of us have edge cases that the 2to3 tool is not going to catch. That means
that in order to run old code in Python 3 we have to first run the tool and
then sanity check it to make sure it has the same behavior (and honestly, do
you really have test cases for every bit of Python you've ever written? No,
and neither do the rest of us.). Where the tool fails we have to find out
why and then go fix our code.

Nobody wants to be involved in this hassle. At best you can hope in the
future that both Python 2 and 3 will be installed on user's systems, and
Python 2 will be the default executable. But expect it to be a very, very
long time before Python 3 adoption overtakes Python 2. There is simply no
impetus to do it. The upgrades to the language are lost on 99% of the
users who first bought into Python because they already liked it and they
have no interest in learning a new version. Myself included.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: EURO GIRLS MISS EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK G

2010-03-21 Thread Brian J Mingus
On Sun, Mar 21, 2010 at 10:55 AM, Zooko O'Whielacronx zoo...@gmail.comwrote:

 On Sat, Mar 20, 2010 at 1:27 PM, Brian J Mingus
 brian.min...@colorado.edu wrote:
  Moderating this stuff requires moderating all messages.

 Not quite. GNU Mailman comes with nice features to ease this task. You
 can configure it so that everyone who is currently subscribed can post
 freely, but new subscribers get a moderated bit set on them. The
 first time this new subscriber attempts to post to the list, a human
 moderator has to inspect their message and decide whether to approve
 it or deny it. If they human moderator approves it, they can also on
 the same web form remove the moderated bit from that poster.

 Therefore, the volunteer work required would be inspecting the *first*
 post from each *new* subscriber to see if that post is spam.

 Regards,

 Zooko


I like this approach, but I like even better simply disabling the usenet
gateway. I can't find the message now but someone mentioned it would almost
completely get rid of the spam problem. I disagree with Steve Holden that
since it's only ~1% we should just ignore it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: EURO GIRLS MISS EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK G

2010-03-20 Thread Brian J Mingus
Moderating this stuff requires moderating all messages. It would take a team
of volunteers.

On Sat, Mar 20, 2010 at 12:55 PM, alex goretoy agore...@gmail.com wrote:

 what do i do to remove this crap? how do i moderate it?

 why not gpg sign messages on python-list that way you know your authorized
 to post and spammers will have one more vector to deal with, there in
 stopping the not so leet
 -Alex Goretoy

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


Re: EURO GIRLS MISS EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK G

2010-03-19 Thread Brian J Mingus
On Fri, Mar 19, 2010 at 10:18 PM, Naeem kse.listed@gmail.com wrote:

 EURO GIRLS MISS EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY
 FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com   SEXY
 RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS
 SEXY HOLLYWOOD GIRLS SEXY BOLLYWOODEURO GIRLS MISS EUROPE
 MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on
 www.sexyandpretty-girls.blogspot.com   SEXY RUSSIAN GIRLS SEXY
 GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS SEXY HOLLYWOOD GIRLS
 SEXY BOLLYWOODEURO GIRLS MISS EUROPE MISS FRENCH FRENCH
 PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com
 SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK
 GIRLS SEXY HOLLYWOOD GIRLS SEXY BOLLYWOODEURO GIRLS MISS
 EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on
 www.sexyandpretty-girls.blogspot.com   SEXY RUSSIAN GIRLS SEXY
 GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS SEXY HOLLYWOOD GIRLS
 SEXY BOLLYWOODEURO GIRLS MISS EUROPE MISS FRENCH FRENCH
 PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com
 SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK
 GIRLS SEXY HOLLYWOOD GIRLS SEXY BOLLYWOODEURO GIRLS MISS
 EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on
 www.sexyandpretty-girls.blogspot.com   SEXY RUSSIAN GIRLS SEXY
 GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS SEXY HOLLYWOOD GIRLS
 SEXY BOLLYWOODEURO GIRLS MISS EUROPE MISS FRENCH FRENCH
 PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com
 SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK
 GIRLS SEXY HOLLYWOOD GIRLS SEXY BOLLYWOODEURO GIRLS MISS
 EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on
 www.sexyandpretty-girls.blogspot.com   SEXY RUSSIAN GIRLS SEXY
 GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS SEXY HOLLYWOOD GIRLS
 SEXY BOLLYWOODEURO GIRLS MISS EUROPE MISS FRENCH FRENCH
 PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com
 SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK
 GIRLS SEXY HOLLYWOOD GIRLS SEXY BOLLYWOODEURO GIRLS MISS
 EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on
 www.sexyandpretty-girls.blogspot.com   SEXY RUSSIAN GIRLS SEXY
 GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS SEXY HOLLYWOOD GIRLS
 SEXY BOLLYWOODEURO GIRLS MISS EUROPE MISS FRENCH FRENCH
 PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com
 SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK
 GIRLS SEXY HOLLYWOOD GIRLS SEXY BOLLYWOODEURO GIRLS MISS
 EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on
 www.sexyandpretty-girls.blogspot.com   SEXY RUSSIAN GIRLS SEXY
 GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS SEXY HOLLYWOOD GIRLS
 SEXY BOLLYWOODEURO GIRLS MISS EUROPE MISS FRENCH FRENCH
 PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com
 SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK
 GIRLS SEXY HOLLYWOOD GIRLS SEXY BOLLYWOODEURO GIRLS MISS
 EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on
 www.sexyandpretty-girls.blogspot.com   SEXY RUSSIAN GIRLS SEXY
 GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS SEXY HOLLYWOOD GIRLS
 SEXY BOLLYWOODEURO GIRLS MISS EUROPE MISS FRENCH FRENCH
 PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com
 SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK
 GIRLS SEXY HOLLYWOOD GIRLS SEXY BOLLYWOODEURO GIRLS MISS
 EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on
 www.sexyandpretty-girls.blogspot.com   SEXY RUSSIAN GIRLS SEXY
 GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS SEXY HOLLYWOOD GIRLS
 SEXY BOLLYWOODEURO GIRLS MISS EUROPE MISS FRENCH FRENCH
 PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com
 SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK
 GIRLS SEXY HOLLYWOOD GIRLS SEXY BOLLYWOODEURO GIRLS MISS
 EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on
 www.sexyandpretty-girls.blogspot.com   SEXY RUSSIAN GIRLS SEXY
 GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS SEXY HOLLYWOOD GIRLS
 SEXY BOLLYWOODEURO GIRLS MISS EUROPE MISS FRENCH FRENCH
 PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com
 SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK
 GIRLS SEXY HOLLYWOOD GIRLS SEXY BOLLYWOODEURO GIRLS MISS
 EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on
 www.sexyandpretty-girls.blogspot.com   SEXY RUSSIAN GIRLS SEXY
 GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS SEXY HOLLYWOOD GIRLS
 SEXY BOLLYWOODEURO GIRLS MISS EUROPE MISS FRENCH FRENCH
 PRETTY GIRLS SEXY FRENCH GIRLS on www.sexyandpretty-girls.blogspot.com
 SEXY RUSSIAN GIRLS SEXY GREEK GIRLS SEXY DUTCH GIRLS SEXY UK
 GIRLS SEXY HOLLYWOOD GIRLS SEXY BOLLYWOODEURO GIRLS MISS
 EUROPE MISS FRENCH FRENCH PRETTY GIRLS SEXY FRENCH GIRLS on
 www.sexyandpretty-girls.blogspot.com   SEXY RUSSIAN GIRLS SEXY
 GREEK GIRLS SEXY DUTCH GIRLS SEXY UK GIRLS SEXY HOLLYWOOD GIRLS
 SEXY BOLLYWOODEURO GIRLS MISS EUROPE MISS FRENCH FRENCH
 

Re: Hacker News, Xahlee.Org, and What is Politics?

2010-03-15 Thread Brian J Mingus
On Mon, Mar 15, 2010 at 1:16 AM, Xah Lee xah...@gmail.com wrote:

 A essay related to the recent discussion of banning, and lisp
 associated group at ycombinator.com .


Is there some Python related issue I might help you out with? Or perhaps you
wish to provide Python assistance to someone on this list. Or perhaps you
would like to write some Python code, or read the friendly Python manual, or
draft a new PEP. Any one of these things would be a much better usage of
your time than drafting middle to high school quality essays.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: BeautifulSoup

2010-01-15 Thread Brian J Mingus
On Wed, Jan 13, 2010 at 5:46 AM, yamamoto blueskykin...@gmail.com wrote:
 Hi,
 I am new to Python. I'd like to extract a tag from a website by
 using beautifulsoup module.
 but it doesnt work!

 //sample.py

 from BeautifulSoup import BeautifulSoup as bs
 import urllib
 url=http://www.d-addicts.com/forum/torrents.php;
 doc=urllib.urlopen(url).read()
 soup=bs(doc)
 result=soup.findAll(a)
 for i in result:
print i


 Traceback (most recent call last):
  File C:\Users\falcon\workspace\p\pyqt\ex1.py, line 8, in module
soup=bs(doc)
  File C:\Python26\lib\site-packages\BeautifulSoup.py, line 1499, in
 __init__
BeautifulStoneSoup.__init__(self, *args, **kwargs)
  File C:\Python26\lib\site-packages\BeautifulSoup.py, line 1230, in
 __init__
self._feed(isHTML=isHTML)
  File C:\Python26\lib\site-packages\BeautifulSoup.py, line 1263, in
 _feed
self.builder.feed(markup)
  File C:\Python26\lib\HTMLParser.py, line 108, in feed
self.goahead(0)
  File C:\Python26\lib\HTMLParser.py, line 148, in goahead
k = self.parse_starttag(i)
  File C:\Python26\lib\HTMLParser.py, line 226, in parse_starttag
endpos = self.check_for_whole_start_tag(i)
  File C:\Python26\lib\HTMLParser.py, line 301, in
 check_for_whole_start_tag
self.error(malformed start tag)
  File C:\Python26\lib\HTMLParser.py, line 115, in error
raise HTMLParseError(message, self.getpos())
 HTMLParser.HTMLParseError: malformed start tag, at line 276, column 36

 any suggestion?
 thanks in advance

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


BeautifulSoup is overkill for this anyways.

 *#!/bin/python*from urllib import urlopen
html = urlopen(http://www.d-addicts.com/forum/torrents.php;).read()links
= set([link.split('')[0] *for* link in html.split('href=')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do I have to use threads?

2010-01-06 Thread Brian J Mingus
On Wed, Jan 6, 2010 at 6:24 AM, Philip Semanchuk phi...@semanchuk.comwrote:


 On Jan 6, 2010, at 12:45 AM, Brian J Mingus wrote:

  On Tue, Jan 5, 2010 at 9:36 PM, Philip Semanchuk phi...@semanchuk.com
 wrote:


 On Jan 5, 2010, at 11:26 PM, aditya shukla wrote:

 Hello people,


 I have 5 directories corresponding 5  different urls .I want to download
 images from those urls and place them in the respective directories.I
 have
 to extract the contents and download them simultaneously.I can extract
 the
 contents and do then one by one. My questions is for doing it
 simultaneously
 do I have to use threads?


 No. You could spawn 5 copies of wget (or curl or a Python program that
 you've written). Whether or not that will perform better or be easier to
 code, debug and maintain depends on the other aspects of your program(s).

 bye
 Philip



 Obviously, spawning 5 copies of wget is equivalent to starting 5 threads.
 The answer is 'yes'.


 ???

 Process != thread


Just like the other nitpicker it is up to you to explain why the
differences, and not he similarities, are relevant to this problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Do I have to use threads?

2010-01-05 Thread Brian J Mingus
On Tue, Jan 5, 2010 at 9:36 PM, Philip Semanchuk phi...@semanchuk.comwrote:


 On Jan 5, 2010, at 11:26 PM, aditya shukla wrote:

  Hello people,

 I have 5 directories corresponding 5  different urls .I want to download
 images from those urls and place them in the respective directories.I have
 to extract the contents and download them simultaneously.I can extract the
 contents and do then one by one. My questions is for doing it
 simultaneously
 do I have to use threads?


 No. You could spawn 5 copies of wget (or curl or a Python program that
 you've written). Whether or not that will perform better or be easier to
 code, debug and maintain depends on the other aspects of your program(s).

 bye
 Philip


Obviously, spawning 5 copies of wget is equivalent to starting 5 threads.
The answer is 'yes'.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: shouldn't list comprehension be faster than for loops?

2009-12-18 Thread Brian J Mingus
On Fri, Dec 18, 2009 at 11:55 AM, sturlamolden sturlamol...@yahoo.nowrote:

 On 17 Des, 18:37, Carlos Grohmann carlos.grohm...@gmail.com wrote:

  Tenting the time spent by each approach (using time.clock()), with a
  file with about 100,000 entries, I get 0.03s for the loop and 0.05s
  for the listcomp.
 
  thoughts?

 Let me ask a retoric question:

 - How much do you really value 20 ms of CPU time?


If it takes 1 nanosecond to execute a single instruction then 20
milliseconds represents 20 million instructions. Therefore I value 20ms of
CPU time very much indeed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which graph library is best suited for large graphs?

2009-12-11 Thread Brian J Mingus
On Fri, Dec 11, 2009 at 3:12 AM, Wolodja Wentland 
wentl...@cl.uni-heidelberg.de wrote:

 Hi all,

 I am writing a library for accessing Wikipedia data and include a module
 that generates graphs from the Link structure between articles and other
 pages (like categories).

 These graphs could easily contain some million nodes which are frequently
 linked. The graphs I am building right now have around 300.000 nodes
 with an average in/out degree of - say - 4 and already need around 1-2GB of
 memory. I use networkx to model the graphs and serialise them to files on
 the disk. (using adjacency list format, pickle and/or graphml).

 The recent thread on including a graph library in the stdlib spurred my
 interest and introduced me to a number of libraries I have not seen
 before. I would like to reevaluate my choice of networkx and need some
 help in doing so.

 I really like the API of networkx but have no problem in switching to
 another one (right now)  I have the impression that graph-tool might
 be faster and have a smaller memory footprint than networkx, but am
 unsure about that.

 Which library would you choose? This decision is quite important for me
 as the choice will influence my libraries external interface. Or is
 there something like WSGI for graph libraries?

 kind regards


I once computed the PageRank of the English Wikipedia. I ended up using the
Boost graph library, of which there is a parallel implementation that runs
on clusters. I tried to do it using Python but failed as the memory
requirements were so large.  Boost and the parallel version both have python
interfaces.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: semantics of ** (unexpected/inconsistent?)

2009-11-30 Thread Brian J Mingus
On Sun, Nov 29, 2009 at 5:58 PM, Esmail ebo...@hotmail.com wrote:

 Brian J Mingus wrote:




 I think you answered your own question. 3**2 comes first in the order of
 operations, followed by the negation.


 No, that's not the problem, I'm ok with the operator precedence of - vs **

 My problem is why I don't get the same result if I use the literal -3 or
 a variable that contains -3 (x in my example)


Yes, that is the problem. Setting x=-3 is the same as writing (-3)**2 vs.
-(3**2).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: semantics of ** (unexpected/inconsistent?)

2009-11-29 Thread Brian J Mingus
On Sun, Nov 29, 2009 at 5:39 PM, Esmail ebo...@hotmail.com wrote:

 Ok, this is somewhat unexpected:

 Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
 [GCC 4.3.3] on linux2
 Type help, copyright, credits or license for more information.


  -3**2
 -9

  x = -3

  x**2
 9
 

 I would have expected the same result in both cases.

 Initially I would have expected -3**2 to yield 9, but I can accept
 that ** binds tighter than the unary -, but shouldn't the results
 be consistent regardless if I use a literal or a variable?


I think you answered your own question. 3**2 comes first in the order of
operations, followed by the negation.

 (-3)**2
9
 3**2
9
 -3**2
-9
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beautifulsoup code that is not running

2009-11-17 Thread Brian J Mingus
On Tue, Nov 17, 2009 at 3:38 PM, Zeynel azeyn...@gmail.com wrote:

 Hello,

 Please help with this code suggested in the beautifulsoup group

 http://groups.google.com/group/beautifulsoup/browse_frm/thread/d288555c6992ceaa

  from BeautifulSoup import BeautifulSoup

  soup = BeautifulSoup (file(test.html).read())
  title = soup.find('title')
  titleString = title.string
  open('extract.text', 'w').write(titleString)


The problem has nothing to do with BeautifulSoup

 from BeautifulSoup import BeautifulSoup
 print BeautifulSoup('titlemytitle/title').title.string
mytitle
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The ol' [[]] * 500 bug...

2009-11-14 Thread Brian J Mingus
On Sat, Nov 14, 2009 at 1:50 AM, Paul Rubin http://phr...@nospam.invalidwrote:

 kj no.em...@please.post writes:
lol = [None] * 500
for i in xrange(len(lol)):
lol[i] = []

 lol = map(list, [()] * 500)


Could someone explain what the deal is with this thread? Thanks.

[[]]*500
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The ol' [[]] * 500 bug...

2009-11-14 Thread Brian J Mingus
On Sat, Nov 14, 2009 at 2:50 AM, Vlastimil Brom vlastimil.b...@gmail.comwrote:

 2009/11/14 Brian J Mingus brian.min...@colorado.edu:
 
 
  On Sat, Nov 14, 2009 at 1:50 AM, Paul Rubin http://phr.cx
 @nospam.invalid
  wrote:
 
  kj no.em...@please.post writes:
 lol = [None] * 500
 for i in xrange(len(lol)):
 lol[i] = []
 
  lol = map(list, [()] * 500)
 
  Could someone explain what the deal is with this thread? Thanks.
  [[]]*500
 

 Try
  lst=[[]]*500
  lst[7].append(2)
  lst
 to see...

 vbr
 --


I see.. Here's what I came up with: list(eval('[],'*500))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python simply not scaleable enough for google?

2009-11-13 Thread Brian J Mingus
On Fri, Nov 13, 2009 at 12:19 AM, Steven D'Aprano 
st...@remove-this-cybersource.com.au wrote:

 On Thu, 12 Nov 2009 22:20:11 -0800, Vincent Manis wrote:

  When I was approximately 5, everybody knew that higher level languages
 were too slow for high-speed numeric computation (I actually didn't know
 that then, I was too busy watching Bill and Ben the Flowerpot Men), and
 therefore assembly languages were mandatory. Then IBM developed Fortran, and
 higher-level languages were not too slow for numeric computation.

 Vincent, could you please fix your mail client, or news client, so
 that it follows the standard for mail and news (that is, it has a
 hard-break after 68 or 72 characters?

 Having to scroll horizontally to read your posts is a real pain.


You're joking, right? Try purchasing a computer manufactured in this
millennium. Monitors are much wider than 72 characters nowadays, old timer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter callback arguments

2009-11-02 Thread Brian J Mingus
On Mon, Nov 2, 2009 at 2:26 AM, Peter Otten __pete...@web.de wrote:

 Alf P. Steinbach wrote:

  for x in range(0,3):
  Button(.., command=lambda x=x: function(x))
 
  An alternative reusable alternative is to create a button-with-id class.
 
  This is my very first Python class so I'm guessing that there are all
  sorts of issues, in particular naming conventions.

 Pseudo-private attributes, javaesque getter methods, unidiomatic None-
 checks, broken naming conventions (**args), spaces in funny places...

  And the idea of creating a reusable solution for such a small issue may
 be
  un-pythonic?

 Screw pythonic, the signal/noise ratio is awful in any language.

  But just as an example, in Python 3.x,

 ...for achieving less in more lines?

  code
  import tkinter
  # I guess for Python 2.x do import Tkinter as tkinter but haven't
  # tested.
 
 
  class IdButton( tkinter.Button ):
   def __init__( self, owner_widget, id = None, command = None, **args
   ):
   tkinter.Button.__init__(
   self, owner_widget, args, command = self.__on_tk_command
   )
   self.__id = id
   self.__specified_command = command
 
   def __on_tk_command( self ):
   if self.__specified_command != None:
   self.__specified_command( self )
   else:
   self.on_clicked()
 
   def on_clicked( self ):
   pass
   def id( self ):
   return self.__id
   def id_string( self ):
   return str( self.id() );
 
 
  def on_button_click( aButton ):
   print( Button  + aButton.id_string() +  clicked! )
 
  window = tkinter.Tk()
 
  n_buttons = 3
  for x in range( 1, n_buttons + 1 ):
   IdButton(
   window, id = x, text = Button  + str( x ), command =
   on_button_click ).pack()
 
  window.mainloop()
  /code

 I'm not grumpy, I just don't like your code ;) And I don't like the notion
 that you are about to spread this style with your book...

 Peter


I was going to agree with you (
particularly about this
)
but then I saw your __email address__ and realized that you, too, have no
style.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Neural networks in python

2009-10-08 Thread Brian J Mingus
Machine Learning: An Algorithmic Perspective
http://www.crcpress.com/product/isbn/9781420067187

Associated python code:
http://seat.massey.ac.nz/personal/s.r.marsland/MLBook.html

On Wed, Oct 7, 2009 at 11:53 PM, ruchir ruchir.haj...@gmail.com wrote:

 I want to design and train a neural network in python. Can anyone
 guide me, from where can I get some useful material/eBook/libraries
 etc. for the same. I have no prior experience in neural netwoks and
 want to implement it urgently.
 Thanks in advance :)
 --
 http://mail.python.org/mailman/listinfo/python-list

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