Re: c[:]()

2007-06-01 Thread Andre Engels
other objects of the same type". And that does not seem to be a case of "We have never needed it yet" - the join method seems to have been specifically tailored so that no such error is needed. -- Andre Engels, [EMAIL PROTECTED] ICQ: 6260644 -- Skype: a_engels -- http://mail.python.org/mailman/listinfo/python-list

Re: error when calling method of class

2007-06-08 Thread Andre Engels
thus the definition should be done with: def splitTime(self,n): -- Andre Engels, [EMAIL PROTECTED] ICQ: 6260644 -- Skype: a_engels -- http://mail.python.org/mailman/listinfo/python-list

Re: skip next item in list

2007-06-11 Thread Andre Engels
would do: flag_last_a = False for a in list: if flag_last_a: flag_last_a = False continue if a=='a': flag_last_a = True # Whatever is done when you don't skip -- Andre Engels, [EMAIL PROTECTED] ICQ: 6260644 -- Skype: a_engels -- http://mail.python.org/mailman/listinfo/python-list

Re: a question about unicode in python

2007-06-13 Thread Andre Engels
just an idea: is your text editor really supporting utf-8? In the mail > it is only displayed as '??' which looks for me as the mail editor did > not send the mail as utf. Try to attach a correct text file. That must be your mail client, not his text editor or mail client. I do see two Chinese characters in the message. -- Andre Engels, [EMAIL PROTECTED] ICQ: 6260644 -- Skype: a_engels -- http://mail.python.org/mailman/listinfo/python-list

Re: web page text extractor

2007-07-12 Thread Andre Engels
extonly(url): # Get the HTML source on url and give only the main text f = urllib2.urlopen(url) text = f.read() r = re.compile('\<[^\<\>]*\>') newtext = r.sub('',text) while newtext != text: text = newtext newtext = r.sub('&#x

Re: web page text extractor

2007-07-12 Thread Andre Engels
2007/7/12, Andre Engels <[EMAIL PROTECTED]>: I forgot to include import urllib2, re here > def textonly(url): ># Get the HTML source on url and give only the main text >f = urllib2.urlopen(url) >text = f.read() >r = re.compile('\<[^\<\>

Re: how to find all completely connected sub-graphs?

2009-03-03 Thread Andre Engels
On Tue, Mar 3, 2009 at 7:35 AM, Hyunchul Kim wrote: > How can I find all "completely connected subgraphs" in a graph when node and > edge data are available? > > "completely connected subgraph" is a group, all members of which are > connected to each other. Here is an algorithm I came up with in

Re: Inverse of dict(zip(x,y))

2009-03-04 Thread Andre Engels
On Wed, Mar 4, 2009 at 11:02 AM, lone_eagle wrote: > Can someone suggest a easy method to do the inverse of dict(zip(x,y)) > to get two lists x and y? > > So, if x and y are two lists, it is easier to make a dictionary using > d = dict(zip(x,y)), but if I have d of the form, d = {x1:y1, > x2:y2,

Re: Inverse of dict(zip(x,y))

2009-03-05 Thread Andre Engels
On Thu, Mar 5, 2009 at 6:01 PM, Tino Wildenhain wrote: > Still I'd like to see an application where this really matters (that > keys() and values() match in order) I think there are many such applications, but also that in each of those cases it's a mis-programming of something that would be don

Re: Inverse of dict(zip(x,y))

2009-03-05 Thread Andre Engels
On Thu, Mar 5, 2009 at 7:07 PM, psykeedelik wrote: > I usually get properties that I compute, in a dictionary like property > = [key1: val1, key2:val2, ...] and then I usually want to plot them in > pylab, which AFAIK requires x and y as lists for the plot argument. > Then I need to get the lists

Re: Inverse of dict(zip(x,y))

2009-03-05 Thread Andre Engels
On Thu, Mar 5, 2009 at 7:46 PM, Andre Engels wrote: > If the dict = {key1: val1, key2: val2, ...}, you can do: > > for key in dict: >    plot(key,dictionary[key]) Of course I meant: for key in dict: plot(key,dict[key]) -- André Engels, andreeng...@gmail.com -- http://mai

Re: While loop

2009-03-05 Thread Andre Engels
On Thu, Mar 5, 2009 at 6:49 PM, Fab86 wrote: > On Mar 5, 5:23 pm, Marco Mariani wrote: >> Fab86 wrote: >> > Is it possible to get the program to catch the exception, wait 10 >> > seconds, then carry of from where it was rather than starting again? >> >> something like this? probably works in PASC

Re: create boolean

2009-03-07 Thread Andre Engels
On Sat, Mar 7, 2009 at 6:03 AM, Grant Edwards wrote: > Putting in the second comparison in makes the code match the > stated requirement.  Otherwise you have to start making > assumptions about what n might be besides None or the empty > list. But the stated requirement already assumes that n is

Re: create boolean

2009-03-09 Thread Andre Engels
On Mon, Mar 9, 2009 at 12:48 AM, Grant Edwards wrote: > I didn't say that he hadn't authorized that assumption.  I just > said that the code does rely on such an assumption.  In my > experience, assumptions like that result broken code down the > road. And assumptions like "when assumptions fail

Re: a problem in datetime.interval()

2009-03-09 Thread Andre Engels
On Mon, Mar 9, 2009 at 10:57 AM, lameck kassana wrote: > hi , > I am writing a scriot which will move old files from one directory to backup > The files are in mode *20090307* mean *mmmdd* to new files. > The script is below is like this > > import os > import datetime > import time > from dat

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Andre Engels
On Sun, Mar 15, 2009 at 7:00 PM, wrote: > Roy Smith wrote: >> In article <49bd3ab8$0$510$bed64...@news.gradwell.net>, tinn...@isbd.co.uk >> wrote: >> >> > I have a date in the form of a datetime object and I want to add (for >> > example) three months to it.  At the moment I can't see any very >

Re: array next pointer

2009-03-17 Thread Andre Engels
On Tue, Mar 17, 2009 at 12:12 PM, Anjanesh Lekshminarayanan wrote: a = ['cat','dog','elephant'] a.next() > Traceback (most recent call last): >  File "", line 1, in > AttributeError: 'list' object has no attribute 'next' > Is there something that imtates PHP's next() ? (http://php.

Re: array next pointer

2009-03-17 Thread Andre Engels
On Tue, Mar 17, 2009 at 12:24 PM, Andre Engels wrote: > On Tue, Mar 17, 2009 at 12:12 PM, Anjanesh Lekshminarayanan > wrote: >>>>> a = ['cat','dog','elephant'] >>>>> a.next() >> Traceback (most recent call last): >>

Re: Python to Perl transalators

2009-03-18 Thread Andre Engels
On Wed, Mar 18, 2009 at 6:27 AM, wrote: > > -Original Message- > From: ch...@rebertia.com [mailto:ch...@rebertia.com] On Behalf Of Chris Rebert > Sent: Wednesday, March 18, 2009 10:53 AM > To: Raju, Abhinayaraj > Cc: python-list@python.org > Subject: Re: Python to Perl transalators > > 20

Re: What way is the best to check an empty list?

2009-03-25 Thread Andre Engels
On Wed, Mar 25, 2009 at 3:38 PM, srinivasan srinivas wrote: > > For ex: to check list 'A' is empty or not.. > if A == []: > if A.count == 0: > if len(A) == 0: > if not A: I would go for the last one, because it has the highest likelihood of doing what is intended when fed with something that is '

Re: What way is the best to check an empty list?

2009-03-25 Thread Andre Engels
On Wed, Mar 25, 2009 at 4:21 PM, andrew cooke wrote: > > i will go against the grain slightly and say that "len" is probably the > best compromise in most situations (although i admit i don't know what > count is) because i think it will work when you expect it to and break > when you have a bug i

Re: absolute newbie: divide a list into sublists (nested lists?) of fixed length

2009-04-11 Thread Andre Engels
On Sun, Apr 12, 2009 at 12:05 AM, wrote: > Thanks very much - works fine! Now for a follow-up question:) > > Actually my original list called "mylist" contains 81217 elements - I > shape those into > len(mylist) > 81217 s = N.array(mylist) s.shape = (241,337) > > which works becau

Re: [False,True] and [True,True] --> [True, True]?????

2009-04-20 Thread Andre Engels
On Mon, Apr 20, 2009 at 9:03 AM, bdb112 wrote: > Is there any obvious reason why > [False,True] and [True,True] > gives [True, True] Well, whether the reason is obvious, I do not know, but the way and seems to be implemented is: X and Y = * X if the boolean value of X is false * Y if the boolean

Re:

2009-04-21 Thread Andre Engels
On Tue, Apr 21, 2009 at 3:00 PM, karlos barlos wrote: > hello to everybody... > > having problem withe this code : > > dom = raw_input("The Domain name..:") >   ad_user.Put('userPrincipalName',user['login']+'@(['dom']) > > but it wont change whay ? Well, you don't tell what ad_user is, an

Re: sorted() erraticly fails to sort string numbers

2009-04-28 Thread Andre Engels
On Tue, Apr 28, 2009 at 9:47 AM, uuid wrote: > I would be very interested in a logical explanation why this happens on > python 2.5.1: > > In order to sort an etree by the .text value of one child, I adapted this > snippet from effbot.org: > >> import xml.etree.ElementTree as ET >> >> tree = ET.pa

Re: Why bool( object )?

2009-04-28 Thread Andre Engels
On Tue, Apr 28, 2009 at 2:22 PM, Colin J. Williams wrote: > Lie Ryan wrote: >> >> Aaron Brady wrote: >>> >>> What is the rationale for considering all instances true of a user- >>> defined type? >> >> User-defined objects (or type) can override .__len__() [usually container >> types] or .__nonzero

Re: Generator oddity

2009-05-01 Thread Andre Engels
On Fri, May 1, 2009 at 4:25 PM, Dave Angel wrote: > The problem is in it2, which is initialized only once.  Thus the second time > you're going through the c2 loop, it doesn't have any more values. > > If you need the indirection provided by those it1 and it2, you need to > postpone the function

Re: Q's on my first python script

2009-05-10 Thread Andre Engels
On Sun, May 10, 2009 at 5:56 PM, Steven D'Aprano wrote: >> 5. The variable wd is meant to be "global" to the script.  In other >>    languages I've programmed in I've seen some typographic convention >>    used for the name of such variables (e.g. all caps) to signal this >>    widened scope.  Do

Re: Sorting a dictionary

2009-05-12 Thread Andre Engels
On Tue, May 12, 2009 at 1:54 PM, Ronn Ross wrote: > I'm attempting to sort for the results of a dictionary. I would like to > short by the 'key' in ascending order. I have already made several attempts > using: sorted() and .sort(). > Here is my loop: >     for key,value in word_count.items(): >  

Re: What's the use of the else in try/except/else?

2009-05-14 Thread Andre Engels
On Thu, May 14, 2009 at 6:39 AM, ma wrote: > A really great use for try/except/else would be if an object is > implementing its own __getitem__ method, so you would have something > like this: > > class SomeObj(object): >    def __getitem__(self, key): >                try: >                      

Re: python

2009-05-15 Thread Andre Engels
We may be willing to help you with your homework, but we will not be doing it for you. Please tell us what you have got (whether it be a non-working a program, a partial program or just some ideas about what you might need to do) and what you think is stopping you from getting further. 2009/5/15

Re: 4 hundred quadrillonth?

2009-05-21 Thread Andre Engels
On Thu, May 21, 2009 at 11:05 PM, wrote: > The explaination in my introductory Python book is not very > satisfying, and I am hoping someone can explain the following to me: > 4 / 5.0 > 0.80004 > > 4 / 5.0 is 0.8. No more, no less. So what's up with that 4 at the end. > It bother

Re: While Statement

2009-05-22 Thread Andre Engels
On Fri, May 22, 2009 at 11:17 AM, Joel Ross wrote: > Hi all, > > I have this piece of code > > class progess(): > >    def __init__(self, number,  char): > >        total = number >        percentage = number >        while percentage > 0 : >            percentage = int(number/total*100) >        

Re: While Statement

2009-05-22 Thread Andre Engels
On Fri, May 22, 2009 at 12:35 PM, Joel Ross wrote: > Im using 2.6 python and when running this > > class progess(): > >    def __init__(self, number, total,  char): > >        percentage = float(number/total*100) >        percentage = int(round(percentage)) >        char = char * percentage >    

Re: Inheritance and Design Question

2009-05-27 Thread Andre Engels
On Wed, May 27, 2009 at 9:58 PM, imageguy wrote: > I have an object the I would like to use as a base class.  Some of the > methods I would like to override completely, but others I would simply > like to call the base class method and use the return value in the > child method.  The purpose here

Re: "TypeError: 'int' object is not callable"

2009-06-01 Thread Andre Engels
On Mon, Jun 1, 2009 at 12:40 PM, Visco Shaun wrote: > when I was executing the below code I got "TypeError: 'int' object is > not callable" exception. Why is it so? > > if type(c) == type(ERROR): > > c can be a string or an integer representing an error Could you please give a larger piece of cod

Re: Question about file objects...

2009-12-02 Thread Andre Engels
On Wed, Dec 2, 2009 at 3:14 PM, J wrote: > Something that came up in class... > > when you are pulling data from a file using f.next(), the file is read > one line at a time. > > What was explained to us is that Python iterates the file based on a > carriage return as the delimiter. > But what if

Re: Why the expression "(1)" is not an one-arity tuple, but int ?

2009-12-04 Thread Andre Engels
2009/12/4 Петров Александр : > Hello All ! > > In my code I try to use a generic approach to work with tuples. Let > "X" be a tuple. > When I want to access a first element of a tuple, I can write: "X[0]". > And that is really working when X is a n-arity tuple, with n>1 (for > example "foo( (1,2,3)

Re: a list/re problem

2009-12-11 Thread Andre Engels
On Fri, Dec 11, 2009 at 9:49 PM, Ed Keith wrote: > I have a problem and I am trying to find a solution to it that is both > efficient and elegant. > > I have a list call it 'l': > > l = ['asc', '*nbh*', 'jlsdjfdk', 'ikjh', '*jkjsdfjasd*', 'rewr'] > > Notice that some of the items in the list start

Re: Symbols as parameters?

2010-01-21 Thread Andre Engels
On Thu, Jan 21, 2010 at 8:43 AM, Martin Drautzburg wrote: > Hello all, > > When passing parameters to a function, you sometimes need a paramter > which can only assume certain values, e.g. > >        def move (direction): >                ... > If direction can only be "up", "down", "left" or "rig

Re: scraping with urllib2

2010-01-26 Thread Andre Engels
On Wed, Jan 27, 2010 at 6:26 AM, Patrick wrote: > I'm trying to scrape the attached link for the price listed $99.99: > http://bananarepublic.gap.com/browse/product.do?cid=41559&vid=1&pid=692392 > > I can see the price if I view the source(I even turned off java and > javascript), but when I use u

Re: myths about python 3

2010-01-27 Thread Andre Engels
On Wed, Jan 27, 2010 at 11:32 AM, Daniel Fetchinson wrote: > Hi folks, > > I was going to write this post for a while because all sorts of myths > periodically come up on this list about python 3. I don't think the > posters mean to spread false information on purpose, they simply are > not aware

Re: list.extend([]) Question

2010-01-30 Thread Andre Engels
On Sat, Jan 30, 2010 at 4:32 PM, Dan Brown wrote: > Why does extending a list with the empty list result in None?  It > seems very counterintuitive to me, at least --- I expected ['a'].extend > ([]) to result in ['a'], not None. Extend is a method of the list. The list itself is changed, it does

Re: How to use variable in a file name

2009-09-29 Thread Andre Engels
On Tue, Sep 29, 2009 at 3:35 PM, kks wrote: > if myFile variable contains the actual filename then how can i open a > file for wirte so that complete filename appears as > "actualname_kks.txt" open(myFile + "_kks.txt", "w") -- André Engels, andreeng...@gmail.com -- http://mail.python.org/mailm

Re: unicode issue

2009-09-30 Thread Andre Engels
On Wed, Sep 30, 2009 at 9:34 AM, gentlestone wrote: > Why don't work this code on Python 2.6? Or how can I do this job? Please be more specific than "it doesn't work": * What exactly are you doing * What were you expecting the result of that to be * What is the actual result? -- André Engels, a

Re: unicode issue

2009-09-30 Thread Andre Engels
I get the feeling that the problem is with the Python interactive mode. It does not have full unicode support, so u"Žabovitá zmiešaná kaša" is changed to u'\x8eabovit\xe1 zmie\x9aan\xe1 ka\x9aa'. If you call your code from another program, it might work correctly. -- André Engels, andreeng...@gm

Re: a=[1,2,3,4].reverse() - why "a" is None?

2009-10-12 Thread Andre Engels
The reverse function is a function to reverse the list in place, not a function to get the reverse of the list: x = [1,2,3,4] y = x z = x.reverse() will result in: x = y = [4,3,2,1] z = None -- André Engels, andreeng...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: a=[1,2,3,4].reverse() - why "a" is None?

2009-10-12 Thread Andre Engels
On Mon, Oct 12, 2009 at 10:44 AM, Nadav Chernin wrote: > >        Chris Withers wrote: > >        ...becauase you were looking for: > >        reversed([1,2,3,4]) > > OK, but my question is generic. Why when I use object's function that > changed values of the object, I can't to get value of it on

Re: for loop: range() result has too many items

2009-10-13 Thread Andre Engels
On Tue, Oct 13, 2009 at 11:17 PM, Peng Yu wrote: > Hi, > > The following code does not run because range() does not accept a big > number. Is there a way to make the code work. I'm wondering if there > is a way to write a for-loop in python similar to that of C style. > > for(int i = 0; i < a_big_

Re: for loop: range() result has too many items

2009-10-13 Thread Andre Engels
On Tue, Oct 13, 2009 at 11:55 PM, Andre Engels wrote: > for i in range(sys.maxint): >    if i % 100 == 0: >       print i Grmbl cut-and-paste error... I meant of course: for i in xrange(sys.maxint): if i % 100 == 0: print i -- André Engels, andreeng...@gmail.com

Re: id( ) function question

2009-10-14 Thread Andre Engels
What is going on is that a few objects that are often used, in particular the small (how small is small depends on the implementation) integers, are 'preloaded'. When one of these is then referred to, a new object is not created, but the pre-defined object is used. 10 is apparently a preloaded cons

Re: [OT] Supporting "homework" (was: Re: Checking a Number for Palindromic Behavior)

2009-10-22 Thread Andre Engels
On Thu, Oct 22, 2009 at 7:04 AM, Dieter Maurer wrote: > Steven D'Aprano writes on 20 Oct 2009 > 05:35:18 GMT: >> As far as I'm concerned, asking for help on homework without being honest >> up-front about it and making an effort first, is cheating by breaking the >> social contract. Anyone who r

Re: Parsing a large number of parms to a print statement.

2009-10-22 Thread Andre Engels
On Thu, Oct 22, 2009 at 11:16 PM, KB wrote: > Hi, > > I have to pass over 150 parameters to a print statement ala: > > print "%s %s %s <150'th unique text> %s" % (v > [0], v[1], ... v[150]) > > I can't use a for loop like I normally would over the list "v" due to > the different text fragmen

Re: how to remove the same words in the paragraph

2009-11-03 Thread Andre Engels
On Tue, Nov 3, 2009 at 11:13 PM, kylin wrote: > I need to remove the word if it appears in the paragraph twice. could > some give me some clue or some useful function in the python. Well, it depends a bit on what you call 'the same word' (In the paragraph "Fly fly, fly!" does the word fly occur 0

Re: Program to compute and print 1000th prime number

2009-11-07 Thread Andre Engels
On Sat, Nov 7, 2009 at 6:40 PM, Mensanator wrote: >> Tongue in cheek solution: >> >> import urllib2 >> >> url = 'http://primes.utm.edu/lists/small/1.txt' >> primes = [] >> for line in urllib2.urlopen(url).read().splitlines(): >>     values = line.split() >>     if len(values) == 10: >>      

Re: Most efficient way to "pre-grow" a list?

2009-11-07 Thread Andre Engels
On Sat, Nov 7, 2009 at 8:25 PM, Luis Alberto Zarrabeitia Gomez wrote: > > Quoting Bruno Desthuilliers : > >> > Another situation where one may want to do this is if one needs to >> > initialize a non-sparse array in a non-sequential order, >> >> Then use a dict. > > Ok, he has a dict. > > Now what

Re: Is there something similar to list comprehension in dict?

2009-11-20 Thread Andre Engels
On Fri, Nov 20, 2009 at 4:18 AM, Peng Yu wrote: > I'm wondering if there is something similar to list comprehension for > dict (please see the example code below). > > > d = dict(one=1, two=2) > print d > > def fun(d):#Is there a way similar to list comprehension to change the > argument d so that

Re: Bizarre arithmetic results

2010-02-11 Thread Andre Engels
On Thu, Feb 11, 2010 at 1:44 AM, Terrence Cole wrote: > Can someone explain to me what python is doing here? > > Python 3.1.1 (r311:74480, Feb  3 2010, 13:36:47) > [GCC 4.3.4] on linux2 > Type "help", "copyright", "credits" or "license" for more information. -0.1 ** 0.1 > -0.7943282347242815

Re: The Disappearing Program?

2010-02-19 Thread Andre Engels
On Fri, Feb 19, 2010 at 12:20 PM, W. eWatson wrote: > I've successfully compiled several small python programs on Win XP into > executables using py2exe. A program goes from a name like snowball.py to > snowball. A dir in the command prompt window finds snowball.py but not > snowball. If I type in

Re: The Disappearing Program?

2010-02-19 Thread Andre Engels
On Fri, Feb 19, 2010 at 3:19 PM, Mark Lawrence wrote: > Andre Engels wrote: >> >> On Fri, Feb 19, 2010 at 12:20 PM, W. eWatson >> wrote: >>> >>> I've successfully compiled several small python programs on Win XP into >>> executables using p

Re: case do problem

2010-03-03 Thread Andre Engels
On Tue, Mar 2, 2010 at 6:46 PM, Tracubik wrote: > and, generally > speaking, the try..except block slow down the execution of the program or > not? Try...except tends to be slow when the exception does occur, fast when it does not. Apart from that, if these fraction-of-a-fraction-of-a-second ga

Re: Interest check in some delicious syntactic sugar for "except:pass"

2010-03-03 Thread Andre Engels
On Wed, Mar 3, 2010 at 10:27 AM, Oren Elrad wrote: > Howdy all, longtime appreciative user, first time mailer-inner. > > I'm wondering if there is any support (tepid better than none) for the > following syntactic sugar: > > silence: > block > > -> > > try: > .

Re: Can't define __call__ within __init__?

2010-03-11 Thread Andre Engels
On Thu, Mar 11, 2010 at 2:30 PM, Steve Holden wrote: >> The example I showed was just a toy problem.  The real problem is >> I expect to call a function many times, and I want to avoid the overhead of >> the 'if blah' everytime. >> > This is a premature optimization. First, make it work. Then (if

Re: Where can i reference the "regular expressions"

2010-03-24 Thread Andre Engels
On Wed, Mar 24, 2010 at 10:07 AM, John Smithury wrote: > Dear pythoners, > > I'm a new member to studay the python, i wan't to studay the "regular > expressions" handle like below: > > ==source > the > is > name > ==source end= > > > after convert, the r

Re: Where can i reference the "regular expressions"

2010-03-24 Thread Andre Engels
On Wed, Mar 24, 2010 at 10:34 AM, John Smithury wrote: > ==source > the > is > name > ==source end= > > First, get the word only(discard the "" and ""), it can use > regular expression, right? > > the > is > name > Second, get a charactor in each word an

Re: Teaching Programming

2010-05-04 Thread Andre Engels
On Tue, May 4, 2010 at 4:35 PM, James Mills wrote: > On Wed, May 5, 2010 at 12:21 AM, Ed Keith wrote: >> To deal with indentation I had to >> >>   1) keep track of indentation of all chunks of code embedded in the >>      document and indent inserted chunks to the sum of all the >>      indentati

Re: solve a newspaper quiz

2010-05-09 Thread Andre Engels
On Sun, May 9, 2010 at 11:31 AM, Xavier Ho wrote: > On Sun, May 9, 2010 at 7:20 PM, superpollo wrote: >> >> "if a b c are digits, solve ab:c=a*c+b" > > Sorry, what does the notation ab:c mean? The number ab divided by c. -- André Engels, andreeng...@gmail.com -- http://mail.python.org/mailma

Re: random number including 1 - i.e. [0,1]

2009-06-10 Thread Andre Engels
On Wed, Jun 10, 2009 at 8:25 AM, John Yeung wrote: > That uniform(a, b) will return a random float in the semi-open > interval [a, b) for certain values of a and b; and in the closed > interval [a, b] for other values of a and b.  (Swap a and b if a > b.) > > To me, the fact that you sometimes get

Re: Question about None

2009-06-14 Thread Andre Engels
On Sat, Jun 13, 2009 at 7:23 PM, John Yeung wrote: > Paul LaFollette is probably thinking along the lines of formal logic > or set theory.  It's a little bit confused because programming isn't > quite the same as math, and so it's a common question when designing > and implementing programming lan

Re: Question about None

2009-06-14 Thread Andre Engels
On Sun, Jun 14, 2009 at 6:49 PM, Paul LaFollette wrote: > Now, suppose that I want to generate, say, the set of all ordered > trees with N nodes.   I need to be able to represent the empty ordered > tree, i.e. the tree with with zero nodes.  There are a lot of ways I > could do this.  The problem i

Re: Question about None

2009-06-14 Thread Andre Engels
On Sun, Jun 14, 2009 at 9:37 PM, Paul Rubin<http://phr...@nospam.invalid> wrote: > Andre Engels writes: >> I don't see why that would be the case. Something of the type "thingy" >> is ONE thingy. Nothing is ZERO thingies, so it is not something of the >

Re: Question about None

2009-06-14 Thread Andre Engels
On Sun, Jun 14, 2009 at 10:21 PM, Paul Rubin<http://phr...@nospam.invalid> wrote: > Andre Engels writes: >> > That seems to confuse values with collections of them.  A car is not >> > the same as a one-element list of cars.  Nothing is not the same as a >> >

Re: waling a directory with very many files

2009-06-14 Thread Andre Engels
On Sun, Jun 14, 2009 at 6:35 PM, tom wrote: > i can traverse a directory using os.listdir() or os.walk(). but if a > directory has a very large number of files, these methods produce very > large objects talking a lot of memory. > > in other languages one can avoid generating such an object by walk

Re: wikipedia with python

2009-06-22 Thread Andre Engels
On Mon, Jun 22, 2009 at 6:58 PM, zelegolas wrote: > Let me know if it's the right place to ask. > > I'm looking for wiki writen with python where I can import all > wikipedia site. > If you have any links please let me know. I don't think that's possible. If you wnat to import Wikipedia in a wiki,

Re: wikipedia with python

2009-06-22 Thread Andre Engels
On Mon, Jun 22, 2009 at 8:24 PM, ZeLegolas wrote: > Well sorry I was not clear. I have a wiki running with mediawiki and I want > to import in a wiki written with python. I don't think it will work, but you could try using the Special:Export page. -- André Engels, andreeng...@gmail.com -- ht

Re: wikipedia with python

2009-06-24 Thread Andre Engels
On Wed, Jun 24, 2009 at 9:17 AM, Tim Harig wrote: > [ ] D. You already have mediawiki running on a webserver; but, you would >        like to get data from another mediawiki server that you don't have >        direct database access to; so, you would like to write a script in >        Python to sc

Re: 3.2*2 is 9.6 ... or maybe it isn't?

2009-06-26 Thread Andre Engels
On Fri, Jun 26, 2009 at 5:07 PM, Scott David Daniels wrote: > pdpi wrote: >> >> ... But since 10 = 2 * 5, all numbers that can be finitely represented in >> binary can be represented finitely in decimal as well, with the exact >> same number of  places for the fractional part (and no more digits >>

Re: finding most common elements between thousands of multiple arrays.

2009-07-04 Thread Andre Engels
On Sat, Jul 4, 2009 at 9:33 AM, mclovin wrote: > Currently I need to find the most common elements in thousands of > arrays within one large array (arround 2 million instances with ~70k > unique elements) > > so I set up a dictionary to handle the counting so when I am > iterating  I up the count o

Re: Creating alot of class instances?

2009-07-05 Thread Andre Engels
On 7/5/09, kk wrote: > I am new to Python classes and trying to figure out this particular > issue here. I will need to create instances of a class. But at the > moment I do not know how many instances I will end up having, in every > case it might be different. Most of the documents I read m

Re: Clarity vs. code reuse/generality

2009-07-06 Thread Andre Engels
On Mon, Jul 6, 2009 at 9:44 AM, Martin Vilcans wrote: > On Fri, Jul 3, 2009 at 4:05 PM, kj wrote: >> I'm will be teaching a programming class to novices, and I've run >> into a clear conflict between two of the principles I'd like to >> teach: code clarity vs. code reuse.  I'd love your opinion abo

Re: Clarity vs. code reuse/generality

2009-07-07 Thread Andre Engels
On Tue, Jul 7, 2009 at 8:01 PM, pdpi wrote: > He asserts: >    assert lo < hi > but then compares: >    sense = cmp(func(hi), func(lo)) > > sense can't ever be anything other than 1. It can - there is no necessity that func is monotonically increasing. -- André Engels, andreeng...@gmail.com --

Re: Try... except....Try again?

2009-07-17 Thread Andre Engels
On Fri, Jul 17, 2009 at 7:31 AM, Xavier Ho wrote: > I have a simple class that generates prime numbers, using memorisation and > iteration to generate the next prime number. > > In the class, I have defined a function that gives, say, the 5th prime > number. Or the 1000th, it's still very fast. But

Re: time in milliseconds by calling time.time()

2009-07-24 Thread Andre Engels
On Sat, Jul 25, 2009 at 3:27 AM, Roy Smith wrote: > Keep in mind that while a float may have a large apparent precision, > there's no promise that the actual value returned by the OS has that much > precision.  You should be fine if all you're looking for is ms, but I > wouldn't count on much more

Re: len() should always return something

2009-07-24 Thread Andre Engels
On Sat, Jul 25, 2009 at 4:50 AM, Dr. Phillip M. Feldman wrote: > > Here's a simple-minded example: > > def dumbfunc(xs): >   for x in xs: >      print x > > This function works fine if xs is a list of floats, but not if it is single > float.  It can be made to work as follows: > > def dumbfunc(xs):

Re: looping through values in a dictionary and appending to a list

2009-08-12 Thread Andre Engels
On Tue, Aug 11, 2009 at 8:17 PM, Krishna Pacifici wrote: > Nevermind, > got it. > > Sorry. > Krishna Pacifici 08/11/09 2:12 PM >>> > Hi, > I want to append the values of a dictionary to a list.  I have a dictionary > sec_dict_clean and I want to append the values to a list, but am having a > h

Re: Scraping Wikipedia with Python

2009-08-13 Thread Andre Engels
On Tue, Aug 11, 2009 at 8:53 PM, David C Ullrich wrote: > Try reading a little there! Starting there I went to > > http://en.wikipedia.org/wiki/Wikipedia:Creating_a_bot > > where I found a section on existing bots, comments on how the "scraping" > is not what you want, and even a Python section wi

Re: variables of the class are not available as default values?

2009-08-27 Thread Andre Engels
On Thu, Aug 27, 2009 at 11:37 PM, seanacais wrote: > I'm working on a program where I wish to define the default value of a > method as a value that was set in __init__.  I get a compilation error > saying that self is undefined. > > As always a code snippet helps :-) > > class foo: >    def __init

Re: Why does this group have so much spam?

2009-09-01 Thread Andre Engels
On Sun, Aug 30, 2009 at 11:18 AM, David<71da...@libero.it> wrote: > Il Sat, 29 Aug 2009 17:18:46 -0700 (PDT), casebash ha scritto: > >> So much of it could be removed even by simple keyword filtering. > > I think there is only one final solution to the spam pestilence: a tiny tax > on email and pos

Re: NameError: name '__main__' is not defined

2009-09-14 Thread Andre Engels
On Mon, Sep 14, 2009 at 4:29 AM, Sean DiZazzo wrote: > Is this a production program that you are using?? > > Please show us the point you are trying to make in something more > valuable. I find this a very bad comment. Not only is it rude, it is condemning a behaviour I would see as beneficial.

Re: unpacking vars from list of tuples

2009-09-15 Thread Andre Engels
On Tue, Sep 15, 2009 at 11:51 PM, Ross wrote: > I'm inexperienced with some of the fancy list slicing syntaxes where > python shines. > > If I have a list of tuples: > >   k=[("a", "bob", "c"), ("p", "joe", "d"), ("x", "mary", "z")] > > and I want to pull the middle element out of each tuple to ma