(&quot;Duh! Code would be good,&quot; says newbie to himself.)<br><br>Here&#39;s an example from django which I am using, but I asked on this list since it seems more related to python than the web framework:<br><br>class Contact(models.Model):<br>
&nbsp;&nbsp;&nbsp; first_name = models.CharField(max_length=30, blank=True)<br>&nbsp;&nbsp;&nbsp; last_name = models.CharField(max_length=30, blank=True)<br>&nbsp;&nbsp;&nbsp; email = models.EmailField(blank=True)<br>&nbsp;&nbsp;&nbsp; phone = models.PhoneNumberField()<br><br>&nbsp;&nbsp;&nbsp; def __unicode__(self):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; l=[self.first_name, self.last_name, self.email, self.phone]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res=[]<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for x in l:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if x != &#39;&#39;:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res.append(x)<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return &#39;;&#39;.join(res)<br>
<br>Thanks!<br>Don<br><br><br><div class="gmail_quote">On Tue, Jul 8, 2008 at 11:56 AM, Kent Johnson &lt;<a href="mailto:kent37@tds.net">kent37@tds.net</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On Tue, Jul 8, 2008 at 9:14 AM, Don Jennings &lt;<a href="mailto:dfjennings@gmail.com">dfjennings@gmail.com</a>&gt; wrote:<br>
&gt; Hi, folks.<br>
&gt;<br>
&gt; From within a class, I want to return a string with data from non-empty<br>
&gt; variables in a class.<br>
&gt;<br>
&gt; I could create a list of all the variables and then iterate over them,<br>
&gt; dropping the ones which are empty, then join() and return them; however, I<br>
&gt; am guessing there is another way to get that list of variables or to<br>
&gt; accomplish my goal. Suggestions?<br>
<br>
</div></div>It would help to see code that works according to your suggestion.<br>
<br>
Where do the variables come from? Do you mean a list of all the<br>
attributes in an instance of a class? A list comprehension is often<br>
useful for creating a filtered list but I don&#39;t know if it will work<br>
for you without understanding better what you want to do.<br>
<font color="#888888"><br>
Kent<br>
</font></blockquote></div><br>