Re: New to Python - block grouping (spaces)

2015-04-17 Thread Antoon Pardon
Op 16-04-15 om 19:10 schreef Steven D'Aprano:
> On Thu, 16 Apr 2015 08:51 pm, BartC wrote:
>
>> On 16/04/2015 06:49, Steven D'Aprano wrote:
>>> On Thursday 16 April 2015 14:07, Blake McBride wrote:
 Is there a utility that will allow me to write Python-like code that
 includes some block delimiter that I can see, that converts the code
 into
 runnable Python code?  If so, where can I find it?
>>> No more bugs from accidentally forgetting to use optional braces!
>> You get bugs instead from mistakenly using the wrong indentation or
>> losing the correct indentation (accidentally pressing the wrong key for
>> example).
> That's nothing! Python gives you absolutely no protection from accidentally
> typing:
>
>
> x += 1
>
> when you actually wanted:
>
>y -= 2

I find this a bit disingenuous. Each time assignment as an expression comes
up, so that it would be possible to have an assignment in a if or while
condition, few of the regulars seem to have a problem with the argument that
the current choice protects against a particular kind of bug.

The fact that braces protect against a kind of bug you care less about,
is just your preference. That doesn't mean a different preference is
somehow worthy of ridicule.

Mistakes of all kinds happen and I see no reason to ridicule someone for
wishing protect against one kind of mistake, while yourself having the
protection you like.

-- 
Antoon Pardon

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


Re: Great Math Mystery

2015-04-17 Thread Fetchinson .
>> In an altercation with the police, complying with their orders greatly
>> increases your chances of survival.
>
> Ah, the definition of a police state: where ordinary people, whether
> breaking the law or not, are forced by fear of death to obey the police at
> all times, whether the police are acting legally or not.

I think you are grossly mischaracterizing that sentence of the OP. He
simply makes an observation: in an altercation with the police,
complying with their orders greatly increases your chances of
survival. Is this observation/statement true or false? Based on
empirical data from the past 50 years (in the US and elsewhere) I'd
say it's true by a huge margin.

The OP didn't make any value judgements on this statement whether he
advocates for compliance or not, whether he encourages the
establishment of a police state or not, whether he thinks compliance
is a good thing or not.

For all we know he might be a flaming anarchist with a keen sense of
observing empirical facts.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Great Math Mystery

2015-04-17 Thread alister
On Fri, 17 Apr 2015 11:47:06 +0200, Fetchinson . wrote:

>>> In an altercation with the police, complying with their orders greatly
>>> increases your chances of survival.
>>
>> Ah, the definition of a police state: where ordinary people, whether
>> breaking the law or not, are forced by fear of death to obey the police
>> at all times, whether the police are acting legally or not.
> 
> I think you are grossly mischaracterizing that sentence of the OP. He
> simply makes an observation: in an altercation with the police,
> complying with their orders greatly increases your chances of survival.
> Is this observation/statement true or false? Based on empirical data
> from the past 50 years (in the US and elsewhere) I'd say it's true by a
> huge margin.
> 
> The OP didn't make any value judgements on this statement whether he
> advocates for compliance or not, whether he encourages the establishment
> of a police state or not, whether he thinks compliance is a good thing
> or not.
> 
> For all we know he might be a flaming anarchist with a keen sense of
> observing empirical facts.
> 
> Cheers,
> Daniel

or simply using a fortune cookie program to generate random signatures, 
just ass I do, sometimes the result is quite spooky).

( i just took a look at mine for this post & was pleasantly surprised to 
see it is programming related)


-- 
((lambda (foo) (bar foo)) (baz))
-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: Python Meeting Düsseldorf - 29.04.2015

2015-04-17 Thread eGenix Team: M.-A. Lemburg
[This announcement is in German since it targets a local user group
 meeting in Düsseldorf, Germany]


ANKÜNDIGUNG

 Python Meeting Düsseldorf

 http://pyddf.de/

   Ein Treffen von Python Enthusiasten und Interessierten
in ungezwungener Atmosphäre.

  Dienstag, 29.04.2015, 18:00 Uhr
  Raum 1, 2.OG im Bürgerhaus Stadtteilzentrum Bilk
Düsseldorfer Arcaden, Bachstr. 145, 40217 Düsseldorf

Diese Nachricht ist auch online verfügbar:
http://www.egenix.com/company/news/Python-Meeting-Duesseldorf-2015-04-29


NEUIGKEITEN

 * Bereits angemeldete Vorträge:

   Johannes Spielmann
   "Nachrichtenprotokolle in Python"

   Matthias Endler
   "The State of PyPy"

   Charlie Clark
   "Die Kunst des Nichtstun: Eine Einführung in Profiling"
   "et_xmlfile: Valides XML schreiben mit niedrigem Speicherbedarf"

   Marc-Andre Lemburg
   "SSL in Python 2.7.9"
   "YouTube Feed mit feedparser auswerten"

   Weitere Vorträge können gerne noch angemeldet werden: i...@pyddf.de

 * Startzeit und Ort:

   Wir treffen uns um 18:00 Uhr im Bürgerhaus in den Düsseldorfer
   Arcaden.

   Das Bürgerhaus teilt sich den Eingang mit dem Schwimmbad
   und befindet sich an der Seite der Tiefgarageneinfahrt der
   Düsseldorfer Arcaden.

   Über dem Eingang steht ein großes “Schwimm’'in Bilk”
   Logo. Hinter der Tür direkt links zu den zwei Aufzügen,
   dann in den 2. Stock hochfahren. Der Eingang zum Raum 1
   liegt direkt links, wenn man aus dem Aufzug kommt.

   Google Street View: http://bit.ly/11sCfiw


EINLEITUNG

Das Python Meeting Düsseldorf ist eine regelmäßige Veranstaltung in
Düsseldorf, die sich an Python Begeisterte aus der Region wendet:

 * http://pyddf.de/

Einen guten Überblick über die Vorträge bietet unser YouTube-Kanal,
auf dem wir die Vorträge nach den Meetings veröffentlichen:

 * http://www.youtube.com/pyddf/

Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld,
in Zusammenarbeit mit Clark Consulting & Research, Düsseldorf:

 * http://www.egenix.com/
 * http://www.clark-consulting.eu/


PROGRAMM

Das Python Meeting Düsseldorf nutzt eine Mischung aus Open Space
und Lightning Talks, wobei die Gewitter bei uns auch schon mal
20 Minuten dauern können ;-).

Lightning Talks können vorher angemeldet werden, oder auch
spontan während des Treffens eingebracht werden. Ein Beamer mit
XGA Auflösung steht zur Verfügung. Folien bitte als PDF auf USB
Stick mitbringen.

Lightning Talk Anmeldung bitte formlos per EMail an i...@pyddf.de


KOSTENBETEILIGUNG

Das Python Meeting Düsseldorf wird von Python Nutzern für Python
Nutzer veranstaltet. Um die Kosten zumindest teilweise zu
refinanzieren, bitten wir die Teilnehmer um einen Beitrag
in Höhe von EUR 10,00 inkl. 19% Mwst, Schüler und Studenten
zahlen EUR 5,00 inkl. 19% Mwst.

Wir möchten alle Teilnehmer bitten, den Betrag in bar mitzubringen.


ANMELDUNG

Da wir nur für ca. 20 Personen Sitzplätze haben, möchten wir
bitten, sich per EMail anzumelden. Damit wird keine Verpflichtung
eingegangen. Es erleichtert uns allerdings die Planung.

Meeting Anmeldung bitte formlos per EMail an i...@pyddf.de


WEITERE INFORMATIONEN

Weitere Informationen finden Sie auf der Webseite des Meetings:

http://pyddf.de/

Mit freundlichen Grüßen,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 17 2015)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> mxODBC Plone/Zope Database Adapter ...   http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


: Try our mxODBC.Connect Python Database Interface for free ! ::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
-- 
https://mail.python.org/mailman/listinfo/python-list


looking for students to take new online python course at no cost

2015-04-17 Thread biker
 Hi,
 (I apologize if this seems spammy, but I think this is a good
opportunity for beginning python programmers.)
 We are seeking candid feedback on a new python programming online
course for beginners, and will randomly select students (lottery
style/5 new students each month) who are new to python to take the
course at no charge.
 For the course project, students code a web crawler and a simple
search engine front-end to query the results from their crawl (stored
in their personal back-end mysql db).
 Some of the python libraries covered/utilized in the course include
urllib2, BeautifulSoup 4 (bs4), robotparser, numpy and
mysql.connector.
 There is no compiler to install because the student development
environment (used to edit, save and run python program files) is 100%
web-based...meaning, only a web browser is needed to access.
 Here is the link to the sign-up form -
http://www.livefirelabs.com/python-online-course.htm [1]
 ... and details about the course are here -
http://www.livefirelabs.com/learn-python-programming-01.htm [2]
 The next new student selection, as indicated on the sign-up web page,
is May 1, 2015.
 Thanks! biker
 

Links:
--
[1] http://www.livefirelabs.com/python-online-course.htm
[2] http://www.livefirelabs.com/learn-python-programming-01.htm
-- 
https://mail.python.org/mailman/listinfo/python-list


Converting text file to different encoding.

2015-04-17 Thread subhabrata . banerji
I am having few files in default encoding. I wanted to change their encodings, 
preferably in "UTF-8", or may be from one encoding to any other encoding. 

I was trying it as follows,

   >>> import codecs
   >>> sourceEncoding = "iso-8859-1"
   >>> targetEncoding = "utf-8"
   >>> source = open("source1","w")
   >>> target = open("target", "w")
   >>> target.write(unicode(source, sourceEncoding).encode(targetEncoding))

but it was giving me error as follows,
Traceback (most recent call last):
  File "", line 1, in 
target.write(unicode(source, sourceEncoding).encode(targetEncoding))
TypeError: coercing to Unicode: need string or buffer, file found

If anybody may kindly suggest how may I solve it. 

Regards,
Subhabrata Banerjee. 
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Converting text file to different encoding.

2015-04-17 Thread Rustom Mody
On Friday, April 17, 2015 at 6:50:08 PM UTC+5:30, subhabrat...@gmail.com wrote:
> I am having few files in default encoding. I wanted to change their 
> encodings, 
> preferably in "UTF-8", or may be from one encoding to any other encoding. 
> 
> I was trying it as follows,
> 
>>>> import codecs
>>>> sourceEncoding = "iso-8859-1"
>>>> targetEncoding = "utf-8"
>>>> source = open("source1","w")

Do you want "w" or "r" ?

>>>> target = open("target", "w")
>>>> target.write(unicode(source, sourceEncoding).encode(targetEncoding))
> 
> but it was giving me error as follows,
> Traceback (most recent call last):
>   File "", line 1, in 
> target.write(unicode(source, sourceEncoding).encode(targetEncoding))
> TypeError: coercing to Unicode: need string or buffer, file found
> 
> If anybody may kindly suggest how may I solve it. 
> 
> Regards,
> Subhabrata Banerjee.

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


Re: Converting text file to different encoding.

2015-04-17 Thread subhabrata . banerji
On Friday, April 17, 2015 at 6:50:08 PM UTC+5:30, subhabrat...@gmail.com wrote:
> I am having few files in default encoding. I wanted to change their 
> encodings, 
> preferably in "UTF-8", or may be from one encoding to any other encoding. 
> 
> I was trying it as follows,
> 
>>>> import codecs
>>>> sourceEncoding = "iso-8859-1"
>>>> targetEncoding = "utf-8"
>>>> source = open("source1","w")
>>>> target = open("target", "w")
>>>> target.write(unicode(source, sourceEncoding).encode(targetEncoding))
> 
> but it was giving me error as follows,
> Traceback (most recent call last):
>   File "", line 1, in 
> target.write(unicode(source, sourceEncoding).encode(targetEncoding))
> TypeError: coercing to Unicode: need string or buffer, file found
> 
> If anybody may kindly suggest how may I solve it. 
> 
> Regards,
> Subhabrata Banerjee.

As an ace coder you may know better than me what I would need, but if you have 
any roundabout or hint you may give I will practice to see if I may port it. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Immediate Hire: Liferay Developer - Remote

2015-04-17 Thread nagaraju thoudoju
Hi,



Hope you are doing well,
This is Raj from International Systems Technologies.

Please find the requirement below and let me know you interest on this position 
on  nagar...@intsystech.com or feel free to call me on D:908-333-3540 



Please 

Requirement:

Role: Liferay Develoeper

Location: Remote

Rate: $50-55/hr on C2C

1. Java: minimum of 3 years

2. Liferay: minimum of 2 years

3. Total IT experience minimum of 5 years

  

Thanks & Best Regards?

Raju

International Systems Technologies Inc.

10 Corporate place south.| Suite 203  |

Piscataway, NJ 08854  |

D:908-333-3540 |Fax:732-348-9533|

E-mail: nagar...@intsystech.com   |

URL: www.intsystech.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Converting text file to different encoding.

2015-04-17 Thread Oscar Benjamin
On 17 April 2015 at 14:51,   wrote:
> On Friday, April 17, 2015 at 6:50:08 PM UTC+5:30, subhabrat...@gmail.com 
> wrote:
>> I am having few files in default encoding. I wanted to change their 
>> encodings,
>> preferably in "UTF-8", or may be from one encoding to any other encoding.
>>
>> I was trying it as follows,
>>
>>>>> import codecs
>>>>> sourceEncoding = "iso-8859-1"
>>>>> targetEncoding = "utf-8"
>>>>> source = open("source1","w")
>>>>> target = open("target", "w")
>>>>> target.write(unicode(source, sourceEncoding).encode(targetEncoding))
>>
>> but it was giving me error as follows,
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> target.write(unicode(source, sourceEncoding).encode(targetEncoding))
>> TypeError: coercing to Unicode: need string or buffer, file found

The error comes from `unicode(source, sourceEncoding)` and results
from the fact that source is a file object when it should be a string.
To read the contents of the file as a string just change `source` to
`source.read()`.


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


Re: [Conferences] PyCon Mexico

2015-04-17 Thread Alexandro Colorado
I did that site, with the hope of rallying the troops to create a Summit in
Cancun about Python. However there were factors that slow the process down
and the project became idle after november.

On Thu, Mar 19, 2015 at 11:05 PM, Pythonízame MX 
wrote:

> Hello, my Name is Alex Dzul.
>
> Python /Django Programmer and actively support the Python community in
> Spanish.
>
>
> - http://pythoniza.me
> - https://www.youtube.com/user/pythonizame
> - https://www.youtube.com/user/alexexc2
>
>
> I wonder about the possibility of doing an event here in Mexico (PyCon
> Mexico).
>
> - What do we need to do it in our country?
> - Who is the contact to talk about it?
>
> I recently found this page http://pycon.mx/ but I don't know if it is
> real.
>
>
> Thanks for your attention.
>
> ___
> Python Conferences mailing list: conferen...@python.org
> https://mail.python.org/mailman/listinfo/conferences
>
> This is an open list with open archives; sensitive or confidential
> information should not be discussed here.
>



-- 
Alexandro Colorado
Apache OpenOffice Contributor
882C 4389 3C27 E8DF 41B9  5C4C 1DB7 9D1C 7F4C 2614
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Immediate Hire: Liferay Developer - Remote

2015-04-17 Thread Skip Montanaro
On Fri, Apr 17, 2015 at 9:02 AM, nagaraju thoudoju <
nagarajuusstaff...@gmail.com> wrote:

> 1. Java: minimum of 3 years
>
> 2. Liferay: minimum of 2 years
>
> 3. Total IT experience minimum of 5 years
>

Raju,

You recently posted another position which had nothing to do with Python. I
replied privately to that post. Others replied here. Please stop posting
inappropriate content for this list. Your posts do nothing but give people
a bad impression of you and the company you represent. I am adding your
company's contact email to this response. Hopefully someone there will
notice and discuss the matter with you.

If what I have written is at all unclear, feel free to call me
(847-971-7098). I would be happy to discuss this with you, especially if it
means you quit spamming python-list@python.org.

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


Re: Converting text file to different encoding.

2015-04-17 Thread subhabrata . banerji
On Friday, April 17, 2015 at 7:36:46 PM UTC+5:30, Oscar Benjamin wrote:
>  wrote:
> > On Friday, April 17, 2015 at 6:50:08 PM UTC+5:30,  wrote:
> >> I am having few files in default encoding. I wanted to change their 
> >> encodings,
> >> preferably in "UTF-8", or may be from one encoding to any other encoding.
> >>
> >> I was trying it as follows,
> >>
> >>>>> import codecs
> >>>>> sourceEncoding = "iso-8859-1"
> >>>>> targetEncoding = "utf-8"
> >>>>> source = open("source1","w")
> >>>>> target = open("target", "w")
> >>>>> target.write(unicode(source, sourceEncoding).encode(targetEncoding))
> >>
> >> but it was giving me error as follows,
> >> Traceback (most recent call last):
> >>   File "", line 1, in 
> >> target.write(unicode(source, sourceEncoding).encode(targetEncoding))
> >> TypeError: coercing to Unicode: need string or buffer, file found
> 
> The error comes from `unicode(source, sourceEncoding)` and results
> from the fact that source is a file object when it should be a string.
> To read the contents of the file as a string just change `source` to
> `source.read()`.
> 
> 
> Oscar

I tried to do as follows,
>>> import codecs
>>> sourceEncoding = "iso-8859-1"
>>> targetEncoding = "utf-8"
>>> source = open("source1","w")
>>> string1="String type"
>>> str1=str(string1)
>>> source.write(str1)
>>> source.close()
>>> target = open("target", "w")
>>> source=open("source1","r")
>>> target.write(unicode(source.read(), sourceEncoding).encode(targetEncoding))
>>>

am I going ok?

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


Re: Converting text file to different encoding.

2015-04-17 Thread Chris Angelico
On Sat, Apr 18, 2015 at 12:26 AM,   wrote:
> I tried to do as follows,
 import codecs
 sourceEncoding = "iso-8859-1"
 targetEncoding = "utf-8"
 source = open("source1","w")
 string1="String type"
 str1=str(string1)
 source.write(str1)
 source.close()
 target = open("target", "w")
 source=open("source1","r")
 target.write(unicode(source.read(), sourceEncoding).encode(targetEncoding))

>
> am I going ok?

Here's how I'd do it.

$ python3
>>> with open("source1", encoding="iso-8859-1") as source, open("target", "w", 
>>> encoding="utf-8") as target:
... target.write(source.read())

Or maybe this:

$ pike
> Stdio.write_file("target", string_to_utf8(Stdio.read_file("source1")));

So much easier than fiddling around with all those steps you're doing.
I'm not sure what they're all for, anyway; calling str() on a
double-quoted literal isn't usually going to do anything, and I don't
see "from __future__ import unicode_literals" anywhere.

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


Re: Converting text file to different encoding.

2015-04-17 Thread Dave Angel

On 04/17/2015 09:19 AM, subhabrata.bane...@gmail.com wrote:

I am having few files in default encoding. I wanted to change their encodings,
preferably in "UTF-8", or may be from one encoding to any other encoding.



You neglected to specify what Python version this is for.  Other 
information that'd be useful is whether the file size is small enough 
that two copies of it will all fit reasonably into memory.


I'll assume it's version 2.7, because of various clues in your sample 
code.  But if it's version 3.x, it could be substantially easier.



I was trying it as follows,

>>> import codecs
>>> sourceEncoding = "iso-8859-1"
>>> targetEncoding = "utf-8"
>>> source = open("source1","w")


mode "w" will truncate the source1 file, leaving you nothing to process. 
 i'd suggest "r"



>>> target = open("target", "w")


It's not usually a good idea to use the same variable for both the file 
name and the opened file object.  What if you need later to print the 
name, as in an error message?



>>> target.write(unicode(source, sourceEncoding).encode(targetEncoding))


I'd not recommend trying to do so much in one line, at least until you 
understand all the pieces.  Programming is not (usually) a contest to 
write the most obscure code, but rather to make a program you can still 
read and understand six months from now.  And, oh yeah, something that 
will run and accomplish something.


>
> but it was giving me error as follows,
> Traceback (most recent call last):
>File "", line 1, in 
>  target.write(unicode(source, sourceEncoding).encode(targetEncoding))
> TypeError: coercing to Unicode: need string or buffer, file found


if you factor this you will discover your error.  Nowhere do you read 
the source file into a byte string.  And that's what is needed for the 
unicode constructor.  Factored, you might have something like:


 encodedtext = source.read()
 text = unicode(source, sourceEncoding)
 reencodedtext = text.encode(targetEncoding)
 target.write(encodedText)

Next, you need to close the files.

source.close()
target.close()

There are a number of ways to improve that code, but this is a start.

Improvements:

 Use codecs.open() to open the files, so encoding is handled 
implicitly in the file objects.


 Use with... syntax so that the file closes are implicit

 read and write the files in a loop, a line at a time, so that you 
needn't have all the data in memory (at least twice) at one time.  This 
will also help enormously if you encounter any errors, and want to 
report the location and problem to the user.  It might even turn out to 
be faster.


 You should write non-trivial code in a text file, and run it from 
there.


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


Re: Converting text file to different encoding.

2015-04-17 Thread Marko Rauhamaa
Chris Angelico :

> Here's how I'd do it.
>
> $ python3
 with open("source1", encoding="iso-8859-1") as source,
>> open("target", "w", encoding="utf-8") as target:
> ... target.write(source.read())

You might run out of memory. How about:


#!/usr/bin/env python3
import shutil
shutil.copyfileobj(
open("source1", encoding="iso-8859-1"),
open("target", "w", encoding="utf-8"))



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


Re: Converting text file to different encoding.

2015-04-17 Thread Dave Angel

On 04/17/2015 10:48 AM, Dave Angel wrote:

On 04/17/2015 09:19 AM, subhabrata.bane...@gmail.com wrote:



>>> target = open("target", "w")


It's not usually a good idea to use the same variable for both the file
name and the opened file object.  What if you need later to print the
name, as in an error message?


Oops, my error.  Somehow my brain didn't notice the quote marks, until I 
reread my own message online.




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


Re: Great Math Mystery

2015-04-17 Thread Steven D'Aprano
On Fri, 17 Apr 2015 07:47 pm, Fetchinson . wrote:

>>> In an altercation with the police, complying with their orders greatly
>>> increases your chances of survival.
>>
>> Ah, the definition of a police state: where ordinary people, whether
>> breaking the law or not, are forced by fear of death to obey the police
>> at all times, whether the police are acting legally or not.
> 
> I think you are grossly mischaracterizing that sentence of the OP. He
> simply makes an observation: in an altercation with the police,
> complying with their orders greatly increases your chances of
> survival. Is this observation/statement true or false? Based on
> empirical data from the past 50 years (in the US and elsewhere) I'd
> say it's true by a huge margin.

Which is *exactly my point*.

"Failure to obey arbitrary commands from random police officers, whether
legally justified or not, may carry the penalty of summary execution at the
discretion of the officer" is a defining characteristic of police states.

I made no comment on the OP's intention for making that statement. Perhaps
he was making an ironic comment on the state of US law enforcement; perhaps
he thinks he is being genuinely helpful; perhaps this is his way of mocking
those killed. I don't know. Whether he is a fascist who thinks police
states are wonderful, or a liberal who thinks they are terrible, he
described a police state. Whether he knew it at the time or not.



-- 
Steven

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


Re: Converting text file to different encoding.

2015-04-17 Thread Peter Otten
Chris Angelico wrote:

> On Sat, Apr 18, 2015 at 12:26 AM,   wrote:
>> I tried to do as follows,
> import codecs
> sourceEncoding = "iso-8859-1"
> targetEncoding = "utf-8"
> source = open("source1","w")
> string1="String type"
> str1=str(string1)
> source.write(str1)
> source.close()
> target = open("target", "w")
> source=open("source1","r")
> target.write(unicode(source.read(),
> sourceEncoding).encode(targetEncoding))
>
>>
>> am I going ok?
> 
> Here's how I'd do it.
> 
> $ python3
 with open("source1", encoding="iso-8859-1") as source, open("target",
 "w", encoding="utf-8") as target:
> ... target.write(source.read())

This approach is also viable in Python 2.6 and 2.7 if you use io.open() 
instead of the builtin. 

To limit memory consumption for big files you can replace

target.write(source.read())

with

shutil.copyfileobj(source, target)

If you want to be sure that line endings are preserved open both files with

io.open(..., newline="") # disable newline translation

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


Re: New to Python - block grouping (spaces)

2015-04-17 Thread Michael Torrie
On 04/16/2015 08:52 AM, Blake McBride wrote:
> Thanks for all the responses.  I especially like the Pike pointer.
> To be clear:
> 
> 1.  I don't think languages should depend on invisible elements to
> determine logic.
> 
> 2.  Having been an employer, it is difficult to force programmers to
> use any particular editor or style.  Different editors handle tabs
> and spaces differently.  This is all a bloody nightmare with Python.
> 
> 3.  Languages that use braces (or the like) can be run through a
> program beautifier to correct the indentation.  You are just screwed
> in Python.  So, Python may be a cute language for you to use as an
> individual, but it is unwieldy in a real development environment.
> 
> 4.  Language beautifiers used on bracey languages removes all
> arguments in favor of an off-side language.

While it appears that you had already made up your mind about the matter
long before posting, and perhaps was just looking for vindication, I
feel that some of the snide replies you got were just not tremendously
professional.  However, it may be that people recognized that you likely
had made up your mind already, and posted accordingly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python - block grouping (spaces)

2015-04-17 Thread Grant Edwards
On 2015-04-17, Michael Torrie  wrote:
> On 04/16/2015 08:52 AM, Blake McBride wrote:
>> Thanks for all the responses.  I especially like the Pike pointer.
>> To be clear:
>
[troll bait elided]

> While it appears that you had already made up your mind about the
> matter long before posting, and perhaps was just looking for
> vindication, I feel that some of the snide replies you got were just
> not tremendously professional.

There are people who post to Usenet professionally?  And I've been
doing it all these years _for_free_?  And, it's not like there's some
sort of Olympics for which I needed to maintain my amateur standing.

> However, it may be that people recognized that you likely had made up
> your mind already, and posted accordingly.

I think most of us just assumed he was just trolling and were playing
along for the fun of it.

-- 
Grant Edwards   grant.b.edwardsYow! As President I have
  at   to go vacuum my coin
  gmail.comcollection!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python - block grouping (spaces)

2015-04-17 Thread BartC

On 17/04/2015 17:28, Grant Edwards wrote:

On 2015-04-17, Michael Torrie  wrote:



However, it may be that people recognized that you likely had made up
your mind already, and posted accordingly.


I think most of us just assumed he was just trolling and were playing
along for the fun of it.


What was troll-like about it? The OP made it clear he didn't like the 
way Python made use of tabs, but he didn't want an argument about it or 
to be persuaded to change his mind or change anyone else's.


He wanted to know if there was a simple syntax wrapper for it. That 
seems reasonable enough.


(Actually *I* would quite like to know why languages don't have 
switchable syntax anyway to allow for people's personal preferences.)


--
Bartc

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


Re: New to Python - block grouping (spaces)

2015-04-17 Thread Rustom Mody
On Friday, April 17, 2015 at 10:36:13 PM UTC+5:30, BartC wrote:
> (Actually *I* would quite like to know why languages don't have 
> switchable syntax anyway to allow for people's personal preferences.)

Mess in programming syntax is because of html:
http://blog.languager.org/2012/10/html-is-why-mess-in-programming-syntax.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Failed to import a "pyd: File When python intepreter embed in C++ project

2015-04-17 Thread saadaouijihed1990
I have a swig module (.pyd).I followed the steps but it doesn't work 
please help me.
-- 
https://mail.python.org/mailman/listinfo/python-list


EuroPython 2015: Django Girls Workshop

2015-04-17 Thread M.-A. Lemburg
We are happy to announce that we will be hosting a Django Girls Workshop
during the EuroPython 2015. It will take place on 20th of July, the
first day of the conference.

We believe in the work that this group is doing to bring more women
into technology, and we will work towards making EuroPython 2015
enjoyable and welcoming for these beginner programmers.

The workshop is free of charge and you must register through their
registration form; some financial aid for travel to Bilbao can be
provided:

https://docs.google.com/forms/d/1OEG1vpOa0fJWaGi81KLvoWloxbhKQW_ufp5Fb2j3QTc/viewform?c=0&w=1

The application process closes on May 31st, 2015.

The workshop is organized and coached by volunteers. If you or your
company would like to contribute by sponsoring, coaching, or any
other help you can provide, please email the organizers at
bil...@djangogirls.org.

Check out their website for more information:

http://djangogirls.org/europython2015/

Enjoy,
--
EuroPython 2015 Team
http://ep2015.europython.eu/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Failed to import a "pyd: File When python intepreter embed in C++ project

2015-04-17 Thread Emile van Sebille

On 4/17/2015 10:17 AM, saadaouijihed1...@gmail.com wrote:

I have a swig module (.pyd).I followed the steps but it doesn't work
please help me.



Start here:

http://catb.org/~esr/faqs/smart-questions.html

Emile


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


Re: New to Python - block grouping (spaces)

2015-04-17 Thread sohcahtoa82
On Friday, April 17, 2015 at 10:06:13 AM UTC-7, BartC wrote:
> On 17/04/2015 17:28, Grant Edwards wrote:
> > On 2015-04-17, Michael Torrie  wrote:
> 
> >> However, it may be that people recognized that you likely had made up
> >> your mind already, and posted accordingly.
> >
> > I think most of us just assumed he was just trolling and were playing
> > along for the fun of it.
> 
> What was troll-like about it? The OP made it clear he didn't like the 
> way Python made use of tabs, but he didn't want an argument about it or 
> to be persuaded to change his mind or change anyone else's.
> 
> He wanted to know if there was a simple syntax wrapper for it. That 
> seems reasonable enough.
> 
> (Actually *I* would quite like to know why languages don't have 
> switchable syntax anyway to allow for people's personal preferences.)
> 
> -- 
> Bartc

Allowing a switchable syntax only makes the fight even worse.  If you made 
braces in Python an option to use instead of whitespace block delimiting, then 
there'd be a ton of infighting among Python developers over which to use.  Just 
look at C/C++ developers fighting over where the opening brace goes.

By having the language itself forcing a specific style, it requires everyone 
using it to either shut up and get over it, or just don't use the language.

Personally, I like the Python style.  It forces people to write code that is at 
least somewhat good to look at.  Not like monstrosities like this that I see 
from newbie (hell, even professional) C/C++ programmers:

if (something > something_else)
{
result = do_something();
if (!result){
printf("Error!\n")
return 0;
}
do_other_stuff();
}

Can someone still write ugly code in Python?  No doubt about it.  But at least 
code blocks will be easily deciphered.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Great Math Mystery

2015-04-17 Thread Ron Adam



On 04/17/2015 11:03 AM, Steven D'Aprano wrote:

On Fri, 17 Apr 2015 07:47 pm, Fetchinson . wrote:


>>>In an altercation with the police, complying with their orders greatly
>>>increases your chances of survival.

>>
>>Ah, the definition of a police state: where ordinary people, whether
>>breaking the law or not, are forced by fear of death to obey the police
>>at all times, whether the police are acting legally or not.

>
>I think you are grossly mischaracterizing that sentence of the OP. He
>simply makes an observation: in an altercation with the police,
>complying with their orders greatly increases your chances of
>survival. Is this observation/statement true or false? Based on
>empirical data from the past 50 years (in the US and elsewhere) I'd
>say it's true by a huge margin.

Which is*exactly my point*.

"Failure to obey arbitrary commands from random police officers, whether
legally justified or not, may carry the penalty of summary execution at the
discretion of the officer" is a defining characteristic of police states.


This is but one subset of the possibilities that could lead to the same 
valid advise.


Keep in mind that many officers are citizens too, at least where I live, 
who have jobs that put them in extremely dangerous situations fairly often. 
 Taking too long to rationally think about a situation could mean the 
police officer is shot instead of the criminal with a gun.


There are some combinations of conditions that will result in a certain 
percentage of outcomes of a certain kind.  I think the original statement 
(Quite possibly from a fortune cookie program.) recognises that concept (as 
well as yours.)  Take a thousand officers, each who respond to a thousand 
calls a year, and there will be a few (very tragic) mistakes.  (and 
hopefully many more fortunate interventions.)  We can maybe shift the 
proportion of mistakes vs interventions, but I don't see how training 
officers to shoot after being shot is a good idea.  We will likely need to 
pay a whole lot more to get people to take those jobs.


Of course it does not excuse willing abuse of authority. Most cases of 
police power abuse here are more likely to be related to an individual 
officers state of mind and/or motives at the time rather than being due to 
instructions higher up.


Possibly there is a way to use Python and statistics to calculate some of 
these values.  With data of course...


   Number of officers.
   number of responses.
   Percent of responses where suspects have deadly weapons.
   Percent of incorrect judgements within some critical time frame
  by people in safe conditions.
   Percentage of incorrect judgements of people in dangerous conditions.
   Percentage of incorrect judgements of people in safe, but perceived
  dangerousness conditions.. etc...

Would be possible to calculate a norm or average from that kind of info?

It is also the type of number people don't want to know about or discuss.

   -Ron



I made no comment on the OP's intention for making that statement. Perhaps
he was making an ironic comment on the state of US law enforcement; perhaps
he thinks he is being genuinely helpful; perhaps this is his way of mocking
those killed. I don't know. Whether he is a fascist who thinks police
states are wonderful, or a liberal who thinks they are terrible, he
described a police state. Whether he knew it at the time or not.


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


Re: EuroPython 2015: Django Girls Workshop

2015-04-17 Thread beliavsky
On Friday, April 17, 2015 at 1:25:51 PM UTC-4, M.-A. Lemburg wrote:
> We are happy to announce that we will be hosting a Django Girls Workshop
> during the EuroPython 2015. It will take place on 20th of July, the
> first day of the conference.
> 
> We believe in the work that this group is doing to bring more women
> into technology, and we will work towards making EuroPython 2015
> enjoyable and welcoming for these beginner programmers.

If your target audience is women, I think you should have termed it the Django 
Womens Workshop rather than the Django Girls Workshop. Referring to adults as 
children can be seen as condescending.

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


Re: New to Python - block grouping (spaces)

2015-04-17 Thread Marko Rauhamaa
sohcahto...@gmail.com:

> Can someone still write ugly code in Python? No doubt about it. But at
> least code blocks will be easily deciphered.

That's how I was originally convinced about Python: a coworker with a
terrible C++ "handwriting" produced neat, legible code in Python.

I'm still slightly annoyed by some downsides in the indentation style,
but the practical benefits more than compensate. Also, the semicolon
rules of JavaScript and Go are horrible compared with the simple line
continuation rules of Python.


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


Re: EuroPython 2015: Django Girls Workshop

2015-04-17 Thread Marko Rauhamaa
beliav...@aol.com:

> If your target audience is women, I think you should have termed it
> the Django Womens Workshop rather than the Django Girls Workshop.
> Referring to adults as children can be seen as condescending.

You got it wrong. The name is not offensive. However, it suffers from
two serious problems:

 * You might think it's for children only.

 * The name's missing an apostrophe.


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


Re: EuroPython 2015: Django Girls Workshop

2015-04-17 Thread Larry Martell
On Fri, Apr 17, 2015 at 4:31 PM, Marko Rauhamaa  wrote:
> beliav...@aol.com:
>
>> If your target audience is women, I think you should have termed it
>> the Django Womens Workshop rather than the Django Girls Workshop.
>> Referring to adults as children can be seen as condescending.
>
> You got it wrong. The name is not offensive.

Most adult woman I know take offense at being called a girl.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python - block grouping (spaces)

2015-04-17 Thread Chris Angelico
On Sat, Apr 18, 2015 at 3:05 AM, BartC  wrote:
> (Actually *I* would quite like to know why languages don't have switchable
> syntax anyway to allow for people's personal preferences.)

Why do it? What's the advantage of calling two different syntaxes one
language? Simpler to just call them two separate languages - maybe two
languages that share some sort of runtime, but two languages. For
instance, Java bytecode doesn't have to be created from Java source
code, but we don't consider NetRexx to be a "switchable syntax" for
Java. It's a completely separate language that compiles to a .class
file.

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


Re: EuroPython 2015: Django Girls Workshop

2015-04-17 Thread Mark Lawrence

On 17/04/2015 20:35, beliav...@aol.com.dmarc.invalid wrote:

On Friday, April 17, 2015 at 1:25:51 PM UTC-4, M.-A. Lemburg wrote:

We are happy to announce that we will be hosting a Django Girls Workshop
during the EuroPython 2015. It will take place on 20th of July, the
first day of the conference.

We believe in the work that this group is doing to bring more women
into technology, and we will work towards making EuroPython 2015
enjoyable and welcoming for these beginner programmers.


If your target audience is women, I think you should have termed it the Django 
Womens Workshop rather than the Django Girls Workshop. Referring to adults as 
children can be seen as condescending.



http://djangogirls.org/

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


ANN: Leo 5.1-final. PIM, scripting Python IDE, Outliner

2015-04-17 Thread edreamleo

http://leoeditor.com/";>Leo 5.1 final is now available at
http://sourceforge.net/projects/leo/files/Leo/";>SourceForge.
Leo is Open Software, using the
http://leoeditor.com/license.html";>MIT License.



Leo 5.1-final is recommended for anyone using Leo 5.1 b1 or Leo 5.0-final.


The highlights of Leo 5.1


This release features @clean, one of the most important developments in 
Leo's history.
@clean nodes create external files without sentinel comments,
yet Leo can update @clean trees from changes made to the corresponding 
external files.
Steve Zatz explains http://leoeditor.com/testimonials.html#steve-zatz-explains-why-clean-changes-everything";>why
 @clean changes everything.


More highlights



@clean trees preserve clone links and user attributes (uA's).
Reading @clean trees is faster than reading @auto or @shadow trees.
A new http://leoeditor.com/load-leo.html";>web page displays 
.leo files in the browser.
Added command history to Leo's minibuffer.
A new IdleTime class greatly simplifies idle-time handling.
Leo now honors @language inside @doc parts.
@data nodes can be composed of their descendant nodes.



Links




The http://leoeditor.com/appendices.html#the-mulder-ream-update-algorithm";> 
Mulder/Ream algorithm
updates @clean trees
http://leoeditor.com";>Leo's home page
http://leoeditor.com/leo_toc.html";>Documentation
http://leoeditor.com/tutorial.html";>Tutorials
http://leoeditor.com/screencasts.html";>Video tutorials
http://groups.google.com/group/leo-editor";>Forum
http://sourceforge.net/projects/leo/files/";>Download
https://github.com/leo-editor/leo-editor";>Leo on Github
http://leoeditor.com/testimonials.html";>What people are saying 
about Leo
http://leoeditor.com/load-leo.html";>A web page that displays .leo 
files
http://leoeditor.com/leoLinks.html";>More links




Edward K. Ream: mailto:edream...@gmail.com";>email.


http://leoeditor.com/";>Leo 5.1
is a PIM, a Python scripting IDE and outliner. (16-Apr-15)

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


Re: EuroPython 2015: Django Girls Workshop

2015-04-17 Thread Ben Finney
Marko Rauhamaa  writes:

> beliav...@aol.com:
>
> > If your target audience is women, I think you should have termed it
> > the Django Womens Workshop rather than the Django Girls Workshop.
> > Referring to adults as children can be seen as condescending.
>
> You got it wrong. The name is not offensive.

It is not for you to say what is offensive to others.

Further, nobody claimed it is “offensive”, so why raise that?

The claim is that to call women “girls” is condenscending.

-- 
 \  “People always ask me, ‘Where were you when Kennedy was shot?’ |
  `\Well, I don't have an alibi.” —Emo Philips |
_o__)  |
Ben Finney

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


Re: EuroPython 2015: Django Girls Workshop

2015-04-17 Thread Terry Reedy

On 4/17/2015 4:31 PM, Marko Rauhamaa wrote:

beliav...@aol.com:


If your target audience is women, I think you should have termed it
the Django Womens Workshop rather than the Django Girls Workshop.
Referring to adults as children can be seen as condescending.


Are all of you claiming this so ignorant that 'girls' is sometimes used 
to refer to adult women, just as 'boys' is someitmes used to refer to 
adult men?  The co-founders of 'Django Girls', djangogirls.org, are two 
Polish females.  Judging from their pictures on their twitter pages, 
they were perhaps in their 20s at the time.  They love Python, are 
Django Core Developers, and want to share, especially with other women. 
They were *not* condescending themselves or other women.


"
We want to inspire women to fall in love with programming.

So we organize free Python and Django workshops, create open sourced 
online tutorials and care about amazing first experiences.

"



You got it wrong. The name is not offensive. However, it suffers from
two serious problems:

  * You might think it's for children only.


I would not.


  * The name's missing an apostrophe.


Nope.  The organization is 'Django Girls', not 'Django Girl'.  A Djange 
Girls Workshop is a workshop by and for Django Girls.


--
Terry Jan Reedy

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


Re: EuroPython 2015: Django Girls Workshop

2015-04-17 Thread Ian Kelly
On Fri, Apr 17, 2015 at 5:29 PM, Terry Reedy  wrote:
> On 4/17/2015 4:31 PM, Marko Rauhamaa wrote:
>>   * You might think it's for children only.
>
>
> I would not.

It was my first impression that it was targeted for children. There
are a lot of STEM programs these days oriented toward girl children,
and the name in combination with the second paragraph of the OP led me
to believe that this was one of those. I think it's fair to say that
the announcement could have been a bit clearer about the organization
behind the event and about the intended audience.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Importing/migrating Mailman mbox files into Google Groups?

2015-04-17 Thread Cameron Simpson

On 16Apr2015 08:32, Skip Montanaro  wrote:

Quite sometime ago (2011?), the classic-rendezvous mailing list, which had
been hosted by a Mailman instance at bikelist.org, was reconstituted as a
Google Group. Just a bunch of old bikies interested in vintage bikes. The
original archives were never imported into the new group. (It might not
have been possible at that time.) I suspect there might be a way to
accomplish that today using some Google API like this:

https://developers.google.com/admin-sdk/groups-migration/v1/reference/archive/insert

Has anyone here attempted such a feat? I have no problem with the Python
side of traversing the necessary mbox archive files, but have no experience
with any of the Google APIs.

Pointers appreciated...


Hmm, I have never used these.

However, before you get very excited see if people can get messages back out of 
the archive. A major annoyance for me with GGroups versus mailman is that if I 
join a group I cannot download the historical archive. (This is a standard step 
for me when I join a mailing list. I hear mailman 3 might be tossing this 
facility; I am unimpressed.)


Returning to the original question, it looks like the uppload format is pretty 
simple. This page:


 
https://developers.google.com/admin-sdk/groups-migration/v1/guides/manage-email-migrations#group_migration_media_upload

which is linked to from your link seems to show an example.

Cheers,
Cameron Simpson 

Facts do not discourage the conspiracy-minded.
   - Robert Crawford 
--
https://mail.python.org/mailman/listinfo/python-list


Re: Failed to import a "pyd: File When python intepreter embed in C++ project

2015-04-17 Thread Dave Angel

On 04/17/2015 01:17 PM, saadaouijihed1...@gmail.com wrote:

I have a swig module (.pyd).I followed the steps but it doesn't work
please help me.



First, unplug the computer and remove the battery.  Then if it's still 
burning, douse it with a fire extinguisher.


If your symptoms are different, you'll have to spell it out.  Like 
Python version, OS, complete stack trace.  And anything else that may be 
needed to diagnose the problem.


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


Need opinions on P vs NP

2015-04-17 Thread Paddy
Having just seen Raymond's talk on Beyond PEP-8 here: 
https://www.youtube.com/watch?v=wf-BqAjZb8M, it reminded me of my own recent 
post where I am soliciting opinions from non-newbies on the relative 
Pythonicity of different versions of a routine that has non-simple array 
manipulations.

The blog post: 
http://paddy3118.blogspot.co.uk/2015/04/pythonic-matrix-manipulation.html

The first, (and original), code sample:

def cholesky(A):
L = [[0.0] * len(A) for _ in range(len(A))]
for i in range(len(A)):
for j in range(i+1):
s = sum(L[i][k] * L[j][k] for k in range(j))
L[i][j] = sqrt(A[i][i] - s) if (i == j) else \
  (1.0 / L[j][j] * (A[i][j] - s))
return L


The second equivalent code sample:

def cholesky2(A):
L = [[0.0] * len(A) for _ in range(len(A))]
for i, (Ai, Li) in enumerate(zip(A, L)):
for j, Lj in enumerate(L[:i+1]):
s = sum(Li[k] * Lj[k] for k in range(j))
Li[j] = sqrt(Ai[i] - s) if (i == j) else \
  (1.0 / Lj[j] * (Ai[j] - s))
return L


The third:

def cholesky3(A):
L = [[0.0] * len(A) for _ in range(len(A))]
for i, (Ai, Li) in enumerate(zip(A, L)):
for j, Lj in enumerate(L[:i]):
#s = fsum(Li[k] * Lj[k] for k in range(j))
s = fsum(Lik * Ljk for Lik, Ljk in zip(Li, Lj[:j]))
Li[j] = (1.0 / Lj[j] * (Ai[j] - s))
s = fsum(Lik * Lik for Lik in Li[:i])
Li[i] = sqrt(Ai[i] - s)
return L

My blog post gives a little more explanation, but I have yet to receive any 
comments on relative Pythonicity.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python - block grouping (spaces)

2015-04-17 Thread Dan Sommers
On Fri, 17 Apr 2015 18:05:52 +0100, BartC wrote:

> (Actually *I* would quite like to know why languages don't have
> switchable syntax anyway to allow for people's personal preferences.)

You want LISP, the programmable programming language.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python - block grouping (spaces)

2015-04-17 Thread Michael Torrie
On 04/17/2015 11:05 AM, BartC wrote:
> He wanted to know if there was a simple syntax wrapper for it. That 
> seems reasonable enough.
> 
> (Actually *I* would quite like to know why languages don't have 
> switchable syntax anyway to allow for people's personal preferences.)

There was a version of Python (compatible at a bytecode level) that did
implement braces for blocks.  It was called pythonb, but it is now
defunct, understandably for lack of interest.  It was just a
modification to the parser is all.  So it's completely doable.  In fact
one could probably do it with a preprocessor of some kind.  But there's
little utility in it.

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


Re: EuroPython 2015: Django Girls Workshop

2015-04-17 Thread catperson
On Fri, 17 Apr 2015 23:31:42 +0300, Marko Rauhamaa 
wrote:

>beliav...@aol.com:
>
>> If your target audience is women, I think you should have termed it
>> the Django Womens Workshop rather than the Django Girls Workshop.
>> Referring to adults as children can be seen as condescending.
>
>You got it wrong. The name is not offensive. However, it suffers from
>two serious problems:
>
> * You might think it's for children only.
>
> * The name's missing an apostrophe.
>
>
>Marko


They are not girls, they are purple penguins.  PC can be taken too
far...

http://journalstar.com/news/local/education/lps-staff-s-transgender-training-concerns-parents/article_0b37dd75-758d-50c1-9deb-16901059bc5a.html

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


Re: New to Python - block grouping (spaces)

2015-04-17 Thread Ben Finney
BartC  writes:

> (Actually *I* would quite like to know why languages don't have
> switchable syntax anyway to allow for people's personal preferences.)

Which people's personal preferences? Are these the same people who have
such passionate disagreement about tabs versus spaces?

If you only write programs that will only ever be read by you and no-one
else, feel free to maintain a fork of Python (or any other language)
that suits your personal preferences.

Too much effort? Or maybe you sometimes want others, whose preferences
may not exactly match yours, to collaborate on programs you write? Then
I think you have your answer of why such personal perferences are not
switchable in the languages we actually use.

-- 
 \  “It is the integrity of each individual human that is in final |
  `\examination. On personal integrity hangs humanity's fate.” |
_o__)   —Richard Buckminster Fuller, _Critical Path_, 1981 |
Ben Finney

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


Re: New to Python - block grouping (spaces)

2015-04-17 Thread Rustom Mody
On Saturday, April 18, 2015 at 6:49:30 AM UTC+5:30, Dan Sommers wrote:
> On Fri, 17 Apr 2015 18:05:52 +0100, BartC wrote:
> 
> > (Actually *I* would quite like to know why languages don't have
> > switchable syntax anyway to allow for people's personal preferences.)
> 
> You want LISP, the programmable programming language.

You got it!!
One of the deep paradoxes in 'getting' programming is that you cant do 
programming without some syntax; and yet syntax is irrelevant.

I dont believe one can ever get that without some experience of Lisp --
Minsky's Turing award lecture is an elaboration of this:
http://web.media.mit.edu/~minsky/papers/TuringLecture/TuringLecture.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need opinions on P vs NP

2015-04-17 Thread Ian Kelly
On Fri, Apr 17, 2015 at 7:19 PM, Paddy  wrote:
> Having just seen Raymond's talk on Beyond PEP-8 here: 
> https://www.youtube.com/watch?v=wf-BqAjZb8M, it reminded me of my own recent 
> post where I am soliciting opinions from non-newbies on the relative 
> Pythonicity of different versions of a routine that has non-simple array 
> manipulations.
>
> The blog post: 
> http://paddy3118.blogspot.co.uk/2015/04/pythonic-matrix-manipulation.html
>
> The first, (and original), code sample:
>
> def cholesky(A):
> L = [[0.0] * len(A) for _ in range(len(A))]
> for i in range(len(A)):
> for j in range(i+1):
> s = sum(L[i][k] * L[j][k] for k in range(j))
> L[i][j] = sqrt(A[i][i] - s) if (i == j) else \
>   (1.0 / L[j][j] * (A[i][j] - s))
> return L
>
>
> The second equivalent code sample:
>
> def cholesky2(A):
> L = [[0.0] * len(A) for _ in range(len(A))]
> for i, (Ai, Li) in enumerate(zip(A, L)):
> for j, Lj in enumerate(L[:i+1]):
> s = sum(Li[k] * Lj[k] for k in range(j))
> Li[j] = sqrt(Ai[i] - s) if (i == j) else \
>   (1.0 / Lj[j] * (Ai[j] - s))
> return L
>
>
> The third:
>
> def cholesky3(A):
> L = [[0.0] * len(A) for _ in range(len(A))]
> for i, (Ai, Li) in enumerate(zip(A, L)):
> for j, Lj in enumerate(L[:i]):
> #s = fsum(Li[k] * Lj[k] for k in range(j))
> s = fsum(Lik * Ljk for Lik, Ljk in zip(Li, Lj[:j]))
> Li[j] = (1.0 / Lj[j] * (Ai[j] - s))
> s = fsum(Lik * Lik for Lik in Li[:i])
> Li[i] = sqrt(Ai[i] - s)
> return L
>
> My blog post gives a little more explanation, but I have yet to receive any 
> comments on relative Pythonicity.

I prefer the first version. You're dealing with mathematical formulas
involving matrices here, so subscripting seems appropriate, and
enumerating out rows and columns just feels weird to me.

That said, I also prefer how the third version pulls the last column
of each row out of the inner loop instead of using a verbose
conditional expression that you already know will be false for every
column except the last one. Do that in the first version, and I think
you've got it.
-- 
https://mail.python.org/mailman/listinfo/python-list


PEP 492, new coroutine syntax for Python

2015-04-17 Thread Paul Rubin
I don't remember anyone mentioning this here yet, and it is mighty cool:

https://www.python.org/dev/peps/pep-0492/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 492, new coroutine syntax for Python

2015-04-17 Thread Chris Angelico
On Sat, Apr 18, 2015 at 1:47 PM, Paul Rubin  wrote:
> I don't remember anyone mentioning this here yet, and it is mighty cool:
>
> https://www.python.org/dev/peps/pep-0492/

Hah. It only just hit python-ideas, so you're jumping in on something
brand new - no wonder it hasn't been mentioned yet :)

And yes, it IS cool. I think the current proposal has a lot of
duplication (it looks like there's almost a complete replica of the
generator protocol being created in parallel), but whatever happens,
it's a good thing.

The document's in a state of some flux at the moment. If you're
interested, I strongly recommend jumping over to python-ideas and
following along - that is, if you're interested enough to drink from
the veritable fire-hose of -ideas! There's a chance this will land in
Python 3.5, but if not, I'd be very surprised if it doesn't hit 3.6.
This is an exciting time to be a Python programmer!

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


Re: Need opinions on P vs NP

2015-04-17 Thread Paddy
On Saturday, 18 April 2015 03:34:57 UTC+1, Ian  wrote:
> On Fri, Apr 17, 2015 at 7:19 PM, Paddy  wrote:
> > Having just seen Raymond's talk on Beyond PEP-8 here: 
> > https://www.youtube.com/watch?v=wf-BqAjZb8M, it reminded me of my own 
> > recent post where I am soliciting opinions from non-newbies on the relative 
> > Pythonicity of different versions of a routine that has non-simple array 
> > manipulations.
> >
> > The blog post: 
> > http://paddy3118.blogspot.co.uk/2015/04/pythonic-matrix-manipulation.html
> >
> > The first, (and original), code sample:
> >
> > def cholesky(A):
> > L = [[0.0] * len(A) for _ in range(len(A))]
> > for i in range(len(A)):
> > for j in range(i+1):
> > s = sum(L[i][k] * L[j][k] for k in range(j))
> > L[i][j] = sqrt(A[i][i] - s) if (i == j) else \
> >   (1.0 / L[j][j] * (A[i][j] - s))
> > return L
> >
> >
> > The second equivalent code sample:
> >
> > def cholesky2(A):
> > L = [[0.0] * len(A) for _ in range(len(A))]
> > for i, (Ai, Li) in enumerate(zip(A, L)):
> > for j, Lj in enumerate(L[:i+1]):
> > s = sum(Li[k] * Lj[k] for k in range(j))
> > Li[j] = sqrt(Ai[i] - s) if (i == j) else \
> >   (1.0 / Lj[j] * (Ai[j] - s))
> > return L
> >
> >
> > The third:
> >
> > def cholesky3(A):
> > L = [[0.0] * len(A) for _ in range(len(A))]
> > for i, (Ai, Li) in enumerate(zip(A, L)):
> > for j, Lj in enumerate(L[:i]):
> > #s = fsum(Li[k] * Lj[k] for k in range(j))
> > s = fsum(Lik * Ljk for Lik, Ljk in zip(Li, Lj[:j]))
> > Li[j] = (1.0 / Lj[j] * (Ai[j] - s))
> > s = fsum(Lik * Lik for Lik in Li[:i])
> > Li[i] = sqrt(Ai[i] - s)
> > return L
> >
> > My blog post gives a little more explanation, but I have yet to receive any 
> > comments on relative Pythonicity.
> 
> I prefer the first version. You're dealing with mathematical formulas
> involving matrices here, so subscripting seems appropriate, and
> enumerating out rows and columns just feels weird to me.
> 
> That said, I also prefer how the third version pulls the last column
> of each row out of the inner loop instead of using a verbose
> conditional expression that you already know will be false for every
> column except the last one. Do that in the first version, and I think
> you've got it.

But shouldn't the maths transcend the slight change in representation? A 
programmer in the J language might have a conceptually neater representation of 
the same thing due to its grounding in arrays (maybe) and for a J 
representation it would become J-thonic. In Python, it is usual to iterate over 
collections and also to use enumerate where we must have indices. 

Could it be that there is a also a strong pull in the direction of using 
indices because that is what is predominantly given in the way matrix maths is 
likely to be expressed mathematically? A case of "TeX likes indices so we 
should too"?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python - block grouping (spaces)

2015-04-17 Thread Larry Hudson

On 04/17/2015 07:22 PM, Ben Finney wrote:

BartC  writes:


(Actually *I* would quite like to know why languages don't have
switchable syntax anyway to allow for people's personal preferences.)


Which people's personal preferences? Are these the same people who have
such passionate disagreement about tabs versus spaces?

If you only write programs that will only ever be read by you and no-one
else, feel free to maintain a fork of Python (or any other language)
that suits your personal preferences.

Too much effort? Or maybe you sometimes want others, whose preferences
may not exactly match yours, to collaborate on programs you write? Then
I think you have your answer of why such personal perferences are not
switchable in the languages we actually use.


I always find discussions like these rather amusing.

From a practical standpoint, no matter now passionately someone feels about this sort of thing, 
it is ultimately totally irrelevant.  The language (whatever language or subject it is) is 
already defined.  You either use it as it exists or go on to something else.  EOD! 
(End-of-discussion).


The exception, of course, is if you are actively involved in the defining and creating something 
new.  But otherwise, take it or leave it.


Naturally you are permitted to have your own opinions, whether passionate or otherwise, but it's 
not worth arguing about.


 -=- Larry -=-

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


Re: PEP 492, new coroutine syntax for Python

2015-04-17 Thread Paul Rubin
Chris Angelico  writes:
> Hah. It only just hit python-ideas, so you're jumping in on something
> brand new - no wonder it hasn't been mentioned yet :)

Interesting.  It's dated a couple weeks ago and has obviously been in
the works for a while.  There's a working implementation which I'd think
means it's outside the idea phase.

> I think the current proposal has a lot of duplication (it looks like
> there's almost a complete replica of the generator protocol being
> created in parallel), but whatever happens, it's a good thing.

But it's so much cleaner than the existing generator stuff and can
pretty much replace it.  That is the kind of change that Python 3 really
should have been about.

> I strongly recommend jumping over to python-ideas and following along
> - that is, if you're interested enough to drink from the veritable
> fire-hose of -ideas! 

I might take a look at the list archive.  I don't think I could deal
with actually receiving the mailings and trying to keep up with them.

> There's a chance this will land in Python 3.5, but if not, I'd be very
> surprised if it doesn't hit 3.6.  

Neat :).  This paper about Lua coroutines is good and if it hasn't been
part of the PEP discussion and looks relevant, you might want to post it
there:

http://www.jucs.org/jucs_10_7/coroutines_in_lua/de_Moura_A_L.pdf
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP 492, new coroutine syntax for Python

2015-04-17 Thread Chris Angelico
On Sat, Apr 18, 2015 at 3:32 PM, Paul Rubin  wrote:
> Chris Angelico  writes:
>> Hah. It only just hit python-ideas, so you're jumping in on something
>> brand new - no wonder it hasn't been mentioned yet :)
>
> Interesting.  It's dated a couple weeks ago and has obviously been in
> the works for a while.  There's a working implementation which I'd think
> means it's outside the idea phase.

I'm not sure, but I suspect it's been developed/discussed in a SIG.
Today's the first day I've seen stuff about it.

>> I think the current proposal has a lot of duplication (it looks like
>> there's almost a complete replica of the generator protocol being
>> created in parallel), but whatever happens, it's a good thing.
>
> But it's so much cleaner than the existing generator stuff and can
> pretty much replace it.  That is the kind of change that Python 3 really
> should have been about.

Generators have other uses, but I think the intention is to subsume
all the generator-based coroutine system. You'd have to raise this on
-ideas, though.

>> There's a chance this will land in Python 3.5, but if not, I'd be very
>> surprised if it doesn't hit 3.6.
>
> Neat :).  This paper about Lua coroutines is good and if it hasn't been
> part of the PEP discussion and looks relevant, you might want to post it
> there:
>
> http://www.jucs.org/jucs_10_7/coroutines_in_lua/de_Moura_A_L.pdf

I hate to say TLDR, but it's the truth here. I'm posting from theatre
(we're performing The Merry Widow and I'm checking in between follow
spot cues... yeah, I'm insane), and don't have time this week to
evaluate a paper like that on a subject that I'm not an expert on.
Either someone else who subscribes to both python-list and
python-ideas will post it, or you'll have to join -ideas yourself,
sorry.

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


Re: New to Python - block grouping (spaces)

2015-04-17 Thread Marko Rauhamaa
Michael Torrie :

> There was a version of Python (compatible at a bytecode level) that did
> implement braces for blocks.  It was called pythonb, but it is now
> defunct, understandably for lack of interest.

http://www.perl.com/pub/2001/04/01/parrot.htm>

   LW: Sure. I'd probably write the program something like this:

   while(@line = Sys::Stdin->readline()):
   continue_next if $line[0] =eq= "#":
   print @line;
   }


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