Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: TypeError: unsupported operand types for +: 'NoneType' and 'str'

Reply
Thread Tools

Re: TypeError: unsupported operand types for +: 'NoneType' and 'str'

 
 
Chris Rebert
Guest
Posts: n/a
 
      11-18-2009
On Tue, Nov 17, 2009 at 7:25 PM, <(E-Mail Removed)> wrote:
<snip>
> The error I get;
>
> File "myscript.py", Line 18, in ?
> projectpath = ourHome+"/etc/TEMPLATE"
> TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
>
> Python 2.4.3
>
> I've read were when passing a string to exec may need to end with a '\n'
>
> I've tried a few diff variations on the below line 18 w/o luck. *Any one
> mind helping out a bratha from anatha ... planet that is?
>
> line 18;
>
> projectpath = ourHome+"/etc/TEMPLATE"
>
> line 17;
> ourHome = os.environ.get('some_env')


>From the `os` docs:

os.environ
A mapping object representing the string environment.

>From the `dict` docs (`dict` being the built-in and prototypical mapping class):

D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.

>From this, I conclude that the environment variable `some_env` does

not exist for you, thus .get() returns None, thus causing an error
when you try and concatenate it with a string.

Solution: Either fix things so the environment variable does exist or
add code to handle the case of the environment variable not existing.

Cheers,
Chris
--
http://blog.rebertia.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TypeError: unsupported operand types for +: 'NoneType' and 'str' aurfalien@gmail.com Python 0 11-18-2009 03:25 AM
Unsupported operand types in if/else list comprehension Mike H Python 13 04-12-2009 08:00 AM
Python interpreter error: unsupported operand type(s) for -: 'tuple' and 'int' Rakesh Python 3 03-30-2005 02:36 PM
Re: TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' Brett C. Python 2 08-30-2004 10:25 PM
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' Martin Koekenberg Python 3 08-26-2004 12:04 PM



Advertisments