I am trying to define a class static variable. But the value of thestatic variable seems to be only defined inside the file that theclass is declared. See the code below. When I run "python w.py", Igot:000=======> Hello World001=======> Hello World002=======> Not Initialized003=======> Not Initialized004=======> Not Initialized005=======> Hello WorldLooks like even though the class variable "ClassW.w_classStaticVar"was set inside "startup()", the value never carried over to functionsin "a.py". Is this a bug in Python's static variable handling. I amrunning Python 2.4.4.Ben#===== file: w.py ========from a import *class ClassW:def startup():if __name__ == '__main__':#===== file: a.py ========from w import *class ClassA:
Duncan,Thanks for replying. However, I am still confused...Even if I put "from __main__ import *" in both "a.py" and "w.py", Istill gotthe same results. So, how should I re-structure my program to make theclassstatic variable works???Thanks,Ben
Option 1:In w.py put:import aand then refer to a.ClassAIn a.py put:import __main__and then refer to __main__.ClassWBut better, option 2:Create a new file script.py which contains:import wif __name__=='__main__':then in a use 'import w' and in w use 'import a' and refer to a.ClassA and w.ClassW as above.Try to think through the order in which Python interprets your code: remember everything is interpreted. Both 'import' statements and 'class' statements are really just variation on an assignment, so none of the names exist until the lines which declare them have been executed. A line 'import a' is roughly the same as: a = __import__(something)and a statement such as 'class ClassA: whatever' is roughly the same as: ClassA = type('ClassA', baseclasses, dict)You should never attempt to use the 'from X import *' form of import when you have modules which include each other (you might get away with it if you move the imports to the end of the module instead of the beginning, but it is much simpler just to import the modules, and good practice in any case).
Hi,I recently checked out py2exe (on Windows). Looks good.Was able to build an EXE out of one of my Python apps.Wondering how it works? Does it actually compile the Python source ofyour script into machine language, or does it do something more likebundling the Python interpreter, the Python libraries and the scriptitself, into a file?Will look at the source code but would like to get some ideas ...Thanks ...Vasudev RamDancing Bison EnterprisesBiz site: http://www.dancingbison.comBlog on software innovation: http://jugad.livejournal.comxtopdf: PDF creation/construction toolkit: http://www.dancingbison.com/products.html
--nextPart24656588.X6EKRnSC4CContent-Type: text/plain; charset="iso-8859-1"Content-Transfer-Encoding: quoted-printableContent-Disposition: inlineessentially, that's what it does.=2D-=20GPG key: 0xF421434B may be found on various keyservers, eg pgp.mit.eduHacker key
Q: A or B?A: Yes.*nudgenudge*
On Jul 2, 12:43 am, Wildemar Wildenburger
I wonder why you chose not to use python-pysqlite2...
Yeah sure thats what is (finally) working but its never clear upfrontfor a package what its dependency needs are -- linux version of DLLhell. And it gets worse for systems that are little worlds inthemselves like python, ruby, eclipse, webmin etc. because they havetheir own package-management systems which invariably quarell with thenative apt/rpm or whatever...
IMO the problem is two folds1- distros and "little worlds" as you call them, not getting in syncas to why or how is the best way to handle packages. which results inincompatible installations, for example anything that installs withsetuptools is almost 100% incompatible with anything installed byemerge,apt,etc. because in general (at least that's the case withdistros I have used) they handle setuptools packages like normaldistutils and handle the dependecies "externally".2- setuptools/distutils having no uninstall option this is mainlybecause of the fact that noone has sit down and write a clear way tomake sure a package is not needed anymore. which will clearly putsetuptools in the land of apt or rpm, but then what happens when asetuptools package depends on something like gnome which isn't handlethis way.so yes it's a big mess.
Hello,eGenix is looking into organizing a one day conferencespecifically for companies doing business with Python, Zope andPlone. The conference will likely be held in or close toDüsseldorf, Germany, which is lively medium-sized city, with goodairport connections world-wide and specifically to all majorEuropean cities, so it's easy getting there and ideal for a oneday event.The focus of the conference is on networking, meeting people,exchanging experience and exploring ways of working together.We are aiming at having a small conference program with just a fewtalks. The main intent of the presentations should be to initiatediscussions among the attendees.Since this will be a business-only event, we will likely getprofessional help from a conference organizer and also try tosign up with a hotel to do all the catering, conference roommaintenance, etc.My questions to you:* Would there be interest in such a conference event ?* How many people from your company would likely attend ?* Would a weekday or weekend conference date be more attractive ?* Does the focus suit your needs ?We will be giving a short presentation of what we have in mindat EuroPython 2007 in Vilnius in the context of the Open Spacesessions: http://wiki.python.org/moin/EuroPython2007OpenSpaceIf you're interested, please contact us.Thanks,
T24gNi8zMC8wNywgQnJ1bm8gRGVzdGh1aWxsaWVycyA8YmRlc3RoLnF1ZWxxdWVjaG9zZUBmcmVlLnF1ZWxxdWVwYXJ0LmZyPiB3cm90ZToKPiBFZHVhcmRvICJFZENyeXB0IiBPLiBQYWRvYW4gYSDDqWNyaXQgOgo+ID4gUmVtZW1iZXIgdGhhdCBwdXJlIENQeXRob24gaGFzIG5vIGRpZmZlcmVudCAiY29tcGlsZSB0aW1lIiBhbmQKPiA+IHJ1bnRpaW1lLgo+Cj4gT2ggeWVzID8gU28gd2hhdCdzIHRoZSBjb21waWxlciBkb2luZywgYW5kIHdoYXQgYXJlIHRob3NlIC5weWMgZmlsZXMgPwo+IChoaW50OiByZWFkIHRoZSBkb2MpCgpTb3JyeSwgSSBzdXJlbHkga25vdyB0aGF0IFB5dGhvbiBoYXMgYSBjb21waWxlIHRpbWUsIEkgd2FudGVkIHRvIHNheQpzb210aGluZyBsaWtlICJjb21waWxlIHRpbWUgY2hlY2tzIGV4Y2VwdCBmcm9tIHN5bnRheCIuIE15IGludGVudGlvbgp3YXMgdG8gc2hvdyB0aGF0IGEgKmh1Z2UqIGNoYW5nZSBpbiB0aGUgUHl0aG9uIGludGVycHJldGF0aW9uIG1vZGVsCndvdWxkIGJlIG5lZWRlZCB0byBhbGxvdyB3aGF0IGhlIHdhbnRlZCwgYnV0IEkgZmluaXNoZWQgbXkgZW1haWwgdG9vCmVhcmx5IDpQCkFuZCB5ZXMsIEkgcmVhZGVkIHRoZSBkb2NzIDopCgotLSAKRWR1YXJkb09QYWRvYW4gKGVvcGFkb2FuLT5hbHRhdml4Ojpjb20pCkJvb2ttYXJrczogaHR0cDovL2RlbC5pY2lvLnVzL2VkY3J5cHQK
According to Wikipedia, http://en.wikipedia.org/wiki/GPS#Ephemeris_and_clock_errors
... snip ...In summary, time is now defined as a non-continuous function, andis thus proof against manipulation by most standard algebraictechniques. Take that :-) In fact, it is not even quanticized.
On 01 Jul 2007 11:57:30 -0700, Paul Rubin
Oh yes, good point, the article ought to mention that.
Systems which need to perform date+time computations into thepast. One advantage of Julian time is that it ignores the "1 BC wasimmediately followed by 1 AD, there is no 0 AD" hiccup, so Julian timeallows dates to use simple arithmetic to determine the interval.I know that PostgreSQL at least stores date values in Julian time, forexactly this benefit.
No it isn't. GPS has never introduced a leap second, and is still on uncorrected UTC-as-of-1980. However, the GPS signal also includes an occasional UTC correction figure, so it can be used to obtain UTC.
The following simple language parser and interpreter is fromchapter 2 of the textbook: _Programming Languages: Applicationand Interpretation_, by Shriram Krishnamurthi.http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/First, I'll show the Scheme version of the program, which usesthe cool define-type and type-case macros (I'd never heard ofthem before reading this book, which is too bad). I think it isbeautiful.; Our grammar:;
...Have you taken a look at pyparsing ?http://pyparsing.wikispaces.com/
Hi everyone.This is my first time posting to this newsgroup, and although Imaintain my netiquette I might've missed something specific to thenewsgroup, so hopefully you can avoid flaming me if I have :) Iapologize for the length of this post but I figure the moreinformation the better.My problem is that I'm getting a syntax error in some Python code thatlooks quite simple. The original code was in Object Pascal as I'm arecent Delphi-turned-Python programmer.I took the code (which is only about 130 lines in OP) and 'translated'it the best I could into Python (ended up being one line shy of 80when I was done). I can't see any problems with the code but it'scoming up with a bunch of errors, which I'm guessing are probably myassuming something is the same in Python as it is in Pascal, and beingwrong.Anyway, here's the code I'm having trouble with (the same error comesup several times but this is the first part of the code it shows upin):[code]randomizing_counter = 0# Put the loop counter for the randomizing to zero.until_val = 36# Set the "until val" to 36. We'll compare them to make sure we're notat the end of our wordlist_both.while randomizing_counter < until_val:[/code]The starred line is the one getting the error message: "SyntaxError:can't assign to function call"Now, I do understand what this means. I'm trying to assign to afunction instead of the value that the function should create. Butsince when is weights_array or small_randomizing_int a function? Bothare being declared in the code on their first usage. This one has gotme stumped, maybe you guys can help me out with it?Thanks,~Dustin
If weights_array is a list or dictionary then useto choose which element of the list gets the assignment.If weights_array is a function, then is the proper way to call the function, but the value returned cannot be the object of an assignment.Gary Herron
Using parens () indicates a function call.I suspect things will work much better using square brackets [].Square brackets indicate the index into a sequence (like a list)
The more relevant information the better. It would have helped had youshown (a) the first use of weights_array (b) your import statementsOthers have pointed out that the likely source of your first problemis using () instead of [] for list subscripting.I'll move on to the next few ...Problem 2: excessive verbosityTry this:Problem 3a:You have an import statement likein which case you would get a runtime error, and should have:or Problem 3b:You have an import statement like:which will not cause a runtime error, merely mass barfing among thespectators :-)Problem 5: putting comments after the code instead of on the same lineas the statement you think needs explanation (most don't) or beforeit.Problem 6: big_randomized_int can only have values in 0, 1, ..., 98,99. So small_randomized_int will have the value 0, always.Perhaps you meant:Problem 7: even if you did intend big.... / 100.00, the above isredundant. 1 / 100.0 is 0.01, 99 / 100.0 is 0.99 -- no rounding isnecessary.Problem 8: it's round(), not Round()First? It's done each time around the loop.So, here's the looping version:and here's the obligatory one-liner, using a list comprehension:range(len(wordlist_both))]and here's an example of it in use:[0.38, 0.12, 0.55000000000000004, 0.23999999999999999,0.91000000000000003, 0.48999999999999999, 0.91000000000000003,0.67000000000000004, 0.77000000000000002,0.81999999999999995]Problem 9: you were expecting "precise" values like 0.55 and 0.24.Solution is to read this:http://docs.python.org/tut/node16.htmlHTH,John
PASCAL --> PYTHON5 div 2 --> 5/25 mod 2 --> 5 % 2
In article <1183352843.803263.82140@57g2000hsv.googlegroups.com>,I'm wary of this line, especially in isolation. I hope it reduces,rather than exacerbates, the original questioner's confusion, for meto observe that [] *also* mark dereferencing into a dictionary (hash,associative array, ...), which is distinct from list indexing.
...That is correct. But why did you try using interact() method in thefirst place?I just want to know to see if I could improve the documentation.After you send the password the 'scp' command should finish quicklyand exit,so there would be nothing for a human to interact with.You could also try using the run() function which is a simplifiedinterface to pexpect.Something like this might work:file2,/files/file3} /tmp',That's all there is to it. The run() function will run the given scpcommand.When it see 'password' in the output it will send the server_password.Yours,NoahYours,Noah
Oops. When I typed
It's an interpreted language. It is compiled into bytecode (notmachine code) the first time a script is run to speed up subsequentexecutions of a script.
I think you mean that CPython doesn't save the results of the compilation of a script. The scripts are compiled every time they are run, as you go on to say.
Hey Steve,To nit pick :) Wouldn't you say it is more accurate to say that itdoes compile the scripts (by which we mean the "main" file - eitherthe one passed as an argument to the interpreter on the command line,or the one with a #! at the top which gets respected, or the .py fileon Windows which is associated with python.exe as its interpreter),but that it doesn't save the results of this compilation to a file tobe used next time?Jean-Paul
As long as nothing tries to re-raise the exception I doubt it breaks anything: >>> import sys >>> try:except StandardError:Traceback (most recent call last): File "
I guess I don't really see that as a problem. Exceptions shouldnormally only be re-raised where they are caught. If a piece of codehas decided to handle an exception, and considers it dealt with, thereis no reason for it not to clear the exception, and good reason for itto do so. Also, any caught exception is automatically cleared whenthe catching procedure returns anyway, so it's not like Python hasever considered a caught exception to be precious information thatought to be preserved long past the point where it is handled.I'm not sure I see the analogy: Calling the GC can be expensive,clearing an exception is not. The exception is going to be clearedanyway when the procedure returns, the GC wouldn't likely be.It's much more like explicitly assigning None to a variable thatcontains a large data structure when you no longer need the contentsof the variable. Doing this sort of thing can be a wise thing to doin certain situations.As Python is not a formally standardized language, and one typicallyrelies on the fact that CPython itself is ported to just about everyplatform known to Man, I don't find this to be a particular worry.Well, I think that the refcounting semantics of CPython are useful,and allow one to often write simpler, easier-to-read and maintaincode. I think that Jython and IronPython, etc., should adopt thesesemantics, but I imagine they might not for performance reasons. Idon't generally use Python for it's speediness, however, but ratherfor it's pleasant syntax and semantics and large, effective library.|>oug
I'm not sure I understand you here. You're saying that I should havethe foresight to wrap all my file opens is a special class tofacilitate debugging?If so, (1) I don't have that much foresight and don't want to haveto. (2) I debug code that other people have written, and they oftenhave less foresight than me. (3) It would make my code less clear toever file open wrapped in some special class.Or are you suggesting that early in __main__.main(), when I wish todebug something, I do something like: __builtins__.open = __builtins__.file = MyFile
QOTW: "Modules are objects too - they're a good example of singletons. If youwant to create a class containing only static methods: use a module instead.If you want to create a class having a single instance (a singleton), most ofthe time you can use a module instead. Functions don't *have* to be methodsin a class, and the resulting design may still be a good design from an OOpoint of view." - Gabriel Genellina"I recommend gmane.org's NNTP server for all your mailing list needs." - GrantEdwards========================================================================Everything Python-related you want is probably one or two clicks away inthese pages:Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topic/python/ (requires subscription) http://groups-beta.google.com/groups?q=python-url+group:comp.lang.python*&start=0&scoring=d& http://purl.org/thecliff/python/url.html (dormant)
weighted.You should always copy and paste the exception you receive (includingthe stack trace). Anyway, read the exception *carefully*. It says "can'tassign to function *call*". In the line: weights_array(randomizing_counter) =3D small_randomized_int"weights_array(randomizing_counter)" is a function call. My guess isthat you think you're trying to modify an element of "weights_array"(your code doesn't show us what weights_array is, but I'm guessing it'sactually a list), but parentheses are not the syntax for element access(subscripting) in Python.You should read the python tutorial:http://docs.python.org/tut/tut.htmlespecially the sections on lists:http://docs.python.org/tut/node5.html#SECTION005140000000000000000and functions:http://docs.python.org/tut/node6.html#SECTION006600000000000000000Cheers,Tim Delaney
Mm very interesting thread, for my needs from numpy import inf is morethan enough :)
float('inf') works well, no? >>> inf = float('inf') >>> inf / inf nan >>> -inf -inf >>> inf / 0 ZeroDivisionError: float division >>> 1 / inf 0.0 >>> 0 * float('inf') nan
It is not cross-platform. The parsing of strings into floats and the stringrepresentation of floats is dependent on your system's C library. For thesespecial values, this differs across platforms. Your code won't work on Windows,for example. Fortunately, it doesn't matter all that much (at least for thosewho just need to create such values; parsing them from files is another matter)since infs and nans can be constructed in a cross-platform way (at least forIEEE-754 platforms where these values make sense). inf = 1e200 * 1e200 nan = inf / inf
The easiest way to do this is to simply restrict the maximum fileupload size. When the client makes the POST request you can see howbig it will be. This won't really give you the image dimensions ofcourse, but there's no simple way to find out that information withoutuploading the entire image.
Hi Python programmers,I need to be able to read the stdout and stderr streams of an externalprogram that I launch from my python script. os.system( 'my_prog' +'>& err.log' ) and was planning on monitoring err.log and to displayits contents. Is this the best way to do this?Thanks,Murali.
from subprocess import Popenstdout, stderr = Popen('my_prog').communicate()
No. The best way to do this is with Popen, as it is portable and avoids the extranous file.
For what it's worth, with python 2.5 on my Macbook:[jloden@macbook jloden]$ python -m timeit 's = "onomatopoeia"; s = s.join(s[::-1])'100000 loops, best of 3: 5.2 usec per loop[jloden@macbook jloden]$ python -m timeit ' 100000 loops, best of 3: 3.94 usec per loop Note that in the second version, I changed the code a little bit so that it no longer iterates over every char in the string and instead just calls lis() to convert it to a list of chars in order to call list.reverse() on it. -Jay
...Hmmm, doesn't look to me as if it's worth much...:s.join(s[::-1])'since what you're doing is...:'aonomatopoeiaionomatopoeiaeonomatopoeiaoonomatopoeiaponomatopoeiaoonomatopoeiatonomatopoeiaaonomatopoeiamonomatopoeiaoonomatopoeianonomatopoeia
Since you mentioned Cobol I couldn't resist...move "spam" to spamDisplay Function Reverse(spam)There's also slicing (known in Cobol as "reference modification")move mystring(5:3) to my-newstring* moves 3 characters starting with character 5No "negative" slicing, though it could be simulated with Function Reverse() and ref.mod.Frank
That's what I get for copying and pasting from the post preceding mine and not actually checking it for what it does ;)
aleax@mac.com (Alex Martelli) wrote innews:1i0kjpx.wjw44j15np22dN%aleax@mac.com: sorry you've lost me there.This is an interesting point to me. I am just learning Python and I wonder how I would know that a built in function already exists? At what point do I stop searching for a ready made solution to a particular problem and start programming my own function?Is it just a matter of reading *all* the documentation before I start coding?
It's worth spending an hour or two reading through the library manual,yes.
Thanks guys!I've used the HTML and the unicodedata suggestions, each on adifferent report. These worked nicely!Andy
Hi,For experienced with Pyhton users, which developing software andenviroment would you suggest for Pyhton programming? Compiler+Editor+Debugger.Also what are your suggestions for beginners of Pyhton programming?Thank you.
Hello,Emacs is the best for anything for me. Some people prefers Eclipsewith PyDev extension.Build some real world applications with Python. Pick what do you needfrom SourceForge or similar one then write it. If it is something youneed then you probably will make it more special then you found andthis will take you to the more coding and more...By the way, thanks for winning Magny Cours grand prix Kimi... :-P
Sa ol say n Kartal :-)
In article <1183317054.513102.127950@q69g2000hsb.googlegroups.com>,I'm very happy with emacs using python mode (http://www.python.org/emacs/). It's a love it or hate it kind of thing. If you're an emacs fan, you'll probably not want to use anything else. If you're not an emacs fan, this is probably not for you.There really is no separate compiler. It's part and parcel of the interpreter. Your .py files do get compiled into .pyc files, but it happens automatically the first time you run a module. No need to run a separate compilation phase like you would with C or Java.As for a debugger, I've honestly never found the need for one. I invest a lot of time in unit tests, which smoke out most of the bugs. For what's left, it's easy enough to stick print statements in strategic places to see what's going on.
There is one tool you won't be able to live without: iPython (no, it'snot an Apple product, but it would be worth waiting in line for 3 daysfor)http://ipython.scipy.org/moin/
then first decide which graphical package you want to use,because that limits your choice.cheers,Stef Mientki
On Jul 1, 10:59 pm, Stef Mientki
Under Windows, take a look at PyScripter.For students learning Python, we are switching from Scite to PyScripter,good editor, online Python shell, graphical debugger with step by step,showing variables values in popups and many other sympathic features...test it.
I use standard CPython bytecode compiler/virtual machine, the Vimeditor, and standard pdb for debugging. Vim is nice as it'smultiplatform, has a built-in Python interpreter for writingextensions, is free and lightweight. It's a modal editor so that's amatter of taste--people either love it or hate it.Start with something like http://www.diveintopython.org for a briefintro.Pick a very small project and program it. Then pick something biggerand do that. Once you're comfortable with small projects, find anopen-source project that you like and try to understand the codeenough to make some change you find useful; reading code is asimportant as writing it.
http://www.wingware.com/ is pretty impressive but non-free of bothbeer & speech varieties
Thanks for the replies so far. Also i have to learn:What is the most reliable and easy way to start learning Ptyhon?Books? Trusted code sammples(where?)?I know the importance and eases of Python quite.Thanks.
Thanks for the replies so far. Also i have to learn:What is the most reliable and easy way to start learning Ptyhon?Books? Trusted code sammples(where?)?I know the importance and eases of Python quiet.Thanks.
I'm looking for information on building a tiny/small/minimalist/vanilla python interpreter. One that implements the core language anda few of the key modules but isn't tied to any specific operatingsystem.I guess I'm asking for the smallest subset of the standard Pythonsource code files that is necessary to get a working interpreter usinga plain C compiler.Is this even possible? If so, has someone done it already? I'velooked on Google and in comp.lang.python but nothing comes up.Thanks!Ron
"rtk"
In article <1183332951.122782.212720@o11g2000prd.googlegroups.com>,Tiny Python, PyMite, EmbeddedPython, Diet Python, deeply embeddedpython, ...--I need to write up a page that explains these.
Python binary/exe its self dosnt include much. if you get the full build and just remove modules, you can strip a lot out.. scripts that try import those files just wont work.
PyMite will get a closer look from me eventually but I found that Luawill fit my immediate needs quite nicely. Thanks for the suggestion.FYI.. I wanted a simple version of Python to run on an ancient DECAlpha box. I got VMS Python 2.5 up and running but it is too slow touse. It takes *minutes* to get the interpreter prompt after typing'python'! Lua, on the other hand, compiled without changes (used theANSI switch) and runs nicely. I'm always up for learning a newlanguage anyway.Ron
Something is wrong. Maybe it's trying to DNS itself and timing out,or something like that.
If you're in London around 6.30pm this Thursday evening, July 5th 2007, you might want to drop in on The Institution of Engineering and Technology [1] on the Embankment near Waterloo Bridge [2] for "A Light byte of Python" [3]. Michael Grazebrook, Pete Ryland and I are flying the Python flag for the benefit of technologists who have not yet had the pleasure. Michael will be using ctypes to control a USB-interfaced sensor kit; Pete will be demoing user interfaces; I'll be using BeautifulSoup and sqlite3 to populate a database from a web page and (time permitting) using csv and ReportLab to push it back out again.We're presenting the thing as a bring-a-laptop workshop, and it would be great if we had experienced Pythoneers along to help afterwards (in addition to ourselves). The take-up's been quite high for the event and there's tea & coffee beforehand and sandwiches afterwards.Tim Golden[1] http://www.theiet.org/[2] http://www.iee.org/OnComms/Branches/UK/england/SEastE/london/Venues/savoy.cfm[3] http://www.iee.org/OnComms/Branches/UK/england/SEastE/london/Events/july.cfm
l_struct = cast(l_res, POINTER( Struct_Password ) )POINTER wants a ctypes type as an argument. Struct_Password() is a Structure instance.A better way to do it is define the return type for getspnam:g_lib.getspnam.restype = POINTER( Struct_Password )Now the function returns a structure pointer so the cast is unnecessary.
Many thanks,
------=_Part_68055_2136133.1183346537409Content-Type: text/plain; charset=ISO-8859-1; format=flowedContent-Transfer-Encoding: 7bitContent-Disposition: inlineHi,I just wanted to mention that I wrote a patch for delicious.py 0.2.5that solves the 401 "bug". The delicious guys changed theirapi to use ssl and stuff. I already sent the patch to the author,but in case you need the library asap (as I did) youcan apply it and it should work.GreetingsKai------=_Part_68055_2136133.1183346537409Content-Type: application/octet-stream; name=delicious-0.2.5-401.patchContent-Transfer-Encoding: base64X-Attachment-Id: f_f3mduy7pContent-Disposition: attachment; filename="delicious-0.2.5-401.patch"ODRjODQKPCBkd3NfYXBpICAgICAgPSAnaHR0cHM6Ly9hcGkuZGVsLmljaW8udXMvdjEvJw0KLS0tCj4gZHdzX2FwaSAgICAgID0gJ2h0dHA6Ly9kZWwuaWNpby51cy9hcGkvJw0KMTUwLDE1NmMxNTAsMTUzCjwgICAgICAgICAjIEZJWE1FOiBOb3Qgc3VyZSBpZiB3ZSBzdGlsbCBuZWVkIHRoaXMgKEthaSBLdWVobmUpDQo8ICAgICAgICAgI2lmIGRlYnVnOiBodHRwbGliLkhUVFBDb25uZWN0aW9uLmRlYnVnbGV2ZWwgPSAxDQo8ICAgICAgICAgcGFzc3dvcmRfbWFuYWdlciA9IHVybGxpYjIuSFRUUFBhc3N3b3JkTWdyV2l0aERlZmF1bHRSZWFsbSgpDQo8ICAgICAgICAgcGFzc3dvcmRfbWFuYWdlci5hZGRfcGFzc3dvcmQoTm9uZSwgZHdzX2FwaSwgc2VsZi51c2VyLCBzZWxmLnBhc3N3ZCkNCjwgICAgICAgICBhdXRoX2hhbmRsZXIgPSB1cmxsaWIyLkhUVFBCYXNpY0F1dGhIYW5kbGVyKHBhc3N3b3JkX21hbmFnZXIpDQo8ICAgICAgICAgb3BlbmVyID0gdXJsbGliMi5idWlsZF9vcGVuZXIoYXV0aF9oYW5kbGVyKQ0KPCAgICAgICAgIHVybGxpYjIuaW5zdGFsbF9vcGVuZXIob3BlbmVyKQ0KLS0tCj4gICAgICAgICBpZiBkZWJ1ZzogaHR0cGxpYi5IVFRQQ29ubmVjdGlvbi5kZWJ1Z2xldmVsID0gMQ0KPiAgICAgICAgIGF1dGhpbmZvID0gdXJsbGliMi5IVFRQQmFzaWNBdXRoSGFuZGxlcigpDQo+ICAgICAgICAgYXV0aGluZm8uYWRkX3Bhc3N3b3JkKGR3c19yZWFsbSwgZHdzX2hvc3RuYW1lLCBzZWxmLnVzZXIsIHNlbGYucGFzc3dkKQ0KPiAgICAgICAgIG9wZW5lciA9IHVybGxpYjIuYnVpbGRfb3BlbmVyKGF1dGhpbmZvLCBEZWZhdWx0RXJyb3JIYW5kbGVyKCkpDQo=------=_Part_68055_2136133.1183346537409--
The point is: let us have good default behavior.Generally, two equal numbers are two conceptualreferences to the same "thing". (Say, the Platonicform of the number.) So it is good that the hash valueis determined by the number. Similarly for strings.Two equal numbers or strings are **also** identical,in the sense of having the same conceptual reference.In contrast, two "equal" cars are generally not identicalin this sense. Of course you can make them so if you wish,but it is odd. So *nothing* is wrong here, imo.Btw:TrueTrueCheers,Alan Isaac
I am trying to use freeze to create a single binary executable for oneof my program. When I run freeze, it runs fine with the followingmodules. These modules are available in the dyn-load directory and Ican import them from the python interpreter.Warning: unknown modules remain: _bisect _heapq _locale _random_socketMake also runs fine, but when I run the program on another machine, itcompiles saying could not import these modules. Any idea how to getthis working...Thanks.
What problems are you having installing? I had one problem with the terrible matlab license server, which I had to solve by making site- packages world writable, installing pymat as a user, and then removing the world writable flag. Root just didn't have access to matlab on my machine. :P
Hey,thanks, but I am affraid this is not what I was looking for. I need tohave some library on my pc (linux) that would allow me to transfer afile to a bluetooth mobile phone (the mine doesn't have symbian). Ihave some programs that allow to do that like for ex. obex_client butI would like to write something similar using python.thanks!regards
Drex schrieb:Wrap thishttp://www.zuckschwerdt.org/apidocs/using ctypes.Diez
Hello,thanks, no idea on how to do it (yet hopefully), but I will try ;)regards
seams that python bindings are already there?http://dev.zuckschwerdt.org/openobex/wiki/ObexFtpExampleClientPython
morphine schrieb:Cool, didn't find that.diez
Hello,thanks, this looks to be what I was looking for!regards
Why do people do this without posting what the actual solution is!!!!
Frank Swarbrick a écrit :Probably because those people think usenet is a free help desk ?
Bruno Desthuilliers skrev:Usenet definitely isn't a help desk. You often get useful answers fromusenet, from people who are not reading from a script.Nis
Bruno Desthuilliers skrev:Usenet definitely isn't a help desk. You often get useful answers fromusenet, from people who are not reading from a script.Nis
Bruno Desthuilliers skrev:Usenet definitely isn't a help desk. You often get useful answers fromusenet, from people who are not reading from a script.Nis
Bruno Desthuilliers skrev:Usenet definitely isn't a help desk. You often get useful answers fromusenet, from people who are not reading from a script.Nis
Hey, if we're expected to magically deduce what the problem iswithout being told an error messages, surely we can magicallydeduce the discovered solution too?
Quite so. Meanwhile the OP is killfiled so can't expect any help from me in the future.
I want to be able to access an excel file and extract the code fromthe macro that is in the file. How can I do this?
You should be able to use PythonWin and the makepy utility to gethandles to the Excel object. See the following article:http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.htmlI also found an article on how to use Python as the scripting languagein Excel:http://www.velocityreviews.com/forums/t319222-re-python-in-excel.htmlMike
This is a multi-part message in MIME format.--------------060502070608050102070102Content-Type: text/plain; charset=ISO-8859-1Content-Transfer-Encoding: 7bitIt would be good if you had showed the code that does that. It is hardfor us to guess what programming error you have made.As you won't show code, I will. Please try the attached cli.py andserver.py on your machine, and report the timing. On my machine, I get0.00105595588684 0.076632976532 8300000which means I can transmit 8.3MB in 76ms, which is a lot less than15s.My guess is that you sum up the incoming data with total_data += received_dataThat is O(n**2).Regards,Martin--------------060502070608050102070102Content-Type: text/x-python; name="cli.py"Content-Transfer-Encoding: 7bitContent-Disposition: inline; filename="cli.py"import socket,time,cStringIOt1 = time.time()s = socket.socket()s.connect(('localhost', 8989))t2 = time.time()storage = cStringIO.StringIO()while True:result = storage.getvalue()t3 = time.time()print t2-t1,t3-t2,len(result)--------------060502070608050102070102Content-Type: text/x-python; name="server.py"Content-Transfer-Encoding: 7bitContent-Disposition: inline; filename="server.py"import socketdata = ' '*8300000s = socket.socket()s.bind(('', 8989))s.listen(10)while True:--------------060502070608050102070102--
I would have put my code up if it were here but it is on my machine atwork which I can't touch until Monday. I know people tend to like tosee code when you're asking for help but it is not available to meright now so I apologize. You are right though, I believe I made themistake of using +=3D to sum the data up and I had never considered thefact that the runtime of that approach is O(n^2). I am willing to betthat this was my major shortcoming and you just solved my problem. Ibet the reason that jacking up the socket.recv size is because it tookfewer concatenations. I'll give an official report tomorrow on weatheror not that was the fix but I am very convinced that you got it andthat I won't have to step around the socket transmission.Thanks a lot Martin and also to the others who responded.
...So here's a tiny example to show that the mere transfer of bytes on thesocket should be taking nowhere like that long:#!/usr/local/bin/pythonimport socket, os, time, sysport = 8881sendsize = 1024recvsize = 1024totsize = 8*1024*sendsizedef server():def client():def main():recvsize)main()brain:~/downloads alex$ python sere.py moving 8388608 bytes (ss=1024, rs=1024)8388608 bytes in 0.08 sec (ss=1024, rs=1024)So, moving 8.3 MB on a bare socket should take about 100 milliseconds,give or take.So let's try WITH pickling and unpickling (done right):#!/usr/local/bin/pythonimport socket, os, time, sys, random, cPickleport = 8881sendsize = 1024recvsize = 1024data = [random.random() for i in xrange(1000*1000)]pickled_data = cPickle.dumps(data, 2)totsize = len(pickled_data)def server():def client():def main():recvsize)main()brain:~/downloads alex$ python sere.py moving 9002006 bytes (ss=1024, rs=1024)9002006 bytes in 0.32 sec (ss=1024, rs=1024)So, a bit more data, quite a bit longer, but still on the order ofmagnitude of 300 milliseconds or so.Again this suggests the problems are not "intrinsic" to the task.It's hard to guess at exactly what it may be that you're doing wrong.For example, if recvdata was a string (grown with +=) rather than a list(grown with append), this would boost the runtime to 0.76 seconds; ahuge waste (more than a factor of two blown away by a minor programminggaucheness) but still a long way from the several orders of magnitureyou're observing.So, I suggest you try programming the interaction directly to baresockets, as I do here (and in several examples in Chapter 20 in "Pythonin a Nutshell" 2nd edition), and see what difference that makes to yourtimings.Alex
Okay, Im back at work and got to put some of these suggestions to use.cPickle is doing a great job a hiking up the serialization rate andcutting out the +=data helped a lot too. The entire search process nowfor this same data set is down to about 4-5 seconds from pressing'search' to having the records posted to the browser. Only a fractionof a second is spent transmitting the data now. Some of the time isspent waiting for the sockets to actually make their connection. I'llbe now looking into FastCGI to see how much more time I can trim offthe total process.Once again I would like to say thanks to everyone for the help andtaking the time out to give me some example code to study. I'm gladthat what I thought I wanted to do is not necessary and that thesockets can send at the speed I hoped they could. This was my firstposting in this group and I plan to remain active and try to help outwhere I can. I am fully statisfied with the responses and consider myproblem solved.
I have found the stop-and-go between two processes on the same machineleads to very poor throughput. By stop-and-go, I mean the producer andconsumer are constantly getting on and off of the CPU since the pipegets full (or empty for consumer). Note that a producer can't run atits top speed as the scheduler will pull it out since it's output pipegot filled up.When you increased the underlying buffer, you mitigated a bit thisshuffling. And hence saw a slight increase in performance.My guess that you can transfer across machines at real high speed, isbecause there are no process swapping as producer and consumer run ondifferent CPUs (machines, actually).Since the two processes are on the same machine, try using a temporaryfile for IPC. This is not as efficient as real shared memory -- but itdoes avoid the IPC stop-n-go. The producer can generate the multi-megabyte file at one go and inform the consumer. The file-systems havegone thru' decades of performance tuning that this job is done reallyefficiently.Thanks,Karthik
http://kokonis.aygoystinos.googlepages.com/http://theologos.kokkonis.googlepages.com/
This is a python script which is fired off from a batchfile pre-commit.bat on Windows2000 server.Everything I've read says that it should work & each part does workwhen tested individually.But when it runs within subversion this statement always ends withthis log_msg being an empty string.log_msg = os.popen(log_cmd, 'r').readline().rstrip('\n')Help. :-)rem pre-commit.batc:\python23\python c:\repository\hooks\check-comments.py %1 %2if errorlevel 1 goto :ERRORexit 0:ERRORecho Error found in commit 1>&2exit 1#check-comments.pyimport sys, os, string, reSVNLOOK='c:\\subversion\\bin\\svnlook.exe'# return true or false if this passed string is a valid commentdef check(comment):def result(r): if r == 1:Comment text' where X is the issue number.") sys.exit(r)def main(repos, txn):if __name__ == '__main__':
Hi,I did something similar already in wxPython, but not yet in PyGTK.Therefore I cannot provide the actual solution... Since noone answered, I will still give you a hint :http://www.pygtk.org/pygtk2tutorial/sec-TreeModelInterface.htmlSee 14.2.9. Sorting TreeModel Rows andset_sort_func(sort_column_id, sort_func, user_data=None)Good luck!Janpsaroudakis a écrit , le 27.06.2007 16:28:
Hi,Can someone explain what a broken pipe is? The following produces abroken pipe error:----------import subprocess as subp = sub.Popen(["ls", "-al", "../"], stdin=sub.PIPE, stdout=sub.PIPE)print p.stdout.read()#outputs the files correctlyp.stdin.write("ls\n")#IOError: [Errno 32] Broken pipe-----------
You are seeing this error because sub.Popen closes both stdin andstdout once the subprocess terminates (which it must have done forp.stdout.read() to return a result).Consequently you are trying to write to a pipeline whose reader hasalready closed it, hence the error message.regards Steve
Hi,Thanks for the response. So are you saying that the only way you canget data out of a pipe is when the subprocess has terminated?
Why doesn't the following program write to the file?driver.py
I suppose your running child process isn't closed cleanly if youterminate the parent process. Also, the pipe may be unbuffered bydefault; file access isn't.Regards,Björn
On Jul 2, 1:58 pm, Bjoern Schliessmann On Jul 2, 2:03 pm, Bjoern Schliessmann Let me ask you a question: what conditions have to be true to this statement to terminate?A: the Python driver.py process has to close its output file. Since it doesn't do this (instead writing a little bit of output then going into an infinite loop) the whole thing just sits there consuming CPU time.Who told you pipes should be unbuffered by default, and what difference does that make anyway?The reason it works now is that your program closes its standard output by default when it terminates.Of course it does, for the reasons mentioned above. file.read() only returns when it has consumed *all* the data from the file (which means the write must close the file for the reader to be able to return).regards Steve So let me see if I have this right:Here is some code: Hi,Thanks for the detailed response.Is that the same as print calling encode(u_str, sys.stdout.encoding) ooops. I mean is that the same as print callingu_str.encode(sys.stdout.encoding)? Almost. It's ratheru_str.encode(sys.stdout.encoding or sys.getdefaultencoding())(in case sys.stdout.encoding isn't set)Regards,Martin HelloHow i can use to connect to a unify els database with pythonRegardsLuca * Maric Michaud On 2 juil, 05:04, "O.R.Senthil Kumaran"Yes, I realize this too, I think this should be considered as a bug inthe documentation.Didn't find one when i made a quick search, but i would suggest tosubmit a documentation bug.BTW, I find this recipe on python cookbook,http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/456195,works fine for me (with the two additionals comments in my case). Wecould add a pointer to this in the doc before fixing urllib2.What would you suggest ? I downloaded Python 5.1 for windows so I could run a program.I have to do the following:In PythonWin, select Tools | COM MakePy utility | Microsoft SpeechObject Library 5.1).I can't find PythonWin .. Does anybody know what this is. I have thePython shell gui but no "PythonWin".THanks. * steveandleyla@gmail.com In article On Sun, 01 Jul 2007 15:53:30 -0700, steveandleyla@gmail.com declaimedthe following in comp.lang.python:like 2.5.x...Python. It is a separate download -- unless you downloaded theActiveState Windows build of Python. The ActiveState build includes thewin32 libraries and "PythonWin" (but lacks a few of the, otherwisestandard, encryption stuff -- which can be copied from a comparable[version-wise] python.org release).unicode
unify els database
urllib2 : https and proxy
what is the PythonWin
needgod.com