Re: Loop with else clause

2019-02-07 Thread DL Neil
Further to our discussion of how to improve a code review's discovery of 
the mistaken handling of a for...else... construct:-



Yesterday was a national holiday, but today gave some opportunity to 
research. Way back in 2009 there was spirited discussion over on the 
Python Ideas list (warning, even the mailing list's index covers 
multiple screen-lengths):


- this confusion is not new by any measure, herewith a list of previous 
occasions "fists were raised concerning for..else."

https://mail.python.org/pipermail/python-ideas/2009-October/006164.html

- an excellent summary of the 2009 debate which offers no less than six 
ways to 'improve' for... else...

https://mail.python.org/pipermail/python-ideas/2009-October/006155.html

- (as mentioned earlier) the BDFL weighed-in a couple of times. His 
regret is: "That's a flaw, and I don't quite know what to do about it. 
It's about 20 years too late to remove or rename it. But we probably 
should not do more of these. That's a lesson."
(OK, so make that thirty years - older than the coder who the 
code-review noticed falling into this coding 'gotcha'!)

https://mail.python.org/pipermail/python-ideas/2009-October/006083.html

- herewith a (rather complicated) suggestion, and critique
https://mail.python.org/pipermail/python-ideas/2009-October/006054.html

- one rather hopeful option (actual words to be used notwithstanding)
for i in SEQ:
  A
except:
  B
else:
  C
appears here:
https://mail.python.org/pipermail/python-ideas/2009-October/006044.html


Somewhat related, PEP 548 proposed an "More Flexible Loop Control". This 
was addressing the confusion caused by break within a loop. It was rejected.



Each of the above addresses issues 'within', that is to say happenings 
during iteration - whether the entire loop or iteration cut-short by a 
break (and thus the idea that "else" might be re-worded to indicate 
'after a break').


However, as mentioned by one contributor, the specific use-case our team 
faced was an issue that arises prior to the loop. Alternately-expressed: 
that according to Python's logic, prevents even a single iteration of 
that loop. Thus, any 'solution' would reside outside of for and while 
statements because they only consider if a loop should continue or 
terminate - not handling the question of whether it should start at all!


PEP 315 is the only discussion (I've found) which looks 'outside' or 
'before' the loop itself. It proposed an "Enhanced While Loop", 
attempting to separate 'setup' or loop control from loop content. It was 
rejected.



So, reading-around brought nothing much useful. Back to the code-face...

Thank you to the several folk who responded with ideas to express/improve:

if list:
process_list() #the heading and for-loop, as above
else:
print( "Sorry...

NB this is a constructed 'toy example' attempting to be the shortest 
illustration of use-cases and invented purely to communicate the need 
and structure. It was expected to be interpreted as pseudo-python-code. 
(you'd not use/allow "process_list" as the name of a function, would you?)


(With apologies as necessary) one of the dangers of 'toy examples' is 
the reader taking them at face value, instead of as (over-)simplified 
illustrations. In 'real life' the loop code and the no-loop exception 
are both considerably longer than a single line. Accordingly, using a 
function would be a good way to summarise and self-document the 
activity, ie the if statement's two code-blocks would make the whole 
statement very/too-long (readability)!


The "if list:" expression is overly-simplistic. The recommendation of 
"if len(list):" is absolutely sound, for reasons of polymorphism.


In-lieu of a Python construct, there are definitely situations when use 
of a sentinel makes better sense. However, given their risk, in many 
ways Python tries to avoid using such, eg consuming iterators until a 
StopIteration exception is returned. (includes files, is subsumed by 
ContextManagers...), thus "pythonic". That said, the classic use of 
for... else... is in searching for a particular element within an 
iterable which has all the hallmarks of a "sentinel".



Today, kicking ideas around, I coded three other possible 'solutions' 
for the review team's discussions:


One of these involves coding three functions: the decision (yielding a 
boolean), the expected-case, and the unusual-case. The satisfaction in 
this was readability factors with a simple if statement..


Somewhat more complex, and I feel a bit OTT, was to sub-class list() and 
write a method which would indicate an empty list, plus include much of 
both the expected-case and the empty-list methods therein. Somehow 
"class ListShouldNotBeEmpty" doesn't seem a catchy (if descriptive) 
title - however, it works! The decision 'function' could also/then be 
made @property and (perhaps) thus contribute to readability.


Lastly, I 'remembered' conditi

The sum of ten numbers inserted from the user

2019-02-07 Thread ^Bart

I thought something like it but doesn't work...

for n in range(1, 11):
x = input("Insert a number: ")

for y in range(x):
sum = y

print ("The sum is: ",y)
--
https://mail.python.org/mailman/listinfo/python-list


Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Joel Goldstick
On Thu, Feb 7, 2019 at 6:31 AM ^Bart  wrote:
>
> I thought something like it but doesn't work...
>
> for n in range(1, 11):
>  x = input("Insert a number: ")

The above, keeps replacing x with each input value.  You don't want
that.  Think about appending the input value to a list
>
> for y in range(x):
>  sum = y
>
Here again you are replacing sum with each value of y.  And think
further about what the value of y is for each iteration.

>  print ("The sum is: ",y)

You should really be asking this sort of question in the python-tutor
mailing list.  You should also use print function in your loops to
learn what is really going on.



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



-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


timezones

2019-02-07 Thread Jaap van Wingerde
I made a small script to practise with timezones:

#!/usr/bin/env python3
# -*- coding: utf_8 -*-
from datetime import datetime, timedelta
from pytz import timezone
import pytz
amsterdam_datetime = datetime(2018, 12, 17, 11, 31, 26,
tzinfo=timezone('Europe/Amsterdam'))
print(amsterdam_datetime)
utc_datetime = amsterdam_datetime.astimezone(pytz.utc)
print(utc_datetime)
amsterdam_datetime = datetime(2018, 6, 17, 11, 31, 26,
tzinfo=timezone('Europe/Amsterdam'))
print(amsterdam_datetime)
utc_datetime = amsterdam_datetime.astimezone(pytz.utc)
print(utc_datetime)

The output of the script is:
2018-12-17 11:31:26+00:20
2018-12-17 11:11:26+00:00
2018-06-17 11:31:26+00:20
2018-06-17 11:11:26+00:00

I respected:
2018-12-17 11:31:26+01:00
2018-12-17 10:31:26+00:00
2018-06-17 11:31:26+02:00
2018-06-17 09:31:26+00:00

I need this functionality for adjusting wrong timestamps in Android
JPG-images as the 'Exif.GPSInfo.GPSTimeStamp' and
'Exif.GPSInfo.GPSDateStamp' are missing.

Why I get this unrespected results?

Kind regards,
Jaap.


-- 

Jaap van Wingerde
e-mail: 1234567...@vanwingerde.nl

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


Re: Implement C's Switch in Python 3 [OT languages]

2019-02-07 Thread Christian Gollwitzer

Am 05.02.19 um 02:20 schrieb DL Neil:
So, even with the French making their dates into sentences, not a single 
one uses ordinals!
- did the computer people in all these languages/cultures decide that 
the more numeric approach was better/easier/...

(ie simpler/less-complex)


:)

For the two languages I know well, German (mother tongue) and Czech 
(studied for 5 years, 1 year abroad in Prague) I can assure you that the 
numeric ordinals were not dicated by the computer people, but that's 
been the typographic tradition since ever. You write the number with a 
period, also for dates. In regular sentences, something like "he 
achieved the eigth placement in a tournament" it depends on the size of 
the number, below ten or twelve one usually spells it out (with 
inflection and everything) and above it's typically written with numbers 
and a period.


But I read a funny story at the Czech language instutute's page about 
the influence of MS Word on Czech spelling. In dates, the name of the 
month is written in lowercase "1. prosince". Howver, MS Word thinks that 
the period is a full-stop which starts a new sentence, and it 
autocorrects it to "1. Prosince". This has happened so often that they 
brought it up as a special topic, that this autocorrection is wrong.



Not even the convention/use of title-case is consistent!


Title case? In German, there are intricate rules about the 
capitalization in regular sentences; there is no such thing as title 
case. Only very rarely ALL CAPS are used.


Have a good sleep ;)

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


RE: timezones

2019-02-07 Thread David Raymond
I'd say if the documentation mentions it, but doesn't say why, then we're not 
gonna be able to do much better for you as far as "why" goes.

http://pytz.sourceforge.net/

"Unfortunately using the tzinfo argument of the standard datetime constructors 
"does not work" with pytz for many timezones."

But it looks like they suggest something along the lines of...

timezone('Europe/Amsterdam').localize(datetime(2018, 12, 17, 11, 31, 26))


>From the examples on http://pytz.sourceforge.net/#problems-with-localtime ...

>>> eastern = timezone('US/Eastern')
>>> fmt = '%Y-%m-%d %H:%M:%S %Z%z'
>>> loc_dt = datetime(2002, 10, 27, 1, 30, 00)
>>> est_dt = eastern.localize(loc_dt, is_dst=True)
>>> edt_dt = eastern.localize(loc_dt, is_dst=False)
>>> print(est_dt.strftime(fmt) + ' / ' + edt_dt.strftime(fmt))
2002-10-27 01:30:00 EDT-0400 / 2002-10-27 01:30:00 EST-0500


Browse through their examples and see if you can find something similar that 
works for you.


-Original Message-
From: Python-list 
[mailto:python-list-bounces+david.raymond=tomtom@python.org] On Behalf Of 
Jaap van Wingerde
Sent: Wednesday, February 06, 2019 9:27 AM
To: python-list@python.org
Subject: timezones

I made a small script to practise with timezones:

#!/usr/bin/env python3
# -*- coding: utf_8 -*-
from datetime import datetime, timedelta
from pytz import timezone
import pytz
amsterdam_datetime = datetime(2018, 12, 17, 11, 31, 26,
tzinfo=timezone('Europe/Amsterdam'))
print(amsterdam_datetime)
utc_datetime = amsterdam_datetime.astimezone(pytz.utc)
print(utc_datetime)
amsterdam_datetime = datetime(2018, 6, 17, 11, 31, 26,
tzinfo=timezone('Europe/Amsterdam'))
print(amsterdam_datetime)
utc_datetime = amsterdam_datetime.astimezone(pytz.utc)
print(utc_datetime)

The output of the script is:
2018-12-17 11:31:26+00:20
2018-12-17 11:11:26+00:00
2018-06-17 11:31:26+00:20
2018-06-17 11:11:26+00:00

I respected:
2018-12-17 11:31:26+01:00
2018-12-17 10:31:26+00:00
2018-06-17 11:31:26+02:00
2018-06-17 09:31:26+00:00

I need this functionality for adjusting wrong timestamps in Android
JPG-images as the 'Exif.GPSInfo.GPSTimeStamp' and
'Exif.GPSInfo.GPSDateStamp' are missing.

Why I get this unrespected results?

Kind regards,
Jaap.


-- 

Jaap van Wingerde
e-mail: 1234567...@vanwingerde.nl

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


RE: The sum of ten numbers inserted from the user

2019-02-07 Thread Schachner, Joseph
Well of course that doesn't work.  For starters, x is an int or a float value.  
After the loop It holds the 10th value.  It might hold 432.7 ...   It is not a 
list.
The default start for range is 0.  The stop value, as you already know, is not 
part of the range.  So I will use range(10).

In the second loop, I think you thought x would be a list and you I'm sure you 
wanted to do 
for y in x:
but instead you did 
for y in range(x)
 and remember x might be a very large number.So the second loop would loop 
that many times, and each pass it would assign y (which has first value of 0 
and last value of whatever x-1 is) to sum.  Even though its name is "sum" it is 
not a sum.  After the loop it would hold x-1.  You wanted to do  sum += y.
Or sum = sum + y.   I prefer the former, but that could reflect my history as a 
C and C++ programmer.

And then you printed y, but you really want to print sum  (assuming that sum 
was actually the sum).

Putting all of the above together, you want to do this:

vallist =[] # an empty list, so we can append to it
for n in range(10):
x = input("Insert a number: ")# get 1 number into x
vallist.append(x)  # append it to our list

# Now vallist holds 10 values

sum = 0   # No need to start sum as a float, in Python if we add a float to an 
integer the result will be float. It doesn't matter in the program if sum is 
int or float.
for y in vallist:
 sum += y

print( "The sum is: ", sum)



-Original Message-
From: ^Bart  
Sent: Thursday, February 7, 2019 6:30 AM
To: python-list@python.org
Subject: The sum of ten numbers inserted from the user

I thought something like it but doesn't work...

for n in range(1, 11):
 x = input("Insert a number: ")

for y in range(x):
 sum = y

 print ("The sum is: ",y)

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


Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ian Clark
This is my whack at it, I can't wait to hear about it being the wrong big o
notation!

numbers=[]

while len(numbers) < 10:
try:
chip = int(input('please enter an integer: '))
except ValueError:
print('that is not a number, try again')
else:
numbers.append(chip)

print(sum(numbers))


On Thu, Feb 7, 2019 at 10:23 AM Schachner, Joseph <
joseph.schach...@teledyne.com> wrote:

> Well of course that doesn't work.  For starters, x is an int or a float
> value.  After the loop It holds the 10th value.  It might hold 432.7 ...
>  It is not a list.
> The default start for range is 0.  The stop value, as you already know, is
> not part of the range.  So I will use range(10).
>
> In the second loop, I think you thought x would be a list and you I'm sure
> you wanted to do
> for y in x:
> but instead you did
> for y in range(x)
>  and remember x might be a very large number.So the second loop would
> loop that many times, and each pass it would assign y (which has first
> value of 0 and last value of whatever x-1 is) to sum.  Even though its name
> is "sum" it is not a sum.  After the loop it would hold x-1.  You wanted to
> do  sum += y.Or sum = sum + y.   I prefer the former, but that could
> reflect my history as a C and C++ programmer.
>
> And then you printed y, but you really want to print sum  (assuming that
> sum was actually the sum).
>
> Putting all of the above together, you want to do this:
>
> vallist =[] # an empty list, so we can append to it
> for n in range(10):
> x = input("Insert a number: ")# get 1 number into x
> vallist.append(x)  # append it to our list
>
> # Now vallist holds 10 values
>
> sum = 0   # No need to start sum as a float, in Python if we add a float
> to an integer the result will be float. It doesn't matter in the program if
> sum is int or float.
> for y in vallist:
>  sum += y
>
> print( "The sum is: ", sum)
>
>
>
> -Original Message-
> From: ^Bart 
> Sent: Thursday, February 7, 2019 6:30 AM
> To: python-list@python.org
> Subject: The sum of ten numbers inserted from the user
>
> I thought something like it but doesn't work...
>
> for n in range(1, 11):
>  x = input("Insert a number: ")
>
> for y in range(x):
>  sum = y
>
>  print ("The sum is: ",y)
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: The sum of ten numbers inserted from the user

2019-02-07 Thread Schachner, Joseph
I just realized that input has changed in Python 3 and I was using Python 
2.7.13 with from __future__ import print_function and some others, but not that.
In Python 3 the int( ) or float( ) cast is necessary because input( ) does what 
raw_input( ) did in Python 2; raw_input( ) name is therefore removed.

--- Joe S.

From: Ian Clark 
Sent: Thursday, February 7, 2019 1:27 PM
To: Schachner, Joseph 
Cc: python-list@python.org
Subject: Re: The sum of ten numbers inserted from the user

This is my whack at it, I can't wait to hear about it being the wrong big o 
notation!

numbers=[]

while len(numbers) < 10:
try:
chip = int(input('please enter an integer: '))
except ValueError:
print('that is not a number, try again')
else:
numbers.append(chip)

print(sum(numbers))


On Thu, Feb 7, 2019 at 10:23 AM Schachner, Joseph 
mailto:joseph.schach...@teledyne.com>> wrote:
Well of course that doesn't work.  For starters, x is an int or a float value.  
After the loop It holds the 10th value.  It might hold 432.7 ...   It is not a 
list.
The default start for range is 0.  The stop value, as you already know, is not 
part of the range.  So I will use range(10).

In the second loop, I think you thought x would be a list and you I'm sure you 
wanted to do
for y in x:
but instead you did
for y in range(x)
 and remember x might be a very large number.So the second loop would loop 
that many times, and each pass it would assign y (which has first value of 0 
and last value of whatever x-1 is) to sum.  Even though its name is "sum" it is 
not a sum.  After the loop it would hold x-1.  You wanted to do  sum += y.
Or sum = sum + y.   I prefer the former, but that could reflect my history as a 
C and C++ programmer.

And then you printed y, but you really want to print sum  (assuming that sum 
was actually the sum).

Putting all of the above together, you want to do this:

vallist =[] # an empty list, so we can append to it
for n in range(10):
x = input("Insert a number: ")# get 1 number into x
vallist.append(x)  # append it to our list

# Now vallist holds 10 values

sum = 0   # No need to start sum as a float, in Python if we add a float to an 
integer the result will be float. It doesn't matter in the program if sum is 
int or float.
for y in vallist:
 sum += y

print( "The sum is: ", sum)



-Original Message-
From: ^Bart mailto:gabriele1nos...@hotmail.com>>
Sent: Thursday, February 7, 2019 6:30 AM
To: python-list@python.org
Subject: The sum of ten numbers inserted from the user

I thought something like it but doesn't work...

for n in range(1, 11):
 x = input("Insert a number: ")

for y in range(x):
 sum = y

 print ("The sum is: ",y)

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


Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ben Bacarisse
Ian Clark  writes:

> This is my whack at it, I can't wait to hear about it being the wrong big o
> notation!
>
> numbers=[]
>
> while len(numbers) < 10:
> try:
> chip = int(input('please enter an integer: '))
> except ValueError:
> print('that is not a number, try again')
> else:
> numbers.append(chip)
>
> print(sum(numbers))

Why would you not keep a running total, rather than list of the numbers?
I've not been following assiduously, so maybe I missed some other
requirement...


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


Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Grant Edwards
On 2019-02-07, Ben Bacarisse  wrote:
> Ian Clark  writes:
>
>> This is my whack at it, I can't wait to hear about it being the wrong big o
>> notation!
>>
>> numbers=[]
>>
>> while len(numbers) < 10:
>> try:
>> chip = int(input('please enter an integer: '))
>> except ValueError:
>> print('that is not a number, try again')
>> else:
>> numbers.append(chip)
>>
>> print(sum(numbers))
>
> Why would you not keep a running total, rather than list of the numbers?
> I've not been following assiduously, so maybe I missed some other
> requirement...

Because you think it likely that tomorrow the marketing people are
going to say "oh, and we want to know the min, max, mode, median,
standard deviation, and count of odd vs. even.

OTOH, they may instead say, "Oh, it's not 10 numbers, it's 10 million
numbers."

-- 
Grant Edwards   grant.b.edwardsYow! I selected E5 ... but
  at   I didn't hear "Sam the Sham
  gmail.comand the Pharoahs"!

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


Re: Python program to phone?

2019-02-07 Thread Jack Dangler



On 2/4/19 3:20 PM, Steve wrote:

I have written my first python program (600 lines!) to help control my blood
sugar and it has been so successful that my A1c dropped form 9.3 to an
impressive 6.4.  It will be much more useful if I had it on my phone.
(MotoG, Android)  The .py file reads/writes to two txt files.

  


About a year ago, I installed Kivy and managed to transfer the "Hello World"
app to my phone and it worked.  I am not on a different computer and believe
that I got all the way through the installation but I do not see how to
invoke it.  I am sure that I can go through the tutorial again and use my
program instead.

  


How do I figure out what is wrong and might there ne a better way to get the
program onto my phone?

  


Steve

  


P.S.  Yes, I tried to post this about two weeks ago but could not seem to
respond to the replies I received.  I could contact one or two individuals
but apparently not the masses.  How do I find out how this list works?

  

  


Foornote:
There's 99 bugs in the code, in the code.

99 bugs in the code.

Take one down and patch it all around.

Now there's 117 bugs in the code.

  


Steve

I'm not sure but I think there is an Android lib for py that is 
available to help convert your app to a mobile platform. Also, if you're 
of a mind, I'd love to see the code you wrote for blood sugar. I need to 
lower my A1C as well and could use all the help I can get.


Regards

Jack

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


Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ben Bacarisse
Bart  writes:

> On 07/02/2019 20:45, Ben Bacarisse wrote:
>> Ian Clark  writes:
>>
>>> This is my whack at it, I can't wait to hear about it being the wrong big o
>>> notation!
>>>
>>> numbers=[]
>>>
>>> while len(numbers) < 10:
>>>  try:
>>>  chip = int(input('please enter an integer: '))
>>>  except ValueError:
>>>  print('that is not a number, try again')
>>>  else:
>>>  numbers.append(chip)
>>>
>>> print(sum(numbers))
>>
>> Why would you not keep a running total, rather than list of the numbers?
>> I've not been following assiduously, so maybe I missed some other
>> requirement...
>
> Because it separates the two tasks: (A) capture N values; (B) perform
> some operation on those values, in this case summing (and taking
> advantage here of the built-in sum()).

Sure.  Did I miss some hint that this program might need to be more
flexible like that?  It looks like a beginners' exercise.

If the purpose is to be flexible, why is an array the right option rather
than, say, accumulating a value over an iterable?  You need some idea of
the future direction or what the exercise is intended to reinforce.


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


Re: The sum of ten numbers inserted from the user

2019-02-07 Thread Ben Bacarisse
Grant Edwards  writes:

> On 2019-02-07, Ben Bacarisse  wrote:
>> Ian Clark  writes:
>>
>>> This is my whack at it, I can't wait to hear about it being the wrong big o
>>> notation!
>>>
>>> numbers=[]
>>>
>>> while len(numbers) < 10:
>>> try:
>>> chip = int(input('please enter an integer: '))
>>> except ValueError:
>>> print('that is not a number, try again')
>>> else:
>>> numbers.append(chip)
>>>
>>> print(sum(numbers))
>>
>> Why would you not keep a running total, rather than list of the numbers?
>> I've not been following assiduously, so maybe I missed some other
>> requirement...
>
> Because you think it likely that tomorrow the marketing people are
> going to say "oh, and we want to know the min, max, mode, median,
> standard deviation, and count of odd vs. even.
>
> OTOH, they may instead say, "Oh, it's not 10 numbers, it's 10 million
> numbers."

Sure.  I can think of reasons for all sorts of designs.  Has there been
any hint?  It looks like a beginners' exercise with little extra to go
on.

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


RE: Python program to phone?

2019-02-07 Thread Steve
BeeWare looks as if it requires Java, does it?
Is it exclusively java?

= 
Footnote:
Zamboni locks up after running into large patch of loose teeth.

-Original Message-
From: Python-list  On
Behalf Of Mario R. Osorio
Sent: Tuesday, February 5, 2019 8:58 AM
To: python-list@python.org
Subject: Re: Python program to phone?


Hi there Steve. Did you check BeeWare? (https://pybee.org/)

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

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


Re: Python program to phone?

2019-02-07 Thread Michael Torrie
On 02/07/2019 09:00 PM, Steve wrote:
> BeeWare looks as if it requires Java, does it?
> Is it exclusively java?

Kind of.  You do your coding in Python, then that's compiled to python
byte code, which is then translated to Java byte code.  You'll need the
Android SDK, even if you're not using Java directly.  Unfortunately
Google no longer lets you download just the SDK by itself. Instead you
have to download the entire 1GB Android Studio.

I haven't done anything with PyBee, but it looks promising for your
purposes.

Instead of using text files, you'll probably need to use sqlite data
stores.  Not a huge deal if PyBee abstracts this for you.

Recently I made an android app using V-play.net, which is built on
QtQuick.  Basically it was all javascript.  This might work for your app
also. It's not Python, but the learning curve isn't huge.  It took me
far longer to figure out the GUI layout than it did to figure out the
Javascript.
-- 
https://mail.python.org/mailman/listinfo/python-list


how to exit from a nested loop in python

2019-02-07 Thread Kaka
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 (Temp[i]['cost'][j] <= (run_parameters.PSD):  -- When 
this condition is true i want to break the nested loop and start from the 
begining
   served_count +=1
   A.T[i]["First_index"]= s
   A.T[i]["Last_index"]= s+req_slots[j]-1
   A.T[i]["Status"]= 1
   A.T[i]["Selected_MOD"] = j
   break

I have this code. When the last "if" condition is satisfied, i want to break 
all the loops and start the nested loop for next i. else, the loop should 
continue.  

can anyone help me?
-- 
https://mail.python.org/mailman/listinfo/python-list