Testing changes to Python code on the fly: reload() + alternatives?
Hi all, I have a couple of questions that I was hoping people might be able to provide suggestions on. 1) Is it possible to reload a class using the reload() method? For instance, suppose you have the following files: my_module/ __init__.py MyClass.py #init.py from MyClass import MyClass #MyClass.py class MyClass: def __init__(self): print("Before...") Is it possible to load the class, change the print statement (e.g. print("after...")), and have the changes take effect right away? The above method does not work: In [1]: import my_module In [2]: my_module.MyClass() Before... Out[2]: In [3]: reload(my_module) Out[3]: In [4]: my_module.MyClass() Before... Out[4]: Is there anyway to make this work while keeping MyClass in the main "my_module" namespace? 2) More generally though, what is the best way to go about testing changes to code as you are writing it? It would be very convenient to be able to use reload() along the lines of the above so that I could test changes to a small part of some class/function/etc without having to reload the entire state from scratch. Another option of course would be to just run everything as a standalone script, but then you lose the ability to be able to easily inspect the objects you are working and change them on the fly, except perhaps by using PDB. Any suggestions would be greatly appreciated. Thanks! Keith -- http://mail.python.org/mailman/listinfo/python-list
PHP Embedded In Python
I am a python and php newbie. Newbie is even pushing it. I need to take the contents of my_cgi.py and evaluate it with the php_module. Is this possible. I think that pyPHP goes the other way. The only reason I need this is because the header that all the html pages use on our website uses a php include and I really don't want to rewrite all the php in python. Thanks, Keith -- http://mail.python.org/mailman/listinfo/python-list
Re: PHP Embedded In Python
jdonnell wrote: > I'm not sure exactly what your trying to do, but I use php and python > together a lot. I usually call the python script from php with the > passthru function like this: > > $outputFromPy = passthru('/path/to/myScript.py'); > ?> I need to go the other direction. I need to call php from within python. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: PHP Embedded In Python
> Well it depends on how php is installed. Is it a linux system? Do you > know how to run a php script from the command line? I'm running on Fedora Core 3. To run php command line I just ran: % php It spit something back at me. Maybe I should lay out what I am doing a little more. I have a website. At the top of each html page in the website it looks like: -- HTML CODE --- In "header.html" it looks like: --- ... HTML CODE FOR LOGO, COMMON MENU ETC... --- As the story goes... I decided to put a Wiki on the website. I got MoinMoin which is a Python based Wiki. It's really cool. MoinMoin uses a python cgi to generate html pages. MoinMoin configuration allows you to put an optional header and footer for each displayed page. Straight html works fine; however, my "header.html" and "footer.html" do not with the embedded php. The resulting python generated pages have the literal string . Maybe the answer is still to use the os call. Thanks for your help. My little brush with the Python community gives me the feeling that you guys are friendly. It's nice. -- http://mail.python.org/mailman/listinfo/python-list
Version Number Comparison Function
Is there a function for comparing version numbers? E.g. 0.1.0 < 0.1.2 1.876b < 1.876c 3.2.2 < 3.4 Keith -- http://mail.python.org/mailman/listinfo/python-list
Re: Version Number Comparison Function
I can't assume there are the same number of '.'s or there are the same number of digits per version. I don't know how the tuple comparison works offhand. But that seems like it would work if you split it. The suggestion with the "re" module seems generic enough and looks like it will work as is. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Version Number Comparison Function
distutils is one of the places I looked: http://www.python.org/doc/2.3.5/lib/module-distutils.html But I didn't see the functions documented. I am new to Python so I didn't know where else to look. Using distutils seems like it would be the most generic and supported way to compare version numbers. -- http://mail.python.org/mailman/listinfo/python-list
A Question About Handling SIGINT With Threads
I got this to work, but was hoping there was a better way. I was hoping that I wouldn't have to use globals. I wouldn't doubt that I could be totally off in what I am doing. Here is some psuedo-code of what I did: def main_thread(): # Don't know how to get rid of these guys global lock global my_thread # Set up a signal handler for Ctrl-C signal.signal(signal.SIGINT, sighdlr) # Create & start thread lock = thread.allocate_lock() lock.acquire() my_thread = threading.Thread( target=child_thread, name='thread_test', args=(lock,) my_thread.start() do_some_work_here() # Tell thread to stop working lock.release() # Wait for child thread to finish my_thread.join() def child_thread(lock): while lock.locked(): do_some_stuff() do_some_cleanup() def sighdlr(signum, frame): # Allow child to finish lock.release() my_thread.join() sys.exit(1) -- http://mail.python.org/mailman/listinfo/python-list
class return another instance
Hello All, Here is simplified version of what I’m trying to do: IDs = {} class ID: def __init__(self, id): if id in IDs: self = IDs[id] else: IDs[id] = self foo = ID(1) bar = ID(2) copy = ID(1) print "foo: " + str(foo) + " with ID of 1" print "bar: " + str(bar) + " with ID of 2" print "copy: " + str(copy) + " should be a copy of foo" print "IDs: " + str(IDs) What I’m after is if you call the class ID… it checks to is if the “id” is in the dictionary IDs… if so then use that class instance… else put self into the dictionary as a new key-value, so if you try and create it again… it will use that instance… Also I know its easy enough to do copy = foo… but I would like the class to determine this for me… any ideas? There has got to be a way to replace self with another instance… or return something from the init statement… Here’s what it returns: foo: <__main__.ID instance at 0x01DE6CB0> with ID of 1 bar: <__main__.ID instance at 0x01DE6CD8> with ID of 2 copy: <__main__.ID instance at 0x01DE6D00> should be a copy of foo IDs: {1: <__main__.ID instance at 0x01DE6CB0>, 2: <__main__.ID instance at 0x01DE6CD8>} What I would expect/want: foo: <__main__.ID instance at 0x01DE6CB0> with ID of 1 bar: <__main__.ID instance at 0x01DE6CD8> with ID of 2 copy: <__main__.ID instance at *0x01DE6CB0*> should be a copy of foo IDs: {1: <__main__.ID instance at 0x01DE6CB0>, 2: <__main__.ID instance at 0x01DE6CD8>} Any help would be great. Cheers, Keith -- http://mail.python.org/mailman/listinfo/python-list
Issues installing MySQL-python-0.3.5
Hi, I am trying to use the Python MySQL APIs and have been attempting to install the above software. I am using MySQL 5.0.18-standard with Python 2.4.1 I get errors on the build. Some searching showed that one of the modules I was having issues with now has less arguments in my version of python, but I can't seem to fix the following error: *** _mysqlmodule.c: In function _mysql_ConnectionObject_shutdown: _mysqlmodule.c:1019: error: too few arguments to function mysql_shutdown *** Should I just give up on MySQL-python-0.3.5 ? Is there a more up to date API I should install for using with my current versions of Python and MySQL? Any help appreciated! Keith -- http://mail.python.org/mailman/listinfo/python-list
MySQLdb compile error with AMD64
Hi, I have been using MySQLdb on a 32-bit processor, no worries. Love it. I went to install on an AMD64 running the 64-bit version of SUSE 10.0. I get the following error during the "python setup.py build" gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -fPIC -I/usr/include/mysql -I/usr/include/python2.4 -c _mysql.c -o build/temp.linux-x86_64-2.4/_mysql.o -I/usr/include/mysql -g -march=i586 -mcpu=i686 -fmessage-length=0 `-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead. _mysql.c:1: error: CPU you selected does not support x86-64 instruction set _mysql.c:1: error: CPU you selected does not support x86-64 instruction set error: command 'gcc' failed with exit status 1 Any ideas on what I have to do to make this work? Any help appreciated! Cheers Keith -- http://mail.python.org/mailman/listinfo/python-list
RE: MySQLdb compile error with AMD64
Can anyone offer any assistance on this one? Is it unsupported on AMD64 ? Nothing in the README points to that. I thought it would default to 32bit if not supported under 64. > > Hi, > > I have been using MySQLdb on a 32-bit processor, no worries. Love it. > > I went to install on an AMD64 running the 64-bit version of SUSE 10.0. > > I get the following error during the "python setup.py build" > > gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -fmessage-length=0 -Wall > -D_FORTIFY_SOURCE=2 -g -fPIC -I/usr/include/mysql > -I/usr/include/python2.4 -c _mysql.c -o > build/temp.linux-x86_64-2.4/_mysql.o -I/usr/include/mysql -g > -march=i586 -mcpu=i686 -fmessage-length=0 > `-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead. > _mysql.c:1: error: CPU you selected does not support x86-64 instruction > set > _mysql.c:1: error: CPU you selected does not support x86-64 instruction > set > error: command 'gcc' failed with exit status 1 > > Any ideas on what I have to do to make this work? > > Any help appreciated! > > Cheers > Keith -- http://mail.python.org/mailman/listinfo/python-list
"struct" module problem w/ pyinstaller
Hello, I am trying to create exectuables on inux using "pyinstaller". I am using pyinstaller-1.3, RHEL 4.4, Python 2.5. The executables fail to run. The problem returned is pertaining to "struct.py" not being able to find the module "_struct". struct.py is located under /usr/local/lib/python-2.5/, and there is a _struct.o (no _struct.py anywhere) located under /usr/local/lib/ python-2.5/lib-dynload. When trying to run the executable, the loader returns: File "/usr/local/lib/python2.5/struct.py", line 30, in ImportError: No module named _struct The line in question is: from _struct import Struct, error I am a python neophyte. If someone could give me some information, I would appreciate it. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Safe to get address of va_list function parameter?
Is it safe to get the address of a va_list function parameter? Keith -- http://mail.python.org/mailman/listinfo/python-list
Re: Determining when a file has finished copying
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ethan Furman wrote: > writeson wrote: >> Guys, >> >> Thanks for your replies, they are helpful. I should have included in >> my initial question that I don't have as much control over the program >> that writes (pgm-W) as I'd like. Otherwise, the write to a different >> filename and then rename solution would work great. There's no way to >> tell from the os.stat() methods to tell when the file is finished >> being copied? I ran some test programs, one of which continously >> copies big files from one directory to another, and another that >> continously does a glob.glob("*.pdf") on those files and looks at the >> st_atime and st_mtime parts of the return value of os.stat(filename). >>> From that experiment it looks like st_atime and st_mtime equal each >> other until the file has finished being copied. Nothing in the >> documentation about st_atime or st_mtime leads me to think this is >> true, it's just my observations about the two test programs I've >> described. >> >> Any thoughts? Thanks! >> Doug > > The solution my team has used is to monitor the file size. If the file > has stopped growing for x amount of time (we use 45 seconds) the file is > done copying. Not elegant, but it works. > -- > Ethan Also I think that matching the md5sums may work. Just set up so that it checks the copy's md5sum every couple of seconds (or whatever time interval you want) and matches against the original's. When they match copying's done. I haven't actually tried this but think it may work. Any more experienced programmers out there let me know if this is unworkable please. K -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIdVkX8vmNfzrLpqoRAsJ2AKCp8wMz93Vz8y9K+MDSP33kH/WHngCgl/wM qTFBfyIEGhu/dNSQzeRrwYQ= =Xvjq -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Cross Module Command Useage
Ok so I’m new to the python programming language… and this is my first post to this mailing list… so here it is… So lets say have two modules.. moduleA and moduleB… they are both imported into a main python program using the “from module import *” command… now moduleA has a dynamic command that needs to access a command that is in moduleB… but when I run these modules from the main python scrip they cant see each other…. it gives me an error that the command does not exist… Dose this mean that I need to import moduleB into moduleA for it to see it… or is there a way that I can tell moduleA too look out to the main python program for the commands… I would hate to have to import lets say the “socket“ module into every module rather than just having it look to the main module for the commands… -- http://mail.python.org/mailman/listinfo/python-list
Engineering numerical format PEP discussion
I am considering writing a PEP for the inclusion of an engineering format specifier, and would appreciate input from others. Background (for those who don't already know about engineering notation): Engineering notation (EN) is type of floating point representation. The idea with EN is that the powers of 10 are all multiples of 3, which correspond to the familiar Greek unit prefixes that engineers use when describing the different sizes of all sorts of real-world devices and phenomena: 1e-12 == pico 1e-9 == nano 1e-6 == micro 1e-3 == milli 1e+3 == kilo 1e+6 == mega 1e+9 == giga When people are talking about Ohms, Farads, Henries, Hz, and many others, they routinely have to normalize to EN. Fancy calculators from HP and TI routinely allow the users to go into engineering mode, but mysteriously things like C, Python, Excel, etc. don't For instance, no one talks about 4.7e-5F, as they would rather see 47e-6 (micro). Instead of 2.2e-2, engineers need to see 22.0e-3 (milli). Originally to address this issue, I wrote for myself an "EFloat" class that subclassed float: import math class EFloat(float): """EFloat(x) -> floating point number with engineering representation when printed Convert a string or a number to a floating point number, if possible. When asked to render itself for printing (via str() or print) it is normalized to engineering style notation at powers of 10 in multiples of 3 (for micro, milli, kilo, mega, giga, etc.) """ def __init__(self, value=0.0, prec=12): super(EFloat, self).__init__(value) self.precision = prec def _get_precision(self): return self._precision def _set_precision(self, p): self._precision = p self.format_string = "%3." + ("%d" % self._precision) + "fe% +d" return precision = property(_get_precision, _set_precision, doc="The number of decimal places printed") def _exponent(self): if self == 0.0: ret = 0 else: ret = math.floor(math.log10(abs(self))) return ret def _mantissa(self): return self/math.pow(10, self._exponent()) def _asEng(self): shift = self._exponent() % 3 retval = self.format_string % (self._mantissa()*math.pow(10, shift), self._exponent() - shift) return retval def __str__(self): return self._asEng() def __repr__(self): return str(self) def __add__(self, x): return EFloat(float.__add__(self, float(x))) def __radd__(self, x): return EFloat(float.__add__(self, float(x))) def __mul__(self, x): return EFloat(float.__mul__(self, float(x))) def __rmul__(self, x): return EFloat(float.__mul__(self, float(x))) def __sub__(self, x): return EFloat(float.__sub__(self, float(x))) def __rsub__(self, x): return EFloat(float.__rsub__(self, float(x))) def __div__(self, x): return EFloat(float.__div__(self, float(x))) def __rdiv__(self, x): return EFloat(float.__rdiv__(self, float(x))) def __truediv__(self, x): return EFloat(float.__truediv__(self, float(x))) def __rtruediv__(self, x): return EFloat(float.__rtruediv__(self, float(x))) def __pow__(self, x): return EFloat(float.__pow__(self, float(x))) def __rpow__(self, x): return EFloat(float.__rpow__(self, float(x))) def __divmod__(self, x): return EFloat(float.__divmod__(self, float(x))) def __neg__(self): return EFloat(float.__neg__(self)) def __floordiv__(self, x): return EFloat(float.__floordiv__(self, float(x))) which works well for working with interactive Python. There are places on the web where I've read that people have to work their butts off trying to "trick" Excel or OpenOffice to do engineering notation, or there is some work-around that is purported to work if you use the right version of the spreadsheet. After many months of using my EFloat class extensively with lots of apps dealing with embedded engineering tasks, it dawns on me that what we really need is simply a new format specifier. I am thinking that if we simply added something like %n (for eNgineer) to the list of format specifiers that we could make life easier for engineers: ("%n" % 12345) == "12.345e+03" ("%n" % 1234) == "1.234e+03" ("%n" % 123) == "123e+00" ("%n" % 1.2345e-5) == "12.345e+06" Of course, the normal dot fields would be put to use to allow us to specify how many total digits or digits of precision we wanted, or if we want zero prepend. (whatever makes the most sense, and keeps the standard most like what is already in the language): ("%.12n" % 12345678) == "12.34567800e+06" Do you think this idea has enough merit to make it to PEP status? --Keith Brafford -- http://mail.python.org/mailman/listinfo/python-list
Re: Engineering numerical format PEP discussion
On Apr 26, 12:02 am, Chris Rebert wrote: > On Sun, Apr 25, 2010 at 8:36 PM, Keith wrote: > > I am considering writing a PEP for the inclusion of an engineering > > format specifier, and would appreciate input from others. snip > Relevant related information: > The Decimal datatype supports engineering format > directly:http://docs.python.org/library/decimal.html#decimal.Decimal.to_eng_st... > > Cheers, > Chris Thanks for pointing that out. Does the engineering community get by with the decimal module? Even though this uses the to_eng_string() function, and even though I am using the decimal.Context class: >>> c = decimal.Context(prec=5) >>> decimal.Decimal(1234567).to_eng_string(c) '1234567' That is not an engineering notation string. --Keith Brafford -- http://mail.python.org/mailman/listinfo/python-list
Re: Engineering numerical format PEP discussion
On Apr 26, 12:29 am, Steven D'Aprano wrote: > On Sun, 25 Apr 2010 20:36:22 -0700, Keith wrote: >>no one talks about 4.7e-5F, as they would rather see 47e-6 >>(micro). Instead of 2.2e-2, engineers need to see 22.0e-3 (milli). >I'd be cautious about making claims about "no one" Good point, and I don't intend to belittle scientific computing folks for whom traditional floating point representation is expected. Nor am I suggesting that any of the six format specifiers that we already have for scientific notation (e, E, f, F, g, G) be altered in any way. I guess I wasn't clear about the F in the 4.7e-5F in the example. People doing engineering don't use 4.7e-5 Farads. They typically have to do extra work to get that number to print out correctly, as 47 e-6 Farads. The same goes for lots of signal processing entities. People doing things with Hz, seconds, you name it, have the same problem. --Keith -- http://mail.python.org/mailman/listinfo/python-list
Re: Engineering numerical format PEP discussion
On Apr 26, 1:19 am, Chris Rebert wrote: > Apparently either you and the General Decimal Arithmetic spec differ > on what constitutes engineering notation, there's a bug in the Python > decimal library, or you're hitting some obscure part of the spec's > definition. snip > The spec:http://speleotrove.com/decimal/decarith.pdf > (to-engineering-string is on page 20 if you're interested) Thanks for that. I didn't realize that Mike Cowlishaw wrote the spec we're discussing. It's too bad OS/2 didn't fare better, or we'd possibly be discussing a proposal for a REP (Rexx Enhancement Proposal) ;-) >From that document it appears that my decimal.Decimal(1234567) example shows that the module has a bug: Doc says: [0,123,3] ===> "123E+3" But Python does: >>> import decimal >>> decimal.Decimal(123000).to_eng_string() '123000' Regardless, given that the whole point of format specifiers (whether they are the traditional python 2.x/C style %[whatever] strings, or the new format() function) is to make it easy for you to format numbers for printing, wouldn't the language be better off if we added engineering notation to the features that already offer scientific notation? --Keith Brafford -- http://mail.python.org/mailman/listinfo/python-list
Re: Engineering numerical format PEP discussion
>Apparently either you and the General Decimal Arithmetic spec differ >on what constitutes engineering notation, there's a bug in the Python >decimal library, You've distilled it precisely, and as you've shown in a different post, it's the former. The Python decimal module seems to implement correctly Mike Cowlishaw's spec, but what that spec refers to as "engineering notation" isn't really what engineers actually use. That is, even with decimal.Decimal.to_eng_string(), engineers still end up having to write their own string formatting code. I think it's worth making the print statement (or print function, as the case may be) let us do engineering notation, just like it lets us specify scientific notation. --Keith Brafford -- http://mail.python.org/mailman/listinfo/python-list
Re: Engineering numerical format PEP discussion
On Apr 26, 5:33 am, Stefan Krah wrote: > Keith wrote: > > Even though this uses the to_eng_string() function, and even though I > > am using the decimal.Context class: > > > >>> c = decimal.Context(prec=5) > > >>> decimal.Decimal(1234567).to_eng_string(c) > > '1234567' > > > That is not an engineering notation string. > > To clarify further: The spec says that the printing functions are not > context sensitive, so to_eng_string does not *apply* the context. > > The context is only passed in for the 'capitals' value, which determines > whether the exponent letter is printed in lower or upper case. > > This is one of the unfortunate situations where passing a context can > create great confusion for the user. Another one is: > > >>> c = Context(prec=5) > >>> Decimal(12345678, c) > > Decimal('12345678') > > Here the context is passed only for the 'flags' and 'traps' members: > > >>> Decimal("wrong", c) > > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python3.2/decimal.py", line 548, in __new__ > "Invalid literal for Decimal: %r" % value) > File "/usr/lib/python3.2/decimal.py", line 3836, in _raise_error > raise error(explanation) > decimal.InvalidOperation: Invalid literal for Decimal: 'wrong' > > >>>c.traps[InvalidOperation] = False > >>> Decimal("wrong", c) > > Decimal('NaN') > > Stefan Krah Thank you for that illustrative clarification, Stefan. I should not have used decimal.Context in that case, nor should I have implied that it would have helped prove my case. --Keith Brafford -- http://mail.python.org/mailman/listinfo/python-list
Re: Engineering numerical format PEP discussion
On Apr 26, 7:56 pm, Mark Dickinson wrote: > On Apr 26, 6:47 am, Keith wrote: > > > From that document it appears that my decimal.Decimal(1234567) example > > shows that the module has a bug: > > > Doc says: > > [0,123,3] ===> "123E+3" > > > But Python does:>>> import decimal > > >>> decimal.Decimal(123000).to_eng_string() > > > '123000' > > That's not a bug. The triple [0,123,3] is Decimal('123e3'), which is > not the same thing as Decimal('123000'). The former has an exponent > of 3 (in the language of the specification), while the latter has an > exponent of 0. > > >>> decimal.Decimal('123e3').to_eng_string() > > '123E+3' > > -- > Mark Thanks, Mark, you're right. It's clear that Decimal.to_eng_string() doesn't solve the problem that I am trying to solve, which is: take the Python "float" type, and print it in engineering format. --Keith Brafford -- http://mail.python.org/mailman/listinfo/python-list
Re: Engineering numerical format PEP discussion
On Apr 26, 8:47 pm, MRAB wrote: > "t" for "powers of a thousand", perhaps? (Or "m"?) Both of those letters are fine. I kinda like "m" for the whole Greco- Roman angle, now that you point it out :-) --Keith Brafford -- http://mail.python.org/mailman/listinfo/python-list
Re: Engineering numerical format PEP discussion
On Apr 27, 9:03 am, Mark Dickinson wrote: > On Apr 27, 2:16 am, Keith wrote: > > > On Apr 26, 8:47 pm, MRAB wrote: > > > > "t" for "powers of a thousand", perhaps? (Or "m"?) > > > Both of those letters are fine. I kinda like "m" for the whole Greco- > > Roman angle, now that you point it out :-) > > By the way, there's already a feature request open for this: > > http://bugs.python.org/issue8060 > > That might be a good place to hash out the precise semantics. If you > could provide unit tests and/or an implementation that would likely > help move the issue along. > > Mark Oh nice! I don't know how I missed that. --Keith Brafford -- http://mail.python.org/mailman/listinfo/python-list
Re: xlrd 0.7.6 released!
Karim wrote in news:mailman.1309.1333529851.3037.python-l...@python.org: > This release manage the '.xlsx' format? http://packages.python.org/openpyxl/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Cannot connect to IMAP server in Python 3.2
Steve Howell wrote in news:ae774035-9db0-469d-aa2a- 02f2d25ff...@qg3g2000pbc.googlegroups.com: > Once you are able to import ssl, you should be able to use IMAP4_SSL, > but that still doesn't entirely explain to me why you got a timeout > error with plain IMAP4 and the proper port. (I would have expected a > failure, but of a different kind.) Connecting to the SSL socket requires that one initiate the TLS handshake forthwith. Establishing a connection to an "I expect SSL from the get- go" using a protocol that speaks "I am a normal unencrypted socket but you can initiate TLS using the starttls command" is not the same thing. In other words, you are violating the requirements of the protocol, and you are timing out. This is because the first protocol step in a standard connection is to wait for the plain-text greeting, where the first step in connecting to the SSL socket is to do a TLS dance, then initiate the IMAP protocol by sending the greeting. If you connect with a non-SSL initiator to an SSL endpoint, you will get a timeout. If you connect with an SSL initiator to a non-SSL endpoint, you will timeout. It is not the connection that is timing out, it is the protocol. > I'd still be curious to see what happens when you try this: > >import socket, imaplib >your_host_name = # ... >socket.create_connection((your_host_name, imaplib.IMAP4_SSL_PORT)) This will, of course, work just fine. You will not see a +Hello however until you have completed the TLS negotiation. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pass a list of variables to a procedure
Thank you, Chris! Sent from my iPhone On Apr 7, 2012, at 3:24 PM, Chris Rebert wrote: > On Sat, Apr 7, 2012 at 2:15 PM, KRB wrote: >> Hi there, >> >> I would like to be able to pass a list of variables to a procedure, and have >> the output assigned to them. > > You cannot pass a variable itself to a function; you can only pass a > variable's value. Which is to say that Python doesn't use > pass-by-reference. > Without using black magic, a Python function cannot rebind variables > in its caller's scope. Mutable values can be mutated however. > Details: http://effbot.org/zone/call-by-object.htm > >> For instance: >> >> x=0 >> y=0 >> z=0 >> >> vars =[x,y,z] >> parameters=[1,2,3] >> >> for i in range(1,len(vars)): >> *** somefunction that takes the parameter "1", does a computation and >> assigns the output to "x", and so on and so forth. >> >> Such that later in the program I can >> print x,y,z >> >> I hope that makes sense, otherwise I have to do: >> x=somefunction(1) >> y=somefunction(2) >> z=somefunction(3) >> etc etc > > Just use sequence (un)packing: > > def somefunction(*parameters): ># one would normally use a list comprehension here; ># for simplicity, I'm not >results = [] >for parameter in parameters: >result = do_some_calculation(parameter) >results.append(result) >return results > > #…later... > x, y, z = somefunction(1, 2, 3) > > > Relevant docs: > http://docs.python.org/tutorial/datastructures.html#tuples-and-sequences > http://docs.python.org/tutorial/controlflow.html#tut-unpacking-arguments > > Cheers, > Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Abandoning Python
Have you looked at Falcon (http://www.falconpl.org/)? It seems to have a lot of what you are looking for. I do not have much experience with it but I like what I've seen so far, except that there are not any third party tools or libraries libraries. Which is where Python shines. -EdK Ed Keith e_...@yahoo.com Blog: edkeith.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Kind of OT - Books on software development?
I do not have my library with me, but I remember a book that fits the bill exactly, is was from Microsoft Press, I think it was called "Writing Solid Code" Hope this helps, -EdK Ed Keith e_...@yahoo.com Blog: edkeith.blogspot.com --- On Wed, 5/25/11, Matty Sarro wrote: > From: Matty Sarro > Subject: Kind of OT - Books on software development? > To: "Python list" > Date: Wednesday, May 25, 2011, 11:40 AM > Hey everyone, > I am looking at some projects coming up, which may or may > not involve > python. So I figured I would throw the question out there > and see what > everyone thinks. > I am looking for some books on software > engineering/development... > something that discusses techniques from ideation, up > through testing, > QA, production, and then maintenance. Is there such a > book? > -Matthew > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Kind of OT - Books on software development?
--- On Wed, 5/25/11, Ed Keith wrote: > I do not have my library with me, but > I remember a book that fits the bill exactly, is was from > Microsoft Press, I think it was called "Writing Solid Code" I have done some research at amazon.com, and while "Writing Solid Code" is an excellent book that I would also recommend highly, the book I was thinking of was "Code Complete". -EdK Ed Keith e_...@yahoo.com Blog: edkeith.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: What should go to stdout/stderr and why Python logging write everything to stderr?
MRAB writes: [...] > The purpose of stderr is to display status messages, logging and error > messages, even user prompts, and not mess up the program's actual > output. This is important on a *nix system where you might be piping > the output of one program into the input of another. I would expect user prompts to be written to stdout, or perhaps to some system-specific stream like the current tty, not to stderr. If a program has user prompts, it probably doesn't make sense to pipe its output to the input of another. -- Keith Thompson (The_Other_Keith) keith.s.thompso...@gmail.com Working, but not speaking, for XCOM Labs void Void(void) { Void(); } /* The recursive call of the void */ -- https://mail.python.org/mailman/listinfo/python-list
Re: hello can I be in your group?
September Skeen writes: > I was wondering if I could be in your group This is an unmoderated Usenet newsgroup. It doesn't have members, just people who post to it. If you want to discuss Python, just post. (Take a look around first to get an idea how how thinks work.) If you see a response from "Manosh Manosh", I recommend ignoring it. He appears to be a spammer. -- Keith Thompson (The_Other_Keith) keith.s.thompso...@gmail.com Working, but not speaking, for XCOM Labs void Void(void) { Void(); } /* The recursive call of the void */ -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.10 Fizzbuzz
Greg Ewing writes: > On 2/03/23 10:59 am, gene heskett wrote: >> Human skin always has the same color > > Um... no? You took that out of context. The assertion was that "Human skin always has the same color" and "the difference is not the color, but the brightness". I offer no opinion on whether that's accurate. -- Keith Thompson (The_Other_Keith) keith.s.thompso...@gmail.com Working, but not speaking, for XCOM Labs void Void(void) { Void(); } /* The recursive call of the void */ -- https://mail.python.org/mailman/listinfo/python-list
Re: =- and -= snag
"Morten W. Petersen" writes: > I was working in Python today, and sat there scratching my head as the > numbers for calculations didn't add up. It went into negative numbers, > when that shouldn't have been possible. > > Turns out I had a very small typo, I had =- instead of -=. > > Isn't it unpythonic to be able to make a mistake like that? Very early versions of C (around 1975 or so, before K&R1 was published) actually used "op=" for compound assignment operators, so `x =- 2` would subtract 2 from x. It was changed to "=op" (`x -= 2`) precisely to avoid this ambiguity that programmers kept running into (people were less generous with whitespace back then). As late as the late 1990s, I used a compiler (VAXC) that still recognized the old-style compound assignment operators, though I think it warned about them. I thought "Pythonic" was more about how you write code than about the design of the language. But designing a language syntax so typos are likely to be syntax errors rather than valid code with different semantics is an interesting challenge. -- Keith Thompson (The_Other_Keith) keith.s.thompso...@gmail.com Working, but not speaking, for XCOM Labs void Void(void) { Void(); } /* The recursive call of the void */ -- https://mail.python.org/mailman/listinfo/python-list
Re: Hide my query about covariance matrix syntax from google
Chris Angelico writes: > On Fri, 14 Apr 2023 at 03:11, Meghna Karkera wrote: >> >> Respected Sir >> >> I kindly request you to hide my query about covariance matrix syntax from >> google which was emailed to you a few years back as it appears on google >> page. >> >> Hoping that you do the needful. > > These posts are public. While it's possible to ask for something to be > removed from the official python-list archive, that won't remove it > from Google Groups or any other third-party archive. > > Also, there's nothing we can do here to remove your post; you'll have > to contact the list admins. > > And just in case it's of interest to you: > https://en.wikipedia.org/wiki/Streisand_effect It's also mirrored to Usenet (comp.lang.python). There's basically no way to delete articles from Usenet. (The protocol includes a command to cancel an article, but servers ignore it due to past abuse.) -- Keith Thompson (The_Other_Keith) keith.s.thompso...@gmail.com Working, but not speaking, for XCOM Labs void Void(void) { Void(); } /* The recursive call of the void */ -- https://mail.python.org/mailman/listinfo/python-list
Re: What do these '=?utf-8?' sequences mean in python?
Chris Green writes: > Chris Green wrote: >> I'm having a real hard time trying to do anything to a string (?) >> returned by mailbox.MaildirMessage.get(). >> > What a twit I am :-) > > Strings are immutable, I have to do:- > > newstring = oldstring.replace("_", " ") > > Job done! Not necessarily. The subject in the original article was: =?utf-8?Q?aka_Marne_=C3=A0_la_Sa=C3=B4ne_(Waterways_Continental_Europe)?= That's some kind of MIME encoding. Just replacing underscores by spaces won't necessarily give you anything meaningful. (What if there are actual underscores in the original subject line?) You should probably apply some kind of MIME-specific decoding. (I don't have a specific suggestion for how to do that.) -- Keith Thompson (The_Other_Keith) keith.s.thompso...@gmail.com Working, but not speaking, for XCOM Labs void Void(void) { Void(); } /* The recursive call of the void */ -- https://mail.python.org/mailman/listinfo/python-list
Re: What to use instead of nntplib?
Grant Edwards writes: > On 2023-05-21, Retrograde wrote: >> Who ever came up with "Removing dead batteries" as a slogan, when >> some of those batteries still work perfectly well, needs to rethink >> it. Go ahead and remove code that no longer works, OK. But removing >> unpopular modules? That undercuts the entire philosophy of the >> platform, in my opinion. > > And one of the metrics of "popularity" seems to be "activity" > (e.g. changes committed). For things that have been around for 20+ > years and have all the features they need and all of the bugs fixed > (and are now very stable) that lack of "activity" is interpreted as > "unpopular" regardless of how many people are using the module. My understanding is that nntplib isn't being erased from reality, it's merely being removed from the set of modules that are provided by default. I presume that once it's removed from the core, it will still be possible to install it via pip or some other mechanism. You can disable the deprecation warning: import warnings warnings.filterwarnings("ignore", category=DeprecationWarning) import nntplib If my understanding is correct, why is this such a big problem? -- Keith Thompson (The_Other_Keith) keith.s.thompso...@gmail.com Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */ -- https://mail.python.org/mailman/listinfo/python-list
Re: Invalid literal for int() with base 10?
"Kevin M. Wilson" writes: > Ok, I'm not finding any info. on the int() for converting a str to an > int (that specifies a base parameter)?! https://docs.python.org/3/library/functions.html#int > The picture is of the code I've written... I don't see a picture. The mailing list probably does not accept attachments. (You don't need a picture anyway.) > And the base 10 paradigm involved?? The int() constructor takes a base parameter whose default value is 10. If you specify base=0, it will accept binary, octal, and hexadecimal numbers in addition to decimal. All this is explained in the link I gave you. > years = int('y') # store for calculationValueError: invalid > literal for int() with base 10: 'y'What is meant by "invalid literal"? '42' is a valid literal for int(). 'y' is not. What value did you expect int('y') to give you? Perhaps you have a variable named 'y' containing a string? If so, you might want something like int(y) or int(f{'y'}), but int('y') passes the literal string 'y', which has nothing to do with a variable of that name. > I'm trying to convert srt to int, Do you mean "str to int"? > and I didn't know I needed to specify the base. You don't. If you don't specify the base, it defaults to 10. > Plus I haven't read anything that I need to specify > the base for the int(). Attached is the code, showing the code and > the execution of said code. Any attachment was removed. > "When you pass through the waters, I will > be with you: and when you pass through the rivers, they will not sweep > over you. When you walk through the fire, you will not be burned: the > flames will not set you ablaze." Isaiah 43:2 You can add a signature to all your messages if you like, but it will be very helpful if you introduce it with a line consisting of "-- ", as I've done here. It would also be very helpful if you introduce line breaks into your message, particularly before and after any included code. The formatting made your message difficult to read. -- Keith Thompson (The_Other_Keith) keith.s.thompso...@gmail.com Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */ -- https://mail.python.org/mailman/listinfo/python-list
Re: Invalid literal for int() with base 10?
Keith Thompson writes: > "Kevin M. Wilson" writes: >> Ok, I'm not finding any info. on the int() for converting a str to an >> int (that specifies a base parameter)?! > > https://docs.python.org/3/library/functions.html#int [...] Or `print(int.__doc__)` at a Python ">>>" prompt, or `pydoc int` (or `pydoc3 int`) at a shell prompt. The latter may or may not be available. -- Keith Thompson (The_Other_Keith) keith.s.thompso...@gmail.com Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */ -- https://mail.python.org/mailman/listinfo/python-list
3D surface plot
I should know this ...! Anyway, I have a list of 36 tuples, each with x, y, z values I want to create a surface plot ... Need help putting data into right format for matplot3D ... This is a gmail account used by Keith D. Anthony On Sat, Mar 16, 2019 at 12:03 PM wrote: > Send Python-list mailing list submissions to > python-list@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/python-list > or, via email, send a message with subject or body 'help' to > python-list-requ...@python.org > > You can reach the person managing the list at > python-list-ow...@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-list digest..." > Today's Topics: > >1. Re: Question regarding the local function object (Terry Reedy) >2. subprocess svn checkout password issue (Martin De Kauwe) >3. RE: asyncio Question (Joseph L. Casale) >4. Re: Implement C's Switch in Python 3 (jf...@ms4.hinet.net) >5. Re: subprocess svn checkout password issue (dieter) >6. Re: subprocess svn checkout password issue (Martin De Kauwe) >7. Re: Question regarding the local function object (Gregory Ewing) >8. Re: how to embed non-tkinter VLC player into grid of tkinter > with python? (akashsahu...@gmail.com) >9. Re: subprocess svn checkout password issue (Dan Sommers) > > > > -- Forwarded message -- > From: Terry Reedy > To: python-list@python.org > Cc: > Bcc: > Date: Fri, 15 Mar 2019 13:00:50 -0400 > Subject: Re: Question regarding the local function object > On 3/15/2019 8:47 AM, Arup Rakshit wrote: > > Hi, > > > > I am reading a book where it says that: > > > > Just like module-level function definitions, the definition of a local > function happens at run time when the def keyword is executed. > Interestingly, this means that each call to sort_by_last_letter results in > a new definition of the function last_letter. That is, just like any other > name bound in a function body, last_letter is bound separately to a new > function each time sort_by_last_letter is called. > > > > If that above is true, why the below program shows the same object > reference for last_letter every time I call function sort_by_last_letter. > > > > # file name is sample.py > > > > def sort_by_last_letter(strings): > > def last_letter(s): > > return s[-1] > > print(last_letter) > > return sorted(strings, key=last_letter) > > > > python3 -i sample.py > >>>> sort_by_last_letter(['ghi', 'def', 'abc']) > > .last_letter at 0x1051e0730> > > ['abc', 'def', 'ghi'] > >>>> sort_by_last_letter(['ghi', 'def', 'abc']) > > .last_letter at 0x1051e0730> > > ['abc', 'def', 'ghi'] > >>>> sort_by_last_letter(['ghi', 'def', 'abckl']) > > .last_letter at 0x1051e0730> > > ['def', 'ghi', 'abckl'] > > To build on Calvin's explanation ... > intersperse other function definitions between the repeated calls > > sort_by_last_letter(['ghi', 'def', 'abc']) > def a(): return 'skjsjlskjlsjljs' > print(a) > sort_by_last_letter(['ghi', 'def', 'abc']) > def b(): return 546465465454 > print(b) > sort_by_last_letter(['ghi', 'def', 'abc']) > > and memory gets reused a different way. > > .last_letter at 0x03A51D40> > # <== is same memory as . > .last_letter at 0x043C2710> > # ditto > .last_letter at 0x043C2768> > > Creating a new list or string did not have the same effect. I believe > that CPython function objects must currently all have the same size or > at least the same max size and conclude that CPython currently allocates > them from a block of memory that is some multiple of that size. These > are, of course, current internal implementation details, subject to > change and even variation across hardware and OSes. > > -- > Terry Jan Reedy > > > > > > -- Forwarded message -- > From: Martin De Kauwe > To: python-list@python.org > Cc: > Bcc: > Date: Fri, 15 Mar 2019 15:17:22 -0700 (PDT) > Subject: subprocess svn checkout password issue > Hi, > > I'm trying to write a script that will make a checkout from a svn repo and > build the result for the user. However,
Re: Jargons of Info Tech industry
Roedy Green <[EMAIL PROTECTED]> writes: [...] > Especially with spam, there are no perfect solutions, but at least we > could do many times better than what we are living with and put the > spammers out of business. A partial solution to spam, or at least to pollution of Usenet newsgroups, would be to STOP POSTING THIS STUFF TO NEWSGROUPS WHERE IT'S NOT RELEVANT. There are several newsgroups that deal with e-mail abuse. This discussion isn't being posted to any of them. Please stop. -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Microsoft Hatred FAQ
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Hm... What does this have to do with Perl? > > Why did you post this in comp.lang.perl.misc? He posted this in comp.lang.python, comp.lang.perl.misc, comp.unix.programmer, comp.lang.java.programmer, *and* comp.os.linux.misc because he's a troll. I wish I could say that he'll go away if we ignore him. I can say, however, that ignoring him will minimize his impact. In the past, his rants have led to long rambling arguments across multiple newsgroups, none of them relevant to any point that might be made -- which is probably exactly what he wants. -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: a Haskell a Day
"Xah Lee" <[EMAIL PROTECTED]> writes: [snip] ___ /| /| | | ||__|| | Please do | / O O\__ NOT | / \ feed the| / \ \ trolls | / _\ \ __| /|\\ \ || / | | | |\/ || / \|_|_|/ \__|| / / \|| || / | | /|| --| | | |// | --| * _| |_|_|_| | \-/ *-- _--\ _ \ // | / _ \\ _ // |/ * / \_ /- | - | | * ___ c_c_c_C/ \C_c_c_c____ -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python doc problem example: gzip module (reprise)
Rick Wotnaz <[EMAIL PROTECTED]> writes: [snip] > I've managed to avoid reading Xah Lee's diatribes for the most > part. Since you included the *WHOLE THING* in your post, I had an > "opportunity" to see what he had to say, and for once I agree with > some of it. That's fine, but if you're going to post a followup, could you please limit it to comp.lang.python? There's no hope of getting Xah Lee to stop posting his rants to irrelevant newsgroups (that's what killfiles are for), but I doubt that many readers of comp.lang.perl.misc really want to read about Python documentation -- if they do, they can always read comp.lang.python. -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to write a tutorial
"Xah Lee" <[EMAIL PROTECTED]> writes: [snip] > Following is a tutorial on Python's classes. [snip] Please stop posting this to comp.lang.c. I'm sure the folks in most of the other newsgroup aren't interested either -- or if they are, they can find it in comp.lang.python. Followups redirected. -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: what's OOP's jargons and complexities?
"Xah Lee" <[EMAIL PROTECTED]> writes: [snip] If you must post a followup to this, please drop comp.lang.c from the newsgroups header. I can't speak for the other newsgroups, but it's definitely off-topic here in comp.lang.c. Thank you. -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: what's OOP's jargons and complexities?
jacob navia <[EMAIL PROTECTED]> writes: > Good post. > > First article that demistifies this OO centered approach > in quite a long time. I have no idea whether it was "good" or not, but it was blatantly off-topic in at least comp.lang.c, and probably all the other newsgroups to which it was cross-posted. Jacob, please don't encourage this kind of newsgroup abuse. -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is Expresiveness in a Computer Language?
"Xah Lee" <[EMAIL PROTECTED]> writes: > What is Expresiveness in a Computer Language > > 20050207, Xah Lee. +---+ .:\:\:/:/:. | PLEASE DO NOT |:.:\:\:/:/:.: | FEED THE TROLLS | :=.' - - '.=: | | '=(\ 9 9 /)=' | Thank you, | ( (_) ) | Management | /`-vvv-'\ +---+ / \ | |@@@ / /|,|\ \ | |@@@ /_// /^\ \\_\ @x@@x@| | |/ WW( ( ) )WW \/| |\| __\,,\ /,,/__ \||/ | | | jgs (__Y__) /\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ ====== -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry
Roedy Green <[EMAIL PROTECTED]> writes: > On 11 Aug 2005 18:23:42 -0700, "Xah Lee" <[EMAIL PROTECTED]> wrote or > quoted : [ the usual nonsense ] > > Jargon [...] [snip] Take a look at the Newsgroups: line. Then look for other articles Xah Lee has posted, and see if you can make sense of any of them. If you must post a followup, at least limit the newsgroups to those where it might be topical. +---+ .:\:\:/:/:. | PLEASE DO NOT |:.:\:\:/:/:.: | FEED THE TROLLS | :=.' - - '.=: | | '=(\ 9 9 /)=' | Thank you, | ( (_) ) | Management | /`-vvv-'\ +---+ / \ | |@@@ / /|,|\ \ | |@@@ /_// /^\ \\_\ @x@@x@| | |/ WW( ( ) )WW \/| |\| __\,,\ /,,/__ \||/ | | | jgs (__Y__) /\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ == -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry ... and Xah Lee (I mean Jerry) Springer
Alex <[EMAIL PROTECTED]> writes: > Xah Lee wrote: [SSSNNNIIIPPP!!!] > I've extracted the preceding castigating snippets from Mr. Lee's > Jargon "thesis". [SSSNNNIIIPPP!!!] *Please stop posting followups to this off-topic nonsense. Just ignore it. Responding to spam is spam; responding to a troll gives him exactly what he wants and annoys the heck out of the rest of us. +---+ .:\:\:/:/:. | PLEASE DO NOT |:.:\:\:/:/:.: | FEED THE TROLLS | :=.' - - '.=: | | '=(\ 9 9 /)=' | Thank you, | ( (_) ) | Management | /`-vvv-'\ +---+ / \ | |@@@ / /|,|\ \ | |@@@ /_// /^\ \\_\ @x@@x@| | |/ WW( ( ) )WW \/| |\| __\,,\ /,,/__ \||/ | | | jgs (__Y__) /\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ == Followups redirected appropriately. -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry
"Xah Lee" <[EMAIL PROTECTED]> writes: [the usual] +---+ .:\:\:/:/:. | PLEASE DO NOT |:.:\:\:/:/:.: | FEED THE TROLLS | :=.' - - '.=: | | '=(\ 9 9 /)=' | Thank you, | ( (_) ) | Management | /`-vvv-'\ +---+ / \ | |@@@ / /|,|\ \ | |@@@ /_// /^\ \\_\ @x@@x@| | |/ WW( ( ) )WW \/| |\| __\,,\ /,,/__ \||/ | | | jgs (__Y__) /\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ ====== -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry
"jan V" <[EMAIL PROTECTED]> writes: >> +---+ .:\:\:/:/:. >> | PLEASE DO NOT |:.:\:\:/:/:.: >> | FEED THE TROLLS | :=.' - - '.=: >> | | '=(\ 9 9 /)=' >> | Thank you, | ( (_) ) >> | Management | /`-vvv-'\ >> +---+ / \ >> | |@@@ / /|,|\ \ >> | |@@@ /_// /^\ \\_\ >>@x@@x@| | |/ WW( ( ) )WW >>\/| |\| __\,,\ /,,/__ >> \||/ | | | jgs (__Y__) >> /\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > Please don't use ASCII art... not everyone uses a fixed-width font for his > newsreader... > (your picture looks all mangled here) If "PLEASE DO NOT" and "FEED THE TROLLS" are legible, even if they aren't aligned as intended, the message has gotten through. -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Perl's documentation come of age
"Xah Lee" <[EMAIL PROTECTED]> writes: [ the usual ] +---+ .:\:\:/:/:. | PLEASE DO NOT |:.:\:\:/:/:.: | FEED THE TROLLS | :=.' - - '.=: | | '=(\ 9 9 /)=' | Thank you, | ( (_) ) | Management | /`-vvv-'\ +---+ / \ | |@@@ / /|,|\ \ | |@@@ /_// /^\ \\_\ @x@@x@| | |/ WW( ( ) )WW \/| |\| __\,,\ /,,/__ \||/ | | | jgs (__Y__) /\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ ====== -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Synchronizing methods of a class
Hello to all fellow c.l.p'ers! Long-time listener, first-time caller. Background: I'm working on a project where I have to do some serious multithreading. I've worked up a decorator in Python 2.3.4 to implement the lock semantics required for specific functions I want to synchronize: def synchronized(method): def f(*args,**kwargs): self = args[0] self._lock.acquire(); try: return method(*args,**kwargs) finally: self._lock.release() return f And a convenience method to synchronize all methods of a given class: def synchronize(klass, allow=None, deny=None): """Synchronize methods in the given class Only synchronize the methods whose names are not in the deny list,in the allow list, or all methods if allow and deny are not specified..""" if deny is None: deny=[] deny.append('__init__') for (name, val) in klass.__dict__.items(): print "attr '%s':" % (name), if callable(val): if name not in deny: if allow is None or name in allow: klass.__dict__[name] = synchronized(val) print "synchronized." else: print "not synchronizing, name not in allow list" % name else: print "not synchronizing, name in deny list." else: print "not synchronizing, not callable." return klass Obviously, my classes have to instantiate the _lock in __init__ in order for this to work. Problem: When iterating through klass.__dict__.items() in the convenience method, I only get the instance variables of the class. No functions. I've found a way to get the function list, by iterating through klass.__class__.__dict__ . My Question: If I decorate these function references in __class__.__dict__, am I doing it only for my specific instance of that class or the base class as well? Thanks in advance, Keith Veleba -- http://mail.python.org/mailman/listinfo/python-list
Re: Synchronizing methods of a class
Chris, Q&D example of <>.__dict__.items() not working for me: >>> import threading >>> class A(threading.Thread): ... def __init__(self): ... threading.Thread.__init__(self) ... def one(self): ... pass ... def two(self): ... pass ... >>> a = A() >>> a.__dict__.items() [('_Thread__block', , 0)>), ('_Thread__name', 'Thread-1'), ('_Thread__daemonic', False), ('_Thread__started', False), ('_Thread__target', None), ('_Thread__kwargs', {}), ('_Verbose__verbose', False), ('_Thread__args', ()), ('_Thread__stopped', False), ('_Thread__initialized', True)] Neither function I added to the A class shows up. However, I think it's because I'm using an instance of my class vs. just referencing the class type. If I type: A.__dict__items() I get the correct list: [('__module__', '__main__'), ('__doc__', None), ('two', ), ('__init__', ), ('one', )] In any case, thanks for the example reference. That's helps me improve my idea, and I will most likely use the methods in it. Keith -- http://mail.python.org/mailman/listinfo/python-list
Re: swig & Python question
It's me wrote: "It's me" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I am playing around with SWING building a Python module using the no brainer example in http://www.swig.org/tutorial.html. With that first example, Oops! Soapy fingers. "SWIG" - not "SWING". -- It's me. I have used SWIG before, and it's not always such a "no-brainer". In fact, it rarely is except for trivial examples. But it can work. I think it is best suited for wrapping large libraries. For small stuff, it would be better to just do it "manually" using the Python C API. Good luck. -- It's not me. -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess.Popen
Michele Simionato wrote: I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I wonder why a "kill" method is missing. I am just adding it via subclassing, class Popen(subprocess.Popen): def kill(self, signal = SIGTERM): os.kill(self.pid, signal) but I would prefer to have it in the standard Popen class. I am surprised it is not there. Any comments? Probably because it is not entirely portable. If you want a more complete, but Posix-only (at least Linux and FreeBSD), process management and spawning then you can use the proctools module in pyNMS. http://sourceforge.net/projects/pynms/ -- \/ \/ (O O) -- oOOo~(_)~oOOo---- Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
Re: Persistent objects
Paul Rubin wrote: I've had this recurring half-baked desire for long enough that I thought I'd post about it, even though I don't have any concrete proposals and the whole idea is fraught with hazards. Basically I wish there was a way to have persistent in-memory objects in a Python app, maybe a multi-process one. So you could have a persistent dictionary d, and if you say d[x] = Frob(foo=9, bar=23) that creates a Frob instance and stores it in d[x]. Then if you exit the app and restart it later, there'd be a way to bring d back into the process and have that Frob instance be there. Check out the Durus project. http://www.mems-exchange.org/software/durus/ -- \/ \/ (O O) -- oOOo~(_)~oOOo---- Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
Re: Persistent objects
Paul Rubin wrote: I've had this recurring half-baked desire for long enough that I thought I'd post about it, even though I don't have any concrete proposals and the whole idea is fraught with hazards. Basically I wish there was a way to have persistent in-memory objects in a Python app, maybe a multi-process one. So you could have a persistent dictionary d, and if you say d[x] = Frob(foo=9, bar=23) that creates a Frob instance and stores it in d[x]. Then if you exit the app and restart it later, there'd be a way to bring d back into the process and have that Frob instance be there. Check out the Durus project. http://www.mems-exchange.org/software/durus/ -- \/ \/ (O O) -- oOOo~(_)~oOOo---- Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
Re: Persistent objects
Paul Rubin wrote: I've had this recurring half-baked desire for long enough that I thought I'd post about it, even though I don't have any concrete proposals and the whole idea is fraught with hazards. Basically I wish there was a way to have persistent in-memory objects in a Python app, maybe a multi-process one. So you could have a persistent dictionary d, and if you say d[x] = Frob(foo=9, bar=23) that creates a Frob instance and stores it in d[x]. Then if you exit the app and restart it later, there'd be a way to bring d back into the process and have that Frob instance be there. Check out the Durus project. http://www.mems-exchange.org/software/durus/ -- \/ \/ (O O) -- oOOo~(_)~oOOo---- Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess.Popen
Keith Dart wrote: Michele Simionato wrote: I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I wonder why a "kill" method is missing. I am just adding it via subclassing, class Popen(subprocess.Popen): def kill(self, signal = SIGTERM): os.kill(self.pid, signal) but I would prefer to have it in the standard Popen class. I am surprised it is not there. Any comments? Probably because it is not entirely portable. If you want a more complete, but Posix-only (at least Linux and FreeBSD), process management and spawning then you can use the proctools module in pyNMS. http://sourceforge.net/projects/pynms/ I forgot to mention that the pyNMS package also has a module called "expect" that works like the Expect language. You can interact and control interactive processes and external CLIs with it. -- \/ \/ (O O) -- oOOo~(_)~oOOo---- Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Perl
Keith Dart wrote: Ian Bicking wrote: Jon Perez wrote: Michael McGarry wrote: I intend to use a scripting language for GUI development and front end code for my simulations in C. I want a language that can support SQL, Sockets, File I/O, and shell interaction. In my experience, Python is definitely much more suitable than Perl for the first four areas mentioned in the last sentence. For the last area, I'm not sure, but Python's capabilities in this area are also quite good. Shell interaction (or rather, external process interaction) is a lot better with Python 2.4's subprocess module. Better or worse than Perl? I'm not sure; generally I'd guess better, as it avoids the shell with all the shell's issues, and provides a more controlled programmatic way of interacting with subprocesses. OTOH, Perl might have perfectly good modules for doing the same thing. I can only say it's been missing for a while in Python, and it's good to see this done right. Yow, I must not get picked up in Google enough. ;-) The "proctools" module in the pyNMS package <http://sourceforge.net/projects/pynms/> has been around for years. I use it all the time for shell-like stuff. There is also an "expect" module, and the "termtools" module. If you need a more complete process spawning and controlling framework then use pyNMS. It can "juggle" multiple processes, reaps child status (no zombies), operates asynchronously (The ProcManager object is a SIGCHLD handler), and works with pty's and pipes. It also offers a "thread-like" interface for Python subprocesses (uses fork). Can leave some fd's open that you specify, can run the subprocess as a different user, and more... Check it out. Oh, I forgot to mention that it also has a more user- and programmer-friendly ExitStatus object that processess can return. This is directly testable in Python: proc = proctools.spawn("somecommand") exitstatus = proc.wait() if exitstatus: print "good result (errorlevel of zero)" else: print exitstatus # prints message with exit value -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
Re: [dictionary] how to get key by item
Skip Montanaro wrote: Egor> i know how to get item by key ... Egor> but i wonder how to get key by item Assuming your dictionary defines a one-to-one mapping, just invert it: >>> forward = {10 : 50, 2 : 12, 4 : 43} >>> reverse = dict([(v,k) for (k,v) in forward.iteritems()]) >>> print forward {10: 50, 4: 43, 2: 12} >>> print reverse {50: 10, 43: 4, 12: 2} That doubles your storage, so you'll have to trade that off against the speed gain of not having to loop over the entire dictionary. Skip But beware that all the items in the original dictionary must be hashable. The example shows just integers, so I assume they are in this case. But generally, this may not work. -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
Re: gather information from various files efficiently
Klaus Neuner wrote: Hello, I need to gather information that is contained in various files. Like so: file1: = foo : 1 2 bar : 2 4 baz : 3 = file2: = foo : 5 bar : 6 baz : 7 = file3: = foo : 4 18 bar : 8 = The straightforward way to solve this problem is to create a dictionary. Like so: [...] a, b = get_information(line) if a in dict.keys(): dict[a].append(b) else: dict[a] = [b] Aye... the dict.keys() line creates a temporary list, and then the 'in' does a linear search of the list. Better would be: try: dict[a].append(b) except KeyError: dict[a] = [b] since you expect the key to be there most of the time, this method is most efficient. You optomistically get the dictionary entry, and on the exceptional case where it doesn't yet exist you add it. -- \/ \/ (O O) -- oOOo~(_)~oOOo---- Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 -- http://mail.python.org/mailman/listinfo/python-list
Re: gather information from various files efficiently
Kent Johnson wrote: Keith Dart wrote: try: dict[a].append(b) except KeyError: dict[a] = [b] or my favorite Python shortcut: dict.setdefault(a, []).append(b) Kent Hey, when did THAT get in there? ;-) That's nice. However, the try..except block is a useful pattern for many similiar situations that the OP might want to keep in mind. It is usually better than the following, also: if dct.has_key(a): dct[a].append(b) else: dct[a] = [b] Which is a pattern I have seen often. -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess vs. proctools
Nick Craig-Wood wrote: Keith Dart <[EMAIL PROTECTED]> wrote: Oh, I forgot to mention that it also has a more user- and programmer-friendly ExitStatus object that processess can return. This is directly testable in Python: proc = proctools.spawn("somecommand") exitstatus = proc.wait() if exitstatus: print "good result (errorlevel of zero)" else: print exitstatus # prints message with exit value This sounds rather like the new subprocess module... import subprocess rc = subprocess.call(["ls", "-l"]) total 381896 -rw-r--r--1 ncw ncw 1542 Oct 12 17:55 1 [snip] -rw-r--r--1 ncw ncw 713 Nov 16 08:18 z~ print rc 0 But this evaluates to False in Python, but True in a shell. It also requires an extra check for normal exit, or exit by a signal. The proctools ExitStatus object avaluates to True only on a normal exit, period. Thus it follows a shell semantics for clarity. You cannot do this with the subprocess module: if rc: print "exited normally" But in proctools, the exitstatus is an object that evaluates True only for normal exit. import proctools proc = proctools.spawnpipe("ls -l") print proc.read() print proc.exitstatus ls: Exited normally. proc = proctools.spawnpipe("ls -l xx") print proc.read() 'ls: xx: No such file or directory\n' print proc.exitstatus ls: Exited abnormally with status 1. if proc.exitstatus: print "returned normally" But you can get the integer return value, if you want it, like this: int(proc.exitstatus) or query it with methods returning booleans: exitstatus.exited() exitstatus.signalled() exitstatus.stopped() Also, proctools lets you use a pty, if you choose. Not every program works well from a pipe. IMHO the new subprocess module is a very well thought out interface... The proctools Process object presents a file-like object to the rest of Python, which makes a process polymorhic with any other file, pipe or socket object. It has the usual read, write, readline, and readlines methods. It can also be made non-blocking, and you can have many open at once. In addition, there are special methods for controlling the sub-process: You can kill it, stop it, re-start it, clone it, wait on it, and get stats from it. The stat() method returns a ProcStat object, which has attributes like what you get from the 'ps' program. Need to know the process's RSS? No problem. It also supports logging to a log file, and on-exit callback for persistent process requirements. You always invoke the spawn* functions with a string. This is parsed by a shell-like parser (the shparser module that comes with it), but no /bin/sh is invoked. The parser can handle single and double quotes, and backslash escapes. Alas, one thing the proctools module does not do well yet is create a pipeline. I have plans to fix that. It does not work with MS Windows, but can work with cygwin on Windows. Whew... and I have not even covered the ProcessManager object... -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
Re: gather information from various files efficiently
Fredrik Lundh wrote: ... if dct.has_key(a): dct[a].append(b) else: dct[a] = [b] the drawback here is that if the number of collisions are high, you end up doing lots of extra dictionary lookups. in that case, there are better ways to do this. Sigh, this reminds me of a discussion I had at my work once... It seems to write optimal Python code one must understand various probabilites of your data, and code according to the likely scenario. 8-) Now, perhaps we could write an adaptive data analyzer-code-generator... ;-) -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess vs. proctools
Donn Cave wrote: Keith Dart <[EMAIL PROTECTED]> wrote: |>> if exitstatus: |>> print "good result (errorlevel of zero)" |>> else: |>> print exitstatus # prints message with exit value This is indeed how the shell works, though the actual failure value is rarely of any interest. It's also in a more general sense how C works - whether errors turn out to be "true" or "false", in either case you test for that status (or you don't.) Python doesn't work that way, there is normally no such thing as an error return. An idiomatic Python interface would be try: proc = proctools.spawn(command) proc.wait() print 'good result' except proctools.error, ev: print >> sys.stderr, '%s: %s' % (proc.name, ev.text) Your first statement is exactly right. One does not always care about the return value of an external process. And some programs still return an undefined value, even when successful. Therefore, I don't want to always have to wrap a call to an external program in a try..except block. Thus, it returns an ExitStatus object that you can easily test true-false with as in a shell, or get the actual value if you need it. Otherwise, just ignore it. [... list of features ...] | You always invoke the spawn* functions with a string. This is parsed by | a shell-like parser (the shparser module that comes with it), but no | /bin/sh is invoked. The parser can handle single and double quotes, and | backslash escapes. It was sounding good up to here. A lot depends on the quality of the parser, but it's so easy to support a list of arguments that gets passed unmodified to execve(), and such an obvious win in the common case where the command parameters are already separate values, that an interface where you "always" have to encode them in a string to be submitted to your parser seems to be ignoring the progress that os.spawnv and popen2.Popen3 made on this. Of course you don't need to repeat their blunders either and accept either string or list of strings in the same parameter, which makes for kind of a shabby API, but maybe a keyword parameter or a separate function would make sense. Actually, an earlier version of proctools did take a list. However, after much usage I realized that in most cases what I got was a string to begin with. Either from user input or read from a file. I also found it easier to construct command-lines using the string-mod operator, substituting various attributes into option-value pairs in arbitrary ways. I was having to split/parse a string so often I decided to just make the Process object parse it itself. The shparser module has been perfectly adequate for this, and you can pass to the Process object pretty much the same string as you would to a real shell (thus making it easier to use for *nix people). I could add a list-input check, but likely I would never use it. -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression
Michael McGarry wrote: Hi, I am horrible with Regular Expressions, can anyone recommend a book on it? Also I am trying to parse the following string to extract the number after load average. " load average: 0.04, 0.02, 0.01" how can I extract this number with RE or otherwise? This particular example might be parsed more quickly and easily just by chopping it up: s = " load average: 0.04, 0.02, 0.01" [left, right] = s.split(":") [av1, av2, av3] = map(float, map(str.strip, right.split(","))) -- \/ \/ (O O) -- oOOo~(_)~oOOo---- Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
Re: ".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)
Fernando Perez wrote: You might want to look at ipython: http://ipython.scipy.org, I did just recently install that. It looks very nice. Would make a great interactive prompt for an IDE, as well. -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
pywhich script - where is that module?
Have you ever wondered where your python modules get imported from? Here is a little script, called "pywhich", that will tell you. -- \/ \/ (O O) -- oOOo~(_)~oOOo---- Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 #!/usr/bin/env python """pywhich Tell which Python module is imported. """ import sys def main(argv): if len(argv) < 2: print __doc__ return for modname in argv[1:]: try: mod = __import__(modname) except: print "No module or package by named '%s' found." % modname else: print "%15s : %s" % (modname, mod.__file__) main(sys.argv) -- http://mail.python.org/mailman/listinfo/python-list
Re: High level SNMP
Jeremy Sanders wrote: Hi - I'd like to write a program which basically does a few snmpgets. I haven't been able to find a python package which gives you a nice high-level and simple way of doing this (like PHP has). Everything appears to be extremely low level. All I need is SNMPv1. Does anyone know of a simple python package for doing this? I'd rather have something written in pure python, so that it is easily cross-platform. Jeremy The pyNMS package at sourceforge has a complete SNMP (v1, v2c) implementation. In pure Python, and fairly self contained. See http://sourceforge.net/projects/pynms There are few docs, sorry. If you want to use it and have any questions then please let me know (I wrote it). BTW, you can also read MIB files if you have libsmi installed. But the pyNMS package contains a utility called mib2py that converts MIB objects to Python, and the pyNMS package has most standard MIBS pre-compiled. So, you don't really need libsmi to use the standard MIBs. The name means Python Network Management System, and will become a complete network management system with GUI and scriptability soon. ;-) There is some support for creating XHTML reports, NMS web interface, SNMP get/set, SNMP trap receiver, Ping/ICMP module, process management, MIB browser, CLI construction kit, web protocols, easy email interface, and asyncio framework. Works well with Linux or FreeBSD. (PS. It can also answer your phone and take a message) -- \/ \/ (O O) -- oOOo~(_)~oOOo---- Keith Dart <[EMAIL PROTECTED]> vcard: <http://www.kdart.com/~kdart/kdart.vcf> public key: ID: F3D288E4 URL: <http://www.kdart.com/~kdart/public.key> -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Perl
Ian Bicking wrote: Jon Perez wrote: Michael McGarry wrote: I intend to use a scripting language for GUI development and front end code for my simulations in C. I want a language that can support SQL, Sockets, File I/O, and shell interaction. In my experience, Python is definitely much more suitable than Perl for the first four areas mentioned in the last sentence. For the last area, I'm not sure, but Python's capabilities in this area are also quite good. Shell interaction (or rather, external process interaction) is a lot better with Python 2.4's subprocess module. Better or worse than Perl? I'm not sure; generally I'd guess better, as it avoids the shell with all the shell's issues, and provides a more controlled programmatic way of interacting with subprocesses. OTOH, Perl might have perfectly good modules for doing the same thing. I can only say it's been missing for a while in Python, and it's good to see this done right. Yow, I must not get picked up in Google enough. ;-) The "proctools" module in the pyNMS package <http://sourceforge.net/projects/pynms/> has been around for years. I use it all the time for shell-like stuff. There is also an "expect" module, and the "termtools" module. If you need a more complete process spawning and controlling framework then use pyNMS. It can "juggle" multiple processes, reaps child status (no zombies), operates asynchronously (The ProcManager object is a SIGCHLD handler), and works with pty's and pipes. It also offers a "thread-like" interface for Python subprocesses (uses fork). Can leave some fd's open that you specify, can run the subprocess as a different user, and more... Check it out. -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Dimitri Tcaciuc wrote: Yup, I was aware of the fact of Monty Python roots of the language name. However, you will probably agree that a snake is more associative. Plus, if to use some characteristic MP feature like a giant foot, I'm not positive that it won't trigger any copyright issues. I prefer an alternate meaning: 2. A diviner by spirits. ``[Manasses] observed omens, and appointed pythons.'' --4 Kings xxi. 6 (Douay version). Since Python is a divine language, and conjures up quick solutions to ghastly problems. And, in the spirit of oracles, reflects the wisdom of the languages design. 8-) Now, how about an icon that conveys something like that? hm... smoke curled around wizard perhaps? -- \/ \/ (O O) -- oOOo~(_)~oOOo---- Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess vs. proctools
Nick Craig-Wood wrote: There are many ways for a program to fail (non-zero exit codes) but only one way for it to succeed (zero exit code). Therefore rc should be 0 for success. Exactly. And as a convenience the ExitStatus object of proctools handles that for you. As a general rule, I believe Python interfaces should be more abstract and object-oriented. I don't think the users of my framework (myself included) should have to know or deal with the fact that "zero means good". You only need to know that if the ExitStatus object you get avaluates to True, it is a "good" exit. IMHO Shell semantics are nuts (0 is True - yeah!) - they hurt my head every time I have to use them ;-) Exactly, and that is why the proctools framework hides that from the user-programmer. import subprocess subprocess.call(["sleep", "60"]) -11 # I killed the sleep process with a SEGV here from another xterm Python> import proctools Python> print proctools.call("sleep 60") sleep exited by signal 11. # same here... sent SEGV. which is easier to understand what is going on? (BTW, I just added a "call" function to proctools with similiar functionality) subprocess.call(["sleep", "asdfasdf"]) sleep: invalid time interval `asdfasdf' Try `sleep --help' for more information. 1 Python> print proctools.call("sleep asdf") sleep: Exited abnormally with status 1. Signals are -ve, exit codes are +ve which seems perfect. Exit codes can only be from 0..255 under linux. Signals go from -1 to -64. And why should my API user-programmers need to know that? That is just too... low-level. if rc: print "exited normally" Actually I think if rc == 0: print "exited normally" is exactly equivalent! Yes, but requires the programmer to know that zero is good, and signals are negative. Again, the proctool's ExitStatus makes that more abstract for you (as Python interfaces should be) and provides test methods if you need them. Python> rc = proctools.call("sleep asdf") Python> rc.exited() True Python> rc.signalled() False Python> int(rc) 1 # Note that you can still get the exit value for those programs that # return something meaningful. Python> rc = proctools.call("sleep 60") # send SEGV Python> rc.signalled() True I like python because I can write stuff on linux and it works on windows without too much effort, and in general I try not to use modules which don't work on both platforms. Sorry for you. I like Python becuase it allows me to write good, solid programs easily and quickly. I try to make my libraries facilitate that, and also be easy to use for beginning Python programmers. Python on Linux is a powerful combination, and I cannot fathom why someone would choose anything less. (I would concede that Python on Darwin is also good) -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 -- http://mail.python.org/mailman/listinfo/python-list
Re: spawn* or exec* and fork, what should I use and how ?
Lingyun Yang wrote: Hi, I want to use python as a "shell like" program, and execute an external program in it( such as mv, cp, tar, gnuplot) I tried: Since you appear to be on a *nix system, a good choice is the proctools module in the pyNMS package. http://sourceforge.net/projects/pynms os.execv("/bin/bash",("/usr/bin/gnuplot",'-c "gnuplot < plot.tmp"')) You could do this: import proctools proctools.spawnpipe("gnuplot plot.tmp") You can keep your existing Python 2.3 installation, as well. 1. why my exec(..) command doesn't work? It replaces your current process. 2. exec* must be with fork ? in this case, yes. but proctools does that for you. 3. In what situation, we choose one over another ? The fork-and-exec is a common pattern in *nix for spawning another process. However, there are libraries in Python that do that for you. See above. -- \/ \/ (O O) -- ----oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 -- http://mail.python.org/mailman/listinfo/python-list
Re: ".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)
Steve Holden wrote: Nick Coghlan wrote: Roel Schroeven wrote: Stefan Behnel wrote: This is the first time I see that and I totally like the idea of writing ".>>>" instead of ">>>" at the beginning of a line. Thank you Dr. Dobb! It's unfortunate for c.l.py that Python uses ">>>" as the default prompt as it messes up the display on mail/news readers that provide "syntax highlighting" for quotes. I use Thunderbird, and started doing it so I could read my own posts. I did copy it from someone, though (but I can't recall who). The trick can also be useful for web tools that strip leading whitespace. Prepending every line with . is not an ideal solution though... I think it gets tiresome very quickly. Aye, can't argue with that. It does have the virtues of reliability and portability, though :) Cheers, Nick. $ python Python 2.4 (#1, Dec 4 2004, 20:10:33) [GCC 3.3.3 (cygwin special)] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.ps1 = ".>>> "; sys.ps2 = " " .>>> print """\ It isn't that hard""" It isn't that hard .>>> Would it work, I wonder, with a leading space on the prompt? That might be a valid change to the standard prompt. Let's see >>> This line isn't really quoted three times. What I do is set Python's sys.ps1 variable to something else. I have a module called "interactive" that I import implicitly by shell alias: py='python -i -c '\''import interactive'\' Which, among other things, sets the prompt to "Python> " 433 $ py Python> print "This has no leader that screws up email programs." This has no leader that screws up email programs. Python> -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 -- http://mail.python.org/mailman/listinfo/python-list
Re: Plugin system; imp module head scratch
Dave wrote: Hi, all, I'm trying to implement a simple plugin framework, with some unexpected results. I'm using Python 2.3.4 on Windows 2000. What would be the difference between a "plugin" and a regular Python module? -- ~~~~~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: Language fluency (was Re: BASIC vs Python)
Hello, Aahz, Aahz wrote: myself to have "complete and utter" fluency. In fact, in some ways my fluency has degenerated now that I'm focusing on writing code for production. I'm curious about that last statement. Are you saying that if you write, full time, code for "production", that fluency will decrease? Or that the nifty recent features of Python (generators, etc.) are not useful in "production" code? -- ~~~~~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: Easy "here documents" ??
Jim Hill wrote: I've done some Googling around on this and it seems like creating a here document is a bit tricky with Python. Trivial via triple-quoted strings if there's no need for variable interpolation but requiring a long, long formatted arglist via (%s,%s,%s,ad infinitum) if there is. So my question is: Is there a way to produce a very long multiline string of output with variables' values inserted without having to resort to this wacky I was thinking about this. But I can't think of any reason why you would want to do this in Python. What's wrong with a regular parameterized function? -- -- ~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie question
David Wurmfeld wrote: I am new to python; any insight on the following would be appreciated, even if it is the admonition to RTFM (as long as you can direct me to a relevant FM) Is there a standard approach to enumerated types? I could create a dictionary with a linear set of keys, but isn't this overkill? There is afterall a "True" and "False" enumeration for Boolean. Not a standard one, but here's what I use: class Enum(int): __slots__ = ("_name") def __new__(cls, val, name): v = int.__new__(cls, val) v._name = str(name) return v def __str__(self): return self._name def __repr__(self): return "%s(%d, %r)" % (self.__class__.__name__, self, self._name) def __cmp__(self, other): if isinstance(other, int): return int.__cmp__(self, other) if type(other) is str: return cmp(self._name, other) raise ValueError, "Enum comparison with bad type" class Enums(list): def __init__(self, *init): for i, val in enumerate(init): if issubclass(type(val), list): for j, subval in enumerate(val): self.append(Enum(i+j, str(subval))) elif isinstance(val, Enum): self.append(val) else: self.append(Enum(i, str(val))) def __repr__(self): return "%s(%s)" % (self.__class__.__name__, list.__repr__(self)) -- ~~~~~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: input record seperator (equivalent of "$|" of perl)
[EMAIL PROTECTED] wrote: Hi, I know that i can do readline() from a file object. However, how can I read till a specific seperator? for exmple, if my files are name profession id # name2 profession3 id2 I would like to read this file as a record. I can do this in perl by defining a record seperator; is there an equivalent in python? thanks I don't think so. But in the pyNMS package (http://sourceforge/net/projects/pynms) there is a module called "expect", and a class "Expect". With that you can wrap a file object and use the Expect.read_until() method to do what you want. -- -- ~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: A completely silly question
Mike Meyer wrote: Craig Ringer <[EMAIL PROTECTED]> writes: On Sat, 2004-12-18 at 00:40, Amir Dekel wrote: This must be the silliest question ever: What about user input in Python? (like stdin) Where can I find it? I can't find any references to it in the documentation. Under UNIX, I generally either use curses, or just put the terminal into raw mode: .>>> def sane(): os.system("stty sane") .>>> def raw(): os.system("stty raw") The termios gives module gives you the tools to manipulate the tty directly, without invoking stty. The tty module gives you an easier interface to those routines. However, it's missing a setsane functions. Hmm. I think it's time for another PEP. In the pyNMS package (http://sourceforge.net/projects/pynms/) there is a module called "termtools". This module can be used in place of the "tty" module. It has many improvements, including a "sane" function, a "raw" function, and an "stty" function. This module also replaces the "getpass" module, as it has the same functions found there. The PagedIO object is used by the CLI framework in pyNMS. -- -- ~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: A completely silly question
Jp Calderone wrote: On Sun, 19 Dec 2004 23:15:40 GMT, Keith Dart <[EMAIL PROTECTED]> wrote: Mike Meyer wrote: The termios gives module gives you the tools to manipulate the tty directly, without invoking stty. The tty module gives you an easier interface to those routines. However, it's missing a setsane functions. Hmm. I think it's time for another PEP. In the pyNMS package (http://sourceforge.net/projects/pynms/) there is a module called "termtools". This module can be used in place of the "tty" module. It has many improvements, including a "sane" function, a "raw" function, and an "stty" function. This module also replaces the "getpass" module, as it has the same functions found there. The PagedIO object is used by the CLI framework in pyNMS. I found this: http://cvs.sourceforge.net/viewcvs.py/*checkout*/pynms/pyNMS/lib/termtools.py?content-type=text%2Fplain&rev=1.4 But I don't see a function named "sane". Is sf cvs out of date? If so, where should I be looking? Jp Yes, sorry, the CVS is very out of date. Please get the tarball (I just today put up a new one with the "sane" function in termtools). I am coverting it all to subversion, and will make pyNMS publicly available through that means when it's ready. Thanks for looking, Keith -- -- ~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: Python To Send Emails Via Outlook Express
[EMAIL PROTECTED] wrote: Hi Ganesan I tried changing s.Send to s.Send(). It now comes up with an exception error.. The details are below. Looks like the COM part works, but sending mail has an error from the SMTP host. But, slightly off topic, FYI, Python can send email directly with the email and snmplib modules. -- -- ~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: Easy "here documents" ??
Fredrik Lundh wrote: Jim Hill wrote: I'm trying to write a script that writes a script for a rather specialized task. I know that seems weird, but the original version was written in Korn shell and most of my team are familiar with the way it does things even though they don't read Korn. so why didn't you tell us? ;-) if you want $-style interpolation, you can use the new string.Template class (mentioned in passing by Nick above); useful examples here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304004 if you don't have 2.4, you can use the RE machinery for the same purpose; see e.g. http://effbot.org/zone/re-sub.htm#simple-templating You might also try the following: -python-- # a self-substituting string object. Just set attribute names to mapping names # that are given in the initializer string. class mapstr(str): def __new__(cls, initstr, **kwargs): s = str.__new__(cls, initstr) return s def __init__(self, initstr, **kwargs): d = {} for name in _findkeys(self): d[name] = kwargs.get(name, None) self.__dict__["_attribs"] = d def __setattr__(self, name, val): if name not in self.__dict__["_attribs"].keys(): raise AttributeError, "invalid attribute name %r" % (name,) self.__dict__["_attribs"][name] = val def __getattr__(self, name): try: return self.__dict__["_attribs"][name] except KeyError: raise AttributeError, "Invalid attribute %r" % (name,) def __str__(self): if None in self._attribs.values(): raise ValueError, "one of the attributes %r is not set" % (self._attribs.keys(),) return self % self._attribs def __call__(self, **kwargs): for name, value in kwargs.items(): setattr(self, name, value) return self % self._attribs def __repr__(self): return "%s(%s)" % (self.__class__.__name__, str.__repr__(self)) def attributes(self): return self._attribs.keys() import re _findkeys = re.compile(r"%\((\w+)\)").findall del re --- You use it like this: TEST = mapstr("some%(one)s one\nsome%(two)s three\nsome%(three)s four") print TEST.attributes() TEST.one = "one" TEST.two = "thing" TEST.three = "where" print TEST s = str(TEST) # makes new, substituted, string assert s == "someone one\nsomething three\nsomewhere four" This allows you to use mapping-substitution syntax on a special string object. But the substituted variables are attributes of the object. String-ifying it gets the new string with the substitutions made. -- -- ~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: Ack! Zombie processes won't die!
Brian wrote: From one script, I'm spawnv'ing another that will launch mpg123 to play a specified mp3. Problem is that After the second script has launched mpg123, it'll turn into a zombie process. It doesn't happen when I launch it from the command line, so there's something wrong with the way I'm calling it (I believe). mp3pid = os.spawnv(os.P_NOWAIT, "/oter/playfile.py", ["playfile", filename, "0"]) Shouldn't this launch the script without waiting for it to finish? It does, but the OS keeps the process information around until you "wait" on it, with "reaps", or collects the exit status then. You can do this asyncronously with a SIGCHLD handler. However, this has already been done. In the the pyNMS package on sourceforge (http://sourceforge.net/projects/pynms) there is a module called "proctools". It has a process manager that does this for you. -- -- ~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: win32 process name
Fredrik Lundh wrote: "phil" <[EMAIL PROTECTED]> wrote: from win32all EnumProcesses gives me the pids, then OpenProcess(pid) gives me a handle. Then what? GetModuleFileNameEX? It requires two handles as args and I can't figure out which one is the handle from OpenProcess and what it wants for the other one and I can't find any Win32 SDK docs that help. http://msdn.microsoft.com/library/en-us/perfmon/base/getmodulefilenameex.asp describes a function with two [in] arguments, and one [out] argument. the first argument is the process handle, the second a module handle; the second argument can be NULL. This ought to be a nobrainer. But Nooo. Its Windows. it can be pretty tricky on other platforms too; that's why Unix programs usually solve this by writing their PID to a file in a known location, so that other programs can find them without having to resort to more or less stupid tricks. On Linux, you can just scan the /proc directory. This is what the procps package does. From the command line: 310 $ ps -o cmd --no-heading 867 metalog [MASTER] In the pyNMS package on sourceforge (http://sourceforge.net/projects/pynms) there is a module called Linux.procfs, and in it there is an object called "ProcStat" that lets you get the process info easily (if running on Linux). Python> import procfs Python> procfs.ProcStat(1) Python> pid1 = procfs.ProcStat(1) Python> print pid1 cmdline: init [3] cmaj_flt: 63690958 cmin_flt: 186761321 cnswap: 0 command: (init) eip: 35 esp: 43 exit_signal: 0 flags: 256 it_real_value: 0 maj_flt: 224 min_flt: 1963 mm_end_code: 134538444 mm_start_code: 134512640 mm_start_stack: 3221225232 nice: 0 nswap: 0 pgrp: 0 pid: 1 ppid: 0 priority: 15 processor: 0 rlim_cur: 4294967295 rss: 117 session: 0 sig_blocked: 0 sig_catch: 671819267 sig_ignore: 1475401980 sig_pending: 0 start_time: 42 state: S tms_cstime: 731277 tms_cutime: 9593767 tms_stime: 237 tms_utime: 75 tty_nr: 0 tty_pgrp: -1 vsize: 1429504 wchan: 3222957162 -- -- ~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: how to start a new process while the other ist running on
On 2004-12-22, Erik Geiger <[EMAIL PROTECTED]> wrote: > Donn Cave schrieb: > >> In article <[EMAIL PROTECTED]>, Erik Geiger <[EMAIL PROTECTED]> >> wrote: > [...] >> > Thats what I've tried, but it did not work. Maybe it's because I want to >> > start something like su -c '/path/to/skript $parameter1 $parameter2' >> > user > >> Unfortunately this particular case kind of dilutes the advantages >> of spawnv. In the common case, parameter1 et al. would be submitted >> directly as the parameter list. I believe it may be clearer to start >> with to think about the spawnv() function - >>os.spawnv(os.P_NOWAIT, path, [cmdname, parameter1, parameter2]) >> >> If one of the parameters is itself another command, then of course >> it has to be rendered as a string >>os.spawnv(os.P_NOWAIT, '/bin/su', ['su', '-c', '%s %s %s' % (cmd, >> parameter1, parameter2)]) >> so you have almost as much work to scan the parameters for shell >> metacharacters as you would have with system(). >> >>Donn Cave, [EMAIL PROTECTED] > OK, thats too high for me ;-) > > Is the %s the variable for the following commands/parameters? If I have > three parameters, I'll need one more %s? Where to write the user for the su > command? > > Well, I've given up ;-) > Hey, don't give up. There is help. ;-) guess... There is a package called pyNMS (http://sourceforge.net/projects/pynms) That has a module called "proctools", and also one called "sudo". Once you set up sudo correctly, you can do what you want easily. However, be aware that proctools spawns a process with the subprocess stdio connected to _your_ parent process, and does not inherit the stdio of the parent. So, if the subprocess writes a lot of stuff you must read it, or the subprocess will block. However, there is some (perhaps buggy) support for asynchronous operation where those reads happen automatically (on Linux). -- -- ~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: Lambda going out of fashion
On 2004-12-23, Stephen Thorne <[EMAIL PROTECTED]> wrote: > Hi guys, > > I'm a little worried about the expected disappearance of lambda in > python3000. I've had my brain badly broken by functional programming > in the past, and I would hate to see things suddenly become harder > than they need to be. I use Python lambda quite a bit, and I don't understand the recent noise about problems with it, and its removal. I don't have a problem with lambdas. My personal gripe is this. I think the core language, as of 2.3 or 2.4 is very good, has more features than most people will ever use, and they (Guido, et al.) can stop tinkering with it now and concentrate more on the standard libraries. -- -- ~~~~~ Keith Dart <[EMAIL PROTECTED]> public key: ID: F3D288E4 = -- http://mail.python.org/mailman/listinfo/python-list
Re: Python docs [was: function with a state]
Please stop cross-posting this stuff! -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Microsoft Windows secretly downloading childporn to your computer ?!
Steve Hayes writes: > On Tue, 1 Dec 2015 03:19:39 +0100, "Skybuck Flying" > wrote: >>The question is: >> >>Is Microsoft [snip] > > You download things FROM a computer, you upload them TO a computer. > > Since you don't even know that much about computers, anything else you > say is obviously not worth readin. Nor is it worth replying to. *Please* don't feed the troll. (Followups set.) -- Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst> Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister" -- https://mail.python.org/mailman/listinfo/python-list
Re: Is Microsoft Windows secretly downloading childporn to your computer ?!
Juha Nieminen writes: > In comp.lang.c++ Steve Hayes wrote: >> You download things FROM a computer, you upload them TO a computer. > > It's a matter of perspective. If a hacker breaks into your computer and > starts a download from somewhere else into your computer, isn't the hacker > "downloading" things to your computer? My understanding of the word "downloading" has always been STOP FEEDING THE TROLL! -- Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst> Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister" -- https://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: Examples of Quality Technical Writing
"javuchi" <[EMAIL PROTECTED]> writes: > Why do you have such a need of being hating everything and everybody > and expressing it so offen? > Can you live without hate? > Can you let others live without your hates? Xah Lee is a well-known troll. Replying to him is a waste of time. Please just ignore him. (A killfile is an effective way to do so.) -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Xah's Edu Corner: IT Industry Predicament
"Xah Lee" <[EMAIL PROTECTED]> writes: [the usual] ___ /| /| | | ||__|| | Please do | / O O\__ NOT | / \ feed the| / \ \ trolls | / _\ \ __| /|\\ \ || / | | | |\/ || / \|_|_|/ \__|| / / \|| || / | | /|| --| | | |// | --| * _| |_|_|_| | \-/ *-- _--\ _ \ // | / _ \\ _ // |/ * / \_ /- | - | | * ___ c_c_c_C/ \C_c_c_c____ -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best IDE for Python
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: >> Hi All, What do you find the best IDE for creating web applications in >> Python is? Preferably FOS IDE. >> >> Cheers > > I like ActiveState's Komodo. It's heavyweight and not free ($30 for > the personal edition) but it also supports Perl, Ruby, PHP and TCL. I > started using it mostly on Windows but I've used it on Linux more > recently (and it runs on Solaris and OSX now too). > It has all the bells and whistles and probably won't appeal too much to > hardcore emacs/vim people because it is so GUI oriented and nowhere > near as fast. Also, it's text editor is similar to the ones you get > with other popular IDE's like MS DevStudio and Eclipse i.e. not very > powerful. > I've used it extensively with Python and it handles whitespace > indentation beautifully. I like that it also supports Perl because I > use Perl quite a bit too. > That being said, I'm going to give Wing IDE a try at some point soon. > Have you tried SPE (Stani's Python Editor) http://stani.be/python/spe/ Free, and available for Linux, Mac, and Windows. -- http://mail.python.org/mailman/listinfo/python-list
Re:
wrote: > Hi guys, > > we are looking for a python developer for a European project. This > project is multilangual and free it is called EuroCv and it need a > module for exporting data in PDF. As web developer I try to create this > module but It's too complicate for me. Check out the service > www.eurocv.eu for more details. Contact us by Skype chat system our > nick is eurocv. > > Thanks > have you looked at the reportlab module? http://www.reportlab.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: can't open chm files all of a sudden
On Wed, 04 Oct 2006 16:34:43 +, Dennis Lee Bieber wrote: > On Wed, 04 Oct 2006 15:55:11 GMT, John Salerno > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > >> the files in a day or two). All I've installed/uninstalled since then >> was HTML Kit. I'm not on a network, it's just me. I redownloaded the chm >> file for Python24 and it does the same thing. >> > Try some other help files... I'd be likely to suspect it was HTML > Kit that overlayed some DLL in the help system... > > (Yeesh -- Just looked at the HTML Kit home page... In the words of Clara > Peller "Where's the beef?"... Lots of glitzy public relations copy, but > no details on exactly what it does, what tools it competes with, etc.) I used HTMLKit when I still used Windows, and liked it a lot. It's really a great HTML/PHP, etc. editor, if you can get past the front page. That being said (if I remember correctly) hh.exe is a part of htmlkit, and may have been the the cause of your problem by making itself the default chm reader. (Check your settings under files to see what you have as the default reader now. (and sorry, forgot how to do that, it's been almost two years since I've had to fiddle with Windows, so I'm not sure of the exact place to check for it.)) Keith -- http://mail.python.org/mailman/listinfo/python-list
webbrowser problems
I’m having trouble trying to pass arguments to a file path url… ie c:/testPython/test.html?testArg=testValue import webbrowser webbrowser.open(“c:/testPython/test.html”) # Works webbrowser.open(“c:/testPython/test.html?testArg=testValue”) # Doesn’t Work webbrowser.get() # Returns a WindowsDefault instance I looked into the webbrowser python command, and see that windows default just does a os.filestart(url) call. If I use the command prompt to try and mimic this it also errors out which is what I would expect. But if I run this from the command line… it seems to work fine: c:\Program Files\Internet Explorer\iexplore.exe c:/testPython/test.html?testArg=testValue I assume this is because the url is being passed as an argument to the iexplore.exe instead of trying to find a file call that url. I guess what I need to do is try and find the file path to the default browser so that I can build my own string to execute via command line. But I have no clue as to how I would go about getting that… and also I want to make sure its still going to be cross platform compatible. Any help? Ideas? Thanks Keith -- http://mail.python.org/mailman/listinfo/python-list