Re: [Tutor] Help Needed
"Raj Medhekar" wrote I am looking to build a program that gets a message from the user and then prints it backward. I 've been at it for hours now but I can't seem to figure it out. So tell us what you re thinking? How would you solve it manually? I've been having trouble trying to index the message so I can print it out backwards. You can index the characters of a string in Python exactly as you do a list. I would've posted my code but I really haven't gotten past the 'raw_input("Enter a message: ")' command line. Its always better to try something even if its wrong, it lets us see where your thinking is going adrift. Or at least describe what you'd like to do conceptually. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best Python Editor
On Mon, Jun 15, 2009 at 1:50 PM, Michael Powe wrote: > I don't like GUI-based stuff, > though, so right off, any editor built on the assumption that I'm a > mouse-oriented user is right out. That's why I'm a solid vim user. I can't stand touching the mouse when I'm coding. It just breaks up the flow of typing. I heard it mentioned before and I feel the same way - I have to switch to a different mindset to move around instead of push buttons. Of course, now that I have one of those eraser mouses in the middle of my laptop it's really hard to use a real mouse for anything except graphics editing. The mouse wins there, and gaming, and that's really it for me. -Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn’t. - Primo Levi ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help Needed
On Mon, Jun 15, 2009 at 3:00 PM, Raj Medhekar wrote: > I am looking to build a program that gets a message from the user and then > prints it backward. I 've been at it for hours now but I can't seem to > figure it out. I've been having trouble trying to index the message so I can > print it out backwards. I would've posted my code but I really haven't > gotten past the 'raw_input("Enter a message: ")' command line. Any help is > gladly appreciated. Thanks! > Python treats a string like a list/array. In [1]: mystr = "I'm not a witch!" In [2]: mystr[0] Out[2]: 'I' Same goes for one that's defined with raw_input: In [4]: mystr = raw_input("She turned you into a newt? ") She turned you into a newt? I got better! In [5]: mystr[0] + mystr[1:] Out[5]: 'I got better!' Python has a slice operator the colon, so mystr[0] gives me the character at 0, and mystr[1:] gives me everything from the first character to the end (if you add something after the colon it will only return whatever is up to that point: In [10]: mystr[2:5] Out[10]: 'got' If you know what a loop is, you should be able to figure out how to get the result you're looking for. HTH, Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help Needed
Hi Raj, It might be easier if you create a simple test string inside the python interpreter and then tinker with it there. once you've found the solution, you can graft it onto the broader program that accepts user input. For example, you might create the following variable message = "This is a message" And then try splitting that message based on spaces and then using the "reverse" list method to switch the order. Or you could iterate through each character in the string and add it to a list, then apply the reverse method. Not sure precisely what you're getting at, but a little experimentation in the interpreter will probably lead you to a solution. HTH, Serdar ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help Needed
I am looking to build a program that gets a message from the user and then prints it backward. I 've been at it for hours now but I can't seem to figure it out. I've been having trouble trying to index the message so I can print it out backwards. I would've posted my code but I really haven't gotten past the 'raw_input("Enter a message: ")' command line. Any help is gladly appreciated. Thanks! -Raj ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best Python Editor
On Mon, Jun 15, 2009 at 06:34:04AM -0700, Emile van Sebille wrote: > On 6/15/2009 2:49 AM Tom Green said... > >Yes, vim or any text editor is suitable for Python, but I > >prefer having a nice GUI interface while coding. I mean the automobile > >replaced the horse and buggy, while they both get you to your > >destination I would still rather travel in a car. > Anyone know of any studies comparing text based vs GUI IDE based code > development? As I recall, programming productivity is measured in > LOC/day and last time I noticed it seemed to be a very small number. > I'm wondering if there might be documented benefits to migrating from my > horse and buggy. :) Are you in a hurry to get somewhere? ;-) I recently worked on a module for a large existing Java application. The module I wrote had to be plugged in to the existing code base. So of course, I had to have all kinds of tie-ins to existing libraries and classes. First, I couldn't run the full application, so I had to rely on unit testing to verify my functionality. Second, I had to connect to hundreds of classes inside the application. I'm not that smart -- I could not have done it without NetBeans, which has fantastic introspection and can tell me most of the ways I'm violating protocol while I'm working. I stubbed out a lot of stuff and prototyped in jEdit. But when it was game on, I had to go to NB. It probably comes down to, How much stuff can you carry in your head? Thanks. mp ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best Python Editor
On Mon, Jun 15, 2009 at 06:30:50AM -0700, johnf wrote: > On Sunday 14 June 2009 07:31:53 pm Michael Powe wrote: > > However, I will say that while following this thread, it occurred to > > me that the one feature that VS and even the VBA editor in MS Office > > has, is the ability to pop you into the debugger on error. This > > feature is so useful that it surprises me nobody else seems to do it. > > Most often, simply the ability to jump to the error line is provided > > and I suppose that must be generally acceptable. > Wing does. When error occurs it stops on the line and the programmer is > working in the debugger. Hello, I'll have to look at that. I have a kind of collection of editors -- the way I collect books, I guess. TextPad, vbsEdit, UltraEdit, SciTE, XmlCopyEditor, EditPlus, emacs. I never do anything with vi except munge conf files. For actual "projects" I use VS and NetBeans. When I get on a "back to basics" kick, I re-enter emacs. It used to be a joke about emacs not being an editor but an operating system. There is nothing on the linux side that even comes close, IMO. I don't like GUI-based stuff, though, so right off, any editor built on the assumption that I'm a mouse-oriented user is right out. Thanks. mp ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] 3.0 on Mac
Here is what my .bash_profile looks like, This is in my user directory " # Setting PATH for EPD_Py25 v4.3.0 # The orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}" export PATH PYTHONPATH="/Volumes/iDisk/match/python" export PYTHONPATH " Note that the file "/Library/Frameworks/Python.framework/Versions/Current" is a symbolic link to the actual python. You could change the smbolic link or pint the Bash_profile directly to the python you want. I also found it difficult to understand the PYTHONPATH, As yu see it above Python will look in my idisk for modules to import. So if I have a file names mymod.py in /Volumes/iDisk/match/python and I "import mymod" it will find it. Hope this helps, When I was learning abut python I found it difficult to find spisific instructins for this. Part of the problem Is that it seems that most instruction assume some understanding of terminal than I had. I know little more that what allows me to follow clear instructions. Thanks Vincent Davis 720-301-3003 On Thu, Jun 11, 2009 at 9:54 PM, Dave Angel wrote: > acfleck wrote: > > I'm a Python nubie and having trouble with 3.0.1 on Mac (10.4.11). I did a >> default install of MacPython 3.0.1. The IDLE.app works fine, but from a >> Terminal window, the 'python' command still gets me V2.5.3 (the original >> Apple installed version). A 'python3' command is not recognized. I'd like to >> know what I need to change to access V3.0.1 from a Terminal window. >> >> > Use the 'which' command to see what versions of python are on your PATH. > Then, since you have two different versions of Python you want available, > create one or more scripts (on your path), to explicitly run the other > installed versions. Probably, those scripts can be one line each, though > you also might conceivably want to set an environment variable or two (such > as pythonpath) > > > As far as I know, the install will not create a script called python3, or > anything else like it. That's up to you. And it's generally not good form > to hide the system-installed version, since many utilities and scripts might > depend on that particular version. > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best Python Editor
"Emile van Sebille" wrote Anyone know of any studies comparing text based vs GUI IDE based code development? As I recall, programming productivity is measured in LOC/day and last time I noticed it seemed to be a very small number. When I started in "software engineering" (c1985) the typical value was between 8-10 lines of working code per person per day. After PCs (and Unix workstations) became the norm the figure slowly rose to around 12-15. With the latest tools I suspect it might be getting close to breaking 20. (On small projects it will be much higher, this is an industry average remember) But i haven't seen a published figure for at least 5 years, if not more! I'm wondering if there might be documented benefits to migrating from my horse and buggy. :) Most improvements in productivity were down to things like seeing more than 24 lines of code at a time and faster navigation, as well as much faster compilatrion speeds (who remembers the days of limits on the number of compiles you could do per day - usually 3 or 4 - or the days when a full build was measured in hours, sometimes days (I worked on one project where we could only do a full build on a Friday night because it didn't finish until late Sunday afternoon...). The IDE doesn't add a huge amount of improvement, and the real issues holding down the figures are those that Fred Brooks called the "essential problems" - like understanding the requirements, defining an architecture etc - as well as regression testing etc. Even with test automation it still takes us 6 weeks to run a full regression test of some of our bigger projects. (Down from 16 though! :-) As for tests comparing text based editing v mouse driven those are very inconclusive and, I suspect, reflect the bias of the tester. Back when the Mac first came out(1984?) Apple showed that WYSIWYG word processors were much faster than older text styles(Wordstar etc) but then Wordstar showed that text based documents had fewer errors and gained students higher marks... I've certainly seen comparisons going both ways for programmer's editors. The one constant is that for pure text editing vi is usually fastest in the hands of an expert(*) even compared to emacs. But programmers do so much more than simply editing text! (*)The old DOS editor Brief ran it a very close second. Brief morphed into an Opensource GUI editor after Windows 3 came out (and Borland bought Brief) but I've forgotten the name and haven't heard of it for years. Wikipedia to the rescue - CrisP was the name and it was Unix only apparently. Then did the very unusual thing of going from Opensource to commercial! Its still going with a release in 2008. Ahh, nostalgia :-) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best Python Editor
for note; full tag completion and tag support can be used in vim via omnicompletion and taglists. Full class support/heiarchy + printing of the docscrint as you ctrl-n through each completion in the preview window. Extremly useful when using someone else's library or for remembering what to pass in; and mostly native to vim. I have never used a debugger (i usually use break points and prints, with a quick e to run and examine output); but I would assume it's there if you want it as I have seen GDB integration (as well as any VCS you would want, which suprises me that has not come up yet.) It just comes down to whether you want ot make the learning investment or not. After using it for awhile; your workflow just; well; flows. This to me is the biggest complement to an editor. Thanks, Chris On Sun, Jun 14, 2009 at 10:16 AM, Wayne wrote: > On Sun, Jun 14, 2009 at 5:55 AM, Tom Green wrote: > >> Since VIM seems to be the editor of choice and I have been programming in >> Python for many years using Pyscripter and Eclipse I was wondering how I >> could transition away from the IDE world to VIM. My main issue is how do I >> go about using VIM to debug my code? > > > I usually use print statements and/or raw_input's if you want break points. > > >> With Pyscripter and other IDES its as simple as placing a breakpoint and >> pressing F7 to step thru the code and you have the ability to see the >> variable values etc. > > > I know you can do some similar things with the python debugger but I've > honestly never used it that much (or worked on a project large enough I > needed to!) > > >> Also, with an IDE such as Pyscripter when calling a function a nice >> balloon hint appears showing you the number of parameters and their types. > > > It's not precisely the same thing, but you can fold multiple lines, which > allows you to have only the top line of a function showing. I find that > rather helpful, and ctrl-n autocompletes the function name. Then you can > mark the location with m then a-to-z (I use c as a mnemonic for 'current') > then move on top of the name and push * - that will find the next occurence > of the word, which is often the function declaration. I just hit "n" (next) > until I find it, if that's not the case. Then I type ` (the one over the > tilde) then c which takes me back to my 'current' location. If you really > wanted, though, you could also have horizontal split of the same file, and > you could probably write a macro that would move to that window/buffer and > find the function declaraition (so it would search for def under cursor>). I don't know precisely how the dropdown autocomplete menu > works but you could also probably edit your script to add parameters for the > function call just like an IDE. > > >> Coming from a Visual Studio background this is great, as I might be >> calling a function or method and I don't know off hand the values. Maybe >> someone could share how they go about programming a good size program with >> VIM as I would like to use it. Don't get me wrong for quick programs I will >> use VIM or notepad, but when it comes to building a OOP program I find >> Eclipse or Pyscripter much easier to use. > > > I suppose that's probably the case for a few people - and certainly the > reason those tools exist in the first place. If I were working on a quite > large program I might consider using an IDE, but in reality I'm probably > just as comfortable jumping around code to look for the information I need > as I would be using an IDE. > > HTH, > Wayne > > >> On Sun, Jun 14, 2009 at 12:54 AM, Eddie wrote: >> >>> I downloaded the previous version of PyScripter although couldn't get >>> it to work and after googling it, I downloaded Python Portable 1.1 >>> (Python 2.6.1 as most sites/books recommend this and not 3) which has >>> PySCripter included and this then works fine.Ii also downloaded Komod0 >>> 5.1 and after messing around with these, I think I prefer PyScripter >>> and will use that for the mean time. >>> >>> I'll also take a look at VIM as being able to use the same program for >>> PHP/CSS/HTML (and Basic if it supports it) as well as hopefully Python >>> (I've only just started learning it) would be an advantage. >>> >>> Thanks guys >>> Eddie >>> >>> 2009/6/14 Mike Hoy : >>> >> >>> >> >>> >> I really like using F5 to run my code, so you can put in your .vimrc >>> so >>> >> you don't have to type it, or just type it every time: >>> >> >>> >> map :!python % >>> >> >>> >> and every time you hit it will run your current script. >>> >> >>> > Thanks for that. It's even better than typing :!python % because it >>> doesn't >>> > spawn a shell separate from the Vim window. >>> > >>> > ___ >>> > Tutor maillist - Tutor@python.org >>> > http://mail.python.org/mailman/listinfo/tutor >>> > >>> > >>> ___ >>> Tutor maillist - Tutor@python.org >>> http://mail.python.org/mail
Re: [Tutor] Best Python Editor
On 6/15/2009 2:49 AM Tom Green said... Yes, vim or any text editor is suitable for Python, but I prefer having a nice GUI interface while coding. I mean the automobile replaced the horse and buggy, while they both get you to your destination I would still rather travel in a car. Anyone know of any studies comparing text based vs GUI IDE based code development? As I recall, programming productivity is measured in LOC/day and last time I noticed it seemed to be a very small number. I'm wondering if there might be documented benefits to migrating from my horse and buggy. :) Emile ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best Python Editor
On Sunday 14 June 2009 07:31:53 pm Michael Powe wrote: > > However, I will say that while following this thread, it occurred to > me that the one feature that VS and even the VBA editor in MS Office > has, is the ability to pop you into the debugger on error. This > feature is so useful that it surprises me nobody else seems to do it. > Most often, simply the ability to jump to the error line is provided > and I suppose that must be generally acceptable. > > Thanks. Wing does. When error occurs it stops on the line and the programmer is working in the debugger. -- John Fabiani ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best Python Editor
Back when I used Windows I used this: http://www.crimsoneditor.com/ I think its not being developed anymore, but it is a great editor/IDE that supports many languages. -- Michael Connors ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best Python Editor
I second Tom Green, when i started off with Python i mainly used Pyscripter on Windows and its excellent. On Sat, Jun 13, 2009 at 1:48 PM, Tom Green wrote: > For Windows check out PyScripter. Its IDE is similar to Borland Delphi and > I find it very easy to use. Whatever works for you would be "best" for > you. PyScripter is FREE and I would highly recommend it for people who are > new to Python or people with programming experience that are used to > programming in a IDE. > > Regards, > T. Green > > > > On Sat, Jun 13, 2009 at 6:52 AM, Dave Angel wrote: > >> Eddie wrote: >> >> Hi guys, >>> >>> What would you regard as the best free Python editor to use on Windows >>> for a new guy? Searching Google i see that there is quite a few out >>> there and is "VIM" the best one to go with? >>> >>> Regards >>> Eddie >>> >>> >>> >> This is such a common question on the python forums it ought to be in a >> FAQ, and maybe it is. >> >> VI and EMACS are the two "standard" Unix editors, going back decades. >> Somebody used to the flexibility of either of those two, who is now stuck >> on Windows, would naturally not want to give up any of the "customizability" >> of these. And people have posted macros for each to automate some of the >> things you'd like for Python, such as auto-indent. VIM is an editor in that >> heritage. >> >> Somebody who's used Windows for 20 years, however, might expect that >> Ctrl-S, Ctrl-F4, Alt-F4, etc. have standard meanings. So they might be more >> comfortable in an editor that starts with the Windows interface, and builds >> on it. I use metapad for many things, though not for Python. Others use >> Notepad++. >> >> Next question is whether you want an IDE. The ability to single-step in >> the debugger, locate and fix a problem in source, and start again, in a >> single environment is appealing. When I have a stack trace showing in the >> debugger, I can use the debugger to locate the source at any level of that >> stack without having to explicitly load the file and jump to the specified >> line number. And no risk that the same file is already loaded into some >> other editor and I'm going to lose changes if some are made one place and >> some another. And of course, it's nice to have a locals window, a globals >> window, a watch window, ... >> >> People that do not like an IDE cite the advantage of using a single editor >> for several programming languages, for word processing, and for web design. >> If such an editor is highly programmable, that would seem very good as >> well. >> >> So then it comes down to opinion. I use the (not-free) Komodo IDE. There >> is a free Komodo-Edit with most of the same features, but I really don't >> know what subset it includes. It is programmable with many canned add-ins, >> or you can customize it yourself with recorded macros and with scripts in >> Python or (I think) Javascript. Its addin technology is related somehow to >> Firefox, and I think it used a lot of the Mozilla code in its engine. The >> default UI is very familiar to people with Windows experience, though I >> don't know how it works on Mac and Linux >> >> http://www.activestate.com/komodo/Komodo IDE >> http://www.activestate.com/komodo_edit/ opensource Komodo Edit >> http://www.activestate.com/komodo_edit/comparison/comparison between >> the two >> >> >> >> >> ___ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Lloyd Dube ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Audio Framework for Python
On Sun, Jun 14, 2009 at 4:04 PM, Tycho Andersen wrote: > All: > > I'm interested in writing a simple media player in python. I've been > poking around on the internet for a framework that can play the common > audio formats (mp3, flac, ogg, etc.), but I haven't found one that I > liked a whole lot. > > PyMedia looks promising, but I've been struggling to build it on an > x64 architecture. Does anyone have any suggestions? Is there a PyMedia mailing list? You will probably get better answers there for build problems. You might also look at http://www.moovida.com/ Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Audio Framework for Python
All: I'm interested in writing a simple media player in python. I've been poking around on the internet for a framework that can play the common audio formats (mp3, flac, ogg, etc.), but I haven't found one that I liked a whole lot. PyMedia looks promising, but I've been struggling to build it on an x64 architecture. Does anyone have any suggestions? TIA! Tycho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Best Python Editor
This has been a great discussion and when I first entered college I was required to take Pascal. At that time we used Turbo Pascal IDE--if you want to call it an IDE. As with anything technology advances and we have new tools for the job and I became spoiled once Visual Studio hit the market. I really can't see doing any large project without a full blown IDE. Yes, vim or any text editor is suitable for Python, but I prefer having a nice GUI interface while coding. I mean the automobile replaced the horse and buggy, while they both get you to your destination I would still rather travel in a car. Regards, T.Green On Mon, Jun 15, 2009 at 2:00 AM, Lie Ryan wrote: > Michael Powe wrote: > > > It's good to see so much common sense prevailing on this topic. > > It's good that this newsgroup is not as prevalent to being flamed. In > certain other newsgroup, even (an honest and naive) mentioning of > preferred editor would turn the thread into World War E. > > > An > > IDE such as eclipse or VS really only becomes a necessity for > > productivity when (a) you are dealing with multiple code files and > > proper compilation and linking and so forth becomes complicated; or > > People that write in text editors often uses makefiles to handle that. > However, in python, there is nothing much to be done with multiple file > handling. Python's import mechanism just works like magic... > > > Most often, simply the ability to jump to the error line is provided > > and I suppose that must be generally acceptable. > > vim does. > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need a solution.
"spir" wrote Actually, it seems that only in the scientific field values are everywhere top-level things. Values _are_ the kind of things maths manipulate. Right? Thats an interesting observation that had not occured to me but I think you are right. What is interesting to me is that when I'm doing "pure" science/math type programmes I tend to adopt a functional style rather than an OO style. Functional programming just seems to suit the nature of math/science type problems for me. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need a solution.
Le Sat, 13 Jun 2009 13:55:58 +0100, "Alan Gauld" s'exprima ainsi: > I think that you have a valid point but that "pure value" objects > occur far less often than you might think. I always treat a value > object as a sign that I've probably put some processing code > in the wrong place! Only when I've checked and convinced > myself I'm wrong would I proceed. > > For example, what do we do with the values? > Do we print them? Then maybe we should have a __str__ method? > Do we save them in a file? Then maybe we need a save() method? > Do we do some calculations? Maybe we should have a calculate() method? > Do we draw them... well, I'm sure you get the idea :-) Yes, I guess I understand what you mean. This is indeed a valid question as far as you consider these 'values' as top-level objects. What are there for, then, if obviously one cannot do much with them? Actually, it seems that only in the scientific field values are everywhere top-level things. Values _are_ the kind of things maths manipulate. Right? But in all other programming things, values are: attributes of higher level objects. Usually, top-level objects are "real" objects. Values determine, or specify them. Among the so-called 'data' attribute, there are values on one side that tell us information about the object, and sub-objects (think: components) on the other side. This is my point of view. It works for me; I don't mean it's better than any other one. Below, V means value, C means component. point position V color V console screen C keyboard C mouse C machine speed V power v engine C mandrill C Well, artificial examples are just this... still, "I'm sure you get the idea :-)" Denis -- la vita e estrany ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor