On Thu, 18 Feb 2010 14:52:29 -, nn wrote:
Wes James wrote:
I have been trying to create a list form a string. The string will be
a list (this is the contents will look like a list). i.e. "[]" or
"['a','b']"
The "[]" is simple since I can just check if value == "[]" then return
[]
Bu
In article ,
Wes James wrote:
>
>try:
>if value=3D=3D'[]' or value=3D=3D'':
> value=3D[]
>else:
> no_brackets =3D value[1:-1] # s.strip(' \t[]')
> c =3D csv.reader([no_brackets], quotechar=3D"'")
> value=3Dc.n
On Thu, Feb 18, 2010 at 2:56 PM, Wes James wrote:
>
> I get an error (when I take the "try" out):
>
> AttributeError: 'function' object has no attribute 'reader'
>
You have a function called "csv" that's defined after the import csv
statement is executed. That function has no attribute 'reader",
import csv
class IS_LIST():
def __init__(self, format='', error_message='must be a list!'):
self.format = format
self.error_message = error_message
def __call__(self, value):
try:
if value=='[]' or value=='':
value=[]
else:
On Thu, Feb 18, 2010 at 12:32 PM, Wes James wrote:
> On Thu, Feb 18, 2010 at 8:18 AM, Tim Chase
> wrote:
>> Wes James wrote:
>
>
>>
>> Just to add to the list of solutions I've seen, letting the built-in csv
>> module do the heavy lifting:
>>
>> >>> s = "['a','b']"
>> >>> import csv
>> >>> no
On Thu, Feb 18, 2010 at 8:18 AM, Tim Chase
wrote:
> Wes James wrote:
>
> Just to add to the list of solutions I've seen, letting the built-in csv
> module do the heavy lifting:
>
> >>> s = "['a','b']"
> >>> import csv
> >>> no_brackets = s[1:-1] # s.strip(' \t[]')
> >>> c = csv.reader([no_br
Wes James wrote:
I have been trying to create a list form a string. The string will be
a list (this is the contents will look like a list). i.e. "[]" or
"['a','b']"
The "[]" is simple since I can just check if value == "[]" then return []
But with "['a','b']" I have tried and get:
a="['a','b
Wes James wrote:
> I have been trying to create a list form a string. The string will be
> a list (this is the contents will look like a list). i.e. "[]" or
> "['a','b']"
>
> The "[]" is simple since I can just check if value == "[]" then return []
>
> But with "['a','b']" I have tried and get:
Wes James writes:
> I have been trying to create a list form a string. The string will be
> a list (this is the contents will look like a list). i.e. "[]" or
> "['a','b']"
Pulling back to ask about the larger problem: Are you trying to create
Python data structures from a serialised representa
Wes James gmail.com> writes:
>
> I have been trying to create a list form a string. The string will be
> a list (this is the contents will look like a list). i.e. "[]" or
> "['a','b']"
>
> The "[]" is simple since I can just check if value == "[]" then return []
>
> But with "['a','b']" I ha
On Thu, 18 Feb 2010 00:13:05 +, Rhodri James wrote:
> On Wed, 17 Feb 2010 23:48:38 -, Wes James
> wrote:
>
>> I have been trying to create a list form a string. The string will be
>> a list (this is the contents will look like a list). i.e. "[]" or
>> "['a','b']"
>
> If your string is
On Wed, 17 Feb 2010 23:48:38 -, Wes James wrote:
I have been trying to create a list form a string. The string will be
a list (this is the contents will look like a list). i.e. "[]" or
"['a','b']"
If your string is trusted (i.e. goes nowhere near a user), just eval() it.
--
Rhodri Jame
2010/2/18 Wes James :
> I have been trying to create a list form a string. The string will be
> a list (this is the contents will look like a list). i.e. "[]" or
> "['a','b']"
>
> The "[]" is simple since I can just check if value == "[]" then return []
>
> But with "['a','b']" I have tried and g
I have been trying to create a list form a string. The string will be
a list (this is the contents will look like a list). i.e. "[]" or
"['a','b']"
The "[]" is simple since I can just check if value == "[]" then return []
But with "['a','b']" I have tried and get:
a="['a','b']"
b=a[1:-1].spli
14 matches
Mail list logo