ANN: PyQt v5.3 Released
PyQt5 v5.3 has been released and is available from http://www.riverbankcomputing.com/software/pyqt/download5. PyQt5 is a comprehensive set of bindings for v5 of Digia's Qt cross-platform application framework. It supports Python v3, v2.7 and v2.6. The highlights of this release include support for Qt v5.3 including the new QtQuickWidgets and QtWebSockets modules. PyQt5 supports cross-compiling to iOS and Android. Windows installers are provided which contain everything needed for PyQt5 development (including Qt, Qt Designer, QScintilla, and MySQL, PostgreSQL, SQLite and ODBC drivers) except Python itself. Installers are provided for the 32 and 64 bit versions of Python v3.4. PyQt5 is implemented as a set of 29 extension modules including support for: - non-GUI infrastructure including event loops, threads, i18n, user and application settings, mapped files and shared memory - GUI infrastructure including window system integration, event handling, 2D graphics, basic imaging, fonts, OpenGL - a comprehensive set of desktop widgets - WebKit - full integration with Quick2 and QML allowing new Quick items to be implemented in Python and created in QML - event driven network programming - multimedia including cameras, audio and radios - Bluetooth - global positioning using satellite, Wi-Fi or text file sources - sensors including accelerometers, altimeters, compasses, gyroscopes, magnetometers, and light, pressure, proximity, rotation and temperature sensors - serial ports - SQL - printing - DBus - XPath, XQuery, XSLT and XML Schema validation - a help system for creating and viewing searchable documentation - unit testing of GUI applications. -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
ANN: pysendfile 2.0.1 released
Hi folks, I'm pleased to announce the 2.0.1 release of pysendfile: https://github.com/giampaolo/pysendfile === About === This is a python interface to sendfile(2) system call available on most UNIX systems. sendfile(2) provides a zero-copy way of copying data from one file descriptor to another (a socket). The phrase zero-copy refers to the fact that all of the copying of data between the two descriptors is done entirely by the kernel, with no copying of data into userspace buffers, resuting in file transfers being from 2x to 3x faster. Basically, any application sending files over the network can take advantage of it. HTTP and FTP servers are a typical example. === Changes === - #20: host tarball on PYPI - #21: project migrated from google code to github - #21: project migrated from SVN to GIT - #22: pysendfile won't compile on python 3.4 - #23: add a Makefile - #24: use of travis continuous integration - #25: use tox for multiple python versions testing === Supported platforms === * Linux * Mac OSX * FreeBSD * Dragon Fly BSD * Sun OS * AIX (not properly tested) === Supported python versions === From 2.5 to 3.4. -- Giampaolo - http://grodola.blogspot.com -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[ANN]: Salstat, friendly open source statistics
I am proud to announce a new source code release of Salstat, the friendly open source statistics program. It is written in Python with Numpy, SciPy, wxPython and many other Python libraries (see the readme.md Code is available from GitHub: https://github.com/salmoni/Salstat ## What is Salstat? Salstat is a program for statistical analysis: Much like SPSS but friendlier and easier to use. It began in 2000 as a project to provide software that removed legacy interfaces and let people learn about statistics rather than having to master an interface. After a career-imposed hiatus since 2003, a few released have crept out over the last year bringing improvements and a more powerful program to people who aren't comfortable with statistics. ## What's new? This latest release features simple histograms. ## What features does it have? *Data import*: SAS, CSV, Excel, LibreOffice Calc *Descriptives*: Too many to mention. There are 9 types of quantile to give you some idea. Can analyse univariate or multivariate data sets. *Inferential tests*: A range of 1 and 2 sample tests, parametric and non-parametric. 2+ sample tests are currently not working because the relevant interface needs a redesign to accommodate them but they will be arriving soon. *Charts, graphs, plots*: Column, bar, scatter, line, spline, area, pie, box plot, histogram. ## Does Salstat need help? Please pass this news around your social media network to spread the word. Find us on Twitter (@Salstat) and full news articles at http://salstat.blogspot.co.uk/. We're okay with the developer talent (although we're always pleased to hear especially if you can commit long-term) but most of all we need users – which means telling people Salstat exists. All the best have fun, Alan J. Salmoni Salstat – Friendly open source statistics GitHub: https://github.com/salmoni/Salstat Blog: http://salstat.blogspot.co.uk/ Facebook: https://www.facebook.com/salstat1 Twitter: @Salstat -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
ANN: Pandas 0.14.0 released
Hello, We are proud to announce v0.14.0 of pandas, a major release from 0.13.1. This release includes a small number of API changes, several new features, enhancements, and performance improvements along with a large number of bug fixes. This was 4 months of work with 1014 commits by 121 authors encompassing 757 issues. We recommend that all users upgrade to this version. *Highlights:* - Officially support Python 3.4 - SQL interfaces updated to use sqlalchemy - Display interface changes - MultiIndexing Using Slicers - Ability to join a singly-indexed DataFrame with a multi-indexed DataFrame - More consistency in groupby results and more flexible groupby specifications - Holiday calendars are now supported in CustomBusinessDay - Several improvements in plotting functions, including: hexbin, area and pie plots - Performance doc section on I/O operations See a full description of Whatsnew for v0.14.0 here: http://pandas.pydata.org/pandas-docs/stable/whatsnew.html *What is it:* *pandas* is a Python package providing fast, flexible, and expressive data structures designed to make working with “relational” or “labeled” data both easy and intuitive. It aims to be the fundamental high-level building block for doing practical, real world data analysis in Python. Additionally, it has the broader goal of becoming the most powerful and flexible open source data analysis / manipulation tool available in any language. Documentation: http://pandas.pydata.org/pandas-docs/stable/ Source tarballs, windows binaries are available on PyPI: https://pypi.python.org/pypi/pandas windows binaries are courtesy of Christoph Gohlke and are built on Numpy 1.8 macosx wheels will be available soon, courtesy of Matthew Brett Please report any issues here: https://github.com/pydata/pandas/issues Thanks The Pandas Development Team Contributors to the 0.14.0 release - Acanthostega - Adam Marcus - agijsberts - akittredge - Alex Gaudio - Alex Rothberg - AllenDowney - Andrew Rosenfeld - Andy Hayden - ankostis - anomrake - Antoine Mazières - anton-d - bashtage - Benedikt Sauer - benjamin - Brad Buran - bwignall - cgohlke - chebee7i - Christopher Whelan - Clark Fitzgerald - clham - Dale Jung - Dan Allan - Dan Birken - danielballan - Daniel Waeber - David Jung - David Stephens - Douglas McNeil - DSM - Garrett Drapala - Gouthaman Balaraman - Guillaume Poulin - hshimizu77 - hugo - immerrr - ischwabacher - Jacob Howard - Jacob Schaer - jaimefrio - Jason Sexauer - Jeff Reback - Jeffrey Starr - Jeff Tratner - John David Reaver - John McNamara - John W. O'Brien - Jonathan Chambers - Joris Van den Bossche - jreback - jsexauer - Julia Evans - Júlio - Katie Atkinson - kdiether - Kelsey Jordahl - Kevin Sheppard - K.-Michael Aye - Matthias Kuhn - Matt Wittmann - Max Grender-Jones - Michael E. Gruen - michaelws - mikebailey - Mike Kelly - Nipun Batra - Noah Spies - ojdo - onesandzeroes - Patrick O'Keeffe - phaebz - Phillip Cloud - Pietro Battiston - PKEuS - Randy Carnevale - ribonoous - Robert Gibboni - rockg - sinhrks - Skipper Seabold - SplashDance - Stephan Hoyer - Tim Cera - Tobias Brandt - Todd Jennings - TomAugspurger - Tom Augspurger - unutbu - westurner - Yaroslav Halchenko - y-p - zach powers -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Crochet 1.3.0 - Use Twisted Anywhere!
Crochet is an MIT-licensed library that makes it easier to use Twisted from regular blocking code. Some use cases include: * Easily use Twisted from a blocking framework like Django or Flask. * Write a library that provides a blocking API, but uses Twisted for its implementation. * Port blocking code to Twisted more easily, by keeping a backwards compatibility layer. * Allow normal Twisted programs that use threads to interact with Twisted more cleanly from their threaded parts. For example this can be useful when using Twisted as a WSGI container. This is a bugfix release, recommended for all users of Crochet. Crochet can be downloaded from https://pypi.python.org/pypi/crochet or by running: $ pip install crochet Documentation can be found at http://crochet.readthedocs.org https://crochet.readthedocs.org/ Bugs and feature requests should be filed at the project https://github.com/itamarst/crochet Here’s an example of a program using Crochet. Notice that you get a completely blocking interface to Twisted and do not need to run the Twisted reactor, the event loop, yourself. #!/usr/bin/python Do a DNS lookup using Twisted's APIs. from __future__ import print_function # The Twisted code we'll be using: from twisted.names import client from crochet import setup, wait_for setup() # Crochet layer, wrapping Twisted's DNS library in a blocking call. @wait_for(timeout=5.0) def gethostbyname(name): Lookup the IP of a given hostname. Unlike socket.gethostbyname() which can take an arbitrary amount of time to finish, this function will raise crochet.TimeoutError if more than 5 seconds elapse without an answer being received. d = client.lookupAddress(name) d.addCallback(lambda result: result[0][0].payload.dottedQuad()) return d if __name__ == '__main__': # Application code using the public API - notice it works in a normal # blocking manner, with no event loop visible: import sys name = sys.argv[1] ip = gethostbyname(name) print(name, -, ip) Run on the command line: $ python blockingdns.py twistedmatrix.com twistedmatrix.com - 66.35.39.66 -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[RELEASE] Python 2.7.7
I'm happy to announce the immediate availability of Python 2.7.7. Python 2.7.7 is a regularly scheduled bugfix release for the Python 2.7 series. This release includes months of accumulated bugfixes. All the changes in Python 2.7.7 are described in detail in the Misc/NEWS file of the source tarball. You can view it online at http://hg.python.org/cpython/raw-file/f89216059edf/Misc/NEWS The 2.7.7 release also contains fixes for two severe, if arcane, potential security vulnerabilities. The first was the possibility of reading arbitrary process memory using JSONDecoder.raw_decode. [1] (No other json APIs are affected.) The second security issue is an integer overflow in the strop module. [2] (You actually have no reason whatsoever to use the strop module.) Another security note for 2.7.7 is that the release includes a backport from Python 3 of hmac.compare_digest. This begins the implementation of PEP 466, Network Security Enhancements for Python 2.7.x. Downloads are at https://python.org/download/releases/2.7.7/ This is a production release. As always, please report bugs to http://bugs.python.org/ Build great things, Benjamin Peterson 2.7 Release Manager (on behalf of all of Python's contributors) [1] http://bugs.python.org/issue21529 [2] http://bugs.python.org/issue21530 -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: ImportError: No module named _gdb
Marcelo Sardelich msardel...@gmail.com writes: So I'm trying to implement pretty printing information using gdb-python27 on Windows7 Hopefully, someone experienced the same issue. GDB is working fine, but when I run gdb-python27 I got the following error (related to a python import): C:\MinGW\bingdb-python27.exe Traceback (most recent call last): File string, line 70, in module File string, line 67, in GdbSetPythonDirectory File c:\mingw\share\gdb/python\gdb\__init__.py, line 19, in module import _gdb ImportError: No module named _gdb Likely, an external (C) extension (named _gdb) must be build (and installed) - and apparently, this is not yet done in your installation. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 is killing Python
in 722944 20140601 124133 Steve Hayes hayes...@telkomsa.net wrote: On Sun, 01 Jun 2014 07:01:46 BST, Bob Martin bob.mar...@excite.com wrote: in 722929 20140601 035727 Steve Hayes hayes...@telkomsa.net wrote: No, it's a bit like flying in a Boeing 747 rather than a Concorde. The latyer may be later and more technically advanced and flew faster, but no one uses or supports it. Actually, the Concorde preceded the 747, and wasn't as technically advanced, it was just faster. Boeing 747s were in airline service in 1970, Concorde didn't enter service till 4-5 years later. Concorde design started in the early 50s, 747 mid-to-late 60s. -- https://mail.python.org/mailman/listinfo/python-list
Re: IDE for python
wxjmfauth at gmail.com writes: Amen. Ite missa est. Oh, why all the lamenting about python's unicode support, when your latin is so superbe ! Elegant solution to all your problems :) -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.2 has some deadly infection
Tim Delaney timothy.c.delaney at gmail.com writes: I also should have been more clear that *in the particular situation I was talking about* iso-latin-1 as default would be the right thing to do, not in the general case. Quite often we won't know the correct encoding until we've executed a command via ssh - iso-latin-1 will allow us to extract the info we need (which will generally be 7-bit ASCII) without the possibility of an invalid encoding. Sure we may get mojibake, but that's better than the alternative when we don't yet know the correct encoding. Latin-1 is one of those legacy encodings which needs to die, not to be entrenched as the default. My terminal uses UTF-8 by default (as itshould), and if I use the terminal to input δжç, Python ought to seewhat I input, not Latin-1 moji-bake. For some purposes, there needs to be a way to treat an arbitrary stream of bytes as an arbitrary stream of 8-bit characters. iso-latin-1 is a convenient way to do that. For that purpose, Python3 has the bytes() type. Read the data as is, then decode it to a string once you figured out its encoding. Wolfgang -- https://mail.python.org/mailman/listinfo/python-list
Re: IDE for python
On 02/06/2014 08:28, Wolfgang Maier wrote: wxjmfauth at gmail.com writes: Amen. Ite missa est. Oh, why all the lamenting about python's unicode support, when your latin is so superbe ! Elegant solution to all your problems :) After all, if you can't use Latin-1 for Latin, what can you use it for? TJG -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.2 has some deadly infection
On 2 June 2014 17:45, Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de wrote: Tim Delaney timothy.c.delaney at gmail.com writes: For some purposes, there needs to be a way to treat an arbitrary stream of bytes as an arbitrary stream of 8-bit characters. iso-latin-1 is a convenient way to do that. For that purpose, Python3 has the bytes() type. Read the data as is, then decode it to a string once you figured out its encoding. I know that, you know that. Convincing other people of that is the difficulty. I probably should have mentioned it, but in my case it's not even Python (Java). It's exactly the same principal - an assumption was made that has become entrenched due to the fear of breakage. If they'd been forced to think about encodings up-front, it shouldn't have been an issue, which was the point I was trying to make. In Java, it's much worse. At least with Python you can perform string-like operations on bytes. In Java you have to convert it to characters before you can really do anything with it, so people just use the default encoding all the time - especially if they want the convenience of line-by-line reading using BufferedReader ... Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list
Re: IDE for python
On 02/06/2014 09:15, Tim Golden wrote: On 02/06/2014 08:28, Wolfgang Maier wrote: wxjmfauth at gmail.com writes: Amen. Ite missa est. Oh, why all the lamenting about python's unicode support, when your latin is so superbe ! Elegant solution to all your problems :) After all, if you can't use Latin-1 for Latin, what can you use it for? TJG What is the Latin for resident unicode expert go home? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: IDE for python
On Mon, Jun 2, 2014 at 7:02 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: What is the Latin for resident unicode expert go home? Google Translate says: Eusebius, et revertatur in domum perito resident. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.2 has some deadly infection
On Mon, Jun 2, 2014 at 7:02 PM, Tim Delaney timothy.c.dela...@gmail.com wrote: In Java, it's much worse. At least with Python you can perform string-like operations on bytes. In Java you have to convert it to characters before you can really do anything with it, so people just use the default encoding all the time - especially if they want the convenience of line-by-line reading using BufferedReader ... What exactly is line-by-line reading with bytes? As I understand it, lines are defined by characters. If you mean reading a stream of bytes and dividing it on 0x0A, then surely you can do that, but that assumes an ASCII-compatible encoding. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: IDE for python
Chris Angelico rosuav at gmail.com writes: On Mon, Jun 2, 2014 at 7:02 PM, Mark Lawrence breamoreboy at yahoo.co.uk wrote: What is the Latin for resident unicode expert go home? Google Translate says: Eusebius, et revertatur in domum perito resident. ChrisA Oh, the joys of Google Translate. Round-tripping this through French (as wxjm may do) back to English I get: Eusebius, and return to their seat in the house experience I'd translate it roughly as: I domum, perite omnipräsens unicodicis! but my last (school) use of Latin is many years back. -- https://mail.python.org/mailman/listinfo/python-list
Re: IDE for python
On 02/06/2014 10:15, Chris Angelico wrote: On Mon, Jun 2, 2014 at 7:02 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: What is the Latin for resident unicode expert go home? Google Translate says: Eusebius, et revertatur in domum perito resident. ChrisA Try: Perite domestice unicodicis: vade in domum tuam [from a friend of mine who manages to combine expertise in historical writings and competence in Unicode] TJG -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.2 has some deadly infection
I probably should have mentioned it, but in my case it's not even Python (Java). It's exactly the same principal - an assumption was made that has become entrenched due to the fear of breakage. If they'd been forced to think about encodings up-front, it shouldn't have been an issue, which was the point I was trying to make. there seems to be an implicit assumption in python land that encoded strings are the norm. On virtually every computer I encounter that assumption is wrong. The vast majority of bytes in most computers is not something that can be easily printed out for humans to read. I suppose some clever pythonista can figure out an encoding to read my .o / .so etc files, but they are practically meaningless to a unicode program today. Same goes for most image formats and media files. Browsers routinely encounter mis/un-encoded pages. In Java, it's much worse. At least with Python you can perform string-like operations on bytes. In Java you have to convert it to characters before you can really do anything with it, so people just use the default encoding all the time - especially if they want the convenience of line-by-line reading using BufferedReader ... .. In python I would have preferred for bytes to remain the default io mechanism, at least that would allow me to decide if I need any decoding. As the cat example http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/ showed these extra assumptions are sometimes really in the way. -- Robin Becker -- https://mail.python.org/mailman/listinfo/python-list
Re: Python GUI?
I don't like it when you can DD to position things. I don't understand why someone wouldn't want to write the positioning code, and have fun with the debugging. That's the best part about writing a program, in my opinion. I'm against DD with programming, and I'm not sure why. I don't understand people that also insist on writing code in notepad :) GUI design is not for programmers, but for designers. But the first version of a GUI can be made by a programmer, so they can make a working application. Then the designer can make the GUI work for the end user. Anyone that know about a better GUI kit than QT that works well with Python? -- https://mail.python.org/mailman/listinfo/python-list
Re: IDE for python
On 02/06/2014 11:43, Tim Golden wrote: On 02/06/2014 10:15, Chris Angelico wrote: On Mon, Jun 2, 2014 at 7:02 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: What is the Latin for resident unicode expert go home? Google Translate says: Eusebius, et revertatur in domum perito resident. ChrisA Try: Perite domestice unicodicis: vade in domum tuam [from a friend of mine who manages to combine expertise in historical writings and competence in Unicode] TJG Surely that'll give a syntax error as the indentation is incorrect, there's no except: clause and the comment should be in quotes, not square brackets??? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Obfuscated Python hack
Kids, don't try this at home! In Python 2.7, run this: exec((lambda *fs: reduce(lambda f, g: lambda x: f(g(x)), fs))(*([lambda s: s[1::2]+s[-2::-2]]*54))('motcye;cye._n8fo_drs(d4+)vle=5 ua.8) (isedamr.ticspt spt rpi')) Then run these: 10 - 6 == 10 - 5 4 + 1 == 7 - 1 2*2 == 10//2 A shiny penny for the first person to explain what's going on.[1] [1] Offer expires April 1st 2014. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Obfuscated Python hack
On 2014-06-02 12:11, Steven D'Aprano wrote: Kids, don't try this at home! In Python 2.7, run this: exec((lambda *fs: reduce(lambda f, g: lambda x: f(g(x)), fs))(*([lambda s: s[1::2]+s[-2::-2]]*54))('motcye;cye._n8fo_drs(d4+)vle=5 ua.8) (isedamr.ticspt spt rpi')) Then run these: 10 - 6 == 10 - 5 4 + 1 == 7 - 1 2*2 == 10//2 A shiny penny for the first person to explain what's going on.[1] Stripping off the exec() call makes it pretty transparent that you're attempting (successfully on some platforms) to set the value of 4 to 5. But a cute hack. -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: Obfuscated Python hack
On Mon, Jun 2, 2014 at 10:27 PM, Tim Chase python.l...@tim.thechases.com wrote: Stripping off the exec() call makes it pretty transparent that you're attempting (successfully on some platforms) to set the value of 4 to 5. But a cute hack. And not on Windows inside IDLE, where attempting to use 4 results in a = RESTART = crash. But a nice try. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
How to read a directory path from a txt file
I have created a txt file with various paths to directories. The paths look like this /home/wachkama/Desktop/api/genshi /home/wachkama/Desktop/www/portal/schedule /home/wachkama/Desktop/show/help.genshi How do i read this paths in python ? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to read a directory path from a txt file
On Tue, Jun 3, 2014 at 12:18 AM, Samuel Kamau wachk...@gmail.com wrote: I have created a txt file with various paths to directories. The paths look like this /home/wachkama/Desktop/api/genshi /home/wachkama/Desktop/www/portal/schedule /home/wachkama/Desktop/show/help.genshi How do i read this paths in python ? This sounds like homework. You'll need to go back to the problem you've been given, figure out what you're actually trying to accomplish, and then break that down into several pieces. We're happy to help you learn, but we will not just do the assignment for you, as that's counter-productive for all of us. If it *isn't* homework, please explain in much more detail what it is you're trying to do here. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to read a directory path from a txt file
On Monday, June 2, 2014 7:48:25 PM UTC+5:30, Samuel Kamau wrote: I have created a txt file with various paths to directories. The paths look like this /home/wachkama/Desktop/api/genshi /home/wachkama/Desktop/www/portal/schedule /home/wachkama/Desktop/show/help.genshi How do i read this paths in python ? for x in open(filenames.txt): print x Assuming your filenames are in a file called filenames.txt in current directory Also in practice: 1. You probably want print x.strip() 2. You dont want a print but whatever is the code you want -- https://mail.python.org/mailman/listinfo/python-list
Re: How to read a directory path from a txt file
On 02/06/2014 15:18, Samuel Kamau wrote: I have created a txt file with various paths to directories. The paths look like this /home/wachkama/Desktop/api/genshi /home/wachkama/Desktop/www/portal/schedule /home/wachkama/Desktop/show/help.genshi How do i read this paths in python ? https://docs.python.org/3/library/functions.html#open https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 is killing Python
On Jun 1, 2014 12:11 PM, wxjmfa...@gmail.com wrote: At least Py2 does not crash when using non ascii (eg sticking with cp1252). I just noticed this last week, Thursday, when presenting the absurdity of the Flexible String Representation. So have you reported this alleged crash bug to the bug tracker? If not, then you're not contributing to Python or the discussion here in any useful way; you're just trolling. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to read a directory path from a txt file
On Monday, June 2, 2014 10:18:25 AM UTC-4, Samuel Kamau wrote: I have created a txt file with various paths to directories. The paths look like this /home/wachkama/Desktop/api/genshi /home/wachkama/Desktop/www/portal/schedule /home/wachkama/Desktop/show/help.genshi How do i read this paths in python ? I have permission issues with my web server. So I have written part of my script to read and write the current paths in the web servers with its username and group name into a txt file. I want my script to replace the new permissions on my web server with the permissions written on my txt file. So The last part of my script is the tricky part. How to read the txt file and go to all the paths and rewrite the permissions as per what is on the txt file. -- https://mail.python.org/mailman/listinfo/python-list
Re: Obfuscated Python hack
On Mon, 02 Jun 2014 23:23:53 +1000, Chris Angelico wrote: On Mon, Jun 2, 2014 at 10:27 PM, Tim Chase python.l...@tim.thechases.com wrote: Stripping off the exec() call makes it pretty transparent that you're attempting (successfully on some platforms) to set the value of 4 to 5. But a cute hack. And not on Windows inside IDLE, where attempting to use 4 results in a = RESTART = crash. Sounds like a bug in IDLE. What happens if you try it in Windows without IDLE, just using the standard interactive interpreter? -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Obfuscated Python hack
On Mon, Jun 2, 2014 at 9:38 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 02 Jun 2014 23:23:53 +1000, Chris Angelico wrote: On Mon, Jun 2, 2014 at 10:27 PM, Tim Chase python.l...@tim.thechases.com wrote: Stripping off the exec() call makes it pretty transparent that you're attempting (successfully on some platforms) to set the value of 4 to 5. But a cute hack. And not on Windows inside IDLE, where attempting to use 4 results in a = RESTART = crash. Sounds like a bug in IDLE. What happens if you try it in Windows without IDLE, just using the standard interactive interpreter? Actually, probably a 32/64-bit issue. The code as supplied caused a segfault on my 64-bit Linux install. I had to change the offset to 16 to see it work. -- https://mail.python.org/mailman/listinfo/python-list
Re: Obfuscated Python hack
On Tue, Jun 3, 2014 at 1:38 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 02 Jun 2014 23:23:53 +1000, Chris Angelico wrote: On Mon, Jun 2, 2014 at 10:27 PM, Tim Chase python.l...@tim.thechases.com wrote: Stripping off the exec() call makes it pretty transparent that you're attempting (successfully on some platforms) to set the value of 4 to 5. But a cute hack. And not on Windows inside IDLE, where attempting to use 4 results in a = RESTART = crash. Sounds like a bug in IDLE. What happens if you try it in Windows without IDLE, just using the standard interactive interpreter? It works fine without IDLE. Python 2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)] on win 32 exec((lambda *fs: reduce(lambda f, g: lambda x: f(g(x)), fs))(*([lambda s: s [1::2]+s[-2::-2]]*54))('motcye;cye._n8fo_drs(d4+)vle=5 ua.8)(isedamr.ticspt spt rpi')) 10 - 6 == 10 - 5 True In IDLE: exec((lambda *fs: reduce(lambda f, g: lambda x: f(g(x)), fs))(*([lambda s: s[1::2]+s[-2::-2]]*54))('motcye;cye._n8fo_drs(d4+)vle=5 ua.8)(isedamr.ticspt spt rpi')) 10 - 6 == 10 - 5 RESTART There's a bit of a pause before the RESTART line comes through, and repeating the equality check after that comes back with a straight-forward False. Running IDLE from a terminal gives this: C:\Documents and Settings\M\python27\python -m idlelib.idle Unhandled server exception! Thread: SockThread Client Address: ('127.0.0.1', 4414) Request: socket._socketobject object at 0x0127ADC0 Traceback (most recent call last): File C:\python27\lib\SocketServer.py, line 295, in _handle_request_noblock self.process_request(request, client_address) File C:\python27\lib\SocketServer.py, line 321, in process_request self.finish_request(request, client_address) File C:\python27\lib\SocketServer.py, line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File C:\python27\lib\idlelib\rpc.py, line 503, in __init__ SocketServer.BaseRequestHandler.__init__(self, sock, addr, svr) File C:\python27\lib\SocketServer.py, line 649, in __init__ self.handle() File C:\python27\lib\idlelib\run.py, line 268, in handle rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05) File C:\python27\lib\idlelib\rpc.py, line 280, in getresponse response = self._getresponse(myseq, wait) File C:\python27\lib\idlelib\rpc.py, line 300, in _getresponse response = self.pollresponse(myseq, wait) File C:\python27\lib\idlelib\rpc.py, line 424, in pollresponse message = self.pollmessage(wait) File C:\python27\lib\idlelib\rpc.py, line 376, in pollmessage packet = self.pollpacket(wait) File C:\python27\lib\idlelib\rpc.py, line 357, in pollpacket self._stage0() File C:\python27\lib\idlelib\rpc.py, line 364, in _stage0 self.bufneed = struct.unpack(i, s)[0] error: unpack requires a string argument of length 4 *** Unrecoverable, server exiting! So... I'd say this isn't so much a bug in IDLE as a limitation: depends on the universe being sane. I mean, honestly. You just changed the meaning of four! :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Obfuscated Python hack
On Tue, Jun 3, 2014 at 1:47 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Mon, Jun 2, 2014 at 9:38 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 02 Jun 2014 23:23:53 +1000, Chris Angelico wrote: On Mon, Jun 2, 2014 at 10:27 PM, Tim Chase python.l...@tim.thechases.com wrote: Stripping off the exec() call makes it pretty transparent that you're attempting (successfully on some platforms) to set the value of 4 to 5. But a cute hack. And not on Windows inside IDLE, where attempting to use 4 results in a = RESTART = crash. Sounds like a bug in IDLE. What happens if you try it in Windows without IDLE, just using the standard interactive interpreter? Actually, probably a 32/64-bit issue. The code as supplied caused a segfault on my 64-bit Linux install. I had to change the offset to 16 to see it work. My test was a 32-bit Python 2.7.4, for what it's worth. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Is MVC Design Pattern good enough?
I had developed many database business applications using MVC design pattern with different programming languages like PHP, Java EE, VB.NET, C#, VB 6.0, VBA, etc. All of them defined the Model layer as the data management of the application domain and business logic implementation. I ready don’t understand what the data has to do with applications business logic. Nothing? Can we implement the application business logic in another layer? Yes or no? Why? Explain? The most intuitive approach to database applications would be: http://en.wikipedia.org/wiki/Naked_objects http://www.nakedobjects.org/ The original Inventor of MVC once declared that this concept matches his intentions a lot better than the very vast majority of MVC implementations. Unfortunately, there's no Python framework (yet?) that implements this design. Sincerely, Wolfgang -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 is killing Python
On Mon, 02 Jun 2014 09:01:01 -0600, Ian Kelly wrote: On Jun 1, 2014 12:11 PM, wxjmfa...@gmail.com wrote: At least Py2 does not crash when using non ascii (eg sticking with cp1252). I just noticed this last week, Thursday, when presenting the absurdity of the Flexible String Representation. So have you reported this alleged crash bug to the bug tracker? If not, then you're not contributing to Python or the discussion here in any useful way; you're just trolling. There's a corollary to Poe's Law that says that a sufficiently advanced troll is indistinguishable from a crank. Whichever JMF is, please don't feed him attention. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: How to read a directory path from a txt file
On Mon, 02 Jun 2014 08:13:23 -0700, Samuel Kamau wrote: I have permission issues with my web server. Hacks to fix permissions problems are dangerous. There is probably a better way to fix this issue. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 is killing Python
In article 538ca310$0$29978$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 02 Jun 2014 09:01:01 -0600, Ian Kelly wrote: On Jun 1, 2014 12:11 PM, wxjmfa...@gmail.com wrote: At least Py2 does not crash when using non ascii (eg sticking with cp1252). I just noticed this last week, Thursday, when presenting the absurdity of the Flexible String Representation. So have you reported this alleged crash bug to the bug tracker? If not, then you're not contributing to Python or the discussion here in any useful way; you're just trolling. There's a corollary to Poe's Law that says that a sufficiently advanced troll is indistinguishable from a crank. Whichever JMF is, please don't feed him attention. Are we talking Tolkien trolls, Pratchett trolls, Rowling trolls, DD trolls, WoW trolls, or what? Details matter. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 is killing Python
On Tue, Jun 3, 2014 at 2:21 AM, Roy Smith r...@panix.com wrote: Are we talking Tolkien trolls, Pratchett trolls, Rowling trolls, DD trolls, WoW trolls, or what? Details matter. Don't forget Frozen trolls, they're love experts! ChrisA (Why aren't you running?) -- https://mail.python.org/mailman/listinfo/python-list
Re: Is MVC Design Pattern good enough?
Wolfgang Keller felip...@gmx.net: The most intuitive approach to database applications would be: http://en.wikipedia.org/wiki/Naked_objects http://www.nakedobjects.org/ [...] Unfortunately, there's no Python framework (yet?) that implements this design. It could be a blessing in disguise. Too often people encumber simple concepts with frameworks. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 is killing Python
On Mon, 02 Jun 2014 12:21:45 -0400, Roy Smith wrote: There's a corollary to Poe's Law that says that a sufficiently advanced troll is indistinguishable from a crank. Whichever JMF is, please don't feed him attention. Are we talking Tolkien trolls, Pratchett trolls, Rowling trolls, DD trolls, WoW trolls, or what? Details matter. Now I think you're trolling :-) Internet troll. As I'm sure you know. http://rationalwiki.org/wiki/Don%27t_feed_the_Troll -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 is killing Python
On 02.06.2014 18:21, Roy Smith wrote: Are we talking Tolkien trolls, Pratchett trolls, Rowling trolls, DD trolls, WoW trolls, or what? Details matter. Monkey Island trolls, obviously. Cheers, 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 -- https://mail.python.org/mailman/listinfo/python-list
Re: How to read a directory path from a txt file
On Monday, June 2, 2014 12:24:59 PM UTC-4, Denis McMahon wrote: On Mon, 02 Jun 2014 08:13:23 -0700, Samuel Kamau wrote: I have permission issues with my web server. Hacks to fix permissions problems are dangerous. There is probably a better way to fix this issue. -- Denis McMahon, denismfmcma...@gmail.com The issue is that i use jenkins to deploy my files to the web server. Jenkins takes possession of all files as username and group name. This over right the right permissions on the web server. I want the script to be restoring the right privileges after jenkins deploys a new build. -- https://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named _gdb
Didier thanks for your prompt reply. I installed a pre-built version of Python. As you said, probably something is missing. I tried to google packages related to gdb, but ain't had no luck. Do you have any idea if it is a compiler directive? I mean I can compile Python from source. Not a problem. Let me know.. On Monday, June 2, 2014 7:07:22 AM UTC+1, dieter wrote: Marcelo Sardelich msardel...@gmail.com writes: So I'm trying to implement pretty printing information using gdb-python27 on Windows7 Hopefully, someone experienced the same issue. GDB is working fine, but when I run gdb-python27 I got the following error (related to a python import): C:\MinGW\bingdb-python27.exe Traceback (most recent call last): File string, line 70, in module File string, line 67, in GdbSetPythonDirectory File c:\mingw\share\gdb/python\gdb\__init__.py, line 19, in module import _gdb ImportError: No module named _gdb Likely, an external (C) extension (named _gdb) must be build (and installed) - and apparently, this is not yet done in your installation. -- https://mail.python.org/mailman/listinfo/python-list
Strange Behavior
Hello folks, I am not sure if it is only on my system the case that the code in http://pastebin.com/WETvqMJN misbehaves in the stated way. Can anybody reproduce it? I thought it could be that the tabs/spaces do influence it, but it doesn't care. Thank you very much for your time. Robert -- https://mail.python.org/mailman/listinfo/python-list
Benefits of asyncio
I read in these groups that asyncio is a great addition to Python 3. I have looked around and saw the related PEP which is quite big BTW but couldn't find a simple explanation for why this is such a great addition. Any simple example where it can be used? It can be used to have a queue of tasks? Like threads? Maybe light weight threads? Those were my thoughts but the library reference clearly stated that this is single-threaded. So there should be some waiting time in between the tasks. Then what is good? These are just jumbled thoughts that came into my mind while trying to make sense of usefulness of asyncio. Anyone can give a better idea? -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange Behavior
On 02/06/2014 17:35, robert...@googlemail.com wrote: Hello folks, I am not sure if it is only on my system the case that the code in http://pastebin.com/WETvqMJN misbehaves in the stated way. Can anybody reproduce it? I thought it could be that the tabs/spaces do influence it, but it doesn't care. Thank you very much for your time. Robert Why couldn't you put your code inline, the same as you showed it here http://bugs.python.org/issue21631 ? Here's the output I get. Traceback (most recent call last): File C:\Users\Mark\MyPython\mytest.py, line 30, in module print(_getStringOfElements(None)) File C:\Users\Mark\MyPython\mytest.py, line 18, in _getStringOfElements if iterationElement[type] == EnumSectionContentType.LABEL: AttributeError: type object 'EnumSectionContentType' has no attribute 'LABEL' As R. David Murray has already said on the bug tracker mailing list, I think you need to be more careful with your testing. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 is killing Python
On Mon, Jun 2, 2014 at 10:15 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 02 Jun 2014 09:01:01 -0600, Ian Kelly wrote: On Jun 1, 2014 12:11 PM, wxjmfa...@gmail.com wrote: At least Py2 does not crash when using non ascii (eg sticking with cp1252). I just noticed this last week, Thursday, when presenting the absurdity of the Flexible String Representation. So have you reported this alleged crash bug to the bug tracker? If not, then you're not contributing to Python or the discussion here in any useful way; you're just trolling. There's a corollary to Poe's Law that says that a sufficiently advanced troll is indistinguishable from a crank. Whichever JMF is, please don't feed him attention. While his description of the bug is so vague that I'm not inclined to believe that it actually exists, if it's real then he should be encouraged to report it. This is the last time, though. If he continues to complain about bugs without reporting or otherwise identifying them, I'll just ignore it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange Behavior
robert...@googlemail.com wrote: Hello folks, I am not sure if it is only on my system the case that the code in http://pastebin.com/WETvqMJN misbehaves in the stated way. Can anybody reproduce it? I thought it could be that the tabs/spaces do influence it, but it doesn't care. Thank you very much for your time. Robert I get what you expect: $ cat bug.py class EnumSectionContentType(object): DATABYTE = 2 DATADOUBLEWORD = 3 DATAWORD = 4 #LABEL = 0 def _getStringOfElements(elements): objectFileString = elements = [{'type': 2, 'data': {'elements': ['83H', '0FAH', '9AH', '27H', '81H', '49H', '0CEH', '11H']}}] for iterationElement in elements: objectFileString += INSIDE1 if iterationElement[type] == EnumSectionContentType.LABEL: objectFileString += iterationElement[data][labelname] + : + \n elif iterationElement[type] == EnumSectionContentType.DATABYTE: objectFileString += INSIDE + \n if iterationElement[type] == EnumSectionContentType.DATADOUBLEWORD: objectFileString += objectFileString + dd elif iterationElement[type] == EnumSectionContentType.DATABYTE: objectFileString += objectFileString + db return objectFileString print(_getStringOfElements(None)) $ python3.4 bug.py Traceback (most recent call last): File bug.py, line 27, in module print(_getStringOfElements(None)) File bug.py, line 15, in _getStringOfElements if iterationElement[type] == EnumSectionContentType.LABEL: AttributeError: type object 'EnumSectionContentType' has no attribute 'LABEL' Are you absolutely sure you are invoking the right bug.py? (I think on windows you can use type instead of cat to see the file contents). -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange Behavior
I invoked the wrong bug.py :/ , works fine now (this happens to me when im a bit tired sometimes...). Im unsure about the real bugreport, will investigate if I find some time and motivation. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 is killing Python
On 02/06/2014 18:53, Ian Kelly wrote: On Mon, Jun 2, 2014 at 10:15 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 02 Jun 2014 09:01:01 -0600, Ian Kelly wrote: On Jun 1, 2014 12:11 PM, wxjmfa...@gmail.com wrote: At least Py2 does not crash when using non ascii (eg sticking with cp1252). I just noticed this last week, Thursday, when presenting the absurdity of the Flexible String Representation. So have you reported this alleged crash bug to the bug tracker? If not, then you're not contributing to Python or the discussion here in any useful way; you're just trolling. There's a corollary to Poe's Law that says that a sufficiently advanced troll is indistinguishable from a crank. Whichever JMF is, please don't feed him attention. While his description of the bug is so vague that I'm not inclined to believe that it actually exists, if it's real then he should be encouraged to report it. This is the last time, though. If he continues to complain about bugs without reporting or otherwise identifying them, I'll just ignore it. It's a pleasant change having him complain about bugs, as opposed to simply complain about nonexistent problems. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Benefits of asyncio
On Mon, Jun 2, 2014 at 11:40 AM, Aseem Bansal asmbans...@gmail.com wrote: I read in these groups that asyncio is a great addition to Python 3. I have looked around and saw the related PEP which is quite big BTW but couldn't find a simple explanation for why this is such a great addition. Any simple example where it can be used? It can be used to have a queue of tasks? Like threads? Maybe light weight threads? Those were my thoughts but the library reference clearly stated that this is single-threaded. So there should be some waiting time in between the tasks. Then what is good? These are just jumbled thoughts that came into my mind while trying to make sense of usefulness of asyncio. Anyone can give a better idea? You're right, neither the PEP nor the docs to much to motivate the module's existence. I suggest you start here: http://en.wikipedia.org/wiki/Asynchronous_I/O The asynchronous model lets you initiate a task (typically an I/O task) that would normally block, and then go on to do other things (like initiating more tasks) while waiting on that task, without having to resort to multiple threads or processes (which have the disadvantages of consuming more system resources as well as introducing the risk of race conditions and deadlocks). It does this by using callbacks; when a task is complete, a callback is called that handles its completion. Often in asynchronous code you end up with large networks of callbacks that can be confusing to follow and debug because nothing ever gets called directly. One of the significant features of the asyncio module is that it allows asynchronous programming using coroutines, where the callbacks are abstracted away and essentially have the effect of resuming the coroutine when the task completes. Thus you end up writing code that looks a lot like threaded, sequential code with none of the pitfalls. -- https://mail.python.org/mailman/listinfo/python-list
Re: Benefits of asyncio
On 6/2/2014 1:40 PM, Aseem Bansal wrote: The following supplement Ian's answer. I read in these groups that asyncio is a great addition to Python 3. I have looked around and saw the related PEP which is quite big BTW but couldn't find a simple explanation for why this is such a great addition. Any simple example where it can be used? asyncio replaces the very old asyncore, which has problems, is beyond fixing due to its design, and is now deprecated. So look up used for asyncore. You could think of asyncio as a lightweight version or core of other async packages, such as Twisted or Tornado. What are they good for. I admit that you should now have to answer the question so indirectly. One generic answer: carry on 'simultaneous' conversions with multiple external systems. asyncio lets you write platform independent code while it makes good use of the asynchronous i/o available on each particular system. Async-i/o is one area where Windows has made advances over posix. But the models are different, and if one uses Windows' i/o completion as if it were posix poll/select, it works poorly. Running well on both types of systems was a major challenge. It can be used to have a queue of tasks? Try set of tasks, as the sequencing may depend on external response times. Like threads? Maybe light weight threads? Try light-weight thread, manages by Python instead of the OS. I believe greenlets are a somewhat similar example. Those were my thoughts but the library reference clearly stated that this is single-threaded. Meaning, asyncio itself only uses one os thread. The application, or individual tasks, can still spin off other os threads, perhaps for a long computation. So there should be some waiting time in between the tasks. I do not understand this. asyncio should switch between tasks faster than the OS switches between threads, thus reducing waiting time. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Benefits of asyncio
In article mailman.10573.1401739639.18130.python-l...@python.org, Terry Reedy tjre...@udel.edu wrote: asyncio lets you write platform independent code while it makes good use of the asynchronous i/o available on each particular system. Async-i/o is one area where Windows has made advances over posix. But the models are different, and if one uses Windows' i/o completion as if it were posix poll/select, it works poorly. Running well on both types of systems was a major challenge. How would you compare using the new asyncio module to using gevent? It seems like they do pretty much the same thing. Assume, for the moment, that gevent runs on Python 3.x (which I assume it will, eventually). -- https://mail.python.org/mailman/listinfo/python-list
Re: Benefits of asyncio
Terry Reedy tjre...@udel.edu: I do not understand this. asyncio should switch between tasks faster than the OS switches between threads, thus reducing waiting time. I don't know if thread switching is slower than task switching. However, there are two main reasons to prefer asyncio over threads: * Scalability. Asyncio can easily manage, say, a million contexts. Most operating systems will have a hard time managing more than about a thousand threads. Such scalability needs may arise in very busy network servers with tens of thousands of simultaneous connections or computer games that simulate thousands of monsters. * Conceptual simplicity. Toy servers are far easier to implement using threads. However, before long, the seeming simplicity turns out to be a complication: - Thread programming assumes each thread is waiting for precisely one external stimulus in any given state -- in practice, each state must be prepared to handle quite a few possible stimuli. - Thread-safe programming is easy to explain but devilishly difficult to get right. Asyncio makes the prototype somewhat cumbersome to write. However, once it is done, adding features, stimuli and states is a routine matter. Threads have one major advantage: they can naturally take advantage of multiple CPU cores. Generally, I would stay away from threads and use multiple processes instead. However, threads may sometimes be the optimal solution. The key is to keep the number of threads small (maybe twice the number of CPUs). Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Benefits of asyncio
Marko Rauhamaa ma...@pacujo.net writes: - Thread programming assumes each thread is waiting for precisely one external stimulus in any given state -- in practice, each state must be prepared to handle quite a few possible stimuli. Eh? Threads typically have their own event loop dispatching various kinds of stimuli. - Thread-safe programming is easy to explain but devilishly difficult to get right. I keep hearing that but not encountering it. Yes there are classic hazards from sharing mutable state between threads. However, it's generally not too difficult to program in a style that avoids such sharing. Have threads communicate by message passing with immutable data in the messages, and things tend to work pretty straightforwardly. Asyncio makes the prototype somewhat cumbersome to write. However, once it is done, adding features, stimuli and states is a routine matter. Having dealt with some node.js programs and the nest of callbacks they morph into as the application gets more complicated, threads have their advantages. -- https://mail.python.org/mailman/listinfo/python-list
Re: Benefits of asyncio
On 06/02/14 20:40, Aseem Bansal wrote: I read in these groups that asyncio is a great addition to Python 3. I have looked around and saw the related PEP which is quite big BTW but couldn't find a simple explanation for why this is such a great addition. Any simple example where it can be used? AFAIR, Guido's US Pycon 2013 keynote is where he introduced asyncio (or tulip, which is the internal codename of the project) so you can watch it to get a good idea about his motivations. So what is Asyncio? In a nutshell, Asyncio is Python's standard event loop. Next time you're going to build an async framework, you should build on it instead of reimplementing it using system calls available on the platform(s) that you're targeting, like select() or epoll(). It's great because 1) Creating an abstraction over Windows and Unix way of event-driven programming is not trivial, 2) It makes use of yield from, a feature available in Python 3.3 and up. Using yield from is arguably the cleanest way of doing async as it makes async code look like blocking code which seemingly makes it easier to reason about the flow of your logic. The idea is very similar to twisted's @inlineCallbacks, if you're familiar with it. If doing lower level programming with Python is not your cup of tea, you don't really care about asyncio. You should instead wait until your favourite async framework switches to it. It can be used to have a queue of tasks? Like threads? Maybe light weight threads? Those were my thoughts but the library reference clearly stated that this is single-threaded. So there should be some waiting time in between the tasks. Then what is good? You can use it to implement a queue of (mostly i/o bound) tasks. You are not supposed to use it in cases where you'd use threads or lightweight threads (or green threads, as in gevent or stackless). Gevent is also technically async but gevent and asyncio differ in a very subtle way: Gevent does cooperative multitasking whereas Asyncio (and twisted) does event driven programming. The difference is that with asyncio, you know exactly when you're switching to another task -- only when you use yield from. This is not always explicit with gevent, as a function that you're calling can switch to another task without letting your code know. So with gevent, you still need to take the usual precautions of multithreaded programming. Gevent actually simulates threads by doing task switching (or thread scheduling, if you will) in userspace. Here's its secret sauce: https://github.com/python-greenlet/greenlet/tree/master/platform There's some scary platform-dependent assembly code in there! I'd think twice before seriously relying on it. Event driven programming does not need such dark magic. You also don't need to be so careful in a purely event-driven setting as you know that at any point in time only one task context can be active. It's like you have an implicit, zero-overhead LOCK ALL for all nonlocal state. Of course the tradeoff is that you should carefully avoid blocking the event loop. It's not that hard once you get the hang of it :) So, I hope this answers your questions. Let me know if I missed something. Best regards, Burak -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.2 has some deadly infection
On 6/2/2014 7:10 AM, Robin Becker wrote: there seems to be an implicit assumption in python land that encoded strings are the norm. I don't know why you say that. To have a stream of bytes interpreted as characters, open in text mode and give the encoding. Otherwise, open in binary mode and apply whatever encoding you want. Image programs like Pil or Pillow assume that bytes have image encodings. Same idea. On virtually every computer I encounter that assumption is wrong. Except for the std streams (see below), it is also not part of Python. I will just point out that bytes are given meaning by encoding meaning into them. Unicode attempts to reduce the hundreds of text encodings to just a few, and mostly to just one for external storage and transmission. In python I would have preferred for bytes to remain the default io Do you really think that defaulting the open mode to 'rb' rather than 'rt' would be a better choice for newbies? mechanism, at least that would allow me to decide if I need any decoding. Assuming that 'rb' is actually needed more than 'rt' for you in particular, is it really such a burden to give a mode more often than not? As the cat example http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/ showed these extra assumptions are sometimes really in the way. This example is *only* about the *pre-opened* stdxyz streams. Python uses these to read characters from the keyboard and print characters to the screen in input, print, and the interactive interpreter. So they are open in text mode (which wraps binary read and write). The developers, knowing that people can and do write batch mode programs that avoid input and print, gave a documented way to convert the streams back to binary. (See the sys doc.) The issue Armin ran into is this. He write a library module that makes sure the streams are binary. Someone else does the same. A program imports both modules, in either order. The conversion method referenced above raises an exception if one attempt to convert an already converted stream. Much of the extra code Armin published detects whether the steam is already binary or needs conversion. The obvious solution is to enhance the conversion method so that one may say 'convert is needed, otherwise just pass'. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Benefits of asyncio
On Tue, Jun 3, 2014 at 6:45 AM, Paul Rubin no.email@nospam.invalid wrote: - Thread-safe programming is easy to explain but devilishly difficult to get right. I keep hearing that but not encountering it. Yes there are classic hazards from sharing mutable state between threads. However, it's generally not too difficult to program in a style that avoids such sharing. Have threads communicate by message passing with immutable data in the messages, and things tend to work pretty straightforwardly. It's more true on some systems than others. The issues of maintaining safe state are very similar in callback systems and threads; the main difference is that a single-threaded asyncio system becomes cooperative, where threading systems are (usually) preemptive. Preemption means you could get a context switch *anywhere*. (In Python, I think the rule is that thread switches can happen only between Python bytecodes, but that's still anywhere as far as your code's concerned.) That means you have to *keep* everything safe, rather than simply get it safe again. Cooperative multitasking means your function will run to completion before any other callback happens (or, at least, will get to a clearly defined yield point). That means you can muck state up all you like, and then fix it afterwards. In some ways, that's easier; but it has a couple of risks: firstly, if your code jumps out early somewhere, you might forget to fix the shared state, and only find out much later; and secondly, if your function takes a long time to execute, everything else stalls. So whichever way you do it, you still have to be careful - just careful of slightly different things. For instance, you might keep track of network activity as a potentially slow operation, and make sure you never block a callback waiting for a socket - but you might do a quick and simple system call, not realizing that it involves a directory that's mounted from a remote server. With threads, someone else will get priority as soon as you block, but with asyncio, you have to be explicit about everything that's done asynchronously. Threads are massively simpler if you have a top-down execution model for a relatively small number of clients. Works really nicely for a sequence of prompts - you just code it exactly as if you were using print() and input() and stuff, and then turn print() into a blocking socket write (or whatever your I/O is done over) and your input() into a blocking socket read with line splitting, and that's all the changes you need. (You could even replace the actual print and input functions, and use a whole block of code untouched.) Async I/O is massively simpler if you have very little state, and simply react to stimuli. Every client connects, authenticates, executes commands, and terminates its connection. If all you need to know is whether the client's authenticated or not (restricted commandset before login), asyncio will be really *really* easy, and threads are overkill. This is even more true if most of your clients are going to be massively idle most of the time, with just tiny queries coming in occasionally and getting responded to quickly. Both have their advantages and disadvantages. Learning both models is, IMO, worth doing; get to know them, then decide which one suits your project. Asyncio makes the prototype somewhat cumbersome to write. However, once it is done, adding features, stimuli and states is a routine matter. Having dealt with some node.js programs and the nest of callbacks they morph into as the application gets more complicated, threads have their advantages. I wrote an uberlite async I/O framework for my last job. Most of the work was done by the lower-level facilities (actual non-blocking I/O, etc), but basically, what I had was a single callback for each connection type and a dictionary of state for each connection (with a few exceptions - incoming UDP has no state, ergo no dict). Worked out beautifully simple; each run through the callback processed one logical action (eg a line of text arriving on a socket, terminated by newline), updated state if required, and returned, back to the main loop. Not all asyncio will fit into that sort of structure, but if it does fit, this keeps everything from getting out of hand. (Plus, keeping state in a separate dict rather than using closures and local variables meant I could update code while maintaining state. Not important for most Python projects, but it was for us.) Both have their merits. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Introdution
HI! plz tell me about books for python i am beginner of this lang.. Regards, Hisham -- https://mail.python.org/mailman/listinfo/python-list
Re: Introdution
On 02/06/2014 23:01, Hisham Mughal wrote: HI! plz tell me about books for python i am beginner of this lang.. Regards, Hisham Either http://www.diveintopython.net/ or http://www.diveintopython3.net/ depending on whether you're using Python 2 or 3. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Introdution
On 6/2/2014 3:56 PM, Mark Lawrence wrote: On 02/06/2014 23:01, Hisham Mughal wrote: HI! plz tell me about books for python i am beginner of this lang.. Regards, Hisham Either http://www.diveintopython.net/ or http://www.diveintopython3.net/ depending on whether you're using Python 2 or 3. You should also check https://wiki.python.org/moin/PythonBooks Emile -- https://mail.python.org/mailman/listinfo/python-list
Re: Introdution
On 03/06/2014 00:04, Emile van Sebille wrote: On 6/2/2014 3:56 PM, Mark Lawrence wrote: On 02/06/2014 23:01, Hisham Mughal wrote: HI! plz tell me about books for python i am beginner of this lang.. Regards, Hisham Either http://www.diveintopython.net/ or http://www.diveintopython3.net/ depending on whether you're using Python 2 or 3. You should also check https://wiki.python.org/moin/PythonBooks Emile Or reviews here http://www.accu.org/index.php?module=bookreviewsfunc=search -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com -- https://mail.python.org/mailman/listinfo/python-list
Issues with tkinter
Am having difficulty with importing tkinter following cross-compiling Python from source. My build environment: GCC 4.7 uClibc 0.9.33 buildroot Python 3.4 Tcl/Tk 8.6 target platform=ARM The symptoms are as follows: import _tkinter ... # trying /usr/lib/python3.4/lib-dynload/_tkinter.cpython-34m.so python: symbol 'FcPatternAddMatrix': can't resolve symbol python: symbol 'FcFontRenderPrepare': can't resolve symbol python: symbol 'FcFontSort': can't resolve symbol python: symbol 'FcPatternDestroy': can't resolve symbol python: symbol 'FcPatternGetString': can't resolve symbol python: symbol 'FcPatternAddInteger': can't resolve symbol python: symbol 'FcCharSetDestroy': can't resolve symbol python: symbol 'FcPatternAddString': can't resolve symbol python: symbol 'FcPatternGetDouble': can't resolve symbol python: symbol 'FcPatternGetCharSet': can't resolve symbol python: symbol 'FcCharSetCopy': can't resolve symbol python: symbol 'FcPatternGetInteger': can't resolve symbol python: symbol 'FcConfigSubstitute': can't resolve symbol python: symbol 'FcPatternAddBool': can't resolve symbol python: symbol 'FcCharSetHasChar': can't resolve symbol python: symbol 'FcFontSetDestroy': can't resolve symbol python: symbol 'FcPatternCreate': can't resolve symbol python: symbol 'FcPatternAddDouble': can't resolve symbol python: symbol 'FcUtf8ToUcs4': can't resolve symbol Traceback (most recent call last): File stdin, line 1, in module File frozen importlib._bootstrap, line 2214, in _find_and_load File frozen importlib._bootstrap, line 2203, in _find_and_load_unlocked File frozen importlib._bootstrap, line 1191, in _load_unlocked File frozen importlib._bootstrap, line 1161, in _load_backward_compatible File frozen importlib._bootstrap, line 539, in _check_name_wrapper File frozen importlib._bootstrap, line 1692, in load_module File frozen importlib._bootstrap, line 321, in _call_with_frames_removed ImportError: unknown dlopen() error It appears to be an issue with FontConfig. If I recompile Tk with --disable-xft, tkinter works correctly but with the legacy method of font selection and rendering. When compiled with --enable-xft (default), Tk demo programs work correctly, but I cannot import tkinter. I believe that there is a link issue with _tkinter.cpython-34m.so, but have not identified anything despite intense research. Any suggestions? Many thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange Behavior
On Mon, 02 Jun 2014 20:05:29 +0200, robertw89 wrote: I invoked the wrong bug.py :/ , works fine now (this happens to me when im a bit tired sometimes...). Clarity in naming is an excellent thing. If you have two files called bug.py, that's two too many. Imagine having fifty files called program.py. Which one is which? How do you know? Programs should be named by what they do (think of Word, which does word processing, or Photoshop, which does photo editing), or when that isn't practical, at least give them a unique and memorable name (Outlook, Excel). The same applies to files demonstrating bugs. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange Behavior
On Tue, Jun 3, 2014 at 10:22 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 02 Jun 2014 20:05:29 +0200, robertw89 wrote: I invoked the wrong bug.py :/ , works fine now (this happens to me when im a bit tired sometimes...). Clarity in naming is an excellent thing. If you have two files called bug.py, that's two too many. Imagine having fifty files called program.py. Which one is which? How do you know? Programs should be named by what they do (think of Word, which does word processing, or Photoshop, which does photo editing), or when that isn't practical, at least give them a unique and memorable name (Outlook, Excel). The same applies to files demonstrating bugs. Heh. I agree, but I've been guilty of this exact problem myself. Suppose you have a program that segfaults when given certain input, so you take the input that crashes it, and progressively simplify it until you have a minimal test-case. What do you call the file that you're editing? What if you have a few different variants? I've had a few called boom and boom2 and booom and so on, because there's really nothing else to call it - if I knew what the cause of the crash was, I wouldn't be naming the testcase files, I'd be fixing the problem. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Strange Behavior
On Mon, Jun 2, 2014 at 5:30 PM, Chris Angelico ros...@gmail.com wrote: On Tue, Jun 3, 2014 at 10:22 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 02 Jun 2014 20:05:29 +0200, robertw89 wrote: I invoked the wrong bug.py :/ , works fine now (this happens to me when im a bit tired sometimes...). Clarity in naming is an excellent thing. If you have two files called bug.py, that's two too many. Imagine having fifty files called program.py. Which one is which? How do you know? Programs should be named by what they do (think of Word, which does word processing, or Photoshop, which does photo editing), or when that isn't practical, at least give them a unique and memorable name (Outlook, Excel). The same applies to files demonstrating bugs. Heh. I agree, but I've been guilty of this exact problem myself. Suppose you have a program that segfaults when given certain input, so you take the input that crashes it, and progressively simplify it until you have a minimal test-case. What do you call the file that you're editing? What if you have a few different variants? I've had a few called boom and boom2 and booom and so on, because there's really nothing else to call it - if I knew what the cause of the crash was, I wouldn't be naming the testcase files, I'd be fixing the problem. test1, test2, test3, testn. At least it will be unique. ;-) Thank you. ChrisA -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Choosing good names for things is difficult (was: Strange Behavior)
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: On Mon, 02 Jun 2014 20:05:29 +0200, robertw89 wrote: I invoked the wrong bug.py :/ , works fine now (this happens to me when im a bit tired sometimes...). Clarity in naming is an excellent thing […] Programs should be named by what they do […] or when that isn't practical, at least give them a unique and memorable name […]. It's worth noting, along with this useful admonition, that naming things well is one of the most difficult things to do. It is especially difficult in computer software, while also being rather more important than the typical problem of naming, because of the simultaneous constraints that the names within computer software should be: * Memorable and evocative of the meaning to humans, who have a limited capacity for remembering large sets of different names exactly, but a high tolerance (even fondness) for multiple-meaning and ambiguous words. So, choosing unique names is difficult, and the set of memorable names is severely limited. * Starkly unique and exact every time for the computer's use, without regard to meaning, and any name is just as memorable to a computer as any other. So, choosing unique meaningful names is crucially important in working with computer software. That combination – difficult but important to do well – is a perennial bugbear for programmers. You can find many essays on the “naming things is difficult” theme, with the most concise and pithy being attributed to Phil Karlton (RIP) of Netscape in the 1990s. Another wit takes that to its logical conclusion: A well known aphorism attributed to Phil Karlton is: There are only two hard things in Computer Science: cache invalidation and naming things. I realized yesterday that this is really only one hard problem: much of the reason that naming things is hard is that changing names is hard, so you'd better name something right the first time. Why is it hard to rename things? Poor cache invalidation. URL:http://www.jefftk.com/p/cache-invalidation -- \ “In the long run, the utility of all non-Free software | `\ approaches zero. All non-Free software is a dead end.” —Mark | _o__)Pilgrim, 2006 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Business model
No need to apologise. It's an interesting question, and reading the answers given last time will be useful. After you have read those dozen or so answers, please come back with any further questions. Here's the link again: http://code.activestate.com/lists/python-list/60/ Thanks for the reply -- https://mail.python.org/mailman/listinfo/python-list
Re: Business model
No need to apologise. It's an interesting question, and reading the answers given last time will be useful. After you have read those dozen or so answers, please come back with any further questions. Here's the link again: http://code.activestate.com/lists/python-list/60/ Thanks for the reply -- https://mail.python.org/mailman/listinfo/python-list
Re: Benefits of asyncio
To all the great responders. If anyone thinks the async intro is inadequate and has a paragraph to contribute, open a tracker issue. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Choosing good names for things is difficult (was: Strange Behavior)
On Tuesday, June 3, 2014 6:27:25 AM UTC+5:30, Ben Finney wrote: Steven D'Aprano writes: On Mon, 02 Jun 2014 20:05:29 +0200, robertw89 wrote: I invoked the wrong bug.py :/ , works fine now (this happens to me when im a bit tired sometimes...). Clarity in naming is an excellent thing […] Programs should be named by what they do […] or when that isn't practical, at least give them a unique and memorable name […]. It's worth noting, along with this useful admonition, that naming things well is one of the most difficult things to do. It is especially difficult in computer software, while also being rather more important than the typical problem of naming, because of the simultaneous constraints that the names within computer software should be: * Memorable and evocative of the meaning to humans, who have a limited capacity for remembering large sets of different names exactly, but a high tolerance (even fondness) for multiple-meaning and ambiguous words. So, choosing unique names is difficult, and the set of memorable names is severely limited. * Starkly unique and exact every time for the computer's use, without regard to meaning, and any name is just as memorable to a computer as any other. So, choosing unique meaningful names is crucially important in working with computer software. That combination – difficult but important to do well – is a perennial bugbear for programmers. Add to that the restriction to limited character sets such as ASCII – a restriction that has only historical relevance Somewhat more seriously there is the complement to Ben/Steven's remarks: Good software systems reduce the naming-demand. Egs. 1. Computationally/algorithmically, these 2 are equivalent: a. desc = sqrt(b*b - 4*a*c) b. left = b*b t1 = 4*a right = t1*c desc = left - right sqrt_desc = sqrt(desc) However the naming load of the b is 5 times a – one of the main benefits of a high level language vs assembly In the same vein… 2. λ-expressions reduce the need to name functions. 3. Point-free style – or more on-topic Tacit Programming – reduces the need for function arguments http://en.wikipedia.org/wiki/Tacit_programming 4. Structured programming removes the need to name control points with labels 5. And problems like this one can be reduced by using the interpreter more and named program files less. Of course even if you can check in the interpreter, to communicate with others/file a bug you may need to name a file. -- https://mail.python.org/mailman/listinfo/python-list
RE: Introdution
-Original Message- From: tagh...@gmail.com Sent: Mon, 2 Jun 2014 15:01:17 -0700 (PDT) To: python-list@python.org Subject: Introdution HI! plz tell me about books for python i am beginner of this lang.. hello! I, too, am fairly new to Python. I have discovered a lot of resources. for free books in .pdf format, I recommend: http://it-ebooks-search.info/search?q=python Codecademy.com has a free python course where I learned a lot. It took me about a week to get through it. Another fun place is Checkio.com for solving simple coding problems (simple is relative, kinda of a challenge for me). I also purchased Python 3 Object Oriented Programming by Dusty Philips that has been pretty good so far. Hope this helps. FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! Check it out at http://www.inbox.com/earth -- https://mail.python.org/mailman/listinfo/python-list
Re: Choosing good names for things is difficult (was: Strange Behavior)
On Tue, Jun 3, 2014 at 12:06 PM, Rustom Mody rustompm...@gmail.com wrote: Add to that the restriction to limited character sets such as ASCII – a restriction that has only historical relevance Wrong. The name has to fit inside the human's brain; if it's not ASCII, that's not a problem. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Lock Windows Screen GUI using python
Dear all, Can we Lock Windows Screen GUI till program runs unlock screen GUI when program finishes? Regards Jaydeep Paril -- https://mail.python.org/mailman/listinfo/python-list
can someone explain the concept of strings (or whatever) being immutable
a_string = "This is a string"a_string is pointing to the above stringnow I change the value of a_stringa_string = "This string is different"I understand that now a_string is pointing to a different string than it was before, in a different location.my question is what happens to the original string?? Is it still in memory somewhere, nameless?Thanks in advance, Free 3D Marine Aquarium Screensaver Watch dolphins, sharks orcas on your desktop! Check it out at www.inbox.com/marineaquarium -- https://mail.python.org/mailman/listinfo/python-list
Re: can someone explain the concept of strings (or whatever) being immutable
On Jun 2, 2014 10:41 PM, Deb Wyatt codemon...@inbox.com wrote: a_string = This is a string a_string is pointing to the above string now I change the value of a_string a_string = This string is different I understand that now a_string is pointing to a different string than it was before, in a different location. my question is what happens to the original string?? Is it still in memory somewhere, nameless? Thanks in advance, If there are still any references being held to the original string, then it will remain in memory. Otherwise, the memory used for it will be freed. You can't rely on this happening immediately (although in CPython it does, as long as the object is not part of a reference cycle), but it will happen eventually. -- https://mail.python.org/mailman/listinfo/python-list
Re: can someone explain the concept of strings (or whatever) being immutable
Deb Wyatt codemon...@inbox.com writes: [no text] Deb, can you expand a bit – and write the question in the body of your message? It's not clear what you want explained. -- \ “I hope if dogs ever take over the world, and they chose a | `\king, they don't just go by size, because I bet there are some | _o__) Chihuahuas with some good ideas.” —Jack Handey | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Benefits of asyncio
I haven't worked with asynchronous tasks or concurrent programming so far. Used VB2010 and have used some jQuery in a recent project but nothing low level. As per the explanation it seems that programming using asyncio would require identifying blocks of code which are not dependent on the IO. Wouldn't that get confusing? @Terry When I said that there would be waiting time I meant as compared to sequential programming. I was not comparing to threads. From all the explanations what I got is that it is the way of doing event driven programming like threads are for concurrent programming. It would have been great if the library reference had mentioned the term event-driven programming. It would have been a great starting point to understand. -- https://mail.python.org/mailman/listinfo/python-list
Re: can someone explain the concept of strings (or whatever) being immutable
-Original Message- From: b...@benfinney.id.au Sent: Tue, 03 Jun 2014 14:54:01 +1000 To: python-list@python.org Subject: Re: can someone explain the concept of strings (or whatever) being immutable Deb Wyatt codemon...@inbox.com writes: [no text] Deb, can you expand a bit – and write the question in the body of your message? It's not clear what you want explained. -- \ “I hope if dogs ever take over the world, and they chose a | `\king, they don't just go by size, because I bet there are some | _o__) Chihuahuas with some good ideas.” —Jack Handey | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list that's strange that you see no text. The body of my email was as follows: a_string = This is a string a_string is pointing to the above string now I change the value of a_string a_string = This string is different I understand that now a_string is pointing to a different string than it was before, in a different location. my question is what happens to the original string?? Is it still in memory somewhere, nameless? That was just the first question. What does immutable really mean if you can add items to a list? and concatenate strings? I don't understand enough to even ask a comprehensible question, I guess. Thanks in advance, Deb in WA, USA FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! Check it out at http://www.inbox.com/earth -- https://mail.python.org/mailman/listinfo/python-list
Re: Lock Windows Screen GUI using python
On Mon, Jun 2, 2014 at 10:28 PM, Jaydeep Patil patil.jay2...@gmail.com wrote: Dear all, Can we Lock Windows Screen GUI till program runs unlock screen GUI when program finishes? If you mean can you programmatically bring up the Windows lock screen, then you can do this: import ctypes ctypes.windll.user32.LockWorkStation() The only way to unlock it is for the user to log in. If you mean something else, you'll have to be more specific. -- https://mail.python.org/mailman/listinfo/python-list
Re: can someone explain the concept of strings (or whatever) being immutable
On 06/02/2014 09:39 PM, Deb Wyatt wrote: a_string = This is a string a_string is pointing to the above string now I change the value of a_string a_string = This string is different I understand that now a_string is pointing to a different string than it was before, in a different location. my question is what happens to the original string?? Is it still in memory somewhere, nameless? Thanks in advance, Yes, possibly, for a short while it will be nameless in memory somewhere. If nothing else is pointing to it, it will eventually be garbage collected. Gary Herron 3D Marine Aquarium Screensaver Preview http://www.inbox.com/marineaquarium *Free 3D Marine Aquarium Screensaver* Watch dolphins, sharks orcas on your desktop! Check it out at www.inbox.com/marineaquarium http://www.inbox.com/marineaquarium -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.2 has some deadly infection
Terry Reedy wrote: The issue Armin ran into is this. He write a library module that makes sure the streams are binary. Seems to me he made a mistake right there. A library should *not* be making global changes like that. It can obtain binary streams from stdin and stdout for its own use, but it shouldn't stuff them back into sys.stdin and sys.stdout. If he had trouble because another library did that, then that library is broken, not Python. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: can someone explain the concept of strings (or whatever) being immutable
Hi Deb, Immutability means that once This is a string is created in memory , the string cannot be changed. When we assign a_string with A different string this A different string is in a new memory location again (a new object) . This is a string and A different string are two different objects which are in existence which have been assigned to the variable a_string at different points in time. Now if This is a string is no longer referenced in the scope of the program , the reference count drops to zero at which point it is taken out of memory. Even though we perform a string concatenation and change the string from A different string to A different string appended with some more words , a new object is created , the initial string A different string is copied to this newly created object, appended with some more words are added to arrive at the final A different string appended with some more words. The original A different string still remains until the point wherein it is not longer referenced after which it is cleaned up. Thanks. On Tue, Jun 3, 2014 at 10:36 AM, Deb Wyatt codemon...@inbox.com wrote: -Original Message- From: b...@benfinney.id.au Sent: Tue, 03 Jun 2014 14:54:01 +1000 To: python-list@python.org Subject: Re: can someone explain the concept of strings (or whatever) being immutable Deb Wyatt codemon...@inbox.com writes: [no text] Deb, can you expand a bit – and write the question in the body of your message? It's not clear what you want explained. -- \ “I hope if dogs ever take over the world, and they chose a | `\king, they don't just go by size, because I bet there are some | _o__) Chihuahuas with some good ideas.” —Jack Handey | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list that's strange that you see no text. The body of my email was as follows: a_string = This is a string a_string is pointing to the above string now I change the value of a_string a_string = This string is different I understand that now a_string is pointing to a different string than it was before, in a different location. my question is what happens to the original string?? Is it still in memory somewhere, nameless? That was just the first question. What does immutable really mean if you can add items to a list? and concatenate strings? I don't understand enough to even ask a comprehensible question, I guess. Thanks in advance, Deb in WA, USA FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! Check it out at http://www.inbox.com/earth -- https://mail.python.org/mailman/listinfo/python-list -- *HAVE A NICE DAY * Prashanth -- https://mail.python.org/mailman/listinfo/python-list
Re: can someone explain the concept of strings (or whatever) being immutable
Deb Wyatt codemon...@inbox.com writes: -Original Message- From: b...@benfinney.id.au Deb, can you expand a bit – and write the question in the body of your message? It's not clear what you want explained. that's strange that you see no text. A likely cause is that your message included no text body. An HTML-only message will often be stripped out, because HTML in email is both problematic and superfluous. Best to configure your message composer to create plain text messages, especially in forums like this where exact representation of program text is important. The body of my email was as follows: Thanks for posting in plain text this time. a_string = This is a string a_string is pointing to the above string now I change the value of a_string a_string = This string is different I understand that now a_string is pointing to a different string than it was before, in a different location. Good, that's half the journey there: you know that the first string is not changed by that operation. A slight tweak: it's better not to think about it in terms of “location”, which is abstract and largely irrelevant in Python. Better to think in terms of objects: the first string is one object, and the second string is a distinct object. my question is what happens to the original string?? Is it still in memory somewhere, nameless? That's a question whose answer is invisible from the perspective of the Python programmer, who does not have direct access to memory locations of Python objects. Objects without references – a name is one kind of reference – cannot be accessed, so may as well not exist from your perspective. The run-time implementation of Python is free to discard unreferenced objects at any time (this is known as “garbage collection”). Different implementations will adopt different garbage collection strategies, possibly multiple ones at different times, in order to clean up memory in optimal ways. From our perspective writing Python programs: Once we no longer have a reference to an object, it's unavailable forevermore. That was just the first question. What does immutable really mean if you can add items to a list? and concatenate strings? It means that an immutable object has a value which cannot be changed. I don't know what “really mean” is asking beyond that. foo = 8 The number 8 will always be 8, and that object will always have that value. If you want ‘foo’ to refer to some other value, you'll need to bind it to a different object, using an assignment statement or some other re-binding operation. A list is not immutable; you can mutate the list (e.g. by appending an item) and the object remains the same object with a different value. foo = [spam, eggs] foo.append(ham) foo [spam, eggs, ham] The list is a container, and the container remains the same object; the items it contains (the list is a collection of references to objects) can change without the list becoming a different object. Any reference to the list will refer to a collection of different values over time, depending on what mutations the list has undergone. Concatenating strings creates a new string object; it does not change the original string values. foo = Lorem ipsum bar = dolor sit amet foo + , + bar 'Lorem ipsum, dolor sit amet' foo 'Lorem ipsum' bar 'dolor sit amet' The string objects are immutable, so they never change value; anything which refers to the object will always refer to the same value. Operations which produce different strings do so by creating new strings (or re-producing the same strings if they already exist, which is an optimisation the implementation is free to make). I don't understand enough to even ask a comprehensible question, I guess. I hope that helps. You're welcome to ask more questions in this forum. You may also be interested to join the “tutor” forum URL:https://mail.python.org/mailman/listinfo/tutor, where patient tutors will discuss any beginner's Python questions. -- \ “I am as agnostic about God as I am about fairies and the | `\ Flying Spaghetti Monster.” —Richard Dawkins, 2006-10-13 | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: can someone explain the concept of strings (or whatever) being immutable
Please adjust your mailer to send plain text only. It is all you need anyway, and renders more reliably for other people. Thank you, Cameron Simpson c...@zip.com.au I am so sorry, I did not realize it was a problem. Hopefully it will behave now. Deb in WA, USA FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! Check it out at http://www.inbox.com/earth -- https://mail.python.org/mailman/listinfo/python-list
Re: Obfuscated Python hack
Tim Chase wrote: Stripping off the exec() call makes it pretty transparent that you're attempting (successfully on some platforms) to set the value of 4 to 5. But you have to do that in *another* Python session, because the first one is broken in interesing ways, e.g. (lambda *fs: reduce(lambda f, g: lambda x: f(g(x)), fs))(*([lambda s: s[1::2]+s[-2::-2]]*54))('motcye;cye._n8fo_drs(d4+)vle=5 ua.8)(isedamr.ticspt spt rpi') File stdin, line 1 SyntaxError: name 'fs' is local and global lambda z: 42 File stdin, line 1 SyntaxError: name 'z' is local and global I never knew that error message existed! Is it even possible to get it from a non-broken Python? To answer my own question, apparently yes: def f(x): ... global x ... File stdin, line 1 SyntaxError: name 'x' is local and global You learn something every day... -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: can someone explain the concept of strings (or whatever) being immutable
On 02Jun2014 21:06, Deb Wyatt codemon...@inbox.com wrote: Deb Wyatt codemon...@inbox.com writes: [no text] Deb, can you expand a bit – and write the question in the body of your message? It's not clear what you want explained. [...] that's strange that you see no text. The body of my email was as follows: a_string = This is a string [... etc ...] That is because whatever you're using for email sent both HTML and plain text, but in complete violation of sanity, left the plain text version empty. Ben's mailer is showing him the plain text version, which is perfectly reasonable, and why he saw nothing. Please adjust your mailer to send plain text only. It is all you need anyway, and renders more reliably for other people. Thank you, Cameron Simpson c...@zip.com.au -- https://mail.python.org/mailman/listinfo/python-list
[issue11387] Tkinter, callback functions
Serhiy Storchaka added the comment: This is not Tkinter bug, this is normal Tk behavior. Here is minimal reproducer on Tcl/Tk : button .b -text Click me bind .b Button-1 {tk_messageBox -message The button is sunken!} pack .b I suppose the button is left sunken because the message box steals a focus. In general binding mouse click event for button is not a good idea, because it makes a button non-usable with keyboard. Use the command option. -- nosy: +serhiy.storchaka resolution: - not a bug ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11387 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11387] Tkinter, callback functions
Changes by Terry J. Reedy tjre...@udel.edu: -- stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11387 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21611] int() docstring - unclear what number is
Dmitry Andreychuk added the comment: Now I see that my message may look like a suggestion to add an encyclopedic definition of number there. Sorry. Actually I was talking about requirements for user-defined types to make them work with int(). Something like: If x has __int__() method return x.__int__(). Else x must be a string, bytes, or bytearray After reading the docstring I was like: Should I just define __int__() for my class to work with int() or maybe int() uses isintance() and my class has also to inherit from numbers.Number? But maybe It's just me and it's clear for everyone else. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21611 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6167] Tkinter.Scrollbar: the activate method needs to return a value, and set should take only two args
Changes by Serhiy Storchaka storch...@gmail.com: -- versions: +Python 3.5 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6167 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21611] int() docstring - unclear what number is
eryksun added the comment: The constructor tries __trunc__ (truncate toward 0) if __int__ isn't defined. If __trunc__ doesn't return an instance of int, it calls the intermediate result's __int__ method. In terms of the numbers ABCs, numbers.Real requires __trunc__, which should return a numbers.Integral, which requires __int__. The special methods __trunc__, __floor__, and __ceil__ aren't documented in the language reference. They're mentioned briefly in the docs for the math functions trunc, floor, and ceil. -- nosy: +eryksun ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21611 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18039] dbm.open(..., flag=n) does not work and does not give a warning
Changes by Claudiu.Popa pcmantic...@gmail.com: -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18039 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18039] dbm.open(..., flag=n) does not work and does not give a warning
Claudiu.Popa added the comment: Serhiy, could you please have a look at this patch? Given the fact that you committed my last dbm patch, I hope you have a couple of minutes to have a look at this one as well. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18039 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4350] Remove dead code from Tkinter.py
Changes by Serhiy Storchaka storch...@gmail.com: -- versions: +Python 3.5 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4350 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17095] Modules/Setup *shared* support broken
Roundup Robot added the comment: New changeset 6c468df214dc by Ned Deily in branch '3.4': Issue #17095: Fix Modules/Setup *shared* support. http://hg.python.org/cpython/rev/6c468df214dc New changeset 227ce85bdbe0 by Ned Deily in branch 'default': Issue #17095: Fix Modules/Setup *shared* support. http://hg.python.org/cpython/rev/227ce85bdbe0 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17095 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17095] Modules/Setup *shared* support broken
Ned Deily added the comment: Committed for release in 3.4.2 and 3.5.0. -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17095 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20147] multiprocessing.Queue.get() raises queue.Empty exception if even if an item is available
Alexei Mozhaev added the comment: Hi! Are there any updates on the issue? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20147 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19997] imghdr.what doesn't accept bytes paths
Claudiu.Popa added the comment: There are other modules with support for bytes filenames in their API: bz2 codecs gzip lzma pipes.Template tarfile tokenize fileinput filecmp sndhdr configparser Also, given the fact that sndhdr supports them and its purpose is similar with imghdr, it would be a surprise for a beginner to find out that imghdr.what(bimg) is not working, while sndhdr.what(bsnd) works. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19997 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21401] python2 -3 does not warn about str/unicode to bytes conversions and comparisons
STINNER Victor added the comment: Serhiy wrote: I think that even if we accept this change (I am unsure in this), a warning should be raised only when bytes and unicode objects are equal. When they are not equal, a warning should not be raised, because this matches Python 3 behavior. Python 3 warns even if strings are equal. $ python3 -b -Wd Python 3.3.2 (default, Mar 5 2014, 08:21:05) e for more information. b'abc' == 'abc' __main__:1: BytesWarning: Comparison between bytes and string False b'abc' == 'abc' False The warning is not repeat in the interactive interprter because it is emited twice at the same location __main__:1. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21401 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com