Friday, June 22, 2012

Re: Import error

Kurtis, Adrian and Daniel,

thank you so much for your help, it actually worked
I have programmed in java 70% of my life

Now I want to send sms to my users when they sign up
in the website. There is some package I have seen which looks
like it is from an email to the phone. Does it work with messages
from a website to a phone...

Emily

On Fri, Jun 22, 2012 at 5:58 PM, Kurtis Mullins <kurtis.mullins@gmail.com> wrote:
+1 on pulling the "random_password()" method out of the Class and setting it up as a module object.
I'd still suggest using this sort of an import statement on it, though:

from myproject.myapp.helpers import random_password

Where in this example you'd substitute your Project name with "myproject", the app name with "myapp" and the this particular python file with "helpers.py".


On Fri, Jun 22, 2012 at 10:54 AM, Daniel Roseman <daniel@roseman.org.uk> wrote:
On Friday, 22 June 2012 15:49:31 UTC+1, aid wrote:

Hi Emily,

On 22 Jun 2012, at 15:46, Emily wrote:

> This is the class I created...
>
> import string
> import random
>
> class Helpers:
>
>     def random_password():

Take random_password outside of the Helpers class and you should be OK.  On the import statement you need to refer to a 'top level object' within the imported file.  The only top level object you have is the class  Helpers - which it doens't look like you really need.

Cheers,

aid


+1. Python is not Java. Don't use a class unless you're encapsulating data.
--
DR. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/eV6jxgDm7cgJ.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment