text stringlengths 226 34.5k |
|---|
BigQuery API:: Able to insert CSV data but data reflection in BigQuery is untimely
Question: Using python script for `Google app engine` to upload `CSV data` into
`Bigquery`. Coded using `PyDev` perspective of `Eclipse on Windows 7`.
The `insert` is successful but inside BigQuery sometimes the data gets
inserted immed... |
Python deepcopy, dictionary value in object changes
Question: I have a python code snippet here:
import copy
class Foo(object):
bar = dict()
def __init__(self, bar):
self.bar = bar
def loop(self):
backup = copy.deepcopy(self)
... |
Flask( using watchdog) and uWSGI - no events from file system
Question: I am using [**watchdog**](https://pypi.python.org/pypi/watchdog) to reload
python modules on run of my **Flask server**. All works when I run my **debug
Flask server**. But when i start Flask server from **uWSGI** no notification
come into **watchd... |
cast a structure in python
Question: i am using ctypes to read some data from an external Database.
this data is written in struct. the problem is, that the recieved Data could
have different results. for bettern understanding: i have created two
structures:
class BEAM(Structure):
_fields_ = [
... |
Matching filename and saving it to a variable in python
Question: Does anyone know how to match a filename and then saving it to a variable?
For instance I've got multiple files that are being saved in one folder. All
of them start with the same name. "AmountFile" all of them start with but then
they differ in filenam... |
Why is my program returning the same permutations multiple times?
Question: I have a simple code which I am using to try and get all combinations of 4
nucleotide bases, but only as sets of 3 because 3 nucleotides make up a codon.
I basically need to generate all possible permutations that can be made by the
4 bases a, ... |
exceptions/traceback not showing after importing qgis-utils
Question: Following on from a
[question](http://stackoverflow.com/questions/26239144/python-qgis-version-
information) I asked about getting the version information from `python-qgis`,
with a brilliant solution provided by @falsetru, I am running into a proble... |
Yosemite and python matplotlib issue
Question: Can someone help me sort out the issue resulting to such an error. My python
codes were working well until I upgraded to Yosemite. Here is the error:
Traceback (most recent call last):
File "/Users/will/Downloads/legend_demo4.py", line 1, in <module>
... |
Speeding up the code using numpy
Question: I'm new to python, and I have this code for calculating the potential inside a
1x1 box using fourier series, but a part of it is going way too slow (marked
in the code below).
If someone could help me with this, I suspect I could've done something with
the numpy library, but ... |
Decorator with configurable attributes got an unexpected keyword argument
Question: I am attempting to combine two decorator tutorials into a single decorator
that will log function arguments at a specified log level.
The first tutorial is from [here](http://juandebravo.com/2012/07/24/why-
python-rocks_and_two/) and l... |
LiveScore BeautifulSoup Python
Question: I am using BeautifulSoup to parse this site:
<http://www.livescore.com/soccer/champions-league/>
I'm looking to get the links for the rows with numbers:
FT Zenit St. Petersburg 3 - 0 Standard Liege"
The 3 - 0 is a link a link; what I want to do is fi... |
Pick subset from list at random and maintain equal number of picks overall in python
Question: given a list of strings like so (in reality I have a much longer list but I'll
keep it short for here):
items=['fish','headphones','wineglass','bowtie','cheese','hammer','socks']
I would like to pick a su... |
How to replace the words that appear once in a sentence in python
Question: I want to replace the words that appear once in a sentence with `'<unk>'`.
Like for a sentence: `hello hello world my world`, I want the output to be
`hello hello world <unk> world`, how to do that?
Right now I'm doing like this:
... |
How to Define Google Endpoints API File Download Message Endpoint
Question: All the examples I can find on google endpoint api (e.g., tic-tac-toe sample)
show strings, integers, enums, etc fields. None of the examples say anything
about how to specify document (e.g., image or zip files) uploads or downloads
using the A... |
Adding input validation to my Rock Paper Scissor PYTHON
Question: I am trying to add input validation to this so the user can only enter ROCK,
rock, PAPER, paper, SCISSORS or scissors. I am unsure about where to add it,
and really how to do it as an if statement. Any help is greatly appreciated.
Of course I would need ... |
Imports from testing folder in Python
Question: I am writing a simple Pong game and am having some trouble with imports in my
testing. My project structure is as follows:
app/
__init__.py
src/
__init__.py
Side.py
Ball.py
test/
... |
Reading from stdin in Python 2.7.6. Sys.stdout.flush() and python -u doesn't work
Question: It seems like many people have been struggling with getting buffers and stdin
and stout working across many flavors of Python. I'm writing a script in
Python 2.7.6 to read from stdin, do a regex match, and print a list of
matchi... |
Python change locale with arrow
Question: I have a date string: "Viernes 24 de Octubre". I want to change it to arrow
datetime object. also i have installed es locales: `sudo apt-get install
language-pack-es-base` This doesn't work:
print arrow.get('Viernes 24 Octubre', 'dddd D MMMM', locale='es')
... |
Remove duplicate sequences from fasta file based on ID
Question: I wrote a tiny biopython script to extract sequences from a fasta file based
on ID but it does extract duplicates so I am looking to filter sequences from
my fasta files which are duplicate (e.g. have the exact same ID).
I tried to modify my script but I... |
Beginner: Adding x number of widgets to layout
Question: Really easy I'm sure but I'm learning Python & kivy (as a hobbyist not
professional).
I have made my first 'complex' kivy layout, and am now attempting to add
python code to it, and _I am fundamentally mis-understanding some things_. I
am keeping it all organise... |
Evaluate math equations from unsafe user input in Python
Question: I have a website where the user enters math equations (expressions) and then
those equations are evaluated against data (constants) provided by the
website. The math operations needed include symbols, arithmetic operations,
`min()`, `max()` and some oth... |
`reduce(add,...)` vs `sum(...)`, why the second fails on a list of objects
Question: I have the expectation that `reduce(add,lst)` and `sum(lst)` should give me
the same result, but
In [18]: class p():
def __init__(self, x, y):
self.x=x ; self.y=y
def __repr__(self):
... |
What is the proper goose import syntax
Question: The goose install places goose in the python-goose directory. When I try to
import goose at the IDLE prompt I get:
>>> from goose import Goose
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from goose import Goo... |
performance of NumPy with different BLAS implementations
Question: I'm running an algorithm that is implemented in Python and uses NumPy. The
most computationally expensive part of the algorithm involves **solving a set
of linear systems** (i.e. a call to `numpy.linalg.solve()`. I came up with
this small benchmark:
... |
Sorting Python list contating dicts
Question: I am looking for the fastest way to re-factor that following list which
contains dicts as items
[{u'domain': u'1d663096.bestapp243.biz',
u'flag_char_code': u'DR',
u'flag_hex': u'8081',
u'identifier': u'0000000002264A00',
u'indicator': ... |
Dump all network requests and responses in Python
Question: How can I use python to dump all of the network requests and responses? What
I'm looking to do would compare to the following (this example is in nodejs
<https://github.com/ariya/phantomjs/blob/master/examples/netlog.js>)
I have been trying a tonne of differe... |
np.mean 'str' object has no attribute 'mean' error
Question: I have Python code that worked up until yesterday and now has some floating
problem that I've been unsuccessful at tracking down. I'm trying to calculate
the mean of a list with np.mean but I get an error stating: `AttributeError:
'str' object has no attribut... |
how do I diagnose a vanishing port listener?
Question: I'm pulling data off a port using a python process, launched as an upstart job
on an Ubuntu server. The data is sent using TCP with each client sending a
single relatively small string of information:
The upstart config:
start on runlevel [2345]
... |
Python 3.4 Compiler?
Question: Ever since I started learning Python, I have wanted to distribute some small
programs I have made to my friends. Without handing out my source code. My
question is, what compilers are there for Python 3.4? I have heard of
cx_freeze and tried it, but it doesn't work for me. I am on Windows... |
How to Use VirtualEnv libraries along with system wide libraries?
Question: It might sound dumb, but I am having a hard time understanding how to use
VirtualEnv. My use case is as follows: 1\. My EC2 is python 2.6.9 and I need
to use graphlab create which uses > 2.7 2\. I installed a virtualenv and
installed graphlab i... |
How to insert object to mysql using python?
Question: I write code to read RFID tag using python, check the existence of the ID in
the database. If successful, right ID on database led is ON, but command
insert to database not work. Python gives no error message, and I do not
understand what's wrong with it.
How can I... |
Plotting datetimeindex on x-axis with matplotlib creates wrong ticks in pandas 0.15 in contrast to 0.14
Question: I create a simple pandas dataframe with some random values and a DatetimeIndex
like so:
import pandas as pd
from numpy.random import randint
import datetime as dt
import matplotli... |
Python break deep recursion - 2.7.8
Question: So I have a huge recursive function. At some point, it finds a result, and I
need it to stop all functions. Suggestions?
Answer: Assuming you cannot refactor your code, you could use generators to achieve
this. Let's say we have the following code:
from __f... |
What is the most pythonic way to use len on a scalar?
Question: I read this question
[python: how to identify if a variable is an array or a
scalar](http://stackoverflow.com/questions/16807011/python-how-to-identify-if-
a-variable-is-an-array-or-a-scalar)
but when using the following code I get a false on an `np.arra... |
How to implement custom control over python multiprocessing.Pool?
Question: Usually i use following code, and it works fine when you do not matter in
which order function `process_func` will handle some parameter:
params = [1,2,3,4,5 ... ]
def process_func():
...
pool = new Pool... |
Python/xpath get instances of text in arbitrary element
Question: Given the following:
<table>
<tr>
<td>
<div>Text 1</div>
</td>
<td>
Text 2
</td>
<td>
<div>
<a href="#"... |
Python & JSON: ValueError: Unterminated string starting at:
Question: I have read multiple StackOverflow articles on this and most of the top 10
Google results. Where my issue deviates is that I am using one script in
python to create my JSON files. And the next script, run not 10 minutes later,
can't read that very fi... |
python3 manage.py migrate exceptions
Question: I am new to django 1.7 and python3. I am using OSX. As I was following the
django 1.7 documentation online,
I tried
python3 manage.py migrate
and it resulted
Operations to perform:
Apply all migrations: auth, contenttypes, sessions,... |
Redirect Fabric output to a file
Question: I use fabric.api.local directly in my script. For example,
fabric_test.py
from fabric.api import local
local('echo hello world')
local('ls')
If I execute it without any io redirection, everything is fine
$ python fabric_test.py... |
Is there any way to make data corruption intentionally in python3?
Question: I'm now making an application which basically corrupts the data. That's what
it does. However, I cannot find ways to save the corrupted data into a
variable. I want the corrupted data saved in a python list like "holder=[]" to
make them access... |
Issue implementing git add/commit in sh python module
Question: I am experiencing the following strange behavior with git from sh python
module:
**Here is the python script:**
import sh
from datetime import datetime
now = str(datetime.now())
filename = "config.cfg"
file = filen... |
Flask Blueprint AttributeError: 'module' object has no attribute 'name' error
Question: My API is being built to allow developers to extend it's functionality. My
plan is to do this by providing an "extensions" directory where they can drop
in Blueprints and they will be dynamically loaded. This is the code I am
utiliz... |
efficient different sized list comparisons
Question: I wish to compare around 1000 lists of varying size. Each list might have
thousands of items. I want to compare each pair of lists, so potentially
around 500000 comparisons. Each comparison consists of counting how many of
the smaller list exists in the larger list (... |
LXML escaped character conversion
Question: Ok so first of all I have a script which is operating on a dos file formatted
XML file. That is, the file has \r\n line terminations. Furthermore, the XML
file I am operating on has some newlines embedded within some attributes. The
XML editor which produced the XML encodes t... |
Nested Lists and their index calls
Question: I was wondering how I would go about assigning a value to a specific index in
a list that is inside another list. For example:
For a list parentList
for i in range(0,rows, 1):
parentList[i] = []
for j in range(0,cols,1):
... |
How to receive UDP packets in Python without dropping
Question: I am writing simple software to parse MPEG-TS stream to check CC (cointinuity
counter) to see if any packets were dropped. When I run my script against file
it works flawlessly. But when using it on UDP stream it shows losses (which
are not confirmed by an... |
Linux : python : clear input buffer before raw_input()
Question: I have looked at a few thread about this, but it doesn't seem to solve my
problem. I am running linux and when I use raw_input(), with a pause between
each, it will take the data that I have pressed before, here is an example :
import time... |
How to put string on two lines in Python?
Question: I am brand new to the world of Python, PyCharm, and Web API testing.
I am trying to test error message that gets displayed when an error is made in
Web API. This error message has two parts and are displayed on two separate
lines.
But somehow any string definition I... |
What to pass when passing arguments where a list or tuple is required?
Question: Which of the following should I use and why?
import numpy as np
a = np.zeros([2, 3])
b = np.zeros((2, 3))
There are many cases where you can pass arguments in either way, I just wonder
if one is more Pythonic o... |
Compiling C extension with anaconda on Travis-CI missing __log_finite symbol
Question: A C extension module that compiles fine on Travis-CI without anaconda fails
when installed with anaconda. It appears to install just fine, but when I try
to import it, I get the following error:
ImportError: /home/trav... |
Python dynamic import and __all__
Question: I am facing a behaviour that I don't understand even through I feel it is a
very basic question...
Imagine you have a python package `mypackage` containing a module `mymodule`
with 2 files `__init__.py` and `my_object.py`. Last file contains a class
named `MyObject`.
I am t... |
How to use "from modname import *" to create and modify global names?
Question: I have read [the
documentation](https://docs.python.org/3.3/reference/simple_stmts.html#the-
import-statement) and also [this comprehensive
answer](http://stackoverflow.com/questions/710551/import-module-or-from-
module-import) but somethin... |
group by function in sqlite3 or itertools.groupy in python, sorting and grouping middle values within a string
Question: I have the following connection to a SQLite database returning data in the
"phone1" column, I'm looking to skip the area code portion and order by the
exchange (middle value) portion of phone1 column... |
GDB printing STL data
Question: After following the instructions given on this site:
<https://sourceware.org/gdb/wiki/STLSupport> GDB is still unable to print the
contents of stl containers like vectors, other than printing out a huge amount
of useless information. When GDB loads, I also get the following errors, which... |
Python Wake On Lan
Question: I'm trying to write a script that checks if a host on my intranet is up. if
so, wait 10 seconds and test again. if it is down, send a wake on lan packet
to the host, then test again in 10 seconds. The code compiles but doesn't seem
to be working. Any help is appreciated.
impo... |
Decoding/Encoding Href Links
Question: How can I get the result of `expected` to return a readable string? In other
words, when given `/wiki/Cookbook:Cao_l%E1%BA%A7u`, it should return
`/wiki/Cookbook:Cao_lầu`.
**Note** : I'm running on Python 2.7.2
import urllib
test_array = [
'/wiki/C... |
Python number game with changing feeback
Question: User guesses four digit number and feedback needs to be 'F' if a number is
correct but not in the right place, 'X' if the number is not in the number at
all and if the digit is correct and in the right position it displays the
digit. Code below shows my attempt but it ... |
Amazon MapReduce with my own reducer for streaming
Question: I wrote a simple map and reduce program in python to count the numbers for
each sentence, and then group the same number together. i.e suppose sentence 1
has 10 words, sentence 2 has 17 words and sentence 3 has 10 words. The final
result will be:
... |
Force Nosetests to Use Python 2.7 instead of 3.4
Question: I've been learning Python using version 3.4. I recently started learning
Web.py so have been using Python 2.7 for that, since web.py not supported in
Python 3.4. I have nose 1.3.4 module installed for both Python 3.4 and 2.7. I
need to run the nosetests command... |
How to plot error bars in polar coordinates in python?
Question: I have the following problem: I want to plot some data points in polar
coordinates in python, which is easy, using some code like
import numpy as np
import matplotlib.pyplot as plt
r = 1e04 * np.array([5.31,5.29,5.25,5.19,5.09,... |
Flask-Admin pages inaccessible in production
Question: I am trying to deploy my Flask app using Apache and mod_wsgi on an Ubuntu
server.
It seems to work fine for restful requests that I have implemented, but I
can't access my Flask-Admin pages (which I can access in development).
Here is the structure of my app (sim... |
pickle module doesn't work for this simple code
Question: when i run this code in Python 3.4.2(win7-64) it doesn't work! it creates file
but nothing in it.(0 bytes) I don't know what is the problem? Help- Thanks
Windo
import pickle
f=open ("G:\\database.txt","wb")
pickle.dump (12345,f)
An... |
Can I use aspects in python without changing a method / function's signature?
Question: I've been using python-aspectlib to weave an aspect to certain methods -
unfortunately this changes the methods signature to `Argspec(args=[],
varargs='args', keywords='kwargs', default=None)`, which creates problems when
working wi... |
Looking a instance's class hierarchy in Python
Question: Taking `zip` for example. I just want to know is it an `Iterable` or
`Iterator` or `Generator` .
so I put this:
zip(x,y).__class__
it prints: zip
Why class name are lowercase?
import inspect
inspect.getmro(zip)
zip... |
Python win32com getting the size of email
Question: I'm trying to generate a certain amount of email traffic using Python 3 and
win32com with Outlook. I need to know the size of the emails that I'm creating
to make sure the correct amount of traffic is generated. I've been trying to
use the mailItem.Size property to ge... |
Get the name of a python variable
Question:
def f(s)
print <name of s> = s
I wish to output "hello=10" for `f(hello)`, given that the variable hello has
value 10.
The problem is how to get the variable name of the variable, i.e., `<name of
s>`?
This is for debugging purpose. Say given a new statement... |
Parse json file with ironpython 2.5
Question: I am using IronPython 2.5 (inside TIBCO Spotfire) and would like to parse a
json file.
The json library is not available in this version of IronPython. simplejson
doesn't work either. Is there another library i can use for this? It can be
.Net or Python, doesn't matter.
T... |
Extracting unsigned char from array of numpy.uint8
Question: I have code to extract a numeric value from a python sequence, and it works
well in most cases, but not for a numpy array.
When I try to extract an unsigned char, I do the following
unsigned char val = boost::python::extract<unsigned char>(seq... |
Displaying the value of a variable in PyClips
Question: **I have been trying to print the value of a variable in PyClips without any
success.Any help would be appreciated. Here is the code.**
**Instead of "Are you observative" it prints "Are you ?name"**
def clips_raw_input(prompt):
return clips... |
QtMediaPlayer issue
Question: I am working with PyQt5 and trying to play a video on my Python application.
I am using Python 3.4.0 and PyQt 5.2.1 and running the application on Ubuntu
14.04, but it id important to make codes cross-platform.
When I run these codes, I get the error of
`defaultServiceProvider::requestS... |
How do I create a button in Python Tkinter to increase integer variable by 1 and display that variable?
Question: I am trying to create a Tkinter program that will store an int variable, and
increase that int variable by 1 each time I click a button, and then display
the variable so I can see that it starts out as 0, a... |
How would I separate my Python File to multiple plugins?
Question: So first thing I want to say: I have been looking into modules and such, I
just don't quiet know how I would rewrite it to fit this in.
Project: What I have is a Skype Bot using the Skype4Py module. I have about 11
commands I noticed the one script is ... |
Write a very basic copy from one file into another using command line arguments
Question: I am new to python and trying to make a basic copy one file into another file
program. My code right now is
import sys
if len(sys.argv) !=3:
print 'usage: filecopy source destination'
else:
t... |
The 'Hangman' game python code testing
Question: I have written this code for the Hangman game in which the opponent is the
computer. But I keep getting errors that I do not know how to solve. please
take a look for me. For example, my current error is:
Traceback (most recent call last):
File "C:\U... |
How to detect what element of a nested list has changed? (python)
Question: I have a large 2D (list of lists) list, each element containing a list of
ints, strings and dicts. I would like to be able to determine the 'path' (eg.
[2][3][2]["items"][2] at the worst!) of any element that is modified, and have
this fire upo... |
Slicing array in regions - Python
Question: I have to "divide" an `n x m` array in regions using a mask input.
For example, suppose I have a `20 x 20` array. My mask is the following (`5 x
5`) -- always:

where the numbers represent the regions in wh... |
Maya 2015 PyQt AttributeError
Question:
import maya.OpenMaya as om
import maya.OpenMayaUI as omUI
import sip
from PyQt4 import QtGui, QtCore, uic
import rpIcons_rc
import maya.cmds as cmds
import maya.mel as mel
def getMayaWindow():
# 'Get the maya main w... |
Product of subset of numbers in python
Question: I'm going through project euler, and i'm getting stuck on this question.
I'm going to post my code with comments, so everyone can follow my thinking
and see where I went wrong. All suggestions are appreciated :)
# need to find the largest product in a ser... |
HDF5 file created with h5py can't be opened by h5py
Question: I created an HDF5 file apparently without any problems, under Ubuntu 12.04
(32bit version), using Anaconda as Python distribution and writing in ipython
notebooks. The underlying data are all numpy arrays. For example,
import numpy as np
i... |
Indentation error
Question: I receive an indentation error that I cannot figure out the reason.
The error is
('unexpected indent', ('C:/Hamid/Failure_index.py',15,1,'\tSDV2=xyList[0]\n')).
My code is
from abaqusConstants import *
from odbAccess import *
from visualization ... |
How to add try exception in scrapy spider?
Question: I build a simple crawler application by using urllib2 and beautifulsoup, now i
am planning to change it into scrapy spider, but how i can handle errors while
running crawler, My current application have some code like this,
error_file = open('errors.tx... |
Grouping ips from list in python
Question: I have a text file containing 100s of comma separated IPs with just spaces
between them.
I need to take them 10 at a time and put them in another block of code. So,
for IPs:
`1.1.1.1, 2.2.2.2, 3.3.3.3, 4.4.4.4, ... 123.123.123.123, 124.124.124.124,
125.125.125.125`
I would ... |
Capture standard output for Python child spawned by external package
Question: I would like to capture in a file the standard output by a child Process
spawned by an external package.
I can NOT simply redirect sys.stdout to a file, as this does not capture the
output of new processes ([How can I capture the stdout out... |
detail view cant find pk
Question: Fairly new to Django and Python, I am trying to build a detail view and a list
view for a bunch of pictures I have uploaded. My list view works and shows all
the pictures I have but I cannot figure out how to create a detailview that
would let me look at only one picture.
In my "mysi... |
Python - Learn Python The Hard Way exercise 41 confused?
Question: I read all the answers related to that section but still didn't understand the
1 part. What exactly the following code does?
random.sample(WORDS, snippet.count("%%%"))
I know it means the number of occurrences of "###" in snippet bu... |
python rumps not working on OS X 10.10 - AttributeError: 'module' object has no attribute 'App'
Question: I am trying to run some demo from
<http://rumps.readthedocs.org/en/latest/examples.html> using Ridiculously
Uncomplicated Mac os x Python Statusbar apps and while importing rumps i get:
`AttributeError: 'module' ob... |
how to get the variables from the configuration file?
Question: please help to solve the problem for python2.7 / django1.6.
I need a console to display the value of the variable SITE_ID of the file
settings.py. For this I use the command:
python manage.py shell
but what to do I do not know.
Ans... |
GAE Python Datastore - query on nested class table
Question: I have a Java class that contains some nested classes, as follow:
public class OuterClass{
@PrimaryKey
private String id;
@Persistent
private String name;
// --- blah blah
stat... |
Read a CSV file in Python and print out unique dates from a column that has date and time
Question: I need to be able to read a csv file and sum a few columns per day and then
generate a new csv file with the solutions. I am brand new to Python and I
have figured out how to read the csv but now I must figure out how to... |
Conda Cython Build PYD/SO Files
Question: I have built a module using "conda build packagename".
However, the built module ends up in "\Anaconda\conda-bld\work".
The module can only be imported (using "import packagename")if I cd into this
directory, then run Python. I have tried placing the files in
"\Anaconda\conda... |
Plot (x, y, z) triples on 2d plane with a colormap
Question: I'm using `python2` and `matplotlib`.
I have lots of triples `(x, y, z)`. I need to plot them as a kind of
**histogram/heatmap** on a 2d plane with the axes `x` and `y` and a color
indicating `z`.
The main problem is that x and y are not on any kind of grid... |
django.db.migrations.graph.CircularDependencyError in Django 1.7.1
Question: Just upgraded to Django 1.7.1 and am trying to setup a fresh dev environment.
I ran a _users_ migration OK, but when I try to run a _tweets_ migration, I
get
Traceback (most recent call last):
File "./manage.py", line 10, ... |
Calculate "age" MongoDB document DateTimeField Flask
Question: I'm using python 3.4 and flask 0.10 with MongoDB 2.6 standard for my
application. With mongo Document. I want to calculate the "age" or "years"
from Persons just with its Birthday. I have this code:
import datetime
from Personal import db... |
Receiving end of socket splits data when printed
Question: So while programming sockets using Java and Python, I stumbled upon something
weird.
When sending a message using Java to the receiving end of the Python socket,
it splits the message into 2 parts, even though this was not intended.
I probably made a mistake ... |
Python Hangman Game finishing touches
Question: Here is my code:
def randWord():
"""opens a file of words and chooses a random word from the file"""
infile = open('dictionary.txt','r')
wordList = infile.read()
wordList2 = wordList.split('\n')
infile.close()
ran... |
python import from the sub-directories
Question: I have the following directories:
|-- project
| |-- __init__.py
| |-- proj1
| | |-- file.py
| | |-- file.py~
| | `-- __init__.py
| `-- proj2
| |-- call.py
| |-- call.py~
| `-- __init__... |
Exporting in CSV file format for Python
Question: I am trying to export some content in CsV format..but not able to do.
Below is the arbitrary idea that i am doing in python.
script , file = argv
emails = open(file,"r") #opens the file
results = csv.writer(open("Results.txt" , "w")) #Creates a ... |
Get data from 2 columns from a CSV file. Check whether the entries are same and add the currency amount
Question: I have a data.CSV file containg the following data
> column1,column2,amount, column3
>
> name1,empId1,**34.12** ,241682-27638-CIGGNT
>
> name2,empId2,**22.14** ,241682-27638-OCGGINT
>
> name3,empId3,**18.9... |
How to execute jar file in python multithreading
Question: In my project, I have a jar file (which was written by other developer) to
copy content from a pdf to text file. Using python multi threading concept, I
tried to execute this jar.
After I ran this script, I can able to see the text files are created. but the
f... |
how to call `getattr()` to get a Python MySQLCursor method?
Question: What do I need to do do before, to make this Python call succeed:
>>>getattr(MySQLCursor, "fetchall")
If I just make this call at the beginning of a script, it fails. I have a
cursor and I need to programmatically obtain one of i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.