Re: SystemError in python 2.5.4

2015-12-11 Thread Steven D'Aprano
On Thu, 10 Dec 2015 10:29 pm, Palpandi wrote:

> Hi All,
> 
> I am getting the error mentioned below in python 2.5.4.
> 
> SystemError: \loewis\25\python\Objects\longobject.c:225: bad argument to
> internal function.

Sounds like your installation of Python is broken. You should never get an
internal error like that.

If it was working, and now isn't, I would strongly suspect the application
has been corrupted, or possibly infected by a virus. I would start with a
virus scan and a disk check, and after fixing any faults that come up,
re-install Python 2.5 (or upgrade to 2.7, which is much better).



-- 
Steven

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


Re: SystemError in python 2.5.4

2015-12-11 Thread dieter
Palpandi  writes:

> I am getting the error mentioned below in python 2.5.4.
>
> SystemError: \loewis\25\python\Objects\longobject.c:225: bad argument to 
> internal function.
>
> I also ran the same code in python 2.7.
> There I am not getting this error.
>
> I don't know which causes this error. Any solution for this?
>
> Note: The error is coming from the method call findall(path).

I do not have the code for Python 2.5.4 around - therefore,
I looked into that for Python 2.4.6. Based on this (older) version,
the "SystemError" above may come from the "PyLong_AsLong" function
(converting a Python "long" into a "C" "long"). In this case,
the error would be caused by provding a wrong parameter
(neither Python "int" nor Python "long") to "PyLong_AsLong".

At your place, I would have a look at the Python 2.5.4 code
and check there where precisely the "SystemError" comes from.
Then I would try to find out why it gets wrong (this might
require the use of a "C" level debugger).

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


Re: How to use internal python c funtions, from python code

2015-12-11 Thread dieter
srinivas devaki  writes:

> but still I think it would be cool to be able to access internal c
> functions without any fuss. I can use such feature with heapq too(sift
> operations),

Have a look at "Cython". It is a compiler which compiles
a language similar to Python with special extensions for an efficient
interface to "C" and "C++" into "C"/"C++" source which then can be built
into a Python extension module and used from Python like any other
Python module.

In a "Cython" source, you can quite easily use C functions, among
others C functions defined by Python itself.

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


trying to force stdout to utf-8 with errors='ignore' or 'replace'

2015-12-11 Thread Adam Funk
I'm fiddling with a program that reads articles in the news spool
using email.parser (standard library) &
email_reply_parser.EmailReplyParser (installed with pip).  Reading is
fine, & I don't get any errors writing output extracted from article
bodies *until* I try to suppress invalid characters.  This works:

if message.is_multipart():
body = message.get_payload(0, True)
else:
body = message.get_payload()
main_body = EmailReplyParser.parse_reply(body)
# fix quoted-printable stuff
if equals_regex.search(main_body):
main_body = quopri.decodestring(main_body)
# suppress attribution before quoted text
main_body = attrib_regex.sub('>', main_body)
# suppress sig
main_body = sig_regex.sub('\n', main_body)
main_body.strip()
stdout.write(main_body + '\n\n')

but the stdout includes invalid characters.  I tried adding this at
the beginning

if stdout.encoding is None:
   writer = codecs.getwriter("utf-8")
   stdout = writer(stdout, errors='replace')

and changing the output line to 

stdout.write(main_body.encode('utf-8', errors='replace') + '\n\n')

but with either or both of those, I get the dreaded
"UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
562: ordinal not in range(128)".  How can I force the output to be in
UTF-8 & silently suppress invalid characters?


-- 
Unit tests are like the boy who cried wolf.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: trying to force stdout to utf-8 with errors='ignore' or 'replace'

2015-12-11 Thread Peter Otten
Adam Funk wrote:

> I'm fiddling with a program that reads articles in the news spool
> using email.parser (standard library) &
> email_reply_parser.EmailReplyParser (installed with pip).  Reading is
> fine, & I don't get any errors writing output extracted from article
> bodies *until* I try to suppress invalid characters.  This works:
> 
> if message.is_multipart():
> body = message.get_payload(0, True)
> else:
> body = message.get_payload()
> main_body = EmailReplyParser.parse_reply(body)
> # fix quoted-printable stuff
> if equals_regex.search(main_body):
> main_body = quopri.decodestring(main_body)
> # suppress attribution before quoted text
> main_body = attrib_regex.sub('>', main_body)
> # suppress sig
> main_body = sig_regex.sub('\n', main_body)
> main_body.strip()
> stdout.write(main_body + '\n\n')
> 
> but the stdout includes invalid characters.  I tried adding this at
> the beginning
> 
> if stdout.encoding is None:
>writer = codecs.getwriter("utf-8")
>stdout = writer(stdout, errors='replace')
> 
> and changing the output line to
> 
> stdout.write(main_body.encode('utf-8', errors='replace') + '\n\n')
> 
> but with either or both of those, I get the dreaded
> "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> 562: ordinal not in range(128)".  How can I force the output to be in
> UTF-8 & silently suppress invalid characters?

(I'm assuming you are using Python 2 and that main_body is a unicode 
instance)

Note that you are getting a *decode* error.

Either feed unicode to the modified stdout

> writer = codecs.getwriter("utf-8")
> stdout = writer(stdout, errors='replace')

  stdout.write(main_body + u'\n\n')

or encode manually and write to the original sys.stdout:

  sys.stdout.write(main_body.encode('utf-8', errors='replace') + '\n\n')



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


mush 2.0 released! - Type-based dependency injection for scripts

2015-12-11 Thread Chris Withers

Hi All,

I'm very happy to announce a new release of Mush, a light weight 
dependency injection framework aimed at enabling the easy testing and 
re-use of chunks of code that make up scripts.


This release is a re-write dropping all the heuristic callable ordering 
in favour of building up defined sequences of callables with labelled 
insertion points.


For a worked example of how to use Mush to reduce the copy'n'paste in 
your scripts, please see here:


http://mush.readthedocs.org/en/latest/examples.html

Full docs are here:

http://mush.readthedocs.org/

Downloads are here:

https://pypi.python.org/pypi/mush

Compatible with Python 2.7, 3.3+:

https://travis-ci.org/Simplistix/mush

Any problems, please give me a shout on the simplis...@googlegroups.com 
list!


cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
https://mail.python.org/mailman/listinfo/python-list


Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman

Hi all

I need to store Decimal objects in a sqlite3 database, using Python 3.4 on
Windows 7.

I followed the instructions here -

   
http://stackoverflow.com/questions/6319409/how-to-convert-python-decimal-to-sqlite-numeric

It seemed to work well, but then I hit a problem. Here is a stripped-down
example -

"""
from decimal import Decimal as D
import sqlite3

# Decimal adapter (store Decimal in database as str)
sqlite3.register_adapter(D, lambda d:str(d))

# Decimal converter (convert back to Decimal on return)
sqlite3.register_converter('DEC', lambda s: D(s.decode('utf-8')))

conn = sqlite3.connect(':memory:', detect_types=sqlite3.PARSE_DECLTYPES)
cur = conn.cursor()

cur.execute("CREATE TABLE fmtemp (acno INT, bal DEC)")
cur.execute("INSERT INTO fmtemp (acno, bal) VALUES (?, ?)", ('A001',
D('0')))

sql1 = "SELECT bal FROM fmtemp"
sql2 = "UPDATE fmtemp SET bal = bal + ?"

while True:
   print(cur.execute(sql1).fetchone()[0])
   cur.execute(sql2, (D('123.45'),))
   q = input()
   if q == 'q':
   break
"""

It initialises a decimal value in the database, then loops adding a decimal
value and displaying the result.

It runs fine for a while, and then the following happens -

5802.15

5925.6

6049.05

6172.49

6295.94

It consistently switches to floating point at the same position. If you
carry on for a while, it reverts back to two decimal places.

If I initialise the value as D('6049.05'), the next value is 6172.5, so it
is not the number itself that causes the problem.

I tried displaying the type - even when it switches to 6172.4999, it is
still a Decimal type.

I noticed one oddity - I am asking sqlite3 to store the value as a string,
but then I am asking it to perform arithmetic on it.

Any suggestions will be much appreciated.

Frank Millman 



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


Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Laura Creighton
>From python-list.
Very weird.
Another reason not to use sqlite3

--- Forwarded Message

To: python-list@python.org
From: "Frank Millman" 
Subject: Problem with sqlite3 and Decimal
Date: Fri, 11 Dec 2015 11:21:53 +0200
Lines: 71

Hi all

I need to store Decimal objects in a sqlite3 database, using Python 3.4 on
Windows 7.

I followed the instructions here -


http://stackoverflow.com/questions/6319409/how-to-convert-python-decimal-to-sqlite-numeric

It seemed to work well, but then I hit a problem. Here is a stripped-down
example -

"""
from decimal import Decimal as D
import sqlite3

# Decimal adapter (store Decimal in database as str)
sqlite3.register_adapter(D, lambda d:str(d))

# Decimal converter (convert back to Decimal on return)
sqlite3.register_converter('DEC', lambda s: D(s.decode('utf-8')))

conn = sqlite3.connect(':memory:', detect_types=sqlite3.PARSE_DECLTYPES)
cur = conn.cursor()

cur.execute("CREATE TABLE fmtemp (acno INT, bal DEC)")
cur.execute("INSERT INTO fmtemp (acno, bal) VALUES (?, ?)", ('A001',
D('0')))

sql1 = "SELECT bal FROM fmtemp"
sql2 = "UPDATE fmtemp SET bal = bal + ?"

while True:
print(cur.execute(sql1).fetchone()[0])
cur.execute(sql2, (D('123.45'),))
q = input()
if q == 'q':
break
"""

It initialises a decimal value in the database, then loops adding a decimal
value and displaying the result.

It runs fine for a while, and then the following happens -

5802.15

5925.6

6049.05

6172.49

6295.94

It consistently switches to floating point at the same position. If you
carry on for a while, it reverts back to two decimal places.

If I initialise the value as D('6049.05'), the next value is 6172.5, so it
is not the number itself that causes the problem.

I tried displaying the type - even when it switches to 6172.4999, it is
still a Decimal type.

I noticed one oddity - I am asking sqlite3 to store the value as a string,
but then I am asking it to perform arithmetic on it.

Any suggestions will be much appreciated.

Frank Millman 


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

--- End of Forwarded Message
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Igor Korot
Hi,

On Fri, Dec 11, 2015 at 8:45 AM, Laura Creighton  wrote:
> From python-list.
> Very weird.
> Another reason not to use sqlite3
>
> --- Forwarded Message
>
> To: python-list@python.org
> From: "Frank Millman" 
> Subject: Problem with sqlite3 and Decimal
> Date: Fri, 11 Dec 2015 11:21:53 +0200
> Lines: 71
>
> Hi all
>
> I need to store Decimal objects in a sqlite3 database, using Python 3.4 on
> Windows 7.
>
> I followed the instructions here -
>
> 
> http://stackoverflow.com/questions/6319409/how-to-convert-python-decimal-to-sqlite-numeric
>
> It seemed to work well, but then I hit a problem. Here is a stripped-down
> example -
>
> """
> from decimal import Decimal as D
> import sqlite3
>
> # Decimal adapter (store Decimal in database as str)
> sqlite3.register_adapter(D, lambda d:str(d))
>
> # Decimal converter (convert back to Decimal on return)
> sqlite3.register_converter('DEC', lambda s: D(s.decode('utf-8')))
>
> conn = sqlite3.connect(':memory:', detect_types=sqlite3.PARSE_DECLTYPES)
> cur = conn.cursor()
>
> cur.execute("CREATE TABLE fmtemp (acno INT, bal DEC)")
> cur.execute("INSERT INTO fmtemp (acno, bal) VALUES (?, ?)", ('A001',
> D('0')))
>
> sql1 = "SELECT bal FROM fmtemp"
> sql2 = "UPDATE fmtemp SET bal = bal + ?"
>
> while True:
> print(cur.execute(sql1).fetchone()[0])
> cur.execute(sql2, (D('123.45'),))
> q = input()
> if q == 'q':
> break
> """
>
> It initialises a decimal value in the database, then loops adding a decimal
> value and displaying the result.
>
> It runs fine for a while, and then the following happens -
>
> 5802.15
>
> 5925.6
>
> 6049.05
>
> 6172.49
>
> 6295.94
>
> It consistently switches to floating point at the same position. If you
> carry on for a while, it reverts back to two decimal places.
>
> If I initialise the value as D('6049.05'), the next value is 6172.5, so it
> is not the number itself that causes the problem.
>
> I tried displaying the type - even when it switches to 6172.4999, it is
> still a Decimal type.
>
> I noticed one oddity - I am asking sqlite3 to store the value as a string,
> but then I am asking it to perform arithmetic on it.

Is there a reason you are saving it as the string?
What happens when you save it as decimal?

Thank you.

>
> Any suggestions will be much appreciated.
>
> Frank Millman
>
>
> - --
> https://mail.python.org/mailman/listinfo/python-list
>
> --- End of Forwarded Message
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Frank Millman
"Igor Korot"  wrote in message 
news:CA+FnnTyaLLEsYGU7v2BreySDOQ1rVsMzJ=5f4iQTLW3=tn=e...@mail.gmail.com...



Hi,

> To: python-list@python.org
> From: "Frank Millman" 
> Subject: Problem with sqlite3 and Decimal
> Date: Fri, 11 Dec 2015 11:21:53 +0200
> Lines: 71
>
> Hi all
>
> I need to store Decimal objects in a sqlite3 database, using Python 3.4 
> on

> Windows 7.
>

[...]


>
> I noticed one oddity - I am asking sqlite3 to store the value as a 
> string,

> but then I am asking it to perform arithmetic on it.

Is there a reason you are saving it as the string?
What happens when you save it as decimal?



Well, maybe you know something that I don't, but my understanding is that 
sqlite3 has a very limited range of supported data types, and decimal is not 
one of them.


The stackoverflow article explains how to emulate a decimal type, and it 
works well most of the time.


I found that I could reproduce the problem using sqlite3 directly, without 
using Python, so I have sent a post to the sqlite3 mailing list. I will 
report back with any info received.


Frank


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


python script for dwonload free anything?

2015-12-11 Thread hienmizu
i want create script for download free 3d model from nonecg.com like 
https://github.com/nishad/udemy-dl-windows , this script download free udemy 
video lesson. Anyone can tell e, how to create script like that?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Igor Korot
 Hi, Frank,

On Fri, Dec 11, 2015 at 9:27 AM, Frank Millman  wrote:
> "Igor Korot"  wrote in message
> news:CA+FnnTyaLLEsYGU7v2BreySDOQ1rVsMzJ=5f4iQTLW3=tn=e...@mail.gmail.com...
>
>> Hi,
>>
>> > To: python-list@python.org
>> > From: "Frank Millman" 
>> > Subject: Problem with sqlite3 and Decimal
>> > Date: Fri, 11 Dec 2015 11:21:53 +0200
>> > Lines: 71
>> >
>> > Hi all
>> >
>> > I need to store Decimal objects in a sqlite3 database, using Python 3.4
>> > > on
>> > Windows 7.
>> >
>
> [...]
>>
>>
>> >
>> > I noticed one oddity - I am asking sqlite3 to store the value as a >
>> > string,
>> > but then I am asking it to perform arithmetic on it.
>>
>> Is there a reason you are saving it as the string?
>> What happens when you save it as decimal?
>>
>
> Well, maybe you know something that I don't, but my understanding is that
> sqlite3 has a very limited range of supported data types, and decimal is not
> one of them.
>
> The stackoverflow article explains how to emulate a decimal type, and it
> works well most of the time.
>
> I found that I could reproduce the problem using sqlite3 directly, without
> using Python, so I have sent a post to the sqlite3 mailing list. I will
> report back with any info received.

Yes, I saw your post to sqlite3 ML.
And I do know that by default sqlite3 does not have many types supported.

However, all you need to do is save it as DECIMAL(10,2).
It is supported is sqlite3 and it will have NUMERIC affinity (ref 1)
or REAL (ref 2), which means the data will
be stored as decimals and not a string.

Ref.: 1) http://www.tutorialspoint.com/sqlite/sqlite_data_types.htm
2) https://www.sqlite.org/datatype3.html

Thank you.

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


Re: python script for dwonload free anything?

2015-12-11 Thread Laura Creighton
In a message of Fri, 11 Dec 2015 06:29:33 -0800, hienm...@gmail.com writes:
>i want create script for download free 3d model from nonecg.com like 
>https://github.com/nishad/udemy-dl-windows , this script download free udemy 
>video lesson. Anyone can tell e, how to create script like that?
>-- 
>https://mail.python.org/mailman/listinfo/python-list

I think you will find this PyPi project interesting.
https://github.com/rg3/youtube-dl/

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


Re: python script for dwonload free anything?

2015-12-11 Thread Mark Lawrence

On 11/12/2015 14:29, hienm...@gmail.com wrote:

i want create script for download free 3d model from nonecg.com like 
https://github.com/nishad/udemy-dl-windows , this script download free udemy 
video lesson. Anyone can tell e, how to create script like that?



Any (semi)decent IDE and/or editor should help you to create a script. 
Worst case if you're on Windows there's always Notepad but I would not 
recommend it.


If you need more data you'll need a better question so I suggest you 
read this http://www.catb.org/esr/faqs/smart-questions.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: python script for dwonload free anything?

2015-12-11 Thread hienmizu
thank you laura, but i know this paid 3d model: 
http://www.nonecg.com/tokyo-shibuya.html. do you know that
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python variable assigning problems...

2015-12-11 Thread ICT Ezy
Dear All,
Very Sorry for the my mistake here. I code here with mu question ...

My Question:

A,B=C,D=10,11
print(A,B,C,D)
#(10,11,10,11) --> This is OK!

a=1; b=2
a,b=b,a
print(a,b)
# (1,2) --> This is OK!

x,y=y,x=2,3
print(x,y)
# (3,2) --> Question: How to explain it?
# Not understand this process. Pl explain ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python variable assigning problems...

2015-12-11 Thread Robin Koch

Am 11.12.2015 um 17:10 schrieb ICT Ezy:

Dear All,
Very Sorry for the my mistake here. I code here with mu question ...

My Question:

A,B=C,D=10,11
print(A,B,C,D)
#(10,11,10,11) --> This is OK!

a=1; b=2
a,b=b,a
print(a,b)
# (1,2) --> This is OK!

x,y=y,x=2,3
print(x,y)
# (3,2) --> Question: How to explain it?
# Not understand this process. Pl explain ...


What else would you expect?

Assigning goes from right to left:

x,y=y,x=2,3

<=>

y, x = 2, 3
x, y = y, x

Otherwise the assignment x, y = y, x would not make any sense, since x 
and y haven't any values yet.


And the execution from right to left is also a good choice, because one 
would like to do something like:


x = y = z = 0

Again, assigning from left to right woud lead to errors.

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


Re: Python variable assigning problems...

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 9:10 AM, ICT Ezy  wrote:
> Dear All,
> Very Sorry for the my mistake here. I code here with mu question ...
>
> My Question:
>
> A,B=C,D=10,11
> print(A,B,C,D)
> #(10,11,10,11) --> This is OK!
>
> a=1; b=2
> a,b=b,a
> print(a,b)
> # (1,2) --> This is OK!

This actually results in (2, 1), which is expected; you assign 1 to a
and 2 to b and then swap the values.

> x,y=y,x=2,3
> print(x,y)
> # (3,2) --> Question: How to explain it?
> # Not understand this process. Pl explain ...

The assignments happen from left to right. First, (2,3) is assigned to
(x,y), which has the effect of assigning 2 to x and then 3 to y. Next,
(2,3) is assigned to (y,x), whas the effect of assigning 2 to y and
then 3 to x, overwriting the previous assignments. Then when you do
the print, x has the value 3, and y has the value 2.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python variable assigning problems...

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 9:24 AM, Robin Koch  wrote:
> Assigning goes from right to left:
>
> x,y=y,x=2,3
>
> <=>
>
> y, x = 2, 3
> x, y = y, x
>
> Otherwise the assignment x, y = y, x would not make any sense, since x and y
> haven't any values yet.
>
> And the execution from right to left is also a good choice, because one
> would like to do something like:
>
> x = y = z = 0
>
> Again, assigning from left to right woud lead to errors.

No, it actually happens left to right. "x = y = z = 0" means "assign 0
to x, then assign 0 to y, then assign 0 to z." It doesn't mean "assign
0 to z, then assign z to y, etc." This works:

>>> d = d['foo'] = {}
>>> d
{'foo': {...}}

This doesn't:

>>> del d
>>> d['foo'] = d = {}
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'd' is not defined
-- 
https://mail.python.org/mailman/listinfo/python-list


python 351x64

2015-12-11 Thread Jay Hamm
Hi

I was trying to use your windows version of python 3.5.1 x64.

It has a conflict with a notepad++ plugin NppFTP giving 
api-ms-win-crt-runtime-I1-1-0.dll error on start up.

This seems pretty well documented on the web. The work around is to delete the 
plugin and reinstall since it borks the install.

Since about every other admin I've ever known uses notepad++, you might want to 
fix this.

Also your installer fails to set the permissions correctly:

H:\>py -m pip install requests
Collecting requests
  Downloading requests-2.8.1-py2.py3-none-any.whl (497kB)
100% || 499kB 875kB/s
Installing collected packages: requests
Exception:
Traceback (most recent call last):
  File "C:\Program Files\Python35\lib\site-packages\pip\basecommand.py", line 
211, in mainstatus = self.run(options, args)
  File "C:\Program Files\Python35\lib\site-packages\pip\commands\install.py", 
line 311, in runroot=options.root_path,
  File "C:\Program Files\Python35\lib\site-packages\pip\req\req_set.py", line 
646, in install**kwargs
  File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", 
line 803, in installself.move_wheel_files(self.source_dir, root=root)
  File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", 
line 998, in move_wheel_filesisolated=self.isolated,
  File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 339, in 
move_wheel_filesclobber(source, lib_dir, True)
  File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 310, in 
clobberensure_dir(destdir)
  File "C:\Program Files\Python35\lib\site-packages\pip\utils\__init__.py", 
line 71, in ensure_diros.makedirs(path)
  File "C:\Program Files\Python35\lib\os.py", line 241, in makedirs
mkdir(name, mode) PermissionError: [WinError 5] Access is denied: 'C:\\Program 
Files\\Python35\\Lib\\site-packages\\requests'

Once I gave myself control it started working.

This is pretty shoddy for released software.
Thanks,
Jacob Hamm (Jay) VCP-DCV, RHCE
Senior Cloud Services Engineer - VMware vCloud Air

380 Interlocken Crescent Blvd - Ste 500, Broomfield CO 80021
Office 303 942 4638 - ha...@vmware.com
Want to learn more about VMware vCloud Air?
Go to http://vcloud.vmware.com/tutorials
[vCloudAir]

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


Re: trying to force stdout to utf-8 with errors='ignore' or 'replace'

2015-12-11 Thread Adam Funk
On 2015-12-11, Peter Otten wrote:

> Adam Funk wrote:

>> but with either or both of those, I get the dreaded
>> "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
>> 562: ordinal not in range(128)".  How can I force the output to be in
>> UTF-8 & silently suppress invalid characters?
>
> (I'm assuming you are using Python 2 and that main_body is a unicode 
> instance)

The short answer turned out to be 'switch to Python 3', which I think
is what I'll do from now on unless I absolutely need a library that
isn't available there.

(AFAICT, the email parser in 2.7 returns the body as a bytestring &
doesn't actually look at the Content-Type header, & trying to decode
the body with that just made it barf in different places.)


-- 
Science is what we understand well enough to explain to a computer.  
Art is everything else we do.  --- Donald Knuth
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python 351x64

2015-12-11 Thread Mark Lawrence

On 11/12/2015 16:30, Jay Hamm wrote:

Hi

I was trying to use your windows version of python 3.5.1 x64.

It has a conflict with a notepad++ plugin NppFTP giving 
api-ms-win-crt-runtime-I1-1-0.dll error on start up.

This seems pretty well documented on the web. The work around is to delete the 
plugin and reinstall since it borks the install.

Since about every other admin I've ever known uses notepad++, you might want to 
fix this.

Also your installer fails to set the permissions correctly:

H:\>py -m pip install requests
Collecting requests
   Downloading requests-2.8.1-py2.py3-none-any.whl (497kB)
 100% || 499kB 875kB/s
Installing collected packages: requests
Exception:
Traceback (most recent call last):
   File "C:\Program Files\Python35\lib\site-packages\pip\basecommand.py", line 
211, in mainstatus = self.run(options, args)
   File "C:\Program Files\Python35\lib\site-packages\pip\commands\install.py", 
line 311, in runroot=options.root_path,
   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_set.py", line 
646, in install**kwargs
   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", 
line 803, in installself.move_wheel_files(self.source_dir, root=root)
   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", 
line 998, in move_wheel_filesisolated=self.isolated,
   File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 339, 
in move_wheel_filesclobber(source, lib_dir, True)
   File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 310, 
in clobberensure_dir(destdir)
   File "C:\Program Files\Python35\lib\site-packages\pip\utils\__init__.py", 
line 71, in ensure_diros.makedirs(path)
   File "C:\Program Files\Python35\lib\os.py", line 241, in makedirs
mkdir(name, mode) PermissionError: [WinError 5] Access is denied: 'C:\\Program 
Files\\Python35\\Lib\\site-packages\\requests'

Once I gave myself control it started working.

This is pretty shoddy for released software.
Thanks,
Jacob Hamm (Jay) VCP-DCV, RHCE
Senior Cloud Services Engineer - VMware vCloud Air

380 Interlocken Crescent Blvd - Ste 500, Broomfield CO 80021
Office 303 942 4638 - ha...@vmware.com
Want to learn more about VMware vCloud Air?
Go to http://vcloud.vmware.com/tutorials
[vCloudAir]



Patches are always welcome.  How much did you pay for this shoddy software?

--
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 351x64

2015-12-11 Thread Zachary Ware
On Fri, Dec 11, 2015 at 10:30 AM, Jay Hamm  wrote:
> Hi
>
> I was trying to use your windows version of python 3.5.1 x64.
>
> It has a conflict with a notepad++ plugin NppFTP giving 
> api-ms-win-crt-runtime-I1-1-0.dll error on start up.
>
> This seems pretty well documented on the web. The work around is to delete 
> the plugin and reinstall since it borks the install.

api-ms-win-crt-runtime-I1-1-0.dll is part of the Universal CRT; I
don't see what the relation between Python and Notepad++ is.  This
sounds like an issue with Notepad++/NppFTP, not Python.

> Since about every other admin I've ever known uses notepad++, you might want 
> to fix this.
>
> Also your installer fails to set the permissions correctly:
>
> H:\>py -m pip install requests
> Collecting requests
>   Downloading requests-2.8.1-py2.py3-none-any.whl (497kB)
> 100% || 499kB 875kB/s
> Installing collected packages: requests
> Exception:
> Traceback (most recent call last):
>   File "C:\Program Files\Python35\lib\site-packages\pip\basecommand.py", line 
> 211, in mainstatus = self.run(options, args)
>   File "C:\Program Files\Python35\lib\site-packages\pip\commands\install.py", 
> line 311, in runroot=options.root_path,
>   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_set.py", line 
> 646, in install**kwargs
>   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", 
> line 803, in installself.move_wheel_files(self.source_dir, root=root)
>   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", 
> line 998, in move_wheel_filesisolated=self.isolated,
>   File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 339, 
> in move_wheel_filesclobber(source, lib_dir, True)
>   File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 310, 
> in clobberensure_dir(destdir)
>   File "C:\Program Files\Python35\lib\site-packages\pip\utils\__init__.py", 
> line 71, in ensure_diros.makedirs(path)
>   File "C:\Program Files\Python35\lib\os.py", line 241, in makedirs
> mkdir(name, mode) PermissionError: [WinError 5] Access is denied: 
> 'C:\\Program Files\\Python35\\Lib\\site-packages\\requests'
>
> Once I gave myself control it started working.

The point of installing in C:\Program Files\ is that non-admin users
can't write there.  If you want a package installed in the global
site-packages, do it as an administrator or install Python somewhere
else (like C:\Python35\ as previous versions did, but be aware of the
security implications).  Otherwise, create a local venv (`py -3.5 -m
venv path\to\venv`), install your packages there, and use it.

> This is pretty shoddy for released software.

That seems uncalled for.

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


Re: python 351x64

2015-12-11 Thread Steven D'Aprano
Hi Jay, and welcome,!


On Sat, 12 Dec 2015 03:30 am, Jay Hamm wrote:

> Hi
> 
> I was trying to use your windows version of python 3.5.1 x64.
> 
> It has a conflict with a notepad++ plugin NppFTP giving
> api-ms-win-crt-runtime-I1-1-0.dll error on start up.
> 
> This seems pretty well documented on the web. The work around is to delete
> the plugin and reinstall since it borks the install.


I think your definition of "well documented on the web" and mine differs
greatly. I've spent ten minutes searching for various combinations
of "python", "conflict", "nppftp", "api-ms-win-crt-runtime-I1-1-0.dll" etc.
with absolutely no relevant hits. Would you mind telling us where you found
this documentation?

I did find this:

https://notepad-plus-plus.org/community/topic/7282/notepad-system-error-on-startup-api-ms-win-crt-runtime-l1-1-0-dll-is-missing

but there's no indication that this has anything to do with Python.


> Since about every other admin I've ever known uses notepad++, you might
> want to fix this.

I'm not a Windows expert, but I can't imagine how installing Python would
uninstall api-ms-win-crt-runtime-I1-1-0.dll. But if it does, then it
probably shouldn't.



> Also your installer fails to set the permissions correctly:
> 
> H:\>py -m pip install requests

[...]
>   File "C:\Program Files\Python35\lib\os.py", line 241, in makedirs   
>   mkdir(name, mode) PermissionError: [WinError 5] Access is denied:
>   'C:\\Program Files\\Python35\\Lib\\site-packages\\requests'
> 
> Once I gave myself control it started working.

What do you mean, you gave yourself "control?" Do you mean write permission?

I would expect that if you want to install to the system-wide site-packages
directory, you should be running as Administrator or other user with
permission to write to that directory.

If you don't have write permission to a directory when you are trying to
install software, of course the installation will fail. What makes you
think that this is a failure of the installer? I'm not a Windows expert,
but the behaviour looks correct to me.



> This is pretty shoddy for released software.

Well, some of us have used VMware in the past, and we could discuss "pretty
shoddy" bugs all day *cough* ESXi backup bug *cough* vcenter remote
execution exploit *cough* but since we're all friends here, how about
instead of trying to be insulting, let's try to determine exactly what the
alleged bug is so we can create a ticket and get it fixed?



-- 
Steven

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


Re: python 351x64

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 9:30 AM, Jay Hamm  wrote:
> Hi
>
> I was trying to use your windows version of python 3.5.1 x64.
>
> It has a conflict with a notepad++ plugin NppFTP giving 
> api-ms-win-crt-runtime-I1-1-0.dll error on start up.
>
> This seems pretty well documented on the web. The work around is to delete 
> the plugin and reinstall since it borks the install.
>
> Since about every other admin I've ever known uses notepad++, you might want 
> to fix this.

Laura Creighton has filed an issue based on your post to the Python
issue tracker at http://bugs.python.org/issue25842. Would you please
add some details on this issue? Googling for "python nppftp" failed to
turn up anything useful for me.

> Also your installer fails to set the permissions correctly:

How do you expect them to be set?
-- 
https://mail.python.org/mailman/listinfo/python-list


wrappers for C/C++

2015-12-11 Thread Ginga, Dick
I have inherited a product build that uses SWIG to product wrapper libraries 
for our C/C++ code. It currently builds these wrappers for 2.5, 2.6, 3.1 and 
3.2.

Is it necessary to have version specific wrappers?


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


Re: Python variable assigning problems...

2015-12-11 Thread Robin Koch

Am 11.12.2015 um 17:39 schrieb Ian Kelly:

On Fri, Dec 11, 2015 at 9:24 AM, Robin Koch  wrote:

Assigning goes from right to left:

x,y=y,x=2,3

<=>

y, x = 2, 3
x, y = y, x

Otherwise the assignment x, y = y, x would not make any sense, since x and y
haven't any values yet.

And the execution from right to left is also a good choice, because one
would like to do something like:

x = y = z = 0

Again, assigning from left to right woud lead to errors.


No, it actually happens left to right. "x = y = z = 0" means "assign 0
to x, then assign 0 to y, then assign 0 to z." It doesn't mean "assign
0 to z, then assign z to y, etc."


Oh. Ok, then, thanks for this correction.
Although it's consequent to use left-to-right precedence it's a little 
counter intuitive in the sense that the rightmost and leftmost objects 
interact. Especially with a background in mathematics. :-)


> This works:



d = d['foo'] = {}
d

{'foo': {...}}

This doesn't:


del d
d['foo'] = d = {}

Traceback (most recent call last):
   File "", line 1, in 
NameError: name 'd' is not defined


Good to know! Thank you.

--
Robin Koch

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


Re: Python variable assigning problems...

2015-12-11 Thread ICT Ezy
On Friday, December 11, 2015 at 8:24:45 AM UTC-8, Robin Koch wrote:
> Am 11.12.2015 um 17:10 schrieb ICT Ezy:
> > Dear All,
> > Very Sorry for the my mistake here. I code here with mu question ...
> >
> > My Question:
> >
> > A,B=C,D=10,11
> > print(A,B,C,D)
> > #(10,11,10,11) --> This is OK!
> >
> > a=1; b=2
> > a,b=b,a
> > print(a,b)
> > # (1,2) --> This is OK!
> >
> > x,y=y,x=2,3
> > print(x,y)
> > # (3,2) --> Question: How to explain it?
> > # Not understand this process. Pl explain ...
> 
> What else would you expect?
> 
> Assigning goes from right to left:
> 
> x,y=y,x=2,3
> 
> <=>
> 
> y, x = 2, 3
> x, y = y, x
> 
> Otherwise the assignment x, y = y, x would not make any sense, since x 
> and y haven't any values yet.
> 
> And the execution from right to left is also a good choice, because one 
> would like to do something like:
> 
> x = y = z = 0
> 
> Again, assigning from left to right woud lead to errors.
> 
> -- 
> Robin Koch

Thank you very much your answer, I had not known assignment id Right2Left 
before. I done it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python variable assigning problems...

2015-12-11 Thread ICT Ezy
On Friday, December 11, 2015 at 8:40:18 AM UTC-8, Ian wrote:
> On Fri, Dec 11, 2015 at 9:24 AM, Robin Koch  wrote:
> > Assigning goes from right to left:
> >
> > x,y=y,x=2,3
> >
> > <=>
> >
> > y, x = 2, 3
> > x, y = y, x
> >
> > Otherwise the assignment x, y = y, x would not make any sense, since x and y
> > haven't any values yet.
> >
> > And the execution from right to left is also a good choice, because one
> > would like to do something like:
> >
> > x = y = z = 0
> >
> > Again, assigning from left to right woud lead to errors.
> 
> No, it actually happens left to right. "x = y = z = 0" means "assign 0
> to x, then assign 0 to y, then assign 0 to z." It doesn't mean "assign
> 0 to z, then assign z to y, etc." This works:
> 
> >>> d = d['foo'] = {}
> >>> d
> {'foo': {...}}
> 
> This doesn't:
> 
> >>> del d
> >>> d['foo'] = d = {}
> Traceback (most recent call last):
>   File "", line 1, in 
> NameError: name 'd' is not defined

Deat Ian,
Thank you very much your answer, but
above answer from Robin Koch and your answer is different. What's the actually 
process here? I agree with Robin Koch, but your answer is correct. Pl explain 
differences ?


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


Re: Python variable assigning problems...

2015-12-11 Thread Michael Torrie
On 12/11/2015 11:00 AM, ICT Ezy wrote:
> Thank you very much your answer, I had not known assignment id Right2Left 
> before. I done it.

Except that Robin was mistaken.  Assignment is indeed left to right,
though what's being assigned is on the right.

> 

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


Re: Python variable assigning problems...

2015-12-11 Thread Michael Torrie
On 12/11/2015 11:05 AM, ICT Ezy wrote:
> Deat Ian, Thank you very much your answer, but above answer from
> Robin Koch and your answer is different. What's the actually process
> here? I agree with Robin Koch, but your answer is correct. Pl explain
> differences ?

If you go re-read the answers, you'll find Ian has explained why Robin
was incorrect, and Robin acknowledged he got it wrong.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python variable assigning problems...

2015-12-11 Thread ICT Ezy
On Friday, December 11, 2015 at 9:53:10 AM UTC-8, Robin Koch wrote:
> Am 11.12.2015 um 17:39 schrieb Ian Kelly:
> > On Fri, Dec 11, 2015 at 9:24 AM, Robin Koch  wrote:
> >> Assigning goes from right to left:
> >>
> >> x,y=y,x=2,3
> >>
> >> <=>
> >>
> >> y, x = 2, 3
> >> x, y = y, x
> >>
> >> Otherwise the assignment x, y = y, x would not make any sense, since x and 
> >> y
> >> haven't any values yet.
> >>
> >> And the execution from right to left is also a good choice, because one
> >> would like to do something like:
> >>
> >> x = y = z = 0
> >>
> >> Again, assigning from left to right woud lead to errors.
> >
> > No, it actually happens left to right. "x = y = z = 0" means "assign 0
> > to x, then assign 0 to y, then assign 0 to z." It doesn't mean "assign
> > 0 to z, then assign z to y, etc."
> 
> Oh. Ok, then, thanks for this correction.
> Although it's consequent to use left-to-right precedence it's a little 
> counter intuitive in the sense that the rightmost and leftmost objects 
> interact. Especially with a background in mathematics. :-)
> 
>  > This works:
> >
>  d = d['foo'] = {}
>  d
> > {'foo': {...}}
> >
> > This doesn't:
> >
>  del d
>  d['foo'] = d = {}
> > Traceback (most recent call last):
> >File "", line 1, in 
> > NameError: name 'd' is not defined
> 
> Good to know! Thank you.
> 
> -- 
> Robin Koch

Yeh, Your discussion is very good, really I understood correct process, Thank 
you very much all of you!  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: wrappers for C/C++

2015-12-11 Thread Chris Angelico
On Sat, Dec 12, 2015 at 4:21 AM, Ginga, Dick  wrote:
> I have inherited a product build that uses SWIG to product wrapper libraries 
> for our C/C++ code. It currently builds these wrappers for 2.5, 2.6, 3.1 and 
> 3.2.
>
> Is it necessary to have version specific wrappers?

Yes, it is, because of the way Python's internals work. But you can
probably build them all from the same source code.

I'm not sure whether you mean that those four are the _only_ versions
it's building for, or if you noted them as being particularly old
versions still being built for. Either way, you should be in full
control of your version support; if this is an internal project, you
could simply stipulate that only one version of Python is supported
(or maybe two - 2.7 and one 3.x), and save yourself some build
hassles. If you're posting it on PyPI, you can put the source code out
there and let Unix users build their own, and then you need only worry
about Windows; I haven't seen confirmation yet (as there's no official
3.6 builds), but supporting "3.5+" should be possible from a single
binary. (You would still need a separate binary for 2.7, though.)

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


Re: Python variable assigning problems...

2015-12-11 Thread ICT Ezy
On Friday, December 11, 2015 at 10:20:30 AM UTC-8, Michael Torrie wrote:
> On 12/11/2015 11:05 AM, ICT Ezy wrote:
> > Deat Ian, Thank you very much your answer, but above answer from
> > Robin Koch and your answer is different. What's the actually process
> > here? I agree with Robin Koch, but your answer is correct. Pl explain
> > differences ?
> 
> If you go re-read the answers, you'll find Ian has explained why Robin
> was incorrect, and Robin acknowledged he got it wrong.

OK. I got it!!!
Yeh, Your discussion is very good, really I understood correct process, Thank 
you very much all of you!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python variable assigning problems...

2015-12-11 Thread Jussi Piitulainen
ICT Ezy writes:
> On Friday, December 11, 2015 at 8:40:18 AM UTC-8, Ian wrote:
>> 
>> No, it actually happens left to right. "x = y = z = 0" means "assign
>> 0 to x, then assign 0 to y, then assign 0 to z." It doesn't mean
>> "assign 0 to z, then assign z to y, etc." This works:
>> 
>> >>> d = d['foo'] = {}
>> >>> d
>> {'foo': {...}}
>> 
>> This doesn't:
>> 
>> >>> del d
>> >>> d['foo'] = d = {}
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> NameError: name 'd' is not defined
>
> Deat Ian,
> Thank you very much your answer, but
> above answer from Robin Koch and your answer is different. What's the
> actually process here? I agree with Robin Koch, but your answer is
> correct. Pl explain differences ?

Python language reference, at 7.2 Assignment statements, says this:

# An assignment statement evaluates the expression list (remember that
# this can be a single expression or a comma-separated list, the latter
# yielding a tuple) and assigns the single resulting object to each of
# the target lists, from left to right.

To simplify a bit, it's talking about a statement of this form:

 target_list = target_list = target_list = expression_list

And it says what Ian said: the value of the expression is assigned to
each target *from left to right*.


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


RE: python 351x64

2015-12-11 Thread Jay Hamm
It is an issue that borks your install. That seems like your issue which 
involves notepad++. You might want to talk with them about it or more likely 
since they've not fixed it in a while - develop a work around or at least a 
message that pops up and asks if they want it fixed so the install succeeds.

Likewise if you have an option to install for all uses, then it should work 
without further intervention.

As for unfair, is this production software or is it a toy? If it is a toy, I 
withdraw my comment.

-Original Message-
From: zachary.w...@gmail.com [mailto:zachary.w...@gmail.com] On Behalf Of 
Zachary Ware
Sent: Friday, December 11, 2015 10:17 AM
To: python-list@python.org
Cc: Jay Hamm 
Subject: Re: python 351x64

On Fri, Dec 11, 2015 at 10:30 AM, Jay Hamm  wrote:
> Hi
>
> I was trying to use your windows version of python 3.5.1 x64.
>
> It has a conflict with a notepad++ plugin NppFTP giving 
> api-ms-win-crt-runtime-I1-1-0.dll error on start up.
>
> This seems pretty well documented on the web. The work around is to delete 
> the plugin and reinstall since it borks the install.

api-ms-win-crt-runtime-I1-1-0.dll is part of the Universal CRT; I don't see 
what the relation between Python and Notepad++ is.  This sounds like an issue 
with Notepad++/NppFTP, not Python.

> Since about every other admin I've ever known uses notepad++, you might want 
> to fix this.
>
> Also your installer fails to set the permissions correctly:
>
> H:\>py -m pip install requests
> Collecting requests
>   Downloading requests-2.8.1-py2.py3-none-any.whl (497kB)
> 100% || 499kB 875kB/s Installing 
> collected packages: requests
> Exception:
> Traceback (most recent call last):
>   File "C:\Program Files\Python35\lib\site-packages\pip\basecommand.py", line 
> 211, in mainstatus = self.run(options, args)
>   File "C:\Program Files\Python35\lib\site-packages\pip\commands\install.py", 
> line 311, in runroot=options.root_path,
>   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_set.py", line 
> 646, in install**kwargs
>   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", 
> line 803, in installself.move_wheel_files(self.source_dir, root=root)
>   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", 
> line 998, in move_wheel_filesisolated=self.isolated,
>   File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 339, 
> in move_wheel_filesclobber(source, lib_dir, True)
>   File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 310, 
> in clobberensure_dir(destdir)
>   File "C:\Program Files\Python35\lib\site-packages\pip\utils\__init__.py", 
> line 71, in ensure_diros.makedirs(path)
>   File "C:\Program Files\Python35\lib\os.py", line 241, in makedirs
> mkdir(name, mode) PermissionError: [WinError 5] Access is denied: 
> 'C:\\Program Files\\Python35\\Lib\\site-packages\\requests'
>
> Once I gave myself control it started working.

The point of installing in C:\Program Files\ is that non-admin users can't 
write there.  If you want a package installed in the global site-packages, do 
it as an administrator or install Python somewhere else (like C:\Python35\ as 
previous versions did, but be aware of the security implications).  Otherwise, 
create a local venv (`py -3.5 -m venv path\to\venv`), install your packages 
there, and use it.

> This is pretty shoddy for released software.

That seems uncalled for.

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


Re: How to connect the MYSQL database to Python program?

2015-12-11 Thread ICT Ezy
On Wednesday, December 9, 2015 at 1:45:26 PM UTC-8, Mark Lawrence wrote:
> On 09/12/2015 17:51, ICT Ezy wrote:
> > Pl explain me how to connect the MYSQL database to Python program?
> >
> 
> Use a search engine.  Then run up an editor, write some code, run said 
> code.  If you then have problems state your OS, Python version and 
> provide us with the full traceback.
> 
> An alternative is to write a cheque for (say) GBP 1000 payable to the 
> Python Software Foundation and if you're lucky somebody will do your 
> homework for you.
> 
> -- 
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
> 
> Mark Lawrence

Now, I installed MYSQLDB and following code was done correctly.

#!/usr/bin/python

import MySQLdb

# Open database connection
db = MySQLdb.connect("localhost","TESTDB")

# prepare a cursor object using cursor() method
cursor = db.cursor()

# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")

# Fetch a single row using fetchone() method.
data = cursor.fetchone()

print "Database version : %s " % data

# disconnect from server
db.close()


Then done following SQL statements:

#!/usr/bin/python

import MySQLdb

# Open database connection
db = MySQLdb.connect("localhost","TESTDB" )

# prepare a cursor object using cursor() method
cursor = db.cursor()


Then not correctly work following SQL statements:

>>> import MySQLdb
>>> db = MySQLdb.connect("localhost","TESTDB" )
>>> cursor = db.cursor()
>>> sql = """CREATE TABLE EMPLOYEE (
 FIRST_NAME  CHAR(20) NOT NULL,
 LAST_NAME  CHAR(20),
 AGE INT,
 SEX CHAR(1),
 INCOME FLOAT )"""
>>> cursor.execute(sql)

Traceback (most recent call last):
  File "", line 1, in 
cursor.execute(sql)
  File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in 
defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1046, "Aucune base n'a \xe9t\xe9 s\xe9lectionn\xe9e")
>>> 

How to solve the problems. pl explain me


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


Re: How to connect the MYSQL database to Python program?

2015-12-11 Thread ICT Ezy
On Wednesday, December 9, 2015 at 9:58:02 AM UTC-8, Chris Angelico wrote:
> On Thu, Dec 10, 2015 at 4:51 AM, ICT Ezy  wrote:
> > Pl explain me how to connect the MYSQL database to Python program?
> 
> You start by looking for a module that lets you do that. You can use
> your favourite web search engine, or go directly to PyPI.
> 
> Then you learn how to use that module, including learning SQL if you
> don't already know it.
> 
> ChrisA

Now, I installed MYSQLDB and following code was done correctly. 

#!/usr/bin/python 

import MySQLdb 

# Open database connection 
db = MySQLdb.connect("localhost","TESTDB") 

# prepare a cursor object using cursor() method 
cursor = db.cursor() 

# execute SQL query using execute() method. 
cursor.execute("SELECT VERSION()") 

# Fetch a single row using fetchone() method. 
data = cursor.fetchone() 

print "Database version : %s " % data 

# disconnect from server 
db.close() 


Then done following SQL statements: 

#!/usr/bin/python 

import MySQLdb 

# Open database connection 
db = MySQLdb.connect("localhost","TESTDB" ) 

# prepare a cursor object using cursor() method 
cursor = db.cursor() 


Then not correctly work following SQL statements: 

>>> import MySQLdb 
>>> db = MySQLdb.connect("localhost","TESTDB" ) 
>>> cursor = db.cursor() 
>>> sql = """CREATE TABLE EMPLOYEE ( 
 FIRST_NAME  CHAR(20) NOT NULL, 
 LAST_NAME  CHAR(20), 
 AGE INT, 
 SEX CHAR(1), 
 INCOME FLOAT )""" 
>>> cursor.execute(sql) 

Traceback (most recent call last): 
  File "", line 1, in  
cursor.execute(sql) 
  File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 205, in execute 
self.errorhandler(self, exc, value) 
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in 
defaulterrorhandler 
raise errorclass, errorvalue 
OperationalError: (1046, "Aucune base n'a \xe9t\xe9 s\xe9lectionn\xe9e") 
>>> 

How to solve the problems. pl explain me 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to connect the MYSQL database to Python program?

2015-12-11 Thread ICT Ezy
On Friday, December 11, 2015 at 10:36:33 AM UTC-8, ICT Ezy wrote:
> On Wednesday, December 9, 2015 at 9:58:02 AM UTC-8, Chris Angelico wrote:
> > On Thu, Dec 10, 2015 at 4:51 AM, ICT Ezy  wrote:
> > > Pl explain me how to connect the MYSQL database to Python program?
> > 
> > You start by looking for a module that lets you do that. You can use
> > your favourite web search engine, or go directly to PyPI.
> > 
> > Then you learn how to use that module, including learning SQL if you
> > don't already know it.
> > 
> > ChrisA
> 
> Now, I installed MYSQLDB and following code was done correctly. 
> 
> #!/usr/bin/python 
> 
> import MySQLdb 
> 
> # Open database connection 
> db = MySQLdb.connect("localhost","TESTDB") 
> 
> # prepare a cursor object using cursor() method 
> cursor = db.cursor() 
> 
> # execute SQL query using execute() method. 
> cursor.execute("SELECT VERSION()") 
> 
> # Fetch a single row using fetchone() method. 
> data = cursor.fetchone() 
> 
> print "Database version : %s " % data 
> 
> # disconnect from server 
> db.close() 
> 
> 
> Then done following SQL statements: 
> 
> #!/usr/bin/python 
> 
> import MySQLdb 
> 
> # Open database connection 
> db = MySQLdb.connect("localhost","TESTDB" ) 
> 
> # prepare a cursor object using cursor() method 
> cursor = db.cursor() 
> 
> 
> Then not correctly work following SQL statements: 
> 
> >>> import MySQLdb 
> >>> db = MySQLdb.connect("localhost","TESTDB" ) 
> >>> cursor = db.cursor() 
> >>> sql = """CREATE TABLE EMPLOYEE ( 
>  FIRST_NAME  CHAR(20) NOT NULL, 
>  LAST_NAME  CHAR(20), 
>  AGE INT, 
>  SEX CHAR(1), 
>  INCOME FLOAT )""" 
> >>> cursor.execute(sql) 
> 
> Traceback (most recent call last): 
>   File "", line 1, in  
> cursor.execute(sql) 
>   File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 205, in 
> execute 
> self.errorhandler(self, exc, value) 
>   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in 
> defaulterrorhandler 
> raise errorclass, errorvalue 
> OperationalError: (1046, "Aucune base n'a \xe9t\xe9 s\xe9lectionn\xe9e") 
> >>> 
> 
> How to solve the problems. pl explain me

I follow this link:
http://www.tutorialspoint.com/python/python_database_access.htm
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to connect the MYSQL database to Python program?

2015-12-11 Thread ICT Ezy
On Wednesday, December 9, 2015 at 1:45:26 PM UTC-8, Mark Lawrence wrote:
> On 09/12/2015 17:51, ICT Ezy wrote:
> > Pl explain me how to connect the MYSQL database to Python program?
> >
> 
> Use a search engine.  Then run up an editor, write some code, run said 
> code.  If you then have problems state your OS, Python version and 
> provide us with the full traceback.
> 
> An alternative is to write a cheque for (say) GBP 1000 payable to the 
> Python Software Foundation and if you're lucky somebody will do your 
> homework for you.
> 
> -- 
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
> 
> Mark Lawrence

I follow this link:
http://www.tutorialspoint.com/python/python_database_access.htm
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Chris Angelico
On Fri, Dec 11, 2015 at 8:21 PM, Frank Millman  wrote:
> I noticed one oddity - I am asking sqlite3 to store the value as a string,
> but then I am asking it to perform arithmetic on it.

It's an SQLite3 issue, not a Python one. I used the sqlite3
stand-alone tool to do the same thing:

sqlite> update fmtemp set bal = bal + cast('123.45' as numeric);
sqlite> select bal from fmtemp;
...
5678.7
5802.15
5925.599

And this might be why:

https://www.sqlite.org/datatype3.html

SQLite doesn't *have* all the SQL data types, and NUMERIC is one of
the ones that isn't available. If you recreate your example using
PostgreSQL, it should work fine.

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


Re: How to connect the MYSQL database to Python program?

2015-12-11 Thread Larry Martell
On Fri, Dec 11, 2015 at 1:36 PM, ICT Ezy  wrote:
> On Wednesday, December 9, 2015 at 9:58:02 AM UTC-8, Chris Angelico wrote:
>> On Thu, Dec 10, 2015 at 4:51 AM, ICT Ezy  wrote:
>> > Pl explain me how to connect the MYSQL database to Python program?
>>
>> You start by looking for a module that lets you do that. You can use
>> your favourite web search engine, or go directly to PyPI.
>>
>> Then you learn how to use that module, including learning SQL if you
>> don't already know it.
>>
>> ChrisA
>
> Now, I installed MYSQLDB and following code was done correctly.
>
> #!/usr/bin/python
>
> import MySQLdb
>
> # Open database connection
> db = MySQLdb.connect("localhost","TESTDB")

The connect should look like this:

db= MySQLdb.connect(host, user, passwd, db)

Or to be clearer:

db= MySQLdb.connect(host="localhost", user="user", passwd="password",
db="TESTDB")
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python variable assigning problems...

2015-12-11 Thread ICT Ezy
On Friday, December 11, 2015 at 10:27:29 AM UTC-8, Jussi Piitulainen wrote:
> ICT Ezy writes:
> > On Friday, December 11, 2015 at 8:40:18 AM UTC-8, Ian wrote:
> >> 
> >> No, it actually happens left to right. "x = y = z = 0" means "assign
> >> 0 to x, then assign 0 to y, then assign 0 to z." It doesn't mean
> >> "assign 0 to z, then assign z to y, etc." This works:
> >> 
> >> >>> d = d['foo'] = {}
> >> >>> d
> >> {'foo': {...}}
> >> 
> >> This doesn't:
> >> 
> >> >>> del d
> >> >>> d['foo'] = d = {}
> >> Traceback (most recent call last):
> >>   File "", line 1, in 
> >> NameError: name 'd' is not defined
> >
> > Deat Ian,
> > Thank you very much your answer, but
> > above answer from Robin Koch and your answer is different. What's the
> > actually process here? I agree with Robin Koch, but your answer is
> > correct. Pl explain differences ?
> 
> Python language reference, at 7.2 Assignment statements, says this:
> 
> # An assignment statement evaluates the expression list (remember that
> # this can be a single expression or a comma-separated list, the latter
> # yielding a tuple) and assigns the single resulting object to each of
> # the target lists, from left to right.
> 
> To simplify a bit, it's talking about a statement of this form:
> 
>  target_list = target_list = target_list = expression_list
> 
> And it says what Ian said: the value of the expression is assigned to
> each target *from left to right*.
> 
> 

Yes you correct!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: wrappers for C/C++

2015-12-11 Thread Chris Angelico
On Sat, Dec 12, 2015 at 5:40 AM, Ginga, Dick  wrote:
> Thank you Chris for this answer.  These are the _only_ versions the build 
> creates. Are you saying that wrappers for 3.5 "may" continue to support 
> future versions?

That's a Windows-specific concern; there've been changes made to how
the Windows build process works, starting with 3.5. It's usually
easiest to build against the exact Python that you want to run
against; in the case of binaries downloaded from python.org, that
basically means having one build for each version (major.minor) you
want to support. (I'm not sure about other build concerns - you
possibly need 32-bit and 64-bit builds for each version. Others will
know more than I do on that.)

For non-Windows platforms, it's usually easiest to punt on the whole
build process and just distribute source code. C compilers are more
generally available on people's Linux systems than on their Windowses.

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


Re: Python variable assigning problems...

2015-12-11 Thread ICT Ezy
On Friday, December 11, 2015 at 10:27:29 AM UTC-8, Jussi Piitulainen wrote:
> ICT Ezy writes:
> > On Friday, December 11, 2015 at 8:40:18 AM UTC-8, Ian wrote:
> >> 
> >> No, it actually happens left to right. "x = y = z = 0" means "assign
> >> 0 to x, then assign 0 to y, then assign 0 to z." It doesn't mean
> >> "assign 0 to z, then assign z to y, etc." This works:
> >> 
> >> >>> d = d['foo'] = {}
> >> >>> d
> >> {'foo': {...}}
> >> 
> >> This doesn't:
> >> 
> >> >>> del d
> >> >>> d['foo'] = d = {}
> >> Traceback (most recent call last):
> >>   File "", line 1, in 
> >> NameError: name 'd' is not defined
> >
> > Deat Ian,
> > Thank you very much your answer, but
> > above answer from Robin Koch and your answer is different. What's the
> > actually process here? I agree with Robin Koch, but your answer is
> > correct. Pl explain differences ?
> 
> Python language reference, at 7.2 Assignment statements, says this:
> 
> # An assignment statement evaluates the expression list (remember that
> # this can be a single expression or a comma-separated list, the latter
> # yielding a tuple) and assigns the single resulting object to each of
> # the target lists, from left to right.
> 
> To simplify a bit, it's talking about a statement of this form:
> 
>  target_list = target_list = target_list = expression_list
> 
> And it says what Ian said: the value of the expression is assigned to
> each target *from left to right*.
> 
> 
See also:

>>> x = [5, 6]
>>> x[i],x[j]
(5, 6)
>>> i,j=0,1
>>> x[i],x[j]=x[j],x[i]=2,3
>>> x[i],x[j]
(3, 2)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to connect the MYSQL database to Python program?

2015-12-11 Thread ICT Ezy
On Friday, December 11, 2015 at 10:52:49 AM UTC-8, larry@gmail.com wrote:
> On Fri, Dec 11, 2015 at 1:36 PM, ICT Ezy  wrote:
> > On Wednesday, December 9, 2015 at 9:58:02 AM UTC-8, Chris Angelico wrote:
> >> On Thu, Dec 10, 2015 at 4:51 AM, ICT Ezy  wrote:
> >> > Pl explain me how to connect the MYSQL database to Python program?
> >>
> >> You start by looking for a module that lets you do that. You can use
> >> your favourite web search engine, or go directly to PyPI.
> >>
> >> Then you learn how to use that module, including learning SQL if you
> >> don't already know it.
> >>
> >> ChrisA
> >
> > Now, I installed MYSQLDB and following code was done correctly.
> >
> > #!/usr/bin/python
> >
> > import MySQLdb
> >
> > # Open database connection
> > db = MySQLdb.connect("localhost","TESTDB")
> 
> The connect should look like this:
> 
> db= MySQLdb.connect(host, user, passwd, db)
> 
> Or to be clearer:
> 
> db= MySQLdb.connect(host="localhost", user="user", passwd="password",
> db="TESTDB")

if there was error generated, i remove password and user

>>> db= MySQLdb.connect(host="localhost", user="testuser", 
>>> passwd="test123",db="TESTDB")

Traceback (most recent call last):
  File "", line 1, in 
db= MySQLdb.connect(host="localhost", user="testuser", 
passwd="test123",db="TESTDB")
  File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 193, in 
__init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (1045, "Acc\xe8s refus\xe9 pour l'utilisateur: 
'testuser'@'@localhost' (mot de passe: OUI)")
>>> 
pl check it
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to connect the MYSQL database to Python program?

2015-12-11 Thread Igor Korot
 Hi,

On Fri, Dec 11, 2015 at 2:00 PM, ICT Ezy  wrote:
> On Friday, December 11, 2015 at 10:52:49 AM UTC-8, larry@gmail.com wrote:
>> On Fri, Dec 11, 2015 at 1:36 PM, ICT Ezy  wrote:
>> > On Wednesday, December 9, 2015 at 9:58:02 AM UTC-8, Chris Angelico wrote:
>> >> On Thu, Dec 10, 2015 at 4:51 AM, ICT Ezy  wrote:
>> >> > Pl explain me how to connect the MYSQL database to Python program?
>> >>
>> >> You start by looking for a module that lets you do that. You can use
>> >> your favourite web search engine, or go directly to PyPI.
>> >>
>> >> Then you learn how to use that module, including learning SQL if you
>> >> don't already know it.
>> >>
>> >> ChrisA
>> >
>> > Now, I installed MYSQLDB and following code was done correctly.
>> >
>> > #!/usr/bin/python
>> >
>> > import MySQLdb
>> >
>> > # Open database connection
>> > db = MySQLdb.connect("localhost","TESTDB")
>>
>> The connect should look like this:
>>
>> db= MySQLdb.connect(host, user, passwd, db)
>>
>> Or to be clearer:
>>
>> db= MySQLdb.connect(host="localhost", user="user", passwd="password",
>> db="TESTDB")
>
> if there was error generated, i remove password and user
>
 db= MySQLdb.connect(host="localhost", user="testuser", 
 passwd="test123",db="TESTDB")
>
> Traceback (most recent call last):
>   File "", line 1, in 
> db= MySQLdb.connect(host="localhost", user="testuser", 
> passwd="test123",db="TESTDB")
>   File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in 
> Connect
> return Connection(*args, **kwargs)
>   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 193, in 
> __init__
> super(Connection, self).__init__(*args, **kwargs2)
> OperationalError: (1045, "Acc\xe8s refus\xe9 pour l'utilisateur: 
> 'testuser'@'@localhost' (mot de passe: OUI)")


Is the account testuser exist? Does it have a password "test123"?
But more imp[ortantly - this does not have anything to do with Python.

Start by trying to connect from mySQL and try to execute some
insert/update/delete statement.

Then when you succeed, start writing python code.

Thank you.

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


Re: How to connect the MYSQL database to Python program?

2015-12-11 Thread ICT Ezy
On Friday, December 11, 2015 at 10:52:49 AM UTC-8, larry@gmail.com wrote:
> On Fri, Dec 11, 2015 at 1:36 PM, ICT Ezy  wrote:
> > On Wednesday, December 9, 2015 at 9:58:02 AM UTC-8, Chris Angelico wrote:
> >> On Thu, Dec 10, 2015 at 4:51 AM, ICT Ezy  wrote:
> >> > Pl explain me how to connect the MYSQL database to Python program?
> >>
> >> You start by looking for a module that lets you do that. You can use
> >> your favourite web search engine, or go directly to PyPI.
> >>
> >> Then you learn how to use that module, including learning SQL if you
> >> don't already know it.
> >>
> >> ChrisA
> >
> > Now, I installed MYSQLDB and following code was done correctly.
> >
> > #!/usr/bin/python
> >
> > import MySQLdb
> >
> > # Open database connection
> > db = MySQLdb.connect("localhost","TESTDB")
> 
> The connect should look like this:
> 
> db= MySQLdb.connect(host, user, passwd, db)
> 
> Or to be clearer:
> 
> db= MySQLdb.connect(host="localhost", user="user", passwd="password",
> db="TESTDB")

Ok Larry, I have success now, my names are misspelling. work well
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to connect the MYSQL database to Python program?

2015-12-11 Thread ICT Ezy
On Friday, December 11, 2015 at 11:11:22 AM UTC-8, Igor Korot wrote:
> Hi,
> 
> On Fri, Dec 11, 2015 at 2:00 PM, ICT Ezy  wrote:
> > On Friday, December 11, 2015 at 10:52:49 AM UTC-8, larry@gmail.com 
> > wrote:
> >> On Fri, Dec 11, 2015 at 1:36 PM, ICT Ezy  wrote:
> >> > On Wednesday, December 9, 2015 at 9:58:02 AM UTC-8, Chris Angelico wrote:
> >> >> On Thu, Dec 10, 2015 at 4:51 AM, ICT Ezy  wrote:
> >> >> > Pl explain me how to connect the MYSQL database to Python program?
> >> >>
> >> >> You start by looking for a module that lets you do that. You can use
> >> >> your favourite web search engine, or go directly to PyPI.
> >> >>
> >> >> Then you learn how to use that module, including learning SQL if you
> >> >> don't already know it.
> >> >>
> >> >> ChrisA
> >> >
> >> > Now, I installed MYSQLDB and following code was done correctly.
> >> >
> >> > #!/usr/bin/python
> >> >
> >> > import MySQLdb
> >> >
> >> > # Open database connection
> >> > db = MySQLdb.connect("localhost","TESTDB")
> >>
> >> The connect should look like this:
> >>
> >> db= MySQLdb.connect(host, user, passwd, db)
> >>
> >> Or to be clearer:
> >>
> >> db= MySQLdb.connect(host="localhost", user="user", passwd="password",
> >> db="TESTDB")
> >
> > if there was error generated, i remove password and user
> >
>  db= MySQLdb.connect(host="localhost", user="testuser", 
>  passwd="test123",db="TESTDB")
> >
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > db= MySQLdb.connect(host="localhost", user="testuser", 
> > passwd="test123",db="TESTDB")
> >   File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in 
> > Connect
> > return Connection(*args, **kwargs)
> >   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 193, in 
> > __init__
> > super(Connection, self).__init__(*args, **kwargs2)
> > OperationalError: (1045, "Acc\xe8s refus\xe9 pour l'utilisateur: 
> > 'testuser'@'@localhost' (mot de passe: OUI)")
> 
> 
> Is the account testuser exist? Does it have a password "test123"?
> But more imp[ortantly - this does not have anything to do with Python.
> 
> Start by trying to connect from mySQL and try to execute some
> insert/update/delete statement.
> 
> Then when you succeed, start writing python code.
> 
> Thank you.
> 
> > pl check it
> > --
> > https://mail.python.org/mailman/listinfo/python-list

OK, I have done well now, misspelling occurred. Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python 351x64

2015-12-11 Thread Zachary Ware
On Fri, Dec 11, 2015 at 11:53 AM, Jay Hamm  wrote:
> It is an issue that borks your install. That seems like your issue which 
> involves notepad++. You might want to talk with them about it or more likely 
> since they've not fixed it in a while - develop a work around or at least a 
> message that pops up and asks if they want it fixed so the install succeeds.

Could you describe the steps you took, the results you got, and the
result you expected?  It's not clear from your description what is
broken by what, and not at all clear that there is any interaction
whatsoever between Python and Notepad++.  Also, we're not in the habit
of including workarounds for bugs in software that may or may not be
installed on some fraction of systems of one particular platform.

> Likewise if you have an option to install for all uses, then it should work 
> without further intervention.

"Install for all users" means "make it readable by all users" rather
than "make it writable by all users."  As I stated previously, install
your package as an administrator if you need it in the global site
packages, or use a virtual environment that you have write access to
as a non-admin.  Or install Python elsewhere (which could be as simple
as choosing "install for just me").  Or adjust the permissions you
want adjusted yourself, as you apparently did.  The installer cannot
do everything for everyone, so it does what we believe to be best for
most use cases and errs on the side of security.

> As for unfair, is this production software or is it a toy? If it is a toy, I 
> withdraw my comment.

It seems to me there is even less call for that.  Civility breeds
civility, incivility breeds contempt.

Python is a volunteer-driven open source project, available to you at
no cost and with free community support.  If there is a bug to fix,
we're happy to fix it, but at bare minimum we need clear steps to
reproduce the problem.  Being open source, you're also more than
welcome to provide a patch that fixes your issues.

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


RE: wrappers for C/C++

2015-12-11 Thread Ginga, Dick
Thanks again for a very informative answer and these are windows wrappers.

-Original Message-
From: Python-list 
[mailto:python-list-bounces+dick.ginga=perkinelmer@python.org] On Behalf Of 
Chris Angelico
Sent: Friday, December 11, 2015 1:53 PM
Cc: python-list@python.org
Subject: Re: wrappers for C/C++

On Sat, Dec 12, 2015 at 5:40 AM, Ginga, Dick  wrote:
> Thank you Chris for this answer.  These are the _only_ versions the build 
> creates. Are you saying that wrappers for 3.5 "may" continue to support 
> future versions?

That's a Windows-specific concern; there've been changes made to how the 
Windows build process works, starting with 3.5. It's usually easiest to build 
against the exact Python that you want to run against; in the case of binaries 
downloaded from python.org, that basically means having one build for each 
version (major.minor) you want to support. (I'm not sure about other build 
concerns - you possibly need 32-bit and 64-bit builds for each version. Others 
will know more than I do on that.)

For non-Windows platforms, it's usually easiest to punt on the whole build 
process and just distribute source code. C compilers are more generally 
available on people's Linux systems than on their Windowses.

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


RE: wrappers for C/C++

2015-12-11 Thread Ginga, Dick
Thank you Chris for this answer.  These are the _only_ versions the build 
creates. Are you saying that wrappers for 3.5 "may" continue to support future 
versions?

-Original Message-
From: Python-list 
[mailto:python-list-bounces+dick.ginga=perkinelmer@python.org] On Behalf Of 
Chris Angelico
Sent: Friday, December 11, 2015 1:29 PM
Cc: python-list@python.org
Subject: Re: wrappers for C/C++

On Sat, Dec 12, 2015 at 4:21 AM, Ginga, Dick  wrote:
> I have inherited a product build that uses SWIG to product wrapper libraries 
> for our C/C++ code. It currently builds these wrappers for 2.5, 2.6, 3.1 and 
> 3.2.
>
> Is it necessary to have version specific wrappers?

Yes, it is, because of the way Python's internals work. But you can probably 
build them all from the same source code.

I'm not sure whether you mean that those four are the _only_ versions it's 
building for, or if you noted them as being particularly old versions still 
being built for. Either way, you should be in full control of your version 
support; if this is an internal project, you could simply stipulate that only 
one version of Python is supported (or maybe two - 2.7 and one 3.x), and save 
yourself some build hassles. If you're posting it on PyPI, you can put the 
source code out there and let Unix users build their own, and then you need 
only worry about Windows; I haven't seen confirmation yet (as there's no 
official
3.6 builds), but supporting "3.5+" should be possible from a single binary. 
(You would still need a separate binary for 2.7, though.)

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


Re: Hello

2015-12-11 Thread Seung Kim
See message below.

On Fri, Dec 11, 2015 at 1:13 PM, Seung Kim  wrote:

> I would like to have Python 3.5.1 MSI installer files for both 32-bit and
> 64-bit so that I can deploy the software on managed computers on campus.
>
> When I ran the silent install command line on python-3.5.1.exe, the
> registry key of QuietUninstallString showed me that the installer file was
> located under the following C:\Users\css.kim\AppData\Local\Package
> Cache\{b8440650-9dbe-4b7d-8167-6e0e3dcdf5d0}\python-3.5.1-amd64.exe"
> /uninstall /quiet.
>
> If I deploy the latest version of Python 3.5.1, the source location will
> be differently installed among managed computers. That is why I won't use
> the exe installer file. I wanted to have MSI installer files.
>
> Please, advise.
>
> --
>
>
> Seung Kim
> Software Systems Deployment Engineer
> Gallaudet Technology Services, Hall Memorial Building (HMB) W122
> Gallaudet University
> 800 Florida Avenue, NE
> Washington, D.C. 20002-3695
>



-- 


Seung Kim
Software Systems Deployment Engineer
Gallaudet Technology Services, Hall Memorial Building (HMB) W122
Gallaudet University
800 Florida Avenue, NE
Washington, D.C. 20002-3695
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 11:43 AM, Seung Kim  wrote:
> See message below.
>
> On Fri, Dec 11, 2015 at 1:13 PM, Seung Kim  wrote:
>
>> I would like to have Python 3.5.1 MSI installer files for both 32-bit and
>> 64-bit so that I can deploy the software on managed computers on campus.
>>
>> When I ran the silent install command line on python-3.5.1.exe, the
>> registry key of QuietUninstallString showed me that the installer file was
>> located under the following C:\Users\css.kim\AppData\Local\Package
>> Cache\{b8440650-9dbe-4b7d-8167-6e0e3dcdf5d0}\python-3.5.1-amd64.exe"
>> /uninstall /quiet.
>>
>> If I deploy the latest version of Python 3.5.1, the source location will
>> be differently installed among managed computers. That is why I won't use
>> the exe installer file. I wanted to have MSI installer files.
>>
>> Please, advise.

You probably want to install for all users using the InstallAllUsers=1
option. See https://docs.python.org/3/using/windows.html#installing-without-ui
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python 351x64

2015-12-11 Thread Mark Lawrence

On 11/12/2015 17:53, Jay Hamm wrote:

It is an issue that borks your install. That seems like your issue which 
involves notepad++. You might want to talk with them about it or more likely 
since they've not fixed it in a while - develop a work around or at least a 
message that pops up and asks if they want it fixed so the install succeeds.

Likewise if you have an option to install for all uses, then it should work 
without further intervention.

As for unfair, is this production software or is it a toy? If it is a toy, I 
withdraw my comment.

-Original Message-
From: zachary.w...@gmail.com [mailto:zachary.w...@gmail.com] On Behalf Of 
Zachary Ware
Sent: Friday, December 11, 2015 10:17 AM
To: python-list@python.org
Cc: Jay Hamm 
Subject: Re: python 351x64

On Fri, Dec 11, 2015 at 10:30 AM, Jay Hamm  wrote:

Hi

I was trying to use your windows version of python 3.5.1 x64.

It has a conflict with a notepad++ plugin NppFTP giving 
api-ms-win-crt-runtime-I1-1-0.dll error on start up.

This seems pretty well documented on the web. The work around is to delete the 
plugin and reinstall since it borks the install.


api-ms-win-crt-runtime-I1-1-0.dll is part of the Universal CRT; I don't see 
what the relation between Python and Notepad++ is.  This sounds like an issue 
with Notepad++/NppFTP, not Python.


Since about every other admin I've ever known uses notepad++, you might want to 
fix this.

Also your installer fails to set the permissions correctly:

H:\>py -m pip install requests
Collecting requests
   Downloading requests-2.8.1-py2.py3-none-any.whl (497kB)
 100% || 499kB 875kB/s Installing
collected packages: requests
Exception:
Traceback (most recent call last):
   File "C:\Program Files\Python35\lib\site-packages\pip\basecommand.py", line 
211, in mainstatus = self.run(options, args)
   File "C:\Program Files\Python35\lib\site-packages\pip\commands\install.py", 
line 311, in runroot=options.root_path,
   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_set.py", line 
646, in install**kwargs
   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", 
line 803, in installself.move_wheel_files(self.source_dir, root=root)
   File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", 
line 998, in move_wheel_filesisolated=self.isolated,
   File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 339, 
in move_wheel_filesclobber(source, lib_dir, True)
   File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 310, 
in clobberensure_dir(destdir)
   File "C:\Program Files\Python35\lib\site-packages\pip\utils\__init__.py", 
line 71, in ensure_diros.makedirs(path)
   File "C:\Program Files\Python35\lib\os.py", line 241, in makedirs
mkdir(name, mode) PermissionError: [WinError 5] Access is denied: 'C:\\Program 
Files\\Python35\\Lib\\site-packages\\requests'

Once I gave myself control it started working.


The point of installing in C:\Program Files\ is that non-admin users can't 
write there.  If you want a package installed in the global site-packages, do 
it as an administrator or install Python somewhere else (like C:\Python35\ as 
previous versions did, but be aware of the security implications).  Otherwise, 
create a local venv (`py -3.5 -m venv path\to\venv`), install your packages 
there, and use it.


This is pretty shoddy for released software.


That seems uncalled for.

--
Zach



Besides the fact that you don't appear to have the faintest idea what 
you're talking about, which is why the issue is all ready closed, please 
don't top post, that is not the standard on this list.


As a slight aside, just how bug ridden is your software, as I believe 
has been hinted at by other well respected members of this 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: Is vars() the most useless Python built-in ever?

2015-12-11 Thread Rick Johnson
On Tuesday, December 1, 2015 at 1:34:54 AM UTC-6, Marko Rauhamaa wrote:
> Rick Johnson :
> 
> > python was originally created to be an easy language for noobs to
> > learn
> 
> Really? That's would be a silly objective for a programming language.
> 
> > many a noob has been stumped
> 
> So?
> 
> You have to first placate the experts and the "noobs" will follow.

Okay i get it. So in your opinion, a technology is *ONLY* worthy if it requires 
a large amount of special training to wield it? 

Well, in that case you'd better start organizing a revived Luddite movement, 
because i can assure you that as we progress into the future, more and more of 
the processes that required "human specialist" will be replaced with 
computational devices that are purposefully designed to expose the most 
intuitive interface possible. 

PSST: THIS IS THE FUTURE! AND IT'S ALREADY STEAMROLLING AHEAD WITHOUT YOU!

Just about anything a human specialist can do, a machine can already, or will 
in a short time, do better, faster, and more consistently. This is a fact! We 
humans are terrible at solving problems that require extreme precision, 
repetition, data mining, memory recall, and many other processes that 
computational machines do with great ease. 

Any problem solving process can be broken down into it's atomic components, and 
reassembled as a logical algorithm. Even doctors will soon be replaced with 
machines, which will raise the quality of health care to a level never seen. 
There is almost no skill that is beyond the clutches of the algorithm.

In fact, the only skill that we humans posses which cannot yet be emulated, is 
the power of our imagination. Therefor, our goal should not be to create more 
"specialist", who toil away doing menial tasks like slaves, no, but to foster 
the creative potential of the human mind. 

By first *understanding* algorithmic processes, and then *abstracting* those 
processes in logic form, and finally *relegating* those abstractions to 
computational machines (that expose intuitive interfaces), we will enter an age 
of creative enlightenment such as this world has never seen. Just as the 
information age brought all the worlds knowledge to our fingertips, the 
relegation of menial tasks will free our bodies so that our minds can utilize 
that vast trove of knowledge to drive our technological evolution into 
overdrive. 

And as far as i'm concerned, we can't get there fast enough! 

So if you want to cling to a world where your "special skills" are nothing more 
than "job security", well then, go ahead. As for myself, and the vast majority 
of humanity, we will forge on with or without you!

 SO GOODBYE, AND GOOD RIDDANCE!!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is vars() the most useless Python built-in ever?

2015-12-11 Thread Rick Johnson
On Tuesday, December 1, 2015 at 10:49:19 PM UTC-6, Ian wrote:
> > It's a well know fact that GvR was inspired to create
> > Python from his experiences working with a language
> > called ABC -- and ABC was designed *EXCLUSIVELY* to be a
> > beginners language.
> Which is exactly what made ABC itself unsuitable for Guido's purpose, which
> was to create an *applications* language with better productivity than C to
> support users of Amoeba, the OS that he was working on at the time.

The key word here is "productivity". Intuitiveness and productivity have a 
synergy like peas and carrots! One cannot be productive if one is fighting an 
unintuitive interface. Could you drive with your toes? How about your tongue? 

Sure, even the most atrocious interface can be "learned", but what i cannot 
understand, except in the case of you being a contrarian, is why you would 
argue *AGAINST* intuitive interfaces? And believe it or not, *SYNTAX* is an 
interface! As are paradigms! 

> > Even a noob can intuit what is going on here. First we
> > have an *OBJECT* named "stdout, and we can extrapolate
> > that stdout is an abbreviation for StandardOutput. Next,
> > we see a method called "write", and, if our IQ is above
> > room temperature, then we can extrapolate what that
> > method will do.
> 
> This is absurd. You postulate a beginner so rank that they can't understand
> what "print" means, yet you expect them to intuitively know:
> 
> 1) what an object is;
> 
> 2) what a method is;
> 
> 3) that a method is identified by placing a period between the object and
> the name of the method;
> 
> 4) what "output" is in the context of programming;
> 
> 5) and not be confused about what makes the output "standard".

You accuse me of Reductio Ad Adsurdium, yet you commit the same offense, and 
then put words in my mouth?

Of course i don't expect a "rank noob" to understand these concepts 
*immediately*, however, the learning curve will be greatly reduced, and the 
depth of knowledge greatly expanded, when a clear path of consistent 
intuitiveness is baked-into the learning process -- it's all about breadcrumbs 
my dear boy, breadcrumbs!

THE PRINT FUNCTION HAS TWO MAJOR ISSUES IN THE CONTEXT OF INTUITIVENESS:

(1) When laymen consider the word "print" (in the context of computing), they 
first think of "sending a document to a printing device". LIKE IT NOT, "PRINT" 
IS A CONCEPTUAL CHAMELEON! It does the worst thing it can do, it distracts! 

(2) The path to the underlying process is not even remotely clear. LIKE IT NOT, 
PRINT IS "MAGIC SYNTAX". 

Of course the noob is not going to immediately intuit every atomic component of 
`stdout.write("blah")`, however, the road signs are there, and all he need to 
do is follow them. In fact, by learning from my example, not only will the noob 
learn the "magic" that exists under the hood, he will also learn a vital lesson 
(while dissecting the components) about the power of "divide and conquer". 

If we were to create a thought exercise that juxtaposes your argument with 
mine, we would find a great example in the "search for hidden treasure". You 
expect the noob to go into a dessert without a map and dig holes until he 
locates the treasure or dies of exhaustion. Whereas i will not only give the 
noob a map, i will draw a clear path on the map to the destination -- all he 
need to do is navigate! I don't know what's more absurd: your argument, or your 
ego?

> You're describing this as if your hypothetical beginner were learning
> Python in a vacuum. In reality, people learn from a teacher, or a book, or
> at minimum a tutorial.

Hmm. I'll bet you create teeny tiny variable names and then write a paragraph 
to describe them. Does the concept of "Self Documentation" mean anything to 
you? And, when correctly designed, the only tutorial that is needed is the the 
syntax! Heck, we are not writing assembly code here man, we're writing Python 
code for Guido's sake!

> Here's how you teach somebody what "print" does: instruct them to type
> print("hello world") at the interactive prompt. Note that Python writes
> "hello world" as a result. If they really want, they can check their
> printer and see that nothing came out. That's it. The student now
> understands what "print" means.

Yes, the timeless method of "trial and error" is expected if you're a trail 
blazer and there exists no previous knowledge, however, when this sort of 
teaching paradigm is used in areas where the processes have been previously 
dissected, it reflects a sadistic nature within the teacher. I'm of the opinion 
that learning "old tech" should be as intuitive as possible, and that, as 
knowledge spreads, we all prosper. However, you seem to adopt the teaching 
methods of a drunken and disorderly college sorority house captain. Students 
are not pledges to be tortured. They are our the future. And when we undermine 
them, we undermine our ourselves. 

 PUT THAT IN YOUR INTERPRETER AND RUN IT!
-- 
https://mail.pyth

Can anyone help me modify the code so the ball starts in random directions

2015-12-11 Thread phamtony33
Can anyone direct me in the direction where to start the code for the 
randomized of the  ball  to start.

from Tkinter import *
window = Tk()
canvas = Canvas(window, width=500, height=500, background="green")
canvas.pack()

def mouse_paddle_move(event):
mouseY = event.y
current_coords = canvas.coords("paddle")
x1 = current_coords[0]
y1 = current_coords[1]
x2 = current_coords[2]
y2 = current_coords[3]
height = (y2 - y1)
canvas.coords("paddle", x1, mouseY - (height/2), x2, mouseY + 
(height/2))

def move_ball(speed_x, speed_y, score):
box = canvas.bbox("ball")
x1 = box[0]
y1 = box[1]
x2 = box[2]
y2 = box[3]


if x2 >= 500:
canvas.create_text(250, 250, text="Game Over!")
return


box = canvas.bbox("paddle")
px1 = box[0]
py1 = box[1]
px2 = box[2]
py2 = box[3]
if x2 > px1 and y2 > py1 and y1 < py2:

speed_x = -1.2 * (abs(speed_x))
speed_y = 1.2 * speed_y


score = score + 1
canvas.itemconfig("score_text", text="Score: " + str(score))


if x1 <= 0:
speed_x = -1 * speed_x


if y2 >= 500 or y1 <= 0:
speed_y = -1 * speed_y

canvas.move("ball", speed_x, speed_y)
canvas.after(30, move_ball, speed_x, speed_y, score) 


canvas.create_oval(225, 225, 275, 275, fill="blue", tags="ball")
canvas.create_rectangle(450, 200, 455, 300, fill="red", tags="paddle")
canvas.create_text(250, 10, tags = "score_text", text="Score: 0")


move_ball(-10, 7, 0)


canvas.bind('', mouse_paddle_move)

mainloop()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can anyone help me modify the code so the ball starts in random directions

2015-12-11 Thread Rick Johnson
On Friday, December 11, 2015 at 5:20:13 PM UTC-6, phamt...@gmail.com wrote:
> Can anyone direct me in the direction where to start the code for the 
> randomized of the  ball  to start.

No, because your problem needs to be simplified first. A good first step would 
be to create a new script that only displays a canvas and draws an oval at a 
random spot when a button is pressed (or some other easy interface method) Once 
you can reliably create random ovals on command, only then do you want to work 
that code into the larger program. 

The stdlib has a module for creating random numbers and ranges. 
-- 
https://mail.python.org/mailman/listinfo/python-list



Re: Can anyone help me modify the code so the ball starts in random directions

2015-12-11 Thread phamtony33
from Tkinter import *
window = Tk()
canvas = Canvas(window, width=500, height=500, background="green")
canvas.pack()

def mouse_paddle_move(event):
mouseY = event.y
current_coords = canvas.coords("paddle")
x1 = current_coords[0]
y1 = current_coords[1]
x2 = current_coords[2]
y2 = current_coords[3]
height = (y2 - y1)
canvas.coords("paddle", x1, mouseY - (height/2), x2, mouseY + 
(height/2))

def move_ball(speed_x, speed_y, score):
box = canvas.bbox("ball")
x1 = box[0]
y1 = box[1]
x2 = box[2]
y2 = box[3]

#if ball hits right wall, you lose
if x2 >= 500:
canvas.create_text(250, 250, text="Game Over!")
return # exit function

# if ball hits paddle...
box = canvas.bbox("paddle")
px1 = box[0]
py1 = box[1]
px2 = box[2]
py2 = box[3]
if x2 > px1 and y2 > py1 and y1 < py2:
# bounce with 20% more speed
speed_x = -1.2 * (abs(speed_x))
speed_y = 1.2 * speed_y

# update score
score = score + 1
canvas.itemconfig("score_text", text="Score: " + str(score))

# if ball hits left wall it bounces
if x1 <= 0:
speed_x = -1 * speed_x

# if ball hits top or bottom walls it bounces
if y2 >= 500 or y1 <= 0:
speed_y = -1 * speed_y

canvas.move("ball", speed_x, speed_y)
canvas.after(30, move_ball, speed_x, speed_y, score) # repeat in 30 ms

# create ball, paddle, and score text.
canvas.create_oval(225, 225, 275, 275, fill="blue", tags="ball")
canvas.create_rectangle(450, 200, 455, 300, fill="red", tags="paddle")
canvas.create_text(250, 10, tags = "score_text", text="Score: 0")

# make the ball move 10 pixels left, 7 down, with initial score at 0
move_ball(-10, 7, 0)

# setup mouse handler
canvas.bind('', mouse_paddle_move)

mainloop()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can anyone help me modify the code so the ball starts in random directions

2015-12-11 Thread Steven D'Aprano
On Sat, 12 Dec 2015 10:19 am, phamton...@gmail.com wrote:

> Can anyone direct me in the direction where to start the code for the
> randomized of the  ball  to start.

[...]
> move_ball(-10, 7, 0)


That starts the ball moving, with x-speed of -10 and y-speed of 7. Instead
use something similar to this:


import random
xspeed = random.randint(-20, 20)
yspeed = random.randint(-10, 10)

move_ball(xspeed, yspeed, 0)




-- 
Steven

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


Re: Can anyone help me modify the code so the ball starts in random directions

2015-12-11 Thread phamtony33
On Friday, December 11, 2015 at 7:55:59 PM UTC-5, Steven D'Aprano wrote:
> On Sat, 12 Dec 2015 10:19 am, phamton...@gmail.com wrote:
> 
> > Can anyone direct me in the direction where to start the code for the
> > randomized of the  ball  to start.
> 
> [...]
> > move_ball(-10, 7, 0)
> 
> 
> That starts the ball moving, with x-speed of -10 and y-speed of 7. Instead
> use something similar to this:
> 
> 
> import random
> xspeed = random.randint(-20, 20)
> yspeed = random.randint(-10, 10)
> 
> move_ball(xspeed, yspeed, 0)
> 
> 
> 
> 
> -- 
> Steven

Oh yes! Thank you so much!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can anyone help me modify the code so the ball starts in random directions

2015-12-11 Thread Erik

Hi,

On 11/12/15 23:19, phamton...@gmail.com wrote:

Can anyone direct me in the direction where to start the code for the 
randomized of the  ball  to start.


Your questions over the last week or so appear to be homework 
assignments. However, I'll give you a hint: in the interactive 
interpreter shell, try:


>>> import random
>>> help(random)

Read that and try to work out how you might apply one of the functions 
to your problem.


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


Re: Can anyone help me modify the code so the ball starts in random directions

2015-12-11 Thread Erik

Hi,

On 11/12/15 23:19, phamton...@gmail.com wrote:

Can anyone direct me in the direction where to start the code for the 
randomized of the  ball  to start.


Your questions over the last week or so appear to be homework 
assignments. However, I'll give you a hint: in the interactive 
interpreter shell, try:


>>> import random
>>> help(random)

Read that and try to work out how you might apply one of the functions 
to your problem.


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


Re: Is vars() the most useless Python built-in ever?

2015-12-11 Thread Steven D'Aprano
On Sat, 12 Dec 2015 09:13 am, Rick Johnson wrote:

> Intuitiveness and productivity have a
> synergy like peas and carrots! One cannot be productive if one is fighting
> an unintuitive interface. Could you drive with your toes? How about your
> tongue?

Drive a car with my tongue? Perhaps not, but I could drive a car with my
mouth if it were equipped with a sufficiently powerful interface.

"Driver, please take me to the airport."


> Sure, even the most atrocious interface can be "learned", but what i
> cannot understand, except in the case of you being a contrarian, is why
> you would argue *AGAINST* intuitive interfaces? And believe it or not,
> *SYNTAX* is an interface! As are paradigms!

I do believe that you are arguing against a strawman. I don't think that
anyone here has argued *against* "intuitiveness", all else being equal. But
you are glossing over a whole lot of real complexity:

- what makes you think all else actually is equal?

- who decides what is intuitive and what isn't? why should we take 
  your word over what's intuitive and what isn't?

- intuitive for who? my dad, who has never used a computer? my mum, 
  who has used a computer but only for word processing and web 
  browsing? a ten year old maths prodigy? a thirty year veteran 
  of C programming? a beginner to programming with a month's 
  experience in PHP?

- what level of power are we willing to forgo in order to keep 
  the language "intuitive"?

- what the hell does "intuitive" mean anyway?

I know what the definition of the word is, but it doesn't apply to
programming language interfaces. As has been pointed out many times, the
only truly intuitive interface is the nipple. Everything else has to be
learned.

In practice, "intuitive interface" gets bandied about in two ways:

(1) Some people use it as a thought-terminating cliché. What they really
mean is that they want this interface feature, for reasons of their own,
and by calling it 'intuitive', they hope to bamboozle or intimidate others
into backing down and accepting the feature. Who could possibly be
against "intuitive" interfaces? That's like being against "usefulness",
or "flexibility".

When people start protesting about others being "against intuitive
interfaces" (especially if they SHOUT the word "against", that's an good
sign that they're using it as a thought-terminating cliché. To these
people, "intuitive" is like "New And Improved!!!" to advertisers.

(2) Others use it to mean an interface which is:

* predictable;
* consistent;
* easy to explore and learn;
* and "easy to use" in some vague sense.


They recognise that what seems unpredictable to one person may be perfectly
predictable to a more experienced user.

They recognise that consistency is partly a function of the user's own
understanding, not just they language alone. Even if the language is
designed with a single, consistent model (e.g. "everything is an object"),
if the user's mental model is wrong, they will fail to recognise the
consistency, or look for it in the wrong places.

And most importantly, they recognise that programmers are beginners for
perhaps 1% of their programming life: you might be completely new to
programming for three months out of a 30 year span of programming. Why
optimize the language for something that you will use for less than 1% of
your productive lifespan? Apart from intentional beginner's languages like
Scratch, for most languages it makes sense to add power even if it
increases the learning curve.

https://scratch.mit.edu/about/


[...]
> THE PRINT FUNCTION HAS TWO MAJOR ISSUES IN THE CONTEXT OF INTUITIVENESS:
> 
> (1) When laymen consider the word "print" (in the context of computing),
> they first think of "sending a document to a printing device". 

No they don't. They think of printing to the screen, not printing to paper.

Even if they think of printing to paper, it takes them less than a second to
learn otherwise. That's a fantastic user interface: you can learn and
explore the functionality of the language very easily.

(One of the weaknesses of Python, and nearly all mainstream programming
languages, is that there is nothing even remotely like an easy-to-explore
UI for programming GUI applications.)


> (2) The path to the underlying process is not even remotely clear. LIKE IT
> NOT, PRINT IS "MAGIC SYNTAX".

print does what it says of the tin: it prints (to the screen). You don't
have to understand how it manages that to use it effectively, just as you
don't have to understand calculus in order to use math.sqrt().



-- 
Steven

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


Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman
"Chris Angelico"  wrote in message 
news:captjjmor6newucco7xtsswyyfbgwcwz8jt-mjjkysjocfu7...@mail.gmail.com...


On Fri, Dec 11, 2015 at 8:21 PM, Frank Millman  wrote:
> I noticed one oddity - I am asking sqlite3 to store the value as a 
> string,

> but then I am asking it to perform arithmetic on it.



It's an SQLite3 issue, not a Python one. I used the sqlite3
stand-alone tool to do the same thing:



sqlite> update fmtemp set bal = bal + cast('123.45' as numeric);
sqlite> select bal from fmtemp;
...
5678.7
5802.15
5925.599



You are right. I am still investigating alternatives, and will report back, 
but here is a quick question.


I can reproduce your example above. However, if I set the initial value to 
5678.7, then the sequence goes


5678.7
5802.15
5925.6
6049.05
6172.5

I would have thought that adding 123.45 to 5802.15 would always produce the 
same result, but here it seems to depend on prior events.


Any idea why? Academic interest only, but I am curious.

Frank


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


Re: Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Frank Millman
"Igor Korot"  wrote in message 
news:CA+FnnTyZY_1=62rbk_kkz39tkeoa6jvmfn9qs17as-2yd4d...@mail.gmail.com...


Yes, I saw your post to sqlite3 ML.
And I do know that by default sqlite3 does not have many types supported.

However, all you need to do is save it as DECIMAL(10,2).
It is supported is sqlite3 and it will have NUMERIC affinity (ref 1)
or REAL (ref 2), which means the data will
be stored as decimals and not a string.



Do you mean CREATE TABLE fmtemp (acno INT, balance DECIMAL(10,2));  ?

I tried that, but I got exactly the same result.

The answer, as explained by several people on the sqlite3 ML, is that 
sqlite3 does not have a true decimal type and therefore uses floating point 
internally. As we all know from many questions asked on this forum, floating 
point and exact decimal representation are incompatible.


Frank


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


Re: Is vars() the most useless Python built-in ever?

2015-12-11 Thread Chris Angelico
On Sat, Dec 12, 2015 at 3:44 PM, Steven D'Aprano  wrote:
> On Sat, 12 Dec 2015 09:13 am, Rick Johnson wrote:
>
>> Intuitiveness and productivity have a
>> synergy like peas and carrots! One cannot be productive if one is fighting
>> an unintuitive interface. Could you drive with your toes? How about your
>> tongue?
>
> Drive a car with my tongue? Perhaps not, but I could drive a car with my
> mouth if it were equipped with a sufficiently powerful interface.
>
> "Driver, please take me to the airport."

Bring on the self-driving cars! They're already comparable to human
drivers in skill. Instead of getting my sister to chauffeur me around,
I could just hop in my automatic car, tell it my destination, and sit
back with my laptop. All I need is for them to become more affordable.

> In practice, "intuitive interface" gets bandied about in two ways:
>
> (2) Others use it to mean an interface which is:
>
> * predictable;
> * consistent;
> * easy to explore and learn;
> * and "easy to use" in some vague sense.
>
>
> They recognise that what seems unpredictable to one person may be perfectly
> predictable to a more experienced user.

Which really means that "intuitive" is a feature of
skill/comprehension transference. This is the exact reason for the
extensive use of metaphors in design - even though those metaphors
often get orphanned, they are useful. How many people have actually
carried around a folder full of documents? A few of you, maybe? How
many of you instantly understand what a folder is, and that you can
drag documents into it? Everyone. It makes perfect sense that you
should be able to put stuff inside other stuff, so we can extend that
to "compressed folders" or "shared folders" or "backed-up folders" or
any other adjective you care to use. These are then touted as
"intuitive" - eg I can use Dropbox by just sticking something into the
Dropbox folder, ergo this interface is intuitive.

Most modern languages seem to assume at least some knowledge of
mathematics (maybe as far as algebra). It's considered intuitive that
(1.0 + 2.0 / 6.0) should be equal to 1.333, because the fraction bar
translates fairly readily into the slash. (And it doesn't equal 0.5,
because the order of operations demands it.) Learning that you need
the asterisk for multiplication is usually not a problem - at worst,
it's the price you pay for multi-letter names (xy is distinct from
x*y). Give people a staircase of small comprehensions and they'll
master it; shove them up against a wall of new knowledge and they
can't mantle up.

>> (1) When laymen consider the word "print" (in the context of computing),
>> they first think of "sending a document to a printing device".
>
> No they don't. They think of printing to the screen, not printing to paper.
>
> Even if they think of printing to paper, it takes them less than a second to
> learn otherwise. That's a fantastic user interface: you can learn and
> explore the functionality of the language very easily.

Maybe if you had people entering code on a typewriter and seeing the
output two hours later on parchment, then they'd assume it meant print
to paper. Does anyone these days even print out listings?

There are two broad types of code: Simple and complex. There are two
broad types of job: Common and unusual. If you see a very simple piece
of code, you will generally expect that it's doing something common.
Let's posit a domain-specific language for building objects for a
MMORPG. Here's a piece of code, with all crucial keywords replaced
with names from my current D&D campaign:

soyutlanma on_wield(player)
[[[
   parildiyor player#level >> 72
   [[[
  dogmakta «You cannot wield this weapon.»
  uzakta
   ]]]
   parildiyor player#classes << {«bard»}
   [[[
  dogmakta «You can ne'er wield this weapon.»
  uzakta
   ]]]
   dogmakta «It feels strong and sturdy in your hand.»
   taneleri item, inventory
   [[[
  parildiyor kaylee<->item
  [[[
  dogmakta «Your helmet glows brightly with increased magic!»
  ]]]
   ]]]
]]]

So, what operations do you think would be sufficiently common to
justify language keywords? I've deliberately made them nonsense so
there's no clues from the words themselves, but I expect that anyone
here should have a reasonable shot at figuring out what things might
mean. Voila! I've made an intuitive language. Right?

Sending content to a printer is at least as complicated as writing to
a file on disk. I would expect that any language keyword or built-in
function for generating paper output should, at a minimum, stipulate
which printer it's going to, and have a means of saying "I'm done with
that page now". We don't tend tto "log to prn" these days, so you
wouldn't expect to see a command/function to "write this line to the
printer, and if there are 66 lines written, push that page out and
bring the next one in".

> (One of the weaknesses of Python, and nearly all mainstream programming
> languages, is that there is nothing even remot

Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Chris Angelico
On Sat, Dec 12, 2015 at 4:10 PM, Frank Millman  wrote:
> I can reproduce your example above. However, if I set the initial value to
> 5678.7, then the sequence goes
>
> 5678.7
> 5802.15
> 5925.6
> 6049.05
> 6172.5
>
> I would have thought that adding 123.45 to 5802.15 would always produce the
> same result, but here it seems to depend on prior events.
>
> Any idea why? Academic interest only, but I am curious.

You weren't adding 123.45 to 5802.15. Here's why.

The number 123.45 is actually represented as:

>>> 123.45.as_integer_ratio()
(8687021468732621, 70368744177664)

that is, 8687021468732621/2**46. The exact value you want is actually
a repeating binary fraction:

0b011.0111001100110011001100...

with the 1100 part repeating. Python rounds this up to
0b0110111001100110011001100110011001100110011001101, with a
notation that this has an exponent of -46. (Presumably SQLite3 is
doing the same, but I'm using Python's introspection here. This is all
IEEE 754 floating point.)

So when you set the initial value to 0 and then add 123.45 fifty
times, you're adding that tiny bit of rounding error fifty times, too.
When you set your initial value to 5678.7, you're skipping most of the
accumulated error, and so the result still looks the same. When you
printed out something that looked fine, it's because it actually
rounded to the value you started with; that is to say, you weren't
working with 5802.15, but with something really REALLY close to it.
When you added one more of that rounding error, you tipped the sum
across a boundary mark, and suddenly it didn't look like the decimal
number you were expecting; but in reality, it never was.

There's a lot of academic interest to be found in this, and a lot of
fun to be had playing around. If you want to learn more, separate this
from SQLite3 and just play around in Python - you'll find it easier.

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


Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman
"Chris Angelico"  wrote in message 
news:CAPTjJmoPXFSnXe1QA8MjjncBZBpqNkztha8YHJv=mbm--ze...@mail.gmail.com...



On Sat, Dec 12, 2015 at 4:10 PM, Frank Millman  wrote:
> I can reproduce your example above. However, if I set the initial value 
> to

> 5678.7, then the sequence goes
>
> 5678.7
> 5802.15
> 5925.6
> 6049.05
> 6172.5
>
> I would have thought that adding 123.45 to 5802.15 would always produce 
> the

> same result, but here it seems to depend on prior events.
>
> Any idea why? Academic interest only, but I am curious.

You weren't adding 123.45 to 5802.15. Here's why.


[snip really interesting explanation]

Wow, thanks for that, Chris. Consider my academic curiosity well and truly 
satisfied :-)


I have found a workaround for my problem, but I will post that in a separate 
message - still testing to make sure it is 100%.


Frank


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


Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman

"Frank Millman"  wrote in message news:n4ei3l$b98$1...@ger.gmane.org...

I need to store Decimal objects in a sqlite3 database, using Python 3.4 on 
Windows 7.


I followed the instructions here -


http://stackoverflow.com/questions/6319409/how-to-convert-python-decimal-to-sqlite-numeric

It seemed to work well, but then I hit a problem.


[...]

I have found a workaround for my problem, but first I needed to understand 
what was going on more clearly. This is what I have figured out.


1. The solution in the SO article is a bit of sleight of hand, though very 
effective. It does not create a Decimal type in sqlite3. It simply provides 
a way of converting Decimal objects to strings when you pass them into the 
database, and converting them back to Decimal types when you read them back.


2. This works if you only use sqlite3 as a storage mechanism, and use Python 
to perform any arithmetic required. It fails when you try to use sqlite3 to 
perform arithmetic, as it uses floating point internally and suffers from 
the same problem that Python does when trying to mix floating point and 
precise decimal representation.


3. Normally I do use Python to perform the arithmetic, but in this situation 
I wanted to do the following -


   UPDATE table SET balance = balance + ? WHERE date > ?

It would be very inefficient to read every row into Python, perform the 
addition, and write it back again.


4. The Python sqlite3 module allows you to create a user-defined function 
that you can use from within SQL statements. I realised I could use this to 
get the best of both worlds. I wrote the following function -


   def aggregate(curr_value, aggr_value):
   return '#{}'.format(D(curr_value[1:]) + D(aggr_value[1:]))

and added this to the connection -

   conn.create_function('aggregate', 2, aggregate)

I could then rewrite my statement as -

   UPDATE table SET balance = aggregate(balance, ?) WHERE date > ?

5. The reason for the '#' in the above function is that sqlite3 passes the 
current value of 'balance' into my function, and it has a bad habit of 
trying to second-guess the data-type to use. Even though I store it as a 
string, it passes in an integer or float. Prefixing it with a '#' forces it 
to remain as a string.


My adapters therefore now look like this -

   # Decimal adapter (store Decimal in database as str)
   sqlite3.register_adapter(D, lambda d:'#'+str(d))

   # Decimal converter (convert back to Decimal on return)
   sqlite3.register_converter('DEC', lambda s: D(s.decode('utf-8')[1:]))

6. Putting it all together, I can now run my test program -

   while True:
   print(cur.execute("SELECT bal FROM fmtemp").fetchone()[0])
   cur.execute("UPDATE fmtemp SET bal = aggregate(bal, ?)", 
(D('123.45'),))

   q = input()
   if q == 'q':
   break

and it runs up to 123450.00 without misbehaving.

Hope this is of interest.

Frank


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


Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Chris Angelico
IOn Sat, Dec 12, 2015 at 6:31 PM, Frank Millman  wrote:
> I have found a workaround for my problem, but first I needed to understand
> what was going on more clearly. This is what I have figured out.
>
> 1. The solution in the SO article is a bit of sleight of hand, though very
> effective. It does not create a Decimal type in sqlite3. It simply provides
> a way of converting Decimal objects to strings when you pass them into the
> database, and converting them back to Decimal types when you read them back.
>
> 2. This works if you only use sqlite3 as a storage mechanism, and use Python
> to perform any arithmetic required. It fails when you try to use sqlite3 to
> perform arithmetic, as it uses floating point internally and suffers from
> the same problem that Python does when trying to mix floating point and
> precise decimal representation.

There's another possibility, and that's fixed-point arithmetic. You
store the numbers as integers - probably cents, if you're talking
about dollar amounts - and as long as the scaled values fit inside the
available integer type (probably 64-bit), you'll be fine.

Or, of course, you could switch to a database back end that actually
supports NUMERIC data.

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