Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
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 = ["Arya","Pupun"]
> >
> > for name in Names:
> >for c in name:
> >print(c)
> >
> > instead use:
> >
> > for c in name in Names:
> > print(c)
> 
> Because programming is all about building up a program from
> primitives. The number of times when we need this kind of nested loop
> (with absolutely nothing in between the loops) is way too small to
> justify dedicated syntax.
> 
> ChrisA

Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
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:
> > 
> > for c in name in Names:
> > print(c)
> 
> Hmm. Why stop there?
> 
> bit = ["kibbles"]
> bits = [bit, bit]
> bitts = [bits, bits]
> for kibbles in bit in bits in bitts:
> do_something(kibbles)

My thought exactly.. :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
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"]
> >
> > for name in Names:
> >for c in name:
> >print(c)
> >
> > instead use:
> >
> > for c in name in Names:
> > print(c)
> 
> It doesn't seem very intuitive (doesn't follow proper English
> phrasing, for instance) and I don't think it's a common enough
> situation to warrant adding a special syntax for it. But if you really
> want it, you could use something like this:
> 
> def double_for(iterable):
> for outer in iterable:
> yield from outer
> 
> for c in double_for(Names):
> print(c)
> 
> But I don't think this is any clearer than making the loops explicit.

Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: For Loop Dilema [python-list]

2018-02-26 Thread arya . kumar2494
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 for. You could use itertools.chain.from_iterable, though:
> 
> py> names = ['Jack', 'Susan']
> py> list(chain.from_iterable(names))
> ['J', 'a', 'c', 'k', 'S', 'u', 's', 'a', 'n']

if you want to access a dict per say insisde a list or maybe some data i.e deep 
nested in some mixture of ds wont it be relevant to use a single for statement 
to query the data out.(Just a thought)
Students = [{"name":John,"age":16},{"name":Maria,"age":18}]

for info in student in Students:
 print(student[info])



-- 
https://mail.python.org/mailman/listinfo/python-list


For Loop Dilema [python-list]

2018-02-25 Thread arya . kumar2494
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