Python launcher problem

2015-07-30 Thread ElChino

If I in a cmd-shell (actually it is 4NT), do:
  c:>py -3 -V & python3 -V

I get:
  Requested Python version (3) not installed  << ! from py -3 -V
  Python 3.5.0b2   << ! from the 2nd cmd.

What nonsense is this? I DO HAVE Python3 in my %PATH.
A Registry setting gone haywire?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python launcher problem

2015-07-30 Thread Thomas 'PointedEars' Lahn
ElChino wrote:

> If I in a cmd-shell (actually it is 4NT), do:
>c:>py -3 -V & python3 -V
> 
> I get:
>Requested Python version (3) not installed  << ! from py -3 -V
>Python 3.5.0b2   << ! from the 2nd cmd.
> 
> What nonsense is this? I DO HAVE Python3 in my %PATH.
> A Registry setting gone haywire?

RTFM.



-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: My code won't work if I double click the saved file

2015-07-30 Thread Mark Lawrence

On 30/07/2015 03:06, Cameron Simpson wrote:

On 29Jul2015 00:20, john  wrote:

I have windows 8 running on my computer and I think I downloaded
python 2 and 3 simultaneously or I think my computer has built in
python 2 and I downloaded python 3. And now when I ran my code in
IDLE, the code works fine but when I save my program and double click
the save file, it will run but it doesn't worked like it used to work
in IDLE.

Can someone explain the possible problem I'm currently facing?

I just want my program to run perfectly in both IDLE and when I double
click the saved file.

I posted my question in stackoverflow but I didn't find an answer.

http://stackoverflow.com/questions/31692156/i-think-my-computer-has-built-in-python-2-and-i-installed-python-3



This sounds like what is known as a "file association" issue. Your
computer's desktop is perhaps associating .py files with the python2
executable. I do not use Windows, but I believe you can adjust these
associations.



With the advent of the Python Launcher for Windows things have changed. 
Here's my setup.


C:\Users\Mark\Documents\MyPython>assoc .py
.py=Python.File

C:\Users\Mark\Documents\MyPython>ftype Python.File
Python.File="C:\Windows\py.exe" "%L" %*

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

Mark Lawrence

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


Re: Python launcher problem

2015-07-30 Thread Mark Lawrence

On 30/07/2015 08:03, ElChino wrote:

If I in a cmd-shell (actually it is 4NT), do:
   c:>py -3 -V & python3 -V

I get:
   Requested Python version (3) not installed  << ! from py -3 -V
   Python 3.5.0b2   << ! from the 2nd cmd.

What nonsense is this? I DO HAVE Python3 in my %PATH.
A Registry setting gone haywire?


I get:-

C:\Users\Mark\Documents\MyPython>py -3 -V & python3 -V
Python 3.5.0b4
'python3' is not recognized as an internal or external command,
operable program or batch file.

I've never had a Windows system with a 'python3' on it, so that is 
presumably something you've set up.  Hence it could be a screwed 
registry setting, but you're the only person in a position to find out :)


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

Mark Lawrence

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


Re: Python launcher problem

2015-07-30 Thread Terry Reedy

On 7/30/2015 3:03 AM, ElChino wrote:

If I in a cmd-shell (actually it is 4NT), do:
   c:>py -3 -V & python3 -V

I get:
   Requested Python version (3) not installed  << ! from py -3 -V
   Python 3.5.0b2   << ! from the 2nd cmd.

What nonsense is this? I DO HAVE Python3 in my %PATH.
A Registry setting gone haywire?


Start with something that works.
C:\Users\Terry>py -3
Python 3.5.0b2 (v3.5.0b2:7a088af5615b, May 31 2015, 06:22:19) [MSC 
v.1900 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

--
Terry Jan Reedy

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


ANN: eGenix pyOpenSSL Distribution 0.13.11

2015-07-30 Thread eGenix Team: M.-A. Lemburg

ANNOUNCING

   eGenix.com pyOpenSSL Distribution

Version 0.13.11

An easy-to-install and easy-to-use distribution
of the pyOpenSSL Python interface for OpenSSL -
   available for Windows, Mac OS X and Unix platforms


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-pyOpenSSL-Distribution-0.13.11.html


INTRODUCTION

The eGenix.com pyOpenSSL Distribution includes everything you need to
get started with SSL in Python.

It comes with an easy-to-use installer that includes the most recent
OpenSSL library versions in pre-compiled form, making your application
independent of OS provided OpenSSL libraries:

http://www.egenix.com/products/python/pyOpenSSL/

pyOpenSSL is an open-source Python add-on that allows writing SSL/TLS-
aware network applications as well as certificate management tools:

https://launchpad.net/pyopenssl/

OpenSSL is an open-source implementation of the SSL/TLS protocol:

http://www.openssl.org/


NEWS

This new release of the eGenix.com pyOpenSSL Distribution includes the
following updates:

New in OpenSSL
--

 * Updated included OpenSSL libraries from OpenSSL 1.0.1o to
   1.0.1p. See https://www.openssl.org/news/secadv_20150709.txt ​for a
   complete list of changes. The following fixes are relevant for
   pyOpenSSL applications:

   - CVE-2015-1793: An error in the implementation of the alternative
 certificate chain logic could allow an attacker to use a regular
 server leaf certificate as CA certificate.

Please see the product changelog for the full set of changes.

http://www.egenix.com/products/python/pyOpenSSL/changelog.html


pyOpenSSL / OpenSSL Binaries Included
-

In addition to providing sources, we make binaries available that
include both pyOpenSSL and the necessary OpenSSL libraries for all
supported platforms: Windows, Linux, Mac OS X and FreeBSD, for x86 and
x64.

To simplify installation, we have uploaded a web installer to PyPI
which will automatically choose the right binary for your platform, so
a simple

pip install egenix-pyopenssl

will get you the package with OpenSSL libraries installed. Please see
our installation instructions for details:

http://www.egenix.com/products/python/pyOpenSSL/#Installation

We have also added .egg-file distribution versions of our eGenix.com
pyOpenSSL Distribution for Windows, Linux and Mac OS X to the
available download options. These make setups using e.g. zc.buildout
and other egg-file based installers a lot easier.


DOWNLOADS

The download archives and instructions for installing the package can
be found at:

http://www.egenix.com/products/python/pyOpenSSL/


UPGRADING

Before installing this version of pyOpenSSL, please make sure that
you uninstall any previously installed pyOpenSSL version. Otherwise,
you could end up not using the included OpenSSL libs.

___
SUPPORT

Commercial support for these packages is available from eGenix.com.
Please see

http://www.egenix.com/services/support/

for details about our support offerings.


MORE INFORMATION

For more information about the eGenix pyOpenSSL Distribution, licensing
and download instructions, please visit our web-site or write to
sa...@egenix.com.

About eGenix (http://www.egenix.com/):

eGenix is a software project, consulting and product company
focusing on expert project services and professional quality
products for companies, Python users and developers.

Enjoy,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jul 30 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 Python developers with S&OP Simulation experience

2015-07-30 Thread regoricardo
Hi all,

We're starting a new Python project where any extra help will be warmly 
welcomed.

Please, contact us at: ricardo att r2software dott com dott br

Cheers,

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


Logical Query in Python

2015-07-30 Thread subhabrata . banerji
Dear Group,

I am trying to query JSON with Logical operators. 

I tried to experiment lot with it, but could not do much. 
I came many times pretty close but missed it almost. 

I tried to experiment with json, jsonquery, jsonschema, jsonpipe, objectpath, 
requests. 

I got a good example from 
http://www-01.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/com.ibm.db2z11.doc.json/src/tpc/db2z_jsonlogicaloperators.dita

But I was looking for one or two worked out examples to start with. 

I am using Python2.7+ on Windows 7 with IDLE as GUI. 

I am trying and if anybody of the esteemed members may kindly help me with.

 

Regards,
Subhabrata Banerjee. 


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


Logical Query JSON

2015-07-30 Thread subhabrata . banerji
Dear Group, 

I am trying to query JSON with Logical operators. 

I tried to experiment lot with it, but could not do much. 
I came many times pretty close but missed it almost. 

I tried to experiment with json, jsonquery, jsonschema, jsonpipe, objectpath, 
requests. 

I got a good example from 
http://www-01.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/com.ibm.db2z11.doc.json/src/tpc/db2z_jsonlogicaloperators.dita
 

But I was looking for one or two worked out examples to start with. 

I am using Python2.7+ on Windows 7 with IDLE as GUI. 

I am trying and if anybody of the esteemed members may kindly help me with. 

  

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


Re: Python launcher problem

2015-07-30 Thread Zachary Ware
On Jul 30, 2015 2:05 AM, "ElChino"  wrote:
>
> If I in a cmd-shell (actually it is 4NT), do:
>   c:>py -3 -V & python3 -V
>
> I get:
>   Requested Python version (3) not installed  << ! from py -3 -V
>   Python 3.5.0b2   << ! from the 2nd cmd.
>
> What nonsense is this? I DO HAVE Python3 in my %PATH.
> A Registry setting gone haywire?

Did you perchance rename the installed 'python.exe' to 'python3.exe'? That
would be enough to break the launcher.  If you want a 'python3' command,
you can copy 'python.exe' to 'python3.exe', but 'python.exe' needs to
remain where it was.

--
Zach
(On a phone)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to Calculate NPV?

2015-07-30 Thread Dave Farrance
ryguy7272  wrote:

>PERFECT!!  SO SIMPLE!!
>I don't know why the author didn't do that in the book.

The book is evidently giving you code snippets to enter into Python's
own interactive interpreter, i.e., you enter "python" at the command
line, then you manually type each command which immediately displays any
returned value.  I assume that the book shows each command with three
chevrons ">>>" in front of them.  If you're using Spyder then you need
to enter the commands into its interactive interpreter (which I think is
bottom right). It sounds, instead, as though you're using Spyder's text
editor to create a file containing the commands, and then using the
"run" icon to run the file -- which is maybe skipping ahead because the
book hasn't told you how to do that yet (?). If you do skip ahead, the
book probably has a forthcoming chapter called "writing programs with a
text editor" or something.  I'd guess from the code snippets that you've
shown us that the book is finance oriented, and the author seems to be
more interested in introducing the features useful for finance than
teaching the basics of Python.  Maybe you should search out a simple
Python primer on the web, work through that, and only then return to
your book.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logical Query in Python

2015-07-30 Thread Steven D'Aprano
On Thu, 30 Jul 2015 11:28 pm, subhabrata.bane...@gmail.com wrote:

> Dear Group,
> 
> I am trying to query JSON with Logical operators.

What does that mean?

> I tried to experiment lot with it, but could not do much.
> I came many times pretty close but missed it almost.

Please:

- show an example of what you tried;

- give the results you expected;

- show the results you actually got.

COPY and PASTE the code and results, do not re-type them, or summarise them.




-- 
Steven

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


[Ann] Package Repository Project

2015-07-30 Thread casa
Hi all,

I have started a package repository project at 
http://github.com/c4s4/cheeseshop. This is useful if you want to share Python 
packages that you can't make public on pypi.python.org. It is aimed to be easy 
to install and efficient.

Any comment welcome

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


EuroPython 2015: Thank you to all volunteers

2015-07-30 Thread M.-A. Lemburg
EuroPython is now over and was a great success thanks to everyone who
helped make it happen.

Unfortunately, we did not properly acknowledge all the volunteers who
were working on the event during the closing session and we would like
to apologize for this, so here’s the full list of all volunteers from
the EuroPython 2015 Workgroups and the on-site volunteers:

 *** https://ep2015.europython.eu/en/volunteers/ ***

On-site Team WG
---

 * Oier Echaniz Beneitez (Chair)
 * Borja Ayerdi Vilches
 * Alexandre Savio
 * Darya Chyzhyk
 * José David Nuñez
 * Luis Javier Salvatierra
 * Ion Marqués

Conference Administration WG


 * Marc-Andre Lemburg (Chair)
 * Vicky Lee
 * Rezuk Turgut
 * Stavros Anastasiadis
 * Stéphane Wirtel
 * Borja Ayerdi Vilches
 * Oier Beneitez

Finance WG
--

 * Borja Ayerdi Vilches (Chair)
 * Fabio Pliger
 * Marc-Andre Lemburg
 * Vicky Lee
 * Rezuk Turgut
 * Jacob Hallén (EPS Treasurer)
 * Darya Chyzhyk

Sponsors WG
---

 * Fabio Pilger (Chair)
 * Alexandre Savio
 * Borja Ayerdi Vilches
 * Marc-Andre Lemburg
 * Vicky Twomey-Lee
 * Hansel Dunlop
 * Raúl Cumplido
 * José David Muñez
 * Oier Echaniz Beneitez
 * Miren Urteaga Aldalur

Communications WG
--

 * Marc-Andre Lemburg (Chair)
 * Oier Beneitez
 * Kerstin Kollmann
 * Fabio Pliger
 * Vicky Lee
 * Dougal Matthews
 * Chris Ward
 * Kristian Rother
 * Stéphane Wirtel
 * Miren Aldalur

Support WG
--

 * Raúl Cumplido
 * Anthon van der Neut
 * Alexandre Savio
 * Ion Marqués
 * Christian Barra
 * Eyad Toma
 * Stavros Anastasiadis

Financial Aid WG


 * Darya Chyzhyk
 * Vicky Twomey-Lee
 * Ion Marqués
 * Stéphane Wirtel

Marketing/Design WG
---

 * Darya Chyzhyk
 * Marc-Andre Lemburg
 * Borja Ayerdi Vilches
 * Alexandre Savio
 * Miren Aldalur
 * Stéphane Wirtel
 * Zachari Saltmer

Program WG
--

 * Alexandre Savio  (Chair)
 * Alexander Hendorf  (Co-chair)
 * Vicky Twomey-Lee
 * Kristian Rother
 * Dougal Matthews
 * Sarah Mount
 * Raúl Cumplido
 * Adam Byrtek
 * Christian Barra
 * Moshe Goldstein
 * Scott Reeve
 * Chris Ward
 * Claudiu Popa
 * Stavros Anastasiadis
 * Harry Percival
 * Daniel Pyrathon

Web WG
--

 * Christian Barra (Chair)
 * Oier Beneitez
 * Marc-Andre Lemburg
 * Adam Byrtek
 * Dougal Matthews
 * Raúl Cumplido
 * Fabio Pliger
 * Eyad Toma
 * Stéphane Wirtel

Media WG


 * Anthon van der Neut
 * José David Muñez
 * Luis Javier Salvatierra
 * Francisco Fernández Castaño
 * Fabio Pliger

On-Site Volunteers
--

In addition to several of the EuroPython Workgroup members, in
particular, the on-site team WG, the following attendees helped as
session manager, room manager, on the registration desk, bag stuffing
and during set up and tear down of the conference.

In alphabetical order:

 * Abraham Martin
 * Agustín Herranz
 * Aisha Bello
 * Alberto Rasillo
 * Ana Balica
 * Andrew McCarthy
 * Anna Bednarska
 * Anna Téglássy
 * Austur
 * Brianna Laugher
 * Cesar Desales
 * Christian Barra
 * Christin Schärfer
 * Corinne Welsh
 * Dorottya Czapari
 * Dougal Matthews
 * Éléonore Mayola
 * Eugene Tataurov
 * Felipe Ximenez
 * Floris Bruynooghe
 * Gautier Hayoun
 * Gregorio Vivo
 * Harry Percival
 * Inigo Aldazabal
 * Iñigo Ugarte Pérez
 * Ion Marques
 * Iraia Etxeberria
 * Iris Yuping Ren
 * Izarra Domingo
 * José David Nuñez
 * Julian Coyne
 * Julian Estevez
 * Jyrki Pulliainen
 * Kasia Kaminska
 * Kerstin Kollmann
 * Leire Ozaeta
 * Luis Javier Salavatierra
 * Matt McGraw
 * Maura Pilia
 * Mikey Ariel
 * Mircea Zetea
 * Miren Urteaga
 * Miroslav Sedivy
 * Pablo
 * Patrick Arminio
 * Paul Cochrane
 * Peter Deba
 * Petr Viktorin
 * Pierre Reinbold
 * Piotr Dyba
 * Raul Cumplido
 * Stefano Fontana
 * Stefano Mazzucco
 * Sven Wontroba
 * Szilvia Kadar
 * Tomasz Nowak
 * Victor Munoz

Some attendees also helped without being registered as volunteer,
e.g. during tear down at the conference venue. We’d like to thank you
and acknowledge you as well. If you have helped and are not on the
above list, please write to i...@europython.eu.

For next year, we will seek to use a better system for volunteer
management and also invest more time into improving the conference
opening and closing sessions.

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


Re: Logical Query JSON

2015-07-30 Thread Denis McMahon
On Thu, 30 Jul 2015 06:32:01 -0700, subhabrata.banerji wrote:

> I am trying to query JSON with Logical operators.

Your post was an excellent example of asking for help without explaining 
what your problem was at all.

Please:

- show an example of what you tried;

- give the results you expected;

- show the results you actually got.

COPY and PASTE the code and results, do not re-type them, or summarise
them.

I found the examples quite easy to follow to create json queries, 
although as I don't have a db2 etc setup here iI'm unale to try feeding 
the resulting json query into a database to see what comes out.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


using sched

2015-07-30 Thread Nkansah Rexford
Using sched, how can I run a function, at for instance, exactly 00:00 GMT, and 
only that time.

If sched wouldn't be the best to do so a job, please can you recommend 
something?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logical Query JSON

2015-07-30 Thread subhabrata . banerji
On Thursday, July 30, 2015 at 9:20:35 PM UTC+5:30, Denis McMahon wrote:
> On Thu, 30 Jul 2015 06:32:01 -0700, subhabrata.banerji wrote:
> 
> > I am trying to query JSON with Logical operators.
> 
> Your post was an excellent example of asking for help without explaining 
> what your problem was at all.
> 
> Please:
> 
> - show an example of what you tried;
> 
> - give the results you expected;
> 
> - show the results you actually got.
> 
> COPY and PASTE the code and results, do not re-type them, or summarise
> them.
> 
> I found the examples quite easy to follow to create json queries, 
> although as I don't have a db2 etc setup here iI'm unale to try feeding 
> the resulting json query into a database to see what comes out.
> 
> -- 
> Denis McMahon

Dear Sir,

I am trying to quote some of my exercises below, and my objective.

(1) Exercise with objectpath: 
>>> from objectpath import *
>>> tree=Tree({"a":1})
>>> tree.execute("$.a")
1
>>> $
{
  "a":1,
  "b":{
"c":[1,2,3]
  }
}
SyntaxError: invalid syntax
>>> x1={"a":1,"b":{"c":[1,2,3]}}
>>> x1.b

Traceback (most recent call last):
  File "", line 1, in 
x1.b
AttributeError: 'dict' object has no attribute 'b'
>>> x1."b"
SyntaxError: invalid syntax

(2) Exercise from IBM Example:

>>> x1={"or":[{"age":4},{"name":"Joe"}]}
>>> x2=x1
>>> print x2
{'or': [{'age': 4}, {'name': 'Joe'}]}
>>> x1['age']

Traceback (most recent call last):
  File "", line 1, in 
x1['age']
KeyError: 'age'
>>> x1['or']
[{'age': 4}, {'name': 'Joe'}]
>>> x1['or']['age']

Traceback (most recent call last):
  File "", line 1, in 
x1['or']['age']
TypeError: list indices must be integers, not str
>>> x1['or'][0]
{'age': 4}
>>> x1['or'][1]
{'name': 'Joe'}


My expectation is:

If I do AND, NOT, OR with two or more JSON values like
{"age":4}, {"name":"Joe"}, ...etc. then I should get recirprocal
results.
Considering each one as Python variable and applying logical Python
operation helps, but I am looking a smarter solution. 

Apology for indentation error. 

Regards,
Subhabrata Banerjee. 





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


Re: Logical Query in Python

2015-07-30 Thread subhabrata . banerji
On Thursday, July 30, 2015 at 8:35:08 PM UTC+5:30, Steven D'Aprano wrote:
> On Thu, 30 Jul 2015 11:28 pm,  wrote:
> 
> > Dear Group,
> > 
> > I am trying to query JSON with Logical operators.
> 
> What does that mean?
> 
> > I tried to experiment lot with it, but could not do much.
> > I came many times pretty close but missed it almost.
> 
> Please:
> 
> - show an example of what you tried;
> 
> - give the results you expected;
> 
> - show the results you actually got.
> 
> COPY and PASTE the code and results, do not re-type them, or summarise them.
> 
> 
> 
> 
> -- 
> Steven

Dear Sir,

I redrafted it and reposted the question. This post I tried to drop but some 
how came. Please ignore this post. My reposting is with JSON. 

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


How to re-write this bash script in Python?

2015-07-30 Thread sutanu . das
#!/bin/bash

_maillist='pa...@email.com'
_hname=`hostname`
_logdir=/hadoop/logs
_dirlog=${_logdir}/directory_check.log

_year=$(date -d "-5 hour" +%Y)
_month=$(date -d "-5 hour" +%m)
_day=$(date -d "-5 hour" +%d)
_hour=$(date -d "-5 hour" +%H)

_hdfsdir=`hdfs dfs -ls -d /hadoop/flume_ingest_*/$_year/$_month | awk '{print 
$8}'`

echo "Checking for HDFS directories:" > ${_dirlog}
echo >> ${_dirlog}

for _currdir in $_hdfsdir
do
hdfs dfs -ls -d $_currdir/$_day/$_hour &>> ${_dirlog}
done

if [[ `grep -i "No such file or directory" ${_dirlog}` ]];
then
echo "Verify Flume is working for all  servers" | mailx -s "HDFS Hadoop Failure 
on Flume: ${_hname}" -a ${_dirlog} ${_maillist}
fi
-- 
https://mail.python.org/mailman/listinfo/python-list


Improper Django Project error

2015-07-30 Thread Gary Roach

Hi all

Being new to Django and Python, I have two projects setup side by side, 
each in it's own virtualenv wrapper.
The twr_project is running Django 1.7, python 2.7 and is set up to 
duplicate the 'Tango With Rango' tutorial.
The archivedb project is running Django 1.8, python 2.7 and is my actual 
project.


I am using Ninja-IDE as my IDE. I like it a lot.

At this point both projects are essentially identical with the exception 
of name changes. The twr project work down to the first template 
inclusion ( index.html ). The archivedb project refuses to find the 
home.html template file. The system layout is exactly the same.


I wiped the home.html file and attempted to re-install it but my IDE 
gave the following error window:


Sorry, either settings file or virtualenv are missingthese are 
required for Django Plugin to work in thepresent version, we are 
working on fixing this.


I have virtualenv installed and active and the settings file is present. 
In any case, the IDE won't let me save the home.html file without some 
fiddling. Even if I get the file saved the web server can't find it. 
(file not found error). The only difference between index.html (Django 
1.7) and home.html (Django 1.8) is the name changes.


I have inserted print statements in the url tree to try debugging this 
but all the path information returned seems reasonable.



Is this a bug in Ninja-IDE, Django 1.8 or is it something else.


If you need more information, please let me know


Gary R.

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


Re: How to re-write this bash script in Python?

2015-07-30 Thread Mark Lawrence

On 30/07/2015 19:31, sutanu@gmail.com wrote:

#!/bin/bash

_maillist='pa...@email.com'
_hname=`hostname`
_logdir=/hadoop/logs
_dirlog=${_logdir}/directory_check.log

_year=$(date -d "-5 hour" +%Y)
_month=$(date -d "-5 hour" +%m)
_day=$(date -d "-5 hour" +%d)
_hour=$(date -d "-5 hour" +%H)

_hdfsdir=`hdfs dfs -ls -d /hadoop/flume_ingest_*/$_year/$_month | awk '{print 
$8}'`

echo "Checking for HDFS directories:" > ${_dirlog}
echo >> ${_dirlog}

for _currdir in $_hdfsdir
do
hdfs dfs -ls -d $_currdir/$_day/$_hour &>> ${_dirlog}
done

if [[ `grep -i "No such file or directory" ${_dirlog}` ]];
then
echo "Verify Flume is working for all  servers" | mailx -s "HDFS Hadoop Failure on 
Flume: ${_hname}" -a ${_dirlog} ${_maillist}
fi



Read the documentation here https://docs.python.org/3/ and then run up 
your favourite editor and start typing.  When and if you hit problems 
come back with a snippet of code that shows the problem, what you 
expected to happen, what actually happened, and the full traceback if 
there is one.  Please use cut and paste to ensure that you get the data 
correct.


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

Mark Lawrence

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


Re: using sched

2015-07-30 Thread Irmen de Jong
On 30-7-2015 17:57, Nkansah Rexford wrote:
> Using sched, how can I run a function, at for instance, exactly 00:00 GMT, 
> and only that time.
> 
> If sched wouldn't be the best to do so a job, please can you recommend 
> something?
> 

The sched module is by itself not really a task scheduler. It can be used to 
build one
though, for example https://pypi.python.org/pypi/TGScheduler

My recommendation would be however to utilize your operating system's native 
task
scheduler (cron, or when you're on windows, the windows task scheduler).


Irmen

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


New module (written in C) for using the high-precision QD library

2015-07-30 Thread baruchel
Hi,

I wrote a module for wrapping the well-known high-precision QD library written 
by D.H. Bailey.
You can find it here: https://github.com/baruchel/qd

It is written in pure C with the CPython C-API in order to get the highest 
possible speed.

The QD library provides floating number types for ~32 and ~64 decimals digits 
of precision and should be quicker for such precisions than other 
arbitrary-precision libraries.

My ultimate goal is to implement these two types as new dtype for Numpy arrays, 
but I release here a first version which already gives a complete interface to 
the QD library.

Regards,

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


Re: How to re-write this bash script in Python?

2015-07-30 Thread random832
On Thu, Jul 30, 2015, at 14:31, sutanu@gmail.com wrote:
> _year=$(date -d "-5 hour" +%Y)
> _month=$(date -d "-5 hour" +%m)
> _day=$(date -d "-5 hour" +%d)
> _hour=$(date -d "-5 hour" +%H)

What is the purpose of the -5 hour offset? Is it an attempt to
compensate for timezones?
-- 
https://mail.python.org/mailman/listinfo/python-list


How to rearrange array using Python?

2015-07-30 Thread Martin Schöön
Here is a problem I think I should be able to solve using Python but
after having searched the internet for the better part of this
evening my head spins and I would apreciate some guidance.

Disclaimer

My formal programming training happened 35+ years ago and
initially involved F77 and later Pascal. Python is something
I have picked up lately and for fun. I don't master Python by any
stretch of imagination. I know some linear algebra and numerical
methods but don't practice any of this on a daily basis...

Problem background

I am just back from visiting my sisters and the younger of them
was busy planning a youth orchestra summer camp. For some reason
the kids are allowed to wish with whom they want to share rooms
and my sister spent several evenings placing kids in rooms
according to these wishes. It struck me that at least some of this
work could be done by silicon running code.

My thinking so far

I have played around a little with something called DSM
https://en.wikipedia.org/wiki/Design_structure_matrix
at work and think entering all wishes into a 2D array
for further processing and overview should be a good idea.

An added piece of information is the number of and sizes
of rooms. I want to overlay this on the array and re-shuffle
until as many of the wishes as possible are fulfilled.

Here is a picture that may help understanding what I am after:
https://picasaweb.google.com/103341501341482571816/Miscellaneous#6177389865951753330
In this example I have 25 individuals (each allowed two wishes),
one 5-bed room, two 4-bed rooms and four 3-bed rooms. 
Wishes are marked by "1" so a wants to sleep in the same room
as i and n etc. The rooms are shown as light grey squares
along the diagonal. Scores to the right show how many wishes
are fulfilled in each room and at the bottom right corner I 
have the total score. The goal is to re-shuffle the array
to maximize this score. 

How do I go about doing that?

Note: This example is worse than the real life problem as
most kids go to this camp with friends and wishes are
highly coordinated. I used a random number generator to
create wishes... The real problem involves some 80 kids.
There are some more differences but let us leave them out
for now.

TIA

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


Re: [Tutor] Mailbox

2015-07-30 Thread Cameron Simpson

On 30Jul2015 19:00, ltc.hots...@gmail.com  wrote:

New revision code:

count = 0
fn = raw_input("Enter file name: ")
if len(fn) < 1 : fname = "mbox-short.txt"
for line in fn:
 if 'From' in line.split()[0]: count += 1
print "There are %d lines starting with From" % count
print len(line)
fn = open(fname)
print "There were", count, "lines in the file with From as the first word"


Syntax message produced by iPython interperter:

NameError Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\assinment_8_5_v_2.py in ()
 6 print "There are %d lines starting with From" % count
 7 print len(line)
> 8 fn = open(fname)
 9 print "There were", count, "lines in the file with From as the first wor
d"

NameError: name 'fname' is not defined


I have reposted this to the python-list. Please always reply to the list.

The message above is not a syntax error. It is a NameError, which happens at 
runtime.


It is complaining that the name "fname" is not defined.

This is because you have the names "fn" and "fname" confused in your code.  
Based on your code, "fname" is supposed to be the filename (a string) and "fn" 
is meant to be the open file object (a file), since you have this line:


 fn = open(fname)

However, you set "fn" from raw_input when you should set "fname". You also have 
the open() call _after_ your loop, but the loop needs to read from the open 
file, so these things are out of order.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Mailbox

2015-07-30 Thread ltc.hotspot
Hi Cameron,

New revision code:


count = 0
fn = raw_input("Enter file name: ")
if len(fn) < 1 : fname = "mbox-short.txt"
for line in fn:
  if 'From' in line.split()[0]: count += 1
print "There are %d lines starting with From" % count
print len(line)
fn = open(fname)
print "There were", count, "lines in the file with From as the first word"




Syntax message produced by iPython interperter:


NameError Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\assinment_8_5_v_2.py in ()
  6 print "There are %d lines starting with From" % count
  7 print len(line)
> 8 fn = open(fname)
  9 print "There were", count, "lines in the file with From as the first wor
d"


NameError: name 'fname' is not defined


In [16]:



Question:


Why is fname = "mbox-short.txt" not loading the sample data?


Sample data file is located at  http://www.pythonlearn.com/code/mbox-short.txt


Regards,
Hal






Sent from Surface





From: Cameron Simpson
Sent: ‎Wednesday‎, ‎July‎ ‎29‎, ‎2015 ‎7‎:‎01‎ ‎PM
To: tu...@python.org





On 29Jul2015 21:55, ltc.hots...@gmail.com  wrote:
>I have a second and unrelated question:
>
>I tried to work backward  to see if there is a logic error associated with a 
>variable is being skipped over:
>
>#top of code, initialize variable
>output_list = ["default"]

Curious: why not just make this an empty list: []

[...snip...]
>count = 0
>fname = raw_input("Enter file name: ")
>if len(fname) < 1 : fname = "mbox-short.txt"
>for line in fname:
>line = line.strip()
>if not line.startswith('From '): continue
>line = line.split()
>count = count + 1
>print len(line)
>fh = open(fname)
>print "There were", count, "lines in the file with From as the first word"
[...snip...]

My first observation would be that "count = count + 1" is not inside the loop.  
That means that it fires just once, _after_ the loop. So it will always be 1.

Also, what is the purpose of this line:

  line = line.split()

Cheers,
Cameron Simpson 
___
Tutor maillist  -  tu...@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to rearrange array using Python?

2015-07-30 Thread Mark Lawrence

On 30/07/2015 21:31, Martin Schöön wrote:

Here is a problem I think I should be able to solve using Python but
after having searched the internet for the better part of this
evening my head spins and I would apreciate some guidance.

Disclaimer

My formal programming training happened 35+ years ago and
initially involved F77 and later Pascal. Python is something
I have picked up lately and for fun. I don't master Python by any
stretch of imagination. I know some linear algebra and numerical
methods but don't practice any of this on a daily basis...

Problem background

I am just back from visiting my sisters and the younger of them
was busy planning a youth orchestra summer camp. For some reason
the kids are allowed to wish with whom they want to share rooms
and my sister spent several evenings placing kids in rooms
according to these wishes. It struck me that at least some of this
work could be done by silicon running code.

My thinking so far

I have played around a little with something called DSM
https://en.wikipedia.org/wiki/Design_structure_matrix
at work and think entering all wishes into a 2D array
for further processing and overview should be a good idea.

An added piece of information is the number of and sizes
of rooms. I want to overlay this on the array and re-shuffle
until as many of the wishes as possible are fulfilled.

Here is a picture that may help understanding what I am after:
https://picasaweb.google.com/103341501341482571816/Miscellaneous#6177389865951753330
In this example I have 25 individuals (each allowed two wishes),
one 5-bed room, two 4-bed rooms and four 3-bed rooms.
Wishes are marked by "1" so a wants to sleep in the same room
as i and n etc. The rooms are shown as light grey squares
along the diagonal. Scores to the right show how many wishes
are fulfilled in each room and at the bottom right corner I
have the total score. The goal is to re-shuffle the array
to maximize this score.

How do I go about doing that?

Note: This example is worse than the real life problem as
most kids go to this camp with friends and wishes are
highly coordinated. I used a random number generator to
create wishes... The real problem involves some 80 kids.
There are some more differences but let us leave them out
for now.

TIA

/Martin



I'm not absolutely certain but I think you're into what's known as a 
constraint satisfaction problem, in which case this 
https://pypi.python.org/pypi/python-constraint/1.2 is as good a starting 
point as any.  If I'm wrong we'll soon get told :)


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

Mark Lawrence

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


Re: How to rearrange array using Python?

2015-07-30 Thread ltc.hotspot
Hi Mark,



I’m still confused because line 4 reads: fh=open(fname,'r') # Open a new file 
handle, not fn = open(fname)


Can you write down line by line from error to correction? 



Hal






Sent from Surface





From: Mark Lawrence
Sent: ‎Thursday‎, ‎July‎ ‎30‎, ‎2015 ‎3‎:‎21‎ ‎PM
To: python-list@python.org





On 30/07/2015 21:31, Martin Schöön wrote:
> Here is a problem I think I should be able to solve using Python but
> after having searched the internet for the better part of this
> evening my head spins and I would apreciate some guidance.
>
> Disclaimer
>
> My formal programming training happened 35+ years ago and
> initially involved F77 and later Pascal. Python is something
> I have picked up lately and for fun. I don't master Python by any
> stretch of imagination. I know some linear algebra and numerical
> methods but don't practice any of this on a daily basis...
>
> Problem background
>
> I am just back from visiting my sisters and the younger of them
> was busy planning a youth orchestra summer camp. For some reason
> the kids are allowed to wish with whom they want to share rooms
> and my sister spent several evenings placing kids in rooms
> according to these wishes. It struck me that at least some of this
> work could be done by silicon running code.
>
> My thinking so far
>
> I have played around a little with something called DSM
> https://en.wikipedia.org/wiki/Design_structure_matrix
> at work and think entering all wishes into a 2D array
> for further processing and overview should be a good idea.
>
> An added piece of information is the number of and sizes
> of rooms. I want to overlay this on the array and re-shuffle
> until as many of the wishes as possible are fulfilled.
>
> Here is a picture that may help understanding what I am after:
> https://picasaweb.google.com/103341501341482571816/Miscellaneous#6177389865951753330
> In this example I have 25 individuals (each allowed two wishes),
> one 5-bed room, two 4-bed rooms and four 3-bed rooms.
> Wishes are marked by "1" so a wants to sleep in the same room
> as i and n etc. The rooms are shown as light grey squares
> along the diagonal. Scores to the right show how many wishes
> are fulfilled in each room and at the bottom right corner I
> have the total score. The goal is to re-shuffle the array
> to maximize this score.
>
> How do I go about doing that?
>
> Note: This example is worse than the real life problem as
> most kids go to this camp with friends and wishes are
> highly coordinated. I used a random number generator to
> create wishes... The real problem involves some 80 kids.
> There are some more differences but let us leave them out
> for now.
>
> TIA
>
> /Martin
>

I'm not absolutely certain but I think you're into what's known as a 
constraint satisfaction problem, in which case this 
https://pypi.python.org/pypi/python-constraint/1.2 is as good a starting 
point as any.  If I'm wrong we'll soon get told :)

-- 
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-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to rearrange array using Python?

2015-07-30 Thread Mark Lawrence

On 30/07/2015 23:31, ltc.hots...@gmail.com wrote:

Hi Mark,

I’m still confused because line 4 reads: fh=open(fname,'r') # Open a new
file handle, not fn = open(fname)

Can you write down line by line from error to correction?



I'd think about it if you could find the correct thread :)

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


'open' is not defined

2015-07-30 Thread ltc.hotspot





Hi Everyone:




Why is open not defined in the following code:NameError: name 'open' is not 
defined




Code reads as follows:







fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
fh = open(fname)
count = 0
for line in fh:
if not line.startswith('From'): continue
line2 = line.strip()
line3 = line2.split()
line4 = line3[1]
print line4
count = count + 1
print "There were", count, "lines in the file with From as the first word"







Regards,

Hal






Sent from Surface-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to rearrange array using Python?

2015-07-30 Thread Robin Koch

Am 30.07.2015 um 22:31 schrieb Martin Schöön:


Scores to the right show how many wishes are fulfilled in each room


Is it possible the is a mistake in the sum column on the third row?
Should the be a 1?


The goal is to re-shuffle the array to maximize this score.

How do I go about doing that?


Depending on how you store those wishes I'd think you can use
random.shuffle()!?

But do you think simply maximising the score is the optimal solution to 
the problem?
That way some kids will get their both wishes fulfilled (s, e and p in 
your example), while other kids not even one (r, z, j, v, c, y, g, m, d).
Shouldn't be the goal to maximise the number of kinds which get at least 
one wished kid in the same room? (I hesitate writing "friend", since you 
maybe wouldn't want to be picked by someone... Friend would be pairs of 
kids picking each other. Another thing one might want to takeinto 
account. :-))


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


Re: using sched

2015-07-30 Thread Nkansah Rexford
Great. Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to rearrange array using Python?

2015-07-30 Thread Thomas 'PointedEars' Lahn
Mark Lawrence wrote:

> On 30/07/2015 21:31, Martin Schöön wrote:
>> I am just back from visiting my sisters and the younger of them
>> was busy planning a youth orchestra summer camp. For some reason
>> the kids are allowed to wish with whom they want to share rooms
>> and my sister spent several evenings placing kids in rooms
>> according to these wishes. It struck me that at least some of this
>> work could be done by silicon running code.
>> […]
>> An added piece of information is the number of and sizes
>> of rooms. I want to overlay this on the array and re-shuffle
>> until as many of the wishes as possible are fulfilled.
>> […]
>> How do I go about doing that?
>>
>> Note: This example is worse than the real life problem as
>> most kids go to this camp with friends and wishes are
>> highly coordinated. I used a random number generator to
>> create wishes... The real problem involves some 80 kids.
>> There are some more differences but let us leave them out
>> for now.
> 
> I'm not absolutely certain but I think you're into what's known as a
> constraint satisfaction problem, in which case this
> https://pypi.python.org/pypi/python-constraint/1.2 is as good a starting
> point as any.  If I'm wrong we'll soon get told :)

It is a CSP indeed, and as I was reading the OP I was thinking of SWI-
Prolog, not Python, for the solution.  Using a PRNG and simple reshuffling 
cannot be the correct approach because you cannot be sure that you do not 
get the same number twice, the same solution twice, and that you can solve 
the problem in finite time.  The correct approach, *a* correct approach at 
least, is as you would do without computers: keeping track of the solutions, 
backtracking, and discarding the solutions that were worse than the so-far-
best one.

However, fascinating to learn that Python has something to offer for CSPs, 
too.

Please trim your quotes to the relevant minimum.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logical Query JSON

2015-07-30 Thread dieter
subhabrata.bane...@gmail.com writes:
> ...
> I am trying to quote some of my exercises below, and my objective.

A general remark. Python errror messages are quite good (unlike e.g.
many Microsoft or Oracle error messages). You can almost always trust
them.

Thus, if you get a "SyntaxError", something with your Python syntax
is wrong (Python is *very* sensitive to leading spaces, take case
to get the correct indentation).

An "AttributeError" means that you used the attribute access syntax
("obj.attr") for something which was not an attribute.

Etc...

> (1) Exercise with objectpath: 
 from objectpath import *
 tree=Tree({"a":1})
 tree.execute("$.a")
> 1
 $
> {
>   "a":1,
>   "b":{
> "c":[1,2,3]
>   }
> }
> SyntaxError: invalid syntax

This looks a bit strange: "$" is not a Python name - thus,
it could give a "SyntaxError" - but then, you should not see the
dict like representation between the "$" and the "SyntaxError".
Anyway, the dict like representation looks out of place - where does
it come from?

 x1={"a":1,"b":{"c":[1,2,3]}}
 x1.b
>
> Traceback (most recent call last):
>   File "", line 1, in 
> x1.b
> AttributeError: 'dict' object has no attribute 'b'

"x1" is a dict and access to its keys is via subscription syntax
("mapping[key]"), not the attribute access syntax ("obj.attr").

 x1."b"
> SyntaxError: invalid syntax

The "attr" in the attribute access syntax "obj.attr" must be
a Python name, not an expression (such as the string '"b"').

The correct access to "b" would be 'x["b"]'.


> (2) Exercise from IBM Example:
>
 x1={"or":[{"age":4},{"name":"Joe"}]}
 x2=x1
 print x2
> {'or': [{'age': 4}, {'name': 'Joe'}]}
 x1['age']
>
> Traceback (most recent call last):
>   File "", line 1, in 
> x1['age']
> KeyError: 'age'

"x1" is a dict with a single key "or". The value for "or"
is a list with two dicts. The get the dict for "age",
you would use 'x1["or"][0]'; to get the age value
'x1["or"][0]["age"]'.

 x1['or']
> [{'age': 4}, {'name': 'Joe'}]
 x1['or']['age']
>
> Traceback (most recent call last):
>   File "", line 1, in 
> x1['or']['age']
> TypeError: list indices must be integers, not str

'x1["or"]' is a list, not a dict.
 x1['or'][0]
> {'age': 4}
 x1['or'][1]
> {'name': 'Joe'}

You are making progress

>
> My expectation is:
>
> If I do AND, NOT, OR with two or more JSON values like
> {"age":4}, {"name":"Joe"}, ...etc. then I should get recirprocal
> results.
> Considering each one as Python variable and applying logical Python
> operation helps, but I am looking a smarter solution. 

You might need to read through the Python tutorial - in order
to get a thorough understanding of

 *  attribute versus subscription access,
 *  Python's simple data types (such as "dict"s, "list"s, etc.)
and how they are represented when printed
 *  what the various error messages (such as "SyntaxError",
"AttributeError", "KeyError", "TypeError", ...) mean.

Keep in mind that Python is a (more or less) "general purpose" language
which does not know about "jsonquery". It has "and", "or" and "not"
operators (defined in the language reference) *BUT* these are not
the operators you are looking for.
You will need a special "jsonquery" extension (search
"http://pypi.python.org"; to find out whether there is something like this)
which would provide appropriate support.

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


Re: Improper Django Project error

2015-07-30 Thread dieter
Gary Roach  writes:
> Being new to Django and Python, I have two projects setup side by
> side, each in it's own virtualenv wrapper.
> The twr_project is running Django 1.7, python 2.7 and is set up to
> duplicate the 'Tango With Rango' tutorial.
> The archivedb project is running Django 1.8, python 2.7 and is my
> actual project.

As this is more a "Django" (than a general "Python") question,
you might get better help in a "Django" mailing list/support forum.


Your "subject" indicates that you likely see (somewhere)
the "Django" error message "Improper Django Project error".
Likely, you have corrupted you "Django" project setup.
Read about how "Django" projects must look like and fix your setup.


> I am using Ninja-IDE as my IDE. I like it a lot.
>
> At this point both projects are essentially identical with the
> exception of name changes. The twr project work down to the first
> template inclusion ( index.html ). The archivedb project refuses to
> find the home.html template file. The system layout is exactly the
> same.
>
> I wiped the home.html file and attempted to re-install it but my IDE
> gave the following error window:
>
>> Sorry, either settings file or virtualenv are missingthese are
>> required for Django Plugin to work in thepresent version, we are
>> working on fixing this.
>>
> I have virtualenv installed and active and the settings file is
> present.

You should ask this question on a "Ninja-IDE" mailing list/support forum.

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


Re: 'open' is not defined

2015-07-30 Thread dieter
 writes:
> ...
> Why is open not defined in the following code:NameError: name 'open' is not 
> defined
>
> Code reads as follows:
>
> fname = raw_input("Enter file name: ")
> if len(fname) < 1 : fname = "mbox-short.txt"
> fh = open(fname)
> count = 0
> for line in fh:
> if not line.startswith('From'): continue
> line2 = line.strip()
> line3 = line2.split()
> line4 = line3[1]
> print line4
> count = count + 1
> print "There were", count, "lines in the file with From as the first word"

You might execute the code above in a "restricted execution environment"
(one where "__builtins__" is not the typical "__builtin__" module --
that's how "open" (and other builtins) is found).

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


GvR Europython keynote described on lwn.net

2015-07-30 Thread Paul Rubin
https://lwn.net/Articles/651967/

Excerpts:

He then moved on to Python 3.5, which is due in September. He would have
trouble choosing a favorite feature from the release because there are
"way too many cool things" in it  Perhaps his favorite 3.5 feature
should be type hints, since it is a PEP he worked on himself. It took a
lot of work for the PEP to get accepted, which is a little bizarre since
he is the benevolent dictator for life (BDFL) and could accept his own
PEP. But he wanted to have independent review and acceptance of the PEP,
which Mark Shannon was graciously willing to provide as the BDFL
delegate, he said.  ... If you caught him unaware, though, he probably
would name the new async and await keywords for coroutines as his
favorite. It was the last PEP accepted for 3.5 and it provides a more
natural way of specifying coroutines.

...

[regarding age of bugs in Python bug tracker]

If you pick any bug at random, including closed bugs, you would likely
get a closed bug. Many bugs are closed quickly and bugs that are easy to
fix tend to get fixed quickly. But the average lifetime of an open bug
grows linearly with the age of the project, he said.

[On designing a new language, and the GIL]

If you were to design a new language today, he said, you would make it
without mutable (changeable) objects, or with limited mutability. From
the audience, though, came: "That would not be Python." Van Rossum
agreed: "You took the words out of my mouth." There are various ongoing
efforts to get around the GIL, including the PyPy software transactional
memory (STM) work and PyParallel. Other developers are also "banging
their head against that wall until it breaks". If anyone has ideas on
how to remove the GIL but still keep the language as Python, he (and
others) would love to hear about it.  

[PyPy, and how GvR and Dropbox use Python]

He was asked about PyPy, whether he used it and whether it might someday
become the default interpreter. He does not use PyPy, but he does
download it once in a while, plays with it for a few minutes, and likes
what he sees. He uses Python in two modes, either writing a short little
script to get something done, for which he just uses one of the
interpreters he already has built on his system, or as a Dropbox
engineer deploying Python code to its cluster.

The Dropbox cluster runs a modified Python 2.7, he said, which elicited
audience laughter. "I said it, it is no secret", he said.

[Favorites]

Five short questions about his favorites was up next. Favorite web
framework? He said he only writes one web app in any framework and that
the last he tried was Flask. Favorite testing library? He mostly just
uses unittest and mock from the standard library. Editor? He uses Emacs,
but started out with vi (both of which were greeted with applause,
presumably by different sets of audience members). He still uses vi (or
Vim) occasionally, but if he does that for five minutes, it takes him
fifteen minutes to get used to Emacs again.

[Anti-favorites]

The final question was about what he hates in Python. "Anything to do
with package distribution", he answered immediately. There are problems
with version skew and dependencies that just make for an "endless
mess". He dreads it when a colleague comes to him with a "simple Python
question". Half the time it is some kind of import path problem and
there is no easy solution to offer.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'open' is not defined

2015-07-30 Thread ltc.hotspot
Dieter,




Thanks. What about using the append function to remove duplicate outputs 
entered on or thereafter line no. 9, i.e., 



LIST_APPEND(i) Calls list.append(TOS[-i], TOS). Used to implement list 
comprehensions. While the appended value is popped off, the list object remains 
on the stack so that it is available for further iterations of the loop. URL 
link available at 
https://docs.python.org/2.7/library/dis.html?highlight=append%20list#opcode-LIST_APPEND




What is the command line for such an append function?









Hal


Sent from Surface






Sent from Surface





From: dieter
Sent: ‎Thursday‎, ‎July‎ ‎30‎, ‎2015 ‎11‎:‎22‎ ‎PM
To: python-list@python.org





 writes:
> ...
> Why is open not defined in the following code:NameError: name 'open' is not 
> defined
>
> Code reads as follows:
>
> fname = raw_input("Enter file name: ")
> if len(fname) < 1 : fname = "mbox-short.txt"
> fh = open(fname)
> count = 0
> for line in fh:
> if not line.startswith('From'): continue
> line2 = line.strip()
> line3 = line2.split()
> line4 = line3[1]
> print line4
> count = count + 1
> print "There were", count, "lines in the file with From as the first word"

You might execute the code above in a "restricted execution environment"
(one where "__builtins__" is not the typical "__builtin__" module --
that's how "open" (and other builtins) is found).

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