5 answers

Conditionals when defining a tuple / list

Say I have a list x = ['a','b','c'] to conditionally add a term to this you could do: if conditional: x.append('d') But I can't do this for a tuple (x = ('a','b','c')) For both cases is there ...

5 answers | 26 secs ago by will on Stack Overflow stackoverflow.com
2 answers

Python NameError: name is not defined for my script

I have a python script and I am receiving the following error. I'm a new learner to this language, so I created a simple script, called writing.py, to write participant names and scores into a text ...

2 answers | 41 secs ago by merit2go on Stack Overflow stackoverflow.com
2 answers

String in a list doesn't accept assignment

import os f=os.popen('df -h') drive_usage=f.read() drive_usage.split() email('test','Critical! Drive usage is very high!') for x in range(4,len(drive_usage)-1,6): s2 = ...

0 answers

DJango Questions: Custom User and ios

I am newbie in django so i'm a bit confused with some of it's features. I have to do a project for university. It consists of a desktop-web app where employees can do stuff like handle files, record ...

1 answer

Fibonacci series in python 3 displays only final number

I'm a beginner for Python and trying to print Fibonacci series recursively. When i try this, the return function doesn't print at all, hence just the argument that i pass gets printed. Here's the ...

1 answers | 2 mins ago by amrrs on Stack Overflow stackoverflow.com
5 answers

Python 2.7: Print to File

Why does trying to print directly to a file instead of sys.stdout produce the following syntax error: Python 2.7.2+ (default, Oct 4 2011, 20:06:09) [GCC 4.6.1] on linux2 Type "help", "copyright", ...

5 answers | 3 mins ago by alex on Stack Overflow stackoverflow.com
2 answers

Using python to call a shell command with sub-shell

I'm trying to call a simple shell command that saves random string to a parameter while using the bash everything is fine: < /dev/urandom LC_CTYPE=C tr -dc A-Za-z | head -c10 ; echo results in: ...

1 answer

Blocking Tkinter interface until thread finishes its task

I am writing a program in python that will process a big amount of data it reads from some excel file. I've build a GUI for this program using Tkinter. I know Tkinter is single threaded, hence to open ...

0 answers

Converting PNG file to bitmap array in Python

I would like to convert a PNG image to a 2 dimensional array where each array holds a list of the RGB values of that specific pixel. How could one create a program to read-in a *.png file and convert ...

12 answers

Extracting extension from filename in Python

Is there a function to extract the extension from a filename?

12 answers | 6 mins ago by Alex on Stack Overflow stackoverflow.com
0 answers

AWS autoscaling based on uwsgi listen queue

I want to add instances to the current setup based on uwsgi listen queue. If uwsgi process have a high backlog, a new machine will spin up and respond to requests.

1 answer

How to draw vertical lines interactively in matplotlib?

I have a time series plot and I need to draw a moving vertical line to show the point of interest. I am using the following toy example to accomplish the same. However, it prints all the lines at ...

1 answers | 7 mins ago by learner on Stack Overflow stackoverflow.com
0 answers

Django authentica() Not Working

I have just implemented Facebook login/signup on my site. When a user logs in, I check if I already have her Facebook UserID and email in my database. If yes the user is logged in with a password I ...

2 answers

How to invert numpy matrices using Singular Value Decomposition?

(Before you tell me, yes, I know you should never invert the matrix. Unfortunately for my calculations, I have a matrix which I have constructed, and it must be inverted somehow.) I have a large ...

1 answer

Getting SystemCheckError using inlines in django, Can't identify source

For the life of me, I cannot find a way to solve this, I don't really know what I'm doing wrong with the inlines. I'm using django 1.8 as well as django-nested-inline 0.3.4. Here's the contents of ...

1 answer

How to show the window which is called out by another .py file?

I have two .py files, respectively simple_1.py and simple_2.py. How to display the window of simple_2.py when I click the button in simple_1.py ? The same , how do display the window of simple_1.py ...

1 answers | 13 mins ago by SunApple on Stack Overflow stackoverflow.com
1 answer

Do I use a z-score or a t-score for my confidence interval?

I would like to estimate the mean of a set of data I have. I have 1000 data points, and I read somewhere that if your sample size is less than 30, you should use a t score, else use a z score. Here ...

1 answers | 13 mins ago by user3600497 on Stack Overflow stackoverflow.com
2 answers

Python only sort sub-sequences in a sequence

My data looks like: {12,} {13,} {10,} {16,} {17, 15,} {22,} {27,} {28,24,29,} {28,} {28,} Each line is a sequence. For each line, if multiple numbers occur in { }, I want to sort them in each ...

2 answers | 13 mins ago by Kyala on Stack Overflow stackoverflow.com
1 answer

Opening and reading UTF-16 files in Python

Recently I have been having trouble opening specific UTF-16 encoded files in Python. I have tried the following: import codecs f = codecs.open('filename.data', 'r', 'utf-16-be') contents = f.read() ...

1 answers | 17 mins ago by DJMcCarthy12 on Stack Overflow stackoverflow.com
1 answer

Python SimpleHTTPServer Change Service Directory

I wrote the following piece of code to start an HTTP server, with a future option of being able to start a TCP/IP server instead: import SimpleHTTPServer import SocketServer import time import socket ...

1 answer

Unable to deduce type parameters in global function

I’m trying to wrap a heavily templatized C++ library that uses classes and global functions acting on them. I would like to know why, in the following example, the Cython compiler gives me the error ...

1 answers | 21 mins ago by Marcel M on Stack Overflow stackoverflow.com
1 answer

check a triggered event with tkinter

Assuming the following line of code,my problem is that when the user click on update twice ,the window is displayed twice. Is there a simple way to disable this feature and check if a widget is ...

1 answers | 22 mins ago by Med.ali on Stack Overflow stackoverflow.com
0 answers

How to apply Naive Bayes Classifier on categorical(str) data?

I want to use sklearn for Naive Bayes Classification, and my data has 7 dimensions categorical data. I tried MultinomialNB It gives me error ValueError: invalid literal for float(): 1000-289 does ...

1 answer

Node.js refuses to find python even after %PYTHON% has been set

So I am trying to get the Node.js to work. Of course, it's not as easy as advertised :) I happen to have two python versions on my computer, but Node.js seems to only work with the older one, 2.7. ...

1 answers | 24 mins ago by Tomáš Zato on Stack Overflow stackoverflow.com
3 answers

Question about sys.argv (python)

sorry to ask a basic question, but it is hard to find on google. anyway, I have a program that does math from numbers found in various .txt files. one thing I would like to add is a -show argument to ...

3 answers | 24 mins ago by bofimpact on Stack Overflow stackoverflow.com
0 answers

On render(), how does Django knows which language to pick?

I am just very curious. Django runs the following line: email_body = get_template("applicant/email_with_token.txt").render(Context()) it runs it from form_valid() of a class-based view. New context ...

0 answers

How to change matplotlib Graph to graph linear equation?

I am a beginner programmer. I have a task to make a GUI with a linear equation y=mx+b and a set of parameters where I can change the m and b values. I have both matplotlib and numpy. I also have ...

0 answers

Web server receiving data as 2 separate array objects rather than the string I am trying to send

I am following through a guide to help me better understand working with sockets in Obj-C. I have run into a snag that I can't figure out. In the code I am using somewhere down the line the string: ...

3 answers

twitter/facebook comments classification into various categories

I have some comments dataset which I want to classify into five categories :- jewelries, clothes, shoes, electronics, food & beverages So if someones talking about pork, steak, wine, soda, eat ...

1 answer

I need help following along this decorator. And confirmation if I'm correct

Hi I'm just learning about how decorators look in my Python flask framework and wanted to confirm if I'm reading this properly since I can get lost in nested functions. Here is a piece of the code I'm ...

1 answers | 29 mins ago by Lem on Stack Overflow stackoverflow.com
15 30 50 per page
1 2 3