[Tutor] How to extract variables from GUI objects

2015-08-19 Thread Eric Kelly
I am a beginner with Python and would like to write a program that includes
a GUI to run it.  I've been through a tutorial on using Python but I'm
trying to also use Gtk and Glade to make the GUI.  I've tried to use the
docs and other tutorials but alas I'm still stuck.

The problem is simply to get the text from a combotext object.  I
simplified the program by only including the combo object and a "Run"
button.  The user should be able to choose a value from the list or enter a
different value manually.  When I click the "Run" button to print the combo
text, I think I get the memory address.  Here is the message that appears
when I click Run:

""

I realize that the program does not know what part of the object to get,
but I am unclear about how to tell it where the text is.  I've tried
assigning variable names to what I think are the appropriate user data
values, but of course none worked.  I'm using Glade 3, Gtk+ 3, and Python
34.

Thanks in advance for any help and suggestions (I'm sure there are other
mistakes here too).

Eric


The Python code is here:

#!C:\Python34
from gi.repository import Gtk


# Make a window to control the program
class MyGI(Gtk.Window):

def __init__(self):
Gtk.Window.__init__(self,title='Title')
self.builder = Gtk.Builder()
self.builder.add_from_file('GI_test.glade')

# Define handlers for signals from window
handlersDict = {
'on_applicationwindow1_destroy':Gtk.main_quit,
'on_buttonRun_clicked':self.on_buttonRun_clicked
}

# Get the objects from the window
self.window = self.builder.get_object('applicationwindow1')
self.buttonRun = self.builder.get_object('buttonRun')

# Connect the signals with their handlers
self.builder.connect_signals(handlersDict)


def on_buttonRun_clicked(self,widget):
comboText = self.builder.get_object('comboboxtext1')
print(comboText)


def main():
win = MyGI()
Gtk.main()

if __name__ == '__main__':
main()



The XML code is here:
---



  
  
True
False


  
True
False
vertical

  
True
False
5

  0
  100
  200

  
  
False
True
0
  


  
Run
True
True
True

  
  
False
True
1
  

  

  

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pip install in a virtualenv *without* internet?

2015-08-19 Thread Mike C. Fletcher

On 15-08-18 04:10 PM, Albert-Jan Roskam wrote:

Hi,
  
  
I use Python(x y) (Python 2.7) on Win7. I need a higher version of openpyxl, because pandas.Dataframe.to_excel yields an error. So pandas and its own dependencies (e.g. numpy) could remain in the python(x y) site-packages, I just need a higher version of openpyxl without disturbing the x,y installation (I do not even have rights to install stuff there!)
  
So I would like to pip install a openpyxl AND its specific dependencies in a virtualenv.

The problem is that I can't use pip to download the packages from Pypi because 
I do not have a regular internet connection. Is there a generic way to install 
a package and its (pre-downloaded) dependencies, a way that requires little or 
no modifications to the original package?
Using pip 'editable' might help: 
http://stackoverflow.com/questions/15031694/installing-python-packages-from-local-file-system-folder-with-pip.
 I am hoping requirements.txt might somehow be used to install the dependencies 
from a local location --but how?


To install without going out to the internet, you can use these arguments:

pip install --no-index --find-links=/path/to/download/directory 



that *won't* work for git/svn/bzr linked (editable) packages, but should 
work for pre-downloaded "released" packages. If you need the editable 
packages, you'll need to pull the git/whatever repositories and modify 
your requirements file to point to the local git repo. But you likely 
could just do a "python setup.py develop" for them if you've got the 
source downloaded anyway.


I often use this with a separate "download dependencies" stage that 
populates the packages directory so that our build server doesn't hit 
PyPi every time we do a rebuild of our virtualenvs (which we do for 
every testing build).


HTH,
Mike

--

  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pip install in a virtualenv *without* internet?

2015-08-19 Thread Alex Kleider

On 2015-08-18 19:32, Mike C. Fletcher wrote:

To install without going out to the internet, you can use these 
arguments:


pip install --no-index --find-links=/path/to/download/directory 




For this to work, /path/to/download/directory would, I assume, first 
have to be populated.
I further assume that running wget from within that directory might do 
the trick.

Can you suggest the correct parameter(s) that need to be provided?
If anyone happens to know approximately how much file space would be 
required, that would be helpful.

Thanks,
Alex
(using python 3.4, Linux- Ubuntu LTS (14.4))
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to extract variables from GUI objects

2015-08-19 Thread Timo

Op 19-08-15 om 01:08 schreef Eric Kelly:

I am a beginner with Python and would like to write a program that includes
a GUI to run it.  I've been through a tutorial on using Python but I'm
trying to also use Gtk and Glade to make the GUI.  I've tried to use the
docs and other tutorials but alas I'm still stuck.

The problem is simply to get the text from a combotext object.  I
simplified the program by only including the combo object and a "Run"
button.  The user should be able to choose a value from the list or enter a
different value manually.  When I click the "Run" button to print the combo
text, I think I get the memory address.  Here is the message that appears
when I click Run:

""
You are printing the actual Gtk.ComboBoxText class. Take this simple 
pure Python example:


>>> class Foo: pass
...
>>> f = Foo()
>>> print(f)
<__main__.Foo object at 0x7f3f32e31630>

See the similarity?

You will have to call the get_active_text() method on the 
Gtk.ComboBoxText class to get the selected text.


API docs: 
http://lazka.github.io/pgi-docs/Gtk-3.0/classes/ComboBoxText.html#Gtk.ComboBoxText.get_active_text
Tutorial: 
http://learngtk.org/tutorials/python_gtk3_tutorial/html/comboboxtext.html


So your code becomes:

def on_buttonRun_clicked(self,widget):
comboText = self.builder.get_object('comboboxtext1')
print(comboText.get_active_text())

Here are the full Gtk API docs: 
http://lazka.github.io/pgi-docs/index.html#Gtk-3.0
And here the tutorial: 
http://learngtk.org/tutorials/python_gtk3_tutorial/html/


Timo



I realize that the program does not know what part of the object to get,
but I am unclear about how to tell it where the text is.  I've tried
assigning variable names to what I think are the appropriate user data
values, but of course none worked.  I'm using Glade 3, Gtk+ 3, and Python
34.

Thanks in advance for any help and suggestions (I'm sure there are other
mistakes here too).

Eric


The Python code is here:

#!C:\Python34
from gi.repository import Gtk


# Make a window to control the program
class MyGI(Gtk.Window):

 def __init__(self):
 Gtk.Window.__init__(self,title='Title')
 self.builder = Gtk.Builder()
 self.builder.add_from_file('GI_test.glade')

 # Define handlers for signals from window
 handlersDict = {
 'on_applicationwindow1_destroy':Gtk.main_quit,
 'on_buttonRun_clicked':self.on_buttonRun_clicked
 }

 # Get the objects from the window
 self.window = self.builder.get_object('applicationwindow1')
 self.buttonRun = self.builder.get_object('buttonRun')

 # Connect the signals with their handlers
 self.builder.connect_signals(handlersDict)


 def on_buttonRun_clicked(self,widget):
 comboText = self.builder.get_object('comboboxtext1')
 print(comboText)


def main():
 win = MyGI()
 Gtk.main()

if __name__ == '__main__':
 main()



The XML code is here:
---



   
   
 True
 False
 
 
   
 True
 False
 vertical
 
   
 True
 False
 5
 
   0
   100
   200
 
   
   
 False
 True
 0
   
 
 
   
 Run
 True
 True
 True
 
   
   
 False
 True
 1
   
 
   
 
   

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pip install in a virtualenv *without* internet?

2015-08-19 Thread Albert-Jan Roskam
> Date: Wed, 19 Aug 2015 02:27:41 -0700
> From: aklei...@sonic.net
> To: tutor@python.org
> Subject: Re: [Tutor] pip install in a virtualenv *without* internet?
> 
> On 2015-08-18 19:32, Mike C. Fletcher wrote:
> 
> > To install without going out to the internet, you can use these 
> > arguments:
> > 
> > pip install --no-index --find-links=/path/to/download/directory 
> > 
> 
> 
> For this to work, /path/to/download/directory would, I assume, first 
> have to be populated.
> I further assume that running wget from within that directory might do 
> the trick.

 
..but, but wget requires an internet connection, which I do not have (at least 
not a normal one).
But if you do have internet I think you could simply copy the URL-with-sha1, 
then for each package do 
wget 
 
regards,
Albert-Jan

  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pip install in a virtualenv *without* internet?

2015-08-19 Thread Albert-Jan Roskam
Sorry, now with Reply All

From: sjeik_ap...@hotmail.com
To: mcfle...@vrplumber.com
Subject: RE: [Tutor] pip install in a virtualenv *without* internet?
Date: Wed, 19 Aug 2015 11:25:49 +




> Date: Tue, 18 Aug 2015 22:32:28 -0400
> From: mcfle...@vrplumber.com
> To: tutor@python.org
> Subject: Re: [Tutor] pip install in a virtualenv *without* internet?
> 
> On 15-08-18 04:10 PM, Albert-Jan Roskam wrote:
> > Hi,
> >   
> >   
> > I use Python(x y) (Python 2.7) on Win7. I need a higher version of 
> > openpyxl, because pandas.Dataframe.to_excel yields an error. So pandas and 
> > its own dependencies (e.g. numpy) could remain in the python(x y) 
> > site-packages, I just need a higher version of openpyxl without disturbing 
> > the x,y installation (I do not even have rights to install stuff there!)
> >   
> > So I would like to pip install a openpyxl AND its specific dependencies in 
> > a virtualenv.
> > The problem is that I can't use pip to download the packages from Pypi 
> > because I do not have a regular internet connection. Is there a generic way 
> > to install a package and its (pre-downloaded) dependencies, a way that 
> > requires little or no modifications to the original package?
> > Using pip 'editable' might help: 
> > http://stackoverflow.com/questions/15031694/installing-python-packages-from-local-file-system-folder-with-pip.
> >  I am hoping requirements.txt might somehow be used to install the 
> > dependencies from a local location --but how?
> 
> To install without going out to the internet, you can use these arguments:
> 
>  pip install --no-index --find-links=/path/to/download/directory 
> 
> 
> that *won't* work for git/svn/bzr linked (editable) packages, but should 
> work for pre-downloaded "released" packages. If you need the editable 
> packages, you'll need to pull the git/whatever repositories and modify 
> your requirements file to point to the local git repo. But you likely 
> could just do a "python setup.py develop" for them if you've got the 
> source downloaded anyway.
> 
> I often use this with a separate "download dependencies" stage that 
> populates the packages directory so that our build server doesn't hit 
> PyPi every time we do a rebuild of our virtualenvs (which we do for 
> every testing build).

Hi Mike,
 
Thank you so much! This looks very useful indeed. In fact, it is strange that 
pip does not cache packages by default (or does it?),
similar to apt-get. I have often been amazed by the number of downloads of some 
packages. Even with very popular packages, many thousands of downloads a day is 
probably mostly the result of build servers that re-download from Pypi with 
each and every push/commit. I always pin the exact version in requirements.txt, 
ie. I use pkg=1.0.1, not pkg>=1.0.1, so I really only use one version.
 
Best wishes,
Albert-Jan

  
  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pip install in a virtualenv *without* internet?

2015-08-19 Thread Alex Kleider

On 2015-08-19 04:28, Albert-Jan Roskam wrote:

Date: Wed, 19 Aug 2015 02:27:41 -0700
From: aklei...@sonic.net
To: tutor@python.org
Subject: Re: [Tutor] pip install in a virtualenv *without* internet?

On 2015-08-18 19:32, Mike C. Fletcher wrote:

> To install without going out to the internet, you can use these
> arguments:
>
> pip install --no-index --find-links=/path/to/download/directory
> 


For this to work, /path/to/download/directory would, I assume, first
have to be populated.
I further assume that running wget from within that directory might do
the trick.



..but, but wget requires an internet connection, which I do not have
(at least not a normal one).
But if you do have internet I think you could simply copy the
URL-with-sha1, then for each package do
wget 

regards,
Albert-Jan



I guess if you 'never' have an internet connection what I'm trying to do 
won't work,
but I'm addressing a different use case:  I have connectivity in some 
environments
but would like to be able to do a pip install at times when there is no 
connectivity.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pip install in a virtualenv *without* internet?

2015-08-19 Thread Marc Tompkins
On Wed, Aug 19, 2015 at 9:18 AM, Alex Kleider  wrote:

> I guess if you 'never' have an internet connection what I'm trying to do
> won't work,
> but I'm addressing a different use case:  I have connectivity in some
> environments
> but would like to be able to do a pip install at times when there is no
> connectivity.


I'm wondering: does the solution absolutely have to involve pip?  I ask
because I first started with Python right about the time pip was being
created, and I didn't actually start using it until about a year ago  Prior
to that, I downloaded my dependencies on my development machine, saved them
to a flash drive, and wrote a script (well, technically a batch file - most
of my clients use Windows) to automate offline installations.

pip is certainly more convenient, and I'm quite grateful to its developers
- but it's a relatively recent solution to the problem, and it's far from
the only way to do things.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] About using list in a function

2015-08-19 Thread Michelle Meiduo Wu
Hi there,
I'm trying to use List in a function. But it doesn't work. Here are sample code 
not work: ---def getResult():ls = []
ls= ls.append(100)ls= ls.append(200)  return ls
reList = []reList = getResult()lsLength = len(reList)print '\n The length of 
the list is:' + str(lsLength)-I ran the 
above code, there is an error message: AttributeError: 'NoneType' object has no 
attribute 'append'
But the code below not using list in a function 
works.--### This works:ls = 
[]ls.append(100)ls.append(200)lsLength = len(ls)print '\n list length is: ' + 
str(lsLength)- Do you know  
the reason?
Thank you,Michelle

  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] About using list in a function

2015-08-19 Thread Steven D'Aprano
Hi Michaelle, and welcome.


On Wed, Aug 19, 2015 at 12:09:15PM -0400, Michelle Meiduo Wu wrote:
> Hi there, I'm trying to use List in a function. But it doesn't work. 
> Here are sample code not work: 
> ---

> def getResult(): 
> ls = [] 
> ls = ls.append(100)

That line above is your problem. The append() method should be thought 
of as a procedure that acts in place, not a function which returns a 
value. So the line:

ls = ls.append(100)

sets ls to None, a special value that means "no result". Instead, you 
should write this:

def getResult():
ls = []
ls.append(100)
ls.append(200)
return ls


Or you can make that even shorter:

def getResult():
ls = [100, 200]
return ls



-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] About using list in a function

2015-08-19 Thread Steven D'Aprano
On Thu, Aug 20, 2015 at 03:05:53AM +1000, Steven D'Aprano wrote:
> Hi Michaelle, and welcome.

Oops, sorry for the typo, I meant Michelle.


-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] About using list in a function

2015-08-19 Thread Alan Gauld

On 19/08/15 17:09, Michelle Meiduo Wu wrote:

Hi there,
I'm trying to use List in a function. But it doesn't work. Here are sample code 
not work: ---def getResult():ls = []
ls= ls.append(100)ls= ls.append(200)  return ls
reList = []reList = getResult()lsLength = len(reList)print '\n The length of 
the list is:' + str(lsLength)-I ran the 
above code, there is an error message: AttributeError: 'NoneType' object has no 
attribute 'append'
But the code below not using list in a function 
works.--### This works:ls = 
[]ls.append(100)ls.append(200)lsLength = len(ls)print '\n list length is: ' + 
str(lsLength)- Do you know  
the reason?
Thank you,Michelle


As you can (hopefully!) see above, this message is completely scrambled.
Normally that means HTML. But the headers suggest it is plain text.
Also, I see that Steve replied with a correctly formatted inclusion.

Did anyone else get the scrambled version?
And does anyone have any clues why I did?

(Using Thunderbird v31.8 and normally not having major issues.)


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] OT: Searching Tutor Archives

2015-08-19 Thread Ken G.
While searching in Google several months ago, I came across a response 
addressed to me regarding on how to read, correct and write to the same 
file at the same time without using a secondary file as a temporary file 
to hold the corrected entries and rewriting to the original file.


The entry was dated back approximately four years ago. I thought I 
printed it out as that was a new concept to me then. Could someone 
explain how to found such an article or kindly refresh my memory on how 
to correct an original file without using a secondary file. Thanks.


Ken
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] About using list in a function

2015-08-19 Thread Laura Creighton
In a message of Wed, 19 Aug 2015 18:25:56 +0100, Alan Gauld writes:
>On 19/08/15 17:09, Michelle Meiduo Wu wrote:
>> Hi there,
>> I'm trying to use List in a function. But it doesn't work. Here are sample 
>> code not work: ---def getResult():ls 
>> = []ls= ls.append(100)ls= ls.append(200)  return ls
>> reList = []reList = getResult()lsLength = len(reList)print '\n The length of 
>> the list is:' + str(lsLength)-I ran 
>> the above code, there is an error message: AttributeError: 'NoneType' object 
>> has no attribute 'append'
>> But the code below not using list in a function 
>> works.--### This works:ls = 
>> []ls.append(100)ls.append(200)lsLength = len(ls)print '\n list length is: ' 
>> + str(lsLength)- Do you 
>> know  the reason?
>> Thank you,Michelle
>
>As you can (hopefully!) see above, this message is completely scrambled.
>Normally that means HTML. But the headers suggest it is plain text.
>Also, I see that Steve replied with a correctly formatted inclusion.
>
>Did anyone else get the scrambled version?
>And does anyone have any clues why I did?
>
>(Using Thunderbird v31.8 and normally not having major issues.)

I got scrambled, same as you.

Laura

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] About using list in a function

2015-08-19 Thread Laura Creighton
Scrambled in the archives, too
https://mail.python.org/pipermail/tutor/2015-August/106528.html
And looks like something thought it would be best as only one line of
text.

Laura
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] About using list in a function

2015-08-19 Thread Marc Tompkins
On Wed, Aug 19, 2015 at 10:25 AM, Alan Gauld 
wrote:

> On 19/08/15 17:09, Michelle Meiduo Wu wrote:
>
>> Hi there,
>> I'm trying to use List in a function. But it doesn't work. Here are
>> sample code not work: ---def
>> getResult():ls = []ls= ls.append(100)ls= ls.append(200)
>> return ls
>> reList = []reList = getResult()lsLength = len(reList)print '\n The length
>> of the list is:' + str(lsLength)-I
>> ran the above code, there is an error message: AttributeError: 'NoneType'
>> object has no attribute 'append'
>> But the code below not using list in a function
>> works.--### This works:ls =
>> []ls.append(100)ls.append(200)lsLength = len(ls)print '\n list length is: '
>> + str(lsLength)- Do you
>> know  the reason?
>> Thank you,Michelle
>>
>
> As you can (hopefully!) see above, this message is completely scrambled.
> Normally that means HTML. But the headers suggest it is plain text.
> Also, I see that Steve replied with a correctly formatted inclusion.
>
> Did anyone else get the scrambled version?
> And does anyone have any clues why I did?
>
> (Using Thunderbird v31.8 and normally not having major issues.)
>
> Same here, using Gmail and usually pretty happy with it.

Completely off-topic: why such an old version of TBird?  I have some
clients (the local office of a large multinational) who need to communicate
with corporate... but corporate IT hasn't dropped SSL 3.0 yet, so they
can't upgrade past version 33. (Every couple of weeks, despite my repeated
attempts to stop TBird from auto-updating, I find that they've got a new
version and can't connect.  Fortunately Mozilla hasn't changed their DB
format, so I can just re-install 33.)  Anyway, I know why _they_ are using
an old, less-secure version, but I'm curious why anybody else would be.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pip install in a virtualenv *without* internet?

2015-08-19 Thread Albert-Jan Roskam
> Date: Wed, 19 Aug 2015 09:49:43 -0700
> From: marc.tompk...@gmail.com
> To: tutor@python.org
> Subject: Re: [Tutor] pip install in a virtualenv *without* internet?
> 
> On Wed, Aug 19, 2015 at 9:18 AM, Alex Kleider  wrote:
> 
> > I guess if you 'never' have an internet connection what I'm trying to do
> > won't work,
> > but I'm addressing a different use case:  I have connectivity in some
> > environments
> > but would like to be able to do a pip install at times when there is no
> > connectivity.
> 
> 
> I'm wondering: does the solution absolutely have to involve pip?  I ask
> because I first started with Python right about the time pip was being
> created, and I didn't actually start using it until about a year ago  Prior
> to that, I downloaded my dependencies on my development machine, saved them
> to a flash drive, and wrote a script (well, technically a batch file - most
> of my clients use Windows) to automate offline installations.

The goal is most important: the installation should "just work", so "python 
setup.py install --user" for everything that is needed (in a .bat) might also 
work. 
 
Btw, today I found out about the pip option "--target" that allows you to 
install to an alternative path. Handy in case you (like me) don't necessarily 
have write access to site-packages. You do need to prepend it to PYTHONPATH. 
That's nicer than prepending to sys.path, IMHO.
 
 
> pip is certainly more convenient, and I'm quite grateful to its developers
> - but it's a relatively recent solution to the problem, and it's far from
> the only way to do things.

I agree, but there could also be too many options (do we still need 
easy_install?). As if the ideal situation is yet to come. I played a bit with 
conda install and it seems *very* convenient. Like a combination of setuptools, 
pip, pythonbrew and virtualenv/wrapper.  
 

 
  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] About using list in a function

2015-08-19 Thread Emile van Sebille

On 8/19/2015 11:20 AM, Marc Tompkins wrote:

(Every couple of weeks, despite my repeated
attempts to stop TBird from auto-updating, I find that they've got a new
version and can't connect.  Fortunately Mozilla hasn't changed their DB
format, so I can just re-install 33.)  Anyway, I know why _they_ are using
an old, less-secure version, but I'm curious why anybody else would be.


We're stuck on 29 due to some ECMAScript compatibility issues with 
existing internal servers.  We keep users from upgrading by configuring 
all user workstations to update only from an internal server where we 
have only approved compatible sources/packages.


Emile



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] About using list in a function

2015-08-19 Thread Marc Tompkins
On Wed, Aug 19, 2015 at 11:36 AM, Emile van Sebille  wrote:

> On 8/19/2015 11:20 AM, Marc Tompkins wrote:
>
>> (Every couple of weeks, despite my repeated
>> attempts to stop TBird from auto-updating, I find that they've got a new
>> version and can't connect.  Fortunately Mozilla hasn't changed their DB
>> format, so I can just re-install 33.)  Anyway, I know why _they_ are using
>> an old, less-secure version, but I'm curious why anybody else would be.
>>
>
> We're stuck on 29 due to some ECMAScript compatibility issues with
> existing internal servers.

Interesting.  There are eight million stories in the naked city; I wonder
how many stories there are behind old software versions?  =D


> We keep users from upgrading by configuring all user workstations to
> update only from an internal server where we have only approved compatible
> sources/packages.
>
> I only dream of having that sort of control.  Ah well.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OT: Searching Tutor Archives

2015-08-19 Thread Ben Finney
"Ken G."  writes:

> Could someone explain how to found such an article

At the end of every message to this forum you'll see this footer:

> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

That address, https://mail.python.org/mailman/listinfo/tutor>,
gives information about the forum, including where to find its archives.

You can browse the archives using a web search, for example
“site:mail.python.org/pipermail/tutor/ beachkidken” in DuckDuckGo
https://duckduckgo.com/?q=site%3Amail.python.org%2Fpipermail%2Ftutor%2F+beachkidken>.

-- 
 \  “If sharing a thing in no way diminishes it, it is not rightly |
  `\  owned if it is not shared.” —Augustine of Hippo (354–430 CE) |
_o__)  |
Ben Finney

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OT: Searching Tutor Archives

2015-08-19 Thread Ken G.



On 08/19/2015 06:09 PM, Ben Finney wrote:

"Ken G."  writes:


Could someone explain how to found such an article

At the end of every message to this forum you'll see this footer:


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

That address, https://mail.python.org/mailman/listinfo/tutor>,
gives information about the forum, including where to find its archives.

You can browse the archives using a web search, for example
“site:mail.python.org/pipermail/tutor/ beachkidken” in DuckDuckGo
https://duckduckgo.com/?q=site%3Amail.python.org%2Fpipermail%2Ftutor%2F+beachkidken>.

Wow, thanks. Just took a look and there are some thirty articles. Again, 
thanks.


Ken
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pip install in a virtualenv *without* internet?

2015-08-19 Thread Mike C. Fletcher

On 15-08-19 05:27 AM, Alex Kleider wrote:

On 2015-08-18 19:32, Mike C. Fletcher wrote:

To install without going out to the internet, you can use these 
arguments:


pip install --no-index --find-links=/path/to/download/directory 




For this to work, /path/to/download/directory would, I assume, first 
have to be populated.
I further assume that running wget from within that directory might do 
the trick.

Can you suggest the correct parameter(s) that need to be provided?
If anyone happens to know approximately how much file space would be 
required, that would be helpful.


I'm not sure what packages you are trying to install, so can't answer 
the space question, but the easiest command to populate the directory is 
pip on the internet-connected machine:


pip install --download=~/packages 

now copy that directory onto your USB key (or whatever) and take it to 
the offline machine. If you're planning to do a *lot* of installations, 
you can also use (once you install the wheel package):


pip wheel --no-index --find-links=/path/to/download 

to create fast-installing wheels from each of the dependencies (do that 
on the target machine so that all libraries match).


HTH,
Mike

--

  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Binary tree expressions

2015-08-19 Thread Quiles, Stephanie
Yes I got the exact same thing. I figured it out once I sent the email. It is 
easier to start the tree from the bottom and work your way up than the way I 
was doing it which was from the top down. Thanks for your reply Alex, it was 
still helpful to get someone else's interpretation 



Stephanie Quiles
Sent from my iPhone

> On Aug 19, 2015, at 2:41 AM, Alex Kleider  wrote:
> 
>> On 2015-08-18 07:36, Quiles, Stephanie wrote:
>> Hello!
>> Not sure if anyone can help me with these or not but here it goes...
>> I have to draw an expression tree for the following (a+b)*c-(d-e).
>> I believe that the last move would go first in the tree so in this
>> case you would subtract c after computing what d-e was. So my tree
>> would start out looking like this :
>> (-)
>> / \
>>   (+)  (-)
>>   / \   / \
>> Sorry not sure how to better draw that...
>> Is that correct so far? Where do I go from there if I am? The c is
>> really throwing me off here.
>> Here's the other tree:
>> ((a+b) *c-(d-e)) ^ (f+g)
>> So for this one you would do everything in the double parentheses
>> first so a+b and d-e then multiple the sum of a+b by c
>> Then I would subtract c from the sum of d-e.
>> Then I would look at the right side and add f+g
>> Finally I would calculate the sum of the left side  ^ of the sum of f+g.
>> So my tree would start with the ^ its children would be * (left child)
>> + (right child)
>> Is that right so far?
> 
> Here's how I interpret the issue:
> 
> (a+b)*c-(d-e)
> 
> 
>-
>  /   \
> * -
>/ \   / \
>   +   c d   e
>  / \
> a   b
> 
> ((a+b) *c-(d-e)) ^ (f+g)
> 
>^
> / \
>-   +
>  /   \/  \
> * -  fg
>/ \   / \
>   +   c d   e
>  / \
> a   b
> 
> If I understand the problem correctly, it seems to be a test of your ability 
> to understand precedence as in 'order of operation.'
> 
> Parentheses trump any of the following.
> ^ is highest of the ones involved here.
> * is next (as is division but that's not involved here)
> + and - are lowest.
> 
> Hope this helps.
> 
> 
> 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OT: Searching Tutor Archives

2015-08-19 Thread Alan Gauld

On 19/08/15 18:43, Ken G. wrote:


explain how to found such an article or kindly refresh my memory on how
to correct an original file without using a secondary file. Thanks.


Others have explained the search.
Let me just point out that the number of cases where you
want to do such a thing is vanishingly small.

It's incredibly unreliable and error prone and if you mess
it up you will probably screw up the source data such that
you can't recover it or re-run it. It's almost never the
best way to go about things - much better to fake it safely.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] About using list in a function

2015-08-19 Thread Alan Gauld

On 19/08/15 18:25, Alan Gauld wrote:

On 19/08/15 17:09, Michelle Meiduo Wu wrote:

Hi there,
I'm trying to use List in a function. But it doesn't work. Here are
sample code not work: ---def



As you can (hopefully!) see above, this message is completely scrambled.


OK, Looks like I wasn't alone.

Steven,
if you are still reading this can you confirm whether
you got a formatted version or manually unscrambled it?

Or can anyone explain why an apparently plain-text
message got mangled?

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OT: Searching Tutor Archives

2015-08-19 Thread Ken G.



On 08/19/2015 07:34 PM, Alan Gauld wrote:

On 19/08/15 18:43, Ken G. wrote:


explain how to found such an article or kindly refresh my memory on how
to correct an original file without using a secondary file. Thanks.


Others have explained the search.
Let me just point out that the number of cases where you
want to do such a thing is vanishingly small.

It's incredibly unreliable and error prone and if you mess
it up you will probably screw up the source data such that
you can't recover it or re-run it. It's almost never the
best way to go about things - much better to fake it safely.



Thanks, Alan. Your point is well taken.

Ken
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] About using list in a function

2015-08-19 Thread Laura Creighton
In a message of Thu, 20 Aug 2015 00:37:17 +0100, Alan Gauld writes:
>On 19/08/15 18:25, Alan Gauld wrote:
>> On 19/08/15 17:09, Michelle Meiduo Wu wrote:
>>> Hi there,
>>> I'm trying to use List in a function. But it doesn't work. Here are
>>> sample code not work: ---def
>
>> As you can (hopefully!) see above, this message is completely scrambled.
>
>OK, Looks like I wasn't alone.
>
>Steven,
>if you are still reading this can you confirm whether
>you got a formatted version or manually unscrambled it?
>
>Or can anyone explain why an apparently plain-text
>message got mangled?

Her mailer appears to have sent out a plain text message where the
whole message was one line with no newlines/returns.  So if her
mailer is set up to automatically remove them ...

Forums do this often but this is the first time I can recall seeing
this in email.

Laura

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Complications Take Two (Long) Frustrations.

2015-08-19 Thread Joseph Gulizia
Complicating a simple expression

Coding Exercise: Complication

Assume that the grader defines two variables A and B for you. Write a
program which prints out the value
min(A, B)

However, there is a catch: your program is not allowed to use the min
function. Instead, use max in a clever way to simulate min.

Hint, Method 1
What is max(-A, -B)?

Hint, Method 2
What is min(A, B)+max(A, B)?
--
Code that gave best results but didn't work for negative numbers...
--

Original = abs(max (-A, -B))
print (Original)

--
Did not pass tests. Please check details below and try again.
Results for test case 1 out of 5
Before running your code: We defined A equal to 35 and B equal to 45.

Program executed without crashing.
Program gave the following correct output:

35

Results for test case 2 out of 5
Before running your code: We defined A equal to 65 and B equal to 20.

Program executed without crashing.
Program gave the following correct output:

20

Results for test case 3 out of 5
Before running your code: We defined A equal to 48 and B equal to 63.

Program executed without crashing.
Program gave the following correct output:

48

Results for test case 4 out of 5
Before running your code: We defined A equal to 0 and B equal to 70.

Program executed without crashing.
Program gave the following correct output:

0

Results for test case 5 out of 5
Before running your code: We defined A equal to -64 and B equal to 0.

Program executed without crashing.
Program output:

64

Expected this correct output:

-64

Result of grading: Your output is not correct.


Spreadsheet examples:


  A   BMin(A, B)Max(-A,- B)

 10 55-   5
   5   105-   5
   9   129-   9
 12 99-   9
 22   37   22- 22
 37   22   22- 22
 45   68   45- 45
 68   45   45- 45
-  6   15-   66
-15 6-  15  15
-80-  65-  80  80
-65-  80-  80  80
 44-102-102 102
-44 102-  44   44


CS Assistant2 stated:

Using the absolute value of the numbers will cause problems with this
solution because sometimes the answer should be a negative number. However,
when you calculate the absolute value of a number, that result will always
be larger than any negative number.

I would suggest you go back to your original table, but include some values
for A and B that are negative numbers (A is negative, B is negative, A and
B are both negative). See what numbers you get for min(A, B) and max(-A,
-B) in those cases.

Think about ways, other than absolute value, that will allow you to convert
a negative number to a positive number and vice versa.

I hope this helps.

Sandy



CS Assistant1 stated:

Hi,

Gathering this much data is a very good start! The two hints give two
different approaches. So let me highlight the 4 most relevant columns:

A   BMin(A, B)Max(-A,- B)
10  5  5  -5
  510  5  -5
  912  9  -9
12  9  9  -9
223722 -22
372222 -22
456845 -45
684545 -45

What's the relationship between min(a, b), which you want but can't
directly call, and max(-a, -b), which you can compute? Feel free to ask if
another hint would help.

Best,
- Dave
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Test discovery not locating module to test

2015-08-19 Thread boB Stepp
W7 64-bit.  Py 3.4.3

unittest result:

E:\Projects\mcm>python -m unittest
E
==
ERROR: test.db.test_mcm_db_mgr (unittest.loader.ModuleImportFailure)
--
Traceback (most recent call last):
  File "C:\Python34\lib\unittest\case.py", line 58, in testPartExecutor
yield
  File "C:\Python34\lib\unittest\case.py", line 577, in run
testMethod()
  File "C:\Python34\lib\unittest\loader.py", line 32, in testFailure
raise exception
ImportError: Failed to import test module: test.db.test_mcm_db_mgr
Traceback (most recent call last):
  File "C:\Python34\lib\unittest\loader.py", line 312, in _find_tests
module = self._get_module_from_name(name)
  File "C:\Python34\lib\unittest\loader.py", line 290, in _get_module_from_name
__import__(name)
  File "E:\Projects\mcm\test\db\test_mcm_db_mgr.py", line 22, in 
import mcm_db_mgr
ImportError: No module named 'mcm_db_mgr'


--
Ran 1 test in 0.000s

FAILED (errors=1)

Relevant code in test_mcm_db_mgr.py:

import unittest

# import modules to be tested:
import mcm_db_mgr

class MCMDBMgrTestCase(unittest.TestCase):
def setUp(self):
# Insert setup code here...
pass

def test_open_mcm_db(self):
pass

def tearDown(self):
# Insert tear-down code here...
pass


I suspect that there is something wrong with my project structure.
Currently it is as follows:

Projects/
--mcm/
.git/
doc/
src/
--db/
__init__.py
mcm_db_mgr.py
--ui/
__init__.py
test/
--db/
__init__.py
test_mcm_db_mgr.py
--ui/
__init__.py
.gitignore
LICENSE.txt
README.txt

All __init__.py files are currently empty.  Alex had asked a question
very similar to this situation, and I thought I had understood the
answer Laura had given, but apparently I do not understand.  Where am
I going wrong this time?

TIA!

-- 
boB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Complications (Long) and Complicatiing Simple both Solved....

2015-08-19 Thread Joseph Gulizia
Original = -1 * max(-A, -B)
print (Original)

or

max = -max(-A,-B)
print(max)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor