How to cat None
LittlePython
LittlePython at lost.com
Wed Feb 15 19:22:18 EST 2006
Thx , I will give this a try.
<bonono at gmail.com> wrote in message
news:1139975928.700808.210850 at g47g2000cwa.googlegroups.com...
> Seems that what you want to do is to create a string in the form of :
>
> "55Init=Init\n55First=first\n55Last=Last\n55Alias=None"
>
> for each dictionary. If that is the case, may be you can try this :
>
> "\n".join("%s=%s" % x for x in user1.iteritems())
>
> Note that you cannot control the ordering of the keys when iterating a
> dict which may or may not be a concern for you.
>
> LittlePython wrote:
> > I found out the hard way that I can not cat None. I get an error. Is
there a
> > simple way to cat None without doing some kind of equation ( if this
then
> > that). Is there a isNone() somewhere. I am not too sure I know what None
> > really means.
> >
> > I include an example to show what I am talking about in case I am
alittle
> > confused.
> >
> >
> >
> >
> > from easygui import *
> > import string
> >
> > msgbox('Starting Program')
> >
> > thisfile = fileopenbox(msg='Choose the correct File', title='Matrix
Input
> > File')
> > input = file(thisfile,'r')
> >
> > header = string.split(string.strip(input.readline()),',')
> > header.extend(['55FirstName',
> > '55Intial','55LastName','55Alias',])
> >
> > all = input.readlines()
> > input.close
> > input = None
> > matrix = {}
> > for user in all:
> > user1 = string.split(string.strip(user),',')
> > user1.extend(['None']*4) <-------------------------I would like
to
> > None or better NULL this instead of string it
> > user1 = dict(zip(header,user1))
> > matrix[user1['OldNTLogon']] = user1
> >
> > mychoice = choicebox(choices=matrix.keys())
> > user1 = matrix[mychoice]
> >
> > alltogether = ''
> >
> > for KeyName in user1.keys():
> > if alltogether == '':
> > alltogether = KeyName + '=' + ' ' + user1.get(KeyName) + '\n'
> > else:
> > alltogether = alltogether + KeyName + '=' + user1.get(KeyName) +
> > '\n' <------- error 'can not cat None with a str' or something like
that
> >
> > msgbox(alltogether,'User Matrix for '+ mychoice )
> >
> > msgbox('The End')
>
More information about the Python-list
mailing list