Tagged Questions
0
votes
0answers
5 views
Does py-postgresql driver accept named parameters in prepared queries?
py-postgresql has a lot of great features, and makes using Postgres from python3 a breeze. A statements is prepared and executed like this (assuming an open conenction named "pg"):
select = ...
-1
votes
1answer
40 views
Processing files listed from a dictionary
I have a text document topics.txt:
1~cocoa
2~
3~
4~
5~grain~wheat~corn~barley~oat~sorghum
6~veg-oil~linseed~lin-oil~soy-oil~sun-oil~soybean~oilseed~corn~sunseed~grain~sorghum~wheat
7~
8~
9~earn
...
2
votes
1answer
33 views
How can I detect special word occurs in teraterm log in run time using Python
I use teraterm as my client-console and save the console log somewhere.
When I open the teraterm and do something on my COM1 serial port (attached with a device),
it will print messages on the screen ...
1
vote
1answer
41 views
python - Using argparse, pass an arbitrary string as an argument to be used in the script
How do I define an arbitrary string as an optional argument using argparse?
Example:
[user@host]$ ./script.py FOOBAR -a -b
Running "script.py"...
You set the option "-a"
You set the option "-b"
You ...
0
votes
3answers
38 views
Is there a way to set a default parameter equal to another parameter value?
For example, I have a basic method that will return a list of permutations.
import itertools
def perms(elements,setLength=elements):
data=[]
for x in range(elements):
data.append(x+1)
...
6
votes
3answers
57 views
Function definition like range
Suppose I wanted to write a function similar to range
Recall that range has a one argument and 2/3 argument form:
class range(object)
| range(stop) -> range object
| range(start, stop[, ...
0
votes
3answers
74 views
how to create a dictionary from a file?
I'm trying to write a Python code that will allow me to take in text, and read it line by line. In each line, the words just go into the dictionary as a key and the numbers should be the assigned ...
0
votes
0answers
17 views
issue with browse button tkinter and py3
I'm running OSX mountain lion and using python3. The following code doesn't allow me to ever select a file after i hit the browse button. It shows files as grayed out. Also, I'm not clear on another ...
-1
votes
2answers
74 views
how to fix zero divide error in python?
import os
import re
import sys
sys.stdout=open('f1.txt','w')
from collections import Counter
from glob import glob
def removegarbage(text):
text=re.sub(r'\W+',' ',text)
text=text.lower()
...
2
votes
2answers
57 views
Sending broadcast to all networks
I am currently writing a python program that needs to discover other instances of itself on LAN. It uses UDP broadcasts for discovery (255.255.255.255).
The problem is that if the computer has ...
3
votes
0answers
36 views
Using Python's multiprocessing module together with the cvxopt package
I just came across an issue with the cvxopt package for convex optimization, which I didn't find mentioned in the documentation. I wonder if anybody knows what causes it and how to best work around ...
0
votes
0answers
21 views
Python Based NIDS
I am currently working on Network Intrusion Detection System Project.
I am trying to do it in a python languages as I am getting used to it.
I wanted to ask is there any library for developing a ...
1
vote
1answer
95 views
how to count words upto a limit in python?
I am writing a code, to count the frequency of word occurrences in a document containing about 20,000 files,i am able to get the overall frequency of a word in the document and
my code so far is:
...
1
vote
2answers
31 views
How do I change the default command for `run-python`?
I'm starting on a Python 3 project, so I'd like to configure Emacs' run-python command to use the python3 interpreter by default.
I don't want to
change python so that it points to python3 instead ...
1
vote
1answer
36 views
word frequency calculation in multiple files
I am writing a code, to count the frequency of word occurrences in a document containing about 20000 files,i am able to get the overall frequency of a word in the document and
my code so far is :
...