python

Sort list of names in Python, ignoring numbers?

['7', 'Google', '100T', 'Chrome', '10', 'Python'] I'd like the result to be all numbers at the end and the rest sorted. The numbers need not be sorted. Chrome Google Python 100T 7 10 It's slightly more complicated though, because I sort a dictionary by value. def sortname(k): return get[k]['NAME'] sortedbyname = sorted(get,key=sort...

Column Filtering on Trace File

I am doing visualization analysis on a trace file I generate from ns-2 that traces out the packets sent/received/dropped at various times of the simulation here is a sample trace output - http://pastebin.com/aPm3EFax I want to filter out the column1 after grouping it into S/D/R separately, so that I can sum it over to separately to fin...

Detach matplotlib window from sub-process

I've got a script which creates a graph, but the script keeps running in the background until the window is closed. I'd like it to quit as soon as the window is created, so that Ctrl-C in the shell won't kill the window, and so that the user can leave the window open and continue working in the shell without bg-ing it manually. I've seen...

Python/Tkinter: Are Tkinter StringVar (IntVar, etc) thread safe?

Are Tkinter StringVar (IntVar, FloatVar, etc) thread safe, eg. can a background thread read or write to these objects? Or must I use a Queue to pass information between my background thread and my main Tkinter GUI thread and have my main Tkinter thread pop the Queue and update the application's StringVar's accordingly? I know my applica...

python cx_freeze problem ascil

Hello I want to make EXE file by use py2exe or cx_freeze. so I was try to make exe file with py2exe but no luck. so now I was test with cx_freeze but it also failed. if anyone can help me much apprecaite following is setup.py file in cx_freeze from cx_Freeze import setup, Executable copyDependentFiles=True silent = True include...

Python regular expressions

Is there any regular expression to match this: a continuous string of characters or/and digits XOR a string of any characters between a pairquotation marks (" XOR ')including nested quotations ? Examples: dgsdggsgggdggsggsd 'dsfsasf .asgafaasfafw rq' "sadas fa fasfa " ...

Split list of names into alphabetic dictionary, in Python.

List. ['Chrome', 'Chromium', 'Google', 'Python'] Result. {'C': ['Chrome', 'Chromium'], 'G': ['Google'], 'P': ['Python']} I can make it work like this. alphabet = dict() for name in ['Chrome', 'Chromium', 'Google', 'Python']: character = name[:1].upper() if not character in alphabet: alphabet[character] = list() alphabet[...

Bluetooth connectivity in Python

How can I find nearby Bluetooth devices using Python, with a Bluetooth adaptor? ...

Dbus connection through mod_wsgi in python

Hi! I'm trying to write small application which allows to send dbus commands (to Amarok) through web page. I'm using python + mod_wsgi, because I need to run the script with the same user as Amarok. When I connect to the Amarok through normal shell, it works. But after connecting through the script, I get the following error: DBusExce...

Proc_open() c++/python problem

Hey, everyone I'm trying to make a call for a c++ / python file with proc_open (bi-directional support needed). After doing some on-line research i found created this code:(I first tried it with c++, after failure i tried pyhton aswell) Php: <?php $descriptorspec = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 =...

Is IronPython a 100% pure Python variant?

I just downloaded the original Python interpreter from Python's site. I just want to learn this language but to start with, I want to write Windows-based standalone applications that are powered by any RDBMS. I want to bundle it like any typical Windows setup. I searched old posts on SO and found guys suggesting wxPython and py2exe. Apa...

custom cgi.FieldStorage make_file implementation doesn't get called

I am building a file uploader that also shows the current progress, so I am trying to override the make_file method of the cgi.FieldStorage class, so that the current transferred data size can be logged. The problem is my method is not being called for some reason. Perhaps I misunderstood how this is supposed to work: #!/usr/bin/env pyt...

Why are these Python scripts giving syntax errors?

I am trying to install python on windows, and this is my first day on python. Install goes well on windows 7 x64. But almost all scripts fails. I am trying to install celery and running following command on celery folder. python setup.py build and it fails, following is an error File "setup.py", line 40 except ImportError, exc: ...

Any recommendations to improve this function?

I am very new to working with SQL queries. Any suggestions to improve this bit of code: (by the way, I really don't care about sql security here; this is a bit of code that will be in a pyexe file connecting to a local sqlite file - so it doesnt make sense to worry about security of the query here). def InitBars(QA = "GDP1POP1_20091224_...

Generate all possible strings from a list of token

Hi I have a list of tokens, like: hel lo bye and i want to generate all the possible combinations of such strings, like: hello lohel helbye byehel lobye byelo Language is not important, any advice? I found http://stackoverflow.com/questions/3846123/generating-permutations-using-bash, but this makes permutation on a single line...

Doing something with each line that belongs to a process's output

When using the subprocess module, how can I do something with each line of a process's output? I don't want to wait for all the output, like when using communicate, but rather do something with it as soon as it's produced. Can this be done? ...

python: how to validate userdefined condition?

what I am struggling with is testing predefined conditions which takes user provided parameters like in example below: cond = "if ( 1 is yes and 2 is no ) or ( 1 is yes and 2 is no )" cond2 = "if (3 is no or 1 is no )" vars = [] lst = cond.split() lst += cond2.split() for l in lst: if l.isdigit(): if l not in ...

how to program 8051 using python

can i program 8051 using python, i m not getting any of the to program 8051 in python environment. if any body know plzz help mee ...

zeromq persistent patents

Who has to manages the persistent in the ZeroMQ? When we use the ZeroMQ clients in Python language, what are the plug-ins/modules available to manage the persistent? I would like to know the patterns to use the ZeroMQ. ...

How to insert a large number of list entries into sqlite statements

Ok, I am using apsw with sqlite, and have a large list of entries.Each entry contains a new row to be inserted. The number of entries is sometimes 20, sometimes 21. Since apsw supports multiple sql statements in curser.execute(), I was wondering if there would be a less confusing way of inserting all my list entries into the database tha...