Re: Learning Python for a new beginner
Hi Lisa, > I hear that Python is one of the easiest languages to learn. It is > easier than PHP or Pearl? Most people think so, though personal experiences can vary. I played around wit hPerl for some time but never got really far. Python, on the other hand, attracted me from the first minute. Don´t be fooled: Learning and mastering Python requires work and brains, but that is the price you have to pay anyways. It helps you to develop at your personal pace from beginner to advanced, and it does so without throwing completely new constructs in your brain every day. It comes bundled with some built-in tools for writing, editing and running programs, good and user-friendly documentation (which appears to be better organized than Perl´s doc), and a lot of built-in functions to handle data structures and files in an easily tractable, easily remembered way. By learning Python, you will also learn some advanced concepts (if you want) that could help you to understand the basics of more advanced languages like C++ and Java. Combine that with fine community support and a lot of free third-party modules (you won´t need all of them on your first day, but it is nice to know that they are out there), and I would say that you have all you need in the best way you can get to start your programming career. BW Piet -- http://mail.python.org/mailman/listinfo/python-list
Error on xpath-ing a DOM with namespaces
Hello, Via Xpath, I want to access nodes which have a namespace prefix. THe document at hand is an Xsl-FO document. I tried the following: from xml.dom import minidom from xml.xpath import Evaluate from xml import sax parser = sax.make_parser() parser.setFeature(sax.handler.feature_namespaces,1) parser.setFeature(sax.handler.feature_namespace_prefixes,1) doc = minidom.parse("fo-file.xml",parser) #everything ok up to here outlines = Evaluate("//fox:outline",doc.documentElement) I get a RuntimeException in [pythonpath]\Lib\site-packages\_xmlplus\xpath\ParsedNodeTest.py, line 168 because of an undefined namespace "fox" In the xml document, the namespace "fox" is defined, e.g. it has been assigned an URL via xmlns:fox. I have installed pyxml 0.83 and 4suite 1.0a3. Since I never had to deal with namespaces before, I have no real idea what to try next. I don't like to use the DOM functions like getElementsByTagNameNS, because xpath is more flexible. Is this error above caused by the employed xml tools, or have I missed something basic about xpath and namespaces in general? Many thanks in advance Piet -- http://mail.python.org/mailman/listinfo/python-list
Re: Error on xpath-ing a DOM with namespaces
> NSS = {u'wsdl': u'http://schemas.xmlsoap.org/wsdl/'} > #""processorNss" = "namespace bindings to be used by the processor" > ctx = Context(wsdl_doc, processorNss=NSS) > Evaluate(u'wsdl:description/wsdl:documentation', context=ctx) > """ > > Should give you a start. Thanks a lot. I found a solution for my problem and lots of food for thought for improving my XML handling in general. Best regards Piet -- http://mail.python.org/mailman/listinfo/python-list
Re: Advantage of the array module over lists?
On Mar 17, 1:49 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > I doubt that. AFAIK both arrays and lists are continuous memory-areas, > that double (at least to a certain threshold or so) when reaching the > capacity limit. For what it's worth, lists over-allocate by ~1/8, and arrays by ~1/16. (Details in listobject.c:list_resize and arraymodule.c:array_resize.) -- http://mail.python.org/mailman/listinfo/python-list
Re: [ctpug] Introducing Kids to Programming: 2 or 3?
On Mon, Sep 27, 2010 at 5:48 PM, Marco Gallotta wrote: > > > We received a grant from Google to reach 1,000 kids in South Africa > with our course in 2011. People have also shown interest in running > the course in Croatia, Poland and Egypt. We're also eyeing developing > African countries in the long-term. This is really great news! Sounds like you guys have been doing an amazing job. As for your course notes and exercises, targeting 3.x sounds like the more productive choice: - As you point, many of the changes in 3.x make it directly more sensible and suitable for teaching purposes. The avoidance of 2.x's str/unicode confusion should be one of the biggest points for first-time programmers, but all the other special cases and legacy cruft that's been removed from 3.x will help reduce distractions to learning. - As Niel Muller points out, library compatibility with 3.x is relatively good, and will only grow with time, while 2.x will become increasingly unsupported. The fact that you'll probably have to stick for the next few years with the material you produce now should seal the deal in favor of targeting 3.x. - The students whose learning advances far enough that they want to play around with more involved Python libraries are also the ones for whom learning 2.x/3.x differences shouldn't pose any difficulty anymore: if they *really* hit a sticking point that requires the use of 2.x (for now), they can just use it, without having to saddle all beginning learners with it. I doubt that students will be confused much more by seeing 2.x code all over the web, though; it's not really any different to 2.x users seeing code that uses old-style classes, string exceptions, and so on. There's not much that can be done about this: at some point, interested learners will have to encounter old idioms and legacy code, regardless of the choice of 2.x or 3.x now. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
kj writes: > This means that no library code can ever count on, for example, > being able to reliably find the path to the file that contains the > definition of __main__. That's a weakness, IMO. On Unix based systems there is no reliable way to find out this information. So how could Python reliably supply this? -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I display unicode value stored in a string variable using ord()
"Blind Anagram" writes: > This is an average slowdown by a factor of close to 2.3 on 3.3 when > compared with 3.2. > > I am not posting this to perpetuate this thread but simply to ask > whether, as you suggest, I should report this as a possible problem with > the beta? Being a beta release, is it certain that this release has been compiled with the same optimization level as 3.2? -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: "convert" string to bytes without changing data (encoding)
Ross Ridge writes: > > But it is in fact only stored in one particular way, as a series of bytes. > No, it can be stored in different ways. Certainly in Python 3.3 and beyond. And in 3.2 also, depending on wide/narrow build. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: "convert" string to bytes without changing data (encoding)
Heiko Wundram writes: > Reading from stdin/a file gets you bytes, and > not a string, because Python cannot automagically guess what format the > input is in. > Huh? Python 3.3.0rc1 (v3.3.0rc1:8bb5c7bc46ba, Aug 25 2012, 10:09:29) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> x = input() abcd123 >>> x 'abcd123' >>> type(x) >>> y = sys.stdin.readline() abcd123 >>> y 'abcd123\n' >>> type(y) -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: What’s the differences between these two pieces of code ?
iMath writes: > What’s the differences between these two pieces of code ? > (1) > for i in range(1, 7): > print(2 * i, end=' ') > > > (2) > for i in range(1, 7): > print(2 * i, end=' ') > print() > > > when executed both respectively in Python shell ,I get the same effect . > Who can tell me why ? The first one gives a syntax error (IndentationError: expected an indented block) -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)
Ismael Farfán writes: > How about something like this: > os.system ( 'ssh remoteuser@remote python remote.py "arg 1" "arg 2" "arg 3"' ) That won't work. You need an additional level of quoting because ssh is also a shell so it adds another level of interpretation. The following works: os.system('''ssh remoteuser@remote "python remote.py 'arg 1' 'arg 2' 'arg 3'"''') -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)
Chris Rebert writes: > Use the `subprocess` module instead (with shell=False). You then won't > need to worry about escaping. > http://docs.python.org/library/subprocess.html You will still need to worry about escaping because on the remote end you invoke ssh which is a shell. The obvious call: subprocess.call(["ssh", "remoteuser@remote", "python", "remote.py", "arg 1", "arg 2", "arg 3"]) won't work because ssh will break up the "arg n" strings. You need to use "'arg n'" or put the whole python command in a string like: "python TEST/testargs.py 'arg 1' 'arg 2' 'arg 3'" -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Should one always add super().__init__() to the __init__?
Chris Angelico writes: > On Sun, Sep 30, 2012 at 3:17 AM, Steven D'Aprano > wrote: >> No. Only add code that works and that you need. Arbitrarily adding calls >> to the superclasses "just in case" may not work: >> >> py> class Spam(object): >> ... def __init__(self, x): >> ... self.x = x >> ... super(Spam, self).__init__(x) >> ... >> py> x = Spam(1) >> Traceback (most recent call last): >> File "", line 1, in >> File "", line 4, in __init__ >> TypeError: object.__init__() takes no parameters > > That's because you're subclassing something that doesn't take > parameters and giving it parameters. Of course that won't work. The > normal and logical thing to do is to pass on only the parameters that > you know the parent class expects... but that implies knowing the > parent, so it's kinda moot. It is not necesarily calling the parent class. It calls the initializer of the next class in the MRO order and what class that is depends on the actual multiple inheritance structure it is used in, which can depend on subclasses that you don't know yet. This makes it even worse. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: simple string format question
Adrien writes: > print "{:.3g}".format(2.356) # this rounds up But: >>> print "{:.3g}".format(12.356) 12.4 >>> print "{:.3g}".format(123.356) 123 -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: eGenix mx Base Distribution 3.2.5 (mxDateTime, mxTextTools, etc.)
"M.-A. Lemburg" writes: > > > ANNOUNCING > >eGenix.com mx Base Distribution > > Version 3.2.5 for Python 2.4 - 2.7 > >Open Source Python extensions providing > important and useful services > for Python programmers. > > This announcement is also available on our web-site for online reading: > http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.5-GA.html It says 3.2.4. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: How to call ltm function using rpy package in python
Mohit Khanna writes: > I am trying the following code-- > > from rpy import * > r.library("ltm") > > dat= #some data frame or matrix > r.ltm(r('dat~z1')) > > error coming is--- > RPy_RException: Error in eval(expr, envir, enclos) : object 'dat' not found > > Please tell me the right way to call ltm function using rpy library Your problem is that the 'dat' object is in the Python world but not in the R world. However, the expression r('dat~z1') is looking for a 'dat' object in the R world. So you must copy the Python object to the R world. I don't know if this will work in rpy, but it does work in rpy2. Rpy2 has much better possibilities than rpy. But just try it: r['=']('dat', dat) r.ltm(r('dat~z1')) -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Loading a PKCS#1 public key using M2Crypto
Marc Aymerich writes: > Hi, > I've been trying very, very hard to load an RSA key using M2Crypto but > without any success. > > basically this is what I'm trying to do: >>>> from M2Crypto import BIO, RSA >>>> >>>> pubkey = """-BEGIN RSA PUBLIC KEY- > ... MIIBCgKCAQEApwotnfHT9RAmxnuaGEMdI3lYPYE4aaqSD9v4KbTh1E7Le3GNJQb7 > ... wCpmDe8+n8S5Kp/gBEpWiYuvsVA/T4KseoX7NMcacP+DJMwjmNd9U58USn2vLz0Z > ... TMtXpc/FUhW5PZdgCiuNzw6IFgGn9ZCCv85jjUIW3KD8fUNdrUfVSv4olDoL9NkR > ... dTRg3Os/znC6l0gv/mqnLaqj2bJ/tx47kUmj6Oq13JuEq34T+DVmsUCFVundQnRp > ... c/vVEqQot7Rvj9UmSvTi4WKt/qxiAnyZf3gXOdrXvxfVTGzD5I/Xg+By+a4C2JwB > ... A5RGvZP3fyfhkCnnhFDpfws5lc20FA6ryQIDAQAB > ... -END RSA PUBLIC KEY-""" >>>> >>>> bio = BIO.MemoryBuffer(pubkey.encode('ascii')) >>>> RSA.load_pub_key_bio(bio) > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.7/dist-packages/M2Crypto/RSA.py", line 422, in > load_pub_key_bio > rsa_error() > File "/usr/lib/python2.7/dist-packages/M2Crypto/RSA.py", line 302, in > rsa_error > raise RSAError, m2.err_reason_error_string(m2.err_get_error()) > M2Crypto.RSA.RSAError: no start line > > > Reading all whats in Internet about this problem it seems that my key is in > PKCS#1 format but M2Crypto only reads X.501 RSA keys. > > I know that python-crypto doesn't have any problem loading this key, but I'll > prefer to stick with M2Crypto because I already have lots code using M2Crypto. > > So my question is, is there any way to load this key using M2Crypto? Can I > convert somehow the key to X.501? > Converting to X.501 isn't difficult (assuming this is a 2048 bit key): Get rid of the 'RSA' in header and trailer Prepend X.501 header 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A' to the data Reformat the lines to 64 characters. from M2Crypto import BIO, RSA pubkey="""-BEGIN RSA PUBLIC KEY- MIIBCgKCAQEApwotnfHT9RAmxnuaGEMdI3lYPYE4aaqSD9v4KbTh1E7Le3GNJQb7 wCpmDe8+n8S5Kp/gBEpWiYuvsVA/T4KseoX7NMcacP+DJMwjmNd9U58USn2vLz0Z TMtXpc/FUhW5PZdgCiuNzw6IFgGn9ZCCv85jjUIW3KD8fUNdrUfVSv4olDoL9NkR dTRg3Os/znC6l0gv/mqnLaqj2bJ/tx47kUmj6Oq13JuEq34T+DVmsUCFVundQnRp c/vVEqQot7Rvj9UmSvTi4WKt/qxiAnyZf3gXOdrXvxfVTGzD5I/Xg+By+a4C2JwB A5RGvZP3fyfhkCnnhFDpfws5lc20FA6ryQIDAQAB -END RSA PUBLIC KEY- """ pk = pubkey.split('\n') pk = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A' + ''.join(pk[1:-2]) pk = [pk[i:i+64] for i in range(0, len(pk), 64)] pk = '-BEGIN PUBLIC KEY-\n' + '\n'.join(pk) + '\n-END PUBLIC KEY-' bio = BIO.MemoryBuffer(pk) # pk is ASCII, don't encode key = RSA.load_pub_key_bio(bio) -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Loading a PKCS#1 public key using M2Crypto
Piet van Oostrum wrote: > Converting to X.501 isn't difficult (assuming this is a 2048 bit key): > Get rid of the 'RSA' in header and trailer > Prepend X.501 header 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A' to the data > Reformat the lines to 64 characters. This solution is a bit restricted as it only works if the key is 2048 bits and uses an exponent of 65537 (which is the default). Otherwise it fails. Here is a robust solution that works for all PKCS#1 keys. Instead of using a fixed X.501 header it calculates the header. We could do a complete ASN.1 encoding, but most of the parts are fixed. The only variable parts are two length fields. So I just plug these into the fixed stuff. This saves using one of the ASN.1 libraries. We do have to work in binary (DER format) instead of base64, however. from M2Crypto import BIO, RSA import base64 def der_length(length): """DER encoding of a length""" if length < 128: return chr(length) prefix = 0x80 result = '' while length > 0: result = chr(length & 0xff) + result length >>= 8 prefix += 1 return chr(prefix) + result pubkey="""-BEGIN RSA PUBLIC KEY- MIIBCgKCAQEApwotnfHT9RAmxnuaGEMdI3lYPYE4aaqSD9v4KbTh1E7Le3GNJQb7 wCpmDe8+n8S5Kp/gBEpWiYuvsVA/T4KseoX7NMcacP+DJMwjmNd9U58USn2vLz0Z TMtXpc/FUhW5PZdgCiuNzw6IFgGn9ZCCv85jjUIW3KD8fUNdrUfVSv4olDoL9NkR dTRg3Os/znC6l0gv/mqnLaqj2bJ/tx47kUmj6Oq13JuEq34T+DVmsUCFVundQnRp c/vVEqQot7Rvj9UmSvTi4WKt/qxiAnyZf3gXOdrXvxfVTGzD5I/Xg+By+a4C2JwB A5RGvZP3fyfhkCnnhFDpfws5lc20FA6ryQIDAQAB -END RSA PUBLIC KEY- """ pk = pubkey.split('\n') pk = '\0' + base64.decodestring("".join(pk[1:-2])) pk = '\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00\x03' + \ der_length(len(pk)) + pk pk = '\x30' + der_length(len(pk)) + pk pk = '-BEGIN PUBLIC KEY-\n' + base64.encodestring(pk) + '-END PUBLIC KEY-' bio = BIO.MemoryBuffer(pk) key = RSA.load_pub_key_bio(bio) -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Loading a PKCS#1 public key using M2Crypto
Marc Aymerich writes: > Thank you very much Piet, > I'm just starting to grasp these cryptography related concepts and your code > is helping me a lot to understand how to handle these keys in a low level. > > I'm updating my code incorporating your new contribution! > > Just to let you know, during my previous research I had found a python-Crypto > related solution that also uses DER and ASN.1 [1], but it uses a different > approach (I guess). I suspect that this approach is also possible with > M2Crypto because it has a method for constructing RSA keys [2]. > > [1] http://stackoverflow.com/a/10574723 > [2] > http://www.heikkitoivonen.net/m2crypto/api/M2Crypto.RSA-module.html#new_pub_key > new_pub_key could be used but then you would have to do an ASN.1 parse of the DER format of your key to get the n and e values. AFAICT M2Crypto doesn't have methods to do this, so you would need to use one of the python ASN.1 libraries (or write that part yourself). -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Forcing Python to detect DocumentRoot
Ferrous Cranus writes: > This is addon domain's counter.py snippet tried to load an image mail.png and > failed because it cant see past its document root > > > # render html template and print it > data = f.read() > counter = ''' > mailto:supp...@superhost.gr";> src="/data/images/mail.png"> > > > Αριθμός Επισκεπτών > %d ''' % hits[0] > > > While from within the same counter.py file > > # open html template file > f = open( '/home/nikos/public_html/test.txt' ) > > opens OK the page file which is also past addons domain's document root > > Can you help counter.py to load the image? Why does it fail to load it? > Python can have access to ANY filesystempath , no matter from what folder > counter.py script runs from. Correct? That piece of code is not opening the image file. It just issues the URL for the image file. The file will then be loaded by the browser in a new request. The image should be at /home/nikos/public_html/data/images/mail.png P.S. I don't understand what you mean by "addon domain". -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Forcing Python to detect DocumentRoot
Ferrous Cranus writes: > Ok i see its just a convention. > Can you help on this: > > so we need to remove since the apache cant > see to open it and let Python open it which we know it can because it has > access to any system file the user has access too. > > httpd cannot open this file because the location of the image is past the > addon domain's Document Root. > > /home/nikos/public_html/cafebar-idea.gr = Addon's Domain Document Root > > /home/nikos/public_html/data/images/mail.png = where the image file is > located > > and the python scipt is on: > > /home/nikos/public_html/cafebar-idea.gr/cgi-bin/counter.py > > So if a python script can open any file the user has access too then we need > a "python way" of opening this file. So why don't you put the image at /home/nikos/public_html/cafebar-idea.gr/data/images/mail.png? -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Uniquely identifying each & every html template
Ferrous Cranus writes: > This python script acts upon websites other people use and every html > templates has been written by different methods(notepad++, > dreamweaver, joomla). > > Renames and moves are performed, either by shell access or either by > cPanel access by website owners. > > That being said i have no control on HOW and WHEN users alter their html > pages. Under these circumstances the only way to solve it is to put an identification *inside* the file and make sure it will not be changed. It could for example be some invisible piece of HTML, or an attribute to some tag. If that can't be done the problem cannot be solved and it makes no sense keeping asking the same question over and over again. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Why do class methods always need 'self' as the first parameter?
Chris Torek writes: [snip] > Instead, we have a syntax where you, the programmer, write out the > name of the local variable that binds to the first parameter. This > means the first parameter is visible. Except, it is only visible > at the function definition -- when you have the instance and call > the instance or class method: > > black_knight = K() > black_knight.meth1('a', 1) > black_knight.meth2(2) > > the first parameters (black_knight, and black_knight.__class__, > respectively) are magic, and invisible. > > Thus, Python is using the "explicit is better than implicit" rule > in the definition, but not at the call site. I have no problem with > this. Sometimes I think implicit is better than explicit. In this > case, there is no need to distinguish, at the calls to meth1() and > meth2(), as to whether they are "class" or "instance" methods. At > the *calls* they would just be distractions. It *is* explicit also at the call site. It only is written at the left of the dot rather than at the right of the parenthesis. And that is necessary to locate which definition of the method applies. It would be silly to repeat this information after the parenthesis. Not only silly, it would be stupid as it would be a source of errors, and an example of DRY. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Closures and Partial Function Application
Travis Parks writes: > I also like partial function application. What is the easiest way of > achieving this in Python? Would it look something like this: > > def foo(x, y): > return x + y > > xFoo = lambda y: foo(10, y) from functools import partial xfoo = partial(foo, 10) -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing WebDAV server
"Fokke Nauta" writes: > INFO:DAVServer.fshandler:get_data: d:\webdav not found > XXX --- [07/Sep/2011 11:57:48] - Mozilla/5.0 UJindows NT 5.1; rv:6.0.1> > Gecko/ > 20100101 Firefox/6.0.1 - "GET / HTTP/1.1" 404 - > XXX --- [07/Sep/2011 11:57:52] - Mozilla/5.0 > Gecko/ > 20100101 Firefox/6.0.1 - "GET / HTTP/1.1" 404 - > >From the log it looks like you are trying to access the server with the url: http://localhost:8008/ or something similar. This won't work as you would try to access the root of your webdav directory in this way (i.e. D:/webdav). The webdav server can only serve files, not directories, so you would have to access http://localhost:8008/somefile.txt where somefile.txt is a file in D:/webdav. This only applies to acces using a browser. If you access the server through a webdav-aware client (for example the Finder on Mac OS X, or probably the Windows Explorer) it can serve the contents of the directory. -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Why do class methods always need 'self' as the first parameter?
"Prasad, Ramit" writes: > It seems to me that if I add a function to the list of class attributes it > will automatically wrap with "self" but adding it to the object directly will > not wrap the function as a method. Can somebody explain why? I would have > thought that any function added to an object would be a method (unless > decorated as a class method). The special magic to transform a function into a method is only applied for functions found as attributes of the class, not for instance attributes. It is a matter of design. > Hmm, or does the decoration just tell Python not to turn an object's function > into a method? I.e. Is the decorator basically just the syntactic sugar for > doing the above? The classmethod decorator transforms the method (or actually the function) into a different kind of object (a class method). -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: String to Dictionary conversion in python
Rustom Mody writes: > On Saturday, September 16, 2017 at 2:04:39 AM UTC+5:30, jlad...@itu.edu wrote: > Yeah… I used to think thus > But literal_eval has excessive crud in its error messages: > >>>> from ast import literal_eval > >>>> literal_eval("{'x':1}") > {'x': 1} > > Ok… > >>>> literal_eval("{x:1}") > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.7/ast.py", line 80, in literal_eval > return _convert(node_or_string) > File "/usr/lib/python2.7/ast.py", line 63, in _convert > in zip(node.keys, node.values)) > File "/usr/lib/python2.7/ast.py", line 62, in > return dict((_convert(k), _convert(v)) for k, v > File "/usr/lib/python2.7/ast.py", line 79, in _convert > raise ValueError('malformed string') > ValueError: malformed string > You can catch the exception and print a nice error message: from ast import literal_eval def literal(s): try: return literal_eval('{'+s+'}') except Exception as e: print "%s: %s" % (type(e).__name__, ', '.join(e.args)) >>> literal("'x':1") {'x': 1} >>> literal("x:1") ValueError: malformed string But in non-interactive use you probably want to propagate the exception. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Problem with subprocess.Popen and EINTR
I am using Python 2.7.14 on MacOS Sierra. I have a small Python program that calls a shell script in a loop with a time.sleep() in it. The shell script is called with subprocess.Popen(), followed by a subprocess.wait(). No information is exchanged with the shell script. Once in a while I send a SIGINT to the program to cancel the sleep. I don't know if the sleep is active at the time of the SIGINT, but most of the time it will be as it takes much more time than the shell script. I do this by having a handler for the SIGINT which does nothing. It is just there to have the SIGINT silently cancel the sleep. Now after weeks of running correctly it crashed. It appears that the SIGINT came during the Popen. This causes a system call in the Popen to be terminated with EINTR and Popen then retries that system call, but unfortunately it fails. It seems to me that this could be a bug. Here is the traceback: Traceback (most recent call last): File "/Users/piet/bin/smoveinloop.py", line 86, in main() File "/Users/piet/bin/smoveinloop.py", line 65, in main task = subprocess.Popen([TASK], executable=TASK) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 390, in __init__ errread, errwrite) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1001, in _execute_child data = _eintr_retry_call(os.read, errpipe_read, 1048576) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 121, in _eintr_retry_call return func(*args) OSError: [Errno 22] Invalid argument TASK is a string with the name of the shell script. Can anybody shed some light on this? -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Problem with subprocess.Popen and EINTR
Cameron Simpson writes: [...] > What if you did this: > > os.signal(SIGINT, SIG_IGN) > ... code code code, including the Popen/wait ... > old_handler = os.signal(SIGINT, do_nothing_handler) > sleep(...) > os.signal(SIGINT, old_handler) > > SIG_IGN is different from a do-nothing handler; it prevents the process > seeing the signal at all, and therefore prevents the signal interrupting > system calls. > > So you activate your dummy-quit-sleeping function only around the sleep > itself. Thanks. That is a good idea. I'll try that out. Or I could first try to switch to Python 3, as Chris suggested, to see if that makes the problem disappear. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Something wrong with the PIP, lots of friend have the same problem
Wentao Liang writes: > even though I try to upgrade PIP[cid:beb9e7c5-7d98-4506-ba67-9e67890edec1] > > > From: Wentao Liang > Sent: Sunday, 21 August 2016 4:35:31 PM > To: python-list@python.org > Subject: Something wrong with the PIP, lots of friend have the same problem > > > [cid:1c20248f-a678-40c0-9563-da4f8a1ef3bd] > Is it the problem from PIP itself, or I used it in a wrong way? [😊] > > Looking forwards to your reply! > > Thank you > > Wentao Liang Without more information it is difficult to say. What command did you use and what was the result? [Maybe you tried to include images in your post/mail but they did not come through. Just copy/paste the text.] -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Expression can be simplified on list
Daiyue Weng writes: > Hi, I found that when I tried to make an equality test on empty like, > > if errors == []: > > PyCharm always warns me, > > Expression can be simplified. > > I am wondering what's wrong and how to fix this? > It is not wrong, but it can be simplified to just: if errors: This is quite usual in Python, but some people prefer the more elaborate form, or something like: if len(errors) == 0: -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Facing an Error after migrating from python 3.4.1 to python 3.6.6 ( Failed to import the site module )
sandeep.ba...@gmail.com writes: > ``` > Error code: > -- > > > Traceback (most recent call last): > File > "C:\Users\sandeep\AppData\Local\Programs\Python\Python36-32\Lib\site.py", > line 73, in import os > File > "C:\Users\sandeep\AppData\Local\Programs\Python\Python36-32\Lib\os.py", line > 652, in > from _collections_abc import MutableMapping > File > "C:\Users\sandeep\AppData\Local\Programs\Python\Python36-32\Lib\_collections_abc.py", > line 58 > async def _coro(): pass > ^ > SyntaxError: invalid syntax > Failed to import the site module > > > After migrating from python 3.4.1 to python 3.6.6 > while Executing my project, I'm facing this issue and not able to > resolve it. Can i get any solution for this issue? Could it be that your PYTHONPATH environment variable is set to a directory in Python 3.4.1? -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Python read text file columnwise
shibashib...@gmail.com writes: > Hello >> >> I'm very new in python. I have a file in the format: >> >> 2018-05-31 16:00:0028.90 81.77 4.3 >> 2018-05-31 20:32:0028.17 84.89 4.1 >> 2018-06-20 04:09:0027.36 88.01 4.8 >> 2018-06-20 04:15:0027.31 87.09 4.7 >> 2018-06-28 04.07:0027.87 84.91 5.0 >> 2018-06-29 00.42:0032.20 104.61 4.8 > > I would like to read this file in python column-wise. > > I tried this way but not working > event_list = open('seismicity_R023E.txt',"r") > info_event = read(event_list,'%s %s %f %f %f %f\n'); Why would you think that this would work? See https://docs.python.org/3/library/csv.html Something like: #!/usr/bin/env python3 import csv with open('testcsv.csv', newline='') as csvfile: reader = csv.reader(csvfile, delimiter='\t') for row in reader: for i in range(2, 5): row[i] = float(row[i]) print(row) You could convert the first two columns to datetime format if you wish. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: The slash "/" as used in the documentation
r...@zedat.fu-berlin.de (Stefan Ram) writes: > The slash »/« as used in the documentation > > f( x, /, y ) > > is so ugly, it will disappear. Especially since it consumes > a comma as it it was a parameter itself. > > Possible alternatives include: > > A newline: > > f( x, > y ) > > A separate specification of the first non-positional parameter: > > f( x, y ) > # y > > (use "(" or ")" when all parameters are non-positional or > positional, respectively). > > A semicolon: > > f( x; y ) > > (the actual call still would use a comma there). > What are you talking about? What documentation? It seems to me you are talking about a completely different programming language, not python. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: The slash "/" as used in the documentation
Christian Gollwitzer writes: >>>> __import__( 'sys' ).version > '3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09) \n[GCC > 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]' >>>> help( __import__( 'math' ).sin ) > > > Help on built-in function sin in module math: > > sin(...) > sin(x) > > Return the sine of x (measured in radians). > > > The help is actually not written out to the terminal but, displayed in > the pager (less), and the first sin(...) is typeset in boldface. > > Christian Even simpler: >>> help(len) help(len) Help on built-in function len in module builtins: len(obj, /) Return the number of items in a container. both in python 3.6 and 3.7. This is weird. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Convert a list with wrong encoding to utf8
vergos.niko...@gmail.com writes: > Τη Πέμπτη, 14 Φεβρουαρίου 2019 - 8:56:31 μ.μ. UTC+2, ο χρήστης MRAB έγραψε: > >> It doesn't have a 'b' prefix, so either it's Python 2 or it's a Unicode >> string that was decoded wrongly from the bytes. > > Yes it doesnt have the 'b' prefix so that hexadecimal are representation of > strings and not representation of bytes. > > I just tried: > > names = tuple( [s.encode('latin1').decode('utf8') for s in names] ) > > but i get > UnicodeEncodeError('latin-1', 'Άκης Τσιάμης', 0, 4, 'ordinal not in > range(256)') > > 'Άκης Τσιάμης' is a valid name but even so it gives an error. > > Is it possible that Python3 a Unicode had the string wrongly decoded from the > bytes ? > > What can i do to get the names?! python3 >>> x = '\xce\x86\xce\xba\xce\xb7\xcf\x82 >>> \xce\xa4\xcf\x83\xce\xb9\xce\xac\xce\xbc\xce\xb7\xcf\x82' >>> b = bytes(ord(c) for c in x) >>> b.decode('utf-8') 'Άκης Τσιάμης' >>> -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: WebScrapping
Adrian Ordona writes: > Hi, > > I’m learning how to code and interested in web scrapping to gather data. > I’m running on Mac OS X 10.9.5 and python 3.7 terminal. > I’m trying to capture the name of the brand and price but i keep getting an > error (see below). > Traceback (most recent call last): > File "", line 1, in > File "/anaconda3/lib/python3.7/site-packages/bs4/element.py", line 1884, in > __getattr__ > "ResultSet object has no attribute '%s'. You're probably treating a list > of items like a single item. Did you call find_all() when you meant to call > find()?" % key > AttributeError: ResultSet object has no attribute 'find'. You're probably > treating a list of items like a single item. Did you call find_all() when you > meant to call find()? > > > Here’s what i got and thanks for the help > > import bs4 > from urllib.request import urlopen as uReq > from bs4 import BeautifulSoup as soup > > my_url = > 'https://www.newegg.com/Desktop-Graphics-Cards/SubCategory/ID-48?Tid=7709' > > uClient = uReq(my_url) > page_html = uClient.read() > uClient.close() > page_soup = soup(page_html, "html.parser") > records = [] > > containers = page_soup.findAll("div",{"class":"item-container"}) > > for container in containers: > brand = container.find('div', attrs={'class':'item-branding'}) > price = container.find('div', attrs={'class':'item-action'}) > records.append((brand, price)) > When I put this in a python file, and run it under python3.7, it works. It seems you were running this line by line interactively, tight? Could it be that you accidentally entered brand = containers.find('div', attrs={'class':'item-branding'}) i.e containers rather than container, because that would generate the error that you copied. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Testing the data type of a value
Luuk writes: > > After thinking about this, (i am prettry new to python), i was doing this: > >>>> print(type(5),type(int),type(5)==type(int),type(5)==int) > False True > > Can someone explain why type(5)==int evaluates to True ? > >>> print(int) The value of int is the class int, which is the class of 5, so type(5) is also that same class int. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Import module from a different subdirectory
Rich Shepard writes: > > $ python3 > Python 3.7.3 (default, Mar 26 2019, 06:40:28) [GCC 5.5.0] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> import sys >>>> sys.path > ['', '/home/rshepard/development/bustrac', '/usr/lib/python37.zip', > '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', > '/usr/lib/python3.7/site-packages'] > > When the gui/ subdirectory is the current working directory and I try to run > text_act_de.py I get the error that model.py is not found in the classes > subdirectory. I don't see how my directory structure, file locations, and > paths differ from your examples. In a previous message the error was that 'classes' wasn't found, not that model.py wasn't found in classes, i.e. it was the same error as Peter got. So to get this working you must make sure 'classes' is inside a directory that is in sys.path, for example by adding: sys.path.insert(0, '..') -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Why is augmented assignment of a tuple with iterable unpacking invalid syntax?
Eugene Alterman writes: > a = 1, 2, 3 > > b = *a, # assignment - OK > b += *a, # augmented assignment - syntax error > > Need to enclose in parenthesis: > > b += (*a,) > > Why isn't it allowed with an augmented assignment, while it is OK with a > regular assignment? > Syntactically (i.e. according to the grammar): The right-hand side of an assignment has as one of the alternative a starred_expression, which includes starred and unstarred expressions. The right-hand side of an augmented assignment has an expression_list there. (The other option is both cases is a yield_expression.) And if it is a list (i.e. there is a comma in it), it is a tuple. Semantically: x += y is more or less equivalent to x = x + y, except that x is only evaluated once, and y is treated as a unity (think implicit parentheses around it). So the y is basically part of an expression. But starred expressions are not allowed in expressions, except within explicit parentheses. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: pandas loc on str lower for column comparison
Sayth Renshaw writes: > Hi > > I am importing 4 columns into a dataframe from a spreadsheet. > > My goal is to create a 5th column with TRUE or False if column 4 (str) > matches column 3. > > Trying to leverage this answer https://stackoverflow.com/a/35940955/461887 > > This is my code > > import pandas as pd > > xls = pd.ExcelFile("Melbourne.xlsx") > df = xls.parse('Sheet1', skiprows= 4) > df1 = df[['UID','Name','New Leader','Current Team', 'New Team']] > df1['Difference'] = df1['Current > Team'].str.lower().str.replace('s/+',"") == df1['New > Team'].str.lower().str.replace('s/+',"") > > Which gives this error > > C:\Users\u369811\AppData\Local\Continuum\anaconda3\lib\site-packages\ipykernel_launcher.py:6: > SettingWithCopyWarning: > A value is trying to be set on a copy of a slice from a DataFrame. I think what happens is that df1 is not a copy of the subset of df that you want, but it is a VIEW on df instead. This means that df1 shares memory with df (for memory savings reasons). But if you would change this view by adding a column, where should it be put? In df? If so, where? So the correct way to do this is to make df1 a copy rather than a view. df1 = df.loc[:, ('UID','Name','New Leader','Current Team', 'New Team')] And than it should work. Except that the str.replace is wrong for what you want. It just replaces the literal string "s/+" with an empty string instead of white space. This was wrong in the stackoverflow post. To replace whitespace it should be str.replace('\\s+',"", regex=True). But simpler is to use str.strip(): df1['Difference'] = df1['Current Team'].str.lower().str.strip() == df1['New Team'].str.lower().str.strip() -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: pandas loc on str lower for column comparison
Piet van Oostrum writes: > So the correct way to do this is to make df1 a copy rather than a view. > > df1 = df.loc[:, ('UID','Name','New Leader','Current Team', 'New Team')] Or maybe even make an explicit copy: df1 = df[['UID','Name','New Leader','Current Team', 'New Team']].copy() -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: pandas loc on str lower for column comparison
Sayth Renshaw writes: > > I have tried both > > df1 = df.loc[:, ('UID','Name','New Leader','Current Team', 'New Team')] > df1['Difference'] = df1.loc['Current Team'].str.lower().str.strip() == > df1.loc['New Team'].str.lower().str.strip() > > and > > df1 = df[['UID','Name','New Leader','Current Team', 'New Team']].copy() > df1['Difference'] = df1.loc['Current Team'].str.lower().str.strip() == > df1.loc['New Team'].str.lower().str.strip() > > But on both occasions I receive this error. > > # KeyError: 'the label [Current Team] is not in the [index]' > > if I test df1 before trying to create the new column it works just fine. > > Sayth What does df1.info() produce? Which versions of numpy, scipy and pandas are you using? It would be helpful if you could make a copy of the original .xlsx file available. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: open, close
Max Zettlmeißl writes: > On Sat, Aug 31, 2019 at 2:22 PM Manfred Lotz wrote: >> >> Could I use the latter as a substitute for the with-construct? >> > > You can't use the second statement as a proper substitute for the first one. > > With the context manager, it is ensured that the file is closed. It's > more or less equal to a "finally" clause which closes the file > descriptor. > So as long as the Python runtime environment functions properly, it > will be closed. > > Your second statement on the other hand, is more or less equivalent to: > > f = open("foo.txt") > lines = f.readlines() > > Close won't be called. There is a difference here with the construct that the OP mentioned: lines = open("foo.txt").readlines() In that case the file COULD be closed, but there is no guarantee. It depends on garbage collection. In your case the file will not be closed as long as there is still a reference to it (as in f). When f disappears and all copies of it as well, the file COULD be closed similarly. On the other hand, the with statement guarantees that the file will be closed, so it is the preferred method. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: pandas loc on str lower for column comparison
Sayth Renshaw writes: > But on both occasions I receive this error. > > # KeyError: 'the label [Current Team] is not in the [index]' > > if I test df1 before trying to create the new column it works just fine. > What do you mean by testing df1? And could it be that 'Current Team' is spelled differently in the assignment than in the construction of df1? For example a difference in spaces, like a triling space or a breaking vs. non-breaking space? Please check that both are exactly the same. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: ``if var'' and ``if var is not None''
Hongyi Zhao writes: > Hi, > > The following two forms are always equivalent: > > ``if var'' and ``if var is not None'' > > Regards In [1]: var = 0 In [2]: if var: ...: print('True') ...: else: ...: print('False') False In [3]: if var is not None: ...: print('True') ...: else: ...: print('False') True -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: IDLE missing !
Alex writes: > I tried downloading the 3.7.4 version of python and and then tried to > install tensorflow but found that TF is only available for version > 3.5.x. > Thus uninstalled the 3.7.4. version and tried downloading multiple 3.5.x > version while all of them downloaded but I couldn’d find the IDLE shell > with them. Well, on MacOS 10.13.6 (High Sierra) tensorflow 1.14.0 does install on Python 3.7.4, and it also runs. It does give some warnings about deprecations, however. There is also a version 2.0RC which installs and runs without warnings. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: pandas loc on str lower for column comparison
Sayth Renshaw writes: > On Sunday, 1 September 2019 10:48:54 UTC+10, Sayth Renshaw wrote: >> I've created a share doc same structure anon data from my google drive. >> >> https://drive.google.com/file/d/0B28JfFTPNr_lckxQRnFTRF9UTEFYRUVqRWxCNVd1VEZhcVNr/view?usp=sharing >> >> Sayth > > I tried creating the df1 dataframe by using iloc instead of loc to avoid any > column naming issues. > > So i created a list of integers for iloc representing the columns in current > example. > > df1 = df.iloc[[0,1,5,6,7]] > > However, I ust be misunderstanding the docs > https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.iloc.html#pandas.DataFrame.iloc > Allowed inputs are: > > An integer, e.g. 5. > A list or array of integers, e.g. [4, 3, 0]. > > Because while it works I appear to grab all columns 13 when I requested 5. > UID Name FTE Agent ID Current Leader New Leader Current Team New > Team Current Site New Site Unnamed: 10 Unnamed: 11 Unnamed: 12 > > How do I misunderstand iloc? > That would select ROWS 0,1,5,6,7, not columns. To select columns 0,1,5,6,7, use two-dimensional indexes df1 = df.iloc[:, [0,1,5,6,7]] : selects all rows. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: pandas loc on str lower for column comparison
Piet van Oostrum writes: > That would select ROWS 0,1,5,6,7, not columns. > To select columns 0,1,5,6,7, use two-dimensional indexes > > df1 = df.iloc[:, [0,1,5,6,7]] > > : selects all rows. And that also solves your original problem. This statement: df1['Difference'] = df1.loc['Current Team'].str.lower().str.strip() == df1.loc['New Team'].str.lower().str.strip() should not use .loc, because then you are selecting rows, not columns, but: df1['Difference'] = df1['Current Team'].str.lower().str.strip() == df1['New Team'].str.lower().str.strip() -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: issue in handling CSV data
Sharan Basappa writes: >> >> Note that the commas are within the quotes. I'd say Andrea is correct: >> This is a tab-separated file, not a comma-separated file. But for some >> reason all fields except the last end with a comma. >> However, genfromtxt is not a full-fledged CSV parser. It does not obey quotes. So the commas inside the quotes ARE treated as separators. > Hi Peter, > > I respectfully disagree that it is not a comma separated. Let me explain why. > If you look the following line in the code, it specifies comma as the > delimiter: > > > my_data = genfromtxt('constraints.csv', delimiter = ',', dtype=None) > > > Now, if you see the print after getting the data, it looks like this: > > ## > [['"\t"81' '"\t5c'] > ['"\t"04' '"\t11'] > ['"\t"e1' '"\t17'] > ['"\t"6a' '"\t6c'] > ['"\t"53' '"\t69'] > ['"\t"98' '"\t87'] > ['"\t"5c' '"\t4b'] > ## 1) Where did the other fields (address, length) go? > > if you observe, the commas have disappeared. That, I think, is because > it actually treated this as a CSV file. 2) As I said above, if you choose ',' as separator, these will disappear. Similarly, if you choose TAB as seperator, the TABs will disappear. As the format is a strange mixture of the two, you can use either one. But if it would be read with a real CSV-reader, that obeys the quote convention, than using ',' as seperator will not work. Only TAB will work. But in both cases you would have to do some pre- or post-processing to get the data as you want them. > Anyway, I am checking to see if I can discard the tabs and process this. > I will keep everyone posted. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: numpy array - convert hex to int
Sharan Basappa writes: > On Sunday, 8 September 2019 11:16:52 UTC-4, Luciano Ramalho wrote: >> >>> int('C0FFEE', 16) >> 12648430 >> >> There you go! >> >> On Sun, Sep 8, 2019 at 12:02 PM Sharan Basappa >> wrote: >> > >> > I have a numpy array that has data in the form of hex. >> > I would like to convert that into decimal/integer. >> > Need suggestions please. >> > -- > > I am sorry. I forgot to mention that I have the data in a numpy array. > So, when I try to convert to int, I get the following error. > > sample code here > # > my_data_3 = int(my_data_2) > > my_data_4 = my_data_3.astype(np.float) > # > > Error here > ### > #np.core.defchararray.replace(my_data_2,",'') > 27 > ---> 28 my_data_3 = int(my_data_2) > 29 > 30 my_data_4 = my_data_3.astype(np.float) > TypeError: only length-1 arrays can be converted to Python scalars > # >>> my_data_2 = numpy.array(['0a', '2f', '38', 'ff']) >>> >>> a_toint = np.frompyfunc(lambda x: int(x, 16), 1, 1) >>> my_data_3 = a_toint(my_data_2) >>> my_data_3 array([10, 47, 56, 255], dtype=object) -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: phyton
tim.g...@quicknet.nl writes: > Hi everybody, > > For school i need to write the right code to get the following outcome. > Can someone help me with this > I can't find a solution to link the word high to 1.21. > > 11 print(add_vat(101, 'high')) > 12 print(add_vat(101, 'low')) > > Outcome: > > 122.21 > 110.09 > > Thanks! You could use a dictionary to connect the words to the values. As this is homework you have to do it yourself. Learn about dictionaries. Otherwise just use 'if'. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: pandas loc on str lower for column comparison
Sayth Renshaw writes: >> >> That actually creates another error. >> >> A value is trying to be set on a copy of a slice from a DataFrame. >> Try using .loc[row_indexer,col_indexer] = value instead >> >> See the caveats in the documentation: >> http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy >> >> So tried this >> df['c'] = df.apply(lambda df1: df1['Current >> Team'].str.lower().str.strip() == df1['New >> Team'].str.lower().str.strip(), axis=1) >> >> Based on this SO answer https://stackoverflow.com/a/46570641 >> >> Thoughts? >> >> Sayth > > This works on an individual row > df2 = df1.loc[(df1['Current Team'] == df1['New Team']),'D'] = 'Wow' > > But how do I apply it to the whole new column and return the new dataset? > > Trying to use lambda but it cannot contain assigment > df2 = df1.apply(lambda df1: [ (df1['Current Team'] == df1['New Team']) > ]['D'] = 'succeed') > df2 > > Confused > > Sayth df1['Difference'] = df1['Current Team'].str.lower().str.strip() == df1['New Team'].str.lower().str.strip() works on whole columns, not only on an individual row. xls = pd.ExcelFile("Melbourne.xlsx") df = xls.parse('Sheet1', skiprows= 4) df1 = df[['UID','Name','New Leader','Current Team', 'New Team']].copy() df1['Difference'] = df1['Current Team'].str.lower().str.strip() == df1['New Team'].str.lower().str.strip() print(df1.head()) -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: not working
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Supersedes: > > MRAB writes: >> >>> import re >> >>> pattern = r'[0-9]{4,6}' >> >>> pattern2 = r'[0-9][0-9][0-9][0-9]([0-9]){0,2}' >> >>> re.search(pattern, '1234') >> >> >>> re.search(pattern2, '1234') >> >>They look the same to me. > > |>>> import re > |>>> pattern = r'[0-9]{4,6}' > |>>> pattern2 = r'[0-9][0-9][0-9][0-9]([0-9]){0,2}' > |>>> re.search( pattern, '1234' ).group( 1 ) > |IndexError: no such group > |>>> re.search( pattern2, '1234' ).group( 1 ) > |>>> > The second pattern has parentheses, hence a group. The first doesn't. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: python is bugging
Dave Martin writes: > On Saturday, September 21, 2019 at 11:55:29 AM UTC-4, Dave Martin wrote: >> what does expected an indented block > > *what does an indented block mean? From the tutorial, https://docs.python.org/3/tutorial/ 3.2. First Steps Towards Programming: The body of the loop is indented: indentation is Python’s way of grouping statements. At the interactive prompt, you have to type a tab or space(s) for each indented line. In practice you will prepare more complicated input for Python with a text editor; all decent text editors have an auto-indent facility. When a compound statement is entered interactively, it must be followed by a blank line to indicate completion (since the parser cannot guess when you have typed the last line). Note that each line within a basic block must be indented by the same amount. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: python is bugging
Dave Martin writes: > On Saturday, September 21, 2019 at 12:44:27 PM UTC-4, Brian Oney wrote: >> On Sat, 2019-09-21 at 08:57 -0700, Dave Martin wrote: >> > On Saturday, September 21, 2019 at 11:55:29 AM UTC-4, Dave Martin >> > wrote: >> > > what does expected an indented block >> > >> > *what does an indented block mean? >> >> It means that the line of code belongs to a certain body as defined >> above its position. >> >> Please follow the tutorial. >> >> https://docs.python.org/3/tutorial/index.html > > df.to_csv(r"faststars.csv", index=None,header=True) > # starAbsMags=df['radial_velocity'] > > #GaiaPandasEscapeVelocityCode > > import pandas as pd > import numpy as np > from astropy.io import fits > import astropy > import matplotlib.pyplot as plt > > > #get the combined data and load the fits files > > fits_filename="Gaia_DR2/gaiadr2_100pc.fits" > df=pd.DataFrame() > with fits.open(fits_filename) as data: > df=pd.DataFrame(data[1].data) > df.columns=[c.lower() for c in df.columns] > print("Columns.") > print(df.columns.values) > print("n/n") > #print out some data meta info to see what we're working with > print("Number of stars:") > nstars=len(df) > print(nstars) > distances = (df['parallax']/1000) > starAbsMags =df['phot_g_mean_mag'] > df = df[(df.parallax_over_error > 10 ) ] > print("Left after filter: " +str(len(df)/float(nstars)*100)+" %") > df.hist(column='radial_velocity') > #fastdf=df[(df.radial_velocity > 200) | (df.radial_velocity < -200)] > fastdf=df[(df.radial_velocity > 550)|(df.radial_velocity<-550)] > print(len(fastdf)) > #print(fastdf)# starTemps=df['astrometric_weight_al'] > # df.plot.scatter("radial_velocity", "astrometric_weight_al", s=1, > c="radial_velocity", colormap="plasma") > # #df=df[(df.radial_velocity>=-550)] > # #plt.axis([0,400,-800,-550]) > # #plt.axis([0,400,550,800]) > # plt.xlabel('weight(Au)') > # plt.ylabel('Speed') > # plt.title('Gaia Speed vs Weight') > > this is my code the error is on line 15 1) What is line 15? 2) Always copy/paste the complete error message with your question. 3) Your with body is not indented: with fits.open(fits_filename) as data: df=pd.DataFrame(data[1].data) df.columns=[c.lower() for c in df.columns] print("Columns.") print(df.columns.values) But how should WE know how many lines belong to the body of the with statements? You should know that and indicate that with the indentation as described in the tutorial. And then there's also a strange line: c="radial_velocity", colormap="plasma") Probably meant to be a continuation of the previous, commented line, but as written it isn't. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Most efficient way to replace ", " with "." in a array and/or dataframe
Markos writes: > Hi, > > I have a table.csv file with the following structure: > > , Polyarene conc ,, mg L-1 ,,, > Spectrum, Py, Ace, Anth, > 1, "0,456", "0,120", "0,168" > 2, "0,456", "0,040", "0,280" > 3, "0,152", "0,200", "0,280" > > I open as dataframe with the command: > > data = pd.read_csv ('table.csv', sep = ',', skiprows = 1) > [snip] > Also I'm also wondering if there would be any benefit of making this > modification in dataframe before extracting the numeric fields to the > array. > > Please, any comments or tip? data = pd.read_csv ('table.csv', sep = ',', skiprows = 1, decimal=b',', skipinitialspace=True) -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Most efficient way to replace ", " with "." in a array and/or dataframe
Markos writes: [...] >>> Please, any comments or tip? >> data = pd.read_csv ('table.csv', sep = ',', skiprows = 1, decimal=b',', >> skipinitialspace=True) >> > Thank you for the tip. > > I didn't realize that I could avoid formatting problems in the dataframe > or array simply by using the read_csv command with the correct > parameters (sep and decimal). > > I searched for information about the meaning of the letter "b" in the > parameter decimal=b',' but didn't find. > > I found that it also works without the letter b. > I added the b because the default in the definition of read_csv is b'.', but you are right, it works with just ','. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: CSV reader ignore brackets
Skip Montanaro writes: > How about just replacing *\(([^)]*)\)* with *"\1"* in a wrapper class's > line reading method? (I think I have the re syntax approximately right.) > The csv reader will "just work". Again, nesting parens not allowed. > > Skip here is some working code: def PReader(csvfile): import re for line in csvfile: line = re.sub(r'\(.*?\)', '"\g<0>"', line) yield line import csv with open('testcsv.csv') as csvfile: reader = csv.reader(PReader(csvfile), quotechar='"') for row in reader: print(row) -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: itertools query
Pradeep Patra writes: > Hi all, > > I have written a small program to generate all the combinations of a and b > of the array. I want (6,7) tuple also included. Can anybody suggest what > change I should make to get 6,7 included in my output? Any suggestions > Why (6,7)? What about (5,7), (5,8) and (6,8)? -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Print to Paper
Daniel writes: > How to do a code to print to paper? please post here a "Hello World" > code to be printed on paper with an inkjet. > Thanks > Daniel It depends on the Operating System. Python doesn't have a standard, system-independent way to print to paper. On most Unix-like systems (like my MacOS) the following works: from subprocess import Popen, PIPE p = Popen('lpr', stdin=PIPE) p.communicate(b'Hello World') p.stdin.close() p.wait() In a production system error checking should be added. Also if a nice layout is desired, you should probably want to generate a PDF file and send that to the printer, possibly with the use of LaTeX. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange tab completion oddity with enums?
Chris Angelico writes: > I'm not sure what's going on here, and it's probably not actually > enum-specific, but that's where I saw it. > > If you create a plain class and have an attribute with an annotation, > you can see that: > >>>> class Foo: > ... spam: "ham" = 1 > ... >>>> Foo.__a > Foo.__abstractmethods__ Foo.__annotations__ >>>> Foo.__annotations__ > {'spam': 'ham'} Also strange: It shows Foo.__abstractmethods__ but there is no such attribute. What's going on? >>> Foo.__abstractmethods__ Traceback (most recent call last): File "", line 1, in AttributeError: __abstractmethods__ -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Jupyter Notebook -> PDF with A4 pages?
Martin Schöön writes: > Is there a way to do "Download as PDF" and get A4 pages instead > of Letter? Yes, I know I can do "Download as LaTeX" and edit the > result to get A4 but if there is a setting I have missed I save > work and time. > > Yes, I have looked through the documentation and searched the > Internet but so far to no avail. > Make a directory ~/.jupyter/templates and put a file A4article.tplx inside it: # ((=- Default to the notebook output style -=)) ((* if not cell_style is defined *)) ((* set cell_style = 'style_jupyter.tplx' *)) ((* endif *)) ((=- Inherit from the specified cell style. -=)) ((* extends cell_style *)) %=== % Latex Article %=== ((* block docclass *)) \documentclass[a4paper,11pt]{article} ((* endblock docclass *)) # Make a file ~/.jupyter/jupyter_notebook_config.py ## import os custom_path = os.path.expanduser("~/.jupyter/templates") c = get_config() c.TemplateExporter.template_path.append(custom_path) c.LatexExporter.template_file = 'A4article' c.PDFExporter.latex_count = 3 c.PDFExporter.template_file = 'A4article' c.PDFExporter.latex_command = ['pdflatex', '{filename}'] # Replace 'pdflatex' with 'xelatex' if you prefer that. You can leave out the c.LatexExporter.template_file line if you don't want the LaTeX exporter to generate A4. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Jupyter Notebook -> PDF with A4 pages?
Martin Schöön writes: > Den 2019-10-13 skrev Piet van Oostrum : >> Martin Schöön writes: >> >>> Is there a way to do "Download as PDF" and get A4 pages instead >>> of Letter? Yes, I know I can do "Download as LaTeX" and edit the >> > < snip > > >> Make a directory ~/.jupyter/templates and put a file A4article.tplx inside >> it: >> >> # >> ((=- Default to the notebook output style -=)) >> ((* if not cell_style is defined *)) >> ((* set cell_style = 'style_jupyter.tplx' *)) >> ((* endif *)) >> > < snip > > >> c.LatexExporter.template_file = 'A4article' >> c.PDFExporter.latex_count = 3 >> c.PDFExporter.template_file = 'A4article' >> c.PDFExporter.latex_command = ['pdflatex', '{filename}'] >> # >> Replace 'pdflatex' with 'xelatex' if you prefer that. >> You can leave out the c.LatexExporter.template_file line if >> you don't want the LaTeX exporter to generate A4. >> > Thanks a lot. > > That worked right away -- at home but not at work. Both are > Linux systems but there are differences in both Python and > LaTeX installations. Shouldn't be too hard to figure out -- > I hope. > > /Martin What does this report? Compare if there is a difference between home and work. from jupyter_core.paths import jupyter_path print(jupyter_path('notebook','templates')) And maybe also print(jupyter_path('nbconvert','templates')) -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Hello, I need help.
Damla Pehlivan writes: > Dear Python Team, [...] > I am writing this mail quite emotionally. I asked a new "friend" for help, > but he laughed. He said it was because I am a girl and this is why I could > not do it. I want to prove to him and the whole world that I can do it. I > have a lesson next Monday, so could you please help me with my problem? That is very nasty. Fortunately Python is not gender-sensitive. What Operating system do you use? I suppose it probably is Windows or Linux. And did you use the installer from www.python.org? These have an IDE that is called IDLE. It is simpler than Pycharm, but it can do the job. So you can try that. If that also gives an error you could try to reinstall Python. If you are familiar with the command line, then that is also a possibility. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Instantiating sub-class from super
DL Neil writes: > That said, if a "trans" person has ovaries or testes (for example) then > a non-traditional sexual identification is irrelevant - for medical > purposes. Diseases in those areas (and now I'm a long way from a > research questionnaire and from Python - but this is roughly how it was > explained to me) still apply, and sadly, may in-fact be considerably > complicated by any medical processes that may have contributed to a > transition. So what if a person has both ovaries and testes? It is better to keep all options open rather than making hasty subdivisions. In this context that means attributes (that can be None) rather than subclasses. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Jupyter Notebook -> PDF with A4 pages?
Martin Schöön writes: > Den 2019-10-15 skrev Piet van Oostrum : >> >> What does this report? Compare if there is a difference between home and >> work. >> >> from jupyter_core.paths import jupyter_path >> print(jupyter_path('notebook','templates')) >> > In both cases I get (with different usernames): > > /home/username/.local/share/jupyter/notebook/templates > /usr/local/share/jupyter/notebook/templates > /usr/share/jupyter/notebook/templates > >> And maybe also >> print(jupyter_path('nbconvert','templates')) > > Same as above but with "nbconvert" substituting "notebook". > > Pretty much all jupyter components are of older versions at > work. Could that be a version where the configuration is done differently? > pip is version 8.1.1 which is what Ubuntu 16.04 comes > with. I have learnt -- the hard way -- that pip should be > used with the --user option. Does this mean I am stuck with > pip version 8.1.1? I mean, pip install --user pip seams like > cheating... Why should that not work? > For a moment I thought that maybe pdflatex was missing at work > but not so. > > Disclaimer: I only had a few minutes to spend on this today. > > /Martin Please also try the following command at the shell: jupyter notebook --generate-config and see where it generates the config file (this will overwrite the one that you made yourself). Also in the shell where the notebook server is started lokk if the are error messages if you generate a PDF from a notebook. -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Convert a scientific notation to decimal number, and still keeping the data format as float64
doganad...@gmail.com writes: > > In the meanwhile I have checked Scala , and it's more limited then Python. > As an example: > 0.0001 > 1.0E-4: Double > Why do you think this means Scala is more limited than Python? -- Piet van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Convert a scientific notation to decimal number, and still keeping the data format as float64
doganad...@gmail.com writes: > I dont know much about scala actually. I have just have tried to give > 0.0001 and it returned a presentation with an 'e' .whereas python takes > 0.0001 and gives 0.0001 . it made me think python is better in that > specific subject. > > However, python though starts to give 'e' number when 5 decimals are > given as input. Although there can be systems around which are better in > this subject other things I can achieve in python overrides some > disadvantages. Yes, I would say Python is more user-friendly in this particular example, although both outputs are correct. If I remember correctly, Python had an update in the area several years ago to make the output for floating-point numbers more user-friendly, (and at the same time maybe even more correct). But these are just choices of the implementers of the language, not characteristics of the language itself. -- Pieter van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Convert a scientific notation to decimal number, and still keeping the data format as float64
Piet van Oostrum writes: > doganad...@gmail.com writes: > >> I dont know much about scala actually. I have just have tried to give >> 0.0001 and it returned a presentation with an 'e' .whereas python takes >> 0.0001 and gives 0.0001 . it made me think python is better in that >> specific subject. >> >> However, python though starts to give 'e' number when 5 decimals are >> given as input. Although there can be systems around which are better in >> this subject other things I can achieve in python overrides some >> disadvantages. > > Yes, I would say Python is more user-friendly in this particular > example, although both outputs are correct. If I remember correctly, > Python had an update in the area several years ago to make the output > for floating-point numbers more user-friendly, (and at the same time > maybe even more correct). > > But these are just choices of the implementers of the language, not > characteristics of the language itself. In Python 0.1 => 1e-05, so it just chooses a different point to switch from pure decimal to scientific notation. -- Pieter van Oostrum WWW: http://piet.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Using '__mul__' within a class
>>>>> James Stroud <[EMAIL PROTECTED]> (JS) wrote: >JS> def Multiply(self, other): >JS> self.a = self.a * other.a + self.b * other.b >JS> self.b = self.a * other.b + self.b * other.c >JS> self.c = self.b * other.b + self.c * other.c I gues this will give the wrong result because the calculation of self.b is supposed to use the original value of self.a, not the newly calculated one. Similar for self.c. The following should do that: self.a, self.b, self.c = (self.a * other.a + self.b * other.b, self.a * other.b + self.b * other.c, self.b * other.b + self.c * other.c) -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: output events on select
>>>>> "Tor Erik Sønvisen" <[EMAIL PROTECTED]> (TES) wrote: >TES> When using select, what exactly will trigger an output-event? I have >TES> a socket registered in the output-list of the select but an >TES> output-event is never generated for that socket. I know the socket is >TES> ready to send data, so how can I make select return with an >TES> output-event? It is better to talk about status than event. The select should return the socket in the ready set for write when a write on that socket can be done without blocking. So if it doen't return it then something is wrong. This is on Unix systems, by the way. On Windows things might be different. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: question about smtplib
>>>>> Tim Roberts <[EMAIL PROTECTED]> (TR) wrote: >TR> [EMAIL PROTECTED] wrote: >>> cool. so this line >>> server = smtplib.SMTP(localhost) >>> is when i connect ? >TR> Use the source, Luke. Source code for every standard module is included on >TR> your hard disk. If you look in the __init__ for "class SMTP", your >TR> question will be answered. The documentation should be the ultimate reference for the API. The source is just implementation detail which may change in the future. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Function decorator that caches function results
>>>>> Steven D'Aprano <[EMAIL PROTECTED]> (SD) wrote: >SD> [penny drops] Now we're getting somewhere... a closure is something >SD> _added_ to a function. So we should talk about functions-without-closures >SD> and functions-with-closures. Well, I have never heard that definition. For more than half of my life I only have heard the definition that a closure is the combination of a function (i.e. its code) plus an environment containing the unbound variables. Depending on the language the variables may be bound to values, memory locations or some other things. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Function decorator that caches function results
>>>>> Paul Rubin <http://[EMAIL PROTECTED]> (PR) wrote: >PR> Tom Anderson <[EMAIL PROTECTED]> writes: >PR> That's misleading, I'd say a closure is a combination of a function >PR> (executable code) and a lexical environment [snip] >PR> This is all described in SICP (mitpress.mit.edu/sicp). Where the word closure is used for something completely different (it mentions that others use the word closure as we do here). :=( -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's Performance
>>>>> Terry Hancock <[EMAIL PROTECTED]> (TH) wrote: >TH> He's got to be talking about runtime name-binding. In >TH> other words, when you refer to: >TH> a.spam >TH> the Python interpreter actually knows you labeled that attribute 'spam', >TH> and the string is stored in a.__dict__ , so you can also access it as >TH> getattr(a, 'spam') >TH> etc. >TH> I'm pretty sure this is what string "internment" is for, though, and >TH> that such lookups are optimized out pretty much whenever possible. In the case of getattr(a, 'spam') a string comparison for 'spam' has to be done. AFAIK, in the case of a.spam the string 'spam' has been interned, so that no string comparison is necessary at lookup, only a pointer comparison. Due to hash collisions probably multiple comparisons could be necessary. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: [Info] PEP 308 accepted - new conditional expressions
>>>>> Paul Rubin <http://[EMAIL PROTECTED]> (PR) wrote: >PR> Reinhold Birkenfeld <[EMAIL PROTECTED]> writes: >>> For a conditional, syntax must be found, and the tradition of Python >>> design is not to use punctuation for something that can be solved with >>> keywords. >PR> Yeah, "if C then A else B" is a ancient tradition stretching from >PR> Algol-60 to OCAML, and who knows what all else in between. I'm not >PR> sure what Guido saw in the "A if C else B" syntax but it's not a big deal. I suspect it is because "if C then A else B" gives problems in the parser because it would have difficulty to distinguish this in time from the if statement. This is because the parser doesn't use a very strong formalism. I think language design should prevail over parsing problems, but in this case it is probably a pragmatic argument that wins. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: bizarro world
>>>>> Bryan <[EMAIL PROTECTED]> (B) wrote: >B> omg!!! wow!!! after reading this i feel like i just stepped in to some >B> bizarro world. So why do you have to repeat the whole thing?? I have kill-filed XL, and now you put the message in my face. Please don't react to this drivel. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: [Info] PEP 308 accepted - new conditional expressions
>>>>> [EMAIL PROTECTED] (Dave Hansen) (DH) wrote: >DH> So lose the "if." >DH>R = C then A else B >DH> I don't think python uses the question mark for anything. Throw that >DH> in, if it makes parsing easier: >DH>R = C ? then A else B We have already had this discussion several times. I don't think it is going to add anything new to it. Besides after the BDFL has decided it is useless. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: confusion between global names and instantiated object variable names
>>>>> "wanwan" <[EMAIL PROTECTED]> (w) wrote: >w> I'm trying to make a GUI, but for some of the instantiated object >w> variable names, the interpreter is looking at them as global names. >w> Here is an example of what I did: >w> class mygui: >w> def __init__(self, root): >w> self.menubar = Menu(root) >w> # Game Menu >w> self.menu1 = Menu(self.menubar, tearoff=0) >w> self.menu1.add_command(label="Open File", command=donothing) >w> self.menu1.add_separator() >w> self.menu1.add_command(label="Exit", command=root.quit) >w> self.menubar.add_cascade(label="File", menu=self.menu1) >w> # ignoring the rest of the program ... >w> when I run my example, an error shows: >w> "NameError: global name'menubar' is not defined" If it talks about global name, it can't be self.menubar or anything.menubar. So there must be a soloist menubar reference somewhere. Doesn't it tell you the line number? -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: popen4
>>>>> "billie" <[EMAIL PROTECTED]> (b) wrote: >b> Hi all. I'm trying to execute system commands and capture the output by >b> using popen4: >b> stdout example: >>>>> exec_cmd = popen2.popen4("echo hello!") >>>>> output = exec_cmd[0].read() >b> hello >b> stderr example: >>>>> exec_cmd = popen2.popen4("echobv hello!") >>>>> output = exec_cmd[0].read() >b> Unrecognized command >b> The problem occurs when I try to execute interactive commands like ftp, >b> python intepreter etc... >b> In this case the program crashes without even giving an error. Crashes? >b> Suggestions? I think you need something like pyexpect for this. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: popen2
>>>>> "g.franzkowiak" <[EMAIL PROTECTED]> (gf) wrote: >gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is >gf> running before, I've a connection to the second process, not to the first. >gf> I can find the process by name before I start a process with popen2..., >gf> but how bcan I connect t this process with a pipe ? You have to use a named pipe. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: popen2
>>>>> Grant Edwards <[EMAIL PROTECTED]> (GE) wrote: >GE> On 2005-10-29, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >>>>>>>> "g.franzkowiak" <[EMAIL PROTECTED]> (gf) wrote: >>> >gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is >gf> running before, I've a connection to the second process, not to the first. >gf> I can find the process by name before I start a process with popen2..., >gf> but how bcan I connect t this process with a pipe ? >>> >>> You have to use a named pipe. >GE> That would require that the application know about the named >GE> pipe and open it. I don't think there is any way to swap a >GE> pipe in for stdin/stdout once a process is running. Sure. 'myprogram' should be designed to communicate through a named pipe, or be called with named pipe(s) as stdin/stdout. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: popen2
>>>>> Grant Edwards <[EMAIL PROTECTED]> (GE) wrote: >GE> On 2005-10-29, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >GE> That would require that the application know about the named >GE> pipe and open it. I don't think there is any way to swap a >GE> pipe in for stdin/stdout once a process is running. >>> >>> Sure. 'myprogram' should be designed to communicate through a >>> named pipe, or be called with named pipe(s) as stdin/stdout. >GE> That's all well and good, but it's got nothing to do with the >GE> OP's problem: he's got a program that's already running and he >GE> wants to write a Python program that can "attach" pipes to that >GE> already running program's stdin/stdout. He didn't state that he has no control over that program. I.e. if it is a program that he has source code of, he could change its behaviour to use a named pipe. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: popen2
>>>>> Piet van Oostrum <[EMAIL PROTECTED]> (PvO) wrote: >PvO> He didn't state that he has no control over that program. I.e. if it is a >PvO> program that he has source code of, he could change its behaviour to use a >PvO> named pipe. He could do the initial run of the program with stdin and stdout redirected to named pipes.At least on Unix that works, I don't know about Windows (but why not). Later you can write input to the stdin pipe and read the output back from the other one. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: reading internet data to generate random numbers.
>>>>> Neil Schemenauer <[EMAIL PROTECTED]> (NS) wrote: >NS> Grant Edwards <[EMAIL PROTECTED]> wrote: >>> Doesn't your OS have an entropy-gathering RN generator built-in? >NS> Alternatively, if you want lots of high-quality random numbers, buy >NS> a cheap web camera: http://www.lavarnd.org/ . Using data from the >NS> Internet is just a bad idea. What about www.random.org? -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Making a persistent HTTP connection
>>>>> "Alan Kennedy" <[EMAIL PROTECTED]> (AK) wrote: >AK> http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1 >AK> Some HTTP 1.0 clients supported persistent connections through the use >AK> of the non-standard "keep-alive" header. >>> And even if it works - what is the problem with connections being created? >AK> The URL above describes the benefits of persistent connections. The >AK> primary problem of the old style of one-request-per-connection is the >AK> creation of more sockets than are necessary. Maybe even more important (and just briefly mentioned in the section referred to above) is the latency introduced by the TCP setup and the slow startup phase of TCP's congestion control. This calculation is one of the exercises the students have to make in my networks class. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: How to write an API for a Python application?
>>>>> Duncan Grisby <[EMAIL PROTECTED]> (DG) wrote: >DG> To me, the situation sounds complex enough, especially with the need >DG> for callbacks, that CORBA is an ideal solution. At the expense of a >DG> small amount of boilerplate code, all the communication issues are >DG> handled for you. In this day and age, why would you want to write code >DG> that deals with sockets apart from the most specialist situations? A more lightweight solution might be Ice. <http://www.zeroc.com/ice.html> It is architecturally similar to Corba, but with less overhead. And supports different programming languages and platforms. But if your application is to be distributed on a non-GPL license you have to pay. That said, I think there is nothing wrong with using Corba for this kind of thing. It has an additional advantage that it is a widely accepted standard. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: How to write an API for a Python application?
>>>>> Duncan Grisby <[EMAIL PROTECTED]> (DG) wrote: >DG> In article <[EMAIL PROTECTED]>, >DG> Piet van Oostrum <[EMAIL PROTECTED]> wrote: >>> A more lightweight solution might be Ice. <http://www.zeroc.com/ice.html> >>> It is architecturally similar to Corba, but with less overhead. >DG> More lightweight and less overhead in what sense? The performance >DG> measurements I've seen show that Ice is significantly slower than many >DG> CORBA implementations. If you mean more lightweight in terms of ease >DG> of use, I don't see how. I quite agree that it's more lightweight in >DG> terms of size of specification and difficulty for the ORB implementor, >DG> but that's largely irrelevant to the users of the technology. On http://www.zeroc.com/performance/ they compare it with TAO and it seems to be faster. It looks also a bit simpler. I don't have experience with Ice myself but a colleague of mine experimented with it and was enthousiastic. It could well be that it is comparable in speed to omniORB, which is my favorite platform for Corba on Python, or maybe even slower. Do you have benchmark results about that? But as I also said there is nothing wrong with using Corba, and the advantage is that it is an established standard. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: How to write an API for a Python application?
>>>>> Duncan Grisby <[EMAIL PROTECTED]> (DG) wrote: >DG> I've not done any benchmarks for Python (yet), but I've just posted >DG> some results to comp.object.corba that show omniORB is a lot faster >DG> than Ice for many things. Very n ice (that was an accident, but I decided to let it stay). -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are there no ordered dictionaries?
>>>>> Christoph Zwerschke <[EMAIL PROTECTED]> (CZ) escribió: >CZ> Eso es exactamente lo que yo queria haber! ¿Haber? ¿Tener? :=( -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic classes
>>>>> "Dave Rose" <[EMAIL PROTECTED]> (DR) wrote: >DR> Hello all. >DR> I was wondering if creating classes could be dynamic. I want to know >DR> if I can make a class Person, then read in a list of names (say >DR> people's names) so then I can have a class instance created for each >DR> name in the list? If you have the class Person, you are not creating it dynamically. And of course you can create instances dynamically as you describe. >DR> Why do I want to do this? I was just thinking if I had a name on the >DR> list, Dave, I could then be able to read the name in the list, and >DR> assign Maria.birthday = <> and all the other attributes I would want >DR> to use a class for, except this is dynamic. I don't know how to >DR> iterate thru the list to assign the different attributes yet, but this >DR> seemed reasonable to want to do, and thought I could learn from this. If I understand you correctly, you want to create a variable with name 'Maria' when you read the name "Maria". Creating variables dynamically is possible in Python but is almost always the wrong thing to do. Instead it is usually better to use a dictionary. class Person: def __init__(self, name): self.name = name persons = {} now you have a loop that reads persons' names, say in name. myperson = persons[name] = Person(name) Now I suppose you want to read additional attributes, while the list of possible attributes is in principle open. So suppose you have read the attribute name in attr and the value in val. The you can dynamically create an instance attribute with: setattr(myperson, attr, val) -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: How to enable bash mode at the interative mode?
>>>>> Anthony Liu <[EMAIL PROTECTED]> (AL) escribió: >AL> That is, at the Python interactive mode, if I hit the >AL> upper arrow key, it'll bring up the last line of code. >AL> At >AL> >http://groups.google.com/group/comp.lang.python/browse_thread/thread/fb8c2fd9eed0d/736fac8c33e84d0c?lnk=st&q=python+%22upper+arrow%22&rnum=2&hl=en#736fac8c33e84d0c >AL> , it seems that Michael Spalinski suggests of >AL> reinstalling Python. >AL> Any easier way to achieve this feature? Just installing the readline module was sufficient in MacOSX (Apple's python). Maybe it is the same for other implementations? -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Cut and paste an EPS file
>>>>> "John Henry" <[EMAIL PROTECTED]> (JH) wrote: >JH> I am looking for a Python tookit that will enable me to cut section of >JH> a picture out from an EPS file and create another EPS file. >JH> I am using a proprietary package for doing certain engineering >JH> calculations. It creates single page x-y line plots that has too much >JH> blank spaces around the plotted area located at the top 2/3 of the >JH> page. I like to be "cut" that white space out by extracting the image >JH> out and may be scale it up - while keeping the bottom 1/3 unchanged. If you just want to remove the spurious whitespace (i.e. crop the picture) you can do this with ghostscript. Look for a script ps2eps. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Can we pass some arguments to system("cmdline")?
>>>>> "Didier Casse" <[EMAIL PROTECTED]> (DC) wrote: >DC> Thanks all for the reply. I'll try out those things out. :) But don't try the following >>> > system("ls $dir"); with >>> dir=="/home/foo; rm -rf /" -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Running Python interpreter in Emacs
>>>>> "Rex Eastbourne" <[EMAIL PROTECTED]> (RE) wrote: >RE> I went to My Computer | Properties | Advanced | Environment Variables >RE> and added c:\program files\python24 to both the PYTHONPATH and Path >RE> variables. Still no luck. I don't know whether the path I'm talking >RE> about is the same as the $PATH you referred to, or whether I'm supposed >RE> to put python.exe explicitly somewhere; could someone refer me to a >RE> place where I can read about these things? Is c:\program files\python24 the directory where python.exe is? You can try two things: 1. Use "c:\program files\python24" in the PATH environment variable, i.e. with the quotes. 2. Set emacs' variable py-python-command to the location of the python executable, e.g. (setq py-python-command "c:\\program files\\python24\\python.exe") or use customize to set that variable. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP E17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: mail sending using telnet in python
>>>>> praba kar <[EMAIL PROTECTED]> (PK) wrote: >PK> Normally we can send mail using >PK> telnet in linux. In the following way >PK> [~user]telnet Ipaddress 25 In fact you are using SMTP through the telnet program. So in Python use the smtplib module. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP E17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: threads and sleep?
>>>>> Christopher Subich <[EMAIL PROTECTED]> (CS) wrote: >CS> Hrm... this would suggest the possibility of designing a metaclass, >CS> perhaps, that would ensure synchronous access to an object. Perhaps "wrap" >CS> the class in another, that gets and releases a mutex on any external >CS> get/set access (except, possibly, for a specified list of "asynchronous" >CS> data members and methods). Sometimes that's not enough, because you may have to synchronise access to a couple of objects, or to multiple operations on some object(s). The system can't know the required granularity of locking, only the application programmer knows that. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: pipes like perl
>>>>> "infidel" <[EMAIL PROTECTED]> (i) wrote: >i> .readlines() won't return until it hits end-of-file, but the "man" >i> command waits for user input to scroll the content, like the "more" or >i> "less" commands let you view "pages" of information on a terminal. man shouldn't wait for user input if its output is a pipe. Try man man|cat. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Should I move to Amsterdam?
>>>>> "Martin P. Hellwig" <[EMAIL PROTECTED]> (MPH) wrote: >MPH> Of course this is all done with public transport and/or bike, not without >MPH> reason. >MPH> Personal transportation sucks in the Netherlands, if you live in the >MPH> Randstad (the area of the above mentioned cities) and you have to travel >MPH> across the Randstad, you go with the bike and/or bus/tram/metro/train >MPH> because that is the fastest way of transportation. That depends very much on where you live and where you have to go (mostly on the number of changes of transport vehicle). I, for example live in a small village, 11 km from my work in Utrecht. By bus it is 45-60 minutes, by bike 40 min. and by car (rush hour) usually 20-25 min. Only when something serious happens it can be 45 min. by car. This happens about once a year. Most of the time I take the bike, but not for the speed. It is actually a pleasant ride, mainly through woods and meadows. My daughter worked some years ago in Nieuwegein, adjacent to Utrecht. By car 20 min., by public transport 60-90 min. And this is not in some remote area, but just in the center of the country, one of the most densely populated areas. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list