On 08/08/2022 12:59, Dan Purgert wrote:
dn wrote:
On 06/08/2022 11.41, avi.e.gr...@gmail.com wrote:
I wonder if someone is pulling our leg as they are sending from an
invalid email address of "GB " which is
a bit sick.
There are a number of folk who use evidently false email addresses - the
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512
dn wrote:
> On 06/08/2022 11.41, avi.e.gr...@gmail.com wrote:
>> I wonder if someone is pulling our leg as they are sending from an
>> invalid email address of "GB " which is
>> a bit sick.
>
> There are a number of folk who use evidently false email
Behalf Of Chris Angelico
Sent: Saturday, August 6, 2022 8:12 AM
To: python-list@python.org
Subject: Re: Trying to understand nested loops
On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote:
>
> On 8/6/22 12:01 AM, Chris Angelico wrote:
> > On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote:
On Sat, 6 Aug 2022 at 22:39, Richard Damon wrote:
>
> On 8/6/22 8:12 AM, Chris Angelico wrote:
> > On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote:
> >> On 8/6/22 12:01 AM, Chris Angelico wrote:
> >>> On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote:
> On Fri, Aug 5, 2022 at 12:54 PM Grant
On 8/6/22 8:12 AM, Chris Angelico wrote:
On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote:
On 8/6/22 12:01 AM, Chris Angelico wrote:
On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote:
On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards
wrote:
In C, this doesn't do what it looks like it's suppose
On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote:
>
> On 8/6/22 12:01 AM, Chris Angelico wrote:
> > On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote:
> >> On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards
> >> wrote:
> >>
> >>> In C, this doesn't do what it looks like it's supposed to do.
> >>>
> >>
On 8/6/22 12:01 AM, Chris Angelico wrote:
On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote:
On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards
wrote:
In C, this doesn't do what it looks like it's supposed to do.
if (foo)
do_this();
and_this();
then_do_this();
It's been quit
On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote:
>
> On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards
> wrote:
>
> > In C, this doesn't do what it looks like it's supposed to do.
> >
> >if (foo)
> > do_this();
> > and_this();
> >then_do_this();
> >
> It's been quite a while since
On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards
wrote:
> In C, this doesn't do what it looks like it's supposed to do.
>
>if (foo)
> do_this();
> and_this();
>then_do_this();
>
It's been quite a while since I used C, but with the right compiler
flag(s), I think this may be a thing
On Fri, 5 Aug 2022 08:34:45 +0100, ojomooluwatolami675 wrote:
> Hello, I’m new to learning python and I stumbled upon a question nested
> loops. This is the question below. Can you please how they arrived at 9
> as the answer. Thanks
>
> var = 0 for i in range(3):
> for j
write articles or books and wants to see what people think but then does not
participate or tell us that is what they wanted.
My point was not to tell anyone else here what to do, simply that I will be
cautious with such posters as I have way better things to do!
Nested loops are indeed a hard
On 06/08/2022 11.41, avi.e.gr...@gmail.com wrote:
> I wonder if someone is pulling our leg as they are sending from an invalid
> email address of "GB " which is a bit sick.
There are a number of folk who use evidently false email addresses - the
OP's had me amused.
Such 'hiding' is a matter for t
On Fri, Aug 5, 2022 at 12:30 PM GB wrote:
> On 05/08/2022 08:56, Frank Millman wrote:
>
> > BTW, there is an indentation error in your original post - line 5 should
> > line up with line 4.
>
> As a Python beginner, I find that Python is annoyingly picky about
> indents. And, the significance of
r at least that they have
spent any serious time learning.
-Original Message-
From: Python-list On
Behalf Of GB
Sent: Friday, August 5, 2022 5:57 AM
To: python-list@python.org
Subject: Re: Trying to understand nested loops
On 05/08/2022 08:56, Frank Millman wrote:
> BTW, there is an inde
On 06/08/2022 10.50, Dan Stromberg wrote:
> On Fri, Aug 5, 2022 at 12:35 AM wrote:
...
> Of if you don't have (or want) a debugger, you could change it to:
>
> var = 0
> for i in range(3):
> print('i is', i)
> for j in range(-2,-7,-2):
> print('j is', j)
> var += 1
> print(var)
>
On Fri, Aug 5, 2022 at 12:35 AM wrote:
> Hello, I’m new to learning python and I stumbled upon a question nested
> loops. This is the question below. Can you please how they arrived at 9 as
> the answer. Thanks
>
> var = 0
> for i in range(3):
> for j in range(-2,-
On 8/5/22 03:56, GB wrote:
> On 05/08/2022 08:56, Frank Millman wrote:
>
>> BTW, there is an indentation error in your original post - line 5
>> should line up with line 4.
>
> As a Python beginner, I find that Python is annoyingly picky about
> indents. And, the significance of indents is a bi
On 2022-08-05, GB wrote:
>> BTW, there is an indentation error in your original post - line 5
>> should line up with line 4.
>
> As a Python beginner, I find that Python is annoyingly picky about
> indents. And, the significance of indents is a bit of a minefield for
> beginners.
As a C begin
On 05/08/2022 08:56, Frank Millman wrote:
BTW, there is an indentation error in your original post - line 5 should
line up with line 4.
As a Python beginner, I find that Python is annoyingly picky about
indents. And, the significance of indents is a bit of a minefield for
beginners.
For
ojomooluwatolami...@gmail.com wrote at 2022-8-5 08:34 +0100:
>Hello, I’m new to learning python and I stumbled upon a question nested loops.
For future, more complex, questions of this kind,
you might have a look at the module `pdb` in Python's runtime library.
It implements a debugg
It’s also a poor code example. Doing a pointless double loop is not good
instructional practice, especially when simpler alternatives exist. e.g.
for i in range(3):
for j in range(-2.-7,-2):
print(i +j )
—
Gerard Weatherby | Application Architect NMRbox | NAN | Department of Molecular
Biol
On 05Aug2022 09:47, Lars Liedtke wrote:
>this looks to me like it might be a piece of homework, as it would be
>given by teachers or professors.
>
>This list has got the rule, that members do not solve other's
>homework. Because very often homework is meant to sit down and think
>about it.
Ver
On 2022-08-05 9:34 AM, ojomooluwatolami...@gmail.com wrote:
Hello, I’m new to learning python and I stumbled upon a question nested loops.
This is the question below. Can you please how they arrived at 9 as the answer.
Thanks
var = 0
for i in range(3):
for j in range(-2,-7,-2):
var
um 09:34 schrieb ojomooluwatolami...@gmail.com:
Hello, I’m new to learning python and I stumbled upon a question nested loops.
This is the question below. Can you please how they arrived at 9 as the answer.
Thanks
var = 0
for i in range(3):
for j in range(-2,-7,-2):
var += 1
prin
Hello, I’m new to learning python and I stumbled upon a question nested loops.
This is the question below. Can you please how they arrived at 9 as the answer.
Thanks
var = 0
for i in range(3):
for j in range(-2,-7,-2):
var += 1
print(var)
Sent from my iPhone
--
https
Neal Becker wrote:
but it does violate the principle "Exceptions should
be used for exceptional conditions).
Python doesn't really go in for that philosophy.
Exceptions are often used for flow control, e.g.
StopIteration.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 2018-09-26 21:06, Mark Lawrence wrote:
>
> To me the Ned Batchelder presentation
> https://www.youtube.com/watch?v=EnSu9hHGq5o "Loop like a Native" is the
> definitive way on how to deal with loops in Python.
>
Hear, hear.
Great talk.
--
https://mail.python.org/mailman/listinfo/python-list
Christian Gollwitzer wrote:
> Am 26.09.18 um 12:28 schrieb Bart:
>> On 26/09/2018 10:10, Peter Otten wrote:
>>> class Break(Exception):
>>> pass
>>>
>>> try:
>>> for i in range(10):
>>> print(f'i: {i}')
>>> for j in range(10):
>>> print(f'\tj: {j}')
>>> for k in range(10):
>>> print(f'\t\tk: {k}')
Am 26.09.18 um 12:28 schrieb Bart:
On 26/09/2018 10:10, Peter Otten wrote:
class Break(Exception):
pass
try:
for i in range(10):
print(f'i: {i}')
for j in range(10):
print(f'\tj: {j}')
for k in range(10):
On Wednesday, September 26, 2018 at 12:50:20 AM UTC-7, vito.d...@gmail.com
wrote:
> I have "abused" the "else" clause of the loops to makes a break "broke" more
> loops
I did this once upon a time. In recent years, when I start writing tricky
nested loop
On 26/09/18 08:50, vito.detul...@gmail.com wrote:
Hi
Today I've added a couple of lines in my source code, and I'm very ashamed of
it.
it "runs", and I know what it does (for now), but it's "too clever".
I have "abused" the "else" clause of the loops to makes a break "broke" more
loops
f
vito.detul...@gmail.com wrote:
> Hi
> Today I've added a couple of lines in my source code, and I'm very ashamed
> of it. it "runs", and I know what it does (for now), but it's "too
> clever". I have "abused" the "else" clause of the loops to makes a break
> "broke" more loops
>
>
> for i in
On Wed, Sep 26, 2018 at 5:56 PM wrote:
>
> Hi
> Today I've added a couple of lines in my source code, and I'm very ashamed of
> it.
> it "runs", and I know what it does (for now), but it's "too clever".
> I have "abused" the "else" clause of the loops to makes a break "broke" more
> loops
>
>
>
Hi
Today I've added a couple of lines in my source code, and I'm very ashamed of
it.
it "runs", and I know what it does (for now), but it's "too clever".
I have "abused" the "else" clause of the loops to makes a break "broke" more
loops
for i in range(10):
print(f'i: {i}')
f
I think you are right, it's the assignment itself which is slow.
Merged loop is only a tad quicker.
On Thursday, September 8, 2016 at 6:04:41 PM UTC+1, Christian Gollwitzer wrote:
> > Why nested loops are so slow in Python? Is it because new contexts are
> > created?
> >
Am 08.09.16 um 12:20 schrieb Igor Kozin:
Why nested loops are so slow in Python? Is it because new contexts are created?
For more details, see
http://stackoverflow.com/questions/26611043/numpy-vs-cython-nested-loop-so-slow
http://stackoverflow.com/questions/39371021/efficient-loop-over-numpy
On Thu, Sep 8, 2016 at 8:20 PM, Igor Kozin wrote:
> Why nested loops are so slow in Python? Is it because new contexts are
> created?
> For more details, see
> http://stackoverflow.com/questions/26611043/numpy-vs-cython-nested-loop-so-slow
> http://stackoverflow.com/questions/393
Why nested loops are so slow in Python? Is it because new contexts are created?
For more details, see
http://stackoverflow.com/questions/26611043/numpy-vs-cython-nested-loop-so-slow
http://stackoverflow.com/questions/39371021/efficient-loop-over-numpy-array
Thanks!
--
https://mail.python.org
On Wed, Dec 10, 2014 at 9:01 AM, Ian Kelly wrote:
> This also seems perfectly natural:
>
> def len(iterable):
> return sum(1 for item in iterable)
>
> My observation is that seems strange to me that one standard sequence
operation should be supported for arbitrary iterators and the other not.
On Wed, Dec 10, 2014 at 1:21 AM, Peter Otten <__pete...@web.de> wrote:
>
> Ian Kelly wrote:
> > Huh, I wasn't even aware that membership tests worked on iterables with
no
> > __contains__ method. Seems odd to me that 'x in y' should be supported
but
> > not 'len(y)'.
>
> To me
>
> def contains(iter
Shiyao Ma wrote:
> Thanks guys.
>
> I was only aware of a limited iterables which themselves are iterators,
> e.g., the generator.
>
> Seems like its really a pitfall. Any glossary, list on the iterables that
> *might* exhaust themselves?
Iterables include:
- iterators
- sequences (e.g. lists,
Shiyao Ma wrote:
> Thanks guys.
>
> I was only aware of a limited iterables which themselves are iterators,
> e.g., the generator.
>
> Seems like its really a pitfall. Any glossary, list on the iterables that
> *might* exhaust themselves?
Usually the test
iterable is iter(iterable)
returns Tr
Thanks guys.
I was only aware of a limited iterables which themselves are iterators, e.g.,
the generator.
Seems like its really a pitfall. Any glossary, list on the iterables that
*might* exhaust themselves?
Regards.
--
https://mail.python.org/mailman/listinfo/python-list
Ian Kelly wrote:
> On Tue, Dec 9, 2014 at 11:30 PM, Chris Angelico wrote:
>> Are you sure it isn't? Your 'space' is an iterable cubic
>> cross-product. Your first loop checks (0,0,0) which is the first
>> element returned, and is thus fast... but it also *consumes* that
>> first element. The next
On Wed, 10 Dec 2014 17:53:05 +1100, Chris Angelico wrote:
> On Wed, Dec 10, 2014 at 5:44 PM, Steven D'Aprano
> wrote:
>> It would be nice if product iterators behaved like xrange() objects and
>> could perform "in" tests without exhausting the iterator, but they
>> don't. That's sad.
>
> It'd be
On 12/10/2014 1:53 AM, Chris Angelico wrote:
On Wed, Dec 10, 2014 at 5:44 PM, Steven D'Aprano wrote:
It would be nice if product iterators behaved like xrange() objects and
could perform "in" tests without exhausting the iterator, but they don't.
That's sad.
It'd be very difficult to do that
On Tue, Dec 9, 2014 at 11:30 PM, Chris Angelico wrote:
> Are you sure it isn't? Your 'space' is an iterable cubic
> cross-product. Your first loop checks (0,0,0) which is the first
> element returned, and is thus fast... but it also *consumes* that
> first element. The next time you test it, the e
On Wed, Dec 10, 2014 at 5:44 PM, Steven D'Aprano wrote:
> It would be nice if product iterators behaved like xrange() objects and
> could perform "in" tests without exhausting the iterator, but they don't.
> That's sad.
It'd be very difficult to do that in the general sense. But it should
be poss
On Wed, 10 Dec 2014 13:20:25 +0800, Shiyao Ma wrote:
> When doing nested loop, the very first iteration of the innermost loop
> ends ultimately slow.
>
> Let's the code speak.
>
> The following code is quite contrived. Actually it's derived from my
> 3d-dct script. The actual difference is way m
On Wed, Dec 10, 2014 at 4:20 PM, Shiyao Ma wrote:
> from itertools import product
> space_len = 580
> space = product(xrange(space_len), xrange(space_len), xrange(space_len))
>
> sparse_cloud = product(xrange(1000), xrange(1000), xrange(1000))
> for i, j, k in sparse_cloud:
> ts = timeit.defau
One thing to note, the logic of using "in" is not of concern here.
This is a *contrived* example, the problem is the slowness of the first
iteration.
--
https://mail.python.org/mailman/listinfo/python-list
When doing nested loop, the very first iteration of the innermost loop ends
ultimately slow.
Let's the code speak.
The following code is quite contrived. Actually it's derived from my 3d-dct
script.
The actual difference is way more significant than this example.
In case of any evil of gmail,
Hi!
> leonardo writes:
how can i have it print a row of stars beside each number, like this?:
how many seconds?: 5
5 * * * * *
4 * * * *
3 * * *
2 * *
1 *
blast off!
--- snip ---
sec = int(input("How many seconds? "))
for i in range(0,sec):
print str(sec-i)+":"+" *"*(sec-i)
print
leonardo writes:
> how can i have it print a row of stars beside each number, like this?:
>
> how many seconds?: 5
> 5 * * * * *
> 4 * * * *
> 3 * * *
> 2 * *
> 1 *
> blast off!
You could use the repetition operator * since you have the number of
repetitions needed in i. Alternatively, consider
On Mon, 25 Feb 2013 23:46:11 +0100, leonardo wrote:
> hi everyone,
>
> i have the following program:
>
> import time count_timer = int(raw_input('how many seconds?: '))
> for i in range(count_timer, 0, -1):
> print i time.sleep(1)
> print 'blast off!'
>
>
> this is the result:
>
> how ma
thanks for the help, it works
Il 26/02/2013 10.58, Sven ha scritto:
Here's one solution
import time
count_timer = int(raw_input('how many seconds?: '))
for i in range(count_timer, 0, -1):
||print i,
print "*" * i
time.sleep(1)
print 'blast off!'
On 25 February 2013 22:46, leonardo
Here's one solution
import time
count_timer = int(raw_input('how many seconds?: '))
for i in range(count_timer, 0, -1):
print i,
print "*" * i
time.sleep(1)
print 'blast off!'
On 25 February 2013 22:46, leonardo wrote:
> hi everyone,
>
> i have the following program:
>
> import tim
hi everyone,
i have the following program:
import time
count_timer = int(raw_input('how many seconds?: '))
for i in range(count_timer, 0, -1):
print i
time.sleep(1)
print 'blast off!'
this is the result:
how many seconds?: 5
5
4
3
2
1
blast off!
how can i have it print a row of star
On 15/02/2012 20:12, Rituparna Sengupta wrote:
Hi,
I'm working on this code and I keep getting an error. It might be some very
basic thing but I was wondering if someone could help. Its a loop within a
loop. The part outside the innermost loop gets printed fine, but the part
within the innerm
On 02/15/2012 03:12 PM, Rituparna Sengupta wrote:
Hi,
I'm working on this code and I keep getting an error. It might be some very
basic thing but I was wondering if someone could help. Its a loop within a
loop. The part outside the innermost loop gets printed fine, but the part
within the inn
On Wed, Feb 15, 2012 at 12:12 PM, Rituparna Sengupta wrote:
> Hi,
>
> I'm working on this code and I keep getting an error. It might be some very
> basic thing but I was wondering if someone could help. Its a loop within a
> loop. The part outside the innermost loop gets printed fine, but the pa
On Wed, Feb 15, 2012 at 1:12 PM, Rituparna Sengupta wrote:
> Hi,
>
> I'm working on this code and I keep getting an error. It might be some very
> basic thing but I was wondering if someone could help. Its a loop within a
> loop. The part outside the innermost loop gets printed fine, but the par
Hi,
I'm working on this code and I keep getting an error. It might be some very
basic thing but I was wondering if someone could help. Its a loop within a
loop. The part outside the innermost loop gets printed fine, but the part
within the innermost loop doesn't get printed. I get an error: 'st
rejected the idea of named labels. I'd need to sit down and trace a few
loops by hand to grasp it. I wonder how new people coming into the project
find it?
Personally, I consider two nested loops right on the boundary of my "magic
number seven, plus or minus two" short term memory[1]
I thought a bit about Carl's and Thomas' proposals, and it gave me an
idea how this problem could be approached:
Break is relatively easy to implement with a context manager that
returns an iterable that throws an exception specific to that context
manager:
with named_loop(i for i in range(10)) as
# loop 4b
> for substeps in step2:
> # at this point, we may have to
> -leave loop 1
> -restart loop 2
> -restart loop 4b
> ...
> ...many more loops...
>
>
> I don't see any
On 9/1/2011 10:05 AM, Daniel wrote:
You seems to be requesting one of the options in
http://python.org/dev/peps/pep-3136/ Labeled break and continue
(The 'Other languages' section omits Fortran.)
The rejection post is at
http://mail.python.org/pipermail/python-3000/2007-July/008663.html
I basica
Am 01.09.2011 16:05 schrieb Daniel:
In pseudocode it looks like this, I am using @ to give loops a name:
@loop1
for c in configurations:
@loop2
while not_done:
@loop3
while step1_did_not_work:
@loop4
for substeps in step1 # loop 4a
like semiconductor chips.
The specification of these tests is already very complex, it has the
form of the nested loops,
for all these configurations try these steps, if they fail try them
again n times, if it still doesn't work give up
this configuration, if it works continue on to the
Chris Angelico wrote:
> Ah well, was worth a try. Raising exceptions smells wrong for this,
> but peppering your code with sentinel checks isn't much better. I
> don't really know what would be a good solution to this... except
> maybe this, which was proposed a few years ago and which I'd never
>
are needed to be.
Same applies to your data acquisition application. Unless you expect these
non-CS people to be hacking the source code, they only interact with the
interface, not the internals.
Earlier, back in your initial post, you said:
"I don't see any way to reduce these nested loop
On Thu, Sep 1, 2011 at 5:07 AM, Daniel wrote:
>> Do you only ever have one top-level loop that you would be naming? If
> no, unfortunately not. The rough structure is several loops deep, and
> I need to break/continue/restart many of them.
> Continue is used more than break, because most of the ti
> Do you only ever have one top-level loop that you would be naming? If
no, unfortunately not. The rough structure is several loops deep, and
I need to break/continue/restart many of them.
Continue is used more than break, because most of the time that I find
some strange value, I'd just _continue
I am really
hitting a wall at the moment.
Maybe I am really missing an obvious solution, because breaking out of
nested loops really doesn't seem like anything fancy. Fortran/c/c++/
Ruby/Perl all have that facility, even Java has named loops.
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Sep 1, 2011 at 1:51 AM, Daniel wrote:
>
> Has anyone an idea on a nice way to write breaks/continues/redos for
> deeply
> nested loops?
>
Do you only ever have one top-level loop that you would be naming? If
so, put that loop into a function and use return instead of break
in step2:
> # at this point, we may have to
> -leave loop 1
> -restart loop 2
> -restart loop 4b
> ...
> ...many more loops...
>
> I don't see any way to reduce these nested loops lo
loop 2
-restart loop 4b
...
...many more loops...
I don't see any way to reduce these nested loops logically, they
describe pretty well what the software has to do.
This is a data acquisition application, so on ever line there is
a lot of IO that might
Raymond Hettinger:
> Another approach for exiting multiple levels of loops is wrap the
> inner calls in a function and return from them when needed:
>
> def f(x):
> for y in y:
> for z in Z:
> if test1(x,y,z):
> return
> frobnic
On Sep 25, 12:01 pm, kj wrote:
> In Perl, one can label loops for finer flow control. For example:
>
> X: for my $x (@X) {
> Y: for my $y (@Y) {
> for my $z (@Z) {
> next X if test1($x, $y, $z);
> next Y if test2($x, $y, $z);
> frobnicate($x, $y, $z);
> }
> glortz(
kj wrote:
In Perl, one can label loops for finer flow control. For example:
X: for my $x (@X) {
Y: for my $y (@Y) {
for my $z (@Z) {
next X if test1($x, $y, $z);
next Y if test2($x, $y, $z);
frobnicate($x, $y, $z);
}
glortz($x, $y);
}
splat($x);
}
What's
r code so you
didn't have to do that.
Seriously though, I find both the perl and python versions
non-obvious. You have had to use constructs like this in practice?
Generally, I would use "flags" in tricky nested loops just like you
did, perhaps with some comments to clarify things.
In Perl, one can label loops for finer flow control. For example:
X: for my $x (@X) {
Y: for my $y (@Y) {
for my $z (@Z) {
next X if test1($x, $y, $z);
next Y if test2($x, $y, $z);
frobnicate($x, $y, $z);
}
glortz($x, $y);
}
splat($x);
}
What's considered
On Sat, 16 Sep 2006, Dan Sommers wrote:
> No, they all work the same way (thank goodness!). The "." between "wx"
> and "frame" is the same dot as is between "random" and "choice" (i.e.,
> random.choice is the same construct as wx.frame).
Ah, yes. I totally forgot this.
Thanks for the reminde
On Sat, 16 Sep 2006 10:06:25 -0700 (PDT),
Rich Shepard <[EMAIL PROTECTED]> wrote:
> On Sat, 16 Sep 2006, Dan Sommers wrote:
>> When you import random, all you're doing is importing the module; you
>> have to specify any given attribute thereof:
> I thought that was implied. For example, I use
On Sat, 16 Sep 2006, Dan Sommers wrote:
> When you import random, all you're doing is importing the module; you have
> to specify any given attribute thereof:
Dan,
I thought that was implied. For example, I use 'import wx' and can then
instantiate wx.frame, wx.dialogbox, etc. without explicit
On Sat, 16 Sep 2006 08:29:26 -0700 (PDT),
Rich Shepard <[EMAIL PROTECTED]> wrote:
> Two questions germane to random: 1) Why wasn't choice available when
> I used 'import random,' ...
When you import random, all you're doing is importing the module; you
have to specify any given attribute thereo
rnal's annual obfuscated C contests. :-)
> from random import choice
Two questions germane to random: 1) Why wasn't choice available when I
used 'import random,' and 2) What are the differences between 'choice' and
'shuffle?'
> Of course nested lo
range(180),
[x]*60 + [y]*60 + [z]*60,
([a]*13 + [b]*14 + [c]*33) * 3] + [random_floats(third)]*28
for row in izip(*columns):
print row
Of course nested loops will work, too. Use whatever you find easiest to
maintain.
Peter
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 15 Sep 2006, Peter Otten wrote:
> It's not clear to me why you would use dictionaries, especially as they
> are unordered; I used lists instead:
...
> Now that is a nice occasion to get acquainted with the itertools module...
Peter,
I have to study the docs to understand what's g
Peter Otten wrote:
> from itertools import count, izip, cycle, chain, repeat, starmap, imap
> from random import choice
>
> first = ["X", "Y", "Z"]
> second = ["A", "B", "C"]
> second_count = [13, 14, 33]
> third = [1.1, 2.2, 3.3, 4.4]
>
> random_floats = imap(choice, repeat(third))
> columns = [
On Fri, 15 Sep 2006, Bjoern Schliessmann wrote:
That doesn't answer the question. A list of 2-tuples would do the same
(and was ordered and could be indexed).
Björn, et al.:
For the purpose of generating a data sample, the list of 2-tuples will
work.
Thanks all,
Rich
--
Richard B. Shepar
Rich Shepard wrote:
> On Fri, 15 Sep 2006, Peter Otten wrote:
>> It's not clear to me why you would use dictionaries, especially
>> as they are unordered; I used lists instead:
>Because the data comes via a serial port as sequences of two
>bytes from an
> OMR reader, and the byte pairs n
On Fri, 15 Sep 2006, Peter Otten wrote:
> It's not clear to me why you would use dictionaries, especially as they
> are unordered; I used lists instead:
Peter,
Because the data comes via a serial port as sequences of two bytes from an
OMR reader, and the byte pairs need to be converted into v
Rich Shepard wrote:
>I want to code what would be nested "for" loops in C, but I don't know
>the
> most elegant way of doing the same thing in python. So I need to learn how
> from you folks. Here's what I need to do: build a database table of 180
> rows. Each row contains 31 columns: the
I want to code what would be nested "for" loops in C, but I don't know the
most elegant way of doing the same thing in python. So I need to learn how
from you folks. Here's what I need to do: build a database table of 180
rows. Each row contains 31 columns: the first is an automatically
incremen
[EMAIL PROTECTED] wrote:
> Call me crazy, but be careful when programming python in different text
> editors and in general, ie cutting and pasting, tabing and spacing.
> Loops can look fine and not work (try moving around test print
> statements for iterators), in this case try re-tabing your inde
>I'm still not sure what was stopping the inner
>loop from working earlier - but removing the redundancy in "j=0" and so
>on seems to have solved it.
Call me crazy, but be careful when programming python in different text
editors and in general, ie cutting and pasting, tabing and spacing.
Loops ca
On 11/05/2006 5:59 PM, Matthew Graham wrote:
> Thanks very much for the advice, have tidied it up and tested and seems
> to be working as needed.
Seems to be working? Consider where you have the expression x^2 + y^2
... I'd like to bet that you mean "x squared" etc, not "x exclusive-or
2" etc.
Thanks very much for the advice, have tidied it up and tested and seems
to be working as needed. I'm still not sure what was stopping the inner
loop from working earlier - but removing the redundancy in "j=0" and so
on seems to have solved it.
Matt
Dennis Lee Bieber wrote:
> If that wor
Oops, I forget to reset the j after the inner loop. Always manage to
work these things out just after asking for help! ;-)
Matthew Graham wrote:
> Hi,
>
> I expect this is very obvious for anyone who knows what they're doing -
> but I don't understand what's the problem with the following code
1 - 100 of 104 matches
Mail list logo