473,326 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to cat None

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')
Feb 15 '06 #1
4 1347
You can just surround the offending value with str(...). You should
probably be doing that anyway, because the value might be a number or
something else not stringish.

Feb 15 '06 #2
LittlePython wrote:
I am not too sure I know what None really means.

It means null, void or lack of value. It is not an empty string. You
can't add None to stings.
r = None
print r None print type(r)

<type 'NoneType'>
Feb 15 '06 #3
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')


Feb 15 '06 #4
Thx , I will give this a try.

<bo****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.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')

Feb 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: M-a-S | last post by:
Can anybody explain this: Python 2.3 (#46, Jul 29 2003, 18:54:32) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> >>> None = 3 <stdin>:1: SyntaxWarning:...
28
by: The Eternal Squire | last post by:
PEP: 336 Title: Make None Callable Version: $Revision: 1.1 $ Last-Modified: $Date: 2004/11/03 16:58:30 $ Author: Andrew McClelland Status: Draft Type: Standards Track Content-Type: text/plain...
6
by: Leif K-Brooks | last post by:
In Python 2.4, although None can't be directly assigned to, globals() can still be; however, that won't change the value of the expression "None" in ordinary statements. Except with the eval...
35
by: Steven Bethard | last post by:
I have lists containing values that are all either True, False or None, e.g.: etc. For a given list: * If all values are None, the function should return None.
16
by: gaudetteje | last post by:
I just read in the 'What's New in Python 2.4' document that the None data type was converted to a constant: http://python.org/doc/2.4/whatsnew/node15.html """ # None is now a constant; code...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
2
by: spifster | last post by:
Hello all, I am building a collapsable tree using Javascript with DOM in IE. In order to make collapsed cells disappear I have been hiding the text. The cells collapse but still leave borders...
8
by: micklee74 | last post by:
hi i wish to map None or "None" values to "". eg a = None b = None c = "None" map( <something> , if i in ("None",None) ]) I can't seem to find a way to put all values to "". Can anyone...
18
by: Alan G Isaac | last post by:
>>None >= 0 False True Explanation appreciated. Thanks, Alan Isaac
15
by: cssExp | last post by:
hello, Rather than going on a wild explanation on what's the the problem, it'll be much quicker and easier if i let you look at it yourself, so I'll post my page source (actual contents taken out,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.