Re: Python text file fetch specific part of line

2016-08-02 Thread honeygne
On Thursday, July 28, 2016 at 1:00:17 PM UTC+5:30, [email protected] wrote:
> On 27Jul2016 22:12, Arshpreet Singh  wrote:
> >I am writing Imdb scrapper, and getting available list of titles from IMDB 
> >website which provide txt file in very raw format, Here is the one part of 
> >file(http://pastebin.com/fpMgBAjc) as the file provides tags like 
> >Distribution  
> >Votes,Rank,Title I want to parse title names, I tried with readlines() 
> >method 
> >but it returns only list which is quite heterogeneous, is it possible that I 
> >can parse each value comes under title section?
> 
> Just for etiquette: please just post text snippets like that inline in your 
> text. Some people don't like fetching random URLs, and some of us are not 
> always online when reading and replying to email. Either way, having the text 
> in the message, especially when it is small, is preferable.
> 
> To your question:
> 
> Your sample text looks like this:
> 
> New  Distribution  Votes  Rank  Title
>   000125  1680661   9.2  The Shawshank Redemption (1994)
>   000125  1149871   9.2  The Godfather (1972)
>   000124  786433   9.0  The Godfather: Part II (1974)
>   000124  1665643   8.9  The Dark Knight (2008)
>   000133  860145   8.9  Schindler's List (1993)
>   000133  444718   8.9  12 Angry Men (1957)
>   000123  1317267   8.9  Pulp Fiction (1994)
>   000124  1209275   8.9  The Lord of the Rings: The Return of the 
> King 
> (2003)
>   000123  500803   8.9  Il buono, il brutto, il cattivo (1966)
>   000133  1339500   8.8  Fight Club (1999)
>   000123  1232468   8.8  The Lord of the Rings: The Fellowship of the 
> Ring (2001)
>   000223  832726   8.7  Star Wars: Episode V - The Empire Strikes 
> Back 
> (1980)
>   000233  1243066   8.7  Forrest Gump (1994)
>   000123  1459168   8.7  Inception (2010)
>   000223  1094504   8.7  The Lord of the Rings: The Two Towers (2002)
>   000232  676479   8.7  One Flew Over the Cuckoo's Nest (1975)
>   000232  724590   8.7  Goodfellas (1990)
>   000233  1211152   8.7  The Matrix (1999)
> 
> Firstly, I would suggest you not use readlines(), it pulls all the text into 
> memory. For small text like this is it ok, but some things can be arbitrarily 
> large, so it is something to avoid if convenient. Normally you can just 
> iterate 
> over a file and get lines.
> 
> You want "text under the Title." Looking at it, I would be inclined to say 
> that 
> the first line is a header and the rest consist of 4 columns: a number 
> (distribution?), a vote count, a rank and the rest (title plus year).
> 
> You can parse data like that like this (untested):
> 
>   # presumes `fp` is reading from the text
>   for n, line in enumerate(fp):
> if n == 0:
>   # heading, skip it
>   continue
> distnum, nvotes, rank, etc = split(line, 3)
> ... do stuff with the various fields ...
> 
> I hope that gets you going. If not, return with what code you have, what 
> happened, and what you actually wanted to happen and we may help further.
Thanks I am able to do it with following:
https://github.com/alberanid/imdbpy/blob/master/bin/imdbpy2sql.py (it was very 
helpful)

python imdbpy2sql.py -d <.txt files downloaded from IMDB> -u 
sqlite:/where/to/save/db --sqlite-transactions
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why not allow empty code blocks?

2016-08-02 Thread Antoon Pardon
Op 30-07-16 om 05:49 schreef Steven D'Aprano:
> On Sat, 30 Jul 2016 04:32 am, Antoon Pardon wrote:
>
>
> Perhaps its *you* who doesn't understand. The subject line talks
> about "empty code blocks", and Bart has suggested that instead of having to
> write
>
> ...
>
> So now you're changing your story, and claiming that you're not actually
> replacing an existing except block with pass (because I think any
> experienced Python developer, which Bart is not, realises that's not likely
> to work). Now you've got a use-case where we start with:

I am not changing my story, I am describing it from a different view point.

> # before
> some code
> more processing
>
> and add an entire try...except around it:
>
> # step 1
> try:
> some code
> except SomeException:
> debugging code
> more processing
>
> *and then* comment out the debugging code and replace it with pass:
>
> # after, as stated by you
> try:
> some code
> except SomeException:
> # debugging code
> pass
> more processing

No I start with writing the above code and the debugging code uncommented.

> Of course it's legitimate to wrap some failing code in a temporary
> try...except block for debugging purposes. But that's not an empty code
> block, and its not "pass", and it's not relevant to Chris' question.

You still don't seem to understand. This code doesn't fail. SomeException
can normally safely be ignored. However some of the called functions might
throw it wrongly.

> And what happens once you have finished debugging the code? According to
> your post, you comment out the debugging code, replacing it by "pass". And
> you do this *frequently*.

That depends what you mean with *frequently*. It depends on the nastyness
of the bug I am chasing. 

> Okay, if you say you do that, I have to believe you. If we take you at your
> word, then we can only conclude that your code is littered with the
> detritus of old debugging code and unnecessary try...except blocks which do
> nothing. That's practically the definition of *poor programming*, leaving
> old code commented out to rot, but if you say that's what you do, who am I
> to argue that you don't?

You are not taking my word for it, you are jumping to conclusions. The
fact that I do this at some point, doesn't mean I leave it in indefenatly.

> Since I don't actually believe you are that poor a programmer, I suspect
> that what you actually do is not replace the debugging code with "pass",
> like you claim, but that once you have finished debugging that section of
> the code you remove the unneeded try...except block and dead, unused
> debugging code, returning it to the "before" state.

But it isn't an unneeded try ... except block. I need the try ... except
block to ignore an exception that should be harmless at that point.

> D'Arcy's suggestion of leaving the debugging code in with a runtime switch
> to turn it on and off also makes sense. 

Yes that makes sense. However if I think that is worth the while I usally
just start using the logging module.

-- 
Antoon



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


Tcl/Tk for Python 3.6.0a3 on Os X 10.9.5

2016-08-02 Thread munozvvaleria
Hello,

I am new to the programming world but I need to learn this program for a 
research class that I am taking. I have downloaded Python 3.6.0a3 on a Mac 
10.9.5 and realized that I also need to download an Active Tcl for it. I can't 
find one for this version. Can someone please direct me to it? The most recent 
one I've been able to find is for Python 3.5.2

Thanks!

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


Re: Tcl/Tk for Python 3.6.0a3 on Os X 10.9.5

2016-08-02 Thread Christian Gollwitzer

Am 02.08.16 um 10:21 schrieb [email protected]:

I am new to the programming world but I need to learn this program for a 
research class that I am taking. I have downloaded Python 3.6.0a3 on a Mac 
10.9.5 and realized that I also need to download an Active Tcl for it. I can't 
find one for this version. Can someone please direct me to it? The most recent 
one I've been able to find is for Python 3.5.2


Tcl/Tk is independent from Python; any version should work. For best 
results on the Mac, try the most recent ActiveTcl from here 
http://www.activestate.com/activetcl/downloads/thank-you?dl=http://downloads.activestate.com/ActiveTcl/releases/8.6.4.1/ActiveTcl8.6.4.1.299124-macosx10.5-i386-x86_64-threaded.dmg


Christian

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


holding if/else condition in live bitcoin trading Python

2016-08-02 Thread Arshpreet Singh
I am making a function that is running in while loop and if/else statements 
make decisions on based on the condition:
here is code:


def main_call():
while True:
l0_0 = getDiff('btcusd',8)
l1_0 = np.tanh(l0_0*0.8446488687)

l1_1 = np.tanh(l0_0*-0.5674069006)
l1_2 = np.tanh(l0_0*0.8676766445)

  
if(l3_0>0):
print l3_0
print auto_order_buy('0.01',str(ticker_last('btcusd')))
elif(l3_0<0):
print l3_0
print auto_order_sell('0.01',str(ticker_last('btcusd')))
else:
pass

now in my function l3_0>0 auto_order_buy() is executed but as program is 
running in while loop so it gets executed again and again. I have implemented 
while loop because I am doing live trading. is there any approach I can go with 
so auto_order_buy() auto_order_sell() function only executed once?
-- 
https://mail.python.org/mailman/listinfo/python-list


Recursive csv import functions for Pandas

2016-08-02 Thread andrea . botti
I have put together the following code:

## DEFINES INPUT FILES
inputcsvT = ['./input_csv/A08_KI_T*.csv',   
'./input_csv/A08_LR_T*.csv','./input_csv/A08_B1_T*.csv',]
#'./input_csv/A10_KI_T*.csv',   
'./input_csv/A10_LR_T*.csv','./input_csv/A10_B1_T*.csv',
#'./input_csv/A11_KI_T*.csv',   
'./input_csv/A11_LR_T*.csv','./input_csv/A11_B1_T*.csv',
#'./input_csv/A16_KI_T*.csv',   
'./input_csv/A16_LR_T*.csv','./input_csv/A16_B1_T*.csv']

inputcsvR = ['./input_csv/A08_KI_R*.csv',   
'./input_csv/A08_LR_R*.csv','./input_csv/A08_B1_R*.csv',]

## DEFINES FUNCTIONS FOR CSV INPUT, MERGE AND HOURLY RESAMPLING
def csv_import_merge_T(f):
dfsT = [pd.read_csv(fp,  index_col=[0], parse_dates=[0], dayfirst=True, 
names=['datetime','temp','rh'], header=0) for fp in files] 
dfT = pd.concat(dfsT)
dfT = dfT.drop('rh', 1)
#dfT[~dfT.index.duplicated()]   # replaced with function below
dfT_clean = 
dfT.reset_index().drop_duplicates('datetime').set_index('datetime')
dfTH = dfT_clean.resample('H').bfill()
return dfTH


def csv_import_merge_R(f):
dfsR = [pd.read_csv(fp,  index_col=[0], parse_dates=[0], dayfirst=True, 
names=['datetime','rad'], header=0) for fp in files] 
dfR = pd.concat(dfsR)
#dfR[~dfR.index.duplicated()]   # replaced with function below
dfR_clean = 
dfR.reset_index().drop_duplicates('datetime').set_index('datetime')
dfRH = dfR_clean.resample('H').mean()
return dfRH


## PERFORMS FUNCTIONS FOR ALL Ts AND Rs AND CALCULATES HEATING DEGREE HOURS 
(HDH) AS R-T WHEN XX_XX_R = XX_XX_T
for csvnameT in inputcsvT:
files = glob.glob(csvnameT)
print ('___'); print (files)
csvT = csvnameT[12:20]
print csvT
t = csv_import_merge_T(files)
t.to_csv('./output_csv/'+ csvT + '.csv')

for csvnameR in inputcsvR:
files = glob.glob(csvnameR)
print ('___'); print (files)
csvR = csvnameR[12:20]
r = csv_import_merge_R(files)
print csvR

while csvnameR[12:18] == csvnameT[12:18]:
print csvR + "=" + csvT

r.to_csv('./output_csv/'+ csvR +'.csv')

hdh = r.sub(t,axis=0).dropna()
hdh[hdh['temp']<=1] = 0
csvHDH = csvnameT[12:18]
hdh_week = 
hdh.temp.resample('W-MON').sum().round(decimals=0)
hdh_week.to_csv('./output_csv/HDH/' + csvHDH + 
'_HDH.csv')

The sequence of action should be:
for A08_KI
 - import A08_KI_T1,T2,...Tn, merge them into A08_KI_T and resample them by the 
hour (room temp.)
 - import A08_KI_R1,R2,...Rn, merge them into A08_KI_R and resample them by the 
hour (radiator temp.)
 - every time XX_XX_R = XX_XX_T (i.e. A08_KI_T and A08_KI_R, or A10_LR_T and 
A10_LR_R) calculate HDH = R - T.

The code I developed has something wrong and the command:

while csvnameR[12:18] == csvnameT[12:18]:
seems to cause the loop to go on for ever.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tcl/Tk for Python 3.6.0a3 on Os X 10.9.5

2016-08-02 Thread Chris Angelico
On Tue, Aug 2, 2016 at 6:21 PM,   wrote:
> I am new to the programming world but I need to learn this program for a 
> research class that I am taking. I have downloaded Python 3.6.0a3 on a Mac 
> 10.9.5 and realized that I also need to download an Active Tcl for it. I 
> can't find one for this version. Can someone please direct me to it? The most 
> recent one I've been able to find is for Python 3.5.2
>

To add to what Christian suggested: If you can't get something working
using an alpha build of Python (that's an unreleased development
version), download Python 3.5.2 instead. That's the current stable
release. Using alphas opens you up to new bugs and incompatibilities,
and generally isn't something I'd recommend for a new programmer. It's
only fools like me who use unreleased software :)

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


Re: Why not allow empty code blocks?

2016-08-02 Thread Antoon Pardon
Op 30-07-16 om 18:15 schreef Rustom Mody:
>
> The more general baby that is significant is that beginners should have
> it easy to distinguish procedure and function and python does not naturally 
> aid that.  print was something procedure-ish in python2 but the general 
> notion being
> absent is a much more significant problem (for beginners) than print.
>
> ...
>
> Ok Python is better than Java is better than C++
> But it cannot stand up to scheme as a teaching language
> [The MIT Profs who replaced scheme by python admit to as much viz.

But AFAIK scheme doesn't aid in distinguishing procedure from function either.

-- 
Antoon. 

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


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread BartC

On 31/07/2016 19:58, Terry Reedy wrote:

On 7/31/2016 6:18 AM, BartC wrote:



 repeat N:



The benefit is not so much performance, but being able to express
something very easily and quickly.


The cost of the 'repeat' contraction is that one cannot use the loop
variable, either as part of a modified computation or for monitoring or
debugging purposes.
   print(i, for_body_result)
Beginners are often atrocious at debugging, and it seems not to be
taught hardly at all.  'repeat n' erects a barrier to debugging.



Debugging: probing a computation to see what actually happens, as
opposed to what one wanted and expected to happen.  (Me, just now ;-)

One major way of debugging is printing values as they are computed.
Naming values (objects) allows them to be printed without recomputing
the value.  In the 'repeat n' context, recomputing would mean adding 3
lines of debugging code instead of 1.

i = 0
repeat n:
   a = f(a)
   print(i, a)
   n += 1


Your objection to a feature such as 'repeat N' doesn't really stack up.

Debugging code is stuff that you add temporarily to find out what's 
going on, then you get rid of it to leave the clean, unfettered lines of 
the program.


You don't want people wondering where that loop index may or may not be 
used.


Anyway, if that was a valid objection, it would apply throughout the 
language. In list-comps for example (there is an index, but where do you 
stick the print?). Or in a for-loop iterating over values:


 a=[10,20,30,40,50]
 for x in a:
print (x)

This will print the element, but what's the index? According to you, 
every such for-loop needs to be written in a form that provides the 
index of a loop, on the off-chance that someone might want to print its 
value somewhere in the body! ('for (i,x) in enumerate(a):')


I get that people here don't want such a feature, but I don't think this 
is the reason.


I think the real reason is not willing to admit that the language lacks 
something that could actually be useful, and especially not to an 
upstart on usenet who is not even an expert in that language.


--
Bartc

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


Installing Python 3 on Windows

2016-08-02 Thread Uri Even-Chen
Hi,

I want to install Python 3 on Windows, but I also need Python 2 for Google
App Engine SDK. When I type a name of a Python file in command line, I want
it to run with Python 3. However, I checked with "print 3/5" and it printed
0 - Python 2. I have the latest versions of Python installed
- python-2.7.12.msi and python-3.5.2.exe

>python --version
Python 2.7.12

>assoc .py
.py=Python.File

>ftype Python.File
Python.File="C:\Python27\python.exe" "%1" %*

By the way, it there a way to print the Python version from Python?

Thanks,
Uri.

*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: [email protected]
Website: http://www.speedysoftware.com/uri/en/
  
    
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 3 on Windows

2016-08-02 Thread Edward Diener

On 8/2/2016 8:11 AM, Uri Even-Chen wrote:

Hi,

I want to install Python 3 on Windows, but I also need Python 2 for Google
App Engine SDK. When I type a name of a Python file in command line, I want
it to run with Python 3. However, I checked with "print 3/5" and it printed
0 - Python 2. I have the latest versions of Python installed
- python-2.7.12.msi and python-3.5.2.exe


python --version

Python 2.7.12


assoc .py

.py=Python.File


ftype Python.File

Python.File="C:\Python27\python.exe" "%1" %*

By the way, it there a way to print the Python version from Python?


Use the Python Launcher for Windows.

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


Re: Why not allow empty code blocks?

2016-08-02 Thread Rustom Mody
On Tuesday, August 2, 2016 at 4:01:25 PM UTC+5:30, Antoon Pardon wrote:
> Op 30-07-16 om 18:15 schreef Rustom Mody:
> >
> > The more general baby that is significant is that beginners should have
> > it easy to distinguish procedure and function and python does not naturally 
> > aid that.  print was something procedure-ish in python2 but the general 
> > notion being
> > absent is a much more significant problem (for beginners) than print.
> >
> > ...
> >
> > Ok Python is better than Java is better than C++
> > But it cannot stand up to scheme as a teaching language
> > [The MIT Profs who replaced scheme by python admit to as much viz.
> 
> But AFAIK scheme doesn't aid in distinguishing procedure from function either.


True. And my words above seem to say that.  However let me restore some more 
context:


On Saturday, July 30, 2016 at 9:45:34 PM UTC+5:30, Rustom Mody wrote:
> On Saturday, July 30, 2016 at 8:17:19 PM UTC+5:30, Steven D'Aprano wrote:



> > On Sat, 30 Jul 2016 09:39 pm, Rustom Mody wrote:
> > > Its a function… ok.
> > > Its ‘just’ a function… Arguable
> > 
> > "Granny Weatherwax, you are a natural-born disputant."
> > "I ain't!"
> 
> Heh I really aint :D
> At least not for this dispute — its not my baby
> Or rather its a stepbaby of stepbaby
> 
> Diff between
> print "x"
> and
> print("x")
> is one char — the closing ‘)’
> 
> To make a dispute about that — I’ll leave to BartC!
> 
> The more general baby that is significant is that beginners should have
> it easy to distinguish procedure and function and python does not naturally 
> aid that.  print was something procedure-ish in python2 but the general 
> notion being
> absent is a much more significant problem (for beginners) than print.
> 
> Brings me to the even more general baby



> But I studied in the 80s and there was greater clarity (about some matters
> of course) than now.
> eg It was completely natural that in ‘school’ one studied 
> ‘nice’ things like Pascal, Lisp, Prolog, Snobol, APL etc
> And in a professional context used ‘real’ things like 
> Fortran, Cobol, PL-1 and a little later C.
> 
> Once omnibus languages like C++, Java, C# and Python became popular
> the academic vs real-world division has disappeared.
> So beginners start with these ‘real-world’
> And get their brains scrambled
> And think it wonderful
> 
> Ok Python is better than Java is better than C++
> But it cannot stand up to scheme as a teaching language
> [The MIT Profs who replaced scheme by python admit to as much viz.



> MIT on practical reasons for python over scheme:
> https://www.wisdomandwonder.com/link/2110/why-mit-switched-from-scheme-to-python
> Berkeley on fundamental reasons for the opposite choice:
> https://people.eecs.berkeley.edu/~bh/proglang.html


So I was talking of 3 very different levels:

1. print x vs print(x)
— a difference too petty for me to waste my time with

2. Procedure vs Function as something very necessary for beginner
thinking-ontology which Pascal gets right

3. The fact that the gap between a mainly-for-teaching language and a serious
software-engineering-real-world language is not closable
And that saying that the same language could be used for both purposes is
like arguing that both these delightful ladies are pianists:


Martha: https://www.youtube.com/watch?v=YLZLp6AcAi4
Rose : https://www.youtube.com/watch?v=_bjKDJD-CLc


Scheme and Pascal happen to be two well-known well-crafted but quite different
for-teaching languages
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 3 on Windows

2016-08-02 Thread Uri Even-Chen
I don't understand. How do I use the Python Launcher? I didn't find such an
option when installing Python 3. http://screencast.com/t/mBXfyMw4jpa
http://screencast.com/t/FidjuB68aJ5G


*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: [email protected]
Website: http://www.speedysoftware.com/uri/en/
  
    

On Tue, Aug 2, 2016 at 3:21 PM, Edward Diener 
wrote:

> On 8/2/2016 8:11 AM, Uri Even-Chen wrote:
>
>> Hi,
>>
>> I want to install Python 3 on Windows, but I also need Python 2 for Google
>> App Engine SDK. When I type a name of a Python file in command line, I
>> want
>> it to run with Python 3. However, I checked with "print 3/5" and it
>> printed
>> 0 - Python 2. I have the latest versions of Python installed
>> - python-2.7.12.msi and python-3.5.2.exe
>>
>> python --version
>>>
>> Python 2.7.12
>>
>> assoc .py
>>>
>> .py=Python.File
>>
>> ftype Python.File
>>>
>> Python.File="C:\Python27\python.exe" "%1" %*
>>
>> By the way, it there a way to print the Python version from Python?
>>
>
> Use the Python Launcher for Windows.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why not allow empty code blocks?

2016-08-02 Thread Rustom Mody
> I think the real reason is not willing to admit that the language lacks
> something that could actually be useful, and especially not to an
> upstart on usenet who is not even an expert in that language.

And earlier you said:

> But dedicated forms (even if they just map to 'while' or 'for') wouldn't
> hurt. Syntax is free after all, and it's about expressing exactly what
> you mean.

You are in effect repeating yourself
What you are saying would be true if syntax were free — or even cheap

However a case may be made that syntax is one of the most wastefully expensive 
hobby with which computer scientists waste their time

First some…

Turing-completeness or Church-Turing thesis says that all languages are the 
same —
identical power. And yet in the last ½ century of computers there is as chaotic 
a babel
of computer languages as there is of natural languages in the last 5000 years 
of human
history.

IOW that L₁ and L₂ are same in power means that the difference is entirely in 
syntax

Of course we need to understand syntax as
- super-superficial — lexical
- superficial — CFG grammar — what is normally called ‘syntax’
- deeper but still static aspects eg type structure

More at http://blog.languager.org/2015/04/poverty-universality-structure-0.html
[Heh! I see it is related to another thread of yours!]


Ok lets agree we need both C (like) and Python (like) languages
because they serve very different purposes.

But do we really need Python and Perl and Ruby and Tcl and Pike and …?
Or bash and zsh and ksh and powershell and …?

Now lets try to quantify the cost of this bedlam

gcc is 15 million lines of code. How much is that in man-years?
I guess somewhere between 100 and 1000

But that’s just the compiler

One needs a development environment.
Java folks tend towards eclipse
C# towards Visual Studio

Evidently eclipse is nearly 50 million lines of code(!!)
https://dzone.com/articles/eclipse-indigo-released

One may expect VS to be of comparable order.

And as the ide-divide points out, choosing a fancy language implies choosing an 
underpowered IDE
And vice-versa:
http://blog.osteele.com/posts/2004/11/ides/

This is exactly the cost I am talking about:
If people did not spend their time inventing newer and newer
languages — especially when that is just fiddling with syntax —
the IDEs and other necessary tooling that is needed for practical
usage would have the chance to develop

So to amplify Steven’s
> No offense intended Bart, but for all we know every single one of your
> benchmarks are faked, your interpreters are buggy pieces of garbage, and for
> all your self-promotion

If your language(s) gain enough traction as to contribute something beyond the 
language — Great! All power to you!

But if its just one more (misshapen) brick in the babel of
computer languages then you are an anti-social element, of course
not on a big scale like a terrorist¹ but let us say of the scale
of someone who litters public spaces


¹ Stupid word! Those who use it should also be considered anti-social
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 3 on Windows

2016-08-02 Thread Uri Even-Chen
I have the launcher installed and I configured it with a C:\Windows\py.ini
file to run Python 3 when typing "py". But when I type the file name it
runs Python 2.

>py
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

>python --version
Python 2.7.12

>assoc .py
.py=Python.File

>ftype Python.File
Python.File="C:\Python27\python.exe" "%1" %*

How do I associate .py files with the launcher?

I read this
http://stackoverflow.com/questions/5087831/how-should-i-set-default-python-version

*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: [email protected]
Website: http://www.speedysoftware.com/uri/en/
  
    

On Tue, Aug 2, 2016 at 3:44 PM, Uri Even-Chen  wrote:

> I don't understand. How do I use the Python Launcher? I didn't find such
> an option when installing Python 3. http://screencast.com/t/mBXfyMw4jpa
> http://screencast.com/t/FidjuB68aJ5G
>
>
> *Uri Even-Chen*
> [image: photo] Phone: +972-54-3995700
> Email: [email protected]
> Website: http://www.speedysoftware.com/uri/en/
> 
> 
>   
>
> On Tue, Aug 2, 2016 at 3:21 PM, Edward Diener  > wrote:
>
>> On 8/2/2016 8:11 AM, Uri Even-Chen wrote:
>>
>>> Hi,
>>>
>>> I want to install Python 3 on Windows, but I also need Python 2 for
>>> Google
>>> App Engine SDK. When I type a name of a Python file in command line, I
>>> want
>>> it to run with Python 3. However, I checked with "print 3/5" and it
>>> printed
>>> 0 - Python 2. I have the latest versions of Python installed
>>> - python-2.7.12.msi and python-3.5.2.exe
>>>
>>> python --version

>>> Python 2.7.12
>>>
>>> assoc .py

>>> .py=Python.File
>>>
>>> ftype Python.File

>>> Python.File="C:\Python27\python.exe" "%1" %*
>>>
>>> By the way, it there a way to print the Python version from Python?
>>>
>>
>> Use the Python Launcher for Windows.
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 3 on Windows

2016-08-02 Thread eryk sun
On Tue, Aug 2, 2016 at 12:11 PM, Uri Even-Chen  wrote:
>
> I want to install Python 3 on Windows, but I also need Python 2 for Google
> App Engine SDK. When I type a name of a Python file in command line, I want
> it to run with Python 3. However, I checked with "print 3/5" and it printed
> 0 - Python 2. I have the latest versions of Python installed
> - python-2.7.12.msi and python-3.5.2.exe
>
>>python --version
> Python 2.7.12
>
>>assoc .py
> .py=Python.File
>
>>ftype Python.File
> Python.File="C:\Python27\python.exe" "%1" %*

Open the control panel's "Programs and Features". Look for the most
recently installed "Python Launcher"; right-click it and select
"Repair". That should fix the Python.File and Python.NoConFile
commands. If these commands aren't your current choice in Explorer,
open Default Programs->Set Associations. Change the association for
.py and .pyw to "Python". If there are multiple "Python" entries in
the list, the icon of the correct one should have a rocket (a
launcher) in the upper left-hand corner.

The launcher handles shebangs and even accepts common Unix paths such
as /usr/bin, e.g.:

Latest 2.x:  #! /usr/bin/python
Latest 3.x:  #! /usr/bin/python3

Without a shebang the launcher currently defaults to Python 2 if it's
installed. To always use Python 3 as the default, set the environment
variable `PY_PYTHON=3`.

> By the way, i[s] there a way to print the Python version from Python?

sys.version is the version string. sys.version_info is a named
sequence of version information:

>>> sys.version_info
sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0)
>>> sys.version_info[:]
(2, 7, 12, 'final', 0)

>>> sys.version_info
sys.version_info(major=3, minor=5, micro=2, releaselevel='final', serial=0)
>>> sys.version_info[:]
(3, 5, 2, 'final', 0)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 3 on Windows

2016-08-02 Thread Uri Even-Chen
Thank you, repair worked! I already have py.ini and don't want to add
shebangs, I have at least 50 Python files and I don't want to edit all of
them.


*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: [email protected]
Website: http://www.speedysoftware.com/uri/en/
  
    

On Tue, Aug 2, 2016 at 4:50 PM, eryk sun  wrote:

> On Tue, Aug 2, 2016 at 12:11 PM, Uri Even-Chen  wrote:
> >
> > I want to install Python 3 on Windows, but I also need Python 2 for
> Google
> > App Engine SDK. When I type a name of a Python file in command line, I
> want
> > it to run with Python 3. However, I checked with "print 3/5" and it
> printed
> > 0 - Python 2. I have the latest versions of Python installed
> > - python-2.7.12.msi and python-3.5.2.exe
> >
> >>python --version
> > Python 2.7.12
> >
> >>assoc .py
> > .py=Python.File
> >
> >>ftype Python.File
> > Python.File="C:\Python27\python.exe" "%1" %*
>
> Open the control panel's "Programs and Features". Look for the most
> recently installed "Python Launcher"; right-click it and select
> "Repair". That should fix the Python.File and Python.NoConFile
> commands. If these commands aren't your current choice in Explorer,
> open Default Programs->Set Associations. Change the association for
> .py and .pyw to "Python". If there are multiple "Python" entries in
> the list, the icon of the correct one should have a rocket (a
> launcher) in the upper left-hand corner.
>
> The launcher handles shebangs and even accepts common Unix paths such
> as /usr/bin, e.g.:
>
> Latest 2.x:  #! /usr/bin/python
> Latest 3.x:  #! /usr/bin/python3
>
> Without a shebang the launcher currently defaults to Python 2 if it's
> installed. To always use Python 3 as the default, set the environment
> variable `PY_PYTHON=3`.
>
> > By the way, i[s] there a way to print the Python version from Python?
>
> sys.version is the version string. sys.version_info is a named
> sequence of version information:
>
> >>> sys.version_info
> sys.version_info(major=2, minor=7, micro=12, releaselevel='final',
> serial=0)
> >>> sys.version_info[:]
> (2, 7, 12, 'final', 0)
>
> >>> sys.version_info
> sys.version_info(major=3, minor=5, micro=2, releaselevel='final',
> serial=0)
> >>> sys.version_info[:]
> (3, 5, 2, 'final', 0)
>
-- 
https://mail.python.org/mailman/listinfo/python-list


gmane sending

2016-08-02 Thread Robin Becker
I just got a mail bounce from my normal gmane --> nntp setup sending to 
[email protected]. Have others seen this and does it mean the end 
of gmane has happened? See

https://developers.slashdot.org/story/16/07/28/2059249/the-end-of-gmane
--
Robin Becker
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread Chris Angelico
On Tue, Aug 2, 2016 at 9:05 PM, BartC  wrote:
> I think the real reason is not willing to admit that the language lacks
> something that could actually be useful, and especially not to an upstart on
> usenet who is not even an expert in that language.

I know what features I miss from the languages I use most frequently.
Here, let me help you out a bit with some examples:

Python
- Support for live code reloads without restarting the process
- A more free-form declarative syntax for laying out GUI code
- Arbitrary-precision non-integers
- Convenient syntax for a few array/list manipulations
- Truly concurrent threads
- Extreme short-hand for executing external commands, the way REXX does

Pike
- Keyword arguments
- "obj in collection" syntax for membership testing
- Better documentation in places
- Out-of-the-box GTK support on OSX
- As with Python, external command execution shorthand

Notice that I did not put "Bracey syntax" under Python, nor "Braceless
syntax" under Pike, despite them not having those options. Notice also
that I didn't put "simpler loop syntax" in either; Python's loops you
know about, and Pike gives you the C-style "for (int i=0; i<10; ++i)"
form and "foreach (collection, item)" like Python's "for item in
collection". The only thing I might yearn for - *MIGHT* - would be for
Python to gain an "index-and-value" iteration form like Pike's
"foreach (collection; index; value)", which for dictionaries would be
like iterating over .items(), and for lists would be like using
enumerate(). But I've never actually found myself yearning for it
while I'm writing Python code - it's a small convenience when I'm
working in Pike, is all.

Does Python "lack" the simple repeat statement? Well, in the sense
that it doesn't have it, sure. But Python also doesn't have a single
function to read a line from a gzipped file and strip HTML tags from
it before returning it [1]. Not everything that doesn't exist is
needed.

ChrisA

[1] http://php.net/manual/en/function.gzgetss.php
-- 
https://mail.python.org/mailman/listinfo/python-list


make an object read only

2016-08-02 Thread Robin Becker
A reportlab user found he was doing the wrong thing by calling canvas.save 
repeatedly, our documentation says you should not use Canvas objects after the 
save method has been used. The user had mixed results :(

It would be better to make the canvas object completely immutable all the way 
down when save has been called, but I think that's quite hard as these objects 
have quite a large and varied set of attributes, lists other objects 
dictionaries etc etc.

I can think of some strategies for making the object unusable eg changing it's 
class and getting rid of __dict__, but that disallows referencing valid 
properties eg pagesize, fontName, etc etc.

Is there a way to recursively turn everything immutable?
-- 
Robin Becker
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: holding if/else condition in live bitcoin trading Python

2016-08-02 Thread Steven D'Aprano
On Tue, 2 Aug 2016 07:14 pm, Arshpreet Singh wrote:

> is there any approach I can go with so auto_order_buy() auto_order_sell()
> function only executed once?

Take them out of the while loop.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: make an object read only

2016-08-02 Thread [email protected]
On Tuesday, 2 August 2016 16:13:01 UTC+1, Robin Becker  wrote:
> A reportlab user found he was doing the wrong thing by calling canvas.save 
> repeatedly, our documentation says you should not use Canvas objects after 
> the 
> save method has been used. The user had mixed results :(
> 
> It would be better to make the canvas object completely immutable all the way 
> down when save has been called, ..
> 
> Is there a way to recursively turn everything immutable?
> -- 
> Robin Becker

Years ago I contributed a recipe to the O'Reilly Python Cookbook, 2nd Ed - 6.12 
Checking an Instance for any State Changes. My original submission was rather 
more naive than that but Alex Martelli, one of the editors, rather took a fancy 
to the idea and knocked into the more presentable shape that got published. I'm 
wondering whether there would be any way of turning this idea around to achieve 
what you want.
--
Regards
David Hughes
Forestfield Software
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: make an object read only

2016-08-02 Thread Steven D'Aprano
On Wed, 3 Aug 2016 01:12 am, Robin Becker wrote:

> A reportlab user found he was doing the wrong thing by calling canvas.save
> repeatedly, our documentation says you should not use Canvas objects after
> the save method has been used. The user had mixed results :( 
> 
> It would be better to make the canvas object completely immutable all the
> way down when save has been called, but I think that's quite hard as these
> objects have quite a large and varied set of attributes, lists other
> objects dictionaries etc etc.

If save() is the only problematic method, that's easy to fix:

class X:
def _bad_save(self):
raise RuntimeError("I told you not to call save() more than once!")

def save(self):
# do the actual saving
# then replace the method:
self.save = self._bad_save


Hmmm... clever as that is, it's probably not clever enough, as users can
still call the unbound save method:

X.save(instance)

So back to the really old-fashioned way:

class X:
def __init__(self):
self._saved = False

def save(self):
if self._saved:
raise RuntimeError("*wack with clue stick*")
else:
# do the actual saving
self._saved = True


> I can think of some strategies for making the object unusable eg changing
> it's class and getting rid of __dict__, but that disallows referencing
> valid properties eg pagesize, fontName, etc etc.

It shouldn't disallow anything.

class X:
 # implementation of everything, properties, etc.
 # as they are expected to work before saving

 def save(self):
 # do the actual save
 self.__class__ = SavedX


class SavedX(X):
# Override just the bits that need neutering
# including save

def save(self):
raise RuntimeError("stop that!")



The tricky bit may be preventing writes to the instance __dict__. I don't
think it is practical to allow the user to add arbitrary attributes to the
instance up to the point they call save(), then prevent them from doing the
same. You might be able to get it to work, but with difficulty.

Better to fix save() so you can call it multiple times without breaking the
instance. If you can't do that, the least-worst alternative would be to use
__slots__ for both X and SavedX so that the user can't add new attributes
at all.

But really, the right way to do this is to fix the class so that save() can
be called multiple times. In your editor, does selecting Save twice corrupt
the file you're working on?


> Is there a way to recursively turn everything immutable?

First you have to come up with a way to turn everything immutable. (Good
luck with that.) Then apply it recursively to the object and all its
attributes.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


problem installinf python

2016-08-02 Thread abreed1
   Hi. I'm having trouble installing Python on my computer.  My computer is a 
64-bit Dell desktop running Windows 8.1. 
   A screen message claimed that I installed Python 3.5.2 (64 bit), but when I 
try to run it, I get only the "Modify 
Setup" screen, with the only choices being "Modify," "Repair," or "Uninstall." 
I have run the "Repair" option, but that does not change anything. Can anyone 
help me install Python? 
   Alex 

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


Re: Why not allow empty code blocks?

2016-08-02 Thread BartC

On 02/08/2016 14:28, Rustom Mody wrote:

I think the real reason is not willing to admit that the language lacks
something that could actually be useful, and especially not to an
upstart on usenet who is not even an expert in that language.



However a case may be made that syntax is one of the most wastefully expensive
hobby with which computer scientists waste their time

First some…

Turing-completeness or Church-Turing thesis says that all languages are the 
same —
identical power. And yet in the last ½ century of computers there is as chaotic 
a babel
of computer languages as there is of natural languages in the last 5000 years 
of human
history.


Who's talking about creating a new language? I was discussing tweaking 
an existing one.



Ok lets agree we need both C (like) and Python (like) languages
because they serve very different purposes.

But do we really need Python and Perl and Ruby and Tcl and Pike and …?
Or bash and zsh and ksh and powershell and …?


You really want my opinion? For my own use, I could use 2 or 3 languages 
at different levels:


1 C-like
2 Intermediate
3 Python-like
4 Scripting

(I have my own versions of 1 and 2, but not of 3.)

Other people will have different lists, and with different languages. 
C++ is quite popular (but so complex that it is unusable IMO). Others 
might like the discipline of Ada. A few might like to code in Haskell.


Or it might need a small footprint. Or work on certain platforms. Or 
needs to be fast.. So there are diverse requirements.


But I agree we don't need thousands of languages, each inventing 
different syntax too. Perhaps someone can just invent or choose syntax 
styles A, B and C and a language can adopt one of those (this is the 
approach I use actually).



Now lets try to quantify the cost of this bedlam

gcc is 15 million lines of code. How much is that in man-years?
I guess somewhere between 100 and 1000



But that’s just the compiler


Well, it also supports lots of targets, which accounts for some of the 
size. But gcc would still be huge.



One needs a development environment.
Java folks tend towards eclipse
C# towards Visual Studio

Evidently eclipse is nearly 50 million lines of code(!!)


OK. 50 million lines. Keep that in mind.


https://dzone.com/articles/eclipse-indigo-released

One may expect VS to be of comparable order.


I heard that VS comprises 1.5 million *files*. And a full compile takes 
60 *hours*.


So the shift has been from evolving languages to horrendously large and 
complex development *tools*.


(And I expect that next they will eliminate languages altogether. All 
you need is some way of specifying a sequence of calls to library 
functions and sprinkling around some control statements; it could be 
drag-and-drop with a GUI display of the program flow.)


I don't have any interest in that. 1.5M files or 50M lines for a tool 
cannot possibly be right. And I believe in using a traditional language 
with textual syntax and not being overly dependent on extraneous tools 
so massive that they completely the language they are supposed to work with.



And as the ide-divide points out, choosing a fancy language implies choosing an 
underpowered IDE
And vice-versa:
http://blog.osteele.com/posts/2004/11/ides/

This is exactly the cost I am talking about:
If people did not spend their time inventing newer and newer
languages — especially when that is just fiddling with syntax —
the IDEs and other necessary tooling that is needed for practical
usage would have the chance to develop


Your figures suggest the opposite! So people spend time creating huge 
bloated IDEs instead of writing 100 lines of a parser so that other 
people can avoid writing 'for i in range(N):' millions of times instead 
of 'for N:' or 'repeat N:'.



So to amplify Steven’s

No offense intended Bart, but for all we know every single one of your
benchmarks are faked, your interpreters are buggy pieces of garbage, and for
all your self-promotion


If your language(s) gain enough traction as to contribute something beyond the
language — Great! All power to you!

But if its just one more (misshapen) brick in the babel of
computer languages then you are an anti-social element,


Anti-social, yes. When I was doing most of my stuff in 80s, my 'brick' 
was the only one. It didn't need to fit to anything else!


However such a brick can still be tremendously useful in the 2010s, just 
like a bicycle can be in city traffic. It's small, manageable, 
understandable, and can go anywhere.


And it can be very nippy. (Very nippy indeed. If I say how long it takes 
me to build my compiler from scratch - for my C replacement language - 
no one would believe me.)


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


Re: problem installinf python

2016-08-02 Thread Stephane Wirtel

And if you uninstall it and reinstall it after ?

On 08/02, [email protected] wrote:

  Hi. I'm having trouble installing Python on my computer.  My computer is a 
64-bit Dell desktop running Windows 8.1.
  A screen message claimed that I installed Python 3.5.2 (64 bit), but when I try to 
run it, I get only the "Modify
Setup" screen, with the only choices being "Modify," "Repair," or "Uninstall." I have run 
the "Repair" option, but that does not change anything. Can anyone help me install Python?
  Alex

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


--
Stéphane Wirtel - http://wirtel.be - @matrixise
--
https://mail.python.org/mailman/listinfo/python-list


Re: Recursive csv import functions for Pandas

2016-08-02 Thread MRAB

On 2016-08-02 10:50, [email protected] wrote:

I have put together the following code:


[snip]

while csvnameR[12:18] == csvnameT[12:18]:
print csvR + "=" + csvT

r.to_csv('./output_csv/'+ csvR +'.csv')

hdh = r.sub(t,axis=0).dropna()
hdh[hdh['temp']<=1] = 0
csvHDH = csvnameT[12:18]
hdh_week = 
hdh.temp.resample('W-MON').sum().round(decimals=0)
hdh_week.to_csv('./output_csv/HDH/' + csvHDH + 
'_HDH.csv')

The sequence of action should be:
for A08_KI
 - import A08_KI_T1,T2,...Tn, merge them into A08_KI_T and resample them by the 
hour (room temp.)
 - import A08_KI_R1,R2,...Rn, merge them into A08_KI_R and resample them by the 
hour (radiator temp.)
 - every time XX_XX_R = XX_XX_T (i.e. A08_KI_T and A08_KI_R, or A10_LR_T and 
A10_LR_R) calculate HDH = R - T.

The code I developed has something wrong and the command:

while csvnameR[12:18] == csvnameT[12:18]:
seems to cause the loop to go on for ever.

Look at the body of that loop. Nowhere in it do you change the value of 
'csvnameR' or 'csvnameT', so if the condition was true initially, it'll 
still be true the next time round, and forever more.

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


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread BartC

On 02/08/2016 15:58, Chris Angelico wrote:

On Tue, Aug 2, 2016 at 9:05 PM, BartC  wrote:

I think the real reason is not willing to admit that the language lacks
something that could actually be useful, and especially not to an upstart on
usenet who is not even an expert in that language.


I know what features I miss from the languages I use most frequently.
Here, let me help you out a bit with some examples:

Python
- Support for live code reloads without restarting the process


If that means what I think it means (ie. effectively re-doing an import 
statement) then I agree.


I think I used a similar feature in the past, but with limitations (the 
module had one only entry point accessible from the code that imports it).


It was used for developing much of an application not only without 
restarting it, but from inside the application (effectively using it as 
an IDE). Very, very useful.



that I didn't put "simpler loop syntax" in either; Python's loops you
know about, and Pike gives you the C-style "for (int i=0; i<10; ++i)"


You've just hit on another bugbear of mine. I detest that form of loop!


Does Python "lack" the simple repeat statement? Well, in the sense
that it doesn't have it, sure. But Python also doesn't have a single
function to read a line from a gzipped file and strip HTML tags from
it before returning it [1]. Not everything that doesn't exist is
needed.


That's not a fundamental language feature. Repeat-N is. And if properly 
designed, isn't an extra feature at all but a special case of a generic 
loop.


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


Re: problem installinf python

2016-08-02 Thread MRAB

On 2016-08-02 17:41, [email protected] wrote:

   Hi. I'm having trouble installing Python on my computer.  My computer is a 
64-bit Dell desktop running Windows 8.1.
   A screen message claimed that I installed Python 3.5.2 (64 bit), but when I try 
to run it, I get only the "Modify
Setup" screen, with the only choices being "Modify," "Repair," or "Uninstall." I have run 
the "Repair" option, but that does not change anything. Can anyone help me install Python?
   Alex


It sounds to me like you're trying to run the installer again.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Why not allow empty code blocks?

2016-08-02 Thread Steven D'Aprano
On Tue, 2 Aug 2016 11:28 pm, Rustom Mody wrote:

>> I think the real reason is not willing to admit that the language lacks
>> something that could actually be useful, and especially not to an
>> upstart on usenet who is not even an expert in that language.
> 
> And earlier you said:
> 
>> But dedicated forms (even if they just map to 'while' or 'for') wouldn't
>> hurt. Syntax is free after all, and it's about expressing exactly what
>> you mean.
> 
> You are in effect repeating yourself
> What you are saying would be true if syntax were free — or even cheap
> 
> However a case may be made that syntax is one of the most wastefully
> expensive hobby with which computer scientists waste their time
> 
> First some…
> 
> Turing-completeness or Church-Turing thesis says that all languages are
> the same — identical power. 

That depends on how you define the power of a language.

Earlier, you wrote:

"Ok Python is better than Java is better than C++
But it cannot stand up to scheme as a teaching language"

So you are aware that languages are *not* the same. Languages have more or
less "power", where power is defined (rather fuzzily) as the expressiveness
of the language, how easy it is for the programmer to read, write and
maintain code, how efficient/fast you can implement it, etc. The power of a
language is rather subjective, but we all surely acknowledge that adding
new features to a language can make it more powerful:

- Python 1.5 is less powerful than Python 3.5;

- Fortran 77 is less powerful than Fortran 95.

We acknowledge that languages can differ in power too:

- 1970s BASIC is less powerful than C;

- COBOL is less powerful than Scheme.

Google for the Blub Paradox, by Paul Graham, for more information.

So language are not all the same, and can differ in power.

So what does the Church-Turing thesis say? It doesn't say anything about
language power in the above sense. Language power is a rather subjective,
fuzzy, non-linear measure, which is why language flame wars will never end.

What the C-T thesis talks about is *computability*. *What* can you compute,
not necessarily how easy it is to compute it. And there is a hierarchy of
language "power" in this sense.

(A Turing Machine can do anything that Conway's Game Of Life can do, but is
easier to program; assembly language is easier still, and Javascript even
more so.)

A good discussion of the Church-Turing thesis can be found in Chapter 13 of
Hofstadter's "Gödel, Escher, Bach". He introduces three languages that
differ in computing power in the computability sense: Bloop, Floop and
Gloop.

- Bloop can perform calculations that predictably terminate; that is, it 
  can do any calculation which can be performed by a primitive recursive
  function;

- Floop can perform calculations that have no upper bounds to the number
  of steps needed; that is, it can perform *unbounded* potentially
  non-terminating loops; another way of saying this is that terminating
  Floop programs are general recursive, and non-terminating Floop
  programs are partial recursive;

- Gloop can perform calculations which never terminate in Floop, and
  do so in a finite number of steps.

In simple terms, Bloop has for-loops; Floop has while-loops; and Gloop,
well, Gloop is magical and probably doesn't exist. "Gloop is a myth" is one
way of putting the Church-Turing Thesis.

Hofstadter gives three equivalent ways to state the C-T Thesis:

(1) What is human-computable is machine-computable;
(2) What is machine-computable is Floop-computable;
(3) What is human-computable is Floop-computable (i.e., general or 
partial recursive).

Most interesting and useful languages are equivalent to Floop, but there are
languages (potential, if not actual) which are equivalent only to Bloop.
Pure regular expressions, for example, are not Turing Complete: they can
only perform calculations which are primitive recursive.

The Halting Problem is easily solved for Bloop languages: they always halt.


> And yet in the last ½ century of computers 
> there is as chaotic a babel of computer languages as there is of natural
> languages in the last 5000 years of human history.

I think that human languages have been *far* more complicated. The history
of English *alone* is probably as complex and chaotic as that of
programming languages. My guess is that once you go down to the level of
regional dialects, there are more variants of English alone than
programming languages have existed. In some sense, virtually every village
and hamlet in Great Britain has had its own version of English (and
sometimes not even mutually comprehensible).


> IOW that L₁ and L₂ are same in power means that the difference is entirely
> in syntax

But as we've seen, syntax can make a HUGE difference to power in the sense
of expressiveness, maintainability of code, readability, efficiency of the
programmer, and even efficiency of the interpreter. Conway's Game of Life
is Turing Complete. Would you rather use Python, or Game

Re: Why not allow empty code blocks?

2016-08-02 Thread Steven D'Aprano
On Wed, 3 Aug 2016 02:56 am, BartC wrote:

> (And I expect that next they will eliminate languages altogether. All
> you need is some way of specifying a sequence of calls to library
> functions and sprinkling around some control statements; 

That would be called "a language".

> it could be 
> drag-and-drop with a GUI display of the program flow.)

It could be, but won't be. Outside of a very few tiny niches, including
Squeak which is designed for children, such user-interfaces are far too
cumbersome to ever get widespread use.

But for limited niches, like generating GUIs, form designers, or even
assembling regular expressions, sure, why not?




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread Steven D'Aprano
On Wed, 3 Aug 2016 03:12 am, BartC wrote:

> That's not a fundamental language feature. Repeat-N is. And if properly
> designed, isn't an extra feature at all but a special case of a generic
> loop.

Which means it is NOT a fundamental language feature.

"Repeat N without tracking the loop variable" is just a special case
of "repeat N with tracking the loop variable", where you don't actually
care what the loop variable is.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Tcl/Tk for Python 3.6.0a3 on Os X 10.9.5

2016-08-02 Thread Terry Reedy

On 8/2/2016 4:21 AM, [email protected] wrote:


I am new to the programming world but I need to learn this program
for a research class that I am taking. I have downloaded Python
3.6.0a3 on a Mac 10.9.5 and realized that I also need to download an
Active Tcl for it. I can't find one for this version. Can someone
please direct me to it? The most recent one I've been able to find is
for Python 3.5.2


This page https://www.python.org/download/mac/tcltk/
does not yet mention 3.6.  So I would start with the recommendation for 
3.5.2: tcl/tk 8.5.18.


I believe Ned Deily hopes to switch to tcl/tk 8.6.x before 3.6.0 is 
released.  If 8.5.18 does not work, I would try 8.6.whatever.  But I 
don't believe the switch has been made yet.


--
Terry Jan Reedy

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


Re: Why not allow empty code blocks?

2016-08-02 Thread Chris Angelico
On Wed, Aug 3, 2016 at 3:54 AM, Steven D'Aprano
 wrote:
> On Wed, 3 Aug 2016 02:56 am, BartC wrote:
>
>> (And I expect that next they will eliminate languages altogether. All
>> you need is some way of specifying a sequence of calls to library
>> functions and sprinkling around some control statements;
>
> That would be called "a language".

:)

>> it could be
>> drag-and-drop with a GUI display of the program flow.)
>
> It could be, but won't be. Outside of a very few tiny niches, including
> Squeak which is designed for children, such user-interfaces are far too
> cumbersome to ever get widespread use.
>
> But for limited niches, like generating GUIs, form designers, or even
> assembling regular expressions, sure, why not?

They do exist, and IMO they're languages just as much as textual ones
are. You don't eliminate computer language by switching to a GUI
drag-and-drop system than you eliminate human language by using hand
signs. In fact, deaf people generally communicate using something
called "{American,Korean,Australian,...} Sign Language" - it's not
called "American Way of Talking Without Talking Or Using Language".

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


Re: gmane sending

2016-08-02 Thread Terry Reedy

On 8/2/2016 10:42 AM, Robin Becker wrote:

I just got a mail bounce from my normal gmane --> nntp setup sending to 
[email protected]. Have others seen this and does it mean the end of 
gmane has happened? See


I am reading and sending via gmane right now.


https://developers.slashdot.org/story/16/07/28/2059249/the-end-of-gmane


I really hope not.

--
Terry Jan Reedy

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


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread BartC

On 02/08/2016 18:57, Steven D'Aprano wrote:

On Wed, 3 Aug 2016 03:12 am, BartC wrote:


That's not a fundamental language feature. Repeat-N is. And if properly
designed, isn't an extra feature at all but a special case of a generic
loop.


Which means it is NOT a fundamental language feature.

"Repeat N without tracking the loop variable" is just a special case
of "repeat N with tracking the loop variable", where you don't actually
care what the loop variable is.


It's fundamental in that, when giving instructions or commands in 
English, it frequently comes up when you want something done a set 
number of times:


"Give me 20 push-ups"

"Press space 5 times"

"Do 10 laps"

Whoever has to execute these may need to keep count somehow, but that is 
not the concern of the person giving the commands.


You wouldn't say, count from 1 to 20, and for each value in turn, do a 
push-up. You could also say count backwards from 95 to 0 in fives; same 
effect. There are so many ways of specifying a loop that is executed 20 
times, that no one way can be the right one. So that extra information 
is irrelevant.


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


Re: Why not allow empty code blocks?

2016-08-02 Thread BartC

On 02/08/2016 18:54, Steven D'Aprano wrote:

On Wed, 3 Aug 2016 02:56 am, BartC wrote:


(And I expect that next they will eliminate languages altogether. All
you need is some way of specifying a sequence of calls to library
functions and sprinkling around some control statements;


That would be called "a language".


No, it wouldn't be given its own identity. And it probably couldn't be 
used without that specific tool. It would be more like a file format, if 
the details are even exposed when the format is proprietary.


A traditional language exists as text and can be stored as plain text.

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


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread Chris Angelico
On Wed, Aug 3, 2016 at 3:57 AM, Steven D'Aprano
 wrote:
> On Wed, 3 Aug 2016 03:12 am, BartC wrote:
>
>> That's not a fundamental language feature. Repeat-N is. And if properly
>> designed, isn't an extra feature at all but a special case of a generic
>> loop.
>
> Which means it is NOT a fundamental language feature.
>
> "Repeat N without tracking the loop variable" is just a special case
> of "repeat N with tracking the loop variable", where you don't actually
> care what the loop variable is.

To be fair, that can be an important distinction. I don't like seeing
code like this:

def f():
x = g()
y = h(x)
return 5 + x

What's y for? Why not just call h(x) and ignore its return value?
Should the last line say "5 + y"? It looks _wrong_ to have a local
variable that's never used. It's still not a consideration strong
enough to demand new loop syntax, though.

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


Re: Why not allow empty code blocks?

2016-08-02 Thread Paul Rubin
Steven D'Aprano  writes:
> where power is defined (rather fuzzily) as the expressiveness
> of the language, how easy it is for the programmer to read, write and
> maintain code, how efficient/fast you can implement it, etc.

Scheme guru Matthias Felleisen takes a stab at a precise definition here
(though it's pointy-headed theory that I don't understand that well):

  http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.51.4656

> The Halting Problem is easily solved for Bloop languages: they always
> halt.

If Bloop is powerful enough to "solve the halting problem" as you
describe, that gives it capabilities that Turing-complete languages
lack.  (Of course it also loses some capabilities).  Some of the
advantages of Turing-incomplete languages (plus why they are less
constraining than it might sound) are discussed here:

   http://www.jucs.org/doi?doi=10.3217/jucs-010-07-0751

> But as we've seen, syntax can make a HUGE difference to power in the
> sense of expressiveness, maintainability of code, readability,
> efficiency of the programmer, and even efficiency of the
> interpreter. Conway's Game of Life is Turing Complete. Would you
> rather use Python, or Game of Life? BrainF*ck or Javascript?

That's completely different than Python vs Scheme, where you can
basically transliterate Python to Scheme by converting indentation
structure into parentheses and a few other things like that.
Felleisen's paper (linked above) has a deeper take on what
expressiveness really means.  I've programmed lots of Python and a fair
amount of Lisp, and Lisp's parentheses really aren't that big a deal.
Python is more pleasant than Lisp for me these days, mostly because its
built-in datatypes and the standard libraries are a better match for
today's programming than Lisp, which is somewhat stuck in the 1980s.

Clojure (a new Lisp dialect with modern capabilities, currently only on
the JVM) may be the way forward for Lisp, parentheses and all.

> you are convinced that Python would be a better language if it
> supported more mathematical notation with Unicode operators.

Haskell and Agda both support this.  It isn't used much in Haskell but
Agda users actually use it, and the Emacs editing mode for Agda has
special stuff to make it easier.  It's probably more useful in Agda
since Agda programs deal more with actual mathematical proofs.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why not allow empty code blocks?

2016-08-02 Thread Grant Edwards
On 2016-08-02, BartC  wrote:
> On 02/08/2016 18:54, Steven D'Aprano wrote:
>> On Wed, 3 Aug 2016 02:56 am, BartC wrote:
>>
>>> (And I expect that next they will eliminate languages altogether. All
>>> you need is some way of specifying a sequence of calls to library
>>> functions and sprinkling around some control statements;
>>
>> That would be called "a language".
>
> No, it wouldn't be given its own identity.

Sure it would.  How else could you talk about it or differentiate it
from something else?

> And it probably couldn't be used without that specific tool.

You mean like a compiler or interpreter?

> It would be more like a file format,

So you'd have to define a combination of syntax and semantics where
you specify what elements are allowed in what order/context and what
they mean in various combinations?

It turns out there's a English word for that.

It's called a "language".

> if the details are even exposed when the format is proprietary.
>
> A traditional language exists as text and can be stored as plain
> text.

Many languages are plain text.  Some aren't.

-- 
Grant Edwards   grant.b.edwardsYow! If elected, Zippy
  at   pledges to each and every
  gmail.comAmerican a 55-year-old
   houseboy ...

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


Re: Why not allow empty code blocks?

2016-08-02 Thread Julien Salort
Steven D'Aprano  wrote:

> It could be, but won't be. Outside of a very few tiny niches, including
> Squeak which is designed for children, such user-interfaces are far too
> cumbersome to ever get widespread use.

Unfortunately, many people use LabView in my field... even for
sufficiently complex programs for it to become totally unreadable.

-- 
Julien Salort
Entia non sunt multiplicanda praeter necessitatem
http://www.juliensalort.org
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread Christian Gollwitzer

Am 02.08.16 um 16:58 schrieb Chris Angelico:

- A more free-form declarative syntax for laying out GUI code


Actually, the Tkinter wrapper misses one feature of grid in Tcl/Tk: You 
can write something like


grid .a .b
grid .c .d

to lay out a GUI 2x2 grid using "ASCII-art". There is a package in Tcl, 
gridplus2 (http://www.satisoft.com/tcltk/gridplus2/example1.html) which 
allows the design of quite complex screens from such ASCII-art - a 
Python translation should not be that difficult (but nobody does it)



- Arbitrary-precision non-integers


https://pypi.python.org/pypi/bigfloat/

?


- Convenient syntax for a few array/list manipulations


Huh? Slices and list comprehensions go a long way. What syntax can you 
imagine that goes beyond that?


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


Re: Tcl/Tk for Python 3.6.0a3 on Os X 10.9.5

2016-08-02 Thread Ned Deily
On 2016-08-02 15:08, Terry Reedy wrote:
> On 8/2/2016 4:21 AM, [email protected] wrote:
>> I am new to the programming world but I need to learn this program
>> for a research class that I am taking. I have downloaded Python
>> 3.6.0a3 on a Mac 10.9.5 and realized that I also need to download an
>> Active Tcl for it. I can't find one for this version. Can someone
>> please direct me to it? The most recent one I've been able to find is
>> for Python 3.5.2
> This page https://www.python.org/download/mac/tcltk/
> does not yet mention 3.6.  So I would start with the recommendation for
> 3.5.2: tcl/tk 8.5.18.

Yes, sorry, I don't usually update that page for pre-releases.

The information you need is also included in the python.org OS X
installer Read Me file which is displayed during the installation
process.  (A copy of it is also preserved at "/Applications/Python
3.6/ReadMe.rtf".).  In the section "Update your version of Tcl/Tk to use
IDLE or other Tk applications":

"For the initial alpha releases of Python 3.6, the installer is linked
with Tcl/Tk 8.5; this will change prior to the beta releases of 3.6.0."

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


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread Chris Angelico
On Wed, Aug 3, 2016 at 5:55 AM, Christian Gollwitzer  wrote:
>> - Arbitrary-precision non-integers
>
>
> https://pypi.python.org/pypi/bigfloat/
>
> ?

Wasn't aware of that. Cool. Not that I need it very often (and when I
do, I can use Pike, which has MPFR support built-in). Or I can use
decimal.Decimal, which isn't exactly the same, but often accomplishes
the same thing.

>> - Convenient syntax for a few array/list manipulations
>
>
> Huh? Slices and list comprehensions go a long way. What syntax can you
> imagine that goes beyond that?

Imagine you have a list (or array, depending on language) of objects,
some of which may be None (or null). Call the foo method on every
object, ignoring the null/None ones.

# Python - creates a useless list
[obj.foo() for obj in objects if obj]
# Python - a bit clunky
for obj in objects:
if obj:
obj.foo()

//Pike
objects->foo();

But my point wasn't "hey, Python sucks", but "look what is *not* on my
list". Other people's lists of stuff they miss will differ (either
because they know of third-party solutions, like bigfloat, or because
they just don't need them... like bigfloat), and that's fine and
correct.

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


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread Terry Reedy

On 8/2/2016 7:05 AM, BartC wrote:

On 31/07/2016 19:58, Terry Reedy wrote:

On 7/31/2016 6:18 AM, BartC wrote:



 repeat N:



The benefit is not so much performance, but being able to express
something very easily and quickly.


The cost of the 'repeat' contraction is that one cannot use the loop
variable, either as part of a modified computation or for monitoring or
debugging purposes.
   print(i, for_body_result)
Beginners are often atrocious at debugging, and it seems not to be
taught hardly at all.  'repeat n' erects a barrier to debugging.



Debugging: probing a computation to see what actually happens, as
opposed to what one wanted and expected to happen.  (Me, just now ;-)

One major way of debugging is printing values as they are computed.
Naming values (objects) allows them to be printed without recomputing
the value.  In the 'repeat n' context, recomputing would mean adding 3
lines of debugging code instead of 1.

i = 0
repeat n:
   a = f(a)
   print(i, a)
   n += 1


Your objection to a feature such as 'repeat N' doesn't really stack up.


My objection is that there is a real cost that MUST be stacked up 
against the benefit.


...

Anyway, if that was a valid objection, it would apply throughout the
language. In list-comps for example (there is an index, but where do you
stick the print?).


In the expression.  Given 'f(i) for i in range(n)', a careful debug 
version might be '(f(i), print(i))[0] for i in range(n)'.  If the loop 
does not finish, the extra None component does not matter.  and the 
subscripting could be omitted.



Or in a for-loop iterating over values:

 a=[10,20,30,40,50]
 for x in a:
print (x)

This will print the element, but what's the index?


Irrelevant.  The end of the sequence of prints says where the loop stopped.

> According to you,

every such for-loop needs to be written in a form that provides the
index of a loop


Don't pretend that I said that.  It is not nice.


I get that people here don't want such a feature, but I don't think this
is the reason.

I think the real reason is not willing to admit that the language lacks
something that could actually be useful,


I think it is you who is unwilling to admit that nearly everything that 
would be useful also has a cost, and that the ultimate cost of adding 
every useful feature, especially syntax features, would be to make 
python less unusable.


Some time around last August to October, I think, someone posted to 
python-ideas that he had produced a children's Python environment that 
accepted 'repeat n' statements and translated them to equivalent for 
loops before running.  His idea was that 'repeat n' should be added to 
python itself so translation would not be needed.  The main use of the 
statement in this context is for logo/turtle code with many 
side-effect-only calls.


I though the idea plausible, at first, and noted that one could add an 
extension to IDLE to experiment further with the idea.  An extension 
could add a menu ited such as 'de-repeat'.  One could also, with about 
the same effort, *patch* IDLE to do the translation just before it calls 
compile(code, ...).


Leaving IDLE aside, one could write a pyre.whatever script to translate 
a .pyre file to a .py file and run the latter.  Any of these methods 
could be applied to experimenting with other 'improvement' ideas.


Anyway, *after thinking about the idea for at least a week*, I became 
less enthusiastic about hiding the loop counter.


--
Terry Jan Reedy

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


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread Paul Rubin
Terry Reedy  writes:
> I think it is you who is unwilling to admit that nearly everything
> that would be useful also has a cost, and that the ultimate cost of
> adding every useful feature, especially syntax features, would be to
> make python less unusable.

I think you meant "usable" ;).  Some of this results from Python's
statement-vs-expression distinction.  I'm not going to claim that's a
broken feature of Python, since it has its supporters; but languages
that don't make the distinction have more flexibility in implementing
such features as ordinary functions rather than syntax features.

Ruby:  17.times| code |
Haskell: replicateM_ 17 code
Lisp: (dotimes (i 17) code...)
etc.

The Lisp example binds 'i' to the loop index, but that's just a choice
made in how the dotimes macro was implemented.  The scope of i is
limited to the dotimes construct, unlike in Python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ctypes Usage Note

2016-08-02 Thread Nobody
On Mon, 01 Aug 2016 18:41:53 -0700, Lawrence D’Oliveiro wrote:

> Sometimes people load a library with ctypes like this:
> 
> libc = ctypes.cdll.LoadLibrary("libc.so")

That specific example is unlikely to work on any modern Linux system, as
libc.so is typically a linker script rather than a symlink to a DSO.
Likewise for libm and libpthread.

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


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread BartC

On 02/08/2016 22:27, Terry Reedy wrote:

On 8/2/2016 7:05 AM, BartC wrote:



Your objection to a feature such as 'repeat N' doesn't really stack up.


My objection is that there is a real cost that MUST be stacked up
against the benefit.

...

Anyway, if that was a valid objection, it would apply throughout the
language. In list-comps for example (there is an index, but where do you
stick the print?).


In the expression.  Given 'f(i) for i in range(n)', a careful debug
version might be '(f(i), print(i))[0] for i in range(n)'.  If the loop
does not finish, the extra None component does not matter.  and the
subscripting could be omitted.


That's quite a big edit to the original code. I would duplicate the 
line, comment out the original, and add the print code to the copy. Then 
I can revert to the original without bugs creeping in. (Unless the rest 
of the line has to change anyway.)


Same method is used with repeats:

   for N:# or whatever syntax is used

If a loop index /has/ to be printed, comment out the above and extend a 
copy of it to:


   for i in range(N):

But only /if/ that value is needed; most won't. (I suspect that loops 
repeated a set number of times might be simpler anyway.)



Or in a for-loop iterating over values:

 a=[10,20,30,40,50]
 for x in a:
print (x)

This will print the element, but what's the index?


Irrelevant.  The end of the sequence of prints says where the loop stopped.


But it might go wrong before it gets to the end. You need the index to 
know how far along the list it's at.



I think the real reason is not willing to admit that the language lacks
something that could actually be useful,


I think it is you who is unwilling to admit that nearly everything that
would be useful also has a cost, and that the ultimate cost of adding
every useful feature, especially syntax features, would be to make
python less unusable.


[Did you mean 'less usable' here?]

I'm only concerned here with basic syntax. And most ideas already exist 
in other languages (not just mine). But here's one I idea I think I 
mentioned last year: having separators in numeric literals.


Now I look and see that PEP 515 describes it! (I think some versions of 
Python will already have it).


Do people think that makes Python top-heavy in features and less usable?

I *know* that actually implementing most of this stuff is trivial 
because I've done it a dozen times. And I appreciate that doing it in a 
very large, existing 'live' language with millions of users has 
administrative problems.


But the technical side of it is nothing compared to the 50Mloc tools 
that have been mentioned.




Some time around last August to October, I think, someone posted to
python-ideas that he had produced a children's Python environment that
accepted 'repeat n' statements and translated them to equivalent for
loops before running.  His idea was that 'repeat n' should be added to
python itself so translation would not be needed.  The main use of the
statement in this context is for logo/turtle code with many
side-effect-only calls.


Apparently 'repeat N' is a Logo statement so it makes sense to try and 
emulate that within Python (to simplify porting Logo algorithms for 
example).



Leaving IDLE aside, one could write a pyre.whatever script to translate
a .pyre file to a .py file and run the latter.  Any of these methods
could be applied to experimenting with other 'improvement' ideas.


Yes, I've experimented with that approach myself. Using a 
source-to-source translator with Python as output. But the input was an 
entirely different syntax (example: http://pastebin.com/Zj89YfTN).


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


Re: gmane sending

2016-08-02 Thread Ben Finney
Terry Reedy  writes:

> I am reading and sending via gmane right now.
>
> > https://developers.slashdot.org/story/16/07/28/2059249/the-end-of-gmane
>
> I really hope not.

I also hope not. Hope doesn't fund important infrastructure like Gmane,
though; and Lars clearly needs help if Gmane is to thrive
https://lwn.net/Articles/695695/>.

The signs are troubling: http://gmane.org/donate.php> has been
timing out since that news :-(

-- 
 \“Human reason is snatching everything to itself, leaving |
  `\   nothing for faith.” —Bernard of Clairvaux, 1090–1153 CE |
_o__)  |
Ben Finney

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


ANN: datatest 0.7.0 (Test driven data wrangling)

2016-08-02 Thread Shawn Brown
datatest 0.7.0 (Test driven data wrangling)
===

Datatest extends the standard library's unittest package to
provide testing tools for asserting data correctness.

 * Docs: http://datatest.readthedocs.io/
 * PyPI: https://pypi.python.org/pypi/datatest/

This release includes:

 * Removes internal magic and renames data assertions to more
   clearly indicate their intended use.
 * Restructures data allowances to provide more consistent
   parameters and more flexible usage.
 * Adds new method to assert unique values.
 * Adds full **fmtparams support for CSV handling.
 * Fixes comparison and allowance behavior for None vs. zero.

Update installs with:

  pip install -U datatest

Backward Compatibility: Existing code that relies on the 0.6.0 (dev1) API
is supported with the following addition to the beginning of each script:

from datatest.__past__ import api_dev1
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread Steven D'Aprano
On Wednesday 03 August 2016 05:14, BartC wrote:

> It's fundamental in that, when giving instructions or commands in
> English, it frequently comes up when you want something done a set
> number of times:
> 
> "Give me 20 push-ups"

At which point the person will invariable drop to the ground and start counting

one...two.thrreee.foooufiive...

Counting is more fundamental than addition. You cannot do 20 push-ups without 
in some sense counting.


> "Press space 5 times"
> 
> "Do 10 laps"
> 
> Whoever has to execute these may need to keep count somehow,
> but that is not the concern of the person giving the commands.

Perhaps not. I don't doubt that there are times where you don't care about the 
loop variable. Fine, you don't care.

There are times that I perform an operation which might fail, and I don't care 
if it fails. I have to still catch the exception. There's no dedicated syntax 
to "run this and ignore exceptions", you just use the general purpose 
try...except syntax.

try:
this()
except Exception:
pass

rather than:

this()   # may raise
$this()  # won't raise

Not everything that is done is worth the cognitive burden of memorising a 
special case.


> You wouldn't say, count from 1 to 20, and for each value in turn, do a
> push-up. You could also say count backwards from 95 to 0 in fives; same
> effect. There are so many ways of specifying a loop that is executed 20
> times, that no one way can be the right one. So that extra information
> is irrelevant.

Sure. That's why we have idioms like `for i in range(20)`, rather than have 
people consider `for i in [None]*20` or `range(53, 114, 3)`. Even if we had a 
dedicated `repeat 20` syntax, it would still be merely a convention that you 
use it rather than `for i in range(53, 114, 3)`.

In some ways, Python is a more minimalist language than you like. That's okay, 
you're allowed to disagree with some design decisions. I personally think that 
new f-strings-that-aren't-actually-strings-but-more-like-eval-in-disguise are a 
terrible idea, and I think that some of the rejected ideas were good ones. 
That's part of the reason why we have so many different languages: people can 
disagree on what things should be features.



-- 
Steve

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