str().join() isn't working

kyosohma at gmail.com kyosohma at gmail.com
Mon Aug 20 14:34:55 EDT 2007


On Aug 20, 1:16 pm, "Robert Dailey" <rcdai... at gmail.com> wrote:
> here is a more realized example of the lists I'm trying to join:
>
> _user_includes = [
>         "../src",
>         "../resource",
>         "../inc",
>         "../src",
>         "../data",
>         "../gui",
>         "../script",
>         "../script/actions",
>         "../gui/dispatch",
>         "../gui/factories",
>         "../gui/frames",
>         "../gui/getters",
>         "../gui/localization",
>         "../gui/player",
>         "../gui/setters",
>         "../gui/utilities",
>         "../sis",
>         "../player",
>         "../platform/ngi",
>         "../../engine",
>         "../../engine/audio/NGI",
>         "../../engine/io",
>         "../../engine/io\NGI",
>         "../../engine/math",
>         "../../engine/math/fixed",
>         "../../engine/path/NGI",
>         "../../engine/text/NGI",
>         "../../engine/mem",
>         "../../engine/text",
>         "../../engine/observer",
>         "../../sdk/tiny_xml",
>         "../../sdk/zlib",
>         "../../sdk/lpng",
>         "../../sdk/IFDLib/Source/Precompile",
>         "../../sdk/IFDLib/Source/CoreLib",
>         "../../sdk/IFDLib/inc",
>         "../../sdk/IFDLib/Source/UtilLib",
>         "../../sdk/IFDLib/Source/GameLib",
>         "../../sdk/IFDlib/Source/OSLib/_NGI",
>         "../../sdk/stl-port/NGI",
>         "../../sdk/mini-boost/NGI",
>         "../../sdk/mini-boost/COMMON",
>         ]
>
> _system_includes = [
>         "../../../../../../Symbian/9.1/NGAGE_SDK_1.1/EPOC32/include",
>         "../../../../../../Symbian/9.1/NGAGE_SDK_1.1/EPOC32/include/osextensions/rga",
>         "../../../../../../Symbian/9.1/NGAGE_SDK_1.1/EPOC32/include/osextensions/stdapis",
>         "../../../../../../Symbian/9.1/NGAGE_SDK_1.1/EPOC32/include/osextensions/stdapis/stlport",
>         "../../../../../../Symbian/9.1/NGAGE_SDK_1.1/epoc32/include/variant"
>         ]
>
> On 8/20/07, Robert Dailey <rcdai... at gmail.com> wrote:
>
> > Hi,
>
> > First have a look at the following code:
>
> > In main.py:
> > -----------------------------------------------------------------------------------
> >     space = " "
>
> >     includes = space.join ( system._user_includes ) + " " + space.join(
> > system._system_includes )
>
> > In system.py:
> > -----------------------------------------------------------------------------------
> > _user_includes = [
> >     ]
>
> > _system_includes = [
> >     ]
>
> > The above does not work. The interpreter states: "TypeError: sequence item
> > 0: expected string, list found". I'm not sure what this means. Can anyone
> > help me figure out what I'm doing wrong? Thanks.
>
> > PS: I've also tried putting strings in the lists above just to make sure
> > that them being empty wasn't the problem. I got no different results.

When you use join, you join the items in the list with each other to
form one long string. In your statement, your script tries to
concatenate 2 lists to each other before it does the join, which is
impossible in Python. The "+" operator is only for addition and for
two or more strings.

See http://www.faqs.org/docs/diveintopython/odbchelper_join.html for
more information on joins.

Mike




More information about the Python-list mailing list