Re: Default Value

2013-06-21 Thread Ian Kelly
On Fri, Jun 21, 2013 at 7:15 PM, Rick Johnson wrote: >> > Let's imagine for a second if Python allowed mutable keys in >> > a dictionary, >> which it does > > Am i just to take your word for this? You cannot provide an > example? Here, allow me to "break the ice": > > # Literal > py> d = {

Re: Default Value

2013-06-21 Thread Ian Kelly
On Fri, Jun 21, 2013 at 7:37 PM, Chris Angelico wrote: class HashableList(list): > def __hash__(self): > return 42 Hey, we both picked exactly the same example! -- http://mail.python.org/mailman/listinfo/python-list

Re: Default Value

2013-06-22 Thread Ian Kelly
On Sat, Jun 22, 2013 at 10:49 AM, Dennis Lee Bieber wrote: > On Fri, 21 Jun 2013 19:27:42 -0600, Ian Kelly > declaimed the following: > >>While we're at it, I would like to petition for a function >>terminates(f, args) that I can use to determine whether a function

Re: How can i fix this?

2013-06-22 Thread Ian Kelly
On Sat, Jun 22, 2013 at 3:50 PM, Борислав Бориславов wrote: > this doesent help me at all It shows you how to include multiple statements in the body of the if block. If you're having trouble getting it to work, then please copy and paste the exact code that you're running for us along with the

Re: What is the semantics meaning of 'object'?

2013-06-22 Thread Ian Kelly
On Sat, Jun 22, 2013 at 9:20 PM, Steven D'Aprano wrote: > * on the down side, automatic delegation of special double-underscore > methods like __getitem__ and __str__ doesn't work with new-style classes. I actually consider that an up side. Sure it's inconvenient that you can't delegate all such

Re: What is the semantics meaning of 'object'?

2013-06-22 Thread Ian Kelly
On Sat, Jun 22, 2013 at 11:23 PM, Steven D'Aprano wrote: > On Sat, 22 Jun 2013 22:27:10 -0600, Ian Kelly wrote: >> I actually consider that an up side. Sure it's inconvenient that you >> can't delegate all such methods at once just by overriding >> __

Re: What is the semantics meaning of 'object'?

2013-06-23 Thread Ian Kelly
On Sun, Jun 23, 2013 at 7:35 AM, Adam Jiang wrote: > Another question raised here is that what is the proper way to refer > to parent class? For example, > > class A(object): > def __init__(self, arg): > print "A" > > class B(A): > def __init__(self, arg): >

Re: What is the semantics meaning of 'object'?

2013-06-23 Thread Ian Kelly
On Sun, Jun 23, 2013 at 10:49 AM, Roy Smith wrote: > One thing I've never understood about Python 2.x's multiple inheritance > (mostly because I almost never use it) is how you do something like this: > > class Base1(object): >def __init__(self, foo): > self.foo = foo > > class Base2(obj

Re: What is the semantics meaning of 'object'?

2013-06-23 Thread Ian Kelly
On Sun, Jun 23, 2013 at 11:08 AM, Ian Kelly wrote: > On Sun, Jun 23, 2013 at 10:49 AM, Roy Smith wrote: >> am I missing something here? > > Yes, you're missing that super() does not simply call the base class, > but rather the next class in the MRO for whatever the type o

Re: What is the semantics meaning of 'object'?

2013-06-23 Thread Ian Kelly
On Sun, Jun 23, 2013 at 11:36 AM, Steven D'Aprano wrote: > On Sun, 23 Jun 2013 11:18:41 -0600, Ian Kelly wrote: > >> Incidentally, although super() is useful, it's not perfect, and this is >> one of my grievances with it: that a user can, based upon the name, draw

Re: What is the semantics meaning of 'object'?

2013-06-23 Thread Ian Kelly
On Sun, Jun 23, 2013 at 12:46 PM, Steven D'Aprano wrote: > All is not lost, there are ways to make your classes cooperative. The > trick is to have your classes' __init__ methods ignore keyword arguments > they don't know what to do with. object used to do the same thing, but it > no longer does,

Re: What is the semantics meaning of 'object'?

2013-06-23 Thread Ian Kelly
On Sun, Jun 23, 2013 at 12:50 PM, Steven D'Aprano wrote: > What else would you call a function that does lookups on the current > object's superclasses? Well, as James Knight points out in the "Super Considered Harmful" article, the equivalent in Dylan is called "next-method", which isn't a valid

Re: What is the semantics meaning of 'object'?

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 9:00 AM, Rotwang wrote: > On 24/06/2013 07:31, Steven D'Aprano wrote: > >> I daresay that there are good reasons why new-style classes don't do the >> same thing, but the point is that had the Python devs had been >> sufficiently interested in keeping the old behaviour, and

Re: What is the semantics meaning of 'object'?

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 9:58 AM, Mark Janssen wrote: >>> Mostly I'm saying that super() is badly named. >> >> What else would you call a function that does lookups on the current >> object's superclasses? > > ^. You make a symbol for it. ^__init__(foo, bar) On the one hand, eww. On the other h

Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 1:52 PM, wrote: > Syntax: > > fwhile X in ListY and conditionZ: > > The following would actually exactly as: for X in ListY: > > fwhile X in ListY and True: > > fwhile would act much like 'for', but would stop if the condition after the > 'and' is no longer True. > > The

Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 1:52 PM, wrote: > Syntax: > > fwhile X in ListY and conditionZ: Also, this syntax is ambiguous. Take for example the statement: fwhile X in ListA and ListB and ListC and ListD: At which "and" does the iterable expression stop and the condition expression begin? -- htt

Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 3:01 PM, Ian Kelly wrote: > On Mon, Jun 24, 2013 at 2:34 PM, Fábio Santos > wrote: >> This can probably be best achieved by adding to the existing for loop, >> so maybe taking advantage of the existing for...if syntax and adding >> for...whil

Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 2:34 PM, Fábio Santos wrote: > This can probably be best achieved by adding to the existing for loop, > so maybe taking advantage of the existing for...if syntax and adding > for...while would be a better idea? The for...if syntax only exists for comprehensions and generat

Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 4:41 PM, Fábio Santos wrote: > > On 24 Jun 2013 22:29, "Ian Kelly" wrote: >> >> On Mon, Jun 24, 2013 at 2:34 PM, Fábio Santos >> wrote: >> > This can probably be best achieved by adding to the existing for loop, >> >

Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 4:35 PM, Chris Angelico wrote: > On Tue, Jun 25, 2013 at 8:30 AM, Tim Chase > wrote: >> On 2013-06-25 07:38, Chris Angelico wrote: >>> Python has no issues with breaking out of loops, and even has >>> syntax specifically to complement it (the 'else:' clause). Use >>> break

Re: Is this PEP-able? fwhile

2013-06-24 Thread Ian Kelly
On Mon, Jun 24, 2013 at 6:41 PM, wu wei wrote: > It's still possible by raising a StopIteration within the condition > function: > > def is_part_of_header(x): > if header_condition: > return True > else: > raise StopIteration Which is basically just tak

Re: Default Value

2013-06-25 Thread Ian Kelly
On Sat, Jun 22, 2013 at 8:40 AM, Antoon Pardon wrote: > Are you two guys now egging on Rick Johnson? No. Rick is incorrigible, and I would have been surprised if he responded to that anyway. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this PEP-able? fwhile

2013-06-25 Thread Ian Kelly
On Mon, Jun 24, 2013 at 2:33 PM, wrote: > Ian, > > Regarding your first message breaks are anathema (for many) and your other > alternative is complicated. > > Regarding your second post, anding of lists is allowed, but generally > returns non-utile results, but p

Re: Is this PEP-able? fwhile

2013-06-25 Thread Ian Kelly
On Tue, Jun 25, 2013 at 1:21 AM, Chris Angelico wrote: > On Tue, Jun 25, 2013 at 2:20 PM, Benjamin Kaplan > wrote: >> The reason I was given (which I promptly ignored, of course) is that >> it's "best practice" to only have one exit point for a block of code. >> Only one way of terminating your l

Re: What is the semantics meaning of 'object'?

2013-06-25 Thread Ian Kelly
On Sun, Jun 23, 2013 at 1:33 PM, Antoon Pardon wrote: > Op 23-06-13 18:35, Steven D'Aprano schreef: >> Please don't. This is false economy. The time you save will be trivial, >> the overhead of inheritance is not going to be the bottleneck in your >> code, and by ignoring super, you only accomplis

Re: newbie question

2013-06-25 Thread Ian Kelly
On Sat, Jun 22, 2013 at 8:49 PM, Gene Heskett wrote: > On Saturday 22 June 2013 22:46:51 christheco...@gmail.com did opine: > >> Writing simple program asking a question with the answer being >> "yes"...how do I allow the correct answer if user types Yes, yes, or >> YES? >> >> Thanks > > AND each

Re: Limit Lines of Output

2013-06-25 Thread Ian Kelly
On Tue, Jun 25, 2013 at 2:31 PM, Joshua Landau wrote: > On 25 June 2013 21:22, Bryan Britten wrote: >> Ah, I always forget to mention my OS on these forums. I'm running Windows. > > Supposedly, Windows has "more" > [http://superuser.com/questions/426226/less-or-more-in-windows], > > For Linux+les

Re: What is the semantics meaning of 'object'?

2013-06-25 Thread Ian Kelly
On Tue, Jun 25, 2013 at 3:58 PM, Mark Janssen wrote: > Ah, and here we see the weakness in the object architecture that has > evolved in the past decade (not just in Python, note). It hasn't > really ironed out what end is what. Here's a proposal: the highest, > most "parental", most general o

Re: What is the semantics meaning of 'object'?

2013-06-25 Thread Ian Kelly
On Tue, Jun 25, 2013 at 4:17 PM, Chris Angelico wrote: > The main problem is getting to the top/end of the call chain. Classic > example is with __init__, but the same problem can also happen with > other calls. Just a crazy theory, but would it be possible to > construct a black-holing object tha

Re: What is the semantics meaning of 'object'?

2013-06-25 Thread Ian Kelly
On Tue, Jun 25, 2013 at 4:38 PM, Mark Janssen wrote: > Sorry my last message got sent prematurely. Retrying... > >> So instead of super(), you would have sub()? It's an interesting >> concept, but I don't think it changes anything. You still have to >> design your classes cooperatively if you e

Re: What is the semantics meaning of 'object'?

2013-06-25 Thread Ian Kelly
On Tue, Jun 25, 2013 at 5:07 PM, Ian Kelly wrote: > On Tue, Jun 25, 2013 at 4:38 PM, Mark Janssen > wrote: >> The issue of classes cooperating isn't as big as it seems, because >> since you're working now from a useful, agreed-upon common base (the >> non-

Re: What is the semantics meaning of 'object'?

2013-06-25 Thread Ian Kelly
On Tue, Jun 25, 2013 at 5:19 PM, Mark Janssen wrote: >>> Combining integers with sets I can make >>> a Rational class and have infinite-precision arithmetic, for example. >> >> Combining two integers lets you make a Rational. > > Ah, but what is going to group them together? You see you've alread

Re: What is the semantics meaning of 'object'?

2013-06-26 Thread Ian Kelly
On Tue, Jun 25, 2013 at 7:07 PM, Mark Janssen wrote: >> When you inherit a "set" to make a Rational, you're making the >> statement (to the interpreter, if nothing else) that a Rational is-a >> set. > > No you don't *inherit* a set to make a Rational, although you gain a > set to make it. Okay, t

Re: Don't feed the troll...

2013-06-26 Thread Ian Kelly
On Mon, Jun 24, 2013 at 7:37 AM, Antoon Pardon wrote: > What do you mean with not a participant in the past? As far > as I can see his first appearance was in dec 2011. That is > over a year ago. It also seems that he always find people > willing to engage with him. Is how the group treats him > n

Re: What is the semantics meaning of 'object'?

2013-06-26 Thread Ian Kelly
On Wed, Jun 26, 2013 at 5:54 PM, Steven D'Aprano wrote: > No. But "the current object" is not Base1, but an instance of Derived, > and Base2 *is* an ancestor of Derived. Perhaps if I had said "self" > instead of current object, you wouldn't have made this error. If so, I > apologise for confusing

Re: Don't feed the troll...

2013-06-27 Thread Ian Kelly
On Wed, Jun 26, 2013 at 1:46 PM, Antoon Pardon wrote: > But you didn't even go to the trouble of trying to find out > what those concerns would be and how strong people feel about > them. You just took your assumptions about those concerns for > granted and proceeded from there. Jumping back in h

Re: Don't feed the troll...

2013-06-29 Thread Ian Kelly
On Thu, Jun 27, 2013 at 12:13 PM, Antoon Pardon wrote: > So what do you think would be a good approach towards people > who are behaving in conflict with this wish of yours? Just > bluntly call them worse than the troll or try to approach them > in a way that is less likely to antangonize them? I

Re: Closures in leu of pointers?

2013-06-29 Thread Ian Kelly
On Sat, Jun 29, 2013 at 11:02 AM, Antoon Pardon wrote: > Op 29-06-13 16:02, Michael Torrie schreef: > >> >> The real problem here is that you don't understand how python variables >> work. And in fact, python does not have variables. It has names that >> bind to objects. > > > I don't understand

Re: Closures in leu of pointers?

2013-06-29 Thread Ian Kelly
On Sat, Jun 29, 2013 at 1:33 PM, Steven D'Aprano wrote: > On Sat, 29 Jun 2013 12:20:45 -0700, cts.private.yahoo wrote: >> Without wanting to analyze it in too much depth now, I >> would want a local keyword to allow me to know I was protecting my >> variables, and a way to specify other scopes, wi

Re: Closures in leu of pointers?

2013-06-29 Thread Ian Kelly
On Sat, Jun 29, 2013 at 2:53 PM, Terry Reedy wrote: > # The alternative for either program or people is a 1-pass + backtracking > process where all understandings are kept provisional until the end of the > body and revised as required. 2 passes are simpler. Or simply an explicit declaration of s

Re: Closures in leu of pointers?

2013-06-29 Thread Ian Kelly
On Sat, Jun 29, 2013 at 10:32 PM, Terry Reedy wrote: > On 6/29/2013 5:21 PM, Ian Kelly wrote: >> Or simply an explicit declaration of scope at the beginning of the >> function definition. > > One of the reasons I switched to Python was to not have to do that, or > hardly

Re: Closures in leu of pointers?

2013-06-29 Thread Ian Kelly
On Sun, Jun 30, 2013 at 12:11 AM, Terry Reedy wrote: > On 6/30/2013 1:46 AM, Ian Kelly wrote: > >> On a related note, I think that generator functions should in some way >> be explicitly marked as such in the declaration, rather than needing >> to scan the entire f

Re: Closures in leu of pointers?

2013-06-30 Thread Ian Kelly
On Sun, Jun 30, 2013 at 4:07 AM, Antoon Pardon wrote: > I don't think this reference is as strong as you think it is. Here is > a paragraph somewhat lower: > > ] If a name is bound in a block, it is a local variable of that block, > ] unless declared as nonlocal. If a name is bound at the module l

Re: Closures in leu of pointers?

2013-06-30 Thread Ian Kelly
On Sun, Jun 30, 2013 at 11:13 AM, Ian Kelly wrote: > On Sun, Jun 30, 2013 at 4:07 AM, Antoon Pardon > wrote: >> I don't think this reference is as strong as you think it is. Here is >> a paragraph somewhat lower: >> >> ] If a name is bound in a block, i

Re: Stupid ways to spell simple code

2013-06-30 Thread Ian Kelly
On Sun, Jun 30, 2013 at 9:20 AM, Chris Angelico wrote: > Yeah, I cannot seriously imagine that the stdlib does anything like > the example I gave :) Pity nobody else is offering further examples, I > thought this might be a fun thread. Well, there is the "this" module. But its code is not *that*

Re: Don't feed the troll...

2013-06-30 Thread Ian Kelly
On Sun, Jun 30, 2013 at 11:25 AM, Antoon Pardon wrote: >>> So what do you think would be a good approach towards people >>> who are behaving in conflict with this wish of yours? Just >>> bluntly call them worse than the troll or try to approach them >>> in a way that is less likely to antangonize

Re: math functions with non numeric args

2013-06-30 Thread Ian Kelly
On Sun, Jun 30, 2013 at 12:46 PM, Andrew Z wrote: > Hello, > > print max(-10, 10) > 10 > print max('-10', 10) > -10 > > My guess max converts string to number bye decoding each of the characters > to it's ASCII equivalent? No, it leaves the types as they are but simply considers strings to be "gr

Re: Regular expression negative look-ahead

2013-07-01 Thread Ian Kelly
On Mon, Jul 1, 2013 at 8:27 PM, Jason Friedman wrote: > Found this: > http://stackoverflow.com/questions/13871833/negative-lookahead-assertion-not-working-in-python. > > This pattern seems to work: > pattern = re.compile(r"^(?!.*(CTL|DEL|RUN))") > > But I am not sure why. > > > On Mon, Jul 1, 2013

Re: python adds an extra half space when reading from a string or list

2013-07-02 Thread Ian Kelly
On Tue, Jul 2, 2013 at 12:54 AM, Antoon Pardon wrote: > Why about you just ignore me? > > Serious, a lot of people here seem to think that if someone is bothered > by someone else, the bothered person should just ignore the botherer. > > That is until something starts bothering these people themse

Re: how to calculate reputation

2013-07-02 Thread Ian Kelly
On Tue, Jul 2, 2013 at 3:43 PM, Surya Kasturi wrote: > Hi all, this seems to be quite stupid question but I am "confused".. > We set the initial value to 0, +1 for up-vote and -1 for down-vote! nice. > > I have a list of bool values True, False (True for up vote, False for > down-vote).. submitted

Re: how to calculate reputation

2013-07-02 Thread Ian Kelly
On Tue, Jul 2, 2013 at 4:19 PM, Surya Kasturi wrote: > I think I didnt explain it clearly.. let me make it clear.. > > 1. The database we are using is having BooleanField for it!! so, cant do > anything > 2. I am not looking for sorting algorithms .. just simple math :) It sounds > crazy but let m

Re: [SPOILERS] Python easter eggs

2013-07-03 Thread Ian Foote
On 03/07/13 14:29, Steven D'Aprano wrote: Most people are familiar with: import this and sometimes even with: from __future__ import braces But I'm aware of at least three more. Anyone care to give them? import antigravity Regards, Ian F -- http://mail.python.org/mailma

Re: [SPOILERS] Python easter eggs

2013-07-03 Thread Ian Kelly
On Wed, Jul 3, 2013 at 8:03 AM, Ian Foote wrote: > On 03/07/13 14:29, Steven D'Aprano wrote: >> >> Most people are familiar with: >> >> import this >> >> >> and sometimes even with: >> >> from __future__ import braces >>

Re: [SPOILERS] Python easter eggs

2013-07-03 Thread Ian Kelly
On Wed, Jul 3, 2013 at 10:14 AM, Ian Kelly wrote: > On Wed, Jul 3, 2013 at 8:03 AM, Ian Foote wrote: >> On 03/07/13 14:29, Steven D'Aprano wrote: >>> >>> Most people are familiar with: >>> >>> import this >>> >>> >>> a

Re: DOS or not? [was Re: How to tell Script to use pythonw.exe ?]

2013-07-03 Thread Ian Kelly
On Wed, Jul 3, 2013 at 4:11 PM, Dennis Lee Bieber wrote: > On 03 Jul 2013 13:19:26 GMT, Steven D'Aprano > declaimed the following: > >>On Wed, 03 Jul 2013 14:00:49 +0100, Tim Golden wrote: >> >>> Goodness, I doubt if you'll find anyone who can seriously make a case >>> that the Windows command pr

Re: Default scope of variables

2013-07-04 Thread Ian Kelly
On Wed, Jul 3, 2013 at 11:32 PM, Steven D'Aprano wrote: >> Python lets you do that across but not within functions. >> >> But Javascript/ECMAScript/whatever doesn't give you that. A var >> declaration makes it function-local, no matter where the declaration is. >> That's pointless. C++, on the oth

Re: How to check for threads being finished?

2013-07-05 Thread Ian Kelly
On Fri, Jul 5, 2013 at 10:59 AM, Steven D'Aprano wrote: > I have a pool of worker threads, created like this: > > threads = [MyThread(*args) for i in range(numthreads)] > for t in threads: > t.start() > > > I then block until the threads are all done: > > while any(t.isAlive() for t in threads

Re: calculating binomial coefficients using itertools

2013-07-06 Thread Ian Kelly
On Fri, Jul 5, 2013 at 4:58 PM, Robert Hunter wrote: > from itertools import count, repeat, izip, starmap > > def binomial(n): > """Calculate list of Nth-order binomial coefficients using itertools.""" > > l = range(2) > for _ in xrange(n): > indices = izip(count(-1), count(1),

Re: Editor Ergonomics [was: Important features for editors]

2013-07-06 Thread Ian Kelly
On Sat, Jul 6, 2013 at 9:04 AM, rusi wrote: > On Saturday, July 6, 2013 7:40:39 PM UTC+5:30, Skip Montanaro wrote: >> > The fact that rms has crippling RSI should indicate that >> > emacs' ergonomics is not right. >> >> Kind of a small sample size, don't you think? Hopefully we can kill >> this me

Re: homework + obfuscation ... this might work ...

2013-07-08 Thread Ian Kelly
On Mon, Jul 8, 2013 at 2:43 PM, Skip Montanaro wrote: > I have an idea. Take the threads where students ask the list to do > their homework for them (but don't have the cojones to admit that's > what they are doing), and merge them with the obfuscated Python idea. > A group of people could come u

Re: Default scope of variables

2013-07-09 Thread Ian Kelly
On Tue, Jul 9, 2013 at 1:35 AM, Frank Millman wrote: > When any of them need any database access, whether for reading or for > updating, they execute the following - > > with db_session as conn: > conn.transaction_active = True # this line must be added if > updating > conn.cu

Re: the general development using Python

2013-07-09 Thread Ian Kelly
On Mon, Jul 8, 2013 at 10:46 PM, CM wrote: >> There are projects that "bundle" the CPython interpreter with your >> project, but this makes those files really big. > > Maybe 5-20 MB. That's a lot bigger than a few hundred K, but it's not that > important to keep size down, really. Funny story:

Re: Default scope of variables

2013-07-09 Thread Ian Kelly
On Tue, Jul 9, 2013 at 10:07 AM, Ethan Furman wrote: > You could also do it like this: > > def updating(self): > self.transaction_active = True > return self Yes, that would be simpler. I was all set to point out why this doesn't work, and then I noticed that the location of

Re: Default scope of variables

2013-07-09 Thread Ian Kelly
On Tue, Jul 9, 2013 at 11:23 AM, Ethan Furman wrote: > On 07/09/2013 09:44 AM, Ian Kelly wrote: >> >> On Tue, Jul 9, 2013 at 10:07 AM, Ethan Furman wrote: >>> >>> You could also do it like this: >>> >>> def updating(self): >>>

Re: multiprocessing

2013-07-09 Thread Ian Kelly
On Tue, Jul 9, 2013 at 12:09 PM, wrote: > I am a beginner with Python, coming from R, and I am having problems with > parallelization with the multiprocessing module. I know that other people > have asked similar questions but the answers were mostly over my head. > > Here is my problem: I trie

Re: Recursive class | can you modify self directly?

2013-07-09 Thread Ian Kelly
On Tue, Jul 9, 2013 at 4:01 PM, Russel Walker wrote: > Sorry for the vague title. Probably best to just show you the code that > explains it better. > > This is a simplified example of what I want to do: > > > # THIS DOESN'T WORK > from random import choice > > class Expr(object): > """ >

Re: Recursive class | can you modify self directly?

2013-07-09 Thread Ian Kelly
On Tue, Jul 9, 2013 at 4:18 PM, Ian Kelly wrote: > If you actually want to modify the current object, you would need to > do something like: > > def expand(self): > import copy > self.expr = Expr(self.expr, self.op, self.val) >

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Ian Kelly
On Wed, Jul 10, 2013 at 2:32 AM, Mats Peterson wrote: > Chris Angelico wrote: >> On Wed, Jul 10, 2013 at 5:55 PM, Mats Peterson wrote: >>> A moderator who calls himself “animuson” on Stack Overflow doesn’t >>> want to face the truth. He has deleted all my postings regarding Python >>> regular ex

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Ian Kelly
On Wed, Jul 10, 2013 at 2:42 AM, Mats Peterson wrote: > Chris Angelico wrote: >> On Wed, Jul 10, 2013 at 5:55 PM, Mats Peterson wrote: >>> A moderator who calls himself “animuson” on Stack Overflow doesn’t >>> want to face the truth. He has deleted all my postings regarding Python >>> regular ex

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Ian Kelly
On Wed, Jul 10, 2013 at 2:46 AM, Mats Peterson wrote: >> Then they would have full control of this list and what gets pos > > Ahhh so this is pos, right? Telling the truth? Interesting. I don't know what you mean by that, but since the joke appears to have flown over your head, I'll explain i

Re: Default scope of variables

2013-07-10 Thread Ian Kelly
On Tue, Jul 9, 2013 at 11:54 PM, Frank Millman wrote: > You had me worried there for a moment, as that is obviously an error. > > Then I checked my actual code, and I find that I mis-transcribed it. It > actually looks like this - > > with db_session as conn: > db_session.transaction_a

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Ian Kelly
On Wed, Jul 10, 2013 at 6:06 AM, Mats Peterson wrote: > Joshua Landau wrote: >> If you actually can satisfy these basic standards for a comparison (as >> I'm sure any competent person with so much bravo could) I'd be willing >> to converse with you. I'd like to see these results where Python comp

Re: Prime number generator

2013-07-10 Thread Ian Kelly
On Wed, Jul 10, 2013 at 8:00 AM, Chris Angelico wrote: > And now for something completely different. > > I knocked together a prime number generator, just for the fun of it, > that works like a Sieve of Eratosthenes but unbounded. It keeps track > of all known primes and the "next composite" that

Re: Prime number generator

2013-07-10 Thread Ian Kelly
On Wed, Jul 10, 2013 at 10:16 AM, Ian Kelly wrote: > The other interesting thing about my sieve is that it's a recursive > generator. I'll dig it up later and share it. As promised. Apologies for the excessive commenting. As noted, this implementation is a recursive generato

Re: Prime number generator

2013-07-10 Thread Ian Kelly
On Wed, Jul 10, 2013 at 11:47 AM, Joshua Landau wrote: >>> If you care about speed, you might want to check the heapq module. Removing >>> the smallest item and inserting a new item in a heap both cost O(log(N)) >>> time, while finding the minimum in a dictionary requires iterating over the >>>

Re: the general development using Python

2013-07-10 Thread Ian Kelly
On Tue, Jul 9, 2013 at 10:49 PM, CM wrote: > Can all the installation of the runtimes be done with an installer that is > itself an .exe, like with PyInstaller? If so, that's probably fine. It should be noted that PyInstaller is confusingly named. It actually creates standalone executables, no

Re: Recursive class | can you modify self directly?

2013-07-10 Thread Ian Kelly
On Wed, Jul 10, 2013 at 4:50 PM, Russel Walker wrote: > def append(self, x): > if len(self) < 3: > list.append(self, x) > else: > oldself = LRExpression(*self) > self.__init__(oldself) > self.append(x) It's probably not wise to b

Re: Kivy for Python 3.3

2013-07-11 Thread Ian Foote
irc channel? (#kivy on freenode, or http://webchat.freenode.net/?nick=kvuser.&channels=kivy&uio=d4) The channel is fairly active, though you might have to wait a bit for a response. I'm not a Windows user myself, so unfortunately I can't help with the issue directly. Regards, Ian F -- http://mail.python.org/mailman/listinfo/python-list

Re: xslice idea | a generator slice

2013-07-11 Thread Ian Kelly
On Thu, Jul 11, 2013 at 8:52 AM, Russel Walker wrote: > Just some dribble, nothing major. > > I like using slices but I also noticed that a slice expression returns a new > sequence. > > I sometimes find myself using them in a for loop like this: > > > seq = range(10) > for even in seq[::2]: >

Re: xslice idea | a generator slice

2013-07-11 Thread Ian Kelly
On Thu, Jul 11, 2013 at 10:34 AM, Oscar Benjamin wrote: > On 11 July 2013 17:21, Russel Walker wrote: >> To confess, this is the second time I've made the mistake of trying to >> implement generator like functionality of a builtin when there already is on >> in itertools. Need to start studying

Re: xslice idea | a generator slice

2013-07-11 Thread Ian Kelly
On Thu, Jul 11, 2013 at 1:58 PM, Fábio Santos wrote: > Isn't all of itertools implemented in C? If we are not using a python-level > and not-so-fast __getitem__ I would wager the C version is a lot faster. > > And if the input is indexable could I assume that it is not too large to > have around i

Re: Callable or not callable, that is the question!

2013-07-12 Thread Ian Kelly
On Thu, Jul 11, 2013 at 8:12 PM, Steven D'Aprano wrote: > On Thu, 11 Jul 2013 15:05:59 +0200, Ulrich Eckhardt wrote: > >> Hello! >> >> I just stumbled over a case where Python (2.7 and 3.3 on MS Windows) >> fail to detect that an object is a function, using the callable() >> builtin function. Inve

Re: GeoIP2 for retrieving city and region ?

2013-07-12 Thread Ian Kelly
On Fri, Jul 12, 2013 at 10:32 AM, Νικόλας wrote: > > I know i have asked before but hwta i get is ISP city not visitors precise > city. > > GeoLiteCity.dat isnt accurate that's why it comes for free. > i must somehow get access to GeoIPCity.dat which is the full version. > > And of course it can b

Re: Is this a bug?

2013-07-16 Thread Ian Kelly
On Tue, Jul 16, 2013 at 9:25 AM, Jack Bates wrote: > Ah, thank you Chris Angelico for explaining how this is like what happens > with default arguments to a function and Joshua Landau for pointing out how > assignments inside class bodies refer to properties of "self" on the LHS. It > makes sense

Re: Storing a very large number

2013-07-17 Thread Ian Kelly
On Wed, Jul 17, 2013 at 1:21 PM, Hasit Mistry wrote: > I came across a problem that requires me to store a very large number (say >>10^100). How do I do it efficiently? Both the int and Decimal types support arbitrary precision. Floats do not. > And also, how do I select a particular number (sa

Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Ian Kelly
On Jul 18, 2013 4:23 PM, "CTSB01" wrote: > > File "", line 2 > ... rtn = [] > ^ The "..." is the continuation prompt from the interactive interpreter, not part of the code. Don't paste it into Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Ian Kelly
On Thu, Jul 18, 2013 at 5:04 PM, CTSB01 wrote: > Thanks Ian. That worked regarding that issue. Now I have an 'invalid > syntax' issue unfortunately. > >>> def phi_m(x,m): > rtn = [] > for n2 in range(0, len(x)*m - 2): >

Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Ian Kelly
On Thu, Jul 18, 2013 at 5:42 PM, Ian Kelly wrote: > On Thu, Jul 18, 2013 at 5:04 PM, CTSB01 wrote: >> Thanks Ian. That worked regarding that issue. Now I have an 'invalid >> syntax' issue unfortunately. >> >>>> def phi_m(x,m): >>

Re: Python 3: dict & dict.keys()

2013-07-24 Thread Ian Kelly
On Tue, Jul 23, 2013 at 8:11 PM, Steven D'Aprano wrote: > Basically, views are set-like, not list-like. The keys and items views are set-like. The values view is not. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3: dict & dict.keys()

2013-07-24 Thread Ian Kelly
On Wed, Jul 24, 2013 at 8:58 AM, Skip Montanaro wrote: >> What do you mean? Why would you want to create a temporary list just to >> iterate over it explicitly or implicitly (set, sorted, max,...)? > > Because while iterating over the keys, he might also want to add or > delete keys to/from the di

Re: Python 3: dict & dict.keys()

2013-07-25 Thread Ian Kelly
On Thu, Jul 25, 2013 at 2:13 AM, Peter Otten <__pete...@web.de> wrote: > Chris Angelico wrote: > >> On Thu, Jul 25, 2013 at 5:04 PM, Steven D'Aprano >> wrote: >>> - Views support efficient (O(1) in the case of keys) membership testing, >>> which neither iterkeys() nor Python2 keys() does. >> >> To

Re: RE Module Performance

2013-07-25 Thread Ian Kelly
On Wed, Jul 24, 2013 at 9:34 AM, Chris Angelico wrote: > On Thu, Jul 25, 2013 at 12:17 AM, David Hutto wrote: >> I've screwed up plenty of times in python, but can write code like a pro >> when I'm feeling better(on SSI and medicaid). An editor can be built simply, >> but it's preference that mak

Re: RE Module Performance

2013-07-25 Thread Ian Kelly
On Thu, Jul 25, 2013 at 12:18 PM, Steven D'Aprano wrote: > On Fri, 26 Jul 2013 01:36:07 +1000, Chris Angelico wrote: > >> On Fri, Jul 26, 2013 at 1:26 AM, Steven D'Aprano >> wrote: >>> On Thu, 25 Jul 2013 14:36:25 +0100, Jeremy Sanders wrote: "To conserve memory, Emacs does not hold fixed-le

Re: RE Module Performance

2013-07-25 Thread Ian Kelly
On Thu, Jul 25, 2013 at 8:48 PM, Steven D'Aprano wrote: > UTF-8 uses a flexible representation on a character-by-character basis. > When parsing UTF-8, one needs to look at EVERY character to decide how > many bytes you need to read. In Python 3, the flexible representation is > on a string-by-str

Re: How would I do this?

2013-07-25 Thread Ian Kelly
On Thu, Jul 25, 2013 at 9:16 PM, John Doe wrote: > Hey guys, > > I;m working on making a chess program and I hit a wall. I have no idea how to > get the position of the chess pieces. I have the chess board 1-8 and A-H for > black as well as 1-8 and a-h for white. i just have to figure out how to

Re: How would I do this?

2013-07-25 Thread Ian Kelly
On Thu, Jul 25, 2013 at 9:40 PM, wrote: > Thank you for the quick reply. Unfortunately I'm still a little confused... > How might I implement that into my current code? Where you print spaces indicating an empty space, you need to look up the current square in the board data structure to see wh

Re: RE Module Performance

2013-07-26 Thread Ian Kelly
On Fri, Jul 26, 2013 at 9:37 PM, Steven D'Aprano wrote: > See the similarity now? Both flexibly change the width used by code- > points, UTF-8 based on the code-point itself regardless of the rest of > the string, Python based on the largest code-point in the string. No, I think we're just using

Re: RE Module Performance

2013-07-27 Thread Ian Kelly
On Sat, Jul 27, 2013 at 12:21 PM, wrote: > Back to utf. utfs are not only elements of a unique set of encoded > code points. They have an interesting feature. Each "utf chunk" > holds intrisically the character (in fact the code point) it is > supposed to represent. In utf-32, the obvious case, i

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Ian Kelly
On Mon, Jul 29, 2013 at 9:43 AM, Steven D'Aprano wrote: > Comparing floats to Fractions gives unexpected results: > > # Python 3.3 > py> from fractions import Fraction > py> 1/3 == Fraction(1, 3) > False > > but: > > py> 1/3 == float(Fraction(1, 3)) > True > > > I expected that float-to-Fraction c

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Ian Kelly
On Mon, Jul 29, 2013 at 10:20 AM, Chris Angelico wrote: > On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: >> I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats >> are approximate anyway, and the float value 1/3 is more likely to be >> Fraction(1, 3) than Fraction(6004799503160661,

<    1   2   3   4   5   6   7   8   9   10   >