Client support automation and self service

2016-05-03 Thread musoke wilson
Hi Guys

Currently working with a team to automate business operations and client 
support for a small enterprise.

Key requirements:
Clients to register, log queries and initiate service request through The Web 
and/or Mobile APP
Clear tracking by the CRM team (SR alert through email/mobile APP)
Real time support (IM/email/mobile phone APP)
Analysis & Visualization of enrollment/Usage stats 

We are considering using possibility of using the Python-twisted framework

Kindly advise if python & twisted framework are appropriate tools and any other 
possible open source solutions to avoid re-inventing the wheel

regards


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


Re: Client support automation and self service

2016-05-03 Thread jmp

On 05/03/2016 10:02 AM, musoke wilson wrote:

Hi Guys

Currently working with a team to automate business operations and client 
support for a small enterprise.

Key requirements:
Clients to register, log queries and initiate service request through The Web 
and/or Mobile APP
Clear tracking by the CRM team (SR alert through email/mobile APP)
Real time support (IM/email/mobile phone APP)
Analysis & Visualization of enrollment/Usage stats

We are considering using possibility of using the Python-twisted framework

Kindly advise if python & twisted framework are appropriate tools and any other 
possible open source solutions to avoid re-inventing the wheel

regards


Wilson



If no one in your team is able to answer that question I'd rather seek 
for professional support than asking this mailing list.


You need something better than "yes twisted can do what you want". (it 
surely can)


However, regarding open source alternative, you could implement a client 
support using bugzilla, probably with a litle bit of tuning. 
https://www.bugzilla.org/


Regarding "business operations" which I'm not sure what it means 
exactly, look at http://www.tryton.org/


jm


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


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread pavlovevidence
On Friday, April 29, 2016 at 6:55:56 PM UTC-7, Christopher Reimer wrote:
> On 4/29/2016 6:29 PM, Stephen Hansen wrote:
> > If isupper/islower were perfect opposites of each-other, there'd be no 
> > need for both. But since characters can be upper, lower, or *neither*, 
> > you run into this situation.
> 
> Based upon the official documentation, I was expecting perfect opposites.
> 
> str.islower(): "Return true if all cased characters [4] in the string 
> are lowercase and there is at least one cased character, false otherwise."
> 
> https://docs.python.org/3/library/stdtypes.html?highlight=islower#str.islower
> 
> str.isupper(): "Return true if all cased characters [4] in the string 
> are uppercase and there is at least one cased character, false otherwise."
> 
> https://docs.python.org/3/library/stdtypes.html?highlight=isupper#str.isupper


Just to take this discussion in a more pure logic direction.  What you call 
perfect opposites (that is, the functions being negations of each other) is not 
what the similar wording in the documentation actually implies: you shouldn't 
have been expecting that.

What you should have been expecting is a symmetry.  Say you have a string G.  
islower(G) will return a certain result.  Now take every letter in G and swap 
the case, and call that string g.  isupper(g) will always return the same 
result is islower(G).

More succinctly, for any string x, the following is always ture:

islower(x) == isupper(swapcase(x))

But that is not the same thing, and does not imply, as the following identity 
(which it turns out is not always true, as we've seen):

islower(x) == not isupper(x)


Another example of functions that behave like this are ispositive and 
isnegative.  The identity "ispositive(x) == isnegative(-x)" is always true.  
However, "ispositive(x) == not isnegative(x)" is false if x == 0.


However, I can understand your confusion, because there are some pairs of 
functions where both identities are true, and if you've seen a few of them it's 
fairly easy for your intuition to overgeneralize a bit.  An example I can think 
of offhand is iseven(x) and isodd(x), for any integer x.  The identities 
"iseven(x) == isodd(x^1)" and "iseven(x) == not isodd(x)" are both always true.


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


Python with Oracle Database Course.

2016-05-03 Thread Tarek Abulnaga
I have created Python with Oracle Database Course, and offer 50% discount till 
10-5-2016.

Any one interested in course just click on below link.

https://www.udemy.com/using-python-with-oracle-db/?

Then write coupon Code=PYTHON_ORACLE_50%25
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Chris Angelico
On Tue, May 3, 2016 at 8:00 PM,   wrote:
>
> What you should have been expecting is a symmetry.  Say you have a string G.  
> islower(G) will return a certain result.  Now take every letter in G and swap 
> the case, and call that string g.  isupper(g) will always return the same 
> result is islower(G).
>
> More succinctly, for any string x, the following is always ture:
>
> islower(x) == isupper(swapcase(x))
>
> But that is not the same thing, and does not imply, as the following identity 
> (which it turns out is not always true, as we've seen):
>
> islower(x) == not isupper(x)
>
>
> Another example of functions that behave like this are ispositive and 
> isnegative.  The identity "ispositive(x) == isnegative(-x)" is always true.  
> However, "ispositive(x) == not isnegative(x)" is false if x == 0.
>

This assumes, of course, that there is a function swapcase which can
return a string with case inverted. I'm not sure such a function
exists.

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


Re: Python Madlibs.py code and error message

2016-05-03 Thread Cai Gengyang
Ok, I got it to work with no error message finally ...

Enter a name: cai gengyang 
Enter an adjective: beautiful 
Enter a second adjective: honest 
Enter a third adjective: pretty 
Enter a verb: hit 
Enter a second verb: run 
Enter a third verb: jump 
Enter a noun: honesty 
Enter a noun: patience 
Enter a noun: happiness 
Enter a noun: danger 
Enter an animal: elephant 
Enter a food: burger 
Enter a fruit: watermelon 
Enter a number: 1985 
Enter a superhero_name: batman 
Enter a country: america 
Enter a dessert: icekachang 
Enter a year: 1984 
This morning I woke up and felt 
because _ was going to finally h 
e big _ honest. On the other sid 
onesty were many patiences prote 
eep elephant in stores. The crow 
_ to the rythym of the burger, 
all of the runs very _. happine 
o _ into the sewers and found wa 
ats. Needing help, pretty quickl 
ump. 1985 appeared and saved cai 
by flying to batman and dropping 
puddle of america. icekachang th 
leep and woke up in the year 198 
rld where dangers ruled the worl 
$









On Thursday, April 28, 2016 at 3:25:46 PM UTC+8, Steven D'Aprano wrote:
> On Thursday 28 April 2016 17:08, Stephen Hansen wrote:
> 
> > On Wed, Apr 27, 2016, at 11:55 PM, Ben Finney wrote:
> >> Stephen Hansen  writes:
> >> 
> >> > On Wed, Apr 27, 2016, at 10:32 PM, Ben Finney wrote:
> >> > > Better: when you have many semantically-different values, use named
> >> > > (not positional) parameters in the format string. [...]
> >> > > 
> >> > > https://docs.python.org/3/library/string.html#formatstrings>
> >> >
> >> > Except the poster is not using Python 3, so all of this is for naught.
> >> 
> >> Everything I described above works fine in Python 2. Any still-supported
> >> version has 'str.format'.
> > 
> > This response is completely unhelpful. The OP is using Python 2, and
> > using %-formatting, and so you give a series of examples of using
> > str.format, to, what? Confuse matters?
> 
> How about we assume good faith and give Ben the benefit of the doubt that he 
> simply made a minor and trivial misjudgement rather than accusing him of 
> intentionally trying to confuse matters?
> 
> You are correct that the OP can use % formatting with named arguments. Ben 
> is correct that the OP can also change his code to use str.format. Some 
> people hate %-formatting and cannot wait to migrate to {}-formatting, and 
> some people don't.
> 
> (For the record, Internet rumours that %-formatting is deprecated are simply 
> not correct.)
> 
> 
> 
> -- 
> Steve
-- 
https://mail.python.org/mailman/listinfo/python-list


How to become more motivated to learn Python

2016-05-03 Thread Cai Gengyang
So I have completed up to CodeAcademy's Python Unit 2 , now moving on to Unit3 
: Conditionals and Control Flow. 

But I feel my motivation wavering , at times I get stuck and frustrated when 
trying to learn a new programming language ?

This might not be a technical question per say, but it is a Python programming 
related one. How do you motivate a person (either yourself or your child) to 
become more interested in programming and stick with it ? Is determination in 
learning (especially in a tough field like software) partly genetic ?

Related , This is a very well written essay on determination by Paul Graham 
http://www.paulgraham.com/determination.html

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


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Jussi Piitulainen
Chris Angelico writes:

> This assumes, of course, that there is a function swapcase which can
> return a string with case inverted. I'm not sure such a function
> exists.

   str.swapcase("foO")
   'FOo'
-- 
https://mail.python.org/mailman/listinfo/python-list


Trouble porting glob bash behavior with argparse to windows shell

2016-05-03 Thread Sayth Renshaw
Hi

I had a simple argparse working on ubuntu bash. However now I am trying to run 
the  script on windows and it cannot work because cmd doesn't handle the glob 
like bash does.

So I am attempting to modify my script to accommodate.

As i am running python 3.5 i can use glob.glob for a list of files I believe.

Now I am specifying my arguments as 2 arguments path and extension

python script.py /mypath/XML *xml

This is my current error I have had many.

TypeError was unhandled by user code
Message: can only concatenate list (not "str") to list
'
import argparse 
import glob


parser = argparse.ArgumentParser(description=None) 


def GetArgs(parser): 
"""Parser function using argparse""" 
# parser.add_argument('directory', help='directory use',
# action='store', nargs='*')

parser.add_argument("path", nargs="+") 
parser.add_argument('-e', '--extension', default='', help='File extension 
to filter by.')
args = parser.parse_args()

files = set()
files |= set(glob.glob(args.path + '/*' + args.extension))
return files


fileList = GetArgs(parser)
for file in fileList:
print(file)


At this became unsure of where to troubleshoot further.

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


Re: How to become more motivated to learn Python

2016-05-03 Thread Sayth Renshaw
On Tuesday, 3 May 2016 21:21:21 UTC+10, Cai Gengyang  wrote:
> So I have completed up to CodeAcademy's Python Unit 2 , now moving on to 
> Unit3 : Conditionals and Control Flow. 
> 
> But I feel my motivation wavering , at times I get stuck and frustrated when 
> trying to learn a new programming language ?
> 
> This might not be a technical question per say, but it is a Python 
> programming related one. How do you motivate a person (either yourself or 
> your child) to become more interested in programming and stick with it ? Is 
> determination in learning (especially in a tough field like software) partly 
> genetic ?
> 
> Related , This is a very well written essay on determination by Paul Graham 
> http://www.paulgraham.com/determination.html
> 
> Gengyang

I have more determination than skill, look at my code :-).

Why, and how can you benefit?

Goals, not just related to Python but goals about what it and my other leanings 
combined will provide. I doubt whether if you are learning for learning sake 
that there is a possible motivation.

In short I coach in corporate world for a living and it becomes quite clear and 
simple on how to get people to achieve goals and meet KRA's its not magic. 
Listen -> Identify values, beliefs and goals -> Discuss vision and outcomes of 
taking a new action (ambitions) -> Relate the business request to this action 
-> then tie the new action to their values what it brings and you have also 
tied them to the business strategy and goals.
As Tony Robbins said it takes a least 3 legs to make a stool. 
Values - Ambitions - Actions

Listen (in this case to yourself), identify key values, beliefs and family 
goals. Then ask yourself how by learning python can I will enrich one or all of 
these facets of my life. Tie the action of learning to a goal which defines 
your vision and your action learning python. 

With a bonus it should hopefully give you more clarity into what sectors of 
Python you want to learn, the great thing about Python is that it is in so many 
domains.

Hope it helps

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


Re: installing scipy

2016-05-03 Thread Fabio Zadrozny
Are you sure that the Python34 you installed is 64-bits and not the 32-bit
version? (you can check that by just executing 'python'... the prompt will
show the proper info to you).

On Tue, Apr 26, 2016 at 12:33 PM, Heli  wrote:

> Hi all,
>
> I have a python34 installed on a windows-64bit machine. I am using Eclipse
> pydev editor. I need to used griddata from scipy.interpolate.
>
> I have installed scipy using by downloading the followng wheel file:
> scipy-0.17.0-cp34-none-win_amd64
>
> and isntalling using pip install. The install is successful, but
>
> It seems like scipy is not installed correctly and I get the following
> error when trying to import and use scipy modules:
>
> C:\Python34\Scripts>python -c "import scipy.interpolate"
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "C:\Python34\lib\site-packages\scipy\interpolate\__init__.py", line
> 158, in 
> from .interpolate import *
>   File "C:\Python34\lib\site-packages\scipy\interpolate\interpolate.py",
> line 11, in 
> import scipy.linalg
>   File "C:\Python34\lib\site-packages\scipy\linalg\__init__.py", line 174,
> in 
> from .misc import *
>   File "C:\Python34\lib\site-packages\scipy\linalg\misc.py", line 5, in
> 
> from .blas import get_blas_funcs
>   File "C:\Python34\lib\site-packages\scipy\linalg\blas.py", line 155, in
> 
> from scipy.linalg import _fblas
> ImportError: DLL load failed
>
> How can I fix this problem?
>
> Thanks,
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: installing scipy

2016-05-03 Thread Sayth Renshaw
On Wednesday, 27 April 2016 01:33:57 UTC+10, Heli  wrote:
> Hi all, 
> 
> I have a python34 installed on a windows-64bit machine. I am using Eclipse 
> pydev editor. I need to used griddata from scipy.interpolate. 
> 
> I have installed scipy using by downloading the followng wheel file:
> scipy-0.17.0-cp34-none-win_amd64
> 
> and isntalling using pip install. The install is successful, but
> 
> It seems like scipy is not installed correctly and I get the following error 
> when trying to import and use scipy modules:
> 
> C:\Python34\Scripts>python -c "import scipy.interpolate"
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "C:\Python34\lib\site-packages\scipy\interpolate\__init__.py", line 
> 158, in 
> from .interpolate import *
>   File "C:\Python34\lib\site-packages\scipy\interpolate\interpolate.py", line 
> 11, in 
> import scipy.linalg
>   File "C:\Python34\lib\site-packages\scipy\linalg\__init__.py", line 174, in 
> 
> from .misc import *
>   File "C:\Python34\lib\site-packages\scipy\linalg\misc.py", line 5, in 
> 
> from .blas import get_blas_funcs
>   File "C:\Python34\lib\site-packages\scipy\linalg\blas.py", line 155, in 
> 
> from scipy.linalg import _fblas
> ImportError: DLL load failed
> 
> How can I fix this problem?
> 
> Thanks,

On windows use Anaconda.
https://www.continuum.io/downloads

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


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Chris Angelico
On Tue, May 3, 2016 at 9:25 PM, Jussi Piitulainen
 wrote:
> Chris Angelico writes:
>
>> This assumes, of course, that there is a function swapcase which can
>> return a string with case inverted. I'm not sure such a function
>> exists.
>
>str.swapcase("foO")
>'FOo'

I suppose for this discussion it doesn't matter if it's imperfect.

>>> "\N{ANGSTROM SIGN}".swapcase().swapcase() == "\N{ANGSTROM SIGN}"
False
>>> "\N{LATIN SMALL LETTER SHARP S}".swapcase().swapcase()
'ss'

But drawing the analogy with the negation of real numbers implies
something that doesn't exist.

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


Saving Consol outputs in a python script

2016-05-03 Thread drewes . mil
Hello, I'm new to python and have a Question.

I'm running a c++ file with a python script like:

import os
import subprocess

subprocess.call(["~/caffe/build/examples/cpp_classification/classification", 
"deploy.prototxt", "this.caffemodel", "mean.binaryproto", "labels.txt", 
"Bild2.jpg"]) 

and it runes fine. On the console it gives me the output:

~/Desktop/Downloader/Sym+$ python Run_C.py 
-- Prediction for Bild2.jpg --
0.9753 - "Class 1"
0.0247 - "Class 2"


What I need are the 2 values for the 2 classes saved in a variable in the .py 
script, so that I can write them into a text file.

Would be super nice if someone could help me!


have a nice day!

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


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread DFS

On 5/3/2016 8:00 AM, Chris Angelico wrote:

On Tue, May 3, 2016 at 9:25 PM, Jussi Piitulainen
 wrote:

Chris Angelico writes:


This assumes, of course, that there is a function swapcase which can
return a string with case inverted. I'm not sure such a function
exists.


   str.swapcase("foO")
   'FOo'


I suppose for this discussion it doesn't matter if it's imperfect.



What was imperfect?



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


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Chris Angelico
On Tue, May 3, 2016 at 11:01 PM, DFS  wrote:
> On 5/3/2016 8:00 AM, Chris Angelico wrote:
>>
>> On Tue, May 3, 2016 at 9:25 PM, Jussi Piitulainen
>>  wrote:
>>>
>>> Chris Angelico writes:
>>>
 This assumes, of course, that there is a function swapcase which can
 return a string with case inverted. I'm not sure such a function
 exists.
>>>
>>>
>>>str.swapcase("foO")
>>>'FOo'
>>
>>
>> I suppose for this discussion it doesn't matter if it's imperfect.
>
>
>
> What was imperfect?

It doesn't invert, the way numeric negation does. And if you try to
define exactly what it does, you'll come right back to
isupper()/islower(), so it's not much help in defining those.

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


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread DFS

On 5/3/2016 9:13 AM, Chris Angelico wrote:

On Tue, May 3, 2016 at 11:01 PM, DFS  wrote:

On 5/3/2016 8:00 AM, Chris Angelico wrote:


On Tue, May 3, 2016 at 9:25 PM, Jussi Piitulainen
 wrote:


Chris Angelico writes:


This assumes, of course, that there is a function swapcase which can
return a string with case inverted. I'm not sure such a function
exists.



   str.swapcase("foO")
   'FOo'



I suppose for this discussion it doesn't matter if it's imperfect.




What was imperfect?


It doesn't invert, the way numeric negation does.



What do you mean by 'case inverted'?

It looks like it swaps the case correctly between upper and lower.





And if you try to
define exactly what it does, you'll come right back to
isupper()/islower(), so it's not much help in defining those.

ChrisA






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


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Chris Angelico
On Tue, May 3, 2016 at 11:19 PM, DFS  wrote:
> What do you mean by 'case inverted'?
>
> It looks like it swaps the case correctly between upper and lower.

I gave two examples in my previous post. Did you read them? You
trimmed them from the quote.

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


Re: Need help understanding list structure

2016-05-03 Thread moa47401
Thanks for the replies. I definitely need a better understanding of "" when using Python objects. So far no luck with web searches 
or my Python books. Could someone point (no pun intended) me to a good 
resource? 

Not that it matters, but the reason I got off track is there are pointers 
within my data that point to other pieces of the data and have nothing to do 
with Python.


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


Re: Need help understanding list structure

2016-05-03 Thread Chris Angelico
On Tue, May 3, 2016 at 11:21 PM,   wrote:
> Thanks for the replies. I definitely need a better understanding of " object at ADDRESS>" when using Python objects. So far no luck with web 
> searches or my Python books. Could someone point (no pun intended) me to a 
> good resource?
>
> Not that it matters, but the reason I got off track is there are pointers 
> within my data that point to other pieces of the data and have nothing to do 
> with Python.

What you're seeing there is the default object representation. It
isn't actually quoting an address but an "identity number". The only
meaning of that number is that it's unique [1]; so if you see the same
number come up twice in the list, you can be confident that the list
has two references to the same object.

Beyond that, it basically tells you nothing. So you know what kind of
object it is, but anything else you'll have to figure out for
yourself.

ChrisA

[1] Among concurrently-existing objects; if an object disappears, its
ID can be reused.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Saving Consol outputs in a python script

2016-05-03 Thread DFS

On 5/3/2016 8:14 AM, [email protected] wrote:

Hello, I'm new to python and have a Question.

I'm running a c++ file with a python script like:

import os
import subprocess

subprocess.call(["~/caffe/build/examples/cpp_classification/classification", "deploy.prototxt", 
"this.caffemodel", "mean.binaryproto", "labels.txt", "Bild2.jpg"])

and it runes fine. On the console it gives me the output:

~/Desktop/Downloader/Sym+$ python Run_C.py
-- Prediction for Bild2.jpg --
0.9753 - "Class 1"
0.0247 - "Class 2"


What I need are the 2 values for the 2 classes saved in a variable in the .py 
script, so that I can write them into a text file.

Would be super nice if someone could help me!



This looks like the ticket:

http://eli.thegreenplace.net/2015/redirecting-all-kinds-of-stdout-in-python/




have a nice day!

Steffen



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


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Jussi Piitulainen
Chris Angelico writes:

> On Tue, May 3, 2016 at 9:25 PM, Jussi Piitulainen wrote:
>> Chris Angelico writes:
>>
>>> This assumes, of course, that there is a function swapcase which can
>>> return a string with case inverted. I'm not sure such a function
>>> exists.
>>
>>str.swapcase("foO")
>>'FOo'
>
> I suppose for this discussion it doesn't matter if it's imperfect.

Not sure. I may have misunderstood what this discussion is about - I
thought you had forgotten that Python has this function :)

 "\N{ANGSTROM SIGN}".swapcase().swapcase() == "\N{ANGSTROM SIGN}"
> False
 "\N{LATIN SMALL LETTER SHARP S}".swapcase().swapcase()
> 'ss'
>
> But drawing the analogy with the negation of real numbers implies
> something that doesn't exist.

I missed the relevance of that analogy.

Ceterum censeo, the only suggested use for .swapcase I've ever heard of
is encryption.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Jussi Piitulainen
DFS writes:

> On 5/3/2016 9:13 AM, Chris Angelico wrote:

>> It doesn't invert, the way numeric negation does.
>
> What do you mean by 'case inverted'?
>
> It looks like it swaps the case correctly between upper and lower.

There's letters that do not come in exact pairs of upper and lower case,
so _some_ swaps are not invertible: you swap twice and end up somewhere
else than your starting point.

The "\N{ANSGTROM SIGN}" looks like the Swedish upper-case
a-with-ring-above but isn't the same character, yet Python swaps its
case to the actual lower-case a-with-ring above. It can't go back to
_both_ the Angstrom sign and the actual upper case letter.

(Not sure why the sign is considered a cased letter at all.)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread DFS

On 5/3/2016 10:49 AM, Jussi Piitulainen wrote:

DFS writes:


On 5/3/2016 9:13 AM, Chris Angelico wrote:



It doesn't invert, the way numeric negation does.


What do you mean by 'case inverted'?

It looks like it swaps the case correctly between upper and lower.


There's letters that do not come in exact pairs of upper and lower case,
so _some_ swaps are not invertible: you swap twice and end up somewhere
else than your starting point.

The "\N{ANSGTROM SIGN}" looks like the Swedish upper-case
a-with-ring-above but isn't the same character, yet Python swaps its
case to the actual lower-case a-with-ring above. It can't go back to
_both_ the Angstrom sign and the actual upper case letter.

(Not sure why the sign is considered a cased letter at all.)



Thanks for the explanation.

Does that mean:

lower(Å) != å ?

and

upper(å) != Å ?


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


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Jussi Piitulainen
DFS writes:

> On 5/3/2016 10:49 AM, Jussi Piitulainen wrote:
>> DFS writes:
>>
>>> On 5/3/2016 9:13 AM, Chris Angelico wrote:
>>
 It doesn't invert, the way numeric negation does.
>>>
>>> What do you mean by 'case inverted'?
>>>
>>> It looks like it swaps the case correctly between upper and lower.
>>
>> There's letters that do not come in exact pairs of upper and lower case,
>> so _some_ swaps are not invertible: you swap twice and end up somewhere
>> else than your starting point.
>>
>> The "\N{ANSGTROM SIGN}" looks like the Swedish upper-case
>> a-with-ring-above but isn't the same character, yet Python swaps its
>> case to the actual lower-case a-with-ring above. It can't go back to
>> _both_ the Angstrom sign and the actual upper case letter.
>>
>> (Not sure why the sign is considered a cased letter at all.)
>
>
> Thanks for the explanation.
>
> Does that mean:
>
> lower(Å) != å ?
>
> and
>
> upper(å) != Å ?

It means "\N{ANGSTROM SIGN}" != "Å", yet both lower to "å", which then
uppers back to "Å" (U+00c5).

The Ångström sign (U+212b) looks like this: Å. Indistinguishable from Å
in the font that I'm seeing - for all I know, it's the same glyph.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Grant Edwards
On 2016-05-03, Jussi Piitulainen  wrote:

>> Does that mean:
>>
>> lower(Å) != å ?
>>
>> and
>>
>> upper(å) != Å ?
>
> It means "\N{ANGSTROM SIGN}" != "Å", yet both lower to "å", which then
> uppers back to "Å" (U+00c5).
>
> The Ångström sign (U+212b) looks like this: Å. Indistinguishable from Å
> in the font that I'm seeing - for all I know, it's the same glyph.

Interesting. FWIW, Å and Å definitely look different with the terminal
and font I'm using (urxvt with 
-misc-fixed-medium-r-normal-*-18-120-*-*-*-90-iso10646-*)

Expecting upper/lower operations to be 100% invertible is probably a
ASCII-centric mindset that will falls over as soon as you start
dealing with non-ASCII encodings.

-- 
Grant Edwards   grant.b.edwardsYow! Xerox your lunch
  at   and file it under "sex
  gmail.comoffenders"!

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


Re: Saving Consol outputs in a python script

2016-05-03 Thread Stephen Hansen
On Tue, May 3, 2016, at 05:14 AM, [email protected] wrote:
> What I need are the 2 values for the 2 classes saved in a variable in the
> .py script, so that I can write them into a text file.
> 
> Would be super nice if someone could help me!

You shouldn't use the call() convienence function, but instead create a
process using the Popen constructor, passing PIPE to stdout. Then use
communicate() to get the output.

This should get you started:

process = subprocess.Popen(["commandline"], stdout=subprocess.PIPE)
output, error = process.communicate()

Output will be a string, string has a splitlines method, etc.

-- 
Stephen Hansen
  m e @ i x o k a i . i o
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help understanding list structure

2016-05-03 Thread moa47401
At the risk of coming across as a complete dunder-head, I think my confusion 
has to do with the type of data the library returns in the list. Any kind of 
text or integer list I manually create, doesn't do this.

See my questions down below at the end.

If I run the following statements on the list returned by the gedcom library:

print(type(myList))
print(len(myList))
print(myList[0])
print(myList[0:29])
print(myList)
for x in myList:
print(x)

I get this:


29
0 HEAD
[, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , , , ]
[, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , 
, , , , ]
0 HEAD
1 SOUR AncestQuest
2 NAME Ancestral Quest
2 VERS 14.00.9
2 CORP Incline Software, LC
3 ADDR PO Box 95543
4 CONT South Jordan, UT 84095
4 CONT USA
1 DATE 3 MAY 2016
2 TIME 10:44:10
1 FILE test_gedcom.ged
1 GEDC
2 VERS 5.5
2 FORM LINEAGE-LINKED
1 CHAR ANSEL
0 @I1@ INDI
1 NAME John /Allen/
1 SEX M
1 BIRT
2 DATE 1750
2 PLAC VA
1 DEAT
2 DATE 1804
2 PLAC KY
1 _UID D6C103E6105D654B85D47DA1B36E474BC7D1
1 CHAN
2 DATE 3 MAY 2016
3 TIME 10:43:35
0 TRLR

Questions:

Why does printing a single item print the actual text of the object?
Why does printing a range print the "representations" of the objects?
Why does iterating over the list print the actual text of the objects?
How can I determine what type of data is in the list?

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


Re: You gotta love a 2-line python solution

2016-05-03 Thread Stephen Hansen
On Mon, May 2, 2016, at 08:57 PM, [email protected] wrote:
> Stephen Hansen at 2016/5/3 11:49:22AM wrote:
> > On Mon, May 2, 2016, at 08:27 PM, [email protected] wrote:
> > > But when I try to get this forum page, it does get a html file but can't
> > > be viewed normally.
> > 
> > What does that mean?
> > 
> > -- 
> > Stephen Hansen
> >   m e @ i x o k a i . i o
> 
> The page we are looking at:-)
> https://groups.google.com/forum/#!topic/comp.lang.python/jFl3GJbmR7A

Try scraping gmane. Google Groups is one big javascript application.

-- 
Stephen Hansen
  m e @ i x o k a i . i o
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Terry Reedy

On 5/3/2016 11:42 AM, Grant Edwards wrote:


Interesting. FWIW, Å and Å definitely look different with the terminal
and font I'm using (urxvt with 
-misc-fixed-medium-r-normal-*-18-120-*-*-*-90-iso10646-*)


In the fixed pitch font used by Thunderbird (Courier?), Angstrom Å has 
the circle touching the A while letter Å has the circle spaced above.


--
Terry Jan Reedy


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


Re: installing scipy

2016-05-03 Thread Heli
Yes, the python I have installed is 64bit. 

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit 
(AMD64)] on win32

and the scipy wheel I am trying to install from is :
scipy-0.17.0-cp34-none-win_amd64.whl

At Sayth: Thanks for recommending Anaconda. I already am familiar with it, but 
I was wondering why the scipy installed on my normal python gives the following 
error :

mportError: DLL load failed 

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


Re: Fastest way to retrieve and write html contents to file

2016-05-03 Thread Tim Chase
On 2016-05-03 00:24, DFS wrote:
> One small comparison I was able to make was VBA vs python/pyodbc to 
> summarize an Access database.  Not quite a fair test, but
> interesting nonetheless.
> 
> Access 2003 file
> Access 2003 VBA code
> Time: 0.18 seconds
>
> same Access 2003 file
> 32-bit python 2.7.11 + 32-bit pyodbc 3.0.6
> Time: 0.49 seconds

Curious whether you're forcing Access VBA to talk over ODBC or
whether Access is using native access/file-handling (and thus
bypassing the ODBC overhead)?

-tkc


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


Re: Saving Consol outputs in a python script

2016-05-03 Thread Terry Reedy

On 5/3/2016 8:14 AM, [email protected] wrote:

Hello, I'm new to python and have a Question.

I'm running a c++ file with a python script like:

import os
import subprocess

subprocess.call(["~/caffe/build/examples/cpp_classification/classification", "deploy.prototxt", 
"this.caffemodel", "mean.binaryproto", "labels.txt", "Bild2.jpg"])

and it runes fine. On the console it gives me the output:

~/Desktop/Downloader/Sym+$ python Run_C.py
-- Prediction for Bild2.jpg --
0.9753 - "Class 1"
0.0247 - "Class 2"


What I need are the 2 values for the 2 classes saved in a variable in the .py 
script, so that I can write them into a text file.


pycaffe is a python interface to caffe.  You should look into it and 
probably use it.  Its functions will return python objects.  I suspect 
that is has a function that will return the result of calling the caffe 
classification function


Stackoverflow has question/answers tagged with 'caffe' and 'pycaffe'.
(There is also a caffe-users group on google groups.)

--
Terry Jan Reedy

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


Re: How to become more motivated to learn Python

2016-05-03 Thread Rob Gaddi
Cai Gengyang wrote:

> So I have completed up to CodeAcademy's Python Unit 2 , now moving on to 
> Unit3 : Conditionals and Control Flow. 
>
> But I feel my motivation wavering , at times I get stuck and frustrated when 
> trying to learn a new programming language ?
>
> This might not be a technical question per say, but it is a Python 
> programming related one. How do you motivate a person (either yourself or 
> your child) to become more interested in programming and stick with it ? Is 
> determination in learning (especially in a tough field like software) partly 
> genetic ?
>
> Related , This is a very well written essay on determination by Paul Graham 
> http://www.paulgraham.com/determination.html
>
> Gengyang

You don't.  Learning programming is dull and sloggy and inherently
unmotiving.

Now, solving a problem, on the other hand.  Solving a problem is fun.  A
real problem, an actual task that you actually need to do, not
FizzBang.  The thorny, nasty, horrible problems are great fun, and when
you beat them into submission and mount their heads on your wall, but
even the little ones like "I've got an 8GB USB stick, I want to put a
random selection of all my MP3 files onto it." are entertaining.

The Python's not the point.  It can never be the point.  Have a thing
you want to do, and not just "Get a high paying job." If the tool for
doing that thing is Python, so be it. If you need a soldering iron, or a
hammer and chisel, or a structural engineering degree instead, then go
figure out how to use one of those and Python will still be waiting when
you do need it.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Need help understanding list structure

2016-05-03 Thread Dan Strohl via Python-list
Take a look at the docs for 
print() https://docs.python.org/3.5/library/functions.html#print 
str() https://docs.python.org/3.5/library/stdtypes.html#str
repr() https://docs.python.org/3.5/library/functions.html#repr 

When you do "print(object)", python will run everything through str() and 
output it.  

Str() will try to return a string representation of the object, what actually 
comes back will depend on how the objects author defined it.  If 
object.__str__() has been defined, it will use that, if __str__() is not 
defined, it will use object.__repr__().  If object.__repr__() has not been 
defined, it will something that looks like "object_name object at xxx".

So, as to your specific questions / comments:

> At the risk of coming across as a complete dunder-head, I think my confusion
> has to do with the type of data the library returns in the list. Any kind of 
> text
> or integer list I manually create, doesn't do this.
Actually, they do, but strings and integers have well defined __str__ and 
__repr__ methods, and behave pretty well.

So... think about what is actually being passed to the print() function in each 
case:

> print(type(myList))
Passing the string object of the results of type(myList)

> print(len(myList))
Passing the integer object returning from len(myList)

> print(myList[0])
Passing the gedcom ELEMENT object found at location 0 in the list

> print(myList[0:29])
Passing a list object created by copying the items from location 0 to location 
29 in the original list

> print(myList)
Passing the entire list object

> for x in myList:
> print(x)
Passing the individual gedcom ELEMENT objects from the list.

So, in each of these cases, you are passing different types of objects, and 
each one (string, integer, list, gedcom)  will behave differently depending on 
how it is coded.

> Why does printing a single item print the actual text of the object?
If you are printing a single item (print(myList[0]), you are printing the 
__str__ or __repr__ for the object stored at that location.

> Why does printing a range print the "representations" of the objects?
If you are printing a range of objects, you are printing the __str__ or 
__repr__ for the RANGE OBJECT or LIST object, not the object itself, which 
apparently only checks for a __repr__() method in the contained gedcom ELEMENT 
objects, which is not defined (see below).

> Why does iterating over the list print the actual text of the objects?
When iterating over the list, you are printing the specific items again (just 
like when you did print(myList[0])  ) 

> How can I determine what type of data is in the list?
Try print(type(myList[0])), which will give you the type of data in the first 
object in the list (though, keep in mind that the object type could be 
different in each item in the list).


If we look at the gedcom library (assuming you are talking about this one: 
https://github.com/madprime/python-gedcom/blob/master/gedcom/__init__.py) at 
the end of the file you can see they defined __str__() in the ELEMENT object,  
but there is no definition for __repr__(), which matches what we surmised above.

If you want to fix it by editing the gedcom library, you could simply add a 
line at the end like:
__repr__() = __str__()


Hope that helps.

Dan Strohl

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


Re: Fastest way to retrieve and write html contents to file

2016-05-03 Thread DFS

On 5/3/2016 11:28 AM, Tim Chase wrote:

On 2016-05-03 00:24, DFS wrote:

One small comparison I was able to make was VBA vs python/pyodbc to
summarize an Access database.  Not quite a fair test, but
interesting nonetheless.

Access 2003 file
Access 2003 VBA code
Time: 0.18 seconds

same Access 2003 file
32-bit python 2.7.11 + 32-bit pyodbc 3.0.6
Time: 0.49 seconds


Curious whether you're forcing Access VBA to talk over ODBC or
whether Access is using native access/file-handling (and thus
bypassing the ODBC overhead)?



The latter, which is why I said "not quite a fair test".


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


Re: Need help understanding list structure

2016-05-03 Thread moa47401
I added a __repr__ method at the end of the gedcom library like so:

def __repr__(self):
""" Format this element as its original string """
result = repr(self.level())
if self.pointer() != "":
result += ' ' + self.pointer()
result += ' ' + self.tag()
if self.value() != "":
result += ' ' + self.value()
return result

and now I can print myList properly.

Eric and Michael also mentioned repr above, but I guess I needed someone to 
spell it out for me. Thanks for taking the time to put it in terms an old dog 
could understand.


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


Re: How to become more motivated to learn Python

2016-05-03 Thread mm0fmf

On 03/05/2016 17:50, Rob Gaddi wrote:

Cai Gengyang wrote:


So I have completed up to CodeAcademy's Python Unit 2 , now moving on to Unit3 
: Conditionals and Control Flow.

But I feel my motivation wavering , at times I get stuck and frustrated when 
trying to learn a new programming language ?

This might not be a technical question per say, but it is a Python programming 
related one. How do you motivate a person (either yourself or your child) to 
become more interested in programming and stick with it ? Is determination in 
learning (especially in a tough field like software) partly genetic ?

Related , This is a very well written essay on determination by Paul Graham 
http://www.paulgraham.com/determination.html

Gengyang


You don't.  Learning programming is dull and sloggy and inherently
unmotiving.

Now, solving a problem, on the other hand.  Solving a problem is fun.  A
real problem, an actual task that you actually need to do, not
FizzBang.  The thorny, nasty, horrible problems are great fun, and when
you beat them into submission and mount their heads on your wall, but
even the little ones like "I've got an 8GB USB stick, I want to put a
random selection of all my MP3 files onto it." are entertaining.

The Python's not the point.  It can never be the point.  Have a thing
you want to do, and not just "Get a high paying job." If the tool for
doing that thing is Python, so be it. If you need a soldering iron, or a
hammer and chisel, or a structural engineering degree instead, then go
figure out how to use one of those and Python will still be waiting when
you do need it.



+1

I learned Python because... I had a problem to solve.

First I had to recompile a Linux kernel for an oddball PPC based NAS I 
used a lowpower computer. Then I had to find the patches that fixed some 
USB issues. Then I had to make a USB GSM modem work as it was a nasty 
Windows Zero-CD system. Then I wrote a program in C/C++ to process data 
from the modem and play with the ASCII strings and then push them to a 
website. I used libcurl to do the web work. It was a nightmare to 
debug/enhance and handling raw C strings in C or C++ was a pain. And I 
thought there has to be a better way.


I kept seeing mention of Python so I thought I'll rewrite this in 
Python. But I couldn't find Python 2.7.x for PPC so I had to get the 
Python source and build that from scrath and check it worked OK.


It took about 7 days of deep hacking to be able to rewrite on a line by 
line basis the C/C++ in Python. Boy was it ugly. But it worked. Then as 
I enhanced the program it became more Pythonic and I starting using the 
language and not abusing it. And the more I used it the easier it 
became. That code is online on a cheap VM running 24/7 and has about 450 
users worldwide growing by several a week. This group was huge source of 
inspiration looking at the replies people gave to questions. It also 
motivated me to stop faffing about and convert my Python2 code to 
Python3 which again was straightforward.


So I learned Python to solve a real world problem and it took a huge 
amount of effort along the way to realise I had to get a better way to 
maintain a program that was now being relied on by others. I didn't set 
out to learn Python but I'm sure glad I did.


In 33 years of code bashing, I found a language that let me think about 
the problem not the programming language.


YMMV




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


RE: Need help understanding list structure

2016-05-03 Thread Dan Strohl via Python-list

> I added a __repr__ method at the end of the gedcom library like so:
> 
> def __repr__(self):
> """ Format this element as its original string """
> result = repr(self.level())
> if self.pointer() != "":
> result += ' ' + self.pointer()
> result += ' ' + self.tag()
> if self.value() != "":
> result += ' ' + self.value()
> return result
> 
> and now I can print myList properly.
> 
> Eric and Michael also mentioned repr above, but I guess I needed someone
> to spell it out for me. Thanks for taking the time to put it in terms an old 
> dog
> could understand.
> 

Glad to help!  (being an old dog myself, I know the feeling!)

One other point for you, if your "__repr__(self)" code is the same as the 
"__str__(self)" code (which it looks like it is, at a glance at least), you can 
instead reference the __str__ method and save having a duplicate code block...  
some examples:

=
Option 1:  This is the easiest to read (IMHO) and allows for the possibility 
that str() is doing something here like formatting or whatever.  (in this case 
it shouldn't be though).  However, to call this actually is taking multiple 
steps (calling object.__repr__, whch calls str(), which calls object.__str__(). 
)

def __repr__(self):
return str(self)

=
Option 2: this isn't hard to read, and just takes two steps (calling 
object.__repr__(), which calls object.__str__().

def __repr__(self):
return self.__str__()


Option 3:  it's not that this is hard to read, but since it doesn't follow the 
standard "def blah(self):" pattern, sometimes I overlook these in the code 
(even when I put them there).  This however is the shortest since it really 
just tells the object to return object.__str__() if either object.__repr__() OR 
object.__str__() is called.


__repr__ = __str__


This probably doesn't matter much in this case, since it probably isn't called 
that much in normal use (though there are always exceptions), and in the end, 
Python is fast enough that unless you really need to slice off a few 
milliseconds, you will never notice the difference, but just some food for 
thought.


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


Use __repr__ to show the programmer's representation (was: Need help understanding list structure)

2016-05-03 Thread Ben Finney
Dan Strohl via Python-list  writes:

> One other point for you, if your "__repr__(self)" code is the same as
> the "__str__(self)" code (which it looks like it is, at a glance at
> least), you can instead reference the __str__ method and save having a
> duplicate code block...

Alternatively, consider: the ‘__repr__’ method is intended to return a
*programmer's* representation of the object. Commonly, this is text
which looks like the Python expression which would create an equal
instance::

>>> foo = datetime.date.fromtimestamp(13012345678)
>>> print(repr(foo))
datetime.date(2382, 5, 7)

So if there is a sensible “here is the expression that could have been
used to create this instance” text, have the ‘__repr__’ method return
that text::

>>> foo = LoremIpsum(bingle, bongle, bungle)
>>> print(repr(foo))
packagename.LoremIpsum("spam", 753, frob=True)

That text is very useful because it can be fed back into the interactive
interpreter to make an equal-valued instance and experiment further.

For some types, there isn't such an expression that would evaluate to an
equal-valued instance of the type. So the conventional non-evaluating
representation is used::

>>> foo = frobnicate_the_widget(widget)
>>> print(repr(foo))


This gives the crucial information of what the type is, and also gives
other interesting (to the programmer) attributes that characterise the
specific instance.

The fallback “” is the least helpful;
it gives the type and identity of the instance, but only because that's
the lowest common information ‘object’ can guarantee. Always implement a
more informative representation for your custom type, if you can.

-- 
 \“Intellectual property is to the 21st century what the slave |
  `\  trade was to the 16th.” —David Mertz |
_o__)  |
Ben Finney

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


RE: Use __repr__ to show the programmer's representation (was: Need help understanding list structure)

2016-05-03 Thread Dan Strohl via Python-list
> > One other point for you, if your "__repr__(self)" code is the same as
> > the "__str__(self)" code (which it looks like it is, at a glance at
> > least), you can instead reference the __str__ method and save having a
> > duplicate code block...
> 
> Alternatively, consider: the ‘__repr__’ method is intended to return a
> *programmer's* representation of the object. Commonly, this is text which
> looks like the Python expression which would create an equal
> instance::

Definitely true per what _repr__ is supposed to do per python docs.   However, 
in this case, that might not have solved the problem if the goal was to return 
the same as a __str__.  (Though to be fair, I don’t really know what the actual 
problem was, so I might provide a different approach with a different goal 
).

I also have never actually used repr() to create code that could be fed back to 
the interpreter (not saying it isn’t done, just that I haven’t run into needing 
it), and there are so many of the libraries that do not return a usable repr 
string that I would hesitate to even try it outside of a very narrow use case.

Personally, I normally use __repr__ to give me a useful troubleshooting 
representation of the object... but that representation might not be exactly 
the same as what would recreate the object since I might show information that 
is dynamic to the current state (like, the name of the parent instead of just a 
pointer or something).

I know that isn’t per the rules, but in the end, it makes it easier for me to 
troubleshoot the code.

Having said that, Ben is totally correct in terms of the "right" way to do it, 
my earlier suggestion was not "right".

Dan

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


Re: Use __repr__ to show the programmer's representation (was: Need help understanding list structure)

2016-05-03 Thread moa47401
quote - (Though to be fair, I don't really know what the actual problem was, so 
I might provide a different approach with a different goal )

Originally I was trying to understand the exact structure of the list being 
returned by the gedcom library. It worked as it was, but I wanted to add 
additional functionality.

I also wanted to understand what character set it was returning. I was giving 
it a gedcom file with ansel encoding, which is normal. My genealogy program can 
also export its database to gedcom using UTF-8 and Unicode. But both of those 
character sets caused the gedcom library to generate an error msg that the file 
violated GEDCOM format.

Keep in mind the gedcom format established by the Latter-day Saints hasn't been 
updated in 20+ years.

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


Re: crash while using PyCharm / Python3

2016-05-03 Thread Adam

"Jonathan N. Little"  wrote in message 
news:[email protected]...
> Adam wrote:
>> "Adam"  wrote in message
>> news:[email protected]...
>>>
>>> "Jonathan N. Little"  wrote in message
>>> news:[email protected]...
 Adam wrote:
> There ought to be a way to just reinstall the graphics subsystem 
> rather
> than
> an all-or-none installation approach.

 Yes you can. Did it for a borked install of the nVidia driver. 
 reference
 this:

 
>>>
>>> Thanks, even after doing the following...
>>>
>>> Problem: Need to purge -fglrx
>>>
>>> Typically, the following manual commands will properly uninstall -fglrx:
>>>
>>>   $ sudo apt-get remove --purge xorg-driver-fglrx fglrx*
>>>   $ sudo apt-get install --reinstall libgl1-mesa-glx libgl1-mesa-dri
>>> xserver-xorg-core
>>>   $ sudo dpkg-reconfigure xserver-xorg
>>>
>>> I still get that dreaded "The system is running in low-graphics mode"
>>> error.
>>> And, recovery mode failsafeX and Ctrl+Alt+F1 hangs with the following...
>>>
>>> 
>>> Initializing built-in extension MIT-SCREEN-SAVER
>>> Initializing built-in extension DOUBLE-BUFFER
>>> Initializing built-in extension RECORD
>>> Initializing built-in extension DPMS
>>> Initializing built-in extension Present
>>> Initializing built-in extension DRI3
>>> Initializing built-in extension X-Resource
>>> Initializing built-in extension XVideo
>>> Initializing built-in extension XVideo-MotionCompensation
>>> Initializing built-in extension SELinux
>>> Initializing built-in extension XFree86-VidModeExtension
>>> Initializing built-in extension XFree86-DGA
>>> Initializing built-in extension XFree86-DRI
>>> Initializing built-in extension DRI2
>>> Loading extension GLX
>>> 
>>>
>>
>> After trying the following...
>>
>> http://askubuntu.com/questions/577093/how-to-install-gnome-desktop
>>
>> $ sudo apt-get update
>> $ sudo apt-get install gnome-shell
>>
>>
>> http://tipsonubuntu.com/2014/06/06/change-display-manager-ubuntu-14-04/
>>
>> $ sudo dpkg-reconfigure lightdm
>
> Not sure about ATI, but when you purge the nVidia driver it takes Unity 
> with it so I had to reinstall unity-desktop afterwards. If you want 
> lightdm but are now using gdm, maybe it happened because unity-desktop was 
> uninstalled and you just installed gnome-shell, your can reset:
>
> sudo dpkg-reconfigure gdm
>
> and select lightdm from the list.
>

Today, I tried to switch from gdm back to lightdm and
still encountered the "The system is running in low-graphics mode" problem 
until I found...

NumLock Key ON...
http://ubuntuforums.org/showthread.php?t=2218111

grumblebum2 provided the fix in post #9...

For NumLock key ON (in Ubuntu 14.04), add...

greeter-setup-script=/usr/bin/numlockx on

to/usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf
(not/etc/lightdm/lightdm.conf, which I deleted since there were no other 
settings)


>
> -- 
> Take care,
>
> Jonathan
> ---
> LITTLE WORKS STUDIO
> http://www.LittleWorksStudio.com 


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


Re: Use __repr__ to show the programmer's representation (was: Need help understanding list structure)

2016-05-03 Thread Random832
On Tue, May 3, 2016, at 15:24, [email protected] wrote:
> I also wanted to understand what character set it was returning. I was
> giving it a gedcom file with ansel encoding, which is normal. My
> genealogy program can also export its database to gedcom using UTF-8 and
> Unicode. But both of those character sets caused the gedcom library to
> generate an error msg that the file violated GEDCOM format.

You haven't said where this library can be found, or what the error
message was.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help understanding list structure

2016-05-03 Thread MRAB

On 2016-05-03 18:54, Dan Strohl via Python-list wrote:



I added a __repr__ method at the end of the gedcom library like so:

def __repr__(self):
""" Format this element as its original string """
result = repr(self.level())
if self.pointer() != "":
result += ' ' + self.pointer()
result += ' ' + self.tag()
if self.value() != "":
result += ' ' + self.value()
return result

and now I can print myList properly.

Eric and Michael also mentioned repr above, but I guess I needed someone
to spell it out for me. Thanks for taking the time to put it in terms an old dog
could understand.



Glad to help!  (being an old dog myself, I know the feeling!)

One other point for you, if your "__repr__(self)" code is the same as the 
"__str__(self)" code (which it looks like it is, at a glance at least), you can instead 
reference the __str__ method and save having a duplicate code block...  some examples:

=
Option 1:  This is the easiest to read (IMHO) and allows for the possibility 
that str() is doing something here like formatting or whatever.  (in this case 
it shouldn't be though).  However, to call this actually is taking multiple 
steps (calling object.__repr__, whch calls str(), which calls object.__str__(). 
)

def __repr__(self):
return str(self)

=
Option 2: this isn't hard to read, and just takes two steps (calling 
object.__repr__(), which calls object.__str__().

def __repr__(self):
return self.__str__()


Option 3:  it's not that this is hard to read, but since it doesn't follow the standard 
"def blah(self):" pattern, sometimes I overlook these in the code (even when I 
put them there).  This however is the shortest since it really just tells the object to 
return object.__str__() if either object.__repr__() OR object.__str__() is called.


__repr__ = __str__


This probably doesn't matter much in this case, since it probably isn't called 
that much in normal use (though there are always exceptions), and in the end, 
Python is fast enough that unless you really need to slice off a few 
milliseconds, you will never notice the difference, but just some food for 
thought.



Option 4:

Delete the __str__ method.


If there's no __str__, Python falls back to __repr__.

If there's no __repr__, Python falls back to the somewhere> format.


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


Broken pipe from gevent/pywsgi.py

2016-05-03 Thread Larry Martell
I have a python server that has this in the main:

from gevent import pywsgi

try:
httpd = pywsgi.WSGIServer(('0.0.0.0', 8000), app)
httpd.serve_forever()
except KeyboardInterrupt:
pass

Recently we began getting HTTPError: 504 Server Error: Gateway
Time-out on requests to the server. Looking in the logs I saw this:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line
508, in handle_one_response
self.run_application()
  File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line
495, in run_application
self.process_result()
  File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line
486, in process_result
self.write(data)
  File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line
380, in write
self._write_with_headers(data)
  File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line
400, in _write_with_headers
self._sendall(towrite)
  File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line
355, in _sendall
self.socket.sendall(data)
  File "/usr/local/lib/python2.7/dist-packages/gevent/socket.py", line
460, in sendall
data_sent += self.send(_get_memory(data, data_sent), flags)
  File "/usr/local/lib/python2.7/dist-packages/gevent/socket.py", line
437, in send
return sock.send(data, flags)
error: [Errno 32] Broken pipe
{'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': '*/*',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_CONNECTION': 'close',
 'HTTP_HOST': 'bekku.bbmsc.com',
 'HTTP_USER_AGENT': 'python-requests/2.9.1',
 'HTTP_X_FORWARDED_FOR': '192.168.10.5',
 'HTTP_X_REAL_IP': '192.168.10.5',
 'PATH_INFO': '/readings',
 'QUERY_STRING': 'target=2225217193085335062&tool=HM',
 'REMOTE_ADDR': '172.17.42.1',
 'REMOTE_PORT': '41708',
 'REQUEST_METHOD': 'GET',
 'SCRIPT_NAME': '',
 'SERVER_NAME': 'fdffcd119506',
 'SERVER_PORT': '8000',
 'SERVER_PROTOCOL': 'HTTP/1.0',
 'SERVER_SOFTWARE': 'gevent/1.0 Python/2.7',
 'wsgi.errors': ', mode 'w' at 0x7f4c299bc1e0>,
 'wsgi.input': ,
 'wsgi.multiprocess': False,
 'wsgi.multithread': False,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0)} failed with error

Once this occurs it seems that no further requests are served. I
googled this and found many places where people said this was
happening, and many places where people explained why it was
happening, but no place did I find a way to fix or workaround this.

Does anyone know how to get it to continue processing after this occurs?
-- 
https://mail.python.org/mailman/listinfo/python-list


Trouble porting glob bash behavior with argparse to windows shell

2016-05-03 Thread Sayth Renshaw
Is there something obvious to this I am doing wrong? 

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


Re: Fastest way to retrieve and write html contents to file

2016-05-03 Thread Tim Chase
On 2016-05-03 13:00, DFS wrote:
> On 5/3/2016 11:28 AM, Tim Chase wrote:
> > On 2016-05-03 00:24, DFS wrote:
> >> One small comparison I was able to make was VBA vs python/pyodbc
> >> to summarize an Access database.  Not quite a fair test, but
> >> interesting nonetheless.
> >>
> >> Access 2003 file
> >> Access 2003 VBA code
> >> Time: 0.18 seconds
> >>
> >> same Access 2003 file
> >> 32-bit python 2.7.11 + 32-bit pyodbc 3.0.6
> >> Time: 0.49 seconds
> >
> > Curious whether you're forcing Access VBA to talk over ODBC or
> > whether Access is using native access/file-handling (and thus
> > bypassing the ODBC overhead)?
> 
> The latter, which is why I said "not quite a fair test".

Can you try the same tests, getting Access/VBA to use ODBC instead to
see how much overhead ODBC entails?

-tkc



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


Re: Trouble porting glob bash behavior with argparse to windows shell

2016-05-03 Thread Peter Otten
Sayth Renshaw wrote:

> Is there something obvious to this I am doing wrong?

> parser.add_argument("path", nargs="+") 
 
The "+" implicitly turns args.path into a list

> files |= set(glob.glob(args.path + '/*' + args.extension))

so the glob() argument is evaluated as

list + str + str

Try

name_pattern = "*" + args.extension
for path in args.path:
files.update(glob.glob(os.path.join(path, name_pattern)))

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


RE: How to become more motivated to learn Python

2016-05-03 Thread Clayton Kirkwood
Find some thing that you really need done, but you've put off because you
didn't have the programming knowledge to do.
Program parts of some thing that you are really interested in doing. For
instance, at some point, I need to find duplicate copies of hardcopy photos
that I have. I'd love to write a program that sorts, compares, and marks as
duplicates. I think I would go about doing this similar to facial
recognition or eye recognition where I would look for 30 points on each
photo and compare them instead of scanning and comparing every bit.

crk

> -Original Message-
> From: Python-list [mailto:python-list-
> [email protected]] On Behalf Of Cai Gengyang
> Sent: Tuesday, May 03, 2016 4:21 AM
> To: [email protected]
> Subject: How to become more motivated to learn Python
> 
> So I have completed up to CodeAcademy's Python Unit 2 , now moving on to
> Unit3 : Conditionals and Control Flow.
> 
> But I feel my motivation wavering , at times I get stuck and frustrated
when
> trying to learn a new programming language ?
> 
> This might not be a technical question per say, but it is a Python
programming
> related one. How do you motivate a person (either yourself or your child)
to
> become more interested in programming and stick with it ? Is determination
> in learning (especially in a tough field like software) partly genetic ?
> 
> Related , This is a very well written essay on determination by Paul
Graham --
> --
> http://www.paulgraham.com/determination.html
> 
> Gengyang
> --
> https://mail.python.org/mailman/listinfo/python-list

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


Re: Trouble porting glob bash behavior with argparse to windows shell

2016-05-03 Thread Terry Reedy

On 5/3/2016 4:55 PM, Sayth Renshaw wrote:

Is there something obvious to this I am doing wrong?

Sayth


Somethin happened so that I don't see what you did.  Fortunately, it did 
show up for Peter, between the '?' and name, so he could answer.


--
Terry Jan Reedy

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


How to call a Python Class?

2016-05-03 Thread David Shi via Python-list
I found a Python class within an Open Source software.
I would like to use it in my own Python script.
I tried to import it, but I got following message.
from intersection import *Traceback (most recent call last):  File 
"", line 1, in     from intersection import *ImportError: 
bad magic number in 'intersection': b'\x03\xf3\r\n'
Can any one help?
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to call a Python Class?

2016-05-03 Thread Chris Angelico
On Wed, May 4, 2016 at 8:56 AM, David Shi via Python-list
 wrote:
> I found a Python class within an Open Source software.
> I would like to use it in my own Python script.
> I tried to import it, but I got following message.
> from intersection import *Traceback (most recent call last):  File 
> "", line 1, in from intersection import *ImportError: 
> bad magic number in 'intersection': b'\x03\xf3\r\n'
> Can any one help?
> Regards.

Did you get a .py file, or only a .pyc? Try deleting all .pyc files
that you downloaded, and try again.

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


Re: How to call a Python Class?

2016-05-03 Thread Ben Finney
David Shi via Python-list  writes:

> I found a Python class within an Open Source software.
> I would like to use it in my own Python script.
> I tried to import it, but I got following message.

Your text is mangled in transit. Please post only plain text messages
(avoid HTML or other “rich” content), so the formatting survives.

> from intersection import *Traceback (most recent call last):  File 
> "", line 1, in     from intersection import *ImportError: 
> bad magic number in 'intersection': b'\x03\xf3\r\n'
> Can any one help?

If we can see the exact code you tried, perhaps.

-- 
 \  “Holy hole in a donut, Batman!” —Robin |
  `\   |
_o__)  |
Ben Finney

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


Re: Use __repr__ to show the programmer's representation (was: Need help understanding list structure)

2016-05-03 Thread Chris Angelico
On Wed, May 4, 2016 at 4:35 AM, Dan Strohl via Python-list
 wrote:
> I also have never actually used repr() to create code that could be fed back 
> to the interpreter (not saying it isn’t done, just that I haven’t run into 
> needing it), and there are so many of the libraries that do not return a 
> usable repr string that I would hesitate to even try it outside of a very 
> narrow use case.

Here's a repr that I like using with SQLAlchemy:

def __repr__(self):
return (self.__class__.__name__ + "(" +
", ".join("%s=%r" % (col.name, getattr(self, col.name)) for
col in self.__table__.columns) +
")")

That results in something that *looks* like you could eval it, but you
shouldn't ever actually do that (because it'd create a new object).
It's still an effective way to make the repr readable; imagine a list
that prints out like this:

[Person(id=3, name="Fred"), Person(id=6, name="Barney"), Person(id=8,
name="Joe")]

You can tell exactly where one starts and another ends; you can read
what's going on with these record objects. Making them
"pseudo-evalable" is worth doing, even if you should never *actually*
eval them.

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


Analytical Geometry in Python with GeoMath

2016-05-03 Thread Vinicius Mesel


Hey guys,

I'm back after some time in the darkness(lol).



So I'm here to announce my contribution for the mathematicians and physicians 
and other guys who love geometry like me!

I created a library called "GeoMath" that it's intent is to solve all 
Analytical Geometry problems in a simple way using Python.

If you want to check it out, here is the link: https://github.com/vmesel/GeoMath

And if you want to install it and start solving your problems with it, just 
run: pip install geomath!





Tnx,

Vinicius Mesel

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


Re: You gotta love a 2-line python solution

2016-05-03 Thread Steven D'Aprano
On Tue, 3 May 2016 01:56 pm, DFS wrote:

> On 5/2/2016 11:27 PM, [email protected] wrote:
>> DFS at 2016/5/3 9:12:24AM wrote:
>>> try
>>>
>>> from urllib.request import urlretrieve
>>>
>>>
http://stackoverflow.com/questions/21171718/urllib-urlretrieve-file-python-3-3
>>>
>>>
>>> I'm running python 2.7.11 (32-bit)
>>
>> Alright, it works...someway.
>>
>> I try to get a zip file. It works, the file can be unzipped correctly.
>>
> from urllib.request import urlretrieve
> urlretrieve("http://www.caprilion.com.tw/fed.zip";,
> "d:\\temp\\temp.zip")
>> ('d:\\temp\\temp.zip', )
>
>>
>> But when I try to get this forum page, it does get a html file but can't
>> be viewed normally.
>>
>
urlretrieve("https://groups.google.com/forum/#!topic/comp.lang.python/jFl3GJ
>> bmR7A", "d:\\temp\\temp.html")
>> ('d:\\temp\\temp.html', )
>
>>
>> I suppose the html is a much complex situation where more processes need
>> to be done before it can be opened by a web browser:-)
> 
> 
> Who knows what Google has done... it won't open in Opera.  The tab title
> shows up, but after 20-30 seconds the screen just stays blank and the
> cursor quits loading.


Dennis has given the answer to this, but since he has X-No-Archive=Yes, his
useful and well-written answer will be lost forever.

So I've taken the liberty of copying his answer here:

Dennis Lee Bieber says:

There's practically no HTML in that page -- just miles of
Javascript.
The one obvious item is:

-=-=-=-=-=-

        
      
-=-=-=-=-=-

which is a RELATIVE path. If you copied the file to your machine and then
load it in a browser, it will be looking for

/forum/C53652DA8B67255A46256B72F0D65A40.cache.js 

to be on your machine in a subdirectory of where you saved the main file.

You'd have to recreate most of the Google environment and fetch
anything that was referenced through a relative path first, to get the
content to display. Of course, you may find, for example, that the
Javascript at some point is doing a database lookup -- and you'd maybe have
to now duplicate the database...



-- 
Steven

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


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Steven D'Aprano
On Wed, 4 May 2016 12:42 am, Jussi Piitulainen wrote:

> Ceterum censeo, the only suggested use for .swapcase I've ever heard of
> is encryption.

iF YOU'RE PROGRAMMING AN EDITOR, sWAP cASE IS REALLY USEFUL FOR THOSE LITTLE
capslock ACCIDENTS THAT PLAGUE TYPISTS.



-- 
Steven

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


Re: How to become more motivated to learn Python

2016-05-03 Thread Christopher Reimer

On 5/3/2016 4:20 AM, Cai Gengyang wrote:

So I have completed up to CodeAcademy's Python Unit 2 , now moving on to Unit3 
: Conditionals and Control Flow.

But I feel my motivation wavering , at times I get stuck and frustrated when 
trying to learn a new programming language ?

This might not be a technical question per say, but it is a Python programming 
related one. How do you motivate a person (either yourself or your child) to 
become more interested in programming and stick with it ? Is determination in 
learning (especially in a tough field like software) partly genetic ?

Related , This is a very well written essay on determination by Paul Graham 
http://www.paulgraham.com/determination.html

Gengyang


I started out translating old BASIC games into Python. These are the 
same BASIC games that I tried to program into my Commodore 64 without 
much success when I was much younger. Many of these BASIC games are a 
good introduction to classical programming problems like rolling dice 
and playing cards.


http://www.atariarchives.org/basicgames/

When I realized that I wasn't learning enough about the Python language 
from translating BASIC games, I started coding a chess engine. If you 
ever look at the academic literature for chess programming from the last 
50+ years, you can spend a lifetime solving the programming challenges 
from implementing the game of kings.


Thank you,

Chris R.


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


Re: How to become more motivated to learn Python

2016-05-03 Thread Cai Gengyang
Cool, I have finally summoned up enough activation energy to start on Unit 3, 
now going through the topic on Conditionals and Control Flows (stuff like this)

>>> boolthree = 200 == (50 * 5)
>>> boolthree
False

Guess it would be really cool to work on AI and games. ( I have been addicted 
to computer games for a long time lol --- To be able to design a blockbuster 
like Starcraft 2, Diablo 3 or Final Fantasy 7 would be an incredible feat !) 

Didn't know that chess programming goes back 50+ years --- I always thought 
that computer programs were a recent invention. As it turns out , Ada Lovelace 
wrote the world's first computer program in 1842 
(http://www.todayifoundout.com/index.php/2011/02/in-1842-ada-lovelace-wrote-the-worlds-first-computer-program/)
 if this piece is true 




On Wednesday, May 4, 2016 at 10:13:13 AM UTC+8, Christopher Reimer wrote:
> On 5/3/2016 4:20 AM, Cai Gengyang wrote:
> > So I have completed up to CodeAcademy's Python Unit 2 , now moving on to 
> > Unit3 : Conditionals and Control Flow.
> >
> > But I feel my motivation wavering , at times I get stuck and frustrated 
> > when trying to learn a new programming language ?
> >
> > This might not be a technical question per say, but it is a Python 
> > programming related one. How do you motivate a person (either yourself or 
> > your child) to become more interested in programming and stick with it ? Is 
> > determination in learning (especially in a tough field like software) 
> > partly genetic ?
> >
> > Related , This is a very well written essay on determination by Paul Graham 
> > http://www.paulgraham.com/determination.html
> >
> > Gengyang
> 
> I started out translating old BASIC games into Python. These are the 
> same BASIC games that I tried to program into my Commodore 64 without 
> much success when I was much younger. Many of these BASIC games are a 
> good introduction to classical programming problems like rolling dice 
> and playing cards.
> 
> http://www.atariarchives.org/basicgames/
> 
> When I realized that I wasn't learning enough about the Python language 
> from translating BASIC games, I started coding a chess engine. If you 
> ever look at the academic literature for chess programming from the last 
> 50+ years, you can spend a lifetime solving the programming challenges 
> from implementing the game of kings.
> 
> Thank you,
> 
> Chris R.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to become more motivated to learn Python

2016-05-03 Thread DFS

On 5/3/2016 10:12 PM, Christopher Reimer wrote:



When I realized that I wasn't learning enough about the Python language
from translating BASIC games, I started coding a chess engine. If you
ever look at the academic literature for chess programming from the last
50+ years, you can spend a lifetime solving the programming challenges
from implementing the game of kings.



We can have a good thread on python chess engines some time.  I'm also 
going to write a chess engine in python - follow the UCI protocol and 
all.  You're way ahead of me, I'm sure, but I did already look into 
algebraic notation, game recording, FEN and all that.


pyChess is a nice little game: www.pychess.org

The one thing I'm not going to do is review anyone else's code until I 
put out v1.0 of my own.  My goal with v1.0 is for the pieces to make 
valid moves.  That's it.  Following that, I'll work in getting the game 
recording right.  No 'strategy' at first.  Maybe later I can load a 
library of well-known openings and try to utilize them.


How far along are you in your engine development?

Getting the code for en passant and castling right looks to be a bit of 
an obstacle.


What's nice is the strongest engine (Stockfish) is totally open source.


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


Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Steven D'Aprano
On Wed, 4 May 2016 12:49 am, Jussi Piitulainen wrote:

> DFS writes:
> 
>> On 5/3/2016 9:13 AM, Chris Angelico wrote:
> 
>>> It doesn't invert, the way numeric negation does.
>>
>> What do you mean by 'case inverted'?
>>
>> It looks like it swaps the case correctly between upper and lower.
> 
> There's letters that do not come in exact pairs of upper and lower case,

Languages with two distinct lettercases, like English, are called bicameral.
The two cases are technically called majuscule and minuscule, but
colloquially known as uppercase and lowercase since movable type printers
traditionally used to keep the majuscule letters in a drawer above the
minuscule letters.

Many alphabets are unicameral, that is, they only have a single lettercase.
Examples include Hebrew, Arabic, Hangul, and many others. Georgian is an
interesting example, as it is the only known written alphabet that started
as a bicameral script and then became unicameral.

Consequently, many letters are neither upper nor lower case, and have
Unicode category "Letter other":

py> c = u'\N{ARABIC LETTER FEH}'
py> unicodedata.category(c)
'Lo'
py> c.isalpha()
True
py> c.isupper()
False
py> c.islower()
False


Even among bicameral alphabets, there are a few anomalies. The three most
obvious ones are Greek sigma, German Eszett (or "sharp S") and Turkish I.

(1) The Greek sigma is usually written as Σ or σ in uppercase and lowercase
respectively, but at the end of a word, lowercase sigma is written as ς.

(This final sigma is sometimes called "stigma", but should not be confused
with the archaic Greek letter stigma, which has two cases Ϛ ϛ, at least
when it is not being written as digamma Ϝϝ -- and if you're confused, so
are the Greeks :-)

Python 3.3 correctly handles the sigma/final sigma when upper- and
lowercasing:

py> 'ΘΠΣΤΣ'.lower()
'θπστς'

py> 'ΘΠΣΤΣ'.lower().upper()
'ΘΠΣΤΣ'



(2) The German Eszett ß traditionally existed in only lowercase forms, but
despite the existence of an uppercase form since at least the 19th century,
when the Germans moved away from blackletter to Roman-style letters, the
uppercase form was left out. In recent years, printers in Germany have
started to reintroduce an uppercase version, and the German government have
standardized on its use for placenames, but not other words.

(Aside: in Germany, ß is not considered a distinct letter of the alphabet,
but a ligature of ss; historically it derived from a ligature of ſs, ſz or
ſʒ. The funny characters you may or may not be able to see are the long-S
and round-Z.)

Python follows common, but not universal, German practice for eszett:

py> 'ẞ'.lower()
'ß'
py> 'ß'.upper()
'SS'

Note that this is lossy: given a name like "STRASSER", it is impossible to
tell whether it should be title-cased to "Strasser" or "Straßer". It also
means that uppercasing a string can make it longer.


For more on the uppercase eszett, see:

https://typography.guru/journal/germanys-new-character/
https://typography.guru/journal/how-to-draw-a-capital-sharp-s-r18/


(3) In most Latin alphabets, the lowercase i and j have a "tittle" diacritic
on them, but not the uppercase forms I and J. Turkish and a few other
languages have both I-with-tittle and I-without-tittle.

(As far as I know, there is no language with a dotless J.)

So in Turkish, the correct uppercase to lowercase and back again should go:

Dotless I: I -> ı -> I

Dotted I: İ -> i -> İ

Python does not quite manage to handle this correctly for Turkish
applications, since it loses the dotted/dotless distinction:

py> 'ı'.upper()
'I'
py> 'İ'.lower()
'i'

and further case conversions follow the non-Turkish rules.

Note that sometimes getting this wrong can have serious consequences:

http://gizmodo.com/382026/a-cellphones-missing-dot-kills-two-people-puts-three-more-in-jail



-- 
Steven

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


Re: How to become more motivated to learn Python

2016-05-03 Thread Christopher Reimer

On 5/3/2016 8:00 PM, DFS wrote:

How far along are you in your engine development?


I can display a text-based chess board on the console (looks better with 
a mono font).



 8   BR BN BB BQ BK BB BN BR

 7   BP BP BP BP BP BP BP BP

 6   __ __ __ __ __ __ __ __

 5   __ __ __ __ __ __ __ __

 4   __ __ __ __ __ __ __ __

 3   __ __ __ __ __ __ __ __

 2   WP WP WP WP WP WP WP WP

 1   WR WN WB WQ WK WB WN WR

 A  B  C  D  E  F  G  H


With feedback from this list, I had to break a lot of bad Java habits to 
make the code more Pythonic. Right now I'm going back and forth between 
writing documentation and unit tests. Once I finalized the code in its 
current state, I'll post it up on GitHub under the MIT license. Future 
updates will have a fuller console interface and moves for individual 
pieces implemented.


Thank you,

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


python chess engines

2016-05-03 Thread DFS

On 5/3/2016 8:00 PM, DFS wrote:

How far along are you in your engine development?



I can display a text-based chess board on the console (looks better
with a mono font).

8   BR BN BB BQ BK BB BN BR

7   BP BP BP BP BP BP BP BP

6   __ __ __ __ __ __ __ __

5   __ __ __ __ __ __ __ __

4   __ __ __ __ __ __ __ __

3   __ __ __ __ __ __ __ __

2   WP WP WP WP WP WP WP WP

1   WR WN WB WQ WK WB WN WR

A  B  C  D  E  F  G  H


With feedback from this list, I had to break a lot of bad Java habits
to make the code more Pythonic. Right now I'm going back and forth
between writing documentation and unit tests. Once I finalized the
code in its current state, I'll post it up on GitHub under the MIT
license. Future updates will have a fuller console interface and
moves for individual pieces implemented.




Thank you,

Chris R.



Wanted to start a new thread, rather than use the 'motivated' thread.

Can you play your game at the console?

The way I think about a chess engine is it doesn't even display a board. 
 It accepts a move as input, records the move, analyzes the positions 
after the move, and returns the next move.


Here's the UCI protocol.
http://download.shredderchess.com/div/uci.zip


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


Re: Fastest way to retrieve and write html contents to file

2016-05-03 Thread DFS

On 5/3/2016 2:41 PM, Tim Chase wrote:

On 2016-05-03 13:00, DFS wrote:

On 5/3/2016 11:28 AM, Tim Chase wrote:

On 2016-05-03 00:24, DFS wrote:

One small comparison I was able to make was VBA vs python/pyodbc
to summarize an Access database.  Not quite a fair test, but
interesting nonetheless.

Access 2003 file
Access 2003 VBA code
Time: 0.18 seconds

same Access 2003 file
32-bit python 2.7.11 + 32-bit pyodbc 3.0.6
Time: 0.49 seconds


Curious whether you're forcing Access VBA to talk over ODBC or
whether Access is using native access/file-handling (and thus
bypassing the ODBC overhead)?


The latter, which is why I said "not quite a fair test".


Can you try the same tests, getting Access/VBA to use ODBC instead to
see how much overhead ODBC entails?

-tkc



Done.

I dropped a few extraneous tables from the database (was 114 tables):

Access 2003 .mdb file
2,009,164 rows
97 tables  (max row = 600288)
725 columns
  text:  389
  boolean:   4
  numeric:   261
  date-time: 69
  binary:2
264 indexes (25 foreign keys)*
299,167,744 bytes on disk


1. DAO
   Time: 0.15 seconds

2. ADODB, Access ODBC driver, OpenSchema method**
   Time: 0.26 seconds

3. python, pyodbc, Access ODBC driver
   Time: 0.42 seconds




* despite being written by Microsoft, the Access ODBC driver doesn't
  support the ODBC SQLForeignKeys function, so the python code doesn't
  show a count of foreign keys

** the Access ODBC driver doesn't support the adSchemaIndexes or
   adSchemaForeignKeys query types, so I used DAO code to count
   indexes and foreign keys.






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


Re: How to become more motivated to learn Python

2016-05-03 Thread Larry Hudson via Python-list

On 05/03/2016 07:55 PM, Cai Gengyang wrote:

Cool, I have finally summoned up enough activation energy to start on Unit 3, 
now going through the topic on Conditionals and Control Flows (stuff like this)


boolthree = 200 == (50 * 5)
boolthree

False

Guess it would be really cool to work on AI and games. ( I have been addicted 
to computer games for a long time lol --- To be able to design a blockbuster 
like Starcraft 2, Diablo 3 or Final Fantasy 7 would be an incredible feat !)



For an introduction to Python via games you might want to check out the book "Invent Your Own 
Computer Games With Python".  (However, these are strictly text-based games -- no graphics, but 
a fairly good intro to Python programming.)  It's available to read on-line, or for download as 
a .pdf athttp://inventwithpython.com/


Use the "PDF and All Source Code" link to download it.

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