title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags list |
|---|---|---|---|---|---|---|---|---|---|
The origin of using # as a comment in Python? | 2,286,120 | <p>So I just had like this mental explosion dude! I was looking at my Python source code and was reading some comments and then I looked a the comments again. When I came across this:</p>
<pre><code>#!/usr/bin/env python
# A regular comment
</code></pre>
<p>Which made me wonder, was <code>#</code> chosen as the symbo... | 4 | 2010-02-18T03:32:41Z | 2,286,153 | <p>Using <code>#</code> for comments was happening before Python came around. The shebang (<code>#!/usr/bin/env python</code>) convention is almost as old as UNIX itself. The two are intertwined for many interpreted (aka shell) languages.</p>
<p>Might as well study up on the <a href="http://en.wikipedia.org/wiki/Sheb... | 6 | 2010-02-18T03:41:50Z | [
"python",
"linux",
"shell"
] |
The origin of using # as a comment in Python? | 2,286,120 | <p>So I just had like this mental explosion dude! I was looking at my Python source code and was reading some comments and then I looked a the comments again. When I came across this:</p>
<pre><code>#!/usr/bin/env python
# A regular comment
</code></pre>
<p>Which made me wonder, was <code>#</code> chosen as the symbo... | 4 | 2010-02-18T03:32:41Z | 2,286,262 | <h3>Very good, you are correct.</h3>
<p>This is known <a href="http://en.wikipedia.org/wiki/Shebang_%28Unix%29" rel="nofollow">as the shebang</a> or hash-bang. I suppose a scripting language could use any comment character it liked and allow #! on the first line as a comment, but it does seem easier to just make # be ... | 0 | 2010-02-18T04:21:09Z | [
"python",
"linux",
"shell"
] |
Python URL Characters | 2,286,188 | <p>I really new to Python and coding in general, but I have been making some good strides.</p>
<p>I am able to pull some data off of the web through an API, and the result should be a string. What I am seeing though, are some instances such as "& amp;"" and " &quot". (I modified the character sets so it would... | 2 | 2010-02-18T03:56:26Z | 2,286,199 | <p><a href="http://docs.python.org/library/xml.sax.utils.html" rel="nofollow">xml.sax.saxutils.unescape</a>(data[, entities]): Unescape '&amp', '&lt', and '&gt' in a string of data.</p>
<p>You can unescape other strings of data by passing a dictionary as the optional entities parameter. The keys and values... | 2 | 2010-02-18T04:02:11Z | [
"python",
"html",
"html-entities"
] |
Putting a message in the same line | 2,286,287 | <pre><code>import pythoncom, pyHook, logging, string
LOG_FILENAME = 'logfile.txt'
def OnKeyboardEvent(event):
print 'MessageName:',event.MessageName
print 'Time:',event.Time
print 'WindowName:',event.WindowName
print 'Ascii:', event.Ascii, chr(event.Ascii)
print 'Key:', event.Key
print '---'
... | 0 | 2010-02-18T04:26:40Z | 2,286,349 | <p>There doesn't seem to be any way to make <code>Logger.debug()</code> append messages to the same line. Since your log file format is so simple, why not just use a plain file object?</p>
<pre>
logger = open(LOG_FILENAME, 'a')
logger.write(k)
logger.close()
</pre>
| 0 | 2010-02-18T04:40:20Z | [
"python",
"logging"
] |
what this python code trying to do | 2,286,438 | <p>The following python code is to traverse a 2D grid of (c, g) in some special order, which is stored in "jobs" and "job_queue". But I am not sure which kind of order it is after trying to understand the code. Is someone able to tell about the order and give some explanation for the purpose of each function? Thanks an... | 1 | 2010-02-18T05:07:42Z | 2,290,188 | <p>Here is an example of <code>permute_sequence</code> in action:</p>
<pre><code>print permute_sequence(range(8))
# prints [4, 2, 6, 1, 5, 3, 7, 0]
print permute_sequence(range(12))
# prints [6, 3, 9, 1, 8, 5, 11, 0, 7, 4, 10, 2]
</code></pre>
<p>I'm not sure <em>why</em> it uses this order, because in <code>main</co... | 1 | 2010-02-18T16:24:00Z | [
"python",
"algorithm",
"search",
"machine-learning",
"libsvm"
] |
what this python code trying to do | 2,286,438 | <p>The following python code is to traverse a 2D grid of (c, g) in some special order, which is stored in "jobs" and "job_queue". But I am not sure which kind of order it is after trying to understand the code. Is someone able to tell about the order and give some explanation for the purpose of each function? Thanks an... | 1 | 2010-02-18T05:07:42Z | 2,290,235 | <p><code>permute_sequence</code> reorders a list of values so that the middle value is first, then the midpoint of each half, then the midpoints of the four remaining quarters, and so on. So <code>permute_sequence(range(1000))</code> starts out like this:</p>
<pre><code> [500, 250, 750, 125, 625, 375, ...]
</code><... | 2 | 2010-02-18T16:31:33Z | [
"python",
"algorithm",
"search",
"machine-learning",
"libsvm"
] |
Sending "Set-Cookie" in a Python HTTP server | 2,286,452 | <p>How do I send the "Set-Cookie" header when working with a <code>BaseHTTPServerRequestHandler</code>, and <code>Cookie</code>? <code>BaseCookie</code> and children don't provide a method to output the value to be passed into <code>send_header()</code>, and <code>*Cookie.output()</code> does not provide a HTTP line de... | 4 | 2010-02-18T05:11:38Z | 2,286,478 | <p>Use <code>C = http.cookie.SimpleCookie</code> to hold the cookies and then <code>C.output()</code> to create the headers for it.</p>
<p><a href="http://docs.python.org/3.1/library/http.cookies.html#example" rel="nofollow">Example here</a></p>
<p>The request handler has a <code>wfile</code> attribute, which is the ... | 3 | 2010-02-18T05:19:09Z | [
"python",
"http",
"cookies"
] |
How do I start GWT devmode on a particular port from the console? | 2,286,468 | <p>So, within the directory containing my GWT application, I can type in the console </p>
<blockquote>
<p>ant devmode</p>
</blockquote>
<p>And it will start up my GWT application as per usual. So far so good.</p>
<p>However, what if wish to specify the port as a dynamic argument when starting devmode. Something co... | 2 | 2010-02-18T05:17:04Z | 2,287,078 | <p>Passing an argument via ant can be done via the ant properties. The call would be:</p>
<pre><code>ant devmode -Dport=8821
</code></pre>
<p>In your ant file specify a property port. The default value will be overridden when you pass the argument via the command line:</p>
<pre><code><property name="port" value="... | 2 | 2010-02-18T08:06:50Z | [
"python",
"gwt",
"ant"
] |
Positional Comparisons in Python | 2,286,557 | <p><em>(Here's a sort of hypothetical situation for everybody. I'm more looking for directions rather than straight processes, but if you can provide them, awesome!)</em></p>
<p>So let's say we have a list of athletes, I'm going to use figure skaters since I'm knee deep in the Winter Olympics right now. (I'm throwing ... | 1 | 2010-02-18T05:40:57Z | 2,286,599 | <p>I would use the athlet name as key in your dicts. Then you can look for their position more easily. Something like:</p>
<pre><code>diff = {}
for (a, pos2) in after_free_skate.items():
pos1 = after_short_program[a]
diff[a] = pos2 - pos1
</code></pre>
<p>I hope it helps</p>
| 7 | 2010-02-18T05:52:23Z | [
"python",
"comparison"
] |
Positional Comparisons in Python | 2,286,557 | <p><em>(Here's a sort of hypothetical situation for everybody. I'm more looking for directions rather than straight processes, but if you can provide them, awesome!)</em></p>
<p>So let's say we have a list of athletes, I'm going to use figure skaters since I'm knee deep in the Winter Olympics right now. (I'm throwing ... | 1 | 2010-02-18T05:40:57Z | 2,286,608 | <p>This solution prints the results in the same order as the final placings.<br>
If the place has not changed (+0) is printed.<br>
If you wish to filter those out instead, simply put an <code>if diff:</code> before the print</p>
<pre><code>>>> after_short_program = [
... 'Evgeni Plushenko',
... 'Evan ... | 3 | 2010-02-18T05:54:11Z | [
"python",
"comparison"
] |
Positional Comparisons in Python | 2,286,557 | <p><em>(Here's a sort of hypothetical situation for everybody. I'm more looking for directions rather than straight processes, but if you can provide them, awesome!)</em></p>
<p>So let's say we have a list of athletes, I'm going to use figure skaters since I'm knee deep in the Winter Olympics right now. (I'm throwing ... | 1 | 2010-02-18T05:40:57Z | 2,286,612 | <p>One way would be to flip the keys and values, then take the difference, ie:</p>
<pre><code>for k, v in after_free_skate.items():
print 'k', v - after_short_program[k]
</code></pre>
| 1 | 2010-02-18T05:55:11Z | [
"python",
"comparison"
] |
Positional Comparisons in Python | 2,286,557 | <p><em>(Here's a sort of hypothetical situation for everybody. I'm more looking for directions rather than straight processes, but if you can provide them, awesome!)</em></p>
<p>So let's say we have a list of athletes, I'm going to use figure skaters since I'm knee deep in the Winter Olympics right now. (I'm throwing ... | 1 | 2010-02-18T05:40:57Z | 2,286,629 | <p>I would put the names as keys and the positions as values, with the positions as ints:</p>
<pre><code>after_short_program = {
'1': 'Evgeni Plushenko',
'2': 'Evan Lysacek',
'3': 'Daisuke Takahashi',
'4': 'Nobunari Oda',
'5': 'Stephane Lambiel'
}
after_free_skate = {
'1': 'Evan Lysacek',
... | 0 | 2010-02-18T06:00:17Z | [
"python",
"comparison"
] |
Positional Comparisons in Python | 2,286,557 | <p><em>(Here's a sort of hypothetical situation for everybody. I'm more looking for directions rather than straight processes, but if you can provide them, awesome!)</em></p>
<p>So let's say we have a list of athletes, I'm going to use figure skaters since I'm knee deep in the Winter Olympics right now. (I'm throwing ... | 1 | 2010-02-18T05:40:57Z | 2,286,661 | <p>I'd personally use lists as they are naturally suited to store 'positional' information... the following is a rather functional approach employing lists:</p>
<pre><code>###_* input data
after_short_program = [
'Evgeni Plushenko',
'Evan Lysacek',
'Daisuke Takahashi',
'Nobunari Oda',
'Stephane Lam... | 1 | 2010-02-18T06:10:25Z | [
"python",
"comparison"
] |
how do I filter values from XML file in python | 2,286,633 | <p>I have a basic grasp of XML and python and have been using minidom with some success. I have run into a situation where I am unable to get the values I want from an XML file. Here is the basic structure of the pre-existing file.</p>
<pre><code><localization>
<b n="Stats">
<l k="SomeStat1"... | 1 | 2010-02-18T06:01:28Z | 2,286,678 | <pre><code>#!/usr/bin/python
from xml.dom.minidom import parseString
xml = parseString("""<localization>
<b n="Stats">
<l k="SomeStat1">
<v>10</v>
</l>
<l k="SomeStat2">
<v>6</v>
</l>
</b>... | 2 | 2010-02-18T06:15:39Z | [
"python",
"xml"
] |
how do I filter values from XML file in python | 2,286,633 | <p>I have a basic grasp of XML and python and have been using minidom with some success. I have run into a situation where I am unable to get the values I want from an XML file. Here is the basic structure of the pre-existing file.</p>
<pre><code><localization>
<b n="Stats">
<l k="SomeStat1"... | 1 | 2010-02-18T06:01:28Z | 2,286,704 | <p>If you really only care about searching for an <code><l></code> tag with a specific "k" attribute and then getting its <code><v></code> tag (that's how I understood your question), you could do it with DOM:</p>
<pre><code>from xml.dom.minidom import parseString
xmlDoc = parseString("""<document goes... | 1 | 2010-02-18T06:20:08Z | [
"python",
"xml"
] |
how do I filter values from XML file in python | 2,286,633 | <p>I have a basic grasp of XML and python and have been using minidom with some success. I have run into a situation where I am unable to get the values I want from an XML file. Here is the basic structure of the pre-existing file.</p>
<pre><code><localization>
<b n="Stats">
<l k="SomeStat1"... | 1 | 2010-02-18T06:01:28Z | 2,286,723 | <pre><code>level = "Level"+raw_input("Enter level number: ")
content= open("xmlfile").read()
data= content.split("</localization>")
for item in data:
if "localization" in item:
s = item.split("</b>")
for i in s:
if """<b n="Levels">""" in i:
for c in i.sp... | 0 | 2010-02-18T06:25:24Z | [
"python",
"xml"
] |
how do I filter values from XML file in python | 2,286,633 | <p>I have a basic grasp of XML and python and have been using minidom with some success. I have run into a situation where I am unable to get the values I want from an XML file. Here is the basic structure of the pre-existing file.</p>
<pre><code><localization>
<b n="Stats">
<l k="SomeStat1"... | 1 | 2010-02-18T06:01:28Z | 2,287,609 | <p>You might consider using XPATH, a language for addressing parts of an xml document.</p>
<p>Here's the answer using <code>lxml.etree</code> and it's support for <code>xpath</code>.</p>
<pre><code>>>> data = """
... <localization>
... <b n="Stats">
... <l k="SomeStat1">
... ... | 3 | 2010-02-18T09:47:14Z | [
"python",
"xml"
] |
how do I filter values from XML file in python | 2,286,633 | <p>I have a basic grasp of XML and python and have been using minidom with some success. I have run into a situation where I am unable to get the values I want from an XML file. Here is the basic structure of the pre-existing file.</p>
<pre><code><localization>
<b n="Stats">
<l k="SomeStat1"... | 1 | 2010-02-18T06:01:28Z | 2,288,150 | <p>If you could use <a href="http://www.crummy.com/software/BeautifulSoup/documentation.html" rel="nofollow">BeautifulSoup</a> library (couldn't you?) you could end up with this dead-simple code:</p>
<pre><code>from BeautifulSoup import BeautifulStoneSoup
def get_it(xml, level_n):
soup = BeautifulStoneSoup(xml)
... | 0 | 2010-02-18T11:21:33Z | [
"python",
"xml"
] |
How can we use ms office communicator client exposed APIs in python, is that possible? | 2,286,790 | <p>I want to use ms office communicator client apis, and i wan to use those in python is it possible to do ?</p>
| 2 | 2010-02-18T06:48:02Z | 2,287,203 | <p>I don't know very well Ms Office communicator but if it exposes a COM interface, you shoudl be able to access it through the Mark Hammond python bindings for COM <a href="http://starship.python.net/crew/skippy/" rel="nofollow">http://starship.python.net/crew/skippy/</a></p>
<p>Otherwise, if it exposes a .NET API yo... | 0 | 2010-02-18T08:30:16Z | [
"python",
"api",
"office-communicator"
] |
How can we use ms office communicator client exposed APIs in python, is that possible? | 2,286,790 | <p>I want to use ms office communicator client apis, and i wan to use those in python is it possible to do ?</p>
| 2 | 2010-02-18T06:48:02Z | 2,777,185 | <p>There is an JSON API to access all office communicator functions via "office communicator web access". You can <a href="http://www.google.com/search?btnG=1&pws=0&q=Microsoft+Office+Communicator+Web+Access+AJAX+Service" rel="nofollow">download</a> a description for that API. But nobody has implemented a modul... | 1 | 2010-05-05T22:22:41Z | [
"python",
"api",
"office-communicator"
] |
How can we use ms office communicator client exposed APIs in python, is that possible? | 2,286,790 | <p>I want to use ms office communicator client apis, and i wan to use those in python is it possible to do ?</p>
| 2 | 2010-02-18T06:48:02Z | 3,754,769 | <pre>
>>> import win32com.client
>>> msg = win32com.client.Dispatch('Communicator.UIAutomation')
>>> msg.InstantMessage('user@domain.com')
</pre>
| 1 | 2010-09-20T19:21:58Z | [
"python",
"api",
"office-communicator"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 2,286,870 | <p>You use a hashtable to store currently discovered keys (access O(1)) and then loop through the array. If a character is in the hashtable, discard it. If it isn't add it to the hashtable and a result string.</p>
<p>Overall: O(n) time (and space).</p>
<p>The naive solution is to search for the character is the resul... | 18 | 2010-02-18T07:12:14Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 2,286,874 | <p>Keep an array of 256 "seen" booleans, one for each possible character.
Stream your string. If you haven't seen the character before, output it and set the "seen" flag for that character.</p>
| 2 | 2010-02-18T07:13:15Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 2,286,876 | <pre><code> string newString = new string("aaaaabbbbccccdddddd".ToCharArray().Distinct().ToArray());
</code></pre>
<p>or </p>
<pre><code> char[] characters = "aaaabbbccddd".ToCharArray();
string result = string.Empty ;
foreach (char c in characters)
{
... | 0 | 2010-02-18T07:13:40Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 2,287,008 | <p>In <strong>Python</strong></p>
<pre><code>>>> ''.join(set("aaaabbbccdbdbcd"))
'acbd'
</code></pre>
<p>If the order needs to be preserved</p>
<pre><code>>>> q="aaaabbbccdbdbcd" # this one is not
>>> ''.join(sorted(set(q),key=q.index)) # so efficient
'abcd'
</code></... | 3 | 2010-02-18T07:51:52Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 2,287,193 | <p>This closely related to the question: <a href="http://stackoverflow.com/questions/2279568/detecting-repetition-with-infinite-input">Detecting repetition with infinite input</a>.</p>
<p>The hashtable approach may not be optimal depending on your input. <strong>Hashtables have a certain amount of overhead</strong> (b... | 5 | 2010-02-18T08:28:02Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 2,287,303 | <p>In C++, you'd probably use an <code>std::set</code>:</p>
<pre><code>std::string input("aaaabbbccddd");
std::set<char> unique_chars(input.begin(), input.end());
</code></pre>
<p>In theory you could use <code>std::unordered_set</code> instead of <code>std::set</code>, which should give O(N) expected overall c... | 0 | 2010-02-18T08:48:51Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 2,330,568 | <p>You can sort the string and then remove the duplicate characters.</p>
<pre><code>#include <iostream>
#include <algorithm>
#include <string>
int main()
{
std::string s = "aaaabbbccdbdbcd";
std::sort(s.begin(), s.end());
s.erase(std::unique(s.begin(), s.end()), s.end());
std::cout... | 0 | 2010-02-24T23:48:41Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 2,330,671 | <p>This sounds like a perfect use for automata.</p>
| 0 | 2010-02-25T00:09:38Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 2,330,733 | <p>C++ - O(n) time, O(1) space, and the output is sorted.</p>
<pre><code>std::string characters = "aaaabbbccddd";
std::vector<bool> seen(std::numeric_limits<char>::max()-std::numeric_limits<char>::min());
for(std::string::iterator it = characters.begin(), endIt = characters.end(); it != endIt; ++it)... | 0 | 2010-02-25T00:26:37Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 5,887,466 | <p>in C this is how i did it: O(n) in time since we only have one for loop. </p>
<pre><code>void remDup(char *str)
{
int flags[256] = { 0 };
for(int i=0; i<(int)strlen(str); i++) {
if( flags[str[i]] == 0 )
printf("%c", str[i]);
flags[str[i]] = 1;
}
}
</code></pre>
| 0 | 2011-05-04T17:33:09Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 11,298,960 | <p>PHP algorythm - O(n):</p>
<pre class="lang-php prettyprint-override"><code>function remove_duplicate_chars($str) {
if (2 > $len = strlen($str)) {
return $str;
}
$flags = array_fill(0,256,false);
$flags[ord($str[0])]=true;
$j = 1;
for ($i=1; $i<$len; $i++) {
$ord = ord($... | 1 | 2012-07-02T18:13:56Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 12,658,442 | <pre><code>import java.util.HashSet;
public class RemoveDup {
public static String Duplicate()
{
HashSet h = new HashSet();
String value = new String("aaaabbbccdbdbcd");
String finalString = new String();
int stringLength = value.length();
for (int i=0;i<=stringLengt... | 0 | 2012-09-30T03:41:30Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 15,709,852 | <p>get a list of first 26 prime numbers..
Now you can map each character (a,b,c,d etc) to each prime number.. (alphabetically say a=2, b=3, c=5 etc.. or depending upon relative abundance of the characters like most frequently used letter with lower prime say e=2, r=3, a=5 etc)...store that mapping in an integer array
i... | 0 | 2013-03-29T19:06:49Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 17,643,412 | <pre><code>#include <iostream>
#include<string>
using namespace std;
#define MAX_SIZE 256
int main()
{
bool arr[MAX_SIZE] = {false};
string s;
cin>>s;
int k = 0;
for(int i = 0; i < s.length(); i++)
{
while(arr[s[i]] == true && i < s.length())
{
... | 1 | 2013-07-14T20:24:54Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 21,584,795 | <p>You Can Do this in O(n) only if you are using HashTable. Code is given below
Please Note- It is assumed that number of possible characters in input string are
256</p>
<pre><code>void removeDuplicates(char *str)
{
int len = strlen(str); //Gets the length of the String
int count[256] = {0}; //initializes all ele... | 2 | 2014-02-05T17:56:26Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 27,192,463 | <pre><code>int main()
{
std::string s = "aaacabbbccdbdbcd";
std::set<char> set1;
set1.insert(s.begin(), s.end());
for(set<char>::iterator it = set1.begin(); it!= set1.end(); ++it)
std::cout << *it;
return 0;
}
std::set takes O(log n) to insert
</code></pre>
| 0 | 2014-11-28T16:11:13Z | [
"python",
"algorithm"
] |
Removing duplicates in a string in Python | 2,286,860 | <p>What is an efficient algorithm to removing all duplicates in a string? </p>
<p>For example : <strong>aaaabbbccdbdbcd</strong></p>
<p>Required result: <strong>abcd</strong></p>
| 3 | 2010-02-18T07:09:36Z | 39,432,325 | <p>O(n) solution: </p>
<pre><code>#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void removeDuplicates(char *);
void removeDuplicates(char *inp)
{
int i=0, j=0, FLAG=0, repeat=0;
while(inp[i]!='\0')
{
if(FLAG==1)
{
inp[i-repeat]=inp[i];
... | 0 | 2016-09-11T02:31:55Z | [
"python",
"algorithm"
] |
How can I add a Picture to a QWidget in PyQt4 | 2,286,864 | <p>How can I add or import a picture to a <code>QWidget</code>? I have found a clue.
I can add a <code>Label</code> and add a <code>Picture</code> in that label. I need the arguments
for the <code>QPicture()</code>. The probable I can use is, <code>QLabel.setPicture(self.QPicture)</code>.</p>
| 12 | 2010-02-18T07:11:01Z | 2,286,888 | <p><code>QPicture</code> is not what you want. <code>QPicture</code> records and replays <code>QPainter</code> commands. What you want is <code>QPixmap</code>. Give a filename to the <code>QPixmap</code> constructor, and set this pixmap to the label using <code>QLabel.setPixmap()</code>.</p>
<p>An implementation examp... | 9 | 2010-02-18T07:18:15Z | [
"python",
"pyqt4"
] |
How can I add a Picture to a QWidget in PyQt4 | 2,286,864 | <p>How can I add or import a picture to a <code>QWidget</code>? I have found a clue.
I can add a <code>Label</code> and add a <code>Picture</code> in that label. I need the arguments
for the <code>QPicture()</code>. The probable I can use is, <code>QLabel.setPicture(self.QPicture)</code>.</p>
| 12 | 2010-02-18T07:11:01Z | 2,308,718 | <p>Here is some code that does what you and @erelender described:</p>
<pre><code>import os,sys
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
window = QtGui.QMainWindow()
window.setGeometry(0, 0, 400, 200)
pic = QtGui.QLabel(window)
pic.setGeometry(10, 10, 400, 100)
#use full ABSOLUTE path to the image, ... | 16 | 2010-02-22T04:02:48Z | [
"python",
"pyqt4"
] |
Recursive splitting of path name (in Python)? | 2,286,948 | <p>I feel that there is (should be?) a Python function out there that recursively splits a path string into its constituent files and directories (beyond basename and dirname). I've written one but since I use Python for shell-scripting on 5+ computers, I was hoping for something from the standard library or simpler th... | 2 | 2010-02-18T07:33:47Z | 2,286,972 | <pre><code>path='main/sub1/sub2/sub3/file'
path.split(os.path.sep)
</code></pre>
| 0 | 2010-02-18T07:38:27Z | [
"python",
"shell"
] |
Recursive splitting of path name (in Python)? | 2,286,948 | <p>I feel that there is (should be?) a Python function out there that recursively splits a path string into its constituent files and directories (beyond basename and dirname). I've written one but since I use Python for shell-scripting on 5+ computers, I was hoping for something from the standard library or simpler th... | 2 | 2010-02-18T07:33:47Z | 2,287,980 | <p><strong>UPDATE: After all the mucking about with <code>altsep</code>, the currently selected answer doesn't even split on backslashes.</strong></p>
<pre><code>>>> import re, os.path
>>> seps = os.path.sep
>>> if os.path.altsep:
... seps += os.path.altsep
...
>>> seps
'\\/'
>... | 3 | 2010-02-18T10:53:49Z | [
"python",
"shell"
] |
Recursive splitting of path name (in Python)? | 2,286,948 | <p>I feel that there is (should be?) a Python function out there that recursively splits a path string into its constituent files and directories (beyond basename and dirname). I've written one but since I use Python for shell-scripting on 5+ computers, I was hoping for something from the standard library or simpler th... | 2 | 2010-02-18T07:33:47Z | 30,029,044 | <p>use this:</p>
<pre><code>import os
def recSplitPath(path):
elements = []
while ((path != '/') and (path != '')):
path, tail = os.path.split(path)
elements.insert(0,tail)
return elements
</code></pre>
<p>This turns <code>/for/bar/whatever</code> into <code>['for','bar','whatever]</code><... | 1 | 2015-05-04T11:30:09Z | [
"python",
"shell"
] |
Python : updating values in a dictionary | 2,287,061 | <p>I have the following dictionary -></p>
<pre><code>key : (time,edge_list)
</code></pre>
<p>Now I want to increment all time values by 1. How do I do that?</p>
<pre><code>dict_list = dict(key:(time+1,edge_list) for key:(time,edge_list) in dict_list)
</code></pre>
| 3 | 2010-02-18T08:04:54Z | 2,287,104 | <pre><code>dict((key, (time + 1, edge_list)) for (key, (time, edge_list)) in somedict.iteritems())
</code></pre>
| 7 | 2010-02-18T08:12:31Z | [
"python"
] |
Python : updating values in a dictionary | 2,287,061 | <p>I have the following dictionary -></p>
<pre><code>key : (time,edge_list)
</code></pre>
<p>Now I want to increment all time values by 1. How do I do that?</p>
<pre><code>dict_list = dict(key:(time+1,edge_list) for key:(time,edge_list) in dict_list)
</code></pre>
| 3 | 2010-02-18T08:04:54Z | 2,287,124 | <pre><code>>>> d={"key" : (100,"edge_list")}
>>> for i,(time,edge_list) in d.items():
... d[i] = time+1, edge_list
...
>>> d
{'key': (101, 'edge_list')}
</code></pre>
| 8 | 2010-02-18T08:16:08Z | [
"python"
] |
How to do I integrate a 304 in Django? | 2,287,387 | <p>When a user requests the same page, with the same data...I'd like Django to return a 304, so that the browser doesn't have to load the page all over again.</p>
<p>I'm new to this. How can this be done?</p>
<p>Thanks.</p>
| 5 | 2010-02-18T09:07:09Z | 2,287,409 | <p>There's extensive description in Django documentation: <a href="https://docs.djangoproject.com/en/1.10/topics/conditional-view-processing/" rel="nofollow">Conditional view processing</a></p>
<p>Following tools are particularly useful:</p>
<ol>
<li><code>@last_modified</code> and <code>@etag</code> view decorators.... | 11 | 2010-02-18T09:10:50Z | [
"python",
"django",
"header",
"http-status-code-304"
] |
How to do I integrate a 304 in Django? | 2,287,387 | <p>When a user requests the same page, with the same data...I'd like Django to return a 304, so that the browser doesn't have to load the page all over again.</p>
<p>I'm new to this. How can this be done?</p>
<p>Thanks.</p>
| 5 | 2010-02-18T09:07:09Z | 2,287,498 | <p>You could look into Django's <a href="http://docs.djangoproject.com/en/dev/topics/cache/">caching system</a>, or if you can easily check if the user is requesting the same data, you can return a <code>HttpResponseNotModified()</code> - this returns a 304. Check out the docs <a href="http://docs.djangoproject.com/en/... | 6 | 2010-02-18T09:26:37Z | [
"python",
"django",
"header",
"http-status-code-304"
] |
Mercurial installation issue | 2,287,876 | <p>We've installed mercurial 1.4.1 and python 2.6.2 on a solaris 8 box. Now some hg commands work as expected, others fail.</p>
<p>I was able to initialize a repository (<code>hg init</code>) and add a file (<code>hg add</code>) but the committing (<code>hg commit</code>) leads to an error message:</p>
<pre><code>abo... | 1 | 2010-02-18T10:33:21Z | 3,616,399 | <p>You need to install the zlib library for your system (<code>libz.so</code>).</p>
| 0 | 2010-09-01T08:54:43Z | [
"python",
"mercurial",
"solaris"
] |
Mercurial installation issue | 2,287,876 | <p>We've installed mercurial 1.4.1 and python 2.6.2 on a solaris 8 box. Now some hg commands work as expected, others fail.</p>
<p>I was able to initialize a repository (<code>hg init</code>) and add a file (<code>hg add</code>) but the committing (<code>hg commit</code>) leads to an error message:</p>
<pre><code>abo... | 1 | 2010-02-18T10:33:21Z | 11,532,301 | <p>Check your <code>LD_LIBRARY_PATH</code> settings. </p>
<p>If it is pulling libz from an odd place you will need to fix it so that it is pulling from <code>/pkg/local/lib</code> first</p>
<p>I was seeing this:</p>
<pre><code>ldd /pkg/local/lib/python2.7/lib-dynload/zlib.so
libz.so => /import/wgs/l... | 0 | 2012-07-17T23:31:16Z | [
"python",
"mercurial",
"solaris"
] |
C++ - How to read Unicode characters( Hindi Script for e.g. ) using C++ or is there a better Way through some other programming language? | 2,287,962 | <p>I have a hindi script file like this:</p>
<pre><code>3. à¤à¤¾à¤°à¤¤ à¤à¤¾ à¤à¤¤à¤¿à¤¹à¤¾à¤¸ à¤à¤¾à¤«à¥ समà¥à¤¦à¥à¤§ à¤à¤µà¤ विसà¥à¤¤à¥à¤¤ हà¥à¥¤
</code></pre>
<p>I have to write a program which adds a position to each and every word in each sentence.
Thus the numbering for every line for a... | 6 | 2010-02-18T10:51:32Z | 2,287,993 | <p>Take a look at <a href="http://site.icu-project.org/" rel="nofollow">http://site.icu-project.org/</a>, a C++ library to process unicode strings.</p>
| 3 | 2010-02-18T10:55:58Z | [
"c++",
"python",
"perl",
"utf-8",
"nlp"
] |
C++ - How to read Unicode characters( Hindi Script for e.g. ) using C++ or is there a better Way through some other programming language? | 2,287,962 | <p>I have a hindi script file like this:</p>
<pre><code>3. à¤à¤¾à¤°à¤¤ à¤à¤¾ à¤à¤¤à¤¿à¤¹à¤¾à¤¸ à¤à¤¾à¤«à¥ समà¥à¤¦à¥à¤§ à¤à¤µà¤ विसà¥à¤¤à¥à¤¤ हà¥à¥¤
</code></pre>
<p>I have to write a program which adds a position to each and every word in each sentence.
Thus the numbering for every line for a... | 6 | 2010-02-18T10:51:32Z | 2,288,015 | <p>If you are working in C++ and decide that UTF-8 is a viable encoding for your application you could look at <a href="http://utfcpp.sourceforge.net/" rel="nofollow">utfcpp</a> which is a library that provides many equivalents for types found in the stdlib (such as streams and string processing functions) but abstract... | 6 | 2010-02-18T10:59:19Z | [
"c++",
"python",
"perl",
"utf-8",
"nlp"
] |
C++ - How to read Unicode characters( Hindi Script for e.g. ) using C++ or is there a better Way through some other programming language? | 2,287,962 | <p>I have a hindi script file like this:</p>
<pre><code>3. à¤à¤¾à¤°à¤¤ à¤à¤¾ à¤à¤¤à¤¿à¤¹à¤¾à¤¸ à¤à¤¾à¤«à¥ समà¥à¤¦à¥à¤§ à¤à¤µà¤ विसà¥à¤¤à¥à¤¤ हà¥à¥¤
</code></pre>
<p>I have to write a program which adds a position to each and every word in each sentence.
Thus the numbering for every line for a... | 6 | 2010-02-18T10:51:32Z | 2,288,540 | <p>The easiest way to do the processing is to get your input into a <code>std::wstring</code> (which is logically an array of <code>wchar_t</code>) Now, you still won't have "characters" because that concept is a bit more complex in Hindi. You will however have substrings seperated by <code>L' '</code>, and the L'।' ... | 1 | 2010-02-18T12:27:58Z | [
"c++",
"python",
"perl",
"utf-8",
"nlp"
] |
C++ - How to read Unicode characters( Hindi Script for e.g. ) using C++ or is there a better Way through some other programming language? | 2,287,962 | <p>I have a hindi script file like this:</p>
<pre><code>3. à¤à¤¾à¤°à¤¤ à¤à¤¾ à¤à¤¤à¤¿à¤¹à¤¾à¤¸ à¤à¤¾à¤«à¥ समà¥à¤¦à¥à¤§ à¤à¤µà¤ विसà¥à¤¤à¥à¤¤ हà¥à¥¤
</code></pre>
<p>I have to write a program which adds a position to each and every word in each sentence.
Thus the numbering for every line for a... | 6 | 2010-02-18T10:51:32Z | 2,288,734 | <p>The first thing to do is determine whether or not your input is in UNICODE. Do this by attempting to read your input as UNICODE and see if the results are garbled.</p>
<pre><code>FILE * fp = _wfopen( L"fname",L"r" );
wchar_t buf[1000];
while( fgetws(buf,999, fp ) ) {
fwprintf(L"%s",buf);
}
</code></pre>
<p>... | 1 | 2010-02-18T13:02:22Z | [
"c++",
"python",
"perl",
"utf-8",
"nlp"
] |
C++ - How to read Unicode characters( Hindi Script for e.g. ) using C++ or is there a better Way through some other programming language? | 2,287,962 | <p>I have a hindi script file like this:</p>
<pre><code>3. à¤à¤¾à¤°à¤¤ à¤à¤¾ à¤à¤¤à¤¿à¤¹à¤¾à¤¸ à¤à¤¾à¤«à¥ समà¥à¤¦à¥à¤§ à¤à¤µà¤ विसà¥à¤¤à¥à¤¤ हà¥à¥¤
</code></pre>
<p>I have to write a program which adds a position to each and every word in each sentence.
Thus the numbering for every line for a... | 6 | 2010-02-18T10:51:32Z | 2,288,897 | <p>I would seriously suggest that you'd use Python for an applicatin like this.
It will lift the burden of decoding the strigns (not to mention allocating memory for them and the like). You will be free to concentrate on your problem, instead of problems of the language.</p>
<p>For example, if the sentence above is co... | 2 | 2010-02-18T13:33:38Z | [
"c++",
"python",
"perl",
"utf-8",
"nlp"
] |
C++ - How to read Unicode characters( Hindi Script for e.g. ) using C++ or is there a better Way through some other programming language? | 2,287,962 | <p>I have a hindi script file like this:</p>
<pre><code>3. à¤à¤¾à¤°à¤¤ à¤à¤¾ à¤à¤¤à¤¿à¤¹à¤¾à¤¸ à¤à¤¾à¤«à¥ समà¥à¤¦à¥à¤§ à¤à¤µà¤ विसà¥à¤¤à¥à¤¤ हà¥à¥¤
</code></pre>
<p>I have to write a program which adds a position to each and every word in each sentence.
Thus the numbering for every line for a... | 6 | 2010-02-18T10:51:32Z | 2,288,959 | <p><a href="http://site.icu-project.org/" rel="nofollow">ICU - International Components for Unicode</a> is IBM supported C++ library that is starting to become a standard for handling of characters of all languages. I see more and more projects using it. It does the job really well. Here are the features (copy/pasted f... | 4 | 2010-02-18T13:43:50Z | [
"c++",
"python",
"perl",
"utf-8",
"nlp"
] |
C++ - How to read Unicode characters( Hindi Script for e.g. ) using C++ or is there a better Way through some other programming language? | 2,287,962 | <p>I have a hindi script file like this:</p>
<pre><code>3. à¤à¤¾à¤°à¤¤ à¤à¤¾ à¤à¤¤à¤¿à¤¹à¤¾à¤¸ à¤à¤¾à¤«à¥ समà¥à¤¦à¥à¤§ à¤à¤µà¤ विसà¥à¤¤à¥à¤¤ हà¥à¥¤
</code></pre>
<p>I have to write a program which adds a position to each and every word in each sentence.
Thus the numbering for every line for a... | 6 | 2010-02-18T10:51:32Z | 2,289,918 | <p>Wow, already 6 answers and not a single one actually does what <strong>mgj</strong> wanted. <strong>jkp</strong> comes close, but then drops the ball by deleting the daá¹á¸a.</p>
<p>Perl to the rescue. Less code, fewer bugs.</p>
<pre><code>use utf8; use strict; use warnings;
use Encode qw(decode);
my $index;
joi... | 7 | 2010-02-18T15:49:13Z | [
"c++",
"python",
"perl",
"utf-8",
"nlp"
] |
Trouble using PIL with Google Appengine SDK | 2,287,966 | <p>I have a Windows Server 2008 R2 (64bits) machine on which I wanted to develop a google AppEngine app.</p>
<p>So I installed Python 2.5.4 from python.org (because the Google SDK said I needed 2.5 and 2.5.6 didn't have any MSI's)
Then I installed PIL from <a href="http://www.pythonware.com/products/pil/" rel="nofoll... | 2 | 2010-02-18T10:52:04Z | 2,292,301 | <p>I guess the PIL is not supported in App Engine. There are currently 629 persons that have flagged <a href="http://code.google.com/p/googleappengine/issues/detail?id=38" rel="nofollow">this issue</a> to ask for the Python Image Library (PIL) (it's the fifth most starred issue for App Engine) and I can only encourage ... | 0 | 2010-02-18T21:24:15Z | [
"python",
"google-app-engine",
"windows-server-2008",
"python-imaging-library"
] |
Trouble using PIL with Google Appengine SDK | 2,287,966 | <p>I have a Windows Server 2008 R2 (64bits) machine on which I wanted to develop a google AppEngine app.</p>
<p>So I installed Python 2.5.4 from python.org (because the Google SDK said I needed 2.5 and 2.5.6 didn't have any MSI's)
Then I installed PIL from <a href="http://www.pythonware.com/products/pil/" rel="nofoll... | 2 | 2010-02-18T10:52:04Z | 5,364,723 | <p>This happens when Python can't find ICCProfile module.
Apperently when using trough GAE instead of an ImportError the importer throws a SystemError, and the function fails.
What i did was to change line 567 in ...\Python25\Lib\site-packages\PIL\PngImagePlugin.py
from </p>
<p><code>except ImportError:</code></p>
<p... | 2 | 2011-03-19T20:32:51Z | [
"python",
"google-app-engine",
"windows-server-2008",
"python-imaging-library"
] |
Trouble using PIL with Google Appengine SDK | 2,287,966 | <p>I have a Windows Server 2008 R2 (64bits) machine on which I wanted to develop a google AppEngine app.</p>
<p>So I installed Python 2.5.4 from python.org (because the Google SDK said I needed 2.5 and 2.5.6 didn't have any MSI's)
Then I installed PIL from <a href="http://www.pythonware.com/products/pil/" rel="nofoll... | 2 | 2010-02-18T10:52:04Z | 5,620,630 | <p>I had the exact same issue on my Windows machine (on MacOS it works) so i uninstalled the PIL 1.1.7 and installed the previous 1.1.6 version and now it works like charm ;).</p>
<p>Here is the source for this hack:
<a href="http://www.chris-wong.net/parent-module-pil-not-loaded/" rel="nofollow">http://www.chris-wong... | 2 | 2011-04-11T11:31:16Z | [
"python",
"google-app-engine",
"windows-server-2008",
"python-imaging-library"
] |
Enumerate CD-Drives using Python (Windows) | 2,288,065 | <p>How can I find out the drive letters of available CD/DVD drives?</p>
<p>I am using Python 2.5.4 on Windows.</p>
| 1 | 2010-02-18T11:07:22Z | 2,288,124 | <p>With the <a href="http://sourceforge.net/projects/pywin32/" rel="nofollow">Python for Windows extensions</a>, you can use:</p>
<pre><code>[drive for drive in win32api.GetLogicalDriveStrings().split('\x00')[:-1]
if win32file.GetDriveType(drive)==win32file.DRIVE_CDROM]
</code></pre>
<p>Adapted from <a href="http:/... | 2 | 2010-02-18T11:16:38Z | [
"python",
"windows"
] |
Enumerate CD-Drives using Python (Windows) | 2,288,065 | <p>How can I find out the drive letters of available CD/DVD drives?</p>
<p>I am using Python 2.5.4 on Windows.</p>
| 1 | 2010-02-18T11:07:22Z | 2,288,126 | <p>If you use the <a href="http://pypi.python.org/pypi/WMI/1.3" rel="nofollow">WMI Module</a>, it's very easy:</p>
<pre><code>import wmi
c = wmi.WMI()
for cdrom in c.Win32_CDROMDrive():
print cdrom.Drive, cdrom.MediaLoaded
</code></pre>
<p>The <code>Drive</code> attribute will give you the drive letter and <code>... | 2 | 2010-02-18T11:16:46Z | [
"python",
"windows"
] |
Enumerate CD-Drives using Python (Windows) | 2,288,065 | <p>How can I find out the drive letters of available CD/DVD drives?</p>
<p>I am using Python 2.5.4 on Windows.</p>
| 1 | 2010-02-18T11:07:22Z | 2,288,134 | <p>you can use WMI, see <a href="http://timgolden.me.uk/python/wmi/cookbook.html#find-drive-types" rel="nofollow">this cookbook</a> for an example</p>
| 0 | 2010-02-18T11:17:45Z | [
"python",
"windows"
] |
Enumerate CD-Drives using Python (Windows) | 2,288,065 | <p>How can I find out the drive letters of available CD/DVD drives?</p>
<p>I am using Python 2.5.4 on Windows.</p>
| 1 | 2010-02-18T11:07:22Z | 2,288,138 | <p>Use <a href="http://msdn.microsoft.com/en-us/library/aa364939%28VS.85%29.aspx" rel="nofollow">GetDriveType Function</a> from <code>win32file</code> module.</p>
<p>Sample code:</p>
<pre><code>import win32file
for d in ('C', 'D', 'E', 'F', 'G'):
dname='%c:\\' % (d)
dt=win32file.GetDriveType(dname)
if dt ... | 2 | 2010-02-18T11:19:12Z | [
"python",
"windows"
] |
Enumerate CD-Drives using Python (Windows) | 2,288,065 | <p>How can I find out the drive letters of available CD/DVD drives?</p>
<p>I am using Python 2.5.4 on Windows.</p>
| 1 | 2010-02-18T11:07:22Z | 2,288,225 | <p>Using win32api you can get list of drives and using <a href="http://msdn.microsoft.com/en-us/library/aa364939%28VS.85%29.aspx" rel="nofollow">GetDriveType</a>
you can check what type of drive it is, you can access win32api either by <a href="http://sourceforge.net/projects/pywin32/" rel="nofollow">'Python for Window... | 8 | 2010-02-18T11:33:57Z | [
"python",
"windows"
] |
What are some good ways to do connection management in C? | 2,288,131 | <p>In C, when making a networking client / server setup, I usually have to do some standard BSD socket setup. Then on the server side, I'll have to manage multiple threads, usually a main thread, an a io thread. Each connection is managed by a connection manager so that you can have connections being processed while ne... | 0 | 2010-02-18T11:17:27Z | 2,288,168 | <p>Personally, I am not a huge fan of the one-thread-per-connection model with synchronous IO. I prefer X threads with a pool of Y connections with asynchronous IO. You can spawn threads as needed, or round robin the connections as they come in to a pre-allocated pool.</p>
<p>If you want to be really tricky, spawn thr... | 2 | 2010-02-18T11:23:51Z | [
"python",
"c",
"sockets",
"service",
"connection-pooling"
] |
python: two way partial credit card storing encrytion | 2,288,448 | <p>For my ecommece site, I want to store partial credit card numbers as string, for this I need to encrypt the information to store at the database and decrypt when users want to reuse the already entered credit card info from earlier purchases without typing it all over again.</p>
<p>I am using Django thus I need to ... | 2 | 2010-02-18T12:12:38Z | 2,288,486 | <p>Are you absolutely sure you want to hash sensitive information like this? It might be worth reading <a href="http://benlog.com/articles/2008/06/19/dont-hash-secrets/" rel="nofollow">this article</a> to get an idea of some of the pitfalls trying to store any sensitive information in a database. In your case it's ev... | 2 | 2010-02-18T12:18:02Z | [
"python",
"django",
"encryption",
"credit-card"
] |
python: two way partial credit card storing encrytion | 2,288,448 | <p>For my ecommece site, I want to store partial credit card numbers as string, for this I need to encrypt the information to store at the database and decrypt when users want to reuse the already entered credit card info from earlier purchases without typing it all over again.</p>
<p>I am using Django thus I need to ... | 2 | 2010-02-18T12:12:38Z | 2,288,706 | <p>Before you go much further you should take a look at <a href="https://www.pcisecuritystandards.org/">PCI-DSS</a>, which governs exactly what processes you need to have in place to even consider storing encrypted card numbers. In short, you should seriously consider outsourcing to a 3rd party payment gateway.</p>
<p... | 15 | 2010-02-18T12:57:28Z | [
"python",
"django",
"encryption",
"credit-card"
] |
Disable Plone Archetypes index/convert doc/pdf files | 2,288,470 | <p>If I rebuild my catalog in plone I get many of these infos:</p>
<pre><code>2010-02-18T11:26:09 INFO Archetypes Error while trying to convert file contents to 'text/plain' in <Field file(file:rw)>.getIndexable() of <ATFile at /site/test1/test.doc>: Unable to find binary "wvHtml" in /sbin:/usr/sbin:/usr/l... | 3 | 2010-02-18T12:15:46Z | 2,289,528 | <p>It is trying to index your doc/pdf files by converting them to HTML files first. Just install wv(ware). The message will go away and all your DOC & PDF files will be indexed and show up in your searches.</p>
<p>On Ubuntu/Debian: sudo apt-get install wv</p>
<p>Is there a reason you don't want to index PDFs or W... | 2 | 2010-02-18T15:02:05Z | [
"python",
"plone",
"zope",
"archetypes",
"plone-3.x"
] |
Disable Plone Archetypes index/convert doc/pdf files | 2,288,470 | <p>If I rebuild my catalog in plone I get many of these infos:</p>
<pre><code>2010-02-18T11:26:09 INFO Archetypes Error while trying to convert file contents to 'text/plain' in <Field file(file:rw)>.getIndexable() of <ATFile at /site/test1/test.doc>: Unable to find binary "wvHtml" in /sbin:/usr/sbin:/usr/l... | 3 | 2010-02-18T12:15:46Z | 2,504,891 | <blockquote>
<p>I don't wanna convert docs or pdfs. How can i disable it completly? [sic]</p>
</blockquote>
<p>Well, you're currently not indexing them, so there's nothing to change.</p>
<p>The above message is an INFO message, it's not an error. If you don't want to see these in your event log, you can change the... | 1 | 2010-03-24T02:00:48Z | [
"python",
"plone",
"zope",
"archetypes",
"plone-3.x"
] |
Disable Plone Archetypes index/convert doc/pdf files | 2,288,470 | <p>If I rebuild my catalog in plone I get many of these infos:</p>
<pre><code>2010-02-18T11:26:09 INFO Archetypes Error while trying to convert file contents to 'text/plain' in <Field file(file:rw)>.getIndexable() of <ATFile at /site/test1/test.doc>: Unable to find binary "wvHtml" in /sbin:/usr/sbin:/usr/l... | 3 | 2010-02-18T12:15:46Z | 2,550,771 | <p>You can disable (remove) transforms in ZMI/portal_transforms tool. If Plone does not find transform from Word to plain text or PDF to plain text, it won't try to index the file contents.
Go to ZMI/portal_transforms and remove word_to_html item.</p>
| 4 | 2010-03-31T05:51:13Z | [
"python",
"plone",
"zope",
"archetypes",
"plone-3.x"
] |
Install python egg in buildout environment including data files | 2,288,533 | <p><em>This question assumes that the python package I want to install is a django app that includes templates and media files. But the question is valid for any python package that does not only contain <code>.py</code> files.</em></p>
<p>I'm using buildout to create a re-buildable environment in which I'm developing... | 4 | 2010-02-18T12:26:53Z | 2,288,759 | <p>It sounds like you need to make use of the <a href="http://docs.python.org/distutils/setupscript.html#installing-package-data" rel="nofollow">package_data keyword argument</a> in your setup.py file, so distutils knows those files should be installed with your package.</p>
| 3 | 2010-02-18T13:07:04Z | [
"python",
"django",
"buildout",
"egg"
] |
Content of file to tree format using python | 2,288,570 | <p>I have a file containing a file "dir.txt" with the below data:</p>
<pre><code>/home/abc/a.txt
/home/abc/b.txt
/home/xyz/test
/home/xyz/test/d.txt
/home/xyz/test/e.txt
/home/xyz/test/f.txt
/home/xyz
/home/xyz/g.txt
</code></pre>
<p>I want to parse the file and get the output like</p>
<pre><code>/home/abc/a.txt
... | 0 | 2010-02-18T12:32:30Z | 2,288,629 | <p>you need to use <code>os.path.split</code> on every path, find the first dirname and print path as it is. find it length and print so many spaces before next basename, on change of the dirname repeat as before.</p>
<pre><code>>>> import os.path
>>> olddir = None
>>> for name in open('... | 4 | 2010-02-18T12:43:28Z | [
"python",
"treeview"
] |
Content of file to tree format using python | 2,288,570 | <p>I have a file containing a file "dir.txt" with the below data:</p>
<pre><code>/home/abc/a.txt
/home/abc/b.txt
/home/xyz/test
/home/xyz/test/d.txt
/home/xyz/test/e.txt
/home/xyz/test/f.txt
/home/xyz
/home/xyz/g.txt
</code></pre>
<p>I want to parse the file and get the output like</p>
<pre><code>/home/abc/a.txt
... | 0 | 2010-02-18T12:32:30Z | 2,288,648 | <p>Try this:</p>
<pre><code>import os.path
txt = """/home/abc/a.txt
/home/abc/b.txt
/home/xyz/test/d.txt
/home/xyz/test/e.txt
/home/xyz/test/f.txt
/home/xyz/g.txt"""
last_d = ''
for l in txt.split('\n'):
(d, n) = os.path.split(l)
if d == last_d:
d = ' ' * len(last_d)
else:
last_d = d
... | 2 | 2010-02-18T12:46:21Z | [
"python",
"treeview"
] |
Content of file to tree format using python | 2,288,570 | <p>I have a file containing a file "dir.txt" with the below data:</p>
<pre><code>/home/abc/a.txt
/home/abc/b.txt
/home/xyz/test
/home/xyz/test/d.txt
/home/xyz/test/e.txt
/home/xyz/test/f.txt
/home/xyz
/home/xyz/g.txt
</code></pre>
<p>I want to parse the file and get the output like</p>
<pre><code>/home/abc/a.txt
... | 0 | 2010-02-18T12:32:30Z | 2,288,668 | <pre><code>>>> filenames="""/home/abc/a.txt
... /home/abc/b.txt
... /home/xyz/test/d.txt
... /home/xyz/test/e.txt
... /home/xyz/test/f.txt
... /home/xyz/g.txt""".split()
>>>
>>> import os
>>> prev=''
>>> for n in filenames:
... path,name = os.path.split(n)
... i... | 0 | 2010-02-18T12:49:37Z | [
"python",
"treeview"
] |
Content of file to tree format using python | 2,288,570 | <p>I have a file containing a file "dir.txt" with the below data:</p>
<pre><code>/home/abc/a.txt
/home/abc/b.txt
/home/xyz/test
/home/xyz/test/d.txt
/home/xyz/test/e.txt
/home/xyz/test/f.txt
/home/xyz
/home/xyz/g.txt
</code></pre>
<p>I want to parse the file and get the output like</p>
<pre><code>/home/abc/a.txt
... | 0 | 2010-02-18T12:32:30Z | 2,288,858 | <p>@Op,use a dictionary. Use the paths as the key and the file names as values</p>
<pre><code>from collections import defaultdict
d=defaultdict(list)
for line in open("file"):
line=line.strip()
s='/'.join(line.split("/")[:-1])
d[s].append(line.split("/")[-1])
for i,j in d.iteritems():
print i,j
</code... | 2 | 2010-02-18T13:25:10Z | [
"python",
"treeview"
] |
Content of file to tree format using python | 2,288,570 | <p>I have a file containing a file "dir.txt" with the below data:</p>
<pre><code>/home/abc/a.txt
/home/abc/b.txt
/home/xyz/test
/home/xyz/test/d.txt
/home/xyz/test/e.txt
/home/xyz/test/f.txt
/home/xyz
/home/xyz/g.txt
</code></pre>
<p>I want to parse the file and get the output like</p>
<pre><code>/home/abc/a.txt
... | 0 | 2010-02-18T12:32:30Z | 2,292,923 | <p>This is an alternate take that offers a different output, just in case the OP would prefer this format:</p>
<pre><code>/home/abc/a.txt
b.txt
xyz/test/d.txt
e.txt
f.txt
g.txt
</code></pre>
<p>then this code:</p>
<pre><code>import os
def pretty_printer(seq_of... | 0 | 2010-02-18T23:07:02Z | [
"python",
"treeview"
] |
What's wrong in this caching function in Django? | 2,288,720 | <p>I've created the model for counting the number of views of my page:</p>
<pre><code>class RequestCounter(models.Model):
count = models.IntegerField(default=0)
def __unicode__(self):
return str(self.count)
</code></pre>
<p>For incrementing the counter I use:</p>
<pre><code>def inc_counter():
cou... | 0 | 2010-02-18T13:00:02Z | 2,288,958 | <p>What CACHE_BACKEND are you using? If it's locmem:// and you're running Apache, you'll have a different cache active for each Apache child, which would explain the differing results. I had this a while ago and it was a subtle one to work out. I'd recommend switching to memcache if you're not already on it, as this wo... | 4 | 2010-02-18T13:43:43Z | [
"python",
"django",
"caching"
] |
Problem with running Django 1.1.1 on Google App Engine Developement Server | 2,288,725 | <p>I've downloaded google_appengine version 1.3.1. Using some web tutorials, I've created basic django 1.1.1 application. Using appcfg I managed to deploy it on GAE and it works. The problem is, that application doesn't want to work on dev_appengine.py developement server.</p>
<p>Whenever I run the app GAE local serve... | 0 | 2010-02-18T13:00:55Z | 2,289,005 | <p>I had module nammed same way as the default GAE launcher (main/ and main.py). After renaming the launcher everything works great.</p>
| 0 | 2010-02-18T13:51:18Z | [
"python",
"django",
"google-app-engine"
] |
Effective ways to implement Every-to-Every interaction? | 2,288,849 | <p>Given a list of elements, how to process all elements if every element requires knowledge about states of every other element of this list?</p>
<p>For example, direct way to implement it in Python could be:</p>
<pre><code>S = [1,2,3,4]
for e in S:
for j in S:
if e!=j:
process_it(e,j)
</code></pre>
<p>... | 0 | 2010-02-18T13:22:23Z | 2,288,875 | <p>If you need to process every pair of items, there are O(n<sup>2</sup>) pairs, so you will have to make that many calls!</p>
<p>If you only need the combinations (ab, ac, bc), not all the permutations (ab,ba,ac,ca,bc,cb), then you can do this, to halve the number of calls (and skip the <code>if</code>):</p>
<pre><c... | 2 | 2010-02-18T13:29:52Z | [
"python",
"c",
"algorithm",
"parallel-processing"
] |
Effective ways to implement Every-to-Every interaction? | 2,288,849 | <p>Given a list of elements, how to process all elements if every element requires knowledge about states of every other element of this list?</p>
<p>For example, direct way to implement it in Python could be:</p>
<pre><code>S = [1,2,3,4]
for e in S:
for j in S:
if e!=j:
process_it(e,j)
</code></pre>
<p>... | 0 | 2010-02-18T13:22:23Z | 2,289,112 | <p>One sure option is to get it implemented in FPGA and have them all work concurrently. Other than that - if there are no exceptions and really -all- need -all-, not "some need some", you're sentenced to the standard approach.</p>
| 0 | 2010-02-18T14:05:36Z | [
"python",
"c",
"algorithm",
"parallel-processing"
] |
Effective ways to implement Every-to-Every interaction? | 2,288,849 | <p>Given a list of elements, how to process all elements if every element requires knowledge about states of every other element of this list?</p>
<p>For example, direct way to implement it in Python could be:</p>
<pre><code>S = [1,2,3,4]
for e in S:
for j in S:
if e!=j:
process_it(e,j)
</code></pre>
<p>... | 0 | 2010-02-18T13:22:23Z | 2,289,291 | <p>The suitability of a given task to be handled in multi-process fashion depends on the <strong><em>nature of the task</em></strong> and the interdependency (or lack thereof) of various subtasks, <strong>not</strong> on <strong><em>the way the list of subtasks is produced</em></strong>.<br>
In other words, using the q... | 1 | 2010-02-18T14:31:36Z | [
"python",
"c",
"algorithm",
"parallel-processing"
] |
Wrong results with Python multiply() and prod() | 2,288,952 | <p>Can anyone explain the following? I'm using Python 2.5</p>
<p>Consider 1*3*5*7*9*11 ... *49. If you type all that from within IPython(x,y) interactive console, you'll get 58435841445947272053455474390625L, which is correct. (why odd numbers: just the way I did it originally)</p>
<p>Python multiply.reduce() or pro... | 1 | 2010-02-18T13:42:42Z | 2,289,067 | <p>The CPU doesn't multiply arbitrarily large numbers, it only performs specific operations defined on particular ranges of numbers represented in base 2, 0-1 bits. </p>
<p>Python '*' handles large integers perfectly through a proper representation and special code beyond the CPU or FPU instructions for multiply. </... | 2 | 2010-02-18T13:58:59Z | [
"python",
"numpy"
] |
Wrong results with Python multiply() and prod() | 2,288,952 | <p>Can anyone explain the following? I'm using Python 2.5</p>
<p>Consider 1*3*5*7*9*11 ... *49. If you type all that from within IPython(x,y) interactive console, you'll get 58435841445947272053455474390625L, which is correct. (why odd numbers: just the way I did it originally)</p>
<p>Python multiply.reduce() or pro... | 1 | 2010-02-18T13:42:42Z | 2,289,076 | <p>This is because <code>numpy.multiply.reduce()</code> converts the range list to an array of type <code>numpy.int32</code>, and the reduce operation overflows what can be stored in 32 bits at some point:</p>
<pre><code>>>> type(numpy.multiply.reduce(range(1, 50, 2)))
<type 'numpy.int32'>
</code></pre>... | 6 | 2010-02-18T14:00:42Z | [
"python",
"numpy"
] |
What is the difference between running a script from the command line and from exec() with PHP? | 2,289,046 | <p>I'm trying to run a Python script using exec() from within PHP. My command works fine when I run it directly using a <code>cmd</code> window, but it produces an error when I run it from <code>exec()</code> in PHP.</p>
<p>My Python script uses <a href="http://www.nltk.org/">NTLK</a> to find proper nouns. Example com... | 6 | 2010-02-18T13:55:51Z | 2,295,334 | <p>Your web server likely runs with other privileges than yourself. Possible problems include:</p>
<ul>
<li>Path/file permission: can the web server user access the files it needs?</li>
<li>Different environment: are all necessary environment variables (PATH, Python-specific stuff, â¦) set?</li>
<li>Configuration: ar... | 2 | 2010-02-19T09:52:43Z | [
"php",
"python",
"apache",
"exec",
"nltk"
] |
What is the difference between running a script from the command line and from exec() with PHP? | 2,289,046 | <p>I'm trying to run a Python script using exec() from within PHP. My command works fine when I run it directly using a <code>cmd</code> window, but it produces an error when I run it from <code>exec()</code> in PHP.</p>
<p>My Python script uses <a href="http://www.nltk.org/">NTLK</a> to find proper nouns. Example com... | 6 | 2010-02-18T13:55:51Z | 5,208,563 | <p>You have to run <code>nltk.download()</code> and choose 'maxent_treebank_pos_tagger'. You must make a python script and in it put:</p>
<pre><code>#!/usr/bin/python
import nltk
nltk.download('maxent_treebank_pos_tagger');
</code></pre>
<p>then run it from command line. It will install the data files for the POS tag... | 30 | 2011-03-06T03:49:37Z | [
"php",
"python",
"apache",
"exec",
"nltk"
] |
What is the difference between running a script from the command line and from exec() with PHP? | 2,289,046 | <p>I'm trying to run a Python script using exec() from within PHP. My command works fine when I run it directly using a <code>cmd</code> window, but it produces an error when I run it from <code>exec()</code> in PHP.</p>
<p>My Python script uses <a href="http://www.nltk.org/">NTLK</a> to find proper nouns. Example com... | 6 | 2010-02-18T13:55:51Z | 32,600,878 | <p>From the shell/terminal, you can use:</p>
<pre><code>sudo python -m nltk.downloader maxent_treebank_pos_tagger
</code></pre>
<p>It will install <code>maxent_treebank_pos_tagger</code> (i.e. the standard treebank POS tagger in NLTK).</p>
| 0 | 2015-09-16T06:03:56Z | [
"php",
"python",
"apache",
"exec",
"nltk"
] |
Fast way to get N Min or Max elements from a list in Python | 2,289,053 | <p>I currently have a long list which is being sorted using a lambda function f. I then choose a random element from the first five elements. Something like:</p>
<pre><code>f = lambda x: some_function_of(x, local_variable)
my_list.sort(key=f)
foo = choice(my_list[:4])
</code></pre>
<p>This is a bottleneck in my progr... | 6 | 2010-02-18T13:56:41Z | 2,289,108 | <p>Use <a href="http://docs.python.org/library/heapq.html#heapq.nlargest"><code>heapq.nlargest</code></a> or <a href="http://docs.python.org/library/heapq.html#heapq.nsmallest"><code>heapq.nsmallest</code></a>.</p>
<p>For example:</p>
<pre><code>import heapq
elements = heapq.nsmallest(4, my_list, key=f)
foo = choice... | 8 | 2010-02-18T14:04:42Z | [
"python",
"sorting"
] |
Fast way to get N Min or Max elements from a list in Python | 2,289,053 | <p>I currently have a long list which is being sorted using a lambda function f. I then choose a random element from the first five elements. Something like:</p>
<pre><code>f = lambda x: some_function_of(x, local_variable)
my_list.sort(key=f)
foo = choice(my_list[:4])
</code></pre>
<p>This is a bottleneck in my progr... | 6 | 2010-02-18T13:56:41Z | 2,289,658 | <p>It's actually possible in linear time (O(N)) on average.</p>
<p>You need a partition algorithm:</p>
<pre><code>def partition(seq, pred, start=0, end=-1):
if end == -1: end = len(seq)
while True:
while True:
if start == end: return start
if not pred(seq[start]): break
... | 1 | 2010-02-18T15:19:15Z | [
"python",
"sorting"
] |
Complete django DB reset | 2,289,187 | <p>How do I completely reset my Django (1.2 alpha) DB (dropping all tables, rather than just clearing them)?</p>
<p><code>manage.py flush</code> does too little (won't work if there are schema changes) and <code>manage.py reset</code> requires me to specify all apps (and appears to take a format that is different from... | 14 | 2010-02-18T14:16:16Z | 2,289,231 | <p>You want <code>sqlreset</code>:</p>
<pre><code>% python manage.py help sqlreset
Usage: manage.py sqlreset [options] <appname appname ...>
Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s).
Options:
-v VERBOSITY, --verbosity=VERBOSITY
Verbosity level; 0... | 0 | 2010-02-18T14:23:05Z | [
"python",
"django"
] |
Complete django DB reset | 2,289,187 | <p>How do I completely reset my Django (1.2 alpha) DB (dropping all tables, rather than just clearing them)?</p>
<p><code>manage.py flush</code> does too little (won't work if there are schema changes) and <code>manage.py reset</code> requires me to specify all apps (and appears to take a format that is different from... | 14 | 2010-02-18T14:16:16Z | 2,289,445 | <p>Just assign a new database and drop this db from the db console. Seems to me to be the simplest.</p>
| 0 | 2010-02-18T14:49:50Z | [
"python",
"django"
] |
Complete django DB reset | 2,289,187 | <p>How do I completely reset my Django (1.2 alpha) DB (dropping all tables, rather than just clearing them)?</p>
<p><code>manage.py flush</code> does too little (won't work if there are schema changes) and <code>manage.py reset</code> requires me to specify all apps (and appears to take a format that is different from... | 14 | 2010-02-18T14:16:16Z | 2,289,727 | <p>take a look at reset command in django's code, and write your own which drops/creates DB first.</p>
| -1 | 2010-02-18T15:26:30Z | [
"python",
"django"
] |
Complete django DB reset | 2,289,187 | <p>How do I completely reset my Django (1.2 alpha) DB (dropping all tables, rather than just clearing them)?</p>
<p><code>manage.py flush</code> does too little (won't work if there are schema changes) and <code>manage.py reset</code> requires me to specify all apps (and appears to take a format that is different from... | 14 | 2010-02-18T14:16:16Z | 2,289,931 | <p>Hm, maybe you lie to manage.py, pretending to make fixtures, but only to look for apps:</p>
<blockquote>
<p>apps=$(python manage.py makefixture 2>&1 | egrep -v '(^Error|^django)'|awk -F . '{print $2}'|uniq); for i in $apps; do python manage.py sqlreset $i; done| grep DROP</p>
</blockquote>
<p>That prints out... | 0 | 2010-02-18T15:50:58Z | [
"python",
"django"
] |
Complete django DB reset | 2,289,187 | <p>How do I completely reset my Django (1.2 alpha) DB (dropping all tables, rather than just clearing them)?</p>
<p><code>manage.py flush</code> does too little (won't work if there are schema changes) and <code>manage.py reset</code> requires me to specify all apps (and appears to take a format that is different from... | 14 | 2010-02-18T14:16:16Z | 2,291,863 | <p><a href="http://www.djangosnippets.org/snippets/828/">This Snippet</a> gives you the code for a <code>manage.py reset_db</code> command you can install, it's the minimum change that solves your problem</p>
<hr>
<p>That said, from comments below:</p>
<blockquote>
<p>You might as well just install Django command ... | 16 | 2010-02-18T20:13:13Z | [
"python",
"django"
] |
Complete django DB reset | 2,289,187 | <p>How do I completely reset my Django (1.2 alpha) DB (dropping all tables, rather than just clearing them)?</p>
<p><code>manage.py flush</code> does too little (won't work if there are schema changes) and <code>manage.py reset</code> requires me to specify all apps (and appears to take a format that is different from... | 14 | 2010-02-18T14:16:16Z | 12,360,587 | <p>Assuming you are (luckily) in a Linux environment as well as:</p>
<ul>
<li>using MySQL and know user/password to access project's db</li>
<li>bash, mysql, readlink are installed</li>
<li>settings.py is settings.py</li>
<li>dbname is the same as your django project name (see <em>MYAPP</em> var below)</li>
<li>all th... | 0 | 2012-09-10T22:58:42Z | [
"python",
"django"
] |
SQLAlchemy.declarative and deferred column loading | 2,289,401 | <p>is it possible to specify some columns in the SQLAlchemy to be deferred-loading? I am using the sqlalchemy.ext.declarative module to define my mapping, example:</p>
<pre><code>from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class SomeClass(Base):
__tablename__ = 'some_table'
... | 5 | 2010-02-18T14:44:38Z | 2,290,847 | <p>Do not define the mapping for the columns which you want to load on demand. Then configure those as described in the <a href="http://www.sqlalchemy.org/docs/05/mappers.html#deferred-column-loading" rel="nofollow">Deferred Column Loading</a> using <code>mapper</code> object. Modified code here:</p>
<pre><code>from s... | 2 | 2010-02-18T17:47:30Z | [
"python",
"sqlalchemy"
] |
SQLAlchemy.declarative and deferred column loading | 2,289,401 | <p>is it possible to specify some columns in the SQLAlchemy to be deferred-loading? I am using the sqlalchemy.ext.declarative module to define my mapping, example:</p>
<pre><code>from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class SomeClass(Base):
__tablename__ = 'some_table'
... | 5 | 2010-02-18T14:44:38Z | 2,291,351 | <p>Just add <code>deferred()</code> around the column declaration:</p>
<pre><code>class SomeClass(Base):
__tablename__ = 'some_table'
id = Column(Integer, primary_key=True)
name = deferred(Column(String(50)))
</code></pre>
| 10 | 2010-02-18T18:59:48Z | [
"python",
"sqlalchemy"
] |
Automate conversion of Sybase .ADT files to SQL | 2,289,519 | <p>I am working with some data I obtained that is read with a program using an embedded Advantage Database Server. The program was not written by me and does not have all of the functionality that I need. I would like to convert this data to a different format so that I can work with it more freely, such as MySQL. <... | 2 | 2010-02-18T15:00:06Z | 2,291,603 | <p>Advantage has a dbi (Perl) driver you could use to access the tables in their existing ADT format. Also has JDBC and OLE DB drivers. See all of them at <a href="http://devzone.advantagedatabase.com/dz/content.aspx?key=20&Release=13" rel="nofollow">http://devzone.advantagedatabase.com/dz/content.aspx?key=20&R... | 2 | 2010-02-18T19:33:30Z | [
"python",
"ruby",
"sybase",
"advantage-database-server"
] |
Automate conversion of Sybase .ADT files to SQL | 2,289,519 | <p>I am working with some data I obtained that is read with a program using an embedded Advantage Database Server. The program was not written by me and does not have all of the functionality that I need. I would like to convert this data to a different format so that I can work with it more freely, such as MySQL. <... | 2 | 2010-02-18T15:00:06Z | 2,304,179 | <p>After some asking and searching it seems that there isn't something like what I was looking for. </p>
<p>I spent a little while earlier today putting something together based on the Ruby DBF gem. I'm not finished, but it works like I want it to. I'll have to finish up the tests and add the exporting of SQL, etc.... | 2 | 2010-02-20T23:27:32Z | [
"python",
"ruby",
"sybase",
"advantage-database-server"
] |
Python and urllib | 2,289,768 | <p>I'm trying to download a zip file ("tl_2008_01001_edges.zip") from an ftp <a href="ftp://ftp2.census.gov/geo/tiger/TIGER2008/01_ALABAMA/01001_Autauga_County/" rel="nofollow">census</a> site using urllib. What form is the zip file in when I get it and how do I save it?</p>
<p>I'm fairly new to Python and don't under... | 4 | 2010-02-18T15:31:50Z | 2,289,822 | <p>Per <a href="http://docs.python.org/library/urllib.html?highlight=urlretrieve#urllib.urlretrieve" rel="nofollow">the docs</a>, <code>urlretrieve</code> puts the file to disk and returns a tuple <code>(filename, headers)</code>. So the file is already saved when <code>urlretrieve</code> returns.</p>
<p>You can open... | 3 | 2010-02-18T15:37:37Z | [
"python",
"urllib2",
"urllib"
] |
Python and urllib | 2,289,768 | <p>I'm trying to download a zip file ("tl_2008_01001_edges.zip") from an ftp <a href="ftp://ftp2.census.gov/geo/tiger/TIGER2008/01_ALABAMA/01001_Autauga_County/" rel="nofollow">census</a> site using urllib. What form is the zip file in when I get it and how do I save it?</p>
<p>I'm fairly new to Python and don't under... | 4 | 2010-02-18T15:31:50Z | 2,289,924 | <pre><code>import os,urllib2
out=os.path.join("/tmp","test.zip")
url="ftp://ftp2.census.gov/geo/tiger/TIGER2008/01_ALABAMA/01001_Autauga_County/tl_2008_01001_edges.zip"
page=urllib2.urlopen(url)
open(out,"wb").write(page.read())
</code></pre>
| 4 | 2010-02-18T15:50:14Z | [
"python",
"urllib2",
"urllib"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.