Re: [Tutor] Structured files?
2011/6/2 Válas Péter : > Good morning, > > I can create files and write strings/unicodes. > Is it possible to write a list, a dictionary or an object or anything into a > file? Or do I have to transform them to strings? Yes you can. I guess the question is how you want the information to be structured. IMHO, everything in Python can be "string-lized". > > Péter > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Regards, Simon Yan http://www.google.com/profiles/simonyanix ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Structured files?
2011/6/2 Válas Péter : > > > 2011. június 2. 9:29 Simon Yan írta, : >> >> Yes you can. >> I guess the question is how you want the information to be structured. >> IMHO, everything in Python can be "string-lized". >> > What is the syntax then? I have Windows XP. The code is: > f=open("xxx.dat","w") > f.write("fff") > d={'one':1, 2:'two'} > f.write(d) > f.close() Try this: f=open("xxx.dat","w") f.write("fff") d={'one':1, 2:'two'} f.write(str(d)) f.close() > > Python 2.5 message: > TypeError: argument 1 must be string or read-only character buffer, not dict > Python 3.1 message: > TypeError: must be str, not dict > > Modified code: > f=open("xxx.dat","wb") The others remain as above, just I wrote wb. > Python 2.5 message: > TypeError: argument 1 must be string or read-only buffer, not dict > Python 3.1 message: > f.write("fff") > TypeError: must be bytes or buffer, not str > This won't write even a string. > > I read something about a pack function, is that the key? > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Regards, Simon Yan http://www.google.com/profiles/simonyanix ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Open source projects build using Python
Dear All, I've been working on Python for a while but haven't got any chance to work on any projects yet. I've spent most of my time reading codes. (I know this is bad when you want to actually learn a programming language) It would be a better idea that I can start to join an open source projects that is built with Python instead of starting up a new project. (I have no good ideas at this moment anyways) I know there are lots of projects which I can work on, but just wanted to hear some recommendations what are the ones good for a long time Python "reader"? -- Regards, YeeYaa (Simon Yan) http://simonyan.fedorapeople.org/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Open source projects build using Python
On Wed, Apr 4, 2012 at 1:41 AM, Mark Lawrence wrote: > On 03/04/2012 18:22, Alan Gauld wrote: > >> On 03/04/12 15:45, Simon Yan wrote: >> >> Do a search on SourceForge and Google and see what comes up. >> >> > Hopefully codeplex.com amongst others. > > Hey Guys, Thank you all for the good suggestions. I'm gonna make some research and look around to find the sweet spot. > -- > Cheers. > > Mark Lawrence. > > > __**_ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> > -- Regards, YeeYaa (Simon Yan) http://simonyan.fedorapeople.org/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to exit this loop in the interpreter
On Thu, May 3, 2012 at 9:57 PM, wrote: > Hello all, > > I have encountered the following scenario. > Here is the code - on IDLE on Windows XP. > > *>>> while True: > try: > number = raw_input("enter number - ") > print number * number > except ValueError: > print "invalid number" > except: > print "unspecified exception" > else: > print "other conditions" > > > enter number - 3 > unspecified exception > * > What I noticed is that no matter, what input I give, I cannot exit this > loop. I have tried control-C, control-D etc. all the keys. So how can I > exit from this loop? > If you simply want to stop after an exception was caught, you can insert "break" after each print line. Like below: >>> while True: try: number = raw_input("enter number - ") print number * number except ValueError: print "invalid number" break except: print "unspecified exception" break else: print "other conditions" break > > Thanks and Regards, > Sumod > > -- > http://spawgi.wordpress.com > We can do it and do it better. > > ___________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Regards, YeeYaa (Simon Yan) http://simonyan.fedorapeople.org/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] First Python Test
On Fri, Feb 1, 2013 at 9:18 PM, Dustin Guerri wrote: > Thanks for replying, Simon. I have no particular reason to use Xcode - > what would you recommend instead ? > I would recommend start off from a simple text editor that has basic syntax highlighting features. There are a number of options out there. TextMate is a good choice, a little pricy. VIM, if you are a terminal guy Even Python IDLE is a good choice you wanted to edit just a few simple .py files. I would suggest give it a look in the Mac App Store and you will find a few other good ones too. > > > *Dustin Guerri* > Mobile : (+ 34) 625 857 967 > dustingue...@gmail.com > [image: > LinkedIn]<http://www.linkedin.com/profile/view?id=16395850&trk=tab_pro> > > Contact me: [image: Google Talk] dustinguerri [image: Skype] dustinguerri > Get a signature like this. > <http://r1.wisestamp.com/r/landing?promo=20&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_20> > CLICK > HERE.<http://r1.wisestamp.com/r/landing?promo=20&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_20> > > > > On 1 February 2013 13:05, Simon Yan wrote: > >> >> >> >> On Thu, Jan 17, 2013 at 6:47 AM, Dustin Guerri wrote: >> >>> Hi there, >>> >>> I'm trying to create a plain text file called "hello.py" with the >>> following text : >>> >>> print('hello world') >>> raw_input('Press any key to continue') >>> >>> I'd then like to run this program with Python Launcher on a Mac. >>> >>> I'd lke to use Xcode as my text editor. Once I have Xcode open, which >>> template should I use to input the text ? >>> >> I don't think there is a file type of Python that you can create from >> Xcode. >> Just curious, why would you want to use XCode as a Python editor? >> >> >>> >>> Thanks, >>> >>> *Dustin Guerri* >>> Mobile : (+ 34) 625 857 967 >>> dustingue...@gmail.com | www.vimeo.com/dustinguerri/pop >>> [image: >>> LinkedIn]<http://www.linkedin.com/profile/view?id=16395850&trk=tab_pro> >>> Contact me: [image: Google Talk] dustinguerri [image: Skype]dustinguerri >>> Get a signature like this. >>> <http://r1.wisestamp.com/r/landing?promo=20&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_20> >>> CLICK >>> HERE.<http://r1.wisestamp.com/r/landing?promo=20&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_20> >>> >>> >>> ___ >>> Tutor maillist - Tutor@python.org >>> To unsubscribe or change subscription options: >>> http://mail.python.org/mailman/listinfo/tutor >>> >>> >> >> >> -- >> Regards, >> YeeYaa (Simon Yan) >> >> http://simonyan.fedorapeople.org/ >> > > -- Regards, YeeYaa (Simon Yan) http://simonyan.fedorapeople.org/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] First Python Test
On Thu, Jan 17, 2013 at 6:47 AM, Dustin Guerri wrote: > Hi there, > > I'm trying to create a plain text file called "hello.py" with the > following text : > > print('hello world') > raw_input('Press any key to continue') > > I'd then like to run this program with Python Launcher on a Mac. > > I'd lke to use Xcode as my text editor. Once I have Xcode open, which > template should I use to input the text ? > I don't think there is a file type of Python that you can create from Xcode. Just curious, why would you want to use XCode as a Python editor? > > Thanks, > > *Dustin Guerri* > Mobile : (+ 34) 625 857 967 > dustingue...@gmail.com | www.vimeo.com/dustinguerri/pop > [image: > LinkedIn]<http://www.linkedin.com/profile/view?id=16395850&trk=tab_pro> > Contact me: [image: Google Talk] dustinguerri [image: Skype] dustinguerri > Get a signature like this. > <http://r1.wisestamp.com/r/landing?promo=20&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_20> > CLICK > HERE.<http://r1.wisestamp.com/r/landing?promo=20&dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_20> > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Regards, YeeYaa (Simon Yan) http://simonyan.fedorapeople.org/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] recursive function password check
On Wed, Feb 6, 2013 at 9:44 PM, Mara Kelly wrote: > Hi everyone, trying to write a program that has the user enter a password, > checks if it contains any vowels, and if it does prints ' It is false that > password(whatever the user enters) has no vowels,' and if it has no vowels > prints it is True that password has no vowels... > > Here is what I have so far... > def password(y): > vowels=["a","e","i","o"] > if y[0] in vowels: > return False > if len(y) ==0: > return True > elif(y[len(y)-1] != vowels): > return False > else: > return password(y[1:len(y)-1]) > x=input("Enter a password:") > print("It is", password(x),"that",x,"has no vowles") > > As of now it just asks for the password, and then prints 'It is False that > password(whatever was entered) has no vowles' for any word I enter. I think > maybe some of my if statement conditions may be being returned to the > function, but then not printing the appropriate one? Can anyone help? > Thanks! > It appears that the issue is from this: elif(y[len(y)-1] != vowels): This condition will be true because you are comparing a string with a list. Thus causing passwrod() returning False. > > _______ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Regards, YeeYaa (Simon Yan) http://simonyan.fedorapeople.org/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor