On Thu, 4 Nov 2021 08:57:14 +0100, ast wrote:
> > li = []
> > li.append(li)
> > li
> [[...]]
>
> >li[0][0][0][0]
> [[...]]
>
> That's funny
After the coming AI upheaval, such cruelty to machines will
be considered punishable and not funny.
--
To email me, substitute nowhere->runbox, invalid->c
ast writes:
>> li = []
>> li.append(li)
>> li
> [[...]]
>
>>li[0][0][0][0]
> [[...]]
>
> That's funny
>
You made a list whose only element is itself.
In [1]: li = []
In [3]: li.append(li)
In [4]: li[0] is li
Out[4]: True
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8D
On Sat, Jun 11, 2011 at 21:39, Terry Reedy wrote:
> What may not be obvious from the docs is that the metaclass calculation
> described in the doc section on class statements is carried out within
> type.__new__ (or after a possible patch, called from within that), so that
> type calls are really
On 6/11/2011 7:38 AM, Steven D'Aprano wrote:
On Sat, 11 Jun 2011 01:33:25 -0400, Terry Reedy wrote:
On 6/10/2011 11:34 PM, Steven D'Aprano wrote:
I have a metaclass in Python 3.1:
class MC1(type):
@staticmethod
def get_mro(bases):
print('get_mro called')
return
On Sat, 11 Jun 2011 01:33:25 -0400, Terry Reedy wrote:
> On 6/10/2011 11:34 PM, Steven D'Aprano wrote:
>> I have a metaclass in Python 3.1:
>>
>> class MC1(type):
>> @staticmethod
>> def get_mro(bases):
>> print('get_mro called')
>> return type('K', bases, {}).__mro__[1
On 6/10/2011 11:34 PM, Steven D'Aprano wrote:
I have a metaclass in Python 3.1:
class MC1(type):
@staticmethod
def get_mro(bases):
print('get_mro called')
return type('K', bases, {}).__mro__[1:]
The call to type figures out the proper metaclass from bases and
forwa
On May 20, 10:18 am, Chris Angelico wrote:
> On Fri, May 20, 2011 at 3:05 PM, rusi wrote:
> > - data can be code -- viruses
>
> It's not JUST viruses. There's plenty of legitimate reasons for your
> data to actually be code... that's how compilers work! :)
>
> Chris Angelico
Yes sure Thanks.
An
On Fri, May 20, 2011 at 3:05 PM, rusi wrote:
> - data can be code -- viruses
It's not JUST viruses. There's plenty of legitimate reasons for your
data to actually be code... that's how compilers work! :)
Chris Angelico
--
http://mail.python.org/mailman/listinfo/python-list
On May 15, 8:20 pm, Mark Dickinson wrote:
> On May 15, 4:32 am, rusi wrote:
>
> > On May 15, 2:19 am, Ian Kelly wrote:
> > > Yup, linear. Assuming you optimize the even case so that it doesn't
> > > actually call fib(n//2) twice, the call tree can be approximated as a
> > > balanced binary tree
On May 15, 4:32 am, rusi wrote:
> On May 15, 2:19 am, Ian Kelly wrote:
> > Yup, linear. Assuming you optimize the even case so that it doesn't
> > actually call fib(n//2) twice, the call tree can be approximated as a
> > balanced binary tree with height log(n). The total number of nodes in
> >
On May 15, 2:19 am, Ian Kelly wrote:
> On Sat, May 14, 2011 at 11:24 AM, rusi wrote:
> > def fib(n):
> > if n==1 or n==2:
> > return 1
> > elif even(n):
> > return sq(fib (n//2)) + 2 * fib(n//2) * fib(n//2 - 1)
> > else:
> > return sq(fib (n//2 + 1)) + sq(fib(n // 2)
On Sat, May 14, 2011 at 11:24 AM, rusi wrote:
> def fib(n):
> if n==1 or n==2:
> return 1
> elif even(n):
> return sq(fib (n//2)) + 2 * fib(n//2) * fib(n//2 - 1)
> else:
> return sq(fib (n//2 + 1)) + sq(fib(n // 2))
>
> This is a strange algo -- logarithmic because i
On May 14, 2:48 am, Mark Dickinson wrote:
> I don't see this (or Hans' version) as cheating at all.
Yeah sure -- cheating is a strong word :-)
> This really *is* the power algorithm, just in a different number system from
> the
> usual one.
Yes that was my point. If we take the standard log
On May 11, 11:06 pm, Hans Mulder wrote:
> On 03/05/2011 09:52, rusi wrote:
>
> > [If you believe it is, then try writing a log(n) fib iteratively :D ]
>
> It took me a while, but this one seems to work:
>
> from collections import namedtuple
>
> Triple = namedtuple('Triple', 'hi mid lo')
> Triple.
On 13/05/2011 13:11, rusi wrote:
On May 12, 3:06 am, Hans Mulder wrote:
On 03/05/2011 09:52, rusi wrote:
[If you believe it is, then try writing a log(n) fib iteratively :D ]
It took me a while, but this one seems to work:
from collections import namedtuple
Triple = namedtuple('Triple', '
On Fri, May 13, 2011 at 5:11 AM, rusi wrote:
> The tightest way I knew so far was this:
> The 2x2 matrix
> 0 1
> 1 1
> raised to the nth power gives the nth fibonacci number. [And then use
> a logarithmic matrix mult]
> Your version is probably tighter than this.
Oh, nice! I did it this way once
On May 12, 3:06 am, Hans Mulder wrote:
> On 03/05/2011 09:52, rusi wrote:
>
> > [If you believe it is, then try writing a log(n) fib iteratively :D ]
>
> It took me a while, but this one seems to work:
>
> from collections import namedtuple
>
> Triple = namedtuple('Triple', 'hi mid lo')
> Triple._
On 03/05/2011 09:52, rusi wrote:
[If you believe it is, then try writing a log(n) fib iteratively :D ]
It took me a while, but this one seems to work:
from collections import namedtuple
Triple = namedtuple('Triple', 'hi mid lo')
Triple.__mul__ = lambda self, other: Triple(
self.hi * othe
On Tue, May 3, 2011 at 5:49 AM, Steven D'Aprano <
[email protected]> wrote:
> On Tue, 03 May 2011 21:04:07 +1000, Chris Angelico wrote:
>
> > And that, Your Honour, is why I prefer bignums (especially for integers)
> > to floating point. Precision rather than performance.
>
> I'
On Tue, May 3, 2011 at 10:49 PM, Steven D'Aprano
wrote:
> On Tue, 03 May 2011 21:04:07 +1000, Chris Angelico wrote:
>
>> And that, Your Honour, is why I prefer bignums (especially for integers)
>> to floating point. Precision rather than performance.
>
> I'm intrigued by your comment "especially f
On Tue, 03 May 2011 21:04:07 +1000, Chris Angelico wrote:
> And that, Your Honour, is why I prefer bignums (especially for integers)
> to floating point. Precision rather than performance.
I'm intrigued by your comment "especially for integers", which implies
that you might use bignums for non-i
On Tue, May 3, 2011 at 8:32 PM, Dave Angel wrote:
> What I'm surprised at is that nobody has pointed out that the logn version
> is also generally more accurate, given traditional floats. Usually getting
> the answer accurate (given the constraints of finite precision
> intermediates) is more impo
On May 3, 3:32 pm, Dave Angel wrote:
> What I'm surprised at is that nobody has pointed out that the logn
> version is also generally more accurate, given traditional floats.
> Usually getting the answer accurate (given the constraints of finite
> precision intermediates) is more important than p
On 01/-10/-28163 02:59 PM, rusi wrote:
On May 3, 10:29 am, Chris Angelico wrote:
On Tue, May 3, 2011 at 3:27 PM, Dan Stromberg wrote:
Doh.
Usually when someone gives a recursive solution to this problem, it's
O(logn), but not this time.
Here's a logn one:
:-) Ok so you beat me to it :D
On May 3, 10:29 am, Chris Angelico wrote:
> On Tue, May 3, 2011 at 3:27 PM, Dan Stromberg wrote:
> Doh.
> Usually when someone gives a recursive solution to this problem, it's
> O(logn), but not this time.
> Here's a logn one:
:-) Ok so you beat me to it :D
I was trying to arrive at an answer
On Mon, May 2, 2011 at 10:29 PM, Chris Angelico wrote:
> On Tue, May 3, 2011 at 3:27 PM, Dan Stromberg wrote:
> >
> > But the recursive solution has time complexity of O(logn). The iterative
> > solution has time complexity of O(n). That's a significant difference
> for
> > large n - a signifi
On Mon, May 2, 2011 at 11:27 PM, Dan Stromberg wrote:
> But the recursive solution has time complexity of O(logn). The iterative
> solution has time complexity of O(n). That's a significant difference for
> large n - a significant benefit of the recursive version.
It's linear as written. I th
On Tue, May 3, 2011 at 3:27 PM, Dan Stromberg wrote:
>
> But the recursive solution has time complexity of O(logn). The iterative
> solution has time complexity of O(n). That's a significant difference for
> large n - a significant benefit of the recursive version.
Are you sure? It will produce
On Mon, May 2, 2011 at 7:13 PM, Chris Angelico wrote:
> On Tue, May 3, 2011 at 11:48 AM, rusi wrote:
> > What are their space/time complexities?
> > Which do you prefer?
>
> They're pretty similar actually. If you rework the first one to not
> use range() but instead have a more classic C style
On Tue, May 3, 2011 at 11:48 AM, rusi wrote:
> What are their space/time complexities?
> Which do you prefer?
They're pretty similar actually. If you rework the first one to not
use range() but instead have a more classic C style of loop, they'll
be almost identical:
def powI(x,n):
result = 1
On 12/2/09, Dave Angel wrote:
> Joel Madigan wrote:
>> Hi everyone!
>> Sorry this isn't strictly a Python question but my algorithms professor
>> contends that given the standard recursive-backtracking maze solving
>> algorithm:
>>
>> width=6
>> height=4
>> maze=[[1,0,1,1,0,1],
>> [0,0,1,0,0
On Wed, 2009-12-02 at 02:07 -0500, Joel Madigan wrote:
>
> that it is possible to make it print the path to the finish in the
> order the steps were taken. That is, the algorithm as written
> produces: (4,0) (4,1) (3,1) (3,2) (3,3) (2,3) (1,3) (1,2) True
>
> Rather than (1,2) (1,3) (2,3) (3,3)
Joel Madigan wrote:
Hi everyone!
Sorry this isn't strictly a Python question but my algorithms professor
contends that given the standard recursive-backtracking maze solving
algorithm:
width=6
height=4
maze=[[1,0,1,1,0,1],
[0,0,1,0,0,0],
[1,0,1,0,1,0],
[0,0,0,0,1,1]]
visited =
process wrote:
http://projecteuler.net/index.php?section=problems&id=18
def recur(tree, pos):
if not tree:
return []
else:
return [[tree[0][pos]] + recur(tree[1:], pos)] + \
[[tree[0][pos]] + recur(tree[1:], pos+1)]
The backslash is not needed here or an
cnb wrote:
this recursive definition of sum thrumped me, is this some sort of
gotcha or am I just braindead today?
and yes i know this is easy a a for x in xs acc += x or just using the
builtin.
def suma(xs, acc=0):
if len(xs) == 0:
acc
else:
suma(
On Sep 14, 9:44 am, "Marco Bizzarri" <[EMAIL PROTECTED]> wrote:
> On Sun, Sep 14, 2008 at 10:08 AM, Marco Bizzarri
>
>
>
> <[EMAIL PROTECTED]> wrote:
> > On Sun, Sep 14, 2008 at 10:01 AM, cnb <[EMAIL PROTECTED]> wrote:
> >> this recursive definition of sum thrumped me, is this some sort of
> >> got
On Sun, Sep 14, 2008 at 10:08 AM, Marco Bizzarri
<[EMAIL PROTECTED]> wrote:
> On Sun, Sep 14, 2008 at 10:01 AM, cnb <[EMAIL PROTECTED]> wrote:
>> this recursive definition of sum thrumped me, is this some sort of
>> gotcha or am I just braindead today?
>> and yes i know this is easy a a for x in xs
On Sep 14, 9:01 am, cnb <[EMAIL PROTECTED]> wrote:
> def suma(xs, acc=0):
> if len(xs) == 0:
> acc
> else:
> suma(xs[1:], acc+xs[0])
>
> it returns none.
Yep, that's because there is no "return" statement anywhere. Python
doesn't return expressions "
On Sun, Sep 14, 2008 at 10:01 AM, cnb <[EMAIL PROTECTED]> wrote:
> this recursive definition of sum thrumped me, is this some sort of
> gotcha or am I just braindead today?
> and yes i know this is easy a a for x in xs acc += x or just using the
> builtin.
>
> def suma(xs, acc=0):
>if len(x
B wrote:
>
> # pass in window handle and parent node
> def gwl(node, hwnd):
> if hwnd:
> yield node, hwnd
> for nd, wnd in Wnd.gwl(node.children[-1], GetWindow(hwnd,
> GW_CHILD)):
> yield nd, wnd
> for nd, wnd in Wnd.gwl(node, GetWind
B wrote:
Now it works, but it runs quite slow (compared to the c++ app). I
changed gwl from strait recursion to use a generator and that helped,
but it still takes 0.5-1.0 seconds to populate the tree. What I'm
wondering is am I doing it in a really inefficient way, or is it just
python?
W
defn noob a écrit :
class Graph(object):
where does anyone write like that?
Almost everywhere nowadays.
I've seen only examples like i have
written.
Most of the doc has still not been updated since the introduction of
newstyle classes years ago. You'll find more here:
http://docs.python.
defn noob wrote:
if start == end:
return path
if not self.dictionary.has_key(start):
if start not in self.dictionnary:
return None
for node in self.dictionary[start]:
if node not in path:
newpath = find_path
>
> > if start == end:
> > return path
> > if not self.dictionary.has_key(start):
>
>if start not in self.dictionnary:
>
> > return None
> > for node in self.dictionary[start]:
> > if node not in path:
> > newpa
class Graph(object):
where does anyone write like that? I've seen only examples like i have
written.
is the object then passed to init?
class Graph(object):
def __init__(self, dictionary):
self.structure = dictionary
or
class Graph(object):
def __init__(self, object):
klant a écrit :
do i need to call Graph.find_path?
>
g = Graph({'A': ['B', 'C'],
'B': ['C', 'D'],
'C': ['D'],
'D': ['C'],
'E': ['F'],
'F': ['C']})
g
<__main__.Graph instance at 0x01D74378>
g.find_all_paths('A', 'C')
Traceb
Wrong:
newpath = find_path(self.dictionary, node, end, path)
newpaths = find_all_paths(self.dictionary, node, end, path)
newpath = find_shortest_path(self.dictionary, node, end, path)
Correct;
newpath = self.find_path(self.dictionary, node, end, path)
newpaths = self.find_all_paths(self.dictionary
On Sun, 25 May 2008 00:00:14 -0700, notnorwegian wrote:
> when using recursion should one use a return statement or not?
This decision has nothing to do with recursion. It's the same as in
non recursive functions. If the function calculates something that you
want to return to the caller you ha
En Sun, 10 Feb 2008 02:09:12 -0200, Victor Lin <[EMAIL PROTECTED]>
escribió:
> On 2月10日, 上午11時42分, "Gabriel Genellina" <[EMAIL PROTECTED]>
> wrote:
>> En Sat, 09 Feb 2008 09:49:46 -0200, Victor Lin <[EMAIL PROTECTED]>
>> escribió:
>>
>> > I encounter a problem with pickle.
>> > I download a html
On 2月10日, 上午11時42分, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Sat, 09 Feb 2008 09:49:46 -0200, Victor Lin <[EMAIL PROTECTED]>
> escribi�:
>
> > I encounter a problem with pickle.
> > I download a html from:
>
> >http://www.amazon.com/Magellan-Maestro-4040-Widescreen-Navigator/dp/B...
>
>
En Sat, 09 Feb 2008 09:49:46 -0200, Victor Lin <[EMAIL PROTECTED]>
escribi�:
> I encounter a problem with pickle.
> I download a html from:
>
> http://www.amazon.com/Magellan-Maestro-4040-Widescreen-Navigator/dp/B000NMKHW6/ref=sr_1_2?ie=UTF8&s=electronics&qid=1202541889&sr=1-2
>
> and parse it w
On Sep 15, 3:06 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote:
>
> There have been languages, for instance, Fortran IV, where local variables
> were part of the function 'object' and which therefore prohibited recursion
> because of the very problem you alluded to in your question. (My guess is
> th
"Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
|f([1, 2, 3])
| r1 f([2, 3]) + [1]
| r2 f([3]) + [2] + [1]
| r3 f([]) + [3] + [2] + [1]
| r4 [] + [3] + [2] + [1]
I might help to note that the above is effectively parenthesized
( ( ([]+{3]) + [2]) +
Gigs_ wrote:
> Steve Holden wrote:
[...]
>>
>> regards
>> Steve
> >>> def factorial(n):
> print "n =", n
> if n==0:
> return 1
> else:
> return n * factorial(n-1)
>
> >>> factorial(3)
> n = 3
> n = 2
> n = 1
> n = 0
> 6
>
>
> now i understand. but one question at t
On Fri, 14 Sep 2007 15:58:39 +0200, Gigs_ wrote:
> >>> def factorial(n):
> print "n =", n
> if n==0:
> return 1
> else:
> return n * factorial(n-1)
>
> >>> factorial(3)
> n = 3
> n = 2
> n = 1
> n = 0
> 6
>
>
> now i understand. but one question at the end this fun
On 2007-09-14, John Machin <[EMAIL PROTECTED]> wrote:
> On Sep 14, 10:04 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> On Fri, 14 Sep 2007 13:40:17 +0200, Gigs_ wrote:
>> > sorry i think that i express wrong. having problem with english
>>
>> > what i mean is how python knows to add al
On Fri, Sep 14, 2007 at 01:40:17PM +0200, Gigs_ wrote regarding Re: recursion:
>
> what i mean is how python knows to add all thing at the end of recursion
>
> >>> def f(l):
> if l == []:
> return []
> else:
> return f(l[1:]) + l[
Steve Holden wrote:
> Gigs_ wrote:
>> sorry i think that i express wrong. having problem with english
>>
>>
>> what i mean is how python knows to add all thing at the end of recursion
>>
>> >>> def f(l):
>> if l == []:
>> return []
>> else:
>> return f(l[1:]) + l[:1]
>>
On Sep 14, 10:04 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Fri, 14 Sep 2007 13:40:17 +0200, Gigs_ wrote:
> > sorry i think that i express wrong. having problem with english
>
> > what i mean is how python knows to add all thing at the end of recursion
>
> Because you have written
Gigs_ wrote:
> sorry i think that i express wrong. having problem with english
>
>
> what i mean is how python knows to add all thing at the end of recursion
>
> >>> def f(l):
> if l == []:
> return []
> else:
> return f(l[1:]) + l[:1]
>
>
> f([1,2,3])
>
> recursi
On Fri, 14 Sep 2007 13:40:17 +0200, Gigs_ wrote:
> sorry i think that i express wrong. having problem with english
>
>
> what i mean is how python knows to add all thing at the end of recursion
Because you have written code that tells Python to do so. ;-)
> >>> def f(l):
> if l == []:
>
sorry i think that i express wrong. having problem with english
what i mean is how python knows to add all thing at the end of recursion
>>> def f(l):
if l == []:
return []
else:
return f(l[1:]) + l[:1]
f([1,2,3])
recursion1 f([2,3]) + [1]
recursion2 f([3]) +
On 2007-09-13, Ian Clark <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> On 2007-09-13, Gigs_ <[EMAIL PROTECTED]> wrote:
>>> Can someone explain me this
>>>
>> def f(l):
>>> if l == []:
>>> return []
>>> else:
>>> return f(l[1:]) + l[:1] # <= cant figure thi
Ian Clark wrote:
> Neil Cerutti wrote:
>> On 2007-09-13, Gigs_ <[EMAIL PROTECTED]> wrote:
>>> Can someone explain me this
>>>
>> def f(l):
>>> if l == []:
>>> return []
>>> else:
>>> return f(l[1:]) + l[:1] # <= cant figure this, how is all
>>> sum at the end?
>>
>> In
Neil Cerutti wrote:
> On 2007-09-13, Gigs_ <[EMAIL PROTECTED]> wrote:
>> Can someone explain me this
>>
> def f(l):
>> if l == []:
>> return []
>> else:
>> return f(l[1:]) + l[:1] # <= cant figure this, how is all sum
>> at the end?
>
> In plain English, t
On 2007-09-13, Gigs_ <[EMAIL PROTECTED]> wrote:
> Can someone explain me this
>
> >>> def f(l):
> if l == []:
> return []
> else:
> return f(l[1:]) + l[:1] # <= cant figure this, how is all sum
> at the end?
In plain English, the above program says:
The s
Gigs_ wrote:
> Can someone explain me this
> def f(l):
> if l == []:
> return []
> else:
> return f(l[1:]) + l[:1] # <= cant figure this, how is
> all sum at the end?
If you think about building up from the simplest case:
f([]) = []
f(['a']) = f([])
En Thu, 07 Jun 2007 08:23:48 -0300, Nathan Harmston
<[EMAIL PROTECTED]> escribió:
> I m trying to implement an object which contains lazy" variables. My
> idea is to alter the getattr and the setattr methods. However I keep
> on getting a recursion error.
Instead of setattr/getattr, use a prope
On 6/7/07, Nathan Harmston <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I m trying to implement an object which contains lazy" variables. My
> idea is to alter the getattr and the setattr methods. However I keep
> on getting a recursion error.
Simplifying radically, you are doing:
def __setattr__(sel
En Tue, 15 May 2007 09:28:52 -0300, Diez B. Roggisch <[EMAIL PROTECTED]>
escribió:
>> with the same hash value.
>> That is, you should define __hash__ and one of (__cmp__ or __eq__).
>> __neq__ (inequality) isn't required nor used by dict/set implementation.
>> (Anyway, Python will transform a!=
> with the same hash value.
> That is, you should define __hash__ and one of (__cmp__ or __eq__).
> __neq__ (inequality) isn't required nor used by dict/set implementation.
> (Anyway, Python will transform a!=b into not(a==b), if __neq__ isn't
> defined). Neither <, <=, >, >= are used.
No, it won'
On May 14, 2:03 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
>
> Dicts and sets use the key's hash value to determine the "bucket" where
> the key will be placed, and == to distingish between different objects
> with the same hash value.
> That is, you should define __hash__ and one of (_
On May 14, 1:20 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote:
>
> Dicts first compare hashes and if they are equal, then check equality. If
> two unequal strings have the same hash value, as is possible of course
> (given only 2**32 possible hashes and many more possible strings), both can
> still
En Mon, 14 May 2007 12:35:16 -0300, elventear <[EMAIL PROTECTED]>
escribió:
> Since I am defining a hash for my object, it makes sense that I should
> be able to define equality. But I am not sure about inequality, in my
> specific case. The paragraph above mentions that __cmp__ should be
> defi
"elventear" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
On May 12, 12:25 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Fri, 11 May 2007 19:17:57 -0300, elventear <[EMAIL PROTECTED]>
> escribió:
> "The only required property is that objects which compare equal have the
>
On May 12, 12:25 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Fri, 11 May 2007 19:17:57 -0300, elventear <[EMAIL PROTECTED]>
> escribió:
> "The only required property is that objects which compare equal have the
> same hash value; it is advised to somehow mix together (e.g., using
On May 11, 11:54 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote:
>
> Without seeing the full code and the exception traceback, my guess is that
> your __hash__ somehow calls itself due to a refence loop in your object. A
> simple example of a loop:
> a = []; a.append(a)
> Now, list objects are not ha
En Fri, 11 May 2007 19:17:57 -0300, elventear <[EMAIL PROTECTED]>
escribió:
> I am runing into recursion limit problems. I have found that the
> culprit was related to the __hash__ function that I had assigned to
> the objects that were added to a set.
As T. Reedy said, probably you have a recu
"elventear" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| Hello everyone,
|
| I am runing into recursion limit problems. I have found that the
| culprit was related to the __hash__ function that I had assigned to
| the objects that were added to a set.
|
| Basically my __hash__ fu
On Apr 23, 2007, at 1:57 AM, proctor wrote:
> On Apr 22, 5:51 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
>> Oops! Note to self: *ALWAYS* try code before posting to a public
>> forum :-(
>>
>> def binary(val, width):
>> print '%10s = the sum of' % val
>> for i in [2 ** x for x
On Apr 22, 5:51 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
> Oops! Note to self: *ALWAYS* try code before posting to a public
> forum :-(
>
> def binary(val, width):
> print '%10s = the sum of' % val
> for i in [2 ** x for x in range(width - 1, -1, -1)]:
> a = v
On Apr 22, 8:23 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
> Steven Bethard <[EMAIL PROTECTED]> wrote:
>
>...
>
>
>
> > > import sys
> > > def ch4(item, n=0):
> > >if n < len(item):
> > >if item[n] == '0':
> > >item[n] = '1'
> > >
On Apr 22, 9:28 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On 22 Apr 2007 19:13:31 -0700, proctor <[EMAIL PROTECTED]> declaimed the
> following in comp.lang.python:
>
>
>
> > :-)
>
> > this is good stuff. for learning especially! thank you again!
>
> Took me some time to find... M
On Apr 22, 9:13�pm, proctor <[EMAIL PROTECTED]> wrote:
> On Apr 22, 7:10 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On 22 Apr 2007 17:06:18 -0700, proctor <[EMAIL PROTECTED]> declaimed the
> > following in comp.lang.python:
>
> > > > � � else:
> > > > � � � � # only one of carry
Alex Martelli wrote:
> Steven Bethard <[EMAIL PROTECTED]> wrote:
>...
>>> import sys
>>> def ch4(item, n=0):
>>>if n < len(item):
>>>if item[n] == '0':
>>>item[n] = '1'
>>>print ''.join(item)
>>>
Steven Bethard <[EMAIL PROTECTED]> wrote:
...
> > import sys
> > def ch4(item, n=0):
> >if n < len(item):
> >if item[n] == '0':
> >item[n] = '1'
> >print ''.join(item)
> >ch4(item)
> >
On Apr 22, 7:34 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
> proctor wrote:
> > On Apr 22, 2:06 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
> >> proctor wrote:
> >>> On Apr 22, 1:24 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
> On Apr 22, 2007, at 1:49 PM, proctor wrote:
> > i have
On Apr 22, 7:10 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On 22 Apr 2007 17:06:18 -0700, proctor <[EMAIL PROTECTED]> declaimed the
> following in comp.lang.python:
>
> > > else:
> > > # only one of carry in, b1, or b2 is set
>
> #or none is set! Missed t
proctor wrote:
> On Apr 22, 2:06 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
>> proctor wrote:
>>> On Apr 22, 1:24 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
On Apr 22, 2007, at 1:49 PM, proctor wrote:
> i have a small function which mimics binary counting. it runs fine as
> lon
On Apr 22, 5:51 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Sun, 22 Apr 2007 17:37:05 -0500, Michael Bentley
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
> > Anything that can be done with recursion can be done without
> > recursion. If you really wanted to mimic
On Apr 22, 5:51 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
> Oops! Note to self: *ALWAYS* try code before posting to a public
> forum :-(
>
> def binary(val, width):
> print '%10s = the sum of' % val
> for i in [2 ** x for x in range(width - 1, -1, -1)]:
> a = v
Oops! Note to self: *ALWAYS* try code before posting to a public
forum :-(
def binary(val, width):
print '%10s = the sum of' % val
for i in [2 ** x for x in range(width - 1, -1, -1)]:
a = val / i
print ' ' * 13 + '%s * (2 ** %s)' % (a, width)
On Apr 22, 2007, at 5:47 PM, proctor wrote:
> On Apr 22, 4:37 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
>> On Apr 22, 2007, at 4:08 PM, proctor wrote:
>>
>>
>>
>>> On Apr 22, 2:55 pm, [EMAIL PROTECTED] wrote:
On Apr 22, 11:49 am, proctor <[EMAIL PROTECTED]> wrote:
>>
> hello,
>>
>>>
On Apr 22, 5:05 pm, tac-tics <[EMAIL PROTECTED]> wrote:
> Yes, you should use a for loop in this situation.
>
> Certain functional languages, such as Scheme and various LISP dialects
> allow for what is called "tail recursion" which effectively eliminates
> this problem by internally converting rec
Yes, you should use a for loop in this situation.
Certain functional languages, such as Scheme and various LISP dialects
allow for what is called "tail recursion" which effectively eliminates
this problem by internally converting recursion to iteration. Python
isn't really cut out for heavy recurs
On Apr 22, 4:37 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
> On Apr 22, 2007, at 4:08 PM, proctor wrote:
>
>
>
> > On Apr 22, 2:55 pm, [EMAIL PROTECTED] wrote:
> >> On Apr 22, 11:49 am, proctor <[EMAIL PROTECTED]> wrote:
>
> >>> hello,
>
> >>> i have a small function which mimics binary countin
On Apr 22, 2007, at 4:08 PM, proctor wrote:
> On Apr 22, 2:55 pm, [EMAIL PROTECTED] wrote:
>> On Apr 22, 11:49 am, proctor <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>>> hello,
>>
>>> i have a small function which mimics binary counting. it runs
>>> fine as
>>> long as the input is not too long, but
On Apr 22, 2:06 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
> proctor wrote:
> > On Apr 22, 1:24 pm, Michael Bentley <[EMAIL PROTECTED]> wrote:
> >> On Apr 22, 2007, at 1:49 PM, proctor wrote:
>
> >>> i have a small function which mimics binary counting. it runs fine as
> >>> long as the input i
On Apr 22, 2:55 pm, [EMAIL PROTECTED] wrote:
> On Apr 22, 11:49 am, proctor <[EMAIL PROTECTED]> wrote:
>
>
>
> > hello,
>
> > i have a small function which mimics binary counting. it runs fine as
> > long as the input is not too long, but if i give it input longer than
> > 8 characters it gives
>
On Apr 22, 11:49 am, proctor <[EMAIL PROTECTED]> wrote:
> hello,
>
> i have a small function which mimics binary counting. it runs fine as
> long as the input is not too long, but if i give it input longer than
> 8 characters it gives
>
> RuntimeError: maximum recursion depth exceeded in cmp
>
> i
1 - 100 of 110 matches
Mail list logo