Functions, callable objects, and bound/unbound methods
If I do this:
def f(self): print self
class c1: pass
setattr(c1, 'm1', f)
Then f is automagically transmogrified into the appropriate sort of
method depending on how it is used:
>>> c1.m1
>>> c1().m1
>
>>> c1().m1()
<__main__.c1 instance at 0x51ec60>
Note that m1 gets passed a self argument.
The same automatic transmogrification does not happen if I use an
callable instance instead of an actual function object:
class callable:
def __call__(self, *args, **kw): return args, kw
>>> setattr(c1, 'm2', callable())
>>> c1.m2
<__main__.callable instance at 0x51e738>
>>> c1().m2
<__main__.callable instance at 0x51e738>
>>> c1().m2()
((), {})
Note that no selfarg has been passed to m2.
The reason I want to do this is that I want to implement a trace
facility that traces only specific class methods. I want to say:
trace(c1.m1)
and have c1.m1 be replaced with a wrapper that prints debugging info
before actually calling the old value of m1. The reason I want that to
be an instance of a callable class instead of a function is that I need
a place to store the old value of the method so I can restore it, and I
don't want to start building a global data structure because that gets
horribly ugly, and a callable class is the Right Thing -- if there's a
way to actually make it work.
Is there? I tried the obvious things (like making callable inherit from
function, and adding im_func and im_self attribuetes) but they didn't
work.
Thanks,
rg
--
http://mail.python.org/mailman/listinfo/python-list
Re: Functions, callable objects, and bound/unbound methods
Ron Garret <[EMAIL PROTECTED]> wrote: > I want to say: > > trace(c1.m1) > > and have c1.m1 be replaced with a wrapper that prints debugging info > before actually calling the old value of m1. The reason I want that > to be an instance of a callable class instead of a function is that I > need a place to store the old value of the method so I can restore it, > and I don't want to start building a global data structure because > that gets horribly ugly, and a callable class is the Right Thing -- if > there's a way to actually make it work. > > Is there? I tried the obvious things (like making callable inherit > from function, and adding im_func and im_self attribuetes) but they > didn't work. Read "Functions and Methods" in http://users.rcn.com/python/download/Descriptor.htm You need to implement a __get__ method on your class. -- http://mail.python.org/mailman/listinfo/python-list
How to read the directory which the actively running python file is located in?
Is there a way to read the directory that the currently running python file is located in? Cheers Mike. -- http://mail.python.org/mailman/listinfo/python-list
Re: v2.3, 2.4, and 2.5's GUI is slow for me
g4rlik <[EMAIL PROTECTED]> wrote: > No one can help? This is seriously bugging me to no end. >> My problem is..the GUI for versions 2.3, 2.4, and 2.5 of Python run >> very sluggishly. When I type in them or move them around my desktop, >> it's very slow. I have figured out that this is because of the >> subprocesses running. Always slow or just sometimes? Idle can get very slow if you have generated a lot of output in the shell window, but usually it performs just fine. If you've accidentally printed "range(10)" then your best best is to kill it and restart. Use idle for development and testing: its best if you run actual scripts outside the development environment. -- http://mail.python.org/mailman/listinfo/python-list
RE: detecting that a SQL db is running
[EMAIL PROTECTED] | Sorry if i did not make myself clear. let me try again. | | I can detect when the db is up and not responding, however, | if the DB does not start at all, my local application hangs. I need to find a | way to determine if the DB has started, that's all. Maybe (and only maybe) some code which will determine when the corresponding Service has started would suffice. There's probably a few ways to do that. Just as a starter, try using WMI: http://timgolden.me.uk/python/wmi.html import wmi c = wmi.WMI () for msde_service in c.Win32_Service (Name="Name-of-msde-service"): if msde_service.State == "Stopped": print "Not up yet" If this worked, you could use WMI events, but be warned, the most recent version of the WMI module has a bug in the event class which someone's pointed out and patched but which I haven't fixed yet. If you want to try WMI (and to use that module) then download the previous version; it'll work perfectly well for the purpose. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I change the icon
On 30 Nov 2006 13:05:23 -0800, Boneh <[EMAIL PROTECTED]> wrote:
Boneh wrote:
> Is it possible to change the icon "Tk" of the windows popped up ?
I am using tkinter for widgets, thanks :-)
--
http://mail.python.org/mailman/listinfo/python-list
user iconbitmap method to change the icon of the window, this method works
on all root or Toplevel windows
iconbitmap(path of the ico file)
Example
from Tkinter import*
root=TK()
root.iconbitmap("c:/python25/smiley.ico")
Godson Gera
http://godson.auroinfo.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: Is there a reason not to do this?
Ron Garret wrote: > One of the things I find annoying about Python is that when you make a > change to a method definition that change is not reflected in existing > instances of a class (because you're really defining a new class when > you reload a class definition, not actually redefining it). So I came > up with this programming style: > > def defmethod(cls): > return lambda (func): type.__setattr__(cls, func.func_name, func) Why not just ``return lambda func: setattr(cls, func.func_name, func)`` ? Your approach is certainly uncommon, but for your use case it seems to me a pretty much decent solution. The only thing I don't like is that all your functions/methods will end up begin 'None'. I'd rather to be able to use the help, so I would write def defmethod(cls): def decorator(func): setattr(cls, func.func_name, func) return func return decorator @defmethod(C) def m1(self, x):pass help(m1) BTW, for people with a Lisp background I recommend using IPython with emacs and the ipython.el mode. It is pretty good, even if not comparable to Slime. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: why would anyone use python when java is there?
may I, as a former Englishman, say how proud we always were to be exploited by our betters many thanks guv Mark Jonathan Smith wrote: > gavino wrote: > > wtf > > Java is a coffee, and coffee comes from exploited Ethiopians (they do > have some damn fine coffee, though). Most of us prefer to exploit > Englishmen instead. (damn them and their humor!) > > -smithj -- http://mail.python.org/mailman/listinfo/python-list
How to turn AUTOCOMMIT ON with cx_Oracle
Hi all.
I use cx_Oracle to connect to an Oracle9i DB. And I want to turn on
AUTOCOMMIT function.
I see that cur.execute("SET AUTOCOMMIT ON") cannot work. Is there any
method to do that ??
Thanks a lot!
--
http://mail.python.org/mailman/listinfo/python-list
Re: Ruby/Python/REXX as a MUCK scripting language
Cameron Laird a écrit : > In article <[EMAIL PROTECTED]>, > Laurent Pointal <[EMAIL PROTECTED]> wrote: >> Fred Bayer a écrit : >>> Tony Belding wrote: I'm interested in using an off-the-shelf interpreted language as a user-accessible scripting language for a MUCK. I'm just not sure if I > . > . > . there's the security issue that really worries me. . . I have to be able to limit what the interpreter can execute. I can't have my users running scripts that access the console, access the filesystem or sockets directly, or call libraries or other binaries outside the MUCK. Is this practical? I'm thinking of Ruby or Python for this, if they can meet the requirements. >>> Don't forget Lua: www.lua.org >>> It fulfills your requirements and is easily embedable. >>> >> I Agree with F.Bayer, when reading OP post, I immediatly think about Lua. > > Does Lua have an appropriate security model--a sandbox or such? > Fond though I am of Lua, such would be news to me. I dont think of a security model like in Java, but in the possibility to limit the accessible libraries for interpreted code. http://www.lua.org/manual/5.1/manual.html#5 If OP just need some computation logic, he could limit external world communication libraries (these libraries must be loaded by the C host program before being usable by scripts). Need to look more precisely to the minimum library set to load and to available functions in this set. Maybe it is possible to remove some undesired functions from Lua symbol tables just after loading libraries. [note: I have still not used Lua, but I look at it for futur use in a current development where an embedded Python would be too heavy and make problems relative to the GIL - but I'm still a Python fan in other use cases] A+ Laurent. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a reason not to do this?
"Ron Garret" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > These objects can be parts of huge networks of massively linked data > structures. They are in constant flux. It is not uncommon to hit a bug > after many minutes, sometimes hours, of computation. Having to store > the whole shlemobble after every operation would slow things down by > orders of magnitude. And writing code to be clever and only store the > dirty bits would be a pain in the ass. I think I'll stick with Plan A. > > rg Sorry, not quite what I meant, I'm not suggesting storing everything after every change. I just meant that to help your development, once you get some instances to a steady state, persist them off in some picklish format, so you can restart quickly by unpickling, instead of dynamically reconstructing. But you know your problem domain better than I, so I'll shut up. Best of luck to you. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
python vs java & eclipse
Hi, It seems to me that measuring productivity in a programming language must take into account available tools and libraries. Eclipse for example provides such an amazing IDE for java that it is no longer obvious to me that one would be much more productive in python for medium sized projects. Sure, all that Java static typing can be painful, but Eclipse takes some of that pain away. Moreover, static typing can result in better on-the-fly error detection and refactoring support. Any thoughts on this? Amir -- http://mail.python.org/mailman/listinfo/python-list
Re: String formatters with variable argument length
John Machin wrote:
>> > Fredrik Tolf wrote:
>> > > The thing is, I want to get format strings from the user, and I don't
>> > > want to require the user to consume all the arguments.
> what's ugly about this:
> [untested]:
>
> def count_format_args(s):
> pending = False
> count = 0
> for c in s:
> if c == "%":
> # doubled % chars aren't counted
> pending = not pending
> elif pending:
> count += 1
> pending = False
> return count
>
> output = format % arglist[:count_format_args(format)]
Keep in mind, though, that it doesn't take '*' into account:
>>> count_format_args("%*.*f")
1
>>> "%*.*f" % (3,2,1)
'1.00'
And just because I don't think I've seen it before:
>>> count_format_args("%42%")
1
>>> "%42%" % ()
' %'
Peter
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to turn AUTOCOMMIT ON with cx_Oracle
"Jia Lu" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all.
> I use cx_Oracle to connect to an Oracle9i DB. And I want to turn on
> AUTOCOMMIT function.
> I see that cur.execute("SET AUTOCOMMIT ON") cannot work. Is there any
> method to do that ??
>
> Thanks a lot!
>
AUTOCOMMIT is a dangerous crutch, beware. Ok for single record updates, but
if you need to update 2 records in synch, AUTOCOMMIT leaves you open to
hard-to-debug bugs (will work ok in development under light load, then fail
intermittently with concurrent users).
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to turn AUTOCOMMIT ON with cx_Oracle
Paul McGuire のメッセージ: > AUTOCOMMIT is a dangerous crutch, beware. Ok for single record updates, but > if you need to update 2 records in synch, AUTOCOMMIT leaves you open to > hard-to-debug bugs (will work ok in development under light load, then fail > intermittently with concurrent users). Thanx. But I am doing an exception test to Servers. So I have to work without commit, but I need a autocommit environment of DB. -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL throws exception when reading bitmap/pnm data
Dennis Lee Bieber schreef: > Send a complaint to M$ requesting them to open document the NTFS > format... I've been out of the loop for a while, but the last time I > checked, NTFS was something that should be treated as read-only from > LINUX -- the recommendation was to make a small FAT-32 partition for any > data that needed to be shared. Going off-topic, but there's another way nowadays: if your Linux partitions use ext2 or ext3, you can use read/write them from Windows with the file system drivers from http://www.fs-driver.org/ -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java & eclipse
On 1 Dec 2006 01:24:47 -0800, Amir Michail <[EMAIL PROTECTED]> wrote: > Eclipse for example provides such an amazing IDE for java that it is no > longer obvious to me that one would be much more productive in python > for medium sized projects. Eclipse can generate a lot of the Java boilerplate code, it's true, saving you a lot of typing up front. But it can't maintain all those reams of pointless code for you, and perhaps more importantly, it can't read it for you. All the useless code that Java requires still has a large price, even if you don't need to type it yourself. > Sure, all that Java static typing can be painful, but Eclipse takes > some of that pain away. Moreover, static typing can result in better > on-the-fly error detection and refactoring support. I do sometimes spend some time finding and fixing bugs of the "I though I had a Spam instance, but it turns out to be a Eggs instance" issues when coding in Python, but then I spend some time sorting out "I know you've got a fry() method in there somewhere - just let me call it!" issues in Java, so it balances out. And the latter problems are more annoying, 'cos I feel the compiler isn't trusting me. Python usually trusts me, even if I don't always deserve it. ;-) FWIW, I spend perhaps 80% of my coding time with Java (and Eclipse), and 20% with Python. -- Cheers, Simon B [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Slicing versus loops, was Re: for i in range() anti-pattern
Steven D'Aprano wrote: > On Thu, 30 Nov 2006 11:17:17 +0100, Peter Otten wrote: > >> Steven D'Aprano wrote: >> >>> And remember that if alist is truly huge, you may take a performance hit >>> due to duplicating all those megabytes of data when you slice it. >> >> Having the same object in two lists simultaneously does not double the >> total amount of memory; you just need space for an extra pointer. > > Sure. But if you have millions of items in a list, the pointers themselves > take millions of bytes -- otherwise known as megabytes. I don't know the exact layout of an int, but let's assume 4 bytes for the class, the value, the refcount and the initial list entry -- which gives you 16 bytes per entry for what is probably the class with the smallest footprint in the python universe. For the range(N) example the slicing approach then needs an extra 4 bytes or 25 percent. On the other hand, if you are not dealing with unique objects (say range(100) * (N//100)) the amount of memory for the actual objects is negligable and consequently the total amount doubles. You should at least take that difference into account when you choose the swapping algorithm. >> That example was chosen to prove your point. > Well, I thought about choosing an example that disproved my point, but I > couldn't think of one :-) Lack of fantasy :-) >> The real contender for the "swap items" problem are slices. >> >> def swap_slice(items): >> left = items[::2] >> items[::2] = items[1::2] >> items[1::2] = left >> return items > > I always forget that extended slices can be assigned to as well as > assigned from! Nice piece of code... if only it worked. > def swap_slice(items): > ... left = items[::2] > ... items[::2] = items[1::2] > ... items[1::2] = left > ... return items > ... alist > [0, 1, 2, 3, 4] swap_slice(alist) > Traceback (most recent call last): > File "", line 1, in ? > File "", line 3, in swap_slice > ValueError: attempt to assign sequence of size 2 to extended slice of size > 3 > > Everybody always forgets corner cases... like lists with odd number of > items... *wink* True in general, but on that one I'm with Duncan. Here is another implementation that cuts maximum memory down from 100 to 50%. from itertools import islice def swap(items): items[::2], items[1::2] = islice(items, 1, None, 2), items[::2] return items Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Slicing versus loops, was Re: for i in range() anti-pattern
Peter Otten wrote: > Here is another implementation that cuts maximum memory down from 100 to > 50%. > > from itertools import islice > def swap(items): > items[::2], items[1::2] = islice(items, 1, None, 2), items[::2] > return items Unfortunately, the following >>> a = [1, 2, 3] >>> a[::2] = iter([10, 20, 30]) Traceback (most recent call last): File "", line 1, in ? ValueError: attempt to assign sequence of size 3 to extended slice of size 2 >>> a [1, 2, 3] does not support my bold claim :-( Since the list is not changed there must be an intermediate copy. Peter -- http://mail.python.org/mailman/listinfo/python-list
Distutils questions.
Hi!
I am writing a package installation using distutils it is very nice but
I have it two snags:
setup(...
data_files=[("foo",["*.data""])],\
...)
setup.py install --prefix=/usr/bar/baz
a) Shouldn't the *.data syntax work?
b) Why does it install the data files on /usr/bar/baz/foo and not in
/usr/bar/baz/share/foo like the documentation seems to imply?
Everything else seems to work as advertised scripts go to /bin
packages to /lib/python2.4/site-packages...
Is it me or is it a bug?
Best regards
José Rui
--
http://mail.python.org/mailman/listinfo/python-list
Re: Functions, callable objects, and bound/unbound methods
Duncan Booth wrote: > Ron Garret <[EMAIL PROTECTED]> wrote: > > > I want to say: > > > > trace(c1.m1) > > > > and have c1.m1 be replaced with a wrapper that prints debugging info > > before actually calling the old value of m1. The reason I want that > > to be an instance of a callable class instead of a function is that I > > need a place to store the old value of the method so I can restore it, > > and I don't want to start building a global data structure because > > that gets horribly ugly, and a callable class is the Right Thing -- if > > there's a way to actually make it work. > > > > Is there? I tried the obvious things (like making callable inherit > > from function, and adding im_func and im_self attribuetes) but they > > didn't work. > > Read "Functions and Methods" in > http://users.rcn.com/python/download/Descriptor.htm > > You need to implement a __get__ method on your class. See also http://groups.google.com/group/comp.lang.python/browse_frm/thread/d691240a5cfebcdf/93503c5b9c66226e?lnk=gst&q=simionato+subclassing+FunctionType&rnum=1&hl=en#93503c5b9c66226e for an example and some discussion. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
RE: How to read the directory which the actively running python file islocated in?
Nevermind, I got it using the sys.argv[0] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Malinowski Sent: Friday, December 01, 2006 9:07 AM To: [email protected] Subject: How to read the directory which the actively running python file islocated in? Is there a way to read the directory that the currently running python file is located in? Cheers Mike. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Win32 Excel Generation Slow
I am trying to create an excel document that displays a table of data.
It does exactly what I want but takes a long time. I am writing around
1000 rows and it takes around a second to do each row.
Is there a quicker way to write this? The reason I want excel is this
needs to read and manipulated by management.
The function I am using is:
def createExcel(data):
xlApp = Dispatch("Excel.Application")
wb = xlApp.Workbooks.Add()
xlApp.Visible = 1
ws = wb.Worksheets[0];
headers = ["Sales Rank", "UPC", "Description", "Stock", "Manifest
Stock", "Total Stock", "Week Sales", "Price", "Total Price", "Days Cover"]
column = 1
for each in headers:
xlApp.ActiveSheet.Cells(1, column).Value = each
column = column + 1
row = 1
for eachline in data:
xlApp.ActiveSheet.Cells(row, 1).Value = row
xlApp.ActiveSheet.Cells(row, 2).Value = eachline[0]
xlApp.ActiveSheet.Cells(row, 3).Value = eachline[1]
xlApp.ActiveSheet.Cells(row, 4).Value = eachline[2]
xlApp.ActiveSheet.Cells(row, 5).Value = eachline[3]
xlApp.ActiveSheet.Cells(row, 6).Value = eachline[4]
xlApp.ActiveSheet.Cells(row, 7).Value = eachline[5]
xlApp.ActiveSheet.Cells(row, 8).Value = eachline[6]
xlApp.ActiveSheet.Cells(row, 9).Value = eachline[7]
xlApp.ActiveSheet.Cells(row, 10).Value = eachline[8]
row = row + 1
--
http://mail.python.org/mailman/listinfo/python-list
python 2.5 install from source problem
Hi, I just tried to install python 2.5 from source on my ScienticLinux (Redhat Clone) machine. It seems to work without any problem, at least I am able to run some of my old scripts. I installed it with './configure --prefix=/opt/python make make altinstall', but now for a 'vtk' installation which needs the python libraries I am not able to find a file like 'libpython2.5.so.*', which I think should be produced (at least at my office's machine (redhat) it is there). I just can find a 'libpython2.5.a' file ... Do I do something wrong? Greetings! Fabian -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java & eclipse
just used the py dev plugin for eclipse.
it is great.
auto indentation and intellisence.
and all other things.
so now how does it look from this end?
python + productivity and eclipse + productivity = double productivity!
only problem with the plugin is that I find it difficult to manage the
script running.
I open a command prompt and run the scripts manually.
any suggestion for this.
for example I had name = raw_input("please enter your name") and the
moment I type the first letter on the keyboard the code execution
moves over to the next statement. should it not wait for the return
key as it always does?
Krishnakant.
--
http://mail.python.org/mailman/listinfo/python-list
Re: python vs java & eclipse
krishnakant Mane wrote:
> just used the py dev plugin for eclipse.
> it is great.
> auto indentation and intellisence.
> and all other things.
> so now how does it look from this end?
> python + productivity and eclipse + productivity = double productivity!
> only problem with the plugin is that I find it difficult to manage the
> script running.
> I open a command prompt and run the scripts manually.
> any suggestion for this.
> for example I had name = raw_input("please enter your name") and the
> moment I type the first letter on the keyboard the code execution
> moves over to the next statement. should it not wait for the return
> key as it always does?
> Krishnakant.
I don't know about raw_input ... my programs all go through some GUI ...
but I run / debug(although almost never) all of my applications from
pydev - no need to change project as with Visual Studio, I just
run/debug whatever I need with a few clicks ... have not touched Konsole
in weeks.
I also, after weeks of testing, decided to invest in the pydev
extensions / the bugs it has found for me already justify the investment.
hg
--
http://mail.python.org/mailman/listinfo/python-list
Re: python vs java & eclipse
Thomas Ploch schrieb: > Amir Michail schrieb: >> Hi, >> >> It seems to me that measuring productivity in a programming language >> must take into account available tools and libraries. >> >> Eclipse for example provides such an amazing IDE for java that it is no >> longer obvious to me that one would be much more productive in python >> for medium sized projects. >> >> Sure, all that Java static typing can be painful, but Eclipse takes >> some of that pain away. Moreover, static typing can result in better >> on-the-fly error detection and refactoring support. >> >> Any thoughts on this? >> >> Amir >> > > Yes, thats true, but since eclipse is resource monster (it is still > using java), and some people (like me) don't have a super fresh and new > computer, and have to run other services to test their work locally > (like mysql and apache servers), it gets pretty harsh with eclipse. I > personally tried eclipse on my laptop (which I work most with), and I > had quite a system resource problem. So I switched back to vim and > console and it hasn't been too bad, since if you know how to use a > powerful editor, it can be as productive. > > But in the end, it is up to anyone to find the best solutiion for > themselves. > > Thomas > Yes, thats true, but since eclipse is resource monster (it is still using java), and some people (like me) don't have a super fresh and new computer, and have to run other services to test their work locally (like mysql and apache servers), it gets pretty harsh with eclipse. I personally tried eclipse on my laptop (which I work most with), and I had quite a system resource problem. So I switched back to vim and console and it hasn't been too bad, since if you know how to use a powerful editor, it can be as productive. But in the end, it is up to anyone to find the best solutiion for themselves. Thomas -- http://mail.python.org/mailman/listinfo/python-list
RE: How to read the directory which the actively running python file islocated in?
Michael Malinowski wrote: > Nevermind, I got it using the sys.argv[0] That doesn't always work, as on unix the path isn't prepended onto sys.argv[0] necessarily. import os.path ... os.path.dirname(os.path.abspath(__file__)) may be better. -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java & eclipse
Thomas Ploch wrote: > Thomas Ploch schrieb: >> Amir Michail schrieb: >>> Hi, >>> >>> It seems to me that measuring productivity in a programming language >>> must take into account available tools and libraries. >>> >>> Eclipse for example provides such an amazing IDE for java that it is no >>> longer obvious to me that one would be much more productive in python >>> for medium sized projects. >>> >>> Sure, all that Java static typing can be painful, but Eclipse takes >>> some of that pain away. Moreover, static typing can result in better >>> on-the-fly error detection and refactoring support. >>> >>> Any thoughts on this? >>> >>> Amir >>> >> Yes, thats true, but since eclipse is resource monster (it is still >> using java), and some people (like me) don't have a super fresh and new >> computer, and have to run other services to test their work locally >> (like mysql and apache servers), it gets pretty harsh with eclipse. I >> personally tried eclipse on my laptop (which I work most with), and I >> had quite a system resource problem. So I switched back to vim and >> console and it hasn't been too bad, since if you know how to use a >> powerful editor, it can be as productive. >> >> But in the end, it is up to anyone to find the best solutiion for >> themselves. >> >> Thomas >> > > Yes, thats true, but since eclipse is resource monster (it is still > using java), and some people (like me) don't have a super fresh and new > computer, and have to run other services to test their work locally > (like mysql and apache servers), it gets pretty harsh with eclipse. I > personally tried eclipse on my laptop (which I work most with), and I > had quite a system resource problem. So I switched back to vim and > console and it hasn't been too bad, since if you know how to use a > powerful editor, it can be as productive. > > But in the end, it is up to anyone to find the best solutiion for > themselves. > > Thomas > If you compare eclipse to VS, it is not that memory hungry - but i agree with you that a min-config is needed. Yet (I believe that) a complete IDE can bring functions that an editor, however powerful, cannot (I still use emacs). I have tried Komodo, Wing, Eric3, Idle, emacs, (not vi ;-) ), SPE, boa-constructor, and many more - I like most of them but am really addicted to eclipse + pydev. ... but even without pydev, I would not use java just because of eclipse. hg -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java & eclipse
krishnakant Mane wrote:
> just used the py dev plugin for eclipse.
> it is great.
But isn't support for java better because the eclipse ide can take
advantage of explicit type declarations (e.g., for intellisense,
refactoring, etc.)?
Amir
> auto indentation and intellisence.
> and all other things.
> so now how does it look from this end?
> python + productivity and eclipse + productivity = double productivity!
> only problem with the plugin is that I find it difficult to manage the
> script running.
> I open a command prompt and run the scripts manually.
> any suggestion for this.
> for example I had name = raw_input("please enter your name") and the
> moment I type the first letter on the keyboard the code execution
> moves over to the next statement. should it not wait for the return
> key as it always does?
> Krishnakant.
--
http://mail.python.org/mailman/listinfo/python-list
python voip modules
Hello, If somebody know any python module that uses voip or sip except shtoom and yate Please tell me full url of that module or send to [EMAIL PROTECTED] Thanks,I will really appreciate that -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Question About Compiling.
Fredrik Lundh wrote: > yndesai wrote: > > > Is it that no compiling facility is hindering the growth of python > > in commercial circuit . . . ? I can see the point of people who are confused about single file executables for Python programs, who are possibly new to the technology and don't know where to look [1] or which questions to ask, and I can also see the need in various situations for people to make such executables. That said, I don't buy into the kind of hypothetical "ISVs need this and that" pontification seen on places like Planet GNOME, written by people who work at companies like Novell. The "commercial circuit" will use a technology (and, in fact, have been using Python for some time) when they recognise the genuine benefits of the technology, and if the technology doesn't deliver exactly what they had in mind, they'll either put in some effort to shape it to their liking or they'll look elsewhere. If none of this activity has any community benefit, I'd argue that there's only so much the community should be prepared to do to "fix" such commercial objections - if what a business wants is valuable enough, that business should be prepared to pay for it. > (why are you blaming you inability to use Linux installation tools on > Python, btw? most basic Python libraries are only an apt-get away if > you're using a sane Linux distribution.) This is true enough, and by packaging one's programs correctly, Python gets automatically brought into the picture when the user asks to install those programs. It's interesting to consider this in the context of the recent Linux Standard Base discussions on python-dev: LSB potentially mitigates issues with shipping executables across different distributions and would be beneficial to those wanting to deploy Python applications in such a way. I notice, however, that the discussion has taken the peanut gallery position of name-calling and mock outrage at the packaging practices of various distributions [2], presumably whilst advocating Python-only solutions like setuptools - something which really isn't going to work well with any large heterogeneous collection of software packages. Moreover, the distributions have to more urgently deal with various issues not yet sufficiently addressed by the Python core developers, particularly architecture issues [3] and licensing issues [4]. Freezing applications has been a fairly well-understood process for the last ten years, but more cooperation with heterogeneous packaging technologies would be far preferable. After all, distributions are actually responsible for a large amount of Python usage, and it would be far better if people actually tried to work with them to resolve some of the supposedly inflammatory aspects of their packaging practices rather than just shouting bad things at them from a distance [5]. A bit of "not invented here" [6] suppression would also be quite welcome, along with taking the needs of vendors [7] other than Apple Computer Inc. into account. Paul P.S. And while a frank discussion [7] did appear to result in a comprehensive exchange of views between Debian and setuptools developers, I'd like to see a bit more understanding for end-users and people who don't want to ignore their system's package management. Python "plays well with others" is a frequent claim, after all. [1] http://wiki.python.org/moin/DistributionUtilities [2] http://mail.python.org/pipermail/python-dev/2006-November/070032.html [3] http://mail.python.org/pipermail/python-dev/2006-November/070043.html [4] http://mail.python.org/pipermail/python-dev/2006-November/070054.html [5] http://mail.python.org/pipermail/python-dev/2006-November/070055.html [6] http://mail.python.org/pipermail/python-dev/2006-November/070101.html [7] http://mail.python.org/pipermail/distutils-sig/2005-November/005500.html -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read the directory which the actively running python file is located in?
in os module there is many funktion/methods to extract this information to ask the path to the current running pythonprogram you can do likes this - CUT--- import os print os.getcwd() - CUT -- // Anders Michael Malinowski skrev: > Is there a way to read the directory that the currently running python file > is located in? > Cheers > Mike. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read the directory which the actively running python file is located in?
in os module there is many funktion/methods to extract this information to ask the path to the current running pythonprogram you can do likes this - CUT--- import os print os.getcwd() - CUT -- // Anders Michael Malinowski skrev: > Is there a way to read the directory that the currently running python file > is located in? > Cheers > Mike. -- http://mail.python.org/mailman/listinfo/python-list
recover/extract content from html with help of cheetah templates
Hello, currently i am developing a very small cms using python and cheetah. very early i have noticed that i was lacking the method to extract/recover the contents (html,text) from the html that is generated by cheetah and delivered to the site viewer. to explain it further: during the output processing by cheetah placeholders are replaced with my text/html input. to edit/alter the page i have to extract my personal input out of the delivered html again, like a diff of output html and the template. is there a method integrated in cheetah which i have not noticed so far to do this? or have i to write a own "diff" method? thanks in advance, manuel -- http://mail.python.org/mailman/listinfo/python-list
PythonWin And Excel Problem
Hi All,
I am having some problems in running a very simple python script,
which prints some numbers in an Excel spreadsheet. The numbers are
stored in a list. I know that the numbers are different (random
generated), but when I open the Excel file I get a column of data with
all the numbers equal to the first item in the python list.
I attach a very simple script that reproduces the problem.
I am using Python 2.5, PythonWin build 210, Windows XP. Am I missing
something? Thank you for every hint.
import os
import random
from win32com.client import Dispatch
therand = []
for ii in xrange(10):
therand.append(random.random())
xlsapp = Dispatch("Excel.Application")
wb = xlsapp.Workbooks.Add()
xlsapp.Worksheets.Item(2).Delete()
xlsapp.Worksheets.Item(1).Delete()
sheet = wb.Sheets[0]
sheet.Name = "Data"
sheet.Range("A1:A10").Value = therand
excelfile = "C:/HelloWin32.xls"
wb.SaveAs(excelfile)
wb.Close()
xlsapp.Quit()
os.startfile(excelfile)
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/
--
http://mail.python.org/mailman/listinfo/python-list
route planning
Hi all Just a very simple question: where can I find a module for route planning? I have looked around and found some implementations of graph theory, e.g. http://sourceforge.net/projects/pynetwork/. But, what I need is not an abstract graph, but one where nodes/vertices have locations (2D), are connected (to follow a path, respecting distance among nodes) and where I can easily find the closest edge and vertex from any point in space. your links are much appreciated thanks André -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin And Excel Problem
First of all you should call the random.seed()
function. That was at least what I´ve always done.
seed([x])
Initialize the basic random number generator.
Second of all, calling random.random() will give you
this:
random()
Return the next random floating point number in
the range [0.0, 1.0).
In your loop try to call random.randit() and call the
random.seed() beforehand.
HTH,
Michael
--- Andrea Gavana <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I am having some problems in running a very
> simple python script,
> which prints some numbers in an Excel spreadsheet.
> The numbers are
> stored in a list. I know that the numbers are
> different (random
> generated), but when I open the Excel file I get a
> column of data with
> all the numbers equal to the first item in the
> python list.
> I attach a very simple script that reproduces the
> problem.
>
> I am using Python 2.5, PythonWin build 210, Windows
> XP. Am I missing
> something? Thank you for every hint.
>
> import os
> import random
>
> from win32com.client import Dispatch
>
> therand = []
> for ii in xrange(10):
> therand.append(random.random())
>
> xlsapp = Dispatch("Excel.Application")
> wb = xlsapp.Workbooks.Add()
>
> xlsapp.Worksheets.Item(2).Delete()
> xlsapp.Worksheets.Item(1).Delete()
> sheet = wb.Sheets[0]
> sheet.Name = "Data"
> sheet.Range("A1:A10").Value = therand
>
> excelfile = "C:/HelloWin32.xls"
>
> wb.SaveAs(excelfile)
> wb.Close()
> xlsapp.Quit()
>
> os.startfile(excelfile)
>
>
> Andrea.
>
> "Imagination Is The Only Weapon In The War Against
> Reality."
> http://xoomer.virgilio.it/infinity77/
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
PythonWin And Excel Problem
Hi Michael, > First of all you should call the random.seed() > function. That was at least what I´ve always done. > seed([x]) Thanks for your suggestion, but it doesn't matter whether you call seed() or not. The random number generator can *not* return 10 equal values if called 10 times, irrespective of the fact that it is initalized or not. You can try by simply doing: import random print random.random() print random.random() print random.random() And you'll see that the numbers are different. Moreover, I can populate that list by hand with 10 values like: therand = [ii for ii in xrange(1, 11)] And the result in Excel will be the same. All the cells will have the value 1. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.virgilio.it/infinity77/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Win32 Excel Generation Slow
"Daniel Bowett" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
>I am trying to create an excel document that displays a table of data. It does
>exactly what I want but takes a long time. I am
>writing around 1000 rows and it takes around a second to do each row.
>
> Is there a quicker way to write this? The reason I want excel is this needs
> to read and manipulated by management.
>
> The function I am using is:
>
> def createExcel(data):
> xlApp = Dispatch("Excel.Application")
> wb = xlApp.Workbooks.Add()
> xlApp.Visible = 1
> ws = wb.Worksheets[0];
>
> headers = ["Sales Rank", "UPC", "Description", "Stock", "Manifest Stock",
> "Total Stock", "Week Sales", "Price", "Total Price",
> "Days Cover"]
>
> column = 1
> for each in headers:
> xlApp.ActiveSheet.Cells(1, column).Value = each
> column = column + 1
>
> row = 1
> for eachline in data:
> xlApp.ActiveSheet.Cells(row, 1).Value = row
> xlApp.ActiveSheet.Cells(row, 2).Value = eachline[0]
> xlApp.ActiveSheet.Cells(row, 3).Value = eachline[1]
> xlApp.ActiveSheet.Cells(row, 4).Value = eachline[2]
> xlApp.ActiveSheet.Cells(row, 5).Value = eachline[3]
> xlApp.ActiveSheet.Cells(row, 6).Value = eachline[4]
> xlApp.ActiveSheet.Cells(row, 7).Value = eachline[5]
> xlApp.ActiveSheet.Cells(row, 8).Value = eachline[6]
> xlApp.ActiveSheet.Cells(row, 9).Value = eachline[7]
> xlApp.ActiveSheet.Cells(row, 10).Value = eachline[8] row = row + 1
>
If you preformat the data including the row number, you can
insert it en masse using a Range object. This runs in just a
couple of seconds:
from win32com.client import Dispatch
data=[(x,'data1','data2','data3','data4','data5','data6','data7','data8','data9')
for x in xrange(1000)]
def createExcel(data):
xlApp = Dispatch("Excel.Application")
wb = xlApp.Workbooks.Add()
xlApp.Visible = 1
ws = wb.Worksheets[0];
headers = ["Sales Rank", "UPC", "Description", "Stock", "Manifest Stock",
"Total Stock", "Week Sales", "Price", "Total
Price", "Days Cover"]
column = 1
for each in headers:
xlApp.ActiveSheet.Cells(1, column).Value = each
column = column + 1
xlApp.ActiveSheet.Range("A2:J1001").Value=data
createExcel(data)
Roger
== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin And Excel Problem
"Andrea Gavana" <[EMAIL PROTECTED]> wrote:
> Hi All,
>
>I am having some problems in running a very simple python script,
> which prints some numbers in an Excel spreadsheet. The numbers are
> stored in a list. I know that the numbers are different (random
> generated), but when I open the Excel file I get a column of data with
> all the numbers equal to the first item in the python list.
> I attach a very simple script that reproduces the problem.
>
> I am using Python 2.5, PythonWin build 210, Windows XP. Am I missing
> something? Thank you for every hint.
>
> import os
> import random
>
> from win32com.client import Dispatch
>
> therand = []
> for ii in xrange(10):
>therand.append(random.random())
>
> xlsapp = Dispatch("Excel.Application")
> wb = xlsapp.Workbooks.Add()
>
> xlsapp.Worksheets.Item(2).Delete()
> xlsapp.Worksheets.Item(1).Delete()
> sheet = wb.Sheets[0]
> sheet.Name = "Data"
> sheet.Range("A1:A10").Value = therand
>
> excelfile = "C:/HelloWin32.xls"
>
> wb.SaveAs(excelfile)
> wb.Close()
> xlsapp.Quit()
>
> os.startfile(excelfile)
>
Each row you insert into the Range need to be a
sequence:
therand.append((random.random(),))
Roger
== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
--
http://mail.python.org/mailman/listinfo/python-list
I/O Multiplexing and non blocking socket
Hi guys, I'm looking for a tutorial to make a client with a i/o multiplexing and non blocking socket. Anybody knows where is a tutorial? Tnx -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a reason not to do this?
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > Ron Garret <[EMAIL PROTECTED]> wrote: > > I don't want to get into a philosophical debate. > > Actually, I changed my mind. Consider: > > def g(): print 'G' > > def h(): print 'H' > > def f(): g() > > class C1: > def m1(self): f() > > class C2: > def m1(self): g() > > c1 = C1() > c2 = C2() > > def f(): h() > > class C2: > def m1(self): h() > > c1.m1() # Prints H > c2.m1() # Prints G > > On what principled basis can you justify two different outputs in this > case? Why should I be able to change the definition of f and not have > to go back and recompile all references to it, but not m1? I see what you were asking now: you want to know why a class statement doesn't modify a previously existing class (as is the case in Ruby) rather than to create a new one. The principle behind this is pretty much "it was just a language design decision". The designers of Python felt it was generally best to have whole classes in one place, rather than spread out over many locations. I tend to agree with this. Changing classes in-place violates the "principle of least surprise"--keep in mind the "surprise" we're talking about is the reader's surprise, not the writer's. A person might be reading a class definition wondering, "WTF is happening, why doesn't it match the behavior?", not knowing that the class was modified in-place somewhere else. (That person could be you three months later.) Valid use cases like yours are exceptional, and can be done straightforwardly without changing class statement to modify in-place, so I think it was the right decision. Your opinion may differ. It doesn't seem to have wreaked havoc in Common Lisp and Ruby. But that's not how Python is. I have things I don't like about Python, too. You just deal with it. P.S. If you want to be truly evil, you could use a class hook to get the modifying in-place behavior: def modify_in_place(name,bases,clsdict): cls = globals()[name] for attr,val in clsdict.iteritems(): setattr(cls,attr,val) return cls # Replace second C2 class above with this class C2: __metaclass__ = modify_in_place def m1(self): h() Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: I/O Multiplexing and non blocking socket
On 1 Dec 2006 06:07:28 -0800, Salvatore Di Fazio <[EMAIL PROTECTED]> wrote: >Hi guys, >I'm looking for a tutorial to make a client with a i/o multiplexing and >non blocking socket. > >Anybody knows where is a tutorial? http://twistedmatrix.com/projects/core/documentation/howto/clients.html Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: I/O Multiplexing and non blocking socket
Salvatore Di Fazio wrote: > I'm looking for a tutorial to make a client with a i/o > multiplexing and non blocking socket. > > Anybody knows where is a tutorial? Perhaps a bit of an overkill, but try this: http://twistedmatrix.com/projects/core/documentation/howto/clients.html Regards, Björn -- BOFH excuse #30: positron router malfunction -- http://mail.python.org/mailman/listinfo/python-list
Re: Win32 Excel Generation Slow
"Daniel Bowett" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I am trying to create an excel document that displays a table of data. It >does exactly what I want but takes a long time. I am writing around 1000 >rows and it takes around a second to do each row. > > Is there a quicker way to write this? The reason I want excel is this > needs to read and manipulated by management. > Are there many many formulas in your worksheet? Try setting calculate to manual, and turn off screenupdating while creating your rows. Then when done, do a manual calculate, and turn auto calc and screenupdating back on. (These are all open to the COM interface, although I don't recall the exact function names.) -- Paul -- http://mail.python.org/mailman/listinfo/python-list
client/server design and advice
I recently completed the general guidelines for a future project that I would like to start developing...but I've sort of hit a wall with respect to how to design it. In short, I want to run through approximately 5gigs of financial data, all of which is stored in a large number of text files. Now as far as formatting and data integrity...I would go through and ensure that each file had the required setup so thats not really the issue. The problem I am having is with respect to speed. The languages I knew the best when coming into this project includes c++ and php. However, I then thought about how long it would take one PC to iterate through everything and figured it would probably take a significant amount of time. As such, I started looking into various languages and python caught my interest the most due to its power and what seems to be ease of use. I was going to initially just use python as a means of creating various indicators (i.e. calculations that would be performed on the data in the file)...however I am leaning towards moving to python entirely mostly due to its gui support. First off, i was wondering if this is a reasonable setup: The entire process would involve a server which manages which pc is processing which set of data (which may be a given text file or the like), and a client application which i would run on a few pc's locally when they aren't in use. I would have a database (sqlite) holding all calculated data of significance. Each client will basically login/connect with the server, request a time interval (i.e. does anything need processed? if so what data should i look at), and then it would update its status with the server which would place a lock on that data set. One thing i was wondering is if it would be worth it to use c++ for the actual iteration through the text file or should i simply use python? While i'm sure that c++ would be faster i am not entirely sure its worth the headache if its not going to save me significant processing time. Another thing is...if i was going to work with python instead of c++, would it be worth it to import all of the data into an sqlite database before hand (for speed issues)? Lastly, as far as the networking goes, i have seen posts and such about something called Pyro (http://pyro.sourceforge.net) and wondered if that was worth looking into for the client/server interaction. I apologize if any of these questions are more lower level, this is simply the first client/server application ive created and am doing so in a language ive never used before ;) Thanks for the help -Tony -- http://mail.python.org/mailman/listinfo/python-list
Re: I/O Multiplexing and non blocking socket
Jean-Paul Calderone ha scritto: > On 1 Dec 2006 06:07:28 -0800, Salvatore Di Fazio <[EMAIL PROTECTED]> wrote: > >Hi guys, > >I'm looking for a tutorial to make a client with a i/o multiplexing and > >non blocking socket. > > > >Anybody knows where is a tutorial? > > http://twistedmatrix.com/projects/core/documentation/howto/clients.html > > Jean-Paul Thank you guys, but I would like to use the standard libraries -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin And Excel Problem
Andrea,
Also, could it be that when you do the following:
sheet.Range("A1:A10").Value = therand
you actually initialize all 10 cells to the first
element of the array? Try to iterate and initialize
every cell separately.
Michael
--- Andrea Gavana <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I am having some problems in running a very
> simple python script,
> which prints some numbers in an Excel spreadsheet.
> The numbers are
> stored in a list. I know that the numbers are
> different (random
> generated), but when I open the Excel file I get a
> column of data with
> all the numbers equal to the first item in the
> python list.
> I attach a very simple script that reproduces the
> problem.
>
> I am using Python 2.5, PythonWin build 210, Windows
> XP. Am I missing
> something? Thank you for every hint.
>
> import os
> import random
>
> from win32com.client import Dispatch
>
> therand = []
> for ii in xrange(10):
> therand.append(random.random())
>
> xlsapp = Dispatch("Excel.Application")
> wb = xlsapp.Workbooks.Add()
>
> xlsapp.Worksheets.Item(2).Delete()
> xlsapp.Worksheets.Item(1).Delete()
> sheet = wb.Sheets[0]
> sheet.Name = "Data"
> sheet.Range("A1:A10").Value = therand
>
> excelfile = "C:/HelloWin32.xls"
>
> wb.SaveAs(excelfile)
> wb.Close()
> xlsapp.Quit()
>
> os.startfile(excelfile)
>
>
> Andrea.
>
> "Imagination Is The Only Weapon In The War Against
> Reality."
> http://xoomer.virgilio.it/infinity77/
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
Re: client/server design and advice
> First off, i was wondering if this is a reasonable setup: The entire > process would involve a server which manages which pc is processing > which set of data (which may be a given text file or the like), and a > client application which i would run on a few pc's locally when they > aren't in use. I would have a database (sqlite) holding all calculated > data of significance. Each client will basically login/connect with > the server, request a time interval (i.e. does anything need processed? > if so what data should i look at), and then it would update its status > with the server which would place a lock on that data set. Don't use sqlite, use a "real" RDBMS. sqlite is cool, but not really suited for large amounts of data, and the concurrent access aspects that are dealt with with an RDBMS for free are not to be underestimated. > One thing i was wondering is if it would be worth it to use c++ for the > actual iteration through the text file or should i simply use python? > While i'm sure that c++ would be faster i am not entirely sure its > worth the headache if its not going to save me significant processing > time. Another thing is...if i was going to work with python instead of > c++, would it be worth it to import all of the data into an sqlite > database before hand (for speed issues)? I'd be putting them in the DB, yes. > Lastly, as far as the networking goes, i have seen posts and such about > something called Pyro (http://pyro.sourceforge.net) and wondered if > that was worth looking into for the client/server interaction. Pyro rocks for that. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: More elegant to get a name: o.__class__.__name__
Carl Banks wrote: > alf wrote: > > Hi, > > is there a more elegant way to get o.__class__.__name__. For instance I > > would imagine name(o). > > def name_of_type(o): > return o.__class__.__name__ > > name_of_type(o) > > > Carl Banks > > P.S. name(o) suggests it's the name of the object, not the type > P.P.S. you could use type(o).__name__ but it doesn't work for old-style > classes You mean it doesn't work for old-style instances; OTOH __class__ doesn't work for old style classes: >>> class X: pass ... >>> X.__class__ AttributeError: class X has no attribute '__class__' So to handle all cases, you'd have to go with: def typename(o): try: cls = o.__class__ except AttributeError: cls = type(o) return cls.__name__ # or for fully qualified names # return '%s.%s' % (cls.__module__, cls.__name__) George -- http://mail.python.org/mailman/listinfo/python-list
Is python memory shared between theads?
So I declare a variable named A in thread1, in script1.py. I assign the value of 2.5 to A. I then run script2.py in thread2. Script2.py assigns the value of 5.5 to a variable named A. Now, when thread1 resums execution, I see that A = 5.5, rather than 2.5 as I expected. Is this normal behavior? Based on the little documentation I have been able to find on this topic, it is normal behavior. The only way to use same-named variables in scripts is to have them run in a different process, rather than different threads. -- http://mail.python.org/mailman/listinfo/python-list
good documentation about win32api ??
Hi all. Recently I've to developed a project in python that made operation under win32 platform and I found a lot of problema to find good information. The only one documentation is in ActivePython page (http://aspn.activestate.com/ASPN/docs/ASPNTOC-APYTH2.4.0) but it is not very good and finally I had to turn to the newsgroups (it was very nice). And the question is: ¿Anybody knows where can I find good documentation about win32api? Thanks in advanced. ScnS. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is python memory shared between theads?
On 2006-12-01, Wesley Henwood <[EMAIL PROTECTED]> wrote: > So I declare a variable named A in thread1, in script1.py. I assign > the value of 2.5 to A. I then run script2.py in thread2. Script2.py > assigns the value of 5.5 to a variable named A. Now, when thread1 > resums execution, I see that A = 5.5, rather than 2.5 as I expected. > > Is this normal behavior? Yes. Threads share global namespace. From a CPU point of view, they share a single address space. > Based on the little documentation I have been able to find on > this topic, it is normal behavior. The only way to use > same-named variables in scripts is to have them run in a > different process, rather than different threads. Or make them local variables. -- Grant Edwards grante Yow! If I felt any more at SOPHISTICATED I would DIE visi.comof EMBARRASSMENT! -- http://mail.python.org/mailman/listinfo/python-list
Re: client/server design and advice
On 1 Dec 2006 06:52:37 -0800, TonyM <[EMAIL PROTECTED]> wrote: >I recently completed the general guidelines for a future project that I >would like to start developing...but I've sort of hit a wall with >respect to how to design it. In short, I want to run through >approximately 5gigs of financial data, all of which is stored in a >large number of text files. Now as far as formatting and data >integrity...I would go through and ensure that each file had the >required setup so thats not really the issue. The problem I am having >is with respect to speed. > >The languages I knew the best when coming into this project includes >c++ and php. However, I then thought about how long it would take one >PC to iterate through everything and figured it would probably take a >significant amount of time. As such, I started looking into various >languages and python caught my interest the most due to its power and >what seems to be ease of use. I was going to initially just use python >as a means of creating various indicators (i.e. calculations that would >be performed on the data in the file)...however I am leaning towards >moving to python entirely mostly due to its gui support. > >First off, i was wondering if this is a reasonable setup: The entire >process would involve a server which manages which pc is processing >which set of data (which may be a given text file or the like), and a >client application which i would run on a few pc's locally when they >aren't in use. I would have a database (sqlite) holding all calculated >data of significance. Each client will basically login/connect with >the server, request a time interval (i.e. does anything need processed? >if so what data should i look at), and then it would update its status >with the server which would place a lock on that data set. > >One thing i was wondering is if it would be worth it to use c++ for the >actual iteration through the text file or should i simply use python? >While i'm sure that c++ would be faster i am not entirely sure its >worth the headache if its not going to save me significant processing >time. Another thing is...if i was going to work with python instead of >c++, would it be worth it to import all of the data into an sqlite >database before hand (for speed issues)? > >Lastly, as far as the networking goes, i have seen posts and such about >something called Pyro (http://pyro.sourceforge.net) and wondered if >that was worth looking into for the client/server interaction. > >I apologize if any of these questions are more lower level, this is >simply the first client/server application ive created and am doing so >in a language ive never used before ;) http://dsd.lbl.gov/gtg/projects/pyGridWare/ might be of some use. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: proof of concept python and tkinter gnugo interface
grindel wrote: > Anton Vredegoor wrote: [...] >> Here's the proof of concept, just copy it to some dir and run the >> Python script: >> >> http://home.hccnet.nl/a.vredegoor/gnugo/ >> >> It needs Python 2.5 which you can get at: >> >> http://www.python.org/ > If you talking about a simple gui for gnu go it's been done to death. > see any misc. pandanet client and numerous other softwares such as > durish or go knot. If your client is going to do something uniquely > different from programs like this then you should focus in this aspect > of the program and develop other features later. It's also important > that it be able to read and write sgf files It's uniquely different from numerous other softwares in that it is completely open source and runs from a standard Python installation (but of course one has to get a Gnugo executable from somewhere). I also implemented reading and writing SGF files and browsing through the move history now. Total command set at the moment: -click on a coordinate: generate a move there and go out of replay mode -space bar: computer makes a move and goes out of replay mode -up key: save an SGF file (only the moves) -down key: read an SGF file -left key: go into replay mode and undo a move -right key: show next move, if at end goes out of replay mode Remember we're still only talking about a proof of concept script! I just want to attract people, and put this script into an SVN somewhere. Anton -- http://mail.python.org/mailman/listinfo/python-list
Simple question on indexing
Hi, I would like to obtain the position index in a tuple when an IF statement is true. Something like >>>a=['aaa','bbb','ccc'] >>>[ ??? for name in a if name == 'bbb'] >>>1 but I'm not able to find the name of the function ??? in the python documentation, any help? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: good documentation about win32api ??
"__schronos__" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] And the question is: ¿Anybody knows where can I find good documentation about win32api? There is the book, Python Programming on WIN32, by Mark Hammond. http://www.amazon.com/Python-Programming-WIN32-Mark-Hammond/dp/1565926218/sr=8-1/qid=1164989859/ref=pd_bbs_sr_1/103-2563546-7494224?ie=UTF8&s=books -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Detecting recursion loops
Ben Finney wrote: > robert <[EMAIL PROTECTED]> writes: > >> Carl Banks wrote: >>> 2. Consider whether you're unwittingly trying to cover up a bug. >>> ISTM no matter how problematic the input is, you should at least >>> be able to make progress on it. Are you getting this error >>> because, say, you're not incrementing a counter somewhere, and >>> thus recalling a function with the same arguments again? >> the "bug" comes in from the I/O input. > > If a program doesn't gracefully deal with bad input, that's a bug in > the program. You should be designing your input handler so that it > will do something helpful (even if that's to stop immediately with an > informative error message) in the event of bad input, rather than > allowing that bad data to send your program into an endless loop. Yet that detection is what the asked alg should do. Example: When a HTML-(content)-relaying sends you around in a circle through a complex handler chain. Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: Detecting recursion loops
On 2006-12-01, robert <[EMAIL PROTECTED]> wrote: > Ben Finney wrote: >> robert <[EMAIL PROTECTED]> writes: >> >>> Carl Banks wrote: 2. Consider whether you're unwittingly trying to cover up a bug. ISTM no matter how problematic the input is, you should at least be able to make progress on it. Are you getting this error because, say, you're not incrementing a counter somewhere, and thus recalling a function with the same arguments again? >>> the "bug" comes in from the I/O input. >> >> If a program doesn't gracefully deal with bad input, that's a bug in >> the program. You should be designing your input handler so that it >> will do something helpful (even if that's to stop immediately with an >> informative error message) in the event of bad input, rather than >> allowing that bad data to send your program into an endless loop. > > > Yet that detection is what the asked alg should do. Example: > When a HTML-(content)-relaying sends you around in a circle > through a complex handler chain. Being in a cycle doesn't actually prove your program will never halt for that particular input, does it? -- Neil Cerutti Customers who consider our waitresses uncivil ought to see the manager --sign at New York restaurant -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple question on indexing
Tartifola wrote: > Hi, > I would like to obtain the position index in a tuple when an IF > statement is true. Something like > > >>>a=['aaa','bbb','ccc'] > >>>[ ??? for name in a if name == 'bbb'] > >>>1 > > but I'm not able to find the name of the function ??? in the python > documentation, any help? > Thanks Ummm, that's a list not a tuple: I'll assume you meant sequence. This will generate a list of indexes which match the criteria: >>> a = [ 1, 2, 3, 2, 5, 7] >>> [elno for elno,el in enumerate(a) if el == 2] [1, 3] hth Jon. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple question on indexing
On Friday 01 December 2006 17:21, Tartifola wrote:
> I would like to obtain the position index in a tuple when an IF
> statement is true. Something like
>
> >>>a=['aaa','bbb','ccc']
> >>>[ ??? for name in a if name == 'bbb']
> >>>1
What about:
[ x for x,y in enumerate(a) if y == 'bbb' ]
Or if there is only one element 'bbb':
a.index('bbb')
Kindly
Christoph
--
http://mail.python.org/mailman/listinfo/python-list
Re: Pimping the 'cgi' module
Harry George wrote: > When I came from Perl, I too missed perl-isms and specifically CGI.pm, so > wrote my own: > http://www.seanet.com/~hgg9140/comp/index.html > http://www.seanet.com/~hgg9140/comp/pyperlish/doc/manual.html > http://www.seanet.com/~hgg9140/comp/cgipm/doc/index.html > > Others on this newsgroup said I'd be better off just doing it in raw > python. After a while, I realized that was true. You do > triple-quoted templates with normal python idioms. Throw in > some persistence mechanisms to deal with maintaining state across > transactions, and you are in business. > > Since then I've looked at Zope, Plone, TurboGears, Django, and (for > standalone apps) Dabo. TurboGears is mostly a set of recommendations > on what 3rd party packages to use, with a wee bit of glueware. So far > nothing feels as simple as just doing it in python. Thats the fragmented journey, almost any web programmer has to go when coming to python. A clear standard, even a clear intro, for simple tasks, like doing state mng, db, error handling, etc. is not there on an easy path. For a level above cgi, what do you think about cherrypy ? http://docs.cherrypy.org/ Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: Detecting recursion loops
robert wrote: > Ben Finney wrote: > > robert <[EMAIL PROTECTED]> writes: > > > >> Carl Banks wrote: > >>> 2. Consider whether you're unwittingly trying to cover up a bug. > >>> ISTM no matter how problematic the input is, you should at least > >>> be able to make progress on it. Are you getting this error > >>> because, say, you're not incrementing a counter somewhere, and > >>> thus recalling a function with the same arguments again? > >> the "bug" comes in from the I/O input. > > > > If a program doesn't gracefully deal with bad input, that's a bug in > > the program. You should be designing your input handler so that it > > will do something helpful (even if that's to stop immediately with an > > informative error message) in the event of bad input, rather than > > allowing that bad data to send your program into an endless loop. > > > Yet that detection is what the asked alg should do. > Example: When a HTML-(content)-relaying sends > you around in a circle through a complex handler chain. You might find some engineering inspiration in CherryPy's InternalRedirect handler [1], which simply raises an error if you visit the same state twice. Another option is to periodically check a timeout, which CherryPy does via an Engine.monitor thread [2] (that runs Response.check_timeout [3]). Note that either approach requires some alteration to the code being inspected. Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] [1] http://www.cherrypy.org/browser/tags/cherrypy-3.0.0RC1/cherrypy/_cpwsgi.py [2] http://www.cherrypy.org/browser/tags/cherrypy-3.0.0RC1/cherrypy/_cpengine.py#L240 [3] http://www.cherrypy.org/browser/tags/cherrypy-3.0.0RC1/cherrypy/_cprequest.py#L565 -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java & eclipse
Amir Michail escreveu: > krishnakant Mane wrote: > > just used the py dev plugin for eclipse. > > it is great. > > But isn't support for java better because the eclipse ide can take > advantage of explicit type declarations (e.g., for intellisense, > refactoring, etc.)? > > Amir The support for Java is light-years ahead. Sometimes I feel that Eclipse is coding for me (quickfix, for instance). There's the fact that Eclipse is developed in Java, so they are eating their own dogfood. That said, the code completion for Python is still in its early stages. There is a lot of room for improvement, even for a dynamic language. Stephen -- http://mail.python.org/mailman/listinfo/python-list
Re: client/server design and advice
You may also want to take a look at Erlang http://www.erlang.org/ for some ideas of how to do distributed programming. -- http://mail.python.org/mailman/listinfo/python-list
Re: Detecting recursion loops
Neil Cerutti wrote: > On 2006-12-01, robert <[EMAIL PROTECTED]> wrote: >> Ben Finney wrote: >>> robert <[EMAIL PROTECTED]> writes: >>> Carl Banks wrote: > 2. Consider whether you're unwittingly trying to cover up a bug. > ISTM no matter how problematic the input is, you should at least > be able to make progress on it. Are you getting this error > because, say, you're not incrementing a counter somewhere, and > thus recalling a function with the same arguments again? the "bug" comes in from the I/O input. >>> If a program doesn't gracefully deal with bad input, that's a bug in >>> the program. You should be designing your input handler so that it >>> will do something helpful (even if that's to stop immediately with an >>> informative error message) in the event of bad input, rather than >>> allowing that bad data to send your program into an endless loop. >> >> Yet that detection is what the asked alg should do. Example: >> When a HTML-(content)-relaying sends you around in a circle >> through a complex handler chain. > > Being in a cycle doesn't actually prove your program will never > halt for that particular input, does it? not. but its not about a theoretical prove. in practice with same state it goes through the same function here.. I had simply had situations where a server looped my client on to a Python (long through a couple of func-calls) recursion error . thus, either I fiddle a recursion/counter parameter through my calls, or I do complex state detection as e.g. to copy that of cherrypy was recommend in other post. Or: I simply throw a hammer at an n-th recursion, wereby I programm the counter locally as simple counter in a "global" thread-local-storage as I wrote.(also possible to use the same counter/limit in multiple functions!) There were just 2 lines of code to add. Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: Is python memory shared between theads?
Wesley Henwood wrote: > So I declare a variable named A in thread1, in script1.py. I assign > the value of 2.5 to A. I then run script2.py in thread2. Script2.py > assigns the value of 5.5 to a variable named A. Now, when thread1 > resums execution, I see that A = 5.5, rather than 2.5 as I expected. > > Is this normal behavior? Based on the little documentation I have been > able to find on this topic, it is normal behavior. The only way to use > same-named variables in scripts is to have them run in a different > process, rather than different threads. Yes and No. local variables are local to each threads. Global variables are global to the threads. -- http://mail.python.org/mailman/listinfo/python-list
Re: Functions, callable objects, and bound/unbound methods
Ron Garret wrote: > The reason I want to do this is that I want to implement a trace > facility that traces only specific class methods. I want to say: > > trace(c1.m1) > > and have c1.m1 be replaced with a wrapper that prints debugging info > before actually calling the old value of m1. The reason I want that to > be an instance of a callable class instead of a function is that I need > a place to store the old value of the method so I can restore it, and I > don't want to start building a global data structure because that gets > horribly ugly, and a callable class is the Right Thing -- if there's a > way to actually make it work. If the only reason for a callable class is to save a single value (the original function), you could instead store it as an attribute of the wrapper function. Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Functions, callable objects, and bound/unbound methods
Ron Garret wrote: > The reason I want to do this is that I want to implement a trace > facility that traces only specific class methods. I want to say: > > trace(c1.m1) > > and have c1.m1 be replaced with a wrapper that prints debugging info > before actually calling the old value of m1. The reason I want that to > be an instance of a callable class instead of a function is that I need > a place to store the old value of the method so I can restore it, and I > don't want to start building a global data structure because that gets > horribly ugly, and a callable class is the Right Thing -- if there's a > way to actually make it work. If the only reason for a callable class is to save a single value (the original function), you could instead store it as an attribute of the wrapper function. Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Is python memory shared between theads?
Wesley Henwood wrote: > So I declare a variable named A in thread1, in script1.py. I assign > the value of 2.5 to A. I then run script2.py in thread2. Script2.py > assigns the value of 5.5 to a variable named A. Now, when thread1 > resums execution, I see that A = 5.5, rather than 2.5 as I expected. > > Is this normal behavior? Not if this is all you are doing. A variable A in script1.py and a variable A in script2.py are completely different, even when running in the same thread. But if you're running script1.py and script2.py by calling execfile or exec and you pass the same dictionary as the globals argument to execfile, then the two scripts would share the global namespace. Variables of the same name would really be the same variable. Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Functions, callable objects, and bound/unbound methods
In article <[EMAIL PROTECTED]>, Kent Johnson <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > The reason I want to do this is that I want to implement a trace > > facility that traces only specific class methods. I want to say: > > > > trace(c1.m1) > > > > and have c1.m1 be replaced with a wrapper that prints debugging info > > before actually calling the old value of m1. The reason I want that to > > be an instance of a callable class instead of a function is that I need > > a place to store the old value of the method so I can restore it, and I > > don't want to start building a global data structure because that gets > > horribly ugly, and a callable class is the Right Thing -- if there's a > > way to actually make it work. > > If the only reason for a callable class is to save a single value (the > original function), you could instead store it as an attribute of the > wrapper function. I considered that, and I may yet fall back on it, but 1) I wanted to understand how these things worked and 2) I need a way to tell when a method has been traced, and isinstance(method, tracer) seems less hackish to me than hasattr(method, 'saved_function'). rg -- http://mail.python.org/mailman/listinfo/python-list
Re: client/server design and advice
> Don't use sqlite, use a "real" RDBMS. sqlite is cool, but not really suited > for large amounts of data, and the concurrent access aspects that are dealt > with with an RDBMS for free are not to be underestimated. Would PostgreSQL be suitable in this situation? I hadn't even thought about the possible problems that could arise with concurrency but i do recall it being an issue the last time i worked with sqlite. I have also looked into mysql given my extensive experience with it...however postgresql seems to be faster from what ive read. Either way i'll work on writing something to convert and insert the data so that it can process while im working on the gui and client/server apps. > Pyro rocks for that. Awesome, ill look into it in greater detail and will most likely use it. Given what ive seen so far it looks like it will make the client/server interface fairly easy to write. Now...if only i could master python gui programming and development ;) I'm not entirely sure which gui lib im going to end up using, but as of now im leaning more towards tkinter as i know it will work where i need and it seems to be one of the more documented. Ive looked at used wxpython a little but had trouble figure out a few minor things while playing around with it initially. I've also thought about pygtk although I haven't taken the time to play with it quite yet as i assumed it was primarily for linux (id be running the majority of these on windows pcs). Thanks for the suggestions :) Tony -- http://mail.python.org/mailman/listinfo/python-list
Re: Functions, callable objects, and bound/unbound methods
In article <[EMAIL PROTECTED]>, "Michele Simionato" <[EMAIL PROTECTED]> wrote: > Duncan Booth wrote: > > Ron Garret <[EMAIL PROTECTED]> wrote: > > > > > I want to say: > > > > > > trace(c1.m1) > > > > > > and have c1.m1 be replaced with a wrapper that prints debugging info > > > before actually calling the old value of m1. The reason I want that > > > to be an instance of a callable class instead of a function is that I > > > need a place to store the old value of the method so I can restore it, > > > and I don't want to start building a global data structure because > > > that gets horribly ugly, and a callable class is the Right Thing -- if > > > there's a way to actually make it work. > > > > > > Is there? I tried the obvious things (like making callable inherit > > > from function, and adding im_func and im_self attribuetes) but they > > > didn't work. > > > > Read "Functions and Methods" in > > http://users.rcn.com/python/download/Descriptor.htm > > > > You need to implement a __get__ method on your class. > > See also > > http://groups.google.com/group/comp.lang.python/browse_frm/thread/d691240a5cfe > bcdf/93503c5b9c66226e?lnk=gst&q=simionato+subclassing+FunctionType&rnum=1&hl=e > n#93503c5b9c66226e > > for an example and some discussion. > > Michele Simionato Thanks! rg -- http://mail.python.org/mailman/listinfo/python-list
[no subject]
Amir Michail schrieb: > krishnakant Mane wrote: >> just used the py dev plugin for eclipse. >> it is great. > > But isn't support for java better because the eclipse ide can take > advantage of explicit type declarations (e.g., for intellisense, > refactoring, etc.)? > > Amir Obviously, since eclipse _is_ a full blown Java application, so support for Java is excellent. It was actually developed for being a Java IDE but (as far as I know) people were liking it so much, so they decided to make it expandable (and PyDev is actually a good thing, it supports PyLint and PyChecker, manages the python path when new modules are added, but can be improved (as can everything :-) )). But as I said, often my system hangs when having quite a few files opened, so that brought me off using it too often. Thomas -- "Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht! -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a reason not to do this?
In article <[EMAIL PROTECTED]>, "Carl Banks" <[EMAIL PROTECTED]> wrote: > The principle behind this is pretty much "it was just a language design > decision". Yes, and I'm not taking issue with the decision, just pointing out that the desire to do things differently is not necessarily perverse. > P.S. If you want to be truly evil, you could use a class hook to get > the modifying in-place behavior: > > def modify_in_place(name,bases,clsdict): > cls = globals()[name] > for attr,val in clsdict.iteritems(): > setattr(cls,attr,val) > return cls > > # Replace second C2 class above with this > class C2: > __metaclass__ = modify_in_place > def m1(self): h() Doesn't work for me: >>> c2 <__main__.C2 instance at 0x51e850> >>> c2.m1() G >>> class C2: ... __metaclass__ = modify_in_place ... def m1(self): print 'Q' ... >>> c2.m1() G >>> C2().m1() Q rg -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a reason not to do this?
In article <[EMAIL PROTECTED]>, "Michele Simionato" <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > One of the things I find annoying about Python is that when you make a > > change to a method definition that change is not reflected in existing > > instances of a class (because you're really defining a new class when > > you reload a class definition, not actually redefining it). So I came > > up with this programming style: > > > > def defmethod(cls): > > return lambda (func): type.__setattr__(cls, func.func_name, func) > > Why not just ``return lambda func: setattr(cls, func.func_name, func)`` > ? Because I'm an idiot. (i.e. yes, that is obviously the right way to do it.) > The only thing I don't like is that all your > functions/methods will end up begin 'None'. > > I'd rather to be able to use > the help, so I would write > > def defmethod(cls): > def decorator(func): > setattr(cls, func.func_name, func) > return func > return decorator > > @defmethod(C) > def m1(self, x):pass > > help(m1) > > > BTW, for people with a Lisp background I recommend using IPython with > emacs and the > ipython.el mode. It is pretty good, even if not comparable to Slime. > > Michele Simionato Good tips. Thanks! rg -- http://mail.python.org/mailman/listinfo/python-list
Re: good documentation about win32api ??
__schronos__ wrote: > Hi all. > > Recently I've to developed a project in python that made operation > under win32 platform and I found a lot of problema to find good > information. The only one documentation is in ActivePython page > (http://aspn.activestate.com/ASPN/docs/ASPNTOC-APYTH2.4.0) but it is > not very good and finally I had to turn to the newsgroups (it was very > nice). > > And the question is: ¿Anybody knows where can I find good > documentation about win32api? > > Thanks in advanced. > > ScnS. http://msdn.microsoft.com covers the API itself, although you need to transliterate from the C code to python. -- http://mail.python.org/mailman/listinfo/python-list
Re: client/server design and advice
TonyM wrote: > Lastly, as far as the networking goes, i have seen posts and such about > something called Pyro (http://pyro.sourceforge.net) and wondered if > that was worth looking into for the client/server interaction. I'm currently busy with a new version of Pyro (3.6) and it already includes a new 'distributed computing' example, where there is a single dispatcher service and one or more 'worker' clients. The clients request work 'packets' from the dispatcher and process them in parallel. Maybe this is a good starting point of your system? Current code is available from Pyro's CVS repository. --Irmen -- http://mail.python.org/mailman/listinfo/python-list
Re: python vs java & eclipse
Stephen Eilert wrote: > > The support for Java is light-years ahead. Sometimes I feel that > Eclipse is coding for me (quickfix, for instance). Eclipse may be quite a technical achievement, but I found it irritating. Aside from the misuse of screen real-estate, I found that typing two characters and having what seemed like half my source file underlined in red, with multiple messages telling me that I had yet to define or import something or other when what I was about to do was to write the declaration, all conspired to make me want to scream, "WTF do you think I was going to type in about five seconds time? Work it out and autocomplete it if you're so damned clever!" So, Eclipse certainly has its share of detractors, too. ;-) [...] > That said, the code completion for Python is still in its early stages. > There is a lot of room for improvement, even for a dynamic language. Agreed. I don't believe in endless refactoring, and I think that's frequently a symptom of using an overly inflexible statically typed language (where it's more like "Refactoring" - the big R symbolising the seriousness and heavy lifting involved), but there are often times when I've wondered whether something could alert me to obvious breakage, especially after fairly big changes, acting possibly within the editing environment. I suppose pylint and similar tools have been working towards that goal, but I often wonder about producing something more subtle: something which is more clever than looking at modules and globals, and yet doesn't nag you continously about things which you'll discover almost immediately anyway. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: v2.3, 2.4, and 2.5's GUI is slow for me
g4rlik wrote: > I've been asking all over the place, namely different forums. I even > e-mailed [EMAIL PROTECTED] about my problem, but they couldn't assist me too > much. > > My problem is..the GUI for versions 2.3, 2.4, and 2.5 of Python run very > sluggishly. When I type in them or move them around my desktop, it's very > slow. I have figured out that this is because of the subprocesses running. I don't use IDLE too much anymore, just for quick tests, but I noticed this from the beginning as well. It's sluggish when you drag it around the screen. Not sure why. -- http://mail.python.org/mailman/listinfo/python-list
RE: client/server design and advice
hi irmen... happened to come across this post. haven't looked at pyro. regarding your 'work packets' could these essentially be 'programs/apps' that that are requested by the client apps, and are then granted by the dispatch/server app? i'm considering condor (univ of wisconsin) but am curious as to if pyro might also work. i'm looking to create a small distributed crawling app for crawling/scraping of targeted websites thanks -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Irmen de Jong Sent: Friday, December 01, 2006 10:05 AM To: [email protected] Subject: Re: client/server design and advice TonyM wrote: > Lastly, as far as the networking goes, i have seen posts and such about > something called Pyro (http://pyro.sourceforge.net) and wondered if > that was worth looking into for the client/server interaction. I'm currently busy with a new version of Pyro (3.6) and it already includes a new 'distributed computing' example, where there is a single dispatcher service and one or more 'worker' clients. The clients request work 'packets' from the dispatcher and process them in parallel. Maybe this is a good starting point of your system? Current code is available from Pyro's CVS repository. --Irmen -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
RE: v2.3, 2.4, and 2.5's GUI is slow for me
> -Original Message- > From: John Salerno > > I don't use IDLE too much anymore, just for quick tests, but Just curious. I have tried IDLE, but stopped using it after going through a few of the tutorials. I just type things in at the 'python' prompt, regardless of which platform I am working on; Linux, AIX or Windows. But, then again, my code winds up in a batch process or part of a web app. Is there something cool I am missing? The information contained in this message and any attachment may be proprietary, confidential, and privileged or subject to the work product doctrine and thus protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify me immediately by replying to this message and deleting it and all copies and backups thereof. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python spam?
aahz> Anyone else getting "Python-related" spam? So far, I've seen aahz> messages "from" Barry Warsaw and Skip Montanaro (although of aahz> course header analysis proves they didn't send it). I blacklisted Barry long ago. He's probably sending out spam in my name in retaliation. ;-) Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: client/server design and advice
TonyM wrote: > > Pyro rocks for that. > > Awesome, ill look into it in greater detail and will most likely use > it. Given what ive seen so far it looks like it will make the > client/server interface fairly easy to write. > Correction: not "fairly easy" - make that "incredibly easy". Even Micky likes it. :=) > Now...if only i could master python gui programming and development ;) > I'm not entirely sure which gui lib im going to end up using, but as of > now im leaning more towards tkinter as i know it will work where i need > and it seems to be one of the more documented. Ive looked at used > wxpython a little but had trouble figure out a few minor things while > playing around with it initially. I've also thought about pygtk > although I haven't taken the time to play with it quite yet as i > assumed it was primarily for linux (id be running the majority of these > on windows pcs). > You would short change yourself if you don't check out the other packages such as Pythoncard, and Dabo. The other thing I recommend for large scale applications: http://www-128.ibm.com/developerworks/library/l-pythrd.html > Thanks for the suggestions :) > Tony -- http://mail.python.org/mailman/listinfo/python-list
Re: good documentation about win32api ??
On 1 Dec 2006 09:56:09 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > http://msdn.microsoft.com covers the API itself, although you need to > transliterate from the C code to python. Exactly! that's where the problem lyes. I am pritty well to do with windows API, I am an a good python programmer, but I can't find the link between the two. there are modules but no good documentation. krishnakant. -- http://mail.python.org/mailman/listinfo/python-list
Security Descriptor and CoInitializeSecurity
I'd like to call pythoncom.CoInitializeSecurity with a PySecurityDescriptor object to set the process-wide security values. But I'm not able to find a way to let the code go through. I have read MSDN and searched web, I've not been able to find answer. I cooked a security descriptor like this (assume aces is a tuple of tuple (access, sid) : sd = win32security.SECURITY_DESCRIPTOR() sd.Initialize() sd.SetSecurityDescriptorOwner(sid_owner, False) sd.SetSecurityDescriptorGroup(sid_group, False) # create DACL dacl = win32security.ACL() dacl.Initialize() for (access, acc_sid) in aces: # Add ACE which is access and SID dacl.AddAccessAllowedAce(win32security.ACL_REVISION, access, isinstance(acc_sid, (unicode, str)) and win32security.ConvertStringSidToSid(acc_sid) or acc_sid) sd.SetDacl(True, dacl, False) # SetSecurityDescriptorDacl print sd.IsSelfRelative()# result is 1 The sd is a self relative one. >From MSDN, after calling InitializeSecurityDescriptor, the sd is absolute sd, and CoInitializeSecurity needs absolute sd. Pythonwin has not wrapped function like 'MakeAbsoluteSD'. Has someone ever had same problem. Could you give a hint for solving the problem. Thanks. Regards -- http://mail.python.org/mailman/listinfo/python-list
Thread help
Hi guys, I would make 3 threads for a client application. Tnx -- http://mail.python.org/mailman/listinfo/python-list
Re: String formatters with variable argument length
Peter Otten wrote:
> John Machin wrote:
>
> >> > Fredrik Tolf wrote:
>
> >> > > The thing is, I want to get format strings from the user, and I don't
> >> > > want to require the user to consume all the arguments.
>
> > what's ugly about this:
> > [untested]:
> >
> > def count_format_args(s):
> > pending = False
> > count = 0
> > for c in s:
> > if c == "%":
> > # doubled % chars aren't counted
> > pending = not pending
> > elif pending:
> > count += 1
> > pending = False
> > return count
> >
> > output = format % arglist[:count_format_args(format)]
>
> Keep in mind, though, that it doesn't take '*' into account:
>
> >>> count_format_args("%*.*f")
> 1
> >>> "%*.*f" % (3,2,1)
> '1.00'
A good point. Adding checking for "*" would make it rather ugly, as "*"
is special only inside a conversion specifier.
>
> And just because I don't think I've seen it before:
>
> >>> count_format_args("%42%")
> 1
> >>> "%42%" % ()
> ' %'
Hmmm ... I hadn't seen that before either. I would have said if shown
that input that I could have put in an error check that pending was not
true at the end of the loop, but was relying instead on an exception
from the formatting operator.
Even better: >>> "%-42%" % ()
'% '
:-)
Before gentle readers consider nominating the Python core dev team to
thedailyWTF.com, they might wish to:
(1) read the Python documentation
(http://docs.python.org/lib/typesseq-strings.html)
[it is not a simple escape mechanism; the second % is a "conversion
type"]
(2) compare those docs carefully with K&R v2 section B1.2 Formatted
Output (pp 243-245)
(3) note that not everything that emanated from Murray Hill NJ obeyed
the Law of Least Astonishment
:-)
Cheers,
John
--
http://mail.python.org/mailman/listinfo/python-list
Watch Alex Jones' Terror Storm, Bohemian Grove, Arrest Video, on video.google.com and infowars.com
The one who digs a trap for others falls into it himself. - Moral law of all religions. == Our confidence in 911 controlled demolition is such that we have invited people to see the truth under the pretext of debunking it. This letter was sent to professors in many US/Europe/China/India/Brazil Universities and please do not hesitate to duplicate. Volunteers are needed. Now please send this to county police stations, fire chiefs, City governments, police sheriffs, judges, magistrates, doctors, lawyers, highschools and all institutions of civil govermnents. == Dear Professor, Ever since the crime of the century on 9/11/2001, there have been many conspiracy theories woven around the incident, and even 1 Million challenge/reward has been posted: http://reopen911.org/Contest.htm Some say that jet fuel cannot melt iron because car accident fires and plane fires have never melted even the steel body of the car or the aluminum body of the plane involved in a traffic accident. Only thermite can melt so much so fast. The conspiracy theorists have erected an enormous body of evidence and we APPEAL you to apply your intellectual power to the known facts and debunk the conspiracy theorists who are now the university professors and a blot on your occupation. Much of their theory is based on the hypothesis of CONTROLLED DEMOLITION based on compositional analysis, finding numerous pieces of columns with diagonal cuts for ejection, pyroclastic flow from pulverization of concrete into fluidized dust, and numerous testimonies of explosions, which they present in videos on the internet. They object that the pentagon was not hit by a plane and FBI confiscated all the pentagon videos. Furthermore, they have shown by producing a side by side video of Osama that his confession video is a fake, and they call it a synthetic terror. Please visit their sites to debunk their spins: www.scholarsfor911truth.org www.journalof911studies.org http://www.journalof911studies.com/JonesAnswersQuestionsWorldTradeCenter.pdf They are using videos to make a spin in the tradition of Edward L Bernays (Freud's Nephew, see wikipedia on him, and watch the video on how he broke the taboo and convinced women to smoke.). They claim that the government used explosives to bring down the buildings in controlled demolition, and used thermate to manufacture molten metal pools to put the blame on smoky jet fuel fire which is ice cold for melting steel. Please search google web for thermate using this link: http://www.google.com/search?as_q=&num=100&as_epq=thermate In the results you will find these videos that show their argument on thermate in brief: http://www.supportthetruth.com/jones.php http://www.youtube.com/watch?v=_wVLeKwSkXA&mode=related http://video.google.com/videoplay?docid=-4757274759497686216 They have put popular mechanics in retreat as in this audio debate with popular mechanics 5MB Audio download: http://www.911podcasts.com/display.php?vid=158 found via http://911blogger.com/node/2278?page=2 == They are also calling professor Noam Chomsky as the gate keeper of the left. Here are the links: Here's the discovery path: On st911.org visit this: Hugo Chavez and the sulfuric odor of "devil" Bush 22 September 2006, onlinejournal.com, Larry Chin http://onlinejournal.com/artman/publish/article_1234.shtml There, visit this: Alternative Media Censorship http://questionsquestions.net/gatekeepers.html == There are a lot of government grants available for research on this subject intimately linked to terrorism. We ask you as concerned citizens to exert your intellectual capabilities on this subject and give an ethical public opinion. If you can find a general thermodynamic type result that their conspiracy theory is impossible and that the cars that burn in accidents can melt their steel body and planes can melt their aluminum from jet fuel or a plane crash can quickly cause mixing of the needed reactants to produce a fast thermate reaction with sulfur from the gypsum wall board, the Administration would have won. Thank you for your time, fortitude and intellectual honesty. If you know someone in departments of Mechanical Engineering, Structural Engineering, Combustion Science and Engineering, Chemistry, Physics, Materials Science, Metallurgy who would have expertise in the subject, please pass on the email and just view the videos as a responsible informed citizen and for its highly entertaining value. There is also a lot of material to work with for your subject area of research and study. Concerned Citizens Appeal to you !!! We have sent this email to select recipients who will be proud of the government and know how to propagate the information intelligently. http://portland.indymedia.org/en/2006/06/341238.shtml If any of the video links dont work, and censored, just v
Re: Ruby/Python/REXX as a MUCK scripting language
In article <[EMAIL PROTECTED]>, Laurent Pointal <[EMAIL PROTECTED]> wrote: >> . >> . >> . > there's the security issue that really worries me. . . I have to be > able to limit what the interpreter can execute. I can't have my users . . . >>> I Agree with F.Bayer, when reading OP post, I immediatly think about Lua. >> >> Does Lua have an appropriate security model--a sandbox or such? >> Fond though I am of Lua, such would be news to me. > >I dont think of a security model like in Java, but in the possibility to >limit the accessible libraries for interpreted code. > > http://www.lua.org/manual/5.1/manual.html#5 > >If OP just need some computation logic, he could limit external world >communication libraries (these libraries must be loaded by the C host >program before being usable by scripts). >Need to look more precisely to the minimum library set to load and to >available functions in this set. Maybe it is possible to remove some >undesired functions from Lua symbol tables just after loading libraries. > > >[note: I have still not used Lua, but I look at it for futur use in a >current development where an embedded Python would be too heavy and make >problems relative to the GIL - but I'm still a Python fan in other use >cases] . . . I agree that Lua has a nice collection of primitives, and there certainly is scope for security-related programming. There isn't a body of work or precedent for polished results in this area, though, ... Good luck with the future use you anticipate. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read the directory which the actively running python file is located in?
Michael Malinowski schrieb: > Is there a way to read the directory that the currently running python file > is located in? Hi Mike! To get the started program: sys.argv[0] Don´t use ``os.curdir``. To get the filename, of the current module: __file__ To get the directory: os.path.split(sys.argv[0])[0] os.path.split(__file__)[0] Regards, Gerold :-) -- Gerold Penz - bcom - Programmierung [EMAIL PROTECTED] | http://gerold.bcom.at | http://sw3.at Ehrliche, herzliche Begeisterung ist einer der wirksamsten Erfolgsfaktoren. Dale Carnegie -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread help
On 2006-12-01, Salvatore Di Fazio <[EMAIL PROTECTED]> wrote: > I would make 3 threads for a client application. You should use 4. -- Grant Edwards grante Yow! My TOYOTA is built at like a... BAGEL with CREAM visi.comCHEESE!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Take the $million challenge: Prove 911 conspriracy theorists are wrong
I found this nice dialog on the internet: = > Well, if you want to convice me, just answer these questions: If you can prove that the official explanation is correct, what's keeping you from collecting a MILLION dollars? Even if you're too wealthy to bother, you could donate the proceeds to the Aryan Nation or the John Birch Society. > 1. How much explosives were used and what type? Thermate/thermite have been discovered in chemical tests, and evidence of its use is plainly visible in photographic an video evidence from the WTC buildings on 9/11. Thermate does not cause millions of tones of concrete to become pulverized into dust in mid-air (as video evidence clearly shows), so another high-energy explosive must have also been used. Now that we have positive proof that explosives were used, and once the secondary compounds have been discovered, the quantities and placement can be estimated from examinations of the video and photo evidence. > 2. How many people were needed to prepare the building for demolition? Irrelevant to the established fact that explosives were used. Will be determined in the new investigation. BTW: It's "buildings," not "building." Did you realize that *three* WTC towers collapsed on 9/11/01, despite only 2 buildings being hit by jets? Most Americans don't realize this obvious fact. Why? > 3. How long did it take to prepare the buildings for demolition? Irrelevant to the established fact that explosives were used. Once the identities of the conspirators are discovered in a new investigation, the timeline can be established. (That's what investigators do.) > 4. How many people had to be bribed and how much were they bribed to > keep silent about the preparations? Irrelevant to the established fact that explosives were used. Those conspirators (whether bribed or not) that are still alive must be discovered and convicted for their crimes, which may include conspiracy to commit treason. The only way to bring the criminals to justice is to open a new investigation which will examine *all* relevant evidence, including sequestered videos, audio tapes, and classified documents. Everybody with an IQ above room temperature knows that the 9/11 Commission report was a whitewash, which didn't even attempt to lay blame at the feet of military and civilian officials who were asleep at the wheel on 9/11/01. It proves that Bush is not serious about national security. -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread help
Grant Edwards ha scritto: > You should use 4. Yes, but I don't know how can I make a thread :) -- http://mail.python.org/mailman/listinfo/python-list
RE: v2.3, 2.4, and 2.5's GUI is slow for me
[EMAIL PROTECTED] wrote: >> I don't use IDLE too much anymore, just for quick tests, but > > Just curious. I have tried IDLE, but stopped using it after going > through a few of the tutorials. I just type things in at the 'python' > prompt, regardless of which platform I am working on; Linux, AIX or > Windows. But, then again, my code winds up in a batch process or part > of a web app. > > Is there something cool I am missing? > The main plus of idle for me is that in interactive mode I can easily pull back any single statement (e.g. a complete class definition) edit and then re-execute it. The command line only pulls back single lines for editing, not complete statements. Also the ways to pull back a previous command are simpler. As well as typing the start of a command then using alt-p to pull it back you can look through the buffer, put the cursor on a command and hit return to get an editable copy. -- http://mail.python.org/mailman/listinfo/python-list
Re: good documentation about win32api ??
krishnakant Mane schrieb: > On 1 Dec 2006 09:56:09 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >> http://msdn.microsoft.com covers the API itself, although you need to >> transliterate from the C code to python. > Exactly! that's where the problem lyes. > I am pritty well to do with windows API, I am an a good python > programmer, but I can't find the link between the two. > there are modules but no good documentation. > krishnakant. Maybe then ctypes is the right thing for you? Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read the directory which the actively running python file is located in?
anders wrote: > in os module there is many funktion/methods to extract this information > to ask the path to the current running pythonprogram you can do likes > this > > - CUT--- > import os > print os.getcwd() > > - CUT -- > > // Anders > > > Michael Malinowski skrev: > > > Is there a way to read the directory that the currently running python file > > is located in? > > Cheers > > Mike. os.getcwd() provides the "current working directory". This is *not* necessarily the directory that the "currently running python file" [whatever that means] is located in. Try picking what you really want/need out of this: C:\junk\foo>type ..\where.py import sys, os if __name__ == "__main__": print "running as script" else: print "imported module named", __name__ print "code loaded from file", __file__ print "sys.argv[0] is", sys.argv[0] print "cwd is", os.getcwd() C:\junk\foo>..\where.py running as script code loaded from file C:\junk\where.py sys.argv[0] is C:\junk\where.py cwd is C:\junk\foo C:\junk\foo>type runwhere.py import sys sys.path[0:0] = ['c:\\junk'] import where C:\junk\foo>runwhere.py imported module named where code loaded from file c:\junk\where.py sys.argv[0] is C:\junk\foo\runwhere.py cwd is C:\junk\foo C:\junk\foo>cd .. C:\junk>md bar C:\junk>cd bar C:\junk\bar>..\foo\runwhere.py imported module named where code loaded from file c:\junk\where.pyc sys.argv[0] is C:\junk\foo\runwhere.py cwd is C:\junk\bar HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: good documentation about win32api ??
"__schronos__" wrote: > Hi all. > > Recently I've to developed a project in python that made operation > under win32 platform and I found a lot of problema to find good > information. The only one documentation is in ActivePython page > (http://aspn.activestate.com/ASPN/docs/ASPNTOC-APYTH2.4.0) but it is > not very good and finally I had to turn to the newsgroups (it was very > nice). > > And the question is: ¿Anybody knows where can I find good > documentation about win32api? > > Thanks in advanced. The pywin32 package has a .chm help file that covers the modules, objects and methods. Also, there are demos of many of the functions and interfaces. Roger == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News== http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups = East and West-Coast Server Farms - Total Privacy via Encryption = -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread help
On 2006-12-01, Salvatore Di Fazio <[EMAIL PROTECTED]> wrote: > Grant Edwards ha scritto: > >> You should use 4. > > Yes, but I don't know how can I make a thread :) Perhaps you should have said that earlier? Googling for "pythong threads" finds some useful info: http://docs.python.org/lib/module-threading.html http://linuxgazette.net/107/pai.html http://www.wellho.net/solutions/python-python-threads-a-first-example.html http://heather.cs.ucdavis.edu/~matloff/Python/PyThreads.pdf -- Grant Edwards grante Yow! Am I elected yet? at visi.com -- http://mail.python.org/mailman/listinfo/python-list
