Upcoming Webinar SQLAlchemy Creator Mike Bayer on How and Why to Integrate Akiban and SQLAlchemy
[image: Akiban] *Upcoming Webinar:* SQLAlchemy Creator Mike Bayer on How and Why to Integrate Akiban and SQLAlchemy Hi guys, I wanted to take a minute and invite you and the Python user group to our next free webinar on SQLAchemy: Presented by: Mike Bayer, Creator of SQLAchemy,Ori Herrnstadt, Creator of Akiban Date: Thursday, December 13, 2012[image: Register Here]http://www.akiban.com/webinars/sqlalchemy-creator-mike-bayer-on-how-and-why-to-integrate-akiban-and-sqlalchemyTime: 2:30 pm ET / 11:30 am PT *SQLAlchemy + Akiban: A very interesting combo* What good is a database if you can’t use it with the language or framework you depend on? From a developer’s perspective, not very. Even though Akiban understands SQL, developers often work at higher level with Object-Relational Mappers (ORM) like Hibernate, SQLAlchemy, or ActiveRecord. Very few developers operate on pure SQL these days. Clearly, we’ve been thinking about this question at Akiban. As we’ve been developing our new database we’ve taken time to work closely with open source developers like Mike Bayer, creator of the SQLAlchemy project, to make sure that developers have access to libraries that understand the Akiban database. Akiban's unique storage approach means that not only does SQL run a lot faster because most joins are free, but also it is possible to access a full object directly within the database. Through the use of Akiban, businesses can quickly implement new services such as real-time dynamic search, social-local-mobile applications, relationship discovery and real-time insight. Akiban enables immediate access to your operational data without negatively impacting operational performance. This also eliminates the Extract-Transform-Load effort and time delay to transfer operational data into a data mart or data warehouse. SQLAlchemy is the first ORM we’ve approached about table grouping, our novel approach to storing data and returning nested result sets in JSON. As Bayer explains, while other databases have provided a JSON view of a relational database, Akiban’s unique approach is at a much deeper level. We’re not just returning data as JSON, we’ve decided to store our data in a hierarchical format on disk. It didn’t take Bayer long to adapt SQLAlchemy to these nested results, nor did it take long to write an extension to psyopg2 that could understand the output of a query that involved table groups. What you'll take away from this webinar: - Brief intro to Akiban. - Snapshot of SQLAlchemy 0.8, new features and additions. - Example of how easy it is to execute a query that returns a nested resultset in Python using SQLAlchemy. - Overview of two recently developed projects: 1. *Akiban for Python* - an extension for the psycopg2 DBAPI. 2. *SQLAlchemy Akiban* - an Akiban dialect and ORM extension for SQLAlchemy. Duration: 1 hour [image: Register]http://www.akiban.com/webinars/sqlalchemy-creator-mike-bayer-on-how-and-why-to-integrate-akiban-and-sqlalchemy Hope to see you there. Regards, Akiban Team *P.S.* If you are unable to make it to the live webinar, register anywayhttp://www.akiban.com/webinars/sqlalchemy-creator-mike-bayer-on-how-and-why-to-integrate-akiban-and-sqlalchemy, and we'll share the recording after the event. *Akiban* 560 Harrison Avenue, Suite 411 Boston, MA 02445 United States of America Contact Us http://info.akiban.com/contact-us.html -- Robert Riegel @akiban https://twitter.com/#!/akiban skype: robert.c.riegel.III | 617-826-9990 -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Nanpy 0.6 - Use your Arduino board with Python
Hi, I'm really glad to announce you Nanpy 0.6, finally with Python3 support and a lot of bugfixing and improvements! http://pypi.python.org/pypi/nanpy/ We have issues with Leonardo boards, seems that they're unable to read serial data.. my friend Fernando Molina is working on this issue, anyway any help/suggestion/patch is welcome :) Remember that Nanpy is now an organization on Github! Join us or donate if you like it! https://github.com/nanpy WHAT IS NANPY - Nanpy is a pure Python library that allows you communicating with an Arduino board connected via USB. Classes and methods used are really similar to the Arduino framework's ones, but simpler and with some additional features, so people who haven't worked with an Arduino can be easily introduced to his world.. The main purpose of Nanpy is making developers' life easier, giving them something simple and fast to use to create prototypes and scripts interacting with Arduino, saving time and making them concentrate on the problem. There are a lot of projects able to do something similar, using Python or other languages, but Nanpy can do more! Nanpy is easily extensible and can theoretically use every library Arduino supports, allowing you to create how many objects you want and without worrying about deallocation. Also, you can use Nanpy in parallel and concurrence programs. Nanpy is under heavy development but is growing fast and just supports the main methods of OneWire, Lcd, Tone, DallasTemperature, Stepper and Servo libraries. Just a word of warning: Raspberry Pi may not provide enough power to drive an Arduino, so you might need external power. UNDER THE WOOD -- With Nanpy you can write your Arduino programs using Python, communicating via serial port without sending hard-to-remember codesor limiting you to use only one object: when you create an object in Python it will be automatically created into your Arduino at runtime.. For example if you write something like Arduino.pinMode(13, Arduino.OUTPUT) Arduino.digitalWrite(13, Arduino.HIGH) or tone = Tone(13) or lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) lcd.printString(Hello World!) or ds = DallasTemperature(5) Nanpy creates the correct object into Arduino for you.. Also, you haven't to take care of deallocation, Nanpy deallocates objects into Arduino as soon as the correspondent Python objects get deleted. Look at the examples to see how simple it is.. (https://github.com/nanpy/nanpy/tree/master/examples) :) I tried running Nanpy on a Raspberry board and it works great!!(that's the result from one of my friends' Twitter account https://twitter.com/andreagrandi/status/251702684380434434 :) ). Also you can use it in other devices suppoting Python and serial communication, with Django, for creating prototypes faster etc.. because you use Python and you don't have to flash the firmware every time. Last but not least, firmware part of Nanpy is Python-indipendent, so you can write another implementation of Nanpy in any other language, for example Java, and see an Arduino controlled via Android (ok, in this case we should use Android USB Host API, writing our own driver, because Android doesn't provide anything to access device files). We will work on this in the future :) DONATE -- Do you like Nanpy? Contributions/suggestions/bug reporting/spreading the project/beers/coffee are accepted :) if you want to donate a coffee and be sure that we will work during the night, here's the link https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclickhosted_button_id=TDTPP5JHVJK8J Thanks for your attention! Best regards, =.4.S.= -- Andrea Stagi - Mobile Software Engineer at SomaFM Job profile: it.linkedin.com/in/andreastagi/en Website: http://4spills.blogspot.it/ -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?
On 13/11/12 22:36:47, Thomas Rachel wrote: Am 12.11.2012 19:30 schrieb Hans Mulder: This will break if there are spaces in the file name, or other characters meaningful to the shell. If you change if to xargsproc.append(test -f '%s/{}' md5sum '%s/{}' % (mydir, mydir)) , then it will only break if there are single quotes in the file name. And if you do mydir_q = mydir.replace(', '\\'') and use mydir_q, you should be safe... The problem isn't single quotes in mydir, but single quotes in the files names that 'tar' generates and 'xargs' consumes. In the shell script, these names go directly from tar to xargs via a pipe. If the OP wants to do your replace, his script would have to read the output of tar and do the replace before passing the filenames down a second pipe to xargs. However, once he does that, it's simpler to cut out xargs and invoke sh directly. Or even cut out sh and test and instead use os.path.isfile and then call md5sum directly. And once he does that, he no longer needs to worry about single quotes. The OP has said, he's going to d all that. One step at a time. That sounds like a sensible plan to me. Hope this helps, -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: creating size-limited tar files
Ian Kelly ian.g.ke...@gmail.com writes: On Tue, Nov 13, 2012 at 11:05 PM, Kushal Kumaran kushal.kumaran+pyt...@gmail.com wrote: Or, you could just change the p1's stderr to an io.BytesIO instance. Then call p2.communicate *first*. This doesn't seem to work. b = io.BytesIO() p = subprocess.Popen([ls, -l], stdout=b) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib64/python3.2/subprocess.py, line 711, in __init__ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File /usr/lib64/python3.2/subprocess.py, line 1112, in _get_handles c2pwrite = stdout.fileno() io.UnsupportedOperation: fileno I think stdout and stderr need to be actual file objects, not just file-like objects. Well, well, I was wrong, clearly. I wonder if this is fixable. -- regards, kushal -- http://mail.python.org/mailman/listinfo/python-list
Re: Detect file is locked - windows
On 14/11/12 02:14:59, Mark Lawrence wrote: On 14/11/2012 00:33, Ali Akhavan wrote: I am trying to open a file in 'w' mode open('file', 'wb'). open() will throw with IOError with errno 13 if the file is locked by another application or if user does not have permission to open/write to the file. How can I distinguish these two cases ? Namely, if some application has the file open or not. I don't have a Windows machine at hand to try, but this might work: if exc.errno == 13: if os.access('file', os.W_OK): print Locked by another process else: print No permission to write Anything here help http://www.python.org/dev/peps/pep-3151/ ? That won't help: in Python 3.3, IOError with errno==13 has been replaced by PermissionError. It still doesn't tell you *why* you got a PermissionError. Hope this helps, -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: stackoverflow quote on Python
Le mardi 13 novembre 2012 16:53:30 UTC+1, Mark Lawrence a écrit : On 13/11/2012 13:21, wxjmfa...@gmail.com wrote: Le mardi 13 novembre 2012 06:42:19 UTC+1, Steven D'Aprano a écrit : On Tue, 13 Nov 2012 03:08:54 +, Mark Lawrence wrote: * strings are now proper text strings (Unicode), not byte strings; Let me laugh. jmf Presumably because you're looking at yourself in a mirror, and have finally realised that you've completely misunderstood the work done with unicode in Python 3, specifically Python 3.3? -- Cheers. Mark Lawrence. I'am still fascinated by the mathematically absurd negative logic used in and by the flexible string representation (algorithm). jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: Detect file is locked - windows
On 14/11/2012 08:55, Hans Mulder wrote: On 14/11/12 02:14:59, Mark Lawrence wrote: On 14/11/2012 00:33, Ali Akhavan wrote: I am trying to open a file in 'w' mode open('file', 'wb'). open() will throw with IOError with errno 13 if the file is locked by another application or if user does not have permission to open/write to the file. How can I distinguish these two cases ? Namely, if some application has the file open or not. I don't have a Windows machine at hand to try, but this might work: if exc.errno == 13: if os.access('file', os.W_OK): print Locked by another process else: print No permission to write No luck, I'm afraid. os.access on Windows is basically non-functional (and would have been deprecated if I'd actually got around to doing it). It basically checks the old-style readonly flag and that's it. IOW, you'd return True for a file whose attributes you could read regardless of whether you could read/write the file contents. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Division matrix
Le mardi 13 novembre 2012 02:00:28 UTC+1, Cleuson Alves a écrit : Hello, I need to solve an exercise follows, first calculate the inverse matrix and then multiply the first matrix. I await help. Thank you. follows the code below incomplete. m = [[1,2,3],[4,5,6],[7,8,9]] x = [] for i in [0,1,2]: y = [] for linha in m: y.append(linha[i]) x.append(y) print x [[1, 4, 7], [2, 5, 8], [3, 6, 9]] def ProdMatrix(x,b): tamL = len(x) tamC = len(x[0]) c = nullMatrix(tamL,tamC) for i in range(tamL): for j in range(tamC): val = 0 for k in range(len(b)): val = val + x[i][l]*b[k][j] c[i][j] return c -- Pedagogical hint: Before blindly calculating the inverse matrix, it may be a good idea to know if the inverse matrix exists. jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: stackoverflow quote on Python
On Wed, Nov 14, 2012 at 7:56 PM, wxjmfa...@gmail.com wrote: I'am still fascinated by the mathematically absurd negative logic used in and by the flexible string representation (algorithm). I am still fascinated that you persist in comparing a buggy old Python against a bug-free new Python and haven't noticed the difference. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Generate unique ID for URL
On 14.11.2012 01:41, Richard Baron Penman wrote: I found the MD5 and SHA hashes slow to calculate. Slow? For URLs? Are you kidding? How many URLs per second do you want to calculate? The builtin hash is fast but I was concerned about collisions. What rate of collisions could I expect? MD5 has 16 bytes (128 bit), SHA1 has 20 bytes (160 bit). Utilizing the birthday paradox and some approximations, I can tell you that when using the full MD5 you'd need around 2.609e16 hashes in the same namespace to get a one in a million chance of a collision. That is, 26090 filenames. For SHA1 This number rises even further and you'd need around 1.71e21 or 171000 hashes in one namespace for the one-in-a-million. I really have no clue about how many URLs you want to hash, and it seems to be LOTS since the speed of MD5 seems to be an issue for you. Let me estimate that you'd want to calculate a million hashes per second then when you use MD5, you'd have about 827 years to fill the namespace up enough to get a one-in-a-million. If you need even more hashes (say a million million per second), I'd suggest you go with SHA-1, giving you 54 years to get the one-in-a-million. Then again, if you went for a million million hashes per second, Python would probably not be the language of your choice. Best regards, Johannes -- Wo hattest Du das Beben nochmal GENAU vorhergesagt? Zumindest nicht öffentlich! Ah, der neueste und bis heute genialste Streich unsere großen Kosmologen: Die Geheim-Vorhersage. - Karl Kaos über Rüdiger Thomas in dsa hidbv3$om2$1...@speranza.aioe.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Detect file is locked - windows
On 14/11/2012 00:33, Ali Akhavan wrote: I am trying to open a file in 'w' mode open('file', 'wb'). open() will throw with IOError with errno 13 if the file is locked by another application or if user does not have permission to open/write to the file. What version of Python are you using? How can I distinguish these two cases ? Namely, if some application has the file open or not. Can I ask what you expect to do differently in each of those cases? In other words, if you can't access the file, you can't access it. (Not to dismiss your question; I just wonder how you're going to handle the different cases) TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Supported Platforms for Python
Hi there! Our team at IBM are exploring the possibility of implementing one of our products using Python. I had a query in this regard. As per IBM's policy, we list details of platforms that our product works on - including the flavors of OS, the versions supported (and sometimes, even the service packs, if it matters) so that it is un-ambiguous to our customers. As an example, you can have a look at this page. Suppose we are riding on Python (i.e., implementing using Python), we need to tell our customers in similar detail as to what platforms we support our products on. I tried to find information about the platforms on which Python is supported from your page. But, it does not detail the versions of OS supported. In this regard, I have the following questions. Thanks for taking your time to respond. 1. Is this information available somewhere? 2. I was pointed to PEP-11, which documents the platforms that are not supported. So, can we take that all active versions of Python (2.7.3 and 3.3, i believe) are supported on all the OS flavors that Python claims to run on -- unless mentioned otherwise in the PEP-11? 3. Also, regarding the following entries listed in the PEP-11. So, any idea which OSes implement these? Name: Linux 1 (Am guessing its the Linux kernel version 1.0?) Unsupported in: Python 2.3 Code removed in: Python 2.4 Name: Systems defining __d6_pthread_create (configure.in) Unsupported in: Python 2.3 Code removed in: Python 2.4 Name: Systems defining PY_PTHREAD_D4, PY_PTHREAD_D6, or PY_PTHREAD_D7 in thread_pthread.h Unsupported in: Python 2.3 Code removed in: Python 2.4 Name: Systems using --with-dl-dld Unsupported in: Python 2.3 Code removed in: Python 2.4 Name: Systems using --without-universal-newlines, Unsupported in: Python 2.3 Code removed in: Python 2.4 Name: Systems using --with-wctype-functions Unsupported in: Python 2.6 Code removed in: Python 2.6 Name: Systems using Mach C Threads Unsupported in: Python 3.2 Code removed in: Python 3.3 Name: Systems using --with-pth (GNU pth threads) Unsupported in: Python 3.2 Code removed in: Python 3.3 Name: Systems using Irix threads Unsupported in: Python 3.2 Code removed in: Python 3.3 Warm Regards, Kiran M N | Software Development (Rational Team Concert for Visual Studio.NET) | IBM Rational | India Software Labs | Email: kiran@in.ibm.com From: Michael Foord mich...@voidspace.org.uk To: webmas...@python.org Cc: Kiran N Mallekoppa/India/IBM@IBMIN Date: 08-11-12 08:10 PM Subject:Re: Supported Platforms for Python On 8 Nov 2012, at 14:36, webmas...@python.org wrote: On Thu, Nov 08, 2012, Kiran N Mallekoppa wrote: Suppose we are riding on Python (i.e., implementing using Python), we need to tell our customers in similar detail as to what platforms we support our products on. I tried to find information about the platforms on which Python is supported from your page. But, it does not detail the versions of OS supported. Is this information available somewhere? If not, can this be published on your site? Not really. ;-) You'll find some on http://www.python.org/download/other/ However, Python is (mostly) plain C and Open Source, which essentially means that support is available for any platform where people are willing to invest resources. AIX in particular has always been one of the problem platforms. What this means for you is that if IBM wants to allocate resources to get Python running on any particular platform, it almost certainly can be done, and we certainly would appreciate getting any such work contributed back to the community. If you want more information, you're probably best off using one of the discussion forums listed in your auto-reply. As an addendum note that there is a list of explicitly unsupported platforms (platforms that used to be supported and in which versions of Python support was removed): http://www.python.org/dev/peps/pep-0011/ You can see which platforms we test Python, and the test systems are considered stable, from our buildbots. The Python 2.7 ones are here: http://buildbot.python.org/all/waterfall?category=2.7.stable Another tangible way to support a platform is to provide and maintain a buildbot for running the Python tests on. All the best, Michael Foord -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Generate unique ID for URL
thanks for perspective! -- http://mail.python.org/mailman/listinfo/python-list
Re: Supported Platforms for Python
Am 14.11.2012 10:51, schrieb Kiran N Mallekoppa: 1. Is this information available somewhere? 2. I was pointed to PEP-11, which documents the platforms that are not supported. So, can we take that all active versions of Python (2.7.3 and 3.3, i believe) are supported on all the OS flavors that Python claims to run on -- unless mentioned otherwise in the PEP-11? There is intent to support these platforms, but as with every software that relies on volunteers, the actual extent varies. If you want to be sure that a platform is actively supported, check that the platform has an available and active build bot, because only this detects bitrot to a certain extent. If you want to be sure, create build and test systems for the systems you target yourself, you will then see if it works. 3. Also, regarding the following entries listed in the PEP-11. So, any idea which OSes implement these? Name: Linux 1(Am guessing its the Linux kernel version 1.0?) Unsupported in: Python 2.3 Code removed in: Python 2.4 Yes, Linux 1 is obsolete and has been for 10 years. Name: Systems defining __d6_pthread_create (configure.in) Unsupported in: Python 2.3 Code removed in: Python 2.4 Name: Systems defining PY_PTHREAD_D4, PY_PTHREAD_D6, or PY_PTHREAD_D7 in thread_pthread.h Unsupported in: Python 2.3 Code removed in: Python 2.4 Name: Systems using --with-dl-dld Unsupported in: Python 2.3 Code removed in: Python 2.4 Name: Systems using --without-universal-newlines, Unsupported in: Python 2.3 Code removed in: Python 2.4 Name: Systems using --with-wctype-functions Unsupported in: Python 2.6 Code removed in: Python 2.6 I'm not sure where these are used. Name: Systems using Mach C Threads Unsupported in: Python 3.2 Code removed in: Python 3.3 Mach is a microkernel. I'm not sure if the Mach C Threads interface is obsolete on Mach or if Mach overall isn't supported. Probably irrelevant for the desktop. Name: Systems using --with-pth (GNU pth threads) Unsupported in: Python 3.2 Code removed in: Python 3.3 I think this is targetted at early Linux threads that used fork() while sharing most of the memory space. Obsolete. Name: Systems using Irix threads Unsupported in: Python 3.2 Code removed in: Python 3.3 Irix was a Unix variant shipped with SGI workstations. I don't kknow to what extent this is relevant for you. I think that the main use cases for these machines is 3D rendering/modelling, unless they have been superseeded by common desktop machines. Kiran M N | Software Development (Rational Team Concert for Visual Studio.NET) Just out of curiosity by one of your RTC users: What nice gimmics are you planning? Cheers! Uli -- http://mail.python.org/mailman/listinfo/python-list
Re: Generate unique ID for URL
On 14.11.2012 02:39, Roy Smith wrote: The next step is to reduce the number of bits you are encoding. You said in another post that 1 collision in 10 million hashes would be tolerable. So you need: math.log(10*1000*1000, 2) 23.25349666421154 24 bits worth of key. Nope :-) Base64 encoded, that's only 4 characters. Actually, I probably just proved that I don't really understand how probabilities work, so maybe what you really need is 32 or 48 or 64 bits. :-)) When doing these calculations, it's important to keep the birthday paradox in mind (this is kind of counter-intuitive): The chance of a collission raises tremendously when we're looking for *any* arbitrary two hashes colliding within a certain namespace. The probability you've calculated is the pre-image probability (which you also again need to multiply with a factor of two, because when trying to collide one given hash, in the mean case you'll only have to search *half* the namespace before finding a collision). There are three things you need to know before you can give an estimate: 1. The permissible probability of a collision (1e-7 in this case) 2. The hash size 3. The worst-case number of elements in the namespace You neglected 3 completely -- but knowing this is really important. This becomes obvious when looking at the extreme cases: Let's say you have a hash of arbitrary size, but only hash one element. The chance of a collision is *always* zero. Or look at a hash of size 2^n. Then put 2^n + 1 elements in the namespace. The chance of a collision is *always* one. Doing the calculations (formulas can be found on wikipedia on the site of the birthday phaenomenon), you can come up with these following bitlenghts of the hash with a 1e-7 probability of collision in respect to the worst-case number of elements 10k elements: 49 bit 100k elements: 56 bit 1e6 elements: 63 bit 100e6 elements: 76 bit 1e9 elements: 83 bit 1e12 elements: 102 bit Best regards, Johannes -- Wo hattest Du das Beben nochmal GENAU vorhergesagt? Zumindest nicht öffentlich! Ah, der neueste und bis heute genialste Streich unsere großen Kosmologen: Die Geheim-Vorhersage. - Karl Kaos über Rüdiger Thomas in dsa hidbv3$om2$1...@speranza.aioe.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Detect file is locked - windows
On 14/11/2012 00:33, Ali Akhavan wrote: I am trying to open a file in 'w' mode open('file', 'wb'). open() will throw with IOError with errno 13 if the file is locked by another application or if user does not have permission to open/write to the file. How can I distinguish these two cases ? Namely, if some application has the file open or not. The Python io module calls into the MS CRT, which maps both errors (ERROR_ACCESS_DENIED ERROR_SHARING_VIOLATION) to posix errno EACCESS, which is 13. If you really need to distinguish the two situations, you'll need to call CreateFile directly (via ctypes or the pywin32 modules or an extension module) and then call GetLastError() to get the specific condition. You're far better off using this EAFP approach as, even if it were simple to determine beforehand whether a file can be locked or read -- and it's not -- that situation could have changed by the time you actually come to open it. Once you've successfully got a handle to the file, that handle is valid regardless of any later changes to the file's security. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: creating size-limited tar files
2012/11/14 Kushal Kumaran kushal.kumaran+pyt...@gmail.com: Well, well, I was wrong, clearly. I wonder if this is fixable. -- regards, kushal -- http://mail.python.org/mailman/listinfo/python-list But would it not be possible to use the pipe in memory in theory? That would be way faster and since I have in theory enough RAM it might be a great improvement.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Detect file is locked - windows
On 14/11/12 11:02:45, Tim Golden wrote: On 14/11/2012 00:33, Ali Akhavan wrote: I am trying to open a file in 'w' mode open('file', 'wb'). open() will throw with IOError with errno 13 if the file is locked by another application or if user does not have permission to open/write to the file. What version of Python are you using? How can I distinguish these two cases ? Namely, if some application has the file open or not. Can I ask what you expect to do differently in each of those cases? In other words, if you can't access the file, you can't access it. (Not to dismiss your question; I just wonder how you're going to handle the different cases) It would be nice if he could give specific error messages, e.g. Can't write %s because it is locked by %s. vs. Can't write %s because you don't have write access. I can't speak for Ali, but I'm always annoyed by error messages listing several possible cuases, such as Can't delete file, because the source or destination is in use. -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: Detect file is locked - windows
On 14/11/2012 11:51, Hans Mulder wrote: It would be nice if he could give specific error messages, e.g. Can't write %s because it is locked by %s. vs. Can't write %s because you don't have write access. I can't speak for Ali, but I'm always annoyed by error messages listing several possible cuases, such as Can't delete file, because the source or destination is in use. (I realise you're not demanding this particular behaviour from Python but just to expand on what the obstacles are to this at present): Speaking merely from the point of view of the current Python implementation on Windows, there are two obstacles to this: * Python calls into the CRT which simply returns 13 (EACCESS) for both of these situations. Obviously, Python could do its own thing on Windows, partly reimplementing what the CRT does anyway and giving more precise feedback. Equally obviously, this wouldn't be a trivial exercise. * The added information -- who's locked the file, what permissions are in place which prevent you gaining the requested access -- is surprisingly fiddly to get hold of and would be something of an overhead for the majority of the time when it's not wanted. Of course, in this hypothetical Python one could add some sort of flag to the open() function which requested or not the additional information. The first obstacle is more significant than the second but neither is negligible. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Generate unique ID for URL
On 11/14/2012 06:29 AM, Johannes Bauer wrote: snip When doing these calculations, it's important to keep the birthday paradox in mind (this is kind of counter-intuitive): The chance of a collission raises tremendously when we're looking for *any* arbitrary two hashes colliding within a certain namespace. The probability you've calculated is the pre-image probability (which you also again need to multiply with a factor of two, because when trying to collide one given hash, in the mean case you'll only have to search *half* the namespace before finding a collision). snip Te birthday paradox could have been important had the OP stated his goal differently. What he said was: Ideally I would want to avoid collisions altogether. But if that means significant extra CPU time then 1 collision in 10 million hashes would be tolerable. That means that he's willing to do the necessary overhead of collision resolution, once in every 10 million lookups. That's not the same as saying that he wants only one chance in 10 million of having ANY collisions among his data items. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Generate unique ID for URL
On 14.11.2012 13:33, Dave Angel wrote: Te birthday paradox could have been important had the OP stated his goal differently. What he said was: Ideally I would want to avoid collisions altogether. But if that means significant extra CPU time then 1 collision in 10 million hashes would be tolerable. That means that he's willing to do the necessary overhead of collision resolution, once in every 10 million lookups. That's not the same as saying that he wants only one chance in 10 million of having ANY collisions among his data items. Since he stated in a later post that he actually went with MD5, the calculations are indeed relevant. They give the number of bits a perfect hash needs to have in order to get the desired low probablility of collision resolutions. And for that the birthday paradox probability must be considered instead of the (much lower) pre-image probability. In any case, it appeared to me as if the OP was rather looking for ideas and wasn't sure himself what approach to take -- so I find it quite appropriate to give suggestions one way or another (even if they might not fit the exact phrasing of one of his postings). Best regards, Johannes -- Wo hattest Du das Beben nochmal GENAU vorhergesagt? Zumindest nicht öffentlich! Ah, der neueste und bis heute genialste Streich unsere großen Kosmologen: Die Geheim-Vorhersage. - Karl Kaos über Rüdiger Thomas in dsa hidbv3$om2$1...@speranza.aioe.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Question regarding running .py program
On Wed, Nov 14, 2012 at 6:02 PM, ru...@yahoo.com wrote: On 11/13/2012 11:02 PM, Chris Angelico wrote: To be more accurate: This is deprecated *by members of* this list. As there is no commanding/controlling entity here, it's up to each individual to make a decision - for instance, abusive users get killfiled rather than banned. The use of Google Groups to post is deprecated in the original sense of the word: strongly disapproved of. s/deprecated *by members of*/deprecated *by some members of*/ (and accuracy could probably be increased further by replacing some with a few.) I stand by what I said. Members, plural, of this list. I didn't say all members of, ergo the word some is superfluous, yet not needful, as Princess Ida put it. In any case, the fact remains that a number of this list's best responders have killfiled Google Groups posters as a whole. Consequently, GG forces you to go to quite a bit of extra work AND prevents your message from getting through to everyone. Why go to extra work to get a worse result? I am therefore not going to recommend Google Groups to anyone as a means of posting to python-list/c.l.p, any more than I would recommend writing it on a Post-It note and feeding it into your floppy drive. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python garbage collector/memory manager behaving strangely
In article 50570de3$0$29981$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 17 Sep 2012 06:46:55 -0400, Dave Angel wrote: On 09/16/2012 11:25 PM, alex23 wrote: def readlines(f): lines = [] while f is not empty: line = f.readline() if not line: break if len(line) 2 and line[-2:] == '|\n': lines.append(line) yield ''.join(lines) lines = [] else: lines.append(line) There's a few changes I'd make: I'd change the name to something else, so as not to shadow the built-in, Which built-in are you referring to? There is no readlines built-in. py readlines Traceback (most recent call last): File stdin, line 1, in module NameError: name 'readlines' is not defined There is a file.readlines method, but that lives in a different namespace to the function readlines so there should be no confusion. At least not for a moderately experienced programmer, beginners can be confused by the littlest things sometimes. Actually, as an experienced programmer, I *do* think it is confusing as evidenced by the mistake Dave made! Segregated namespaces are wonderful (per Zen), but let's not pollute multiple namespaces with same name, either. It may not be literally shadowing the built-in, but it definitely mentally shadows the built-in. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess puzzle and two questions
In article mailman.3666.1352873042.27098.python-l...@python.org, William Ray Wing w...@mac.com wrote: On Nov 13, 2012, at 11:41 PM, Roy Smith r...@panix.com wrote: In article mailman.3664.1352867713.27098.python-l...@python.org, w...@mac.com wrote: I need to time the operation of a command-line utility (specifically nslookup) from within a python program I'm writing. Ugh. Why are you doing this? Shelling out to nslookup is an incredibly slow and clumsy way of doing name translation. What you really want to be doing is calling getaddrinfo() directly. See http://docs.python.org/2/library/socket.html#socket.getaddrinfo for details. -- Because, unless I'm badly mistaken (very possible), getaddrinfo doesn't let me specify the server from which the name is returned. I'm really not after the name, what I'm REALLY after is the fact that a path exists to the name server I specify (and how long it takes to respond). In the good old days I would just have ping'd it, but these days more and more DNS boxes (and servers of all sorts) are shutting off their ping response. Thanks, Bill Oh, my. You're using DNS as a replacement for ping? Fair enough. In that case, all you really care about is that you can connect to port 53 on the server... import socket import time s = socket.socket() t0 = time.time() s.connect(('8.8.8.8', 53)) t1 = time.time() print it took %f seconds to connect % (t1 - t0) -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess puzzle and two questions
On Thu, Nov 15, 2012 at 1:22 AM, Roy Smith r...@panix.com wrote: Oh, my. You're using DNS as a replacement for ping? Fair enough. In that case, all you really care about is that you can connect to port 53 on the server... import socket import time s = socket.socket() t0 = time.time() s.connect(('8.8.8.8', 53)) t1 = time.time() print it took %f seconds to connect % (t1 - t0) That assumes that (a) the remote server supports TCP for DNS (since UDP is by far the more often used, some name servers don't bother supporting TCP), and (b) that connection time for TCP is comparable to ping or an actual DNS lookup. But in terms of approximating your connection times, that's gotta be way better than shelling out to several other processes. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Error
for this code m getting this error : CODE : def ComputeClasses(data): radius = .5 points = [] for cy in xrange(0, data.height): for cx in xrange(0, data.width): if data[cy,cx] != (0.0,0.0,0.0): centre = data[cy, cx] points.append(centre) change = True while change: for ring_number in xrange(1, 1000): change = False new_indices = GenerateRing(cx, cy, ring_number) for idx in new_indices: point = data[idx[0], idx[1]] if point == (0.0, 0.0, 0.0 ): continue else: dist = distance(centre, point) if dist radius : print point points.append(point) change = True print change break ERROR : Traceback (most recent call last): File Z:\modules\classification2.py, line 74, in module ComputeClasses(data) File Z:\modules\classification2.py, line 56, in ComputeClasses dist = distance(centre, point) UnboundLocalError: local variable 'centre' referenced before assignment And i am unable to understand .. WHY ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Error
On Thu, Nov 15, 2012 at 2:18 AM, inshu chauhan insidesh...@gmail.com wrote: for this code m getting this error : CODE : def ComputeClasses(data): if data[cy,cx] != (0.0,0.0,0.0): centre = data[cy, cx] ... dist = distance(centre, point) ERROR : UnboundLocalError: local variable 'centre' referenced before assignment And i am unable to understand .. WHY ? In brief, here's what causes that error: 1) Somewhere in the function, you assign to that name, which implicitly sets it to be a local variable. That happens there where you go centre = data[cy, cx]. 2) Somewhere else in the function, you reference that name. That happens where you try to calculate the distance from your previously-defined centre to the current point. 3) At run-time, you haven't executed #1, but you do execute #2. Your problem here I can't diagnose, but it looks like your first point is (0.0,0.0,0.0), so centre never gets set. There are a couple of possible fixes for this, and you'll need to figure out what to do based on knowing your own code. Possibly you just need to initialize centre above the loop, so that it always has a valid value; or possibly the code below needs to not execute if the current centre hasn't been set. Go through your function's logic by hand and figure out what happens when, and whether that's what it ought to do. Then decide what should happen when a data value is (0.0,0.0,0.0) - currently it's retaining the value of centre from the previous iteration of the loop, which smells wrong to me. Beyond that, I don't think I can really help, it's up to you. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess puzzle and two questions
On Nov 14, 2012, at 9:22 AM, Roy Smith r...@panix.com wrote: In article mailman.3666.1352873042.27098.python-l...@python.org, William Ray Wing w...@mac.com wrote: On Nov 13, 2012, at 11:41 PM, Roy Smith r...@panix.com wrote: In article mailman.3664.1352867713.27098.python-l...@python.org, w...@mac.com wrote: I need to time the operation of a command-line utility (specifically nslookup) from within a python program I'm writing. Ugh. Why are you doing this? Shelling out to nslookup is an incredibly slow and clumsy way of doing name translation. What you really want to be doing is calling getaddrinfo() directly. See http://docs.python.org/2/library/socket.html#socket.getaddrinfo for details. -- Because, unless I'm badly mistaken (very possible), getaddrinfo doesn't let me specify the server from which the name is returned. I'm really not after the name, what I'm REALLY after is the fact that a path exists to the name server I specify (and how long it takes to respond). In the good old days I would just have ping'd it, but these days more and more DNS boxes (and servers of all sorts) are shutting off their ping response. Thanks, Bill Oh, my. You're using DNS as a replacement for ping? Fair enough. In that case, all you really care about is that you can connect to port 53 on the server... import socket import time s = socket.socket() t0 = time.time() s.connect(('8.8.8.8', 53)) t1 = time.time() print it took %f seconds to connect % (t1 - t0) -- http://mail.python.org/mailman/listinfo/python-list Now THAT looks better. Simpler, cleaner, (longer, taller, stronger, faster, cheaper… :-) Thanks, Bill -- http://mail.python.org/mailman/listinfo/python-list
Re: Error
On Wed, Nov 14, 2012 at 10:18 AM, inshu chauhan insidesh...@gmail.comwrote: for this code m getting this error : CODE : def ComputeClasses(data): radius = .5 points = [] for cy in xrange(0, data.height): for cx in xrange(0, data.width): if data[cy,cx] != (0.0,0.0,0.0): This code is only run if the test above is true centre = data[cy, cx] points.append(centre) change = True while change: for ring_number in xrange(1, 1000): change = False new_indices = GenerateRing(cx, cy, ring_number) for idx in new_indices: point = data[idx[0], idx[1]] if point == (0.0, 0.0, 0.0 ): continue else: dist = distance(centre, point) centre is only set if the test above is true. In your run, it apparently wasn't if dist radius : print point points.append(point) change = True print change break ERROR : Traceback (most recent call last): File Z:\modules\classification2.py, line 74, in module ComputeClasses(data) File Z:\modules\classification2.py, line 56, in ComputeClasses dist = distance(centre, point) UnboundLocalError: local variable 'centre' referenced before assignment And i am unable to understand .. WHY ? -- http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick -- http://mail.python.org/mailman/listinfo/python-list
Re: creating size-limited tar files
On 11/14/2012 10:56 AM, andrea crotti wrote: Ok this is all very nice, but: [andrea@andreacrotti tar_baller]$ time python2 test_pipe.py /dev/null real 0m21.215s user 0m0.750s sys 0m1.703s [andrea@andreacrotti tar_baller]$ time ls -lR /home/andrea | cat /dev/null real 0m0.986s user 0m0.413s sys 0m0.600s snip So apparently it's way slower than using this system, is this normal? I'm not sure how this timing relates to the thread, but what it mainly shows is that starting up the Python interpreter takes quite a while, compared to not starting it up. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: creating size-limited tar files
2012/11/14 Dave Angel d...@davea.name: On 11/14/2012 10:56 AM, andrea crotti wrote: Ok this is all very nice, but: [andrea@andreacrotti tar_baller]$ time python2 test_pipe.py /dev/null real 0m21.215s user 0m0.750s sys 0m1.703s [andrea@andreacrotti tar_baller]$ time ls -lR /home/andrea | cat /dev/null real 0m0.986s user 0m0.413s sys 0m0.600s snip So apparently it's way slower than using this system, is this normal? I'm not sure how this timing relates to the thread, but what it mainly shows is that starting up the Python interpreter takes quite a while, compared to not starting it up. -- DaveA Well it's related because my program has to be as fast as possible, so in theory I thought that using Python pipes would be better because I can get easily the PID of the first process. But if it's so slow than it's not worth, and I don't think is the Python interpreter because it's more or less constantly many times slower even changing the size of the input.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-list Digest, Vol 110, Issue 106
Hi, I have a question about Django. I easy_installed Django1.4 and psycopg2, and python manage.py syncdb. And gave me a error; No module named psycopg2.extensions. posgre9.1 is installed. It works fine on my MAC but not my Windows. Does anyone know about this issue Hope to resolve this issue soon. Jun -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess puzzle and two questions
I wrote: Oh, my. You're using DNS as a replacement for ping? Fair enough. In that case, all you really care about is that you can connect to port 53 on the server... s = socket.socket() s.connect(('8.8.8.8', 53)) In article mailman.3684.1352904008.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: That assumes that (a) the remote server supports TCP for DNS This is true. I honestly don't know what percentage of DNS servers out there only support UDP. The two I tried (Google's 8.8.8.8, and my Apple TimeCapsule) both supported TCP, but that's hardly a representitive sample. and (b) that connection time for TCP is comparable to ping or an actual DNS lookup. My first thought to solve both of these is that it shouldn't be too hard to hand-craft a minimal DNS query and send it over UDP. Then, I hunted around a bit and found that somebody had already done that, in spades. Take a look at http://www.dnspython.org; it might be exactly what's needed here. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating size-limited tar files
On 11/14/2012 11:16 AM, andrea crotti wrote: 2012/11/14 Dave Angel d...@davea.name: On 11/14/2012 10:56 AM, andrea crotti wrote: Ok this is all very nice, but: [andrea@andreacrotti tar_baller]$ time python2 test_pipe.py /dev/null real 0m21.215s user 0m0.750s sys 0m1.703s [andrea@andreacrotti tar_baller]$ time ls -lR /home/andrea | cat /dev/null real 0m0.986s user 0m0.413s sys 0m0.600s snip So apparently it's way slower than using this system, is this normal? I'm not sure how this timing relates to the thread, but what it mainly shows is that starting up the Python interpreter takes quite a while, compared to not starting it up. -- DaveA Well it's related because my program has to be as fast as possible, so in theory I thought that using Python pipes would be better because I can get easily the PID of the first process. But if it's so slow than it's not worth, and I don't think is the Python interpreter because it's more or less constantly many times slower even changing the size of the input.. Well, as I said, I don't see how the particular timing has anything to do with the rest of the thread. If you want to do an ls within a Python program, go ahead. But if all you need can be done with ls itself, then it'll be slower to launch python just to run it. Your first timing runs python, which runs two new shells, ls, and cat. Your second timing runs ls and cat. So the difference is starting up python, plus starting the shell two extra times. I'd also be curious if you flushed the system buffers before each timing, as the second test could be running entirely in system memory. And no, I don't know offhand how to flush them in Linux, just that without it, your timings are not at all repeatable. Note the two identical runs here. davea@think:~/temppython$ time ls -lR ~ | cat /dev/null real0m0.164s user0m0.020s sys 0m0.000s davea@think:~/temppython$ time ls -lR ~ | cat /dev/null real0m0.018s user0m0.000s sys 0m0.010s real time goes down by 90%, while user time drops to zero. And on a 3rd and subsequent run, sys time goes to zero as well. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting empty attachment with smtplib
I just found out that the attachment works fine when I read the mail from the gmail website. Thunderbird complains that the attachment is empty. Thanks, Toby On 11/14/2012 09:51 AM, Tobiah wrote: I've been sending an email blast out with smtplib and it's been working fine. I'm attaching an html doc with msg.attach(MIMEText(email, 'html')) and it displays fine. Now I need to attach a .pdf doc, but Thunderbird complains that the attachment is empty. When I view the source of the email, the headers look ok to me, and a large base64 looking mess follows: --===0152408622== Content-Type: application/pdf MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=tics.pdf JVBERi0xLjYNJeLjz9MNCjE0IDAgb2JqDTw8L0xpbmVhcml6ZWQgMS9MIDExNzk1My9PIDE2L0Ug MTEyNjE3L04gMS9UIDExNzY0My9IIFsgNjA2IDI1M10+Pg1lbmRvYmoNICAgICAgICAgICAgICAg DQo2MSAwIG9iag08PC9EZWNvZGVQYXJtczw8L0NvbHVtbnMgNS9QcmVkaWN0b3IgMTI+Pi9GaWx0 ZXIvRmxhdGVEZWNvZGUvSURbPDg4RkMxMTM2QjQ3RDhEQzRFMjkxQkEzRDJGNEIyODBBPjxGRTNC RkM3MjNFMDg3QzRCQUEyNTUzMkM5NEI5QjNCOT5dL0luZGV4WzE0IDc4XS9JbmZvIDEzIDAgUi9M and so on. I've tried a few recipes, and this is the one I'm trying now: pdf = MIMEApplication(pdf_data, 'pdf') pdf.add_header('Content-Disposition','attachment', filename = 'tics.pdf') msg.attach(pdf) Any help is appreciated. Also, if anyone has a working recipe, I'd like to see it. Thanks! Tobiah -- http://mail.python.org/mailman/listinfo/python-list
Running a curl command within py script
Hi Guys, i found pycurl to execute python curl command but not sure how I can execute the curl command using the pycurl. curl -u admin:geoserver -v -XPUT -H 'Content-type: text/plain' -d 'file:/var/www/geo/shapefile/csvQshp/Quercus_iltisii.shp' http://localhost:8080/geoserver/rest/workspaces/acme/datastores/Quercus_iltisii/external.shp ? This is the curl command. -- Thanks Regards Smaran Harihar -- http://mail.python.org/mailman/listinfo/python-list
How Run Py.test from PyScripter
I am a newbie to py.test , Please let me know how to run the py.test in PyScripter Editor. I have tried in the belwo way but it doesn't work. import pytest def func(x): return x + 1 def test_answer(): assert func(3) == 5 pytest.main() below is the Exception that i get Traceback (most recent call last): File module1, line 10, in module File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\core.py, line 474, in main exitstatus = config.hook.pytest_cmdline_main(config=config) File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\core.py, line 422, in __call__ return self._docall(methods, kwargs) File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\core.py, line 433, in _docall res = mc.execute() File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\core.py, line 351, in execute res = method(**kwargs) File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\main.py, line 107, in pytest_cmdline_main return wrap_session(config, _main) File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\main.py, line 92, in wrap_session config.pluginmanager.notify_exception(excinfo, config.option) File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\core.py, line 285, in notify_exception res = self.hook.pytest_internalerror(excrepr=excrepr) File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\core.py, line 422, in __call__ return self._docall(methods, kwargs) File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\core.py, line 433, in _docall res = mc.execute() File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\core.py, line 351, in execute res = method(**kwargs) File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\terminal.py, line 152, in pytest_internalerror self.write_line(INTERNALERROR + line) File C:\Python27\lib\site-packages\pytest-2.3.2-py2.7.egg\_pytest\terminal.py, line 140, in write_line self._tw.line(line, **markup) File C:\Python27\lib\site-packages\py-1.4.11-py2.7.egg\py\_io\terminalwriter.py, line 181, in line self.write(s, **kw) File C:\Python27\lib\site-packages\py-1.4.11-py2.7.egg\py\_io\terminalwriter.py, line 225, in write self._file.write(msg) File C:\Python27\lib\site-packages\py-1.4.11-py2.7.egg\py\_io\terminalwriter.py, line 241, in write self._writemethod(data) TypeError: 'AsyncStream' object is not callable -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Question regarding running .py program
On 11/14/2012 06:35 AM, Chris Angelico wrote: On Wed, Nov 14, 2012 at 6:02 PM, rurpy wrote: On 11/13/2012 11:02 PM, Chris Angelico wrote: To be more accurate: This is deprecated *by members of* this list. As there is no commanding/controlling entity here, it's up to each individual to make a decision - for instance, abusive users get killfiled rather than banned. The use of Google Groups to post is deprecated in the original sense of the word: strongly disapproved of. s/deprecated *by members of*/deprecated *by some members of*/ (and accuracy could probably be increased further by replacing some with a few.) I stand by what I said. Members, plural, of this list. I didn't say all members of, ergo the word some is superfluous, yet not needful, as Princess Ida put it. Then you would have no problem I suppose with Australians are racists because some Australians are racist and I didn't say all? I stand by what I said. Using the passive voice to give a false sense of authority, leaving out quantifiers when there are likely thousands of readers of this group perhaps a half dozen who've been vocal against GG, is not an accurate description. In any case, the fact remains that a number of this list's best responders have killfiled Google Groups posters as a whole. Consequently, GG forces you to go to quite a bit of extra work AND prevents your message from getting through to everyone. Why go to extra work to get a worse result? As a user of GG, Usenet and email lists I claim you are wrong. GG does NOT require quite a bit of extra work. If it did, I wouldn't use it. For occasional posters, GG is EASIER. (It would be even easier if Google would fix their execrable quoting behaviour but as I showed, it is easy to work around that.) I think you are ignoring setup time and a number of other secondary factors, things that are very significant to occasional posters, in your evaluation of easy. As for best, that is clearly a matter of opinion. The very fact that someone would killfile an entire class of poster based on a some others' posts reeks of intolerance and group-think. And since some of the anti-GG proponents are also among the most opinionated and argumentative participants here, their not reading GG posts could be seen as an advantage. As an aside, I've noticed that some those most vocal against GG have also been very vocal about this group being inclusive. If one observes that women post here (as a group) a lot less frequently then men, and if GG is easier for occasional posters, then the anti-GG attitude expressed here by a few would have the effect of disproportionately discriminating against women. I am therefore not going to recommend Google Groups to anyone as a means of posting to python-list/c.l.p, That's fine. But when doing so please leave out the false metaphors... any more than I would recommend writing it on a Post-It note and feeding it into your floppy drive. ...such as posting here via GG is similar to feeding post-its into a floppy drive. -- http://mail.python.org/mailman/listinfo/python-list
Re: Error
On 2012-11-14 15:18, inshu chauhan wrote: for this code m getting this error : CODE : def ComputeClasses(data): radius = .5 points = [] for cy in xrange(0, data.height): for cx in xrange(0, data.width): if data[cy,cx] != (0.0,0.0,0.0): centre = data[cy, cx] points.append(centre) Look at this line: change = True It's indented the same as the preceding 'if' statement, which means that it's executed even if the body of the 'if' statement wasn't executed and it hasn't assigned to 'centre'. So 'change' has been set to True, the 'while' loop is entered, and subsequently an attempt is made to get 'centre', which hasn't been set. while change: for ring_number in xrange(1, 1000): change = False new_indices = GenerateRing(cx, cy, ring_number) for idx in new_indices: point = data[idx[0], idx[1]] if point == (0.0, 0.0, 0.0 ): continue else: dist = distance(centre, point) if dist radius : print point points.append(point) change = True print change The indentation of this line looks wrong to me: break It'll affect the 'for cx' loop at the end of its first iteration, every time. ERROR : Traceback (most recent call last): File Z:\modules\classification2.py, line 74, in module ComputeClasses(data) File Z:\modules\classification2.py, line 56, in ComputeClasses dist = distance(centre, point) UnboundLocalError: local variable 'centre' referenced before assignment And i am unable to understand .. WHY ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Running a curl command within py script
Smaran Harihar smaran.hari...@gmail.com wrote: i found pycurl to execute python curl command but not sure how I can execute the curl command using the pycurl. curl -u admin:geoserver -v -XPUT -H 'Content-type: text/plain' -d 'file:/var/www/geo/shapefile/csvQshp/Quercus_iltisii.shp' http://localhost:8080/geoserver/rest/workspaces/acme/datastores/Quercus_iltisii/external.shp ? Off-topic, but here's an idea. Use the 'curl --libcurl foo' option to see what setopt() calls to use in PyCurl. Like: import sys, pycurl c = pycurl.Curl() c.setopt (c.URL, 'http://localhost:8080/geoserver/rest/workspaces/acme/datastores/Quercus_iltisii/external.shp') c.setopt (c.USERPWD, 'admin:geoserver') c.setopt (c.POSTFIELDS, 'file:/var/www/geo/shapefile/csvQshp/Quercus_iltisii.shp'); etc. --gv -- http://mail.python.org/mailman/listinfo/python-list
Re: creating size-limited tar files
On 11/14/2012 04:33 PM, Dave Angel wrote: Well, as I said, I don't see how the particular timing has anything to do with the rest of the thread. If you want to do an ls within a Python program, go ahead. But if all you need can be done with ls itself, then it'll be slower to launch python just to run it. Your first timing runs python, which runs two new shells, ls, and cat. Your second timing runs ls and cat. So the difference is starting up python, plus starting the shell two extra times. I'd also be curious if you flushed the system buffers before each timing, as the second test could be running entirely in system memory. And no, I don't know offhand how to flush them in Linux, just that without it, your timings are not at all repeatable. Note the two identical runs here. davea@think:~/temppython$ time ls -lR ~ | cat /dev/null real0m0.164s user0m0.020s sys 0m0.000s davea@think:~/temppython$ time ls -lR ~ | cat /dev/null real0m0.018s user0m0.000s sys 0m0.010s real time goes down by 90%, while user time drops to zero. And on a 3rd and subsequent run, sys time goes to zero as well. Right I didn't think about that.. Anyway the only thing I wanted to understand is if using the pipes in subprocess is exactly the same as doing the Linux pipe, or not. And any idea on how to run it in ram? Maybe if I create a pipe in tmpfs it might already work, what do you think? -- http://mail.python.org/mailman/listinfo/python-list
Re: creating size-limited tar files
On 11/14/2012 03:43 PM, Andrea Crotti wrote: SNIP Anyway the only thing I wanted to understand is if using the pipes in subprocess is exactly the same as doing the Linux pipe, or not. It's not the same thing, but you can usually assume it's close. Other effects will probably dominate any differences. And any idea on how to run it in ram? Maybe if I create a pipe in tmpfs it might already work, what do you think? In a good virtual OS, such as Linux, there's very little predictable difference between running in RAM (which is to say reading and writing to the swap file) or reading and writing to a file you specify. In fact, writing to a file can frequently be quicker, if it's sequential. Why? Linux is using any given piece of physical RAM to map a file, or an allocated buffer, or shared memory, or nearly anything. About the only special cases are the kind of RAM that has to be locked into RAM for hardware reasons. Linux decides which pieces to keep in memory, whether it calls it caching, swapping, memory mapping, or whatever. And frequently, attempts to beat the system result in counterintuitive results. If in doubt, measure. But choose your measures carefully, because lots more things will change the measurement than you might expect. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess puzzle and two questions
On Thu, Nov 15, 2012 at 3:20 AM, Roy Smith r...@panix.com wrote: I wrote: Oh, my. You're using DNS as a replacement for ping? Fair enough. In that case, all you really care about is that you can connect to port 53 on the server... s = socket.socket() s.connect(('8.8.8.8', 53)) In article mailman.3684.1352904008.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: That assumes that (a) the remote server supports TCP for DNS This is true. I honestly don't know what percentage of DNS servers out there only support UDP. The two I tried (Google's 8.8.8.8, and my Apple TimeCapsule) both supported TCP, but that's hardly a representitive sample. I don't know either, all I know is that DNSReport recommends supporting TCP, and none of my DNS servers ever fail that check. and (b) that connection time for TCP is comparable to ping or an actual DNS lookup. My first thought to solve both of these is that it shouldn't be too hard to hand-craft a minimal DNS query and send it over UDP. Then, I hunted around a bit and found that somebody had already done that, in spades. Take a look at http://www.dnspython.org; it might be exactly what's needed here. Yeah, that sounds like a good option. I'm slightly surprised that there's no way with the Python stdlib to point a DNS query at a specific server, but dnspython might be the solution. On the flip side, dnspython is dauntingly large; it looks like a full implementation of DNS, but I don't see a simple entrypoint that wraps it all up into a simple function that can be bracketed with time.time() calls (granted, I only skimmed the docs VERY quickly). So it may be simpler to hand-craft an outgoing UDP packet once, save it as a string literal, send that, and just wait for any response. That eliminates all DNS protocolling and just times the round trip. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Describing code with slides
I'm trying to work out the best way to provide a description of some code in a set of presentation slides which can be played backward and forward through the bits that someone is trying to understand (rather than using a screencast -- where you can never seem to rewind just the right amount ...). This example http://slidespeech.com/s/dLItUXnOen/ required taking multiple screenshots and then importing them into PowerPoint with Insert Photo Album. I added a voice over script to the speaker notes. The result was then run through SlideSpeech. If the code is available on a website, the slides can link to that site: http://slidespeech.com/s/dLItUXnOen?link=http://codepad.org/X1GPad5c Any suggestions on 1/ how to speed up the authoring process for this or 2/ improve the display of the code (such as avoiding showing all the IDE)? -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Question regarding running .py program
On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote: On 11/14/2012 06:35 AM, Chris Angelico wrote: [...] I stand by what I said. Members, plural, of this list. I didn't say all members of, ergo the word some is superfluous, yet not needful, as Princess Ida put it. Then you would have no problem I suppose with Australians are racists because some Australians are racist and I didn't say all? Speaking as an Australian, I wouldn't have a problem with that, because Australians *are* racist. To the degree that we can talk about a national character, the national character of Australia is racist, even if many Aussies aren't, and many more try not to be. In any case, your example is provocative. Here's a less provocative version: [paraphrase] Then you would have no problem I suppose with People have two legs because some people have two legs and I didn't say all? [end paraphrase] As a user of GG, Usenet and email lists I claim you are wrong. GG does NOT require quite a bit of extra work. If it did, I wouldn't use it. For occasional posters, GG is EASIER. (It would be even easier if Google would fix their execrable quoting behaviour but as I showed, it is easy to work around that.) I think you are ignoring setup time and a number of other secondary factors, things that are very significant to occasional posters, in your evaluation of easy. I don't understand why you suggest counting setup time for the alternatives to Google Groups, but *don't* consider setup time for Google Groups. You had to create a Google Account didn't you? You've either put in your mobile phone number -- and screw those who don't have one -- or you get badgered every time you sign in. You do sign in don't you? For *really* occasional posters, they might not even remember their Google account details from one post to the next. So they have to either create a new account, or go through the process of recreating it. Why do you ignore these factors in *your* evaluation of easy? We all do it -- when we talk about easy or difficult, we have an idealised generalised user in mind. Your idealised user is different from Chris' idealised user. You are both generalising. And that's *my* generalisation. Even if you are right that Google Groups is easier for some users, in my opinion it is easy in the same way as the Dark Side of the Force. Quicker, faster, more seductive, but ultimately destructive. As for best, that is clearly a matter of opinion. The very fact that someone would killfile an entire class of poster based on a some others' posts reeks of intolerance and group-think. Intolerance? Yes. But group-think? You believe that people are merely copying the group's prejudice against Google Groups. I don't think they are. I think that the dislike against GG is group consensus based on the evidence of our own eyes, not a mere prejudice. The use of Google Groups is, as far as I can tell, the single most effective predictor of badly written, badly thought out, badly formatted posts, and a common source of spam. As for intolerance, you say that like it is that a bad thing. Why should people have to tolerate bad behaviour? Google Groups *encourages* bad behaviour. Should we tolerate spam because any spam filter might occasionally throw away a legitimate mail? Should we tolerate acid attacks on women because occasionally there might be some woman who actually deserves such a horrible fate? I don't think so. For many things, intolerance is a *good* thing, and many people here believe that intolerance for Google Groups is one of those cases. You of course are free to make whatever arrangements to filter spam and use Google Groups as you like, but you equally must respect other people's right to control their own inbox by filtering away GG posters. [...] As an aside, I've noticed that some those most vocal against GG have also been very vocal about this group being inclusive. I call bullshit. If you are going to accuse people of being very vocal against minorities, you damn well better have some evidence to back up your claim. And if you don't, I would expect a public apology for that slur. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Question regarding running .py program
On Wednesday, November 14, 2012 4:07:53 PM UTC-7, Steven D'Aprano wrote: On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote: [...] As an aside, I've noticed that some those most vocal against GG have also been very vocal about this group being inclusive. I call bullshit. If you are going to accuse people of being very vocal against minorities, you damn well better have some evidence to back up your claim. And if you don't, I would expect a public apology for that slur. I wasn't very clear. I should have written ...those most vocal against GG have also been very vocal *in favor* of this group being inclusive. In the next paragraph which you clipped I pointed out the irony of that attitude versus one possible effect of advocating the blacklisting of GG posters: If one observes that women post here (as a group) a lot less frequently then men, and if GG is easier for occasional posters, then the anti-GG attitude expressed here by a few would have the effect of disproportionately discriminating against women. Response to your other points will need to wait until I have more time. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Question regarding running .py program
Steven, whilst I hold you in high regard, this post seems spurned by bias. I would urge you to reconsider your *argument*, although your *position* has merit. On 14 November 2012 23:07, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote: On 11/14/2012 06:35 AM, Chris Angelico wrote: I stand by what I said. Members, plural, of this list. I didn't say all members of, ergo the word some is superfluous, yet not needful, as Princess Ida put it. Then you would have no problem I suppose with Australians are racists because some Australians are racist and I didn't say all? Speaking as an Australian, I wouldn't have a problem with that, because Australians *are* racist. To the degree that we can talk about a national character, the national character of Australia is racist, even if many Aussies aren't, and many more try not to be. In any case, your example is provocative. Here's a less provocative version: [paraphrase] Then you would have no problem I suppose with People have two legs because some people have two legs and I didn't say all? [end paraphrase] Ahem? Seriously? With rounding, all people *do* have two legs. That's not fair. In fact, the idea that most users of this list ban Google Groups is probably false. Additionally, being provocative isn't actually weakness of his argument, although it is a distraction. He asked if you had a problem with it on the basis that if it was a fair claim you would not, in order to show that it was not a fair claim. That would *imply* his correctness. How about this(?): People have brown hair. As a user of GG, Usenet and email lists I claim you are wrong. GG does NOT require quite a bit of extra work. If it did, I wouldn't use it. For occasional posters, GG is EASIER. (It would be even easier if Google would fix their execrable quoting behaviour but as I showed, it is easy to work around that.) I think you are ignoring setup time and a number of other secondary factors, things that are very significant to occasional posters, in your evaluation of easy. I don't understand why you suggest counting setup time for the alternatives to Google Groups, but *don't* consider setup time for Google Groups. You had to create a Google Account didn't you? You've either put in your mobile phone number -- and screw those who don't have one -- or you get badgered every time you sign in. You do sign in don't you? That's not fair, either, on the basis that almost everyone has a Google account. Additionally, who signs in manually any more [*wink*]? For *really* occasional posters, they might not even remember their Google account details from one post to the next. So they have to either create a new account, or go through the process of recreating it. Why do you ignore these factors in *your* evaluation of easy? They might not remember their Email account either. This seems to be a really contrived point. We all do it -- when we talk about easy or difficult, we have an idealised generalised user in mind. Your idealised user is different from Chris' idealised user. You are both generalising. And that's *my* generalisation. All of this is really beside the point, anyway. He claimed the he used it because *he* found it easier. And there was claim that there were good reasons to use Google Groups. If you claim that his point is invalid because it only talks about *his* idealised user, you've only invalidated your own point. Even if you are right that Google Groups is easier for some users, in my opinion it is easy in the same way as the Dark Side of the Force. Quicker, faster, more seductive, but ultimately destructive. How so? As for best, that is clearly a matter of opinion. The very fact that someone would killfile an entire class of poster based on a some others' posts reeks of intolerance and group-think. Intolerance? Yes. But group-think? You believe that people are merely copying the group's prejudice against Google Groups. I don't think they are. I think that the dislike against GG is group consensus based on the evidence of our own eyes, not a mere prejudice. Consensus? Hrm...A synonym of consensus is unanimity. This argument's existence basically disproves that. The use of Google Groups is, as far as I can tell, the single most effective predictor of badly written, badly thought out, badly formatted posts, and a common source of spam. As for intolerance, you say that like it is that a bad thing. Why should people have to tolerate bad behaviour? Google Groups *encourages* bad behaviour. I think this is a valid thing to say. I agree largely because it's the user's choice to read and reply to this list. Calling someone helpful in a community intolerant because you think they could be nicer would be a bit intolerant yourself. Should we tolerate spam because any spam filter might occasionally throw away a legitimate
Re: access spreadsheet data
On 11/14/2012 1:35 AM, Amit Agrawal wrote: my problem is, i want to access data in spreadsheet to python code manualy My data is 1/1982 8:00:000 1/2/1982 8:00:000 1/3/1982 8:00:000 1/4/1982 8:00:000 1/5/1982 8:00:000.7885 1/6/1982 8:00:000 1/7/1982 8:00:000 1/8/1982 8:00:001.6127 You used tabs, which get deleted by some mail/news readers. Anyway, here is a start: data='''\ 1/1982 8:00:00 0 1/5/1982 8:00:00 0.7885 1/19/1982 8:00:00 0 1/20/1982 8:00:00 0''' lines = data.split('\n') # up to here, only for example for line in lines: fields = line.split() print('date {}: time {}: value {}'.format(fields[0], fields[1], fields[2])) date 1/1982: time 8:00:00: value 0 date 1/5/1982: time 8:00:00: value 0.7885 date 1/19/1982: time 8:00:00: value 0 date 1/20/1982: time 8:00:00: value 0 For real usage assume data are in data.txt in current directory. Then start with with open('data.txt') as lines: for line in lines -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Question regarding running .py program
On Wed, 14 Nov 2012 23:07:53 +, Steven D'Aprano wrote: On Wed, 14 Nov 2012 10:20:13 -0800, rurpy wrote: [...] [...] As an aside, I've noticed that some those most vocal against GG have also been very vocal about this group being inclusive. I call bullshit. If you are going to accuse people of being very vocal against minorities, you damn well better have some evidence to back up your claim. And if you don't, I would expect a public apology for that slur. Ah, apparently I misread Rurpy's comment. I'm sorry, I was completely wrong to accuse Rurpy of accusing others of being opposed to including minorites in this group. My apologies Rurpy, I don't know how I made that misreading. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Question regarding running .py program
On 11/13/2012 11:10 PM, Chris Angelico wrote: On Wed, Nov 14, 2012 at 2:31 PM, Caroline Hou joyhou2...@gmail.com wrote: Thank you Dave and everybody here for your helpful comments!This place is awesome! I found this group when I googled python-list. Seems like this is not the usual way you guys access the list? There are several ways to communicate with this list. * The comp.lang.python newsgroup - get a newsreader (there are plenty around), and either connect to your ISP's news server (if they have one that carries c.l.p) or to a public server, some of which cost money. * Use a news-to-web gateway such as Google Groups. That specific one is deprecated on this list, as there's more noise than signal from Google Groups. * The mailing list python-list, delivered directly to your inbox many times a day. This is what I personally use. news.gmane.org group gmane.comp.python.general many 'mail' programs such as Outlook Express or Thunderbird also handle news -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Question regarding running .py program
On 11/14/2012 2:02 AM, ru...@yahoo.com wrote: On the other hand finding and configuring a newsreader for someone whose never done it before, as you recommend, is a major time consumer. Use a mail/news program such as Thunderbird and the newsreader comes for free. Setting up a gmane account with Thunderbird was, as I remember rather easy, easier than setting up a mail account. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess puzzle and two questions
In article mailman.3700.1352930072.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: I'm slightly surprised that there's no way with the Python stdlib to point a DNS query at a specific server Me too, including the only slightly part. The normal high-level C resolver routines (getaddrinfo/getnameinfo, or even the old gethostbyname series), don't expose any way to do that. You have to dig quite far down in the resolver library stack to get to the point where you can do that. The concept of not knowing or caring which specific server has the data you need is quite deeply baked into the basic DNS architecture. -- http://mail.python.org/mailman/listinfo/python-list
Python questions help
I brought a python book and i'm a beginner and I read and tried to do the questions and I still get it wrong. How to create a program that reads an uspecified number of integers, that determines how many positive and negative values have been read, and computes the total and average of the input values(not counting zeroes). My program have to end with the input 0 and have to display the average as a floating-point number. Use nested loops that display the following patterns in separate programs: 1 12 123 1234 12345 123456 123456 12345 1234 123 12 1 1 21 321 4321 54321 654321 Write a program that computes the following summation: 1/ 1+square root of 2 + 1/ 1+square root of 2 + square root of 3 + 1/ 1+square root of 3 + square root of 4...+ 1/ 1+square root of 624 + square root of 625 How to a program to draw a chessboard using range? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Python questions help
On Thu, Nov 15, 2012 at 12:47 PM, su29090 129k...@gmail.com wrote: I brought a python book and i'm a beginner and I read and tried to do the questions and I still get it wrong. Pick one of the questions, write as much of the code as you can, and then post the specific difficulties you're having. If we write the code for you, it won't help you to learn, will it? Once you have some code that isn't working, we can help you to figure out what it is that isn't working. But do your best to write the code yourself first. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess puzzle and two questions
On Thu, Nov 15, 2012 at 12:49 PM, Roy Smith r...@panix.com wrote: In article mailman.3700.1352930072.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: I'm slightly surprised that there's no way with the Python stdlib to point a DNS query at a specific server Me too, including the only slightly part. The normal high-level C resolver routines (getaddrinfo/getnameinfo, or even the old gethostbyname series), don't expose any way to do that. You have to dig quite far down in the resolver library stack to get to the point where you can do that. The concept of not knowing or caring which specific server has the data you need is quite deeply baked into the basic DNS architecture. Indeed. But Python boasts that the batteries are included, and given the wealth of other networking facilities that are available, it is a bit of a hole that you can't run DNS queries in this way. Mind you, if Python's managed to get this far without it being a major stumbling-block, that probably means that it's not a serious lack. And I don't think many people write DNS *servers* in Python. (Most people don't write DNS servers at all, since BIND exists. But I did exactly that this week, since it would be easier than most other options.) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess puzzle and two questions
In article mailman.3707.1352945064.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: Indeed. But Python boasts that the batteries are included, and given the wealth of other networking facilities that are available, it is a bit of a hole that you can't run DNS queries in this way. Think of the socket and struct modules as a pile of carbon rods and gobs of zinc paste, from which you can assemble your own batteries, and make them in exactly the shape and size you need. -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess puzzle and two questions
On Thu, Nov 15, 2012 at 1:10 PM, Roy Smith r...@panix.com wrote: In article mailman.3707.1352945064.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: Indeed. But Python boasts that the batteries are included, and given the wealth of other networking facilities that are available, it is a bit of a hole that you can't run DNS queries in this way. Think of the socket and struct modules as a pile of carbon rods and gobs of zinc paste, from which you can assemble your own batteries, and make them in exactly the shape and size you need. Then assembly language is a pile of protons, neutrons, and electrons... :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess puzzle and two questions
On 11/14/2012 09:21 PM, Chris Angelico wrote: On Thu, Nov 15, 2012 at 1:10 PM, Roy Smith r...@panix.com wrote: In article mailman.3707.1352945064.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: Indeed. But Python boasts that the batteries are included, and given the wealth of other networking facilities that are available, it is a bit of a hole that you can't run DNS queries in this way. Think of the socket and struct modules as a pile of carbon rods and gobs of zinc paste, from which you can assemble your own batteries, and make them in exactly the shape and size you need. Then assembly language is a pile of protons, neutrons, and electrons... And real machine language (microcode) is a pile of quarks; fermions versus bosons. But in recent years, you pretty much have to work at Intel to see that part of the processor. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess puzzle and two questions
Chris Angelico ros...@gmail.com writes: On Thu, Nov 15, 2012 at 12:49 PM, Roy Smith r...@panix.com wrote: In article mailman.3700.1352930072.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: I'm slightly surprised that there's no way with the Python stdlib to point a DNS query at a specific server Me too, including the only slightly part. The normal high-level C resolver routines (getaddrinfo/getnameinfo, or even the old gethostbyname series), don't expose any way to do that. You have to dig quite far down in the resolver library stack to get to the point where you can do that. The concept of not knowing or caring which specific server has the data you need is quite deeply baked into the basic DNS architecture. Indeed. But Python boasts that the batteries are included, and given the wealth of other networking facilities that are available, it is a bit of a hole that you can't run DNS queries in this way. Mind you, if Python's managed to get this far without it being a major stumbling-block, that probably means that it's not a serious lack. And I don't think many people write DNS *servers* in Python. (Most people don't write DNS servers at all, since BIND exists. But I did exactly that this week, since it would be easier than most other options.) Indeed. Most people would prefer if random applications didn't make their own decisions about using specific DNS servers. That way, the users can make their own configuration choices (gai.conf, nsswitch.conf) according to their site preferences. If your application needs that level of control (if you're writing a nslookup replacement for some reason, perhaps), dnspython (www.dnspython.org) seems to have it. -- regards, kushal -- http://mail.python.org/mailman/listinfo/python-list
DNS from Python (was Re: Subprocess puzzle and two questions)
In article mailman.3700.1352930072.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Thu, Nov 15, 2012 at 3:20 AM, Roy Smith r...@panix.com wrote: My first thought to solve both of these is that it shouldn't be too hard to hand-craft a minimal DNS query and send it over UDP. Then, I hunted around a bit and found that somebody had already done that, in spades. Take a look at http://www.dnspython.org; it might be exactly what's needed here. Yeah, that sounds like a good option. I'm slightly surprised that there's no way with the Python stdlib to point a DNS query at a specific server, but dnspython might be the solution. On the flip side, dnspython is dauntingly large; it looks like a full implementation of DNS, but I don't see a simple entrypoint that wraps it all up into a simple function that can be bracketed with time.time() calls (granted, I only skimmed the docs VERY quickly). So it may be simpler to hand-craft an outgoing UDP packet once, save it as a string literal, send that, and just wait for any response. That eliminates all DNS protocolling and just times the round trip. From one of my scripts lying around: domain = MAILTO.split('@',1)[1] server = str(dns.resolver.query(domain, 'MX')[0].exchange) You'll need to play around a bit to find out what that does, but it should point you in the right direction. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ LL YR VWL R BLNG T S -- www.nancybuttons.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python garbage collector/memory manager behaving strangely
a...@pythoncraft.com (Aahz) writes: ... def readlines(f): lines = [] while f is not empty: line = f.readline() if not line: break if len(line) 2 and line[-2:] == '|\n': lines.append(line) yield ''.join(lines) lines = [] else: lines.append(line) There's a few changes I'd make: I'd change the name to something else, so as not to shadow the built-in, ... Actually, as an experienced programmer, I *do* think it is confusing as evidenced by the mistake Dave made! Segregated namespaces are wonderful (per Zen), but let's not pollute multiple namespaces with same name, either. It may not be literally shadowing the built-in, but it definitely mentally shadows the built-in. I disagree with you. namespaces are there that in working with a namespace I do not need to worry much about other namespaces. Therefore, calling a function readlines is very much justified (if it reads lines from a file), even though there was a module around with name readlines. By the way, the module is named readline (not readlines). -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting empty attachment with smtplib
Tobiah t...@tobiah.org writes: I just found out that the attachment works fine when I read the mail from the gmail website. Thunderbird complains that the attachment is empty. The MIME standard (a set of RFCs) specifies how valid messages with attachments should look like. Fetch the mail (unprocessed if possible) and look at its structure. If it is conformant to the MIME standard, then Thunderbird made a mistake; otherwise, something went wrong with the message construction. I can already say that smtplib is not to blame. It is (mostly) unconcerned with the internal structure of the message -- and by itself will not empty attachments. -- http://mail.python.org/mailman/listinfo/python-list
[issue16469] Exceptions raised by Fraction() from those raised by int()
Mark Dickinson added the comment: Certainly TypeError seems inappropriate here, and using ValueError for conversions from NaN sounds good to me. I'm not a big fan of the OverflowError for converting infinities to an integer: nothing's actually overflowed here. I think that should have been ValueError, too. So either of ValueError or OverflowError works for me there. I'd suggest fixing this for = 3.4 only. -- stage: - needs patch versions: +Python 3.4 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16469 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16469] Exceptions raised by Fraction() different from those raised by int()
Changes by Mark Dickinson dicki...@gmail.com: -- title: Exceptions raised by Fraction() from those raised by int() - Exceptions raised by Fraction() different from those raised by int() ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16469 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16157] Irrelevant references to Misc/News
Serhiy Storchaka added the comment: This issue affects only 3.3+ (see links above). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16157 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16469] Exceptions raised by Fraction() different from those raised by int()
Mark Dickinson added the comment: The from_decimal method should be changed as well. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16469 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16465] dict creation performance regression
Serhiy Storchaka added the comment: As I understand, the new dict created on every call of function with keyword arguments. This slow down every such call about 0.1 µsec. This is about 10% of int('42', base=16). In the sum, some programs can slow down to a few percents. Direct comparison of 3.2 and 3.3 is meaningless because of the influence of other factors (first of all PEP 393). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16465 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14373] C implementation of functools.lru_cache
Changes by Serhiy Storchaka storch...@gmail.com: -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14373 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16418] argparse with many choices can generate absurdly long usage message
Chris Jerdonek added the comment: To simplify the discussion and for issue resolution purposes, I propose that the discussion about large choices containers be divided into separate discussions for (1) changes that should be applied to all maintenance releases (i.e. bug fix changes), and (2) changes that should be applied only to the in-development branch (i.e. enhancements). I propose that the current issue be used for the former. 3.4-only enhancements can be dealt with as part of a separate issue. I also created issue 16468 for the bug that Terry observed above that ArgumentParser does not in general support choices values that support the in operator. That issue exists and can be resolved independent of whether the choices collection is large. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16418 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16418] argparse with many choices can generate absurdly long usage message
Chris Jerdonek added the comment: (1) changes that should be applied to all maintenance releases (i.e. bug fix changes) This should instead read, (1) changes that should be applied to all maintenance releases (e.g. bug fix and/or documentation changes). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16418 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2333] Backport set and dict comprehensions
Yongzhi Pan added the comment: I think metal means that the different ways set is repr'd in 2.7 and 3. In 2.7: In [9]: a = {x for x in 'abracadabra' if x not in 'abc'} In [10]: repr(a) Out[10]: set(['r', 'd']) In 3.2: In [6]: a = {x for x in 'abracadabra' if x not in 'abc'} In [7]: repr(a) Out[7]: {'r', 'd'} We were saying not changing __repr__ in #2335. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2333 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16469] Exceptions raised by Fraction() different from those raised by int()
Changes by Mark Dickinson dicki...@gmail.com: -- assignee: - mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16469 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16418] argparse with many choices can generate absurdly long usage message
Chris Jerdonek added the comment: The code could simply use the str or repr of the choice object It seems to me that this would result in less user-friendly behavior in many cases. It would also require the end-user to understand Python (e.g. xrange and dictionaries), which I don't think should be necessary for the user of a command-line script. For example, in Python 2.7 the containers xrange(5, 10), xrange(2, 10, 2), and {1: foo, 2: bar} currently yield the following user-friendly messages for choice 0: invalid choice: 0 (choose from 5, 6, 7, 8, 9) invalid choice: 0 (choose from 2, 4, 6, 8) invalid choice: 0 (choose from 1, 2) With the proposed change, these messages would be as follows, which seem unnecessarily obfuscated: invalid choice: 0 (choose from xrange(5, 10)) invalid choice: 0 (choose from xrange(2, 10, 2)) invalid choice: 0 (choose from {1: 'foo', 2: 'bar'}) Thus, I think the proposal above would be a regression if applied. I think any changes to maintenance releases should preserve the current user-friendly messages (when those messages are user-friendly, e.g. when the containers are small). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16418 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16460] Strange results for floor division (//) with non-integer divisors
Martin v. Löwis added the comment: I talked to a bunch of people (n=7) here at the company where I also give Python courses from time to time. I asked them two questions: 1. Is this behavior of FD what you would expect? 2. Given the current behavior of FD, what use cases do you see? The answers were always the same (and I tend to agree): 1. No. 2. No idea. All of you seem to answer the first questions with yes, but what's your answer to the second question? It's not that I had expected that answer, and I certainly agree that it is confusing. However, I also believe that it is the correct answer. What would you recommend your 10-year-old son or your 62-year-old mother to do with the current FD operator? The most obvious use case for FD is integer division. Neither my son nor my mom should use it for floating point (nor should they use floating-point in the first place). It's floating point. *Of course* it misbehaves. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16460 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16460] Strange results for floor division (//) with non-integer divisors
Martin v. Löwis added the comment: Zitat von Tom Pohl rep...@bugs.python.org: This is not: 1 // 0.1 = 9.0 because math.floor(1/0.1) is able to come up with the result that is expected from an operator called floor division. You apparently assume that it is possible to give a definition to FD for floating point that is less confusing. I do not think that this is possible; in particular, I believe that definining x//y as math.floor(x/y) is also confusing, in other cases (without being able to construct such cases right away). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16460 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16460] Strange results for floor division (//) with non-integer divisors
Mark Dickinson added the comment: I believe that definining x//y as math.floor(x/y) is also confusing in other cases (without being able to construct such cases right away). In addition, defining x//y as math.floor(x / y) would break its connection with %: a key invariant is that (x // y) * y + x % y should be (approximately in the case of floats) equal to y. The connection between // and % is more fundamental than the connection between // and /, so in cases where the two disagree, the %-related one wins. For applications: it's true that they're not common, but they do exist. One such is argument reduction: e.g., for a toy case, suppose that you're implementing a function that computes and returns sin and cos. The computation can be reduced to computing for angles between 0 and pi / 4: def sincos(x): Compute and return sin(x) and cos(x). q, r = divmod(x, pi / 4) compute sincos(r) use symmetries and the last 3 bits of q to compute sincos(x) This is an example where if the relationship between % and // were broken, we'd get wrong results---not simply inaccurate, but completely wrong. It's also worth noting that // and % are special in that they're the only basic arithmetic operations that can be computed *exactly*, with no numeric error, for a wide range of inputs: e.g., if x and y are positive and x / y 2**53, then both x // y and x % y return exact results. Modifying them to return inexact results instead would be ... surprising. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16460 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16460] Strange results for floor division (//) with non-integer divisors
Tom Pohl added the comment: Mark, thanks for explaining the connection of // and %. Finally, I can see why somebody would want to stick to the current behavior of FD. It renders FD useless for all of my use cases, but there are simple alternatives. Thanks for your time, Tom -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16460 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16471] upgrade to sphinx 1.1
New submission from Chris Jerdonek: This issue is to upgrade Python's Sphinx from version 1.0 to 1.1. I don't already see an issue for this, and I'm not sure what upgrading entails. Personally, I'm interested in the enhanced indexing capabilities, e.g. the see and seealso entry types, as well as marking main index entries: http://sphinx-doc.org/markup/misc.html#directive-index I'm sure other reasons for upgrading have been floated, though I don't know what they are. -- assignee: docs@python components: Documentation messages: 175560 nosy: chris.jerdonek, docs@python priority: normal severity: normal status: open title: upgrade to sphinx 1.1 type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16471 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16469] Exceptions raised by Fraction() different from those raised by int()
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16469 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14373] C implementation of functools.lru_cache
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14373 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16471] upgrade to sphinx 1.1
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +eric.araujo, ezio.melotti, georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16471 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16465] dict creation performance regression
Antoine Pitrou added the comment: As I understand, the new dict created on every call of function with keyword arguments. This slow down every such call about 0.1 µsec. This is about 10% of int('42', base=16). Ok, but `int('42', base=16)` is about the fastest function call with keyword arguments one can think about :-) In other words, the overhead will probably not be noticeable for most function calls. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16465 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16378] venv.EnvBuilder docstring inconsistencies
Roundup Robot added the comment: New changeset afb476dc202f by Vinay Sajip in branch '3.3': Issue #16378: Updated docstrings to reflect the defaults present in the code. http://hg.python.org/cpython/rev/afb476dc202f New changeset 6f0e49ed0589 by Vinay Sajip in branch 'default': Closes #16378: Merged docstring changes from 3.3. http://hg.python.org/cpython/rev/6f0e49ed0589 -- nosy: +python-dev resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16378 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16465] dict creation performance regression
Serhiy Storchaka added the comment: Ok, but `int('42', base=16)` is about the fastest function call with keyword arguments one can think about :-) Not as fast as a call without keywords, `int('42', 16)`. :-( But this is a different issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16465 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16418] argparse with many choices can generate absurdly long usage message
R. David Murray added the comment: I agree with Chris that using the repr in the general case would be a regression in usability for the end user (and certainly not suitable for a maintenance release). Here is some brainstorming: We could special case this via duck typing. If the object that represents the choices has 'start' and 'stop' attributes, use those to generate a message. (from {start} up to but not including {stop}). [*] If it doesn't, or it also has a 'step' that is not 1, check the len, generate the list if it is less than, say, 50, and if it is more give up and use the repr. If there is no len, do the expansion (which is what happens now) and throw it away in favor of the repr if there are more than 50 elements. If there is no iter, use the repr. Then as an enhancement we can also look for a special attribute (values_description?) that gives the entire text to use in the parenthesis in the help phrase to provide a way to customize the help text in 3.4+. [*] Or, at the risk of being too clever, if there is a 'step' use the message above and if there isn't a step attribute at all use between {start} and {stop}. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16418 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8400] zipimporter find_module fullname mis-documented
Te-jé Rodgers added the comment: Disregard the last...error on my part (so embarrassing!) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8400 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8400] zipimporter find_module fullname mis-documented
Te-jé Rodgers added the comment: It gets worse. Even though find_module works with the path separator, load_module fails. zi.find_module(lib\\ui) zipimporter object dist/Test_Editor-1.0-py3.2.zip zi.load_module(lib\\ui) Traceback (most recent call last): File stdin, line 1, in module File dist/Test_Editor-1.0-py3.2.zip\lib\ui\__init__.py, line 9, in module File dist\Test_Editor-1.0-py3.2.zip\lib\ui\texteditorwindow.py, line 5, in module File dist\Test_Editor-1.0-py3.2.zip\lib\ui\designer\__init__.py, line 5, in module ValueError: Attempted relative import beyond toplevel package -- versions: -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8400 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16465] dict creation performance regression
Serhiy Storchaka added the comment: Here is a really simple patch. It speed up to 1.9x an empty dict creation (still 1.6x slower than 3.2). Make your measurements of real-world programs. -- keywords: +patch stage: - patch review Added file: http://bugs.python.org/file27983/dict_free_key_list.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16465 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11566] hypot define in pyconfig.h clashes with g++'s cmath
Václav Šmilauer added the comment: Martin, I know it is not a proper fix. OTOH, Python is not the only project which recommends its header be included as first. I don't know if it is an issue for Python 3.x; will try to test that. This bug, though, is clearly reported about Python 2.7, which IS in bug-fix mode. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11566 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16472] Distutils+mingw links agains msvcr90, while python27.dll is linked agains msvcrt
New submission from Václav Šmilauer: Compiling an extension with --compiler=mingw32 with official python 2.7.3 distribution on Windows (64bit) leads to unusable result - crash on module load (invalid access to memory). The reasons is that Lib/distutils/cygwincompiler.py#l62 links the resulting .pyd file against msvcr90.dll (version is determined by version of MSVC used to build python itself), while python27.dll is linked against msvcrt.dll (shows the Dependency Walker). Based on my own experience (above) and MSDN docs http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx, http://msdn.microsoft.com/en-us/library/ms235460.aspx), loading 2 different runtimes is asking for trouble. I raised this topic on distutils-sig, hoping for an explanation. Judging by the reaction, it is quite possibly historical relict which is no longer needed. This is also hinted at by comments at the beginning of Lib/distutils/cygwincompiler.py if you use a msvc compiled python version (1.5.2) mingw gcc 3.2/ld 2.13 works I am aware of distutils being frozen for new features (unless you want to call bugfix a new feature). -- assignee: eric.araujo components: Distutils messages: 175569 nosy: eric.araujo, eudoxos, tarek priority: normal severity: normal status: open title: Distutils+mingw links agains msvcr90, while python27.dll is linked agains msvcrt versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16472 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16472] Distutils+mingw links agains msvcr90, while python27.dll is linked agains msvcrt
Changes by Ralf Schmitt python-b...@systemexit.de: -- nosy: +schmir ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16472 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16469] Exceptions raised by Fraction() different from those raised by int()
Martin v. Löwis added the comment: The description of OverflowError is that is is raised when the result of an arithmetic operation is too large to be represented, so it doesn't actually need to overflow. Still, I see that ∞ actually isn't too large to be represented (and the documentation points out that integer operations will raise MemoryError instead of OverflowError). So yes, ValueError seems more appropriate. +1 for fixing this in 3.4, only. -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16469 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16458] subprocess.py throw The handle is invalid error on duplicating the STD_INPUT_HANDLE
Changes by Tim Golden m...@timgolden.me.uk: -- nosy: +gregory.p.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16458 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16458] subprocess.py throw The handle is invalid error on duplicating the STD_INPUT_HANDLE
Tim Golden added the comment: On 13/11/2012 20:57, Karthk Rajagopalan wrote: I added test case using perl and python since it was easy to reproduce using perl socket module and show the issue happening with python's subprocess.py. There is definitely an action required in subprocess.py to catch 'invalid handle error' and my attached patch handle this situation. So, because subprocess.call includes a call to DuplicateHandle(stdin), that call will fail if stdin is currently a handle to a socket. Is that right? Your patch fails to apply cleanly to the hg tip, because Gregory P. Smith has been making changes in this very piece of code over the last few days. I'll add him as interested to the call as someone who can make a call as to the suitability of your patch. I can come up with a test case like perl does to create a listening socket and map the socket handle to a file descriptor. You will see this issue *only* when the open_osfhandle(..) is used to map the handle to a file descriptor. If this is to go ahead, we will need a test case which can run as part of the Python stdlib tests, and perl is not part of that stdlib! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16458 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16458] subprocess.py throw The handle is invalid error on duplicating the STD_INPUT_HANDLE
Karthk Rajagopalan added the comment: Hi Tim, Thanks for your reply. Yes, DuplicateHandle(..) seem to fail if the handle is to a socket under XP SP3. Can you point me to the guidelines about submitting patch so I can merge my change in main branch and upload it? We build python from source and doesn't use pywin32 as of now. So I downloaded them yesterday to come up with a test case in python which you can use in your test bed. -Karthik -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16458 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16458] subprocess.py throw The handle is invalid error on duplicating the STD_INPUT_HANDLE
Tim Golden added the comment: Start here: http://docs.python.org/devguide/ In particular: http://docs.python.org/devguide/patch.html -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16458 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16468] argparse only supports iterable choices
Chris Jerdonek added the comment: For the record, choices types implementing only __contains__ never worked in any cases. (I should have said ArgumentParser.add_argument() raises a ValueError in the above.) So I wonder if we should classify this as an enhancement and simply document the restriction in maintenance releases to iterable types. Clearly the module was written under the assumption (in multiple places) that choices are iterable. Also, if we do change this, perhaps we should fall back to displaying the metavar in help messages when naming the container rather than using repr(). A message like the following, for example, wouldn't be very helpful or look very good: invalid choice: 0 (choose from __main__.Container object at 0x10555efb0) I think we should avoid letting Python creep into help and usage text. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16468 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16400] update default PyPI behavior in docs re: listing versions
Chris Jerdonek added the comment: Martin, can you confirm that PyPI's behavior is as described in the patch? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16400 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16290] PyComplex_AsCComplex should allow __complex__ to return float.
Roundup Robot added the comment: New changeset 399e59ad0a70 by Mark Dickinson in branch 'default': Issue #16290: __complex__ must now always return an instance of complex. http://hg.python.org/cpython/rev/399e59ad0a70 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16290 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16290] PyComplex_AsCComplex should allow __complex__ to return float.
Changes by Mark Dickinson dicki...@gmail.com: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16290 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com