<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[python] schnell strings mit bestimmtem präfix finden]]></title><description><![CDATA[<p>hi,</p>
<p>gibt es eine builtin python struktur, mit der ich schnell alle strings mit einem gegebenem präfix finden kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/245650/python-schnell-strings-mit-bestimmtem-präfix-finden</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 10:13:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/245650.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 16 Jul 2009 16:56:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [python] schnell strings mit bestimmtem präfix finden on Thu, 16 Jul 2009 16:56:03 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>gibt es eine builtin python struktur, mit der ich schnell alle strings mit einem gegebenem präfix finden kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1744430</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1744430</guid><dc:creator><![CDATA[pre-fix]]></dc:creator><pubDate>Thu, 16 Jul 2009 16:56:03 GMT</pubDate></item><item><title><![CDATA[Reply to [python] schnell strings mit bestimmtem präfix finden on Thu, 16 Jul 2009 17:47:22 GMT]]></title><description><![CDATA[<p>pre-fix schrieb:</p>
<blockquote>
<p>hi,</p>
<p>gibt es eine builtin python struktur, mit der ich schnell alle strings mit einem gegebenem präfix finden kann?</p>
</blockquote>
<p>string.startswith(&quot;deinpraefix&quot;)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1744447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1744447</guid><dc:creator><![CDATA[dfgdfgdfg]]></dc:creator><pubDate>Thu, 16 Jul 2009 17:47:22 GMT</pubDate></item><item><title><![CDATA[Reply to [python] schnell strings mit bestimmtem präfix finden on Thu, 16 Jul 2009 18:08:28 GMT]]></title><description><![CDATA[<p>dfgdfgdfg schrieb:</p>
<blockquote>
<p>pre-fix schrieb:</p>
<blockquote>
<p>hi,</p>
<p>gibt es eine builtin python struktur, mit der ich schnell alle strings mit einem gegebenem präfix finden kann?</p>
</blockquote>
<p>string.startswith(&quot;deinpraefix&quot;)</p>
</blockquote>
<p>ah jo, für <em>einen</em> string. aber wenn ich eine liste nehme</p>
<pre><code>for i in sequence:
   if i.startswith(prefix)
      do_foo_on_i(i)
</code></pre>
<p>ist das Omega(n). Wenn ich das in einen Baum packe, geht das sicher besser. Frage: was ist die beste Struktur dafür, und gibt es die in Python schon?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1744457</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1744457</guid><dc:creator><![CDATA[pre-fix]]></dc:creator><pubDate>Thu, 16 Jul 2009 18:08:28 GMT</pubDate></item><item><title><![CDATA[Reply to [python] schnell strings mit bestimmtem präfix finden on Fri, 17 Jul 2009 09:30:36 GMT]]></title><description><![CDATA[<p>Ja, dann mach es halt so. Dann kannst du die Präfixe in O(l) erfragen, mit l = Präfixlänge. Allerdings dürfte die Konstruktion dieser Struktur einiges kosten und es gibt auch kein geeignetes Builtin dafür.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1744689</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1744689</guid><dc:creator><![CDATA[suffix]]></dc:creator><pubDate>Fri, 17 Jul 2009 09:30:36 GMT</pubDate></item><item><title><![CDATA[Reply to [python] schnell strings mit bestimmtem präfix finden on Fri, 17 Jul 2009 18:50:06 GMT]]></title><description><![CDATA[<p>du könntest ein dict nehmen, welches die präfixes als keys hat und listen von strings mit den prefixes als values. an die liste mit den values kommst du dann noch mit .values() (vorsicht, sind dann listen in listen du brauchst also eine doppelte for schleife, ändert aber nichts an der laufzeit) und an die elemente kommst du dann mit dict[key] in O(1), also du kannst dann sowas machen wie results = map(do_foo_on_i, dict[prefix])</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1745007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1745007</guid><dc:creator><![CDATA[borg]]></dc:creator><pubDate>Fri, 17 Jul 2009 18:50:06 GMT</pubDate></item></channel></rss>