Re: sobering observation, python vs. perl

2016-03-20 Thread Charles T. Smith
On Thu, 17 Mar 2016 19:08:58 +0200, Marko Rauhamaa wrote:

> "Charles T. Smith" :
> 

> 
> Compare Perl (http://www.perlmonks.org/?node_id=98357>):
> 
>my $str = "I have a dream";
>my $find = "have";
>my $replace = "had";
>$find = quotemeta $find; # escape regex metachars if present
>$str =~ s/$find/$replace/g;
>print $str;
> 
> with Python:
> 
>print("I have a dream".replace("have", "had"))
> 
> 
> Marko

Uh... that perl is way over my head.  I admit though, that perl's
powerful substitute command is also clumsy.  The best I can do
right now is:

$v =  "I have a dream\n";
$v =~ s/have/had/;
print $v

One of the ugliest things about perl are the "silly" type
prefixes ($, @, %).  But in a python project I'm doing now,
I realized an important advantage that they bring...

I want to be able to initialize msgs to communicate with
C.  Ideally, I'd to just specify the path to an equivalent
python instance but all intermediate instances have to
already exist - python does not have autovivication.
I implemented it but only up until the leaf node - because
python doesn't know their types.  Perl can do that, because the
prefix tells it the type.

But, don't get me wrong, coding in python is a JOY!
-- 
https://mail.python.org/mailman/listinfo/python-list


from a module return a class

2016-03-20 Thread kevind0718
Hello:

Working with python 2.7.

I have a module promptUser_PWord  that will prompt a user for their user name 
and pword.  Works fine stand alone.
I also have a module, genXLS that does a bunch of processing it has worked fine 
for months.  And a class Unamepword define as follows:
class Unamepword:
## 
## class to hold user name and pWord for Database
uName = None
pWord = None
def __init__(self, uStr, pStr):
self.uName = uStr
self.pWord = pStr

There are scenarios where running genXLS requires the user to be prompted for 
their user name and password.

The final line of promptUser_PWord are:
user_pword =  Unamepword(dbUser, pWord)
return user_pword


And in genXLS I have  
##  prompt the user for a User name a& pWord
user_pword = promptUser_PWord()   

I get the error 
  File "H:\dev\eclipse\workspace\genXls\src\genXls\promptUser_PWord.py", line 58
return user_pword
SyntaxError: 'return' outside function


Here is my complete newbee question:
   How do I stich these pieces together so the user will be prompted and the 
values (contained in the class Unamepword) will be passed back to genXLS ?

Many thanks for your attention to this matter.

KD



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


Re: TSP in python ; this is code to solve tsp whenever called, where given coordinates as in name of pos and then start coordinate as in start, help me how it works ?

2016-03-20 Thread Qurrat ul Ainy
help required !!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Case Statements

2016-03-20 Thread Antoon Pardon
Op 16-03-16 om 18:24 schreef Mark Lawrence:
> On 16/03/2016 15:27, Antoon Pardon wrote:
>> Op 16-03-16 om 15:02 schreef Mark Lawrence:
>>> On 16/03/2016 13:38, Antoon Pardon wrote:
 Op 16-03-16 om 12:07 schreef Mark Lawrence:
>
> Raise the item on the python-ideas mailing list for the umpteenth time
> then, and see how far you get.

 I don't care enough. I do care about people using valid arguments.

>>>
>>> Arguments have been made for and against.  When the PEPs were rejected
>>> are you saying that the arguments for acceptance were actually
>>> stronger than the arguments for rejection?
>>>
>> No, I was just saying that your argument: "We've done without for 25
>> years" is invalid, because that would imply python should no longer make
>> any progress. Because any progress that will be made now, we've done
>> without for 25 years. -- Antoon
>>
> 
> So putting something into the language that we don't actually need is 
> progress?  Hum, in my book that's just plain weird.

It can be yes. Look at decorators. They don't provide functionality
we wouldn't have without them. So we don't actually need them. Do
you argue that introducing them wasn't progress?

-- 
Antoon Pardon.

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


Re: How to waste computer memory?

2016-03-20 Thread Marko Rauhamaa
Steven D'Aprano :

> On Sun, 20 Mar 2016 03:12 am, Marko Rauhamaa wrote:
>> Steven D'Aprano :
>>> On Sun, 20 Mar 2016 02:02 am, Marko Rauhamaa wrote:
 Yes, but UTF-16 produces 16-bit values that are outside Unicode.
>>>
>>> Show me.
>>>
>>> Before you answer, if your answer is "surrogate pairs", that is
>>> incorrect. Surrogate pairs is how UTF-16 encodes astral characters.
>> 
>> UTF-16 inputs a Unicode stream and produces a stream of 16-bit numbers.
>> Thus, the output of UTF-16 is not Unicode.
>
> [...]
>
> If your point is that the data you get from running UTF-16 on a
> sequence of code points is "not Unicode, but 2-byte words", then I
> agree, but I'm not sure why you think that's significant.

I say the surrogate characters are not Unicode. You say they are because
they are used to encode astral characters. I say that point is
irrelevant.

I'm saying the surrogate characters are not Unicode because you are not
allowed to store or communicate them. They are a hole in the Unicode
fabric.

They could have—probably should have—specified a UTF-16 encoding for the
surrogate characters as well. That would have left the Unicode range
uninterrupted. Well, the silver lining is that Python gained a number of
extra code points it was free to use for special purposes, although to
be faithful to Unicode, Python should refuse to store them.


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


Re: Case Statements

2016-03-20 Thread Rustom Mody
On Wednesday, March 16, 2016 at 5:51:21 PM UTC+5:30, Marko Rauhamaa wrote:
> BartC :
> 
> > On 16/03/2016 11:07, Mark Lawrence wrote:
> >> but I still very much doubt we'll be adding a switch statement --
> >> it's a "sexy" language design issue
> >
> > That's the first time I've heard a language feature common in C
> > described as sexy.
> 
> Scheme has a "switch" statement (a "case" form). However, it is slightly
> better equipped for it than Python:
> 
>  * Scheme has an atom type ("symbol"). It corresponds to interned
>strings and is supposed to be compared by reference.
> 
>  * Scheme has defined three equality operators: "eq?", "eqv?" and
>"equal?". Python only has two: "is" (~ "eq?") and "==" (~ "equal?").
>The "case" form makes use of the operator "eqv?" that is missing from
>Python ("eqv?" compares numbers numerically but is otherwise the same
>as "eq?").
> 
> 
> Marko

I think it needs to be mentioned:
Almost every modern functional language has pattern matching
And pattern matching is really case statements on steroids

https://www.vex.net/~trebla/haskell/crossroad.xhtml

>From those of us who regularly use functional programming, its important
to say that the things that get big press -- lambdas, monads etc -- are probably
less significant than things like pattern matching that dont

A smattering of languages that support it:

Erlang: http://erlang.org/doc/reference_manual/functions.html
Scala: 
https://kerflyn.wordpress.com/2011/02/14/playing-with-scalas-pattern-matching/
SML: http://www.cs.cornell.edu/courses/cs312/2004fa/lectures/lecture3.htm
Clojure : https://github.com/clojure/core.match

Scheme is an odd case: Does not have it builtin but writing a macro for that is 
an entertaining exercise
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to waste computer memory?

2016-03-20 Thread Steven D'Aprano
On Fri, 18 Mar 2016 10:46 pm, Steven D'Aprano wrote:

> I think it is typical of JMF that his idea of a language where Unicode
> "just works" is one where it *does work at all* (at least not as strings).

Er, does NOT work at all.

> Python 1.5 strings supported Unicode just as well as Go's string class.

Since I'm replying to myself, I guess I can take the opportunity to expand
on this. Go's concept of strings is, more or less, byte strings:

https://blog.golang.org/strings

They are handled as an array of bytes and indexing produces bytes. That's
exactly the same functionality as Python strings provided in version 1.5.
In fairness, Go does provide a second type, "runes", which is equivalent to
Python 2.7 unicode using a wide build (i.e. equivalent to UTF-32).




-- 
Steven

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


Re: How to waste computer memory?

2016-03-20 Thread Paul Rubin
Chris Angelico  writes:
> You can pretend that only 1 and 0 are enough. Good luck making THAT work.

YOU had ONES???  Back in the day, my folks had to do everything with
just zeros.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to waste computer memory?

2016-03-20 Thread Mark Lawrence

On 17/03/2016 21:26, BartC wrote:

On 17/03/2016 21:11, Marko Rauhamaa wrote:

Chris Angelico :


Like every language *including* English. You can pretend that ASCII is
enough, but you do lose some information.


Hold it, I'll quickly update my résumé before we resume the
conversation. What does this exposé expose? At least it gives a coup de
grâce to ASCII with grace.


'ANSI' (Windows code page 1252), will do most of what ASCII doesn't, as
far as western Europe (and the US, Canada, Australia and probably the
rest of the Americas) is concerned. Including euro and pound (€,£)
currency symbols.

ANSI could have been equivalent to the first 256 Unicode code points,
rather than just 128, if Unicode hadn't squandered codes 128 to 159 on
even more control codes, when it's difficult to see a use for most of
the 32 that ASCII already reserves.



Why would you care?  I swear blind that you stated a few days back that 
you, and hence your newly published language, couldn't care about 
unicode.  Have I got it wrong?


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: from a module return a class

2016-03-20 Thread kevind0718
On Thursday, March 17, 2016 at 12:19:39 PM UTC-4, [email protected] wrote:
> Hello:
> 
> Working with python 2.7.
> 
> I have a module promptUser_PWord  that will prompt a user for their user name 
> and pword.  Works fine stand alone.
> I also have a module, genXLS that does a bunch of processing it has worked 
> fine for months.  And a class Unamepword define as follows:
> class Unamepword:
> ## 
> ## class to hold user name and pWord for Database
> uName = None
> pWord = None
> def __init__(self, uStr, pStr):
> self.uName = uStr
> self.pWord = pStr
> 
> There are scenarios where running genXLS requires the user to be prompted for 
> their user name and password.
> 
> The final line of promptUser_PWord are:
> user_pword =  Unamepword(dbUser, pWord)
> return user_pword
> 
> 
> And in genXLS I have  
> ##  prompt the user for a User name a& pWord
> user_pword = promptUser_PWord()   
> 
> I get the error 
>   File "H:\dev\eclipse\workspace\genXls\src\genXls\promptUser_PWord.py", line 
> 58
> return user_pword
> SyntaxError: 'return' outside function
> 
> 
> Here is my complete newbee question:
>How do I stich these pieces together so the user will be prompted and the 
> values (contained in the class Unamepword) will be passed back to genXLS ?
> 
> Many thanks for your attention to this matter.
> 
> KD



As requested , full code for promptUser_PWord

import base64
import os

import _winreg
import winerror

from cryptography.fernet import Fernet
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from Tkinter import *

from unamepword import Unamepword

def butContinue():
global dbUser 
global pWord
global pwKey 
dbUser = entryName.get()
pWord  = entryPWord.get()
root1.quit()


dbUser = ""
pWord  = ""
root1 = Tk()
##root1.geometry("500x250")


lblTop = Label(root1, text=  'Please enter Database User Name & Password   ', 
font="Helvetica 14").grid(row=0, column=0, columnspan=3 , pady=5)
lblDB =Label(root1,text= 'User Name').grid(row=2, column=0 )
lblPWord = Label(root1, text= 'Password').grid(row=3,column=0)

entryName = Entry(root1)
entryName.grid(row=2, column=1, pady=5)

entryPWord = Entry(root1)
entryPWord.grid(row=3, column=1, pady = 5)

butGo  =  Button(root1, text="   Continue "  , command=butContinue 
).grid(row=5, column=1, sticky=W, pady=10)

root1.mainloop()

print "After the MainLoop"
print  dbUser
print  pWord


if dbUser is None or pWord is None  or  dbUser.strip() == ""   or  
pWord.strip() ==  ""  :
print "** ** ** ** ** ** ** ** ** **  ** **  ** ** ** ** ** ** ** ** ** **  
** **"
print "**  Missing a value CANNOT continue  ** ** ** "
print "**  Bye "
##  sys.exit()

user_pword =  Unamepword(dbUser, pWord)

return user_pword

   
 









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


Re: Case Statements

2016-03-20 Thread Mark Lawrence

On 20/03/2016 08:01, Rustom Mody wrote:

On Wednesday, March 16, 2016 at 5:51:21 PM UTC+5:30, Marko Rauhamaa wrote:

BartC :


On 16/03/2016 11:07, Mark Lawrence wrote:

but I still very much doubt we'll be adding a switch statement --
it's a "sexy" language design issue




I did *NOT* write the above, that was me quoting the BDFL from 
https://mail.python.org/pipermail/python-ideas/2014-April/027667.html.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: TSP in python ; this is code to solve tsp whenever called, where given coordinates as in name of pos and then start coordinate as in start, help me how it works ?

2016-03-20 Thread Mark Lawrence

On 18/03/2016 17:04, Qurrat ul Ainy wrote:

help required !!!



For what, house cleaning?

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: WP-A: A New URL Shortener

2016-03-20 Thread Daniel Wilcox
>
>
> +list
>>
>>
> You will be far more welcome here if you intersperse your replies or
> bottom post.  Top posting is very heavily frowned upon.  Thanks.


noted.

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


Re: Is this an error in python-babel or am I missing something?

2016-03-20 Thread cl
[email protected] wrote:
> I am getting the following error when running some code that uses
> python-sqlkit.  This uses python-babel to handle dates for different
> locales.
> 
> Traceback (most recent call last):
> File 
> "/usr/local/lib/python2.7/dist-packages/sqlkit-0.9.6.1-py2.7.egg/sqlkit/widgets/table/columns.py",
>  
> 
 
> line 169, in cell_data_func_cb formatted_value = 
> self.field.format_value(value) 
> 
> File 
> "/usr/local/lib/python2.7/dist-packages/sqlkit-0.9.6.1-py2.7.egg/sqlkit/fields.py",
>  
> line 1114, in format_value return dates.format_date(value, format=format 
> or self.format, locale=self.locale) 
> File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 569, in 
> format_date 
> return pattern.apply(date, locale) 
> File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 892, in apply 
> return self % DateTimeFormat(datetime, locale) 
> File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 889, in __mod__ 
> return self.format % other 
> File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 948, in 
> __getitem__ 
> return self.format_milliseconds_in_day(num) 
> File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 1029, in 
> format_milliseconds_in_day 
> self.value.minute * 6 + self.value.hour * 360 
> AttributeError: 'datetime.date' object has no attribute 'microsecond'
> 
> I'm handling a date in my sqlite database, *not* a datetime.  The
> sqlkit code seems to be calling the correct method - format_date() -
> in the python-babel dates.py file.
> 
> However it seems that python-babel ends up trying to hand the date
> down to a method that's expecting a datetime.
> 
> I've tried searching for reports of this error but I can't see any
> which makes me wonder if it's not a bug in python-babel, however if
> it's not a bug then I'm confused about what has gone wrong.
> 
> Is it a bug or is sqlkit doing something wrong?
> 
Well, it's a sort of bug.  I had made the sqlkit code set the 'format'
field to something that it shouldn't be.  It should be "full", "long",
"medium", or "short".  Due to my misunderstanding I had set it to a
completely wrong value.  This makes python-babel fall over as above.

So, my mistake, but python-babel should have caught it.

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bash-like pipes in Python

2016-03-20 Thread Random832
On Wed, Mar 16, 2016, at 11:20, Random832 wrote:
> How about:
> 
> from functools import partial, reduce
> from operator import mul
> def rcall(arg, func): return func(arg)
> def fpipe(*args): return reduce(rcall, args)

It occurs to me that this suggests a further refinement: have all
functions (and classes? map and filter seem to be classes.) define
__ror__ as calling the left-hand operand. Then this could be written as
"abcd12345xyz" | pfilter(str.isdigit) | pmap(int) | preduce(mul).

You could also define, say, __mul__ as partial application, so you could
write "abcd12345xyz" | filter*str.isdigit | map*int | reduce*mul.

> pfilter = partial(partial, filter)
> pmap = partial(partial, map)
> preduce = partial(partial, reduce)
> 
> fpipe("abcd12345xyz", pfilter(str.isdigit), pmap(int), preduce(mul))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to waste computer memory?

2016-03-20 Thread Steven D'Aprano
On Sun, 20 Mar 2016 05:20 pm, Rustom Mody wrote:

> On Sunday, March 20, 2016 at 10:32:07 AM UTC+5:30, Steven D'Aprano wrote:
>> On Sun, 20 Mar 2016 03:12 am, Marko Rauhamaa wrote:
>> 
>> > Steven D'Aprano :
>> > 
>> >> On Sun, 20 Mar 2016 02:02 am, Marko Rauhamaa wrote:
>> >>> Yes, but UTF-16 produces 16-bit values that are outside Unicode.
>> >>
>> >> Show me.
>> >>
>> >> Before you answer, if your answer is "surrogate pairs", that is
>> >> incorrect. Surrogate pairs is how UTF-16 encodes astral characters.
>> > 
>> > UTF-16 inputs a Unicode stream and produces a stream of 16-bit numbers.
>> > Thus, the output of UTF-16 is not Unicode.
>> 
>> I'm not sure what point you think you are making.
>> 
>> Unicode (the character set part of it) is a set of abstract 23-bit
>> numbers,
> 
> 23? Or 21?

Oops, you're right, its 21 bits.


> More pertinently if the number of bits signifies, whatever is the sense of
> the word 'abstract'?

The Unicode standard does not, as far as I am aware, care how you represent
code points in memory, only that there are 0x11 of them, numbered from
U+ to U+10. That's what I mean by abstract. The obvious
implementation is to use 32-bit integers, where 0x represents code
point U+, 0x0001 represents U+0001, and so forth. This is
essentially equivalent to UTF-16, but it's not mandated or specified by the
Unicode standard, you could, if you choose, use something else.

On the other hand, I believe that the output of the UTF transformations is
explicitly described in terms of 8-bit bytes and 16- or 32-bit words. For
instance, the UTF-8 encoding of "A" has to be a single byte with value 0x41
(decimal 65). It isn't that this is the most obvious implementation, its
that it can't be anything else and still be UTF-8.



-- 
Steven

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


Re: sobering observation, python vs. perl

2016-03-20 Thread Charles T. Smith
On Thu, 17 Mar 2016 15:29:47 +, Charles T. Smith wrote:

And for completeness, and also surprising:

time sed -n -e '/ is ready/{s///;h}' -e '/release_req/{g;p}'  *.out | sort -u
TestCase_F_00_P
TestCase_F_00_S
TestCase_F_01_S
TestCase_F_02_M

real0m10.998s
user0m10.885s
sys 0m0.108s

Twice as long as perl...  I guess there's no excuse for sed anymore...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to waste computer memory?

2016-03-20 Thread Marko Rauhamaa
Chris Angelico :

> Like every language *including* English. You can pretend that ASCII is
> enough, but you do lose some information.

Hold it, I'll quickly update my résumé before we resume the
conversation. What does this exposé expose? At least it gives a coup de
grâce to ASCII with grace.


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


Re: How to waste computer memory?

2016-03-20 Thread Chris Angelico
On Sun, Mar 20, 2016 at 10:06 PM, Steven D'Aprano  wrote:
> The Unicode standard does not, as far as I am aware, care how you represent
> code points in memory, only that there are 0x11 of them, numbered from
> U+ to U+10. That's what I mean by abstract. The obvious
> implementation is to use 32-bit integers, where 0x represents code
> point U+, 0x0001 represents U+0001, and so forth. This is
> essentially equivalent to UTF-16, but it's not mandated or specified by the
> Unicode standard, you could, if you choose, use something else.

(UTF-32)

The codepoints are not representable in *memory*; they are, by
definition, representable in a field of integers. If you choose to
represent those integers as little-endian 32-bit values, then yes, the
layout in memory will look like UTF-32LE, but that's because UTF-32LE
is defined in this extremely simple way. In fact, that's exactly how
the layers work - Unicode defines a mapping of characters to code
points, and then UTF-x defines a mapping of code points to bytes.

> On the other hand, I believe that the output of the UTF transformations is
> explicitly described in terms of 8-bit bytes and 16- or 32-bit words. For
> instance, the UTF-8 encoding of "A" has to be a single byte with value 0x41
> (decimal 65). It isn't that this is the most obvious implementation, its
> that it can't be anything else and still be UTF-8.

Exactly. Aside from the way UTF-16 and UTF-32 have LE and BE variants,
there is only one bitpattern for any given character sequence and
UTF-x (so if you work with eg "UTF-16LE", there's only one). This is
no accident. Unlike some encodings, in which there's a "one most
obvious" way to encode things but then a number of other legal ways,
UTF-x can be compared for equality [1] using simple byte-for-byte
comparisons. This means you don't have to worry about someone sneaking
a magic character past your filter; if you're checking a UTF-8 stream
for the character U+003C LESS-THAN SIGN, the only byte value to look
for is 0x3C - the sequence 0xC0 0xBC, despite mathematically
representing the number 003C, is explicitly forbidden.

ChrisA

[1] Though not inequality - lexical sorting doesn't follow codepoint
order, and codepoint order won't always match byte order. But equality
is easy.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to waste computer memory?

2016-03-20 Thread Steven D'Aprano
On Sun, 20 Mar 2016 10:22 pm, Chris Angelico wrote:

> On Sun, Mar 20, 2016 at 10:06 PM, Steven D'Aprano 
> wrote:
>> The Unicode standard does not, as far as I am aware, care how you
>> represent code points in memory, only that there are 0x11 of them,
>> numbered from U+ to U+10. That's what I mean by abstract. The
>> obvious implementation is to use 32-bit integers, where 0x
>> represents code point U+, 0x0001 represents U+0001, and so forth.
>> This is essentially equivalent to UTF-16, but it's not mandated or
>> specified by the Unicode standard, you could, if you choose, use
>> something else.
> 
> (UTF-32)

D'oh!

I mean, yes, well done, you have passed my little test to see if anyone is
paying attention. Have a gold star.


> The codepoints are not representable in *memory*; they are, by
> definition, representable in a field of integers. 

They're not directly representable in memory because the definition of code
points is not given in terms of memory values. Hence, they are abstract
values, numbered in a certain way, and given certain semantics.

In other words, there's nothing in the Unicode standard that says that code
point U+0020 has to be stored as a byte 0x20, or a word 0x0020. But the
standard does say that the code point U+0020 represents a space character.


[...]
>> On the other hand, I believe that the output of the UTF transformations
>> is explicitly described in terms of 8-bit bytes and 16- or 32-bit words.
>> For instance, the UTF-8 encoding of "A" has to be a single byte with
>> value 0x41 (decimal 65). It isn't that this is the most obvious
>> implementation, its that it can't be anything else and still be UTF-8.
> 
> Exactly. Aside from the way UTF-16 and UTF-32 have LE and BE variants,

Blame the chip manufacturers for that. Actually, I think we can blame Intel
specifically for that, for reversing the normal layout of words in memory.



-- 
Steven

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


Re: Error

2016-03-20 Thread Joel Goldstick
On Sun, Mar 20, 2016 at 6:39 AM, Abeer Sohail 
wrote:

> Oh well. Every time I try to open, or reinstall and open Python.exe, it
> shows me this error. Hopefully the error will be in the
>

When you say 'this error', you don't say what the error is. Please don't
attach anything, let alone image files.

What version of python, what operating system.  Where did you get python.
What instructions did you follow

> Joel Goldstick
>> http://joelgoldstick.com/ 
>> http://cc-baseballstats.info/
>>
>
>


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


Re: How to waste computer memory?

2016-03-20 Thread Chris Angelico
On Sun, Mar 20, 2016 at 11:14 PM, Steven D'Aprano  wrote:
>>> On the other hand, I believe that the output of the UTF transformations
>>> is explicitly described in terms of 8-bit bytes and 16- or 32-bit words.
>>> For instance, the UTF-8 encoding of "A" has to be a single byte with
>>> value 0x41 (decimal 65). It isn't that this is the most obvious
>>> implementation, its that it can't be anything else and still be UTF-8.
>>
>> Exactly. Aside from the way UTF-16 and UTF-32 have LE and BE variants,
>
> Blame the chip manufacturers for that. Actually, I think we can blame Intel
> specifically for that, for reversing the normal layout of words in memory.

No, I disagree; it's inherent in the notion of representing a 16-bit
or 32-bit value across bytes. Maybe there could have been one
most-common standard, but there'd still have been another way of doing
it. Little-endianness and big-endianness are important enough to have
to deal with.

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


Re: Bash-like pipes in Python

2016-03-20 Thread Marko Rauhamaa
Steven D'Aprano :

> On Thu, 17 Mar 2016 02:20 am, Random832 wrote:
>> fpipe("abcd12345xyz", pfilter(str.isdigit), pmap(int), preduce(mul))
>
> Intriguing! Thank you for the suggestion.

Still want the pipeline syntax!


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


Re: monkey patching __code__

2016-03-20 Thread Ian Kelly
On Fri, Mar 18, 2016 at 7:47 AM, Ian Kelly  wrote:
> Your patched version takes two extra arguments. Did you add the
> defaults for those to the function's __defaults__ attribute?

And as an afterthought, you'll likely need to replace the function's
__globals__ with your own as well.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Case Statements

2016-03-20 Thread Mark Lawrence

On 16/03/2016 15:27, Antoon Pardon wrote:

Op 16-03-16 om 15:02 schreef Mark Lawrence:

On 16/03/2016 13:38, Antoon Pardon wrote:

Op 16-03-16 om 12:07 schreef Mark Lawrence:


Raise the item on the python-ideas mailing list for the umpteenth time
then, and see how far you get.


I don't care enough. I do care about people using valid arguments.



Arguments have been made for and against.  When the PEPs were rejected
are you saying that the arguments for acceptance were actually
stronger than the arguments for rejection?


No, I was just saying that your argument: "We've done without for 25
years" is invalid, because that would imply python should no longer make
any progress. Because any progress that will be made now, we've done
without for 25 years. -- Antoon



So putting something into the language that we don't actually need is 
progress?  Hum, in my book that's just plain weird.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Python directory

2016-03-20 Thread Terry Reedy

On 3/16/2016 9:01 PM, Xerma Palmares wrote:

Hello,
I have just downloaded Python latest version on to PC running windows 10.
Unfortunately, after the completion of the download the Python icon was not
showing up on the Desktop


The installer does not make desktop icons.

> and could not found the Python files on the Programs folder either.

By default, the installer puts an 'all users' install in 'Programs 
Files'.  A 'me only' install goes in an obscure place in 
/users/me/appdata (hidden directory).  At least for 'all users' install, 
you can change the default.


After installation, a Python x.y entry is put under Start Menu => All 
apps => P.



--
Terry Jan Reedy

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


Re: sobering observation, python vs. perl

2016-03-20 Thread Ethan Furman

On 03/17/2016 09:08 AM, Charles T. Smith wrote:

On Thu, 17 Mar 2016 10:52:30 -0500, Tim Chase wrote:



Not saying this will make a great deal of difference, but these two
items jumped out at me.  I'd even be tempted to just use string
manipulations for the isready aspect as well.  Something like
(untested)


well, I don't want to forgo REs in order to have python's numbers be better


The issue is not avoiding REs, but using Python's strengths and idioms. 
 Write the code in Python's style, get the same results, then compare 
the times.


If you posted the data file and exact results the rest of us could try, 
but as it is all we can do is offer ideas and you have test them.


--
~Ethan~

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


Re: empty clause of for loops

2016-03-20 Thread Ruud de Jong

Peter Otten schreef op 2016-03-16 13:57:

If you don't like exceptions implement (or find) something like

items = peek(items)
if items.has_more():
   # at least one item
   for item in items:
   ...
else:
   # empty

Only if such a function is used a lot or cannot be conceived without 
severe
shortcumings adding to the syntax should be considered. The 
(hypothetical)
question you should answer: which current feature would you throw out 
to

make room for your cool new addition?


No need for hypothetical functions or syntax:

x = sentinal = object()
for x in sequence:
   # handle x
if x is sentinal:
   # sequence was empty.

Disclaimer: not tested because I don't have access to Python from my 
working location.
But it should work according to the language reference, section 8.3 on 
the 'for' statement:
"Names in the target list are not deleted when the loop is finished, but 
if the sequence is empty, they will not have been assigned to at all by 
the loop."


Regards, Ruud

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


Re: sobering observation, python vs. perl

2016-03-20 Thread Charles T. Smith
On Thu, 17 Mar 2016 21:18:43 +0530, srinivas devaki wrote:

> please upload the log file,


Sorry, it's work stuff, can't do that, but just take any big set of files
and change the strings appropriately and the numbers should be equivalent.


> 
> and global variables in python are slow, so just keep all that in a
> function and try again. generally i get 20-30% time improvement by
> doin that.

#!/usr/bin/env python
# vim: tw=0
import sys
import re

def faster ():
isready = re.compile ("(.*) is ready")
relreq = re.compile (".*release_req")
for fn in sys.argv[1:]: # logfile name
tn = None
with open (fn) as fd:
for line in fd:
#match = re.match ("(.*) is ready", line)
match = isready.match (line)
if match:
tn = match.group(1)
continue
#match = re.match (".*release_req", line)
match = relreq.match (line)
if match:
#print "%s: %s" % (tn, line),
print tn

faster()

$ time python ./find-relreq *.out | sort -u
TestCase_F_00_P
TestCase_F_00_S
TestCase_F_01_S
TestCase_F_02_M

real0m25.515s
user0m25.294s
sys 0m0.136s

3 more seconds!

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


Re: Case Statements

2016-03-20 Thread Antoon Pardon
Op 16-03-16 om 12:07 schreef Mark Lawrence:
> On 16/03/2016 10:52, Antoon Pardon wrote:
>> Op 16-03-16 om 10:51 schreef Mark Lawrence:
>>> On 16/03/2016 09:35, Antoon Pardon wrote:
 Op 16-03-16 om 09:47 schreef Mark Lawrence:
>
>>
>> Same with switch. You can use a hash table etc. to simulate
>> switches,
>> but only if the codeblocks are independent. Otherwise, if-elif
>> chains
>> are the way to go. Command line parsing is a case where switch
>> statements are often used, e.g. in shell scripts.
>
> I've seen at least six different ways of simulating switches, so
> those
> people who want them, can have them.  if-elif chains are not
> likely to
> kill any Python programmer.
>
> I have no interest what other languages use switch/case statements
> for, as we've on the PYTHON mailing list.

 There once were multiple ways to simulate a conditional expression.
 And it was generally thought that using if else statements instead
 of a conditional expression was unlikely to kill any Python
 programmer.

 But then one of the core developers was bitten by a nasty bug because
 he was using one of those constructs that simulated a conditional
 expression and soon enough Python had a conditional expression.

 So I guess those who would like a case statement in Python can
 only hope a core developer gets bitten by a nasty bug while using
 one of those ways of simulating switches.

>>>
>>> So that core developers can waste their time putting something into
>>> the language that we've done without for 25 years, yes, that strikes
>>> me as extremely worthwhile.
>>
>> Do you think python should stop progressing? Because all progress
>> python wil make, will be done by putting something in the language
>> we've done without for 25 years.
>>
>> That we have done without doesn't contradict it can be useful to have.
>>
>
> Raise the item on the python-ideas mailing list for the umpteenth time
> then, and see how far you get.

I don't care enough. I do care about people using valid arguments.

-- 
Antoon Pardon


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


Exception from pyd methods

2016-03-20 Thread Palpandi
Hi,

I am using methods from pyd files. At some cases, it is throwing some error 
messages in the console.

When I use try.. except.. I am getting only the exception name.
Not able to catch the entire error message.

How do I get the the entire error message printed in the console?


Thanks,
Palpandi
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to waste computer memory?

2016-03-20 Thread Ben Bacarisse
Rustom Mody  writes:

> On Sunday, March 20, 2016 at 10:32:07 AM UTC+5:30, Steven D'Aprano wrote:

>> Unicode (the character set part of it) is a set of abstract 23-bit numbers,
>
> 23? Or 21?

It's 21.  The reason being (or at least part of the reason being) that
21 bits can be UTF-8 encoded in 4 bytes: 0xxx 10xx 10xx
10xx (3 + 3*6).


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


Re: How to waste computer memory?

2016-03-20 Thread Marko Rauhamaa
Ben Bacarisse :

> It's 21. The reason being (or at least part of the reason being) that
> 21 bits can be UTF-8 encoded in 4 bytes: 0xxx 10xx 10xx
> 10xx (3 + 3*6).

I bet the reason is UTF-16. Microsoft and Sun/Oracle would have insisted
on a maximum of 4 bytes per character. UTF-16 can just barely squeeze 21
bits into the scheme and only at the expense of creating an ugly hole
inside Unicode. Politics, politics.


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


Re: monkey patching __code__

2016-03-20 Thread Sven R. Kunze

On 19.03.2016 00:58, Matt Wheeler wrote:

I know you have a working solution now with updating the code &
defaults of the function, but what about just injecting your function
into the modules that had already imported it after the
monkeypatching?

Seems perhaps cleaner, unless you'd end up having to do it to lots of modules...


Why do you consider it cleaner?

Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to waste computer memory?

2016-03-20 Thread Random832
On Sun, Mar 20, 2016, at 10:55, Ben Bacarisse wrote:
> It's 21.  The reason being (or at least part of the reason being) that
> 21 bits can be UTF-8 encoded in 4 bytes: 0xxx 10xx 10xx
> 10xx (3 + 3*6).

The reason is the UTF-16 limit. Prior to that, UTF-8 had no such limit
(it could encode up to 31 bits, as six bytes), and it doesn't account
for the fact that four bytes can encode up to U+1F rather than
U+10.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fetch Gmail Archieved messages

2016-03-20 Thread Arshpreet Singh
On Saturday, 19 March 2016 05:38:16 UTC+5:30, Rick Johnson  wrote:

> I gave you "real help". 
> 
> What you want me to do -- write the code for you? Sorry, but Python-list is 
> not a soup kitchen for destitute code. Neither is it a triage center were you 
> can bring your sick code, drop it at the door, and say: "Here, fix this, i'm 
> going to the bar".  
> 
> Where is your traceback? 
> 
> Does your code run without raising Errors?
> 
> Why did you create a loop, simply to iterate over a list-literal containing  
> one value?
> 
> At this point, i can't determine if you're trolling or serious...

Thanks "Big boy"! I just asked for help not any kind of malfunction here. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: E-commerce system in Python

2016-03-20 Thread Arshpreet Singh
On Friday, 18 March 2016 21:44:46 UTC+5:30, Chris Warrick  wrote:
 
> asyncio is, as you said, brand new -- probably nothing exists.
> Why not use the existing Django solution though? What is your problem
> with it? It's a great framework that does a lot of the hard work for
> you. Flask is low-level.

Yes Flask is low level so it comes before for me.
-- 
https://mail.python.org/mailman/listinfo/python-list


script exits prematurely with no stderr output, but with system errors

2016-03-20 Thread Larry Martell
I have a script that I run a lot - at least 10 time every day. Usually
it works fine. But sometime it just stops running with nothing output
to stdout or stderr. I've been trying to debug this for a while, and
today I looked in the system logs and saw this:

abrt: detected unhandled Python exception in
'/home/prod_user/python/make_workitem_list.py'
abrtd: Directory 'pyhook-2016-03-19-22:20:43-26461' creation detected
abrt-server[3688]: Saved Python crash dump of pid 26461 to
/var/spool/abrt/pyhook-2016-03-19-22:20:43-26461
abrtd: Executable '/home/prod_user/python/make_workitem_list.py'
doesn't belong to any package and ProcessUnpackaged is set to 'no'
abrtd: 'post-create' on
'/var/spool/abrt/pyhook-2016-03-19-22:20:43-26461' exited with 1
abrtd: Deleting problem directory
'/var/spool/abrt/pyhook-2016-03-19-22:20:43-26461'
abrtd: make_workitem_list: page allocation failure. order:1, mode:0x20
abrtd: Pid: 31870, comm: make_workitem_list Not tainted
2.6.32-573.12.1.el6.x86_64 #1

I have never seen anything like this before. Usually, if there is an
unhandled exception something is dumped to stderr. Anyone have any
idea what is going on? How can I get it to not delete this crash dump
it mentioned? I guess I can put a big exception handler around the
enter script with a traceback.

This is on Red Hat Enterprise Linux Server release 6.7 (Santiago).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: script exits prematurely with no stderr output, but with system errors

2016-03-20 Thread Joel Goldstick
On Sun, Mar 20, 2016 at 4:32 PM, Larry Martell 
wrote:

> I have a script that I run a lot - at least 10 time every day. Usually
> it works fine. But sometime it just stops running with nothing output
> to stdout or stderr. I've been trying to debug this for a while, and
> today I looked in the system logs and saw this:
>
> abrt: detected unhandled Python exception in
> '/home/prod_user/python/make_workitem_list.py'
> abrtd: Directory 'pyhook-2016-03-19-22:20:43-26461' creation detected
> abrt-server[3688]: Saved Python crash dump of pid 26461 to
> /var/spool/abrt/pyhook-2016-03-19-22:20:43-26461
> abrtd: Executable '/home/prod_user/python/make_workitem_list.py'
> doesn't belong to any package and ProcessUnpackaged is set to 'no'
> abrtd: 'post-create' on
> '/var/spool/abrt/pyhook-2016-03-19-22:20:43-26461' exited with 1
> abrtd: Deleting problem directory
> '/var/spool/abrt/pyhook-2016-03-19-22:20:43-26461'
> abrtd: make_workitem_list: page allocation failure. order:1, mode:0x20
> abrtd: Pid: 31870, comm: make_workitem_list Not tainted
> 2.6.32-573.12.1.el6.x86_64 #1
>
> I have never seen anything like this before. Usually, if there is an
> unhandled exception something is dumped to stderr. Anyone have any
> idea what is going on? How can I get it to not delete this crash dump
> it mentioned? I guess I can put a big exception handler around the
> enter script with a traceback.
>
> This is on Red Hat Enterprise Linux Server release 6.7 (Santiago).
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Googling I found this:
http://stackoverflow.com/questions/2628901/interpreting-kernel-message-page-allocation-failure-order1

It seems that the kernel can't allocate memory is a likely cause.

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


Re: script exits prematurely with no stderr output, but with system errors

2016-03-20 Thread Larry Martell
On Sun, Mar 20, 2016 at 4:47 PM, Joel Goldstick
 wrote:
> On Sun, Mar 20, 2016 at 4:32 PM, Larry Martell 
> wrote:
>
>> I have a script that I run a lot - at least 10 time every day. Usually
>> it works fine. But sometime it just stops running with nothing output
>> to stdout or stderr. I've been trying to debug this for a while, and
>> today I looked in the system logs and saw this:
>>
>> abrt: detected unhandled Python exception in
>> '/home/prod_user/python/make_workitem_list.py'
>> abrtd: Directory 'pyhook-2016-03-19-22:20:43-26461' creation detected
>> abrt-server[3688]: Saved Python crash dump of pid 26461 to
>> /var/spool/abrt/pyhook-2016-03-19-22:20:43-26461
>> abrtd: Executable '/home/prod_user/python/make_workitem_list.py'
>> doesn't belong to any package and ProcessUnpackaged is set to 'no'
>> abrtd: 'post-create' on
>> '/var/spool/abrt/pyhook-2016-03-19-22:20:43-26461' exited with 1
>> abrtd: Deleting problem directory
>> '/var/spool/abrt/pyhook-2016-03-19-22:20:43-26461'
>> abrtd: make_workitem_list: page allocation failure. order:1, mode:0x20
>> abrtd: Pid: 31870, comm: make_workitem_list Not tainted
>> 2.6.32-573.12.1.el6.x86_64 #1
>>
>> I have never seen anything like this before. Usually, if there is an
>> unhandled exception something is dumped to stderr. Anyone have any
>> idea what is going on? How can I get it to not delete this crash dump
>> it mentioned? I guess I can put a big exception handler around the
>> enter script with a traceback.
>>
>> This is on Red Hat Enterprise Linux Server release 6.7 (Santiago).
>
> Googling I found this:
> http://stackoverflow.com/questions/2628901/interpreting-kernel-message-page-allocation-failure-order1
>
> It seems that the kernel can't allocate memory is a likely cause.

Yes, I was thinking that as well about the "page allocation failure"
message, but it's almost like there were 2 errors, the first being the
unhandled exception. But why would it not output something to stderr?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: script exits prematurely with no stderr output, but with system errors

2016-03-20 Thread Joel Goldstick
On Sun, Mar 20, 2016 at 4:55 PM, Larry Martell 
wrote:

> On Sun, Mar 20, 2016 at 4:47 PM, Joel Goldstick
>  wrote:
> > On Sun, Mar 20, 2016 at 4:32 PM, Larry Martell 
> > wrote:
> >
> >> I have a script that I run a lot - at least 10 time every day. Usually
> >> it works fine. But sometime it just stops running with nothing output
> >> to stdout or stderr. I've been trying to debug this for a while, and
> >> today I looked in the system logs and saw this:
> >>
> >> abrt: detected unhandled Python exception in
> >> '/home/prod_user/python/make_workitem_list.py'
> >> abrtd: Directory 'pyhook-2016-03-19-22:20:43-26461' creation detected
> >> abrt-server[3688]: Saved Python crash dump of pid 26461 to
> >> /var/spool/abrt/pyhook-2016-03-19-22:20:43-26461
> >> abrtd: Executable '/home/prod_user/python/make_workitem_list.py'
> >> doesn't belong to any package and ProcessUnpackaged is set to 'no'
> >> abrtd: 'post-create' on
> >> '/var/spool/abrt/pyhook-2016-03-19-22:20:43-26461' exited with 1
> >> abrtd: Deleting problem directory
> >> '/var/spool/abrt/pyhook-2016-03-19-22:20:43-26461'
> >> abrtd: make_workitem_list: page allocation failure. order:1, mode:0x20
> >> abrtd: Pid: 31870, comm: make_workitem_list Not tainted
> >> 2.6.32-573.12.1.el6.x86_64 #1
> >>
> >> I have never seen anything like this before. Usually, if there is an
> >> unhandled exception something is dumped to stderr. Anyone have any
> >> idea what is going on? How can I get it to not delete this crash dump
> >> it mentioned? I guess I can put a big exception handler around the
> >> enter script with a traceback.
> >>
> >> This is on Red Hat Enterprise Linux Server release 6.7 (Santiago).
> >
> > Googling I found this:
> >
> http://stackoverflow.com/questions/2628901/interpreting-kernel-message-page-allocation-failure-order1
> >
> > It seems that the kernel can't allocate memory is a likely cause.
>
> Yes, I was thinking that as well about the "page allocation failure"
> message, but it's almost like there were 2 errors, the first being the
> unhandled exception. But why would it not output something to stderr?
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Others may know.  Not my area of expertise.  I gleaned that it couldn't
create 2 pages of memory for the kernel.  Some of the google links show
ways to look at log files.  It was over my head!

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


Re: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc?

2016-03-20 Thread kosvanec
On Wednesday, October 14, 2015 at 9:06:11 PM UTC+2, John S. James wrote:
> I installed 3.5.0 today and it's working fine -- either from the command 
> prompt, or running a .py script.
> 
> But the Python 3.4 that was previously installed on the computer had a 
> Python34 folder, which contained DDLs, Doc, include, Lib, and various other 
> folders and files. I haven't found a comparable Python35 folder anywhere. I'd 
> like to find the 3.5 Doc folder at least.
> 
> I looked for the installation directory using the command prompt, but at 
> c:\Users\(my name)\ there is no AppData.
> 
> Where can I find that folder? Or can I just ignore it for now (and get the 
> documentation elsewhere)?

Python 3.5, for "all users" is in 
C:\Users\myName\AppData\Local\Programs\Python\Python35-32
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fetch Gmail Archieved messages

2016-03-20 Thread Mark Lawrence

On 20/03/2016 19:56, Arshpreet Singh wrote:

On Saturday, 19 March 2016 05:38:16 UTC+5:30, Rick Johnson  wrote:


I gave you "real help".

What you want me to do -- write the code for you? Sorry, but Python-list is not a soup 
kitchen for destitute code. Neither is it a triage center were you can bring your sick 
code, drop it at the door, and say: "Here, fix this, i'm going to the bar".

Where is your traceback?

Does your code run without raising Errors?

Why did you create a loop, simply to iterate over a list-literal containing  
one value?

At this point, i can't determine if you're trolling or serious...


Thanks "Big boy"! I just asked for help not any kind of malfunction here.



Please ignore "Ranting Rick", he's a well known troll who's just been 
slapped firmly down over on the Python ideas mailing list.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: E-commerce system in Python

2016-03-20 Thread Mark Lawrence

On 18/03/2016 04:25, Arshpreet Singh wrote:

I am looking for an E-commerce system in python to sell things things online, 
which can also be responsive for Android and IOS.

A  quick Google search brought me  http://getsaleor.com/ it uses Django, Is 
there any available one using Flask or newly born asyncio based framework?



Not yet production ready but you might at least find this 
http://www.defuze.org/archives/385-an-asynchronous-cherrypy-server-based-on-asyncio.html 
interesting.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Installed 3.5.0 successfully on Windows 10, but where is DDLs, Doc, Lib, etc?

2016-03-20 Thread eryk sun
On Sun, Mar 20, 2016 at 5:33 PM,   wrote:
> On Wednesday, October 14, 2015 at 9:06:11 PM UTC+2, John S. James wrote:
>> I installed 3.5.0 today and it's working fine -- either from the command 
>> prompt, or running a .py script.
>>
>> But the Python 3.4 that was previously installed on the computer had a 
>> Python34 folder, which
>> contained DDLs, Doc, include, Lib, and various other folders and files. I 
>> haven't found a
>> comparable Python35 folder anywhere. I'd like to find the 3.5 Doc folder at 
>> least.
>>
>> I looked for the installation directory using the command prompt, but at 
>> c:\Users\(my name)\ there is
>> no AppData.
>>
>> Where can I find that folder? Or can I just ignore it for now (and get the 
>> documentation elsewhere)?
>
> Python 3.5, for "all users" is in 
> C:\Users\myName\AppData\Local\Programs\Python\Python35-32

No, "%LocalAppData%\Programs\Python\PythonXY[-32]" is for a per-user
installation, unless a buggy version of the 3.5 installer failed to
update the target directory. Per-machine installs of 3.5+ default to
either "%ProgramFiles%\PythonXY" or "%ProgramFiles(x86)%\PythonXY-32",
where X and Y are the major and minor release numbers. Note that the
initial 3.5.0 release, and only 3.5.0, uses a "Python 3.5" naming
convention.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python boilerplate

2016-03-20 Thread Fernando Felix do Nascimento Junior
@all

I released version 1.0.0 with a tiny glossary and explanation of each file in 
the boilerplate.

@Chris

I made the boilerplate with intent that everyone can understand, download and 
use quickly. So, I didn't put extra dependence like cookiecutter (that depends 
jinja, that depends markupsafe) to **just** replace fields and then run the 
project.

I also preferred to use .md instead .rst because it's more clean in my opinion 
and used by default in platforms like GitHub and Stackoverflow. See mkdocs to 
generate documentation with markdown.

In same way, I choose pytest because the default test framework is verbose and 
its CamelCase sux.

About entry_points maybe I'll consider it too, but I didn't understand why 
packages are best than modules... both can be reusable and not every project 
needs packages.

I looked your release shell script. It's very nice. In Flask GitHub repository 
has a pretty nice too. See it ~scripts/make-release.py.


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


Output format

2016-03-20 Thread vernleffler
I can't find a formatting way to get columns of data. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Output format

2016-03-20 Thread Joel Goldstick
On Sun, Mar 20, 2016 at 7:37 PM,  wrote:

> I can't find a formatting way to get columns of data.
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Welcome Vern.  We're gonna need more than that -- os, python version, your
code, traceback if you get one, what results you get, what you want

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


Re: Output format

2016-03-20 Thread Mark Lawrence

On 20/03/2016 23:37, [email protected] wrote:

I can't find a formatting way to get columns of data.



Take your pick from:-

https://docs.python.org/3/library/stdtypes.html#string-methods

https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting

https://docs.python.org/3/library/string.html#string-formatting

https://docs.python.org/3/library/string.html#template-strings

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-20 Thread BartC

On 15/03/2016 00:25, BartC wrote:
> On 14/03/2016 23:24, Steven D'Aprano wrote:

>> Try this instead:
>>
>> c = chr(c)
>> if 'A' <= c <= 'Z':
>>  upper += 1
>> elif 'a' <= c <= 'z':
>>  lower += 1
>> elif '0' <= c <= '9':
>>  digits += 1
>> else:
>>  other += 1
>>
>>
>> But even better:
>>
>> if c.isupper():
>>  upper += 1
>> elif c islower():
>>  lower += 1
>> elif c.isdigit():
>>  digits += 1
>> else:
>>  other += 1
>>
>>
>> which will work correctly for non-ASCII characters as well.
>
> Yes, but now you've destroyed my example!
>
> A more realistic use of switch is shown below [not Python].

A tokeniser along those lines in Python, with most of the bits filled 
in, is here:


http://pastebin.com/dtM8WnFZ

This is a test of a character-at-a-time task in Python; I know such 
tasks are not popular here, but exactly such tasks are what I often use 
dynamic languages for.


I started off trying to write it in a more efficient way that would suit 
Python better, but quickly tired of that. I should be able to express 
the code how I want.


But it is based on strings (integers seem to be slower in Python), and 
uses your style above.


However, this is crying out for at least a case statement (which works 
with anything) if not a switch that works with ints and constants.


All other versions it is compared against use switches, integers, and 
names that don't change at runtime.


-

Performance figures for the test code above. These use the same input 
file (220K lines of CPython C sources), and show lines-per-second 
achieved not runtime.


Interpreters:

Py2  Python 2 (various)
Py3  Python 3.4
PyPy PyPy 3.2.5

PCA  Mine (accelerated via some ASM routines, 64-bit)
PCC  Mine (standard, 32-bit)


Windows 7 64-bits:

Py3:   33K lps (lines per second)
Py2:   43K lps
PyPy  100K lps

PCC:  460K lps
C:   1000K lps (Tiny C compiler, native code)
PCA: 1200K lps
B:   5800K Lps (My own compiler, native code)
C:   9000K lps (gcc C compiler, native code)

(Tiny C is particularly poor at generating code for switches. Still, 
native code is running slower than byte-code, which is something.)



Ubuntu 15.x 64-bits (run via VirtualBox on Windows 7):

Py2:   58K lps
PyPy: 133K lps (2.x)

PCC:  250-330K lps (via 'wine'; timings variable)
PCA:  500-800K lps (via 'wine')


(Debian on an old Raspberry Pi:

Py2:2K lps
PCC:   16K lps

I think these, especially for PCC, should be faster. But this was a 
hastily created Linux port of PCC.)


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


Re: script exits prematurely with no stderr output, but with system errors

2016-03-20 Thread Terry Reedy

On 3/20/2016 4:55 PM, Larry Martell wrote:


Yes, I was thinking that as well about the "page allocation failure"
message, but it's almost like there were 2 errors, the first being the
unhandled exception. But why would it not output something to stderr?


Formatting a traceback requires memory.  As I remember, Python gives up 
after out-of-memory error.  It might be that the out-of-memory caused a 
MemoryException that was not handled.


--
Terry Jan Reedy

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-20 Thread Mark Lawrence

On 21/03/2016 01:15, BartC wrote:

On 15/03/2016 00:25, BartC wrote:
 > On 14/03/2016 23:24, Steven D'Aprano wrote:

 >> Try this instead:
 >>
 >> c = chr(c)
 >> if 'A' <= c <= 'Z':
 >>  upper += 1
 >> elif 'a' <= c <= 'z':
 >>  lower += 1
 >> elif '0' <= c <= '9':
 >>  digits += 1
 >> else:
 >>  other += 1
 >>
 >> But even better:
 >>
 >> if c.isupper():
 >>  upper += 1
 >> elif c islower():
 >>  lower += 1
 >> elif c.isdigit():
 >>  digits += 1
 >> else:
 >>  other += 1
 >>
 >> which will work correctly for non-ASCII characters as well.
 >
 > Yes, but now you've destroyed my example!
 >
 > A more realistic use of switch is shown below [not Python].

A tokeniser along those lines in Python, with most of the bits filled
in, is here:

http://pastebin.com/dtM8WnFZ



I got to line 22, saw the bare except, and promptly gave up.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-20 Thread Chris Angelico
On Mon, Mar 21, 2016 at 12:28 PM, Mark Lawrence  wrote:
> I got to line 22, saw the bare except, and promptly gave up.

Oh, keep going, Mark. It gets better.

def readstrfile(file):
try:
data=open(file,"r").read()
except:
return 0
return data

def start():
psource=readstrfile(infile)
if psource==0:
print ("Can't open file",infile)
exit(0)



So, if any exception happens during the reading of the file, it gets
squashed, and 0 is returned - which results in a generic message being
printed, and the program terminating, with return value 0. Awesome!

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-20 Thread Mark Lawrence

On 21/03/2016 01:35, Chris Angelico wrote:

On Mon, Mar 21, 2016 at 12:28 PM, Mark Lawrence  wrote:

I got to line 22, saw the bare except, and promptly gave up.


Oh, keep going, Mark. It gets better.

def readstrfile(file):
 try:
 data=open(file,"r").read()
 except:
 return 0
 return data

def start():
 psource=readstrfile(infile)
 if psource==0:
 print ("Can't open file",infile)
 exit(0)

So, if any exception happens during the reading of the file, it gets
squashed, and 0 is returned - which results in a generic message being
printed, and the program terminating, with return value 0. Awesome!

ChrisA



The essential question is "which is faster?".  Who cares about trivial 
little details like the user being given false data, as (say) they can 
open the file but can't read it.  Or inadvertantly writing an infinite 
loop and not being able to CTRL-C out of it, having to revert to your OS 
to kill the rogue that's killing your CPU.


25 years of trying to teach people how to write Pythonic code and this 
is how far we've got.  Heck, I think I'll see my GP later today for some 
more, more powerful, tranquilisers.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-20 Thread BartC

On 21/03/2016 01:35, Chris Angelico wrote:

On Mon, Mar 21, 2016 at 12:28 PM, Mark Lawrence  wrote:

I got to line 22, saw the bare except, and promptly gave up.


Oh, keep going, Mark. It gets better.

def readstrfile(file):
 try:
 data=open(file,"r").read()
 except:
 return 0
 return data

def start():
 psource=readstrfile(infile)
 if psource==0:
 print ("Can't open file",infile)
 exit(0)



So, if any exception happens during the reading of the file, it gets
squashed, and 0 is returned - which results in a generic message being
printed, and the program terminating, with return value 0. Awesome!


I don't have a clue about exceptions, but why wouldn't read errors be 
picked up by the same except: block?


But I've anyway sprinkled one or two more try/excepts in there and put 
some actual exception codes in. However, this readstrfile() is just 
there to load the file into memory and avoid having a 200,000-line 
string in the program.


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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-20 Thread Chris Angelico
On Mon, Mar 21, 2016 at 1:04 PM, BartC  wrote:
> On 21/03/2016 01:35, Chris Angelico wrote:
>>
>> On Mon, Mar 21, 2016 at 12:28 PM, Mark Lawrence 
>> wrote:
>>>
>>> I got to line 22, saw the bare except, and promptly gave up.
>>
>>
>> Oh, keep going, Mark. It gets better.
>>
>> def readstrfile(file):
>>  try:
>>  data=open(file,"r").read()
>>  except:
>>  return 0
>>  return data
>>
>> def start():
>>  psource=readstrfile(infile)
>>  if psource==0:
>>  print ("Can't open file",infile)
>>  exit(0)
>>
>>
>>
>> So, if any exception happens during the reading of the file, it gets
>> squashed, and 0 is returned - which results in a generic message being
>> printed, and the program terminating, with return value 0. Awesome!
>
>
> I don't have a clue about exceptions, but why wouldn't read errors be picked
> up by the same except: block?

They are. So would NameError, AttributeError, KeyboardInterrupt, and
anything else that happens to get raised. Everything gets absorbed
into the same message, "Can't open file", and then the program exits 0
to make absolutely sure that the caller can't figure anything out.

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-20 Thread Ben Finney
BartC  writes:

> I don't have a clue about exceptions

Please, stop making assertions about Python code until you have learned
Python.

You are a Python beginner. You would be welcome to learn Python over at
the ‘tutor’ forum https://mail.python.org/mailman/listinfo/tutor>.

Otherwise, please stop with the assertions about how Python works.

You're free to tinker privately with your own programming language. But
this is not an appropriate forum to go on at length about it in
comparison with Python. You can create your own weblog if you want a
forum for that.

-- 
 \“Program testing can be a very effective way to show the |
  `\presence of bugs, but is hopelessly inadequate for showing |
_o__)  their absence.” —Edsger W. Dijkstra |
Ben Finney

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-20 Thread Terry Reedy

On 3/20/2016 9:15 PM, BartC wrote:

http://pastebin.com/dtM8WnFZ
This is a test of a character-at-a-time task in Python;


I disagree.  It tests of C code re-written in ludicrously crippled 
Python.  No use of the re module, designed for tasks like this, and no 
use of dicts, which replace many uses of switch statements.


> but exactly such tasks are what I often use dynamic languages for.

For instance, there are about 15 clauses like
---
elif c=="?":
lxsymbol=question_sym
return
---

I believe it would be much faster to combine these in one clause. First 
define simple_symbols = {'?': question_sym, ...}. Then

elif c in simple_symbols:
lxsymbol = simple_symbols[c]
return

In any case, the O(k), where k is the number of alternatives, linear 
search should be replaced by an O(log k) binary search (nested if-else 
statement) or O(1) hashed search (with a dictionary mapping chars to 
functions.



I started off trying to write it in a more efficient way that would suit
Python better, but quickly tired of that. I should be able to express
the code how I want.


Of course you can.  But you cannot write in a crippled Python subset and 
fairly claim that the result represents idiomatic Python code.


--
Terry Jan Reedy

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


Re: Why do you use python?

2016-03-20 Thread rharding64
On Saturday, October 31, 2009 at 3:22:20 AM UTC-6, Martin P. Hellwig wrote:
> sk wrote:
> > What would be your answer if this question is asked to you in an
> > interview?
> > 
> > a modified version might be:
> > "Where would you use python over C/C++/Java?"
> > 
> > (because my resume says I know C/C++/Java)?
> 
> I would say where I can, where 'can' is depending on the problem, 
> already implementations and requirements.
> 
> On the other hand, when I go to a restaurant I usually don't tell the 
> chef which brand of knives he has to prepare my meal with, even though I 
> prefer Globals knives for my own use.
> 
> -- 
> MPH
> http://blog.dcuktec.com
> 'If consumed, best digested with added seasoning to own preference.'

here's what i tell employers and potential employers for next gig;

i go to the job like the plumber; i have a toolbox full of hardware and 
software of my design that i use to solve client problems.  what i dislike is 
the fact that some employers ONLY want to use python and nothing else.  while i 
can appreciate the point that they are trying to get across, the fact is that 
solving real world problems sometimes takes other languages and approaches that 
cannot be easily done or not done at all in python. 

instead, to be efficient, it is best to combine tools to solve problems that 
contain complexities where there is nothing available off the shelve that does 
the job. c# is free, free VS studio, i can run ironpython there, i can do 
python there, and talk to linux boxes with python, i can run c# on linux boxes 
using mono(did that back in 2004 and thereafter for a while).  i can run python 
on my beaglebone black inside of snappy ubuntu, ect. 

so i ask those employers why not use what is available to solve problems 
instead of limiting yourself to just one???
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-20 Thread Mark Lawrence

On 21/03/2016 02:04, BartC wrote:

On 21/03/2016 01:35, Chris Angelico wrote:

On Mon, Mar 21, 2016 at 12:28 PM, Mark Lawrence
 wrote:

I got to line 22, saw the bare except, and promptly gave up.


Oh, keep going, Mark. It gets better.

def readstrfile(file):
 try:
 data=open(file,"r").read()
 except:
 return 0
 return data

def start():
 psource=readstrfile(infile)
 if psource==0:
 print ("Can't open file",infile)
 exit(0)



So, if any exception happens during the reading of the file, it gets
squashed, and 0 is returned - which results in a generic message being
printed, and the program terminating, with return value 0. Awesome!


I don't have a clue about exceptions, but why wouldn't read errors be
picked up by the same except: block?


If you don't understand exceptions, you don't understand Python, which 
prefers EAFP than LBYL.  See 
https://docs.python.org/3/glossary.html#term-eafp and 
https://docs.python.org/3/glossary.html#term-lbyl




But I've anyway sprinkled one or two more try/excepts in there and put
some actual exception codes in. However, this readstrfile() is just
there to load the file into memory and avoid having a 200,000-line
string in the program.



Just let the exception bubble up if anything goes wrong.  In most 
circumstances that's far better than masking everything that could 
possibly go wrong.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Why do you use python?

2016-03-20 Thread Chris Angelico
On Mon, Mar 21, 2016 at 2:59 PM,   wrote:
> instead, to be efficient, it is best to combine tools to solve problems that 
> contain complexities where there is nothing available off the shelve that 
> does the job. c# is free, free VS studio, i can run ironpython there, i can 
> do python there, and talk to linux boxes with python, i can run c# on linux 
> boxes using mono(did that back in 2004 and thereafter for a while).  i can 
> run python on my beaglebone black inside of snappy ubuntu, ect.
>
> so i ask those employers why not use what is available to solve problems 
> instead of limiting yourself to just one???

Because you won't be there forever, and they'll have to find someone
else to maintain your hellspawn hodge-podge of languages, tools, and
libraries. (And yes, it will be described that way by the next person,
no matter how careful you are.) It's in their interests to restrict
its complexity at least a bit. I'm not sure what advantage you gain by
incorporating C# into the mix, but the *dis*advantage is that, forever
afterward, Visual Studio and Mono will be necessary to use and develop
this project. Every new thing needed is another thing that can go
wrong, another thing people need to learn, etc, etc.

So instead of treating programming like a plumber at a hardware store,
treat it like an artist with a canvas. You wouldn't normally see a
portrait done partly in watercolor and partly in oils - or if it is,
it's for a VERY deliberate effect. You'd more often see one style used
for one project, and maybe another one used for another.

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


Re: Why do you use python?

2016-03-20 Thread Dan Sommers
On Mon, 21 Mar 2016 15:13:22 +1100, Chris Angelico wrote:

> On Mon, Mar 21, 2016 at 2:59 PM,   wrote:

>> instead, to be efficient, it is best to combine tools to solve
>> problems that contain complexities where there is nothing available
>> off the shelve that does the job. c# is free, free VS studio, i can
>> run ironpython there, i can do python there, and talk to linux boxes
>> with python, i can run c# on linux boxes using mono(did that back in
>> 2004 and thereafter for a while).  i can run python on my beaglebone
>> black inside of snappy ubuntu, ect.

>> so i ask those employers why not use what is available to solve
>> problems instead of limiting yourself to just one???

> Because you won't be there forever, and they'll have to find someone
> else to maintain your hellspawn hodge-podge of languages, tools, and
> libraries. (And yes, it will be described that way by the next person,
> no matter how careful you are.) It's in their interests to restrict
> its complexity at least a bit. I'm not sure what advantage you gain by
> incorporating C# into the mix, but the *dis*advantage is that, forever
> afterward, Visual Studio and Mono will be necessary to use and develop
> this project. Every new thing needed is another thing that can go
> wrong, another thing people need to learn, etc, etc.

> So instead of treating programming like a plumber at a hardware store,
> treat it like an artist with a canvas. You wouldn't normally see a
> portrait done partly in watercolor and partly in oils - or if it is,
> it's for a VERY deliberate effect. You'd more often see one style used
> for one project, and maybe another one used for another.

Both viewpoints must be tempered in order to create successful systems.

I've worked on jobs where the tool or target operating sytem (singular)
was chosen first, or specified as part of the "system requirements," and
it can work out just as badly as a hellspawn hodge-podge of a solution.
We've all heard the one about all problems looking like nails.

It should, by now, go without saying, but choose the right tool (or
tools) for the job, where "right" includes any number of things *not*
related to its immediate implementation, and often includes some number
of things *counter* to an obviously superior, in one way or another,
implementation.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why do you use python?

2016-03-20 Thread Mark Lawrence

On 21/03/2016 03:59, [email protected] wrote:

On Saturday, October 31, 2009 at 3:22:20 AM UTC-6, Martin P. Hellwig wrote:

sk wrote:

What would be your answer if this question is asked to you in an
interview?

a modified version might be:
"Where would you use python over C/C++/Java?"

(because my resume says I know C/C++/Java)?


I would say where I can, where 'can' is depending on the problem,
already implementations and requirements.

On the other hand, when I go to a restaurant I usually don't tell the
chef which brand of knives he has to prepare my meal with, even though I
prefer Globals knives for my own use.

--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'


here's what i tell employers and potential employers for next gig;

i go to the job like the plumber; i have a toolbox full of hardware and 
software of my design that i use to solve client problems.  what i dislike is 
the fact that some employers ONLY want to use python and nothing else.  while i 
can appreciate the point that they are trying to get across, the fact is that 
solving real world problems sometimes takes other languages and approaches that 
cannot be easily done or not done at all in python.

instead, to be efficient, it is best to combine tools to solve problems that 
contain complexities where there is nothing available off the shelve that does 
the job. c# is free, free VS studio, i can run ironpython there, i can do 
python there, and talk to linux boxes with python, i can run c# on linux boxes 
using mono(did that back in 2004 and thereafter for a while).  i can run python 
on my beaglebone black inside of snappy ubuntu, ect.

so i ask those employers why not use what is available to solve problems 
instead of limiting yourself to just one???



I'm not quite sure why you've replied to a five year old thread, but I'd 
suggest that the employers' main concern is Total Cost of Ownership.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Why do you use python?

2016-03-20 Thread Chris Angelico
On Mon, Mar 21, 2016 at 3:49 PM, Dan Sommers  wrote:
>> So instead of treating programming like a plumber at a hardware store,
>> treat it like an artist with a canvas. You wouldn't normally see a
>> portrait done partly in watercolor and partly in oils - or if it is,
>> it's for a VERY deliberate effect. You'd more often see one style used
>> for one project, and maybe another one used for another.
>
> Both viewpoints must be tempered in order to create successful systems.
>
> I've worked on jobs where the tool or target operating sytem (singular)
> was chosen first, or specified as part of the "system requirements," and
> it can work out just as badly as a hellspawn hodge-podge of a solution.
> We've all heard the one about all problems looking like nails.
>
> It should, by now, go without saying, but choose the right tool (or
> tools) for the job, where "right" includes any number of things *not*
> related to its immediate implementation, and often includes some number
> of things *counter* to an obviously superior, in one way or another,
> implementation.

True. I'm not saying you should never use more than one tool, but that
every additional tool used costs exponentially in complexity. And
people who claim they should use any tool whatsoever usually use "I
know this tool" as the most important criterion in the decision -
which results in the worst kind of hodge-podge.

Possibly the best way to handle it is to have to justify every new
tool you use to at least two other people, preferably people who have
never used it before.

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


Re: Why do you use python?

2016-03-20 Thread Ben Finney
Chris Angelico  writes:

> True. I'm not saying you should never use more than one tool, but that
> every additional tool used costs exponentially in complexity. And
> people who claim they should use any tool whatsoever usually use "I
> know this tool" as the most important criterion in the decision -
> which results in the worst kind of hodge-podge.

There is also an important distinction to draw on how much effect one's
choice of tool will impact others working on the same code base, either
contemporaneously or in the future.

If I choose to use Vim, and passionately defend that decision, this
choice of tool is unlikely to have much impact on my workmates or future
programmers.

Whereas if I pull the entire code base into a Subversion repository,
that choice will have a major impact on what others must to do
collaborate and work on the code base.

The more impact a choice of tool will have on others working on that
same code base, the less weight should be given to “what tool makes me
personally happy” and the more weight needs to be given to “what will
help people work together better on this code base”.

-- 
 \   “Everyone is entitled to their own opinions, but they are not |
  `\entitled to their own facts.” —US Senator Pat Moynihan |
_o__)  |
Ben Finney

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


Re: Output format

2016-03-20 Thread Alphwe
On Monday, March 21, 2016 at 7:37:39 AM UTC+8, [email protected] wrote:
> I can't find a formatting way to get columns of data.

I don't think this express is a question, or asking for help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-20 Thread Steven D'Aprano
On Monday 21 March 2016 12:35, Chris Angelico wrote:

> On Mon, Mar 21, 2016 at 12:28 PM, Mark Lawrence 
> wrote:
>> I got to line 22, saw the bare except, and promptly gave up.
> 
> Oh, keep going, Mark. It gets better.
[...]
> So, if any exception happens during the reading of the file, it gets
> squashed, and 0 is returned - which results in a generic message being
> printed, and the program terminating, with return value 0. Awesome!


While there is a certain level of entertainment to be gained from snarking 
at other people's bad code, and I'm as guilty as anyone else for doing so, 
please remember that Bart is engaged in a good-faith attempt to compare 
Python to other dynamic code. He's not claiming to be a Python expert or 
that he's writing idiomatic Python code.

Bart, bare except clauses are (as a general rule) an anti-pattern, and 
should be avoided except for the quickest and dirtiest of throw-away 
scripts. With very few exceptions (heh) you should *always* specify the 
narrowest set of exceptions that you know you can deal with.

Over-enthusiastic use of try...except is *deadly* for the ability to debug 
code:

https://realpython.com/blog/python/the-most-diabolical-python-antipattern/


-- 
Steve

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-20 Thread Steven D'Aprano
On Monday 21 March 2016 13:11, Ben Finney wrote:

> BartC  writes:
> 
>> I don't have a clue about exceptions
> 
> Please, stop making assertions about Python code until you have learned
> Python.


I don't see how "I don't have a clue about exceptions" is an assertion about 
Python code.

I think there's a lot of hostility aimed at Bart, undeserved hostility, 
because he continues to demonstrate that Python is not as fast as it could 
be. I don't see that Bart is trolling or being malicious, although I do 
think he perhaps hasn't fully grasped the idea that *we know*, and we're 
willing to live with reduced speed in favour of certain design choices.

(Ironically, for all that we as a community will go to the battlements to 
fight to the death to keep these dynamic features, we'll also tar and 
feather anyone who actually *uses* them. I've even seen people criticise 
Raymond Hettinger, one of the most experienced and competent senior Python 
guys, because his "namedtuple" uses exec. Go figure.)

I'll ask everyone to please give Bart the benefit of the doubt and assume 
good faith. Rather than snark at him if he writes un-Pythonic code, teach 
him how to write it better, don't just sneer at the poor quality of his code 
or fob him off onto another list.

(Bart, I am also on the tutor mailing list that Ben suggested, and you would 
be welcome them.)


-- 
Steve

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


Re: Output format

2016-03-20 Thread Rustom Mody
On Monday, March 21, 2016 at 5:54:31 AM UTC+5:30, Mark Lawrence wrote:
> On 20/03/2016 23:37, :
> > I can't find a formatting way to get columns of data.
> >
> 
> Take your pick from:-
> 
> https://docs.python.org/3/library/stdtypes.html#string-methods
> 
> https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting
> 
> https://docs.python.org/3/library/string.html#string-formatting
> 
> https://docs.python.org/3/library/string.html#template-strings


Also maybe look at csv:
https://docs.python.org/2/library/csv.html
-- 
https://mail.python.org/mailman/listinfo/python-list