qid
int64
46k
74.7M
question
stringlengths
54
37.8k
date
stringlengths
10
10
metadata
listlengths
3
3
response_j
stringlengths
17
26k
response_k
stringlengths
26
26k
49,154,899
I want to create a virtual environment using conda and yml file. Command: ``` conda env create -n ex3 -f env.yml ``` Type ENTER it gives following message: ``` ResolvePackageNotFound: - gst-plugins-base==1.8.0=0 - dbus==1.10.20=0 - opencv3==3.2.0=np111py35_0 - qt==5.6.2=5 - libxcb==1.12=1 - libgcc==5.2.0=0 ...
2018/03/07
[ "https://Stackoverflow.com/questions/49154899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7722305/" ]
There can be another reason for the '**ResolvePackageNotFound**' error -- the version of the packages you require might be in an old version of the repository that is not searched by default. The different paths to locations in the Anaconda repositories can be found at: <https://repo.continuum.io/pkgs/> My yml fil...
Use `--no-builds` option to `conda env export` <https://github.com/conda/conda/issues/7311#issuecomment-442320274>
49,154,899
I want to create a virtual environment using conda and yml file. Command: ``` conda env create -n ex3 -f env.yml ``` Type ENTER it gives following message: ``` ResolvePackageNotFound: - gst-plugins-base==1.8.0=0 - dbus==1.10.20=0 - opencv3==3.2.0=np111py35_0 - qt==5.6.2=5 - libxcb==1.12=1 - libgcc==5.2.0=0 ...
2018/03/07
[ "https://Stackoverflow.com/questions/49154899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7722305/" ]
Use `--no-builds` option to `conda env export` <https://github.com/conda/conda/issues/7311#issuecomment-442320274>
If you are looking at this and feel too much chore to change Conda version `packge=ver=py.*` to pip style `package==ver`, I wrote this small script that delete the `=py.*` part from Conda style. Note below code work on the presume that you already changed `package=ver` to `package==ver`. ``` #!/bin/bash COUNT=0 fi...
49,154,899
I want to create a virtual environment using conda and yml file. Command: ``` conda env create -n ex3 -f env.yml ``` Type ENTER it gives following message: ``` ResolvePackageNotFound: - gst-plugins-base==1.8.0=0 - dbus==1.10.20=0 - opencv3==3.2.0=np111py35_0 - qt==5.6.2=5 - libxcb==1.12=1 - libgcc==5.2.0=0 ...
2018/03/07
[ "https://Stackoverflow.com/questions/49154899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7722305/" ]
I had same problem and found your question googling for it. `ResolvePackageNotFound` error describes all packages not installed yet, but required. To solve the problem, move them under `pip` section: ``` name: ex3 channels: - menpo - defaults dependencies: - cairo=1.14.8=0 - *** - another dependencies, except ...
Let's assume the following command is used to create the environment.yml file : `conda env export --from-history -n envName -f environment1.yml` where envName is the name of the environment we are interested in. Assuming the content of the file is: ``` name: envName channels: - defaults dependencies:...
49,154,899
I want to create a virtual environment using conda and yml file. Command: ``` conda env create -n ex3 -f env.yml ``` Type ENTER it gives following message: ``` ResolvePackageNotFound: - gst-plugins-base==1.8.0=0 - dbus==1.10.20=0 - opencv3==3.2.0=np111py35_0 - qt==5.6.2=5 - libxcb==1.12=1 - libgcc==5.2.0=0 ...
2018/03/07
[ "https://Stackoverflow.com/questions/49154899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7722305/" ]
I got the same issue and found a [GitHub issue](https://github.com/conda/conda/issues/6073#issuecomment-356981567) related to this. In the comments, @kalefranz posted an ideal solution by using the `--no-builds` flag with conda env export. ``` conda env export --no-builds > environment.yml ``` However, even remove b...
For Apple ARM you should use another requirements: <https://github.com/magnusviri/stable-diffusion-old/blob/apple-silicon-mps-support/environment-mac.yaml>
65,822,290
I made two components using python functions and I am trying to pass data between them using files, but I am unable to do so. I want to calculate the sum and then send the answer to the other component using a file. Below is the partial code (The code works without the file passing). Please assist. ``` # Define your c...
2021/01/21
[ "https://Stackoverflow.com/questions/65822290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13435688/" ]
Here is a slightly simplified version of your pipeline that I tested and which works. It doesn't matter what class type you pass to `OutputTextFile` and `InputTextFile`. It'll be read and written as `str`. So this is what you should change: * While writing to `OutputTextFile`: cast `sum_` from `float to str` * While r...
`('out', comp.OutputTextFile(float))` This is not really valid. The `OutputTextFile` annotation (and other similar annotations) can only be used in the function parameters. The function return value is only for outputs that you want to output as values (not as files). Since you already have `f: comp.OutputTextFile(fl...
41,006,153
Using python 3.4.3 or python 3.5.1 I'm surprised to see that: ``` from decimal import Decimal Decimal('0') * Decimal('123.456789123456') ``` returns: ``` Decimal('0E-12') ``` Worse part is that this specific use case works with float. Is there anything I could do to make sure the maths work and 0 multiplied by a...
2016/12/06
[ "https://Stackoverflow.com/questions/41006153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6451083/" ]
`0E-12` actually is `0` (it's short for `0 * 10 ** -12`; since the coefficient is 0, that's still 0), `Decimal` just provides the `E-12` bit to indicate the "confidence level" of the `0`. What you've got will still behave like zero (it's falsy, additive identity, etc.), the only quirk is in how it prints. If you need ...
Do the multiplication with floats and convert to decimal afterwards. ``` x = 0 y = 123.456789123456 Decimal(x*y) ``` returns (on Python 3.5.2): ``` Decimal('0') ```
41,006,153
Using python 3.4.3 or python 3.5.1 I'm surprised to see that: ``` from decimal import Decimal Decimal('0') * Decimal('123.456789123456') ``` returns: ``` Decimal('0E-12') ``` Worse part is that this specific use case works with float. Is there anything I could do to make sure the maths work and 0 multiplied by a...
2016/12/06
[ "https://Stackoverflow.com/questions/41006153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6451083/" ]
`0E-12` actually is `0` (it's short for `0 * 10 ** -12`; since the coefficient is 0, that's still 0), `Decimal` just provides the `E-12` bit to indicate the "confidence level" of the `0`. What you've got will still behave like zero (it's falsy, additive identity, etc.), the only quirk is in how it prints. If you need ...
Even though `Decimal('0E-12')` is not visually the same as `Decimal('0')`, there is no difference to python. ``` >>> Decimal('0E-12') == 0 True ``` The notation 0E-12 actually represents: 0 \* 10 \*\* -12. This expression evaluates to 0.
41,006,153
Using python 3.4.3 or python 3.5.1 I'm surprised to see that: ``` from decimal import Decimal Decimal('0') * Decimal('123.456789123456') ``` returns: ``` Decimal('0E-12') ``` Worse part is that this specific use case works with float. Is there anything I could do to make sure the maths work and 0 multiplied by a...
2016/12/06
[ "https://Stackoverflow.com/questions/41006153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6451083/" ]
`0E-12` actually is `0` (it's short for `0 * 10 ** -12`; since the coefficient is 0, that's still 0), `Decimal` just provides the `E-12` bit to indicate the "confidence level" of the `0`. What you've got will still behave like zero (it's falsy, additive identity, etc.), the only quirk is in how it prints. If you need ...
You may quantize your result to required precision. ``` from decimal import Decimal, ROUND_HALF_UP result = Decimal('0') * Decimal('123.456789123456') result.quantize(Decimal('.01'), rounding = ROUND_HALF_UP) >>>Decimal('0.00') ``` For more info (eg. about rounding modes or even setting up a context for all decimal...
41,006,153
Using python 3.4.3 or python 3.5.1 I'm surprised to see that: ``` from decimal import Decimal Decimal('0') * Decimal('123.456789123456') ``` returns: ``` Decimal('0E-12') ``` Worse part is that this specific use case works with float. Is there anything I could do to make sure the maths work and 0 multiplied by a...
2016/12/06
[ "https://Stackoverflow.com/questions/41006153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6451083/" ]
Even though `Decimal('0E-12')` is not visually the same as `Decimal('0')`, there is no difference to python. ``` >>> Decimal('0E-12') == 0 True ``` The notation 0E-12 actually represents: 0 \* 10 \*\* -12. This expression evaluates to 0.
Do the multiplication with floats and convert to decimal afterwards. ``` x = 0 y = 123.456789123456 Decimal(x*y) ``` returns (on Python 3.5.2): ``` Decimal('0') ```
41,006,153
Using python 3.4.3 or python 3.5.1 I'm surprised to see that: ``` from decimal import Decimal Decimal('0') * Decimal('123.456789123456') ``` returns: ``` Decimal('0E-12') ``` Worse part is that this specific use case works with float. Is there anything I could do to make sure the maths work and 0 multiplied by a...
2016/12/06
[ "https://Stackoverflow.com/questions/41006153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6451083/" ]
You may quantize your result to required precision. ``` from decimal import Decimal, ROUND_HALF_UP result = Decimal('0') * Decimal('123.456789123456') result.quantize(Decimal('.01'), rounding = ROUND_HALF_UP) >>>Decimal('0.00') ``` For more info (eg. about rounding modes or even setting up a context for all decimal...
Do the multiplication with floats and convert to decimal afterwards. ``` x = 0 y = 123.456789123456 Decimal(x*y) ``` returns (on Python 3.5.2): ``` Decimal('0') ```
41,006,153
Using python 3.4.3 or python 3.5.1 I'm surprised to see that: ``` from decimal import Decimal Decimal('0') * Decimal('123.456789123456') ``` returns: ``` Decimal('0E-12') ``` Worse part is that this specific use case works with float. Is there anything I could do to make sure the maths work and 0 multiplied by a...
2016/12/06
[ "https://Stackoverflow.com/questions/41006153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6451083/" ]
Even though `Decimal('0E-12')` is not visually the same as `Decimal('0')`, there is no difference to python. ``` >>> Decimal('0E-12') == 0 True ``` The notation 0E-12 actually represents: 0 \* 10 \*\* -12. This expression evaluates to 0.
You may quantize your result to required precision. ``` from decimal import Decimal, ROUND_HALF_UP result = Decimal('0') * Decimal('123.456789123456') result.quantize(Decimal('.01'), rounding = ROUND_HALF_UP) >>>Decimal('0.00') ``` For more info (eg. about rounding modes or even setting up a context for all decimal...
32,407,824
I am new to python programming. I need to read contents from a csv file and print based on a matching criteria. The file contains columns like this: abc, A, xyz, W gfk, B, abc, Y, xyz, F I want to print the contents of the adjacent column based on the matching input string. For e.g. if the string is abc it should...
2015/09/04
[ "https://Stackoverflow.com/questions/32407824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5298602/" ]
Your approach made it more difficult to print adjacent values, because even if you used `enumerate` to get the indices, you would have to search the row again, after finding each pattern (after `if i in row:` you wouldn't immediately know where it was in the row). By structuring the data in a dictionary it becomes simp...
You can adapt this for the CSV, but it basically do what you ask for ``` csv = [['abc', 'A', 'xyz', 'W'], ['gfk', 'B', 'abc', 'Y', 'xyz', 'F']] match_string = ['abc','xyz','gfk'] for row in csv: for i, column_content in enumerate(row): if column_content in match_string: print row[i + ...
45,622,443
I started using Retrofit in my android app consuming RESTful web services. I managed to get it working with a simple object. But when trying with a more complex object it remains desperately empty. I put Okhttp in debug, and the json I'm expecting is present in the response, so I think there is a problem during the cr...
2017/08/10
[ "https://Stackoverflow.com/questions/45622443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4208537/" ]
Try first sending data to your WebServices using clients like [Postman](https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop), this is a very usefull tool. You can check what's your WebService sending to your Android app
I faced with the same problem by using retrofit on kotlin. it was: ``` data class MtsApprovalResponseData( @field:Element(name = "MessageId", required = false) @Namespace(reference = WORKAROUND_NAMESPACE) var messageId: String? = null, @field:Element(name = "Version", required = false) @Namespac...
72,944,672
In one directory there are several folders that their names are as follows: 301, 302, ..., 600. Each of these folders contain two folders with the name of `A` and `B`. I need to copy all the image files from A folders of each parent folder to the environment of that folder (copying images files from e.g. 600>A to 600 f...
2022/07/11
[ "https://Stackoverflow.com/questions/72944672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11140344/" ]
I recommend you to use the [Pathlib](https://docs.python.org/3/library/pathlib.html). ``` from pathlib import Path import shutil from tqdm import tqdm folder_to_be_sorted = Path("/your/path/to/the/folder") for folder_named_number_i in tqdm(list(folder_to_be_sorted.iterdir())): # folder_named_number_i is 301, 302...
@hellohawii gave an excellent answer. Following code also works and you only need change value of *Source* when using. ``` import shutil import os, sys from tqdm import tqdm exepath = sys.argv[0] # current path of code Source = os.path.dirname(os.path.abspath(exepath))+"\\Credits\\" # path of folders:301, 302... 6...
67,707,605
I am trying to use python to place orders through the TWS API. My problem is getting the next valid order ID. Here is what I am using: ``` from ibapi.client import EClient from ibapi.wrapper import EWrapper from ibapi.common import TickerId from ibapi import contract, order, common from threading import Thread class...
2021/05/26
[ "https://Stackoverflow.com/questions/67707605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15524510/" ]
The `nextValidId` method is a wrapper method. From the client, you need to call `reqIds` to get an Order ID. ``` ib_api.reqIds(-1) ``` The parameter of `reqIds` doesn't matter. Also, it doesn't have a return value. Instead, `reqIds` sends a message to IB, and when the response is received, the wrapper's `nextValidId...
Add some delay after `reqIds` ----------------------------- In the wrapper class for receiving updates from `ibapi`, override `nextValidId` function as it is used by `ib_api.reqIds` to respond back. ``` from ibapi.wrapper import iswrapper @iswrapper def nextValidId(self, orderId: int): super().nextValidId(orderI...
68,164,039
I'm a python beginner and I'm trying to solve a cubic equation with two independent variables and one dependent variable. Here is the equation, which I am trying to solve for v: 3pv^3−(p+8t)v^2+9v−3=0 If I set p and t as individual values, I can solve the equation with my current code. But what I would like to do is ...
2021/06/28
[ "https://Stackoverflow.com/questions/68164039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16334402/" ]
You can simply use a for loop I think. This is what seems to work: ``` for p in range(10): solution = solve(3*p*(v**3)-(v**2)*(p+8*t)+9*v-3, v) print(solution) ``` Also, note that range(10) goes from 0 to 9 (inclusive)
Same idea as previous answer, but I think it's generally good practice to keep imports at the top and to separate equation and solution to separate lines etc. Makes it a bit easier to read ``` from sympy.solvers import solve from sympy import Symbol import numpy as np tc = 300 t1 = 315 t = t1/tc v = Symbol('v') # Va...
54,853,332
I tried using pip install sendgrid, but got this error: > > Collecting sendgrid > Using cached <https://files.pythonhosted.org/packages/24/21/9bea4c51f949497cdce11f46fd58f1a77c6fcccd926cc1bb4e14be39a5c0/sendgrid-5.6.0-py2.py3-none-any.whl> > Requirement already satisfied: python-http-client>=3.0 in /home/avin/.loca...
2019/02/24
[ "https://Stackoverflow.com/questions/54853332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3512538/" ]
This is a very useful command `pip install --ignore-installed <package>` It will make your life easy :)
Solved. It required another package that I missed: `pip install python-HTTP-Client`. After that I no longer needed the `--user` and the imports worked fine
18,564,642
So I have been trying to install SimpleCV for some time now. I was finally able to install pygame, but now I have ran into a new error. I have used pip, easy\_install, and cloned the SimpleCV github repository to try to install SimpleCV, but I get this error from all: ``` ImportError: No module named scipy....
2013/09/02
[ "https://Stackoverflow.com/questions/18564642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2364997/" ]
From my understanding, what you trying to do is showing a custom dialog or alertview and only on its return value, the code should execute further. So lets say, If you display a `UIAlertView` with `UITextView` inside for adding more information, you should move your `sendEmail` method to the callback of alertview's bu...
The flow needs to be designed so that when the email is prompted it has set everything up and created a window with a button, at that point your code has finished and is not doing anything. Then when the button is pressed the next function/method is called that uses the data that was prepared before hand.
18,564,642
So I have been trying to install SimpleCV for some time now. I was finally able to install pygame, but now I have ran into a new error. I have used pip, easy\_install, and cloned the SimpleCV github repository to try to install SimpleCV, but I get this error from all: ``` ImportError: No module named scipy....
2013/09/02
[ "https://Stackoverflow.com/questions/18564642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2364997/" ]
From my understanding, what you trying to do is showing a custom dialog or alertview and only on its return value, the code should execute further. So lets say, If you display a `UIAlertView` with `UITextView` inside for adding more information, you should move your `sendEmail` method to the callback of alertview's bu...
I use MB Progress HUD <https://github.com/jdg/MBProgressHUD> i guess it is what you are looking for. It will show a loader which puts like overlay over the view in which it is added to. You can use it like this : In your Interface add ``` MBProgressHUD *HUD; ``` Then call this when even you need ``` -(void) ...
7,561,640
Executive summary: a Python module is linked against a different version of `libstdc++.dylib` than the Python executable. The result is that calls to `iostream` from the module crash. Backstory --------- I'm creating a Python module using SWIG on an older computer (running 10.5.8). For various reasons, I am using GCC...
2011/09/26
[ "https://Stackoverflow.com/questions/7561640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/118160/" ]
Solved it. I discovered that this problem is not too uncommon when mixing GCC versions on the mac. After reading [this solution for mpich](http://www.mail-archive.com/libmesh-users@lists.sourceforge.net/msg02756.html) and checking the [mpich source code](http://anonscm.debian.org/gitweb/?p=debian-science/packages/mpich...
Run Python in GDB, set a breakpoint on `malloc_error_break`. That will show you what's being freed that's not allocated. I doubt that this is an error between ABIs between the versions of libstdc++.
70,190,565
Kinda long code by complete beginner ahead, please help out I have a database with the following values: | Sl.No | trips | sales | price | | --- | --- | --- | --- | | 1 | 5 | 20 | 220 | | 2 | 8 | 30 | 330 | | 3 | 9 | 45 | 440 | | 4 | 3 | 38 | 880 | I am trying to use mysql-connector and python to get the sum of the ...
2021/12/01
[ "https://Stackoverflow.com/questions/70190565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17184842/" ]
It’s *possible*, but this doesn't look like great design. What happens when a new stage is added? I suspect your issues will disappear if you make a separate "Stage" table with two columns: Stage\_Number and Stage\_Value. Then finding the last filled in stage is a simple MAX query (and the rejection comes from adding o...
You can convert the columns to a JSON structure, then unnest the keys, sort them and pick the first one: ``` select t.*, (select x.col from jsonb_each_text(jsonb_strip_nulls(to_jsonb(t) - 'id' - 'status')) as x(col, val) order by x.col desc limit 1) as final_stage from the_table t ``` ...
24,175,446
I'd like to assign each pixel of a mat `matA` to some value according to values of `matB`, my code is a nested for-loop: ``` clock_t begint=clock(); for(size_t i=0; i<depthImg.rows; i++){ for(size_t j=0; j<depthImg.cols; j++){ datatype px=depthImg.at<datatype>(i, j); if(px==0) depthImg....
2014/06/12
[ "https://Stackoverflow.com/questions/24175446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1150712/" ]
I am unable to replicate your timing results on my machine Your C++ code runs in under 1ms on my machine. However, whenever you have slow iteration, `at<>()` should be immediately suspect. OpenCV has a [tutorial on iterating through images](http://docs.opencv.org/doc/tutorials/core/how_to_scan_images/how_to_scan_images...
In your C++ code, at every pixel you are making a function call, and passing in two indices which are getting converted into a flat index doing something like `i*depthImageCols + j`. My C++ skills are mostly lacking, but using [this](http://docs.opencv.org/modules/core/doc/basic_structures.html#mat-begin) as a templat...
19,872,942
Alright, so I've been wrestling with this problem for a good two hours now. I want to use a settings module, local.py, when I run my server locally via this command: ``` $ python manage.py runserver --settings=mysite.settings.local ``` However, I see this error when I try to do this: ``` ImportError: Could no...
2013/11/09
[ "https://Stackoverflow.com/questions/19872942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2744684/" ]
The underlying value is the same anyway. How you display it is a matter of **formatting**. Formatting in SQL is usually unnecessary. Formatting should be done on the client that receives the data from the database system. Don't change anything in SQL. Simply format your grid to display the required number of digits.
Convert number in code side. ex. : ``` string.Format("{0:0.##}", 256.583); // "256.58" string.Format("{0:0.##}", 256.586); // "256.59" string.Format("{0:0.##}", 256.58); // "256.58" string.Format("{0:0.##}", 256.5); // "256.5" string.Format("{0:0.##}", 256.0); // "256" //=============================== string.F...
19,872,942
Alright, so I've been wrestling with this problem for a good two hours now. I want to use a settings module, local.py, when I run my server locally via this command: ``` $ python manage.py runserver --settings=mysite.settings.local ``` However, I see this error when I try to do this: ``` ImportError: Could no...
2013/11/09
[ "https://Stackoverflow.com/questions/19872942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2744684/" ]
You can [convert](http://msdn.microsoft.com/en-us/library/ms187928.aspx) to decimal type with 2 decimal points. ``` Select Vt.Id, Vt.Description, convert(decimal(20,2),abs(Vt.Rate)) as VRate,convert(decimal(20,2),Sum(((itemprice*Qty)*(abs(Vt.Rate)/100)))) as VatAmount ,convert(decimal(20,2),Sum(itemprice*Qty),)as NetA...
You can use Round function to get only required number of digits after decimal point. ``` double myValue = 23.8000000000000; double newValue=Math.Round(myValue, 2); ``` Result : newValue = 23.8
19,872,942
Alright, so I've been wrestling with this problem for a good two hours now. I want to use a settings module, local.py, when I run my server locally via this command: ``` $ python manage.py runserver --settings=mysite.settings.local ``` However, I see this error when I try to do this: ``` ImportError: Could no...
2013/11/09
[ "https://Stackoverflow.com/questions/19872942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2744684/" ]
The underlying value is the same anyway. How you display it is a matter of **formatting**. Formatting in SQL is usually unnecessary. Formatting should be done on the client that receives the data from the database system. Don't change anything in SQL. Simply format your grid to display the required number of digits.
You can use Round function to get only required number of digits after decimal point. ``` double myValue = 23.8000000000000; double newValue=Math.Round(myValue, 2); ``` Result : newValue = 23.8
19,872,942
Alright, so I've been wrestling with this problem for a good two hours now. I want to use a settings module, local.py, when I run my server locally via this command: ``` $ python manage.py runserver --settings=mysite.settings.local ``` However, I see this error when I try to do this: ``` ImportError: Could no...
2013/11/09
[ "https://Stackoverflow.com/questions/19872942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2744684/" ]
Convert number in code side. ex. : ``` string.Format("{0:0.##}", 256.583); // "256.58" string.Format("{0:0.##}", 256.586); // "256.59" string.Format("{0:0.##}", 256.58); // "256.58" string.Format("{0:0.##}", 256.5); // "256.5" string.Format("{0:0.##}", 256.0); // "256" //=============================== string.F...
You can use Round function to get only required number of digits after decimal point. ``` double myValue = 23.8000000000000; double newValue=Math.Round(myValue, 2); ``` Result : newValue = 23.8
19,872,942
Alright, so I've been wrestling with this problem for a good two hours now. I want to use a settings module, local.py, when I run my server locally via this command: ``` $ python manage.py runserver --settings=mysite.settings.local ``` However, I see this error when I try to do this: ``` ImportError: Could no...
2013/11/09
[ "https://Stackoverflow.com/questions/19872942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2744684/" ]
You can [convert](http://msdn.microsoft.com/en-us/library/ms187928.aspx) to decimal type with 2 decimal points. ``` Select Vt.Id, Vt.Description, convert(decimal(20,2),abs(Vt.Rate)) as VRate,convert(decimal(20,2),Sum(((itemprice*Qty)*(abs(Vt.Rate)/100)))) as VatAmount ,convert(decimal(20,2),Sum(itemprice*Qty),)as NetA...
Convert number in code side. ex. : ``` string.Format("{0:0.##}", 256.583); // "256.58" string.Format("{0:0.##}", 256.586); // "256.59" string.Format("{0:0.##}", 256.58); // "256.58" string.Format("{0:0.##}", 256.5); // "256.5" string.Format("{0:0.##}", 256.0); // "256" //=============================== string.F...
19,872,942
Alright, so I've been wrestling with this problem for a good two hours now. I want to use a settings module, local.py, when I run my server locally via this command: ``` $ python manage.py runserver --settings=mysite.settings.local ``` However, I see this error when I try to do this: ``` ImportError: Could no...
2013/11/09
[ "https://Stackoverflow.com/questions/19872942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2744684/" ]
The underlying value is the same anyway. How you display it is a matter of **formatting**. Formatting in SQL is usually unnecessary. Formatting should be done on the client that receives the data from the database system. Don't change anything in SQL. Simply format your grid to display the required number of digits.
You can format the data displayed using the following code. This code causes truncation not rounding. ``` dataGridView1.DataSource=sometable; //bind to datasource DataGridViewCellStyle style = new DataGridViewCellStyle(); style.Format = "N2"; this.dataGridView1.Columns["Price"].DefaultCellStyle = style; ```
19,872,942
Alright, so I've been wrestling with this problem for a good two hours now. I want to use a settings module, local.py, when I run my server locally via this command: ``` $ python manage.py runserver --settings=mysite.settings.local ``` However, I see this error when I try to do this: ``` ImportError: Could no...
2013/11/09
[ "https://Stackoverflow.com/questions/19872942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2744684/" ]
You can [convert](http://msdn.microsoft.com/en-us/library/ms187928.aspx) to decimal type with 2 decimal points. ``` Select Vt.Id, Vt.Description, convert(decimal(20,2),abs(Vt.Rate)) as VRate,convert(decimal(20,2),Sum(((itemprice*Qty)*(abs(Vt.Rate)/100)))) as VatAmount ,convert(decimal(20,2),Sum(itemprice*Qty),)as NetA...
enclose your VatAmount with `round(,2)`: `round(Sum(((itemprice*Qty)*(abs(Vt.Rate)/100))),2)`
19,872,942
Alright, so I've been wrestling with this problem for a good two hours now. I want to use a settings module, local.py, when I run my server locally via this command: ``` $ python manage.py runserver --settings=mysite.settings.local ``` However, I see this error when I try to do this: ``` ImportError: Could no...
2013/11/09
[ "https://Stackoverflow.com/questions/19872942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2744684/" ]
You can format the data displayed using the following code. This code causes truncation not rounding. ``` dataGridView1.DataSource=sometable; //bind to datasource DataGridViewCellStyle style = new DataGridViewCellStyle(); style.Format = "N2"; this.dataGridView1.Columns["Price"].DefaultCellStyle = style; ```
Convert number in code side. ex. : ``` string.Format("{0:0.##}", 256.583); // "256.58" string.Format("{0:0.##}", 256.586); // "256.59" string.Format("{0:0.##}", 256.58); // "256.58" string.Format("{0:0.##}", 256.5); // "256.5" string.Format("{0:0.##}", 256.0); // "256" //=============================== string.F...
19,872,942
Alright, so I've been wrestling with this problem for a good two hours now. I want to use a settings module, local.py, when I run my server locally via this command: ``` $ python manage.py runserver --settings=mysite.settings.local ``` However, I see this error when I try to do this: ``` ImportError: Could no...
2013/11/09
[ "https://Stackoverflow.com/questions/19872942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2744684/" ]
enclose your VatAmount with `round(,2)`: `round(Sum(((itemprice*Qty)*(abs(Vt.Rate)/100))),2)`
You can use Round function to get only required number of digits after decimal point. ``` double myValue = 23.8000000000000; double newValue=Math.Round(myValue, 2); ``` Result : newValue = 23.8
19,872,942
Alright, so I've been wrestling with this problem for a good two hours now. I want to use a settings module, local.py, when I run my server locally via this command: ``` $ python manage.py runserver --settings=mysite.settings.local ``` However, I see this error when I try to do this: ``` ImportError: Could no...
2013/11/09
[ "https://Stackoverflow.com/questions/19872942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2744684/" ]
The underlying value is the same anyway. How you display it is a matter of **formatting**. Formatting in SQL is usually unnecessary. Formatting should be done on the client that receives the data from the database system. Don't change anything in SQL. Simply format your grid to display the required number of digits.
enclose your VatAmount with `round(,2)`: `round(Sum(((itemprice*Qty)*(abs(Vt.Rate)/100))),2)`
65,356,299
I am running VS Code (Version 1.52) with extensions Jupyter Notebook (2020.12) and Python (2020.12) on MacOS Catalina. **Context:** I have problems getting Intellisense to work properly in my Jupyter Notebooks in VS Code. Some have had some success with adding these config parameters to the global settings of VS Code...
2020/12/18
[ "https://Stackoverflow.com/questions/65356299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5197386/" ]
Since Nov 2020 the Jupyter extension is seperated from Python extension for VS Code. The setting key has been renamed from `python.dataScience` to `jupyter`[^update](https://devblogs.microsoft.com/python/introducing-the-jupyter-extension-for-vs-code/) So in your case please rename `python.dataScience.runStartupCommand...
According to your description, you could refer to the following: 1. Whether in the "`.py`" file or the "`.ipynb`" file, we can use the shortcut key `"Ctrl+space`" to open the code suggested options: [![enter image description here](https://i.stack.imgur.com/K3MlT.png)](https://i.stack.imgur.com/K3MlT.png) 2. It is re...
49,145,059
In a dynamic system my base values are all functions of time, `d(t)`. I create the variable `d` using `d = Function('d')(t)` where `t = S('t')` Obviously it's very common to have derivatives of d (rates of change like velocity etc.). However the default printing of `diff(d(t))` gives:- ``` Derivative(d(t), t) ``` a...
2018/03/07
[ "https://Stackoverflow.com/questions/49145059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4443898/" ]
I do this by substitution. It is horribly stupid, but it works like a charm: ``` q = Function('q')(t) q_d = Function('\\dot{q}')(t) ``` and then substitute with ``` alias = {q.diff(t):q_d, } # and higher derivatives etc.. hd = q.diff(t).subs(alias) ``` And the output hd has a pretty dot over it's head! As I said...
The [vector printing](http://docs.sympy.org/latest/modules/physics/vector/api/printing.html) module that you already found is the only place where such printing is implemented in SymPy. ``` from sympy.physics.vector import dynamicsymbols from sympy.physics.vector.printing import vpprint, vlatex d = dynamicsymbols('d'...
38,645,486
I'm sure that this is a pretty simple problem and that I am just missing something incredibly obvious, but the answer to this predicament has eluded me for several hours now. My project directory structure looks like this: ``` -PhysicsMaterial -Macros __init__.py Macros.py -Modules __init__.py...
2016/07/28
[ "https://Stackoverflow.com/questions/38645486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6649949/" ]
This occurs because you're running the script as `__main__`. When you run a script like this: ``` python /path/to/package/module.py ``` That file is loaded as `__main__`, not as `package.module`, so it can't do relative imports because it isn't part of a package. This can lead to strange errors where a class defin...
[How to fix "Attempted relative import in non-package" even with \_\_init\_\_.py](https://stackoverflow.com/questions/11536764/attempted-relative-import-in-non-package-even-with-init-py) Well, guess it's on to using sys.path.append now. Clap and a half to @BrenBarn, @fireant, and @Ignacio Vazquez-Abrams
70,922,321
I've been coding with R for quite a while but I want to start learning and using python more for its machine learning applications. However, I'm quite confused as to how to properly install packages and set up the whole working environment. Unlike R where I suppose most people just use RStudio and directly install pack...
2022/01/31
[ "https://Stackoverflow.com/questions/70922321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14540717/" ]
I had to import the metada of the `Table` I manually defined
I came to this page because autogenerating migrations no longer worked with the upgrade to SQLAlchemy 1.4, as the metadata were no longer recognized and the automatically generated migration deleted every table (DROP table in upgrade, CREATE TABLE in downgrade). I have first tried to import the tables metadata like th...
72,640,228
I'm trying to replace a single character '°' with '?' in an [edf](https://www.edfplus.info/specs/edf.html) file with binary encoding.([File](https://github.com/warren-manuel/sleep-edf/tree/main/Files)) I need to change all occurances of it in the first line. I cannot open it without specifying read binary. (The follow...
2022/06/16
[ "https://Stackoverflow.com/questions/72640228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4126542/" ]
You need to have **Advanced Access** to **business\_management** permission. You can submit app review for advanced access, if it approved, you can call /bm-id/adaccount to create ad account with required parameter.
Also, you can't create an ad account on a real FB user. It works with test users well, but you need special permissions from FB to do this on a real user's account.
7,558,814
> > **Possible Duplicate:** > > [Python replace multiple strings](https://stackoverflow.com/questions/6116978/python-replace-multiple-strings) > > > I am looking to replace `“ “`, `“\r”`, `“\n”`, `“<”`, `“>”`, `“’”` (single quote), and `‘”’` (double quote) with `“”` (empty). I’m also looking to replace `“;”` a...
2011/09/26
[ "https://Stackoverflow.com/questions/7558814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/454488/" ]
If you want to remove all occurrences of those characters, just put them all in a character class and do [`re.sub()`](http://docs.python.org/library/re.html#re.sub) ``` your_str = re.sub(r'[ \r\n\'"]+', '', your_str) your_str = re.sub(r'[;|]', ',', your_str) ``` You have to call `re.sub()` for every replacement rule...
``` import re reg = re.compile('([ \r\n\'"]+)|([;|]+)') ss = 'bo ba\rbu\nbe\'bi"by-ja;ju|jo' def repl(mat, di = {1:'',2:','}): return di[mat.lastindex] print reg.sub(repl,ss) ``` Note: '|' loses its speciality between brackets
7,558,814
> > **Possible Duplicate:** > > [Python replace multiple strings](https://stackoverflow.com/questions/6116978/python-replace-multiple-strings) > > > I am looking to replace `“ “`, `“\r”`, `“\n”`, `“<”`, `“>”`, `“’”` (single quote), and `‘”’` (double quote) with `“”` (empty). I’m also looking to replace `“;”` a...
2011/09/26
[ "https://Stackoverflow.com/questions/7558814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/454488/" ]
If you need to replace only single characters then you could use [`str.translate()`](http://docs.python.org/library/stdtypes.html#str.translate): ``` import string table = string.maketrans(';|', ',,') deletechars = ' \r\n<>\'"' print "ex'a;m|ple\n".translate(table, deletechars) # -> exa,m,ple ```
If you want to remove all occurrences of those characters, just put them all in a character class and do [`re.sub()`](http://docs.python.org/library/re.html#re.sub) ``` your_str = re.sub(r'[ \r\n\'"]+', '', your_str) your_str = re.sub(r'[;|]', ',', your_str) ``` You have to call `re.sub()` for every replacement rule...
7,558,814
> > **Possible Duplicate:** > > [Python replace multiple strings](https://stackoverflow.com/questions/6116978/python-replace-multiple-strings) > > > I am looking to replace `“ “`, `“\r”`, `“\n”`, `“<”`, `“>”`, `“’”` (single quote), and `‘”’` (double quote) with `“”` (empty). I’m also looking to replace `“;”` a...
2011/09/26
[ "https://Stackoverflow.com/questions/7558814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/454488/" ]
If you need to replace only single characters then you could use [`str.translate()`](http://docs.python.org/library/stdtypes.html#str.translate): ``` import string table = string.maketrans(';|', ',,') deletechars = ' \r\n<>\'"' print "ex'a;m|ple\n".translate(table, deletechars) # -> exa,m,ple ```
``` import re reg = re.compile('([ \r\n\'"]+)|([;|]+)') ss = 'bo ba\rbu\nbe\'bi"by-ja;ju|jo' def repl(mat, di = {1:'',2:','}): return di[mat.lastindex] print reg.sub(repl,ss) ``` Note: '|' loses its speciality between brackets
53,632,979
i recently start learning about python, and made simple source of 2 balls in canvas which are moving with 2d vector rule. i want multiply the number of balls with list in python. here is source of that. ``` import time import random from tkinter import * import numpy as np import math window = Tk() canvas = Canvas(win...
2018/12/05
[ "https://Stackoverflow.com/questions/53632979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10749521/" ]
1) You should be. I highly recommend avoiding secondary indexes and ALLOW FILTERING consider them advanced features for corner cases. 2) It can be more efficient with index, but still horrible, and also horrible in more new ways. There are only very few scenarios where secondary indexes are acceptable. There are very ...
As worst case for your use case, consider searching for an Austrian composer born in 1756. Yes, you can find him (Mozart) in a table of all humans who ever lived by intersecting the index of nationality=Austria, the index of birth=1756 and the index of profession=composer. But Cassandra will implement such a query very...
69,301,316
Im currently trying to get the mean() of a group in my dataframe (tdf), but I have a mix of some NaN values and filled values in my dataset. Example shown below | Test # | a | b | | --- | --- | --- | | 1 | 1 | 1 | | 1 | 2 | NaN | | 1 | 3 | 2 | | 2 | 4 | 3 | My code needs to take this dataset, and make a new dataset c...
2021/09/23
[ "https://Stackoverflow.com/questions/69301316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16985105/" ]
You can use ```py (?<![a-zA-Z0-9_.-])@(?=([A-Za-z]+[A-Za-z0-9_-]*))\1(?![@\w]) (?a)(?<![\w.-])@(?=([A-Za-z][\w-]*))\1(?![@\w]) ``` See the [regex demo](https://regex101.com/r/KFHwo8/3). *Details*: * `(?<![a-zA-Z0-9_.-])` - a negative lookbehind that matches a location that is not immediately preceded with ASCII dig...
Another option is to assert a whitespace boundary to the left, and assert no word char or @ sign to the right. ``` (?<!\S)@([A-Za-z]+[\w-]+)(?![@\w]) ``` The pattern matches: * `(?<!\S)` Negative lookbehind, assert not a non whitespace char to the left * `@` Match literally * `([A-Za-z]+[\w-]+)` Capture group1, mat...
29,240,807
What is the complexity of the function `most_common` provided by the `collections.Counter` object in Python? More specifically, is `Counter` keeping some kind of sorted list while it's counting, allowing it to perform the `most_common` operation faster than `O(n)` when `n` is the number of (unique) items added to the ...
2015/03/24
[ "https://Stackoverflow.com/questions/29240807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3397458/" ]
From the source code of [collections.py](https://github.com/python/cpython/blob/a8e814db96ebfeb1f58bc471edffde2176c0ae05/Lib/collections/__init__.py#L571), we see that if we don't specify a number of returned elements, `most_common` returns a sorted list of the counts. This is an `O(n log n)` algorithm. If we use `mos...
[The source](https://github.com/python/cpython/blob/1b85f4ec45a5d63188ee3866bd55eb29fdec7fbf/Lib/collections/__init__.py#L575) shows exactly what happens: ``` def most_common(self, n=None): '''List the n most common elements and their counts from the most common to the least. If n is None, then list all eleme...
54,565,417
When I'm visiting my website (<https://osm-messaging-platform.appspot.com>), I get this error on the main webpage: ``` 502 Bad Gateway. nginx/1.14.0 (Ubuntu). ``` It's really weird, since when I run it locally ``` python app.py ``` I get no errors, and my app and the website load fine. I've already tried lookin...
2019/02/07
[ "https://Stackoverflow.com/questions/54565417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10808093/" ]
The error is produced because the App Engine Standard Python37 runtime handles the requests in the `main.py` file by default. I guess that you don't have this file and you are handling the requests in the `app.py` file. Also the logs traceback is pointing to it: `ModuleNotFoundError: No module named 'main'` Change t...
My mistake was naming the main app "main" which conflicted with main.py. It worked fine locally as it did not use main.py. I changed it to root and everything worked fine. It took me a whole day to solve it out.
54,565,417
When I'm visiting my website (<https://osm-messaging-platform.appspot.com>), I get this error on the main webpage: ``` 502 Bad Gateway. nginx/1.14.0 (Ubuntu). ``` It's really weird, since when I run it locally ``` python app.py ``` I get no errors, and my app and the website load fine. I've already tried lookin...
2019/02/07
[ "https://Stackoverflow.com/questions/54565417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10808093/" ]
The error is produced because the App Engine Standard Python37 runtime handles the requests in the `main.py` file by default. I guess that you don't have this file and you are handling the requests in the `app.py` file. Also the logs traceback is pointing to it: `ModuleNotFoundError: No module named 'main'` Change t...
I resolved the issue in `main.py` by changing the host from: ``` app.run(host="127.0.0.1", port=8080, debug=True) ``` to ``` app.run(host="0.0.0.0", port=8080, debug=True) ```
54,565,417
When I'm visiting my website (<https://osm-messaging-platform.appspot.com>), I get this error on the main webpage: ``` 502 Bad Gateway. nginx/1.14.0 (Ubuntu). ``` It's really weird, since when I run it locally ``` python app.py ``` I get no errors, and my app and the website load fine. I've already tried lookin...
2019/02/07
[ "https://Stackoverflow.com/questions/54565417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10808093/" ]
My mistake was naming the main app "main" which conflicted with main.py. It worked fine locally as it did not use main.py. I changed it to root and everything worked fine. It took me a whole day to solve it out.
I resolved the issue in `main.py` by changing the host from: ``` app.run(host="127.0.0.1", port=8080, debug=True) ``` to ``` app.run(host="0.0.0.0", port=8080, debug=True) ```
70,147,775
I am just learning python and was trying to loop through a list and use pop() to remove all items from original list and add them to a new list formatted. Here is the code I use: ``` languages = ['russian', 'english', 'spanish', 'french', 'korean'] formatted_languages = [] for a in languages: formatted_languages....
2021/11/28
[ "https://Stackoverflow.com/questions/70147775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17534746/" ]
Look: ``` languages = ['russian', 'english', 'spanish', 'french', 'korean'] formatted_languages = [] for a in languages: print(a) print(languages) formatted_languages.append(languages.pop().title()) print(formatted_languages) ``` Notice what "a" is: ``` russian ['russian', 'english', 'spanish', 'f...
What you're doing here is changing the size of the list whilst the list is being processed, so that once you've got to spanish in the list (3rd item), you've removed french and korean already, so once you've removed spanish, there are no items left to loop through. You can use the code below to get around this. ```py ...
70,147,775
I am just learning python and was trying to loop through a list and use pop() to remove all items from original list and add them to a new list formatted. Here is the code I use: ``` languages = ['russian', 'english', 'spanish', 'french', 'korean'] formatted_languages = [] for a in languages: formatted_languages....
2021/11/28
[ "https://Stackoverflow.com/questions/70147775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17534746/" ]
Look: ``` languages = ['russian', 'english', 'spanish', 'french', 'korean'] formatted_languages = [] for a in languages: print(a) print(languages) formatted_languages.append(languages.pop().title()) print(formatted_languages) ``` Notice what "a" is: ``` russian ['russian', 'english', 'spanish', 'f...
The reason you don't get the full values is because you are making the list shorter on each iteration. Consider what is happening in your loop: ``` for a in languages: formatted_languages.append(languages.pop().title()) ``` By the time `a` is equal to the 3rd element in your list, you already removed 3 elements...
17,509,607
I have seen questions like this asked many many times but none are helpful Im trying to submit data to a form on the web ive tried requests, and urllib and none have worked for example here is code that should search for the [python] tag on SO: ``` import urllib import urllib2 url = 'http://stackoverflow.com/' # P...
2013/07/07
[ "https://Stackoverflow.com/questions/17509607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2292723/" ]
If you want to pass `q` as a parameter in the URL using [`requests`](http://docs.python-requests.org/), use the `params` argument, not `data` (see [Passing Parameters In URLs](http://docs.python-requests.org/en/latest/user/quickstart.html#passing-parameters-in-urls)): ``` r = requests.get('http://stackoverflow.com', p...
``` import urllib import urllib2 url = 'http://www.someserver.com/cgi-bin/register.cgi' values = {'name' : 'Michael Foord', 'location' : 'Northampton', 'language' : 'Python' } data = urllib.urlencode(values) req = urllib2.Request(url, data) response = urllib2.urlopen(req) the_page = response.read() ``` ...
17,509,607
I have seen questions like this asked many many times but none are helpful Im trying to submit data to a form on the web ive tried requests, and urllib and none have worked for example here is code that should search for the [python] tag on SO: ``` import urllib import urllib2 url = 'http://stackoverflow.com/' # P...
2013/07/07
[ "https://Stackoverflow.com/questions/17509607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2292723/" ]
If you want to pass `q` as a parameter in the URL using [`requests`](http://docs.python-requests.org/), use the `params` argument, not `data` (see [Passing Parameters In URLs](http://docs.python-requests.org/en/latest/user/quickstart.html#passing-parameters-in-urls)): ``` r = requests.get('http://stackoverflow.com', p...
Mechanize library from python is also great allowing you to even submit forms. You can use the following code to create a browser object and create requests. ``` import mechanize,re br = mechanize.Browser() br.set_handle_robots(False) # ignore robots br.set_handle_refresh(False) # can sometimes hang without this br...
17,509,607
I have seen questions like this asked many many times but none are helpful Im trying to submit data to a form on the web ive tried requests, and urllib and none have worked for example here is code that should search for the [python] tag on SO: ``` import urllib import urllib2 url = 'http://stackoverflow.com/' # P...
2013/07/07
[ "https://Stackoverflow.com/questions/17509607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2292723/" ]
``` import urllib import urllib2 url = 'http://www.someserver.com/cgi-bin/register.cgi' values = {'name' : 'Michael Foord', 'location' : 'Northampton', 'language' : 'Python' } data = urllib.urlencode(values) req = urllib2.Request(url, data) response = urllib2.urlopen(req) the_page = response.read() ``` ...
Mechanize library from python is also great allowing you to even submit forms. You can use the following code to create a browser object and create requests. ``` import mechanize,re br = mechanize.Browser() br.set_handle_robots(False) # ignore robots br.set_handle_refresh(False) # can sometimes hang without this br...
17,847,869
I have this following Python Tkinter code which redraw the label every 10 second. My question is , to me it seems like it is drawing the new label over and over again over the old label. So, eventually, after a few hours there will be hundreds of drawing overlapping (at least from what i understand). Will this use more...
2013/07/25
[ "https://Stackoverflow.com/questions/17847869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2180836/" ]
The correct way to run a function or update a label in tkinter is to use the [after](http://effbot.org/tkinterbook/widget.htm#Tkinter.Widget.after-method) method. This puts an event on the event queue to be executed at some time in the future. If you have a function that does some work, then puts itself back on the eve...
To allow the cleanup with minimal code changes, you could pass previous frames explicitly: ``` import Tkinter as tk def Draw(oldframe=None): frame = tk.Frame(root,width=100,height=100,relief='solid',bd=1) frame.place(x=10,y=10) tk.Label(frame, text='HELLO').pack() frame.pack() if oldframe is not N...
8,008,829
I am working on a project in python in which I need to extract only a subfolder of tar archive not all the files. I tried to use ``` tar = tarfile.open(tarfile) tar.extract("dirname", targetdir) ``` But this does not work, it does not extract the given subdirectory also no exception is thrown. I am a beginner in py...
2011/11/04
[ "https://Stackoverflow.com/questions/8008829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/517272/" ]
Building on the second example from the [tarfile module documentation](https://docs.python.org/3.5/library/tarfile.html#examples), you could extract the contained sub-folder and all of its contents with something like this: ``` with tarfile.open("sample.tar") as tar: subdir_and_files = [ tarinfo for tarinf...
The other answer will retain the subfolder path, meaning that `subfolder/a/b` will be extracted to `./subfolder/a/b`. To extract a subfolder to the root, so `subfolder/a/b` would be extracted to `./a/b`, you can rewrite the paths with something like this: ``` def members(tf): l = len("subfolder/") for member i...
31,767,292
I may be way off here - but would appreciate insight on just how far .. In the following `getFiles` method, we have an anonymous function being passed as an argument. ``` def getFiles(baseDir: String, filter: (File, String) => Boolean ) = { val ffilter = new FilenameFilter { // How to assign to the anonymous fun...
2015/08/01
[ "https://Stackoverflow.com/questions/31767292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1056563/" ]
There is no way easy or type-safe way (that I know of) to assign a function to a method as they are different types. In Python or JavaScript you could do something like this: ``` var fnf = new FilenameFilter(); fnf.accepts = filter; ``` But in Scala you have to do the delegation: ``` val fnf = new FilenameFilter { ...
I think you are actually misunderstanding the meaning of the override keyword. It is for redefining methods defined in the superclass of a class, not redefining a method in an instance of a class. If you want to redefine the accept method in the instances of FilenameFilter, you will need to add the filter method to th...
35,201,647
How to use hook in bottle? <https://pypi.python.org/pypi/bottle-session/0.4> I am trying to implement session plug in with bottle hook. ``` @bottle.route('/loginpage') def loginpage(): return ''' <form action="/login" method="post"> Username: <input name="username" type="text" /> Passwo...
2016/02/04
[ "https://Stackoverflow.com/questions/35201647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3282945/" ]
Try this ................. Your **initializers/carrierwave.rb** look like this. ``` CarrierWave.configure do |config| config.fog_credentials = { :provider => 'AWS', # required :aws_access_key_id => 'xxx', # required :aws_secret_access_key ...
`CarrierWave::Uploader::Base:Class#fog_provider=` is not released yet. It is only available on the CarrierWave `master` branch. **Solution 1 (Use master):** Change your `Gemfile` entry to ``` gem "carrierwave", git: "git@github.com:carrierwaveuploader/carrierwave.git" ``` But this is not recommended since it is ...
10,043,636
A common antipattern in Python is to concatenate a sequence of strings using `+` in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of CPython can apparently optimize this in some cases, but other implementat...
2012/04/06
[ "https://Stackoverflow.com/questions/10043636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1064659/" ]
There is nothing wrong in concatenating *two* strings with `+`. Indeed it's easier to read than `''.join([a, b])`. You are right though that concatenating more than 2 strings with `+` is an O(n^2) operation (compared to O(n) for `join`) and thus becomes inefficient. However this has not to do with using a loop. Even `...
The assumption that one should never, ever use + for string concatenation, but instead always use ''.join may be a myth. It is true that using `+` creates unnecessary temporary copies of immutable string object but the other not oft quoted fact is that calling `join` in a loop would generally add the overhead of `funct...
10,043,636
A common antipattern in Python is to concatenate a sequence of strings using `+` in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of CPython can apparently optimize this in some cases, but other implementat...
2012/04/06
[ "https://Stackoverflow.com/questions/10043636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1064659/" ]
When working with multiple people, it's sometimes difficult to know exactly what's happening. Using a format string instead of concatenation can avoid one particular annoyance that's happened a whole ton of times to us: Say, a function requires an argument, and you write it expecting to get a string: ``` In [1]: def ...
**''.join([a, b])** is better solution than **+**. Because Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such) form a += b or a = a + b is fragile even in CPython and isn't present at all in implementations **that don't use** *...
10,043,636
A common antipattern in Python is to concatenate a sequence of strings using `+` in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of CPython can apparently optimize this in some cases, but other implementat...
2012/04/06
[ "https://Stackoverflow.com/questions/10043636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1064659/" ]
Plus operator is perfectly fine solution to concatenate **two** Python strings. But if you keep adding more than two strings (n > 25) , you might want to think something else. `''.join([a, b, c])` trick is a performance optimization.
The assumption that one should never, ever use + for string concatenation, but instead always use ''.join may be a myth. It is true that using `+` creates unnecessary temporary copies of immutable string object but the other not oft quoted fact is that calling `join` in a loop would generally add the overhead of `funct...
10,043,636
A common antipattern in Python is to concatenate a sequence of strings using `+` in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of CPython can apparently optimize this in some cases, but other implementat...
2012/04/06
[ "https://Stackoverflow.com/questions/10043636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1064659/" ]
There is nothing wrong in concatenating *two* strings with `+`. Indeed it's easier to read than `''.join([a, b])`. You are right though that concatenating more than 2 strings with `+` is an O(n^2) operation (compared to O(n) for `join`) and thus becomes inefficient. However this has not to do with using a loop. Even `...
I use the following with python 3.8 ```py string4 = f'{string1}{string2}{string3}' ```
10,043,636
A common antipattern in Python is to concatenate a sequence of strings using `+` in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of CPython can apparently optimize this in some cases, but other implementat...
2012/04/06
[ "https://Stackoverflow.com/questions/10043636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1064659/" ]
There is nothing wrong in concatenating *two* strings with `+`. Indeed it's easier to read than `''.join([a, b])`. You are right though that concatenating more than 2 strings with `+` is an O(n^2) operation (compared to O(n) for `join`) and thus becomes inefficient. However this has not to do with using a loop. Even `...
Plus operator is perfectly fine solution to concatenate **two** Python strings. But if you keep adding more than two strings (n > 25) , you might want to think something else. `''.join([a, b, c])` trick is a performance optimization.
10,043,636
A common antipattern in Python is to concatenate a sequence of strings using `+` in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of CPython can apparently optimize this in some cases, but other implementat...
2012/04/06
[ "https://Stackoverflow.com/questions/10043636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1064659/" ]
Plus operator is perfectly fine solution to concatenate **two** Python strings. But if you keep adding more than two strings (n > 25) , you might want to think something else. `''.join([a, b, c])` trick is a performance optimization.
According to Python docs, using str.join() will give you performance consistence across various implementations of Python. Although CPython optimizes away the quadratic behavior of s = s + t, other Python implementations may not. > > **CPython implementation detail**: If s and t are both strings, some > Python imple...
10,043,636
A common antipattern in Python is to concatenate a sequence of strings using `+` in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of CPython can apparently optimize this in some cases, but other implementat...
2012/04/06
[ "https://Stackoverflow.com/questions/10043636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1064659/" ]
The assumption that one should never, ever use + for string concatenation, but instead always use ''.join may be a myth. It is true that using `+` creates unnecessary temporary copies of immutable string object but the other not oft quoted fact is that calling `join` in a loop would generally add the overhead of `funct...
**''.join([a, b])** is better solution than **+**. Because Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such) form a += b or a = a + b is fragile even in CPython and isn't present at all in implementations **that don't use** *...
10,043,636
A common antipattern in Python is to concatenate a sequence of strings using `+` in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of CPython can apparently optimize this in some cases, but other implementat...
2012/04/06
[ "https://Stackoverflow.com/questions/10043636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1064659/" ]
There is nothing wrong in concatenating *two* strings with `+`. Indeed it's easier to read than `''.join([a, b])`. You are right though that concatenating more than 2 strings with `+` is an O(n^2) operation (compared to O(n) for `join`) and thus becomes inefficient. However this has not to do with using a loop. Even `...
When working with multiple people, it's sometimes difficult to know exactly what's happening. Using a format string instead of concatenation can avoid one particular annoyance that's happened a whole ton of times to us: Say, a function requires an argument, and you write it expecting to get a string: ``` In [1]: def ...
10,043,636
A common antipattern in Python is to concatenate a sequence of strings using `+` in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of CPython can apparently optimize this in some cases, but other implementat...
2012/04/06
[ "https://Stackoverflow.com/questions/10043636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1064659/" ]
There is nothing wrong in concatenating *two* strings with `+`. Indeed it's easier to read than `''.join([a, b])`. You are right though that concatenating more than 2 strings with `+` is an O(n^2) operation (compared to O(n) for `join`) and thus becomes inefficient. However this has not to do with using a loop. Even `...
**''.join([a, b])** is better solution than **+**. Because Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such) form a += b or a = a + b is fragile even in CPython and isn't present at all in implementations **that don't use** *...
10,043,636
A common antipattern in Python is to concatenate a sequence of strings using `+` in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of CPython can apparently optimize this in some cases, but other implementat...
2012/04/06
[ "https://Stackoverflow.com/questions/10043636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1064659/" ]
When working with multiple people, it's sometimes difficult to know exactly what's happening. Using a format string instead of concatenation can avoid one particular annoyance that's happened a whole ton of times to us: Say, a function requires an argument, and you write it expecting to get a string: ``` In [1]: def ...
According to Python docs, using str.join() will give you performance consistence across various implementations of Python. Although CPython optimizes away the quadratic behavior of s = s + t, other Python implementations may not. > > **CPython implementation detail**: If s and t are both strings, some > Python imple...
11,566,355
Why it executes the script every 2 minutes? Shouldn't it execute every 10 minutes ? ``` *\10 * * * * /usr/bin/python /var/www/py/LSFchecker.py ```
2012/07/19
[ "https://Stackoverflow.com/questions/11566355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1131053/" ]
``` *\10 * * * * ``` Should probably be ``` */10 * * * * ```
You can try: 00,10,20,30,40,50 \* \* \* \* /usr/bin/python /var/www/py/LSFchecker.py
39,003,106
Comrades, I'd like to capture images from the laptop camera in Python. Currently all signs point to OpenCV. Problem is OpenCV is a nightmare to install, and it's a nightmare that reoccurs every time you reinstall your code on a new system. Is there a more lightweight way to capture camera data in Python? I'm looking...
2016/08/17
[ "https://Stackoverflow.com/questions/39003106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/851699/" ]
I've done this before using [pygame](http://www.pygame.org/download.shtml). But I can't seem to find the script that I used... It seems there is a tutorial [here](http://www.pygame.org/docs/tut/camera/CameraIntro.html) which uses the native camera module and is not dependent on OpenCV. Try this: ``` import pygame imp...
Videocapture for Windows ======================== I've used [videocapture](http://videocapture.sourceforge.net/) in the past and it was perfect: ``` from VideoCapture import Device cam = Device() cam.saveSnapshot('image.jpg') ```
39,003,106
Comrades, I'd like to capture images from the laptop camera in Python. Currently all signs point to OpenCV. Problem is OpenCV is a nightmare to install, and it's a nightmare that reoccurs every time you reinstall your code on a new system. Is there a more lightweight way to capture camera data in Python? I'm looking...
2016/08/17
[ "https://Stackoverflow.com/questions/39003106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/851699/" ]
As [the documentation states](https://www.pygame.org/docs/ref/camera.html), currently `pygame.camera` only supports linux and v4l2 cameras, so this would not work on macOS. On Linux instead it works fine.
Videocapture for Windows ======================== I've used [videocapture](http://videocapture.sourceforge.net/) in the past and it was perfect: ``` from VideoCapture import Device cam = Device() cam.saveSnapshot('image.jpg') ```
39,003,106
Comrades, I'd like to capture images from the laptop camera in Python. Currently all signs point to OpenCV. Problem is OpenCV is a nightmare to install, and it's a nightmare that reoccurs every time you reinstall your code on a new system. Is there a more lightweight way to capture camera data in Python? I'm looking...
2016/08/17
[ "https://Stackoverflow.com/questions/39003106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/851699/" ]
You can use pyavfcam [github](https://github.com/dashesy/pyavfcam). You will need to install xcode and cython, first. This is the official demo. ``` import pyavfcam # Open the default video source cam = pyavfcam.AVFCam(sinks='image') cam.snap_picture('test.jpg') print "Saved test.jpg (Size: " + str(cam.shape[0]) + "...
Videocapture for Windows ======================== I've used [videocapture](http://videocapture.sourceforge.net/) in the past and it was perfect: ``` from VideoCapture import Device cam = Device() cam.saveSnapshot('image.jpg') ```
32,231,589
*Question:* I am trying to debug a function in a `class` to make sure a list is implemented and if not, I want an error to be thrown up. I am new to programming and am trying to figure how to effectively add an `assert` for the debugging purposes mentioned above. In the method body of `class BaseAPI()` I have to iter...
2015/08/26
[ "https://Stackoverflow.com/questions/32231589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5140076/" ]
I am going to go for my Self Learner badge, here, and answer my own question. I did about 8 hours of research on this and came up with a great solution. Three things had to be done. 1. Set the HTML5 video src to something other than the original URL. This will trigger the player to close the open socket connection. 2...
Added a line between pause() and remove(): ``` // Handling Bootstrap Modal Window Close Event // Trigger player destroy $("#xr-interaction-detail-modal").on("hidden.bs.modal", function () { var player = xr.ui.mediaelement.xrPlayer(); if (player) { player.pause(); ("video,audio").attr("src", ""...
44,472,252
I am very beginner Python. So my question could be quite naive. I just started to study this language principally due to mathematical tools such as Numpy and Matplotlib which seem to be very useful. In fact I don't see how python works in fields other than maths I wonder if it is possible (and if yes, how?) to use Pyt...
2017/06/10
[ "https://Stackoverflow.com/questions/44472252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8141006/" ]
If you want to concatenate them the good ol' fashioned way, and put them in a new file, you can do this: ``` a = open('A.txt') b = open('B.txt') c = open('C.txt', 'w') for a_line, b_line in zip(a, b): c.write(a_line.rstrip() + ' ' + b_line) a.close() b.close() c.close() ```
Try this,read files as numpy arrays ``` a = np.loadtxt('a.txt') b = np.genfromtxt('b.txt',dtype='str') ``` In case of b you need genfromtext because of string content.Than ``` np.concatenate((a, b), axis=1) ``` Finally, you will get ``` np.concatenate((a, b), axis=1) array([['0.22222', '0.11111', '0.0', 'F', 'F...
44,472,252
I am very beginner Python. So my question could be quite naive. I just started to study this language principally due to mathematical tools such as Numpy and Matplotlib which seem to be very useful. In fact I don't see how python works in fields other than maths I wonder if it is possible (and if yes, how?) to use Pyt...
2017/06/10
[ "https://Stackoverflow.com/questions/44472252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8141006/" ]
Of course Python can be used for text processing (possibly it is even better suited for that than for numerical jobs). The task in question, however, can be done with a single Unix command: `paste A.txt B.txt > output.txt` And here is a Python solution without using `numpy`: ``` with open('A.txt') as a: with op...
Try this,read files as numpy arrays ``` a = np.loadtxt('a.txt') b = np.genfromtxt('b.txt',dtype='str') ``` In case of b you need genfromtext because of string content.Than ``` np.concatenate((a, b), axis=1) ``` Finally, you will get ``` np.concatenate((a, b), axis=1) array([['0.22222', '0.11111', '0.0', 'F', 'F...
44,472,252
I am very beginner Python. So my question could be quite naive. I just started to study this language principally due to mathematical tools such as Numpy and Matplotlib which seem to be very useful. In fact I don't see how python works in fields other than maths I wonder if it is possible (and if yes, how?) to use Pyt...
2017/06/10
[ "https://Stackoverflow.com/questions/44472252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8141006/" ]
Of course Python can be used for text processing (possibly it is even better suited for that than for numerical jobs). The task in question, however, can be done with a single Unix command: `paste A.txt B.txt > output.txt` And here is a Python solution without using `numpy`: ``` with open('A.txt') as a: with op...
If you want to concatenate them the good ol' fashioned way, and put them in a new file, you can do this: ``` a = open('A.txt') b = open('B.txt') c = open('C.txt', 'w') for a_line, b_line in zip(a, b): c.write(a_line.rstrip() + ' ' + b_line) a.close() b.close() c.close() ```
3,999,829
I wouldn't call myself programmer, but I've started learning Python recently and really enjoy it. I mainly use it for small tasks so far - scripting, text processing, KML generation and ArcGIS. From my experience with R (working with excellent Notepad++ and [NppToR](http://sourceforge.net/projects/npptor/) combo) I u...
2010/10/22
[ "https://Stackoverflow.com/questions/3999829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319487/" ]
I use Notepad++ for most of my Windows based Python development and for debugging I use [Winpdb](http://winpdb.org/about/). It's a cross platform GUI based debugger. You can actually setup a keyboard shortcut in Notepad++ to launch the debugger on your current script: To do this go to "Run" -> "Run ..." in the menu an...
[Light Table](http://lighttable.com/) was doing that for me, unfortunately it is discontinued: > > INLINE EVALUTION No more printing to the console in order to view your > results. Simply evaluate your code and the results will be displayed > inline. > > > [![enter image description here](https://i.stack.imgur.co...
3,999,829
I wouldn't call myself programmer, but I've started learning Python recently and really enjoy it. I mainly use it for small tasks so far - scripting, text processing, KML generation and ArcGIS. From my experience with R (working with excellent Notepad++ and [NppToR](http://sourceforge.net/projects/npptor/) combo) I u...
2010/10/22
[ "https://Stackoverflow.com/questions/3999829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319487/" ]
I use Notepad++ for most of my Windows based Python development and for debugging I use [Winpdb](http://winpdb.org/about/). It's a cross platform GUI based debugger. You can actually setup a keyboard shortcut in Notepad++ to launch the debugger on your current script: To do this go to "Run" -> "Run ..." in the menu an...
I like [vim-ipython](https://github.com/ivanov/vim-ipython#id2). With it I can `<ctrl>+s` to run a specific line. Or several lines selected on visual modes. Take a look at this [video demo](http://pirsquared.org/vim-ipython/).
3,999,829
I wouldn't call myself programmer, but I've started learning Python recently and really enjoy it. I mainly use it for small tasks so far - scripting, text processing, KML generation and ArcGIS. From my experience with R (working with excellent Notepad++ and [NppToR](http://sourceforge.net/projects/npptor/) combo) I u...
2010/10/22
[ "https://Stackoverflow.com/questions/3999829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319487/" ]
I use Notepad++ for most of my Windows based Python development and for debugging I use [Winpdb](http://winpdb.org/about/). It's a cross platform GUI based debugger. You can actually setup a keyboard shortcut in Notepad++ to launch the debugger on your current script: To do this go to "Run" -> "Run ..." in the menu an...
Visual Studio and PTVS: <http://www.hanselman.com/blog/OneOfMicrosoftsBestKeptSecretsPythonToolsForVisualStudioPTVS.aspx> (There is also a REPL inside VS)
3,999,829
I wouldn't call myself programmer, but I've started learning Python recently and really enjoy it. I mainly use it for small tasks so far - scripting, text processing, KML generation and ArcGIS. From my experience with R (working with excellent Notepad++ and [NppToR](http://sourceforge.net/projects/npptor/) combo) I u...
2010/10/22
[ "https://Stackoverflow.com/questions/3999829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319487/" ]
The upcoming RStudio 1.2 is so good that you have to try to write some python with it.
[PyCharm](http://www.jetbrains.com/pycharm/) from JetBrains has a very nice debugger that you can step through code with. Django and console integration built in.
3,999,829
I wouldn't call myself programmer, but I've started learning Python recently and really enjoy it. I mainly use it for small tasks so far - scripting, text processing, KML generation and ArcGIS. From my experience with R (working with excellent Notepad++ and [NppToR](http://sourceforge.net/projects/npptor/) combo) I u...
2010/10/22
[ "https://Stackoverflow.com/questions/3999829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319487/" ]
If you are on Windows, give [Pyscripter](http://code.google.com/p/pyscripter/) a try -- it offers comprehensive, step-through debugging, which will let you examine the state of your variables at each step of your code.
Visual Studio and PTVS: <http://www.hanselman.com/blog/OneOfMicrosoftsBestKeptSecretsPythonToolsForVisualStudioPTVS.aspx> (There is also a REPL inside VS)
3,999,829
I wouldn't call myself programmer, but I've started learning Python recently and really enjoy it. I mainly use it for small tasks so far - scripting, text processing, KML generation and ArcGIS. From my experience with R (working with excellent Notepad++ and [NppToR](http://sourceforge.net/projects/npptor/) combo) I u...
2010/10/22
[ "https://Stackoverflow.com/questions/3999829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319487/" ]
If you like R's layout. I highly recommend trying out [Spyder](https://www.spyder-ide.org/). If you are using windows, try out Python(x,y). It is a package with a few different editors and a lot of common extra modules like scipy and numpy.
Visual Studio and PTVS: <http://www.hanselman.com/blog/OneOfMicrosoftsBestKeptSecretsPythonToolsForVisualStudioPTVS.aspx> (There is also a REPL inside VS)
3,999,829
I wouldn't call myself programmer, but I've started learning Python recently and really enjoy it. I mainly use it for small tasks so far - scripting, text processing, KML generation and ArcGIS. From my experience with R (working with excellent Notepad++ and [NppToR](http://sourceforge.net/projects/npptor/) combo) I u...
2010/10/22
[ "https://Stackoverflow.com/questions/3999829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319487/" ]
If you are on Windows, give [Pyscripter](http://code.google.com/p/pyscripter/) a try -- it offers comprehensive, step-through debugging, which will let you examine the state of your variables at each step of your code.
[PyCharm](http://www.jetbrains.com/pycharm/) from JetBrains has a very nice debugger that you can step through code with. Django and console integration built in.
3,999,829
I wouldn't call myself programmer, but I've started learning Python recently and really enjoy it. I mainly use it for small tasks so far - scripting, text processing, KML generation and ArcGIS. From my experience with R (working with excellent Notepad++ and [NppToR](http://sourceforge.net/projects/npptor/) combo) I u...
2010/10/22
[ "https://Stackoverflow.com/questions/3999829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319487/" ]
WingIDE, I've been using it successfully for over a year, and very pleased with it.
I like [vim-ipython](https://github.com/ivanov/vim-ipython#id2). With it I can `<ctrl>+s` to run a specific line. Or several lines selected on visual modes. Take a look at this [video demo](http://pirsquared.org/vim-ipython/).
3,999,829
I wouldn't call myself programmer, but I've started learning Python recently and really enjoy it. I mainly use it for small tasks so far - scripting, text processing, KML generation and ArcGIS. From my experience with R (working with excellent Notepad++ and [NppToR](http://sourceforge.net/projects/npptor/) combo) I u...
2010/10/22
[ "https://Stackoverflow.com/questions/3999829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319487/" ]
If you like R's layout. I highly recommend trying out [Spyder](https://www.spyder-ide.org/). If you are using windows, try out Python(x,y). It is a package with a few different editors and a lot of common extra modules like scipy and numpy.
I use Notepad++ for most of my Windows based Python development and for debugging I use [Winpdb](http://winpdb.org/about/). It's a cross platform GUI based debugger. You can actually setup a keyboard shortcut in Notepad++ to launch the debugger on your current script: To do this go to "Run" -> "Run ..." in the menu an...
3,999,829
I wouldn't call myself programmer, but I've started learning Python recently and really enjoy it. I mainly use it for small tasks so far - scripting, text processing, KML generation and ArcGIS. From my experience with R (working with excellent Notepad++ and [NppToR](http://sourceforge.net/projects/npptor/) combo) I u...
2010/10/22
[ "https://Stackoverflow.com/questions/3999829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/319487/" ]
I would plump for EMACS all round. If you're looking for a function to run code line by line (or a region if you have one highlighted), try adding this to your .emacs (I'm using python.el and Pymacs): ``` ;; send current line to *Python (defun my-python-send-region (&optional beg end) (interactive) (let ((beg (cond ...
[Light Table](http://lighttable.com/) was doing that for me, unfortunately it is discontinued: > > INLINE EVALUTION No more printing to the console in order to view your > results. Simply evaluate your code and the results will be displayed > inline. > > > [![enter image description here](https://i.stack.imgur.co...
18,149,636
I have a centos 6 server, and I'm trying to configure apache + wsgi + django but I can't. As I have Python 2.6 for my system and I using Python2.7.5, I can't install wit yum. I was dowload a tar file and try to compile using: ``` ./configure --with-python=/usr/local/bin/python2.7 ``` But not works. Systems respond: ...
2013/08/09
[ "https://Stackoverflow.com/questions/18149636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1623769/" ]
**I assume** you are on a shared hosting server, **mod\_wsgi** is not supported on most of shared hosting providers.
Try using [nginx](http://wiki.nginx.org/Main) server, it seems to be much easier to deploy. Here is a [good tutorial for deploying to EC2](http://www.yaconiello.com/blog/setting-aws-ec2-instance-nginx-django-uwsgi-and-mysql/#sthash.E2Gg8vGi.dpbs) but you can use parts of it to configure the server.
18,149,636
I have a centos 6 server, and I'm trying to configure apache + wsgi + django but I can't. As I have Python 2.6 for my system and I using Python2.7.5, I can't install wit yum. I was dowload a tar file and try to compile using: ``` ./configure --with-python=/usr/local/bin/python2.7 ``` But not works. Systems respond: ...
2013/08/09
[ "https://Stackoverflow.com/questions/18149636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1623769/" ]
This is covered in the mod\_wsgi documentation. * <http://code.google.com/p/modwsgi/wiki/InstallationIssues> Your Python installation wasn't configured with the --enable-shared option when it was built. You cannot workaround it at the time of building mod\_wsgi. Your Python installation needs to be reinstalled with t...
**I assume** you are on a shared hosting server, **mod\_wsgi** is not supported on most of shared hosting providers.
18,149,636
I have a centos 6 server, and I'm trying to configure apache + wsgi + django but I can't. As I have Python 2.6 for my system and I using Python2.7.5, I can't install wit yum. I was dowload a tar file and try to compile using: ``` ./configure --with-python=/usr/local/bin/python2.7 ``` But not works. Systems respond: ...
2013/08/09
[ "https://Stackoverflow.com/questions/18149636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1623769/" ]
This is covered in the mod\_wsgi documentation. * <http://code.google.com/p/modwsgi/wiki/InstallationIssues> Your Python installation wasn't configured with the --enable-shared option when it was built. You cannot workaround it at the time of building mod\_wsgi. Your Python installation needs to be reinstalled with t...
Try using [nginx](http://wiki.nginx.org/Main) server, it seems to be much easier to deploy. Here is a [good tutorial for deploying to EC2](http://www.yaconiello.com/blog/setting-aws-ec2-instance-nginx-django-uwsgi-and-mysql/#sthash.E2Gg8vGi.dpbs) but you can use parts of it to configure the server.
41,320,092
I am new to `python` and `boto3`, I want to get the latest snapshot ID. I am not sure if I wrote the sort with lambda correctly and how to access the last snapshot, or maybe I can do it with the first part of the script when I print the `snapshot_id` and `snapshot_date` ? Thanks. Here is my script ``` import boto3 ...
2016/12/25
[ "https://Stackoverflow.com/questions/41320092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308473/" ]
You should it sort in `reverse` order. ``` sorted(list_to_be_sorted, key=lambda k: k['date'], reverse=True)[0] ``` sorts the list by the date (in ascending order - oldest to the latest) If you add `reverse=True`, then it sorts in descending order (latest to the oldest). `[0]` returns the first element in the list wh...
You can append the snapshots to list, then sort the list based on date ``` def find_snapshots(): list_of_snaps = [] for snapshot in ec2client_describe_snapshots['Snapshots']: snapshot_volume = snapshot['VolumeId'] mnt_vol = "vol-xxxxx" if mnt_vol == snapshot_volume: snapshot_date = snapsho...
41,320,092
I am new to `python` and `boto3`, I want to get the latest snapshot ID. I am not sure if I wrote the sort with lambda correctly and how to access the last snapshot, or maybe I can do it with the first part of the script when I print the `snapshot_id` and `snapshot_date` ? Thanks. Here is my script ``` import boto3 ...
2016/12/25
[ "https://Stackoverflow.com/questions/41320092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308473/" ]
``` def find_snapshots(): list_of_snaps = [] for snapshot in ec2client_describe_snapshots['Snapshots']: snapshot_volume = snapshot['VolumeId'] mnt_vol = "vol-xxxxx" if mnt_vol == snapshot_volume: snapshot_date = snapshot['StartTime'] snapshot_id = snapshot['SnapshotId'] list_...
You can append the snapshots to list, then sort the list based on date ``` def find_snapshots(): list_of_snaps = [] for snapshot in ec2client_describe_snapshots['Snapshots']: snapshot_volume = snapshot['VolumeId'] mnt_vol = "vol-xxxxx" if mnt_vol == snapshot_volume: snapshot_date = snapsho...
41,320,092
I am new to `python` and `boto3`, I want to get the latest snapshot ID. I am not sure if I wrote the sort with lambda correctly and how to access the last snapshot, or maybe I can do it with the first part of the script when I print the `snapshot_id` and `snapshot_date` ? Thanks. Here is my script ``` import boto3 ...
2016/12/25
[ "https://Stackoverflow.com/questions/41320092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308473/" ]
The last line needs to be like this: ``` newlist = sorted(list_of_snaps, key=lambda k: k['snap_id']) ```
You can append the snapshots to list, then sort the list based on date ``` def find_snapshots(): list_of_snaps = [] for snapshot in ec2client_describe_snapshots['Snapshots']: snapshot_volume = snapshot['VolumeId'] mnt_vol = "vol-xxxxx" if mnt_vol == snapshot_volume: snapshot_date = snapsho...
41,320,092
I am new to `python` and `boto3`, I want to get the latest snapshot ID. I am not sure if I wrote the sort with lambda correctly and how to access the last snapshot, or maybe I can do it with the first part of the script when I print the `snapshot_id` and `snapshot_date` ? Thanks. Here is my script ``` import boto3 ...
2016/12/25
[ "https://Stackoverflow.com/questions/41320092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308473/" ]
You should it sort in `reverse` order. ``` sorted(list_to_be_sorted, key=lambda k: k['date'], reverse=True)[0] ``` sorts the list by the date (in ascending order - oldest to the latest) If you add `reverse=True`, then it sorts in descending order (latest to the oldest). `[0]` returns the first element in the list wh...
``` def find_snapshots(): list_of_snaps = [] for snapshot in ec2client_describe_snapshots['Snapshots']: snapshot_volume = snapshot['VolumeId'] mnt_vol = "vol-xxxxx" if mnt_vol == snapshot_volume: snapshot_date = snapshot['StartTime'] snapshot_id = snapshot['SnapshotId'] list_...
41,320,092
I am new to `python` and `boto3`, I want to get the latest snapshot ID. I am not sure if I wrote the sort with lambda correctly and how to access the last snapshot, or maybe I can do it with the first part of the script when I print the `snapshot_id` and `snapshot_date` ? Thanks. Here is my script ``` import boto3 ...
2016/12/25
[ "https://Stackoverflow.com/questions/41320092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308473/" ]
You should it sort in `reverse` order. ``` sorted(list_to_be_sorted, key=lambda k: k['date'], reverse=True)[0] ``` sorts the list by the date (in ascending order - oldest to the latest) If you add `reverse=True`, then it sorts in descending order (latest to the oldest). `[0]` returns the first element in the list wh...
The last line needs to be like this: ``` newlist = sorted(list_of_snaps, key=lambda k: k['snap_id']) ```
25,985,491
I have a sentiment analysis task and i need to specify how much data (in my case text) does scikit can handle. I have a corpus of 2500 opinions all ready tagged. I now that it´s a small corpus but my thesis advisor is asking me to specifically argue how many data does scikit learn can handle. My advisor has his doubts ...
2014/09/23
[ "https://Stackoverflow.com/questions/25985491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3930105/" ]
Here are some timings for scikit-learn's document classification example on my machine (Python 2.7, NumPy 1.8.2, SciPy 0.13.3, scikit-learn 0.15.2, Intel Core i7-3540M laptop running on battery power). The dataset is twenty newsgroups; I've trimmed the output quite a bit. ``` $ python examples/document_classification_...
[This Scikit page](http://scikit-learn.org/stable/modules/scaling_strategies.html) may provide some answers if you are experiencing some issues with the amount of data that you are trying to load. As stated in your other question on data size [concerning Weka](https://stackoverflow.com/questions/25979182/how-much-tex...
25,985,491
I have a sentiment analysis task and i need to specify how much data (in my case text) does scikit can handle. I have a corpus of 2500 opinions all ready tagged. I now that it´s a small corpus but my thesis advisor is asking me to specifically argue how many data does scikit learn can handle. My advisor has his doubts ...
2014/09/23
[ "https://Stackoverflow.com/questions/25985491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3930105/" ]
Here are some timings for scikit-learn's document classification example on my machine (Python 2.7, NumPy 1.8.2, SciPy 0.13.3, scikit-learn 0.15.2, Intel Core i7-3540M laptop running on battery power). The dataset is twenty newsgroups; I've trimmed the output quite a bit. ``` $ python examples/document_classification_...
The question is not about `scikit-learn`, it's about what algorithms you want to use. Most of `scikit-learn`'s internals are implemented in `C` or `Fortran`, so it's quite efficient. For example, `scikit-learn` random forest is the fastest out there ([see page 116 in this link](http://www.montefiore.ulg.ac.be/%7Egloupp...
9,291,036
I'm putting together a basic photoalbum on appengine using python 27. I have written the following method to retrieve image details from the datastore matching a particular "adventure". I'm using limits and offsets for pagination, however it is very inefficient. After browsing 5 pages (of 5 photos per page) I've alread...
2012/02/15
[ "https://Stackoverflow.com/questions/9291036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/714852/" ]
A few things: 1. You don't need to have count called each time, you can cache it 2. Same goes to the query, why are you querying all the time? cache it also. 3. Cache the pages also, you should not calc the data per page each time. 4. You only need the blob\_key but your are loading the entire photo entity, try to mod...
The way you handle paging is inefficient as it goes through every record before the offset to deliver the data. You should consider building the paging mechanisms using the bookmark methods described by Google <http://code.google.com/appengine/articles/paging.html>. Using this method you only go through the items you ...
9,291,036
I'm putting together a basic photoalbum on appengine using python 27. I have written the following method to retrieve image details from the datastore matching a particular "adventure". I'm using limits and offsets for pagination, however it is very inefficient. After browsing 5 pages (of 5 photos per page) I've alread...
2012/02/15
[ "https://Stackoverflow.com/questions/9291036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/714852/" ]
A few things: 1. You don't need to have count called each time, you can cache it 2. Same goes to the query, why are you querying all the time? cache it also. 3. Cache the pages also, you should not calc the data per page each time. 4. You only need the blob\_key but your are loading the entire photo entity, try to mod...
You may want to consider moving to the new NDB API. Its use of futures, caches and autobatching may help you a lot. Explicit is better than implicit, but NDB's management of the details makes your code simpler and more readable. BTW, did you try to use appstats and see how your requests are using the server resources?
9,291,036
I'm putting together a basic photoalbum on appengine using python 27. I have written the following method to retrieve image details from the datastore matching a particular "adventure". I'm using limits and offsets for pagination, however it is very inefficient. After browsing 5 pages (of 5 photos per page) I've alread...
2012/02/15
[ "https://Stackoverflow.com/questions/9291036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/714852/" ]
The way you handle paging is inefficient as it goes through every record before the offset to deliver the data. You should consider building the paging mechanisms using the bookmark methods described by Google <http://code.google.com/appengine/articles/paging.html>. Using this method you only go through the items you ...
You may want to consider moving to the new NDB API. Its use of futures, caches and autobatching may help you a lot. Explicit is better than implicit, but NDB's management of the details makes your code simpler and more readable. BTW, did you try to use appstats and see how your requests are using the server resources?
35,390,152
I am new to selenium with python. Tried this sample test script. ``` from selenium import webdriver def browser(): driver= webdriver.Firefox() driver.delete_all_cookies() driver.get('http://www.gmail.com/') driver.maximize_window() driver.save_screenshot('D:\Python Programs\Sc...
2016/02/14
[ "https://Stackoverflow.com/questions/35390152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5861605/" ]
Just use [pandas](http://pandas.pydata.org/): ``` In [1]: import pandas as pd ``` Change the number of decimals: ``` In [2]: pd.options.display.float_format = '{:.3f}'.format ``` Make a data frame: ``` In [3]: df = pd.DataFrame({'gof_test': gof_test, 'gof_train': gof_train}) ``` and display: ``` In [4]: df ...
Indeed you cannot affect the display of the Python output with CSS, but you can give your results to a formatting function that will take care of making it "beautiful". In your case, you could use something like this: ``` def compare_dicts(dict1, dict2, col_width): print('{' + ' ' * (col_width-1) + '{') for k1...
42,449,296
In OpenAPI, inheritance is achieved with `allof`. For instance, in [this example](https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v2.0/json/petstore-simple.json): ```js "definitions": { "Pet": { "type": "object", "allOf": [ { "$ref": "#/definitions/NewPet" # <---...
2017/02/24
[ "https://Stackoverflow.com/questions/42449296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653485/" ]
JSON Schema doesn't support inheritance. The behavior of `allOf` can sometimes look like inheritance, but if you think about it that way you will end up getting confused. The `allOf` keyword means just what it says: all of the schemas must validate. Nothing gets overridden or takes precedence over anything else. Every...
One thing to consider is what inheritance means. In Eclipse Modeling Framework trying to create a class that extends 2 classes with the same attribute is an error. Never the less I consider that multiple inheritance. This is called the Diamond Problem. See <https://en.wikipedia.org/wiki/Multiple_inheritance>
60,942,530
I'm working on an Django project, and building and testing with a database on GCP. Its full of test data and kind of a mess. Now I want to release the app with a new and fresh another database. How do I migrate to the new database? with all those `migrations/` folder? I don't want to delete the folder cause the deve...
2020/03/31
[ "https://Stackoverflow.com/questions/60942530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4971866/" ]
> > or maybe a different data structure to keep both the name and the value of the variable? > > > Ding ding! You want to use a map for this. A map stores a key and a value as a pair. To give you a visual representation, a map looks like this: ``` Cats: 5 Dogs: 3 Horses: 2 ``` Using a map you can access both th...
You might want to consider priority queue in java. But first you need a class which have 2 attributes (the word and its quantity). This class should implement Comparable and compareTo method should be overridden. Here's an example: <https://howtodoinjava.com/java/collections/java-priorityqueue/>
37,972,029
[PEP 440](https://www.python.org/dev/peps/pep-0440) lays out what is the accepted format for version strings of Python packages. These can be simple, like: `0.0.1` Or complicated, like: `2016!1.0-alpha1.dev2` What is a suitable regex which could be used for finding and validating such strings?
2016/06/22
[ "https://Stackoverflow.com/questions/37972029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1728179/" ]
I had the same question. This is the most thorough regex pattern I could find. PEP440 links to the codebase of the packaging library in it's references section. ``` pip install packaging ``` To access just the pattern string you can use the global ``` from packaging import version version.VERSION_PATTERN ``` See:...
I think this should comply with PEP440: ``` ^(\d+!)?(\d+)(\.\d+)+([\.\-\_])?((a(lpha)?|b(eta)?|c|r(c|ev)?|pre(view)?)\d*)?(\.?(post|dev)\d*)?$ ``` ### Explained Epoch, e.g. `2016!`: ``` (\d+!)? ``` Version parts (major, minor, patch, etc.): ``` (\d+)(\.\d+)+ ``` Acceptable separators (`.`, `-` or `_`): ``` (...