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
620,954
Are there any easy to use python components that could be used in a GUI? It would be great to have something like JSyntaxPane for Python. I would like to know of python-only versions ( not interested in jython ) .
2009/03/07
[ "https://Stackoverflow.com/questions/620954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
Other than pygments? <http://pygments.org/>
If you're using gtk+, there's a binding of gtksourceview for Python in [gnome-python-extras](http://ftp.gnome.org/pub/GNOME/sources/gnome-python-extras/2.25/). It seems to work well in my experience. The downside: the documentation is less than perfect. There's also a binding of [QScintilla](http://www.riverbankcomput...
620,954
Are there any easy to use python components that could be used in a GUI? It would be great to have something like JSyntaxPane for Python. I would like to know of python-only versions ( not interested in jython ) .
2009/03/07
[ "https://Stackoverflow.com/questions/620954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
Other than pygments? <http://pygments.org/>
You can use [StyledTextCtrl](http://www.wxpython.org/docs/api/wx.stc.StyledTextCtrl-class.html) in [wxPython](http://www.wxpython.org). Check out the official demo for an example (The *demo code* tab for any demo).
620,954
Are there any easy to use python components that could be used in a GUI? It would be great to have something like JSyntaxPane for Python. I would like to know of python-only versions ( not interested in jython ) .
2009/03/07
[ "https://Stackoverflow.com/questions/620954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
Other than pygments? <http://pygments.org/>
You say "in a GUI app" but don't mention the toolkit. If you are using PyQt, and need a read-only widget, you can use QWebKit which has a whole HTML widget in it based on WebKit, so it supports pretty much anything, from flash to the ACID2 test. If you want a read-write widget, Qt's QTextEdit supports syntax highligh...
620,954
Are there any easy to use python components that could be used in a GUI? It would be great to have something like JSyntaxPane for Python. I would like to know of python-only versions ( not interested in jython ) .
2009/03/07
[ "https://Stackoverflow.com/questions/620954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
If you're using gtk+, there's a binding of gtksourceview for Python in [gnome-python-extras](http://ftp.gnome.org/pub/GNOME/sources/gnome-python-extras/2.25/). It seems to work well in my experience. The downside: the documentation is less than perfect. There's also a binding of [QScintilla](http://www.riverbankcomput...
You can use [StyledTextCtrl](http://www.wxpython.org/docs/api/wx.stc.StyledTextCtrl-class.html) in [wxPython](http://www.wxpython.org). Check out the official demo for an example (The *demo code* tab for any demo).
620,954
Are there any easy to use python components that could be used in a GUI? It would be great to have something like JSyntaxPane for Python. I would like to know of python-only versions ( not interested in jython ) .
2009/03/07
[ "https://Stackoverflow.com/questions/620954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
If you're using gtk+, there's a binding of gtksourceview for Python in [gnome-python-extras](http://ftp.gnome.org/pub/GNOME/sources/gnome-python-extras/2.25/). It seems to work well in my experience. The downside: the documentation is less than perfect. There's also a binding of [QScintilla](http://www.riverbankcomput...
You say "in a GUI app" but don't mention the toolkit. If you are using PyQt, and need a read-only widget, you can use QWebKit which has a whole HTML widget in it based on WebKit, so it supports pretty much anything, from flash to the ACID2 test. If you want a read-write widget, Qt's QTextEdit supports syntax highligh...
620,954
Are there any easy to use python components that could be used in a GUI? It would be great to have something like JSyntaxPane for Python. I would like to know of python-only versions ( not interested in jython ) .
2009/03/07
[ "https://Stackoverflow.com/questions/620954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
You can use [StyledTextCtrl](http://www.wxpython.org/docs/api/wx.stc.StyledTextCtrl-class.html) in [wxPython](http://www.wxpython.org). Check out the official demo for an example (The *demo code* tab for any demo).
You say "in a GUI app" but don't mention the toolkit. If you are using PyQt, and need a read-only widget, you can use QWebKit which has a whole HTML widget in it based on WebKit, so it supports pretty much anything, from flash to the ACID2 test. If you want a read-write widget, Qt's QTextEdit supports syntax highligh...
60,396,222
I know there are questions like that but I still wanted to ask this because I couldn't solve, so there is my code: ``` #! python3 import os my_path = 'E:\\Movies' for folder in os.listdir(my_path): size = os.path.getsize(folder) print(f'size of the {folder} is: {size} ') ``` And I got this error: ``` Tr...
2020/02/25
[ "https://Stackoverflow.com/questions/60396222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10577122/" ]
Temporary tables are created using the server's collation by default. It looks like your server's collation is `SQL_Latin1_General_CP1_CI_AS` and the database's (actually, the column's) `Hebrew_CI_AS` or vice versa. You can overcome this by using `collate database_default` in the temporary table's column definitions, ...
In your temp table definition #x,add COLLATE DATABASE\_DEFAULT to the String columns, like ``` custName nvarchar(xx) COLLATE DATABASE_DEFAULT NOT NULL ```
29,723,590
I'm trying to set up Python to run on my local apache server on a mac. On `httpd.conf`, I've ``` <VirtualHost *:80> DocumentRoot "/Users/ptamzz/Sites/python/sandbox.ptamzz.com" <Directory "/Users/pritams/Sites/python/sandbox.ptamzz.com"> Options Indexes FollowSymLinks MultiViews ExecCGI AddHa...
2015/04/18
[ "https://Stackoverflow.com/questions/29723590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383393/" ]
**Executing python in Apache ( cgi )** System : OSX yosmite 10.10.3 , Default apache **uncommented in http config** ``` LoadModule cgi_module libexec/apache2/mod_cgi.so ``` **virtual hosts entry** ``` <VirtualHost *:80> # Hook virtual host domain name into physical location. ServerName python.localhost ...
For later Versions of Apache (2.4) the answer of Sojan V Jose is mostly still applying, except that I got an authorization failure, that can be resolved by replacing: ``` Order allow,deny Allow from all ``` with: ``` Require all granted ```
70,125,767
I am a student, new to python. I am trying to code a program that will tell if a user input number is fibonacci or not. ``` num=int(input("Enter the number you want to check\n")) temp=1 k=0 a=0 summ=0 while summ<=num: summ=temp+k temp=summ k=temp if summ==num: a=a+1 print("Yes. {} is a ...
2021/11/26
[ "https://Stackoverflow.com/questions/70125767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17517066/" ]
You don't need quite so many variables. A Fibonacci integer sequence can be generated with the single assignment ``` a, b = b, a + b # Short for # temp = a # a = b # b = temp + b ``` Repeated applications sets `a` to the numbers in the pattern in sequence. The choice of initial values for `a` and `b` d...
I'd suggest something like this: ``` fib_terms = [0, 1] # first two fibonacci terms user_input= int(input('Enter the number you want to check\n')) # Add new fibonacci terms until the user_input is reached while fib_terms[-1] <= user_input: fib_terms.append(fib_terms[-1] + fib_terms[-2]) if user_input in fib_te...
70,125,767
I am a student, new to python. I am trying to code a program that will tell if a user input number is fibonacci or not. ``` num=int(input("Enter the number you want to check\n")) temp=1 k=0 a=0 summ=0 while summ<=num: summ=temp+k temp=summ k=temp if summ==num: a=a+1 print("Yes. {} is a ...
2021/11/26
[ "https://Stackoverflow.com/questions/70125767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17517066/" ]
You don't need quite so many variables. A Fibonacci integer sequence can be generated with the single assignment ``` a, b = b, a + b # Short for # temp = a # a = b # b = temp + b ``` Repeated applications sets `a` to the numbers in the pattern in sequence. The choice of initial values for `a` and `b` d...
welcome to the python community. In Your code `temp` means the previous number and `k` means the previous number of `temp`. The problem is that you change the `temp` before you assign the next value to `k`. To solve that you just have to sawp the lines 8 and 9. In the new order you first assign the value of `temp` to ...
70,125,767
I am a student, new to python. I am trying to code a program that will tell if a user input number is fibonacci or not. ``` num=int(input("Enter the number you want to check\n")) temp=1 k=0 a=0 summ=0 while summ<=num: summ=temp+k temp=summ k=temp if summ==num: a=a+1 print("Yes. {} is a ...
2021/11/26
[ "https://Stackoverflow.com/questions/70125767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17517066/" ]
You don't need quite so many variables. A Fibonacci integer sequence can be generated with the single assignment ``` a, b = b, a + b # Short for # temp = a # a = b # b = temp + b ``` Repeated applications sets `a` to the numbers in the pattern in sequence. The choice of initial values for `a` and `b` d...
Check this: ``` def fibonacci_list(limit): u_n_1 = 1 u_n_2 = 1 u_n = 1 out_list = [u_n] while u_n <= limit: out_list.append(u_n) u_n = u_n_1 + u_n_2 u_n_2 = u_n_1 u_n_1 = u_n return out_list def is_fibonacci_number(n): if n in fibonacci_list(n): retu...
70,125,767
I am a student, new to python. I am trying to code a program that will tell if a user input number is fibonacci or not. ``` num=int(input("Enter the number you want to check\n")) temp=1 k=0 a=0 summ=0 while summ<=num: summ=temp+k temp=summ k=temp if summ==num: a=a+1 print("Yes. {} is a ...
2021/11/26
[ "https://Stackoverflow.com/questions/70125767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17517066/" ]
You don't need quite so many variables. A Fibonacci integer sequence can be generated with the single assignment ``` a, b = b, a + b # Short for # temp = a # a = b # b = temp + b ``` Repeated applications sets `a` to the numbers in the pattern in sequence. The choice of initial values for `a` and `b` d...
``` bool checkfibonacci(int n) { int a = 0; int b = 1; if (n == a || n == b) return true; int c = a + b; while(c <= n) { if(c == n) return true; a = b; b = c; c = a + b; } return false; } ``` Someth...
46,035,788
I'm trying to use python to search through a directory of files and open every single file in search of a string. We're talking about less than 1000 files with 1, 2, 3 line each, so opening them all only takes a few seconds. Well, I think that I've made it, but there's a problem: the string that I'm search for is "**...
2017/09/04
[ "https://Stackoverflow.com/questions/46035788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6834568/" ]
Because the start of your pattern match the empty string: ``` /|google... ``` That means: nothing OR google ...
This pattern is invalid: ``` |google|robot|bot|spider|crawler|curl|Facebot|facebook|archiver|^$ ^ | +--- this character (an alternator) effectively renders the regex useless ``` This means that the regex could in theory match anything because the left part is empty. Moreover, `^$` on the right of the last alternato...
40,981,908
I'm new to AWS Lambda and pretty new to Python. I wanted to write a python lambda that uses the AWS API. boto is the most popular python module to do this so I wanted to include it. Looking at examples online I put `import boto3` at the top of my Lambda and it just worked- I was able to use boto in my Lambda. How ...
2016/12/05
[ "https://Stackoverflow.com/questions/40981908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1028270/" ]
[The documentation](http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html) seems to suggest `boto3` is provided by default on AWS Lambda: > > AWS Lambda includes the AWS SDK for Python (Boto 3), so you don't need to include it in your deployment package. However, if you want ...
AWS Lambda includes the AWS SDK for Python (Boto 3), so you don't need to include it in your deployment package. This link will give you a little more in-depth info on Lambda environment <https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/> And this too <https://alestic.com/2014/12/aws-lambda-persistence...
40,981,908
I'm new to AWS Lambda and pretty new to Python. I wanted to write a python lambda that uses the AWS API. boto is the most popular python module to do this so I wanted to include it. Looking at examples online I put `import boto3` at the top of my Lambda and it just worked- I was able to use boto in my Lambda. How ...
2016/12/05
[ "https://Stackoverflow.com/questions/40981908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1028270/" ]
AWS Lambda's Python environment comes pre-installed with `boto3`. Any other libraries you want need to be part of the zip you upload. You can install them locally with `pip install whatever -t mysrcfolder`.
AWS Lambda includes the AWS SDK for Python (Boto 3), so you don't need to include it in your deployment package. This link will give you a little more in-depth info on Lambda environment <https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/> And this too <https://alestic.com/2014/12/aws-lambda-persistence...
26,278,386
I have a list or array (what is the correct term in python?) of objects. What is the most efficient way to get all objects matching a condition? I could iterate over the list and check each element, but that doesn't seem very efficient. ``` objects = [] for object in list: if object.value == "123": objects.add(...
2014/10/09
[ "https://Stackoverflow.com/questions/26278386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1474934/" ]
This is the simplest way: ``` objects = [x for x in someList if x.value == 123] ``` If you're looking for a *faster* solution, you have to tell us more about your objects and how the source list is built. For example, if the property in question is unique among the objects, you can have better performance using `dic...
You can use `filter` ``` objects = filter(lambda i: i.value == '123', l) ``` *Note to self* Apparently the ["filter vs list comp"](https://stackoverflow.com/questions/3013449/list-filtering-list-comprehension-vs-lambda-filter) debate starts flame wars.
41,079,379
I have to program a task in python 3.4 that requires the following: - The program ask the user to enter a data model that is made by several submodels in a form of string like the following: ``` # the program ask : please input the submodel1 # user will input: A = a*x + b*y*exp(3*c/d*x) # then the program ask : -> pl...
2016/12/10
[ "https://Stackoverflow.com/questions/41079379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4434914/" ]
Invisible reCAPTCHA =================== Implementing Google's new Invisible reCAPTCHA is very similar to how we add v2 to our site. You may add it as its own container like normal, or the new method of adding it to the form submit button. I hope this guide will help you along the correct path. Standalone CAPTCHA Cont...
If you're looking for a fully customizable general solution which will even work with multiple forms on the same page, I'll explicitly render the reCaptcha widget by using the **render=explicit** and **onload=aFunctionCallback** parameters. Here is a simple example: ```html <!DOCTYPE html> <html> <body> <form act...
41,079,379
I have to program a task in python 3.4 that requires the following: - The program ask the user to enter a data model that is made by several submodels in a form of string like the following: ``` # the program ask : please input the submodel1 # user will input: A = a*x + b*y*exp(3*c/d*x) # then the program ask : -> pl...
2016/12/10
[ "https://Stackoverflow.com/questions/41079379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4434914/" ]
Invisible reCAPTCHA =================== Implementing Google's new Invisible reCAPTCHA is very similar to how we add v2 to our site. You may add it as its own container like normal, or the new method of adding it to the form submit button. I hope this guide will help you along the correct path. Standalone CAPTCHA Cont...
1. Login with your google account 2. Visit the google recaptcha link. 3. Then follow the link to code integration, follow the code for both client and serverside validation. <https://developers.google.com/recaptcha/docs/invisible> 4. Increase or decrease the security level once after creating the recaptcha, go to the a...
41,079,379
I have to program a task in python 3.4 that requires the following: - The program ask the user to enter a data model that is made by several submodels in a form of string like the following: ``` # the program ask : please input the submodel1 # user will input: A = a*x + b*y*exp(3*c/d*x) # then the program ask : -> pl...
2016/12/10
[ "https://Stackoverflow.com/questions/41079379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4434914/" ]
Invisible reCAPTCHA =================== Implementing Google's new Invisible reCAPTCHA is very similar to how we add v2 to our site. You may add it as its own container like normal, or the new method of adding it to the form submit button. I hope this guide will help you along the correct path. Standalone CAPTCHA Cont...
Here is how to implement a client + server side **(php)** Invisible reCaptcha functionality: * Client Side ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>reCaptcha</title> <!--api link--> <script src="https://www.google.com/recaptcha/api.js" async defer></script> <!...
41,079,379
I have to program a task in python 3.4 that requires the following: - The program ask the user to enter a data model that is made by several submodels in a form of string like the following: ``` # the program ask : please input the submodel1 # user will input: A = a*x + b*y*exp(3*c/d*x) # then the program ask : -> pl...
2016/12/10
[ "https://Stackoverflow.com/questions/41079379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4434914/" ]
Invisible reCAPTCHA =================== Implementing Google's new Invisible reCAPTCHA is very similar to how we add v2 to our site. You may add it as its own container like normal, or the new method of adding it to the form submit button. I hope this guide will help you along the correct path. Standalone CAPTCHA Cont...
Here is a **working** example: ``` <html lang="en"> <head> <meta charset="UTF-8"> <title>ReCAPTCHA Example</title> </head> <body> <div class="container"> <form method="post" action="/contact/" id="contact-form"> <h3 class="title-divider"> <span>Contact Us</span> </h3> <input type="text" name="...
41,079,379
I have to program a task in python 3.4 that requires the following: - The program ask the user to enter a data model that is made by several submodels in a form of string like the following: ``` # the program ask : please input the submodel1 # user will input: A = a*x + b*y*exp(3*c/d*x) # then the program ask : -> pl...
2016/12/10
[ "https://Stackoverflow.com/questions/41079379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4434914/" ]
If you're looking for a fully customizable general solution which will even work with multiple forms on the same page, I'll explicitly render the reCaptcha widget by using the **render=explicit** and **onload=aFunctionCallback** parameters. Here is a simple example: ```html <!DOCTYPE html> <html> <body> <form act...
1. Login with your google account 2. Visit the google recaptcha link. 3. Then follow the link to code integration, follow the code for both client and serverside validation. <https://developers.google.com/recaptcha/docs/invisible> 4. Increase or decrease the security level once after creating the recaptcha, go to the a...
41,079,379
I have to program a task in python 3.4 that requires the following: - The program ask the user to enter a data model that is made by several submodels in a form of string like the following: ``` # the program ask : please input the submodel1 # user will input: A = a*x + b*y*exp(3*c/d*x) # then the program ask : -> pl...
2016/12/10
[ "https://Stackoverflow.com/questions/41079379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4434914/" ]
If you're looking for a fully customizable general solution which will even work with multiple forms on the same page, I'll explicitly render the reCaptcha widget by using the **render=explicit** and **onload=aFunctionCallback** parameters. Here is a simple example: ```html <!DOCTYPE html> <html> <body> <form act...
Here is a **working** example: ``` <html lang="en"> <head> <meta charset="UTF-8"> <title>ReCAPTCHA Example</title> </head> <body> <div class="container"> <form method="post" action="/contact/" id="contact-form"> <h3 class="title-divider"> <span>Contact Us</span> </h3> <input type="text" name="...
41,079,379
I have to program a task in python 3.4 that requires the following: - The program ask the user to enter a data model that is made by several submodels in a form of string like the following: ``` # the program ask : please input the submodel1 # user will input: A = a*x + b*y*exp(3*c/d*x) # then the program ask : -> pl...
2016/12/10
[ "https://Stackoverflow.com/questions/41079379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4434914/" ]
Here is how to implement a client + server side **(php)** Invisible reCaptcha functionality: * Client Side ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>reCaptcha</title> <!--api link--> <script src="https://www.google.com/recaptcha/api.js" async defer></script> <!...
1. Login with your google account 2. Visit the google recaptcha link. 3. Then follow the link to code integration, follow the code for both client and serverside validation. <https://developers.google.com/recaptcha/docs/invisible> 4. Increase or decrease the security level once after creating the recaptcha, go to the a...
41,079,379
I have to program a task in python 3.4 that requires the following: - The program ask the user to enter a data model that is made by several submodels in a form of string like the following: ``` # the program ask : please input the submodel1 # user will input: A = a*x + b*y*exp(3*c/d*x) # then the program ask : -> pl...
2016/12/10
[ "https://Stackoverflow.com/questions/41079379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4434914/" ]
Here is a **working** example: ``` <html lang="en"> <head> <meta charset="UTF-8"> <title>ReCAPTCHA Example</title> </head> <body> <div class="container"> <form method="post" action="/contact/" id="contact-form"> <h3 class="title-divider"> <span>Contact Us</span> </h3> <input type="text" name="...
1. Login with your google account 2. Visit the google recaptcha link. 3. Then follow the link to code integration, follow the code for both client and serverside validation. <https://developers.google.com/recaptcha/docs/invisible> 4. Increase or decrease the security level once after creating the recaptcha, go to the a...
41,079,379
I have to program a task in python 3.4 that requires the following: - The program ask the user to enter a data model that is made by several submodels in a form of string like the following: ``` # the program ask : please input the submodel1 # user will input: A = a*x + b*y*exp(3*c/d*x) # then the program ask : -> pl...
2016/12/10
[ "https://Stackoverflow.com/questions/41079379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4434914/" ]
Here is how to implement a client + server side **(php)** Invisible reCaptcha functionality: * Client Side ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>reCaptcha</title> <!--api link--> <script src="https://www.google.com/recaptcha/api.js" async defer></script> <!...
Here is a **working** example: ``` <html lang="en"> <head> <meta charset="UTF-8"> <title>ReCAPTCHA Example</title> </head> <body> <div class="container"> <form method="post" action="/contact/" id="contact-form"> <h3 class="title-divider"> <span>Contact Us</span> </h3> <input type="text" name="...
7,378,431
How to add data to a relationship with multiple foreign keys in Django? I'm building a simulation written in python and would like to use django's orm to store (intermediate and final) results in a database. Therefore I am not concerned with urls and views. The problem I am having is the instantiation of an object wi...
2011/09/11
[ "https://Stackoverflow.com/questions/7378431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/939186/" ]
Try using [PAM](http://en.wikipedia.org/wiki/Pluggable_Authentication_Modules) via [Python PAM](http://atlee.ca/software/pam/) or similar
That should be possible by having your script read the `/etc/passwd` and `/etc/shadow` files, which contain details about usernames and passwords on a Linux system. Do note that the script will have to have read access to the files, which depending on the situation may or may not be possible. Here are two good article...
3,495,290
relatively long-time PHP user here. I could install XAMPP in my sleep at this point to the point where I can get a PHP script running in the browser at "localhost", but in my searches to find a similar path using Python, I've run out of Googling ideas. I've discovered the mod\_python Apache mod, but then I also discove...
2010/08/16
[ "https://Stackoverflow.com/questions/3495290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/385950/" ]
well mod\_python has been retired. So in order to host python apps you want `mod_wsgi` <http://code.google.com/p/modwsgi/> But python isn't really like php(as in you mix it with html to get output, if I understand your question correctly). In learning python, using the command line/repl will probably be much more us...
Most Python webframeworks have a built-in minimal development server: * [Flask](http://flask.pocoo.org/docs/quickstart/) * [Turbogears](http://turbogears.org/2.0/docs/main/QuickStart.html#run-the-server) * [Django](http://docs.djangoproject.com/en/dev/ref/django-admin/#runserver-port-or-ipaddr-port) * [Pylons](http://...
3,495,290
relatively long-time PHP user here. I could install XAMPP in my sleep at this point to the point where I can get a PHP script running in the browser at "localhost", but in my searches to find a similar path using Python, I've run out of Googling ideas. I've discovered the mod\_python Apache mod, but then I also discove...
2010/08/16
[ "https://Stackoverflow.com/questions/3495290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/385950/" ]
well mod\_python has been retired. So in order to host python apps you want `mod_wsgi` <http://code.google.com/p/modwsgi/> But python isn't really like php(as in you mix it with html to get output, if I understand your question correctly). In learning python, using the command line/repl will probably be much more us...
Many options, here are a couple: * [mod\_wsgi](http://code.google.com/p/modwsgi/) is an Apache module that is suitable for production environments * [SimpleHTTPServer](http://docs.python.org/library/simplehttpserver.html) ships with Python and is easy to use * frameworks like [Django](http://www.djangoproject.com/) o...
40,879,188
np.where lets you pick values to assign for a boolean type query, e.g. ``` test = [0,1,2] np.where(test==0,'True','False') print test ['True','False','False'] ``` Which is basically an 'if' statement. Is there a pythonic way of having an 'if, else if, else' kind of statement (with different cases) for a numpy array?...
2016/11/30
[ "https://Stackoverflow.com/questions/40879188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5531108/" ]
`np.choose` is something of a multielement `where`: ``` In [97]: np.choose([0,1,1,2,0,1],['red','green','blue']) Out[97]: array(['red', 'green', 'green', 'blue', 'red', 'green'], dtype='<U5') In [113]: np.choose([0,1,2],[0,np.array([1,2,3])[:,None], np.arange(10,13)]) Out[113]: array([[ 0, 1, 12], [ 0...
One of the more Pythonic ways to do this would be to use a list comprehension, like this: ``` >>> color = [0,1,2] >>> ['red' if c == 0 else 'blue' if c == 1 else 'green' for c in color] ['red', 'blue', 'green'] ``` It's fairly intuitive if you read it. For a given item in the list `color`, the value in the new list ...
40,879,188
np.where lets you pick values to assign for a boolean type query, e.g. ``` test = [0,1,2] np.where(test==0,'True','False') print test ['True','False','False'] ``` Which is basically an 'if' statement. Is there a pythonic way of having an 'if, else if, else' kind of statement (with different cases) for a numpy array?...
2016/11/30
[ "https://Stackoverflow.com/questions/40879188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5531108/" ]
[numpy.select()](https://numpy.org/doc/stable/reference/generated/numpy.select.html) is what you want here. It is the numpy version of case when. Syntax: ``` import numpy as np color = np.array([0,1,2]) condlist = [color == 1, color == 2, color == 3] choicelist = ['red', 'blue', 'green'] np.select(condlist, choicelist...
One of the more Pythonic ways to do this would be to use a list comprehension, like this: ``` >>> color = [0,1,2] >>> ['red' if c == 0 else 'blue' if c == 1 else 'green' for c in color] ['red', 'blue', 'green'] ``` It's fairly intuitive if you read it. For a given item in the list `color`, the value in the new list ...
40,879,188
np.where lets you pick values to assign for a boolean type query, e.g. ``` test = [0,1,2] np.where(test==0,'True','False') print test ['True','False','False'] ``` Which is basically an 'if' statement. Is there a pythonic way of having an 'if, else if, else' kind of statement (with different cases) for a numpy array?...
2016/11/30
[ "https://Stackoverflow.com/questions/40879188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5531108/" ]
[numpy.select()](https://numpy.org/doc/stable/reference/generated/numpy.select.html) is what you want here. It is the numpy version of case when. Syntax: ``` import numpy as np color = np.array([0,1,2]) condlist = [color == 1, color == 2, color == 3] choicelist = ['red', 'blue', 'green'] np.select(condlist, choicelist...
`np.choose` is something of a multielement `where`: ``` In [97]: np.choose([0,1,1,2,0,1],['red','green','blue']) Out[97]: array(['red', 'green', 'green', 'blue', 'red', 'green'], dtype='<U5') In [113]: np.choose([0,1,2],[0,np.array([1,2,3])[:,None], np.arange(10,13)]) Out[113]: array([[ 0, 1, 12], [ 0...
24,606,931
I have tried for hours to install `FiPy` I've installed Pip and many other things to get it to work. Pip successfull installed many of the things I needed but I cannot get it to work for PySparse or FiPy. Why I try, to install PySparse I get an error: ``` $ pip install pysparse Downloading/unpacking pysparse Could n...
2014/07/07
[ "https://Stackoverflow.com/questions/24606931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3811717/" ]
I've just encountered the same problems you did, and here are my work-arounds: Pysparse: pip doesn't find the pysparse distribution in PyPI because it appears to not be a stable version (see e.g. [Could not find a version that satisfies the requirement pytz](https://stackoverflow.com/questions/18230956/could-not-find-...
PySparse is not a strict requirement for FiPy. FiPy needs one of PySparse, Scipy or Trilinos as a linear solver and Scipy is probably the easiest to install. To check that FiPy has access to a linear solver, you can run the tests, ``` $ python -c "import fipy; fipy.test()" ``` It should be evident from the test outp...
55,016,775
I need help making a mirrored right triangle like below ``` 1 21 321 4321 54321 654321 ``` I can print a regular right triangle with the code below ``` print("Pattern A") for i in range(8): for j in range(1,i): print(j, end="") print("") ``` Which prints ``` 1 12 123 1234 12345 1...
2019/03/06
[ "https://Stackoverflow.com/questions/55016775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11157933/" ]
Here is one using the new f-string formatting system: ``` def test(x): s = "" for i in range(1,x+1): s = str(i) + s print(f'{s:>{x}}') test(6) ```
Something like this works. I loop over the amount of lines, add the whitespace needed for that line and print the numbers. ``` def test(x): for i in range(1,x+1): print((x-i)*(" ") + "".join(str(j+1) for j in range(i))) test(6) ```
44,690,174
How to convert a column that has been read as a string into a column of arrays? i.e. convert from below schema ``` scala> test.printSchema root |-- a: long (nullable = true) |-- b: string (nullable = true) +---+---+ | a| b| +---+---+ | 1|2,3| +---+---+ | 2|4,5| +---+---+ ``` To: ``` scala> test1.printSchema...
2017/06/22
[ "https://Stackoverflow.com/questions/44690174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4531806/" ]
There are various method, The best way to do is using `split` function and cast to `array<long>` ``` data.withColumn("b", split(col("b"), ",").cast("array<long>")) ``` You can also create simple udf to convert the values ``` val tolong = udf((value : String) => value.split(",").map(_.toLong)) data.withColumn("ne...
Using a [UDF](https://jaceklaskowski.gitbooks.io/mastering-apache-spark/spark-sql-udfs.html) would give you exact required schema. Like this: ``` val toArray = udf((b: String) => b.split(",").map(_.toLong)) val test1 = test.withColumn("b", toArray(col("b"))) ``` It would give you schema as follows: ``` scala> test...
44,690,174
How to convert a column that has been read as a string into a column of arrays? i.e. convert from below schema ``` scala> test.printSchema root |-- a: long (nullable = true) |-- b: string (nullable = true) +---+---+ | a| b| +---+---+ | 1|2,3| +---+---+ | 2|4,5| +---+---+ ``` To: ``` scala> test1.printSchema...
2017/06/22
[ "https://Stackoverflow.com/questions/44690174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4531806/" ]
There are various method, The best way to do is using `split` function and cast to `array<long>` ``` data.withColumn("b", split(col("b"), ",").cast("array<long>")) ``` You can also create simple udf to convert the values ``` val tolong = udf((value : String) => value.split(",").map(_.toLong)) data.withColumn("ne...
In python (pyspark) it would be: ``` from pyspark.sql.types import * from pyspark.sql.functions import col, split test = test.withColumn( "b", split(col("b"), ",\s*").cast("array<int>").alias("ev") ) ```
29,989,024
Im trying to use a [specific gamma corrected grayscale implementation](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0029740) - Gleam to convert an images pixels to grayscale. How can i do this manually with PIL python? ``` def tau_gamma_correct(pixel_channel): pixel_channel = pixel_channel**(1/...
2015/05/01
[ "https://Stackoverflow.com/questions/29989024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/688830/" ]
I found that i could just build another image: ``` import sys import os import glob import numpy from PIL import Image def tau_gamma_correct(pixel_channel): pixel_channel = pixel_channel**(1/2.2) return pixel_channel #@param: rgb #@result: returns grayscale value def gleam(rgb): #convert rgb tuple to lis...
Seeing the `SystemError: new style getargs format but argument is not a tuple` error it seems that you need to return a tuple, which is represented as : ``` sample_tuple = (1, 2, 3, 4) ``` So we edit the `gleam()` function as: ``` def gleam(rgb): #convert rgb tuple to list rgblist = list(rgb) #gamma cor...
29,989,024
Im trying to use a [specific gamma corrected grayscale implementation](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0029740) - Gleam to convert an images pixels to grayscale. How can i do this manually with PIL python? ``` def tau_gamma_correct(pixel_channel): pixel_channel = pixel_channel**(1/...
2015/05/01
[ "https://Stackoverflow.com/questions/29989024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/688830/" ]
The problem is that `image.mode = 'L'` doesn't actually change the type of the image, it just changes the attribute so it's no longer accurate. To change the mode of the image you need to make a new copy with [`image.convert('L')`](http://effbot.org/imagingbook/image.htm#tag-Image.Image.convert). Once you have an imag...
Seeing the `SystemError: new style getargs format but argument is not a tuple` error it seems that you need to return a tuple, which is represented as : ``` sample_tuple = (1, 2, 3, 4) ``` So we edit the `gleam()` function as: ``` def gleam(rgb): #convert rgb tuple to list rgblist = list(rgb) #gamma cor...
29,989,024
Im trying to use a [specific gamma corrected grayscale implementation](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0029740) - Gleam to convert an images pixels to grayscale. How can i do this manually with PIL python? ``` def tau_gamma_correct(pixel_channel): pixel_channel = pixel_channel**(1/...
2015/05/01
[ "https://Stackoverflow.com/questions/29989024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/688830/" ]
I found that i could just build another image: ``` import sys import os import glob import numpy from PIL import Image def tau_gamma_correct(pixel_channel): pixel_channel = pixel_channel**(1/2.2) return pixel_channel #@param: rgb #@result: returns grayscale value def gleam(rgb): #convert rgb tuple to lis...
The problem is that `image.mode = 'L'` doesn't actually change the type of the image, it just changes the attribute so it's no longer accurate. To change the mode of the image you need to make a new copy with [`image.convert('L')`](http://effbot.org/imagingbook/image.htm#tag-Image.Image.convert). Once you have an imag...
66,312,791
i have a python script to download and save a MP3 and i would like to add code to cut out 5 seconds from the beginning of the MP3. ``` def download(): ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': 'c:/MP3/%(title)s.%(ext)s', 'cookiefile': 'cookies.txt', 'postprocessors': [{ ...
2021/02/22
[ "https://Stackoverflow.com/questions/66312791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11675699/" ]
I don't think you can directly limit the width of the `Textfield`, it will take the max width of its parent element. But you can put it in a parent element with fixable width: ```py v.Row( children = [ v.Html( tag = 'div', style_ = 'width: 500px', children = [ ...
Here is the best I have so far, based on Christoph's answer: I added v.Spacer, and converted the second part to a v.Col (might be worth also including the first part to a v.Col ?) ``` import ipyvuetify as v v.Row( children = [ v.Html( tag = 'div', style_ = 'width: 50px', ...
66,312,791
i have a python script to download and save a MP3 and i would like to add code to cut out 5 seconds from the beginning of the MP3. ``` def download(): ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': 'c:/MP3/%(title)s.%(ext)s', 'cookiefile': 'cookies.txt', 'postprocessors': [{ ...
2021/02/22
[ "https://Stackoverflow.com/questions/66312791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11675699/" ]
Adding a `max-width:50px` to the TextField style works. ```py import ipyvuetify as v text_field_widget = v.TextField( style_ = "max-width:50px", v_model=None, type="number") #Textfield should be an one digit number... row = v.Row(class_ = 'mx-2',children=[text_field_widget, v.Html(tag='H1',children=['Some text here'])...
I don't think you can directly limit the width of the `Textfield`, it will take the max width of its parent element. But you can put it in a parent element with fixable width: ```py v.Row( children = [ v.Html( tag = 'div', style_ = 'width: 500px', children = [ ...
66,312,791
i have a python script to download and save a MP3 and i would like to add code to cut out 5 seconds from the beginning of the MP3. ``` def download(): ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': 'c:/MP3/%(title)s.%(ext)s', 'cookiefile': 'cookies.txt', 'postprocessors': [{ ...
2021/02/22
[ "https://Stackoverflow.com/questions/66312791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11675699/" ]
Adding a `max-width:50px` to the TextField style works. ```py import ipyvuetify as v text_field_widget = v.TextField( style_ = "max-width:50px", v_model=None, type="number") #Textfield should be an one digit number... row = v.Row(class_ = 'mx-2',children=[text_field_widget, v.Html(tag='H1',children=['Some text here'])...
Here is the best I have so far, based on Christoph's answer: I added v.Spacer, and converted the second part to a v.Col (might be worth also including the first part to a v.Col ?) ``` import ipyvuetify as v v.Row( children = [ v.Html( tag = 'div', style_ = 'width: 50px', ...
44,141,117
I am trying to print fibonacci series using lists in python. This is my code ``` f=[1,1] for i in range(8): f.append(f[i-1]+f[i-2]) print(f) ``` output is ``` [1, 1, 2, 3, 2, 3, 5, 5, 5, 8] ``` I am not getting the bug here!
2017/05/23
[ "https://Stackoverflow.com/questions/44141117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054946/" ]
``` f=[1,1] for i in range(8): s=len(f) f.append(f[s-1]+f[s-2]) #sum of last two elements print(f) ``` or use -1 and -2 as index for two last element.
Script ``` f=[1,1] for i in range(2,8): print(i) f.append(f[i-1]+f[i-2]) print(f) ``` Output ``` 2 [1, 1, 2] 3 [1, 1, 2, 3] 4 [1, 1, 2, 3, 5] 5 [1, 1, 2, 3, 5, 8] 6 [1, 1, 2, 3, 5, 8, 13] 7 [1, 1, 2, 3, 5, 8, 13, 21] ``` Issue is `i` starts from 0, `f[-1], f[-2]` returns 0. start using range from 2 and 8 r...
44,141,117
I am trying to print fibonacci series using lists in python. This is my code ``` f=[1,1] for i in range(8): f.append(f[i-1]+f[i-2]) print(f) ``` output is ``` [1, 1, 2, 3, 2, 3, 5, 5, 5, 8] ``` I am not getting the bug here!
2017/05/23
[ "https://Stackoverflow.com/questions/44141117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054946/" ]
``` f=[1,1] for i in range(8): s=len(f) f.append(f[s-1]+f[s-2]) #sum of last two elements print(f) ``` or use -1 and -2 as index for two last element.
You should be aware that the [`range`](https://docs.python.org/3.6/library/functions.html#func-range) function starts at 0 if you don't explicitly specify a starting point. In your case, it should be: `for i in range(2, 8)`. Output: ``` [1, 1, 2, 3, 5, 8, 13, 21] ``` Also, in Python, you can use negative index in a...
44,141,117
I am trying to print fibonacci series using lists in python. This is my code ``` f=[1,1] for i in range(8): f.append(f[i-1]+f[i-2]) print(f) ``` output is ``` [1, 1, 2, 3, 2, 3, 5, 5, 5, 8] ``` I am not getting the bug here!
2017/05/23
[ "https://Stackoverflow.com/questions/44141117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054946/" ]
``` f=[1,1] for i in range(8): f.append(f[i]+f[i+1]) print(f) ``` **RESULT** ``` [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] ```
Script ``` f=[1,1] for i in range(2,8): print(i) f.append(f[i-1]+f[i-2]) print(f) ``` Output ``` 2 [1, 1, 2] 3 [1, 1, 2, 3] 4 [1, 1, 2, 3, 5] 5 [1, 1, 2, 3, 5, 8] 6 [1, 1, 2, 3, 5, 8, 13] 7 [1, 1, 2, 3, 5, 8, 13, 21] ``` Issue is `i` starts from 0, `f[-1], f[-2]` returns 0. start using range from 2 and 8 r...
44,141,117
I am trying to print fibonacci series using lists in python. This is my code ``` f=[1,1] for i in range(8): f.append(f[i-1]+f[i-2]) print(f) ``` output is ``` [1, 1, 2, 3, 2, 3, 5, 5, 5, 8] ``` I am not getting the bug here!
2017/05/23
[ "https://Stackoverflow.com/questions/44141117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054946/" ]
``` f=[1,1] for i in range(8): s=len(f) f.append(f[s-1]+f[s-2]) #sum of last two elements print(f) ``` or use -1 and -2 as index for two last element.
Adding to pjs' answer: When `i = 0`, you are adding `f[-1]` and `f[-2]`, where an index of `-1` gives you the last element in the list and so on. To fix that, as other answers have already pointed out, you need to set the correct starting point for `range()`.
44,141,117
I am trying to print fibonacci series using lists in python. This is my code ``` f=[1,1] for i in range(8): f.append(f[i-1]+f[i-2]) print(f) ``` output is ``` [1, 1, 2, 3, 2, 3, 5, 5, 5, 8] ``` I am not getting the bug here!
2017/05/23
[ "https://Stackoverflow.com/questions/44141117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054946/" ]
Python's `range` starts at 0, you need to start with generating element 2. By starting at 0, you get negative indices for the first couple of calculations, which access from the end of the list. To fix this, change the loop to `for i in range(2, 8)`. To clarify what seems to be a source of confusion, by starting the `...
Script ``` f=[1,1] for i in range(2,8): print(i) f.append(f[i-1]+f[i-2]) print(f) ``` Output ``` 2 [1, 1, 2] 3 [1, 1, 2, 3] 4 [1, 1, 2, 3, 5] 5 [1, 1, 2, 3, 5, 8] 6 [1, 1, 2, 3, 5, 8, 13] 7 [1, 1, 2, 3, 5, 8, 13, 21] ``` Issue is `i` starts from 0, `f[-1], f[-2]` returns 0. start using range from 2 and 8 r...
44,141,117
I am trying to print fibonacci series using lists in python. This is my code ``` f=[1,1] for i in range(8): f.append(f[i-1]+f[i-2]) print(f) ``` output is ``` [1, 1, 2, 3, 2, 3, 5, 5, 5, 8] ``` I am not getting the bug here!
2017/05/23
[ "https://Stackoverflow.com/questions/44141117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054946/" ]
``` f=[1,1] for i in range(8): f.append(f[i]+f[i+1]) print(f) ``` **RESULT** ``` [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] ```
You should be aware that the [`range`](https://docs.python.org/3.6/library/functions.html#func-range) function starts at 0 if you don't explicitly specify a starting point. In your case, it should be: `for i in range(2, 8)`. Output: ``` [1, 1, 2, 3, 5, 8, 13, 21] ``` Also, in Python, you can use negative index in a...
44,141,117
I am trying to print fibonacci series using lists in python. This is my code ``` f=[1,1] for i in range(8): f.append(f[i-1]+f[i-2]) print(f) ``` output is ``` [1, 1, 2, 3, 2, 3, 5, 5, 5, 8] ``` I am not getting the bug here!
2017/05/23
[ "https://Stackoverflow.com/questions/44141117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054946/" ]
``` f=[1,1] for i in range(8): f.append(f[i]+f[i+1]) print(f) ``` **RESULT** ``` [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] ```
``` f=[1,1] for i in range(8): s=len(f) f.append(f[s-1]+f[s-2]) #sum of last two elements print(f) ``` or use -1 and -2 as index for two last element.
44,141,117
I am trying to print fibonacci series using lists in python. This is my code ``` f=[1,1] for i in range(8): f.append(f[i-1]+f[i-2]) print(f) ``` output is ``` [1, 1, 2, 3, 2, 3, 5, 5, 5, 8] ``` I am not getting the bug here!
2017/05/23
[ "https://Stackoverflow.com/questions/44141117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054946/" ]
Python's `range` starts at 0, you need to start with generating element 2. By starting at 0, you get negative indices for the first couple of calculations, which access from the end of the list. To fix this, change the loop to `for i in range(2, 8)`. To clarify what seems to be a source of confusion, by starting the `...
Adding to pjs' answer: When `i = 0`, you are adding `f[-1]` and `f[-2]`, where an index of `-1` gives you the last element in the list and so on. To fix that, as other answers have already pointed out, you need to set the correct starting point for `range()`.
44,141,117
I am trying to print fibonacci series using lists in python. This is my code ``` f=[1,1] for i in range(8): f.append(f[i-1]+f[i-2]) print(f) ``` output is ``` [1, 1, 2, 3, 2, 3, 5, 5, 5, 8] ``` I am not getting the bug here!
2017/05/23
[ "https://Stackoverflow.com/questions/44141117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054946/" ]
``` f=[1,1] for i in range(8): f.append(f[i]+f[i+1]) print(f) ``` **RESULT** ``` [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] ```
Adding to pjs' answer: When `i = 0`, you are adding `f[-1]` and `f[-2]`, where an index of `-1` gives you the last element in the list and so on. To fix that, as other answers have already pointed out, you need to set the correct starting point for `range()`.
44,141,117
I am trying to print fibonacci series using lists in python. This is my code ``` f=[1,1] for i in range(8): f.append(f[i-1]+f[i-2]) print(f) ``` output is ``` [1, 1, 2, 3, 2, 3, 5, 5, 5, 8] ``` I am not getting the bug here!
2017/05/23
[ "https://Stackoverflow.com/questions/44141117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054946/" ]
Python's `range` starts at 0, you need to start with generating element 2. By starting at 0, you get negative indices for the first couple of calculations, which access from the end of the list. To fix this, change the loop to `for i in range(2, 8)`. To clarify what seems to be a source of confusion, by starting the `...
``` f=[1,1] for i in range(8): s=len(f) f.append(f[s-1]+f[s-2]) #sum of last two elements print(f) ``` or use -1 and -2 as index for two last element.
21,395,069
I am running ubuntu 13.10 with the latest pip. I have a whole set of SSL certs for my corporate proxy installed as per: <https://askubuntu.com/questions/73287/how-do-i-install-a-root-certificate> now. Firefox no longer complains about unrecognised certs but I still get: ``` Could not fetch URL http://pypi.python.or...
2014/01/28
[ "https://Stackoverflow.com/questions/21395069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1687633/" ]
I guess you would have to use `pip`'s `--cert` option. ``` --cert <path> Path to alternate CA bundle. ``` There's no indication in the documentation that you can use the `cert=` option in the `pip.conf` configuration file. See: <https://pip.pypa.io/en/stable/reference/pip/?highlight=proxy#cmdoption-cer...
try updating your proxy variables as shown here for http\_proxy and https\_proxy <https://askubuntu.com/questions/228530/updating-http-proxy-environment-variable> you should need the cert (or declared global cert as you have it above) as well as the proxy. the alternative to setting the variables would be to use it f...
21,395,069
I am running ubuntu 13.10 with the latest pip. I have a whole set of SSL certs for my corporate proxy installed as per: <https://askubuntu.com/questions/73287/how-do-i-install-a-root-certificate> now. Firefox no longer complains about unrecognised certs but I still get: ``` Could not fetch URL http://pypi.python.or...
2014/01/28
[ "https://Stackoverflow.com/questions/21395069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1687633/" ]
I guess you would have to use `pip`'s `--cert` option. ``` --cert <path> Path to alternate CA bundle. ``` There's no indication in the documentation that you can use the `cert=` option in the `pip.conf` configuration file. See: <https://pip.pypa.io/en/stable/reference/pip/?highlight=proxy#cmdoption-cer...
Despite what the documentation might say placing `cert = PATH_TO_CERTIFICATE_FILE` in the `pip.conf` or `pip.ini` did indeed work for me, at least for native Windows Python 2.7.13 with pip 9.0.1. BTW: on windows the configuration file is in `%APPDATA%\pip\pip.ini` and might have to be created manually (including the `...
21,395,069
I am running ubuntu 13.10 with the latest pip. I have a whole set of SSL certs for my corporate proxy installed as per: <https://askubuntu.com/questions/73287/how-do-i-install-a-root-certificate> now. Firefox no longer complains about unrecognised certs but I still get: ``` Could not fetch URL http://pypi.python.or...
2014/01/28
[ "https://Stackoverflow.com/questions/21395069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1687633/" ]
I don't know if this has always been the case, but I've found I also need to set the REQUESTS\_CA\_BUNDLE environment variable, presumably as pip uses requests and doesn't pass all the config through to it.
try updating your proxy variables as shown here for http\_proxy and https\_proxy <https://askubuntu.com/questions/228530/updating-http-proxy-environment-variable> you should need the cert (or declared global cert as you have it above) as well as the proxy. the alternative to setting the variables would be to use it f...
21,395,069
I am running ubuntu 13.10 with the latest pip. I have a whole set of SSL certs for my corporate proxy installed as per: <https://askubuntu.com/questions/73287/how-do-i-install-a-root-certificate> now. Firefox no longer complains about unrecognised certs but I still get: ``` Could not fetch URL http://pypi.python.or...
2014/01/28
[ "https://Stackoverflow.com/questions/21395069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1687633/" ]
I don't know if this has always been the case, but I've found I also need to set the REQUESTS\_CA\_BUNDLE environment variable, presumably as pip uses requests and doesn't pass all the config through to it.
Despite what the documentation might say placing `cert = PATH_TO_CERTIFICATE_FILE` in the `pip.conf` or `pip.ini` did indeed work for me, at least for native Windows Python 2.7.13 with pip 9.0.1. BTW: on windows the configuration file is in `%APPDATA%\pip\pip.ini` and might have to be created manually (including the `...
70,622,248
My question is an extension to this: [Python Accessing Values in A List of Dictionaries](https://stackoverflow.com/questions/17117912/python-accessing-values-in-a-list-of-dictionaries) I want to only return values from dictionaries if another given value exists in that dictionary. In the case of the example given in...
2022/01/07
[ "https://Stackoverflow.com/questions/70622248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3465940/" ]
The reason for your error is that the conditional operator (`c ? t : f`) takes precedence over the lambda declaration (`=>`). [source](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/#operator-precedence) Wrapping the conditional operator in `{}` brackets should solve your problem: ```cs ...
If someone has this error and the answers above do not help, try the following. <https://stackoverflow.com/a/60379426/13434418> Preview (Conditional mapping with different source types) ``` //Cannot convert lambda expression to type x.MapFrom(src => src.CommunityId.HasValue ? src.Community : src.Account) //OK x.MapFr...
70,622,248
My question is an extension to this: [Python Accessing Values in A List of Dictionaries](https://stackoverflow.com/questions/17117912/python-accessing-values-in-a-list-of-dictionaries) I want to only return values from dictionaries if another given value exists in that dictionary. In the case of the example given in...
2022/01/07
[ "https://Stackoverflow.com/questions/70622248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3465940/" ]
I found that we can get rid of this stupid message by just casting the non-null result to the output type. So where ``` .ForMember( dst => dst.VisitReportFileId, opt => opt.MapFrom(src => src.VisitReportFile == null ? null : src.VisitReportFile.Id.Key)); ``` Gives me a > > Cannot convert...
If someone has this error and the answers above do not help, try the following. <https://stackoverflow.com/a/60379426/13434418> Preview (Conditional mapping with different source types) ``` //Cannot convert lambda expression to type x.MapFrom(src => src.CommunityId.HasValue ? src.Community : src.Account) //OK x.MapFr...
63,583,084
According to this [FAQ page](https://faq.whatsapp.com/iphone/how-to-link-to-whatsapp-from-a-different-app) of Whatsapp on **How to link to WhatsApp from a different app** Using the URL `whatsapp://send?phone=XXXXXXXXXXXXX&text=Hello` can be used to open the Whatsapp app on a Windows PC and perform a custom action. ...
2020/08/25
[ "https://Stackoverflow.com/questions/63583084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/603633/" ]
You can use cmd exe to do such a job. Just try ``` import subprocess subprocess.Popen(["cmd", "/C", "start whatsapp://send?phone=XXXXXXXXXXXXX&text=Hello"], shell=True) ``` edit: if you want to pass '&'(ampersand) in cmd shell you need to use escape char '^' for it. please try that one ``` subprocess.Popen(["cmd"...
Using this command start whatsapp://send?phone=XXXXXXXXXXXXX^&text=Hello not working after updated to new WhatsApp Desktop App (UWP) for windows. you have other idea for send text message to destination user.
50,546,892
i've seen some people write their shebang line with a space after env. Eg. ``` #!/usr/bin/env python ``` Is this a typo? I don't ever use a space. I use ``` #!/usr/bin/env/python ``` Can someone please clarify this?
2018/05/26
[ "https://Stackoverflow.com/questions/50546892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9536653/" ]
No it isn't a typo! The one you are using will not work on all os's. E.G. in my Ubuntu Linux implementation 'env' is a program in /usr/bin not a directory so #!/usr/bin/env/python won't work.
Not using a space isn't a typo, but leads to portability issues when executing the same file on different machines. The purpose of the shebang line (`#!/usr....`) is to indicate what interpreter is to be used when executing the code in the file. According to [Wikipedia](https://en.wikipedia.org/wiki/Shebang_%28Unix%29#...
57,864,579
I have a dataset of 8500 rows of text. I want to apply a function `pre_process` on each of these rows. When I do it serially, it takes about 42 mins on my computer: ``` import pandas as pd import time import re ### constructing a sample dataframe of 10 rows to demonstrate df = pd.DataFrame(columns=['text']) df.text =...
2019/09/10
[ "https://Stackoverflow.com/questions/57864579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5305512/" ]
Try following : ``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.Xml.Serialization; namespace ConsoleApplication131 { class Program { const string FILENAME = @"c:\temp\test.xml"; static void Main(string[] args) { ...
you can use `local-name()` to ignore the namespace in xpath ``` //*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='BatchResponse'] ```
51,311,741
how can i create a spoofed UDP packet using python sockets,without using scapy library. i have created the socket like this ``` sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP sock.sendto(bytes('', "utf-8"), ('192.168.1.9', 7043))# 192.168.1.9dest 7043 dest port ```
2018/07/12
[ "https://Stackoverflow.com/questions/51311741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6584777/" ]
This is one of the first results for google searches like "spoofing udp packet python" so I am going to expand @Cukic0d's answer using scapy. Using the scapy CLI tool (some Linux distributions package it separately to the scapy Python library ): ```py pkt = IP(dst="1.1.1.1")/UDP(sport=13338, dport=13337)/"fm12abcd" s...
I think you mean changing the source and destination addresses from the IP layer (on which the UDP layer is based). To do so, you will need to use raw sockets. (SOCK\_RAW), meaning that you have to build everything starting from the Ethernet layer to the UDP layer. Honestly, without scapy, that’s a lot of hard work. ...
20,078,739
I have a list of objects that I need to sort according to a [key function](https://wiki.python.org/moin/HowTo/Sorting/#Key_Functions "Key functions"). The problem is that some of the elements in my list can go "out-of-date" while the list is being sorted. When the key function is called on such an expired item, it fail...
2013/11/19
[ "https://Stackoverflow.com/questions/20078739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839209/" ]
Every sorting algorithm I know doesn't throw out some values because they're outdated or something. The task of sorting algorithm is to **sort** the list, and sort it fast, everything else is extraneous, specific task. So, I would write this magical function myself. It would do the sorting in two steps: first it wou...
Since the result of the key function can change over time, and most sorting implementations probably assume a deterministic key function, it's probably best to only execute the key function once per object, to ensure a well-ordered and crash-free final list. ``` def func(seq, **kargs): key = kargs["key"] store...
20,078,739
I have a list of objects that I need to sort according to a [key function](https://wiki.python.org/moin/HowTo/Sorting/#Key_Functions "Key functions"). The problem is that some of the elements in my list can go "out-of-date" while the list is being sorted. When the key function is called on such an expired item, it fail...
2013/11/19
[ "https://Stackoverflow.com/questions/20078739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839209/" ]
Every sorting algorithm I know doesn't throw out some values because they're outdated or something. The task of sorting algorithm is to **sort** the list, and sort it fast, everything else is extraneous, specific task. So, I would write this magical function myself. It would do the sorting in two steps: first it wou...
If the list items can go from Good to Bad while sorting, then there is nothing you can do. The `key`s are evaluated only once before sorting, so any change in the key will be invisible to the sort function: ``` >>> from random import randrange >>> values = [randrange(100) for i in range(10)] >>> values [54, 72, 91, 73...
20,078,739
I have a list of objects that I need to sort according to a [key function](https://wiki.python.org/moin/HowTo/Sorting/#Key_Functions "Key functions"). The problem is that some of the elements in my list can go "out-of-date" while the list is being sorted. When the key function is called on such an expired item, it fail...
2013/11/19
[ "https://Stackoverflow.com/questions/20078739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839209/" ]
I did this once with a mergesort. Mergesort makes it relatively simple to eliminate no-longer-useful values. The project I did it in is at <http://stromberg.dnsalias.org/~dstromberg/equivalence-classes.html#python-3e> . Feel free to raid it for ideas, or lift code out of it; it's Free as in speech (GPLv2 or later, at ...
Since the result of the key function can change over time, and most sorting implementations probably assume a deterministic key function, it's probably best to only execute the key function once per object, to ensure a well-ordered and crash-free final list. ``` def func(seq, **kargs): key = kargs["key"] store...
20,078,739
I have a list of objects that I need to sort according to a [key function](https://wiki.python.org/moin/HowTo/Sorting/#Key_Functions "Key functions"). The problem is that some of the elements in my list can go "out-of-date" while the list is being sorted. When the key function is called on such an expired item, it fail...
2013/11/19
[ "https://Stackoverflow.com/questions/20078739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839209/" ]
I did this once with a mergesort. Mergesort makes it relatively simple to eliminate no-longer-useful values. The project I did it in is at <http://stromberg.dnsalias.org/~dstromberg/equivalence-classes.html#python-3e> . Feel free to raid it for ideas, or lift code out of it; it's Free as in speech (GPLv2 or later, at ...
If the list items can go from Good to Bad while sorting, then there is nothing you can do. The `key`s are evaluated only once before sorting, so any change in the key will be invisible to the sort function: ``` >>> from random import randrange >>> values = [randrange(100) for i in range(10)] >>> values [54, 72, 91, 73...
20,078,739
I have a list of objects that I need to sort according to a [key function](https://wiki.python.org/moin/HowTo/Sorting/#Key_Functions "Key functions"). The problem is that some of the elements in my list can go "out-of-date" while the list is being sorted. When the key function is called on such an expired item, it fail...
2013/11/19
[ "https://Stackoverflow.com/questions/20078739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839209/" ]
Since the result of the key function can change over time, and most sorting implementations probably assume a deterministic key function, it's probably best to only execute the key function once per object, to ensure a well-ordered and crash-free final list. ``` def func(seq, **kargs): key = kargs["key"] store...
If the list items can go from Good to Bad while sorting, then there is nothing you can do. The `key`s are evaluated only once before sorting, so any change in the key will be invisible to the sort function: ``` >>> from random import randrange >>> values = [randrange(100) for i in range(10)] >>> values [54, 72, 91, 73...
14,104,128
I'm trying to define "variables" in an openoffice document, and I must be doing something wrong because when I try to display the value of the variable using a field, I only get an empty string. Here's the code I'm using (using the Python UNO bridge). The interesting bit is the second function. ```python import tim...
2012/12/31
[ "https://Stackoverflow.com/questions/14104128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/281368/" ]
Use the updater property: <http://jsfiddle.net/ZUhFy/10/> ``` .typeahead({ source: namelist, updater: function(item) { $('#log').append(item + '<br>'); return item; } }); ``` > > updater returns selected item The method used to return selected item. > Accepts a ...
try ``` $('#findname').on('keyup', function() {...}); ```
14,104,128
I'm trying to define "variables" in an openoffice document, and I must be doing something wrong because when I try to display the value of the variable using a field, I only get an empty string. Here's the code I'm using (using the Python UNO bridge). The interesting bit is the second function. ```python import tim...
2012/12/31
[ "https://Stackoverflow.com/questions/14104128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/281368/" ]
Use the updater property: <http://jsfiddle.net/ZUhFy/10/> ``` .typeahead({ source: namelist, updater: function(item) { $('#log').append(item + '<br>'); return item; } }); ``` > > updater returns selected item The method used to return selected item. > Accepts a ...
### Try using the `keyup` ``` .on('keyup', function(){...}) ```
69,503,139
My path is all messed up, javac and python commands not found, I even uninstalled and reinstalled java. I would throw in random stuff from the internet into my terminal whenever my code wouldn't work and have subsequently ruined my path, I've even added stuff to my bash\_profile and I don't know how to reset it or fix ...
2021/10/09
[ "https://Stackoverflow.com/questions/69503139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17110677/" ]
In SQL Server Management Studio you can remove the shortcut CTRL+E to execute a query. Go to Tools > Options in the menu, then go to Environment > Keyboard > Keyboard in the tree on the left. Then select `Query.Execute` in the right table. Select the shortcut `CTRL+E (SQL Query Editor)` then click Remove which removes...
To prevent executing an entire script file from start to end, and only allow running selected snippets, this would work: ``` WHILE 1=1 PRINT 'NOT ALLOWED, press the STOP button' PRINT 'After WHILE, will not show unless executed manually' GO PRINT 'After GO, will not show unless executed manually' ``` Because th...
69,503,139
My path is all messed up, javac and python commands not found, I even uninstalled and reinstalled java. I would throw in random stuff from the internet into my terminal whenever my code wouldn't work and have subsequently ruined my path, I've even added stuff to my bash\_profile and I don't know how to reset it or fix ...
2021/10/09
[ "https://Stackoverflow.com/questions/69503139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17110677/" ]
Add `set noexec on;` at the top of your script. That will prevent running *any* statements in the file.
In SQL Server Management Studio you can remove the shortcut CTRL+E to execute a query. Go to Tools > Options in the menu, then go to Environment > Keyboard > Keyboard in the tree on the left. Then select `Query.Execute` in the right table. Select the shortcut `CTRL+E (SQL Query Editor)` then click Remove which removes...
69,503,139
My path is all messed up, javac and python commands not found, I even uninstalled and reinstalled java. I would throw in random stuff from the internet into my terminal whenever my code wouldn't work and have subsequently ruined my path, I've even added stuff to my bash\_profile and I don't know how to reset it or fix ...
2021/10/09
[ "https://Stackoverflow.com/questions/69503139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17110677/" ]
Add `set noexec on;` at the top of your script. That will prevent running *any* statements in the file.
To prevent executing an entire script file from start to end, and only allow running selected snippets, this would work: ``` WHILE 1=1 PRINT 'NOT ALLOWED, press the STOP button' PRINT 'After WHILE, will not show unless executed manually' GO PRINT 'After GO, will not show unless executed manually' ``` Because th...
66,345,760
I'm trying to play a `.mp3` file. My code : ``` import os os.system("start C:\Users\User\Desktop\Wakeup.mp3") ``` But, it gives an error like this: ``` File "C:/Users/User/PycharmProjects/pythonProject/Test.py", line 2 os.system("start C:\Users\User\Desktop\Wakeup.mp3") ^ SyntaxError: (unicode er...
2021/02/24
[ "https://Stackoverflow.com/questions/66345760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15272617/" ]
You did not escape the backslash character. try this: ``` os.system("start C:\\Users\\User\\Desktop\\Wakeup.mp3") ``` **Option 2** Use forward slash instead: ``` os.system("start C:/Users/User/Desktop/Wakeup.mp3") ``` **Option 3** Use "raw" string: ``` os.system(r"start C:\Users\User\Desktop\Wakeup.mp3") ```
If you want to play sound. You can do something like this. ``` from playsound import playsound playsound("path/name.mp3") ``` Hope this helps ... :D
5,639,049
I found in the [documentation of pygraph](http://dl.dropbox.com/u/1823095/python-graph/docs/pygraph.classes.graph.graph-class.html) how to change the [attributes of the nodes and the edges](http://www.graphviz.org/doc/info/attrs.html), but I found no help on how to change the attributes of the graphs. I tried without...
2011/04/12
[ "https://Stackoverflow.com/questions/5639049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/380038/" ]
So, doing more research on my own, I found that [pygraphviz](http://networkx.lanl.gov/pygraphviz/index.html) is offering what I need. Here is the `pygraph` example using `pygraphviz` and accepting attributes. It is also shorter, as you don't have to specify the nodes if all of them are connected via edges. ``` #!/usr/...
I don't know about pygraph, but I think the way you set attributes in python was: ``` setattr(object, attr, value) setattr(gr, 'aspect', 2) ``` I mean, you have tried gr.aspect = 2, right?
5,639,049
I found in the [documentation of pygraph](http://dl.dropbox.com/u/1823095/python-graph/docs/pygraph.classes.graph.graph-class.html) how to change the [attributes of the nodes and the edges](http://www.graphviz.org/doc/info/attrs.html), but I found no help on how to change the attributes of the graphs. I tried without...
2011/04/12
[ "https://Stackoverflow.com/questions/5639049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/380038/" ]
Apparently you can use `gv.setv()` to set attributes on a graph. ``` import gv g = gv.digraph('19261920') gv.setv(g, 'overlap', 'compress') ``` I found `gv.setv()` by examining the `gv.py` interface definition file at `/usr/include/graphviz/gv.i` Searching the interwebz for `"import gv" overlap setv` led me to [thi...
I don't know about pygraph, but I think the way you set attributes in python was: ``` setattr(object, attr, value) setattr(gr, 'aspect', 2) ``` I mean, you have tried gr.aspect = 2, right?
5,639,049
I found in the [documentation of pygraph](http://dl.dropbox.com/u/1823095/python-graph/docs/pygraph.classes.graph.graph-class.html) how to change the [attributes of the nodes and the edges](http://www.graphviz.org/doc/info/attrs.html), but I found no help on how to change the attributes of the graphs. I tried without...
2011/04/12
[ "https://Stackoverflow.com/questions/5639049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/380038/" ]
So, doing more research on my own, I found that [pygraphviz](http://networkx.lanl.gov/pygraphviz/index.html) is offering what I need. Here is the `pygraph` example using `pygraphviz` and accepting attributes. It is also shorter, as you don't have to specify the nodes if all of them are connected via edges. ``` #!/usr/...
Try the following ``` import pydot dot = write(gr) dotG = pydot.graph_from_dot_data(dot) params = { 'rotate': 10, 'color': 'red'} dotG.set_graph_defaults(**params) dot = dotG.to_string() ```
5,639,049
I found in the [documentation of pygraph](http://dl.dropbox.com/u/1823095/python-graph/docs/pygraph.classes.graph.graph-class.html) how to change the [attributes of the nodes and the edges](http://www.graphviz.org/doc/info/attrs.html), but I found no help on how to change the attributes of the graphs. I tried without...
2011/04/12
[ "https://Stackoverflow.com/questions/5639049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/380038/" ]
Apparently you can use `gv.setv()` to set attributes on a graph. ``` import gv g = gv.digraph('19261920') gv.setv(g, 'overlap', 'compress') ``` I found `gv.setv()` by examining the `gv.py` interface definition file at `/usr/include/graphviz/gv.i` Searching the interwebz for `"import gv" overlap setv` led me to [thi...
Try the following ``` import pydot dot = write(gr) dotG = pydot.graph_from_dot_data(dot) params = { 'rotate': 10, 'color': 'red'} dotG.set_graph_defaults(**params) dot = dotG.to_string() ```
64,866,304
I'm trying to set up a new cygwin installation and install python through cygwin. I've done so, and the setup completed, but when I try to run `python3.8` I get a fatal python error: ```sh $ python3.8 Python path configuration: PYTHONHOME = 'C:\Users\cmhac\AppData\Local\Programs\Python\Python38' PYTHONPATH = 'C:\U...
2020/11/16
[ "https://Stackoverflow.com/questions/64866304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11831775/" ]
I saw this exact error: Fatal Python error: init\_fs\_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings' If you set these two env variables to nil, the problem should disappear: set PYTHONHOME= set PYTHONPATH=
Go to your wsgi.py file under your project and do something similar to: ``` import os import sys from django.core.wsgi import get_wsgi_application sys.path.append('path/to/yourprojectenv/lib/python3.8/site-packages') ``` Restart your server and try again.
44,434,185
I am trying to create a python program that will take data from multiple excel sheets and I am kinda stuck at the moment: ``` import xlrd import xlwt workbook1 = xlrd.open_workbook('Z:\Public\Safety\SafetyDataPullProject\TestFile.xlsx', on_demand = True) worksheet = workbook1.sheet_by_index('Sheet1') sheet.cell(5, 5)...
2017/06/08
[ "https://Stackoverflow.com/questions/44434185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8131036/" ]
The answer's well documented in Marshmallows [api reference](http://marshmallow.readthedocs.io/en/latest/api_reference.html#module-marshmallow.fields). I need to use `dump_to` : ``` class ApiSchema(Schema): class Meta: strict = True time = fields.Number(dump_to='_time') id = fields.String(dump_t...
You can override the [`dump`](https://marshmallow.readthedocs.io/en/latest/api_reference.html#marshmallow.Schema.dump) method to *prepend* underscores to selected fields before returning the serialised object: ``` class ApiSchema(Schema): class Meta: strict = True time = fields.Number() id = field...
44,434,185
I am trying to create a python program that will take data from multiple excel sheets and I am kinda stuck at the moment: ``` import xlrd import xlwt workbook1 = xlrd.open_workbook('Z:\Public\Safety\SafetyDataPullProject\TestFile.xlsx', on_demand = True) worksheet = workbook1.sheet_by_index('Sheet1') sheet.cell(5, 5)...
2017/06/08
[ "https://Stackoverflow.com/questions/44434185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8131036/" ]
<https://marshmallow.readthedocs.io/en/2.x-line/quickstart.html#specifying-attribute-names> Even though the docs are for version 2, this seems to still work as of 3.5.1. The stable version 3 docs will not have this example. ``` class ApiSchema(Schema): class Meta: strict = True _time = fields.Number(attr...
You can override the [`dump`](https://marshmallow.readthedocs.io/en/latest/api_reference.html#marshmallow.Schema.dump) method to *prepend* underscores to selected fields before returning the serialised object: ``` class ApiSchema(Schema): class Meta: strict = True time = fields.Number() id = field...
44,434,185
I am trying to create a python program that will take data from multiple excel sheets and I am kinda stuck at the moment: ``` import xlrd import xlwt workbook1 = xlrd.open_workbook('Z:\Public\Safety\SafetyDataPullProject\TestFile.xlsx', on_demand = True) worksheet = workbook1.sheet_by_index('Sheet1') sheet.cell(5, 5)...
2017/06/08
[ "https://Stackoverflow.com/questions/44434185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8131036/" ]
The accepted answer (using `attribute`) didn't work for me, possibly [because](https://marshmallow.readthedocs.io/en/latest/api_reference.html#marshmallow.fields.Field): > > Note: This should only be used for very specific use cases such as outputting multiple fields for a single attribute. In most cases, you should ...
You can override the [`dump`](https://marshmallow.readthedocs.io/en/latest/api_reference.html#marshmallow.Schema.dump) method to *prepend* underscores to selected fields before returning the serialised object: ``` class ApiSchema(Schema): class Meta: strict = True time = fields.Number() id = field...
44,434,185
I am trying to create a python program that will take data from multiple excel sheets and I am kinda stuck at the moment: ``` import xlrd import xlwt workbook1 = xlrd.open_workbook('Z:\Public\Safety\SafetyDataPullProject\TestFile.xlsx', on_demand = True) worksheet = workbook1.sheet_by_index('Sheet1') sheet.cell(5, 5)...
2017/06/08
[ "https://Stackoverflow.com/questions/44434185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8131036/" ]
<https://marshmallow.readthedocs.io/en/2.x-line/quickstart.html#specifying-attribute-names> Even though the docs are for version 2, this seems to still work as of 3.5.1. The stable version 3 docs will not have this example. ``` class ApiSchema(Schema): class Meta: strict = True _time = fields.Number(attr...
The answer's well documented in Marshmallows [api reference](http://marshmallow.readthedocs.io/en/latest/api_reference.html#module-marshmallow.fields). I need to use `dump_to` : ``` class ApiSchema(Schema): class Meta: strict = True time = fields.Number(dump_to='_time') id = fields.String(dump_t...
44,434,185
I am trying to create a python program that will take data from multiple excel sheets and I am kinda stuck at the moment: ``` import xlrd import xlwt workbook1 = xlrd.open_workbook('Z:\Public\Safety\SafetyDataPullProject\TestFile.xlsx', on_demand = True) worksheet = workbook1.sheet_by_index('Sheet1') sheet.cell(5, 5)...
2017/06/08
[ "https://Stackoverflow.com/questions/44434185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8131036/" ]
The accepted answer (using `attribute`) didn't work for me, possibly [because](https://marshmallow.readthedocs.io/en/latest/api_reference.html#marshmallow.fields.Field): > > Note: This should only be used for very specific use cases such as outputting multiple fields for a single attribute. In most cases, you should ...
The answer's well documented in Marshmallows [api reference](http://marshmallow.readthedocs.io/en/latest/api_reference.html#module-marshmallow.fields). I need to use `dump_to` : ``` class ApiSchema(Schema): class Meta: strict = True time = fields.Number(dump_to='_time') id = fields.String(dump_t...
44,434,185
I am trying to create a python program that will take data from multiple excel sheets and I am kinda stuck at the moment: ``` import xlrd import xlwt workbook1 = xlrd.open_workbook('Z:\Public\Safety\SafetyDataPullProject\TestFile.xlsx', on_demand = True) worksheet = workbook1.sheet_by_index('Sheet1') sheet.cell(5, 5)...
2017/06/08
[ "https://Stackoverflow.com/questions/44434185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8131036/" ]
<https://marshmallow.readthedocs.io/en/2.x-line/quickstart.html#specifying-attribute-names> Even though the docs are for version 2, this seems to still work as of 3.5.1. The stable version 3 docs will not have this example. ``` class ApiSchema(Schema): class Meta: strict = True _time = fields.Number(attr...
The accepted answer (using `attribute`) didn't work for me, possibly [because](https://marshmallow.readthedocs.io/en/latest/api_reference.html#marshmallow.fields.Field): > > Note: This should only be used for very specific use cases such as outputting multiple fields for a single attribute. In most cases, you should ...
15,627,307
I am trying to figure out the best way to convert from epoch seconds (since NTP epoch 1900-01-01 00:00) to a datetime string (MM/DD/YY,hh:mm:ss) without any libraries/modules/external functions, as they are not available on an embedded device. My first thought was to look at the [Python datetime module source code](ht...
2013/03/26
[ "https://Stackoverflow.com/questions/15627307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2209295/" ]
The `getDateFromJulianDay` function originally proposed is too computationally intensive for effective use on an embedded device, containing many multiplication and division operations on large `long` variables or, as originally written in C++, [`longlong` variables](http://qt.gitorious.org/qt/qt/blobs/4.7/src/corelib/...
TL;DR ===== If you are using a Telit GC-864, the Python interpreter seemingly inserts some sort of delay in-between each line of code execution. For a Telit GC-864, the function in my question `getDateFromJulianDay(julianDay)` is faster than the function in my answer, `ntp_time_to_date(ntp_time)`. More Detail ======...
46,367,625
I am trying to detect language of the string with langdetect package. But it does not work. ``` from langdetect import detect word_string = "Books are for reading" print(detect(word_string)) ``` If I use code above I get error `ImportError: cannot import name detect` When I replace detect with \* ``` from langdet...
2017/09/22
[ "https://Stackoverflow.com/questions/46367625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6152972/" ]
Try installing it first by writing :-> `!pip install langdetect` on terminal and then `import langdetect`
You can not import it because it is probably not there. See if the name is correct. Seeing other questions here on SO I assume you mean detect\_langs.
46,367,625
I am trying to detect language of the string with langdetect package. But it does not work. ``` from langdetect import detect word_string = "Books are for reading" print(detect(word_string)) ``` If I use code above I get error `ImportError: cannot import name detect` When I replace detect with \* ``` from langdet...
2017/09/22
[ "https://Stackoverflow.com/questions/46367625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6152972/" ]
Try installing it first by writing :-> `!pip install langdetect` on terminal and then `import langdetect`
Your error indicates the Python interpreter couldn't find the `module` you are importing in it's `sys.path`. Add to your code ``` import os sys.path.append('absolute_path to your module.py file') ``` and try again. Another option is to add your **[PYTHONPATH](https://docs.python.org/2/using/cmdline.html#envvar-PY...
39,370,879
I have a dataframe df\_energy2 ``` df_energy2.info() <class 'pandas.core.frame.DataFrame'> RangeIndex: 29974 entries, 0 to 29973 Data columns (total 4 columns): TIMESTAMP 29974 non-null datetime64[ns] P_ACT_KW 29974 non-null int64 PERIODE_TARIF 29974 non-null object P_SOUSCR 29974 non-null in...
2016/09/07
[ "https://Stackoverflow.com/questions/39370879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2278337/" ]
I think you need [`dt.hour`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.dt.hour.html): ``` print (df.TIMESTAMP.dt.hour) 0 0 1 0 Name: TIMESTAMP, dtype: int64 df['hours'] = df.TIMESTAMP.dt.hour print (df) TIMESTAMP P_ACT_KW PERIODE_TARIF P_SOUSCR hours 0 2016-01-01 00:00:0...
Given your data: > > > ``` > df_energy2.head() > > TIMESTAMP P_ACT_KW PERIODE_TARIF P_SOUSCR > 2016-01-01 00:00:00 116 HC 250 > 2016-01-01 00:10:00 121 HC 250 > > ``` > > You have timestamp as the index. For extracting hours from timestamp where you have it as the index of the dataframe: ``` hours = df_ene...
16,027,942
I've written a high level motor controller in Python, and have got to a point where I want to go a little lower level to get some speed, so I'm interested in coding those bits in C. I don't have much experience with C, but the math I'm working on is pretty straightforward, so I'm sure I can implement with a minimal am...
2013/04/16
[ "https://Stackoverflow.com/questions/16027942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1481457/" ]
You can take a look at this tutorial [here](http://csl.name/C-functions-from-Python/). Also, a more reliable example on the official python website, [here](http://docs.python.org/2/extending/extending.html#a-simple-example). For example, `sum.h` function ``` int sum(int a, int b) ``` A file named, `module.c`, `...
Another option: try [numba](http://numba.pydata.org/). It gives you C-like speed for free: just import numba and @autojit your functions, for a wonderful speed increase. Won't work if you have complicated data types, but if you're looping and jumping around array indices, it might be just what you're looking for.
16,027,942
I've written a high level motor controller in Python, and have got to a point where I want to go a little lower level to get some speed, so I'm interested in coding those bits in C. I don't have much experience with C, but the math I'm working on is pretty straightforward, so I'm sure I can implement with a minimal am...
2013/04/16
[ "https://Stackoverflow.com/questions/16027942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1481457/" ]
You can take a look at this tutorial [here](http://csl.name/C-functions-from-Python/). Also, a more reliable example on the official python website, [here](http://docs.python.org/2/extending/extending.html#a-simple-example). For example, `sum.h` function ``` int sum(int a, int b) ``` A file named, `module.c`, `...
you can use SWIG, it is very simple to use
16,027,942
I've written a high level motor controller in Python, and have got to a point where I want to go a little lower level to get some speed, so I'm interested in coding those bits in C. I don't have much experience with C, but the math I'm working on is pretty straightforward, so I'm sure I can implement with a minimal am...
2013/04/16
[ "https://Stackoverflow.com/questions/16027942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1481457/" ]
You can take a look at this tutorial [here](http://csl.name/C-functions-from-Python/). Also, a more reliable example on the official python website, [here](http://docs.python.org/2/extending/extending.html#a-simple-example). For example, `sum.h` function ``` int sum(int a, int b) ``` A file named, `module.c`, `...
You can use Cython for setting the necessary c types and compile your python syntax code.
21,119,958
I am trying to negate the value returned by one function. Consider the code to be ``` def greater(a,b): return a>b check = negate(greater) assert check(8,9) ``` OR ``` def equal(a,b): return a==b check = negate(equal) assert check("python","java") ``` How should I define the ***NEGATE*** function???
2014/01/14
[ "https://Stackoverflow.com/questions/21119958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3181773/" ]
Like this: ``` def negate(func): def result(*args): return not func(*args) return result ``` This is a function which creates a function which returns the result of invoking the original function and `not`ing it's return value, and then returning that function.
Use the `not` operator in a decorator: ``` from functools import wraps def negate(func): @wraps(func) def wrapper(*args, **kw): return not func(*args, **kw) return wrapper ``` The above decorator returns a wrapper function that applies `not` to the return value of the wrapped function. The [`@fu...
21,119,958
I am trying to negate the value returned by one function. Consider the code to be ``` def greater(a,b): return a>b check = negate(greater) assert check(8,9) ``` OR ``` def equal(a,b): return a==b check = negate(equal) assert check("python","java") ``` How should I define the ***NEGATE*** function???
2014/01/14
[ "https://Stackoverflow.com/questions/21119958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3181773/" ]
Use a function-style [decorator](http://docs.python.org/2/glossary.html#term-decorator): ``` def negate(func): def inner(*args, **kwargs): val = func(*args, **kwargs) return not val return inner ``` **Demo:** ``` >>> greater(10, 20) False >>> negate(greater)(10, 20) True ``` To preserve th...
Use the `not` operator in a decorator: ``` from functools import wraps def negate(func): @wraps(func) def wrapper(*args, **kw): return not func(*args, **kw) return wrapper ``` The above decorator returns a wrapper function that applies `not` to the return value of the wrapped function. The [`@fu...
21,119,958
I am trying to negate the value returned by one function. Consider the code to be ``` def greater(a,b): return a>b check = negate(greater) assert check(8,9) ``` OR ``` def equal(a,b): return a==b check = negate(equal) assert check("python","java") ``` How should I define the ***NEGATE*** function???
2014/01/14
[ "https://Stackoverflow.com/questions/21119958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3181773/" ]
Like this: ``` def negate(func): def result(*args): return not func(*args) return result ``` This is a function which creates a function which returns the result of invoking the original function and `not`ing it's return value, and then returning that function.
Use a function-style [decorator](http://docs.python.org/2/glossary.html#term-decorator): ``` def negate(func): def inner(*args, **kwargs): val = func(*args, **kwargs) return not val return inner ``` **Demo:** ``` >>> greater(10, 20) False >>> negate(greater)(10, 20) True ``` To preserve th...
14,749,379
Because *programming* is one of my favorite hobbies I started a small project in python. I'm trying to make a nutritional calculator for daily routine, see the code below: ``` # Name: nutri.py # Author: pyn my_dict = {'chicken':(40, 50, 10), 'pork':(50, 30, 20) } foods = raw_input("Enter your food...
2013/02/07
[ "https://Stackoverflow.com/questions/14749379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2050432/" ]
You could use the sibling selector. As long as div's share the same parent, you can still affect them with hover [DEMO](http://jsfiddle.net/8LFWR/) Vital Code: ``` #gestaltung_cd:hover ~ #mainhexa1, #gestaltung_illu:hover ~ #mainhexa2, #gestaltung_klassisch:hover ~ #mainhexa3 { display: block; } ```
Here's an example of how to do the first one and you'd just do the same for the other two with the relevant IDs. ``` $("#gestaltung_cd").hover( function () { $("#mainhexa1").show(); }, function () { $("#mainhexa1").hide(); } ); ```
14,749,379
Because *programming* is one of my favorite hobbies I started a small project in python. I'm trying to make a nutritional calculator for daily routine, see the code below: ``` # Name: nutri.py # Author: pyn my_dict = {'chicken':(40, 50, 10), 'pork':(50, 30, 20) } foods = raw_input("Enter your food...
2013/02/07
[ "https://Stackoverflow.com/questions/14749379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2050432/" ]
using jQuerys hover function, like this: ``` $('#gestaltung_cd').hover(function() { $('#mainhexa1').toggle(); }); ``` (if you don't want to hide the div on blur, then change toggle() to show())
Just for the record ... You can do the effect you want only with CSS and HTML ( without javascript ), but you have to place your elements to follow each other and use `+` selector in CSS. Something like : HTML ``` <div id="gestaltung_cd"></div> <div id="mainhexa1"></div> <div id="gestaltung_illu"></div> <div id="mai...
14,749,379
Because *programming* is one of my favorite hobbies I started a small project in python. I'm trying to make a nutritional calculator for daily routine, see the code below: ``` # Name: nutri.py # Author: pyn my_dict = {'chicken':(40, 50, 10), 'pork':(50, 30, 20) } foods = raw_input("Enter your food...
2013/02/07
[ "https://Stackoverflow.com/questions/14749379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2050432/" ]
You could use the sibling selector. As long as div's share the same parent, you can still affect them with hover [DEMO](http://jsfiddle.net/8LFWR/) Vital Code: ``` #gestaltung_cd:hover ~ #mainhexa1, #gestaltung_illu:hover ~ #mainhexa2, #gestaltung_klassisch:hover ~ #mainhexa3 { display: block; } ```
I'd suggest you add an attribute to the first three divs that specifies which div to show on hover: ``` <div id="gestaltung_cd" data-maindiv="mainhexa1"></div> <div id="gestaltung_illu" data-maindiv="mainhexa2"></div> <div id="gestaltung_klassisch" data-maindiv="mainhexa3"></div> ``` That way you can handle the show...
14,749,379
Because *programming* is one of my favorite hobbies I started a small project in python. I'm trying to make a nutritional calculator for daily routine, see the code below: ``` # Name: nutri.py # Author: pyn my_dict = {'chicken':(40, 50, 10), 'pork':(50, 30, 20) } foods = raw_input("Enter your food...
2013/02/07
[ "https://Stackoverflow.com/questions/14749379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2050432/" ]
Using jQuery's [hover](http://api.jquery.com/hover/) function : ``` var divs = { cd: 'mainhexa1', illu: 'mainhexa2', klassisch: 'mainhexa3' }; $('[id^=gestaltung]').hover(function(){ // selects all elements whose id starts with gestaltung $('#'+divs[this.id.slice('gestaltung_'.length)]).toggle(...
If you wrap each block of divs in a container you can match them up by index, which will make the code work regardless of how many divs there are. Something like this: ``` <div class="gesaltung-container"> <div id="gestaltung_cd">gestaltung_cd</div> <div id="gestaltung_illu">gestaltung_illu</div> <div id="...
14,749,379
Because *programming* is one of my favorite hobbies I started a small project in python. I'm trying to make a nutritional calculator for daily routine, see the code below: ``` # Name: nutri.py # Author: pyn my_dict = {'chicken':(40, 50, 10), 'pork':(50, 30, 20) } foods = raw_input("Enter your food...
2013/02/07
[ "https://Stackoverflow.com/questions/14749379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2050432/" ]
You could use the sibling selector. As long as div's share the same parent, you can still affect them with hover [DEMO](http://jsfiddle.net/8LFWR/) Vital Code: ``` #gestaltung_cd:hover ~ #mainhexa1, #gestaltung_illu:hover ~ #mainhexa2, #gestaltung_klassisch:hover ~ #mainhexa3 { display: block; } ```
``` $("#gestaltung_cd").hover(function({ $("#mainhexa1").css({ "visibility": "visible" }); }, function() { //Your hover out function }); ```
14,749,379
Because *programming* is one of my favorite hobbies I started a small project in python. I'm trying to make a nutritional calculator for daily routine, see the code below: ``` # Name: nutri.py # Author: pyn my_dict = {'chicken':(40, 50, 10), 'pork':(50, 30, 20) } foods = raw_input("Enter your food...
2013/02/07
[ "https://Stackoverflow.com/questions/14749379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2050432/" ]
Using jQuery's [hover](http://api.jquery.com/hover/) function : ``` var divs = { cd: 'mainhexa1', illu: 'mainhexa2', klassisch: 'mainhexa3' }; $('[id^=gestaltung]').hover(function(){ // selects all elements whose id starts with gestaltung $('#'+divs[this.id.slice('gestaltung_'.length)]).toggle(...
Here's an example of how to do the first one and you'd just do the same for the other two with the relevant IDs. ``` $("#gestaltung_cd").hover( function () { $("#mainhexa1").show(); }, function () { $("#mainhexa1").hide(); } ); ```
14,749,379
Because *programming* is one of my favorite hobbies I started a small project in python. I'm trying to make a nutritional calculator for daily routine, see the code below: ``` # Name: nutri.py # Author: pyn my_dict = {'chicken':(40, 50, 10), 'pork':(50, 30, 20) } foods = raw_input("Enter your food...
2013/02/07
[ "https://Stackoverflow.com/questions/14749379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2050432/" ]
using jQuerys hover function, like this: ``` $('#gestaltung_cd').hover(function() { $('#mainhexa1').toggle(); }); ``` (if you don't want to hide the div on blur, then change toggle() to show())
If you wrap each block of divs in a container you can match them up by index, which will make the code work regardless of how many divs there are. Something like this: ``` <div class="gesaltung-container"> <div id="gestaltung_cd">gestaltung_cd</div> <div id="gestaltung_illu">gestaltung_illu</div> <div id="...