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 does multitail buffer its output?
37,575,348
<p>This may not be the best wording for the question. I am trying to see 2 files at once on my screen. I run:</p> <pre><code>multitail ~/path/to/somefile.err ~/path/to/somefile.out </code></pre> <p>I have a python script with the following lines:</p> <pre><code>sys.stdout = open('~/path/to/somefile.out', 'a') sys.st...
1
2016-06-01T17:36:43Z
37,576,512
<p>You need to pass either <code>buffering=0</code> (for unbuffered) or <code>buffering=1</code> (for line-buffered - probably what you want) in your call to <code>open</code>.</p> <p>The default is <code>buffering=-1</code>, which is equivalent to something like <code>buffering=512</code> with a value depending on th...
1
2016-06-01T18:46:06Z
[ "python", "linux", "redhat" ]
How to run Python Autobahn applications in production?
37,575,350
<p>I'm using Autobahn on a project and while reading the <a href="http://autobahn.ws/python/wamp/programming.html#running-components" rel="nofollow">running autobahn components section</a> of the docs I've come across the fact that you can run Application components using the built in ApplicationRunner. E.g.,</p> <pre...
0
2016-06-01T17:36:51Z
38,037,590
<p>If Crossbar is running on the same machine that your application is, then you can configure Crossbar to start it automatically.</p> <p>Otherwise, <code>ApplicationRunner</code> is a convenience API, you can always do what it does (start event loop, init the connections, etc) manually if you want. You can check <a h...
0
2016-06-26T10:33:37Z
[ "python", "wamp", "autobahn" ]
Can boost::python pass ownership of an object to a python callback function?
37,575,412
<p>I am currently passing a C++ pointer to a python callback function with the <code>boost::python::call</code> function. This works fine, but if I don't subsequently delete the pointer in the C++ code, I introduce a memory leak.</p> <p>I would like to pass the pointer to the callback and have python's garbage collect...
4
2016-06-01T17:39:42Z
37,576,046
<p>The way <a href="http://www.boost.org/doc/libs/1_59_0/libs/python/doc/v2/manage_new_object.html" rel="nofollow"><code>manage_new_object</code></a> works is by being a metafunction class that converts an argument into a converted result that the caller must take responsibility for. With the normal call policies, it's...
4
2016-06-01T18:18:23Z
[ "python", "c++", "boost", "boost-python" ]
Issue with iterating through list of callable
37,575,481
<p>I am having an issue with iterating over a list of callables in python. The callables are supposed to be called on a generator of strings. The current behaviour is that the last callable in the list is called as many times as there are callables in the list. My current code:</p> <pre><code>for m in list_of_callable...
0
2016-06-01T17:43:17Z
37,575,781
<pre><code>strings = (m(s) for s in strings) </code></pre> <p>This doesn't actually call your callable. It creates a generator expression that will call <code>m</code> later, <em>using whatever <code>m</code> happens to be later</em>.</p> <p>After the loop, <code>m</code> is the final callable. When you try to retrie...
2
2016-06-01T18:01:21Z
[ "python", "string", "python-2.7", "for-loop", "callable-statement" ]
I'm trying to run an Ipython notebook, except it's giving me an "astype timedelta64" error
37,575,608
<p>I'm interested in big data, and I recently happened upon this Ipython notebook: <a href="https://github.com/lmart999/GIS/blob/master/SF_GIS_Crime.ipynb" rel="nofollow">https://github.com/lmart999/GIS/blob/master/SF_GIS_Crime.ipynb</a></p> <p>And immediately downloaded it and attempted to run it. The first dozen or ...
2
2016-06-01T17:51:32Z
37,576,868
<p>The problem is that Numpy no longer supports creating <code>timedelta64</code> objects from a float (presumably that was possible when the notebook was published).</p> <p>You need to first cast the scaled-up index into integers before casting to <code>timedelta64</code>.</p> <pre><code>days_from_start=pd.Series(t_...
1
2016-06-01T19:06:36Z
[ "python", "numpy", "pandas", "ipython", "gis" ]
Override a pytest parameterized functions name
37,575,690
<p>My parameters determine the name of my parameterized pytest. I will be using a some randomized params for these tests. In order for my reporting names in junit to not get messed up, I'd like to create a static name for each parameterized test.</p> <p>Is it possible?</p> <p>JUnit seems to have a parameter: <a href=...
3
2016-06-01T17:56:10Z
37,575,774
<p>You're looking for the <code>ids</code> argument of <a href="https://pytest.org/latest/parametrize.html#_pytest.python.Metafunc.parametrize" rel="nofollow"><code>pytest.mark.parametrize</code></a>:</p> <blockquote> <p>list of string ids, or a callable. If strings, each is corresponding to the argvalues so that ...
4
2016-06-01T18:01:02Z
[ "python", "rename", "py.test", "fixtures", "parameterized" ]
Extract data using lxml in Python from every namespace attribute
37,575,765
<p>The following is a snippet of code from the extraction of an FODT file:</p> <pre><code>&lt;office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:...
0
2016-06-01T18:00:20Z
37,576,146
<p>The <a href="http://lxml.de/api/lxml.etree._Element-class.html#nsmap" rel="nofollow"><code>nsmap</code></a> property on the root element holds a dictionary with all declared namespaces. Example:</p> <pre><code>from lxml import etree XML = "your XML document here..." root = etree.fromstring(XML) for ns in sorted(r...
2
2016-06-01T18:23:44Z
[ "python", "xml", "lxml" ]
Django settings, module specific settings
37,575,862
<p>We have this model on Django app</p> <pre><code>class MyModel(models.Model): # A constant MY_CONSTANT = 'this is a constant' field1 = models.Charfield() field2 = models.Charfield() def some_method(self): if field1 == MY_CONSTANT: do_some_stuff() </code></pre> <p>So my que...
0
2016-06-01T18:06:39Z
37,575,909
<p>Is it a configurable setting, or is it just a constant? If the latter, it should be defined on the model (as you have it above); if the former, put it in the settings config.</p>
1
2016-06-01T18:09:26Z
[ "python", "django" ]
pandas groupby dropping columns
37,575,944
<p>I'm doing a simple group by operation, trying to compare group means. As you can see below, I have selected specific columns from a larger dataframe, from which all missing values have been removed.</p> <p><a href="http://i.stack.imgur.com/y8EEI.png" rel="nofollow">selected columns and df head</a></p> <p>But when ...
1
2016-06-01T18:11:40Z
37,575,995
<p>I think it is <code>Automatic exclusion of 'nuisance' columns</code>, what described <a href="http://pandas.pydata.org/pandas-docs/stable/groupby.html#automatic-exclusion-of-nuisance-columns" rel="nofollow">here</a>.</p> <p>Sample:</p> <pre><code>df = pd.DataFrame({'C': {0: -0.91985400000000006, 1: -0.042379, 2: 1...
2
2016-06-01T18:15:14Z
[ "python", "pandas", "dataframe", "group-by" ]
Pass <input> value to Django view
37,576,008
<p>Let's say I have the following pointless example view:</p> <pre><code>def foo(request, input): return HttpResponse() </code></pre> <p>and in a template I have a form:</p> <pre><code>&lt;form method="get" action="{% url 'foo' ??? %}"&gt; &lt;input id="myinput" type="text" name="myinput"&gt; ... &lt;/...
-1
2016-06-01T18:16:06Z
37,577,276
<h1>The source of my misunderstanding</h1> <p>Although I did not make this clear in an attempt to simplify my example and avoid using app-specific code, my use case is a simple search view. The view was actually one of the first views I wrote in the start of my Django journey, and I mistakenly was <code>POST</code>ing...
2
2016-06-01T19:31:11Z
[ "python", "django" ]
Calling ActionChains move_to_element() leads to attribute error?
37,576,123
<p>I'm getting the following error when running my python/selenium script:</p> <p><strong>AttributeError: 'WebElement' object has no attribute 'move_to_element'</strong></p> <p>What does this particular error message tell? Is it not recognizing move_to_element as a valid action? I am importing the actionchains module...
0
2016-06-01T18:22:32Z
37,576,260
<p>Here is the problem line:</p> <blockquote> <p><code>self.wait_for_element_visibility(waitTime, locatorMode, Locator).move_to_element(element).perform()</code></p> </blockquote> <p>Here <code>wait_for_element_visibility()</code> waits for element's visibility and returns the element itself, then, you are calling ...
1
2016-06-01T18:31:09Z
[ "python", "selenium" ]
Calling ActionChains move_to_element() leads to attribute error?
37,576,123
<p>I'm getting the following error when running my python/selenium script:</p> <p><strong>AttributeError: 'WebElement' object has no attribute 'move_to_element'</strong></p> <p>What does this particular error message tell? Is it not recognizing move_to_element as a valid action? I am importing the actionchains module...
0
2016-06-01T18:22:32Z
37,576,286
<p>This is where your code would fail : </p> <pre><code> self.wait_for_element_visibility(waitTime, locatorMode, Locator).move_to_element(element).perform() </code></pre> <p>A sample code to use Actions in python goes in here : </p> <pre><code>element = self.driver.find_element_by_id(&lt;id&gt;) //use any of your lo...
0
2016-06-01T18:32:16Z
[ "python", "selenium" ]
Calling ActionChains move_to_element() leads to attribute error?
37,576,123
<p>I'm getting the following error when running my python/selenium script:</p> <p><strong>AttributeError: 'WebElement' object has no attribute 'move_to_element'</strong></p> <p>What does this particular error message tell? Is it not recognizing move_to_element as a valid action? I am importing the actionchains module...
0
2016-06-01T18:22:32Z
37,576,289
<p>I think you're trying to call 'move_to_element()' as an WebElement object extension, and it is not possible. Even if you import the ActionChain, a WebElement will not have this kind of extension.</p> <p>You need to do something like it:</p> <pre><code>ActionChains(driver).move_to_element(element).perform() </code>...
0
2016-06-01T18:32:28Z
[ "python", "selenium" ]
python script to call itself with xvfb
37,576,129
<p>I've written a script that generates a phylogentic tree with the <a href="http://etetoolkit.org/" rel="nofollow">ete3 package</a>, the script runs on a headless server thus it must be launched with <a href="https://www.x.org/archive/X11R7.6/doc/man/man1/Xvfb.1.xhtml" rel="nofollow">xvfb-run</a> (per <a href="https:/...
0
2016-06-01T18:22:48Z
37,710,545
<p>I was able to put something together, just add the function <code>check_xvfb()</code> to the start of your script.</p> <pre><code>def check_xvfb(): """ Use of the ete3 library from the command line requires an X11 server which doesn't exist on this headless Ubuntu server. One way around this is to ...
1
2016-06-08T18:47:19Z
[ "python", "xvfb" ]
Adding Score Clock to Game in Python
37,576,161
<p>I have my code for a game here. I have commented out the displayScore(score) call in the main function to allow the program to run. When that call is uncommented the program window closes immediately after opening. </p> <p>The objective of the function displayScore is to display the game score in the top left corne...
1
2016-06-01T18:25:14Z
37,576,251
<p>Just replace the line</p> <pre><code>displayScore(score) </code></pre> <p>By: </p> <pre><code>displayScore(str(score)) </code></pre> <p>You are trying to use a number instead of a string to the argument of render ;) Score is an int and <code>BASICFONT.render((score), True, WHITE) </code> asks for score to be a...
2
2016-06-01T18:30:14Z
[ "python", "function", "python-3.x", "pygame" ]
How to run ansible and ansible-playbook in python
37,576,355
<p>I am using python 3.4 and ansible 2.0, all my ansible tasks are working properly from command line</p> <p>here i am executing a simple task:</p> <pre><code>- hosts: all tasks: - name: Install bind yum: state=latest name=bind </code></pre> <p>my host file is :</p> <pre><code>S1 ansible_host=server1.jackso...
0
2016-06-01T18:36:30Z
37,605,169
<p>Ansible Docs provides a good document for using the Python API, for both 2.0 and pre-2.0. See <a href="http://docs.ansible.com/ansible/developing_api.html#python-api-2-0" rel="nofollow">http://docs.ansible.com/ansible/developing_api.html#python-api-2-0</a>.</p> <p>I did have issues getting the right version of ans...
0
2016-06-03T02:46:43Z
[ "python", "python-3.x", "ansible", "ansible-playbook", "ansible-2.x" ]
RegEx Repeating Capture Group
37,576,436
<p>I have the following data:</p> <pre><code> User ID Name Last Activity Date -------------------- ------------------------------------------------------------ ----------------------- UserID1 UserName1 ...
1
2016-06-01T18:41:03Z
37,577,763
<p>Please have a look at the regex in the link: <a href="https://regex101.com/r/gN2cH2/2" rel="nofollow">https://regex101.com/r/gN2cH2/2</a> The python code generated from the link is. This regex captures all the USerIDs, names , activity dates except the heading row.</p> <pre><code>import re p = re.compile(ur'((UserI...
2
2016-06-01T20:01:53Z
[ "python", "regex" ]
Get model ID correctly
37,576,442
<p>I got two models. One model for building main menu, another one - for Articles. Every Article have <code>ForeignKey</code>to link it to main menu item.</p> <p>I can't figured out, how can I show on page <code>Article</code>, that linked to <code>menuItem</code> Model and how to use <code>menuItem</code> model's <co...
1
2016-06-01T18:41:46Z
37,576,509
<p>You just filter by the alias on <code>MainMenuItem</code> then get all articles that related to that <code>MainMenuItem</code>:</p> <pre><code>def menu_builder(request, alias): main_menu_item = MainMenuItem.objects.get(alias=alias) elements = { 'menuItems': main_menu_item, 'articles'...
2
2016-06-01T18:45:54Z
[ "python", "django", "django-models", "django-views", "django-urls" ]
A popout window that recives an value from the user
37,576,462
<p>I want to create a simple tkinter function, that i can use to recive a value from the user (like raw_input, but with a popout window). for example, if the function is "getFromUser()", I will be able to use it like this:</p> <pre><code>value=getFromUser() </code></pre> <p>and then to do something else with what I r...
-3
2016-06-01T18:43:06Z
37,576,837
<p>You should look into the tkinter.tksimpledialog package: <a href="http://effbot.org/tkinterbook/tkinter-entry-dialogs.htm" rel="nofollow">http://effbot.org/tkinterbook/tkinter-entry-dialogs.htm</a></p>
0
2016-06-01T19:04:41Z
[ "python", "tkinter" ]
Finding the point of intersection of two line graphs drawn in matplotlib
37,576,527
<p>Is there a way to find the point of intersection of two line graphs in matplotlib?</p> <p>Consider the code </p> <pre><code>import numpy as np import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) ax.plot([1,2,3,4,5,6,7,8],[20,100,50,120,55,240,50,25],color='lightblue',linewidth=3) ax.p...
2
2016-06-01T18:47:06Z
37,577,440
<p>Here is an ugly solution (an improved version is at the bottom). After plotting, we know that two line graphs make a cross at the range of <code>(6, 7)</code></p> <p><a href="http://i.stack.imgur.com/NojFp.png" rel="nofollow"><img src="http://i.stack.imgur.com/NojFp.png" alt="enter image description here"></a></p> ...
3
2016-06-01T19:41:20Z
[ "python", "matplotlib" ]
Limit choices and validate django's foreign key to related objects (also in REST)
37,576,541
<p>I have my <code>models.py</code> like this:</p> <pre><code>class Category(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=256, db_index=True) class Todo(models.Model): user = models.ForeignKey(User) category = models.ForeignKey(Category) ... </code></pre> <p>An...
0
2016-06-01T18:47:42Z
37,580,946
<p>Here what I've found so far:</p> <p>To get <code>Foreignkey</code> showed right in admin, you have to specify a form in <code>ModelAdmin</code></p> <pre><code>class TodoAdminForm(ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['category'].queryset ...
0
2016-06-02T00:42:05Z
[ "python", "django", "django-admin", "django-rest-framework" ]
Dealing with None values when using Pandas Groupby and Apply with a Function
37,576,552
<p>I have a <code>Dataframe</code> in <code>Pandas</code> with a letter and two dates as columns. I would like to calculate the business days between the two date columns for the previous row using <code>shift()</code>, provided that the <code>Letter</code> value is the same (using a <code>.groupby()</code>). I was doi...
1
2016-06-01T18:48:13Z
37,577,599
<ul> <li><p>Ignoring the <code>NaT</code>s for the moment, note that the <code>np.busday_count</code> calculation can be done on whole columns of <code>df</code> <em>before</em> applying <code>groupby</code>. This will save time since this replaces many calls to <code>np.busday_count</code> (one for each group) with a ...
2
2016-06-01T19:51:25Z
[ "python", "python-2.7", "pandas" ]
Rearrange a pandas data frame to create a 2d ratings matrix
37,576,594
<p>I'm trying to build a item-based recommendation system off of the yelp data set. I managed to process the data to an extent where I have the ratings given by all the users that reviewed a restaurant in a given state. Eventually I want to get to the point where I have a ratings matrix with restaurants on one axis and...
2
2016-06-01T18:50:33Z
37,576,723
<p>I think you need <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.pivot.html" rel="nofollow"><code>pivot</code></a> with <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.fillna.html" rel="nofollow"><code>fillna</code></a></p> <pre><code>print (df.pivot(i...
1
2016-06-01T18:57:53Z
[ "python", "pandas", "dataframe", "recommendation-engine", "yelp" ]
When I try to import TextBlob I get "ImportError: cannot import name compat". What does this mean? How can I fix it?
37,576,649
<p>From what I can tell "compat" is some component of NLTK, TextBlob is built on. Strangely, I've imported TextBlob in the past, so this must be something recent. I've updated both TextBlob and NLTK to their most recent versions, so that's not what the problem is.</p> <p>Similar questions such as <a href="http://stack...
0
2016-06-01T18:53:56Z
37,576,944
<p>Are you sure textblob is installed correctly? You might want to try </p> <pre><code>pip install -U textblob python -m textblob.download_corpora </code></pre> <p>Try running the code afterwards, it should work correctly.</p>
1
2016-06-01T19:11:35Z
[ "python", "nlp", "nltk", "importerror", "textblob" ]
Validation when updating SQLAlchemy row
37,576,657
<p>I'm successfully able to update a row in my SQLAlchemy-driven database (using the answers to <a href="http://stackoverflow.com/questions/9667138/how-to-update-sqlalchemy-row-entry">how to update SQLAlchemy row entry</a>). Before I'm happy, I want to do some validation. Specifically, I want to</p> <ul> <li><p>make...
0
2016-06-01T18:54:06Z
37,634,443
<p>to extract the list of columns based on ORM class definition:</p> <pre><code>from sqlalchemy import inspect mapper = inspect(your_orm_class) columns = [i.key for i in mapper.attrs] </code></pre> <p>to extract primary key name based on ORM class definition:</p> <pre><code>from sqlalchemy.orm import class_mapper pk...
0
2016-06-04T19:55:33Z
[ "python", "sqlalchemy" ]
Python Pandas memory - subsetting and releasing main data frame
37,576,661
<p>I have Pandas data frame big data frame loaded into memory. Trying to utilize memory more efficient way.</p> <p>For this purposes, i won't use this data frame after i will subset from this data frame only rows i am interested are:</p> <pre><code>DF = pd.read_csv("Test.csv") DF = DF[DF['A'] == 'Y'] </code></pre> ...
0
2016-06-01T18:54:23Z
37,576,808
<p>you can try the following trick (if you can read the whole CSV file into memory):</p> <pre><code>DF = pd.read_csv("Test.csv").query("A == 'Y'") </code></pre> <p>Alternatively, you can read your data in chunks, using <a href="http://stackoverflow.com/a/25962187/5741205">read_csv()</a></p> <p>But i would strongly r...
1
2016-06-01T19:02:49Z
[ "python", "pandas", "memory" ]
python robo framework - how to sent form data in http request?
37,576,697
<p>I'm trying to automate the following flow in python robo , using requests 'requests' </p> <p><code>curl -X POST https://localhost:12443/api/customdata/upload/userid/user_values --form "user_data=@user1_data_values"</code></p> <p><code>user1_data_values</code> is the file which will have details of some information...
-1
2016-06-01T18:56:39Z
37,610,531
<p>It has been resolved by doing the following in the code </p> <blockquote> <blockquote> <blockquote> <p>url = '<a href="http://httpbin.org/post" rel="nofollow">http://httpbin.org/post</a>' files = {'file': open('report.xls', 'rb')}</p> <p>r = requests.post(url, files=files) r.tex...
0
2016-06-03T09:19:27Z
[ "python", "forms", "http-headers", "robotframework" ]
Find java comments (multi and single line) using regex
37,576,721
<p>I found the following regex online at <a href="http://regexlib.com/" rel="nofollow">http://regexlib.com/</a></p> <pre><code>(\/\*(\s*|.*?)*\*\/)|(\/\/.*) </code></pre> <p>It seems to work well for the following matches:</p> <pre><code>// Compute the exam average score for the midterm exam /** * The HelloWorld pr...
0
2016-06-01T18:57:47Z
37,577,433
<p>You can try this pattern:</p> <pre><code>(?ms)^[^'"\n]*?(?:(?:"(?:\\.|[^"])*"|'\\?.')[^'"\n]*?)*((?:(?://[^\n]*|/\*.*?\*/)[ \t]*)+) </code></pre> <p>This captures comments in group 1, but only if the comment is not inside a string. <a href="https://regex101.com/r/cQ8kX9/6" rel="nofollow">Demo.</a></p> <hr> <p>Br...
-1
2016-06-01T19:40:55Z
[ "java", "python", "regex" ]
Find java comments (multi and single line) using regex
37,576,721
<p>I found the following regex online at <a href="http://regexlib.com/" rel="nofollow">http://regexlib.com/</a></p> <pre><code>(\/\*(\s*|.*?)*\*\/)|(\/\/.*) </code></pre> <p>It seems to work well for the following matches:</p> <pre><code>// Compute the exam average score for the midterm exam /** * The HelloWorld pr...
0
2016-06-01T18:57:47Z
37,591,082
<p>The regex you are looking for is one that allows the comment beginning (<code>//</code> or <code>/*</code>) to appear anywhere except in each of the regexps that result in tokens that can contain those substrings inside. If you look at the <a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html" rel="...
0
2016-06-02T11:51:21Z
[ "java", "python", "regex" ]
Error when connecting kSoap to Spyne The attribute '{http://schemas.xmlsoap.org/soap/encoding/}root' is not allowed
37,576,838
<p>I have a soap server written in python using spyne. I have also created a soap client in python using suds. It works perfect. Here is the code for the server</p> <pre><code>class Personnel(ServiceBase): @rpc(_returns=String) def personnel(self): """Docstrings for service methods appear as documentation in t...
1
2016-06-01T19:04:44Z
37,576,895
<p>I found the answer. I do not claim to understand why it work but it did. See <a href="http://stackoverflow.com/questions/8949020/how-can-you-remove-namespace-declarations-in-ksoap">How can you remove namespace declarations in ksoap?</a> for more details.</p> <p>Here is the code that I added to my java program:</p...
1
2016-06-01T19:08:37Z
[ "android", "python", "ksoap", "spyne" ]
searching a csv file and then outputting a term associating to the term
37,576,839
<p>I am creating a code, that read a csvs file and search for a specific item code and then it will output the name of the item. How would i do this? I don't have any code yet </p> <p>Thanks</p>
-2
2016-06-01T19:04:48Z
37,576,959
<p>You can use <a href="http://pandas.pydata.org/pandas-docs/version/0.15.2/tutorials.html" rel="nofollow">pandas</a> </p> <p>Install it, then try</p> <pre><code>import pandas as pd df = pd.read_csv('yourFile.csv') print df </code></pre>
0
2016-06-01T19:12:24Z
[ "python", "csv" ]
How do I make my program give me the value of a certain cell in a CSV?
37,576,905
<p>I am having problems with trying to make my program find a certain cell in a CSV file. My program will ask you for a 8 digit number. If it is in the CSV file, the row should be written to a text file. It then should proceed to ask the user how much of the product they want to buy. This quantity will then be multipli...
0
2016-06-01T19:08:54Z
37,577,157
<p>You could just iterate through the lines of the csv file and return a particular column of the row that contains the 8 digit number:</p> <pre><code>import csv def get_row(filename, number, column): with open(filename, 'r') as f: for row in csv.reader(f): if str(number) in row: ...
1
2016-06-01T19:23:12Z
[ "python", "csv" ]
Python Django Getting user input
37,577,037
<p>I am setting up a simple html page, the page captures the information that the user entered and based on the information that the user entered makes a new page. The problem is that I cant get back the information entered by the user at the backed and I dont understand where I am going wrong.</p> <p>My views file is...
2
2016-06-01T19:17:13Z
37,577,151
<p>You are using a forms.HiddenInput() as the widget and then add the form field yourself. This doesn't work that way. What if you change the field class to TextInput:</p> <pre><code>class BusinessName(forms.Form): business_name = forms.CharField(widget = forms.TextInput()) </code></pre> <p>If you're goal is to a...
0
2016-06-01T19:22:50Z
[ "python", "django" ]
Python: What is the syntax for adding a command to a tkinter Listbox item?
37,577,039
<p>below is my code for creating a tool that takes a file path, stores the value, and then opens the specific file path selected by the user. </p> <p>Currently, I'm looking to take the user entry <code>mypathEntry</code> that is stored in the <code>mypathList</code> listbox after clicking the <code>Save</code> button ...
-1
2016-06-01T19:17:18Z
37,577,578
<p>According to this, <a href="http://effbot.org/tkinterbook/listbox.htm" rel="nofollow">http://effbot.org/tkinterbook/listbox.htm</a> The listbox item does not have a command option. So what you need to do instead is to bind an event to it. Here is a complete working example. </p> <pre><code>from tkinter import * imp...
2
2016-06-01T19:50:12Z
[ "python", "drop-down-menu", "tkinter", "filepath" ]
String splitting python
37,577,064
<p>I am trying to parse a file and split the line in python. Currently i can parse the file and load it into a list.</p> <p>I am trying to take each line and split it by the parenthesis,</p> <pre><code>'datediff(varchar(30),timestamp(3),timestamp(3))' reverse(text) checkcluster(int,int,int,int,int) declaredown(int) <...
0
2016-06-01T19:18:19Z
37,577,142
<blockquote> <p>Is there a way to split it just by the first occurrence and last occurrence of parenthesis?</p> </blockquote> <p>Yes, use <a href="https://docs.python.org/2/library/stdtypes.html#str.partition" rel="nofollow"><code>partition</code></a> and <a href="https://docs.python.org/2/library/stdtypes.html#str....
3
2016-06-01T19:22:19Z
[ "python", "scripting" ]
Difference between Len and Print Len()
37,577,127
<p>I've recently started doing data analysis in Python and since I didn't learn Python from scratch I feel I've missed a few nuances.</p> <p>One thing I noticed is in one of my reports I had imported a data set from a CSV, put it in as a dictionary, manipulated it and was trying to print the remaining entries.</p> <p...
1
2016-06-01T19:21:29Z
37,577,214
<p>len(list) does not print anything, it only returns. If you are using REPL (read - evaluate - print - loop) then it will print the returned value and loop. Therefore to print more than one you must call print.</p> <p><a href="http://www.tutorialspoint.com/python/list_len.htm" rel="nofollow">Here is the method docume...
4
2016-06-01T19:26:50Z
[ "python", "jupyter" ]
Difference between Len and Print Len()
37,577,127
<p>I've recently started doing data analysis in Python and since I didn't learn Python from scratch I feel I've missed a few nuances.</p> <p>One thing I noticed is in one of my reports I had imported a data set from a CSV, put it in as a dictionary, manipulated it and was trying to print the remaining entries.</p> <p...
1
2016-06-01T19:21:29Z
37,577,220
<p><a href="https://docs.python.org/2/library/functions.html#len" rel="nofollow"><code>len</code></a> returns a value, only in the REPL you'll see the value returned without assigning the value to a variable. More specifically,</p> <blockquote> <p>len(s)</p> <p>Return the length (the number of items) of an obje...
3
2016-06-01T19:27:34Z
[ "python", "jupyter" ]
Difference between Len and Print Len()
37,577,127
<p>I've recently started doing data analysis in Python and since I didn't learn Python from scratch I feel I've missed a few nuances.</p> <p>One thing I noticed is in one of my reports I had imported a data set from a CSV, put it in as a dictionary, manipulated it and was trying to print the remaining entries.</p> <p...
1
2016-06-01T19:21:29Z
37,577,249
<p>You need print or write when it is not clear, that everything that produces some value needs to be echoed (like in an interactive session we call REPL Read Eval Print Loop).</p> <p>So:</p> <pre><code>v = len([1, 42]) </code></pre> <p>places the value 2 in v.</p> <p>So in a script executed that has the following ...
0
2016-06-01T19:29:24Z
[ "python", "jupyter" ]
Difference between Len and Print Len()
37,577,127
<p>I've recently started doing data analysis in Python and since I didn't learn Python from scratch I feel I've missed a few nuances.</p> <p>One thing I noticed is in one of my reports I had imported a data set from a CSV, put it in as a dictionary, manipulated it and was trying to print the remaining entries.</p> <p...
1
2016-06-01T19:21:29Z
37,577,277
<p>Look at it this way.</p> <pre><code>n = len(a) </code></pre> <p>sets <code>n</code> to the returned value.</p> <pre><code>n = print(len(a)) </code></pre> <p>assigns <code>None</code> to <code>n</code>, because that's what <code>print()</code> returns. Printing the value to the console is a side effect, in funct...
0
2016-06-01T19:31:15Z
[ "python", "jupyter" ]
Write text file into a zip without temp files
37,577,153
<p>In the code below, I need to wright <code>package.inf</code> directly into the zip file created at the bottom of the script.</p> <pre><code>import os import zipfile print("Note: All theme files need to be inside of the 'theme_files' folder.") themeName = input("\nTheme name: ") themeAuthor = input("\nTheme author:...
0
2016-06-01T19:23:00Z
37,577,417
<p>Use <code>io.StringIO</code> to create a file-like object in memory:</p> <pre><code>import io import os import zipfile print("Note: All theme files need to be inside of the 'theme_files' folder.") themeName = input("\nTheme name: ") themeAuthor = input("\nTheme author: ") themeDescription = input("\nTheme descript...
1
2016-06-01T19:39:42Z
[ "python", "python-3.x", "zip", "zipfile" ]
Deploy python app and as part of process install python, git, virtualenv on windows
37,577,162
<p>How would i have a self contained setup file that would do the following processes...</p> <ol> <li>Install python 2.7 (it just download/launch the python installer doesn't have to automate it just get and launch it)</li> <li>Install Git (same as above)</li> <li>Install PiP</li> <li>Install Python Virtualenv</li> <l...
0
2016-06-01T19:23:22Z
37,577,880
<p>We done something very similar to this. Here's what we did. Create an installer (we used NSIS <a href="http://nsis.sourceforge.net/Main_Page" rel="nofollow">http://nsis.sourceforge.net/Main_Page</a>) that installs python. After python is installed, we then run a python script that performs the rest of the steps.</p>...
1
2016-06-01T20:09:17Z
[ "python", "windows", "deployment" ]
Count frequency of a number in a column while equals to text in another column
37,577,178
<p>This is from sample csv</p> <p>Roughly it looks like this 5 columns </p> <p>Clipboard:</p> <pre><code>Year Course Modul Q1 Q2 2015 Physics CS1203 4 2 2015 Physics CS1203 4 3 2015 Physics CS1203 3 1 2015 Physics CS1203 4 4 2015 English IR0001 2 5 2015 English IR0001 1 2 2015 English IR0001 3 ...
3
2016-06-01T19:24:26Z
37,577,281
<p>I think you need <a href="http://pandas.pydata.org/pandas-docs/stable/indexing.html#boolean-indexing" rel="nofollow"><code>boolean indexing</code></a>:</p> <pre><code>print (df[(df.module == 'CS1203') &amp; (df.q1 == 4)]) year course module q1 q2 0 2015 Physics CS1203 4 2 1 2015 Physics CS1203 4...
2
2016-06-01T19:31:22Z
[ "python", "pandas" ]
Count frequency of a number in a column while equals to text in another column
37,577,178
<p>This is from sample csv</p> <p>Roughly it looks like this 5 columns </p> <p>Clipboard:</p> <pre><code>Year Course Modul Q1 Q2 2015 Physics CS1203 4 2 2015 Physics CS1203 4 3 2015 Physics CS1203 3 1 2015 Physics CS1203 4 4 2015 English IR0001 2 5 2015 English IR0001 1 2 2015 English IR0001 3 ...
3
2016-06-01T19:24:26Z
37,577,285
<p>you can first filter your DF by module (<code>df.module == 'CS1203'</code>), then filter columns selecting only those matching <code>q\d+</code> RegEx, select only <code>4</code>s and finally calculate the sum:</p> <pre><code>In [74]: (df[df.module == 'CS1203'].filter(regex=r'q\d+') == 4).sum() Out[74]: q1 3 q2 ...
2
2016-06-01T19:31:28Z
[ "python", "pandas" ]
Count frequency of a number in a column while equals to text in another column
37,577,178
<p>This is from sample csv</p> <p>Roughly it looks like this 5 columns </p> <p>Clipboard:</p> <pre><code>Year Course Modul Q1 Q2 2015 Physics CS1203 4 2 2015 Physics CS1203 4 3 2015 Physics CS1203 3 1 2015 Physics CS1203 4 4 2015 English IR0001 2 5 2015 English IR0001 1 2 2015 English IR0001 3 ...
3
2016-06-01T19:24:26Z
37,577,410
<p>Maybe you can try something like this:</p> <pre><code>df.groupby(['module','q1'])['module'].agg({'Frequency':'count'}) </code></pre> <p>Please refer to this <a href="http://stackoverflow.com/questions/23402150/grouping-and-computing-frequency-pandas">post</a>.</p>
1
2016-06-01T19:39:05Z
[ "python", "pandas" ]
python get day if its in a dates range
37,577,326
<p>I'm trying to check if first date of the month and the last date of the month lies in a range of dates (the range is 7 days window starting from current date) . below is an example for what I'm trying to achieve:</p> <pre><code>import datetime, calendar today = datetime.date.today() date_list = [today + datetime.t...
1
2016-06-01T19:33:19Z
37,578,059
<p>The only thing I can come up with, without having to make use of iteration is:</p> <pre><code>import datetime, calendar today = datetime.date.today() week_from_today = today + datetime.timedelta(days=6) last_day_of_month = today.replace(day=calendar.monthrange(today.year,today.month)[-1]) if today.month != week_f...
6
2016-06-01T20:19:59Z
[ "python", "date", "datetime" ]
Ways to end a worker process in a thread in Python 3
37,577,372
<p>I am wondering the ways to end a worker thread in Python 3.</p> <p>If you look at this code sample from <a href="http://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread-in-python">this question</a> the <code>worker</code> has a <code>while True</code> loop in it and all I see is that <code>q.tas...
0
2016-06-01T19:36:15Z
37,577,596
<blockquote> <p>What options exist to end the workers infinite loop?</p> </blockquote> <p>Run with the while loop polling a <code>threading.semaphore</code> object instance, rather than a constant <code>True</code> boolean. Signal the semaphore from the killing thread when you want to kill the worker, and it will dr...
1
2016-06-01T19:51:10Z
[ "python", "multithreading" ]
Scrapy crawling not working on ASPX website
37,577,405
<p>I'm scraping the Madrid Assembly's website, built in aspx, and I have no idea how to simulate clicks on the links where I need to get the corresponding politicians from. I tried this:</p> <pre><code>import scrapy class AsambleaMadrid(scrapy.Spider): name = "Asamblea_Madrid" start_urls = ['http://www.a...
1
2016-06-01T19:38:42Z
37,582,781
<p>Do agree with ELRuLL - Firebug is your best friend while scraping. If you want to avoid JS simulation then you need reproduce carefully all the params/headers that are being sent. </p> <p>For example from what I see for __EVENTTARGET you're sending just <code>id="ctl00_m_g_36ea0310_893d_4a19_9ed1_88a133d06423...
-1
2016-06-02T04:39:53Z
[ "javascript", "python", "asp.net", "web-scraping", "scrapy" ]
Scrapy crawling not working on ASPX website
37,577,405
<p>I'm scraping the Madrid Assembly's website, built in aspx, and I have no idea how to simulate clicks on the links where I need to get the corresponding politicians from. I tried this:</p> <pre><code>import scrapy class AsambleaMadrid(scrapy.Spider): name = "Asamblea_Madrid" start_urls = ['http://www.a...
1
2016-06-01T19:38:42Z
37,603,423
<p>If you look at the data posted to the form in chrome or firebug you can see there are many fields passed in the post request, there are a few that are essential and must be parsed from the original page, parsing the ids from the <code>div.sangria ul li a</code> tags is not sufficient as the actual data posted is sl...
3
2016-06-02T22:56:08Z
[ "javascript", "python", "asp.net", "web-scraping", "scrapy" ]
Scrapy crawling not working on ASPX website
37,577,405
<p>I'm scraping the Madrid Assembly's website, built in aspx, and I have no idea how to simulate clicks on the links where I need to get the corresponding politicians from. I tried this:</p> <pre><code>import scrapy class AsambleaMadrid(scrapy.Spider): name = "Asamblea_Madrid" start_urls = ['http://www.a...
1
2016-06-01T19:38:42Z
37,617,412
<p>I think that scrapy's <code>from_response</code> could help you a lot (maybe this isn't the best re but for it, but you'll get the idea), try something like this:</p> <pre><code>import scrapy import urllib from scrapy.http.request.form import FormRequest class AsambleaMadrid(scrapy.Spider): name = "Asamblea_M...
1
2016-06-03T14:46:29Z
[ "javascript", "python", "asp.net", "web-scraping", "scrapy" ]
List index out of range in a random generating program
37,577,421
<p>I was working on a program that take random words from a list and combine them into one sentence but I keep getting an error:</p> <pre><code> File "test2.py", line 13, in generater print list[z+2] , IndexError: list index out of range </code></pre> <p>This is my code:</p> <pre><code>def generater(): list...
0
2016-06-01T19:40:02Z
37,577,489
<p>Your list contains 12 items, so the valid index range is 0 to 11. </p> <p>Your rand generator returns a value between 0 and 10.</p> <p>10 + 2 is more than 11 - so you're trying to access a list index which is off the end of the list.</p>
2
2016-06-01T19:45:04Z
[ "python", "list" ]
List index out of range in a random generating program
37,577,421
<p>I was working on a program that take random words from a list and combine them into one sentence but I keep getting an error:</p> <pre><code> File "test2.py", line 13, in generater print list[z+2] , IndexError: list index out of range </code></pre> <p>This is my code:</p> <pre><code>def generater(): list...
0
2016-06-01T19:40:02Z
37,577,670
<p>The problem is in your statement</p> <pre><code>if z == x or z == y and z &lt; 8: </code></pre> <p>Try putting parentheses around (z == x or z == y). In the event that z == x, your program does not ensure that z &lt; 8. You can test this by entering</p> <pre><code>if 1 or 1 and 0: print('TRUE!') </code></pr...
2
2016-06-01T19:55:39Z
[ "python", "list" ]
Python Pandas - Moving Average with uneven period lengths
37,577,470
<p>I'm trying to figure out how to deal with time series data in pandas that has uneven period lengths. The first example I'm looking at is how to calculate a moving average for the last 15 days. Here is an example of the data (time is UTC)</p> <pre><code>index date_time data 46701 1/06/2016 19:27 15.00...
1
2016-06-01T19:43:47Z
37,578,573
<p>You can do something like this.</p> <ul> <li>Resample at the frequency you want (or downsampling) <ul> <li>You have to pay attention here to the resampling strategy. It has to be consistent with the meaning of your data. Here I have arbitrary used <code>bfill</code> (back fill that use next valid value) but anothe...
3
2016-06-01T20:53:01Z
[ "python", "pandas" ]
JSON encoding and downloading from a URL
37,577,549
<p>I'm trying to get JSON from a Steam inventory. I get the data like this :</p> <pre><code>def downloadString(url): req = urllib.request.Request( url, data=None, headers={ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chr...
1
2016-06-01T19:48:45Z
37,578,264
<p>JSON can be encoded in any of UTF-8, UTF-16, or UTF-32. I would try decoding as UTF-16 instead of UTF-8.</p>
0
2016-06-01T20:33:13Z
[ "python", "json", "encoding" ]
Anaconda problems modifying PYHTONPATH in .profile and .bash_profile
37,577,666
<p>So I have my .profile and .bash_profile setup as follows:</p> <p><a href="http://i.stack.imgur.com/NHMaZ.png" rel="nofollow"><img src="http://i.stack.imgur.com/NHMaZ.png" alt="enter image description here"></a></p> <p>But I am also using the anaconda Python package.</p> <p>I'm following these set of instructions ...
0
2016-06-01T19:55:22Z
37,578,705
<p>You have set <code>PYTHONPATH</code> incorrectly. You included one path component too many.</p> <p>From <a href="http://www.skirt.ugent.be/pts/_install_mac_set_up.html" rel="nofollow">Configuring paths and aliases</a></p> <blockquote> <p>Add the following lines:</p> </blockquote> <pre><code>export PYTHONPATH=~/...
1
2016-06-01T21:01:12Z
[ "python", "bash", "terminal", "anaconda" ]
Using Python objects in C++
37,577,676
<p>I'm writing a code that calculates the images of nonlinear maps using methods from interval analysis, applies a minkowski sum and repeats for an arbitrary number of iterations.</p> <p>I've written a working code in Python, however I would like to be able to implement some of the more iteration/recursion intensive p...
2
2016-06-01T19:56:08Z
37,592,955
<p>Yes. You will get a speed-up over pure python but not on par with the increase you'd get if you were using pure <code>C/C++</code>. If you want to handle Python Objects you'll need to do it via the <a href="https://docs.python.org/3/c-api/index.html" rel="nofollow"><code>Python C/API</code></a>; this adds overhead t...
1
2016-06-02T13:14:26Z
[ "python", "c++", "object", "cython" ]
Multiple Python Interpreters used in the same project?
37,577,785
<p>I am using pycharm and it only lets you use one interpreter for example Python 2.7.5 or Python 3.5.1.</p> <p>The problem is I have certain modules one from google to access analytics data and one called docxfactory that I want to use together.</p> <p>I can only get docxfactory to work on Python 3.5.1 and I can onl...
4
2016-06-01T20:03:15Z
37,578,051
<p>One idea is to write two seperate scripts; one for analytics and one for docxfactory. Decide which of these is the driver, and have that driver shell the other -- being sure to invoke the appropriate version of python.</p> <p>ex:</p> <pre><code>#/usr/bin/env python2.7 import subprocess # Do something with analytic...
6
2016-06-01T20:19:27Z
[ "python", "pycharm" ]
Multiple Python Interpreters used in the same project?
37,577,785
<p>I am using pycharm and it only lets you use one interpreter for example Python 2.7.5 or Python 3.5.1.</p> <p>The problem is I have certain modules one from google to access analytics data and one called docxfactory that I want to use together.</p> <p>I can only get docxfactory to work on Python 3.5.1 and I can onl...
4
2016-06-01T20:03:15Z
37,579,206
<p>To use different interpreters on pycharm is easy, follow these steps bellow:</p> <ul> <li>First you need to add a new interpreter, go to section "settings"</li> </ul> <p><a href="http://i.stack.imgur.com/01KUn.png" rel="nofollow"><img src="http://i.stack.imgur.com/01KUn.png" alt="enter image description here"></a...
0
2016-06-01T21:36:24Z
[ "python", "pycharm" ]
Generating random vectors of Euclidean norm <= 1 in Python?
37,577,803
<p>More specifically, given a natural number d, how can I generate random vectors in R^d such that each vector x has Euclidean norm &lt;= 1?</p> <p>Generating random vectors via numpy.random.rand(1,d) is no problem, but the likelihood of such a random vector having norm &lt;= 1 is predictably bad for even not-small d....
11
2016-06-01T20:04:26Z
37,577,963
<p>Based on the Wolfram Mathworld article on <a href="http://mathworld.wolfram.com/HyperspherePointPicking.html" rel="nofollow">hypersphere point picking</a> and <a href="http://math.stackexchange.com/questions/87230/picking-random-points-in-the-volume-of-sphere-with-uniform-probability">Nate Eldredge's answer</a> to a...
9
2016-06-01T20:14:50Z
[ "python", "numpy", "random" ]
Generating random vectors of Euclidean norm <= 1 in Python?
37,577,803
<p>More specifically, given a natural number d, how can I generate random vectors in R^d such that each vector x has Euclidean norm &lt;= 1?</p> <p>Generating random vectors via numpy.random.rand(1,d) is no problem, but the likelihood of such a random vector having norm &lt;= 1 is predictably bad for even not-small d....
11
2016-06-01T20:04:26Z
37,579,811
<p>Based on the answer by user2357112, you need something like this:</p> <pre><code>import numpy as np ... inv_d = 1.0 / d for ...: gauss = np.random.normal(size=d) length = np.linalg.norm(gauss) if length == 0.0: x = gauss else: r = np.random.rand() ** inv_d x = np.multiply(gau...
3
2016-06-01T22:29:04Z
[ "python", "numpy", "random" ]
Most efficient way to aggregate tabular data meeting certain conditions in Python in O(1) time?
37,577,965
<p>Let's say I have a table with a bunch of data in long format (each row has one data point). For instance, let's say we have a table of people's SAT scores, with columns for state, city, school, gender, race, and person. My goal is to find a way to easily pull out and average data points corresponding to certain grou...
0
2016-06-01T20:14:58Z
37,581,302
<p>You cannot do this in O(1) time. </p> <p>This problem has more than one complexity associated with it. I can think of three: Prepossessing, insertion, and lookup. </p> <p>You could do this in O(nlog(n)) preproccessing + O(log(n)) lookup time, and O(log(n)) insertion as follows:</p> <pre><code> from collections...
0
2016-06-02T01:33:43Z
[ "python", "pandas" ]
Access denied when attempting to remove printer
37,578,005
<pre><code>def on_printer_button_clicked(self, button): for i in range(len(self.printer_buttons)): if button == self.printer_buttons[i]: pHandle = win32print.OpenPrinter(self.printers[i]['pPrinterName']) win32print.DeletePrinter(pHandle) return </code></pre> <p>So all I'm doing is openi...
0
2016-06-01T20:17:03Z
37,586,129
<p>The documentation states that <em>Printer handle must be opened for PRINTER_ACCESS_ADMINISTER</em>. Something like this might work:</p> <pre><code>PRINTER_DEFAULTS = {"DesiredAccess":win32print.PRINTER_ACCESS_ADMINISTER} win32print.OpenPrinter(self.printers[i]['pPrinterName'], PRINTER_DEFAULTS) </code></pre>
1
2016-06-02T08:09:08Z
[ "python", "printing", "pycharm", "pywin32" ]
filling columns based on multiple row values in Python
37,578,012
<p>I have a dataframe <code>A</code> with some empty cells that I want to fill to have dataframe <code>B</code>. Here is a sample data:</p> <pre><code>A= Month Type Sale 2016-01 A 20 2016-02 A 10 2016-01 B 40 2016-02 B 30 2016-01 C 2016-02 C 2016-01 D ...
1
2016-06-01T20:17:29Z
37,578,265
<p>I think you can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.fillna.html" rel="nofollow"><code>fillna</code></a> by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.sum.html" rel="nofollow"><code>sum</code></a>:</p> <pre><code>df['Sale'] = df.groupby('...
1
2016-06-01T20:33:14Z
[ "python", "pandas", "dataframe", "group-by" ]
filling columns based on multiple row values in Python
37,578,012
<p>I have a dataframe <code>A</code> with some empty cells that I want to fill to have dataframe <code>B</code>. Here is a sample data:</p> <pre><code>A= Month Type Sale 2016-01 A 20 2016-02 A 10 2016-01 B 40 2016-02 B 30 2016-01 C 2016-02 C 2016-01 D ...
1
2016-06-01T20:17:29Z
37,578,658
<p>Actually, since pandas 0.14 you can use <code>fillna</code> directly on the dataframe you need to fill in missing values.</p> <pre><code>A.fillna(B) Out[8]: Type Sale Month 2016-01 A 20.0 2016-02 A 10.0 2016-01 B 40.0 2016-02 B 30.0 2016-01 C 60.0 2016-02 C 40.0 2016-0...
1
2016-06-01T20:58:14Z
[ "python", "pandas", "dataframe", "group-by" ]
Create a video of layered videos
37,578,035
<p>I'm a python and OpenCV beginner! I would like to create a video made of 3 others videos. Each video is a moving car on a black background</p> <p>I created the video which is empty for the moment: </p> <pre><code>video_summary=cv2.VideoWriter(video_output_path ,fourcc,video_fps ,(480,270), True) </code></pre> <p>...
1
2016-06-01T20:18:44Z
37,583,901
<p>I'm not sure what you mean by "made of 3 other videos", here are 2 ideas:</p> <p>1) the 3 videos are seen one after another in succession:</p> <p>If this is the case, you can check which if the current video is finished. If it isn't, add its frame, else append the frame from the next video:</p> <pre><code>ret1,im...
1
2016-06-02T06:06:56Z
[ "python", "opencv", "video", "overlap" ]
'ListSerializer' object is not callable
37,578,159
<p>I am trying to implement Django-Rest framework for a voting application with content_type objects. I tried using the <a href="https://github.com/Ian-Foote/rest-framework-generic-relations" rel="nofollow">rest-framework-generic-relations</a> for serializers.py. It seems to me that the error might be within serializ...
0
2016-06-01T20:27:06Z
37,578,461
<p>The error is that it's trying to call the serializer_class, which is an instance of ListSerializer, instead of a clas.</p> <p>Shouldn't this:</p> <pre><code>serializer_class = VoteSerializer(queryset, many=True) </code></pre> <p>Be that:</p> <pre><code>serializer_class = VoteSerializer </code></pre>
1
2016-06-01T20:44:53Z
[ "python", "django", "serialization", "django-rest-framework" ]
Python return a linear/cumulative pairs of a list of numbers
37,578,160
<p>I have a pandas dataframe which has a messy concatenation of many different tables. I want to segment these tables out and perform operations on them. I have a list of table header locations that looks like this: [1, 4, 5, 7, 9, 12, 15] - so the header of the first table is at index 1, the header of the second table...
1
2016-06-01T20:27:06Z
37,578,351
<p>What about implementing this function like that:</p> <pre><code>def pairwise(itr): return list(zip(itr[:-1], itr[1:])) </code></pre> <p>So for a list <code>[1, 4, 5, 7, 9, 12, 15]</code> this function would zip <code>[1, 4, 5, 7, 9, 12]</code> and <code>[4, 5, 7, 9, 12, 15]</code>, returning the expected <code...
0
2016-06-01T20:38:14Z
[ "python", "list", "pandas", "pair" ]
Python return a linear/cumulative pairs of a list of numbers
37,578,160
<p>I have a pandas dataframe which has a messy concatenation of many different tables. I want to segment these tables out and perform operations on them. I have a list of table header locations that looks like this: [1, 4, 5, 7, 9, 12, 15] - so the header of the first table is at index 1, the header of the second table...
1
2016-06-01T20:27:06Z
37,578,353
<p>Do you have to have an iterator? You can just using slicing and <code>zip</code> to get a list of the desired pairs.</p> <pre><code>a = [1, 4, 5, 7, 9, 12, 15] idx_pairs = [list(z) for z in zip(a[:-1], a[1:])] idx_pairs &gt;&gt;&gt;[[1, 4], [4, 5], [5, 7], [7, 9], [9, 12], [12, 15]] </code></pre>
0
2016-06-01T20:38:25Z
[ "python", "list", "pandas", "pair" ]
Python return a linear/cumulative pairs of a list of numbers
37,578,160
<p>I have a pandas dataframe which has a messy concatenation of many different tables. I want to segment these tables out and perform operations on them. I have a list of table header locations that looks like this: [1, 4, 5, 7, 9, 12, 15] - so the header of the first table is at index 1, the header of the second table...
1
2016-06-01T20:27:06Z
37,578,403
<p>The problem is that izip is taking an item off the iterator each time, which is why the end up in pairs. Here is a direct approach to forming the iterator:</p> <pre><code>def pairwise(iterable): seq = iter(iterable) a = next(seq) for b in seq: yield a,b a = b list(pairwise([1,2,3,4])) ...
0
2016-06-01T20:41:34Z
[ "python", "list", "pandas", "pair" ]
Python return a linear/cumulative pairs of a list of numbers
37,578,160
<p>I have a pandas dataframe which has a messy concatenation of many different tables. I want to segment these tables out and perform operations on them. I have a list of table header locations that looks like this: [1, 4, 5, 7, 9, 12, 15] - so the header of the first table is at index 1, the header of the second table...
1
2016-06-01T20:27:06Z
37,578,423
<p>This should do the trick for you:</p> <pre><code>def pairwise(l1): l1Iter = iter(l1) pre = next(l1Iter) result = [] for curr in l1Iter: result.append([pre, curr]) pre = curr return result </code></pre> <p>Or if you don't need this list and a generator if fine:</p> <pre><code>de...
0
2016-06-01T20:42:45Z
[ "python", "list", "pandas", "pair" ]
Python return a linear/cumulative pairs of a list of numbers
37,578,160
<p>I have a pandas dataframe which has a messy concatenation of many different tables. I want to segment these tables out and perform operations on them. I have a list of table header locations that looks like this: [1, 4, 5, 7, 9, 12, 15] - so the header of the first table is at index 1, the header of the second table...
1
2016-06-01T20:27:06Z
37,578,640
<p>Why not just <code>[[a[x], a[x+1]] for x in range(len(a)-1)]</code>? assuming <code>a= [1, 4, 5, 7, 9, 12, 15]</code></p>
1
2016-06-01T20:57:35Z
[ "python", "list", "pandas", "pair" ]
python - update thread variable
37,578,254
<p>how do I update a variable inside a running thread, which is an infinite loop based on such variable?<br> a simplified version of what I tried is what follows, to no results of course, and I can't find any pointer.</p> <pre><code>import some_module as mod import threading class thr (threading.Thread): NUM = 5 ...
1
2016-06-01T20:32:19Z
37,578,438
<p>The problem is that you're creating a new thread each time you "call" (i.e. instantiate) <code>thr</code>. Change your code to</p> <pre><code>t = thr() t.start() time.sleep(1) t.NUM = 2 time.sleep(1) t.NUM = 6 time.sleep(1) t.NUM = 8 time.sleep(1) </code></pre>
1
2016-06-01T20:43:20Z
[ "python", "multithreading" ]
python - update thread variable
37,578,254
<p>how do I update a variable inside a running thread, which is an infinite loop based on such variable?<br> a simplified version of what I tried is what follows, to no results of course, and I can't find any pointer.</p> <pre><code>import some_module as mod import threading class thr (threading.Thread): NUM = 5 ...
1
2016-06-01T20:32:19Z
37,579,474
<p>Maybe try use queue for change NUM variable.</p> <p><a href="https://docs.python.org/2/library/queue.html" rel="nofollow">https://docs.python.org/2/library/queue.html</a></p> <p>Check examples here :</p> <p><a href="https://pymotw.com/2/Queue/" rel="nofollow">https://pymotw.com/2/Queue/</a></p> <p>Generally spea...
0
2016-06-01T21:57:38Z
[ "python", "multithreading" ]
clone url of a pull request
37,578,259
<p>I'm trying to get the clone URL of a pull request. For example in Ruby using the Octokit library, I can fetch it from the head and base like so, where <code>pr</code> is a PullRequest object: <code>pr.head.repo.clone_url</code> or <code>pr.base.repo.clone_url</code>. How can I achieve the same thing using github3.py...
0
2016-06-01T20:32:52Z
37,578,664
<p><code>github3.pull_request(owner, repo, number).as_dict()['head']['repo']['clone_url']</code></p>
0
2016-06-01T20:58:24Z
[ "python", "github", "github3.py" ]
Loading and saving graphs in python
37,578,327
<p>I need to create a graph based on a set of input files. Since those files could be loaded during separate iterations, I need to <strong>save the graph</strong> and be able to add to it after <strong>re-loading the graph information from file</strong>.</p> <p>The obvious choice seems <a href="http://graphviz.readthe...
2
2016-06-01T20:36:50Z
37,578,709
<p><a href="https://networkx.github.io/" rel="nofollow">NetworkX</a> provides abundant file formats for reading and writing graphs. Refer to <a href="https://networkx.github.io/documentation/development/reference/readwrite.html" rel="nofollow">Reading and writing graphs</a> for the detailed description. For instance,</...
2
2016-06-01T21:01:17Z
[ "python", "graph" ]
Extract Values from heavily nested list of dictionaries with duplicate key value pairs
37,578,346
<p>Trying to extract Total Cash and Cash Equivalent values from complex and messy list of dictionaries. A shortened version of the structure follows below. </p> <p>I've tried: maps, Dataframe.from_dict &amp; .from_records. Trying to avoid using RE.</p> <p>I'm stumped.</p> <p><div class="snippet" data-lang="js" data-...
1
2016-06-01T20:37:59Z
37,580,997
<p>If you know that the data will have exactly the format from above and you really just need these two values, you can access it directly (assuming <code>data</code> is your above structure):</p> <pre><code>print data[0]['Rows'][2]['Rows'][3]['Cells'][1]['Value'] print data[0]['Rows'][2]['Rows'][3]['Cells'][2]['Value...
1
2016-06-02T00:48:53Z
[ "python", "dictionary", "pandas" ]
How to set cookies in phantomjs using selenium with python?
37,578,397
<p><a href="http://i.stack.imgur.com/gMWqc.png" rel="nofollow"><img src="http://i.stack.imgur.com/gMWqc.png" alt="enter image description here"></a></p> <p>It raise an error message said "Can only set Cookies for the current domain",but all I did is just put the old cookies in.Sometime I add the 'correct' domain,it wi...
1
2016-06-01T20:41:06Z
37,578,697
<p>The PhantomJS driver doesn't support all the keys from the cookie dictionary. One way to overcome this issue is to select the keys:</p> <pre><code>from selenium import webdriver driver = webdriver.PhantomJS() driver.get('http://stackoverflow.com/') cookies = driver.get_cookies() driver.delete_all_cookies() for ...
2
2016-06-01T21:00:31Z
[ "python", "selenium", "cookies", "phantomjs" ]
Precision and Recall on PySpark DecisionTree model diverges from manual results
37,578,416
<p>I trained a <code>DecisionTree</code> model on a PySpark dataframe. The resulting dataframe is simulated below:</p> <pre><code>rdd = sc.parallelize( [ (0., 1.), (0., 0.), (0., 0.), (1., 1.), (1.,0.), (1.,0.), (1.,1.), (1.,1.) ] ) df = sqlC...
1
2016-06-01T20:42:32Z
37,578,882
<p>The problem is that you are using MultiClassMetrics for processing output of a Binary classifier. From the <a href="https://spark.apache.org/docs/1.5.2/api/java/index.html?org/apache/spark/mllib/evaluation/MulticlassMetrics.html" rel="nofollow">docs</a>:</p> <pre><code>recall() Returns recall (equals to precision f...
2
2016-06-01T21:13:56Z
[ "python", "apache-spark", "pyspark" ]
Creating a Stopwatch progam for Python 3.3 only in IDLE
37,578,426
<p>I have an assignment where I need to create a stopwatch, but only for IDLE. Here's what I have so far, I'm not sure how to convert the times to normal time.</p> <pre><code>import time start = 0 def stopwatch(): while True: command = input("Type: start, stop, reset, or quit: \n") if (command == "...
0
2016-06-01T20:42:54Z
37,578,497
<p>You can use <a href="https://docs.python.org/2/library/datetime.html#timedelta-objects" rel="nofollow"><code>datetime.timedelta()</code></a>:</p> <pre><code>import datetime print(datetime.timedelta(seconds=total)) </code></pre> <p>For example:</p> <pre><code>In [10]: print datetime.timedelta(seconds=10000000) 11...
0
2016-06-01T20:47:49Z
[ "python", "python-3.x" ]
Creating a Stopwatch progam for Python 3.3 only in IDLE
37,578,426
<p>I have an assignment where I need to create a stopwatch, but only for IDLE. Here's what I have so far, I'm not sure how to convert the times to normal time.</p> <pre><code>import time start = 0 def stopwatch(): while True: command = input("Type: start, stop, reset, or quit: \n") if (command == "...
0
2016-06-01T20:42:54Z
37,578,859
<p>Think of it like this... Idle is really no different than coding in the interactive python interpreter which I do all the time (well, I use ipython).</p> <p>Think of your stopwatch like an object. What functionality does it have? Things like start, stop, reset.</p> <p>This may not be the most efficient way to solv...
0
2016-06-01T21:11:56Z
[ "python", "python-3.x" ]
Google Vision API's label detection
37,578,483
<p><strong>Problem 1:</strong> </p> <p>I'm using <code>Vision API's label detection</code> and I'm getting the following error: </p> <blockquote> <p>"<strong>HttpError 429</strong> when requesting <a href="https://vision.googleapis.com/v1/images:annotate?alt=json" rel="nofollow">https://vision.googleapis.com/v1/...
1
2016-06-01T20:46:56Z
40,085,414
<p>Try rebuilding the "service" for each loop/call to the image, so as to refresh the token</p>
0
2016-10-17T11:38:28Z
[ "python", "python-2.7", "google-api", "google-api-python-client", "vision" ]
ERROR_NO_MORE_ITEMS with named pipe and IO completion port
37,578,491
<p>I have a simple named pipe server implemented in python+ctypes:</p> <pre><code>pipe = windll.kernel32.CreateNamedPipeA('\\\\.\\pipe\\pipe_name', PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE, 1, 0, 0, 0, None) overlapped_struct = OVERLAPPED() windll.kernel32.ConnectNamedPipe(pipe, byref(overlapped_str...
0
2016-06-01T20:47:32Z
37,665,695
<p>I figured it out. A completion packet is queued after <strong>any</strong> operation on a pipe. It means that <code>GetQueuedCompletionStatus</code> will return after client connection, write and read operation.</p> <p>What was happening in my situation:</p> <ol> <li>I received data from external program. Completi...
0
2016-06-06T19:48:25Z
[ "python", "ctypes", "named-pipes", "io-completion-ports" ]
Blender scale value not updating
37,578,517
<p>When I run this script:</p> <pre><code>import bpy import math s = bpy.context.scene.frame_start e = bpy.context.scene.frame_end values = [] print(s) print(e) for i in range(s,e): bpy.context.scene.frame_current = i print(i) v = (bpy.context.object.scale[1]) bpy.context.object.scale[0] = i pr...
0
2016-06-01T20:49:19Z
37,582,630
<p>You are looking at the wrong values.</p> <p>You have <code>v = scale[1]</code> then set <code>scale[0] = i</code> and then <code>print(v)</code> so your reading scale.y and changing scale.x then looking at scale.y</p> <p>It is better to use <a href="https://www.blender.org/api/blender_python_api_current/bpy.types....
0
2016-06-02T04:23:09Z
[ "python", "audio", "blender" ]
looping over a dataframe and fetching related data from another dataframe :PANDAS
37,578,530
<p>I have a dataframe having all transaction data of customers. columns are mailid,txn_date,city. Now I have a situation where I have to consider customer's from 01jan2016 and for each of mailid in that I have to fetch their txn data from base file and by considering their last 12 Month data(txn date between last Txn...
0
2016-06-01T20:50:32Z
37,579,626
<p>You can use the groupby and apply functionality more efficiently.</p> <p>Group by both city and maild and get the maximum date and total number of transactions. Sort by the max date.</p> <pre><code>g=d.groupby(['maild','city'])['txn_date'].agg(['count','max']).sort_values('max',ascending=False) </code></pre> <p>T...
1
2016-06-01T22:13:11Z
[ "python", "pandas" ]
looping over a dataframe and fetching related data from another dataframe :PANDAS
37,578,530
<p>I have a dataframe having all transaction data of customers. columns are mailid,txn_date,city. Now I have a situation where I have to consider customer's from 01jan2016 and for each of mailid in that I have to fetch their txn data from base file and by considering their last 12 Month data(txn date between last Txn...
0
2016-06-01T20:50:32Z
37,579,682
<p>Here's an alternative that might be a little easier to read:</p> <pre><code>def f(g): dc=g.groupby('city')['txn_date'] dc_sorted=dc.agg(['count','max']).sort_values('max',ascending=False) return dc_sorted['count'].argmax() d.groupby(['maild']).apply(f) </code></pre> <p>However, I suspect that <code>ap...
1
2016-06-01T22:17:52Z
[ "python", "pandas" ]
looping over a dataframe and fetching related data from another dataframe :PANDAS
37,578,530
<p>I have a dataframe having all transaction data of customers. columns are mailid,txn_date,city. Now I have a situation where I have to consider customer's from 01jan2016 and for each of mailid in that I have to fetch their txn data from base file and by considering their last 12 Month data(txn date between last Txn...
0
2016-06-01T20:50:32Z
37,604,959
<p>Consider an <code>apply</code> and <code>transform</code> function. The first runs group counts on <code>maild</code> and <code>city</code> according to time frame and second maximizes the count by <code>maild</code>. Finally the <code>groupby()</code> filtering at end keeps the pair whose count equals max count.</p...
0
2016-06-03T02:22:06Z
[ "python", "pandas" ]
Python, checking if string consists only of 1's and 0's
37,578,628
<p>I'm trying to write a function that checks if given string is binary or not. I'm using a while loop to browse characters in string one by one. If all of them are 0's or 1's it's going to return True, if anything is not - break the loop and return False. I've just written this tiny part of code, but it doesn't run. ...
-1
2016-06-01T20:57:02Z
37,578,673
<p>You can use the <code>int</code> object and give it a base. It will fail if the object passed doesn't consist of a binary representation. Recall that a binary string is base 2.</p> <pre><code>def fnIsBin(string): try: binary_repr = int(string, 2) except ValueError as err print("error: {0}".f...
1
2016-06-01T20:59:00Z
[ "python", "loops" ]
Python, checking if string consists only of 1's and 0's
37,578,628
<p>I'm trying to write a function that checks if given string is binary or not. I'm using a while loop to browse characters in string one by one. If all of them are 0's or 1's it's going to return True, if anything is not - break the loop and return False. I've just written this tiny part of code, but it doesn't run. ...
-1
2016-06-01T20:57:02Z
37,578,706
<p>Your function fails because you never actually return <code>True</code>. That means if the string is actually binary, you'd return <code>None</code> which Python would consider as <code>False</code> in any boolean check.</p> <p>Simply add <code>return True</code> at the end of the function.</p> <p>As @Barmar menti...
3
2016-06-01T21:01:15Z
[ "python", "loops" ]
Python, checking if string consists only of 1's and 0's
37,578,628
<p>I'm trying to write a function that checks if given string is binary or not. I'm using a while loop to browse characters in string one by one. If all of them are 0's or 1's it's going to return True, if anything is not - break the loop and return False. I've just written this tiny part of code, but it doesn't run. ...
-1
2016-06-01T20:57:02Z
37,578,735
<p>Here's one of the ways you could rewrite your function and maintain a similar structure (looping through each character):</p> <pre><code>def fnIsBin(string): for character in string: if not character in '01': return False return True </code></pre> <p>You could also do it using regular e...
0
2016-06-01T21:03:30Z
[ "python", "loops" ]
Python, checking if string consists only of 1's and 0's
37,578,628
<p>I'm trying to write a function that checks if given string is binary or not. I'm using a while loop to browse characters in string one by one. If all of them are 0's or 1's it's going to return True, if anything is not - break the loop and return False. I've just written this tiny part of code, but it doesn't run. ...
-1
2016-06-01T20:57:02Z
37,578,755
<p>You're printing <code>OK</code> for each character that's <code>0</code> or <code>1</code>, even though there may be a later character that isn't. You need to wait until the end of the loop to know that it's really OK.</p> <pre><code>def fnIsBin(string): for character in string: if character != '0' and ...
0
2016-06-01T21:04:38Z
[ "python", "loops" ]
Python, checking if string consists only of 1's and 0's
37,578,628
<p>I'm trying to write a function that checks if given string is binary or not. I'm using a while loop to browse characters in string one by one. If all of them are 0's or 1's it's going to return True, if anything is not - break the loop and return False. I've just written this tiny part of code, but it doesn't run. ...
-1
2016-06-01T20:57:02Z
37,629,154
<p>There are many ways to do this:</p> <p>Set:</p> <pre><code>fnInBin(s): return set(s).issubset({'0', '1'}) and bool(s) </code></pre> <p>Regular expression:</p> <pre><code>fnInBin(s): return bool(re.fullmatch('[01]+', s)) </code></pre> <p>Integer conversion: </p> <pre><code>fnIsBin(s): try: in...
0
2016-06-04T10:35:36Z
[ "python", "loops" ]
How to feed Cifar10 trained model with my own image and get label as output?
37,578,876
<p>I am trying to use the trained model based on the <a href="https://www.tensorflow.org/versions/r0.8/tutorials/deep_cnn/index.html" rel="nofollow">Cifar10 tutorial</a> and would like to feed it with an external image 32x32 (jpg or png).<br> My goal is to be able to get <strong>the label as an output</strong>. In othe...
1
2016-06-01T21:13:18Z
37,579,847
<p>Some basics first:</p> <ol> <li>First you define your graph: image queue, image preprocessing, inference of the convnet, top-k accuracy</li> <li>Then you create a <code>tf.Session()</code> and work inside it: starting the queue runners, and calls to <code>sess.run()</code></li> </ol> <hr> <p>Here is what your cod...
1
2016-06-01T22:31:46Z
[ "python", "tensorflow" ]
Error shown in Python - TypeError : unsupported operand type(s) for ** or pow() :'str' and 'int'
37,578,877
<p>I just started python today.. Spent hours on codeacademy and learnt quite a bit so I thought I'd make my own program to square the ages of a person and their sibling. Very basic just a starter. Pretty useless actually just wanted to see what I can do. I keep getting this TypeError mentioned in the title. Here's my...
-1
2016-06-01T21:13:26Z
37,579,055
<p>First and foremost, if you're just starting, you <strong><em>really</em></strong> should be learning Python 3, not 2. </p> <p>The code you posted has many issues. Here's a line-by-line breakdown, with corrections in Python 3:</p> <pre><code>a=raw_input(''enter age'') b=raw_input(''sibling's age'') </code></pre> ...
1
2016-06-01T21:26:32Z
[ "python", "python-2.7", "typeerror" ]
How to pass Bash variables as Python arguments
37,578,878
<p>I'm trying to figure out if it is possible to pass values stored in a variable in Bash in as argument values in a python script.</p> <p>We have a python script that we use to create DNS records in BIND and I've been tasked with cleaning up our outdated DNS database. so far I have something like this in bash:</p> <...
0
2016-06-01T21:13:28Z
37,578,910
<p>As long as the variables are exported, they're accessible from Python.</p> <pre><code>$ export VAR=val $ python -c "import os; print os.environ['VAR']" val </code></pre>
2
2016-06-01T21:16:04Z
[ "python", "bash" ]
How to pass Bash variables as Python arguments
37,578,878
<p>I'm trying to figure out if it is possible to pass values stored in a variable in Bash in as argument values in a python script.</p> <p>We have a python script that we use to create DNS records in BIND and I've been tasked with cleaning up our outdated DNS database. so far I have something like this in bash:</p> <...
0
2016-06-01T21:13:28Z
37,579,099
<p>Yes, seems to work just fine to me.</p> <p>To test, I threw together a very quick python script called test.py:</p> <pre><code>#!/usr/bin/python import sys print 'number of arguments: ', len(sys.argv) #we know sys.argv[0] is the script name, let's look at sys.argv[1] print sys.argv[1] </code></pre> <p>Then, in y...
3
2016-06-01T21:29:39Z
[ "python", "bash" ]
Sensible way to create filenames for files based on URLs?
37,578,891
<p>I am screenshotting a bunch of web pages, using Python with Selenium. I want to save the PNGs locally for reference. The list of URLs looks something like this:</p> <pre><code>www.mysite.com/dir1/pageA www.mysite.com/dir1/pageB </code></pre> <p>My question is about what filenames to give the screenshotted PNGs. <...
2
2016-06-01T21:14:46Z
37,579,133
<p>What if you use '%2F'? It's the '/' but html encoded.</p> <p>source: <a href="http://www.w3schools.com/tags/ref_urlencode.asp" rel="nofollow">http://www.w3schools.com/tags/ref_urlencode.asp</a></p>
0
2016-06-01T21:31:58Z
[ "python", "filesystems", "naming" ]
Sensible way to create filenames for files based on URLs?
37,578,891
<p>I am screenshotting a bunch of web pages, using Python with Selenium. I want to save the PNGs locally for reference. The list of URLs looks something like this:</p> <pre><code>www.mysite.com/dir1/pageA www.mysite.com/dir1/pageB </code></pre> <p>My question is about what filenames to give the screenshotted PNGs. <...
2
2016-06-01T21:14:46Z
37,588,424
<p>The easiest way to represent what's almost certainly a directory structure on the server is to do like <code>wget</code> does and replicate that structure on your local machine.</p> <p>Thus the <code>/</code> characters become directory delimiters, and your <code>www.mysite.com/dir1/pageA.png</code> would become a ...
1
2016-06-02T09:53:14Z
[ "python", "filesystems", "naming" ]
How do I concatenate lines from a file onto a single line of code?
37,578,927
<p>I'm new to programming and currently working on problem <a href="https://www.reddit.com/r/dailyprogrammer/comments/4lpygb/20160530_challenge_269_easy_basic_formatting/" rel="nofollow">#269 from r/dailyprogrammer.</a> I want to add the ability to read files and format them based on the indention format given. My cur...
1
2016-06-01T21:17:06Z
37,579,082
<p>Your <code>indents</code> string ends with a newline, like this: <code>" \n"</code>. You want to get rid of that. </p> <pre><code>indents=f.readline().strip('\n') </code></pre> <p>When reading from a text file, there will always be a newline character at the end of each line until you've reached the end of the ...
1
2016-06-01T21:28:26Z
[ "python" ]
How do I concatenate lines from a file onto a single line of code?
37,578,927
<p>I'm new to programming and currently working on problem <a href="https://www.reddit.com/r/dailyprogrammer/comments/4lpygb/20160530_challenge_269_easy_basic_formatting/" rel="nofollow">#269 from r/dailyprogrammer.</a> I want to add the ability to read files and format them based on the indention format given. My cur...
1
2016-06-01T21:17:06Z
37,579,536
<p>Just use multiple lines string in your program as an input.<p> inputBasicCode = """<p> ...<p> '"""<p> It is more simple and clear way to do program input. Perfect for debugging. Just concentrate on the target.<p></p> <p><a href="https://www.reddit.com/r/dailyprogrammer/comments/4lpygb/20160530_challenge_269_easy_ba...
-1
2016-06-01T22:03:28Z
[ "python" ]
How do I concatenate lines from a file onto a single line of code?
37,578,927
<p>I'm new to programming and currently working on problem <a href="https://www.reddit.com/r/dailyprogrammer/comments/4lpygb/20160530_challenge_269_easy_basic_formatting/" rel="nofollow">#269 from r/dailyprogrammer.</a> I want to add the ability to read files and format them based on the indention format given. My cur...
1
2016-06-01T21:17:06Z
37,580,700
<p>Your statement <code>print(indents*block+line)</code> inherently adds a new line character at the end. Since the python "print" statement adds newline regardless of whats inside the print command. Add a comma at the end of the print statement like this <code>print(indents*block+line,)</code> and it will not print th...
0
2016-06-02T00:07:53Z
[ "python" ]
Create copy of Oracle database table to another Oracle database using SQL
37,578,985
<p>I am wondering if there is a simple way to copy either an entire Oracle database table or data rows into another Oracle database table (different databases). Is there some type of way to do this using SQL language? My initial thought is to use a SQL query like this:</p> <pre><code>INSERT INTO outputTable SELECT *...
2
2016-06-01T21:20:49Z
37,579,131
<p>You can create a <a href="https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_5005.htm" rel="nofollow">DBLink</a> to connect the source and the target DB, then simply use SQL to save your data in the linked DB.</p> <p>Something like:</p> <pre><code>create database link "TARGET" connect to YOUR_SCHEMA...
3
2016-06-01T21:31:50Z
[ "python", "sql", "oracle" ]