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
2,400,605
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want...
2010/03/08
[ "https://Stackoverflow.com/questions/2400605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235131/" ]
Why should an answer be different if the question was asked by a Delphi programmer, than a programmer from any other platform? Any decent language should be fun to learn, regardless of the tool you are using right now. That said, I myself walked a way from Borland Pascal and Delphi (quite some time ago), over PHP and ...
Actually, the answer probably is ASP.NET using C#. You'll see (ex-)Borland engineering syntax that looks quite familiar coming from Delphi. To deploy on Linux have a look at the [Mono project](http://www.mono-project.com/Main_Page).
2,400,605
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want...
2010/03/08
[ "https://Stackoverflow.com/questions/2400605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235131/" ]
Only good answer - C# ;) Seriously ;) Why? Anders Hejlsberg. He made it. It is the direct continuation of his work that started with Turbo Pascal and went over to Delphi... then Microsoft hired him and he moved from Pascal to C (core langauge) and made C#. Read it up on <http://en.wikipedia.org/wiki/Anders_Hejlsberg>...
I have done a fairly large (4-5 FTE) project based on webhub (www.href.com). I can certainly advise this if it is a webapp for internal use.
2,400,605
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want...
2010/03/08
[ "https://Stackoverflow.com/questions/2400605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235131/" ]
Try Morfik <http://www.morfik.com/> P.S. It looked promising a few years ago, but after I digged it deeper I must admit that it's quite limited web development environment for a very basic web development.
Only good answer - C# ;) Seriously ;) Why? Anders Hejlsberg. He made it. It is the direct continuation of his work that started with Turbo Pascal and went over to Delphi... then Microsoft hired him and he moved from Pascal to C (core langauge) and made C#. Read it up on <http://en.wikipedia.org/wiki/Anders_Hejlsberg>...
2,400,605
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want...
2010/03/08
[ "https://Stackoverflow.com/questions/2400605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235131/" ]
I agree about Intraweb, but Delphi itself is still a good language to build websites with. You could start a CGI application or an ISAPI-extesion. You could also check out <http://xxm.sf.net> , it's an open-source project I started that offers a few extra's: * You can mix HTML and Delphi code into the same files (much...
I'm a long-time Delphi developer myself and had to do some web work recently, I decided to use ASP.Net with [Delphi Prism](http://www.embarcadero.com/products/delphi-prism) and found myself right at home since I didn't have to learn a new language, just a new framework.
2,400,605
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want...
2010/03/08
[ "https://Stackoverflow.com/questions/2400605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235131/" ]
If you feel like stretching your muscles, you could try out [Seaside](http://www.seaside.st/). Seaside's a Smalltalk framework (so working with it will feel pretty much like working with Ruby) that lets you write your website just like you'd build a desktop application. You can split your code up into components that ...
Actually, the answer probably is ASP.NET using C#. You'll see (ex-)Borland engineering syntax that looks quite familiar coming from Delphi. To deploy on Linux have a look at the [Mono project](http://www.mono-project.com/Main_Page).
2,400,605
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want...
2010/03/08
[ "https://Stackoverflow.com/questions/2400605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235131/" ]
PHP is a pretty simple answer. One reason is there is both Delphi4PHP (the rather cryptic IDE licensed by Embarcadero which in my estimation is really only for Web Apps (not for doing whole site)s) and PHP4Delphi (the pretty awesome Delphi Component that lets you compile your Delphi code to PHP Extensions).
Actually, the answer probably is ASP.NET using C#. You'll see (ex-)Borland engineering syntax that looks quite familiar coming from Delphi. To deploy on Linux have a look at the [Mono project](http://www.mono-project.com/Main_Page).
2,400,605
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want...
2010/03/08
[ "https://Stackoverflow.com/questions/2400605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235131/" ]
I agree about Intraweb, but Delphi itself is still a good language to build websites with. You could start a CGI application or an ISAPI-extesion. You could also check out <http://xxm.sf.net> , it's an open-source project I started that offers a few extra's: * You can mix HTML and Delphi code into the same files (much...
PHP is a pretty simple answer. One reason is there is both Delphi4PHP (the rather cryptic IDE licensed by Embarcadero which in my estimation is really only for Web Apps (not for doing whole site)s) and PHP4Delphi (the pretty awesome Delphi Component that lets you compile your Delphi code to PHP Extensions).
2,400,605
I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications so I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want...
2010/03/08
[ "https://Stackoverflow.com/questions/2400605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235131/" ]
If you feel like stretching your muscles, you could try out [Seaside](http://www.seaside.st/). Seaside's a Smalltalk framework (so working with it will feel pretty much like working with Ruby) that lets you write your website just like you'd build a desktop application. You can split your code up into components that ...
I'm a long-time Delphi developer myself and had to do some web work recently, I decided to use ASP.Net with [Delphi Prism](http://www.embarcadero.com/products/delphi-prism) and found myself right at home since I didn't have to learn a new language, just a new framework.
31,682,981
I am a newbie in Django un I want to write a Test for Django Web-poll application (<https://docs.djangoproject.com/en/1.8/intro/tutorial01/>) but I got this error: ``` devuser@localhost:~/Django-apps/poolApp$ django-admin shell --plain --no-startup Traceback (most recent call last): File "/usr/local/bin/django-admi...
2015/07/28
[ "https://Stackoverflow.com/questions/31682981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4450024/" ]
Use `manage.py`, not `django-admin`.
What does work is using ``` django-admin shell --plain --no-startup --pythonpath "." --settings "myproject.settings" ``` while you are in the root of your django app. However `manage.py shell` (or the amazing `shell_plus` from django\_extensions <https://github.com/django-extensions/django-extensions>) is recommend...
46,034,924
When I try to run python manage.py runserver I get this error: ``` Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/Users/user/lokvi/lokvi_env/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_l...
2017/09/04
[ "https://Stackoverflow.com/questions/46034924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3565829/" ]
You need to import `settings` module ``` from django.conf import settings ```
Oh, It was not the python path specific question, sorry. I just needed `__init__.py` in settings module inside of my project, since there were no settings it tried to find it in python lib itself and couldn't, I believe.
2,134,941
For a package of mine, I have a README.rst file that is read into the setup.py's long description like so: ``` readme = open('README.rst', 'r') README_TEXT = readme.read() readme.close() setup( ... long_description = README_TEXT, .... ) ``` This way that I can have the README file show up on my [git...
2010/01/25
[ "https://Stackoverflow.com/questions/2134941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
Another option is to side-step the issue completely by adding a paragraph that works in both environments: "The latest unstable code is on github. The latest stable kits are on pypi." After all, why assume that pypi people don't want to be pointed to github? This would be more helpful to both audiences, and simplifies...
You could always do this: ``` GITHUB_ALERT = 'This document reflects a pre-release version...' readme = open('README.rst', 'r') README_TEXT = readme.read().replace(GITHUB_ALERT, '') readme.close() setup( ... long_description = README_TEXT, .... ) ``` But then you'd have to keep that `GITHUB_ALERT` s...
2,134,941
For a package of mine, I have a README.rst file that is read into the setup.py's long description like so: ``` readme = open('README.rst', 'r') README_TEXT = readme.read() readme.close() setup( ... long_description = README_TEXT, .... ) ``` This way that I can have the README file show up on my [git...
2010/01/25
[ "https://Stackoverflow.com/questions/2134941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
You can just use a ReST comment with some text like "split here", and then split on that in your setup.py. Ian Bicking does that in virtualenv with [index.txt](http://bitbucket.org/ianb/virtualenv/src/77d301cdbf8c/docs/index.txt) and [setup.py](http://bitbucket.org/ianb/virtualenv/src/tip/setup.py).
You could always do this: ``` GITHUB_ALERT = 'This document reflects a pre-release version...' readme = open('README.rst', 'r') README_TEXT = readme.read().replace(GITHUB_ALERT, '') readme.close() setup( ... long_description = README_TEXT, .... ) ``` But then you'd have to keep that `GITHUB_ALERT` s...
2,134,941
For a package of mine, I have a README.rst file that is read into the setup.py's long description like so: ``` readme = open('README.rst', 'r') README_TEXT = readme.read() readme.close() setup( ... long_description = README_TEXT, .... ) ``` This way that I can have the README file show up on my [git...
2010/01/25
[ "https://Stackoverflow.com/questions/2134941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
You can just use a ReST comment with some text like "split here", and then split on that in your setup.py. Ian Bicking does that in virtualenv with [index.txt](http://bitbucket.org/ianb/virtualenv/src/77d301cdbf8c/docs/index.txt) and [setup.py](http://bitbucket.org/ianb/virtualenv/src/tip/setup.py).
Another option is to side-step the issue completely by adding a paragraph that works in both environments: "The latest unstable code is on github. The latest stable kits are on pypi." After all, why assume that pypi people don't want to be pointed to github? This would be more helpful to both audiences, and simplifies...
64,375,499
``` def save_weights(self, filename = "./" + str(timestamp) + "-tfsave"): ### save model weights saver = tf.train.Saver() saver.save(self.sess, filename) print("saved to:",filename) ``` --- UnknownError Traceback (most recent call last) ~\Anaconda3\envs\tf\lib\site-packages\tensorflow\_core\pyt...
2020/10/15
[ "https://Stackoverflow.com/questions/64375499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12137831/" ]
You can achieve this without javascript by using a [media-query](https://www.w3schools.com/css/css_rwd_mediaqueries.asp): ```css #show-nav { display: none; background-color: red; } /* if screen width is smaller than 720px, #show-nav will be a block */ @media only screen and (max-width: 720px) { #show-nav { ...
You could use only css to do so. DEMO (make it full page) ------------------------ ```css body{ margin: 0; } nav{ width: 100vw; background:yellow; } @media only screen and (min-width: 720px){ nav{ background:red; } } ``` ```html <nav> <ul> <li>Welcome</li> </ul> </nav ```
64,375,499
``` def save_weights(self, filename = "./" + str(timestamp) + "-tfsave"): ### save model weights saver = tf.train.Saver() saver.save(self.sess, filename) print("saved to:",filename) ``` --- UnknownError Traceback (most recent call last) ~\Anaconda3\envs\tf\lib\site-packages\tensorflow\_core\pyt...
2020/10/15
[ "https://Stackoverflow.com/questions/64375499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12137831/" ]
You can achieve this without javascript by using a [media-query](https://www.w3schools.com/css/css_rwd_mediaqueries.asp): ```css #show-nav { display: none; background-color: red; } /* if screen width is smaller than 720px, #show-nav will be a block */ @media only screen and (max-width: 720px) { #show-nav { ...
``` @media only screen and (max-width: 720px) { #show-nav { display: block; } } ```
50,539,199
So I am trying to find a way to "merge" a dependency list which is in the form of a dictionary in python, and I haven't been able to come up with a solution. So imagine a graph along the lines of this: (all of the lines are downward pointing arrows in this directed graph) ``` 1 2 4 \ / / \ 3 5 8 \ / \ ...
2018/05/26
[ "https://Stackoverflow.com/questions/50539199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9849681/" ]
You can use a chained `dict comprehension` with `list comprehension` for up to two nodes. ``` >>> {k: v + [item for i in v for item in d.get(i, [])] for k,v in d.items()} {3: [1, 2], 5: [4], 6: [3, 5, 1, 2, 4], 7: [5, 4], 8: [4], 9: [8, 4], 1: [], 2: [], 4: []} ``` --- For unlimited depth, you can use a r...
Here's a really simple way to do it. ``` In [22]: a Out[22]: {1: [], 2: [], 3: [1, 2], 4: [], 5: [4], 6: [3, 5], 7: [5], 8: [4], 9: [8]} In [23]: final = {} In [24]: for key in a: ...: nodes = set() ...: ...: for val in a[key]: ...: nodes.add(val) ...: if val ...
24,635,064
Here is my problem with urllib in python 3. I wrote a piece of code which works well in Python 2.7 and is using urllib2. It goes to the page on Internet (which requires authorization) and grabs me the info from that page. The real problem for me is that I can't make my code working in python 3.4 because there is no u...
2014/07/08
[ "https://Stackoverflow.com/questions/24635064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3816874/" ]
Thankfully to you guys I finally figured out the way it works. Here is my code: ``` request = urllib.request.Request('http://mysite/admin/index.cgi?index=127') base64string = base64.b64encode(bytes('%s:%s' % ('login', 'password'),'ascii')) request.add_header("Authorization", "Basic %s" % base64string.decode('utf-8')) ...
What about [urllib.request](https://docs.python.org/dev/library/urllib.request.html) ? It seems it has everything you need. ``` import base64 import urllib.request request = urllib.request.Request('http://mysite/admin/index.cgi?index=127') base64string = bytes('%s:%s' % ('login', 'password'), 'ascii') request.add_he...
24,635,064
Here is my problem with urllib in python 3. I wrote a piece of code which works well in Python 2.7 and is using urllib2. It goes to the page on Internet (which requires authorization) and grabs me the info from that page. The real problem for me is that I can't make my code working in python 3.4 because there is no u...
2014/07/08
[ "https://Stackoverflow.com/questions/24635064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3816874/" ]
What about [urllib.request](https://docs.python.org/dev/library/urllib.request.html) ? It seems it has everything you need. ``` import base64 import urllib.request request = urllib.request.Request('http://mysite/admin/index.cgi?index=127') base64string = bytes('%s:%s' % ('login', 'password'), 'ascii') request.add_he...
An alternative using [OpenerDirector](https://docs.python.org/3.9/library/urllib.request.html#urllib.request.OpenerDirector) that installs the auth headers for all future urllib requests ```py login_pass = base64.b64encode(f'{login}:{password}'.encode()).decode() opener = urllib.request.build_opener() opener.addheader...
24,635,064
Here is my problem with urllib in python 3. I wrote a piece of code which works well in Python 2.7 and is using urllib2. It goes to the page on Internet (which requires authorization) and grabs me the info from that page. The real problem for me is that I can't make my code working in python 3.4 because there is no u...
2014/07/08
[ "https://Stackoverflow.com/questions/24635064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3816874/" ]
Thankfully to you guys I finally figured out the way it works. Here is my code: ``` request = urllib.request.Request('http://mysite/admin/index.cgi?index=127') base64string = base64.b64encode(bytes('%s:%s' % ('login', 'password'),'ascii')) request.add_header("Authorization", "Basic %s" % base64string.decode('utf-8')) ...
An alternative using [OpenerDirector](https://docs.python.org/3.9/library/urllib.request.html#urllib.request.OpenerDirector) that installs the auth headers for all future urllib requests ```py login_pass = base64.b64encode(f'{login}:{password}'.encode()).decode() opener = urllib.request.build_opener() opener.addheader...
57,073,765
I'm writing API results to CSV file in python 3.7. Problem is it adds double quotes ("") to each row when it writes to file. I'm passing format as csv to API call, so that I get results in csv format and then I'm writing it to csv file, store to specific location. Please suggest if there is any better way to do this. ...
2019/07/17
[ "https://Stackoverflow.com/questions/57073765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8449329/" ]
This is maybe the same as your original code, but use `prop()` instead of `attr()`. > > [`attr()`](https://api.jquery.com/attr/) - As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set. To retrieve and change DOM properties such as the checked, selected, or disabled state of for...
You can try to bind the change event on the `.form-check-input` class, and inside that event you can check wheter if the checkboxes are "empty" or not. ```js $('.form-check-input').on("change", function(){ var noChecked = $('.form-check-input:checked').length; if(noChecked === 0){ console.log("0 checkboxes...
19,736,625
I'm trying to write my first python script. I want to write a program that will get information out of a website. I managed to open the website, read all the data and transform the data from bytes to a string. ``` import urllib.request response = urllib.request.urlopen('http://www.imdb.com/title/tt0413573/episodes?...
2013/11/01
[ "https://Stackoverflow.com/questions/19736625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2904861/" ]
When dealing with structured texts like HTML/XML it is a good idea to use existing tools that leverage this structure. Instead of using regex or searching by hand, this gives a much more reliable and readable solution. In this case, I suggest to install [lxml](http://lxml.de/) to parse the HTML. Applying this principl...
Would that work? ``` lines = website.splitlines() lines.append('') for index, line in enumerate(lines): for keyword in ["airdate","episodeNumber"]: if keyword in line: print(lines[index + 1]) ``` It prints the next line if the keyword is found in the line.
19,736,625
I'm trying to write my first python script. I want to write a program that will get information out of a website. I managed to open the website, read all the data and transform the data from bytes to a string. ``` import urllib.request response = urllib.request.urlopen('http://www.imdb.com/title/tt0413573/episodes?...
2013/11/01
[ "https://Stackoverflow.com/questions/19736625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2904861/" ]
If that is your first Python script, it is really impressive to see you have made so far. You will use some legit parser to help you with your parsing. Check out [BeautifulSoup4](http://www.crummy.com/software/BeautifulSoup/) ``` # intellectual property belongs to imdb import urllib2 from bs4 import Beautiful...
Would that work? ``` lines = website.splitlines() lines.append('') for index, line in enumerate(lines): for keyword in ["airdate","episodeNumber"]: if keyword in line: print(lines[index + 1]) ``` It prints the next line if the keyword is found in the line.
61,370,108
I have a data input pipeline that has: * input datapoints of types that are not castable to a `tf.Tensor` (dicts and whatnot) * preprocessing functions that could not understand tensorflow types and need to work with those datapoints; some of which do data augmentation on the fly I've been trying to fit this into a `...
2020/04/22
[ "https://Stackoverflow.com/questions/61370108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5235369/" ]
Please read the documentation first before post any questions. Visit <https://react-bootstrap.github.io/components/toasts/> change > > import { Toast } from 'react-bootstrap'; > > > with > > import Toast from 'react-bootstrap/Toast' > > >
Change your import to import { Toast } from 'react-bootstrap/Toast'
25,056,700
I am trying to connect to cassandra from python , I have installed `cassandra` as `pip install pycassa`.When i am trying to connect to the `cassandra` i am getting the following exception ``` from pycassa.pool import ConnectionPool pool = ConnectionPool('Keyspace1') Traceback (most recent call last): File "<stdin>", ...
2014/07/31
[ "https://Stackoverflow.com/questions/25056700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531707/" ]
Perhaps the best known is the *branchless absolute value*: ``` int m = x >> 31; int abs = x + m ^ m; ``` Which uses an arithmetic shift to copy the signbit to all bits. Most uses of arithmetic shift that I've encountered were of that form. Of course an arithmetic shift is not *required* for this, you could replace a...
In C when writing device drivers, bit shift operators are used extensively since bits are used as switches that need to be turned on and off. Bit shift allow one to easily and correctly target the right switch. Many hashing and cryptographic functions make use of bit shift. Take a look at [Mercenne Twister](https://en...
25,056,700
I am trying to connect to cassandra from python , I have installed `cassandra` as `pip install pycassa`.When i am trying to connect to the `cassandra` i am getting the following exception ``` from pycassa.pool import ConnectionPool pool = ConnectionPool('Keyspace1') Traceback (most recent call last): File "<stdin>", ...
2014/07/31
[ "https://Stackoverflow.com/questions/25056700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531707/" ]
Indeed logical right shift is much more commonly used. However there are many operations that require an arithmetic shift (or are solved much more elegantly with an arithmetic shift) * Sign extension: + Most of the time you only deal with the available types in C and the compiler will automatically sign extend when ...
In C when writing device drivers, bit shift operators are used extensively since bits are used as switches that need to be turned on and off. Bit shift allow one to easily and correctly target the right switch. Many hashing and cryptographic functions make use of bit shift. Take a look at [Mercenne Twister](https://en...
25,056,700
I am trying to connect to cassandra from python , I have installed `cassandra` as `pip install pycassa`.When i am trying to connect to the `cassandra` i am getting the following exception ``` from pycassa.pool import ConnectionPool pool = ConnectionPool('Keyspace1') Traceback (most recent call last): File "<stdin>", ...
2014/07/31
[ "https://Stackoverflow.com/questions/25056700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531707/" ]
It has come in handy for me before, in the creation of masks that were then used in '&' or '|' operators when manipulating bit fields, either for bitwise data packing or bitwise graphics. I don't have a handy code sample, but I do recall using that technique many years ago in black-and-white graphics to zoom in (by ex...
In C when writing device drivers, bit shift operators are used extensively since bits are used as switches that need to be turned on and off. Bit shift allow one to easily and correctly target the right switch. Many hashing and cryptographic functions make use of bit shift. Take a look at [Mercenne Twister](https://en...
25,056,700
I am trying to connect to cassandra from python , I have installed `cassandra` as `pip install pycassa`.When i am trying to connect to the `cassandra` i am getting the following exception ``` from pycassa.pool import ConnectionPool pool = ConnectionPool('Keyspace1') Traceback (most recent call last): File "<stdin>", ...
2014/07/31
[ "https://Stackoverflow.com/questions/25056700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531707/" ]
It has come in handy for me before, in the creation of masks that were then used in '&' or '|' operators when manipulating bit fields, either for bitwise data packing or bitwise graphics. I don't have a handy code sample, but I do recall using that technique many years ago in black-and-white graphics to zoom in (by ex...
I am not too sure what you mean. BUt i'm going to speculate that you want to use the bit shift as an arithmetic function. One interesting thing i have seen is this property of binary numbers. ``` int n = 4; int k = 1; n = n << k; // is the same as n = n * 2^k //now n = (4 * 2) i.e. 8 n = n >> k; // is the same as n =...
25,056,700
I am trying to connect to cassandra from python , I have installed `cassandra` as `pip install pycassa`.When i am trying to connect to the `cassandra` i am getting the following exception ``` from pycassa.pool import ConnectionPool pool = ConnectionPool('Keyspace1') Traceback (most recent call last): File "<stdin>", ...
2014/07/31
[ "https://Stackoverflow.com/questions/25056700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531707/" ]
Perhaps the best known is the *branchless absolute value*: ``` int m = x >> 31; int abs = x + m ^ m; ``` Which uses an arithmetic shift to copy the signbit to all bits. Most uses of arithmetic shift that I've encountered were of that form. Of course an arithmetic shift is not *required* for this, you could replace a...
Indeed logical right shift is much more commonly used. However there are many operations that require an arithmetic shift (or are solved much more elegantly with an arithmetic shift) * Sign extension: + Most of the time you only deal with the available types in C and the compiler will automatically sign extend when ...
25,056,700
I am trying to connect to cassandra from python , I have installed `cassandra` as `pip install pycassa`.When i am trying to connect to the `cassandra` i am getting the following exception ``` from pycassa.pool import ConnectionPool pool = ConnectionPool('Keyspace1') Traceback (most recent call last): File "<stdin>", ...
2014/07/31
[ "https://Stackoverflow.com/questions/25056700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531707/" ]
Here's an example of a function that will find the least power of two greater than or equal to the input. There are other solutions to this problem that are probably faster, namly any hardware oriented solution or just a series of right shifts and ORs. This solution uses arithmetic shift to perform a binary search. ``...
Indeed logical right shift is much more commonly used. However there are many operations that require an arithmetic shift (or are solved much more elegantly with an arithmetic shift) * Sign extension: + Most of the time you only deal with the available types in C and the compiler will automatically sign extend when ...
25,056,700
I am trying to connect to cassandra from python , I have installed `cassandra` as `pip install pycassa`.When i am trying to connect to the `cassandra` i am getting the following exception ``` from pycassa.pool import ConnectionPool pool = ConnectionPool('Keyspace1') Traceback (most recent call last): File "<stdin>", ...
2014/07/31
[ "https://Stackoverflow.com/questions/25056700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531707/" ]
Indeed logical right shift is much more commonly used. However there are many operations that require an arithmetic shift (or are solved much more elegantly with an arithmetic shift) * Sign extension: + Most of the time you only deal with the available types in C and the compiler will automatically sign extend when ...
I am not too sure what you mean. BUt i'm going to speculate that you want to use the bit shift as an arithmetic function. One interesting thing i have seen is this property of binary numbers. ``` int n = 4; int k = 1; n = n << k; // is the same as n = n * 2^k //now n = (4 * 2) i.e. 8 n = n >> k; // is the same as n =...
25,056,700
I am trying to connect to cassandra from python , I have installed `cassandra` as `pip install pycassa`.When i am trying to connect to the `cassandra` i am getting the following exception ``` from pycassa.pool import ConnectionPool pool = ConnectionPool('Keyspace1') Traceback (most recent call last): File "<stdin>", ...
2014/07/31
[ "https://Stackoverflow.com/questions/25056700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531707/" ]
Perhaps the best known is the *branchless absolute value*: ``` int m = x >> 31; int abs = x + m ^ m; ``` Which uses an arithmetic shift to copy the signbit to all bits. Most uses of arithmetic shift that I've encountered were of that form. Of course an arithmetic shift is not *required* for this, you could replace a...
I am not too sure what you mean. BUt i'm going to speculate that you want to use the bit shift as an arithmetic function. One interesting thing i have seen is this property of binary numbers. ``` int n = 4; int k = 1; n = n << k; // is the same as n = n * 2^k //now n = (4 * 2) i.e. 8 n = n >> k; // is the same as n =...
25,056,700
I am trying to connect to cassandra from python , I have installed `cassandra` as `pip install pycassa`.When i am trying to connect to the `cassandra` i am getting the following exception ``` from pycassa.pool import ConnectionPool pool = ConnectionPool('Keyspace1') Traceback (most recent call last): File "<stdin>", ...
2014/07/31
[ "https://Stackoverflow.com/questions/25056700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531707/" ]
Here's an example of a function that will find the least power of two greater than or equal to the input. There are other solutions to this problem that are probably faster, namly any hardware oriented solution or just a series of right shifts and ORs. This solution uses arithmetic shift to perform a binary search. ``...
I am not too sure what you mean. BUt i'm going to speculate that you want to use the bit shift as an arithmetic function. One interesting thing i have seen is this property of binary numbers. ``` int n = 4; int k = 1; n = n << k; // is the same as n = n * 2^k //now n = (4 * 2) i.e. 8 n = n >> k; // is the same as n =...
25,056,700
I am trying to connect to cassandra from python , I have installed `cassandra` as `pip install pycassa`.When i am trying to connect to the `cassandra` i am getting the following exception ``` from pycassa.pool import ConnectionPool pool = ConnectionPool('Keyspace1') Traceback (most recent call last): File "<stdin>", ...
2014/07/31
[ "https://Stackoverflow.com/questions/25056700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531707/" ]
Here's an example of a function that will find the least power of two greater than or equal to the input. There are other solutions to this problem that are probably faster, namly any hardware oriented solution or just a series of right shifts and ORs. This solution uses arithmetic shift to perform a binary search. ``...
In C when writing device drivers, bit shift operators are used extensively since bits are used as switches that need to be turned on and off. Bit shift allow one to easily and correctly target the right switch. Many hashing and cryptographic functions make use of bit shift. Take a look at [Mercenne Twister](https://en...
45,920,527
I would like to download a subset of a WAT archive segment from Amazon S3. **Background:** Searching the Common Crawl index at <http://index.commoncrawl.org> yields results with information about the location of WARC files on AWS S3. For example, searching for [url=www.celebuzz.com/2017-01-04/\*&output=json](http://...
2017/08/28
[ "https://Stackoverflow.com/questions/45920527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2861935/" ]
The Common Crawl index does not contain offsets into WAT and WET files. So, the only way is to search the whole WAT/WET file for the desired record/URL. Eventually, it would be possible to estimate the offset because the record order in WARC and WAT/WET files is the same.
After many trial and error I had managed to get a range from a warc file in python and boto3 the following way: ``` # You have this form the index offset, length, filename = 2161478, 12350, "crawl-data/[...].warc.gz" import boto3 from botocore import UNSIGNED from botocore.client import Config # Boto3 anonymous logi...
52,898,576
I am trying to read a json data from an input file, and to pass it as the request to make a http call in python. Here is the highlights in my python code: ``` with open('input.json') as f: raw_data = json.load(f) cookies = ... headers = { 'Content-Type': 'application/json;charset=UTF-8', 'Accept': ...
2018/10/19
[ "https://Stackoverflow.com/questions/52898576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3595231/" ]
When you pass a `dict` (which is what `raw_data` is) as the `data` argument to `requests.put`, it will be form-encoded, which does not make for valid JSON. Either pass serialized JSON to `data`: ``` requests.put(..., data=json.dumps(raw_data), ...) ``` or use the `json` keyword and let `requests` do the serializatio...
``` with open('input.json') as f: ``` did you mean ``` with open('input.json','r') as f: ``` or ``` with open('input.json','rb') as f: ``` if the data is stored as bytes, you have to read it in as 'rb'.
58,660,173
Given a list of dictionaries like: ``` history = [ { "actions": [{"action": "baz", "people": ["a"]}, {"action": "qux", "people": ["d", "e"]}], "events": ["foo"] }, { "actions": [{"action": "baz", "people": ["a", "b", "c"]}], "events": ["foo", "bar"] }, ] ``` What is the most efficient (whilst...
2019/11/01
[ "https://Stackoverflow.com/questions/58660173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4007992/" ]
You can use `collections.defaultdict` with `itertools.groupby`: ``` from collections import defaultdict from itertools import groupby as gb d = defaultdict(list) for i in history: for b in i['events']: d[b].extend(i['actions']) new_d = {a:[(j, list(k)) for j, k in gb(sorted(b, key=lambda x:x['action']), key=lam...
It is not a less verbose answer, but maybe a bit better readable. Also it does not depend on anything else and is just standard python. ``` tmp_dict = {} for d in history: for event in d["events"]: if event not in tmp_dict: tmp_dict[event] = {} for actions in d["actions"]: ...
25,043,982
i'm having some trouble to handle jpeg files on Python under AWS Elastic Beanstalk. I have this on .ebextensions/python.config file: ``` packages: yum: libjpeg-turbo-devel: [] libpng-devel: [] freetype-devel: [] ... ``` So i believe i have libjpeg installed and working (i tried libjpeg-devel, but yum can't f...
2014/07/30
[ "https://Stackoverflow.com/questions/25043982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1541615/" ]
Following the general advice from [here](https://stackoverflow.com/questions/8915296/python-image-library-fails-with-message-decoder-jpeg-not-available-pil?rq=1), I solved this by adding the following in my .ebextensions configuration and re-deploying. ``` packages: yum: libjpeg-turbo-devel: [] libpng-devel...
As suggested, I SSHed again into the instance and reinstalled Pillow through pip (/opt/python/run/venv/bin/pip), not before I has had sure libjpeg-devel was on environment before Pillow. I ran selftest.py and it confirmed that I had support for jpeg. So, in a last try, I went to "Restart App Server" on Elastic Beansta...
25,087,111
I'm running a simulation on a 2D space with periodic boundary conditions. A continuous function is represented by its values on a grid. I need to be able to evaluate the function and its gradient at any point in the space. Fundamentally, this isn't a hard problem -- or to be precise, it's an almost already solved probl...
2014/08/01
[ "https://Stackoverflow.com/questions/25087111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2672942/" ]
It appears that the python function that comes closest is scipy.signal.cspline2d. This is exactly what I want, *except* that it assumes mirror-symmetric boundary conditions. Thus, it appears that I have three options: 1. Write my own cubic spline interpolation function that works with periodic boundary conditions, per...
Another function that could work is `scipy.ndimage.interpolation.map_coordinates`. It does spline interpolation with periodic boundary conditions. It does not not directly provide derivatives, but you could calculate them numerically.
25,087,111
I'm running a simulation on a 2D space with periodic boundary conditions. A continuous function is represented by its values on a grid. I need to be able to evaluate the function and its gradient at any point in the space. Fundamentally, this isn't a hard problem -- or to be precise, it's an almost already solved probl...
2014/08/01
[ "https://Stackoverflow.com/questions/25087111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2672942/" ]
It appears that the python function that comes closest is scipy.signal.cspline2d. This is exactly what I want, *except* that it assumes mirror-symmetric boundary conditions. Thus, it appears that I have three options: 1. Write my own cubic spline interpolation function that works with periodic boundary conditions, per...
These functions can be found at my github, [`master/hmc/lattice.py`](https://github.com/flipdazed/Hybrid-Monte-Carlo/tree/master/hmc/lattice.py): * **Periodic boundary conditions** The `Periodic_Lattice()` class is [described here](https://stackoverflow.com/a/38066786/4013571) in full. * **Lattice Derivatives** In the...
25,087,111
I'm running a simulation on a 2D space with periodic boundary conditions. A continuous function is represented by its values on a grid. I need to be able to evaluate the function and its gradient at any point in the space. Fundamentally, this isn't a hard problem -- or to be precise, it's an almost already solved probl...
2014/08/01
[ "https://Stackoverflow.com/questions/25087111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2672942/" ]
It appears that the python function that comes closest is scipy.signal.cspline2d. This is exactly what I want, *except* that it assumes mirror-symmetric boundary conditions. Thus, it appears that I have three options: 1. Write my own cubic spline interpolation function that works with periodic boundary conditions, per...
I have been using the following function which augments the input to create data with effective periodic boundary conditions. Augmenting the data has a distinct advantage over modifying an existing algorithm: the augmented data can easily be interpolated using any algorithm. See below for an example. ``` def augment_...
25,087,111
I'm running a simulation on a 2D space with periodic boundary conditions. A continuous function is represented by its values on a grid. I need to be able to evaluate the function and its gradient at any point in the space. Fundamentally, this isn't a hard problem -- or to be precise, it's an almost already solved probl...
2014/08/01
[ "https://Stackoverflow.com/questions/25087111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2672942/" ]
Another function that could work is `scipy.ndimage.interpolation.map_coordinates`. It does spline interpolation with periodic boundary conditions. It does not not directly provide derivatives, but you could calculate them numerically.
These functions can be found at my github, [`master/hmc/lattice.py`](https://github.com/flipdazed/Hybrid-Monte-Carlo/tree/master/hmc/lattice.py): * **Periodic boundary conditions** The `Periodic_Lattice()` class is [described here](https://stackoverflow.com/a/38066786/4013571) in full. * **Lattice Derivatives** In the...
25,087,111
I'm running a simulation on a 2D space with periodic boundary conditions. A continuous function is represented by its values on a grid. I need to be able to evaluate the function and its gradient at any point in the space. Fundamentally, this isn't a hard problem -- or to be precise, it's an almost already solved probl...
2014/08/01
[ "https://Stackoverflow.com/questions/25087111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2672942/" ]
Another function that could work is `scipy.ndimage.interpolation.map_coordinates`. It does spline interpolation with periodic boundary conditions. It does not not directly provide derivatives, but you could calculate them numerically.
I have been using the following function which augments the input to create data with effective periodic boundary conditions. Augmenting the data has a distinct advantage over modifying an existing algorithm: the augmented data can easily be interpolated using any algorithm. See below for an example. ``` def augment_...
27,214,053
I am getting an error when trying to install uinput I tried PIP and `easy_install`. I also tried to install 'manually' from tar package. I always get an error. Below is the error I get when installing with easy\_install. Can you guide me on how to fix it ? ``` rpi@torpi ~/scripts $ sudo easy_install python-uinput Sea...
2014/11/30
[ "https://Stackoverflow.com/questions/27214053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308766/" ]
Had this problem and fixed it with ``` sudo apt-get install libudev-dev ```
I could not get input to install properly so, I ended up using [evdev](https://pypi.python.org/pypi/evdev) instead.
27,214,053
I am getting an error when trying to install uinput I tried PIP and `easy_install`. I also tried to install 'manually' from tar package. I always get an error. Below is the error I get when installing with easy\_install. Can you guide me on how to fix it ? ``` rpi@torpi ~/scripts $ sudo easy_install python-uinput Sea...
2014/11/30
[ "https://Stackoverflow.com/questions/27214053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308766/" ]
I could not get input to install properly so, I ended up using [evdev](https://pypi.python.org/pypi/evdev) instead.
I see that this is a very old question, but I had the same problem, and running `sudo apt-get install libudev-dev` worked for me. Also, make sure to run pip with sudo.
27,214,053
I am getting an error when trying to install uinput I tried PIP and `easy_install`. I also tried to install 'manually' from tar package. I always get an error. Below is the error I get when installing with easy\_install. Can you guide me on how to fix it ? ``` rpi@torpi ~/scripts $ sudo easy_install python-uinput Sea...
2014/11/30
[ "https://Stackoverflow.com/questions/27214053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308766/" ]
Had this problem and fixed it with ``` sudo apt-get install libudev-dev ```
I see that this is a very old question, but I had the same problem, and running `sudo apt-get install libudev-dev` worked for me. Also, make sure to run pip with sudo.
49,741,030
I am building a RESTful API using Python 3.6, the Falcon Framework, Google App Engine, and Firebase Cloud Firestore. At runtime I am receiving the following error ... ``` File "E:\Bill\Documents\GitHubProjects\LetsHang-BackEnd\lib\google\cloud\firestore_v1beta1\_helpers.py", line 24, in &lt;module> import grpc File "E...
2018/04/09
[ "https://Stackoverflow.com/questions/49741030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7183052/" ]
You seem to be mixing up the GAE standard and flexible environments: * using Python 3.6 is only possible in the flexible environment (which, BTW, is fundamentally Docker-based) * installing app dependencies in the `lib` directory and using `dev_appserver.py` for local development are only applicable to the standard en...
Ok. I will write up my findings just in case there's another fool like me. First, [Dan's](https://stackoverflow.com/users/4495081/dan-cornilescu) response is correct. I was mixing standard and flexible environments. I had looked up a method for using the Falcon Framework with App Engine; as it turns out, the only arti...
62,463,565
I have three csv dataframes of tweets, each ~5M tweets. The following code for concatenating them exists with low memory error. My machine has 32GB memory. How can I assign more memory for this task in pandas? ``` df1 = pd.read_csv('tweets.csv') df2 = pd.read_csv('tweets2.csv') df3 = pd.read_csv('tweets3.csv') frames...
2020/06/19
[ "https://Stackoverflow.com/questions/62463565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2414957/" ]
I think this is problem with malformed data (some data not structure properly in `tweets2.csv`) for that you can use `error_bad_lines=False` and try to chnage engine from c to python like `engine='python'` ex : `df2 = pd.read_csv('tweets2.csv', error_bad_lines=False)` or ex : `df2 = pd.read_csv('tweets2.csv', engine=...
Specify `dtype` option on import or set `low_memory=False`
61,390,586
I am currently working on a schoolproject, and im trying to import data from a CSV file to MySQL using python. This is my code so far: ``` import mysql.connector import csv mydb = mysql.connector.connect(host='127.0.0.1', user='root', password='abc123!', db='jd_university') cursor = mydb.cursor() with open('C:/User...
2020/04/23
[ "https://Stackoverflow.com/questions/61390586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13391817/" ]
* You don't need to quote the `%s` placeholders. * Since you're using `DictReader`, you will need to name the columns in your `row` expression (or not use DictReader and hope for the correct order, which I'd not do). Try this: ```py import mysql.connector import csv mydb = mysql.connector.connect( host="127.0.0....
Validate the datatype for DOB field in your data file and database column. Could be a data issue or table definition issue.
25,608,078
I am trying to create an SVG font, so I need to create some paths. One of the letters is defined by the following path: ![Path](https://i.imgur.com/Uj2Wbdd.png) Which I created with [svgwrite](https://pypi.python.org/pypi/svgwrite), by creating two `circles` and a `rect`, and then using inkscape to take the differenc...
2014/09/01
[ "https://Stackoverflow.com/questions/25608078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/218558/" ]
The first arc has a negative (0) draw angle, the second must have a positive (1) draw angle and drawn from the opposite side to achieve the desired effect. ```py #--------------------------N-----------↓↓↓-↓↓↓-------------P-↓↓↓-↓↓↓↓↓---------------------------------------------- d="M 0 128 A 128 128 1 1 0 0 127.9 Z M ...
following @martineau's suggestion and [this](https://stackoverflow.com/questions/5737975/circle-drawing-with-svgs-arc-path) SO question, I came to this solution: * Create a circle made of two halfs * Creates two smaller half circles (not quite circular) * then use [`fill-rule: evenodd`](http://www.w3.org/TR/SVG/painti...
25,608,078
I am trying to create an SVG font, so I need to create some paths. One of the letters is defined by the following path: ![Path](https://i.imgur.com/Uj2Wbdd.png) Which I created with [svgwrite](https://pypi.python.org/pypi/svgwrite), by creating two `circles` and a `rect`, and then using inkscape to take the differenc...
2014/09/01
[ "https://Stackoverflow.com/questions/25608078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/218558/" ]
The first arc has a negative (0) draw angle, the second must have a positive (1) draw angle and drawn from the opposite side to achieve the desired effect. ```py #--------------------------N-----------↓↓↓-↓↓↓-------------P-↓↓↓-↓↓↓↓↓---------------------------------------------- d="M 0 128 A 128 128 1 1 0 0 127.9 Z M ...
Filters don't produce paths, they just produce bitmaps (so if you need a path - this is the wrong answer). But Here's a version using an SVG Filter - since you tagged the question with it (won't work in Firefox - can't use objects as feImage inputs yet - you'd have to inline them as data URI). ```html <svg width="200...
44,430,246
I have list of dictionaries and in each one of them the key `site` exists. So in other words, this code returns `True`: ``` all('site' in site for site in summary) ``` Question is, what will be the pythonic way to iterate over the list of dictionaries and return `True` if a key different from `site` exists in any of...
2017/06/08
[ "https://Stackoverflow.com/questions/44430246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5517847/" ]
If all dictionaries have the key `site`, the dictionaries have a length of at least 1. The presence of *any other key* would increase the dictionary size to be greater than 1, test for that: ``` any(len(d) > 1 for d in summary) ```
You could just check, for each dictionary `dct`: ``` any(key != "site" for key in dct) ``` If you want to check this for a list of dictionaries `dcts`, shove another `any` around that: `any(any(key != "site" for key in dct) for dct in dcts)` This also makes it easily extensible to allowing multiple different keys. ...
44,430,246
I have list of dictionaries and in each one of them the key `site` exists. So in other words, this code returns `True`: ``` all('site' in site for site in summary) ``` Question is, what will be the pythonic way to iterate over the list of dictionaries and return `True` if a key different from `site` exists in any of...
2017/06/08
[ "https://Stackoverflow.com/questions/44430246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5517847/" ]
If all dictionaries have the key `site`, the dictionaries have a length of at least 1. The presence of *any other key* would increase the dictionary size to be greater than 1, test for that: ``` any(len(d) > 1 for d in summary) ```
This is a bit longer version, but it gives you what you need. Just to give more options: ``` any({k: v for k, v in site.items() if k != 'site'} for site in summary) ```
44,430,246
I have list of dictionaries and in each one of them the key `site` exists. So in other words, this code returns `True`: ``` all('site' in site for site in summary) ``` Question is, what will be the pythonic way to iterate over the list of dictionaries and return `True` if a key different from `site` exists in any of...
2017/06/08
[ "https://Stackoverflow.com/questions/44430246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5517847/" ]
You could just check, for each dictionary `dct`: ``` any(key != "site" for key in dct) ``` If you want to check this for a list of dictionaries `dcts`, shove another `any` around that: `any(any(key != "site" for key in dct) for dct in dcts)` This also makes it easily extensible to allowing multiple different keys. ...
This is a bit longer version, but it gives you what you need. Just to give more options: ``` any({k: v for k, v in site.items() if k != 'site'} for site in summary) ```
71,184,380
I have two lists. I want to create a `Literal` using both these lists ```python category1 = ["image/jpeg", "image/png"] category2 = ["application/pdf"] SUPPORTED_TYPES = typing.Literal[category1 + category2] ``` Is there any way to do this? I have seen the question [typing: Dynamically Create Literal Alias from Li...
2022/02/19
[ "https://Stackoverflow.com/questions/71184380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14595305/" ]
Use the same technique as in the question you linked: build the lists from the literal types, instead of the other way around: ``` SUPPORTED_IMAGE_TYPES = typing.Literal["image/jpeg", "image/png"] SUPPORTED_OTHER_TYPES = typing.Literal["application/pdf"] SUPPORTED_TYPES = typing.Literal[SUPPORTED_IMAGE_TYPES, SUPPORT...
I got an answer to this - Create a literal for both the lists, and then create a combined literal ```python category1 = Literal["image/jpeg", "image/png"] category2 = Literal["application/pdf"] SUPPORTED_TYPES = Literal[category1, category2] ``` Sorry: hadnt seen that monica answered the question
74,214,700
i wrote this code: ``` admitted_List = [1, 5, 10, 50, 100, 500, 1000] tempString = "" finalList = [] for i in range(len(xkcd)-1): if int(xkcd[i] + xkcd[i+1]) in admitted_List: tempString += xkcd[i] continue else: tempString += xkcd[i] finalList.append(int(tempString)) te...
2022/10/26
[ "https://Stackoverflow.com/questions/74214700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18943770/" ]
> > > ``` > nodejs test.js > > ``` > > > > > ``` > nodejs -v > v10.19.0 > > ``` > > You are running this with Node 10 which is beyond end of life and does not support ECMAScript modules (with provide `import`) except as an experimental feature locked behind a flag. Use the other version of Node.js you ha...
What worked for me: 1. Install **curl**: `sudo apt install curl` 2. Install **NVM**: `sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash` ``` export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ]...
74,214,700
i wrote this code: ``` admitted_List = [1, 5, 10, 50, 100, 500, 1000] tempString = "" finalList = [] for i in range(len(xkcd)-1): if int(xkcd[i] + xkcd[i+1]) in admitted_List: tempString += xkcd[i] continue else: tempString += xkcd[i] finalList.append(int(tempString)) te...
2022/10/26
[ "https://Stackoverflow.com/questions/74214700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18943770/" ]
> > > ``` > nodejs test.js > > ``` > > > > > ``` > nodejs -v > v10.19.0 > > ``` > > You are running this with Node 10 which is beyond end of life and does not support ECMAScript modules (with provide `import`) except as an experimental feature locked behind a flag. Use the other version of Node.js you ha...
1. Make sure you're using at least [email protected] 2. Change your run command from `node test.js` to `node test.js --input-type=module` (This will allow using `import` in your code) See the docs: <https://nodejs.org/api/packages.html#--input-type-flag>
74,214,700
i wrote this code: ``` admitted_List = [1, 5, 10, 50, 100, 500, 1000] tempString = "" finalList = [] for i in range(len(xkcd)-1): if int(xkcd[i] + xkcd[i+1]) in admitted_List: tempString += xkcd[i] continue else: tempString += xkcd[i] finalList.append(int(tempString)) te...
2022/10/26
[ "https://Stackoverflow.com/questions/74214700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18943770/" ]
1. Make sure you're using at least [email protected] 2. Change your run command from `node test.js` to `node test.js --input-type=module` (This will allow using `import` in your code) See the docs: <https://nodejs.org/api/packages.html#--input-type-flag>
What worked for me: 1. Install **curl**: `sudo apt install curl` 2. Install **NVM**: `sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash` ``` export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ]...
66,166,103
How do I turn these numbers into a list using python? 16 3 2 13 -> ["16","3","2","13"]
2021/02/12
[ "https://Stackoverflow.com/questions/66166103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15195153/" ]
You can divide it by using [split](https://docs.python.org/3/library/stdtypes.html?highlight=split#str.split): ``` "16 3 2 13".split() ``` Output: ``` ["16","3","2","13"] ```
``` a = '16 3 2 13' b = [''] print(type(b)) print(len(b)) j = 0 for i in range(len(a)): if a[i] != ' ': b[j] = b[j] + a[i] else: j = j+1 b.append('') print(b) ```
66,166,103
How do I turn these numbers into a list using python? 16 3 2 13 -> ["16","3","2","13"]
2021/02/12
[ "https://Stackoverflow.com/questions/66166103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15195153/" ]
If you just want to split by whitespaces. ``` data = '16 3 2 13' print(data.split()) ```
``` a = '16 3 2 13' b = [''] print(type(b)) print(len(b)) j = 0 for i in range(len(a)): if a[i] != ' ': b[j] = b[j] + a[i] else: j = j+1 b.append('') print(b) ```
72,726,621
I have two lists. ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list ``` If I look closely, L1 has `'not worry'` and `'good very'` which are exact reversed repetitio...
2022/06/23
[ "https://Stackoverflow.com/questions/72726621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6803114/" ]
``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list def solution(lst): res = [] for item in lst: if " ".join(item.split()[::-1]) not in res: ...
This is a possible solution (the complexity is linear with respect to the number of strings): ``` from collections import defaultdict from operator import itemgetter d = defaultdict(list) for s in L2: d[max(s, reversed(s.split()))].append(s) result = list(map(itemgetter(0), d.values())) ``` Here are the result...
72,726,621
I have two lists. ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list ``` If I look closely, L1 has `'not worry'` and `'good very'` which are exact reversed repetitio...
2022/06/23
[ "https://Stackoverflow.com/questions/72726621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6803114/" ]
You can do it with list comprehensions if you iterate over the list from the end ``` lst = L1[::-1] # L2[::-1] x = [s for i, s in enumerate(lst) if ' '.join(s.split()[::-1]) not in lst[i+1:]][::-1] # L1: ['worry not', 'be happy', 'very good', 'full stop'] # L2: ['take into account', 'always be happy', 'stay safe frie...
You can use an index set and add both direct and reversed n-grams to it: ``` index = set() res = [] for x in L1: a = tuple(x.split()) b = tuple(reversed(a)) if a in index or b in index: continue index.add(a) index.add(b) res.append(x) print(res) ```
72,726,621
I have two lists. ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list ``` If I look closely, L1 has `'not worry'` and `'good very'` which are exact reversed repetitio...
2022/06/23
[ "https://Stackoverflow.com/questions/72726621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6803114/" ]
You can do it with list comprehensions if you iterate over the list from the end ``` lst = L1[::-1] # L2[::-1] x = [s for i, s in enumerate(lst) if ' '.join(s.split()[::-1]) not in lst[i+1:]][::-1] # L1: ['worry not', 'be happy', 'very good', 'full stop'] # L2: ['take into account', 'always be happy', 'stay safe frie...
Using a set of tuples is the way to deal with this: ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list for list_ in L1, L2: s = set() for e in list_: t...
72,726,621
I have two lists. ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list ``` If I look closely, L1 has `'not worry'` and `'good very'` which are exact reversed repetitio...
2022/06/23
[ "https://Stackoverflow.com/questions/72726621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6803114/" ]
Using a set of tuples is the way to deal with this: ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list for list_ in L1, L2: s = set() for e in list_: t...
This is a possible solution (the complexity is linear with respect to the number of strings): ``` from collections import defaultdict from operator import itemgetter d = defaultdict(list) for s in L2: d[max(s, reversed(s.split()))].append(s) result = list(map(itemgetter(0), d.values())) ``` Here are the result...
72,726,621
I have two lists. ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list ``` If I look closely, L1 has `'not worry'` and `'good very'` which are exact reversed repetitio...
2022/06/23
[ "https://Stackoverflow.com/questions/72726621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6803114/" ]
``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list def solution(lst): res = [] for item in lst: if " ".join(item.split()[::-1]) not in res: ...
My solution consist on iterate foreach element in the list, transform that element in a list, sort it and compare with the next element making the same, transform it in a list and sort it, if the arrays are matching, remove this element. Here is my code: ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'go...
72,726,621
I have two lists. ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list ``` If I look closely, L1 has `'not worry'` and `'good very'` which are exact reversed repetitio...
2022/06/23
[ "https://Stackoverflow.com/questions/72726621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6803114/" ]
You can do it with list comprehensions if you iterate over the list from the end ``` lst = L1[::-1] # L2[::-1] x = [s for i, s in enumerate(lst) if ' '.join(s.split()[::-1]) not in lst[i+1:]][::-1] # L1: ['worry not', 'be happy', 'very good', 'full stop'] # L2: ['take into account', 'always be happy', 'stay safe frie...
My solution consist on iterate foreach element in the list, transform that element in a list, sort it and compare with the next element making the same, transform it in a list and sort it, if the arrays are matching, remove this element. Here is my code: ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'go...
72,726,621
I have two lists. ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list ``` If I look closely, L1 has `'not worry'` and `'good very'` which are exact reversed repetitio...
2022/06/23
[ "https://Stackoverflow.com/questions/72726621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6803114/" ]
You can do it with list comprehensions if you iterate over the list from the end ``` lst = L1[::-1] # L2[::-1] x = [s for i, s in enumerate(lst) if ' '.join(s.split()[::-1]) not in lst[i+1:]][::-1] # L1: ['worry not', 'be happy', 'very good', 'full stop'] # L2: ['take into account', 'always be happy', 'stay safe frie...
``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list def solution(lst): res = [] for item in lst: if " ".join(item.split()[::-1]) not in res: ...
72,726,621
I have two lists. ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list ``` If I look closely, L1 has `'not worry'` and `'good very'` which are exact reversed repetitio...
2022/06/23
[ "https://Stackoverflow.com/questions/72726621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6803114/" ]
You can do it with list comprehensions if you iterate over the list from the end ``` lst = L1[::-1] # L2[::-1] x = [s for i, s in enumerate(lst) if ' '.join(s.split()[::-1]) not in lst[i+1:]][::-1] # L1: ['worry not', 'be happy', 'very good', 'full stop'] # L2: ['take into account', 'always be happy', 'stay safe frie...
This is a possible solution (the complexity is linear with respect to the number of strings): ``` from collections import defaultdict from operator import itemgetter d = defaultdict(list) for s in L2: d[max(s, reversed(s.split()))].append(s) result = list(map(itemgetter(0), d.values())) ``` Here are the result...
72,726,621
I have two lists. ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list ``` If I look closely, L1 has `'not worry'` and `'good very'` which are exact reversed repetitio...
2022/06/23
[ "https://Stackoverflow.com/questions/72726621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6803114/" ]
Using a set of tuples is the way to deal with this: ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list for list_ in L1, L2: s = set() for e in list_: t...
``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list def solution(lst): res = [] for item in lst: if " ".join(item.split()[::-1]) not in res: ...
72,726,621
I have two lists. ``` L1 = ['worry not', 'be happy', 'very good', 'not worry', 'good very', 'full stop'] # bigrams list L2 = ['take into account', 'always be happy', 'stay safe friend', 'happy be always'] #trigrams list ``` If I look closely, L1 has `'not worry'` and `'good very'` which are exact reversed repetitio...
2022/06/23
[ "https://Stackoverflow.com/questions/72726621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6803114/" ]
You can use an index set and add both direct and reversed n-grams to it: ``` index = set() res = [] for x in L1: a = tuple(x.split()) b = tuple(reversed(a)) if a in index or b in index: continue index.add(a) index.add(b) res.append(x) print(res) ```
This is a possible solution (the complexity is linear with respect to the number of strings): ``` from collections import defaultdict from operator import itemgetter d = defaultdict(list) for s in L2: d[max(s, reversed(s.split()))].append(s) result = list(map(itemgetter(0), d.values())) ``` Here are the result...
63,145,924
Let say I have something like this : ``` --module1 def called(): if caller.class.attrX == 1 : ... --module2 class ABC: attrX = 1 def method(): called() ``` I want to access caller Class-attribute ? I know I have to use inspect somehow but can figure how exactly. python3
2020/07/29
[ "https://Stackoverflow.com/questions/63145924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1019129/" ]
The code works perfectly fine for me in python 3.7.3. `The number is: 2825302` `['28', '82', '253', '2530', '5302']` this is the output I have received
I don't get the error. Better practice is to pass mutable objects as parameters to functions. Changed `find_ten_substring()` to take additional parameter ``` def find_sum(num_str): sum1 = 0 for i in num_str: sum1 += int(i) return sum1 def find_ten_substring(num_str, dict1): list1 = [] for...
1,223,927
I have django running through WSGI like this : ``` <VirtualHost *:80> WSGIScriptAlias / /home/ptarjan/django/django.wsgi WSGIDaemonProcess ptarjan processes=2 threads=15 display-name=%{GROUP} WSGIProcessGroup ptarjan Alias /media /home/ptarjan/django/mysite/media/ </VirtualHost> ``` But if in python ...
2009/08/03
[ "https://Stackoverflow.com/questions/1223927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/90025/" ]
It is not 'deadlock-timeout' you want as specified by another, that is for a very special purpose which will not help in this case. As far as trying to use mod\_wsgi features, you instead want the 'inactivity-timeout' option for WSGIDaemonProcess directive. Even then, this is not a complete solution. This is because ...
If I understand well the question, you want to protect apache from locking up when running some random scripts from people. Well, if you're running untrusted code, I think you have other things to worry about that are worst than apache. That said, you can use some configuration directives to adjust a *safer* environme...
44,746,078
I have some exception handling code in `python` where two exceptions can be raised, the first one being a "superset" of the second one. I.e. the following code summarizes what I need to do (and works fine) ``` try: normal_execution_path() except FirstError: handle_first_error() handle_second_error() excep...
2017/06/25
[ "https://Stackoverflow.com/questions/44746078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3246191/" ]
If you wish to manually throw the second error to be handled, you can use nested try-catch blocks like these: ``` try: normal_execution_path() except FirstError: try: handle_first_error() raise SecondError except SecondError: handle_second_error() except SecondError: handle_...
Perhaps it is worth reviewing the code architecture. But for your particular case: Create a generic class that handles this type of error. To inherit from it for the first and second error cases. Create a handler for this type of error. In the handler, check the first or second special case and process it with a water...
39,902,759
I have a cube of size `N * N * N`, say `N=8`. Each dimension of the cube is discretised to 1, so that I have labelled points `(0,0,0), (0,0,1)..(N,N,N)`. At each labelled points, I would like to assign a random value, and thus produce an array which stores value at each vertex. For example `val[0,0,0]=1, val[0,0,1]=1.2...
2016/10/06
[ "https://Stackoverflow.com/questions/39902759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6700176/" ]
You could simply generate lists of lists. While not in any way efficient, it would allow you to access your cube like `val[0][0][0]`. ``` arr = [[[] for _ in range(8)] for _ in range(8)] arr[0][0].append(1) ```
For large matrices, look into using `numpy`. This is the problem that it's designed to solve
39,902,759
I have a cube of size `N * N * N`, say `N=8`. Each dimension of the cube is discretised to 1, so that I have labelled points `(0,0,0), (0,0,1)..(N,N,N)`. At each labelled points, I would like to assign a random value, and thus produce an array which stores value at each vertex. For example `val[0,0,0]=1, val[0,0,1]=1.2...
2016/10/06
[ "https://Stackoverflow.com/questions/39902759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6700176/" ]
Did you mean this: ``` import numpy as np n = 5 val = np.empty((n, n, n)) # Create an 3d array full of 0's val[0,0,0] = 11 val[0,0,1] = 33 print(val[0, 0]) array([ 11., 33., 0., 0., 0.]) ```
For large matrices, look into using `numpy`. This is the problem that it's designed to solve
53,480,515
Note: I am quite new to Python so the problem could be anything. * Python: 3.6 * MySQL: 8 I have a MySQL database setup and can successfully query from it through Python, so I am sure my connection is OK. I can insert records inside MySQL Workbench, so I am fairly sure the DB is OK. However, when I run the following ...
2018/11/26
[ "https://Stackoverflow.com/questions/53480515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/546813/" ]
I thin you should close your cursor. And your connection is autocommited? Plese check it, and you should commit it!
I don't see anything obvious, though I have a suggestion. The same way you created the query above before executing it, do the same below and print it before execution so you can be sure what you are executing. As a general rule I don't construct query strings within the execute function. I don't see a close which mig...
36,490,093
Can anyone tell me how to use if statement in python for the difference between the two nos is 1..?? I have written like below and I am getting error if num1 = num2 + 1: what should be the content with if?
2016/04/08
[ "https://Stackoverflow.com/questions/36490093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6174977/" ]
Your guess was mostly correct. It's not that the passing of references was a problem, is that after all the references got passed around, here, and there, and everywhere, the object that was referenced went out of scope and got destroyed, with the reference left hanging around. Using the reference at that point becomes...
I changed the line: const vector >& \_cycles; to const vector > \_cycles; and everything worked fine!
36,490,093
Can anyone tell me how to use if statement in python for the difference between the two nos is 1..?? I have written like below and I am getting error if num1 = num2 + 1: what should be the content with if?
2016/04/08
[ "https://Stackoverflow.com/questions/36490093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6174977/" ]
Your guess was mostly correct. It's not that the passing of references was a problem, is that after all the references got passed around, here, and there, and everywhere, the object that was referenced went out of scope and got destroyed, with the reference left hanging around. Using the reference at that point becomes...
In foo() you're allocating a Permutation object in the current stack frame and then returning to your caller, destroying the frame(i.e. going out scope). You could instead allocate the new Permutation object on the heap and return the pointer, keeping in mind you'll want to free it at some point if done in something be...
36,490,093
Can anyone tell me how to use if statement in python for the difference between the two nos is 1..?? I have written like below and I am getting error if num1 = num2 + 1: what should be the content with if?
2016/04/08
[ "https://Stackoverflow.com/questions/36490093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6174977/" ]
In foo() you're allocating a Permutation object in the current stack frame and then returning to your caller, destroying the frame(i.e. going out scope). You could instead allocate the new Permutation object on the heap and return the pointer, keeping in mind you'll want to free it at some point if done in something be...
I changed the line: const vector >& \_cycles; to const vector > \_cycles; and everything worked fine!
44,933,326
I am having problems connecting to my database through postgreSQL3 version 9.5. However, after running the code below: ``` import psycopg2 as p con = p.connect("dbname ='dvdrental' user = 'myusername' host ='localhost' password ='somepassword'") cur = con.cursor() cur.execute("select * from title") rows = cur.fetchal...
2017/07/05
[ "https://Stackoverflow.com/questions/44933326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7620397/" ]
Check the listen adresses of postgres, using `netstat` (from the shell): --- ``` plasser@pisbak$ netstat -nl |grep 5432 tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN tcp6 0 0 :::5432 :::* LISTEN unix 2 [ ACC ] STREAM LI...
what if you add `port = '5433'` to your `p.connect` line? ``` import psycopg2 as p con = p.connect("dbname ='dvdrental' user = 'myusername' host ='localhost' password ='somepassword' port='5433'") cur = con.cursor() cur.execute("select * from title") rows = cur.fetchall() ```
34,936,039
Env: Windows 10 Pro I installed python 2.7.9 and using `pip` installed `robotframework` and `robotframework-selenium2library` and it all worked fine with no errors. Then I was doing some research and found that unless there is a reason for me to use 2.x versions of Python, I should stick with 3.x versions. Since 3.4 ...
2016/01/21
[ "https://Stackoverflow.com/questions/34936039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4496252/" ]
You need to assign `heroclass.toLowerCase();` to the original value of `heroclass`: ``` heroclass = heroclass.toLowerCase(); ``` If you do not do this, the lowercase version of heroclass is not saved.
Put your loop in a labeled block: ``` myblock: { while (true) { //code heroclass = heroclass.toLowerCase(); switch(heroclass) { case "slayer": A = "text"; break myblock; //repeat with other cases } } } //goes to here when you say ...
34,936,039
Env: Windows 10 Pro I installed python 2.7.9 and using `pip` installed `robotframework` and `robotframework-selenium2library` and it all worked fine with no errors. Then I was doing some research and found that unless there is a reason for me to use 2.x versions of Python, I should stick with 3.x versions. Since 3.4 ...
2016/01/21
[ "https://Stackoverflow.com/questions/34936039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4496252/" ]
You need to assign `heroclass.toLowerCase();` to the original value of `heroclass`: ``` heroclass = heroclass.toLowerCase(); ``` If you do not do this, the lowercase version of heroclass is not saved.
heroclass is of String type. String is immutable type of object, so you can't update this string. heroclass.toLowerCase() just return another String object with lower cased characters, so you need to reassign this string result to this variable: ``` heroclass = heroclass.toLowerCase(); ```
34,936,039
Env: Windows 10 Pro I installed python 2.7.9 and using `pip` installed `robotframework` and `robotframework-selenium2library` and it all worked fine with no errors. Then I was doing some research and found that unless there is a reason for me to use 2.x versions of Python, I should stick with 3.x versions. Since 3.4 ...
2016/01/21
[ "https://Stackoverflow.com/questions/34936039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4496252/" ]
You need to assign `heroclass.toLowerCase();` to the original value of `heroclass`: ``` heroclass = heroclass.toLowerCase(); ``` If you do not do this, the lowercase version of heroclass is not saved.
Although coding wombat is right, i'm not a big fan of the way you did things here. A loop around your whole program like this isn't good practice. It's super clunky and will lead to many problems, not to mention you're making things more complicated for yourself. Ideally you'd want to put this class selection part of t...
34,936,039
Env: Windows 10 Pro I installed python 2.7.9 and using `pip` installed `robotframework` and `robotframework-selenium2library` and it all worked fine with no errors. Then I was doing some research and found that unless there is a reason for me to use 2.x versions of Python, I should stick with 3.x versions. Since 3.4 ...
2016/01/21
[ "https://Stackoverflow.com/questions/34936039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4496252/" ]
Put your loop in a labeled block: ``` myblock: { while (true) { //code heroclass = heroclass.toLowerCase(); switch(heroclass) { case "slayer": A = "text"; break myblock; //repeat with other cases } } } //goes to here when you say ...
Although coding wombat is right, i'm not a big fan of the way you did things here. A loop around your whole program like this isn't good practice. It's super clunky and will lead to many problems, not to mention you're making things more complicated for yourself. Ideally you'd want to put this class selection part of t...
34,936,039
Env: Windows 10 Pro I installed python 2.7.9 and using `pip` installed `robotframework` and `robotframework-selenium2library` and it all worked fine with no errors. Then I was doing some research and found that unless there is a reason for me to use 2.x versions of Python, I should stick with 3.x versions. Since 3.4 ...
2016/01/21
[ "https://Stackoverflow.com/questions/34936039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4496252/" ]
heroclass is of String type. String is immutable type of object, so you can't update this string. heroclass.toLowerCase() just return another String object with lower cased characters, so you need to reassign this string result to this variable: ``` heroclass = heroclass.toLowerCase(); ```
Although coding wombat is right, i'm not a big fan of the way you did things here. A loop around your whole program like this isn't good practice. It's super clunky and will lead to many problems, not to mention you're making things more complicated for yourself. Ideally you'd want to put this class selection part of t...
73,616,000
I want to hide this warning `UserWarning: pandas only support SQLAlchemy connectable(engine/connection) ordatabase string URI or sqlite3 DBAPI2 connectionother DBAPI2 objects are not tested, please consider using SQLAlchemy` and I've tried ``` import warnings warnings.simplefilter(action='ignore', category=UserWarning...
2022/09/06
[ "https://Stackoverflow.com/questions/73616000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8089312/" ]
It seems I cannot disable the pandas warning, so I used SQLAlchemy (as the warning message wants me to do so) to wrap the psycopg2 connection. I followed the instruction here: [SQLAlchemy for psycopg2 documentation](https://docs.sqlalchemy.org/en/14/dialects/postgresql.html#module-sqlalchemy.dialects.postgresql.psycop...
The warnings that you're filtering right now are warnings of type `FutureWarning`. The warning that you're getting is of type `UserWarning`, so you should change the warning category to `UserWarning`. I hope [this](https://stackoverflow.com/a/71083448/8293793) answers your question regarding why pandas is giving that w...
6,595,673
I'm trying to read a column oriented csv file into R as a data frame. the first line of the file is like so: `sDATE, sTIME,iGPS_ALT, ...` and then each additional line is a measurement: `4/10/2011,2:15,78, ...` when I try to read this into R, via `d = read.csv('filename')` I get a duplicate row.names error since...
2011/07/06
[ "https://Stackoverflow.com/questions/6595673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3926/" ]
`read.csv` only assumes there are any row names if there are less values in the header than in the other rows. So somehow you are either missing a column name or have an extra column you don't want.
You probably DO have an extra column. But it probably arises from a stray formatted cell (or column of cells) that is actually empty, to the right of your data in your original spreadsheet. Here is the key: Excel will save empty fields in the CSV file for any empty cells that are formatted in your sheet. Here is ...
6,595,673
I'm trying to read a column oriented csv file into R as a data frame. the first line of the file is like so: `sDATE, sTIME,iGPS_ALT, ...` and then each additional line is a measurement: `4/10/2011,2:15,78, ...` when I try to read this into R, via `d = read.csv('filename')` I get a duplicate row.names error since...
2011/07/06
[ "https://Stackoverflow.com/questions/6595673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3926/" ]
`read.csv` only assumes there are any row names if there are less values in the header than in the other rows. So somehow you are either missing a column name or have an extra column you don't want.
One possible reason can be an extra comma at the end of lines after the header line. Excel silently ignores them and removes while saving. At least it was the case for me
6,595,673
I'm trying to read a column oriented csv file into R as a data frame. the first line of the file is like so: `sDATE, sTIME,iGPS_ALT, ...` and then each additional line is a measurement: `4/10/2011,2:15,78, ...` when I try to read this into R, via `d = read.csv('filename')` I get a duplicate row.names error since...
2011/07/06
[ "https://Stackoverflow.com/questions/6595673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3926/" ]
`read.csv` only assumes there are any row names if there are less values in the header than in the other rows. So somehow you are either missing a column name or have an extra column you don't want.
I faced the same issue. It got resolved by adding `header=TRUE` like below ``` tempdata <- read.csv("C:\\File.csv",header=TRUE) ``` The first column which was the date column got aligned properly.
6,595,673
I'm trying to read a column oriented csv file into R as a data frame. the first line of the file is like so: `sDATE, sTIME,iGPS_ALT, ...` and then each additional line is a measurement: `4/10/2011,2:15,78, ...` when I try to read this into R, via `d = read.csv('filename')` I get a duplicate row.names error since...
2011/07/06
[ "https://Stackoverflow.com/questions/6595673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3926/" ]
You probably DO have an extra column. But it probably arises from a stray formatted cell (or column of cells) that is actually empty, to the right of your data in your original spreadsheet. Here is the key: Excel will save empty fields in the CSV file for any empty cells that are formatted in your sheet. Here is ...
One possible reason can be an extra comma at the end of lines after the header line. Excel silently ignores them and removes while saving. At least it was the case for me
6,595,673
I'm trying to read a column oriented csv file into R as a data frame. the first line of the file is like so: `sDATE, sTIME,iGPS_ALT, ...` and then each additional line is a measurement: `4/10/2011,2:15,78, ...` when I try to read this into R, via `d = read.csv('filename')` I get a duplicate row.names error since...
2011/07/06
[ "https://Stackoverflow.com/questions/6595673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3926/" ]
You probably DO have an extra column. But it probably arises from a stray formatted cell (or column of cells) that is actually empty, to the right of your data in your original spreadsheet. Here is the key: Excel will save empty fields in the CSV file for any empty cells that are formatted in your sheet. Here is ...
I faced the same issue. It got resolved by adding `header=TRUE` like below ``` tempdata <- read.csv("C:\\File.csv",header=TRUE) ``` The first column which was the date column got aligned properly.
43,882,498
The following code is my pipeline for reading images and labels from files: ``` import tensorflow as tf import numpy as np import tflearn.data_utils from tensorflow.python.framework import ops from tensorflow.python.framework import dtypes import sys #process labels in the input file def process_label(label): inf...
2017/05/10
[ "https://Stackoverflow.com/questions/43882498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/332289/" ]
`tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath)` is called by the table view each time it needs a new cell. If only 12 cells are visible at a time then the table view initially needs only 12 cells so will ask for only 12 cells. You'd have to scroll before it would need to ask for more. It won't...
So interestingly, even though the table is displaying correctly, the printout only reaches 12, and that happens regardless of how many cells you scroll to. Is that what you are finding? This is because you have 12 rows in a view, and the cells are reused, so you are not creating more cells but you are just reusing the ...
23,271,575
I'm trying to get text to display as bold, or in colors, or possibly in italics, in ipython's qtconsole. I found this link: [How do I print bold text in Python?](https://stackoverflow.com/questions/8924173/python-print-bold-text), and used the first and second answers, but in qtconsole, only the underlining option wor...
2014/04/24
[ "https://Stackoverflow.com/questions/23271575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3566002/" ]
Those are ANSI escapes, special sequences of characters which terminals process to switch font styles. The Qt console interprets some of them, but not all of the ones that serious terminals do. This sequence works to print in red, for instance: ``` print('\x1b[1;31m'+'Hello world'+'\x1b[0m') ``` However, if you're t...
If you mean the body text of the iPython notebook (Markdowns), you can put 2 underline characters directly before and after your text to make it **BOLD**: `__BOLD TEXT__` => **BOLD TEXT** if you put a backslash before that, it will be counteracted: `\__BOLD TEXT__` => \_\_BOLD TEXT\_\_
23,271,575
I'm trying to get text to display as bold, or in colors, or possibly in italics, in ipython's qtconsole. I found this link: [How do I print bold text in Python?](https://stackoverflow.com/questions/8924173/python-print-bold-text), and used the first and second answers, but in qtconsole, only the underlining option wor...
2014/04/24
[ "https://Stackoverflow.com/questions/23271575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3566002/" ]
Those are ANSI escapes, special sequences of characters which terminals process to switch font styles. The Qt console interprets some of them, but not all of the ones that serious terminals do. This sequence works to print in red, for instance: ``` print('\x1b[1;31m'+'Hello world'+'\x1b[0m') ``` However, if you're t...
Few more ways you can tweak around (I tried in iPython Notebook, not sure about other).. ``` **BOLD TEXT** ``` Above will produce bold text: **BOLD TEXT** ``` *__BOLD TEXT__* ``` will produce bold and italic text: ***BOLD TEXT***
23,271,575
I'm trying to get text to display as bold, or in colors, or possibly in italics, in ipython's qtconsole. I found this link: [How do I print bold text in Python?](https://stackoverflow.com/questions/8924173/python-print-bold-text), and used the first and second answers, but in qtconsole, only the underlining option wor...
2014/04/24
[ "https://Stackoverflow.com/questions/23271575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3566002/" ]
In Jupyter Notebooks, one clean way of solving this problem is using markdown: ``` from IPython.display import Markdown, display def printmd(string): display(Markdown(string)) ``` And then do something like: ``` printmd("**bold text**") ``` Of course, this is great for bold, italics, etc., but markdown itself...
Those are ANSI escapes, special sequences of characters which terminals process to switch font styles. The Qt console interprets some of them, but not all of the ones that serious terminals do. This sequence works to print in red, for instance: ``` print('\x1b[1;31m'+'Hello world'+'\x1b[0m') ``` However, if you're t...
23,271,575
I'm trying to get text to display as bold, or in colors, or possibly in italics, in ipython's qtconsole. I found this link: [How do I print bold text in Python?](https://stackoverflow.com/questions/8924173/python-print-bold-text), and used the first and second answers, but in qtconsole, only the underlining option wor...
2014/04/24
[ "https://Stackoverflow.com/questions/23271575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3566002/" ]
In Jupyter Notebooks, one clean way of solving this problem is using markdown: ``` from IPython.display import Markdown, display def printmd(string): display(Markdown(string)) ``` And then do something like: ``` printmd("**bold text**") ``` Of course, this is great for bold, italics, etc., but markdown itself...
If you mean the body text of the iPython notebook (Markdowns), you can put 2 underline characters directly before and after your text to make it **BOLD**: `__BOLD TEXT__` => **BOLD TEXT** if you put a backslash before that, it will be counteracted: `\__BOLD TEXT__` => \_\_BOLD TEXT\_\_
23,271,575
I'm trying to get text to display as bold, or in colors, or possibly in italics, in ipython's qtconsole. I found this link: [How do I print bold text in Python?](https://stackoverflow.com/questions/8924173/python-print-bold-text), and used the first and second answers, but in qtconsole, only the underlining option wor...
2014/04/24
[ "https://Stackoverflow.com/questions/23271575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3566002/" ]
I would like to complete the previous incomplete answer. Way more complex and fun things can be done without importing additional packages. e.g. ``` print('\x1b[1;03;31;46m'+'Hello'+ '\x1b[0;4;30;42m' + ' world' '\x1b[0m') ``` i.e.: Open with: ``` '\x1b[XX;YY;ZZm' ``` Close with: ``` '\x1b[0m' ``` Where XX, Y...
If you mean the body text of the iPython notebook (Markdowns), you can put 2 underline characters directly before and after your text to make it **BOLD**: `__BOLD TEXT__` => **BOLD TEXT** if you put a backslash before that, it will be counteracted: `\__BOLD TEXT__` => \_\_BOLD TEXT\_\_
23,271,575
I'm trying to get text to display as bold, or in colors, or possibly in italics, in ipython's qtconsole. I found this link: [How do I print bold text in Python?](https://stackoverflow.com/questions/8924173/python-print-bold-text), and used the first and second answers, but in qtconsole, only the underlining option wor...
2014/04/24
[ "https://Stackoverflow.com/questions/23271575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3566002/" ]
In Jupyter Notebooks, one clean way of solving this problem is using markdown: ``` from IPython.display import Markdown, display def printmd(string): display(Markdown(string)) ``` And then do something like: ``` printmd("**bold text**") ``` Of course, this is great for bold, italics, etc., but markdown itself...
Few more ways you can tweak around (I tried in iPython Notebook, not sure about other).. ``` **BOLD TEXT** ``` Above will produce bold text: **BOLD TEXT** ``` *__BOLD TEXT__* ``` will produce bold and italic text: ***BOLD TEXT***
23,271,575
I'm trying to get text to display as bold, or in colors, or possibly in italics, in ipython's qtconsole. I found this link: [How do I print bold text in Python?](https://stackoverflow.com/questions/8924173/python-print-bold-text), and used the first and second answers, but in qtconsole, only the underlining option wor...
2014/04/24
[ "https://Stackoverflow.com/questions/23271575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3566002/" ]
I would like to complete the previous incomplete answer. Way more complex and fun things can be done without importing additional packages. e.g. ``` print('\x1b[1;03;31;46m'+'Hello'+ '\x1b[0;4;30;42m' + ' world' '\x1b[0m') ``` i.e.: Open with: ``` '\x1b[XX;YY;ZZm' ``` Close with: ``` '\x1b[0m' ``` Where XX, Y...
Few more ways you can tweak around (I tried in iPython Notebook, not sure about other).. ``` **BOLD TEXT** ``` Above will produce bold text: **BOLD TEXT** ``` *__BOLD TEXT__* ``` will produce bold and italic text: ***BOLD TEXT***
23,271,575
I'm trying to get text to display as bold, or in colors, or possibly in italics, in ipython's qtconsole. I found this link: [How do I print bold text in Python?](https://stackoverflow.com/questions/8924173/python-print-bold-text), and used the first and second answers, but in qtconsole, only the underlining option wor...
2014/04/24
[ "https://Stackoverflow.com/questions/23271575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3566002/" ]
In Jupyter Notebooks, one clean way of solving this problem is using markdown: ``` from IPython.display import Markdown, display def printmd(string): display(Markdown(string)) ``` And then do something like: ``` printmd("**bold text**") ``` Of course, this is great for bold, italics, etc., but markdown itself...
I would like to complete the previous incomplete answer. Way more complex and fun things can be done without importing additional packages. e.g. ``` print('\x1b[1;03;31;46m'+'Hello'+ '\x1b[0;4;30;42m' + ' world' '\x1b[0m') ``` i.e.: Open with: ``` '\x1b[XX;YY;ZZm' ``` Close with: ``` '\x1b[0m' ``` Where XX, Y...
17,128,878
I was trying to install `autoclose.vim` to Vim. I noticed I didn't have a `~/.vim/plugin` folder, so I accidentally made a `~/.vim/plugins` folder (notice the extra 's' in plugins). I then added `au FileType python set rtp += ~/.vim/plugins` to my .vimrc, because from what I've read, that will allow me to automatically...
2013/06/15
[ "https://Stackoverflow.com/questions/17128878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2467761/" ]
[:help load-plugins](http://vimdoc.sourceforge.net/htmldoc/starting.html#load-plugins) outlines how plugins are loaded. Adding a folder to your `rtp` alone does not suffice; it must have a `plugin` subdirectory. For example, given `:set rtp+=/tmp/foo`, a file `/tmp/foo/plugin/bar.vim` would be detected and loaded, but...
You are on the right track with `set rtp+=...` but there's a bit more to it (`rtp` is non-recursive, help indexing, many corner cases) than what meets the eye so it is not a very good idea to do it by yourself. Unless you are ready for a months-long drop in productivity. If you want to store all your plugins in a spec...