Re: [Tutor] more help with vitualenv

2012-04-27 Thread Steven D'Aprano

Ivor Surveyor wrote:


As suggested I visited the site virtualenv.  However I could not find 
the files for download and to install on my machine.

Could I please ask for further guidance on how to proceed?


Which site did you go to? "virtualenv" is not a site, it is a name. Precision 
of language is your friend -- when asking for help, please be precise and 
accurate in your descriptions.


When I google for "virtualenv", the very first link that comes up is this:

http://pypi.python.org/pypi/virtualenv

Is that the site you went to? If not, which site did you go to?

On that site, there is a link "Downloads" almost at the top of the page, 
immediately under the title:


virtualenv 1.7.1.2
Virtual Python Environment builder
Downloads


Clicking on the Downloads link takes you directly to the download area, where 
you can download a source tarball (.tar.gz file).



Or if you prefer, there are other instructions for installing it. Do you have 
pip installed on your computer? If so, you can run


pip install virtualenv

from the command line (NOT the Python interactive interpreter) to 
automatically install virtualenv.


Or if all else fails, the site above links directly to a single Python file 
which you can save to your hard drive.




--
Steven

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


Re: [Tutor] Pygame installation problems

2012-04-27 Thread Steven D'Aprano

Osemeka Osuagwu wrote:

Hi,
I started learning Python recently, having only very little programming
experience. I installed Pygame and tried using



How did you install it?

What operating system are you using?



import pygame


to test the installation and got the following error in return;

Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named pygame

Please does this mean I didn't install pygame correctly?


Yes.



--
Steven

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


Re: [Tutor] more help with vitualenv

2012-04-27 Thread Russell Smith
http://pypi.python.org/pypi/virtualenv/1.7.1.2

Read the page at the link above. You will find it.

On Friday, April 27, 2012, Ivor Surveyor wrote:

>
> As suggested I visited the site virtualenv.  However I could not find the
> files for download and to install on my machine.
> Could I please ask for further guidance on how to proceed?
>
> Ivor Surveyor
> isurve...@vianet.net.au
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] more help with vitualenv

2012-04-27 Thread Ivor Surveyor


As suggested I visited the site virtualenv.  However I could not find 
the files for download and to install on my machine.

Could I please ask for further guidance on how to proceed?

Ivor Surveyor
isurve...@vianet.net.au 


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


Re: [Tutor] Pygame installation problems

2012-04-27 Thread Russell Smith
I would google 'pygame download' and look at the first hit. You are right
to add the import but you need to download the files still.

On Friday, April 27, 2012, Osemeka Osuagwu wrote:

> Hi,
> I started learning Python recently, having only very little programming
> experience. I installed Pygame and tried using
>
> >import pygame
>
> to test the installation and got the following error in return;
>
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: No module named pygame
>
> Please does this mean I didn't install pygame correctly?
> How do I get it to work.
>
> Thanks,
>
> eMeka.
>
>
> --
> *We have enough for our need but not enough for our greed.*
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Pygame installation problems

2012-04-27 Thread Osemeka Osuagwu
Hi,
I started learning Python recently, having only very little programming
experience. I installed Pygame and tried using

>import pygame

to test the installation and got the following error in return;

Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named pygame

Please does this mean I didn't install pygame correctly?
How do I get it to work.

Thanks,

eMeka.


-- 
*We have enough for our need but not enough for our greed.*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] tkinter question

2012-04-27 Thread Alan Gauld

On 27/04/12 05:08, Khalid Al-Ghamdi wrote:


I've created this simple window with two widgets (a label and a button)
the button is supposed to  exit the root window, but the problem is it
doesn't seem to,
top=tkinter.Tk()

> ...

tkinter.mainloop()


try

  top.mainloop()

I'm not sure if that makes a difference but it is usual to call 
mainloop() on the root widget, calling at the module level may do 
something strange...


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

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


Re: [Tutor] Is there a way I can print the output of help(module)?

2012-04-27 Thread Leam Hall

On 04/27/2012 03:11 PM, Joel Goldstick wrote:


Hey Steven, thanks.

I guess I was a little lazy in my research.  I just discovered pydocs
before I read your response.  Its great!  This is great motivation to
write concise and complete docstrings.



Joel, I am constantly amazed by all the things Python offers. Enjoy the 
language!


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


Re: [Tutor] Is there a way I can print the output of help(module)?

2012-04-27 Thread Joel Goldstick
On Fri, Apr 27, 2012 at 3:03 PM, Steven D'Aprano  wrote:
> Joel Goldstick wrote:
>>
>> Its really nice how python displays help from the docstrings of
>> modules.  I'd like to save this info to a file, and I realize I've
>> never come across how to do that.
>
>
> At the command prompt (not the Python interactive interpreter!), run the
> pydoc command:
>
> pydoc math
>
> will display the documentation for help.
>
> pydoc -w math
>
> will write it to a file math.html.
>
>
> To do the same thing from the interactive interpreter, start with:
>
> import pydoc
>
> and go from there.
>
>
>
> --
> Steven
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

Hey Steven, thanks.

I guess I was a little lazy in my research.  I just discovered pydocs
before I read your response.  Its great!  This is great motivation to
write concise and complete docstrings.

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


Re: [Tutor] Is there a way I can print the output of help(module)?

2012-04-27 Thread Steven D'Aprano

Joel Goldstick wrote:

Its really nice how python displays help from the docstrings of
modules.  I'd like to save this info to a file, and I realize I've
never come across how to do that.


At the command prompt (not the Python interactive interpreter!), run the pydoc 
command:


pydoc math

will display the documentation for help.

pydoc -w math

will write it to a file math.html.


To do the same thing from the interactive interpreter, start with:

import pydoc

and go from there.



--
Steven

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


[Tutor] Is there a way I can print the output of help(module)?

2012-04-27 Thread Joel Goldstick
Its really nice how python displays help from the docstrings of
modules.  I'd like to save this info to a file, and I realize I've
never come across how to do that.



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


Re: [Tutor] PIL and converting an image to and from a string value

2012-04-27 Thread Russell Smith
What did you do?

On Friday, April 27, 2012, Chris Hare wrote:

>
> I got it figured out.
>
> On Apr 27, 2012, at 12:21 AM, Chris Hare wrote:
>
> >
> > Here is what I am trying to:
> >
> > the application user chooses an image file.  I want to store the image
> data in a field in a sqlite database.  My understanding from the reading I
> have done is that I have to convert the image data into a string , which I
> can then store in the database.  Additionally, I need to be able to take
> the stored image data and convert it back to an image  so I can display it
> in a canvas widget.  I am using the python imaging library
> >
> > I think I have the following parts correct:
> >
> > image = Image.open("cover.jpg")
> > image = image.resize((150,150),Image.ANTIALIAS)
> > png = image.tostring("PNG")
> >
> > I am taking the image data from the file, resizing the image, and then
> using the PNG coder to force it into a PNG format image and converting it
> to a string.
> >
> > I am stuck however, in figuring out how to take the string data and
> converting it back to an image that I can put into the canvas widget.
>  Either I am not finding a good explanation of how to do this or I am just
> not understanding what I am finding:-)
> >
> > Any ideas are appreciated!
> >
> > Thanks,
> > Chris
> >
> > ___
> > Tutor maillist  -  Tutor@python.org 
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
>
> ___
> Tutor maillist  -  Tutor@python.org 
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PIL and converting an image to and from a string value

2012-04-27 Thread Chris Hare

I got it figured out.  

On Apr 27, 2012, at 12:21 AM, Chris Hare wrote:

> 
> Here is what I am trying to:
> 
> the application user chooses an image file.  I want to store the image data 
> in a field in a sqlite database.  My understanding from the reading I have 
> done is that I have to convert the image data into a string , which I can 
> then store in the database.  Additionally, I need to be able to take the 
> stored image data and convert it back to an image  so I can display it in a 
> canvas widget.  I am using the python imaging library
> 
> I think I have the following parts correct:
> 
> image = Image.open("cover.jpg")
> image = image.resize((150,150),Image.ANTIALIAS)
> png = image.tostring("PNG")
> 
> I am taking the image data from the file, resizing the image, and then using 
> the PNG coder to force it into a PNG format image and converting it to a 
> string.
> 
> I am stuck however, in figuring out how to take the string data and 
> converting it back to an image that I can put into the canvas widget.  Either 
> I am not finding a good explanation of how to do this or I am just not 
> understanding what I am finding:-)
> 
> Any ideas are appreciated!
> 
> Thanks,
> Chris
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

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


Re: [Tutor] running an imported function

2012-04-27 Thread Steven D'Aprano

Cranky Frankie wrote:


Is there a way I can import clr.py and then run clr()?


The same way you import any other module and then call a function in that 
module. Don't be fooled by the function having the same name as the module.


import clr  # import the module
clr.clr()  # and call the fully-qualified name of the function


Or if you prefer:

from clr import clr  # import only the function
clr()


By the way, this may be a simpler way of clearing the screen:

def clr():
print("\n"*50)


This is probably better, although it's not guaranteed to work for all terminal 
types:


def clr():
print("\033[2J")


--
Steven

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


[Tutor] running an imported function

2012-04-27 Thread Cranky Frankie
This is in 3.2.2.

I wanted a function to clear the screen in IDLE. I have this in a
clr.py file in a directory in my path:

# Function to clear the IDLE screen by printing blank lines
def clr():
'''Function to clear the IDLE screen
   by printing 50 lines.'''
for i in range(1, 50):
print()


I can import it in IDLE no problem, but when I do this:

>>> clr()

I get

Traceback (most recent call last):
  File "", line 1, in 
clr()
TypeError: 'module' object is not callable



Is there a way I can import clr.py and then run clr()?


-- 
Frank L. "Cranky Frankie" Palmeri
Risible Riding Raconteur & Writer
“The problem with quotes on the Internet is that
it is often difficult to verify their authenticity.”
- Abraham Lincoln
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] virtualenv

2012-04-27 Thread Mark Lawrence

On 27/04/2012 07:49, Ivor Surveyor wrote:


I recently asked the question how can I get graphic.py to work on my
edition of Python which is 2.7.2
The problem was identified by Python tutor from my error messages as:


"What that error is telling you is that you have a version 8.5.9 oftcl,
but whatever you're trying to run is expecting _only_ 8.5.2

Sadly, probably, the way to "fix" this is by relaxing the requirements
of the thing you're trying to run. Alternatively, look at virtualenv to
set up an environment your code will work with."

My next question is where do I obtain an appropriate version of virtualenv?

My operating system is

OS Name Microsoft Windows 7 Professional
Version 6.1.7600 Build 7600 .

I would appreciate any help, kind regards


Ivor Surveyor
isurve...@vianet.net.au


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


Google for python virtualenv windows and it's the first hit.

--
Cheers.

Mark Lawrence.

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


Re: [Tutor] passing results between functions

2012-04-27 Thread Gerhardus Geldenhuis
Thank you for all the replies.

Having reread my question it is clear that it is not as well constructed as
it should be. I will have a bit more of a think with regards to what I want
to achieve and then if required rephrase my question.

Best Regards

On 25 April 2012 19:12, Alan Gauld  wrote:

> On 25/04/12 10:36, Gerhardus Geldenhuis wrote:
>
>> Hi
>> I wrote two functions which does different manipulations on text files.
>>
>> To start out with I passed the filename as a parameter and each function
>> opened the file and saved it.
>>
>
> I assume you mean it did some processing on the file data and then wrote
> it back?
>
>
>  I then realized I would need to do that twice if I wanted to use both my
>> functions on the same file. I the modified the functions to take the
>> input as follows:
>> myfunction(open(sys.argv[1]),'**ro'))
>>
>
> You mean it took a file object and a string?
>
>
>  It still wasn't good enough so I modified the function to return data as
>> follows:
>>
>> def myfunction
>> returndata = []
>> # some code
>> ...
>>   return ''.join(returndata)
>>
>
> So it returns a string.
>
>
>  so now I can do myfunction(mysecondfunction(**sys.argv[1],'ro'))
>> or mysecondfunction(myfunction(**sys.argv[1],'ro'))
>>
>
> Thats inconsistent since to one occasion you pass two arguments but on the
> other only one - the return value of the first function. And since the
> first parameter is expecting a file object the string will cause an error.
>
> But if you fixed the inconsistent data issue then the principle is fine.
>
>
>  so my question is philosophical. Is that the pythonian way or is there a
>> better/easier/more efficient way to pass data?
>>
>
> It depends what kind of data and what you mean by "pass".
> You could use objects to pass more complex types of data, or tuples to
> pass multiple values. Or you could write the values into a shared database.
> It just depends on what you want to do, whether the function needs to e
> thread-safe, how big the data is, etc.
>
>
>  To be honest I am still a bit stuck in how I did things when I
>> programmed in Delphi years ago and trying to make the paradigm shift and
>> understanding the data structures.
>>
>
> Thee is virtually no difference between Delphi and Python in the way
> functions (and objects) work. I'm not sure what paradigmn shift you have in
> mind. Delphi can't return tuples, but other than that the options and
> styles are pretty similar.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>



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