Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2017-06-15 21:49:00.657 | Py2exe - Can't run a .exe created on Windows 10 with a Windows 7 computer | I created a .exe file using Py2exe on Windows 10 but when I try to run it on a Windows 7 computer it says that the os version is wrong.
Can anyone tell me how to fix this? (like using another Python or Py2exe version or setting a specific configuration inside setup.py) | I solved the problem myself and I'm going to share the answer if someone ever has the same mistake. I just had to download a 32-bit version of Canopy (with Python 2.7) and py2exe in order for them to work on Windows 7. | 1.2 | true | 1 | 4,939 |
2017-06-16 09:43:57.063 | How to change cmd python from anaconda to default python? | windows power shell or cmd uses anaconda python instead of the default windows installation
how to make them use the default python installation?
my os is win 8.1
python 3.6
anaconda python 3.6 | Set the environment path variable of your default python interpreter in system properties.
or if this doesn't work do:
in cmd C:\Python27\python.exe yourfilename.py
in the command first part is your interpreter location and second is your file name | 1.2 | true | 1 | 4,940 |
2017-06-16 16:50:21.430 | Discord.py show who invited a user | I am currently trying to figure out a way to know who invited a user. From the official docs, I would think that the member class would have an attribute showing who invited them, but it doesn't. I have a very faint idea of a possible method to get the user who invited and that would be to get all invites in the server... | Watching the number of uses an invite has had, or for when they run out of uses and are revoked, is the only way to see how a user was invited to the server. | 0.135221 | false | 2 | 4,941 |
2017-06-16 16:50:21.430 | Discord.py show who invited a user | I am currently trying to figure out a way to know who invited a user. From the official docs, I would think that the member class would have an attribute showing who invited them, but it doesn't. I have a very faint idea of a possible method to get the user who invited and that would be to get all invites in the server... | In Discord, you're never going to 100% sure who invited the user.
Using Invite, you know who created the invite.
Using on_member_join, you know who joined.
So, yes, you could have to check invites and see which invite got revoked. However, you will never know for sure who invited since anyone can paste the same invite ... | 0.135221 | false | 2 | 4,941 |
2017-06-16 18:24:13.907 | Get unix file type with Python os module | I would like to get the unix file type of a file specified by path (find out whether it is a regular file, a named pipe, a block device, ...)
I found in the docs os.stat(path).st_type but in Python 3.6, this seems not to work.
Another approach is to use os.DirEntry objects (e. g. by os.listdir(path)), but there are onl... | Python 3.6 has pathlib and its Path objects have methods:
is_dir()
is_file()
is_symlink()
is_socket()
is_fifo()
is_block_device()
is_char_device()
pathlib takes a bit to get used to (at least for me having come to Python from C/C++ on Unix), but it is a nice library | 1.2 | true | 1 | 4,942 |
2017-06-16 20:33:39.033 | How to use model.fit_generator in keras | When and how should I use fit_generator?
What is the difference between fit and fit_generator? | They are useful for on-the-fly augmentations, which the previous poster mentioned. This however is not neccessarily restricted to generators, because you can fit for one epoch and then augment your data and fit again.
What does not work with fit is using too much data per epoch though. This means that if you have a dat... | 0.386912 | false | 1 | 4,943 |
2017-06-17 15:37:17.260 | Python web app ideas- incremental/unique file suggestions for multiple users | Firstly, this question isn't a request for code suggestions- it's more of a question about a general approach others would take for a given problem.
I've been given the task of writing a web application in python to allow users to check the content of media files held on a shared server. There will also likely be a po... | These requirements are more or less straightforward to follow. Given that you will have a persistent database that can share the state of each file with multiple sessions - and even multiple deploys - of your system - and that is more or less a given with Python + PostgreSQL.
I'd suggest you to create a Python class w... | 1.2 | true | 1 | 4,944 |
2017-06-18 19:31:38.603 | How to share data between programs that use different languages to run | I want to share data between programs that run locally which uses different languages, I don't know how to approach this.
For example, if I have a program that uses C# to run and another that uses python to run, and I want to share some strings between the two, how can I do it?
I thought about using sockets for this b... | There are a lot of ways to do so, I would recommend you reading more about IPC (Inter Process Communication) - sockets, pipes, named pipes, shared memory and etc...
Each method has it's own advantages, therefore, you need to think about what you're trying to achieve and choose the method that fits you the best. | 1.2 | true | 2 | 4,945 |
2017-06-18 19:31:38.603 | How to share data between programs that use different languages to run | I want to share data between programs that run locally which uses different languages, I don't know how to approach this.
For example, if I have a program that uses C# to run and another that uses python to run, and I want to share some strings between the two, how can I do it?
I thought about using sockets for this b... | Any kind of IPC (InterProcess Communication) — sockets or shared memory. Any common format — plain text files or structured, JSON, e.g. Or a database. | 0.201295 | false | 2 | 4,945 |
2017-06-18 19:41:42.263 | Python(scapy): how to sniff packets that are only outboun packets | how do I sniff packets that are only outbound packets?
I tried to sniff only destination port but it doesn't succeed at all | Maybe you can get your device MAC address and filter any packets with that address as source address. | 0 | false | 1 | 4,946 |
2017-06-19 09:17:05.203 | python- how to find same words in two different excel workbooks | I want to find the same words in two different excel workbooks. I have two excel workbooks (data.xls and data1.xls). If in data.xls have the same words in the data1.xls, i want it to print the row of data1.xls that contain of the same words with data.xls. I hope u can help me. Thank you. | I am assuming that both excel sheets have a list of words, with one word in each cell.
The best way to write this program would be something like this:
Open the first excel file, you might find it easier to open if you export it as a CSV first.
Create a Dictionary to store word and Cell Index Pairs
Iterate over each... | 0 | false | 1 | 4,947 |
2017-06-19 12:30:55.347 | Is it possible to store an array in Django model? | I was wondering if it's possible to store an array in a Django model?
I'm asking this because I need to store an array of int (e.g [1,2,3]) in a field and then be able to search a specific array and get a match with it or by it's possible combinations.
I was thinking to store that arrays as strings in CharFields and th... | I don't know why nobody has suggested it, but you can always pickle things and put the result into a binary field.
The advantages of this method are that it will work with just about any database, it's efficient, and it's applicable to more than just arrays. The downside is that you can't have the database run queries... | 0.16183 | false | 1 | 4,948 |
2017-06-19 14:15:51.887 | Does twitter support webhooks for chatbots or should i use Stream API? | I am trying to build a twitter chat bot which is interactive and replies according to incoming messages from users. Webhook documentation is unclear on how do I receive incoming message notifications. I'm using python. | Answering my own question.
Webhook isn't needed, after searching for long hours on Twitter Documentation, I made a well working DM bot, it uses Twitter Stream API, and StreamListener class from tweepy, whenever a DM is received, I send requests to REST API which sends DM to the mentioned recipient. | 1.2 | true | 1 | 4,949 |
2017-06-19 20:10:42.877 | TensorFlow extracting columns | I have a tensor of shape (10, 100, 20, 3). Basically, it can be thought of as a batch of images. So the image height is 100 and width is 20 and channel depth is 3.
I have run some computations to generate a set of 10*50 indices corresponding to 50 columns I would like to keep per image in the batch. The indices are sto... | I can't comment on the question because of low rep, so using an answer instead.
Can you clarify your question a bit, maybe with a small concrete example using very small tensors?
What are the "columns" you are referring to? You say that you want to keep 50 columns (presumably 50 numbers) per image. If so, the (10, 50) ... | 0 | false | 1 | 4,950 |
2017-06-20 11:33:10.110 | Alternative for 'enter' key in python interpreter? | Recently my Enter key stopped working. For sure it's a hardware problem!. However I managed so many days without Enter key by using the alternatives ctrl + j or ctrl + m .Running python programs was fine as I would run the script by saving it in a file. Now that I need to give commandline values I have to press enter f... | Normally, IDLE has an Option / Configure IDLE menu which allows you to remap almost any action to a key combination. The newline and indent action is by default mapped to Key Return and Num Keypad Return, while Ctrl J is used for plain newline and indent. But it is easy to change this mapping configuration. | 1.2 | true | 1 | 4,951 |
2017-06-21 13:37:02.370 | How to convert RPM spec file dependencies to Python setup.py? | Basically I'm working on porting a program from being packaged with RPM into using setup.py to package it as a wheel. My core question is whether there exists some guide or tool on how to make this conversion.
The key issue is that I'm looking to convert dependencies as specified by RPM's spec file to setup.py and can'... | Any answer likely depends on the distro for which the rpm was built. A generic, albeit manual approach, would to start with rpm -q --requires $PACKAGE but as you already have the spec file, you can simply rpmspec -q --requires *spec to get that same info. Look for the packages providing Python resources, e.g., python... | 0 | false | 1 | 4,952 |
2017-06-21 13:53:41.573 | Python selenium with chrome webdriver - change user agent | I am running some code with selenium using python, and I figured out that I need to dynamically change the UserAgent after I already created the webdriver. Any advice if it is possible and how this could be done? Just to highlight - I want to change it on the fly, after almost each GET or POST request I send | I would go with creating a new driver and copy all the necessary attributes from the old driver except the user agent. | 1.2 | true | 1 | 4,953 |
2017-06-21 14:17:38.280 | Associating a python project with a virtual environment | been searching for this with no success, i don't know if i am missing something but i have a virtualenv already but how do i create a project to associate the virtualenv with, thanks
P.S. Am on windows | Requirements:
Virtual Env
Pycharm
Go to Virtual env and type which python
Add remote project interpreter (File > Default Settings > Project Interpreter (cog) add remote)
You'll need to set up your file system so that PyCharm can also open the project.
NOTE:
do not turn off your virtual environment without saving you... | 0.201295 | false | 2 | 4,954 |
2017-06-21 14:17:38.280 | Associating a python project with a virtual environment | been searching for this with no success, i don't know if i am missing something but i have a virtualenv already but how do i create a project to associate the virtualenv with, thanks
P.S. Am on windows | If you already have your virtualenv installed you just need to start using it.
Create your projects virtual environment using virtualenv env_name on cmd. To associate a specific version of python with your environment use: virtualenv env_name -p pythonx.x;
Activate your environment by navigating into its Scripts folde... | 0.101688 | false | 2 | 4,954 |
2017-06-21 14:58:32.037 | Using Scapy to fitler HTTP packets | I am trying to make a filter for packets that contain HTTP data, yet I don't have a clue on how to do so.
I.E. Is there a way to filter packets using Scapy that are only HTTP? | Yes, you can. You can filter by TCP port 80 (checking each packet or using BPF) and then check the TCP payload to ensure there is an HTTP header. | 0.135221 | false | 1 | 4,955 |
2017-06-22 11:33:18.787 | dispatch.yaml not getting updated | I edited my dispatch.yaml and deployed on app engine using
appcfg.py update_dispatch .
But when I go and see source code under StackDriver debug, I don't see the change.
Why the changes doesn't get reflected. But when I deploy complete app by appcfg.py update . the changes get reflected.
But in case, If I only want to... | Try
gcloud app deploy dispatch.yaml
...to connect services to dispatch rules. | 0.201295 | false | 1 | 4,956 |
2017-06-22 14:59:24.760 | should i be using threads multiprocessing or asycio for my project? | I am trying to build a temperature control module that can be controlled over a network or with manual controls. the individual parts of my program all work but I'm having trouble figuring out how to make them all work together.also my temperature control module is python and the client is C#.
so far as physical compon... | Multiprocessing is generally for when you want to take advantage of the computational power of multiple processing cores. Multiprocessing limits your options on how to handle shared state between components of your program, as memory is copied initially on process creation, but not shared or updated automatically. Thre... | 1.2 | true | 1 | 4,957 |
2017-06-22 16:39:33.887 | How can I force CMake to use the correct OpenCV version? | I'm trying to run a python script that uses a custom module written by someone else. I created that module by running CMake according to the creator's instructions. Running my python script, I get the error: ImportError: libopencv_imgproc.so.3.1: cannot open shared object file: No such file or directory. This error is ... | The problem was an old version of the module lurking an a different folder where the python script was actually looking. This must have been created in the past with an OpenCV 3.1 environment. | 0 | false | 1 | 4,958 |
2017-06-22 23:57:29.247 | How to escape the string "\x0a\xfd\x ....." in python? | I'm a Python3 User. And I'm now face some problem about byte to string control..
First, I'm get data from some server as a byte.
[Byte data] : b'\xaaD\x12\x1c+\x00\x00 \x18\x08\x00\x00\x88\xb4\xa2\x07\xf8\xaf\xb6\x19\x00\x00\x00\x00\x03Q\xfa3/\x00\x00\x00\x1d\x00\x00\x00\x86=\xbd\xc9~\x98uA>\xdf#=\x9a\xd8\xdb\x18\x1c_... | You need to decode the byte data:
byte_data.decode("utf-8") | 0 | false | 1 | 4,959 |
2017-06-23 01:55:41.933 | script first line _author_="dev" does not show up | I am learning Python by watching youtube videos and also through an online course that I bought. In every video I watch, the first line of each file is: _author_='dev'. For some reason when I start a new file this does not come up. What does this mean and if it is an issue how do I correct it?
FYI I am using Intel... | It is pre-compiled in some IDEs like PyDev but not in IDEA, you can add it manually if you want it. I also recommend you to use PyCharm instead of IDEA for python. | 1.2 | true | 1 | 4,960 |
2017-06-23 08:14:33.390 | KernelPCA produces NaNs | After applying KernelPCA to my data and passing it to a classifier (SVC) I'm getting the following error:
ValueError: Input contains NaN, infinity or a value too large for
dtype('float64').
and this warning while performing KernelPCA:
RuntimeWarning: invalid value encountered in sqrt X_transformed =
self.alphas_... | The NaNs are produced because the eigenvalues (self.lambdas_) of the input matrix are negative which provoke the ValueError as the square root does not operate with negative values.
The issue might be overcome by setting KernelPCA(remove_zero_eig=True, ...) but such action would not preserve the original dimensionality... | 1.2 | true | 1 | 4,961 |
2017-06-23 12:27:52.800 | Eclipse cannot import already installed pip package | So basically I used pip to import the docx python package and it installed correctly, (verified by the freeze command). However I cannot import the package in eclipse.
Through some serious effort I've noticed that I can import the package using the 32 bit IDLE shell whereas I cannot when using the 64 bit IDLE shell. My... | thanks for the reply.
The actual problem was that I was using python 3.6 where eclipse only accepts python grammar versions up to 3.5. The docx package also only works with python 2.6, 2.7, 3.3, or 3.4 so I installed python 3.4 and docx is now working! | 0 | false | 1 | 4,962 |
2017-06-23 14:08:12.667 | VGG16 Training new dataset: Why VGG16 needs label to have shape (None,2,2,10) and how do I train mnist dataset with this network? | I was trying to train CIFAR10 and MNIST dataset on VGG16 network. In my first attempt, I got an error which says shape of input_2 (labels) must be (None,2,2,10). What information does this structure hold in 2x2x10 array because I expect input_2 to have shape (None, 10) (There are 10 classes in both my datasets).
I trie... | Low accuracy is caused by the problem in layers. I just modified my network and obtained .7496 accuracy. | 1.2 | true | 1 | 4,963 |
2017-06-23 17:45:54.153 | Scheduling a .py file on Task Scheduler in Windows 10 | I already tried to convert my .py file into .exe file. Unfortunately, the .exe file gives problems; I believe this is because my code is fairly complicated.
So, I am trying to schedule directly my .py file with Task Scheduler but every time I do it and then run it to see if works, a window pops up and asks me how I wou... | The script you execute would be the exe found in your python directory
ex) C:\Python27\python.exe
The "argument" would be the path to your script
ex) C:\Path\To\Script.py
So think of it like this: you aren't executing your script technically as a scheduled task. You are executing the root python exe for your computer w... | 0.04532 | false | 2 | 4,964 |
2017-06-23 17:45:54.153 | Scheduling a .py file on Task Scheduler in Windows 10 | I already tried to convert my .py file into .exe file. Unfortunately, the .exe file gives problems; I believe this is because my code is fairly complicated.
So, I am trying to schedule directly my .py file with Task Scheduler but every time I do it and then run it to see if works, a window pops up and asks me how I wou... | This absolutely worked for me . I am using windows 10 professional edition and it has taken me almost 6 months to get this solution.Thanks to the suggestion made above.
I followed this suggestion and it worked right away and smoothly. All I did was to instruct the scheduler to run python.exe with my script as an argu... | 0 | false | 2 | 4,964 |
2017-06-24 19:25:27.237 | how to preserve number of records in word2vec? | I have 45000 text records in my dataframe. I wanted to convert those 45000 records into word vectors so that I can train a classifier on the word vector. I am not tokenizing the sentences. I just split the each entry into list of words.
After training word2vec model with 300 features, the shape of the model resulted in... | If you are splitting each entry into a list of words, that's essentially 'tokenization'.
Word2Vec just learns vectors for each word, not for each text example ('record') – so there's nothing to 'preserve', no vectors for the 45,000 records are ever created. But if there are 26,000 unique words among the records (after... | 1.2 | true | 1 | 4,965 |
2017-06-27 03:13:25.170 | How to use pyqt widget event() method? | Exactly how do I utilize the various event methods that widgets have? Say I have a comboBox(drop down list) and I want to initiate a function every time someone changes the choice. There is the changeEvent() method in the documentation but It would be great if someone explains to me with a piece of code. | This is a pretty broad question. I recommend checking out the many tutorials on Youtube.com.
However, in your init method, put something like this:
self.ui.charge_codes_combo.currentIndexChanged.connect(self.setup_payments)
In my example, the combo box was placed on a form in Qt Designer. Self.setup_payment is a m... | 0 | false | 1 | 4,966 |
2017-06-27 19:40:07.247 | Python remove . after state | I have sentences with state codes followed by a . (ie. "CA.", "AL.", but also good "CA", "AL") or things like "acct." or "no."
I'd like to:
1. remove those "."
2. keep other "."
3. change no. to #
For example, I'd like:
"Mr. J. Edgar Hoover from CA. owes us $123.45 from acct. no. 98765."
to become
"Mr. J. Edgar Hoover... | state code always contains 2 uppercase characters, so you can use this pattern to do your replacement.
match this:
([A-Z]{2}).
and replace by this: $1 | 0 | false | 1 | 4,967 |
2017-06-28 18:42:40.853 | Option to add extra choices in django form | I am trying to create a model via a form that has multiple other models related to it. Say I have a model Publisher, then another model Article with a foreign key to Publisher. When creating a Publisher via a form, I want to create An article at the same time. I know how to do this via formsets. However, I don't know ... | This can only be done using JavaScript. The hard part is to have the management form sync up with the number of rows.
But there's two alternatives:
Semi-javascript (Mezzanine's approach): Generate a ton of rows in the formset and only show one empty. Upon the click of the "add another row" button, unhide the next one.... | 0 | false | 1 | 4,968 |
2017-06-29 22:49:40.293 | Installing rpy2 to work with R 3.4.0 on OSX | I would like to use some R packages requiring R version 3.4 and above. I want to access these packages in python (3.6.1) through rpy2 (2.8).
I have R version 3.4 installed, and it is located in /Library/Frameworks/R.framework/Resources However, when I use pip3 install rpy2 to install and use the python 3.6.1 in /Librar... | I had uninstall the version pip installed and install from source python setup.py install on the download https://bitbucket.org/rpy2/rpy2/downloads/. FWIW not using Anaconda at all either. | 0 | false | 2 | 4,969 |
2017-06-29 22:49:40.293 | Installing rpy2 to work with R 3.4.0 on OSX | I would like to use some R packages requiring R version 3.4 and above. I want to access these packages in python (3.6.1) through rpy2 (2.8).
I have R version 3.4 installed, and it is located in /Library/Frameworks/R.framework/Resources However, when I use pip3 install rpy2 to install and use the python 3.6.1 in /Librar... | I uninstalled rpy2 and reinstalled with --verborse. I then found
ld: warning: ignoring file /opt/local/lib/libpcre.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libpcre.dylib
ld: warning: ignoring file /opt/local/lib/liblzma.dylib, file was built for x86_64 ... | 1.2 | true | 2 | 4,969 |
2017-06-30 05:32:37.393 | how can I change default python version in pythonanywhere? | I am trying to deploy my Django application on pythonanywhere through manual-configuration. I selected Python 3.6.When I opened the console and type "python --version" It is showing python 2.7 instead of 3.6. How can I change this?
Please help me. | to set your default python version from 2.7 to 3.7 run the command below
$ alias python=python3
that's it now check the version
$ python --version
it should be solved | 0.201295 | false | 3 | 4,970 |
2017-06-30 05:32:37.393 | how can I change default python version in pythonanywhere? | I am trying to deploy my Django application on pythonanywhere through manual-configuration. I selected Python 3.6.When I opened the console and type "python --version" It is showing python 2.7 instead of 3.6. How can I change this?
Please help me. | Try to type "python3 --version". This can work on linux, but I am not sure whether it works on pythonanywhere | 0 | false | 3 | 4,970 |
2017-06-30 05:32:37.393 | how can I change default python version in pythonanywhere? | I am trying to deploy my Django application on pythonanywhere through manual-configuration. I selected Python 3.6.When I opened the console and type "python --version" It is showing python 2.7 instead of 3.6. How can I change this?
Please help me. | Python 3.6 is available as python3.6 in a console on PythonAnywhere. | 1.2 | true | 3 | 4,970 |
2017-06-30 17:24:12.180 | Python : Redirecting device with MITM | I have built a MITM with python and scapy.I want to make the "victim" device be redirected to a specific page each time it tried to access a website. Any suggestions on how to do it?
*Keep in mind that all the traffic from the device already passes through my machine before being routed. | You can directly answer HTTP requests to pages different to that specific webpage with HTTP redirections (e.g. HTTP 302). Moreover, you should only route packets going to the desired webpage and block the rest (you can do so with a firewall such as iptables). | 1.2 | true | 1 | 4,971 |
2017-07-01 06:19:03.213 | how to get random pixel index from binary image with value 1 in python? | I have a binary image of large size (2000x2000). In this image most of the pixel values are zero and some of them are 1. I need to get only 100 randomly chosen pixel coordinates with value 1 from image. I am beginner in python, so please answer. | I'd suggest making a list of coordinates of all non-zero pixels (by checking all pixels in the image), then using random.shuffle on the list and taking the first 100 elements. | 0.296905 | false | 1 | 4,972 |
2017-07-02 13:26:51.027 | In spyder how to get back default view of running a code in Ipython console | Hi on running a code in the console I am getting the display as:
runfile('C:/Users/DX/Desktop/me template/Part 1 - Data Preprocessing/praCTICE.py', wdir='C:/Users/DX/Desktop/me template/Part 1 - Data Preprocessing')
and on viewing a small matrix it is showing up as
array([['France', 44.0, 72000.0],
['Spa... | (Spyder developer here) Please use the Variable Explorer to visualize Numpy arrays and Pandas DataFrames. That's its main purpose. | 0.386912 | false | 1 | 4,973 |
2017-07-04 10:02:47.110 | how to install python package on azure hdinsight pyspark3 kernel? | I would like to install python 3.5 packages so they would be available in Jupyter notebook with pyspark3 kernel.
I've tried to run the following script action:
#!/bin/bash
source /usr/bin/anaconda/envs/py35/bin/activate py35
sudo /usr/bin/anaconda/envs/py35/bin/conda install -y keras tensorflow theano gensim
but the p... | Have you tried installing using pip?
In some cases where you have both Python 2 and Python 3, you have to run pip3 instead of just pip to invoke pip for Python 3. | 0 | false | 1 | 4,974 |
2017-07-04 16:59:15.487 | How to retrieve the pg_config file from Azure postgresql Database | Trying to install a postgresql database which resides on Azure for my python flask application; but the installation of psycopg2 package requires the pg_config file which comes when postgresql is installed. So how do I export the pg_config file from the postgresql database which also resides on azure? Is pg_config all ... | You don't need the specific pg_config from the target database. It's only being used to compile against libpq, the client library for PostgreSQL, so you only need the matching PostgreSQL client installed on your local machine.
If you're on Windows I strongly advise you to install a pre-compiled PostgreSQL. You can just... | 1.2 | true | 1 | 4,975 |
2017-07-06 17:31:04.937 | What are my options for navigating through subroutines? | Suppose I want a program Foo.py which has some arbitrary routines Bar(), Quux(), and Fizz(). Let's say that the usual order of execution from a procedural perspective should be Bar() -> Quux() -> Fizz(). However, Fizz() should conditionally call a function Buzz() depending on some runtime action, and calling Buzz() at ... | Using coroutines (multithreading) will provide the desired concurrent functionality. Source in the comments of the question and of user2357112's answer. | 1.2 | true | 1 | 4,976 |
2017-07-06 18:44:39.873 | How to create a list of string in nth position of every line in Python | What would be a pythonic way to create a list of (to illustrate with an example) the fifth string of every line of a text file, assuming it ressembles something like this:
12, 27.i, 3, 6.7, Hello, 438
In this case, the script would add "Hello" (without quotes) to the list.
In other words (to generalize), with an input ... | This may not be the most efficient solution, but you could also just hard code it e.g. create a variable equivalent to zero, add one to the variable for each word in the line, and append the word to a list when variable = 5. Then reset the variable equal to zero. | 0 | false | 1 | 4,977 |
2017-07-06 21:16:21.740 | pytest: environment variable to specify pytest.ini location | How can I set an environment variable with the location of the pytest.ini, tox.ini or setup.cfg for running pytest by default?
I created a docker container with a volume pointing to my project directory, so every change I make is also visible inside the docker container. The problem is that I have a pytest.ini file on ... | There is no way to do that. You can use a different pytest configuration using pytest -c but tox.ini and setup.cfg must reside in the top-level directory of your package, next to setup.py. | 1.2 | true | 1 | 4,978 |
2017-07-08 01:11:39.293 | How to grab the nth occurence of a float on a line using regex? | The text file I'm searching through looks like a lot of text blocks like this:
MKC,2017-06-23 07:54,-94.5930,39.1230,79.00,73.90,84.41,220.00,4.00,0.00,29.68,1003.90,10.00,M,FEW,M,M,M,9500.00,M,M,M,M,KMKC 230754Z 22004KT 10SM FEW095 26/23 A2968 RMK AO2 SLP039 T02610233
(That's all one line)
I'm looking to grab the 2n... | You could use the re.findall(regex, string, flags) function in python. That returns non-overlapping matches of the patter in string in a list of strings. You could then grab the second member of the returned list. | 0 | false | 1 | 4,979 |
2017-07-08 03:50:55.650 | how to add the trigger s3 bucket to lambda function dynamically(python boto3 API) | how to add trigger s3 bucket to lambda function with boto3, then I want attach that lambda function to dynamically created s3 buckets using programmatically(boto3) | Three steps I followed
1) connected to aws lambda with boto3 used add_permission API
2)also applyed get_policy
3)connected to S3 with boto resource to configuring BucketNotification API,put LambdaFunctionConfigurations | 1.2 | true | 1 | 4,980 |
2017-07-08 16:35:37.417 | Updating my Django website's database from a third party service, strategies? | I'm learning Django and to practice I'm currently developing a clone page of YTS, it's a movie torrents repository*.
As of right now, I scrapped all the movies in the website and have them on a single db table called Movie with all the basic information of each movie (I'm planning on adding one more for Genre).
Every ... | I think you should choose definetely the third alternative, a cron job to update the database regularly seems the best option.
You don' t need to use a seperate python function, you can schedule a task with celery, which can be easily integrated with django using django-celery | 0.386912 | false | 1 | 4,981 |
2017-07-09 08:11:49.910 | Destroy session or cookie in django when user get offline | I have a website and i want to destroy some session or cookie in django when user discoonet suddenly or get offline (wifi discoonect or disconnect mobil data).
But i dont know to how do this!
Is there any default library to do this? | Well you can't know if users disconnected their internet or WiFi.
But you can check if user is still online and browsing the website.
to achieve that you can use javascript to send a request every 10 second (less or more) and check if user is still on the site. and if user is not online anymore you can make some change... | 0 | false | 1 | 4,982 |
2017-07-09 12:49:19.787 | Could someone please provide a walkthrough on how to setup a self signing ssl certificate on cloud 9? | I am migrating my personal hobby python web application from 127.0.0.1 to cloud 9 lately, but found myself completely new to the idea of setting up ssl certificate. I did some online research on openssl and its python wrapper but still couldn't find any definitive guide on how to set it up in practice, specifically for... | Cloud9 runs your app behind an https proxy, so you need to just use http, since cloud9 proxy won't accept your self signed certificate. | 0 | false | 1 | 4,983 |
2017-07-09 15:20:51.687 | CMake's find packages finds nonexisting python library | FindPythonLibs.cmake is somehow finding Python versions that don't exist/were uninstalled.
When I run find_package(PythonLibs 3 REQUIRED) CMake properly finds my Python3.6 installation and adds its include path, but then I get the error
No rule to make target 'C:/Users/ultim/Anaconda2/libs/python27.lib', needed by 'mi... | Since the "REQUIRED" option to find_package() is not working, you can be explicit about which Python library using CMake options with cache variables:
cmake -DPYTHON_INCLUDE_DIR=C:\Python36\include -DPYTHON_LIBRARY=C:\Python36\libs\python36.lib .. | 0 | false | 1 | 4,984 |
2017-07-10 14:46:22.527 | Apache Airflow Continous Integration Workflow and Dependency management | I'm thinking of starting to use Apache Airflow for a project and am wondering how people manage continuous integration and dependencies with airflow. More specifically
Say I have the following set up
3 Airflow servers: dev staging and production.
I have two python DAG'S whose source code I want to keep in seperate repo... | We use docker to run the code with different dependencies and DockerOperator in airflow DAG, which can run docker containers, also on remote machines (with docker daemon already running). We actually have only one airflow server to run jobs but more machines with docker daemon running, which the airflow executors call.... | 0.995055 | false | 1 | 4,985 |
2017-07-11 17:31:38.430 | Placing a Video at Start of GUI to Transition to Main Code Kivy | I have a GUI that starts off with a video written in Kivy. That GUI is supposed to then begin loading the whole program in the background while the clip is playing, and after the clip, a window for login is supposed to come up. How do I load the whole program and at the same time load the video to play at the start of ... | i think you should first try and convert the video to an image format (gif) and then load it in the Image class in the kv file and then use clock to schedule it to load a new screen(login) after some seconds depending on the duration of the gif | 0 | false | 1 | 4,986 |
2017-07-11 19:37:38.147 | How to control odoo 10 from command line while its running in the web | I'm running ODOO 10 from source code in Eclipse on Windows 10. It's running ok in the web interface (on localhost)
I want to control the odoo via command line at the same time. Can I do so while its running in the web interface?
If so how do I invoke the odoo commands to the server? | You can try below
python ./odoo-bin -c odoo.conf
Hope this help you | 0 | false | 1 | 4,987 |
2017-07-11 20:09:16.870 | Python Flask Wtforms File Field full path | When you make a file field with WTForms in Flask, it only returns the filename. Does anyone know how to get it to return the full path of the file? | The file was uploaded from the user, the browser gets it and keeps it on the sky, so you can save it with a path. That's why you can't get its full path.
If an apple flies in the sky, how do you know which apple tree he comes from? | 0 | false | 1 | 4,988 |
2017-07-11 20:31:22.623 | Bazel has no definition for py_proto_library | I'm getting the following error when trying to run
$ bazel build object_detection/...
And I'm getting ~20 of the same error (1 for each time it attempts to build that). I think it's something with the way I need to configure bazel to recognize the py_proto_library, but I don't know where, or how I would do this.
/src/g... | Are you using load in the BUILD file you're building?
load("@protobuf//:protobuf.bzl", "py_proto_library")?
The error seems to indicate the symbol py_proto_library isn't loaded into skylark. | 0 | false | 1 | 4,989 |
2017-07-11 22:01:16.840 | How to configure Django Rest Framework + React | I have an application backend in Django-rest-framework, and I have a reactjs app.
How can I do to they work together ?
For development I open 2 terminals and run them separately. There is some way to make them work together ?
Also to deploy it to production I have no idea how I can do that.
I tried to look for some g... | For dev:
You can run both of them on two different shells. By default, your django rest api will be at 127.0.0.1:8000 and React will at 127.0.0.1:8081. I do not think there will be any issues for the two to communicate via the fetch api. Just make sure you have ALLOWED_HOSTS=['127.0.0.1'] in your django's settings file... | 0 | false | 1 | 4,990 |
2017-07-12 09:27:30.737 | Enum Module with AWS Lambda Python 2.7, Deployed with Travis CI | I have an AWS Lambda handler in Python 2.7 that is deployed from Travis CI. However, when I try running the function I received an error from AWS saying that it cannot import the enum module (enum34). Is there a simple way to resolve this? Should Travis CI include the virtual environment that Python is running in? ... | Solved it. I was installing the Python modules into a subdirectory of my project root, rather than in the project root itself.
Essentially was doing this:
pip install -r requirements.txt ./virtualenv/
when I should have been doing this:
pip install -r requirements.txt ./ | 1.2 | true | 1 | 4,991 |
2017-07-12 14:24:27.557 | is the Matlab radon() function a "circular" radon transform? | I am trying to translate some matlab code to python. In the matlab code, I have a radon transform function. I start with a 146x146 image, feed it into the radon() function, and get a 211x90 image. When I feed the same image into my python radon() function, I get a 146x90 image. The documentation for the python radon ()... | Matlab's radon() function is not circular. This was the problem. Although the output image sizes do still differ, I am getting essentially the result I want. | 0 | false | 1 | 4,992 |
2017-07-13 04:43:46.947 | How to send custom header (metadata) with Python gRPC? | I want to know how to send custom header (or metadata) using Python gRPC. I looked into documents and I couldn't find anything. | If you metadata has one key/value you can only use list(eg: [(key, value)]) ,If you metadata has Mult k/v you should use list(eg: [(key1, value1), (key2,value2)]) or tuple(eg: ((key1, value1), (key2,value2)) | 0 | false | 1 | 4,993 |
2017-07-13 18:17:46.553 | Django Local Environment Settings | i started a new project in Django but local environment settings come from the previous project.
So how can i reset local environment settings?
Thank you.. | Started a new project. And you replaced the settings.py from another project? If so just update your database and install the required packages with pip. To update the database: python manage.py makemigrations and then python manage.py migrate. | 0 | false | 1 | 4,994 |
2017-07-14 14:05:59.067 | Histogram bins size to equal 1 day - pyplot | I have this list of delivery times in days for cars that are 0 years old. The list contains nearly 20,000 delivery days with many days being repeated. My question is how do i get the histogram to show bin sizes as 1 day. I have set the bin size to the amount of unique delivery days there by:
len(set(list))
but when i... | As you pointed out, len(set(list)) is the number of unique values for the "delivery days" variable. This is not the same thing as the bin size; it's the number of distinct bins. I would use "bin size" to describe the number of items in one bin; "bin count" would be a better name for the number of bins.
If you want to g... | 0 | false | 1 | 4,995 |
2017-07-14 21:17:39.433 | Sending string via socket qpython3 android (client) to python2.7 linux (server) | Someone know how can I send string by socket qpython3 android (client) to python2.7 linux (server)?
For python2.7 linux (server) ok, I know, but I dont know how create the client with qpython3 android.
Someone Know?
TKS | It's your loopback address this wont work
HOST = '127.0.0.1'
Instead that use true ip address on network for your host and make sure port of 5000 on server is open already | 0 | false | 1 | 4,996 |
2017-07-17 12:37:42.180 | how to use PYTHONPATH for independent python application | Can anyone let me know how to set PYTHONPATH?
Do we need to set it in the environment variables (is it system specific) or we can independently set the PYTHONPATH and use it to run any independent python application?
i need to pick the module from a package available in directory which is different from the directory ... | I assume you are using Linux
Before executing your application u can metion pythonpath=path && execution script
Other elegant way is using virtualenv. Where u can have diff packages for each application.
Before exection say workon env and then deactivate
Python3 has virtualenv by default | 0.201295 | false | 1 | 4,997 |
2017-07-18 02:39:09.010 | Python URL Request under corporate proxy | I'm writing this application where the user can perform a web search to obtain some information from a particular website.
Everything works well except when I'm connected to the Internet via Proxy (it's a corporate proxy).
The thing is, it works sometimes.
By sometimes I mean that if it stops working, all I have to do ... | Check if there is any proxy setting in chrome | 0 | false | 1 | 4,998 |
2017-07-18 10:00:20.813 | SWT folder '..\framework\x86' does not exist. Please set ANDROID_SWT to point to the folder containing swt.jar for your platform | i try to run my android test script by "monkeyrunner cameraTest.py"
but it can't work, the cmd show me this
SWT folder '..\framework\x86' does not exist.
Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
anyone know how to deal with this?thanks | In addition to @ohbo's solution, copying AdbWinApi.dll, AdbWinUsbApi.dll into framework folder solved my problem. | 0 | false | 1 | 4,999 |
2017-07-18 22:12:17.190 | Read different streams separately | I need to open a multi-channel audio file (two or more microphones) and record the audio of each of them on a different file. With PyAudio I know how to open a multi-channel file (open method) and stop when 1.5 seconds of silence are recorded, but eventually I end up with a single (multi-channel) file. I would like to ... | My solution is not very elegant, but it does work. Open separate streams with the appropriate input_device_index for each.
stream1 = audio.open(input_device_index = 1 ...)
stream2 = audio.open(input_device_index = 2 ...) | 0.386912 | false | 1 | 5,000 |
2017-07-19 18:37:20.533 | Python Pandas - Dataframe column - Convert FY in format '2015/2016' to '15/16' | I have a column in my dataframe (call it 'FY') which has financial year values in the format: 2015/2016 or 2016/2017.
I want to convert the whole column so it says 15/16 or 16/17 etc instead.
I presume you somehow only take the 3rd, 4th and 5th character from the string, as well as the 8th and 9th, but haven't got a cl... | If you have a string you can always just choose parts of it by writing:
foo = 'abcdefg'
foo2 = foo[2:4]
print foo2
then the output would be:
cd | 0.081452 | false | 1 | 5,001 |
2017-07-20 14:57:17.750 | freezing the "tensorflow object detection api pet detector" graph | I've followed the pet detector tutorial, i have exported the model using "export_inference_graph.py".
However when I try to freeze the graph using the provided "freeze_graph.py" but now sure what --output_node_names to use.
Does anyone know which I should use, or more importantly how I find out what to use for when I t... | To find what to use for output_node_names, just checkout the graph.pbtxt file. In this case it was Softmax | 0 | false | 1 | 5,002 |
2017-07-21 22:02:44.383 | Convert datetime into number of hours? | I have a datetime stamp (e.g. time(6,30)) which would return 06:30:00.
I was wondering how I could then convert this into 6.5 hrs.
Kind regards | Assuming that you mean 6.5 hours of elapsed time, that would be a timedelta. The time object is for time-of-day, as on a 24-hour clock. These are different concepts, and shouldn't be mixed.
You should also not think of time-of-day as "time elapsed since midnight", as some days include daylight saving time transitions... | 0.201295 | false | 1 | 5,003 |
2017-07-22 04:48:48.083 | How can I install all my python 2 packages for python 3? | I installed Anaconda with Python 2.7 and then later installed the Python 3.6 kernel. I have lots of Python 2 packages and I don't want to have to manually install all of the packages for Python 3. Has anyone written, or does anyone know how to write, a bash script that will go through all my Python 2 packages and just ... | In your Python 2 pip, run pip freeze > requirements.txt. This will write all your installed packages to a text file.
Then, using your Python 3 pip (perhaps pip3), run pip install -r /path/to/requirements.txt. This will install all of the packages as listed in the requirements.txt file. | 1.2 | true | 1 | 5,004 |
2017-07-24 11:13:14.230 | Write a wrapper to expose existing REST APIs as SOAP web services? | I have existing REST APIs, written using Django Rest Framework and now due to some client requirements I have to expose some of them as SOAP web services.
I want to know how to go about writing a wrapper in python so that I can expose some of my REST APIs as SOAP web services. OR should I make SOAP web services separa... | Lets Discuss both the Approaches and their pros and cons
Seperate SOAP Service
Reusing Same Code - if you are sure the code changes will not impact the two code flow ,it is good to go.
Extension of Features - if you are sure that new feature extension will not impact other parts it is again best to go.
Scalablity - ... | 0 | false | 1 | 5,005 |
2017-07-24 13:29:15.150 | When To Use A View Vs. A New Project | This is a non-specific question about best practice in Django. Also note when I say "app" I'm referring to Django's definition of apps within a project.
How should you go about deciding when to use a new view and when to create an entirely new app? In theory, you can have a simple webapp running entirely on one views.p... | It totally depends on your application.
If you are an only developer working on project .
It is advisable to write one view for each web page or event.
If you have multiple developers in your house you can split the view if you want to make a part of it reusable or something like that.
Again its all about how your team... | 1.2 | true | 1 | 5,006 |
2017-07-24 13:39:48.503 | Tensorflow: combining two tensors with dimension X into one tensor with dimension X+1 | I am doing some sentiment analysis with Tensorflow, but there is a problem I can't solve:
I have one tensor (input) shaped as [?, 38] [batch_size, max_word_length] and one (prediction) shaped as [?, 3] [batch_size, predicted_label].
My goal is to combine both tensors into a single tensor with the shape of [?, 38, 3].
T... | This is impossible. You have tensor, which contains batch_size * max_word_length
elements and tensor which contains batch_size * predicted_label elements. Hence there are
batch_size * (max_word_length + predicted_label)
elements. And now you want to create new tensor [batch_size, max_word_length, predicted_label] w... | 1.2 | true | 1 | 5,007 |
2017-07-25 08:53:36.257 | How to autofill child produts in treeview, when parent product (BOM) is selected in odoo? | I'm writing a module in odoo. I hve defined some parent products and their child products. I want to do, when I'm selecting a parent product from many2one field, this parent product's childs will open in Treeview lines automatically. This tree view field is defined as one2many field.
I used onchange_parent_product fun... | to use one2many field you need many2one field in products
to this new model that you create. to make it easy use many2many
field it's better that way and use onchange to fill it.
just search for product that have parent_id equals to the selected
product and add this record to your many2many field.
if you need to keep... | 0 | false | 1 | 5,008 |
2017-07-25 09:43:59.520 | Variable Resolution with Tensorflow for Superresolution | I am using tensorflow to scale images by a factor of 2. But since the tensor (batchsize, height, width, channels) determines the resolution it only accepts images of only one resolution for inference and training.
For other resolutions I have to modify the code and retrain the model. Is it possible to make my code reso... | Okay so here is what I did:
input and output tensors now have the shape (batchsize, None, None, channels)
The training images now have to be resized outside of the network.
Important reminder: training images have to be the same size since they are in batches! Images in one batch have to have the same size. When infere... | 1.2 | true | 1 | 5,009 |
2017-07-25 17:55:37.773 | python matplotlib save graph as data file | I want to create a python script that zooms in and out of matplotlib graphs along the horizontal axis. My plot is a set of horizontal bar graphs.
I also want to make that able to take any generic matplotlib graph.
I do not want to just load an image and zoom into that, I want to zoom into the graph along the horizonta... | @Cedric's Answer.
Additionally, if you get the pickle error for pickling functions, add the 'dill' library to your pickling script. You just need to import it at the start, it will do the rest. | 0.545705 | false | 1 | 5,010 |
2017-07-25 19:04:12.620 | Where is python on mac? (osx el capitan) | I'm trying to download pygame on my computer and use it, but from what I've seen, I need the 32-bit python not the 64-bit one I have. however, I cannot find where the file is on my computer to delete it. I looked through all of my files with the name of 'python' but nothing has shown up about the 64-bit pre installed p... | Type
which python
on terminal. | 0 | false | 1 | 5,011 |
2017-07-26 19:26:01.650 | Downloading python 3 on windows | I am currently trying to figure out how to set up using python 3 on my machine (Windows 10 pro 64-bit), but I keep getting stuck.
I used the Python 3.6 downloader to install python, but whenever I try to use Command Prompt it keeps saying "'python' is not recognized as an internal or external command, operable program ... | Thanks everyone, I ended up uninstalling and then re-downloading python, and selecting the button that says "add to environment variables." Previously, I typed the addition to Path myself, so I thought it might make a difference if I included it in the installation process instead. Then, I completely restarted my compu... | 0 | false | 3 | 5,012 |
2017-07-26 19:26:01.650 | Downloading python 3 on windows | I am currently trying to figure out how to set up using python 3 on my machine (Windows 10 pro 64-bit), but I keep getting stuck.
I used the Python 3.6 downloader to install python, but whenever I try to use Command Prompt it keeps saying "'python' is not recognized as an internal or external command, operable program ... | Why are you using command prompt? I just use the python shell that comes with IDLE. It’s much simpler.
If you have to use command prompt for some reason, you’re problem is probably that you need to type in python3. Plain python is what you use for using Python 2 in the command prompt. | 0 | false | 3 | 5,012 |
2017-07-26 19:26:01.650 | Downloading python 3 on windows | I am currently trying to figure out how to set up using python 3 on my machine (Windows 10 pro 64-bit), but I keep getting stuck.
I used the Python 3.6 downloader to install python, but whenever I try to use Command Prompt it keeps saying "'python' is not recognized as an internal or external command, operable program ... | In environmental variables under path, add your python path... you said you already so please ensure is their comma separation between previous path..
And once added save environment variables tab. And close all command prompt then open it.
Then only command prompt will refresh with your python config..
Main thing, ... | 0.135221 | false | 3 | 5,012 |
2017-07-27 03:50:16.467 | python 3.6.2 not giving me option to create or run files or anything of the sort | I know some basics of Java and C++, and am looking to learn Python
I am trying to develop some random stuffs to get a good feel of how it works, but i can only make 1 line scripts that run every time i press enter to go to the next line.
I've seen tutorial videos where they can just open up files from a menu and type ... | To exit out of the "interactive mode" that you mentioned (the included REPL shell in IDLE) and write a script, you will have to create a new file by either selecting the option from the top navigation bar or pressing Control-N. As for running the file, there's also that option on the navigation bar; alternatively, you ... | 0 | false | 1 | 5,013 |
2017-07-27 12:34:57.267 | Python asyncio training exercises | Feeling the need to learn how to use asyncio, but cannot think of applicable problem (or problem set) that can help me learn this new technique.
Could you suggest a problem that can help me understand and learn asyncio usage in practice?
In another words: can you suggest me an example of some abstract problem or applic... | Any I/O bound task would be a good case for asyncio. In the context of the network programming - any application, that requires simultaneous handling of the thousands of connections. Web server, web crawler, chat backend, MMO game backend, torrent tracker and so on. Keep in mind, though, that you should go async all th... | 1.2 | true | 1 | 5,014 |
2017-07-27 23:12:17.600 | 32bit pyodbc for 32bit python (3.6) works with microsoft's 64 bit odbc driver. Why? | What I can observe:
I am using windows 7 64bit My code (establish an odbc connection with
a SQL server on the network, simple reading operations only) is
written in python 3.6.2 32bit
I pip installed pyodbc, so I assume that was 32bit as well.
I downloaded and installed the 64bit "Microsoft® ODBC Driver 13.1 for SQL... | A 32bit application can NOT invoke a 64bit dll, so python 32bit can not talk to a 64bit driver for sure.
msodbc driver for sql server is in essence a dll file: msodbcsql13.dll
I just found out (which is not even mentioned by microsoft) that "odbc for sql server 13.1 x64" will install a 64bit msodbcsql13.dll in system32... | 1.2 | true | 1 | 5,015 |
2017-07-28 08:18:53.760 | avoiding a pyinstaller .exe disapear of the screen without closing | I'm working on a GUI that I would like to put at the disposal for my colleagues to use under the form of .exe , after some researchs i found pyinstaller as "freezer" which work great after downloading the github version , but my issue is even if the .exe is created when i run it , it show up for less than a second on t... | Another option would be to manually open a CMD window, navigate to, and then execute your exe, rather than letting the packaged application spawn the instance. | 0 | false | 1 | 5,016 |
2017-07-28 18:36:34.007 | Does the Python Virtual Machine (CPython) convert bytecode into machine language? | I'm a little confused as to how the PVM gets the cpu to carry out the bytecode instructions. I had read somewhere on StackOverflow that it doesn't convert byte-code to machine code, (alas, I can't find the thread now).
Does it already have tons of pre-compiled machine instructions hard-coded that it runs/chooses one o... | If you mean Standard Python (CPython) by Python, then no! The byte-code (.pyc or .pyo files) are just a binary version of your code line by line, and is interpreted at run-time. But if you use pypy, yes! It has a JIT Compiler and it runs your byte-codeas like Java dn .NET (CLR). | 0.386912 | false | 1 | 5,017 |
2017-07-29 05:45:41.230 | Changing database structure of Django in server | When we work with Django in local environment, we change the structure of the Data Base using Command Prompt through migration.
But for using Django in server, i don't now how can i apply such changes? How can i type commands to change Data Base structure? Is it a good way to upload site files every time that i do som... | The whole point of migrations is that you run them on both your local database and in production, to keep them in sync. | 0.386912 | false | 1 | 5,018 |
2017-07-31 01:51:17.923 | How to get html using python when the site requires authenticasion? | I can get html of a web site using lxml module if authentication is not required. However, when it required, how do I input 'User Name' and 'Password' using python? | It very much depends on the method of authentication used. If it's HTTP Basic Auth, then you should be able to pass those headers along with the request. If it's using a web page-based login, you'll need to automate that request and pass back the cookies or whatever session token is used with the next request. | 1.2 | true | 1 | 5,019 |
2017-07-31 07:44:52.137 | how to use scrapy-redis pipeline? | I am using scrapy-redis now, and I am ok with it, and I am success to crawl in different computer by using the same redis server.
But I don't understand how to use the scrapy-redis pipeline properly.
In my understanding, I think I need another script than the spiders to deal with the item in the redis pipeline list, th... | The pipeline is a different script, yes. In the settings file you can enable the pipeline. A pipeline can be used to store the crawled results in any database you want. | 0 | false | 1 | 5,020 |
2017-08-01 12:05:06.467 | Implementing Policy iteration methods in Open AI Gym | I am currently reading "Reinforcement Learning" from Sutton & Barto and I am attempting to write some of the methods myself.
Policy iteration is the one I am currently working on. I am trying to use OpenAI Gym for a simple problem, such as CartPole or continuous mountain car.
However, for policy iteration, I need both... | No, OpenAI Gym environments will not provide you with the information in that form. In order to collect that information you will need to explore the environment via sampling: i.e. selecting actions and receiving observations and rewards. With these samples you can estimate them.
One basic way to approximate these valu... | 0.386912 | false | 1 | 5,021 |
2017-08-01 18:12:40.107 | Python: What is the "size" parameter in Gensim Word2vec model class | I have been struggling to understand the use of size parameter in the gensim.models.Word2Vec
From the Gensim documentation, size is the dimensionality of the vector. Now, as far as my knowledge goes, word2vec creates a vector of the probability of closeness with the other words in the sentence for each word. So, suppos... | size is, as you note, the dimensionality of the vector.
Word2Vec needs large, varied text examples to create its 'dense' embedding vectors per word. (It's the competition between many contrasting examples during training which allows the word-vectors to move to positions that have interesting distances and spatial-rela... | 1.2 | true | 2 | 5,022 |
2017-08-01 18:12:40.107 | Python: What is the "size" parameter in Gensim Word2vec model class | I have been struggling to understand the use of size parameter in the gensim.models.Word2Vec
From the Gensim documentation, size is the dimensionality of the vector. Now, as far as my knowledge goes, word2vec creates a vector of the probability of closeness with the other words in the sentence for each word. So, suppos... | It's equal to vector_size.
To make it easy, it's a uniform size of dimension of the output vectors for each word that you trained with word2vec. | 0 | false | 2 | 5,022 |
2017-08-01 20:08:49.300 | Caffe LMDB train and val.txt | During the process of making a lmdb file,we are supposed to make a train.txt and val.txt file,i have already made a train.txt file which consists of the image name space its corresponding label.Ex image1.JPG 0.
Now that i have to make the val.txt file im confused as to how do i give it its corresponding values since it... | You are confusing test and validation sets. A validation set is a set where you know the labels (like in training) but you do not train on it. The validation set is used to make sure you are not overfitting the training data.
At test time you may present your model with unlabeled data and make prediction for these samp... | 1.2 | true | 1 | 5,023 |
2017-08-02 08:47:46.137 | xlwings VBA function settings edit | I would like to use xlwings wit the OPTIMIZED_CONNECTION set to TRUE. I would like to modify the setting but somehow cannot find where to do it. I change the _xlwings.conf sheet name in my workbook but this seems to have no effect. Also I cannot find these settings in VBA as I think I am supposed to under what is calle... | The add-in replaces the need for the settings in VBA in newer versions.
One can debug the xlam module using "xlwings" as a password.
This enabled me to realize that the OPTIMIZED_CONNECTION parameter is now set through "USE UDF SERVER" keyword in the xlwings.conf sheet (which does work) | 0 | false | 1 | 5,024 |
2017-08-03 05:31:03.520 | how to change 1 to 0 and 0 to 1 in binary(Python) | all.
I want to change 1 to 0 and 0 to 1 in binary.
for example,
if binary is 00000110.
I want to change it to 11111001.
how to do that in python3?
Best regards. | You can use the ~ operator. If A = 00100, ~A = 11011.
If A is a string version of a decimal, convert it into int first. | 0 | false | 1 | 5,025 |
2017-08-03 14:38:55.097 | Unable to install cherrypy on an offline server | Good Morning everyone, I am attempting to install CherryPy on a server without internet access. It has windows Server 2012. I can RDP to it, which is how i have attempted to install it. The server has Python 2.7 installed.
What I have tried (unsuccessfully):
RDP to the server, pip install cherrypy from command line (is... | Ended up copying my entire lib\site-packages folder to the remote server, placed where it would have been on my old server, and it worked fine.
TL:DR copy you %Python_home%/lib/site-packages folder to your remote machine and it might work. need to have the same version of python installed. In my case it was 2.7. | -0.386912 | false | 1 | 5,026 |
2017-08-04 04:16:14.013 | Weird behavior by db.cursor.execute() | So I was trying learn sqlite and how to use it from Ipython notebook, and I have a sqlite object named db.
I am executing this command:
sel=" " " SELECT * FROM candidates;" " "
c=db.cursor().execute(sel)
and when I do this in the next cell:
c.fetchall()
it does print out all the rows but when I run this same comman... | That is because .fetchall() makes your cursor(c) pointing the last row.
if you want to select your DB again, you should .execute again.
Or, if you just want to use your fetched data again, you can store c.fetchall() into your variable. | 1.2 | true | 1 | 5,027 |
2017-08-04 07:43:58.720 | Django SQL get query returns a hashmap, how to access the value? | I am using django 1.10 and python 3.6.1
when executing
get_or_none(models.Character, pk=0), with SQL's get method, the query returns a hashmap i.e.: <Character: example>
How can I extract the value example?
I tried .values(), I tried iterating, I tried .Character
nothing seems to work, and I can't find a solution in t... | @Daniel Roseman helped me understand the answer.
SOLVED:
What I was getting from the query was the model of character, so I couldn't have accessed it thru result.Character but thru result.Field_Inside_Of_Character | 0 | false | 1 | 5,028 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.