getattr returns a function, so you want to be sure to call it before
calling split.

var2 = var().split('\\')[1]

    -keithb

Greg wrote:
> I tired doing that.  However I guess the end result for var is
> different for each way:
>
> var = getattr(self, 'get_%s_filename' % shape)
> var = self.get_round_filename()
>
> ////////////
>
> Because, after I assign var I do the following:
>
> var2 = var.split('\\')[1]
>
> ////////////////
>
> When I use 'var = getattr(self, 'get_%s_filename' % shape)' I then get
> the following error:
>
> AttributeError at /admin/plush/photo/add/
> 'function' object has no attribute 'split'
>
>
>
>
> On Nov 20, 9:37 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> > > self.create(50, 50, "round")
> >
> > > def create(self, wsize, hsize, shape):
> > >         var = self.get_shape_filename()
> > >         etc....
> >
> > > ///////////////
> >
> > > I get an error whenever it hits the line 'var =
> > > self.get_shape_filename()'.  The error is:
> >
> > > object has no attribute 'get_shape_filename'
> >
> > > ////////////
> >
> > > In the above case I'm sending 'round' to the method.  So it's supposed
> > > to be get_round_filename.
> >
> > Sounds like you're looking for the getattr() call in the standard
> > library...something like
> >
> >    get_filename = getattr(self,
> >      'get_%s_filename' % shape)
> >    var = get_filename()
> >
> > -tim- Hide quoted text -
> >
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to