python

Help me with my backprop implementation in Python

EDIT2: New training set... Inputs: [ [0.0, 0.0], [0.0, 1.0], [0.0, 2.0], [0.0, 3.0], [0.0, 4.0], [1.0, 0.0], [1.0, 1.0], [1.0, 2.0], [1.0, 3.0], [1.0, 4.0], [2.0, 0.0], [2.0, 1.0], [2.0, 2.0], [2.0, 3.0], [2.0, 4.0], [3.0, 0.0], [3.0, 1.0], [3.0, 2.0], [3.0, 3.0], [3.0, 4.0], [4.0, 0.0], [4.0,...

SWIG: C++, Python. Single Interface for different shared libraries(sharing common base class)

Environment : C++, Python, SWIG Problem : C++ : I have different shared library(.so) files which share common base class. SWIG: I can have a wrapper for each .so file & can use corresponding .py in python module. But, this makes lot of interface files & also lot of import statements in python. Expected: I would like to have best poss...

How to customize pynotify?

How to set icon size in the notifications? How to set how much time the notification have to be shown? Where is a complete pynotify documentation? Can the notification be clickable? (example: if I click on the notification, print "hello world" in the terminal). ...

Checking for duplicates

Hello everyone, I have a small problem. I am trying to check to see if status's value already exists and make sure I do not create another instance of it, but I am having some trouble. Ex. If the project status was once "Quote" I do not want to be able make the status "Quote" again. Right now, I check to make sure if the user select...

How to use ConfigParser with virtualenv?

I wrote a tool that looks in several places for an INI config file: in /usr/share, /usr/local/share, ~/.local/share, and in the current directory. c = ConfigParser.RawConfigParser() filenames = ['/usr/share/myconfig.conf', '/usr/local/share/myconfig.conf', os.path.expanduser('~/.local/share/myconfig.conf'), ...

Problem with removing mail message. use imap4

I try to remove message from inbox folder and all alright, but when i switched to All Mail folder the removing does not work. expunge() method returns ('OK', [None]) and message was not removed: >>>import imaplib >>>server = imaplib.IMAP4_SSL('imap.gmail.com','993') >>>server.login('[email protected]','Password') >>>server.select('...

Cross-platform way to specify Python interpreter when running with execv

I am currently running a Python scripts both on Linux and Windows 7. The file is executed in an execv style with which I mean that the interpreter is defined in the beginning of the file in a command. In Windows system, the interpreter specification is: #!C:\Python26\python.exe However in Linux this needs to be #!/usr/bin/python I...

Registering a Python program as a Windows Server 2003 R2 Service

Hi all, I wrote a Python script that I need to have installed on Windows Server 2003 R2, that will run when a specific directory is changed in any way (new files, deleted files, etc). I believe I need to register this as a system service, in order to listen for that, but I'm really not sure. So, my question is this: does such a script n...

Python: Use Regular expression to remove something.

Hi,I've got a string looks like this ABC(a =2,b=3,c=5,d=5,e=Something) I want the result to be like ABC(a =2,b=3,c=5) What's the best way to do this? I prefer to use regular expression in Python. Sorry, something changed, the raw string changed to ABC(a =2,b=3,c=5,dddd=5,eeee=Something) ...

Python: Regular expression help

Hi, I've got a string looks like this String a is "ACdA(a = %b, ccc= 2r2)" String b is "\ewfsd\ss.jpg" Expected outputs: ACdA(a = %b, ccc= 2r2, b_holder = \ewfsd\ss.jpg) It adds the string b to the end of string a, that's it! But be careful of the ")" "b_holder " is hard coded string, it's absolutly same in all cases, won't be cha...

Using Python to download a document that's not explicitly referenced in a URL

I wrote a web crawler in Python 2.6 using the Bing API that searches for certain documents and then downloads them for classification later. I've been using string methods and urllib.urlretrieve() to download results whose URL ends in .pdf, .ps etc., but I run into trouble when the document is 'hidden' behind a URL like: http://www.oecd...

How to find positions of the list maximum?

I have a list: a = [32, 37, 28, 30, 37, 25, 27, 24, 35, 55, 23, 31, 55, 21, 40, 18, 50, 35, 41, 49, 37, 19, 40, 41, 31] max element is 55 (two elements on position 9 and 12) I need to find on which position the maximum elements are situated. Please, help. ...

PyCXX: How to construct an instance of a user defined new style class from C++ code?

I am using PyCXX to write an extension that exposes multiple (new style) classes to Python. A method of one of the classes (say A) needs to return an instance of another (say B) of these classes. I can't see an obvious way of constructing an instance of B from within C++ code. The constructors of new style classes require a PythonClass...

copy from file while find a mark in python

hello guys i tried to do that code but it's not work :( F=open('C:\T\list.txt','r').readlines() B=open('C:\T\list2.txt','w') BB=open('C:\T\list2.txt','r').readlines() while BB.readlines() == 'John smith': B.writelines(F) so how i can told my python : go to copy from file : List1.txt to List2.txt but if you found John smith stop co...

cut from file in python

hello guys can anyone led me what i should do with cut from file so how i can told my python open items.txt then cut 20 lines from beginning then paste it on Sold-items.txt ...

CherryPy combine file and dictionary based configuration

I'm setting up a CherryPy application and would like to have the majority of my configuration settings in a .conf file like this: [global] server.socketPort = 8080 server.threadPool = 10 server.environment = "production" However I would also like to setup a few with a dictionary in code like this: conf = {'/': {'tools.staticdir.on': ...

swig/python detected a memory leak... no destructor found - for enums!

This is about embedded python using swig. I have an std::map exposed to python (embedded python). When the script is executed, swig spits out the below "warning" at the end (when the map goes out of scope - I guess): swig/python detected a memory leak of type 'std::map< MyEnum, std::string> ... no destructor found The .i file is: en...

Is python time module reliable enough to use to measure response time?

Hi, My question was not specific enough last time, and so this is second question about this topic. I'm running some experiments and I need to precisely measure participants' response time to questions in millisecond unit. I know how to do this with the time module, but I was wondering if this is reliable enough or I should be carefu...

python to uncomment the right line

Hi, guys, I have a file as follows: line 1: _____ ... # for AAA #export CONFIG = AAA_defconfig # for BBB, BbB, Bbb, BBb3 #export CONFIG = BBB_defconfig # for CCC, CcC, Ccc, Ccc1 #export CONFIG = CCC_defconfig ... other lines I want manipulate the file, so that based on the given string, I could export the right "CONFIG", and...

Insert data into texctrl

To insert data into a textctrl i do this : num_items = self.lc_sources.GetItemCount() self.lc_sources.SetStringItem(num_items, 1, data) But the problem is the insertion is done after the treatment of data, well and i need to do insertion in real time. Please how can i do this ...