Hi,
I'm writing a parser in Python. I've converted an input string into a list of tokens, such as:
['(', '2', '.', 'x', '.', '(', '3', '-', '1', ')', '+', '4', ')', '/', '3', '.', 'x', '^', '2']
I want to be able to split the list into multiple lists, like the str.split('+') function. But there doesn't seem to be a way to do my_list.split('+'). Any ideas?
Thanks!
I am trying really hard to make a sliding frame containing widgets in tkinter in python. There is this frame inside a big window with different widgets. And as soon as i click on the next button on that frame the frame should slowly slide towards the left and vanish ultimately. As soon as it vanishes, i want new frame with widgets to come sliding towards right.
What should i do?
Anticipating your suggestions and ideas.
I'm new in python and I'm having some issues doing a simple thing.
I've an array (or list as it's said in pyton) like this:
list = [ 'NICE dog' , 'blue FLOWER' , 'GOOD cat' , 'YELLOW caw']
As you see each element of this array contains some words. These words is both lowercase and uppercase.
How I can delete from this array each lowercase words?
For example I'd like to have as result this list:
list = [ 'NICE' , 'FLOWER' , 'GOOD' , 'YELLOW']
I'm trying to work with sockets and I have such problem
In code example:
setsockopt(socket.SOL_SOCKET,IN.SO_BINDTODEVICE,self.listen_address+'\0')
I have error
AttributeError: 'module' object has no attribute 'SO_BINDTODEVICE'
On Linux machine this attribute is OK but on FreeBSD trere are no any SO_* attributes in module IN. What port should I install to resolve this problem on FreeBDS machine?
Python versions on Linux tested:
2.5.4 and 2.6.4;
on FreeBSD:
2.5.5
I can't find anything about this module in my book, and googling keyword IN looks like seamless ...
Python
params = urllib.parse.urlencode({'spam': '1', 'eggs': '2', 'bacon': '3'})
binary_data = params.encode('utf-8')
reg = urllib.request.Request("http://www.abc.com/abc/smart/ap/request/",binary_data)
reg.add_header('Content-Type','application/x-www-form-urlencoded')
f = urllib.request.urlopen(reg)
print(f.read())
PHP
if($_SERVER['REQUEST_METHOD'] == 'POST') {
//parse_str($_SERVER['QUERY_STRING']);
var_dump($_SERVER['QUERY_STRING']);
}
When i try print binary_data , it does show the parameter but by the time it reaches the PHP , i see nothing.
Any idea?
I want to produce a JSON file, containing some initial parameters and then records of data like this:
{
"measurement" : 15000,
"imi" : 0.5,
"times" : 30,
"recalibrate" : false,
{
"colorlist" : [234, 431, 134]
"speclist" : [0.34, 0.42, 0.45, 0.34, 0.78]
}
{
"colorlist" : [214, 451, 114]
"speclist" : [0.44, 0.32, 0.45, 0.37, 0.53]
}
...
}
How can this be achieved using the Python json module? The data records cannot be added by hand as there are very many.
I'm looking for a Python XMPP library that is able to reuse an already existing socket-like object (more specifically, a Bluetooth socket) for communicating, instead of connecting to a server.
Is there any nice library that can accomplish this?
Hi all
I am a newbie to the python. Can I unhash, or rather how can I unhash a value. I am using std hash() function. What I would like to do is to first hash a value send it somewhere and then unhash it as such:
#process X
hashedVal = hash(someVal)
#send n receive in process Y
someVal = unhash(hashedVal)
#for example print it
print someVal
Thx in advance
Is there any way other than creating a method myself to write XML using python which are easily readable? xMLFile.write(xmlDom.toxml()) does create proper xml but reading them is pretty difficult. I tried toprettyxml but doesn't seem like it does much. e.g. following is what I would consider a human readable xml:
Hi
i am new to python
i am trying to extract the text between that has specific text file
----
data1
data1
data1
extractme
----
data2
data2
data2
----
data3
data3
extractme
----
and then dump it to text file so that
----
data1
data1
data1
extractme
---
data3
data3
extractme
---
thanks for the help
data1
data1
I have a long-running python server and would like to be able to upgrade a service without restarting the server. What's the best way do do this?
if foo.py has changed:
unimport foo <-- how do I do this?
import foo
myfoo=foo.Foo()
I need to be able to block the urls that are stored in a text file on the hard disk using Python. If the url the user tries to visit is in the file, it redirects them to another page instead. How is this done?
Does anybody know any module in Python that computes the best bipartite matching?
I have tried the following two:
munkres
hungarian
However, in my case, I have to deal with non-complete graph (i.e., there might not be an edge between two nodes), and therefore, there might not be a match if the node has no edge. The above two packages seem not to be able to deal with this.
Any advice?
I need to use the Sybase Python module but our SA's won't install because it's not in the repo's. I've downloaded it and placed it on the box and would just like to 'import' or 'include' the module without installing it first. - Is this possible? From the looks of it (Sybase ASE) it needs some type of compilation before use. Is it possible for this type of work around?
I have downloaded and install a python library, via setup.py , python2.5 setup.py install ...
now the version is changed at the source . a newer library is available. originally , i have clone it via mercurial, and install it. right now , i have updated repository.
how do i use the newer version ? overwrite the installation ?
by simply doing setup.py install again ?
Im using python to access a MySQL database and im getting a unknown column in field due to quotes not being around the variable.
code below:
cur = x.cnx.cursor()
cur.execute('insert into tempPDBcode (PDBcode) values (%s);' % (s))
rows = cur.fetchall()
How do i manually insert double or single quotes around the value of s?
I've trying using str() and manually concatenating quotes around s but it still doesn't work.
The sql statement works fine iv double and triple check my sql query.
I just installed python 2.6 on my mac, mainly because I couldn't find freeze in my 2.5 distribution. I am wondering where freeze is. Is it even installed at all in the mac distribution?
I want to break a Python string into its characters.
sequenceOfAlphabets = list( string.uppercase )
works.
However, why does not
sequenceOfAlphabets = re.split( '.', string.uppercase )
work?
All I get are empty, albeit expected count of elements
(Using python 3.2 currently)
I need to be able to:
Run a command using subprocess
Both stdout/stderr of that command need be printed to the terminal in real-time (it doesn't matter if they both come out on stdout or stderr or whatever
At the same time, I need a way to know if the command printed anything to stderr (and preferably what it printed).
I've played around with subprocess pipes as well as doing strange pipe redirects in bash, as well as using tee, but as of yet haven't found anything that would work. Is this something that's possible?
How do you end up running pypcap for python 2.6 on a mac? It seems that there hasn't been any new releases since 2.5 or am I just looking in the wrong places?
I am iterating over an array in python:
for g in [ games[0:4] ]:
g.output()
Can I also initialise and increment an index in that for loop and pass it to g.output()?
such that g.output(2) results in:
Game 2 - name: Fruit Splat, text: "Splat fruits!", bitrate: 250000
Hi folks,
I'm serving a Django app behind IIS 6. I'm wondering if I can restart IIS 6 within Python/Django and what one of the best ways to do would be.
Help would be great!