Note that there are some explanatory texts on larger screens.

plurals
  1. POlist() doesn't work in appengine?
    primarykey
    data
    text
    <p>i am trying to use set function in appengine, to prepare a list with unique elements. I hit a snag when i wrote a python code which works fine in the python shell but not in appengine + django</p> <p>This is what i intend to do(ran this script in IDLE):</p> <pre><code>import re value=' r.dushaynth@gmail.com, dash@ben,, , abc@ac.com.edu ' value = value.lower() value = list(set(re.split('^\s*|\s*,+\s*|\s*$', value))) if (value[0] == ''): value.remove('') print value </code></pre> <p>The desired output is(got this output in IDLE):</p> <pre><code>['dash@ben', 'abc@ac.com.edu', 'r.dushaynth@gmail.com'] </code></pre> <p>Now when i do something equivalent in my views.py file in appengine :</p> <pre><code>import os import re import django from django.http import HttpResponse from django.shortcuts import render_to_response # host of other imports also there def add(request): value=' r.dushaynth@gmail.com, dash@ben,, , abc@ac.com.edu ' value = value.lower() value = list(set(re.split('^\s*|\s*,+\s*|\s*$', value))) if (value[0] == ''): value.remove('') return render_to_response('sc-actonform.html', { 'value': value, }) </code></pre> <p>I get this error while going to the appropriate page(pasting the traceback):</p> <pre><code>Traceback (most recent call last): File "G:\Dhushyanth\Google\google_appengine\lib\django\django\core\handlers\base.py" in get_response 77. response = callback(request, *callback_args, **callback_kwargs) File "G:\Dhushyanth\development\AppengineProjects\trunk_sanjhachoolha\sandbox\dushyanth\sanjhachoolha\views.py" in add 148. value = list(set(re.split('^\s*|\s*,+\s*|\s*$', value))) File "G:\Dhushyanth\development\AppengineProjects\trunk_sanjhachoolha\sandbox\dushyanth\sanjhachoolha\views.py" in list 208. return respond(request, None, 'sc-base', {'content': responseText}) File "G:\Dhushyanth\development\AppengineProjects\trunk_sanjhachoolha\sandbox\dushyanth\sanjhachoolha\views.py" in respond 115. params['sign_in'] = users.create_login_url(request.path) AttributeError at /sanjhachoolha/acton/add 'set' object has no attribute 'path' </code></pre> <p>on commenting out:</p> <pre><code>#value = list(set(re.split('^\s*|\s*,+\s*|\s*$', value))) </code></pre> <p>I get the desired output in the appropriate webpage:</p> <pre><code>r.dushaynth@gmail.com, dash@ben,, , abc@ac.com.edu </code></pre> <p>I am sure the list() is the root of my troubles. CAn anyone suggest why this is happening. Please also suggest alternatives. The aim is to remove duplicates from the list.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload