On 14/12/2022 13:49, Stefan Ram wrote:
I also found an example similar to what was discussed here
in pypy's library file "...\Lib\_tkinter\__init__.py":
|def _flatten(item):
|def _flatten1(output, item, depth):
|if depth > 1000:
|raise ValueError("nesting too deep i
On 13/12/2022 15:46, Michael F. Stemper wrote:
It's easy enough -- in fact necessary -- to handle the bottom
level of a function differently than the levels above it. What
about the case where you want to handle something differently
in the top level than in lower levels? Is there any way to tell
On 13/12/2022 09.03, Stefan Ram wrote:
"Michael F. Stemper" writes:
def fred(cf,toplevel=True):
x = cf[0]
if len(cf)>1:
if toplevel:
return x + fred(cf[1:],False)
else:
return "(" + x + fred(cf[1:],False) + ")"
else:
if toplevel:
return x
else:
On Wed, 14 Dec 2022 at 05:01, Mats Wichmann wrote:
>
> On 12/13/22 10:36, Chris Angelico wrote:
> > On Wed, 14 Dec 2022 at 03:35, Michael F. Stemper
> > wrote:
> >>
> >> It's easy enough -- in fact necessary -- to handle the bottom
> >> level of a function differently than the levels above it. Wh
On 12/13/22 10:36, Chris Angelico wrote:
On Wed, 14 Dec 2022 at 03:35, Michael F. Stemper
wrote:
It's easy enough -- in fact necessary -- to handle the bottom
level of a function differently than the levels above it. What
about the case where you want to handle something differently
in the top
On Wed, 14 Dec 2022 at 03:35, Michael F. Stemper
wrote:
>
> It's easy enough -- in fact necessary -- to handle the bottom
> level of a function differently than the levels above it. What
> about the case where you want to handle something differently
> in the top level than in lower levels? Is the
: Tuesday, December 13, 2022 10:25 AM
To: python-list@python.org
Subject: Re: Top level of a recursive function
Supersedes:
r...@zedat.fu-berlin.de (Stefan Ram) writes:
>def rest( s ):
>return "(" + s[ 0 ] +( rest( s[1:] ) if len( s )> 1 else '' )+ ')'
&
It's easy enough -- in fact necessary -- to handle the bottom
level of a function differently than the levels above it. What
about the case where you want to handle something differently
in the top level than in lower levels? Is there any way to tell
from within a function that it wasn't invoked b
Yawar Amin wrote:
Cool ... but it looks like this can still potentially hit the max
recursion limit?
It depends on the nature of your data. If the data is
a tree, it's very unlikely you'll reach the recursion
limit unless the tree is massively unbalanced.
If there's a chance of that, or if th
Roy Smith wrote:
I will commonly put something like:
import logging
logger = logging.getLogger("logger-name-for-my-module")
But that's not really a global variable, it's a
global constant. There's nothing wrong with those,
we use them all the time -- classes, functions, etc.
If you were to re
On Sun, Jan 18, 2015 at 4:30 AM, Albert van der Horst
wrote:
> The proper technique is make the global local to the normal subroutine,
> then make the subroutine with those parameters you don't want to see
> also local to that subroutine.
> E.g.
>
> def fib(n):
> ' return the n-th Fibonacci nu
In article <5e4ccec6-7a00-467d-8cf6-258ab0421...@googlegroups.com>,
Tim wrote:
>I have this type of situation and wonder if I should use a global
>variable outside the recursive function instead of passing the updated
>parameter through.
>
>I want to get a union of al
In article <54ba3654$0$13008$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
> Good reasons for using global variables are few and far between. Just about
> the only good reason for using global variables that I can think of is if
> you have one or more settings/preference that get s
Tim wrote:
> I have this type of situation and wonder if I should use a global variable
> outside the recursive function instead of passing the updated parameter
> through.
To a first approximation, the answer to:
"I have a X, should I use a global variable or a parameter?"
On Friday, January 16, 2015 at 9:24:15 PM UTC-5, Yawar Amin wrote:
> [...]
> vals.extend(curr_obj.values())
Ah, I should mention that the above will do a breadth-first search. If
we want to do a depth-first search we simply replace the above line
with:
vals.extendleft(curr_obj.values(
On Friday, January 16, 2015 at 1:34:51 PM UTC-5, Peter Otten wrote:
> [...]
> I recommend that you use a generator:
>
> >>> def walk(obj):
> ... if not hasattr(obj, "keys"):
> ... return
> ... if "things" in obj:
> ... yield obj["things"]
> ... for v in obj.values():
>
On Sat, Jan 17, 2015 at 9:20 AM, Gregory Ewing
wrote:
> The only thing I would change is to wrap it all up
> in a top-level function that takes care of creating
> the result set and returning it.
>
> def walk(obj):
> res = set()
> _walk(obj, res)
> return res
>
> def _walk(obj, res):
> ...
Tim wrote:
I have this type of situation and wonder if I should use a global variable
outside the recursive function instead of passing the updated parameter
through.
No! Globals are evil, at least for that sort of thing.
The way you're doing it is fine.
The only thing I would change
On Friday, January 16, 2015 at 1:34:51 PM UTC-5, Peter Otten wrote:
>> Tim wrote:
>>
> Globals are generally bad as they make code non-reentrant; when two calls of
> the function run simultaneously the data will be messed up.
>
> I recommend that you use a generator:
>
> >>> def walk(obj):
> ..
Tim wrote:
> I have this type of situation and wonder if I should use a global variable
> outside the recursive function instead of passing the updated parameter
> through.
>
> I want to get a union of all the values that any 'things' key may have,
> even in a nes
On Friday, January 16, 2015 at 11:26:46 PM UTC+5:30, Chris Angelico wrote:
> On Sat, Jan 17, 2015 at 4:49 AM, Tim wrote:
> > I want to get a union of all the values that any 'things' key may have,
> > even in a nested dictionary (and I do not know beforehand how deep the
> > nesting might go):
>
On Sat, Jan 17, 2015 at 4:49 AM, Tim wrote:
> I want to get a union of all the values that any 'things' key may have, even
> in a nested dictionary (and I do not know beforehand how deep the nesting
> might go):
>
> d = {'things':1, 'two':{'things':2}}
>
> def walk(obj, res):
> if not hasatt
I have this type of situation and wonder if I should use a global variable
outside the recursive function instead of passing the updated parameter
through.
I want to get a union of all the values that any 'things' key may have, even in
a nested dictionary (and I do not know befo
s
to first write the simplest version of the function you can think
of, the version that solves the most trivial form for the
problem.
For example, lets say I want to write a recursive function to
reverse a string (you would never do this except as an exercise),
I'd first write a version that ca
Yes, I simplified it a lot.
I need to run it 24 times. What I don't really understand is how to put the
final temperature (result) in it = 0 in temp_-1 in it =1
--
http://mail.python.org/mailman/listinfo/python-list
2013/3/5 Ana Dionísio :
> Hello!
>
> I have to make a script that calculates temperature, but one of the
> parameters is the temperature in the iteration before, for example:
> temp = (temp_-1)+1
>
> it = 0
> temp = 3
>
> it = 1
> temp = 3+1
>
> it = 2
> temp = 4+1
>
> How can I do this in a simple
On 03/05/2013 10:32 AM, Ana Dionísio wrote:
Hello!
I have to make a script that calculates temperature, but one of the
parameters is the temperature in the iteration before, for example:
temp = (temp_-1)+1
it = 0
temp = 3
it = 1
temp = 3+1
it = 2
temp = 4+1
How can I do this in a simple way?
Hello!
I have to make a script that calculates temperature, but one of the
parameters is the temperature in the iteration before, for example:
temp = (temp_-1)+1
it = 0
temp = 3
it = 1
temp = 3+1
it = 2
temp = 4+1
How can I do this in a simple way?
Thanks a lot!
--
http://mail.python.org/mai
iling function.
>>
>> I would like to get some suggestions.
>>
>
> The recursive call inside your function should call the undecorated
> function, not the decorated function again. Decorator syntax is not
> convenient anymore.
>
> Using t
tax is not
convenient anymore.
Using the same names as in the recipe example:
# a recursive function
def my_slow_function(n):
...
return my_slow_function(n-1)
my_profiled_slow_function = hotshotit(my_slow_function)
my_profiled_slow_function(n)
This works, in the sense that it does
Hi,
I am using hotshot module to profile my python function.
I used the details from (
http://code.activestate.com/recipes/576656-quick-python-profiling-with-hotshot/
).
The function I profile is a recursive one and I am getting the following
error,
"ProfilerError: profiler already active"
I
Seebs wrote:
> On 2010-10-07, TP wrote:
>> Diez B. Roggisch wrote:
>>> A safer alternative for these cases is using tuples, because they are
>>> immutable.
>
>> The problem with tuples is that it is not easy to modify them:
>
> This is probably the best post-and-response I've seen in the last c
On 10/6/2010 3:22 PM, TP wrote:
Hi,
I have a function f that calls itself recursively. It has a list as second
argument, with default argument equal to None (and not [], as indicated at:
http://www.ferg.org/projects/python_gotchas.html#contents_item_6 )
This sort of function is an exception. I
TP writes:
> Diez B. Roggisch wrote:
>
>> Back to your example: your solution is perfectly fine, although a bit
>> costly and more error-prone if you happen to forget to create a copy.
>> A safer alternative for these cases is using tuples, because they are
>> immutable.
>
> Thanks Diez for your
On Wed, Oct 6, 2010 at 10:25 PM, TP wrote:
> Diez B. Roggisch wrote:
>
>> Back to your example: your solution is perfectly fine, although a bit
>> costly and more error-prone if you happen to forget to create a copy.
>> A safer alternative for these cases is using tuples, because they are
>> immut
On 2010-10-07, TP wrote:
> Diez B. Roggisch wrote:
>> A safer alternative for these cases is using tuples, because they are
>> immutable.
> The problem with tuples is that it is not easy to modify them:
This is probably the best post-and-response I've seen in the last couple
of months.
-s
--
C
Steven D'Aprano wrote:
>> I think I prefer doing an explicit copy.copy, because it allows to
>> remind the reader that it is very important to take care of that.
>
> I think a comment is better for that. It's better to explicitly say
> something is important than to assume the reader will guess.
Diez B. Roggisch wrote:
> Back to your example: your solution is perfectly fine, although a bit
> costly and more error-prone if you happen to forget to create a copy.
> A safer alternative for these cases is using tuples, because they are
> immutable.
Thanks Diez for your explanation.
The proble
On Wed, 06 Oct 2010 23:00:10 +0200, TP wrote:
> I think I prefer doing an explicit copy.copy, because it allows to
> remind the reader that it is very important to take care of that.
I think a comment is better for that. It's better to explicitly say
something is important than to assume the re
TP writes:
> Hi,
>
> I have a function f that calls itself recursively. It has a list as second
> argument, with default argument equal to None (and not [], as indicated at:
> http://www.ferg.org/projects/python_gotchas.html#contents_item_6 )
>
> This is the outline of my function:
>
> def f ( a
Chris Torek wrote:
>>import copy from copy
>
> [from copy import copy, rather]
Yes, sorry.
> Note that if f() is *supposed* to be able to modify its second
> parameter under some conditions, you would want to make the copy
> not at the top of f() but rather further in, and in this case,
> that
In article
TP wrote:
>I have a function f that calls itself recursively. It has a list as second
>argument, with default argument equal to None (and not [], as indicated at:
>http://www.ferg.org/projects/python_gotchas.html#contents_item_6 )
>
>This is the outline of my function:
>
>def f ( arg
Hi,
I have a function f that calls itself recursively. It has a list as second
argument, with default argument equal to None (and not [], as indicated at:
http://www.ferg.org/projects/python_gotchas.html#contents_item_6 )
This is the outline of my function:
def f ( argument, some_list = None ):
MRAB wrote:
On 17/09/2010 17:55, Ethan Furman wrote:
MRAB wrote:
On 16/09/2010 00:23, Ethan Furman wrote:
PS
My apologies if this shows up twice, I haven't seen my other post yet
and it's been 27 hours.
That's probably because you sent it directly to me.
That would explain it -- like I sa
On 17/09/2010 17:55, Ethan Furman wrote:
MRAB wrote:
On 16/09/2010 00:23, Ethan Furman wrote:
I need some fresh eyes, or better brains, or both!
'next_item' is a generator, but it's just calling itself and discarding
the result. I think it should be yielding the results to its caller.
That f
On 16/09/2010 00:23, Ethan Furman wrote:
I need some fresh eyes, or better brains, or both!
The expected debugging output is a list of names in alphabetical order
from each node (there are about 90 of them); what I am getting is this:
--> dbf.tables.Index.from_file('', r'aad13658_last_name_for_
I need some fresh eyes, or better brains, or both!
The expected debugging output is a list of names in alphabetical order
from each node (there are about 90 of them); what I am getting is this:
--> dbf.tables.Index.from_file('', r'aad13658_last_name_for_state.idx')
starting next_item call fo
Dear Kev
Thank you very much.
I got it.:)
2009/8/16 Kev Dwyer
> On Sun, 16 Aug 2009 16:57:41 +0900, Chang Min Jeon wrote:
>
>
> Hello,
>
> You have placed recursive calls to the function in a number of different
> locations; when len(macro) becomes zero control will return to the
> calling func
On Sun, 16 Aug 2009 16:57:41 +0900, Chang Min Jeon wrote:
Hello,
You have placed recursive calls to the function in a number of different
locations; when len(macro) becomes zero control will return to the
calling function, but this calling function may have more code to
execute, including fur
I'm trying to write program to translate define macro in 'C'.
And start_parse has return condition that list's length is 0.
At this time return statement invoke start_parse() function.
I can't understand do that.
I'm using Python 2.6.2 in Windows XP
import re
import sys
comment = '''
#if defined
In article ,
andrew cooke wrote:
>
>sorry for the shouting, but someone asks this EVERY DAY AND I CAN'T TAKE
>ANY MORE.
Nobody's forcing you to respond. Nobody's forcing you to top-post,
either.
--
Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/
"Debugging is twic
Peter Otten wrote:
> I would be surprised by the behaviour of Andrew's variant:
>
def append(item, items=None):
> ... items = items or []
> ... items.append(item)
> ... return items
> ...
a = []
append("x", a)
> ['x']
ah that's a good point. andrew
--
http://mail.
If the order of node-entry into seen_nodes is never used (if particular,
if 'node in seen_nodes' is its only usage), then seen_nodes could be a
set and the 'in' operation would be O(1) instead of O(n).
--
http://mail.python.org/mailman/listinfo/python-list
Daniel Oberski wrote:
> Hi Peter,
>
>> Plus, it works as expected (read: modifies the argument) if you
>> explicitly pass an empty list to the function...
>
> That is not so. The reason is given by Andrew Cooke in this thread.
>
> I would "expect" that when function calls lower in the recursion
andrew cooke wrote:
it's not global, it's mutable. you are passing THE SAME FRICKING OBJECT
to is_terminal and appending values to it.
instead, make a new copy:
branch.next.is_terminal(list(seen_nodes))
sorry for the shouting, but someone asks this EVERY DAY AND I CAN'T TAKE
ANY MORE.
[s
Hi Peter,
> Plus, it works as expected (read: modifies the argument) if you
> explicitly pass an empty list to the function...
That is not so. The reason is given by Andrew Cooke in this thread.
I would "expect" that when function calls lower in the recursion
hierarchy return, the object is not
Hi Diez,
Great, this totally clears it up. Thank you!
- daniel
On Thu, 26 Mar 2009 17:50:20 +0100, Diez B. Roggisch wrote:
>
> That's not a local variable, that is a default argument. Which is in
> fact only created once for each function, yes.>
> http://effbot.org/pyfaq/why-are-default-value
Hi Andrew,
> it's not global, it's mutable. you are passing THE SAME FRICKING OBJECT
> to is_terminal and appending values to it.
That, I understand. I already saw in the archives this confuses many
people, e.g. the thread "Odd behavior regarding a list". I think this is
understandable if you
andrew cooke wrote:
> Diez B. Roggisch wrote:
>> That's not a local variable, that is a default argument. Which is in
>> fact only created once for each function, yes.
>>
>> http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm
>
> a nice way of handling this was posted here j
Diez B. Roggisch wrote:
> That's not a local variable, that is a default argument. Which is in
> fact only created once for each function, yes.
>
> http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm
a nice way of handling this was posted here just yesterday, which isn't in
t
Daniel Oberski schrieb:
Hello all,
I wrote this function to recurse through a tree structure of Nodes
connected by Branches.
I use a local variable seen_nodes to mark off Nodes already seen by the
function (i.e. add them to a list).
That's not a local variable, that is a default argument.
>>
>>>> n1.add(b1)
>>>> n2.add(b2)
>>>> n2.add(b3)
>>>> n4.add(b4)
>>>>
>>>> print n1.is_terminal()
> 1
>
>>>> # terminal graph with a cycle
>>>> #-> b1 -> b2 -> b3
>>>
ext = n5)
>>>
>>> n1.add(b1)
>>> n2.add(b2)
>>> n2.add(b3)
>>> n4.add(b4)
>>>
>>> print n1.is_terminal()
1
>>> # terminal graph with a cycle
>>> #-> b1 -> b2 -> b3
>>> # a -|
>>> #
NOT tail-recursive
2. Yes, the arguments are immutable after I call the function the
first time.
I think the best description of the problem may be:
How to keep some argument constant and accessable in one function
(especially, recursive function). We know that we can use something
like self.param
s NOT tail-recursive
2. Yes, the arguments are immutable after I call the function the
first time.
I think the best description of the problem may be:
How to keep some argument constant and accessable in one function
(especially, recursive function). We know that we can use something
like self.parameter to
of this though.
- Chris
On Tue, Sep 2, 2008 at 8:20 PM, Davy <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Sometimes I need to pass same parameter in recursive function. From my
> point of view, the style is redundant, and I don't what to use some
> global style like self.A, self.B, I
Hi all,
Sometimes I need to pass same parameter in recursive function. From my
point of view, the style is redundant, and I don't what to use some
global style like self.A, self.B, Is there any other choice?
For example,
def func(self, x, y, A, B, C):
#x, y change in recursive call
#A,
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
>> #include
>> #include
>>
>> def RecursiveFact(n):
>> if(n>1):
>> return n*RecursiveFact(n-1)
>> else:
>> return 1
>>
>> fact = RecursiveFact(31)
>> print fact
>>
>> fact = "End of program"
>> print fact
>>
>>
>> ..but y
On Apr 2, 5:00 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] schrieb:
>
>
>
> > #include
> > #include
>
> > def RecursiveFact(n):
> > if(n>1):
> > return n*RecursiveFact(n-1)
> > else:
> > return 1
>
> > fact = RecursiveFact(31)
> > print fact
>
> >
[EMAIL PROTECTED] schrieb:
> #include
> #include
>
> def RecursiveFact(n):
> if(n>1):
> return n*RecursiveFact(n-1)
> else:
> return 1
>
> fact = RecursiveFact(31)
> print fact
>
> fact = "End of program"
> print fact
>
>
> ..but yet it still gives the right answe
In article <[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]> wrote:
(Subject: Recursive function won't compile)
>#include
>#include
>
>def RecursiveFact(n):
>..but yet it still gives the right answer. How is this possible?
Possibly because it gives the right ans
On Apr 2, 5:23 pm, [EMAIL PROTECTED] wrote:
> #include
> #include
>
> def RecursiveFact(n):
> if(n>1):
> return n*RecursiveFact(n-1)
> else:
> return 1
>
> fact = RecursiveFact(31)
> print fact
The output is 822283865417792281772556288000 and is correct. But
the "#incl
[EMAIL PROTECTED] wrote:
> #include
> #include
>
> def RecursiveFact(n):
> if(n>1):
> return n*RecursiveFact(n-1)
> else:
> return 1
>
> fact = RecursiveFact(31)
> print fact
>
> fact = "End of program"
> print fact
>
>
> ..but yet it still gives the right answer. How
#include
#include
def RecursiveFact(n):
if(n>1):
return n*RecursiveFact(n-1)
else:
return 1
fact = RecursiveFact(31)
print fact
fact = "End of program"
print fact
..but yet it still gives the right answer. How is this possible?
--
http://mail.python.org/mailman/l
On Fri, 11 Jan 2008 06:30:04 -0600, Nick Craig-Wood wrote:
> HYRY <[EMAIL PROTECTED]> wrote:
>> def bears (n):
>> if n==42:
>> return True
...
>> return False
>
> Almost but you missed a case...
Why are you people doing the OP's homework for him? And then DEBUGGING it
as wel
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:python-
> [EMAIL PROTECTED] On Behalf Of Tom_chicollegeboy
> Sent: Friday, January 11, 2008 3:30 AM
> To: python-list@python.org
> Subject: python recursive function
>
> Now, you are to write a program tha
On 11 Jan, 08:30, Tom_chicollegeboy <[EMAIL PROTECTED]> wrote:
> here is what I have to do:
>
> This question involves a game with teddy bears. The game starts when I
> give you some bears. You then start giving me back some bears, but you
> must follow these rules (where n is the number of bears t
HYRY <[EMAIL PROTECTED]> wrote:
> def bears (n):
> if n==42:
> return True
> if n%5==0:
> if bears(n-42):
> return True
> if n%2==0:
> if bears(n/2):
> return True
> if n%3==0 or n%4==0:
> one = (n%10)
> two
Duncan Booth a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]>
> wrote:
>
>> You want:
>>return bears(n - 42)
>
> Actually, no he doesn't. He needs to explore all options when the first
> attempt fails.
Possibly - I didn't bother checking the algorithm correctness, just
pointed
> def bears (n):
> if n==42:
> return True
> if n%5==0:
> bears(n-42)
> if n%2==0:
> bears(n/2)
> if n%3==0 or n%4==0:
> one = (n%10)
> two = ((n%100)/10)
> if one!=0 and two!=0:
> bears(n-(one*two))
> return False
>
>
> Stylistically I prefer 'if not n % 5', looks neater.
> As for your assignment, the hardest task will be creating an effective
> method of ensuring you recurse through all possibilities.
I was chatting to a friend about the 'if not n % 5' and while I am
happy to use it saying that when 5 % 5 is F
On Jan 11, 10:30 am, Tom_chicollegeboy <[EMAIL PROTECTED]> wrote:
> here is what I have to do:
>
> This question involves a game with teddy bears. The game starts when I
> give you some bears. You then start giving me back some bears, but you
> must follow these rules (where n is the number of bear
Bruno Desthuilliers <[EMAIL PROTECTED]>
wrote:
> You want:
>return bears(n - 42)
Actually, no he doesn't. He needs to explore all options when the first
attempt fails. But I'm not going to write his homework for him.
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 11, 9:46 am, Gary Herron <[EMAIL PROTECTED]> wrote:
> Tom_chicollegeboy wrote:
> > here is what I have to do:
>
> > This question involves a game with teddy bears. The game starts when I
> > give you some bears. You then start giving me back some bears, but you
> > must follow these rules (w
Gary Herron a écrit :
> Tom_chicollegeboy wrote:
>> here is what I have to do:
>>
>> This question involves a game with teddy bears. The game starts when I
>> give you some bears. You then start giving me back some bears, but you
>> must follow these rules (where n is the number of bears that you
>
Tom_chicollegeboy a écrit :
(snip)
> As you see my program must use recursion.
It's conceptually easier to express using recursions - but every
recursion-based algorithm can be rewritten to use iteration (and
vice-versa).
> I came up with this idea but I am not sure if its right or are there
>
Tom_chicollegeboy wrote:
> here is what I have to do:
>
> This question involves a game with teddy bears. The game starts when I
> give you some bears. You then start giving me back some bears, but you
> must follow these rules (where n is the number of bears that you
> have):
>
This sounds very
here is what I have to do:
This question involves a game with teddy bears. The game starts when I
give you some bears. You then start giving me back some bears, but you
must follow these rules (where n is the number of bears that you
have):
If n is even, then you may give back exactly n/2 bears.
ing all the files and folders so that
> it would map the
> file system hierarchy.
>
> I wrote a recursive function that would go through the file system
> tree.
>
> My problem is that a sub-node of a gtk.TreeStore is not a
> gtk.TreeStore, but
> a gtk.TreeIter. And gtk.treeter
it would map the
> file system hierarchy.
>
> I wrote a recursive function that would go through the file system
> tree.
>
> My problem is that a sub-node of a gtk.TreeStore is not a
> gtk.TreeStore, but
> a gtk.TreeIter. And gtk.treeter has almost no functions I would be
>
Hello,
I would like to create a minimalist file browser using pyGTK.
Having read lot of tutorials, it seems to me that that in my case, the
best solution is
to have a gtk.TreeStore containing all the files and folders so that
it would map the
file system hierarchy.
I wrote a recursive function
Hendrik van Rooyen wrote:
> "cesco" <[EMAIL PROTECTED]> wrote:
>
> >
> > Neil Cerutti wrote:
> > > On 2007-01-08, cesco <[EMAIL PROTECTED]> wrote:
> > > > Hi,
> > > >
> > > > I have a dictionary of lists of tuples like in the following example:
> > > > dict = {1: [(3, 4), (5, 8)],
> > > >
"cesco" <[EMAIL PROTECTED]> wrote:
>
> Neil Cerutti wrote:
> > On 2007-01-08, cesco <[EMAIL PROTECTED]> wrote:
> > > Hi,
> > >
> > > I have a dictionary of lists of tuples like in the following example:
> > > dict = {1: [(3, 4), (5, 8)],
> > > 2: [(5, 4), (21, 3), (19, 2)],
> > >
most inner tuple is
> equal to N.
>
> For example, assuming N = 24, in this case it should return:
> [((3, 4), (5, 4), (16, 1)), ((3, 4), (21, 3), (0, 2)), ((5, 8),
> (19, 2), (0, 2))]
>
> A simple list comprehension would be enough if only I knew the
> number of keys/lists bef
On 8 Jan 2007 16:03:53 +0100, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>
> len(dict.keys()).
>
Or
len(dict)
:)
--
http://mail.python.org/mailman/listinfo/python-list
First possible solution:
def rloop(seqin, comb):
# xcross product recipe 302478 by David Klaffenbach
if seqin:
for item in seqin[0]:
newcomb = comb + [item]
for item in rloop(seqin[1:], newcomb):
yield item
else:
yield comb
data
Neil Cerutti wrote:
> On 2007-01-08, cesco <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I have a dictionary of lists of tuples like in the following example:
> > dict = {1: [(3, 4), (5, 8)],
> > 2: [(5, 4), (21, 3), (19, 2)],
> > 3: [(16, 1), (0, 2), (1, 2), (3, 4)]]
> >
> > In this
On 2007-01-08, cesco <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a dictionary of lists of tuples like in the following example:
> dict = {1: [(3, 4), (5, 8)],
> 2: [(5, 4), (21, 3), (19, 2)],
> 3: [(16, 1), (0, 2), (1, 2), (3, 4)]]
>
> In this case I have three lists inside the dict
)), ((3, 4), (21, 3), (0, 2)), ((5, 8), (19,
2), (0, 2))]
A simple list comprehension would be enough if only I knew the number
of keys/lists beforehand but this is not the case. I guess I need a
recursive function. Can anyone help?
Thanks in advance
Francesco
--
http://mail.python.org/mailman
Fredrik Lundh wrote:
> Matthew Warren wrote:
>
> > I have the following code that implements a simple recursive tree like
> > structure.
> >
> > The trouble is with the GetTreeBranch function, the print statement
> > prints a valid value but the return immediatley afterward doesn't return
> > anyt
1 - 100 of 158 matches
Mail list logo