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
How to select all values from one threshold to another?
40,011,617
<p>I have an ordered tuple of data:</p> <pre><code>my_data = (1,2,3,2,4,2,3,3,5,7,5,3,6,8,7) </code></pre> <p>How can I subset the tuple items such that all items including and after the first instance of 3 are kept until the first value == 7? For example, the result should be:</p> <pre><code>desired_output = (3,2,4...
-1
2016-10-13T03:04:14Z
40,011,683
<p><code>itertools</code> has <code>dropwhile</code> and <code>takewhile</code> that you can use to your advantage. Use <code>dropwhile</code> to drop everything until the first <code>3</code>, and <code>takewhile</code> to take everything until the first 7 thereafter. Then just merge the two</p> <pre><code>import ite...
0
2016-10-13T03:13:00Z
[ "python", "tuples" ]
How to select all values from one threshold to another?
40,011,617
<p>I have an ordered tuple of data:</p> <pre><code>my_data = (1,2,3,2,4,2,3,3,5,7,5,3,6,8,7) </code></pre> <p>How can I subset the tuple items such that all items including and after the first instance of 3 are kept until the first value == 7? For example, the result should be:</p> <pre><code>desired_output = (3,2,4...
-1
2016-10-13T03:04:14Z
40,011,685
<pre><code>found_three = False res = [] for d in data: if d == 3: found_three = True if found_three: res.append(d) if d == 7; break </code></pre>
0
2016-10-13T03:13:09Z
[ "python", "tuples" ]
How to select all values from one threshold to another?
40,011,617
<p>I have an ordered tuple of data:</p> <pre><code>my_data = (1,2,3,2,4,2,3,3,5,7,5,3,6,8,7) </code></pre> <p>How can I subset the tuple items such that all items including and after the first instance of 3 are kept until the first value == 7? For example, the result should be:</p> <pre><code>desired_output = (3,2,4...
-1
2016-10-13T03:04:14Z
40,011,689
<p>my_data.index(my_data.index(min_thre):my_data.index(max_thre)+1)</p>
2
2016-10-13T03:13:22Z
[ "python", "tuples" ]
Running total won't print properly
40,011,678
<pre><code>def load(): global name global count global shares global pp global sp global commission name=input("Enter stock name OR -999 to Quit: ") count =0 while name != '-999': count=count+1 shares=int(input("Enter number of shares: ")) pp=float(input("...
0
2016-10-13T03:12:42Z
40,011,832
<p>You are resetting <code>totalpr</code> every time <code>calc</code> is called.</p> <pre><code>def calc(): totalpr=0 # resets to zero every time # ... totalpr=totalpr+profit_loss # same as `totalpr = 0 + profit_loss` </code></pre> <p>Instead, you have to initialize <code>totalpr</code> outside of <cod...
0
2016-10-13T03:29:04Z
[ "python", "python-3.x", "printing" ]
Self is not defined?
40,011,755
<p>I am attempting to make a basic study clock as a learning exercise for Tkinter but I get an error when attempting run it saying self is not defined. Here is the error message.</p> <pre><code>Traceback (most recent call last): File "productivityclock.py", line 6, in &lt;module&gt; class gui(object): ...
-1
2016-10-13T03:21:53Z
40,011,828
<p>Yes, at line 113, <code>while 0 &lt; self.z:</code> is not properly indented, and all the lines below it.</p>
0
2016-10-13T03:28:40Z
[ "python", "python-2.7", "tkinter" ]
How to convert a selenium webelement to string variable in python
40,011,816
<pre><code>from selenium import webdriver from time import sleep from selenium.common.exceptions import NoSuchAttributeException from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.keys import Keys driver = webdriver.Firefox() driver.get('https://www.linkedin.com/jobs/search?loc...
1
2016-10-13T03:27:33Z
40,012,512
<p>In case, if you need a list of links to each job:</p> <pre><code>job_list = [] jobtitlebuttons = driver.find_elements_by_class_name('job-title-link') for job in jobtitlebuttons: job_list.append(job.get_attribute('href')) </code></pre> <p>In case, if you want just a job titles list:</p> <pre><code>job_list = [...
1
2016-10-13T04:50:22Z
[ "python", "selenium" ]
python modifying a variable with a function
40,011,826
<p>I am trying to write a function for a basic python course that I am taking. We are at the point where we join as a group and make one program as a team. I have assigned each member to write their portion as a function in the hopes that I can just call each function to perform the overall program. It has been a while...
-1
2016-10-13T03:28:26Z
40,011,968
<p>As it is right now, you are throwing away the result of your calculation. You have to store it an use it as input for the next calculation.</p> <pre><code>while MOBhp &gt; 0: TYPEatck=random.choice('RM') MOBhp = ATTACK(TYPEatck,MOBhp) </code></pre>
2
2016-10-13T03:45:43Z
[ "python", "function", "variables" ]
python modifying a variable with a function
40,011,826
<p>I am trying to write a function for a basic python course that I am taking. We are at the point where we join as a group and make one program as a team. I have assigned each member to write their portion as a function in the hopes that I can just call each function to perform the overall program. It has been a while...
-1
2016-10-13T03:28:26Z
40,014,125
<p>MisterMiyagi's answer is helpful. If you want to use global variables ,you may use it like this:</p> <pre><code>import random MOBhp=100 def ATTACK(TYPEatck, hp): global MOBhp MOBhp = hp print('the type attack chosen was ',TYPEatck,'the MOB has ',MOBhp) if TYPEatck == 'M' or TYPEatck == 'm': ...
0
2016-10-13T06:49:57Z
[ "python", "function", "variables" ]
python modifying a variable with a function
40,011,826
<p>I am trying to write a function for a basic python course that I am taking. We are at the point where we join as a group and make one program as a team. I have assigned each member to write their portion as a function in the hopes that I can just call each function to perform the overall program. It has been a while...
-1
2016-10-13T03:28:26Z
40,028,856
<p>Thank you all for you assistance! I figured it out and was able to write my program to completion. </p> <p><a href="https://www.reddit.com/r/Python/comments/578b6e/0300/" rel="nofollow">Here is the code formatted and shared on Reddit</a></p>
0
2016-10-13T18:56:27Z
[ "python", "function", "variables" ]
Jumping simulation stop falling when returned to ground
40,011,860
<p>I am trying to simulate a jump in a Rect.</p> <p>I set the KEYDOWN and KEYUP events and K_SPACE button to simulate the jump. </p> <p>My difficulty is stopping the returning fall when the rect reaches the ground (using cordX).</p> <p>I realize that will not work and comment it out in the GAME_BEGIN statement.</p>...
0
2016-10-13T03:32:27Z
40,012,254
<p>Tks, i have done what you said, here is my code</p> <pre><code> import pygame pygame.init() screen = pygame.display.set_mode((400,300)) pygame.display.set_caption("shield hacking") JogoAtivo = True GAME_BEGIN = False # Speed in pixels per frame speedX = 0 speedY = 0 cordX = 10 cordY = 100 groundX=0; groundY=150...
0
2016-10-13T04:23:44Z
[ "python", "pygame" ]
If value true but null not work
40,011,874
<p>I made program is input number and delete data in mysql. but run program error then report <code>sql1</code> Syntax Error\i change true</p> <pre><code>#!/usr/bin/python import mysql.connector conn = mysql.connector.connect(host="",user="",passwd="",db="") cursor = conn.cursor() try: num = int(input("Inpu...
1
2016-10-13T03:33:24Z
40,012,032
<p>num = int(input("InputNumber: ")<code>)</code> &lt;- don't forguet to close it</p> <p>I'm not sure about the <code>%i</code>, I always see using <code>%d</code> for Integer and <code>%s</code> to strings</p> <p>But, you also have one problem into your query, <a href="https://en.wikipedia.org/wiki/SQL_injection"...
3
2016-10-13T03:54:21Z
[ "python", "mysql" ]
Debug tensorflow unit tests
40,011,891
<p>I find the <a href="http://stackoverflow.com/questions/34204551/run-tensorflow-unit-tests">link</a> which shows how to run the unit tests.</p> <p>And I think it could get a better understanding about the source code by debug the unit tests.</p> <p>I can debug the source code as the tensorflow python application ru...
0
2016-10-13T03:35:57Z
40,099,717
<p>To summarize:</p> <ul> <li>you have to make sure the test binary is built first: either by running <code>bazel test &lt;target&gt;</code> or with <code>bazel build &lt;target&gt;</code> or with <code>bazel build -c dbg &lt;target&gt;</code>. The last one gives fully debuggable executables that give you line numbers...
0
2016-10-18T04:47:42Z
[ "python", "c++", "machine-learning", "gdb", "tensorflow" ]
NLTK vs Stanford NLP
40,011,896
<p>I have recently started to use NLTK toolkit for creating few solutions using Python.</p> <p>I hear a lot of community activity regarding using stanford NLP. Can anyone tell me what is the difference between NLTK and Stanford NLP ? Are they 2 different libraries ? i know that NLTK has an interface to stanford NLP bu...
0
2016-10-13T03:36:31Z
40,028,128
<blockquote> <p>Can anyone tell me what is the difference between NLTK and Stanford NLP? Are they 2 different libraries ? I know that NLTK has an interface to Stanford NLP but can anyone throw some light on few basic differences or even more in detail.</p> </blockquote> <p>(I'm assuming you mean "<a href="http://sta...
2
2016-10-13T18:13:06Z
[ "python", "nltk", "stanford-nlp" ]
Join two dataframes on values within the second dataframe
40,011,943
<p>I am trying to join two dataframes off of values within the dataset:</p> <pre><code>df1 t0 t1 text0 text1 ID 2133 7.0 3.0 NaN NaN 1234 10.0 8.0 NaN NaN 7352 9.0 7.0 NaN NaN 2500 7.0 6.0 NaN NaN 3298 10.0 ...
2
2016-10-13T03:42:53Z
40,013,126
<p>You can use first <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.melt.html" rel="nofollow"><code>melt</code></a> for reshaping with <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.drop.html" rel="nofollow"><code>drop</code></a> empty columns <code>text0</code> a...
3
2016-10-13T05:41:58Z
[ "python", "python-3.x", "pandas", "join", "dataframe" ]
Anaconda - HTTPError when Updating
40,011,948
<p>I'm getting the following error when I try to run <code>conda update numpy</code> (also when running <code>conda update conda</code>)</p> <pre><code>Fetching package metadata ............CondaHTTPError: HTTP Error: Could not find URL: https://conda.anaconda.org/condaforge/linux-64/ </code></pre> <p>The person in <...
0
2016-10-13T03:43:23Z
40,022,617
<p>The correct channel name is <code>conda-forge</code>. You should</p> <pre><code>conda config --remove channels condaforge conda config --add channels conda-forge </code></pre>
0
2016-10-13T13:38:19Z
[ "python", "anaconda", "conda" ]
How to handle 0 entries in book crossing dataset
40,012,035
<p>I am working with book <a href="http://www2.informatik.uni-freiburg.de/~cziegler/BX/" rel="nofollow">crossing Data-set</a> , It have a file which given user X's rating for book Y, but a lot of entries contains value 0 that means user X liked the book Y but did not give rating to it. I am using collaborative filterin...
0
2016-10-13T03:55:12Z
40,014,658
<p>ISBN codes are very messy, contain a lot of incorrect ISBNs, and are not unified.</p> <p>Here are just a few examples:</p> <pre><code>"User-ID";"ISBN";"Book-Rating" "11676";" 9022906116";"7" "11676";"\"0432534220\"";"6" "11676";"\"2842053052\"";"7" "11676";"0 7336 1053 6";"0" "11676";"0=965044153";"7" "11676";"000...
0
2016-10-13T07:19:39Z
[ "python", "pandas", "machine-learning", "data-science" ]
Uncapitalizing first letter of a name
40,012,062
<p>To code a name like DeAnna you type:</p> <pre><code>name = "de\aanna" </code></pre> <p>and </p> <pre><code>print(name.title()) </code></pre> <p>In this code <code>\a</code> capitalizes a normally uncapitalized letter. What do you code to produce a name like <code>"George von Trapp"</code> where I want to uncapi...
3
2016-10-13T03:59:43Z
40,012,160
<p>The <code>\a</code> does not capitalize a letter - it is the <a href="https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals" rel="nofollow">bell escape sequence</a>.</p> <p>The <a href="https://docs.python.org/3/library/stdtypes.html#textseq" rel="nofollow"><code>str.title</code></a> s...
5
2016-10-13T04:11:16Z
[ "python", "string", "python-3.x" ]
Uncapitalizing first letter of a name
40,012,062
<p>To code a name like DeAnna you type:</p> <pre><code>name = "de\aanna" </code></pre> <p>and </p> <pre><code>print(name.title()) </code></pre> <p>In this code <code>\a</code> capitalizes a normally uncapitalized letter. What do you code to produce a name like <code>"George von Trapp"</code> where I want to uncapi...
3
2016-10-13T03:59:43Z
40,012,240
<blockquote> <p>What do you code to produce a name like <code>"George von Trapp"</code> where I want to uncapitalize a normally capitalized letter?</p> </blockquote> <p>Letters are not auto-capitalized in Python. In your case, <code>"de\aanna"</code>(I think you should use <code>"de anna"</code> instead) is capita...
0
2016-10-13T04:21:55Z
[ "python", "string", "python-3.x" ]
Uncapitalizing first letter of a name
40,012,062
<p>To code a name like DeAnna you type:</p> <pre><code>name = "de\aanna" </code></pre> <p>and </p> <pre><code>print(name.title()) </code></pre> <p>In this code <code>\a</code> capitalizes a normally uncapitalized letter. What do you code to produce a name like <code>"George von Trapp"</code> where I want to uncapi...
3
2016-10-13T03:59:43Z
40,012,496
<p>Why not just roll your own function for it?</p> <pre><code> def capitalizeName(name): #split the name on spaces parts = name.split(" ") # define a list of words to not capitalize do_not_cap = ['von'] # for each part of the name, # force the word to lowercase # then check if it i...
1
2016-10-13T04:49:09Z
[ "python", "string", "python-3.x" ]
elementTree is not opening and parsing my xml file
40,012,110
<p>seems like <code>vehicles.write(cars_file)</code> and <code>vehicles = cars_Etree.parse(cars_file)</code> are having a problem with the file name:</p> <pre><code>import argparse import xml.etree.ElementTree as cars_Etree # elementTree not reading xml file properly if __name__ == '__main__': parser = argparse...
0
2016-10-13T04:05:50Z
40,038,333
<p>works fine now but im still improving it. thank you </p> <p>I made this modification in main.py:</p> <pre><code>path = "/Users/benbitdiddle/PycharmProjects/VehicleFilter/" CF = CarFilter(path+args.file_name, args.car_make) CF.filterCar() </code></pre> <p>And changed 'w' to wb' in CarFilter.py class file:</p> ...
0
2016-10-14T08:19:14Z
[ "python", "xml", "argparse", "elementtree" ]
How to have one script call and run another one concurrently in python?
40,012,128
<p>What I am trying to accomplish is to stream tweets from Twitter for an hour, write the list of tweets to a file, clean and run analysis on the most recent hour of tweets, and then repeat the process indefinitely. </p> <p>The problem I am running into is that if I run the cleaning and analysis of the tweets in the s...
0
2016-10-13T04:07:42Z
40,013,698
<h2>Subprocess</h2> <p>You can use <code>subprocess.Popen</code>, as you tried, to run a different script concurrently:</p> <pre><code>the_other_process = subprocess.Popen(['python', 'cleaner.py']) </code></pre> <p>That line alone does what you want. What you <strong>don't want to</strong> do is:</p> <pre><code>the...
1
2016-10-13T06:24:08Z
[ "python", "concurrency", "subprocess" ]
url encoding in python and sqlite web app
40,012,153
<p>am new to python and am trying to build a blog kind of web app, my major problem is that I want the title of the each post to be its link which I would store in my database. I am using the serial number of each post as the url, but it doesn't meet my needs. Any help is appreciated.</p>
0
2016-10-13T04:10:22Z
40,012,208
<p>If I understand your right what you are looking for is to store a slug. There's a package that can help you with this.</p> <p><a href="https://github.com/un33k/python-slugify" rel="nofollow">https://github.com/un33k/python-slugify</a></p> <p>Hope it helps!</p>
0
2016-10-13T04:17:31Z
[ "python", "url", "web-applications" ]
Parsing through JSON file with python and selecting multiple values on certain conditions
40,012,289
<p>I have this JSON file. </p> <pre><code>{ "reviewers":[ { "user":{ "name":"keyname", "emailAddress":"John@email", "id":3821, "displayName":"John Doe", "active":true, "slug":"jslug", "type":"NORMAL", ...
0
2016-10-13T04:26:57Z
40,012,381
<p>You probably want something along the lines of this:</p> <pre><code>def get_reviewers(stash_json): reviewers = "" for item in stash_json["reviewers"]: if item["approved"]: reviewers += item["user"]["displayName"] + "(A)" + ", " else: reviewers += item["user"]["display...
2
2016-10-13T04:36:19Z
[ "python", "json" ]
Parsing through JSON file with python and selecting multiple values on certain conditions
40,012,289
<p>I have this JSON file. </p> <pre><code>{ "reviewers":[ { "user":{ "name":"keyname", "emailAddress":"John@email", "id":3821, "displayName":"John Doe", "active":true, "slug":"jslug", "type":"NORMAL", ...
0
2016-10-13T04:26:57Z
40,012,524
<p>This looks like a good place to use <code>join</code> and list comprehension:</p> <pre><code>def get_reviewers(stash_json): return ", ".join([item['user']['displayName'] + ('(A)' if item['approved'] else '') for item in stash_json['reviewers']]) </code></pre>
0
2016-10-13T04:51:03Z
[ "python", "json" ]
Authenticate via XMLRPC in Odoo from a PHP system
40,012,293
<p>I would like to authenticate into Odoo via xmlrpc but as a SSO kind of implementation. The credentials of the users will be the same in both Odoo and PHP, so basically there will be a redirection to Odoo from the php system when the user is logged in there. The thing is since the passwords are hashed at both the PHP...
0
2016-10-13T04:27:14Z
40,014,473
<p>Odoo supports other authentication mechanisms than local passwords, out-of-the-box:</p> <ul> <li>LDAP authentication is provided by the built-in <a href="https://www.odoo.com/apps/modules/8.0/auth_ldap/" rel="nofollow"><code>auth_ldap</code></a> module. It requires an external LDAP service, such as <a href="http://...
0
2016-10-13T07:09:33Z
[ "php", "python", "openerp", "odoo-8", "xml-rpc" ]
How to add numbers to x axis instead of year in morris line chart?
40,012,355
<p>I have added morris line chart in my python project. I want x-axis in the interval of 5-10-15-20-15-30. And not in the year format. How to do it?</p> <pre><code>$(document).ready(function(){ Morris.Line({ element: 'line-example', data: [ { y: '5', a: {{count5}}, b: {{count...
0
2016-10-13T04:34:15Z
40,015,984
<p>Simply set the <code>parseTime</code> parameter to <code>false</code>:</p> <pre><code>parseTime: false </code></pre> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>Morris.L...
1
2016-10-13T08:31:03Z
[ "python", "html", "jquery-ui", "morris.js" ]
django models manager for content type models
40,012,394
<p>I am currently writing a Django Application to contain all the Content Type Models(generic relations)</p> <pre><code>from django.db import models from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.models import ContentType from django.core.validators i...
0
2016-10-13T04:38:09Z
40,012,923
<p>Thanks to <a href="http://stackoverflow.com/users/5662309/ticktomp">TickTomp</a> I was able to figure out that instead of making a MagicMock(User_Info), I should have actually made an instance of User_Info class to test. The test ran fine afterwards...</p>
0
2016-10-13T05:27:22Z
[ "python", "django", "django-models", "django-testing" ]
Append to a list of dictionaries in python
40,012,415
<pre><code>self.LOG_DIR_LIST_BACKEND = [AMPLI_LOG, VAR_LOG, CORE_DUMP_LOG] backend_nodes = [backend-1, backend-2, backend-3] self.log_in_nodes = [] log_file = {} for LOG_DIR_BACKEND in self.LOG_DIR_LIST_BACKEND: for node_backend in backend_nodes: log_in_nodes 'find %s -type f -name \"*log.*.gz\"' % LOG_DIR...
-1
2016-10-13T04:39:46Z
40,012,793
<p>Every time you run this method, it will reset <code>self.log_in_nodes</code>, because you are doing:</p> <pre><code>self.log_in_nodes = [] </code></pre> <p>If you want to append stuff to that list, either make this like a class variable or put it outside the class, and initialize only once.</p> <p>Option one:</p>...
0
2016-10-13T05:15:04Z
[ "python" ]
python : cant open file 'hw.py': [Errno 2] No such file or directory
40,012,445
<p><a href="https://i.stack.imgur.com/HyEHd.png" rel="nofollow">here my output looks like, please see this image</a>as I m new in this programing world, I m trying to do some python code, but it seems like my raspberry pi doesn't recognise my folder here it looks like python : cant open file 'hw.py': [Errno 2] No suc...
-1
2016-10-13T04:42:59Z
40,012,468
<p>Okay so you need to save the file in the same directory as your IDE.</p>
0
2016-10-13T04:46:23Z
[ "python", "opencv", "raspberry-pi", "raspberry-pi3" ]
replace values in list of python dictionaries
40,012,502
<p>So I have a huge list of dictionaries and I want to: </p> <ul> <li>change asterixs into the integer "4"</li> <li>change all spaces "" to the integer "0"</li> <li>change all other numbers to integers</li> </ul> <p>(this is only a portion of the list)</p> <pre><code> clean_dict= [{'origin': 'Various/Unknown', 'idps...
0
2016-10-13T04:49:25Z
40,012,963
<p>I guess this is what you want.</p> <pre><code>clean_dict= [{'origin': 'Various/Unknown', 'idps': '', 'year': '1951', 'total': '180000', 'stateless': '', 'ret_refugees': '', 'asylum': '', 'country': 'Australia', 'others': '', 'ret_idps': '', 'refugees': '180000'}, {'origin': 'Various/Unknown', 'idps': '', 'year': '1...
0
2016-10-13T05:30:43Z
[ "python", "list", "dictionary", "replace" ]
replace values in list of python dictionaries
40,012,502
<p>So I have a huge list of dictionaries and I want to: </p> <ul> <li>change asterixs into the integer "4"</li> <li>change all spaces "" to the integer "0"</li> <li>change all other numbers to integers</li> </ul> <p>(this is only a portion of the list)</p> <pre><code> clean_dict= [{'origin': 'Various/Unknown', 'idps...
0
2016-10-13T04:49:25Z
40,013,033
<p>Assuming you're using Python 3 try this. For Python 2.x the main difference is to use <code>iteritems()</code> instead of <code>items()</code> but the rest should remain the same.</p> <pre><code>for dict in clean_dict: for k,v in dict.items(): if v == '*': dict[k] = 4 elif v == '': ...
0
2016-10-13T05:36:21Z
[ "python", "list", "dictionary", "replace" ]
Extract keys from elasticsearch result and store in other list
40,012,550
<p>I have a ES returned list stored in a dict </p> <pre><code>res = es.search(index="instances-i*",body=doc) </code></pre> <p>The result returned by res looks like: </p> <pre><code>{ "took": 34, "timed_out": false, "_shards": { "total": 1760, "successful": 1760, "failed": 0 }, "hits": { "total": 551, "max_score": 0....
0
2016-10-13T04:53:17Z
40,013,118
<p>To store the value of <code>WEB_URL</code> you need to iterate over the dictionary-</p> <pre><code>data = response_from_es['hits'] list_of_urls = [] for item in data['hits']: list_of_urls.append(item['_source']['ansible']['WEB_URL']) print list_of_urls </code></pre> <p>And to make the <code>list_of_urls uniqu...
3
2016-10-13T05:41:28Z
[ "python", "dictionary" ]
Trouble sending np.zeros through to tf.placeholder
40,012,599
<p>I've been learning tensorflow recently and I'm having trouble sending the appropriately sized and typed numerical data through to the placeholder in tensorflow. This code has been adapted from <a href="https://github.com/SullyChen/Nvidia-Autopilot-TensorFlow" rel="nofollow">https://github.com/SullyChen/Nvidia-Autopi...
0
2016-10-13T04:57:28Z
40,013,261
<p>My problem was that I was updating the placeholder inside the class, a definite no-no. I just changed </p> <pre><code>self.c_state = tf.mul(ingate, cgate) + tf.mul(fgate, self.c_state) </code></pre> <p>to</p> <pre><code>self.new_c_state = tf.mul(ingate, cgate) + tf.mul(fgate, self.c_state) </code></pre> <p>and</...
0
2016-10-13T05:51:51Z
[ "python", "numpy", "tensorflow" ]
Generate meaningful text from random letters
40,012,656
<p>Is there's someway to generate a meaningful text from random letters as ex. if I type </p> <blockquote> <p>sbras</p> </blockquote> <p>the program should give this or something similar </p> <blockquote> <p>saber</p> </blockquote> <p>if the above request can't get a good answer , then</p> <p>I like the gene...
-1
2016-10-13T05:03:41Z
40,013,325
<p>As for your first question: Well, that depends on how specifically you want it. If you want to do it real-time, i.e. you want proper words to appear as you type random stuff, well, good luck with that. If you have a text with random letters, you could afterwards look for proper anagrams of every word in the text. Yo...
0
2016-10-13T05:57:52Z
[ "python", "random", "programming-languages", "dynamically-generated" ]
Problems while installing StanfordCoreNLP in OSX: How to set up the environment variables for jupyter/pycharm?
40,012,711
<p>I downloaded and installed the <a href="http://nlp.stanford.edu/software/CRF-NER.shtml" rel="nofollow">StanfordCoreNLP</a> as <a href="https://gist.github.com/alvations/e1df0ba227e542955a8a" rel="nofollow">follows</a>:</p> <pre><code>$ cd $ wget http://nlp.stanford.edu/software/stanford-ner-2015-12-09.zip $ unzip s...
1
2016-10-13T05:07:52Z
40,019,383
<p>Look like you're starting the notebook server from the GUI. The problem is that in OS X, the GUI does not inherit the environment of the shell. You can immediately get it to work by starting the notebook server from the terminal:</p> <pre><code>jupyter notebook &lt;path-to-notebook-folder&gt; &amp; </code></pre> <...
2
2016-10-13T11:10:33Z
[ "python", "osx", "environment-variables", "nltk", "stanford-nlp" ]
Operations in multi index dataframe pandas
40,012,740
<p>I need to process geographic and statistical data from a big data csv. It contains data from geographical administrative and geostatistical. Municipality, Location, geostatistical basic division and block constitute the hierarchical indexes.</p> <p>I have to create a new column ['data2'] for every element the max v...
1
2016-10-13T05:10:39Z
40,014,671
<p>You can first create <code>mask</code> from <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.MultiIndex.html" rel="nofollow"><code>MultiIndex</code></a>, compare with <code>0</code> and check at least one <code>True</code> (at least one <code>0</code>) by <a href="http://pandas.pydata.org/pandas...
1
2016-10-13T07:20:25Z
[ "python", "pandas" ]
How to save a previous command line argument
40,012,745
<p>I'm writing my first python command line tool using docopt and have run into an issue. </p> <p>My structure is like this:</p> <pre><code>Usage: my-tool configure my-tool [(-o &lt;option&gt; | --option &lt;option&gt;)] ... </code></pre> <p>I'm trying to find a way to run <code>my-tool -o foo-bar</code> first...
3
2016-10-13T05:11:01Z
40,013,319
<p>Since you run this on 2 different instances it might be best to store the values in some sort of config/json file that will be cleared each time you run "configure".</p> <pre><code>import json def configure(config_file): print config_file[opt_name] # do something with options in file # clear config file ...
1
2016-10-13T05:57:22Z
[ "python", "python-2.7", "command-line-interface", "docopt" ]
How to save a previous command line argument
40,012,745
<p>I'm writing my first python command line tool using docopt and have run into an issue. </p> <p>My structure is like this:</p> <pre><code>Usage: my-tool configure my-tool [(-o &lt;option&gt; | --option &lt;option&gt;)] ... </code></pre> <p>I'm trying to find a way to run <code>my-tool -o foo-bar</code> first...
3
2016-10-13T05:11:01Z
40,018,475
<p>I tried writing some script to help you but it was a bit beyond my (current) Newbie skill level. However, the tools/approach I started taking may be able to help. Try using <code>sys.argv</code> (which generates a list of all arguments from when the script is run), and then using some regular expressions (<code>impo...
0
2016-10-13T10:28:41Z
[ "python", "python-2.7", "command-line-interface", "docopt" ]
Divide values divided by tab, in their own variable
40,012,853
<p>I create an output file in a different process, which has 2 values with a tab separating each other. Each line has 2 values and newline, so you always have 2 values per line.</p> <p>I would like to get the first and second value in 2 different variables, and use them; but I am having hard time to split them.</p> <...
0
2016-10-13T05:20:03Z
40,012,873
<p>Assuming all your lines are stored in a list called <code>my_lines</code> you can do:</p> <pre><code>for line in my_lines: val1, val2 = line.strip().split("\t", 1) </code></pre>
1
2016-10-13T05:22:36Z
[ "python", "file", "split" ]
Divide values divided by tab, in their own variable
40,012,853
<p>I create an output file in a different process, which has 2 values with a tab separating each other. Each line has 2 values and newline, so you always have 2 values per line.</p> <p>I would like to get the first and second value in 2 different variables, and use them; but I am having hard time to split them.</p> <...
0
2016-10-13T05:20:03Z
40,012,931
<p>You can try:</p> <pre><code>&gt;&gt;&gt; s = """This is demo string""" &gt;&gt;&gt; s.split("\t") ['This ', 'is ', 'demo ', 'string'] </code></pre>
1
2016-10-13T05:27:58Z
[ "python", "file", "split" ]
Divide values divided by tab, in their own variable
40,012,853
<p>I create an output file in a different process, which has 2 values with a tab separating each other. Each line has 2 values and newline, so you always have 2 values per line.</p> <p>I would like to get the first and second value in 2 different variables, and use them; but I am having hard time to split them.</p> <...
0
2016-10-13T05:20:03Z
40,012,970
<p>you can do like:</p> <pre><code>with open("file.txt", "r") as f: for line in f: value1, value2 = line.strip().split("\t", maxsplit=1) #print(value1, value2) </code></pre> <p><code>maxsplit=1</code> keyword argument ensures that you split only once since you said you only have two values which are tab s...
1
2016-10-13T05:31:04Z
[ "python", "file", "split" ]
Flask app is not start over twisted 16.4.X as wsgi
40,012,956
<p>I have simple Flask app test.py:</p> <pre><code>from flask import Flask app = Flask(__name__) @app.route('/') def test(): return 'Hello world!' if __name__ == '__main__': app.run() </code></pre> <p>Run over twisted 16.3.0 work fine:</p> <pre><code>twistd -n web --port 5000 --wsgi test.app </code></pre>...
0
2016-10-13T05:30:08Z
40,013,084
<p>Your are likely picking up the <code>test</code> module which is part of the Python standard library. Rename your code file (module) to something else. You also may need to set <code>PYTHONPATH</code> so it looks in the directory where code module is.</p>
0
2016-10-13T05:39:01Z
[ "python", "flask", "twisted", "wsgi" ]
Importing packages causes Unicode error in Anaconda
40,013,060
<p>In my program when I type: import matplotlib as pt, I get the following error:</p> <pre><code> File "C:\Users\hh\Anaconda3\lib\site-packages\numpy\__config__.py", line 5 blas_mkl_info={'libraries': ['mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll'], 'library_dirs': ['C:\Users\hh\Anaconda3\\Library\...
0
2016-10-13T05:37:41Z
40,013,834
<p>You're missing (several) escape-backslashes in your path strings:</p> <pre><code>'C:\Users\hh\Anaconda3\\Library\\lib' </code></pre> <p>Here python will attempt to interprete <code>\U</code> as the start of a unicode escape sequence (see e.g. <a href="https://docs.python.org/2/reference/lexical_analysis.html#strin...
1
2016-10-13T06:33:28Z
[ "python", "anaconda" ]
convert an unfair coin into a fair coin in Python 2.7
40,013,074
<p>Using Python 2.7. Suppose I have an unfair coin and I want to turn it into a fair coin using the following way,</p> <ol> <li>Probability of generating head is equal for unfair coin;</li> <li>Flip unfair coin and only accept head;</li> <li>When a head is appearing, treat it as 1 (head for virtual fair coin), when an...
1
2016-10-13T05:38:30Z
40,013,248
<p><a href="http://www.billthelizard.com/2009/09/getting-fair-toss-from-biased-coin.html" rel="nofollow">Getting a Fair Toss From a Biased Coin</a> explains a simple algorithm for turning a biased coin into a fair coin:</p> <ol> <li>Flip the coin twice.</li> <li>If both tosses are the same (heads-heads or tails-tails)...
2
2016-10-13T05:51:08Z
[ "python", "algorithm", "python-2.7", "probability", "coin-flipping" ]
convert an unfair coin into a fair coin in Python 2.7
40,013,074
<p>Using Python 2.7. Suppose I have an unfair coin and I want to turn it into a fair coin using the following way,</p> <ol> <li>Probability of generating head is equal for unfair coin;</li> <li>Flip unfair coin and only accept head;</li> <li>When a head is appearing, treat it as 1 (head for virtual fair coin), when an...
1
2016-10-13T05:38:30Z
40,014,058
<p>An alternative implementation of @Barmar's answer that avoids the recursive call (even though it may be harmless)</p> <pre><code>def fairCoin(): coin1 = 0 coin2 = 0 while coin1 == coin2: coin1 = unfairCoin() coin2 = unfairCoin() return coin1 </code></pre>
2
2016-10-13T06:45:21Z
[ "python", "algorithm", "python-2.7", "probability", "coin-flipping" ]
File's Data keeps getting overwritten by function
40,013,190
<p>for some reason I am running into an issue where my function call seems to be overwriting the data read in from the file without me asking it to. I am trying to get the sum of the original list but I keep getting the sum of the squared list. </p> <p><strong>CODE:</strong></p> <pre><code>def toNumbers(strList): ...
0
2016-10-13T05:46:21Z
40,013,307
<p>Your squareEach function modifies the original list which is passed to it. To see what's going, consider adding a print between your function calls. <code> def main(): file=open("numbers.txt","r").readline().split(" ") print(str(squareEach(file))) print(str(file)) print(str(sumLis...
2
2016-10-13T05:56:38Z
[ "python", "file-io" ]
File's Data keeps getting overwritten by function
40,013,190
<p>for some reason I am running into an issue where my function call seems to be overwriting the data read in from the file without me asking it to. I am trying to get the sum of the original list but I keep getting the sum of the squared list. </p> <p><strong>CODE:</strong></p> <pre><code>def toNumbers(strList): ...
0
2016-10-13T05:46:21Z
40,013,641
<p>I am not sure whether i am helping . But whatever you are trying to do can be done as follows</p> <pre><code>file=open("numbers.txt","r").readline().split(" ") print ([int (m)**2 for m in file]) print (sum([int(m) for m in file])) </code></pre> <p>And if you want functions</p> <pre><code>def squareEach(file): ...
0
2016-10-13T06:19:34Z
[ "python", "file-io" ]
File's Data keeps getting overwritten by function
40,013,190
<p>for some reason I am running into an issue where my function call seems to be overwriting the data read in from the file without me asking it to. I am trying to get the sum of the original list but I keep getting the sum of the squared list. </p> <p><strong>CODE:</strong></p> <pre><code>def toNumbers(strList): ...
0
2016-10-13T05:46:21Z
40,013,680
<p>The list <code>nums</code> is modified in <code>squareEach</code> method. Consider storing the results in a different list variable of the below sort:</p> <pre><code>def squareEach(nums): sq = list() for i in range(len(nums)): sq.append(str(int(nums[i])**2)) # nums[i] = str(int(nums[i])**2) ...
0
2016-10-13T06:22:58Z
[ "python", "file-io" ]
I can't delete data multiple in mysql from python
40,013,196
<p><strong>I made input 2 value row and num when input data so program throw Rollback not work if-else and thank for help</strong></p> <pre><code>#!/usr/bin/python import mysql.connector conn = mysql.connector.connect(host="",user="",passwd="",db="") cursor = conn.cursor() try: row = raw_input("InputNameRow : ...
0
2016-10-13T05:46:58Z
40,013,464
<p>Try :</p> <pre><code>cursor.execute(sqlde) </code></pre> <p>instead of </p> <pre><code>cursor.execute(sqlde, (num)) </code></pre>
2
2016-10-13T06:06:49Z
[ "python", "mysql" ]
calling virtualenv bundled pip wuth subprocess.call fails on long path to venv directory on Linux
40,013,347
<p>The following line throws strange exceptions in Linux (several Ubuntu 14.04 installations and one Arch linux installation with all updates installed):</p> <pre><code>subprocess.call(['/home/vestnik/Development/test/python/subdir/subdir/subdir/subdir/subdir/subdir/subdir/subdir/subdir/subdir/venv/bin/pip','install',...
0
2016-10-13T05:58:59Z
40,014,028
<p>When I've tried to call pip in venv from bash I got bad interpretator error.</p> <p>The real source of the problem is shebang string length limitation (the comment to accepted answer <a href="http://stackoverflow.com/questions/10813538/shebang-line-limit-in-bash-and-linux-kernel">here</a> claims default limit to be...
0
2016-10-13T06:43:51Z
[ "python", "linux", "subprocess", "virtualenv" ]
selenium python webscrape fails after first iteration
40,013,400
<p>Im iterating through tripadvisor to save comments(non-translated, original) and translated comments (from portuguese to english). So the scraper first selects portuguese comments to be displayed , then as usual it converts them into english one by one and saves the translated comments in com_, whereas the expanded n...
1
2016-10-13T06:02:24Z
40,019,493
<p>There are 3 problems in your code</p> <ol> <li>Inside method <code>save_comments()</code>, at the <code>driver.find_element_by_class_name("ui_close_x").click().perform()</code>, the method <code>click()</code> of a webelement is not an ActionChain so you cannot call <code>perform()</code>. Therefore, that line shou...
1
2016-10-13T11:16:46Z
[ "python", "selenium", "web-scraping" ]
StopValidation() In route without raiseing wsgi debuger flask wtf
40,013,443
<p>I need to overwrite the Vlaidator in the form and apply my own validator this specific route. When the image uploaded is not a jpg then it will not pass the form.validate_on_submit() check and the template will render the errors in the html. When i try to use</p> <pre><code> raise StopValidation("image1 jpg only...
0
2016-10-13T06:05:24Z
40,035,652
<p>If you want to validate only jpg file, then make a custom validation instead of using StopValidation and just define in your form.</p> <pre><code>def customvalidatorForImage(form, field): allowed_file = ['jpg','jpeg','png','gif'] # you can modify your valid file list here if form.image.data: if for...
0
2016-10-14T05:37:41Z
[ "python", "wtforms", "flask-wtforms" ]
I am not able get the sorted values from the input
40,013,529
<p>problem with sorting</p> <pre><code>a = raw_input("Do you know the number of inputs ?(y/n)") if a == 'y': n = int(input("Enter the number of inputs : ")) total = 0 i = 1 while i &lt;= n: s = input() total = total + int(s) i = i + 1 s.sort() print s ...
0
2016-10-13T06:10:37Z
40,013,811
<pre><code>n = int(input("Enter the number of inputs : ")) total = 0 i = 1 array = [] while i &lt;= n: s = int(input()) array.append(s) total = total + int(s) i = i + 1 array.sort() print(array) print('The sum is ' + str(total)) </code></pre> <p>this will solve your problem, sort applies on list not o...
0
2016-10-13T06:31:45Z
[ "python" ]
I am not able get the sorted values from the input
40,013,529
<p>problem with sorting</p> <pre><code>a = raw_input("Do you know the number of inputs ?(y/n)") if a == 'y': n = int(input("Enter the number of inputs : ")) total = 0 i = 1 while i &lt;= n: s = input() total = total + int(s) i = i + 1 s.sort() print s ...
0
2016-10-13T06:10:37Z
40,013,815
<p>Because you are trying to <code>sort</code> on input. <code>sort</code> only work on iterating like list and tuples. </p> <p>I just rewrite your code,</p> <pre><code>a = raw_input("Do you know the number of inputs ?(y/n)") if a == 'y': n = int(input("Enter the number of inputs : ")) inputs = [] for i...
0
2016-10-13T06:32:03Z
[ "python" ]
I am not able get the sorted values from the input
40,013,529
<p>problem with sorting</p> <pre><code>a = raw_input("Do you know the number of inputs ?(y/n)") if a == 'y': n = int(input("Enter the number of inputs : ")) total = 0 i = 1 while i &lt;= n: s = input() total = total + int(s) i = i + 1 s.sort() print s ...
0
2016-10-13T06:10:37Z
40,013,985
<p>Store the numbers in a list. Then use sum(list) to get the sum of elements in the list, and sorted(list) to get the list sorted in ascending order.</p> <pre><code> n = int(input("Enter the number of inputs: ")) l=[] for i in range(n): s = input() l.append(int(s)) print('The sum i...
0
2016-10-13T06:41:50Z
[ "python" ]
Python Adding 2 list with common keys to dictionary
40,013,642
<p>I am new to python. I'm extracting two rows from a csvfile.</p> <pre><code>Foodlist = ['apple, carrot, banana','chocolate, apple', 'strawberry, orange, carrot'] </code></pre> <p>And the quantity list corresponds to each of the items in its sequence.</p> <pre><code>Quantity = ['1,2,1','2,5','1,2'] </code></pre> <...
0
2016-10-13T06:20:02Z
40,013,884
<p>You can use <a href="https://docs.python.org/3/library/collections.html#collections.Counter" rel="nofollow"><code>Counter</code></a> to aggregate the result:</p> <pre><code>from collections import Counter Foodlist = ['apple, carrot, banana','chocolate, apple', 'strawberry, orange, carrot'] Quantity = ['1,2,1','2,5...
1
2016-10-13T06:36:51Z
[ "python", "list", "csv", "dictionary", "key" ]
Python Adding 2 list with common keys to dictionary
40,013,642
<p>I am new to python. I'm extracting two rows from a csvfile.</p> <pre><code>Foodlist = ['apple, carrot, banana','chocolate, apple', 'strawberry, orange, carrot'] </code></pre> <p>And the quantity list corresponds to each of the items in its sequence.</p> <pre><code>Quantity = ['1,2,1','2,5','1,2'] </code></pre> <...
0
2016-10-13T06:20:02Z
40,013,887
<p>Use collections.default_dict to set up a dictionary to count your items in.</p> <pre><code>In [1]: from collections import defaultdict In [2]: items = defaultdict(int) In [3]: Foodlist = ['apple, carrot, banana','chocolate, apple', 'strawberry, or ...: ange, carrot'] In [4]: Quantity = ['1,2,1','2,5','1,2'] ...
1
2016-10-13T06:37:00Z
[ "python", "list", "csv", "dictionary", "key" ]
How to implement a message system?
40,013,849
<p>I am running a website where user can send in-site message (no instantaneity required) to other user, and the receiver will get a notification about the message.</p> <p>Now I am using a simple system to implement that, detail below.</p> <p>Table <code>Message</code>:</p> <ul> <li>id</li> <li>content</li> <li>rece...
0
2016-10-13T06:34:34Z
40,015,293
<p>I think you will need to read about pub/sub for messaging services. For php, you can use libraries such as redis.</p> <p>So for e.g, user1 subscribe to topic1, any user which publish to topic1, user1 will be notified, and you can implement what will happen to the user1.</p>
0
2016-10-13T07:54:43Z
[ "php", "python", "web", "messagebox" ]
parameters for google cloud natural language api
40,013,944
<p>I want to use pure http requests to get the result from google cloud natural language api, but their document does not specify the parameter names.</p> <p>Here is my python code:</p> <pre><code>import requests url = "https://language.googleapis.com/v1beta1/documents:analyzeEntities" d = {"document": {"content": "s...
0
2016-10-13T06:39:24Z
40,014,342
<p>ok, I figured it out. I need to pass JSON-Encoded POST/PATCH data, so the request should be <code>r = requests.post(url, params=para, json=d)</code></p>
0
2016-10-13T07:02:18Z
[ "python", "rest", "google-api", "google-cloud-platform" ]
How to clean up upon a crash?
40,013,946
<p>I would like some clean-up activities to occur in case of crash of my program. I understand that some situations cannot be handled (a <code>SIGKILL</code> for instance) but I would like to cover as much as possible.</p> <p>The <a href="https://docs.python.org/3.5/library/atexit.html#module-atexit" rel="nofollow"><c...
0
2016-10-13T06:39:26Z
40,014,076
<p><code>SIGKILL</code> <a href="https://en.m.wikipedia.org/wiki/Unix_signal#SIGKILL" rel="nofollow">cannot be handled</a>, no matter what, your program is just terminated (killed violently), and you can do nothing about this. </p> <p>The only thing you can do about <code>SIGKILL</code> is to look for data that needs ...
0
2016-10-13T06:46:32Z
[ "python", "python-3.x", "crash", "code-cleanup" ]
How to read csv file as dtype datetime64?
40,013,975
<p>Now I have csv file </p> <pre><code> date 201605 201606 201607 201608 </code></pre> <p>I wanna get dataframe like this</p> <p>df</p> <pre><code> date 0 2016-05-01 1 2016-06-01 2 2016-07-01 3 2016-08-01 </code></pre> <p>so,I would like to read csvfile as datetime64. and add the date 1. How can I read an...
1
2016-10-13T06:41:28Z
40,014,033
<p>Maybe this answer will help you to convert your column to datetime object <a href="http://stackoverflow.com/a/26763793/5982925">http://stackoverflow.com/a/26763793/5982925</a></p>
1
2016-10-13T06:43:59Z
[ "python", "csv", "parsing", "datetime", "pandas" ]
How to read csv file as dtype datetime64?
40,013,975
<p>Now I have csv file </p> <pre><code> date 201605 201606 201607 201608 </code></pre> <p>I wanna get dataframe like this</p> <p>df</p> <pre><code> date 0 2016-05-01 1 2016-06-01 2 2016-07-01 3 2016-08-01 </code></pre> <p>so,I would like to read csvfile as datetime64. and add the date 1. How can I read an...
1
2016-10-13T06:41:28Z
40,014,048
<p>You can use parameter <code>date_parser</code> in <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow"><code>read_csv</code></a>:</p> <pre><code>import sys if sys.version_info.major&lt;3: from StringIO import StringIO else: from io import StringIO import pandas...
1
2016-10-13T06:44:41Z
[ "python", "csv", "parsing", "datetime", "pandas" ]
Python-Flask not accepting custom fonts
40,013,987
<p> Folder Blueprint <br></p> <p>Templates</p> <ul> <li>File.html<br></li> </ul> <p>Static</p> <ul> <li>Fonts</li> <li>Style</li> </ul> <p>In the css file , i tried :</p> <pre><code>@font-face{ font-family:&lt;Font_name&gt; src:{{ url_for('static',filename='fonts/&lt;font_name&gt;.ttf') }} ; } </code></pre> <p>W...
0
2016-10-13T06:41:57Z
40,015,356
<p>You can't use template tags in css. the Jinja template tags are only meant for html files and templates not css.</p> <p>To use a css file, you have to insert the link manually there, something along the lines of:</p> <pre><code>@font-face{ font-family:customfont src:/static/Fonts/font.ttf') }} ; } </code></pre> <...
0
2016-10-13T07:58:04Z
[ "python", "flask" ]
Python 3.5.2 - How to detect a program running i.e "chrome.exe" using stock modules
40,014,042
<p>If I wanted to have a program that detects program running such as 'chrome.exe' then opens a program <code>message.txt</code> in this case</p> <p>Psuedocode:</p> <pre><code>import os if "chrome.exe" is running: os.startfile("message.txt") </code></pre>
0
2016-10-13T06:44:22Z
40,015,194
<p>You could use wmi package to check running process in windows like below snippet.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>import wmi c = wmi.WMI() for p...
0
2016-10-13T07:48:51Z
[ "python" ]
Python 3.5.2 - How to detect a program running i.e "chrome.exe" using stock modules
40,014,042
<p>If I wanted to have a program that detects program running such as 'chrome.exe' then opens a program <code>message.txt</code> in this case</p> <p>Psuedocode:</p> <pre><code>import os if "chrome.exe" is running: os.startfile("message.txt") </code></pre>
0
2016-10-13T06:44:22Z
40,015,344
<p>You could you below too as <a href="http://stackoverflow.com/users/1832058/furas">furas</a> said. Thanks furas. :smile:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><cod...
0
2016-10-13T07:57:29Z
[ "python" ]
how can I plot values with big variance using matplotlib
40,014,142
<p>The values of Y are like <code>[0, 2, 38, 47, 123, 234, 1003, 100004, 50000003, 1000000004]</code></p> <p>The figure I want to get is just as following:</p> <p><a href="https://i.stack.imgur.com/SSHCO.png" rel="nofollow"><img src="https://i.stack.imgur.com/SSHCO.png" alt="logplot"></a></p>
0
2016-10-13T06:50:33Z
40,014,190
<p>From the examples <a href="http://matplotlib.org/examples/pylab_examples/log_demo.html" rel="nofollow">here</a></p> <pre><code># log y axis import matplotlib.pyplot as plt import numpy as np t = np.arange(0.01, 20.0, 0.01) plt.subplot(221) plt.semilogy(t, np.exp(-t/5.0)) plt.title('semilogy') plt.grid(True) plt.sh...
4
2016-10-13T06:52:59Z
[ "python", "matplotlib", "plot" ]
Upload Image in Django ImageField
40,014,178
<p>I'm try to test my model with ImageField, for this purpose i'm reading .jpg file in binary mode and save in the model. I find a lot of question in StackOverflow, but nothing seems to work for me.</p> <pre><code>testImagePath = os.path.join(settings.BASE_DIR, 'test_image_folder/test_image.jpg') "image" : SimpleUplo...
2
2016-10-13T06:52:34Z
40,050,146
<p>ImageField need to obtain file, not data. This solve the problem:</p> <pre><code>"image" : open(os.path.join(settings.BASE_DIR, 'test_image_folder/test_image.jpg'), 'rb') </code></pre>
0
2016-10-14T18:49:18Z
[ "python", "django" ]
calling values from dict and changing values in a list
40,014,191
<p>I have a list of DNA sequences like this: very small example:</p> <pre><code>&gt; seq = ['ATGGCGGCGCGA', 'GCCTCTGCCTTG', 'CTGAAAACG'] </code></pre> <p>and if you divide the number of characters in each sequence by 3 you would get even number. I also have this dictionary which is codons and amino acids. </p> <pre...
1
2016-10-13T06:53:01Z
40,014,260
<p>Sure (maybe there's a more pythonic way of doing that but that is simple and works):</p> <pre><code>seq = ['ATGGCGGCGCGA', 'GCCTCTGCCTTG', 'CTGAAAACG'] gencode = { 'ATA':'I', 'ATC':'I', 'ATT':'I', 'ATG':'M', 'ACA':'T', 'ACC':'T', 'ACG':'T', 'ACT':'T', 'AAC':'N', 'AAT':'N', 'AAA':'K', 'AAG':'K', 'AGC...
1
2016-10-13T06:57:13Z
[ "python" ]
calling values from dict and changing values in a list
40,014,191
<p>I have a list of DNA sequences like this: very small example:</p> <pre><code>&gt; seq = ['ATGGCGGCGCGA', 'GCCTCTGCCTTG', 'CTGAAAACG'] </code></pre> <p>and if you divide the number of characters in each sequence by 3 you would get even number. I also have this dictionary which is codons and amino acids. </p> <pre...
1
2016-10-13T06:53:01Z
40,014,288
<p>You can do one liner with list comprehension:</p> <pre><code>seq = ['ATGGCGGCGCGA', 'GCCTCTGCCTTG', 'CTGAAAACG'] gencode = { 'ATA':'I', 'ATC':'I', 'ATT':'I', 'ATG':'M', 'ACA':'T', 'ACC':'T', 'ACG':'T', 'ACT':'T', 'AAC':'N', 'AAT':'N', 'AAA':'K', 'AAG':'K', 'AGC':'S', 'AGT':'S', 'AGA':'R', 'AGG':'R',...
2
2016-10-13T06:58:55Z
[ "python" ]
calling values from dict and changing values in a list
40,014,191
<p>I have a list of DNA sequences like this: very small example:</p> <pre><code>&gt; seq = ['ATGGCGGCGCGA', 'GCCTCTGCCTTG', 'CTGAAAACG'] </code></pre> <p>and if you divide the number of characters in each sequence by 3 you would get even number. I also have this dictionary which is codons and amino acids. </p> <pre...
1
2016-10-13T06:53:01Z
40,014,441
<p>Define a helper generator to split an iterable into chunks of length 3:</p> <pre><code>def chunks(xs, n): for i in range(0, len(xs), n): yield xs[i:i + n] </code></pre> <p>Replace each chunk with its corresponding amino acid and group them back together:</p> <pre><code>result = [''.join(gencode[c] for...
1
2016-10-13T07:07:48Z
[ "python" ]
Is there a way to define function-dictionaries in android/Java like in python?
40,014,231
<p>In python it is possible to create a dictionary of functions (<code>foo,bar</code>) and call them by accessing the dictionaries element:</p> <pre><code>d = {'a':foo, 'b':bar} d[val]() </code></pre> <p>In this example if <code>var='a'</code> the function <code>foo</code> is called, and if <code>var='b'</code> the f...
0
2016-10-13T06:55:41Z
40,014,286
<p>In Java Dictionaries we will Call it as HashTable / HashMap.</p> <p>Please have a look at this Classes. <a href="https://developer.android.com/reference/java/util/Hashtable.html" rel="nofollow">https://developer.android.com/reference/java/util/Hashtable.html</a></p> <p>Example of HashTable: <a href="https://www.t...
-1
2016-10-13T06:58:50Z
[ "java", "android", "python", "dictionary" ]
Is there a way to define function-dictionaries in android/Java like in python?
40,014,231
<p>In python it is possible to create a dictionary of functions (<code>foo,bar</code>) and call them by accessing the dictionaries element:</p> <pre><code>d = {'a':foo, 'b':bar} d[val]() </code></pre> <p>In this example if <code>var='a'</code> the function <code>foo</code> is called, and if <code>var='b'</code> the f...
0
2016-10-13T06:55:41Z
40,014,313
<p>This is easy in Python because methods are <a href="https://en.wikipedia.org/wiki/First-class_function" rel="nofollow">First-Class Citizens</a>. Whereas in Java, they are not.</p> <p>In Java 8 -however- you can create a <code>Map</code> (in this case a <code>HashMap</code>) of <code>Runnable</code></p> <pre><code...
0
2016-10-13T07:00:49Z
[ "java", "android", "python", "dictionary" ]
Is there a way to define function-dictionaries in android/Java like in python?
40,014,231
<p>In python it is possible to create a dictionary of functions (<code>foo,bar</code>) and call them by accessing the dictionaries element:</p> <pre><code>d = {'a':foo, 'b':bar} d[val]() </code></pre> <p>In this example if <code>var='a'</code> the function <code>foo</code> is called, and if <code>var='b'</code> the f...
0
2016-10-13T06:55:41Z
40,014,319
<pre><code>import java.util.*; class HashMethod { public void foo() { System.out.println("foo"); } public void bar() { System.out.println("bar"); } public static void main(String[] args) throws IllegalAccessException { HashMethod obj = new HashMethod(); Map&lt;Char...
0
2016-10-13T07:01:09Z
[ "java", "android", "python", "dictionary" ]
Momentum portfolio(trend following) quant simulation on pandas
40,014,258
<p>I am trying to construct trend following momentum portfolio strategy based on S&amp;P500 index (momthly data)</p> <p>I used Kaufmann's fractal efficiency ratio to filter out whipsaw signal (<a href="http://etfhq.com/blog/2011/02/07/kaufmans-efficiency-ratio/" rel="nofollow">http://etfhq.com/blog/2011/02/07/kaufmans...
0
2016-10-13T06:57:07Z
40,016,938
<p>You could simplify further by storing the values corresponding to <code>p</code> in a <code>DF</code> rather than computing for each series separately as shown:</p> <pre><code>def fractal(a, p): df = pd.DataFrame() for count in range(1,p+1): a['direction'] = np.where(a['price'].diff(count)&gt;0,1,0)...
1
2016-10-13T09:17:55Z
[ "python", "pandas", "quantitative-finance", "momentum" ]
Change Letters to numbers (ints) in python
40,014,282
<p>This might be python 101, but I am having a hard time changing letters into a valid integer.</p> <p>The put what I am trying to do simply</p> <p>char >> [ ] >> int</p> <p>I created a case statement to give me a number depending on certain characters, so what I tried doing was</p> <pre><code>def char_to_int(some...
-2
2016-10-13T06:58:37Z
40,014,702
<p>in the python console:</p> <p><code>&gt;&gt;&gt; type({ 'Z':1, 'Y':17, 'X':8, 'w':4, }.get('X', '')) &lt;class 'int'&gt;</code></p> <p>so as cdarke suggested, you should look at how you are calling the function.</p>
0
2016-10-13T07:22:16Z
[ "python", "switch-statement" ]
Parse an Nginx log with Python
40,014,283
<p>I have this Log from Nginx server and I need to parse it with Python:</p> <pre><code>2016/10/11 11:15:57 [debug] 44229#0: *45677 SSL_do_handshake: -1 2016/10/11 11:15:57 [debug] 44229#0: *45677 SSL_get_error: 2 2016/10/11 11:15:57 [debug] 44229#0: *45677 post event 0000000001449060 2016/10/11 11:15:57 [debug] 44229...
0
2016-10-13T06:58:40Z
40,051,743
<p>If you just want a comma delimited string to be printed out, you can change the line</p> <pre><code>print &gt;&gt;resultsFile, printList </code></pre> <p>to:</p> <pre><code>print &gt;&gt;resultsFile, ",".join(printList) </code></pre>
1
2016-10-14T20:46:54Z
[ "python", "regex", "parsing", "nginx" ]
Initialize variable depending on another variables type
40,014,390
<p>In Python 2.7 I want to intialize a variables type depending on another variable.</p> <p>For example I want to do something like:</p> <pre><code>var_1 = type(var_2) </code></pre> <p>Is there a simple/fast way to do that?</p>
3
2016-10-13T07:04:48Z
40,014,466
<p>Just create another instance</p> <pre><code>var_1 = type(var_2)() </code></pre> <p>Note that if you're not sure whether the object has a non-default constructor, you cannot rely on the above, but you can use <code>copy</code> or <code>deepcopy</code> (you get a "non-empty" object.</p> <pre><code>import copy var_1...
2
2016-10-13T07:09:07Z
[ "python", "python-2.7" ]
Initialize variable depending on another variables type
40,014,390
<p>In Python 2.7 I want to intialize a variables type depending on another variable.</p> <p>For example I want to do something like:</p> <pre><code>var_1 = type(var_2) </code></pre> <p>Is there a simple/fast way to do that?</p>
3
2016-10-13T07:04:48Z
40,014,469
<pre><code>a = 1 # a is an int a_type = type(a) # a_type now contains the int-type b = '1' # '1' is a string c = a_type(b) # c is now an int with the value 1 </code></pre> <p>So you can get the type of a variable using <code>type()</code>. You can then store this type in a variable and y...
2
2016-10-13T07:09:24Z
[ "python", "python-2.7" ]
How to wait for the site to return the data using Beautifulsoup4
40,014,395
<p>I wrote a script using beautifulsoup4 , the script basically brings the list of ciphers from the table present on a web page. The problem is my python script doesn't wait for the returned content of the web page and either breaks or says 'list index out of range'. The code is as follows: </p> <pre><code>ssl_lab_url...
0
2016-10-13T07:05:00Z
40,014,536
<p>If the data isn't present in the original HTML page but is returned from JS code in the background, consider using a headless browser, such as PhantomJS, with Selenium. <a href="https://realpython.com/blog/python/headless-selenium-testing-with-python-and-phantomjs/" rel="nofollow">Here's an example</a>.</p>
1
2016-10-13T07:13:14Z
[ "python", "beautifulsoup" ]
How to wait for the site to return the data using Beautifulsoup4
40,014,395
<p>I wrote a script using beautifulsoup4 , the script basically brings the list of ciphers from the table present on a web page. The problem is my python script doesn't wait for the returned content of the web page and either breaks or says 'list index out of range'. The code is as follows: </p> <pre><code>ssl_lab_url...
0
2016-10-13T07:05:00Z
40,015,599
<p>I was thinking that this page use JavaScript to get data but it use old HTML method to refresh page. </p> <p>It adds HTML tag <code>&lt;meta http-equiv="refresh" content='**time**; url&gt;</code> and browser will reload page after <strong>time</strong> seconds.</p> <p>You have to check this tag - if you find it th...
1
2016-10-13T08:10:45Z
[ "python", "beautifulsoup" ]
Updating other players screen Django
40,014,528
<p>I am developing a small game with four members for a board. When a player moves something, that move has to updated in remaining players screen(their webpage). I ended up tornado, but I can't find any examples for my case. </p> <p>I need to display the move to all players when a move was saved in DB. Polling DB con...
0
2016-10-13T07:12:45Z
40,017,978
<p>Use websockets instead. Here's the <a href="http://www.tornadoweb.org/en/stable/websocket.html" rel="nofollow">documentation</a> with a simple example.</p>
0
2016-10-13T10:03:01Z
[ "python", "django", "tornado" ]
Matplotlib interpolating / plotting unstructured data
40,014,554
<p>usually, Im working with image data which is in arrays the shape of m x n. Displaying is easy, right?</p> <pre><code>import numpy as np import matplotlib.pyplot as plt #sample data m,n = 10,20 sample = np.random.random((m,n)) plt.imshow(sample) </code></pre> <p>from a different algorith, Im now getting data which...
0
2016-10-13T07:13:52Z
40,017,056
<p>Below is slightly changed example of <a href="http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.interpolate.griddata.html#scipy.interpolate.griddata" rel="nofollow">scipy.interpolate.griddata</a> usage:</p> <pre><code>import numpy as np from scipy.interpolate import griddata import matplotlib.pyplot ...
0
2016-10-13T09:22:51Z
[ "python", "matplotlib" ]
Compile python virtual environment
40,014,823
<p>I created a Python script for a Freelance job and I can't find how to compile/build/package it for easy sharing. The person for which I created it is not a technical one, so I can't explain him how to activate a virtualenv, install requirements and so on.</p> <p>What is the easiest way for him to run the project ri...
0
2016-10-13T07:28:45Z
40,014,914
<p>Yes you can package your python programs and it's dependencies with</p> <p><a href="https://cx-freeze.readthedocs.io/en/latest/" rel="nofollow">Cx_Freeze</a></p> <p>There are other python modules that do the same, personally i prefer <code>cx_Freeze</code> because it's cross platform and was the only one that work...
0
2016-10-13T07:34:01Z
[ "python", "virtualenv" ]
How to redirect Python print commands to putty SSH console?
40,014,826
<p>after many unsuccessful researches I've decided to ask my question here so maybe someone will provide me an answer or a lead for a problem I got.</p> <p>I have a Python script that runs as a background process on an embedded device (the OS is a Linux distro). This script do important measurements and because of tha...
0
2016-10-13T07:28:58Z
40,018,845
<p>As suggested by GhostCat, I've decided to go for a logging solution so anyone who can connect to the device by SSH can just "tail -F" the log file and see the debug messages.</p> <p>I've removed all the print() statements in the code and replaced them by logging calls (which is, indeed, a more professional approach...
0
2016-10-13T10:46:27Z
[ "python", "linux", "ssh", "putty" ]
python-accessing the next object in database while in for loop
40,014,953
<p>This is my view code. I iterate over all the entries in DB and when rollno matches, I want to store the student name for previous,current and next student in one go. Is there any way to implement it?</p> <pre><code>if request.method == 'POST': rollno = request.POST.get('roll',None) studentlist = Stu...
0
2016-10-13T07:35:26Z
40,015,051
<p>Assuming <code>roll_no</code> is incremental then you can just use <code>__in</code></p> <pre><code>Student.objects.filter(roll_no__in=[roll_no - 1, roll_no, roll_no + 1]) </code></pre> <p>If you can't guarrantee they're always incremental then you may need a separate query first to get the roll_no's you're trying...
0
2016-10-13T07:41:02Z
[ "python", "django" ]
python-accessing the next object in database while in for loop
40,014,953
<p>This is my view code. I iterate over all the entries in DB and when rollno matches, I want to store the student name for previous,current and next student in one go. Is there any way to implement it?</p> <pre><code>if request.method == 'POST': rollno = request.POST.get('roll',None) studentlist = Stu...
0
2016-10-13T07:35:26Z
40,015,676
<p>If I understood you correctly this is what you want</p> <pre><code># create generator that will provide you with 3 neighobring students at the same time def student_gen(): triple = [] for s in Students.objects.all(): if len(triple) == 3: triple.pop(0) triple.append(s) ...
0
2016-10-13T08:15:31Z
[ "python", "django" ]
Converting daily data to weekly means and medians
40,014,986
<p>I have a list of dicts like this:</p> <pre><code>[ {'2016-06-11': 10, '2016-06-09': 10, 'ID': 1, '2016-06-04': 10, '2016-06-07': 10, '2016-06-06': 10, '2016-06-01': 10, '2016-06-03': 10, 'type': 'primary', '2016-06-05': 10, '2016-06-10': 10, '2016-06-02'...
2
2016-10-13T07:37:10Z
40,015,340
<p>I think you can <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.resample.html" rel="nofollow"><code>resample</code></a> by <code>months</code>, aggregate <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.tseries.resample.Resampler.mean.html" rel="nofollow"><code>me...
1
2016-10-13T07:57:20Z
[ "python", "date", "pandas", "mean", "median" ]
Python Xlrd and Xlwt
40,014,989
<p>I have the following content in an old Excel sheet:</p> <p><a href="https://i.stack.imgur.com/64eFb.png" rel="nofollow"><img src="https://i.stack.imgur.com/64eFb.png" alt="excel sheet screenshot"></a></p> <p>I need to generate a new Excel sheet with the following values:</p> <p><a href="https://i.stack.imgur.com/...
0
2016-10-13T07:37:20Z
40,022,335
<p>Try the following. This uses the <code>xlrd</code> and <code>xlwt</code> libraries to read and write <code>xls</code> spreadsheets:</p> <pre><code>import xlrd import xlwt wb_in = xlrd.open_workbook(r'input.xls') sheet_name = wb_in.sheet_names()[0] ws_in = wb_in.sheet_by_name(sheet_name) wb_out = xlwt.Workbook() w...
0
2016-10-13T13:26:25Z
[ "python", "xlrd", "xlwt" ]
Selenium not working with python 2.7
40,015,019
<p>I am trying to run a basic selenium code with python 2.7. I got the below exception. I have installed the latest selenium. </p> <p>What should I do to fix it?</p> <pre><code>C:\Python27\python.exe D:/Python/Selenium/seleniumTest.py Traceback (most recent call last): File "D:/Python/Selenium/seleniumTest.py", ...
0
2016-10-13T07:39:15Z
40,015,712
<p>If by latest version you mean the 2.53 you get with <code>pip install selenium</code>, it's a known problem (<a href="https://github.com/SeleniumHQ/selenium/issues/2739" rel="nofollow">https://github.com/SeleniumHQ/selenium/issues/2739</a>), this version does not support the last versions of firefox, and it won't be...
1
2016-10-13T08:16:56Z
[ "python", "python-2.7", "selenium", "firefox" ]
How to print predefined sequence in python
40,015,183
<p>I am trying to print predefined sequence from pdb input file in python but I am not getting expected result. I am new in python, and I have also import directory but its not working. not showing anything (unable to find error). Its just running without any output. </p> <pre><code>import os os.chdir('C:\Users\Vishn...
0
2016-10-13T07:48:12Z
40,015,411
<p>Here are my comments all combined into an answer:</p> <pre><code>with open('1AHI.pdb') as pdbfile: for line in pdbfile: if line[:6] != "HETATM": continue chainID = line[21:22] atomID = line[13:16].strip() if chainID not in ('A', 'B'): continue if a...
1
2016-10-13T08:00:45Z
[ "python", "python-2.7", "python-3.x", "bioinformatics", "biopython" ]
load .mat file from python
40,015,212
<p>I am trying to run from Python a script in Matlab that run a Simulink mode, save a variable as Power.mat and read this variable in Python. I am using Python 2.7 on Windows.</p> <p>I've tried to use the library hdf5storage to read the file:</p> <pre><code>import hdf5storage x=hdf5storage.loadmat('Power.mat','r') </...
0
2016-10-13T07:49:46Z
40,015,513
<p>You can use scipy.io to exchange data between Python and Matlab. There are functions named savemat and loadmat for this purpose. </p> <p>Something like this should work:</p> <pre><code>import scipy.io mat = scipy.io.loadmat('Power.mat') </code></pre> <p>For reference, <a href="http://docs.scipy.org/doc/scipy/refe...
1
2016-10-13T08:06:16Z
[ "python", "matlab", "h5py", "hdf5storage" ]
load .mat file from python
40,015,212
<p>I am trying to run from Python a script in Matlab that run a Simulink mode, save a variable as Power.mat and read this variable in Python. I am using Python 2.7 on Windows.</p> <p>I've tried to use the library hdf5storage to read the file:</p> <pre><code>import hdf5storage x=hdf5storage.loadmat('Power.mat','r') </...
0
2016-10-13T07:49:46Z
40,015,516
<p>Try this code :</p> <pre><code>import h5py Data = h5py.File('File.mat') </code></pre>
0
2016-10-13T08:06:25Z
[ "python", "matlab", "h5py", "hdf5storage" ]
Whey is_leap_year returning None instead of True
40,015,236
<p>Why does this code print None instead of True. It seems that once it checks if it divisible by 4 it does not go on to check the other requirements. From my current understanding, for each successive if statement it should keep going down and checking the next if until one of them is false. At which point it should g...
-1
2016-10-13T07:51:18Z
40,015,272
<blockquote> <p>From my current understanding, for each successive if statement it should keep going down and checking the next if until one of them is false. At which point it should go the the else statement and return False</p> </blockquote> <p>No that isn't completely true. That <code>else</code> block is ...
1
2016-10-13T07:53:41Z
[ "python" ]
Whey is_leap_year returning None instead of True
40,015,236
<p>Why does this code print None instead of True. It seems that once it checks if it divisible by 4 it does not go on to check the other requirements. From my current understanding, for each successive if statement it should keep going down and checking the next if until one of them is false. At which point it should g...
-1
2016-10-13T07:51:18Z
40,015,279
<p>Your function will only return <code>True</code> if the year is divisible by <code>4</code>, <code>100</code> <em>and</em> <code>400</code> and it will return <code>False</code> if the year is not divisible by <code>4</code>.</p> <p>There are a number of cases where you haven't specified the return value (e.g. divi...
1
2016-10-13T07:53:58Z
[ "python" ]
Whey is_leap_year returning None instead of True
40,015,236
<p>Why does this code print None instead of True. It seems that once it checks if it divisible by 4 it does not go on to check the other requirements. From my current understanding, for each successive if statement it should keep going down and checking the next if until one of them is false. At which point it should g...
-1
2016-10-13T07:51:18Z
40,015,296
<p>The <code>else</code> refers only to the first <code>if</code> - i.e. for years not divisible by four. Therefore for a year divisible by four, but not by 100 you do not fall into the <code>else</code>. Python functions return <code>None</code> if no return value is specified.</p> <p>In general <code>else</code> ref...
2
2016-10-13T07:54:55Z
[ "python" ]
Whey is_leap_year returning None instead of True
40,015,236
<p>Why does this code print None instead of True. It seems that once it checks if it divisible by 4 it does not go on to check the other requirements. From my current understanding, for each successive if statement it should keep going down and checking the next if until one of them is false. At which point it should g...
-1
2016-10-13T07:51:18Z
40,015,822
<p>You can use this approach:</p> <pre><code>def is_leap_year(year): leap = False # step 1 check if dvisible by 4 if year % 4 == 0: print "year is divisble by 4" leap = True # step 2 check if divisible by 100 if year % 100 == 0: print "year is divisible by 100" lea...
0
2016-10-13T08:22:58Z
[ "python" ]
Apache - Prefork and Worker
40,015,289
<p>I am trying to build a Python Web Application using Django. On it's official "<a href="https://docs.djangoproject.com/en/1.10/topics/install/" rel="nofollow">how-to-install</a>" page, it says Apache and mod_wsgi must be installed. </p> <p>I have manually installed, in my Ubuntu machine, Apache 2.2.31 HTTP Server at...
0
2016-10-13T07:54:32Z
40,015,453
<p>You are worrying about two things that you absolutely do not need to worry about.</p> <p>Firstly, on that Django page, it explicitly states that to begin development you do not need to install any server. It suggests that you will need mod_wsgi when you come to deploy to your production server, although goes on to ...
0
2016-10-13T08:02:42Z
[ "python", "django", "apache", "mod-wsgi" ]
Why does map return a map object instead of a list in Python 3?
40,015,439
<p>I am interested in understanding the <a href="http://stackoverflow.com/questions/1303347/getting-a-map-to-return-a-list-in-python-3-x">new language design of Python 3.x</a>.</p> <p>I do enjoy, in Python 2.7, the function <code>map</code>:</p> <pre><code>Python 2.7.12 In[2]: map(lambda x: x+1, [1,2,3]) Out[2]: [2, ...
20
2016-10-13T08:01:41Z
40,015,480
<p>Because it returns an iterator, it omit storing the full list in the memory. So that you can easily iterate over it in the future not making pain to memory. Possibly you even don't need a full list, but the part of it, until your condition is matched.</p> <p>You can find this <a href="https://docs.python.org/3/glos...
7
2016-10-13T08:04:08Z
[ "python", "python-3.x" ]
Why does map return a map object instead of a list in Python 3?
40,015,439
<p>I am interested in understanding the <a href="http://stackoverflow.com/questions/1303347/getting-a-map-to-return-a-list-in-python-3-x">new language design of Python 3.x</a>.</p> <p>I do enjoy, in Python 2.7, the function <code>map</code>:</p> <pre><code>Python 2.7.12 In[2]: map(lambda x: x+1, [1,2,3]) Out[2]: [2, ...
20
2016-10-13T08:01:41Z
40,015,658
<p>In Python 3, many functions (not just <code>map</code> but <code>zip</code>, <code>range</code> and others) return an iterator rather than the full list. This puts an emphasis on a <em>lazy</em> approach, where each item is generated sequentially on the fly until the iterator is exhausted, so that an entire list doe...
4
2016-10-13T08:14:25Z
[ "python", "python-3.x" ]
Why does map return a map object instead of a list in Python 3?
40,015,439
<p>I am interested in understanding the <a href="http://stackoverflow.com/questions/1303347/getting-a-map-to-return-a-list-in-python-3-x">new language design of Python 3.x</a>.</p> <p>I do enjoy, in Python 2.7, the function <code>map</code>:</p> <pre><code>Python 2.7.12 In[2]: map(lambda x: x+1, [1,2,3]) Out[2]: [2, ...
20
2016-10-13T08:01:41Z
40,015,733
<p>I think the reason why map still exists <em>at all</em> when generator expressions also exist, is that it can take multiple iterator arguments that are all looped over and passed into the function:</p> <pre><code>&gt;&gt;&gt; list(map(min, [1,2,3,4], [0,10,0,10])) [0,2,0,4] </code></pre> <p>That's slightly easier ...
5
2016-10-13T08:17:55Z
[ "python", "python-3.x" ]