plot debugging problem
Hi friends pls help with debugging problem the mutter is: during debugging the debug processes stacks when fig is created for example, in code import random import matplotlib.pyplot as plt from pylab import * x= 23; y = 11; print(23456) plt.plot(range(10)) plot([1,2,3]) show() print() a=888 it is impossible after show() to continue debug as stated in Beginning Python Visualization - Crafting Visual Transformation Scripts (2009) page 187 Note If you’re not using matplotlib interactively in Python, be sure to call the function show() after all graphs have been generated, as it enters a user interface main loop that will stop execution of the rest of your code. The reason behind this behavior is that matplotlib is designed to be embedded in a GUI as well. In Windows, if you’re working from interactive Python, you need only issue show() once; close the figures (or figures) to return to the shell. Subsequent plots will be drawn automatically without issuing show(), and you’ll be able to plot graphs interactively. Best Regards Sandy _ Hotmail: Free, trusted and rich email service. https://signup.live.com/signup.aspx?id=60969-- http://mail.python.org/mailman/listinfo/python-list
graphs in Python during debugging
Hi friends Can you help pls to find how to plot graphs in Python during debugging without destroying figures to continue to debug the mutter is: during debugging the debug processes stacks when fig is created for example, in code import random import matplotlib.pyplot as plt from pylab import * x= 23; y = 11; print(23456) plt.plot(range(10)) plot([1,2,3]) show() print() a=888 it is impossible after show() to continue debug as stated in Beginning Python Visualization - Crafting Visual Transformation Scripts (2009) page 187 Note If you’re not using matplotlib interactively in Python, be sure to call the function show() after all graphs have been generated, as it enters a user interface main loop that will stop execution of the rest of your code. The reason behind this behavior is that matplotlib is designed to be embedded in a GUI as well. In Windows, if you’re working from interactive Python, you need only issue show() once; close the figures (or figures) to return to the shell. Subsequent plots will be drawn automatically without issuing show(), and you’ll be able to plot graphs interactively. Best Regards Sandy _ Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. https://signup.live.com/signup.aspx?id=60969-- http://mail.python.org/mailman/listinfo/python-list
RE: Do any debuggers support "edit and continue?"
good question I also looking for debugging tools like Matlab in Python do you know how to stop in breakpoint investigate the variables by using graphics in figures and continue the mutter is: during debugging the debug processes stacks when fig is created for example, in code import random import matplotlib.pyplot as plt from pylab import * x= 23; y = 11; print(23456) plt.plot(range(10)) plot([1,2,3]) show() print() a=888 it is impossible after show() to continue debug as stated in Beginning Python Visualization - Crafting Visual Transformation Scripts (2009) page 187 Note If you’re not using matplotlib interactively in Python, be sure to call the function show() after all graphs have been generated, as it enters a user interface main loop that will stop execution of the rest of your code. The reason behind this behavior is that matplotlib is designed to be embedded in a GUI as well. In Windows, if you’re working from interactive Python, you need only issue show() once; close the figures (or figures) to return to the shell. Subsequent plots will be drawn automatically without issuing show(), and you’ll be able to plot graphs interactively. the problem is that after show() the debugger stacks the decision can be to use threads like this from pylab import plot,show,ion ion() x = range(10) plot(x) from threading import Timer t = Timer(0, show) t.start() a = 133 y = [2, 8, 3, 9, 4] plot(y) zz= 12346 print(4) but it is not working, bug?? Sandy > From: zapwiredashgro...@yahoo.com > Subject: Do any debuggers support "edit and continue?" > Date: Wed, 12 May 2010 10:42:31 -0700 > To: python-list@python.org > > Just curious... in Microsoft's Visual Studio (and I would presume some other > tools), for many languages (both interpreted and compiled!) there's an "edit > and conitnue" option that, when you hit a breakpoint, allows you to modify a > line of code before it's actually executed. > > Does any Python debugger support this feature? Being an interpreted language > it doesn't seem like it would necessarily be too onerous to support? It'd be > quite handy in that, especially if you hit a breakpoint due to the > interpreter > throwing an error, you could fix just the line in question and keep going, > rather than having to stop the entire program, fix the line, and then run > again and potentially kill a bunch of time getting the program back into the > same "state." > > Thanks, > ---Joel Koltner > > -- > http://mail.python.org/mailman/listinfo/python-list _ Hotmail: Trusted email with Microsoft’s powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969-- http://mail.python.org/mailman/listinfo/python-list
RE: Do any debuggers support "edit and continue?"
maybe ipython? http://showmedo.com/videos/video?name=120&fromSeriesID=100 > From: zapwiredashgro...@yahoo.com > Subject: Do any debuggers support "edit and continue?" > Date: Wed, 12 May 2010 10:42:31 -0700 > To: python-list@python.org > > Just curious... in Microsoft's Visual Studio (and I would presume some other > tools), for many languages (both interpreted and compiled!) there's an "edit > and conitnue" option that, when you hit a breakpoint, allows you to modify a > line of code before it's actually executed. > > Does any Python debugger support this feature? Being an interpreted language > it doesn't seem like it would necessarily be too onerous to support? It'd be > quite handy in that, especially if you hit a breakpoint due to the > interpreter > throwing an error, you could fix just the line in question and keep going, > rather than having to stop the entire program, fix the line, and then run > again and potentially kill a bunch of time getting the program back into the > same "state." > > Thanks, > ---Joel Koltner > > -- > http://mail.python.org/mailman/listinfo/python-list _ Hotmail: Powerful Free email with security by Microsoft. https://signup.live.com/signup.aspx?id=60969-- http://mail.python.org/mailman/listinfo/python-list
Performance Issues of MySQL with Python
Hi All, I am a newbie to MySQL and Python. At the first place, I would like to know what are the general performance issues (if any) of using MySQL with Python. By performance, I wanted to know how will the speed be, what is the memory overhead involved, etc during database specific operations (retrieval, update, insert, etc) when MySQL is used with Python. Any solutions to overcome these issues (again, if any)? Thanks and Regards, Sandeep -- http://mail.python.org/mailman/listinfo/python-list
I've started new blog
Hi all, I've started a new blog for discussion about the help can be provided to freshers. visit following URL: http://forfreshers.blogspot.com/ please visit and let the frshers get benifit from our discussion. thank you in advance. sandeep. -- http://mail.python.org/mailman/listinfo/python-list
Python Parallel Paradigm
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote >Well, I tried that, and it did something. It made it so the space bar >switched the clock once, but not a second time. And it still crashed, >but not always at the same time, sometimes it would do it the second >time I hit the space bar, sometimes before I hit it the first time, but >always when i did something that would generate a Console event (moving >the mouse or something). So, I thought it had something to do with >Console not working well with threads, so I took it completely out of >threads and had just the event checking loop run by itself, and it >still crashed. So apparently I am using the Console events wrong. I am >going to try and find some examples online on how to watch for events >with it, but if worse comes to worse I can try and use keyboard hooks, >I've looked at those before, and they might work better. Dear Pythonauts, I usually lurk on the comp.lang.python newsgroup. I'm not an expert in the slightest, but I have had a growing feeling that there's something definitely lacking in the concurrency aspects of Python. It is the same problem with Java. Forgive me if I don't know the right vocabulary, but Python concurrency seems to be exposed at too "low a level". It's like assembler: it's all _possible_ to implement, but in practise it's very complicated and fragile, glitchy, and really difficult to extend. Like programming in Dartmouth BASIC with just conditionals and "goto" instructions, before structured programming. A higher-level system of concurrency, not based on monitors and locks and great programmer discipline, will ultimately require making "Python 3000" a reality. In the meantime, is there anywhere, or any thing, that discusses the various concurrency options related to Python? There's Stackless Python (which I can't make head or tail of; I have been unable to find any lucid overview, or genuine explanation of the purpose of the design.) I know that there's a package for an Erlang system for Python, somewhere ("Parnassus" probably). There's probably a Py-CSP somewhere too. Lots of trees, but where's the Wood? Where are concurrency/distributed models compared and discussed? With kind regards, Sandy -- Alexander Anderson <[EMAIL PROTECTED]> (Yorkshire, England) Where there is no vision, the people perish. -- http://mail.python.org/mailman/listinfo/python-list
=?UTF-8?Q?=E2=96=BA=E2=96=BA=E2=96=BA_Earn_MILLIONS_online, _working_One_Hour_a_D?= AY ◄◄◄
Would you like a side-income of 1000's of Dollars a month? YES, This is possible if you have the skills to trade Forex. AND you can do all this without monitoring the market constantly. The Website listed below is tailored to both the new as well as the intermediate trader. In it, you will learn ::> How the Forex market works, ::> How to Profit from it, with as little as an hour a day of work. And Above ALL you get $50 bonus to TRADE FOREX ONLINE. For Further Details: http://forexzing.gigacities.net -- http://mail.python.org/mailman/listinfo/python-list
SciTE: Printing in Black & White
Dear Pythonic People, I recently discovered SciTE (1.68) as a programming editor, and I find it just beautiful. Small, fast, elegant and beautiful. I particularly like syntax highlighting features -- not simply different colours, but styles and fonts too. I don't know whether this is the right place to ask this type of question, but... ...I like to study large files of (hobby) code on paper. I have a black and white bubble-jet printer. However, my (Win NT4) screen syntax-highlighting setup has a couple of problems when it comes to doing print-outs. The _chief_ problem is that my on-screen background colour is not bright white -- it's an off-white cream, which is so much easier on my eyes: SciTEGlobal.properties... ... # Global default styles for all languages # Default style.*.32=$(font.base),back:#EDE1D5,fore:#00 ... However, each page of printout appears as black (or darkish) characters, on top of a filled rectangle of light texture, as the above "background". Ideally, I'd like to be able to configure SciTE printouts with a different highlighting style from the appearance on the screen. Instead of colour variations, I'd use combinations of bold, underlined, and italics, and different font faces -- all in plain black print -- for printouts on my b&w printer. How can I go about doing this? If I understand things right, I can configure my SciTE installation using Lua. But I hesitate slightly at this prospect, if there's a simpler (but more plodding) way. (I've already noticed that exporting as say RTF, and then changing the RTF styles for printing with a regular-expression script, is one possible, messy and very kludgey solution.) With kind regards, Sandy -- Alexander Anderson <[EMAIL PROTECTED]> (Yorkshire, England) Where there is no vision, the people perish. -- http://mail.python.org/mailman/listinfo/python-list
Re: SciTE: Printing in Black & White
Alexander Anderson: > ...I like to study large files of (hobby) code on paper. I have a > black and white bubble-jet printer. However, my (Win NT4) screen > syntax-highlighting setup has a couple of problems when it comes to > doing print-outs. > > The _chief_ problem is that my on-screen background colour is not > bright white -- it's an off-white cream, which is so much easier on my > eyes: There are several properties that tweak printing listed in the documentation. Perhaps you want print.colour.mode=2. Neil [ copied from the SciTE-interest mailing list, http://mailman.lyra.org/mailman/listinfo/scite-interest ] -- http://mail.python.org/mailman/listinfo/python-list
How to get a window ID in linux using python?
Hi all, Is there a way to get window ID in linux using python by just using the window name (say 'VPython')? This can be done in (Microsoft) windows (got it from somewhere else, not tested). import win32gui self.VP = win32gui.FindWindow ( None, 'VPython' ) In Linux, we can get window info by executing 'xwininfo' and then selecting the desired window manually. Can this be done automatically in python? Thanks, Sandy -- http://mail.python.org/mailman/listinfo/python-list
Re: prolog with python
you can also look at swi-prolog and python bridge: pyswip. I am using it and its very nice though it has some issues with 64-bit os. http://code.google.com/p/pyswip/ - dksr On Dec 3, 2:56 am, Chris Rebert wrote: > On Wed, Dec 2, 2009 at 6:47 PM, William Heath wrote: > > Hi All, > > > I have the following prolog program that I would really like to be able to > > run in python in some elegant way: > >From googling: > > http://pyke.sourceforge.net/http://code.activestate.com/recipes/303057/ > > Cheers, > Chris > --http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Simple if-else question
Hi all, A simple and silly if-else question. I saw some code that has the following structure. My question is why else is used there though removing else has the same result. More important, is it not syntactically wrong :-( for i in xrange(8): if i < 4: print i else: print i Cheers, dksr -- http://mail.python.org/mailman/listinfo/python-list
logging from several independent classes
Hi all, I was going through the last example in logging docs: http://docs.python.org/library/logging.html#using-logging-in-multiple-modules It explains how to log from multiple classes. The example works fine as long as the logger names are in a heirarchy (spam_application.auxiliary.Auxiliary, spam_application.auxiliary, spam_application). Just configure at top level and the child classes automatically inherit the config. If I change the name that don't have any heirarchy, it fails to log properly. My question is: Is it possible to configure logging in the main script that calls different independent classes (say A, B, C) and still the loggers in A, B, C inherit the config from the main script? For example in class A, all I want to do is import logging log = logging.getLogger("A") and log should be configured according to who ever instantiates A. Cheers, Sandeep -- http://mail.python.org/mailman/listinfo/python-list
Re: logging from several independent classes
> All named loggers (including "A", "B" etc.) inherit from the root logger, > obtained by doing > > root_logger = logging.getLogger() > > or > > root_logger = logging.getLogger("") Somehow I missed this in the docs. Thanks Vinay. -- http://mail.python.org/mailman/listinfo/python-list
confused with os.fork()
Hi all, I am a little bit confused about os.fork(). Say I have the following code. import os a = ['a','b','c','d','e'] for i in xrange(len(a)): pid = os.fork() if not pid: print a[i] os._exit(0) >From most of the tuts and examples I saw online, I expect it to print a,b,c,d,e. Sometimes (very rare) it prints something like this: ab c d e I thought there is no way a parent process can enter the 'if'. Can anyone explain this behaviour? Is it the case where parent is forking a child even before the previous child is printing? In that case is there a way to prevent that? I can use os.wait(), but I don't want to wait till the child is finished, just don't want to mix the child processes, that's it. - dksr -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for crossfold validation code
Following is the code I use. I got it from web, but forgot the link. def k_fold_cross_validation(X, K, randomise = False): """ Generates K (training, validation) pairs from the items in X. Each pair is a partition of X, where validation is an iterable of length len(X)/K. So each training iterable is of length (K-1)*len(X)/K. If randomise is true, a copy of X is shuffled before partitioning, otherwise its order is preserved in training and validation. """ if randomise: from random import shuffle; X=list(X); shuffle(X) for k in xrange(K): training = [x for i, x in enumerate(X) if i % K != k] validation = [x for i, x in enumerate(X) if i % K == k] yield training, validation Cheers, dksr On Feb 20, 1:15 am, Mark Livingstone wrote: > Hello, > > I am doing research as part of a Uni research Scholarship into using > data compression for classification. What I am looking for is python > code to handle the crossfold validation side of things for me - that > will take my testing / training corpus and create the testing / > training files after asking me for number of folds and number of times > (or maybe allow me to enter a random seed or offset instead of times.) > I could then either hook my classifier into the program or use it in a > separate step. > > Probably not very hard to write, but why reinvent the wheel ;-) > > Thanks in advance, > > MarkL -- http://mail.python.org/mailman/listinfo/python-list
Re: cxfreeze on ubuntu 9.10
I used cxFreeze without any problem on Ubuntu 9.10 32 bit version. I tried it on a wxPython gui script and it works fine though I did'n use any setup file. Just try cxFreeze executable (should be in /usr/bin/) instead of setup file. $/usr/bin/cxFreeze my_script.py --target-dir=/what_ever_dir/ what_ever_dir will have the executable file and other libraries needed to run the executable. - dksr On Mar 25, 12:33 am, Waspinator wrote: > Hi, > > I'm trying to compile a python script on Ubuntu 9.10. It uses the gtk > toolkit. I tried to run GUI2EXE for a cxfreeze gui, but even after > installing wxPython in synaptic it still complains about not having > it. > > I also tried to use cxfreeze by itself but the file it produces does > not run. > > I tried to follow the information > athttp://cx-freeze.sourceforge.net/cx_Freeze.html > > I created a setup.py file that looks like this (from the page) > > from cx_Freeze import setup, Executable > > setup( > name = "gtk_test", > version = "0.1", > description = "gtk_test", > executables = [Executable("gtk_test.py")]) > > and ran: > > python setup.py build > > When I try to run the executable I get the following error: > > ../build/exe.linux-i686-2.6/library.zip/gtk/_gtk.py:12: > RuntimeWarning: tp_compare didn't return -1 or -2 for exception > ImportError: could not import gio > ImportError: could not import gio > Traceback (most recent call last): > File "/usr/lib/pymodules/python2.6/cx_Freeze/initscripts/ > Console.py", line 29, in > exec code in m.__dict__ > File "gtk_test.py", line 274, in > File "gtk_test.py", line 228, in main > AttributeError: 'module' object has no attribute 'Window' > > I was thinking of using the 'copy-dependent-files' option but I'm not > sure how. > > Any ideas? > > Thanks -- http://mail.python.org/mailman/listinfo/python-list
deleting objects present in a list
Hi all, I have large number of objects created and to handle them properly, I store them in a list. How can I delete all of these objects (delete I mean here is to remove the object from memory not just from list)? I cannot use the list to iterate through the objects to delete them. Because 'del' only reduces the reference count and as it is present in the list it is not deleted. I cannot delete the list because I loose control over the objects. Can anyone give a nice solution for this? Cheers, dksr -- http://mail.python.org/mailman/listinfo/python-list
Re: deleting objects present in a list
Thanks for the replies. Terry, What does 'immediately' mean? I did a small test and here are the results. import psutil def testing(): class Object(): pass l = {} apm = psutil.avail_phymem()/(1024*1024) print 'Before creating objs: ' + repr(apm) for i in xrange(50): l.update({Object():1}) apm = psutil.avail_phymem()/(1024*1024) print 'After creating objs: ' + repr(apm) return l def hello(): myl = testing() apm = psutil.avail_phymem()/(1024*1024) print 'Before deleting: ' + repr(apm) del myl # Here I want to delete the objects in the list # deleting myl doesn't seem to change the memory apm = psutil.avail_phymem()/(1024*1024) print 'After deleting: ' + repr(apm) if __name__ == '__main__': hello() OUTPUT: Before creating objs: 2516L After creating objs: 2418L Before deleting: 2418L After deleting: 2430L In my original case the memory is not getting released even after long time. - dksr On Apr 20, 8:44 pm, Terry Reedy wrote: > On 4/20/2010 3:21 PM, Sandy wrote: > > > Hi all, > > I have large number of objects created and to handle them properly, I > > store them in a list. How can I delete all of these objects (delete I > > mean here is to remove the object from memory not just from list)? > > I cannot use the list to iterate through the objects to delete them. > > Because 'del' only reduces the reference count and as it is present in > > the list it is not deleted. I cannot delete the list because I loose > > control over the objects. > > Deleting the list is the best you can do. If that deletes the last > reference, then the interpreter will delete the object when it feels > like it. For *current* CPython, this will be immediately. For other > implementations, whenever. -- http://mail.python.org/mailman/listinfo/python-list
Re: deleting objects present in a list
On Apr 21, 10:48 am, Dave Angel wrote: > (For some reason you posted your response before the message you were > replying to. That's called Top-posting, and is bad form on these > mailing lists) > > > > Sandy wrote: > > Thanks for the replies. > > > Terry, > > What does 'immediately' mean? I did a small test and here are the > > results. > > > import psutil > > > def testing(): > > class Object(): > > pass > > > l =} > > apm =sutil.avail_phymem()/(1024*1024) > > print 'Before creating objs: ' + repr(apm) > > > for i in xrange(50): > > l.update({Object():1}) > > > apm =sutil.avail_phymem()/(1024*1024) > > print 'After creating objs: ' + repr(apm) > > return l > > > def hello(): > > myl =esting() > > > apm =sutil.avail_phymem()/(1024*1024) > > print 'Before deleting: ' + repr(apm) > > > del myl > > > # Here I want to delete the objects in the list > > # deleting myl doesn't seem to change the memory > > > apm =sutil.avail_phymem()/(1024*1024) > > print 'After deleting: ' + repr(apm) > > > if __name__ ='__main__': > > hello() > > > OUTPUT: > > Before creating objs: 2516L > > After creating objs: 2418L > > Before deleting: 2418L > > After deleting: 2430L > > > In my original case the memory is not getting released even after long > > time. > > > - dksr > > > On Apr 20, 8:44 pm, Terry Reedy wrote: > > >> On 4/20/2010 3:21 PM, Sandy wrote: > > >>> Hi all, > >>> I have large number of objects created and to handle them properly, I > >>> store them in a list. How can I delete all of these objects (delete I > >>> mean here is to remove the object from memory not just from list)? > >>> I cannot use the list to iterate through the objects to delete them. > >>> Because 'del' only reduces the reference count and as it is present in > >>> the list it is not deleted. I cannot delete the list because I loose > >>> control over the objects. > > >> Deleting the list is the best you can do. If that deletes the last > >> reference, then the interpreter will delete the object when it feels > >> like it. For *current* CPython, this will be immediately. For other > >> implementations, whenever. > > First, you're using some 3rd party library for measuring some kind of > memory usage. I'd guess you're probably > usinghttp://code.google.com/p/psutil/ Since I'm not familiar with > how they derive these numbers, I can only make a good guess as to how > valid they are. And if avail_phymem refers to what its name implies, > it has little to do with Python. Python doesn't control physical > memory, only virtual. > > So let's skip those numbers and talk about what CPython actually does. > As others have pointed out, other implementations will be different. > > When you delete a large number of objects (which you can do with > myl=None), CPython may keep some of the memory under its own control for > reuse. A future object of the same size will fit nicely in the hole, > and that may be faster than calling free() and malloc() again. > > When CPython calls free(), the C runtime library almost certainly keeps > the memory for reuse by subsequent calls to malloc(). Operating system > calls for allocating and freeing memory are (usually) done in larger, > fixed-size blocks. In Windows for example, the granularity is 4k or 64k > for the more efficient methods of memory allocation. Swapfile > allocation, for example, is always in 4k multiples. See function call > VirtualAlloc(). Anyway, if there's even a single allocated byte in a > block, it can't release the block. And searching for such blocks is slow. > > When the operating system is told to free something, it usually does not > "free" physical memory immediately. In the case of Windows, it marks > the block as available, and eventually a daemon task will zero it. But > it could very well be "charged to" the current process until some other > process needs the physical memory. What it does do is free it from > virtual memory. But notice that Virtual memory is represented by a > swapfile on disk, and Windows doesn't support a file with gaps in it > (sparse allocation). So unless this particular allocation is at the end > of the file, the size isn't likely to go down. > > If you really want
Re: example of multi threads
On Jun 23, 11:58 am, Stefan Behnel wrote: > Mag Gam, 23.06.2010 12:24: > > > I am looking for a simple multi threaded example. > > > Lets say I have to ssh to 20 servers and I would like to that in > > parallel. Can someone please provide a an example for that? > > Sounds like you want to run background processes, not threads. Take a look > at the subprocess module. > > Stefan I use ssh which in turn uses paramiko import os import ssh for i in xrange(len(tasks)): pid = os.fork() if pid == 0: # if child process s = ssh.Connection(host = server, log = False) s.execute(cmd) s.close() os._exit(0) time.sleep(1) os.waitpid(pid, 0) - dksr -- http://mail.python.org/mailman/listinfo/python-list
all possible matchings of elements of two lists
Hi all, I basically want all possible matchings of elements from two lists, Ex: [1,2] [a,b,c] Required: [ [(1,a),(2,b)] [(1,b),(2,c)] [(1,c),(2,b)] [(1,b),(2,a)] [(1,c),(2,a)] [(1,a),(2,c)] ] My thought is to get all possible permutations of two lists given and select any combination and use zip to get the tuples. Repeat this for all possible combinations. Any other ideas? Sandy -- http://mail.python.org/mailman/listinfo/python-list
How to find free resident memory in Linux using python
Hi all, I want to find how much free memory (RAM) is available in my system using python. I tried psutil, parsing /proc/meminfo, top output etc but not satisfied. For example my gnome-system-monitor gui shows I am using 1GB (25%) of my RAM while /proc/meminfo, top, psutil says around 2GB is used. Is there anyway I can get the correct availble memory, may be adding cache, buffers etc to free memory in these and get some value that matches with the gnome-system-monitor gui? For example 'top' says: Mem: 3995048k total, 2231924k used, 1763124k free,43480k buffers while gnome-system-monitor gui shows I am using 1GB (25%) Thanks in advance, dksr -- http://mail.python.org/mailman/listinfo/python-list
Re: How to find free resident memory in Linux using python
On Oct 2, 10:08 pm, Seebs wrote: > On 2010-10-02, Sandy wrote: > > > I want to find how much free memory (RAM) is available in my system > > using python. > > The question is essentially incoherent on modern systems. You'd have to > define terms. Consider that on a given system, it's quite possible that > gigabytes of space are being used to cache disk buffers. Some of those > could be freed as soon as they get written; some could be freed simply by > dropping them, since they're just a read cache. There may be data which > have been paged out, and will be paged back in as soon as possible -- meaning > that freeing up space wouldn't actually increase the number of available > pages of memory for long. > > So basically, the question isn't all that well defined. You can get all > sorts of numbers. They may or may not mean anything. > > -s > -- > Copyright 2010, all wrongs reversed. Peter Seebach / > usenet-nos...@seebs.nethttp://www.seebs.net/log/<-- lawsuits, religion, and > funny pictureshttp://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get > educated! > I am not speaking for my employer, although they do rent some of my opinions. Thanks all for your suggestions. -- http://mail.python.org/mailman/listinfo/python-list
os.stat UnicodeEncodeError:
Hello everyone, I'm running into a problem with file names containing Unicode chars. Here is the error that I get when calling os.path.isfile: File "/usr/lib/python2.6/genericpath.py", line 29, in isfile st = os.stat(path) UnicodeEncodeError: 'ascii' codec can't encode characters in position 38-41: ordinal not in range(128) I'm working with python2.6, Ubuntu 10.10 running Gnome. The interesting thing is that I do not get this error when running the command in the python interpreter (with the same filename). Only when I do it through the application I developed. Shouldn't os module not be using the system locale in both cases? I tried setting the locale to en_US.UTF-8 but to no avail. Thank you, Sandy -- http://mail.python.org/mailman/listinfo/python-list
Python Training in Bangalore
Python Training in Bangalore Best Python Training Courses in Bangalore – Marathahalli, BTM Layout, Rajajinagar & Jaya Nagar. We train the students from basic level to advanced concepts with a real-time environment. We are the Best Python Training Institute in bangalore. URL : https://www.besanttechnologies.com/training-courses/python-training-institute-in-bangalore -- https://mail.python.org/mailman/listinfo/python-list
Python Training in Chennai
Python Training in Chennai with expert guidance and fully hands-on classes. Python is a high-level programming language sometimes it also denoted as the scripting language as it provides rapid & fast development and easy of use. url : https://www.besanttechnologies.com/training-courses/python-training-institute-in-chennai -- https://mail.python.org/mailman/listinfo/python-list
New Python opportunity in Boston
Hello, My name is Sandy Kontos and I have a Python/Jython role here in Boston for 3-6 months. Should you have any interest in the Boston area please give either myself and/or Mo Bitahi a call at 781 449 0600 Thank you Sandy Sandy Kontos Overture Partners, LLC 75 Second Avenue Suite 710 Needham, MA 02494 www.overturepartners.com [EMAIL PROTECTED] 781 449 0600 -- http://mail.python.org/mailman/listinfo/python-list
Socket communication problem
Hi, I'm new here, and fairly new to Python. I have been playing around with Python and started having a look at socket IO. I have written a script that communicates over a network to a server which is written in C. While trying to get this working, I have been running into a problem where the Python client appears to hang when it should be receiving data back from the server. After a few successful exchanges of data, the server sends 3605 bytes to the client, which the client receives. The server then sends 2 bytes to the client, and the client doesn't get them. A client program written in C# does not have this problem. I have narrowed the problem down as far as I can, and have two small scripts, client and server, and a data file they read from to know what they should be sending and receiving. The problem can be replicated using them within a few milliseconds of running them. At first, I thought this may be caused by Nagel's algorithm, so I disabled it explicitly using: s.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1) This made no difference. Can anyone point out what I'm doing wrong here? You can get the scripts and the 7K data file here: http://www.sorn.net/~sandyd/python/problem/ Or all together in a zip file here: http://www.sorn.net/~sandyd/python/problem.zip Thanks in advance, Sandy -- http://mail.python.org/mailman/listinfo/python-list
Re: Socket communication problem
Sandy Dunlop wrote: > Hi, > I'm new here, and fairly new to Python. I have been playing around with > Python and started having a look at socket IO. I have written a script > that communicates over a network to a server which is written in C. > While trying to get this working, I have been running into a problem > where the Python client appears to hang when it should be receiving data > back from the server. I forgot to add, I'm using Python 2.5.1 on OS X, and have also tried my program under Python 2.5.1 on Solaris 9. Cheers, Sandy -- http://mail.python.org/mailman/listinfo/python-list
Re: Socket communication problem
Jean-Paul Calderone wrote: > Neither the server nor client Python programs you linked to uses the socket > API correctly. The most obvious mistake is that the code does not check the > return value of socket.send(), which you must do. > > Twisted is a third-party library which abstracts many of the low-level > details of the BSD socket API away from you. You might want to take a > look at it. Thankyou. I've managed to get it working now that I'm using the socket API correctly. In case anyone else has the same issue in the future, I'll leave my solution here: http://sorn.net/~sandyd/python/solution I'll have a look at Twisted - sounds good. Thanks, Sandy -- http://mail.python.org/mailman/listinfo/python-list
Python 2.6.4 - Urllib2 - Windows XP - Reading streaming HTTP source kills network card ... (believe it or not)
This is very odd. Hopefully someone can shed some insight. I've tried this with Python 2.5.2 and recently upgraded to 2.6.4 and see the same problem. I'm running on Windows XP sp3. I'm interfacing with an IP camera that streamed jpeg frames at 10fps over HTTP. The format of the stream is: 4 bytes - size of the frame N N bytes - the jpeg frame I have the following program to read the data. It works fine for about 30-40 iterations and then my NIC dies. All connectivity to the outside world goes away until I need to reboot. So, first I thought it was a driver problem. I've replaced the NIC, tried other drivers, you name it ... same problem. I've tried it on another machine and while it doesn't take down the NIC, all communications to the camera after a while fail with "connection reset by peer" exception. The camera attempts to keep sending frame after frame (one every 100ms), but I'm only interested in the first frame. After I grab it I kill the connection to the camera. There is still data coming in. I assume it's in HTTP Chunked format, but have not put Wireshark on it yet. I suspect Python doesn't like me killing the connection when there is still data coming down ... but why would it take down my NIC too? The code is very simple: #- import urllib2 import struct import time import datetime ip='192.168.1.189' username='user' password='password' password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() top_level_url = "http://%s"; % ip password_mgr.add_password(None, top_level_url, username, password) handler = urllib2.HTTPBasicAuthHandler(password_mgr) opener = urllib2.build_opener(handler) urllib2.install_opener(opener) url = "http://%s/user/img_stream0.cgi"; % (ip, ) while 1: response = urllib2.urlopen(url) size_bytes = response.read(4) size, = struct.unpack("i", size_bytes) frame = response.read(size) response.close() print "Got ", datetime.datetime.now() time.sleep(1) #- Which gives the following output: testpull.py Got 2010-01-12 15:30:08.125000 Got 2010-01-12 15:30:09.453000 Got 2010-01-12 15:30:10.812000 Got 2010-01-12 15:30:12.156000 Got 2010-01-12 15:30:13.515000 Got 2010-01-12 15:30:14.89 Got 2010-01-12 15:30:16.265000 Got 2010-01-12 15:30:17.625000 Got 2010-01-12 15:30:19.031000 Got 2010-01-12 15:30:20.39 Got 2010-01-12 15:30:21.765000 Got 2010-01-12 15:30:23.093000 Got 2010-01-12 15:30:24.437000 Got 2010-01-12 15:30:25.765000 Got 2010-01-12 15:30:27.109000 Got 2010-01-12 15:30:28.75 Got 2010-01-12 15:30:30.078000 Got 2010-01-12 15:30:31.437000 Got 2010-01-12 15:30:32.781000 Got 2010-01-12 15:30:34.546000 Got 2010-01-12 15:30:35.906000 Got 2010-01-12 15:30:37.25 Got 2010-01-12 15:30:38.609000 Got 2010-01-12 15:30:39.953000 Got 2010-01-12 15:30:41.281000 Got 2010-01-12 15:30:42.578000 Got 2010-01-12 15:30:43.921000 Got 2010-01-12 15:30:45.25 Got 2010-01-12 15:30:46.562000 Got 2010-01-12 15:30:47.89 Got 2010-01-12 15:30:49.265000 Got 2010-01-12 15:30:50.625000 Got 2010-01-12 15:30:51.968000 Got 2010-01-12 15:30:53.328000 Got 2010-01-12 15:30:54.734000 Traceback (most recent call last): File "C:\dev\5110Snapshot\testpull.py", line 22, in response = urllib2.urlopen(url) File "C:\Python26\lib\urllib2.py", line 124, in urlopen return _opener.open(url, data, timeout) File "C:\Python26\lib\urllib2.py", line 389, in open response = self._open(req, data) File "C:\Python26\lib\urllib2.py", line 407, in _open '_open', req) File "C:\Python26\lib\urllib2.py", line 367, in _call_chain result = func(*args) File "C:\Python26\lib\urllib2.py", line 1146, in http_open return self.do_open(httplib.HTTPConnection, req) File "C:\Python26\lib\urllib2.py", line 1121, in do_open raise URLError(err) urllib2.URLError: failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond> At which point all connectivity on the PC is dead. This is truly bizarre. Anyone have any insights as to what might be happening. Or is there something blatantly wrong with my code? Help! -Sandy <>-- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6.4 - Urllib2 - Windows XP - Reading streaming HTTP source kills network card ... (believe it or not)
I've also run this under IronPython 2.6 and, while it takes longer (about 5 minutes), I get the same results. And this too takes down the NIC on the PC. It's gotta be something with my PC, so don't sweat it ... time for an upgrade I think. -S <>-- http://mail.python.org/mailman/listinfo/python-list
Strangeness: Cannot write to a file from a process created by Windows Task Scheduler ...
Hi there, Seeing some really weird behavior and perhaps someone has seen something similar: I have a python script that launches as a Windows Scheduled Task. The program simply opens a disk file and writes some text to it: --- f = open("waiting.txt", "w") x = 0 while 1: f.write("Sleeping: %d\r\n" % x) x += 1 time.sleep(2) f.close() --- I've run it under my user account. I've run it as Local Account. I've run it via pythonw and python ... only one way works: When I run with full credentials (not local account) and python (not pythonw) I get output in the file (and a CMD window appears while it's running). In every other combination it creates the 'waiting.txt' file, but doesn't write any output to the file. The length of the file is 0 bytes. Anyone have ideas what could be causing this? I suspect it's blocking on something, but I can't imagine where. There is no stderr/stdout output anywhere in the program so it's not blocking on anything stdio related (that I can imagine) Thoughts? -Sandy <>-- http://mail.python.org/mailman/listinfo/python-list
Re: Strangeness: Cannot write to a file from a process created by Windows Task Scheduler ...
Thanks Marco & Al, Yes it seems to be a flush problem. Strange how it doesn't require the explicit flush() when the console window appears, but does otherwise. Either way, it gives me a good direction to chase after. Thanks again for your quick help guys! -Sandy Marco Bizzarri wrote: You could try to flush the file? Maybe it would flush once you close, which never happens; did you try to limit the amount of times it run inside the 'while' loop? Regards Marco On Mon, Oct 26, 2009 at 6:17 PM, Sandy Walsh wrote: Hi there, Seeing some really weird behavior and perhaps someone has seen something similar: I have a python script that launches as a Windows Scheduled Task. The program simply opens a disk file and writes some text to it: --- f = open("waiting.txt", "w") x = 0 while 1: f.write("Sleeping: %d\r\n" % x) x += 1 time.sleep(2) f.close() --- I've run it under my user account. I've run it as Local Account. I've run it via pythonw and python ... only one way works: When I run with full credentials (not local account) and python (not pythonw) I get output in the file (and a CMD window appears while it's running). In every other combination it creates the 'waiting.txt' file, but doesn't write any output to the file. The length of the file is 0 bytes. Anyone have ideas what could be causing this? I suspect it's blocking on something, but I can't imagine where. There is no stderr/stdout output anywhere in the program so it's not blocking on anything stdio related (that I can imagine) Thoughts? -Sandy -- http://mail.python.org/mailman/listinfo/python-list <>-- http://mail.python.org/mailman/listinfo/python-list
Help with python-twain module
Hello everyone, Really need help with the python-twain module. I installed the module for python 2.6 on a win-xp 32bit machine. I ran the demo app and got a python core crash when calling SourceManager.OpenSource(). I've managed to run the scanner I'm using on a Linux machine with python-imaging-sane module, but ran into problems when switching to windows. Any help will be greatly appreciated, Thanks, Sandy -- http://mail.python.org/mailman/listinfo/python-list
python and GNU plot
pls pls help how to use Gnuplot Gnuplot runs from Python under Vista downloaded Gnuplot, but what they suggest only Run wgnuplot.exe Thank you very much in advance!!! Sandy _ Hotmail: Trusted email with Microsoft’s powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969-- http://mail.python.org/mailman/listinfo/python-list
RE: Multi-Threading in Python
great can help to find some examples of multiprocessing Sandy > Subject: Re: Multi-Threading in Python > From: awill...@whitemice.org > To: python-list@python.org > Date: Tue, 18 May 2010 10:45:11 -0400 > > On Tue, 2010-05-18 at 07:35 -0700, Lou wrote: > > Can anyone tell me how easy it is to do multi-threading in Python? > > Very easy. Or as easy as in any other platform - and as easy to screw > up. Personally I prefer to use multiprocessing [which is a module that > 'simulates' threads using separate processes]. IMO, it is hard to screw > up as you don't get any shared-state for free. > > > This has probably been brought up already, so if it has, thanks anyway > > -- > Adam Tauno Williams LPIC-1, Novell CLA > <http://www.whitemiceconsulting.com> > OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba > > -- > http://mail.python.org/mailman/listinfo/python-list _ Hotmail: Free, trusted and rich email service. https://signup.live.com/signup.aspx?id=60969-- http://mail.python.org/mailman/listinfo/python-list
RE: Multi-Threading in Python
good thanks a lot Sandy > Subject: RE: Multi-Threading in Python > From: awill...@whitemice.org > To: python-list@python.org > Date: Tue, 18 May 2010 12:45:37 -0400 > > On Tue, 2010-05-18 at 20:29 +0500, Sandy Ydnas wrote: > > great > > can help to find some examples of multiprocessing > > There is the reasonably good documentation at: > <http://docs.python.org/library/multiprocessing.html> > > I did a Multiprocessing presentation recently: > <http://groups.google.com/group/grpug/web/Multiprocessing.pdf> > > And I use multiprocessing in my project; but less than previously as I > now use AMQ for the IPC and multiprocessing only for the process > management. > <http://coils.hg.sourceforge.net/hgweb/coils/coils/file/af60dd17fa0e> > But an entire project is quite a bit to pick through. > > > > Subject: Re: Multi-Threading in Python > > > From: awill...@whitemice.org > > > To: python-list@python.org > > > Date: Tue, 18 May 2010 10:45:11 -0400 > > > > > > On Tue, 2010-05-18 at 07:35 -0700, Lou wrote: > > > > Can anyone tell me how easy it is to do multi-threading in Python? > > > > > > Very easy. Or as easy as in any other platform - and as easy to > > screw > > > up. Personally I prefer to use multiprocessing [which is a module > > that > > > 'simulates' threads using separate processes]. IMO, it is hard to > > screw > > > up as you don't get any shared-state for free. > > > > > > > This has probably been brought up already, so if it has, thanks > > anyway > > > > > > -- > > > Adam Tauno Williams LPIC-1, Novell CLA > > > <http://www.whitemiceconsulting.com> > > > OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba > > > > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > __ > > Hotmail: Free, trusted and rich email service. Get it now. > > > -- > http://mail.python.org/mailman/listinfo/python-list _ Hotmail: Trusted email with powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969-- http://mail.python.org/mailman/listinfo/python-list
to prevent reveres engineering for Python
Agree, reveres engineering is crucial issuer for programming language but every executable file can be cracked, for example by using disassembler!!! For each weapon there is antiweapon, so is it possible to prevent reveres engineering when customer have access to executable made from Python code??? Regards Sandy > From: pmau...@gmail.com > Subject: Re: where are the program that are written in python? > Date: Fri, 21 May 2010 23:29:37 -0700 > To: python-list@python.org > > On May 21, 9:12 pm, Ben Finney wrote: > > a...@pythoncraft.com (Aahz) writes: > > > In article > > > , > > > Patrick Maupin wrote: > > > > > >There are a lot of commercial programs written in Python. But any > > > >company which thinks it has a lock on some kind of super secret sauce > > > >isn't going to use Python, because it's very easy to reverse engineer > > > >even compiled Python programs. > > > > > That's not always true. Both my employer (Egnyte) and one of our main > > > competitors (Dropbox) use Python in our clients. We don't care much > > > because using our servers is a requirement of the client. > > > > Doesn't that mean those companies don't fit the above description? That > > is, neither of them “thinks it has a lock on some kind of super secret > > sauce” in the programs. So they don't seem to be counter-examples. > > Just because someone has competition doesn't mean they don't think > they have secret sauce. I think Aahz's main point was that in his sub- > industry, the secret sauce is guarded by not actually letting the > customer have access to executable code, other than through the > network. > > Regards, > Pat > -- > http://mail.python.org/mailman/listinfo/python-list _ Hotmail: Trusted email with Microsoft’s powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969-- http://mail.python.org/mailman/listinfo/python-list
RE: where are the program that are written in python?
http://en.wikipedia.org/wiki/List_of_Python_software List of Python software >From Wikipedia, the free encyclopedia Jump to:navigation, search This article needs additional citations for verification. Please help improve this article by adding reliable references. Unsourced material may be challenged and removed. (March 2008) The Python programming language is actively used by many people, both in industry and academia for a wide variety of purposes. Contents[hide] 1 Integrated development environments 2 Applications 3 Web Applications 4 Video games 5 Web frameworks 6 Graphics frameworks 7 GUI frameworks 8 Scientific packages 9 Mathematical libraries 10 Additional development packages 11 Embedded as a scripting language 12 Commercial uses 13 Python implementations 14 References 15 External links [edit] Integrated development environments Boa Constructor, a cross-platform IDE for Python development EasyEclipse, an open source IDE for Python and other languages Eric, an IDE for Python and Ruby PIDA, open source IDE written in Python capable of embedding other text editors, such as Vim Stani's Python Editor (SPE), a cross-platform IDE for Python development Webware for Python, a suite of programming tools for constructing web-based applications in Python Wing IDE, an IDE for Python NetBeans, is written in Java and runs everywhere where a JVM is installed. [edit] Applications Anki, a spaced repetition flashcard program Bazaar, a free distributed revision control system BitTorrent, original client, along with several derivatives BuildBot, a continuous integration system Calibre, an open source e-book management tool Chandler, a personal information manager including calendar, email, tasks and notes support that is currently under development Decibel Audio Player, an open source audio player Deluge, a BitTorrent client for GNOME emesene, a MSN/WLM substitute Exaile, an open source audio player Gajim, an instant messaging client for the XMPP protocol GRAMPS, an open source genealogy software Gwibber, a microblogging client Impressive (ex. KeyJnote), a presentation software Juice, a popular podcast downloader Mercurial a cross-platform, distributed source management tool Miro, a cross-platform internet television application Morpheus, file-sharing client/server software operated by the company StreamCast MusicBrainz Picard, a cross-platform MusicBrainz tag editor Nicotine, a PyGTK Soulseek client OpenLP, lyrics projection software OpenShot Video Editor PiTiVi, a non-linear video editor Portage, the heart of Gentoo Linux, an advanced package management system based on the BSD-style ports system Quake Army Knife, an environment for developing 3D maps for games based on the Quake engine Resolver One, a spreadsheet Sage (sagemath) combines more than 20 main opensource math packages and provides easy to use web interface with the help of Python SCons, a tool for building software Ubuntu Software Center, a graphical package manager, installed by default in Ubuntu 9.10 and higher Wammu, a mobile phone management utility Wicd, a network manager for Linux YUM, a package management utility for RPM-compatible Linux operating systems [edit] Web Applications ERP5, a powerful open source ERP / CRM used in Aerospace, Apparel, Banking and for e-government GNU Mailman, one of the more popular packages for running email mailing lists MoinMoin, a popular wiki engine Planet, a feed aggregator Plone, a user-friendly and powerful open source content management system Projectplace, Europe’s Leading Online Service for Project Collaboration Roundup, a bug tracking system ViewVC, a web-based interface for browsing CVS and SVN repositories Trac, web-based bug/issue tracking database, wiki, and version control front-end MediaCore Video CMS is an open source media focused content management system. [edit] Video games Civilization IV uses Python for most of its tasks Battlefield 2 uses Python for all of its addons and a lot of its functionality Eve Online uses Stackless Python Freedom Force Frets on Fire uses Python and Pygame The Temple of Elemental Evil, a computer role-playing game based on the classic Greyhawk Dungeons & Dragons campaign setting Vampire: The Masquerade – Bloodlines, a computer role-playing game based on the World of Darkness campaign setting Vega Strike, an open source space simulator [edit] Web frameworks CherryPy, an object-oriented web application server and framework Django, an MVC (model, view, controller) web framework Pylons, a lightweight web framework emphasizing flexibility and rapid development Quixote, a framework for developing Web applications in Python Topsite Templating System, another Python-powered web framework TurboGears, a web framework combining CherryPy, SQLObject, and Kid web2py, a full-stack enterprise web application framework, following the MVC design Zope, an application server, commonly used to build content management systems [edi