Re: [setuptools] install data-file in users home-dir

2015-07-10 Thread Chris Angelico
On Sat, Jul 11, 2015 at 10:01 AM,   wrote:
> On 2015-07-10 09:39 Chris Warrick  wrote:
>> And you should not create the files in your install script.  Instead,
>> install them to a different data dir (somewhere in 'share/appname', or
>> alongside your package). When someone runs your app, only then you
>> should copy this file to user’s config directory
>
> I have to check if there still is a user config file.
> When doing this with the app itself, the check would be done while each
> start - what is quite unnecessary.

Wrong. It is completely necessary. What happens if (a) the user
deletes the config file? (b) a different user runs the app? (c) a hard
drive melt-down wipes out all home directories, and the sysadmin
restores from last night's backup (which was before the app was
installed)? You MUST check for the absence of the user config file.
Most programs will be expected to function correctly after having
their configs wiped out - it's a standard way of saying "go back to
all defaults".

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


Re: Trouble getting to windows My Documents directory

2015-07-10 Thread random832
The My Documents directory is not guaranteed to be named "Documents". On
older versions of windows it was "My Documents", and on foreign versions
of windows it is a name in their language.

The correct way to get the path of this folder is, for example (couldn't
test since I'm on a mac right now)

import ctypes
from ctypes import wintypes

CSIDL_PERSONAL = 5

SHGetFolderPath = ctypes.windll.shell32.SHGetFolderPathW
pszPath = ctypes.create_unicode_buffer(wintypes.MAX_PATH)
SHGetFolderPath.argtypes = [wintypes.HWND, ctypes.c_int,
wintypes.HANDLE, wintypes.DWORD, LPWSTR]
SHGetFolderPath.restype = wintypes.HRESULT

hResult = SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, pszPath)

if hResult == 0:
  print pszPath.value
else
  raise OSError("Could not find My Documents directory")


Linux systems generally provide their own way to get it (e.g.
xdg-user-dirs), on OSX everything I can find indicates it really is
always ~/Documents .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [setuptools] install data-file in users home-dir

2015-07-10 Thread c.buhtz
On 2015-07-10 09:39 Chris Warrick  wrote:
> And you should not create the files in your install script.  Instead,
> install them to a different data dir (somewhere in 'share/appname', or
> alongside your package). When someone runs your app, only then you
> should copy this file to user’s config directory

I have to check if there still is a user config file.
When doing this with the app itself, the check would be done while each
start - what is quite unnecessary.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The EuroPython 2015 Keynotes

2015-07-10 Thread Terry Reedy

On 7/10/2015 5:14 PM, beliavsky--- via Python-list wrote:

On Friday, July 10, 2015 at 2:58:18 PM UTC-4, Chris Angelico wrote:

On Fri, Jul 10, 2015 at 10:01 PM, beliavsky--- via Python-list
 wrote:

On Friday, July 10, 2015 at 7:21:14 AM UTC-4, M.-A. Lemburg
wrote:

With Mandy Waite we have announced all keynotes for EuroPython
2015: 5 keynotes, 6 speakers, 4 women and 2 men.



Your mentioning these numbers makes me wonder if the organizing
committee is using gender preferences in its selection of keynote
speakers.


I am sure they did, just as most organizing committees have been doing 
for decades, though in the opposite direction. However, 2 of the 4 women 
are the founders of PyLadies, who I presume will talk about the 
successes and lessons of their work.  Eliminating them, we have a 
balanced 2 and 2.  About time.



If 80% of Python programmers and potential speakers at a Python
conference are male, the chance of 4 out 6 speakers being female is
fairly low if gender is ignored. Some people think gender diversity
in tech is so important that there should be gender preferences --
see for example this post by a Python blogger
http://ilovesymposia.com/2015/04/03/calling-out-scipy-on-diversity/ .


It is a real fact that some members of the tech community have tried to 
make people with female bodies feel unwelcome.  (Hardly unique, the same 
is true of the academic community, for instance.)  I strongly feel that 
all Python programmers who respect others should be respected and welcome.



It is plausible that the organizers preferred female keynote
speakers.


Assume so and don't go if it bothers you. Let us hope that this is a 
non-issue within a decade.



Can the OP comment on this?


Mark has better things to do, like continuing preparing for the conference.

--
Terry Jan Reedy

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


Re: pygtk2 and colors

2015-07-10 Thread nickgeovanis
I may be phrasing this question improperly, but...If I need a canvas or 
canvas-like object, does GTK3/pygobject provide one? Or only GTK2/PyGTK? The 
answer seems to be "only GTK2/PyGTK" but the discussion I find online doesn't 
seem to have a clear answer.

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


Re: The EuroPython 2015 Keynotes

2015-07-10 Thread Jon Ribbens
On 2015-07-10, beliav...@aol.com  wrote:
> On Friday, July 10, 2015 at 2:58:18 PM UTC-4, Chris Angelico wrote:
>> On Fri, Jul 10, 2015 at 10:01 PM, beliavsky--- via Python-list
>>  wrote:
>> > On Friday, July 10, 2015 at 7:21:14 AM UTC-4, M.-A. Lemburg wrote:
>> >> With Mandy Waite we have announced all keynotes for EuroPython 2015:
>> >> 5 keynotes, 6 speakers, 4 women and 2 men.
>> >
>> > Your mentioning these numbers makes me wonder if the organizing
>> > committee is using gender preferences in its selection of keynote
>> > speakers. I hope not. It is better to choose the speakers who
>> > will give the most interesting talks and let the demographic
>> > chips fall where they may.
>> 
>> I think that's more a matter of having the statistically-curious
>> brain. In my father's family, there are 5 sons and 2 daughters - does
>> that indicate gender preference in my reporting, or just an
>> acknowledgement of a fact?
>
> If 80% of Python programmers and potential speakers at a Python
> conference are male, the chance of 4 out 6 speakers being female is
> fairly low if gender is ignored. Some people think gender diversity
> in tech is so important that there should be gender preferences --
> see for example this post by a Python blogger
> http://ilovesymposia.com/2015/04/03/calling-out-scipy-on-diversity/
> . It is plausible that the organizers preferred female keynote
> speakers.

I certainly hope they did, and applaud them if so.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The EuroPython 2015 Keynotes

2015-07-10 Thread beliavsky--- via Python-list
On Friday, July 10, 2015 at 2:58:18 PM UTC-4, Chris Angelico wrote:
> On Fri, Jul 10, 2015 at 10:01 PM, beliavsky--- via Python-list
>  wrote:
> > On Friday, July 10, 2015 at 7:21:14 AM UTC-4, M.-A. Lemburg wrote:
> >> With Mandy Waite we have announced all keynotes for EuroPython 2015:
> >> 5 keynotes, 6 speakers, 4 women and 2 men.
> >
> > Your mentioning these numbers makes me wonder if the organizing committee 
> > is using gender preferences in its selection of keynote speakers. I hope 
> > not. It is better to choose the speakers who will give the most interesting 
> > talks and let the demographic chips fall where they may.
> >
> 
> I think that's more a matter of having the statistically-curious
> brain. In my father's family, there are 5 sons and 2 daughters - does
> that indicate gender preference in my reporting, or just an
> acknowledgement of a fact?

If 80% of Python programmers and potential speakers at a Python conference are 
male, the chance of 4 out 6 speakers being female is fairly low if gender is 
ignored. Some people think gender diversity in tech is so important that there 
should be gender preferences -- see for example this post by a Python blogger 
http://ilovesymposia.com/2015/04/03/calling-out-scipy-on-diversity/ . It is 
plausible that the organizers preferred female keynote speakers. Can the OP 
comment on this?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble getting to windows My Documents directory

2015-07-10 Thread Tim Chase
On 2015-07-10 09:27, Mark Storkamp via Python-list wrote:
> sourcedir = os.environ['HOME']+"/Documents/"

First, I'd do a couple things here to accommodate various systems to
make it cross-platform:

  sourcedir = os.path.join(
os.path.expanduser('~'),
"Documents"
)

> os.chdir(sourcedir)
> src = askopenfilename()

Then, rather than changing to that directory, use

  src = askopenfilename(initialdir=sourcedir)

> When this is run from IDLE, it works fine. But when I double click
> on the saved file to run it, it quits without ever showing the open
> file dialog box, and doesn't show any error message.

If the above doesn't solve the problem, you might try writing the
sourcedir to a file so you can see what it thinks you're trying to
open.

> The problem is with the os.environ['HOME'] call. If I comment it
> out (and fix up the surrounding code with an absolute path) then it
> runs. But then it won't work properly for other users.

I suspect that inspecting that sourcedir will show what's going on,
and that the above tweaks will ameliorate the problem.

-tkc


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


Re: The EuroPython 2015 Keynotes

2015-07-10 Thread Chris Angelico
On Fri, Jul 10, 2015 at 10:01 PM, beliavsky--- via Python-list
 wrote:
> On Friday, July 10, 2015 at 7:21:14 AM UTC-4, M.-A. Lemburg wrote:
>> With Mandy Waite we have announced all keynotes for EuroPython 2015:
>> 5 keynotes, 6 speakers, 4 women and 2 men.
>
> Your mentioning these numbers makes me wonder if the organizing committee is 
> using gender preferences in its selection of keynote speakers. I hope not. It 
> is better to choose the speakers who will give the most interesting talks and 
> let the demographic chips fall where they may.
>

I think that's more a matter of having the statistically-curious
brain. In my father's family, there are 5 sons and 2 daughters - does
that indicate gender preference in my reporting, or just an
acknowledgement of a fact?

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


Re: [setuptools] install data-file in users home-dir

2015-07-10 Thread c.buhtz
Hi Chris,

thank you for your answer.

On 2015-07-10 09:39 Chris Warrick  wrote:
> You should NEVER use sudo with pip.  Instead, use virtualenvs as a
> regular user, or create your own .deb packages.  

I am not sure, but maybe this is an Ubuntu-specific "problem"?
When I don't use sudo I got errors like this
"PermissionError: [Errno 13] Permission denied:
'/usr/local/lib/python3.4/dist-packages/SQLAlchemy-1.0.6.dist-info"

And it make sense for me.

Don't tell me about deb-Packages! :D I am stuck with that currently. I
would be glad to have a correct working whl-file for my local needs.
After that - maybe! - I will start again with thinking about a deb.

How can virtualenv help here? I need to install
python-software/packages to the system and not to a different
environment or sandbox.
I never used virtualenv but as I understand it it is for testing
purpose not for productive system.

> And you should not create the files in your install script.  Instead,
> install them to a different data dir (somewhere in 'share/appname'  

What do you mean with "data dir"? For a default config-file it could
be /etc/appname/default.conf. But I have no rights for that.

> should copy this file to user’s config directory (use pkg_resources to
> help you get it) if it does not exist yet.  

I will look at this package.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble getting to windows My Documents directory

2015-07-10 Thread Rustom Mody
On Friday, July 10, 2015 at 11:18:57 PM UTC+5:30, Rustom Mody wrote:
> On Friday, July 10, 2015 at 8:56:48 PM UTC+5:30, Mark Storkamp wrote:
> >  MRAB  wrote:
> > 
> > > On 2015-07-10 15:27, Mark Storkamp via Python-list wrote:
> > > > I'm just learning Python, and I've run into trouble trying to change
> > > > directory to the windows My Documents directory. There's likely a better
> > > > way to do this, but this is what I've tried so far:
> > > >
> > > > -
> > > > from tkinter import Tk
> > > > from tkinter.filedialog import askopenfilename
> > > >
> > > > import os
> > > >
> > > > Tk().withdraw()
> > > >
> > > > sourcedir = os.environ['HOME']+"/Documents/"
> > > > os.chdir(sourcedir)
> > > > src = askopenfilename()
> > > > if src == '' :
> > > >  sys.exit()
> > > > fin = open(src, mode='r')
> > > > ## do stuff
> > > > fin.close()
> > > > ---
> > > >
> > > > When this is run from IDLE, it works fine. But when I double click on
> > > > the saved file to run it, it quits without ever showing the open file
> > > > dialog box, and doesn't show any error message.
> > > >
> > > > The problem is with the os.environ['HOME'] call. If I comment it out
> > > > (and fix up the surrounding code with an absolute path) then it runs.
> > > > But then it won't work properly for other users.
> > > >
> > > > Interestingly enough, when I moved this to a Mac so I could post to
> > > > Usenet, I discovered it works fine on the Mac. Only Windows seems to be
> > > > the problem. Windows 7.
> > > >
> > > > Any thoughts or suggestions?
> > > >
> > > Try os.path.expanduser(r'~\Documents').
> > > 
> > > It's a bad idea to use os.chdir; it's better to use absolute paths:
> > > 
> > > src = askopenfilename(initialdir=os.path.expanduser(r'~\Documents'))
> > 
> > I thought there must be a way to pass the directory to askopenfilename, 
> > but I just hadn't figured out how yet.
> > 
> > The other suggestions for using HOMEPATH also worked for both Mac and 
> > Windows.
> > 
> > Thanks.
> 
> According to 
> http://serverfault.com/questions/29948/difference-between-profile-and-home-path
> it seems %userprofile% is more current than %homepath%
> [though windows arcana is not exactly my forte ;-) ]

which may need to be combined with something like:
home = 'HOME' if os.name=='posix' else 'USERPROFILE'
(see https://docs.python.org/2/library/os.html for os.name)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble getting to windows My Documents directory

2015-07-10 Thread Rustom Mody
On Friday, July 10, 2015 at 8:56:48 PM UTC+5:30, Mark Storkamp wrote:
>  MRAB  wrote:
> 
> > On 2015-07-10 15:27, Mark Storkamp via Python-list wrote:
> > > I'm just learning Python, and I've run into trouble trying to change
> > > directory to the windows My Documents directory. There's likely a better
> > > way to do this, but this is what I've tried so far:
> > >
> > > -
> > > from tkinter import Tk
> > > from tkinter.filedialog import askopenfilename
> > >
> > > import os
> > >
> > > Tk().withdraw()
> > >
> > > sourcedir = os.environ['HOME']+"/Documents/"
> > > os.chdir(sourcedir)
> > > src = askopenfilename()
> > > if src == '' :
> > >  sys.exit()
> > > fin = open(src, mode='r')
> > > ## do stuff
> > > fin.close()
> > > ---
> > >
> > > When this is run from IDLE, it works fine. But when I double click on
> > > the saved file to run it, it quits without ever showing the open file
> > > dialog box, and doesn't show any error message.
> > >
> > > The problem is with the os.environ['HOME'] call. If I comment it out
> > > (and fix up the surrounding code with an absolute path) then it runs.
> > > But then it won't work properly for other users.
> > >
> > > Interestingly enough, when I moved this to a Mac so I could post to
> > > Usenet, I discovered it works fine on the Mac. Only Windows seems to be
> > > the problem. Windows 7.
> > >
> > > Any thoughts or suggestions?
> > >
> > Try os.path.expanduser(r'~\Documents').
> > 
> > It's a bad idea to use os.chdir; it's better to use absolute paths:
> > 
> > src = askopenfilename(initialdir=os.path.expanduser(r'~\Documents'))
> 
> I thought there must be a way to pass the directory to askopenfilename, 
> but I just hadn't figured out how yet.
> 
> The other suggestions for using HOMEPATH also worked for both Mac and 
> Windows.
> 
> Thanks.

According to 
http://serverfault.com/questions/29948/difference-between-profile-and-home-path
it seems %userprofile% is more current than %homepath%
[though windows arcana is not exactly my forte ;-) ]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Matplotlib X-axis timezone trouble

2015-07-10 Thread Peter Pearson
On Thu, 09 Jul 2015 19:50:33 GMT, Tony the Tiger  wrote:
> On Tue, 30 Jun 2015 00:56:26 +, Peter Pearson wrote:
>
>> If I use timezone US/Central, I get the same (bad) plot.
>
> Perhaps this can help?:
> http://stackoverflow.com/questions/1301493/setting-timezone-in-python

Yes, thanks.  As I summarized (in greater detail) elsewhere on this
thread, Matplotlib was entirely innocent, and was correctly labeling
erroneous datetime objects.  My real problem was that datetime.datetime()
malfunctions when its tzinfo parameter is a timezone with daylight
saving time.  The practical solution is to use pytz.localize().

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Combing Search Engine with REST

2015-07-10 Thread subhabangalore
On Friday, July 10, 2015 at 5:36:48 PM UTC+5:30, Laura Creighton wrote:
> In a message of Fri, 10 Jul 2015 04:46:25 -0700, 
>  writes:
> >Dear Group,
> >
> >I am trying to make a search engine. I used Whoosh to do it. 
> >I want to add documents to it. This is going fine. 
> >Now, I want to add documents in the index with REST framework.
> >I could learn Flask well. 
> >My task is to use Flask to add documents (by using put/post) to index. 
> >I am slightly confused how may I do it.
> >
> >If any one of esteemed members of the group may suggest.
> >
> >Regards,
> >Subhabrata Banerjee. 
> 
> I suggest you look at
> https://pythonhosted.org/Flask-WhooshAlchemy/
> and see if it does what you want.
> 
> Laura

Hi,
Thanks. But documentation is very low. Both whoosh and Flask are well 
documented.
Regards,
Subhabrata. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble getting to windows My Documents directory

2015-07-10 Thread Mark Storkamp via Python-list
In article ,
 MRAB  wrote:

> On 2015-07-10 15:27, Mark Storkamp via Python-list wrote:
> > I'm just learning Python, and I've run into trouble trying to change
> > directory to the windows My Documents directory. There's likely a better
> > way to do this, but this is what I've tried so far:
> >
> > -
> > from tkinter import Tk
> > from tkinter.filedialog import askopenfilename
> >
> > import os
> >
> > Tk().withdraw()
> >
> > sourcedir = os.environ['HOME']+"/Documents/"
> > os.chdir(sourcedir)
> > src = askopenfilename()
> > if src == '' :
> >  sys.exit()
> > fin = open(src, mode='r')
> > ## do stuff
> > fin.close()
> > ---
> >
> > When this is run from IDLE, it works fine. But when I double click on
> > the saved file to run it, it quits without ever showing the open file
> > dialog box, and doesn't show any error message.
> >
> > The problem is with the os.environ['HOME'] call. If I comment it out
> > (and fix up the surrounding code with an absolute path) then it runs.
> > But then it won't work properly for other users.
> >
> > Interestingly enough, when I moved this to a Mac so I could post to
> > Usenet, I discovered it works fine on the Mac. Only Windows seems to be
> > the problem. Windows 7.
> >
> > Any thoughts or suggestions?
> >
> Try os.path.expanduser(r'~\Documents').
> 
> It's a bad idea to use os.chdir; it's better to use absolute paths:
> 
> src = askopenfilename(initialdir=os.path.expanduser(r'~\Documents'))

I thought there must be a way to pass the directory to askopenfilename, 
but I just hadn't figured out how yet.

The other suggestions for using HOMEPATH also worked for both Mac and 
Windows.

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


Re: Trouble getting to windows My Documents directory

2015-07-10 Thread MRAB

On 2015-07-10 15:27, Mark Storkamp via Python-list wrote:

I'm just learning Python, and I've run into trouble trying to change
directory to the windows My Documents directory. There's likely a better
way to do this, but this is what I've tried so far:

-
from tkinter import Tk
from tkinter.filedialog import askopenfilename

import os

Tk().withdraw()

sourcedir = os.environ['HOME']+"/Documents/"
os.chdir(sourcedir)
src = askopenfilename()
if src == '' :
 sys.exit()
fin = open(src, mode='r')
## do stuff
fin.close()
---

When this is run from IDLE, it works fine. But when I double click on
the saved file to run it, it quits without ever showing the open file
dialog box, and doesn't show any error message.

The problem is with the os.environ['HOME'] call. If I comment it out
(and fix up the surrounding code with an absolute path) then it runs.
But then it won't work properly for other users.

Interestingly enough, when I moved this to a Mac so I could post to
Usenet, I discovered it works fine on the Mac. Only Windows seems to be
the problem. Windows 7.

Any thoughts or suggestions?


Try os.path.expanduser(r'~\Documents').

It's a bad idea to use os.chdir; it's better to use absolute paths:

src = askopenfilename(initialdir=os.path.expanduser(r'~\Documents'))

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


Re: Trouble getting to windows My Documents directory

2015-07-10 Thread Laura Creighton
Maybe HOMEPATH is what windows calls it?
http://libertyboy.free.fr/computing/reference/envariables/
(but maybe this is only for windows XP.  I don't have
a windows system, so I cannot test this.)

Laura

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


Re: Evaluation order

2015-07-10 Thread Mark Lawrence

On 10/07/2015 15:30, Thierry Chappuis wrote:

[snipped]

Please don't top post here as it can get irritating, especially in long 
threads, thanks.


--
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: [setuptools] install data-file in users home-dir

2015-07-10 Thread Chris Warrick
CC’ing the mailing list; please use Reply All in the future.

On 10 July 2015 at 16:36,   wrote:
> Hi Chris,
>
> thank you for your answer.
>
> On 2015-07-10 09:39 Chris Warrick  wrote:
>> You should NEVER use sudo with pip.  Instead, use virtualenvs as a
>> regular user, or create your own .deb packages.
>
> I am not sure, but maybe this is an Ubuntu-specific "problem"?
> When I don't use sudo I got errors like this
> "PermissionError: [Errno 13] Permission denied:
> '/usr/local/lib/python3.4/dist-packages/SQLAlchemy-1.0.6.dist-info"
>
> And it make sense for me.

This is correct.  Don’t install things system-wide with pip.

> Don't tell me about deb-Packages! :D I am stuck with that currently. I
> would be glad to have a correct working whl-file for my local needs.
> After that - maybe! - I will start again with thinking about a deb.
>
> How can virtualenv help here? I need to install
> python-software/packages to the system and not to a different
> environment or sandbox.
> I never used virtualenv but as I understand it it is for testing
> purpose not for productive system.

virtualenv should be used for both testing AND production
environments. Your projects can have different versions of
dependencies, and this is what virtualenv helps with: they are
separate from each other. You can also modify the system packages
without messing with your system packages.

You can also use pip install --user to install to ~/.local

>> And you should not create the files in your install script.  Instead,
>> install them to a different data dir (somewhere in 'share/appname'
>
> What do you mean with "data dir"? For a default config-file it could
> be /etc/appname/default.conf. But I have no rights for that.

https://pythonhosted.org/setuptools/setuptools.html#including-data-files

Makes your package installable through wheel files and friendly for
all environments.

>> should copy this file to user’s config directory (use pkg_resources to
>> help you get it) if it does not exist yet.
>
> I will look at this package.

https://pythonhosted.org/setuptools/setuptools.html#accessing-data-files-at-runtime

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble getting to windows My Documents directory

2015-07-10 Thread Mark Lawrence

On 10/07/2015 15:27, Mark Storkamp via Python-list wrote:

I'm just learning Python, and I've run into trouble trying to change
directory to the windows My Documents directory. There's likely a better
way to do this, but this is what I've tried so far:

-
from tkinter import Tk
from tkinter.filedialog import askopenfilename

import os

Tk().withdraw()

sourcedir = os.environ['HOME']+"/Documents/"
os.chdir(sourcedir)
src = askopenfilename()
if src == '' :
 sys.exit()
fin = open(src, mode='r')
## do stuff
fin.close()
---

When this is run from IDLE, it works fine. But when I double click on
the saved file to run it, it quits without ever showing the open file
dialog box, and doesn't show any error message.

The problem is with the os.environ['HOME'] call. If I comment it out
(and fix up the surrounding code with an absolute path) then it runs.
But then it won't work properly for other users.

Interestingly enough, when I moved this to a Mac so I could post to
Usenet, I discovered it works fine on the Mac. Only Windows seems to be
the problem. Windows 7.

Any thoughts or suggestions?



Home isn't defined in Windows but somehow is in IDLE?  From a command 
line enter "set home".  Doing that on my Windows 8.1 box shows:-

HOMEDRIVE=C:
HOMEPATH=\Users\Mark

--
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: Evaluation order

2015-07-10 Thread Thierry Chappuis
Anyway, if we enter this kind of discussion, it is a reliable indication that
the code smells. There is a pythonic way to express the same task:

>>> t.sort()
>>> t

kind regards

Thierry

On ven., juil. 10, 2015 at 2:28 PM, Terry Reedy < tjre...@udel.edu 
[tjre...@udel.edu] > wrote:
On 7/10/2015 8:04 AM, candide wrote:
> Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a écrit :
>> I'm not sure what contradiction you're referring to, here. The
>> evaluation that you're pointing out says, as Terry showed via the
>> disassembly, that Python's first action is to look up the name 't' and
>> grab a reference to whatever object it points to.
>
> But in order to perform an operation, the interpreter has to evaluate
> the operands and "evaluating" is not "grabbing a reference to".

In the CPython, evaluating a name is implemented as getting the
reference corresponding to the name.

>> The execution of
>> t.sort() has to happen before the multiplication, because of the
>> parentheses.

> Official docs explains what evaluation is :
>
> When the name is bound to an object, evaluation of the atom yields that
object.

Conceptually, that is exactly right. How that is implemented on a
computer in CPython is to load the address on the top of the virtual
machine stack.

> So, since the Python interpreter is performing evaluation from left to right,
> the first operand of the expression :
>
> t*(1+int(bool(t.sort(
>
> evaluates to [2020, 42, 2015].

't' evaluates to the ***mutable*** list that 't' is bound to.

> Next, the second operatand evaluates to the integer 1.

And in the process of that evaluation, the list is sorted.


--
Terry Jan Reedy


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


Trouble getting to windows My Documents directory

2015-07-10 Thread Mark Storkamp via Python-list
I'm just learning Python, and I've run into trouble trying to change 
directory to the windows My Documents directory. There's likely a better 
way to do this, but this is what I've tried so far:

-
from tkinter import Tk
from tkinter.filedialog import askopenfilename

import os

Tk().withdraw()

sourcedir = os.environ['HOME']+"/Documents/"
os.chdir(sourcedir)
src = askopenfilename()
if src == '' :
sys.exit()
fin = open(src, mode='r')
## do stuff
fin.close()
---

When this is run from IDLE, it works fine. But when I double click on 
the saved file to run it, it quits without ever showing the open file 
dialog box, and doesn't show any error message.

The problem is with the os.environ['HOME'] call. If I comment it out 
(and fix up the surrounding code with an absolute path) then it runs. 
But then it won't work properly for other users.

Interestingly enough, when I moved this to a Mac so I could post to 
Usenet, I discovered it works fine on the Mac. Only Windows seems to be 
the problem. Windows 7.

Any thoughts or suggestions?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Evaluation order

2015-07-10 Thread Chris Angelico
On Fri, Jul 10, 2015 at 10:04 PM, candide  wrote:
> But in order to perform an operation, the interpreter has to evaluate the 
> operands and "evaluating" is not "grabbing a reference to".

Actually, it is. Suppose that instead of 't', you had a function call:

def get_t(announce, returnme=[]):
print(announce)
return returnme

get_t("setup").extend((2020, 42, 2015))
get_t("first")*(1+int(bool(get_t("second").sort(

I think it's obvious from running the above code that get_t("first")
is evaluated before get_t("second") is. In the trivial case where the
operand is a simple name, yes, evaluating that name is simply "grab a
reference to the object this name references" (and in the case of
CPython, shove it onto the stack; other Pythons may operate some other
way).

> Official docs explains what evaluation is :
>
> When the name is bound to an object, evaluation of the atom yields that 
> object.
>
> So, since the Python interpreter is performing evaluation from left to right, 
> the first operand of the expression :
>
> t*(1+int(bool(t.sort(
>
> evaluates to [2020, 42, 2015]. Next, the second operatand evaluates to the 
> integer 1. So I was expecting the result to be a shallow copy of the first 
> list [2020, 42, 2015] (the value of t before side effect produced by the sort 
> method). On the contrary, the final result takes into in account the side 
> effect and it is as if the first operand has been evaluated twice before 
> execution of the multiplication operation.
>

The shallow copy isn't made until the multiplication is performed;
it's only at that point that a function takes two parameters and does
the work, something like this:

class list:
def __mul__(self, count):
result = []
for i in range(count): result.extend(self)
return result

Obviously you can't call that function until you know both the list
object and the count, so no copies are made until both those values
can be provided. The first operand evaluates to *the list with the
identity X*, the second operand evaluates to *the integer 1*, and then
the multiplication is performed.

Does that answer the question?

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


Re: (side-)effects and ...

2015-07-10 Thread Chris Angelico
On Sat, Jul 11, 2015 at 12:05 AM, Skip Montanaro
 wrote:
> I'm not sure about X-No-Html. A quick Google search for that header returned
> nothing useful.

Yeah. At best it seems redundant - "Hey look, there's no HTML in this
message!" - but I suspect it's mainly bragging "I can add headers to
my posts".

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


Re: (side-)effects and ...

2015-07-10 Thread Skip Montanaro
On Thu, Jul 9, 2015 at 9:05 PM, Chris Angelico  wrote:

> Even if it respects that, there's no way that Mailman can know to
> respect his ridiculous copyright restriction.
>

Well, sure. But Mailman is probably not alone in this regard. In case it
wasn't clear from Tony the Tiger's post (everything was wrapped in my
copy), here's how those headers all look in-the-raw:

X-Copyright: (C) Copyright 2015 Stefan Ram. All rights reserved.
 Distribution through any means other than regular usenet
 channels is forbidden. It is forbidden to publish this
 article in the world wide web. It is forbidden to change
 URIs of this article into links. It is forbidden to remove
 this notice or to transfer the body without this notice.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is only set, because this prevents some
 services to mirror the article via the web (HTTP). But Stefan Ram
 hereby allows to keep this article within a Usenet archive server
 with only NNTP access without any time limitation.
X-No-Html: yes

So he's got five headers, two of which you would clearly expect mail
software to recognize (X-No-Archive and Archive), two which must be for
human consumption only (X-Copyright and X-No-Archive-Readme). I'm not sure
about X-No-Html. A quick Google search for that header returned nothing
useful.

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


Re: Evaluation order

2015-07-10 Thread Thierry Chappuis
Hi,

No, the value of t is a reference to tje list. So first, (1) the value of
the reference t is recovered, (2) the parenthesis is evaluated, (...) the
whole expression is evaluated.

To evaluate (2), the .sort() call is executed in place with the side effect
of sorting the content of t. t.sort() returns None. When the whole
expression is evaluated, the sorted list will be displayed, as expected.

Kind regards

2015-07-10 14:04 GMT+02:00 candide :

> Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a écrit :
>
>
>
> > I'm not sure what contradiction you're referring to, here. The
> > evaluation that you're pointing out says, as Terry showed via the
> > disassembly, that Python's first action is to look up the name 't' and
> > grab a reference to whatever object it points to.
>
>
> But in order to perform an operation, the interpreter has to evaluate the
> operands and "evaluating" is not "grabbing a reference to".
>
> > The execution of
> > t.sort() has to happen before the multiplication, because of the
> > parentheses.
> >
>
>
>
> Official docs explains what evaluation is :
>
> When the name is bound to an object, evaluation of the atom yields that
> object.
>
> So, since the Python interpreter is performing evaluation from left to
> right, the first operand of the expression :
>
> t*(1+int(bool(t.sort(
>
> evaluates to [2020, 42, 2015]. Next, the second operatand evaluates to the
> integer 1. So I was expecting the result to be a shallow copy of the first
> list [2020, 42, 2015] (the value of t before side effect produced by the
> sort method). On the contrary, the final result takes into in account the
> side effect and it is as if the first operand has been evaluated twice
> before execution of the multiplication operation.
>
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Evaluation order

2015-07-10 Thread Thierry Chappuis
Hi,

No, the value of t is a reference to tje list. So first, (1) the value of
the reference t is recovered, (2) the parenthesis is evaluated, (...) the
whole expression is evaluated.

To evaluate (2), the .sort() call is executed in place with the side effect
of sorting the content of t. t.sort() returns None. When the whole
expression is evaluated, the sorted list will be displayed, as expected.

Kind regards

2015-07-10 14:04 GMT+02:00 candide :

> Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a écrit :
>
>
>
> > I'm not sure what contradiction you're referring to, here. The
> > evaluation that you're pointing out says, as Terry showed via the
> > disassembly, that Python's first action is to look up the name 't' and
> > grab a reference to whatever object it points to.
>
>
> But in order to perform an operation, the interpreter has to evaluate the
> operands and "evaluating" is not "grabbing a reference to".
>
> > The execution of
> > t.sort() has to happen before the multiplication, because of the
> > parentheses.
> >
>
>
>
> Official docs explains what evaluation is :
>
> When the name is bound to an object, evaluation of the atom yields that
> object.
>
> So, since the Python interpreter is performing evaluation from left to
> right, the first operand of the expression :
>
> t*(1+int(bool(t.sort(
>
> evaluates to [2020, 42, 2015]. Next, the second operatand evaluates to the
> integer 1. So I was expecting the result to be a shallow copy of the first
> list [2020, 42, 2015] (the value of t before side effect produced by the
> sort method). On the contrary, the final result takes into in account the
> side effect and it is as if the first operand has been evaluated twice
> before execution of the multiplication operation.
>
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Evaluation order

2015-07-10 Thread Terry Reedy

On 7/10/2015 8:04 AM, candide wrote:

Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a écrit :

I'm not sure what contradiction you're referring to, here. The
evaluation that you're pointing out says, as Terry showed via the
disassembly, that Python's first action is to look up the name 't' and
grab a reference to whatever object it points to.


But in order to perform an operation, the interpreter has to evaluate

> the operands and "evaluating" is not "grabbing a reference to".

In the CPython, evaluating a name is implemented as getting the 
reference corresponding to the name.



The execution of
t.sort() has to happen before the multiplication, because of the
parentheses.



Official docs explains what evaluation is :

When the name is bound to an object, evaluation of the atom yields that object.


Conceptually, that is exactly right.  How that is implemented on a 
computer in CPython is to load the address on the top of the virtual 
machine stack.



So, since the Python interpreter is performing evaluation from left to right,

> the first operand of the expression :


t*(1+int(bool(t.sort(

evaluates to [2020, 42, 2015].


't' evaluates to the ***mutable*** list that 't' is bound to.


 Next, the second operatand evaluates to the integer 1.


And in the process of that evaluation, the list is sorted.


--
Terry Jan Reedy


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


Re: Evaluation order

2015-07-10 Thread Ned Batchelder
On Friday, July 10, 2015 at 8:04:36 AM UTC-4, candide wrote:
> Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a écrit :
> 
> 
>  
> > I'm not sure what contradiction you're referring to, here. The
> > evaluation that you're pointing out says, as Terry showed via the
> > disassembly, that Python's first action is to look up the name 't' and
> > grab a reference to whatever object it points to. 
> 
> 
> But in order to perform an operation, the interpreter has to evaluate the 
> operands and "evaluating" is not "grabbing a reference to". 
> 
> > The execution of
> > t.sort() has to happen before the multiplication, because of the
> > parentheses.
> >
> 
> 
> 
> Official docs explains what evaluation is :
> 
> When the name is bound to an object, evaluation of the atom yields that 
> object.
> 
> So, since the Python interpreter is performing evaluation from left to right, 
> the first operand of the expression :
> 
> t*(1+int(bool(t.sort(
> 
> evaluates to [2020, 42, 2015]. Next, the second operatand evaluates to the 
> integer 1. So I was expecting the result to be a shallow copy of the first 
> list [2020, 42, 2015] (the value of t before side effect produced by the sort 
> method). On the contrary, the final result takes into in account the side 
> effect and it is as if the first operand has been evaluated twice before 
> execution of the multiplication operation.

The first operand is t. Evaluating t does not make a copy of t, it is simply
a reference to t.  If t is later modified (by the sort method), the modified
data will be seen when t is used in the multiplication.

Python never implicitly copies lists (or any other data structure).  This
explains more about the mechanics of names and values: http://bit.ly/pynames1

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


Re: Evaluation order

2015-07-10 Thread candide
Le vendredi 10 juillet 2015 04:02:56 UTC+2, Chris Angelico a écrit :


 
> I'm not sure what contradiction you're referring to, here. The
> evaluation that you're pointing out says, as Terry showed via the
> disassembly, that Python's first action is to look up the name 't' and
> grab a reference to whatever object it points to. 


But in order to perform an operation, the interpreter has to evaluate the 
operands and "evaluating" is not "grabbing a reference to". 

> The execution of
> t.sort() has to happen before the multiplication, because of the
> parentheses.
>



Official docs explains what evaluation is :

When the name is bound to an object, evaluation of the atom yields that object.

So, since the Python interpreter is performing evaluation from left to right, 
the first operand of the expression :

t*(1+int(bool(t.sort(

evaluates to [2020, 42, 2015]. Next, the second operatand evaluates to the 
integer 1. So I was expecting the result to be a shallow copy of the first list 
[2020, 42, 2015] (the value of t before side effect produced by the sort 
method). On the contrary, the final result takes into in account the side 
effect and it is as if the first operand has been evaluated twice before 
execution of the multiplication operation.




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


Re: The EuroPython 2015 Keynotes

2015-07-10 Thread beliavsky--- via Python-list
On Friday, July 10, 2015 at 7:21:14 AM UTC-4, M.-A. Lemburg wrote:
> With Mandy Waite we have announced all keynotes for EuroPython 2015:
> 5 keynotes, 6 speakers, 4 women and 2 men.

Your mentioning these numbers makes me wonder if the organizing committee is 
using gender preferences in its selection of keynote speakers. I hope not. It 
is better to choose the speakers who will give the most interesting talks and 
let the demographic chips fall where they may.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Combing Search Engine with REST

2015-07-10 Thread Laura Creighton
In a message of Fri, 10 Jul 2015 04:46:25 -0700, subhabrata.bane...@gmail.com
 writes:
>Dear Group,
>
>I am trying to make a search engine. I used Whoosh to do it. 
>I want to add documents to it. This is going fine. 
>Now, I want to add documents in the index with REST framework.
>I could learn Flask well. 
>My task is to use Flask to add documents (by using put/post) to index. 
>I am slightly confused how may I do it.
>
>If any one of esteemed members of the group may suggest.
>
>Regards,
>Subhabrata Banerjee. 

I suggest you look at
https://pythonhosted.org/Flask-WhooshAlchemy/
and see if it does what you want.

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


Combing Search Engine with REST

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

I am trying to make a search engine. I used Whoosh to do it. 
I want to add documents to it. This is going fine. 
Now, I want to add documents in the index with REST framework.
I could learn Flask well. 
My task is to use Flask to add documents (by using put/post) to index. 
I am slightly confused how may I do it.

If any one of esteemed members of the group may suggest.

Regards,
Subhabrata Banerjee. 




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


The EuroPython 2015 Keynotes

2015-07-10 Thread M.-A. Lemburg
With Mandy Waite we have announced all keynotes for EuroPython 2015:
5 keynotes, 6 speakers, 4 women and 2 men.

Keynote Schedule


 * Monday: Ola Sendecka & Ola Sitarska
 * Tuesday: Guido van Rossum
 * Wednesday: Holger Krekel
 * Thursday: Carrie Anne
 * Friday: Mandy Waite

More details about the keynotes are available on the
EuroPython 2015 Keynotes page:

https://ep2015.europython.eu/en/events/keynotes/

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


Re: [setuptools] install data-file in users home-dir

2015-07-10 Thread Chris Warrick
On 10 July 2015 at 03:11,   wrote:
> I am using setuptools to create a wheel file.
>
> There is a conf-file I want to install into the users config-diretory.
> e.g. /home/user/.config/appname/app.conf
>
> setup(...,
>   data_files = [ ('~/.config/appname/', ['app.conf']) ]
>  )
>
> I see two problems here:
>
> 1.
> I don't know the users "name". So I have to use a placeholder here.
> Does '~' work here in that case?

It doesn’t.  You would have to use os.path.expanduser, but don’t do that.

> 2.
> To install the wheel-file with pip I need sudo-privilegs on Ubuntu
> 14.04.2. That means while the install script runs I can not ask for the
> users name because it is "root" in that case.
> --
> https://mail.python.org/mailman/listinfo/python-list

You should NEVER use sudo with pip.  Instead, use virtualenvs as a
regular user, or create your own .deb packages.

And you should not create the files in your install script.  Instead,
install them to a different data dir (somewhere in 'share/appname', or
alongside your package). When someone runs your app, only then you
should copy this file to user’s config directory (use pkg_resources to
help you get it) if it does not exist yet.

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


EuroPython 2015 Keynote: Mandy Waite

2015-07-10 Thread M.-A. Lemburg
We are pleased to introduce our final keynote speaker for EuroPython
2015: Mandy Waite. She will be giving her keynote on Friday, July 24.

About Mandy Waite
-

Mandy works at Google as a Developer Advocate for Google Cloud
Platform and to make the world a better place for developers building
applications for the Cloud:

  “I came to Google from Sun Microsystems where I worked with partners
  on performance and optimisation of large scale applications and
  services before moving on to building an ecosystem of Open Source
  applications for OpenSolaris. In my spare time I’m learning Japanese
  and play the guitar.”

The Keynote: So, I have all these Docker containers, now what?
--

You’ve solved the issue of process-level reproducibility by packaging
up your apps and execution environments into a number of Docker
containers. But once you have a lot of containers running, you’ll
probably need to coordinate them across a cluster of machines while
keeping them healthy and making sure they can find each other. Trying
to do this imperatively can quickly turn into an unmanageable mess!
Wouldn’t it be helpful if you could declare to your cluster what you
want it to do, and then have the cluster assign the resources to get
it done and to recover from failures and scale on demand?

Kubernetes (http://kubernetes.io) is an open source, cross platform
cluster management and container orchestration platform that
simplifies the complex tasks of deploying and managing your
applications in Docker containers. You declare a desired state, and
Kubernetes does all the work needed to create and maintain it. In this
talk, we’ll look at the basics of Kubernetes and at how to map common
applications to these concepts. This will include a hands-on
demonstration and visualization of the steps involved in getting an
application up and running on Kubernetes.

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


[setuptools] install data-file in users home-dir

2015-07-10 Thread c.buhtz
I am using setuptools to create a wheel file.

There is a conf-file I want to install into the users config-diretory.
e.g. /home/user/.config/appname/app.conf

setup(...,
  data_files = [ ('~/.config/appname/', ['app.conf']) ]
 )

I see two problems here:

1.
I don't know the users "name". So I have to use a placeholder here.
Does '~' work here in that case?

2.
To install the wheel-file with pip I need sudo-privilegs on Ubuntu
14.04.2. That means while the install script runs I can not ask for the
users name because it is "root" in that case.
-- 
https://mail.python.org/mailman/listinfo/python-list