Karthikeyan Singaravelan added the comment:
@pradnyan The break statement [0] only exits the for loop where it's present in
this the one where y is involved so the outer loop involving x will continue to
execute. So after every attempt where y = 0 the cnt value succeeds and breaks
out of
anthonybaxter, barry, benjamin.peterson, eric.araujo, ezio.melotti,
georg.brandl, gvanrossum, lemburg, mdk, ned.deily, pradnyan, tarek
priority: normal
severity: normal
status: open
title: Nested For Loop in Python not working as Expected after cnt=2136
type: behavior
versions: Python 3.7
Adde
On 8/02/19 7:45 PM, Kaka wrote:
for i in range(len(A.hp)):
for j in range(len(run_parameters.bits_Mod)):
req_slots[j] = math.ceil((A.T[i])
for g in Temp[i]["Available_ranges"][j]:
for s in range(g[0], g[-1]):
if (s+req_slots[j]-1) <=
On Thursday, February 7, 2019 at 11:45:23 PM UTC-7, Kaka wrote:
> for i in range(len(A.hp)):
>
> for j in range(len(run_parameters.bits_Mod)):
> req_slots[j] = math.ceil((A.T[i])
>
> for g in Temp[i]["Available_ranges"][j]:
> for s in range(g[0], g[-1]):
>
Kaka wrote:
> for i in range(len(A.hp)):
>
> for j in range(len(run_parameters.bits_Mod)):
> req_slots[j] = math.ceil((A.T[i])
>
> for g in Temp[i]["Available_ranges"][j]:
> for s in range(g[0], g[-1]):
> if (s+req_slots[j]-1) <= g[-1]:
>
for i in range(len(A.hp)):
for j in range(len(run_parameters.bits_Mod)):
req_slots[j] = math.ceil((A.T[i])
for g in Temp[i]["Available_ranges"][j]:
for s in range(g[0], g[-1]):
if (s+req_slots[j]-1) <= g[-1]:
if
On Monday, February 26, 2018 at 12:57:25 PM UTC+5:30, Chris Angelico wrote:
> On Mon, Feb 26, 2018 at 5:19 AM, wrote:
> > Why we don’t use:
> >
> > for _ in _ in _
> >
> > Instead of
> >
> > for _ in _:
> > for _ in _:
> >
> > Ex:
> >
> > Names =
On Monday, February 26, 2018 at 6:23:24 AM UTC+5:30, Rick Johnson wrote:
> On Sunday, February 25, 2018 at 12:19:56 PM UTC-6, arya.ku...@gmail.com wrote:
>
> > Ex:
> >
> > Names = ["Arya","Pupun"]
> >
> > for name in Names:
> >for c in name:
> >print(c)
> >
> > instead use:
> >
>
On Monday, February 26, 2018 at 6:20:06 AM UTC+5:30, Ian wrote:
> On Sun, Feb 25, 2018 at 11:19 AM, wrote:
> > Why we don’t use:
> >
> > for _ in _ in _
> >
> > Instead of
> >
> > for _ in _:
> > for _ in _:
> >
> > Ex:
> >
> > Names = ["Arya","Pupun"]
> >
> >
On Monday, February 26, 2018 at 8:51:35 PM UTC+5:30, Ian wrote:
> On Sun, Feb 25, 2018 at 8:05 PM, INADA Naoki wrote:
> > https://docs.python.org/3.6/library/itertools.html#itertools.product
>
> I don't see how you would use itertools.product to do what the OP
> asked
On Sun, Feb 25, 2018 at 8:05 PM, INADA Naoki wrote:
> https://docs.python.org/3.6/library/itertools.html#itertools.product
I don't see how you would use itertools.product to do what the OP
asked for. You could use itertools.chain.from_iterable, though:
py> names =
On Mon, Feb 26, 2018 at 5:19 AM, wrote:
> Why we don’t use:
>
> for _ in _ in _
>
> Instead of
>
> for _ in _:
> for _ in _:
>
> Ex:
>
> Names = ["Arya","Pupun"]
>
> for name in Names:
>for c in name:
>print(c)
>
> instead use:
>
> for c in name in
https://docs.python.org/3.6/library/itertools.html#itertools.product
On Mon, Feb 26, 2018 at 3:19 AM, wrote:
> Why we don’t use:
>
> for _ in _ in _
>
> Instead of
>
> for _ in _:
> for _ in _:
>
> Ex:
>
> Names = ["Arya","Pupun"]
>
> for name in Names:
>
On Sunday, February 25, 2018 at 12:19:56 PM UTC-6, arya.ku...@gmail.com wrote:
> Ex:
>
> Names = ["Arya","Pupun"]
>
> for name in Names:
>for c in name:
>print(c)
>
> instead use:
>
> for c in name in Names:
> print(c)
Hmm. Why stop there?
bit = ["kibbles"]
bits = [bit,
On Sun, Feb 25, 2018 at 11:19 AM, wrote:
> Why we don’t use:
>
> for _ in _ in _
>
> Instead of
>
> for _ in _:
> for _ in _:
>
> Ex:
>
> Names = ["Arya","Pupun"]
>
> for name in Names:
>for c in name:
>print(c)
>
> instead use:
>
> for c in name in
Why we don’t use:
for _ in _ in _
Instead of
for _ in _:
for _ in _:
Ex:
Names = ["Arya","Pupun"]
for name in Names:
for c in name:
print(c)
instead use:
for c in name in Names:
print(c)
--
https://mail.python.org/mailman/listinfo/python-list
On 28/04/2016 10:34, g.v.aar...@skct.edu.in wrote:
start_list = [5, 3, 1, 2, 4]
square_list = []
# Your code here!
for square_list in start_list:
x = pow(start_list, 2)
square_list.append(x)
square_list.sort()
print square_list
TypeError: unsupported operand type(s) for ** or pow():
g.v.aar...@skct.edu.in wrote:
> start_list = [5, 3, 1, 2, 4]
> square_list = []
>
> # Your code here!
> for square_list in start_list:
You are iterating over start_list, that's OK. But you are assigning the
current value to square_list, a variable name that you already use for the
list where
On Thu, 28 Apr 2016 07:34 pm, g.v.aar...@skct.edu.in wrote:
> start_list = [5, 3, 1, 2, 4]
> square_list = []
Here you set square_list to a list.
> # Your code here!
> for square_list in start_list:
.^
Here you set square_list to each item of the start_list. So the first time
start_list = [5, 3, 1, 2, 4]
square_list = []
# Your code here!
for square_list in start_list:
x = pow(start_list, 2)
square_list.append(x)
square_list.sort()
print square_list
TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int'
Please provide me the solution for
Changes by vegeshna satyanarayana raju satya.nani...@gmail.com:
--
nosy: satyanani40
priority: normal
severity: normal
status: open
title: json data iteration through loop in python
___
Python tracker rep...@bugs.python.org
http://bugs.python.org
New submission from vegeshna satyanarayana raju:
I have json data in following format
{message:[frappe,websocerp,erpnext]}
I want each name (frappe, websocerp, erpnext) in three iteration
after that i can use as
frappe.something.get_data()
websocerp.something.get_data()
Steven D'Aprano added the comment:
This is a bug tracker for issues in the Python language and standard library,
not a service for learning how to program using Python.
If you have an actual bug to report, you should give more detail including the
actual code you used, the result you
Hi i am new for this version and could please help me .
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Jun 22, 2011 at 11:50 PM, kkiranmca kkiran...@gmail.com wrote:
Hi i am new for this version and could please help me .
You didn't pose an actual question...
Cheers,
Chris
--
http://mail.python.org/mailman/listinfo/python-list
kkiranmca kkiran...@gmail.com writes:
Hi i am new for this version and could please help me .
Welcome!
Don't ask whether you can ask. Just ask.
URL:http://catb.org/~esr/faqs/smart-questions.html
--
\ “I put contact lenses in my dog's eyes. They had little |
`\ pictures of
trying to write a simple shell loop in Python.
My simple approach works fine - but the first output line after entering
something is always indented by one blank.
Is there any logic explanation for this?
How can I get rid of the blank?
Is there a smarter way to write a simple shell
Dietrich Bollmann wrote:
Hi,
I am trying to write a simple shell loop in Python.
My simple approach works fine - but the first output line after entering
something is always indented by one blank.
Is there any logic explanation for this?
How can I get rid of the blank
Dietrich Bollmann wrote:
I am trying to write a simple shell loop in Python.
My simple approach works fine - but the first output line after entering
something is always indented by one blank.
Is there any logic explanation for this?
Yes
How can I get rid of the blank?
By not asking
Hi,
I am trying to write a simple shell loop in Python.
My simple approach works fine - but the first output line after entering
something is always indented by one blank.
Is there any logic explanation for this?
How can I get rid of the blank?
Is there a smarter way to write a simple shell
Dietrich Bollmann wrote:
Hi,
I am trying to write a simple shell loop in Python.
My simple approach works fine - but the first output line after entering
something is always indented by one blank.
Is there any logic explanation for this?
How can I get rid of the blank?
Is there a smarter
statement's being in a loop.
By the way, you don't need parens around the loop guard in python:
while 1: (or as I prefer, while True:) work just fine.
http://codepad.org/f2XSwsPo
This component I wrote - just for the hell of it - (just for this thread)
works nicely :)
cheers
James
--
http
Dietrich Bollmann dir...@web.de writes:
I am trying to write a simple shell loop in Python.
You should investigate the ‘cmd’ module in the standard library
URL:http://docs.python.org/library/cmd.html.
My simple approach works fine - but the first output line after
entering something
On Sep 21, 3:47 am, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
On Sat, 20 Sep 2008 16:27:41 -0700, Alex Snast wrote:
Another quick question please, is the List data structure just a dynamic
array? If so how can you use static size array, linked list, AVL trees
etcetera.
Hello
I'm new to python and i can't figure out how to write a reverse for
loop in python
e.g. the python equivalent to the c++ loop
for (i = 10; i = 0; --i)
--
http://mail.python.org/mailman/listinfo/python-list
Alex Snast a écrit :
Hello
I'm new to python and i can't figure out how to write a reverse for
loop in python
e.g. the python equivalent to the c++ loop
for (i = 10; i = 0; --i)
for (i = 0; i 10; i--) - for i in range(10):
for (i = 10; i = 0; --i) - for i in range(10,-1,-1):
Thoma
On Sep 20, 11:16�am, Alex Snast [EMAIL PROTECTED] wrote:
Hello
I'm new to python and i can't figure out how to write a reverse for
loop in python
e.g. the python equivalent to the c++ loop
for (i = 10; i = 0; --i)
for i in xrange(10,-1,-1): print i,
10 9 8 7 6 5 4 3 2 1 0
Note
Alex Snast [EMAIL PROTECTED] wrote:
Hello
I'm new to python and i can't figure out how to write a reverse for
loop in python
e.g. the python equivalent to the c++ loop
for (i = 10; i = 0; --i)
The exact equivalent would be:
for i in range(10, -1, -1): print i
except you
2008/9/20 Alex Snast [EMAIL PROTECTED]:
I'm new to python and i can't figure out how to write a reverse for
loop in python
e.g. the python equivalent to the c++ loop
for (i = 10; i = 0; --i)
for i in range(10, 0, -1):
print i
--
Cheers,
Simon B.
--
http://mail.python.org/mailman
Alex Snast wrote:
I'm new to python and i can't figure out how to write a reverse for
loop in python
e.g. the python equivalent to the c++ loop
for (i = 10; i = 0; --i)
use range with a negative step:
for i in range(10-1, -1, -1):
...
or just reverse the range:
for i
Alex Snast wrote:
Hello
I'm new to python and i can't figure out how to write a reverse for
loop in python
e.g. the python equivalent to the c++ loop
for (i = 10; i = 0; --i)
--
http://mail.python.org/mailman/listinfo/python-list
What are you trying to loop through?
If it's the contents
Fredrik Lundh wrote:
e.g. the python equivalent to the c++ loop
for (i = 10; i = 0; --i)
use range with a negative step:
for i in range(10-1, -1, -1):
...
or just reverse the range:
for i in reversed(range(10)):
...
(and to include the 10 in the range, add one to
Gary Herron wrote:
Or you can create a new reversed (copy of the original) list and iterate
through it
for item in reversed(L):
print item
It's not a copy, it's a view:
items = [1,2,3]
r = reversed(items)
items[:] = abc
for item in r: print item
...
c
b
a
Peter
--
Duncan Booth:
e.g. the python equivalent to the c++ loop
for (i = 10; i = 0; --i)
The exact equivalent would be:
for i in range(10, -1, -1): print i
I'd use xrange there. Anyway, I have always felt that Python syntax
not easy to understand at first sight, expecially when you try to
On Sep 20, 8:13 pm, [EMAIL PROTECTED] wrote:
Duncan Booth:
e.g. the python equivalent to the c++ loop
for (i = 10; i = 0; --i)
The exact equivalent would be:
for i in range(10, -1, -1): print i
I'd use xrange there. Anyway, I have always felt that Python syntax
not easy to
On Sep 20, 8:13 pm, [EMAIL PROTECTED] wrote:
Duncan Booth:
e.g. the python equivalent to the c++ loop
for (i = 10; i = 0; --i)
The exact equivalent would be:
for i in range(10, -1, -1): print i
I'd use xrange there. Anyway, I have always felt that Python syntax
not easy to
Alex Snast wrote:
Another quick question please, is the List data structure just a
dynamic array? If so how can you use static size array, linked list,
AVL trees etcetera.
You should treat Python lists as an opaque item. You shouldn't concern
yourself with the implementation details. Python
En Sat, 20 Sep 2008 20:27:41 -0300, Alex Snast [EMAIL PROTECTED] escribió:
Another quick question please, is the List data structure just a
dynamic array? If so how can you use static size array, linked list,
AVL trees etcetera.
Yes, lists are implemented as dynamic arrays (but you shouldn't
On Sat, 20 Sep 2008 16:22:31 -0700, Alex Snast wrote:
That's a lot of responses guys. Thanks a lot i think i got it. Another
question, are there any pointers in python (or iterators) for when i use
a data structure that doesn't support random access?
That surely depends on the data
Christian Heimes:
Unless you have specific needs for highly specialized data types, use lists.
There's also the collections.deque for other related purposes.
(I suggest people willing to look at some nice C code to read the
sources of deque, Hettinger has created some refined code, very
On Sat, 20 Sep 2008 16:27:41 -0700, Alex Snast wrote:
Another quick question please, is the List data structure just a dynamic
array? If so how can you use static size array, linked list, AVL trees
etcetera.
Before I answer your question, I should say that you can go a LONG way
with just the
On Sun, 21 Sep 2008 01:56:59 +0200, Christian Heimes wrote:
Just *don't* try to abuse lists by creating fancy stuff e.g. linked
lists. The memory overhead is going to kill your app.
I agree with your advice not to abuse lists, but not for the reason you
give. The memory overhead of a linked
I gotta say that as number cruncher, iteration in python is my biggest
nightmare. I do what is possible with numpy, but element by element
processing is a hassle. My programming experience is still pretty fresh
at a year, so exotics as such are not in play yet. I also wish python
looping/iterative
Hi all,
What you are comparing is either IO times (the print loop program),
where Perl beats C - which means that Perl's IO have been written at a
very low level instead of relying on the stdlib's IO -
i'd like to know what aspects are really coded in very low level for python ?
regards,
I am going to be a bit blunt. Don't get offended.
Also the first thing any newbie to python asks me is abt raw speed in
comparison with similar languages like perl when i advocate python to perl.
Judging by your other posts, you are a newbie yourself. You are not
really in a position to
James enlightened us with:
One does not compare speed when they use Perl/Python/Ruby/Tcl. They
are all more or less in the same performance ball park.
I don't want to offend you or anything, but doesn't the second
sentence mean that someone DID do a speed comparison?
Sybren
--
The problem
Sybren Stuvel wrote:
James enlightened us with:
One does not compare speed when they use Perl/Python/Ruby/Tcl. They
are all more or less in the same performance ball park.
I don't want to offend you or anything, but doesn't the second
sentence mean that someone DID do a speed comparison?
Peter Hansen enlightened us with:
Yes, and has shown that they are in the same ballpark, and therefore
one does not _need_ to compare speed any more.
Ok. I'd worded it as there have been tests already, so there is no
need to do your own, instead of one does not test.
Sybren
--
The problem
I don't want to offend you or anything, but doesn't the second sentence mean
that someone DID do a speed comparison?
I did provide Language Shootout link in the next paragraph of the post
you referred to along with an obligatory caution about interpreting
benchmarks. The Language Shootout is a
Terry Hancock wrote:
On Tuesday 23 August 2005 05:35 am, bruno modulix wrote:
(snip)
ot
If you hope to be taken seriously, please abandon the sms-talk style here.
/ot
I think it's reasonably clear that neither poster hoped to be taken
seriously. :-D
Err... I guess that to be taken
If you want a fast language, try Holden. I've just invented it.
Unfortunately it gets the answer to every problem wrong unless the
answer is 42, but boy it runs quickly. The code for the whole
interpreter (it's written in Python) follows:
print 42
great ! u can use it for ur own
computers are cheap. i am expensive. give me clear and maintainable
code every time.
randy
--
http://mail.python.org/mailman/listinfo/python-list
km wrote:
that this obsession reveals a certain inexperience.
its neither obsession nor inexperience ... its just the requirement.
i think less buggy code is not the main concern for all.
Argh (choking)
Then you are definitely a dangerous person! If your program is fast to
give a false
Terry Reedy wrote:
Benjamin Niemann [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
(snip)
In that case, you are interested in IO performance. The time spent
handling
the loop is not significant compared to the time spent executing the
'print' statement - which is a very complex
Steve Holden wrote:
(snip)
If you want a fast language, try Holden. I've just invented it.
Unfortunately it gets the answer to every problem wrong unless the
answer is 42, but boy it runs quickly. The code for the whole
interpreter (it's written in Python) follows:
print 42
keyboard !
km wrote:
If you want a fast language, try Holden. I've just invented it.
Unfortunately it gets the answer to every problem wrong unless the
answer is 42, but boy it runs quickly. The code for the whole
interpreter (it's written in Python) follows:
print 42
great ! u can use it for ur
Steve Holden wrote:
If you want a fast language, try Holden. I've just invented it.
Unfortunately it gets the answer to every problem wrong unless the
answer is 42, but boy it runs quickly. The code for the whole
interpreter (it's written in Python) follows:
print 42
Why are you looking
On Tuesday 23 August 2005 05:35 am, bruno modulix wrote:
km wrote:
If you want a fast language, try Holden. I've just invented it.
Unfortunately it gets the answer to every problem wrong unless the
answer is 42, but boy it runs quickly. The code for the whole
interpreter (it's written in
Hi all,
Why is it that the implementation of empty loop so slow in python when compared
to perl ?
#i did this in python (v 1.5)
for x in xrange(1000):
print x
# this took 0.017 seconds
--
#similar code in perl (v 5.6):
for $x (0..1000)
{
print $x;
}
# this took
km [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]:
Hi all,
Why is it that the implementation of empty loop so slow in
python when compared to perl ?
#i did this in python (v 1.5)
for x in xrange(1000):
print x
# this took 0.017 seconds
--
#similar
km wrote:
Hi all,
Why is it that the implementation of empty loop so slow in python when
compared to perl ?
#i did this in python (v 1.5)
Python 1.5.2 was released in april 1999. Current Python version is 2.4.1.
Please consider upgrading - unless of course you just want to troll...
km wrote:
Why is it that the implementation of empty loop so slow in python when
compared to perl ?
[...]
Is python runtime slow at all aspects when compared to perl ?
No
I really wonder what makes python slower than perl ?
It could be that the Perl compiler recognizes such a for loop
km wrote:
Hi all,
Why is it that the implementation of empty loop so slow in python when
compared to perl ?
#i did this in python (v 1.5)
for x in xrange(1000):
print x
# this took 0.017 seconds
--
#similar code in perl (v 5.6):
for $x (0..1000)
{
Hi all,
ya i am sorry i tried with an empty loop first and then one which emits a
value as the snippet. I have tested it on my machine and now ...
1) perl (v 5.8) does the job in 0.005 seconds
2) but python (v 2.4.1) is horribly slow its 0.61 seconds.
and using range() instead of xrange() in
km wrote:
ya i am sorry i tried with an empty loop first and then one which
emits a value as the snippet. I have tested it on my machine
and now ...
what more do i need to accept python is slow when it comes to
loops concept ?
You've sort of missed some of the points being made,
km [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
ya i am sorry i tried with an empty loop first and then one which emits
a value as the snippet. I have tested it on my machine and now ...
1) perl (v 5.8) does the job in 0.005 seconds
2) but python (v 2.4.1) is horribly slow
Hi all,
thing. If *all* your loops are going to do is print stuff, then you're
doing the right thing with the version that emits values.
ya most of the loops print values.
know this). Since you haven't got any working code, it's not possible
that you *need* whatever negligible speed
They come out even in the computer language shootout:
http://shootout.alioth.debian.org/benchmark.php?test=alllang=pythonsort=fullcpu
(tied 8-8 in execution time, although perl wins 4-12 on memory consumption)
Peace
Bill Mill
On 8/23/05, km [EMAIL PROTECTED] wrote:
Hi all,
thing. If
km wrote:
Hi all,
Why is it that the implementation of empty loop so slow in python when
compared to perl ?
#i did this in python (v 1.5)
for x in xrange(1000):
print x
# this took 0.017 seconds
--
#similar code in perl (v 5.6):
for $x (0..1000)
{
If you want a fast language, try Holden. I've just invented it.
Unfortunately it gets the answer to every problem wrong unless the
answer is 42, but boy it runs quickly.
+1 QOTW
(sometimes the zen master has to whack the student on the head)
Peace
Bill Mill
bill.mill at gmail.com
--
km a écrit :
Hi all,
ya i am sorry i tried with an empty loop first and then one which emits a
value as the snippet. I have tested it on my machine and now ...
1) perl (v 5.8) does the job in 0.005 seconds
2) but python (v 2.4.1) is horribly slow its 0.61 seconds.
and using range()
km wrote:
thing. If *all* your loops are going to do is print stuff, then you're
doing the right thing with the version that emits values.
ya most of the loops print values.
No, you missed my point. I said if *all* the loops are going to do is
print stuff. In other words, no other
km wrote:
Also the first thing any newbie to python asks me is abt raw speed
in comparison with similar languages like perl when i advocate
python to perl.
Always the same chorus... Just tell the newbies that speed is not on
their top list.
If most of the world's computer programs where
km wrote:
Hi all,
thing. If *all* your loops are going to do is print stuff, then you're
doing the right thing with the version that emits values.
ya most of the loops print values.
In that case, you are interested in IO performance. The time spent handling
the loop is not significant
km [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I agree that python emphasizes on readability which i didnt see in many
of the languages, but when the application concern is speed, does it
mean that python is not yet ready? even most of the googling abt python
Funny you should
Benjamin Niemann [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
km wrote:
Hi all,
thing. If *all* your loops are going to do is print stuff, then you're
doing the right thing with the version that emits values.
ya most of the loops print values.
In that case, you are
km wrote:
Is python runtime slow at all aspects when compared to perl ?
And in addition to all that everyone else has said most of this is
startup time. The python interpreter is a fair bit slower to start up
(i.e. does much more at startup time) than the perl one:
lenford$ time
Hi,
a few questions:
A shallow thread is just a generator modified in the most obvious way
possible. The yield statement is replaced with a waitfor expression.
You give it the object you wish to wait for. Then when it's ready
you get back a return value or an exception. These waitfor
First a bit about myself. I've been programming in python several
years now, and I've got several more years before that with C. I've
got a lot of interest in the more theoretical stuff (language design,
component architectures, etc). Of late my focus has been on concurrent
operations (and on
In article [EMAIL PROTECTED],
Rhamphoryncus [EMAIL PROTECTED] wrote:
import mainloop, urllib
def get_and_save(path):
infile = waitfor urllib.urlopen(path, async=True)
outfile = waitfor open(path.split('/')[-1], async=True)
waitfor outfile.write(waitfor infile.read(async=True),
Gary D. Duzan wrote:
A while back I tossed something together to deal with the same
issue
in terms of futures (or promises.) Here is roughly what the
above
code would look like with futures as I implemented them:
snip
This was all done using plain Python 1.5.2 in 80 lines of code,
91 matches
Mail list logo