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
53,480,409
I have installed the bloomberg Python API and set the `BLPAPI_ROOT` to the VC++ folder. However, when I import `blpapi`, I got the following error. How to get rid of these errors? Thank you very much. ``` import blpapi Traceback (most recent call last): File "C:\Users\user\AppData\Roaming\Python\Python36\site-pa...
2018/11/26
[ "https://Stackoverflow.com/questions/53480409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9087866/" ]
I did 2 things to solve an issue similar to that: 1- I installed Microsoft Visual Studio with the following components * C++/CLI Support * VC++ 2015.3 v14.00 (v140) toolset for desktop * Visual C++ MFC for x86 and x64 * Visual C++ ATL for x86 and x64 2- I manually copied the .dll files in C++API\lib (blpapi3\_32.dll...
Please set BLPAPI\_ROOT environment variable to the location where the blpapi C++ SDK is located.
53,480,409
I have installed the bloomberg Python API and set the `BLPAPI_ROOT` to the VC++ folder. However, when I import `blpapi`, I got the following error. How to get rid of these errors? Thank you very much. ``` import blpapi Traceback (most recent call last): File "C:\Users\user\AppData\Roaming\Python\Python36\site-pa...
2018/11/26
[ "https://Stackoverflow.com/questions/53480409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9087866/" ]
I did 2 things to solve an issue similar to that: 1- I installed Microsoft Visual Studio with the following components * C++/CLI Support * VC++ 2015.3 v14.00 (v140) toolset for desktop * Visual C++ MFC for x86 and x64 * Visual C++ ATL for x86 and x64 2- I manually copied the .dll files in C++API\lib (blpapi3\_32.dll...
An alternative option is to use `conda`, as discussed [here](https://stackoverflow.com/questions/43322486/conda-install-blpapi) and [here](https://stackoverflow.com/questions/41725483/anaconda-install-blpapi-in-environment). If you use `conda` you don't need to worry about downloading the C++ SDK and properly configur...
1,440,233
I want to intercept and transform some automated emails into a more readable format. I believe this is possible using VBA, but I would prefer to manipulate the text with Python. Can I create an ironpython client-side script to pre-process certain emails? EDIT: I believe this can be done with outlook rules. In Outlook ...
2009/09/17
[ "https://Stackoverflow.com/questions/1440233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20712/" ]
I can only offer you a pointer. Years ago, I used a Bayesian spam filter with Outlook. It was written in Python, and provided an Outlook plug-in that would filter incoming mail. The name of the software was [*SpamBayes*](http://spambayes.sourceforge.net/), and the project is still online. As it is open source, you will...
There is an answer here: [how to trigger a python script in outlook using rules?](https://stackoverflow.com/questions/13265861/how-to-trigger-a-python-script-in-outlook-using-rules) that may help you. You can make a simple VBA script to trigger the python script.
1,440,233
I want to intercept and transform some automated emails into a more readable format. I believe this is possible using VBA, but I would prefer to manipulate the text with Python. Can I create an ironpython client-side script to pre-process certain emails? EDIT: I believe this can be done with outlook rules. In Outlook ...
2009/09/17
[ "https://Stackoverflow.com/questions/1440233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20712/" ]
You can reference the outlook object model here: <http://msdn.microsoft.com/en-us/library/ms268893.aspx> Connect to outlook through COM, you'll need [pywin32](http://sourceforge.net/projects/pywin32/). There's no python reference that I know of, but you can reference the sample scripts and 'translate' to python. It's...
There is an answer here: [how to trigger a python script in outlook using rules?](https://stackoverflow.com/questions/13265861/how-to-trigger-a-python-script-in-outlook-using-rules) that may help you. You can make a simple VBA script to trigger the python script.
1,440,233
I want to intercept and transform some automated emails into a more readable format. I believe this is possible using VBA, but I would prefer to manipulate the text with Python. Can I create an ironpython client-side script to pre-process certain emails? EDIT: I believe this can be done with outlook rules. In Outlook ...
2009/09/17
[ "https://Stackoverflow.com/questions/1440233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20712/" ]
This is a work in progress, but I've figured out part of the answer with the help of the other posts. Here are the instructions for re-writing specified emails by running a script. I'm using Outlook 2007. 1. Download and install [pywin32](http://sourceforge.net/projects/pywin32/) 2. Download and install [ExchangeCdo.e...
There is an answer here: [how to trigger a python script in outlook using rules?](https://stackoverflow.com/questions/13265861/how-to-trigger-a-python-script-in-outlook-using-rules) that may help you. You can make a simple VBA script to trigger the python script.
63,896,043
I am creating my first django app in django 3.1.1. There are video tutorials for old django versions and they don't always work... I want to create HTML pages for both home and about sections. I have already written some HTML files, but the ``` def home(request): return render(request, 'home.html') ``` doesn't w...
2020/09/15
[ "https://Stackoverflow.com/questions/63896043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14224948/" ]
Alright, found it myself with your inspiration :) Thank you, @Selcuk and @m.arthur. Thanks for contributing @Mahmoud Ishag too :) The answer lies in there I mustn't have created this app as a project and there was a short string missing in templates: ``` TEMPLATES = [ { 'BACKEND': 'django.template.backend...
Django look for the template in folder called `templates` you need to create that folder inside your app folder and put `home.html` inside it.
43,413,914
I recently found out that scrapy is a great library for scraping so i tried to install scrapy on my machine, but when i tried to do `pip install scrapy` it installed for a while and threw me this error.. ``` error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub...
2017/04/14
[ "https://Stackoverflow.com/questions/43413914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7618421/" ]
Scrapy docs now recommend using [Conda](https://conda.io/miniconda) for Windows installation: <https://doc.scrapy.org/en/latest/intro/install.html#windows>
This error comes up when you don't have Windows SDK installed. When you used Build Tools or Visual Studio to compile, often you need both the C++ compiler and Windows SDK. In the Build Tools, there is a "Custom" installation option which enables you to select to install both C++ and Windows SDK. In Visual Studio, you ...
43,989,929
I'm trying to use `pytesseract` for the first time. I'm also not so confortable with python. I've created a new folder called `python_test` on my desktop. I'm on Mac. In this folder I have a `test.png` file and a py script : ``` from pytesseract import image_to_string from PIL import Image print image_to_string(Image...
2017/05/15
[ "https://Stackoverflow.com/questions/43989929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6273496/" ]
I got the same error as you, installing the `tesseract` package fixed it (or `tesseract-ocr` on debian/ubuntu). It contains the native code library used under the hood by `pytesseract`. An image load error seems like an odd way for the library to fail if the underlying native library is not installed, but there you go...
I also had the error when I used first time `image_to_string`. You have to change the the following line in the `pytesseract.py` file. ``` tesseract_cmd = 'C:\\Tesseract-OCR\\tesseract' ``` *Note: I'm using windows.*
4,942,305
The Windows console has been Unicode aware for at least a decade and perhaps as far back as Windows NT. However for some reason the major cross-platform scripting languages including Perl and Python only ever output various 8-bit encodings, requiring much trouble to work around. Perl gives a "wide character in print" w...
2011/02/09
[ "https://Stackoverflow.com/questions/4942305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527702/" ]
Michael Kaplan has series of blog posts about the `cmd` console and Unicode that may be informative (while not really answering your question): * [Conventional wisdom is retarded, aka What the @#%&\* is \_O\_U16TEXT?](https://web.archive.org/web/20130101094000/http://www.siao2.com/2008/03/18/8306597.aspx) * [Anyone wh...
Are you sure your script would output Unicode on some other platform correctly? "wide character in print" warning makes me very suspicious. I recommend to look over this [overview](http://en.wikibooks.org/wiki/Perl_Programming/Unicode_UTF-8)
4,942,305
The Windows console has been Unicode aware for at least a decade and perhaps as far back as Windows NT. However for some reason the major cross-platform scripting languages including Perl and Python only ever output various 8-bit encodings, requiring much trouble to work around. Perl gives a "wide character in print" w...
2011/02/09
[ "https://Stackoverflow.com/questions/4942305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527702/" ]
I have to unask many of your questions. Did you know that * Windows uses UTF-16 for its APIs, but still defaults to the various "fun" legacy encodings (e.g. Windows-1252, Windows-1251) in userspace, including file names, differently for the many localisations of Windows? * you need to encode output, and picking the a...
[Unicode issues in Perl](http://www.i-programmer.info/programming/other-languages/1973-unicode-issues-in-perl.html) covers how the Win32 console works with Perl and the transcoding that happens behind the scene from ANSI to Unicode;albeit not just a Perl issue but affects other languages
4,942,305
The Windows console has been Unicode aware for at least a decade and perhaps as far back as Windows NT. However for some reason the major cross-platform scripting languages including Perl and Python only ever output various 8-bit encodings, requiring much trouble to work around. Perl gives a "wide character in print" w...
2011/02/09
[ "https://Stackoverflow.com/questions/4942305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527702/" ]
Michael Kaplan has series of blog posts about the `cmd` console and Unicode that may be informative (while not really answering your question): * [Conventional wisdom is retarded, aka What the @#%&\* is \_O\_U16TEXT?](https://web.archive.org/web/20130101094000/http://www.siao2.com/2008/03/18/8306597.aspx) * [Anyone wh...
For Perl to fully support Windows in this way, every call to `print` `printf` `say` `warn` and `die` has to be modified. * Is this Windows? * Which version of Windows? Perl still mostly works on Windows 95 * Is this going to the console, or somewhere else. Once you have that determined, you then have to use a complet...
4,942,305
The Windows console has been Unicode aware for at least a decade and perhaps as far back as Windows NT. However for some reason the major cross-platform scripting languages including Perl and Python only ever output various 8-bit encodings, requiring much trouble to work around. Perl gives a "wide character in print" w...
2011/02/09
[ "https://Stackoverflow.com/questions/4942305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527702/" ]
Michael Kaplan has series of blog posts about the `cmd` console and Unicode that may be informative (while not really answering your question): * [Conventional wisdom is retarded, aka What the @#%&\* is \_O\_U16TEXT?](https://web.archive.org/web/20130101094000/http://www.siao2.com/2008/03/18/8306597.aspx) * [Anyone wh...
> > Why on earth after all these years do > they not just simply call the Win32 -W > APIs that output UTF-16 Unicode > instead of forcing everything through > the ANSI/codepage bottleneck? > > > Because Perl and Python aren't Windows programs. They're Unix programs that happen to have been mostly ported to Win...
4,942,305
The Windows console has been Unicode aware for at least a decade and perhaps as far back as Windows NT. However for some reason the major cross-platform scripting languages including Perl and Python only ever output various 8-bit encodings, requiring much trouble to work around. Perl gives a "wide character in print" w...
2011/02/09
[ "https://Stackoverflow.com/questions/4942305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527702/" ]
The main problem seems to be that it is not possible to use Unicode on Windows using only the standard C library and no platform-dependent or third-party extensions. The languages you mentioned originate from Unix platforms, whose method of implementing Unicode blends well with C (they use normal `char*` strings, the C...
Small contribution to the discussion - I am running Czech localized Windows XP, which almost everywhere uses CP1250 code page. Funny thing with console is though that it still uses legacy DOS 852 code page. I was able to make very simple perl script that prints utf8 encoded data to console using: ``` binmode STDOUT,...
4,942,305
The Windows console has been Unicode aware for at least a decade and perhaps as far back as Windows NT. However for some reason the major cross-platform scripting languages including Perl and Python only ever output various 8-bit encodings, requiring much trouble to work around. Perl gives a "wide character in print" w...
2011/02/09
[ "https://Stackoverflow.com/questions/4942305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527702/" ]
Are you sure your script would output Unicode on some other platform correctly? "wide character in print" warning makes me very suspicious. I recommend to look over this [overview](http://en.wikibooks.org/wiki/Perl_Programming/Unicode_UTF-8)
[Unicode issues in Perl](http://www.i-programmer.info/programming/other-languages/1973-unicode-issues-in-perl.html) covers how the Win32 console works with Perl and the transcoding that happens behind the scene from ANSI to Unicode;albeit not just a Perl issue but affects other languages
4,942,305
The Windows console has been Unicode aware for at least a decade and perhaps as far back as Windows NT. However for some reason the major cross-platform scripting languages including Perl and Python only ever output various 8-bit encodings, requiring much trouble to work around. Perl gives a "wide character in print" w...
2011/02/09
[ "https://Stackoverflow.com/questions/4942305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527702/" ]
> > Why on earth after all these years do > they not just simply call the Win32 -W > APIs that output UTF-16 Unicode > instead of forcing everything through > the ANSI/codepage bottleneck? > > > Because Perl and Python aren't Windows programs. They're Unix programs that happen to have been mostly ported to Win...
[Unicode issues in Perl](http://www.i-programmer.info/programming/other-languages/1973-unicode-issues-in-perl.html) covers how the Win32 console works with Perl and the transcoding that happens behind the scene from ANSI to Unicode;albeit not just a Perl issue but affects other languages
4,942,305
The Windows console has been Unicode aware for at least a decade and perhaps as far back as Windows NT. However for some reason the major cross-platform scripting languages including Perl and Python only ever output various 8-bit encodings, requiring much trouble to work around. Perl gives a "wide character in print" w...
2011/02/09
[ "https://Stackoverflow.com/questions/4942305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527702/" ]
The main problem seems to be that it is not possible to use Unicode on Windows using only the standard C library and no platform-dependent or third-party extensions. The languages you mentioned originate from Unix platforms, whose method of implementing Unicode blends well with C (they use normal `char*` strings, the C...
For Python, the relevant issue in tracker is <http://bugs.python.org/issue1602> (as said in comments). Note that it is open for 7 years. I tried to publish a working solution (based on information in the issue) as a Python package: <https://github.com/Drekin/win-unicode-console>, <https://pypi.python.org/pypi/win_unico...
4,942,305
The Windows console has been Unicode aware for at least a decade and perhaps as far back as Windows NT. However for some reason the major cross-platform scripting languages including Perl and Python only ever output various 8-bit encodings, requiring much trouble to work around. Perl gives a "wide character in print" w...
2011/02/09
[ "https://Stackoverflow.com/questions/4942305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527702/" ]
The main problem seems to be that it is not possible to use Unicode on Windows using only the standard C library and no platform-dependent or third-party extensions. The languages you mentioned originate from Unix platforms, whose method of implementing Unicode blends well with C (they use normal `char*` strings, the C...
> > Why on earth after all these years do > they not just simply call the Win32 -W > APIs that output UTF-16 Unicode > instead of forcing everything through > the ANSI/codepage bottleneck? > > > Because Perl and Python aren't Windows programs. They're Unix programs that happen to have been mostly ported to Win...
4,942,305
The Windows console has been Unicode aware for at least a decade and perhaps as far back as Windows NT. However for some reason the major cross-platform scripting languages including Perl and Python only ever output various 8-bit encodings, requiring much trouble to work around. Perl gives a "wide character in print" w...
2011/02/09
[ "https://Stackoverflow.com/questions/4942305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527702/" ]
The main problem seems to be that it is not possible to use Unicode on Windows using only the standard C library and no platform-dependent or third-party extensions. The languages you mentioned originate from Unix platforms, whose method of implementing Unicode blends well with C (they use normal `char*` strings, the C...
Michael Kaplan has series of blog posts about the `cmd` console and Unicode that may be informative (while not really answering your question): * [Conventional wisdom is retarded, aka What the @#%&\* is \_O\_U16TEXT?](https://web.archive.org/web/20130101094000/http://www.siao2.com/2008/03/18/8306597.aspx) * [Anyone wh...
10,474,942
I try my very best to never use php and as thus i am not well versed in it I am having a issue that I don't understand at all here I have tried a number of things including not including the table reference in /config changing to from localhost as mysql host ect. It will probably be something exceedingly obvious but i...
2012/05/06
[ "https://Stackoverflow.com/questions/10474942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1231175/" ]
Access denied means you're using the wrong username/password, and/or the account you're accessing has not be properly created in MySQL. What does a `show grants for [email protected]` show? if you created the account as `username@machinename` and MySQL is unable to do a reverse DNS lookup to change your IP back to m...
Check the following: 1) You entered the right database hostname (this is not always localhost), username and password? 2) The user has permissions on database. Let me know if you don't know how to check.
38,570,698
This is my first time using raw sockets (yes, I need to use them as I must modify a field inside a network header) and all the documentation or tutorials I read describe a solution to sniff packets but that is not exactly what I need. I need to create a script which intercepts the packet, process it and sends it furthe...
2016/07/25
[ "https://Stackoverflow.com/questions/38570698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6104632/" ]
Your description seems to be different from what your title suggest. My understanding is that you want to receive, modify and possibly drop incoming network packets. And this is to be done on Linux. In that case I suggest you use a netfilter prerouting hook, which will make things a lot simpler (and likely more stable)...
I suppose that your Linux box is configured as a router (not a bridge). The packet will pass through your Linux because you have enabled **IP Forwarding**. So there are two solution: ***Solution 1:*** Disable **IP Forwarding** and then receive the packet from one interface and do the appropriate task (forwarding to ...
35,393,672
python 2.7: Count how many numbers are entered by the user. I can't figure out how to count the raw\_input... here's what I have so far: ``` while True: datum = raw_input('enter a number: ') if datum == 'done': break count = 0 for line in datum: ...
2016/02/14
[ "https://Stackoverflow.com/questions/35393672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5925494/" ]
The reason for the endless loop is dead simple. You are *never* updating the value of `$terms` inside the loop body, which is being used in loop condition. So the loop body is executed either zero times or infinitely. --- The fix seems to replace the `while` with the `if`, because you handle the parent via a recur...
The misunderstanding lies in the scope of the `$terms` variable. This variable has scope that is local to the function call it exists in. The loop ``` while ($terms > 0) { //do some logic $parent_id = $terms->parent; $this->parent_category_has_fiance($parent_id); } ``` is referencing the `$terms` variabl...
55,758,883
When i tried to install openCV using pip3 install opencv-python i got this error Could not find a version that satisfies the requirement opencv-python (from versions: ) No matching distribution found for opencv-python i have tried upgrading pip using ``` pip install --upgrade pip ``` and ``` curl https://bootst...
2019/04/19
[ "https://Stackoverflow.com/questions/55758883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8923850/" ]
Here is the code corrected, there are. Which are to be deleted I also added `math.round` to get rounded result: ```html <html> <head> <script> function calcAmount() { let userAmount = document.getElementById("amount").value; let level1 = 351; if (userAmount <= level1) { document...
Three things: * You had `.` in your ID selectors, these shouldn't be there (they should be `#` but only in a `querySelector` method). * You were calculating `calcLevel1` straightaway, which meant it was `0 * 7 / 100` which is `0`. * You needed to calculate `calcLevel1` with `amount.value`, which means you can remove `...
47,041,267
I'm currently trying to program and learn python, while making a project with the raspberry pi zero w. So far I'm just trying to get it to start recording video using picamera in python, as well as stream that video so I can monitor what the output is on my phone. However as it currently stands it only starts recording...
2017/10/31
[ "https://Stackoverflow.com/questions/47041267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8863714/" ]
> > However as it currently stands it only starts recording video once I connect to it via some sort of streaming program. What I'd like for it to do is start recording the video at the start of the program and be able to connect to it whenever I'd like to monitor it. > > > This is due to the following line of cod...
KillerXtreme, This should be the code you were looking for 5 years ago (namely, you can connect and reconnect to this over and over with no hiccups)! Hope this helps somebody! ``` import socket import picamera from threading import Thread def stop_recording(cam): try: cam.stop_recording() except Excep...
42,630,281
I have a python script which is supposed to loop through all files in a directory and set the date of each file to the current time. It seems to have no effect, i.e. the Date column in the file explorer shows no change. I see the code looping through all files, it just appears that the call to `utime` has no effect. T...
2017/03/06
[ "https://Stackoverflow.com/questions/42630281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1978617/" ]
You've got three issues: 1. You're using the file name, not the full path, when `touch`ing, so all the `touch`ing occurs in the working directory 2. You're stripping the file extension too, so the touched files lack extensions 3. You're touching files to which you have an open file handle, and on Windows, on Python 2....
os.utime does work on Windows but probably you are looking at the wrong date in explorer. os.utime does not modify the creation date (which it looks like is what is used in the date field in explorer). It does update the "Date modified" field. You can see this if you right click on the category bar and check the "date ...
46,742,947
I have a folder full of files that need to be modified in order to extract the true file in it's real format. I need to remove a certain number of bytes from BOTH the beginning and end of the file in order to extract the data I am looking for. How can I do this in python? * I need this to work recursively on an e...
2017/10/14
[ "https://Stackoverflow.com/questions/46742947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7838844/" ]
1. Recursive iteration over files [os.walk](https://docs.python.org/3/library/os.html#os.walk) 2. Change position in file: [f.seek](https://docs.python.org/3/tutorial/inputoutput.html?highlight=seek) 3. Get file size: [os.stat](https://docs.python.org/3/library/os.html#os.stat) 4. Remove data from current position to e...
Your question is pretty badly constructed, but as this is somewhat advanced stuff I'll provide you with a code. You can now use os.walk() to recursively traverse directory you want and apply my slicefile() function. This code does the following: 1. After checking validity of start and end arguments it creates a memo...
14,416,914
I am new to bash and shell but I am running a debian install and I am trying to make a script which can find a date in the past without having to install any additional packages. From tutorials I have got to this stage: ``` #!/bin/sh # # BACKUP DB TO S3 # # VARIABLES TYPE="DATABASE" DAYS="30" # GET CURRENT DATETIME ...
2013/01/19
[ "https://Stackoverflow.com/questions/14416914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1738522/" ]
Try ``` date -d '30 days ago' ``` should do on debian.
You could modify the python script instead -- that way you would not depend on particular implementation of `date`
14,416,914
I am new to bash and shell but I am running a debian install and I am trying to make a script which can find a date in the past without having to install any additional packages. From tutorials I have got to this stage: ``` #!/bin/sh # # BACKUP DB TO S3 # # VARIABLES TYPE="DATABASE" DAYS="30" # GET CURRENT DATETIME ...
2013/01/19
[ "https://Stackoverflow.com/questions/14416914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1738522/" ]
Try ``` date -d '30 days ago' ``` should do on debian.
You can use the following script: ``` #!/bin/bash days=73 while [ ${days} -ge 0 ]; do date -d "${days} days ago" +'%F' days=$((days-1)) done ```
14,416,914
I am new to bash and shell but I am running a debian install and I am trying to make a script which can find a date in the past without having to install any additional packages. From tutorials I have got to this stage: ``` #!/bin/sh # # BACKUP DB TO S3 # # VARIABLES TYPE="DATABASE" DAYS="30" # GET CURRENT DATETIME ...
2013/01/19
[ "https://Stackoverflow.com/questions/14416914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1738522/" ]
Try doing this : ``` #!/bin/sh # # BACKUP DB TO S3 # # VARIABLES TYPE="DATABASE" DAYS="30" # GET CURRENT DATETIME CURRENTDATE="$(date +%Y%m%d%H%M%S)" # GENERATE PAST DATE FROM DAYS CONSTANT OLDERDATE="$(date "+%Y%m%d%H%M%S" -d "$DAYS days ago")" # CALL PYTHON SCRIPT WITH OLDERDATE ARGUMENT python script.py "$OLDER...
You could modify the python script instead -- that way you would not depend on particular implementation of `date`
14,416,914
I am new to bash and shell but I am running a debian install and I am trying to make a script which can find a date in the past without having to install any additional packages. From tutorials I have got to this stage: ``` #!/bin/sh # # BACKUP DB TO S3 # # VARIABLES TYPE="DATABASE" DAYS="30" # GET CURRENT DATETIME ...
2013/01/19
[ "https://Stackoverflow.com/questions/14416914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1738522/" ]
Try doing this : ``` #!/bin/sh # # BACKUP DB TO S3 # # VARIABLES TYPE="DATABASE" DAYS="30" # GET CURRENT DATETIME CURRENTDATE="$(date +%Y%m%d%H%M%S)" # GENERATE PAST DATE FROM DAYS CONSTANT OLDERDATE="$(date "+%Y%m%d%H%M%S" -d "$DAYS days ago")" # CALL PYTHON SCRIPT WITH OLDERDATE ARGUMENT python script.py "$OLDER...
You can use the following script: ``` #!/bin/bash days=73 while [ ${days} -ge 0 ]; do date -d "${days} days ago" +'%F' days=$((days-1)) done ```
14,416,914
I am new to bash and shell but I am running a debian install and I am trying to make a script which can find a date in the past without having to install any additional packages. From tutorials I have got to this stage: ``` #!/bin/sh # # BACKUP DB TO S3 # # VARIABLES TYPE="DATABASE" DAYS="30" # GET CURRENT DATETIME ...
2013/01/19
[ "https://Stackoverflow.com/questions/14416914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1738522/" ]
You can use the following script: ``` #!/bin/bash days=73 while [ ${days} -ge 0 ]; do date -d "${days} days ago" +'%F' days=$((days-1)) done ```
You could modify the python script instead -- that way you would not depend on particular implementation of `date`
35,642,131
I am training a problem such that my output (y) could be more than one class. For example, the SVM could say, this input vector is class 1, but it could also say, this input vector is classes 1 AND 5. This is not the same as a multiclass SVM problem, where the output could be ONE of multiple classes. My output could be...
2016/02/26
[ "https://Stackoverflow.com/questions/35642131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5983697/" ]
Yes, use a for loop using the `length` method. You can get the letter at a given position using [CharSequence#charAt](https://docs.oracle.com/javase/8/docs/api/java/lang/CharSequence.html#charAt-int-). `String` implements `CharSequence` so you can do `a.charAt(i);`
I like the `charAtSequence()` suggested by pyb, my own first instinct however would be char array. I think they both will work the same though. I didint want to write the whole code for you, but I hope this helps... ``` char [] _a = a.toCharArray(); // note 1 //do the same for the b string here... else if (a....
35,642,131
I am training a problem such that my output (y) could be more than one class. For example, the SVM could say, this input vector is class 1, but it could also say, this input vector is classes 1 AND 5. This is not the same as a multiclass SVM problem, where the output could be ONE of multiple classes. My output could be...
2016/02/26
[ "https://Stackoverflow.com/questions/35642131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5983697/" ]
Can't you simply use the [String compareTo()](http://www.tutorialspoint.com/java/java_string_compareto.htm) function? It seems to do exactly what you need: ``` String a = "cats"; String b = "cuts"; String result = ""; if(a.length() != b.length()){ result = "BYE"; } else if (a.compareTo(b) <= 0){ result = "TRUE...
Yes, use a for loop using the `length` method. You can get the letter at a given position using [CharSequence#charAt](https://docs.oracle.com/javase/8/docs/api/java/lang/CharSequence.html#charAt-int-). `String` implements `CharSequence` so you can do `a.charAt(i);`
35,642,131
I am training a problem such that my output (y) could be more than one class. For example, the SVM could say, this input vector is class 1, but it could also say, this input vector is classes 1 AND 5. This is not the same as a multiclass SVM problem, where the output could be ONE of multiple classes. My output could be...
2016/02/26
[ "https://Stackoverflow.com/questions/35642131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5983697/" ]
You have to loop the individual chars in your strings ``` for (int x = 0; x < a.length(); x++) { if (a.charAt (x) > b.charAt (x)) { System.out.println ("First String is BIGGER"); // maybe break now ? } } ```
I like the `charAtSequence()` suggested by pyb, my own first instinct however would be char array. I think they both will work the same though. I didint want to write the whole code for you, but I hope this helps... ``` char [] _a = a.toCharArray(); // note 1 //do the same for the b string here... else if (a....
35,642,131
I am training a problem such that my output (y) could be more than one class. For example, the SVM could say, this input vector is class 1, but it could also say, this input vector is classes 1 AND 5. This is not the same as a multiclass SVM problem, where the output could be ONE of multiple classes. My output could be...
2016/02/26
[ "https://Stackoverflow.com/questions/35642131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5983697/" ]
Can't you simply use the [String compareTo()](http://www.tutorialspoint.com/java/java_string_compareto.htm) function? It seems to do exactly what you need: ``` String a = "cats"; String b = "cuts"; String result = ""; if(a.length() != b.length()){ result = "BYE"; } else if (a.compareTo(b) <= 0){ result = "TRUE...
I like the `charAtSequence()` suggested by pyb, my own first instinct however would be char array. I think they both will work the same though. I didint want to write the whole code for you, but I hope this helps... ``` char [] _a = a.toCharArray(); // note 1 //do the same for the b string here... else if (a....
35,642,131
I am training a problem such that my output (y) could be more than one class. For example, the SVM could say, this input vector is class 1, but it could also say, this input vector is classes 1 AND 5. This is not the same as a multiclass SVM problem, where the output could be ONE of multiple classes. My output could be...
2016/02/26
[ "https://Stackoverflow.com/questions/35642131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5983697/" ]
Can't you simply use the [String compareTo()](http://www.tutorialspoint.com/java/java_string_compareto.htm) function? It seems to do exactly what you need: ``` String a = "cats"; String b = "cuts"; String result = ""; if(a.length() != b.length()){ result = "BYE"; } else if (a.compareTo(b) <= 0){ result = "TRUE...
You have to loop the individual chars in your strings ``` for (int x = 0; x < a.length(); x++) { if (a.charAt (x) > b.charAt (x)) { System.out.println ("First String is BIGGER"); // maybe break now ? } } ```
73,739,734
I am currently able to use quick fix to auto import python functions from external typings such as `from typing import List`. [Python module quick fix import](https://i.stack.imgur.com/q3m7F.png) However, I am unable to detect local functions/classes for import. For example: If I have the data class `SampleDataClass`...
2022/09/16
[ "https://Stackoverflow.com/questions/73739734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20008915/" ]
Turns out the latest versions for Pylance broke quick-fix imports and any extra path settings for VSCode. When I rolled back the version to `v2022.8.50` it now works again. I filed an issue here: <https://github.com/microsoft/pylance-release/issues/3353>.
According to an [issue](https://github.com/microsoft/pylance-release/issues/3324) I raised in github earlier, the developer gave a reply. Custom code will **not** be added to the autocomplete list at this time (unless it has already been imported). This is done to prevent users from having too many custom modules, whi...
72,631,459
I am trying to test an API that sends long-running jobs to a queue processed by Celery workers.. I am using RabbitMQ running in a Docker container as the message queue. However, when sending a message to the queue I get the following error: `Error: [Errno 111] Connection refused` Steps to reproduce: * Start RabbitMQ ...
2022/06/15
[ "https://Stackoverflow.com/questions/72631459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6131554/" ]
You can't connect to rabbitmq on `localhost`; it's not running in the same container as your Python app. Since you've exposed rabbit on your host, you can connect to it using the address of your host. One way of doing that is starting the app container like this: ``` docker run -it -p 8000:8000 --add-host host.docker....
Update **tasks.py** ``` import time celery = Celery('tasks', broker='amqp://user:pass@host:port//') @celery.task(name='update_db') def update_db(num: int) -> None: time.sleep(30) return ```
6,999,522
I'm looking to generate, from a large Python codebase, a summary of heap usage or memory allocations over the course of a function's run. I'm familiar with [heapy](http://guppy-pe.sourceforge.net/), and it's served me well for taking "snapshots" of the heap at particular points in my code, but I've found it difficult ...
2011/08/09
[ "https://Stackoverflow.com/questions/6999522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/104200/" ]
I would use [`sys.settrace`](http://docs.python.org/library/sys.html#sys.settrace) at program startup to register a custom tracer function. The custom\_trace\_function will be called for each line of code. Then you can use that function to store information gathered by heapy or [meliae](https://launchpad.net/meliae) in...
You might be interested by [memory\_profiler](https://pypi.org/project/memory-profiler/).
35,667,105
I am an amateur python programer with 2 months of experience. I am trying to write a GUI to-do list through tkinter. The actual placement of the buttons are not important. I can play around with those after. I need some help with displaying the appended item to the list. In the program, it updates well on the digit, bu...
2016/02/27
[ "https://Stackoverflow.com/questions/35667105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5989438/" ]
Just replace the package name with your package name / applicationId You do not need to publish the app first, just keep the same applicationId when you eventually upload the app. For example <https://play.google.com/store/apps/details?id=com.instagram.android> market://details?id=com.instagram.android app/build.g...
No need to update the app. First you can do it with a temp link with dynamic process. After your app publish, you can replace that link with playstore link.
35,667,105
I am an amateur python programer with 2 months of experience. I am trying to write a GUI to-do list through tkinter. The actual placement of the buttons are not important. I can play around with those after. I need some help with displaying the appended item to the list. In the program, it updates well on the digit, bu...
2016/02/27
[ "https://Stackoverflow.com/questions/35667105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5989438/" ]
**You can use this code** ``` "https://play.google.com/store/apps/details?id="+getApplicationContext().getPackageName() ``` work for me fine I hope help this
No need to update the app. First you can do it with a temp link with dynamic process. After your app publish, you can replace that link with playstore link.
35,667,105
I am an amateur python programer with 2 months of experience. I am trying to write a GUI to-do list through tkinter. The actual placement of the buttons are not important. I can play around with those after. I need some help with displaying the appended item to the list. In the program, it updates well on the digit, bu...
2016/02/27
[ "https://Stackoverflow.com/questions/35667105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5989438/" ]
**You can use this code** ``` "https://play.google.com/store/apps/details?id="+getApplicationContext().getPackageName() ``` work for me fine I hope help this
Just replace the package name with your package name / applicationId You do not need to publish the app first, just keep the same applicationId when you eventually upload the app. For example <https://play.google.com/store/apps/details?id=com.instagram.android> market://details?id=com.instagram.android app/build.g...
67,883,300
I want to print all Thursdays between these date ranges ``` from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date ``` What is the best pythonic way to do that?
2021/06/08
[ "https://Stackoverflow.com/questions/67883300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/778942/" ]
using your `sdate.weekday() # returns int between 0 (mon) and 6 (sun)`: ``` sdate = ... while sdate < edate: if sdate.weekday() != 3: # not thursday sdate += timedelta(days=1) continue # It is thursday print(sdate) sdate += timedelta(days=7) # next week ```
```py import datetime import calendar def weekday_count(start, end, day): start_date = datetime.datetime.strptime(start, '%d/%m/%Y') end_date = datetime.datetime.strptime(end, '%d/%m/%Y') day_count = [] for i in range((end_date - start_date).days): if calendar.day_name[(start_date + dateti...
67,883,300
I want to print all Thursdays between these date ranges ``` from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date ``` What is the best pythonic way to do that?
2021/06/08
[ "https://Stackoverflow.com/questions/67883300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/778942/" ]
Compute the number of days till thursday from the start date : ``` days_to_thursday = (3 - sdate.weekday()) % 7 ``` Compute the number of thursdays inbetween both dates: ``` week_diff = ((edate - sdate).days - days_to_thursday ) // 7 ``` Get all thursdays in the date range: ``` thursdays = [sdate + timedelta(day...
```py import datetime import calendar def weekday_count(start, end, day): start_date = datetime.datetime.strptime(start, '%d/%m/%Y') end_date = datetime.datetime.strptime(end, '%d/%m/%Y') day_count = [] for i in range((end_date - start_date).days): if calendar.day_name[(start_date + dateti...
67,883,300
I want to print all Thursdays between these date ranges ``` from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date ``` What is the best pythonic way to do that?
2021/06/08
[ "https://Stackoverflow.com/questions/67883300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/778942/" ]
Most people are iterating through every day which is a waste. Also might be helpful to delay calculating the thursdays until you actually need them. For this you could use a generator. ```py def get_days(start, day_index, end=None): # set the start as the next valid day start += timedelta(days=(day_index - sta...
```py import datetime import calendar def weekday_count(start, end, day): start_date = datetime.datetime.strptime(start, '%d/%m/%Y') end_date = datetime.datetime.strptime(end, '%d/%m/%Y') day_count = [] for i in range((end_date - start_date).days): if calendar.day_name[(start_date + dateti...
67,883,300
I want to print all Thursdays between these date ranges ``` from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date ``` What is the best pythonic way to do that?
2021/06/08
[ "https://Stackoverflow.com/questions/67883300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/778942/" ]
using your `sdate.weekday() # returns int between 0 (mon) and 6 (sun)`: ``` sdate = ... while sdate < edate: if sdate.weekday() != 3: # not thursday sdate += timedelta(days=1) continue # It is thursday print(sdate) sdate += timedelta(days=7) # next week ```
Simple solution: ```py from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date delta = edate - sdate for day in range(delta.days + 1): day_obj = sdate + timedelta(days=day) if day_obj.weekday() == 3: # Thursday print(day_obj) # 2015-01-0...
67,883,300
I want to print all Thursdays between these date ranges ``` from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date ``` What is the best pythonic way to do that?
2021/06/08
[ "https://Stackoverflow.com/questions/67883300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/778942/" ]
using your `sdate.weekday() # returns int between 0 (mon) and 6 (sun)`: ``` sdate = ... while sdate < edate: if sdate.weekday() != 3: # not thursday sdate += timedelta(days=1) continue # It is thursday print(sdate) sdate += timedelta(days=7) # next week ```
You could try a list comprehension to get the Thursdays between the 2 dates. This code actually outputs the dates as formatted strings but you can get actual dates by dropping the `strftime`. ```py from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date th...
67,883,300
I want to print all Thursdays between these date ranges ``` from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date ``` What is the best pythonic way to do that?
2021/06/08
[ "https://Stackoverflow.com/questions/67883300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/778942/" ]
Compute the number of days till thursday from the start date : ``` days_to_thursday = (3 - sdate.weekday()) % 7 ``` Compute the number of thursdays inbetween both dates: ``` week_diff = ((edate - sdate).days - days_to_thursday ) // 7 ``` Get all thursdays in the date range: ``` thursdays = [sdate + timedelta(day...
Simple solution: ```py from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date delta = edate - sdate for day in range(delta.days + 1): day_obj = sdate + timedelta(days=day) if day_obj.weekday() == 3: # Thursday print(day_obj) # 2015-01-0...
67,883,300
I want to print all Thursdays between these date ranges ``` from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date ``` What is the best pythonic way to do that?
2021/06/08
[ "https://Stackoverflow.com/questions/67883300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/778942/" ]
Most people are iterating through every day which is a waste. Also might be helpful to delay calculating the thursdays until you actually need them. For this you could use a generator. ```py def get_days(start, day_index, end=None): # set the start as the next valid day start += timedelta(days=(day_index - sta...
Simple solution: ```py from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date delta = edate - sdate for day in range(delta.days + 1): day_obj = sdate + timedelta(days=day) if day_obj.weekday() == 3: # Thursday print(day_obj) # 2015-01-0...
67,883,300
I want to print all Thursdays between these date ranges ``` from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date ``` What is the best pythonic way to do that?
2021/06/08
[ "https://Stackoverflow.com/questions/67883300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/778942/" ]
Compute the number of days till thursday from the start date : ``` days_to_thursday = (3 - sdate.weekday()) % 7 ``` Compute the number of thursdays inbetween both dates: ``` week_diff = ((edate - sdate).days - days_to_thursday ) // 7 ``` Get all thursdays in the date range: ``` thursdays = [sdate + timedelta(day...
You could try a list comprehension to get the Thursdays between the 2 dates. This code actually outputs the dates as formatted strings but you can get actual dates by dropping the `strftime`. ```py from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date th...
67,883,300
I want to print all Thursdays between these date ranges ``` from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date ``` What is the best pythonic way to do that?
2021/06/08
[ "https://Stackoverflow.com/questions/67883300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/778942/" ]
Most people are iterating through every day which is a waste. Also might be helpful to delay calculating the thursdays until you actually need them. For this you could use a generator. ```py def get_days(start, day_index, end=None): # set the start as the next valid day start += timedelta(days=(day_index - sta...
You could try a list comprehension to get the Thursdays between the 2 dates. This code actually outputs the dates as formatted strings but you can get actual dates by dropping the `strftime`. ```py from datetime import date, timedelta sdate = date(2015, 1, 7) # start date edate = date(2015, 12, 31) # end date th...
64,867,992
I am using beautiful soup (BS4) with python to scrape data from the yellowpages through the waybackmachine/webarchive. I am able to return the Business name and phone number easily but when I attempt to retrieve the website url for the business, I only return the entire div tag. ``` #Import Dependencies from splinter ...
2020/11/17
[ "https://Stackoverflow.com/questions/64867992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10930010/" ]
Simple and very neat solution: *(added my comments so you can understand what I did)* ``` start = int(input('enter the starting range: ')) end = int(input('enter the ending range: ')) #create an empty list numbers = [] for d in range(start,end): if d % 2 != 0: #if number is odd, add it to the list num...
Print the message before the loop then the numbers during the loop: ```py start = int(input('enter the starting range:')) end = int(input('enter the ending range:')) # use end='' to avoid printing a newline at the end print(f'The odd numbers between {start} & {end} is: ', end='') should_print_comma = False for d in ra...
64,867,992
I am using beautiful soup (BS4) with python to scrape data from the yellowpages through the waybackmachine/webarchive. I am able to return the Business name and phone number easily but when I attempt to retrieve the website url for the business, I only return the entire div tag. ``` #Import Dependencies from splinter ...
2020/11/17
[ "https://Stackoverflow.com/questions/64867992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10930010/" ]
Using list comprehension you could make it more shorter ```py start=int(input('enter the starting range:')) end=int(input('enter the ending range:')) # New lines numbers = ", ".join([str(i) for i in range(start, end) if i % 2 != 0]) print(f"The odds numbers between {start} and {end} are:", numbers) ```
Print the message before the loop then the numbers during the loop: ```py start = int(input('enter the starting range:')) end = int(input('enter the ending range:')) # use end='' to avoid printing a newline at the end print(f'The odd numbers between {start} & {end} is: ', end='') should_print_comma = False for d in ra...
64,867,992
I am using beautiful soup (BS4) with python to scrape data from the yellowpages through the waybackmachine/webarchive. I am able to return the Business name and phone number easily but when I attempt to retrieve the website url for the business, I only return the entire div tag. ``` #Import Dependencies from splinter ...
2020/11/17
[ "https://Stackoverflow.com/questions/64867992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10930010/" ]
Simple and very neat solution: *(added my comments so you can understand what I did)* ``` start = int(input('enter the starting range: ')) end = int(input('enter the ending range: ')) #create an empty list numbers = [] for d in range(start,end): if d % 2 != 0: #if number is odd, add it to the list num...
```py start=int(input('enter the starting range:')) end=int(input('enter the ending range:')) s = "" for d in range(start,end): if d%2!=0: s += str(d) + ", "; print('The odd numbers between',start,'&',end,'is:',s) ``` You should probably put it in a function but that's just a preference.
64,867,992
I am using beautiful soup (BS4) with python to scrape data from the yellowpages through the waybackmachine/webarchive. I am able to return the Business name and phone number easily but when I attempt to retrieve the website url for the business, I only return the entire div tag. ``` #Import Dependencies from splinter ...
2020/11/17
[ "https://Stackoverflow.com/questions/64867992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10930010/" ]
Using list comprehension you could make it more shorter ```py start=int(input('enter the starting range:')) end=int(input('enter the ending range:')) # New lines numbers = ", ".join([str(i) for i in range(start, end) if i % 2 != 0]) print(f"The odds numbers between {start} and {end} are:", numbers) ```
```py start=int(input('enter the starting range:')) end=int(input('enter the ending range:')) s = "" for d in range(start,end): if d%2!=0: s += str(d) + ", "; print('The odd numbers between',start,'&',end,'is:',s) ``` You should probably put it in a function but that's just a preference.
43,247,031
I have a file named phone.py which give me output as(in terminal): ``` +911234567890 +910123321423 ``` There can be more number of outputs. Another file named email.py which produces(in terminal): ``` [email protected] [email protected] ``` or more. And I have a JSON File whose structure is as follows: ``` {"One":"Some d...
2017/04/06
[ "https://Stackoverflow.com/questions/43247031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6541394/" ]
You can obtain the stdout from `subprocess.run` simply by `resp.stdout`, where `resp` is the returned object.
As already mentioned by Rishav, you need to assign the output to a variable & then use it to get the related attributes. [Sample usage](https://docs.python.org/3/library/subprocess.html#subprocess.CompletedProcess) - ``` >>> import subprocess >>> out = subprocess.run(["ls", "-l", "/dev/null"], stdout=subprocess.PIPE)...
47,227,445
Im trying to make a while loop in python, but the loop keeps looping infinitely. Here's what I have so far: ``` def pvalue(num): ans = '' while num > 0: if 1 <= num <= 9: ans += 'B' num -= 1 if num >= 10: ans += 'A' num -= 10 return ans ``` ...
2017/11/10
[ "https://Stackoverflow.com/questions/47227445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5016648/" ]
You may want to learn about the [break statement](https://docs.python.org/3/reference/simple_stmts.html#break). As for your code: ``` def pvalue(num): ans = '' while num > 0: if num >= 10: ans += 'A' num -= 10 else: ans += 'B' num -= 1 return...
Use the break statement to get out of the loop. ``` def pvalue(num): ans = '' while num > 0: if 1 <= num <= 9: ans += 'B' num -= 1 if num >= 10: ans += 'A' num -= 10 if num<=0: break return ans ```
68,262,836
I'm trying to use an array of dictionaries in python as arguement to a custom dash component and use it as array of objects in python : ``` audioList_py = [ { "name": "random", "singer": 'waveGAN\'s music', "cover": 'link_1.jpg', "musicSrc": 'link_1.mp3', },...
2021/07/05
[ "https://Stackoverflow.com/questions/68262836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13652942/" ]
Make sure you run `npm run build` after you make a change to your custom React component. With those proptypes you shouldn't get that error. If I remove the `audios` proptype I can reproduce that error. Besides that you pass a value to the `audios` property: ``` music_component.MusicComponent(audios=audioList_py) ``...
Issue fixed, I should run : `npm run build:backends` to generate the Python, R and Julia class files for the components, but instead I was executing `npm run build:js` and this command just generate the JavaScript bundle (which didn't know about the new props). And set the audios property in the component to be like s...
61,976,835
I'm new to python and I've seen two different ways to initialize an empty list: ``` # way 1 empty_list = [] # way 2 other_empty_list = list() ``` Is there a "preferred" way to do it? Maybe one way is better for certain conditions than the other? Thank you
2020/05/23
[ "https://Stackoverflow.com/questions/61976835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8947060/" ]
No there isn't much of a difference, you can neglect the difference and pick anyone of them As most of the times it's a one or limited execution any difference in execution won't have much impact
Using parenthesis will create a tuple, which is immutable. A list uses brackets.
61,976,835
I'm new to python and I've seen two different ways to initialize an empty list: ``` # way 1 empty_list = [] # way 2 other_empty_list = list() ``` Is there a "preferred" way to do it? Maybe one way is better for certain conditions than the other? Thank you
2020/05/23
[ "https://Stackoverflow.com/questions/61976835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8947060/" ]
`[]` is the pythonic way. `[]` way is quite efficient as you can see from below image. [![enter image description here](https://i.stack.imgur.com/UySz6.png)](https://i.stack.imgur.com/UySz6.png)
Using parenthesis will create a tuple, which is immutable. A list uses brackets.
61,976,835
I'm new to python and I've seen two different ways to initialize an empty list: ``` # way 1 empty_list = [] # way 2 other_empty_list = list() ``` Is there a "preferred" way to do it? Maybe one way is better for certain conditions than the other? Thank you
2020/05/23
[ "https://Stackoverflow.com/questions/61976835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8947060/" ]
`[]` is the pythonic way. `[]` way is quite efficient as you can see from below image. [![enter image description here](https://i.stack.imgur.com/UySz6.png)](https://i.stack.imgur.com/UySz6.png)
No there isn't much of a difference, you can neglect the difference and pick anyone of them As most of the times it's a one or limited execution any difference in execution won't have much impact
66,062,702
I am trying to install the jupyterlab plotly extension with this command (according to <https://plotly.com/python/getting-started/>): **jupyter labextension install [email protected]** I get this error: ``` An error occured. ValueError: Please install Node.js and npm before continuing installation. You may be...
2021/02/05
[ "https://Stackoverflow.com/questions/66062702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11904988/" ]
No, you have **not** installed node.js. You installed some kind of Python bindings for node ([python-nodejs](https://pypi.org/project/nodejs/), with its [repository](https://github.com/markfinger/python-nodejs) archived by the author) which itself require an actual nodejs. It is dangerous to install stuff from PyPI wit...
First install nodejs latest version `conda install nodejs -c conda-forge --repodata-fn=repodata.json` Then install jupyterlab extension: `jupyter labextension install [email protected]` Then **RESTART JUPYTER LAB**
36,227,688
I have a python program that I usually run as a part of a package: ``` python -m mymod.client ``` in order to deal with relative imports inside "mymod/client.py." How do I run this with pdb - the python debugger. The following does not work: ``` python -m pdb mymod.client ``` It yields the error: ``` Error: mymo...
2016/03/25
[ "https://Stackoverflow.com/questions/36227688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3357587/" ]
I *think* I have a solution. Run it like this: ``` python -m pdb path/mymod/client.py arg1 arg2 ``` that will run it as a script, but will not treat it as a package. At the top of client.py, the first line should be: ``` import mymod ``` That will get the package itself loaded. I am still playing with this,...
This is not possible. Though unstated in documentation, Python will not parse two modules via the `-m` command line option.
56,798,328
I am just beginning to use python and could use some help! I was working on a rock, paper, scissors game and I wanted to add a restart option once either the human or computer reaches 3 wins. I have looked all over for some answers but from all the other code I looked at seemed way out of my league or extremely diffe...
2019/06/27
[ "https://Stackoverflow.com/questions/56798328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11606900/" ]
You already have the loop to do this. So when you want to "restart" your game, you really just need to reset the scores. Starting from your win/lose conditions: ``` #Win/lose restart point? if player_score == 3: print("-----You Win!-----") replay = input("Would you like to play again?") if replay.upper()....
You need to get user input in the `while` loop and set `keep_playing` accordingly. ``` while keep_playing == True: cmove = random.choice(moves) pmove = input("What is your move: Rock, Paper, or Scissors?") print("The computer chose", cmove) #Logic to game if cmove == pmove: print("It's ...
57,420,171
I am writing a batch file that lies somewhere in a folder structure alongside a .venv folder (python virtual environment) ``` KnownFolderName | +-- 1.0.0 | | | +-- .venv | | | +-- folder | | | +-- folder | | | +-- batch.bat | +-- 1.0.1 | +-- .venv | +-- folder | +-- ba...
2019/08/08
[ "https://Stackoverflow.com/questions/57420171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/869598/" ]
Got it. Of course as soon as I post the question the answer appears! After trying all sorts of ways to extract the string from the cwd I found that just looping backwards is the way: ``` :loop IF EXIST .venv ( cd .venv\Scripts ) ELSE ( cd .. goto loop ) ``` Then you can return to the original location with the stan...
What about the following approach which makes use of string manipulation features: ```cmd @echo off set "BATCH=%~f0" echo ABSOLUTE BATCH PATH: "%BATCH%" set "RELATIVE=%BATCH:*\KnownFolderName\=%" echo RELATIVE BATCH PATH: "%RELATIVE%" set "TEST=%BATCH%|" call set "ROOT=%%TEST:\%RELATIVE%|=%%" echo ROOT DIRECTORY PATH:...
68,708,540
I want to generate random number between 0 and 1 in **python code** but only get 2 numbers after sign . Example: ``` 0.22 0.25 0.9 ``` I have searched many sources but have not found the solution. Can you help me?
2021/08/09
[ "https://Stackoverflow.com/questions/68708540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16462598/" ]
Want this? ``` import random round(random.random(), 2) ```
Try this `print(round(random.random(), 2))`
68,708,540
I want to generate random number between 0 and 1 in **python code** but only get 2 numbers after sign . Example: ``` 0.22 0.25 0.9 ``` I have searched many sources but have not found the solution. Can you help me?
2021/08/09
[ "https://Stackoverflow.com/questions/68708540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16462598/" ]
You can use the format method in python if you want EXACTLY 2 digits after the decimal point (for example if you want 0.90): ``` import random x = random.random() print("{:.2f}".format(x)) ``` or if you are fine with numbers like 0.9: ``` import random x = random.random() print(round(x,2)) ```
Try this `print(round(random.random(), 2))`
49,544,701
I'm relatively new to python, and I am trying to build a program that can visit a website using a proxy from a list of proxies in a text file, and continue doing so with each proxy in the file until they're all used. I found some code online and tweaked it to my needs, but when I run the program, the proxies are succes...
2018/03/28
[ "https://Stackoverflow.com/questions/49544701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9566525/" ]
Your problem is with these nested loops, which don't appear to be doing what you want: ``` proxy = [] while count < 10: proxy.append(proxylist[count].strip()) count += 1 for i in proxy: Visiter(i) ``` The outer loop builds up the `proxy` list, adding one value each time un...
`while count < 10: proxy.append(proxylist[count].strip()) count += 1 for i in proxy: Visiter(i)` The for loop within the while loop means that every time you hit proxy.append you'll call Visiter for *every* item already in proxy. That might explain why you're getting multiple hits per proxy. As far as the out of ...
4,778,679
i have no way of upgrade to python 2.7 or 3.1 so i am stuck with python 2.6 on my ubuntu 10.04 machine. will i still be able to find host that supports python 2.6? is using python 2.6 still consider outdated or bad practice?
2011/01/24
[ "https://Stackoverflow.com/questions/4778679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62617/" ]
2.6 will be around for a long time. There are many machines that still run even 2.4, so you're fine.
Python3.1 is in the repositories for 10.04 ``` $ apt-cache show python3 Package: python3 Priority: optional Section: python Installed-Size: 76 Maintainer: Ubuntu Developers <[email protected]> Original-Maintainer: Matthias Klose <[email protected]> Architecture: all Source: python3-defaults Version: ...
4,778,679
i have no way of upgrade to python 2.7 or 3.1 so i am stuck with python 2.6 on my ubuntu 10.04 machine. will i still be able to find host that supports python 2.6? is using python 2.6 still consider outdated or bad practice?
2011/01/24
[ "https://Stackoverflow.com/questions/4778679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62617/" ]
2.6 will be around for a long time. There are many machines that still run even 2.4, so you're fine.
> > will i still be able to find host that > supports python 2.6? > > > Yes. No problems whatsoever. > > is using python 2.6 still consider > outdated or bad practice? > > > No, it is not. **However:** > > I have no way of upgrade to python 2.7 > > > **Yes you do.** You download the source code from...
4,778,679
i have no way of upgrade to python 2.7 or 3.1 so i am stuck with python 2.6 on my ubuntu 10.04 machine. will i still be able to find host that supports python 2.6? is using python 2.6 still consider outdated or bad practice?
2011/01/24
[ "https://Stackoverflow.com/questions/4778679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62617/" ]
Python 2.6 will probably still be around for a while, as Python 2.7 was released only a few months ago. You can always use `from __future__ import ...` to make use of some of the newer features from Python 3.x
Python3.1 is in the repositories for 10.04 ``` $ apt-cache show python3 Package: python3 Priority: optional Section: python Installed-Size: 76 Maintainer: Ubuntu Developers <[email protected]> Original-Maintainer: Matthias Klose <[email protected]> Architecture: all Source: python3-defaults Version: ...
4,778,679
i have no way of upgrade to python 2.7 or 3.1 so i am stuck with python 2.6 on my ubuntu 10.04 machine. will i still be able to find host that supports python 2.6? is using python 2.6 still consider outdated or bad practice?
2011/01/24
[ "https://Stackoverflow.com/questions/4778679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62617/" ]
Python 2.6 will probably still be around for a while, as Python 2.7 was released only a few months ago. You can always use `from __future__ import ...` to make use of some of the newer features from Python 3.x
> > will i still be able to find host that > supports python 2.6? > > > Yes. No problems whatsoever. > > is using python 2.6 still consider > outdated or bad practice? > > > No, it is not. **However:** > > I have no way of upgrade to python 2.7 > > > **Yes you do.** You download the source code from...
4,778,679
i have no way of upgrade to python 2.7 or 3.1 so i am stuck with python 2.6 on my ubuntu 10.04 machine. will i still be able to find host that supports python 2.6? is using python 2.6 still consider outdated or bad practice?
2011/01/24
[ "https://Stackoverflow.com/questions/4778679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62617/" ]
> > will i still be able to find host that > supports python 2.6? > > > Yes. No problems whatsoever. > > is using python 2.6 still consider > outdated or bad practice? > > > No, it is not. **However:** > > I have no way of upgrade to python 2.7 > > > **Yes you do.** You download the source code from...
Python3.1 is in the repositories for 10.04 ``` $ apt-cache show python3 Package: python3 Priority: optional Section: python Installed-Size: 76 Maintainer: Ubuntu Developers <[email protected]> Original-Maintainer: Matthias Klose <[email protected]> Architecture: all Source: python3-defaults Version: ...
61,804,295
I am using python to do some data cleaning and i've used the datetime module to split date time and tried to create another column with just the time. My script works but it just takes the last value of the data frame. Here is the code: ``` import datetime i = 0 for index, row in df.iterrows(): date = dateti...
2020/05/14
[ "https://Stackoverflow.com/questions/61804295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13543531/" ]
`df['minutes'] = date.minute` reassigns the entire `'minutes'` column with the scalar value `date.minute` from the last iteration. You don't need a loop, as 99% of the cases when using pandas. You can use vectorized assignment, just replace `'source_column_name'` with the name of the column with the source data. ```...
Seems like you're trying to get the time column from the datetime which is in string format. That's what I understood from your post. Could you give this a shot? ``` from datetime import datetime import pandas as pd def get_time(date_cell): dt = datetime.strptime(date_cell, "%Y-%m-%dT%H:%M:%SZ") return dateti...
66,402,926
I am new to python and I want to know how to create empty column with a specific number. Let's say I want to create 20 columns. What I tried: ``` import pandas as pd num =20 for i in range(num): df = df + pd.DataFrame(columns=['col'+str(i)]) ``` But I got the unwanted result: ``` Empty DataFrame Columns: [col...
2021/02/27
[ "https://Stackoverflow.com/questions/66402926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13230133/" ]
Assuming you wish to create an empty dataframe, the solution is to remove the for loop, and use a list comprehension for the column names: ``` import pandas as pd num =20 df = pd.DataFrame(columns=['col'+str(i) for i in range(num)]) ```
Instead of adding dataframes together, let's just create a dictionary with the mappings you'd like, and create one dataframe: ``` data = {"col" + str(i): [] for i in range(20)} df = pd.DataFrame(data) #Empty DataFrame #Columns: [col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12, col13, co...
35,328,941
In python / numpy - is there a way to build an expression containing factorials - but since in my scenario, many factorials will be duplicated or reduced, wait until I instruct the run time to compute it. Let's say `F(x) := x!` And I build an expression like `(F(6) + F(7)) / F(4)` - I can greatly accelerate this, eve...
2016/02/11
[ "https://Stackoverflow.com/questions/35328941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/127257/" ]
As @Oleg has suggested, you can do this with sympy: ``` import numpy as np import sympy as sp # preparation n = sp.symbols("n") F = sp.factorial # create the equation f = (F(n) + F(n + 1)) / F(n - 2) print(f) # => (factorial(n) + factorial(n + 1))/factorial(n - 2) # reduce it f = f.simplify() print(f)...
Maybe you could look into increasing the efficiency using table lookups if space efficiency isn't a major concern. It would greatly reduce the number of repeated calculations. The following isn't terribly efficient, but it's the basic idea. ``` cache = {1:1} def cached_factorial(n): if (n in cache): return...
34,394,578
I am using python 2.7.8. I have a website which contains text written with bullets list which is ordered list aka <**ol**> . I want to extract those text i.e ``` Coffee Tea Milk ``` My html code: ``` <!DOCTYPE html> <html> <body> <ol type="I"> <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ol> <ol type="a"> ...
2015/12/21
[ "https://Stackoverflow.com/questions/34394578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3440716/" ]
You can see why it is that beautifulsoup function does not work for your variable 'ul" by inserting this line while commenting out the line you previously had. ``` print ul """print(ul.get_text(' ', strip=True))""" ``` What is happening is that your variable ul is storing the string: 1. C99 standard guarantees uniq...
I never used the BeautifulSoup, but I do this with regular expression: ``` import re html = """<!DOCTYPE html> <html> <body> <ol type="I"> <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ol> <ol type="a"> <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ol> <ol type="1"> <li>Coffee</li> <li>Tea</li> <li>...
4,387,847
Assuming i have a class that implements several methods. We want a user to chose to which methods to run among the exisiting methods or he can decide to add any method on\_the\_fly. from example ``` class RemoveNoise(): pass ``` then methods are added as wanted ``` RemoveNoise.raw = Raw() RemoveNoise.bais =...
2010/12/08
[ "https://Stackoverflow.com/questions/4387847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535019/" ]
Functions can be added to a class at runtime. ``` class Foo(object): pass def bar(self): print 42 Foo.bar = bar Foo().bar() ```
There is no solving needed, you just do it. Here is your code, with the small changes needed: ``` class RemoveNoise(): pass RemoveNoise.raw = Raw RemoveNoise.bias = Bias def new(self): pass RemoveNoise.new=new instance = RemoveNoise() ``` It's that simple. Python is wonderful. Why on earth you would n...
4,387,847
Assuming i have a class that implements several methods. We want a user to chose to which methods to run among the exisiting methods or he can decide to add any method on\_the\_fly. from example ``` class RemoveNoise(): pass ``` then methods are added as wanted ``` RemoveNoise.raw = Raw() RemoveNoise.bais =...
2010/12/08
[ "https://Stackoverflow.com/questions/4387847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535019/" ]
Functions can be added to a class at runtime. ``` class Foo(object): pass def bar(self): print 42 Foo.bar = bar Foo().bar() ```
Well, here's some code that does what I think you're asking for -- although I'm not really sure what you meant by "**save**" when you wrote "I want to save the class\_with\_the\_methods\_used". Also note that using an `exec` statement on user input can be *extremely* dangerous if it comes from an untrusted source. ``...
4,387,847
Assuming i have a class that implements several methods. We want a user to chose to which methods to run among the exisiting methods or he can decide to add any method on\_the\_fly. from example ``` class RemoveNoise(): pass ``` then methods are added as wanted ``` RemoveNoise.raw = Raw() RemoveNoise.bais =...
2010/12/08
[ "https://Stackoverflow.com/questions/4387847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535019/" ]
There is no solving needed, you just do it. Here is your code, with the small changes needed: ``` class RemoveNoise(): pass RemoveNoise.raw = Raw RemoveNoise.bias = Bias def new(self): pass RemoveNoise.new=new instance = RemoveNoise() ``` It's that simple. Python is wonderful. Why on earth you would n...
Well, here's some code that does what I think you're asking for -- although I'm not really sure what you meant by "**save**" when you wrote "I want to save the class\_with\_the\_methods\_used". Also note that using an `exec` statement on user input can be *extremely* dangerous if it comes from an untrusted source. ``...
53,469,407
I got into automating tasks on the web using python. I have tried requests/urllib3/requests-html but they don't get me the right elements, because they get only the `html` (not the updated version with `javascript`). Some recommended Selenium, but it opens a browser with the `webdriver`. I need a way to get elements af...
2018/11/25
[ "https://Stackoverflow.com/questions/53469407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9534986/" ]
Don't overthink this. It seems that everything you have in your object gets allocated there, so use smart pointers: ``` std::vector<std::unique_ptr<Object>> pointer_vector; ```
Every object that you create with `new` will have to be `delete`ed at some point. It's your responsibility to do that. In your case the easiest solution is to add it in the destructor for your `Problem` class. ``` Problem::~Problem() { for (auto ptr : pointer_vector) delete ptr; } ``` If you ever remove ...
58,194,852
I am trying to load a pkl file, ``` pkl_file = open(sys.argv[1], 'rb') world = pickle.load(pkl_file) ``` but I get an error from these lines ``` Traceback (most recent call last): File "E:/python/test.py", line 186, in <module> world = pickle.load(pkl_file) ModuleNotFoundError: No module named 'numpy.core.multiarra...
2019/10/02
[ "https://Stackoverflow.com/questions/58194852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7548018/" ]
I think there are two problems here. First, your pickle is or contains a [NumPy](https://numpy.org/) object, which is not part of the standard library. Therefore you must ensure that NumPy is installed into your current Python environment and imported **before** you try to load the pickled object. Depending on your se...
Ok, I just had to figure this out for myself, and I solved it. All you have to do is change all the "\r\n" to "\n". You can do this in multiple ways. You can go into Notepad++ and change line endings from CR LF to just LF. Or programmatically you can do ``` open(newfile, 'w', newline = '\n').write(open(oldfile, 'r').r...
31,575,359
I recently downloaded some software that requires one to change to the directory with python files, and run `python setup.py install --user` in the Terminal. One then checks whether the code is running correctly by trying `from [x] import [y]` This works on my Terminal. However, when I then try `from [x] import [y]`...
2015/07/22
[ "https://Stackoverflow.com/questions/31575359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4596596/" ]
What about using the following selector: `input[id^='something_stuff_'][id$='_work']` It will get inputs with id starting with "something\_stuff\_" and finishing with "\_work".
An approach to this problem would be to use classes instead of ids and have things that are styled the same to be classed the same. for example: ``` <input id="something_stuff_01_work" class="input_class"> <input id="something_stuff_02_work" class="input_class"> <input id="something_stuff_03_work" class="input_class">...
31,575,359
I recently downloaded some software that requires one to change to the directory with python files, and run `python setup.py install --user` in the Terminal. One then checks whether the code is running correctly by trying `from [x] import [y]` This works on my Terminal. However, when I then try `from [x] import [y]`...
2015/07/22
[ "https://Stackoverflow.com/questions/31575359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4596596/" ]
What about using the following selector: `input[id^='something_stuff_'][id$='_work']` It will get inputs with id starting with "something\_stuff\_" and finishing with "\_work".
CSS does not support regexes in selectors. Use classes or starts-from and ends-with attribute selectors.
31,575,359
I recently downloaded some software that requires one to change to the directory with python files, and run `python setup.py install --user` in the Terminal. One then checks whether the code is running correctly by trying `from [x] import [y]` This works on my Terminal. However, when I then try `from [x] import [y]`...
2015/07/22
[ "https://Stackoverflow.com/questions/31575359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4596596/" ]
What about using the following selector: `input[id^='something_stuff_'][id$='_work']` It will get inputs with id starting with "something\_stuff\_" and finishing with "\_work".
Try prefixing the numeric id with \3. I came across this today, it was the selector generated using chrometools, I'd not seen it before, and it works using Chromium Webdriver: #\37 Full selector used is "#\37 > div > div.cell-text". This was a selector to select an element with id = "7". It (prefixing with \3) see...
31,575,359
I recently downloaded some software that requires one to change to the directory with python files, and run `python setup.py install --user` in the Terminal. One then checks whether the code is running correctly by trying `from [x] import [y]` This works on my Terminal. However, when I then try `from [x] import [y]`...
2015/07/22
[ "https://Stackoverflow.com/questions/31575359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4596596/" ]
An approach to this problem would be to use classes instead of ids and have things that are styled the same to be classed the same. for example: ``` <input id="something_stuff_01_work" class="input_class"> <input id="something_stuff_02_work" class="input_class"> <input id="something_stuff_03_work" class="input_class">...
Try prefixing the numeric id with \3. I came across this today, it was the selector generated using chrometools, I'd not seen it before, and it works using Chromium Webdriver: #\37 Full selector used is "#\37 > div > div.cell-text". This was a selector to select an element with id = "7". It (prefixing with \3) see...
31,575,359
I recently downloaded some software that requires one to change to the directory with python files, and run `python setup.py install --user` in the Terminal. One then checks whether the code is running correctly by trying `from [x] import [y]` This works on my Terminal. However, when I then try `from [x] import [y]`...
2015/07/22
[ "https://Stackoverflow.com/questions/31575359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4596596/" ]
CSS does not support regexes in selectors. Use classes or starts-from and ends-with attribute selectors.
Try prefixing the numeric id with \3. I came across this today, it was the selector generated using chrometools, I'd not seen it before, and it works using Chromium Webdriver: #\37 Full selector used is "#\37 > div > div.cell-text". This was a selector to select an element with id = "7". It (prefixing with \3) see...
43,994,599
Thanks to [Python Library](https://docs.python.org/2/library/telnetlib.html "Library") i was able to use their example to telnet to Cisco switches, I am using this for learning purposes, specifically learning python. However, although all the code seem generally easy to read, I am a bit confused as to the following: ...
2017/05/16
[ "https://Stackoverflow.com/questions/43994599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1736707/" ]
It looks like `PyCrypto` is [not being maintained currently](https://github.com/dlitz/pycrypto/issues/168). So, it's better you switch to [PyCryptodome](https://pypi.python.org/pypi/pycryptodome). ``` pip install pycryptodome ``` If you still want to use PyCrypto you could still try, > > <https://packaging.python....
If doing `python -m Cryptodome.SelfTest` is giving you an error, you can do: ``` pip uninstall pycryptodome ``` and then: ``` easy_install pycryptodome ``` Even after this, running `python -m Cryptodome.SelfTest` was giving me an error, but when I re-ran the file, it worked.
18,615,524
I'm trying to get the valid python list from the response of a server like you can see below: > > window.\_\_search.list=[{"order":"1","base":"LAW","n":"148904","access":{"css":"avail\_yes","title":"\u042 > 2\u0435\u043a\u0441\u0442\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0434\u043e\u0441\u0442\u0443\...
2013/09/04
[ "https://Stackoverflow.com/questions/18615524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1621838/" ]
Probably, your regular expression has found char ';' somewhere in the middle of a response, and because of this you get an error, because, using your regular expression, you might have received an incomplete, cropped response, and that's why you could not convert it into JSON. Yes, I agree with user RickyA that someti...
What about: ``` response = response.strip() #get rid of whitespaces response = response[response.find("["):] #trim everything before the first '[' if response[-1:] == ";": #if last char == ";" response = response[:-1] #trim it ``` Seems like a big overkill to do this with regex.
21,067,730
I have this piece of code in my views.py for a django app: ``` for i in range(0,10): row = cursor.fetchone() tablestring = tablestring + "<tr><td>" + row[0] + "</td><td>" + + str(row[3]) + "</td></tr>" ``` This works fine when I load the page but if I change the range to (0,20) or anything higher, I just get...
2014/01/11
[ "https://Stackoverflow.com/questions/21067730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/754604/" ]
you should really use [django orm](https://docs.djangoproject.com/en/dev/topics/db/queries/) and write those table markups in a [template](https://docs.djangoproject.com/en/dev/topics/templates/), follow this [tutorial](https://docs.djangoproject.com/en/dev/intro/tutorial01/) to get the basic concepts
My first guess would be that there are less than 20 rows, so once you run out of them `row` will be None and your attempt to index it will throw an exception. As for improving the code: Like Yossi suggested, you should probably go with an ORM. An ORM (Object Relational Mapper) lets you access a database in a more obj...
29,386,310
I am downloading a compressed file from the internet: ``` with lzma.open(urllib.request.urlopen(url)) as file: for line in file: ... ``` After having downloaded and processed a a large part of the file, I eventually get the error: > > File "/usr/lib/python3.4/lzma.py", line 225, in \_fill\_buffer raise...
2015/04/01
[ "https://Stackoverflow.com/questions/29386310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4424589/" ]
from the [urllib.urlopen docs:](https://docs.python.org/2/library/urllib.html) > > One caveat: the read() method, if the size argument is omitted or > negative, may not read until the end of the data stream; there is no > good way to determine that the entire stream from a socket has been > read in the general cas...
Assuming you need to download a big file, it is better to use the "write and binary" mode when writing content to a file in python. You may also try to use the [python requests](http://docs.python-requests.org/en/master/) module more than the urllib module: Please see below a working code: ``` import requests url="h...
29,386,310
I am downloading a compressed file from the internet: ``` with lzma.open(urllib.request.urlopen(url)) as file: for line in file: ... ``` After having downloaded and processed a a large part of the file, I eventually get the error: > > File "/usr/lib/python3.4/lzma.py", line 225, in \_fill\_buffer raise...
2015/04/01
[ "https://Stackoverflow.com/questions/29386310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4424589/" ]
It's probably liblzma bug. As a workaround try adding: ``` lzma._BUFFER_SIZE = 1023 ``` before calling `lzma.open()`.
Assuming you need to download a big file, it is better to use the "write and binary" mode when writing content to a file in python. You may also try to use the [python requests](http://docs.python-requests.org/en/master/) module more than the urllib module: Please see below a working code: ``` import requests url="h...
29,386,310
I am downloading a compressed file from the internet: ``` with lzma.open(urllib.request.urlopen(url)) as file: for line in file: ... ``` After having downloaded and processed a a large part of the file, I eventually get the error: > > File "/usr/lib/python3.4/lzma.py", line 225, in \_fill\_buffer raise...
2015/04/01
[ "https://Stackoverflow.com/questions/29386310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4424589/" ]
Have you tried using the requests library? I believe it provides an abstraction over urllib. The following solution should work for you, but it uses the requests library instead of urllib (but requests > urllib anyway!). Let me know if you prefer to continue using urllib. ``` import os import requests def download(ur...
Assuming you need to download a big file, it is better to use the "write and binary" mode when writing content to a file in python. You may also try to use the [python requests](http://docs.python-requests.org/en/master/) module more than the urllib module: Please see below a working code: ``` import requests url="h...
21,310,125
I would like to know what are the advantages and disadvantages of using AWS OpsWorks vs AWS Beanstalk and AWS CloudFormation? I am interested in a system that can be auto scaled to handle any high number of simultaneous web requests (From 1000 requests per minute to 10 million rpm.), including a database layer that ca...
2014/01/23
[ "https://Stackoverflow.com/questions/21310125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1112656/" ]
**AWS Beanstalk:** It is Deploy and manage applications in the AWS cloud without worrying about the infrastructure that runs yor web applications with Elastic Beanstalk. No need to worry about EC2 or else installations. **AWS OpsWorks** AWS OpsWorks is nothing but an application management service that makes it easy f...
You should use OpsWorks in place of CloudFormation if you need to deploy an application that requires updates to its EC2 instances. If your application uses a lot of AWS resources and services, including EC2, use a combination of CloudFormation and OpsWorks If your application will need other AWS resources, such as da...
21,310,125
I would like to know what are the advantages and disadvantages of using AWS OpsWorks vs AWS Beanstalk and AWS CloudFormation? I am interested in a system that can be auto scaled to handle any high number of simultaneous web requests (From 1000 requests per minute to 10 million rpm.), including a database layer that ca...
2014/01/23
[ "https://Stackoverflow.com/questions/21310125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1112656/" ]
In Opsworks you can share "roles" of layers across a stack to use less resources by combining the specific jobs an underlying instance maybe doing. Layer Compatibility List (as long as security groups are properly set): ``` HA Proxy : custom, db-master, and memcached. MySQL : custom, lb, memcached, monitoring-mast...
**AWS OpsWorks** - This is a part of AWS management service. It helps to configure the application using scripting. It uses Chef as the devops framework for this application management and operation. There are templates which can be used for configuration of server, database, storage. The templates can also be customi...
21,310,125
I would like to know what are the advantages and disadvantages of using AWS OpsWorks vs AWS Beanstalk and AWS CloudFormation? I am interested in a system that can be auto scaled to handle any high number of simultaneous web requests (From 1000 requests per minute to 10 million rpm.), including a database layer that ca...
2014/01/23
[ "https://Stackoverflow.com/questions/21310125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1112656/" ]
> > I would like to know what are the advantages and disadvantages of using AWS OpsWorks vs AWS Beanstalk and AWS CLoudFormation? > > > The answer is: it depends. AWS OpsWorks and AWS Beanstalk are (I've been told) simply different ways of managing your infrastructure, depending on how you think about it. CloudFo...
In Opsworks you can share "roles" of layers across a stack to use less resources by combining the specific jobs an underlying instance maybe doing. Layer Compatibility List (as long as security groups are properly set): ``` HA Proxy : custom, db-master, and memcached. MySQL : custom, lb, memcached, monitoring-mast...
21,310,125
I would like to know what are the advantages and disadvantages of using AWS OpsWorks vs AWS Beanstalk and AWS CloudFormation? I am interested in a system that can be auto scaled to handle any high number of simultaneous web requests (From 1000 requests per minute to 10 million rpm.), including a database layer that ca...
2014/01/23
[ "https://Stackoverflow.com/questions/21310125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1112656/" ]
As many others have commented AWS Beanstalk, AWS OpsWorks and AWS Cloud Formation offers different solutions for different problems. In order to acomplish with ``` I am interested in a system that can be auto scaled to handle any high number of simultaneous web requests (From 1000 requests per minute to 10 million r...
Just use terraform and ECS or EKS. opsworks, elastic beanstalk and cloudformation old tech now. -)
21,310,125
I would like to know what are the advantages and disadvantages of using AWS OpsWorks vs AWS Beanstalk and AWS CloudFormation? I am interested in a system that can be auto scaled to handle any high number of simultaneous web requests (From 1000 requests per minute to 10 million rpm.), including a database layer that ca...
2014/01/23
[ "https://Stackoverflow.com/questions/21310125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1112656/" ]
**AWS OpsWorks** - This is a part of AWS management service. It helps to configure the application using scripting. It uses Chef as the devops framework for this application management and operation. There are templates which can be used for configuration of server, database, storage. The templates can also be customi...
As many others have commented AWS Beanstalk, AWS OpsWorks and AWS Cloud Formation offers different solutions for different problems. In order to acomplish with ``` I am interested in a system that can be auto scaled to handle any high number of simultaneous web requests (From 1000 requests per minute to 10 million r...
21,310,125
I would like to know what are the advantages and disadvantages of using AWS OpsWorks vs AWS Beanstalk and AWS CloudFormation? I am interested in a system that can be auto scaled to handle any high number of simultaneous web requests (From 1000 requests per minute to 10 million rpm.), including a database layer that ca...
2014/01/23
[ "https://Stackoverflow.com/questions/21310125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1112656/" ]
In Opsworks you can share "roles" of layers across a stack to use less resources by combining the specific jobs an underlying instance maybe doing. Layer Compatibility List (as long as security groups are properly set): ``` HA Proxy : custom, db-master, and memcached. MySQL : custom, lb, memcached, monitoring-mast...
You should use OpsWorks in place of CloudFormation if you need to deploy an application that requires updates to its EC2 instances. If your application uses a lot of AWS resources and services, including EC2, use a combination of CloudFormation and OpsWorks If your application will need other AWS resources, such as da...
21,310,125
I would like to know what are the advantages and disadvantages of using AWS OpsWorks vs AWS Beanstalk and AWS CloudFormation? I am interested in a system that can be auto scaled to handle any high number of simultaneous web requests (From 1000 requests per minute to 10 million rpm.), including a database layer that ca...
2014/01/23
[ "https://Stackoverflow.com/questions/21310125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1112656/" ]
**AWS Beanstalk:** It is Deploy and manage applications in the AWS cloud without worrying about the infrastructure that runs yor web applications with Elastic Beanstalk. No need to worry about EC2 or else installations. **AWS OpsWorks** AWS OpsWorks is nothing but an application management service that makes it easy f...
**AWS OpsWorks** - This is a part of AWS management service. It helps to configure the application using scripting. It uses Chef as the devops framework for this application management and operation. There are templates which can be used for configuration of server, database, storage. The templates can also be customi...
21,310,125
I would like to know what are the advantages and disadvantages of using AWS OpsWorks vs AWS Beanstalk and AWS CloudFormation? I am interested in a system that can be auto scaled to handle any high number of simultaneous web requests (From 1000 requests per minute to 10 million rpm.), including a database layer that ca...
2014/01/23
[ "https://Stackoverflow.com/questions/21310125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1112656/" ]
In Opsworks you can share "roles" of layers across a stack to use less resources by combining the specific jobs an underlying instance maybe doing. Layer Compatibility List (as long as security groups are properly set): ``` HA Proxy : custom, db-master, and memcached. MySQL : custom, lb, memcached, monitoring-mast...
Just use terraform and ECS or EKS. opsworks, elastic beanstalk and cloudformation old tech now. -)