Re: [Tutor] Coming from R, what's a good IDE editor? I've tried PyCharm and Spyder
Atom.io Editor is my current favorite after having swapped around a lot. http://www.marinamele.com/install-and-configure-atom-editor-for-python ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Running Python code without python installed
There are actually some options here. But all of them will require some form of a installer. The only gotcha is you need an installer for each platform you plan on distributing too. So for Windows I currently use: INNO Setup Installer ( http://www.jrsoftware.org/isinfo.php ) and package the Python installer for windows with-in it; then install Python and after that is complete I install my python program; once everything is installed you can create a launcher. Inno comes with a nice little IDE to help you create the installer. It also runs well in Wine in case you are on Windows. For Linux: I use a self extracting shell installer script ( http://stephanepeter.com/makeself/ ) that runs the appropriate installation commands for Linux to get a Python interpret installed and then switch it over to Python to finish the install. But I also test for Python and 99% of the time my installer has reported that Python in some form was already installed on Linux. For OSX I have not yet tried to get my code working there; but I am fairly certain that Python is installed on most OSX installs by default it just becomes a matter of upgrading it to a more modern version. For Android and IOS I use Kivy and buildozer to create the necessary packages. Also the web app option is another good possibility; as mentioned by Alan; since HTML5 has done so much to improve the state of web applications. On Sat, Aug 27, 2016 at 2:26 AM, Jade Beckmannwrote: > Hi there, > > I'm creating a program using python that uses a GUI and I want to be able > to give the file to others for them to use the program on their computer. > I'm just wondering how someone who doesn't have the python software > installed on their PC or mac would be able to run the program? > > Thanks, > > Jade > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best tool for programming interactive games in Python
On Wed, Mar 30, 2016 at 10:36 AM, john <jo...@jfcomputer.com> wrote: > On 03/30/2016 04:27 AM, wolfrage8...@gmail.com wrote: >>> >>> I have a few students who are interested in creating interactive games in >>> Python. We have learned how to use tkinter but we are looking for >>> something more robust. I tried using pygame >> >> I recommend Kivy; because then it is easy to take the app from >> computer to Phone; which opens the world of touch devices! >> Though not specifically made for games it works very well for my >> purposes which are a game. >> > I believe Kivy requires pygame so he would get the same error. Since Kivy 1.9 the requirement for pygame has been dropped and they are now using OpenGL instead. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best tool for programming interactive games in Python
>I have a few students who are interested in creating interactive games in >Python. We have learned how to use tkinter but we are looking for > something more robust. I tried using pygame I recommend Kivy; because then it is easy to take the app from computer to Phone; which opens the world of touch devices! Though not specifically made for games it works very well for my purposes which are a game. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] OT: (Continuous) integration testing: Can a solo developer with very limited resources truly do this?
>> >>> Does one need to already have installation media for each OS to be >>> used, or are they pre-loaded? If the first, for Windows that could >>> potentially be a chunk of money! >> >> See Here Free Virtual Machines for Windows: >> https://dev.windows.com/en-us/microsoft-edge/tools/vms/windows/ > > I saw these but my superficial impression was that these were for > Explorer and Edge browser testing. Are they in fact usable for any OS > functions I might have my programs using? Yes at least the last time I downloaded one from the site it was a full up and functional version of Windows only stipulation is the trial period but using Virtual Box Snapshot functionality I am always able to easily revert the VM back to day 0 of the trial period. > > If yes, perhaps we should post to the entire Tutor list, too? Sorry I mean to post to the entire tutor list; thanks for pointing that out. > > -- > boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] OT: (Continuous) integration testing: Can a solo developer with very limited resources truly do this?
> You're already writing unit tests to exercise your code. Whenever you > modify or refactor your code, you exercise your test cases before you > check in the code. All you have to do now is exercise your test cases > on each supported platform or environment. > > If your application is expected to run on different operating systems > (MacOS, Linux, Windows, etc.), *** you need to test on all of them *** > [My emphasis.]. If you expect your application to work on different > versions of the Java Virtual Machine (VM) or .NET common language > runtime (CLR), *** you need to test that as well *** [My emphasis.]. > > > I firmly agree that this -- in principle -- must be done. But how on > earth can a solo developer, perhaps hoping to make a buck or two, with I as a solo developer have been unable to achieve this task too; but once my software is closer to complete that is when I look to do integration testing. > very limited resources, accomplish manual (much less continuous, > automated) integration testing on all reasonable environment > possibilities? Just the possibilities for Windows with their > constant, unending (albeit, necessary) string of security updates > boggles my imagination! You can always download the free test versions of windows; that is what I do and then I throw them on a virtual machine so as to not have to suck up that cost. But dealing with what security updates break is a different story all together. > > One of the many beauties of Python is its portability across many > platforms, but it is not perfect. And surprises can occur, even if it > is not Python's fault. I *thought* I was finally finished with > supporting Python 2.4 at work, and could start using features > available in Python 2.6. While testing some new code where I had > starting using "with ..." to take care of closing files, I started > receiving erratic crashes. Sure enough the traceback pointed to the > sections of code using the "with ..." blocks. Huh?!? After > investigation, I found that when my IS and commercial vendor friends > installed the second computational server for the planning software we > use, they did *not* install the *exact* same environment. The OS > version was the same, but not all of the other ancillary software was > the same. In this instance, they went backwards with Python and > installed Python 2.4 on the new server. Since which server gets used > is out of the user's control, sometimes my tests ran on one server, > sometimes on the other. And since I am stuck doing manual testing, > these kinds of things are especially hard to catch! The only way I > will ever be able to automate testing at work will be to write my own > custom testing framework that can bridge the "automation gap" between > the software we use with its proprietary scripting language which does > not support automated testing of any sort and the Python that I find > myself using more and more, where I have the potential to automate. > But the bottom line is -- at work -- the core data I need is in the > proprietary environment and after the needed processing with Python it > has to be translated back into the proprietary environment's scripting > language and run there. Yes in my virtual environments I have over time been diligently writing a testing automation tool; that starts when the OS boots; then looks to a specific server for a specific directory to download the code to be tested. But it is very rough; the key is to start small and write code that can be re-used. But I am still missing an android and IOS client so I have to test those manually. > > The above was just a single practical example (Rant? Sorry!). But > even for stuff I do at home, even with using some complex combination > of virtual environments to test all relevant OS's (Assuming I could > even afford copies WinXP, WinVista, Win7, Win10, etc., with all their > many permutations.), how can automated, continuous integration testing > be accomplished *in practice* for the severely resource-constrained > solo developer? Good Luck! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How do I access and manipulate files?
On Fri, Mar 11, 2016 at 8:03 PM, Justin Hayeswrote: > Access: https://docs.python.org/2/library/functions.html#open Basic Manipulation: http://stackoverflow.com/posts/9283052/revisions Please try some code and ask some more specific questions. The Python documentation is pretty good and there is a wealth of information online. > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing the interpreter prompt symbol from ">>>" to ???
On Sat, Mar 12, 2016 at 1:53 AM, boB Steppwrote: > > Thanks for the feedback. I tried out your link, codeanywhere.com . I > have to confess my experience was not a good one. Firstly, the > environment supplied would not accept my space bar characters! So I > could not type any import statements. However, I did try: Yes I do not endorse codeanywhere.com; but it is the only editor I have access to while at work; so as the only it meets my needs barely. > > print('\u25ba'), which did not require any spaces and received an > error stating that it would not accept values greater than hex ff. So > it is pretty clear that following Cameron's suggestion is not (At > least on the surface.) doable in the codeanywhere environment. Might > I suggest pythonanywhere? All of this works fine with utf-8 there. I used to use Pythonanywhere.com but it is blocked; so it is no longer an option. > > boB > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing the interpreter prompt symbol from ">>>" to ???
Also before I get called out; sorry for the top post; I blame G-Mail's Interface. And good luck finding a better option; perhaps detecting if Unicode is supported on the system then we could use something such as Right Facing Triangle. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing the interpreter prompt symbol from ">>>" to ???
I am not surprised since you have set it to a usually non printable character of ascii the data link escape. Perhaps you would have better luck with the extended ascii characters; but not much in there for arrows. I would probably go with chr(175) but that did not display correctly in the web based terminal either; because it looked like an underline at the top of the character block. On Fri, Mar 11, 2016 at 10:59 PM, boB Steppwrote: > On Fri, Mar 11, 2016 at 9:31 PM, boB Stepp wrote: > >> Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 >> 64 bit (AMD64)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. > import sys > sys.ps1 = '=>' >> =>sys.ps1 = chr(26) >> →sys.ps1 = chr(16) >> ► >> >> I personally like the last of these. My question is, will this show >> up as a black, filled-in arrowhead pointing to the right on everyone's >> email? I have yet to delve into Unicode display issues, but I have >> vague recollections that the old ASCII table values might not always >> display the same thing from one person's display to another one's. Is >> this correct? > > There looks to be the potential for problems. I tried: > > ►for i in range(256): > ... try: > ... print(str(i) + ': ' + chr(i)) > ... except UnicodeEncodeError as e: > ... print(e) > > which gave in some sections: > > 126: ~ > 127: > 'charmap' codec can't encode character '\x80' in position 5: character > maps to > 'charmap' codec can't encode character '\x81' in position 5: character > maps to > > So how reliable is the chr(16) character on people's displays? > > boB > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing the interpreter prompt symbol from ">>>" to ???
On a web based terminal via codeanywhere.com setting sys.ps1 = chr(16) results in no character being displayed. It is literally just a new line. So something to think about. I set it back to sys.ps1 = '>>>' On Fri, Mar 11, 2016 at 10:59 PM, boB Steppwrote: > On Fri, Mar 11, 2016 at 9:31 PM, boB Stepp wrote: > >> Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 >> 64 bit (AMD64)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. > import sys > sys.ps1 = '=>' >> =>sys.ps1 = chr(26) >> →sys.ps1 = chr(16) >> ► >> >> I personally like the last of these. My question is, will this show >> up as a black, filled-in arrowhead pointing to the right on everyone's >> email? I have yet to delve into Unicode display issues, but I have >> vague recollections that the old ASCII table values might not always >> display the same thing from one person's display to another one's. Is >> this correct? > > There looks to be the potential for problems. I tried: > > ►for i in range(256): > ... try: > ... print(str(i) + ': ' + chr(i)) > ... except UnicodeEncodeError as e: > ... print(e) > > which gave in some sections: > > 126: ~ > 127: > 'charmap' codec can't encode character '\x80' in position 5: character > maps to > 'charmap' codec can't encode character '\x81' in position 5: character > maps to > > So how reliable is the chr(16) character on people's displays? > > boB > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] AWS /Django/Apache/Python/Github
I recommend that you give Kivy a try for desktop and mobile give it a look up on YouTube. https://kivy.org/ http://m.youtube.com/watch?v=F7UKmK9eQLY ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] AWS /Django/Apache/Python/Github
What kind of apps do you want to deploy? Mobile; Web; Desktop; or Server? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] question
When you say "Window" are you referring to the Installer or Idle? Which Operating System are you using and what version of Python did you download? Did you run the installer that you downloaded? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Modularity
Modularity of code is difficult for sure and is kind of an art. To do it best you will have to read about and implement some of the Design Patterns. There are many but some of the ones that I have leaned towards over time are Composition over inheritance, Message Passing Interfaces, Mediator, and Model View Controller. Each of these is a large subject in there own right; and how to use each in your use case takes care and consideration. You also will need to consider that there is a learning curve associated with each design pattern so you will loose some time as you try to learn the pattern before it will begin to save you time by making your code less coupled. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Message Passing & User Interfaces
I realize this is a higher level question; so please direct me as appropriate. I can not seem to find a good standard that is in practical use for controlling user interfaces via a message passing. Does any one have any links to such an example? I would be most grateful. Thank you. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fwd: Re: creating a mspaint utility
Might I also recommend Kivy as the GUI. It has a nice tutorial that is actually on this subject. https://kivy.org/docs/tutorials/firstwidget.html ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fwd: Kivy Install
This is a general Python mailing list. For Kivy please reference: https://groups.google.com/forum/#!forum/kivy-users or find the developers on freenode IRC in #kivy This is the official Kivy repository here: https://github.com/kivy/kivy The official Kivy site is here: http://kivy.org/ But you are in luck I am a Kivy User too. However I am a Linux OS user so your luck just became a little less. For Windows I do not believe installing via Python's PIP is not supported. However their are pre-built binaries for windows with executable installers here: http://kivy.org/#download So what exactly are you trying to do? Install Kivy on your windows machine for development or Install Kivy on other peoples computers that use your software which is built on Kivy? On Thu, Dec 17, 2015 at 1:06 PM, peter mcfarlanewrote: > Hi, > I don't know if this is the correct forum, I am new to Python and > trying to install Kivy. I keep getting the following error message. > Can you help? > > thanks, > pete > > > > > pip install --user Kivy > > > Collecting Kivy > Using cached Kivy-1.9.0.tar.gz > Requirement already satisfied (use --upgrade to upgrade): > Kivy-Garden==0.1.1 in c:\python27\lib\site-packages (from Kivy) > Requirement already satisfied (use --upgrade to upgrade): requests in > c:\python27\lib\site-packages (from Kivy-Garden==0.1.1->Kivy) > Building wheels for collected packages: Kivy > Running setup.py bdist_wheel for Kivy > Complete output from command C:\Python27\python.exe -c "import > setuptools;__file__='C:\\Users\\edge\\AppData\\Local\\Temp\\pycharm-packaging0.tmp\\Kivy\\setup.py';exec(compile(open(__file__).read().replace('\r\n', > '\n'), __file__, 'exec'))" bdist_wheel -d > c:\users\edge\appdata\local\temp\tmps896gmpip-wheel-: > [INFO ] [Logger ] Record log in > C:\Users\edge\.kivy\logs\kivy_15-12-17_35.txt > [INFO ] [Kivy] v1.9.0 > [INFO ] [Python ] v2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 > 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] > > Detected Cython version 0.21.2 > Windows platform detected, force GLEW usage. > Using this graphics system: OpenGL > WARNING: A problem occured while running pkg-config --libs --cflags > gstreamer-1.0 (code 1) > > 'pkg-config' is not recognized as an internal or external command, > operable program or batch file. > > > WARNING: A problem occured while running pkg-config --libs --cflags sdl2 > SDL2_ttf SDL2_image SDL2_mixer (code 1) > > 'pkg-config' is not recognized as an internal or external command, > operable program or batch file. > > > running bdist_wheel > running build > running build_py > creating build > creating build\lib.win32-2.7 > creating build\lib.win32-2.7\kivy > copying kivy\animation.py -> build\lib.win32-2.7\kivy > copying kivy\app.py -> build\lib.win32-2.7\kivy > copying kivy\atlas.py -> build\lib.win32-2.7\kivy > copying kivy\base.py -> build\lib.win32-2.7\kivy > copying kivy\cache.py -> build\lib.win32-2.7\kivy > copying kivy\clock.py -> build\lib.win32-2.7\kivy > copying kivy\compat.py -> build\lib.win32-2.7\kivy > copying kivy\config.py -> build\lib.win32-2.7\kivy > copying kivy\context.py -> build\lib.win32-2.7\kivy > copying kivy\event.py -> build\lib.win32-2.7\kivy > copying kivy\factory.py -> build\lib.win32-2.7\kivy > copying kivy\factory_registers.py -> build\lib.win32-2.7\kivy > copying kivy\geometry.py -> build\lib.win32-2.7\kivy > copying kivy\gesture.py -> build\lib.win32-2.7\kivy > copying kivy\interactive.py -> build\lib.win32-2.7\kivy > copying kivy\lang.py -> build\lib.win32-2.7\kivy > copying kivy\loader.py -> build\lib.win32-2.7\kivy > copying kivy\logger.py -> build\lib.win32-2.7\kivy > copying kivy\metrics.py -> build\lib.win32-2.7\kivy > copying kivy\multistroke.py -> build\lib.win32-2.7\kivy > copying kivy\parser.py -> build\lib.win32-2.7\kivy > copying kivy\resources.py -> build\lib.win32-2.7\kivy > copying kivy\support.py -> build\lib.win32-2.7\kivy > copying kivy\utils.py -> build\lib.win32-2.7\kivy > copying kivy\vector.py -> build\lib.win32-2.7\kivy > copying kivy\weakmethod.py -> build\lib.win32-2.7\kivy > copying kivy\__init__.py -> build\lib.win32-2.7\kivy > creating build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\adapter.py -> build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\args_converters.py -> > build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\dictadapter.py -> build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\listadapter.py -> build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\models.py -> build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\simplelistadapter.py -> > build\lib.win32-2.7\kivy\adapters > copying kivy\adapters\__init__.py -> build\lib.win32-2.7\kivy\adapters > creating build\lib.win32-2.7\kivy\core > copying kivy\core\__init__.py ->
Re: [Tutor] Mobile apps in Python
I definitely recommend Kivy. I have enjoyed great success with it, and it was very easy to port my code to work on Android. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Making Doubly Linked List with Less Lines of Code.
On Tue, Dec 30, 2014 at 2:37 PM, Danny Yoo d...@hashcollision.org wrote: If that's the case, then none of this requires linked list storage. Instead, we can represent this as a list of rows. Each row element would be itself a list of tiles. In short, a matrix. See: https://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list True, I could use a multidimensional list. And originally I was using a 2D list. But I wanted the ability to quickly search across a row or up and down a column and so the added benefit of the linked list was that it simply requires me to access the next node reference. And finding neighboring tiles also wouldn't be too bad: Given a tile at (i, j), we can find its neighbors through arithmetic (i plus or minus one, j plus or minus one). From a coding perspective the linked list seemed simplier, because my other 2D list implementation required me to have a function that could map from any position to North, South, East, West, plus it needed to perform bounds checking. Of course having the list now be doubly linked has added complexity. If the game grid were a lot more dynamic and non-squarish, then that might make it appropriate. Linked lists give us a flexible way to represent such a game board. But at the moment, I think it's overkill for the scenario you're showing us. That may be True. I would like to know, if you know, would this doubly linked list be more or less memory efficient than the 2D list method and which one would provide faster look-ups? I do know that the doubly linked list has an initial speed cost in constructing it, which is obviously more than the 2D list. The overall application to which this code will be applied is a Kivy App that will be deployed to mobile devices, that is why I have these questions, although I realize this is pre-optimizing which is the root of evil... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] My Query - How to implement multi threading with remote execution capability in python to achieve parallel processing
On Mon, Dec 22, 2014 at 6:27 AM, Vishwas Pathak vishwas_pat...@persistent.com wrote: Your Disclaimer alone means that I can not respond to this question, or else it would apparently become the property of Persistent Systems Ltd. I prefer Open Source to closed source... good day. DISCLAIMER == This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] My Query - How to implement multi threading with remote execution capability in python to achieve parallel processing
On Mon, Dec 22, 2014 at 10:21 PM, Dave Angel da...@davea.name wrote: On 12/22/2014 09:58 PM, Alex Kleider wrote: On Dec 22, 2014 12:36 PM, wolfrage8...@gmail.com wrote: On Mon, Dec 22, 2014 at 6:27 AM, Vishwas Pathak vishwas_pat...@persistent.com wrote: Your Disclaimer alone means that I can not respond to this question, or else it would apparently become the property of Persistent Systems Ltd. I prefer Open Source to closed source... good day. Although I also find the disclaimer somewhat obnoxious and also prefer open source, I think you are mistaken in your conclusion about exactly what the disclaimer says. You're right that he's mistaken. it's even worse. The disclaimer claims I'm not permitted to read such messages, nor save them on my machine. So I'm considering writing a filter to try to comply by deleting them before they accidentally come before my eyes. I had sent this just to Alex, but since reading your reply (Dave) I figured I should just post it too. Sent to Alex: You are completely correct. I more so felt like the OP wanted us to help him with something that is clearly at a business level with the expectation that it would disappear into his company. But then again I am placing words into his mouth which clearly were not said. Although who is the authorized party to read and retain his emails, it seems ambiguous when he is sending it to a public mailing list? Sorry for over generalizing and being overly sarcastic. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] A question about using stdin/out/err vs named files
Are you planning to pipe data to a python program? If so please specify and you will get more complete answers. Specifically I am thinking you want information pertaining to subprocess in the standard library. https://docs.python.org/3/library/subprocess.html On Sat, Oct 18, 2014 at 2:36 PM, George R Goffe grgo...@yahoo.com.dmarc.invalid wrote: Hi, When you run a python program, it appears that stdin, stdout, and stderr are opened automatically. I've been trying to find out how you tell if there's data in stdin (like when you pipe data to a python program) rather than in a named input file. It seems like most/all the Unix/Linux commands are able to figure this out. Do you know how Python programs do this or might do this? MANY thanks for any/all help/hints/tips/suggestions, George... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Question
It will also be helpful if you tell us your OS and Python Version. Can you also tell us if you are writing the code to a file and executing, using IDLE or some other IDE, or are you using the interpreter interactively? On Fri, Jan 10, 2014 at 8:57 PM, Amy Davidson amydavid...@sympatico.ca wrote: Hey Danny, I just started taking the course (introduction to Computer Science) on last Tuesday, so I am not to familiar. I have been doing my best to understand the material by reading the text book, Learn Python the hard way. In my quest to answer the question given to me, I have searched the internet high and low of other functions thus, I am familiar with the basic knowledge of them (i.e. starting with def) as well as examples. We can attempt the approach to the method that you prefer. Thans for helping me, by the way. On Jan 10, 2014, at 5:25 PM, Danny Yoo d...@hashcollision.org wrote: On Fri, Jan 10, 2014 at 2:00 PM, Keith Winston keithw...@gmail.com wrote: Amy, judging from Danny's replies, you may be emailing him and not the list. If you want others to help, or to report on your progress, you'll need to make sure the tutor email is in your reply to: Hi Amy, Very much so. Please try to use Reply to All if you can. If you're wondering why I'm asking for you to try to recall any other example function definitions, I'm doing so specifically because it is a general problem-solving technique. Try to see if the problem that's stumping you is similar to things you've seen before. Several of the heuristics from Polya's How to Solve It refer to this: http://en.wikipedia.org/wiki/How_to_Solve_It If you haven't ever seen any function definition ever before, then we do have to start from square one. But this would be a very strange scenario, to be asked to write a function definition without having seen any previous definitions before. If you have seen a function before, then one approach we might take is try to make analogies to those previous examples. That's an approach I'd prefer. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] os.system() not working
On Tue, Aug 27, 2013 at 6:33 AM, Nitish Kunder ndk1...@gmail.com wrote: Hii I have a python program which i am calling from a php script. The arguments to the program is a path to the file The program when directly run from console executes normally. But when I try to execute the program from browser ie call the python script from php, os.system command is not working what might be the problem. Thanks Due to the lack of context I am forced to think you must be slightly confused. PHP is not Python. Thus your PHP script can not execute the os.system() function, because it does not exist in PHP, only in Python. PHP equivalent would be exec() at least as far as I know, but use it carefully and with caution. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] global variables
Steve, Thanks for all of this information. It seems the OP has sparked the kind of discussion that I had hopped for when I posted http://thread.gmane.org/gmane.comp.python.tutor/83251 Luckily though I did get an excellent response from Alan. http://thread.gmane.org/gmane.comp.python.tutor/83251/focus=83252 Still what you have posted here has been a good read, so, thank you. -- Jordan On Thu, Aug 22, 2013 at 12:18 PM, Steven D'Aprano st...@pearwood.info wrote: On 23/08/13 00:59, Andy McKenzie wrote: Isn't object orientation kind of the whole POINT of Python? From python.org: Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Well, yes and no. Python is an object-oriented language in the sense that all of Python is built using objects. Everything, including modules, functions, ints, strings, yes, even classes themselves, are objects. But also no, in the sense that the code you write doesn't have to be written using OOP techniques. Python is a multi-paradigm language in the sense that you can write code using any of these styles: - object-oriented - functional - procedural - imperative - or a mix of all of the above. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Parsing a multi-line/record text file
On Sun, Nov 11, 2012 at 6:01 AM, Marc m...@marcd.org wrote: ** Hello, I am trying to parse a text file with a structure that looks like: [record: Some text about the record] Attribute 1 = Attribute 1 text Attribute 3 = Attribute 3 text Attribute 4 = Attribute 4 text Attribute 7 = Attribute 7 text [record: Some text about the record] Attribute 1 = Attribute 1 text SNIP Etc…for many hundreds of records It looks like a Config or INI file to me. It is worth a try to see if configparser is able to process the file, if it can you have a solution, if not you only wasted a few minutes trying. SNIP ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] string to binary and back... Python 3
On Fri, Jul 20, 2012 at 12:33 AM, Dave Angel d...@davea.name wrote: On 07/19/2012 05:55 PM, Prasad, Ramit wrote: I am not sure how to answer that question because all files are binary, but the files that I will parse have an encoding that allows them to be read in a non-binary output. But my program will not use the in a non-binary way, that is why I plan to open them with the 'b' mode to open them as binary with no encoding assumed by python. I just not have tested this new technique that you gave me on a binary file yet as I was still implementing it for strings. As far as I know, even in binary mode, python will convert the binary data to read and write strings. So there is no reason this technique would not work for binary. Note, I was able to use the string representation of a PDF file to write another PDF file. So you do not need to worry about the conversion of binary to strings. All you need to do is convert the string to int, encrypt, decrypt, convert back to string, and write out again. Note Python3 being Unicode might change things a bit. Not sure if you will need to convert to bytes or some_string.decode('ascii'). In Python 3, if you open the file with b (as Jordan has said), it creates a bytes object. No use of strings needed or wanted. And no assumptions of ascii, except for the output of the % operator on a hex conversion. myfile = open(filename, b) data = myfile.read(size) At that point, convert it to hex with: hexdata = binascii.hexlify(data) then convert that to an integer: numdata = int(hexdata, 16) At that point, it's ready to xor with the one-time key, which had better be the appropriate size to match the data length. newhexdata = bytes(%x % numdata, ascii) newdata = binascii.unhexlify(newhexdata) If the file is bigger than the key, you have to get a new key. If the keys are chosen with a range of 2**200, then you'd read and convert the file 25 bytes at a time. Thanks I will give this a try. Can you explian a little further for me what exactly this: newhexdata = bytes(%x % numdata, ascii) line is doing? I don't quite understand the use of the %x % on numdata. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] string to binary and back... Python 3
On Thu, Jul 19, 2012 at 12:16 AM, Dave Angel d...@davea.name wrote: On 07/18/2012 05:07 PM, Jordan wrote: OK so I have been trying for a couple days now and I am throwing in the towel, Python 3 wins this one. I want to convert a string to binary and back again like in this question: Stack Overflow: Convert Binary to ASCII and vice versa (Python) http://stackoverflow.com/questions/7396849/convert-binary-to-ascii-and-vice-versa-python But in Python 3 I consistently get some sort of error relating to the fact that nothing but bytes and bytearrays support the buffer interface or I get an overflow error because something is too large to be converted to bytes. Please help me and then explian what I am not getting that is new in Python 3. I would like to point out I realize that binary, hex, and encodings are all a very complex subject and so I do not expect to master it but I do hope that I can gain a deeper insight. Thank you all. test_script.py: import binascii test_int = 109 test_int = int(str(test_int) + '45670') data = 'Testing XOR Again!' while sys.getsizeof(data) test_int.bit_length(): test_int = int(str(test_int) + str(int.from_bytes(os.urandom(1), 'big'))) print('Bit Length: ' + str(test_int.bit_length())) key = test_int # Yes I know this is an unnecessary step... data = bin(int(binascii.hexlify(bytes(data, 'UTF-8')), 16)) print(data) data = int(data, 2) print(data) data = binascii.unhexlify('%x' % data) I don't get the same error you did. I get: File jordan.py, line 13 test_int = int(str(test_int) + str(int.from_bytes(os.urandom(1), 'big'))) ^ test_int = int(str(test_int) + str(int.from_bytes(os.urandom(1), \ 'big'))) # That was probably just do to the copy and paste. IndentationError: expected an indented block Please post it again, with correct indentation. if you used tabs, then expand them to spaces before pasting it into your test-mode mail editor. I only use spaces and this program did not require any indentation until it was pasted and the one line above became split across two line. Really though that was a trivial error to correct. I'd also recommend you remove a lot of the irrelevant details there. if you have a problem with hexlfy and/or unhexlify, then give a simple byte string that doesn't work for you, and somebody can probably identify why not. And if you want people to run your code, include the imports as well. My problem is not specific to hexlify and unhexlify, my problem is trying to convert from string to binary and back. That is why all of the details, to show I have tried on my own. Sorry that I forgot to include sys and os for imports. As it is, you're apparently looping, comparing the byte memory size of a string (which is typically 4 bytes per character) with the number of significant bits in an unrelated number. I suspect what you want is something resembling (untested): mybytes = bytes( %x % data, ascii) newdata = binascii.unexlify(mybytes) I was comparing them but I think I understand how to compare them well, now I want to convert them both to binary so that I can XOR them together. Thank you for your time and help Dave, now I need to reply to Ramit. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] using dynamic import statements
Might I recommend you use the logging module that is part of core Python rather than rolling your own if Debug. I found the logging module made growing my logging across multiple applications so easy! http://docs.python.org/library/logging.html On Mon, Jul 9, 2012 at 2:10 PM, Chris Hare ch...@labr.net wrote: Thanks all for the ideas. I wanted to have my own error messages printed for the user - something a little more meaningful than the standard error. Thanks for the advice - very helpful! On Jul 9, 2012, at 6:12 AM, Alan Gauld wrote: On 09/07/12 10:19, Kwpolska wrote: Why does this bloody ML want me to respond to the last person instead of tutor@python.org? Because that's how it, along with many other mailing lists, works. If it helps, think of it as you receiving a mail from the sender and CCd to the list. Therefore hitting reply sends to the person who sent the mail and ReplyAll goes to everyone. Seems logical to me! :-) It allows me to choose to reply to the OP only or to the group, I use both depending on the nature of my reply. (About 80% of my replies go to the everyone.) But some prefer it differently... :-) Why not the more usual: import sys, os, imp, stat,\ re, webbrowser, Image, \ StringIO, shutil, datetime Why not the more standard: import sys import os and so on? http://www.python.org/dev/peps/pep-0008/#imports Indeed but the OP seemed to want to remove duplicate coding so I assumed that he included using multiple imports. Personally I'd probably code the above as: import sys, os, shutil, stat, datetime import re, StringIO import webbrowser, import Image, import imp Which groups things into roughly related categories - system, strings, other... OTOH I ignore large chunks of Pep 8 because I find its style harder to read than the one I'm used to. But then, I'm not contributing to the standard library etc... Style is largely a matter of taste. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Is this possible and should it be done?
All, I have had a curious idea for awhile, and was wondering the best way to implement it in Python and if it is even possible. The concept is this, a file that is actually a folder that contains multiple files (Like an Archive format). The actual files are really un-important. What I want is for the folder to be represented as a single file by any normal file browser, but to be able to access the files with-in via Python. I will actually use the word archive to represent my mystical folder as a file concept for the rest of this message. Some additional things I would like to be possible: is for multiple copies of the program to write to the same archive, but different files with-in at the same time (Reading Writing to the archive should not lock the archive as long as they are different files); and for just the desired files with-in the archive to be loaded to memory with out having to hold the entire archive in memory. Use case for these additional capabilities. I was reading about how some advanced word processing programs (MS Word) actually save multiple working copies of the file with-in a single file representation and then just prior to combining the working copies it locks the original file and saves the working changes. That is what I would like to do. I want the single file because it is easy for a user to grasp that they need to copy a single file or that they are working on a single file, but it is not so easy for them to grasp the multiple file concepts. MS Word uses Binary streams as shown here: http://download.microsoft.com/download/5/0/1/501ED102-E53F-4CE0-AA6B-B0F93629DDC6/WindowsCompoundBinaryFileFormatSpecification.pdf Is this easy to do with python? Does it prevent file locking if you use streams? Is this worth the trouble, or should I just use a directory and forget this magical idea? A piece of reference for my archive thoughts, ISO/IEC 26300:2006 chapter 17.2 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Is this possible and should it be done?
-- Forwarded message -- From: wolfrage8...@gmail.com wolfrage8...@gmail.com Date: Mon, May 21, 2012 at 2:16 PM Subject: Re: [Tutor] Is this possible and should it be done? To: Steven D'Aprano st...@pearwood.info Thank you for the information. Sorry if I implied I wanted to re-invent the wheel but actually this feedback is exactly what I was looking for. I wanted to know existing methods to do just such operations. Also good point about the file browsers the only limitation to them is how much they understand the format. So since tar looks like an excellent option for what I want to do, I have another question before I begin my research. Do you already know if any of these formats offer file locking with in them, ;et me say that better. Can I open a, as example, tar file and lock a file with in it, with out locking the entire tar archive? Just asking if you already know if this is possible? Thank you again for the information! SNIPED ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Is this possible and should it be done?
Forwarded because I did not reply to the list properly. Hopefully I did not forward wrong. -- Forwarded message -- From: wolfrage8...@gmail.com wolfrage8...@gmail.com Date: Mon, May 21, 2012 at 2:18 PM Subject: Re: [Tutor] Is this possible and should it be done? To: Joel Goldstick joel.goldst...@gmail.com Thank you for your help Joel. In this case I don't want to know about the details just want an easy implementation and tar looks like the right solution. I also think that the compression being seperated from the format is likely best and will probably not use the compression as it would hinder my overall goal. OK going to read up on TAR now! Thanks again. SNIPED ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Is this possible and should it be done?
On Mon, May 21, 2012 at 4:06 PM, William R. Wing (Bill Wing) w...@mac.com wrote: On May 21, 2012, at 6:38 AM, wolfrage8...@gmail.com wrote: All, I have had a curious idea for awhile, and was wondering the best way to implement it in Python and if it is even possible. The concept is this, a file that is actually a folder that contains multiple files (Like an Archive format). The actual files are really un-important. What I want is for the folder to be represented as a single file by any normal file browser, but to be able to access the files with-in via Python. I will actually use the word archive to represent my mystical folder as a file concept for the rest of this message. Some additional things I would like to be possible: is for multiple copies of the program to write to the same archive, but different files with-in at the same time (Reading Writing to the archive should not lock the archive as long as they are different files); and for just the desired files with-in the archive to be loaded to memory with out having to hold the entire archive in memory. Use case for these additional capabilities. I was reading about how some advanced word processing programs (MS Word) actually save multiple working copies of the file with-in a single file representation and then just prior to combining the working copies it locks the original file and saves the working changes. That is what I would like to do. I want the single file because it is easy for a user to grasp that they need to copy a single file or that they are working on a single file, but it is not so easy for them to grasp the multiple file concepts. As others have noted, this smells a lot like a .tar or similar archive. I'd suggest that it also smells like a scaled down and locally served Concurrent Versioning System. CVS does exactly what you want in terms of preserving only differences between edited versions of a file and it only locks the particular file that has been checked out; also allows you to back up to any previous version of a file. There are CVS-Python bindings (as well as SVN-Python, SVN being a newer more modern version of CVS). Google will turn up lots of references to both. -Bill Hey that sounds really interesting I did not know that SVN or CVS was even an option, but can they work with an archive, I will have to experiment, but that would take care of the multiple working copies and final merges latter. Thanks for the idea! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Coding Challenges
On Mon, May 21, 2012 at 4:47 PM, Malcolm Newsome malcolm.news...@gmail.com wrote: Hey all, Being new to programming, I've found that my learning is accelerated when I've been asked to write scripts and deliver them in a specified time frame...Then, have those scripts critiqued. My question: Would the moderators of this list be interested in creating a monthly challenge of sorts? Then, those who participated could receive suggestions on how their code could have been written differently. If not, and you know of something else like this that exists, would you kindly share those resources? Thanks! Malcolm Newsome Sent from my Windows Phone ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor If they agree I am all for it, if not I would still like to know what kind of plan that you come up with; as it will only make me better. -- Jordan Farrell ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python problem
To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor On Tue, Jan 10, 2012 at 11:04 AM, Bojan Antonijevic antonijevi...@gmail.com wrote: Hello, I send you a mail at 29.12.2011. about problem with my IDLE (Python GUI) and I didnt recive any ansfer; Instead, I am receiving correspondence between other members of forum; Honestly, I don't want to receive all this conversation's. Thank you. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Primitive Chess Clock Program Question
I assume you want to display something like this: Enter your next move: 0:30 SNIP Assuming Steven has guessed right then I think you need to use one of the non blocking input mechanisms like kbhit() or getch() or somesuch. Those methods are notioriously unreliable and OS specific. For example you may need to use curses or the Microsoft runtime module msvcrt. I would recommend termios for unix over curses, because curses pretty much takes over. Something like this: http://code.activestate.com/recipes/577977-get-single-keypress/ SNIP label while awaiting user input is almost trivial (for a GUI). I agree with Alan, a GUI toolkit makes this trivial because it can run using events and timers. For a terminal I would recommend you use a couple of threads. One that checks for input on getchar() and the other thread, the main thread, that can update the display of the prompt. You can use Queue to pass the key(s) recieved to the main thread. Also to reduce or eliminate flicker I would also recommend you look at sending the backspace characters to the terminal and then replace the correct time. Something like this: import sys sys.stdout.write('\b') sys.stdout.flush() Of course that is assuming that your terminal will support \b . On Wed, Jan 4, 2012 at 2:22 AM, Alan Gauld alan.ga...@btinternet.com wrote: On 03/01/12 21:28, Steven D'Aprano wrote: I assume you want to display something like this: Enter your next move: 0:30 where the 0:30 is the time remaining, and is constantly updating. When it hits zero, the function returns whether the user has typed anything or not. Assuming Steven has guessed right then I think you need to use one of the non blocking input mechanisms like kbhit() or getch() or somesuch. Those methods are notioriously unreliable and OS specific. For example you may need to use curses or the Microsoft runtime module msvcrt. The general code will look like Display prompt while no key hit sleep briefly update time in prompt (using ctrl characters to delete/overwrire previouis entry) #when key hit process input. It is a non trivial problem and the details will depend on whether you use curses or the microsoft route. It is one of those few cases that is actually much easier to do in a GUI. GUIs generally make life more complex but in this case updating a label while awaiting user input is almost trivial (for a GUI). -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor