From eromijn at solidlinks.nl Sun Mar 1 12:43:43 2015 From: eromijn at solidlinks.nl (Erik Romijn) Date: Sun, 1 Mar 2015 12:43:43 +0100 Subject: [python-nl] Dutch Django Sprint 2015 In-Reply-To: <6663E7E1-1896-4842-89DA-789B32C789E8@solidlinks.nl> References: <6663E7E1-1896-4842-89DA-789B32C789E8@solidlinks.nl> Message-ID: <94EB311A-36BD-4FD2-B238-23F416AEBAFB@solidlinks.nl> Hello all, Reminder: next weekend is the Dutch Django sprint 2015 in Amsterdam. There are still places available, sign up on http://www.meetup.com/dutch-django-assocation/events/220368460/ Core developer Daniele Procida will also be doing his famed ?Don?t be afraid to commit? workshop, which will take people new to contributing to Django through the entire contribution process with real tickets. So please don?t hesitate to join even if you do have some experience with Django, but you?ve never contributed to Django before. Erik > On 10 Feb 2015, at 13:07, Erik Romijn wrote: > > Dear all, > > The Dutch Django Association is organising another Django Sprint! Everyone can join to make the Django framework even better! During the 2 sprint days, we will contribute to Django together. Triage or solve tickets, easy or hard ones, improve existing patches, make the documentation better, take your pick! > > This year's sprint will be on March 7 and 8 (weekend) and will be hosted by DashCare in their offices at B. Amsterdam. > > For more details and to sign up: http://www.meetup.com/dutch-django-assocation/events/220368460/ > More details on the sprint will follow as the date approaches. Follow @DutchDjango for updates. > > Erik Romijn > _______________________________________________ > Python-nl mailing list > Python-nl at python.org > https://mail.python.org/mailman/listinfo/python-nl -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: Message signed with OpenPGP using GPGMail URL: From vm at klankschap.nl Sat Mar 7 13:32:18 2015 From: vm at klankschap.nl (Floris van Manen) Date: Sat, 7 Mar 2015 13:32:18 +0100 Subject: [python-nl] random.jumpahead() In-Reply-To: <54C62718.3040600@fox-it.com> References: <7E99689E469D7146957C833FE12C6E7E2C0E092C@exchcbv-fl01.summacollege.nl> <7E99689E469D7146957C833FE12C6E7E2C0E09AF@exchcbv-fl01.summacollege.nl> <54BD1E26.9020901@fox-it.com> <54C62718.3040600@fox-it.com> Message-ID: <8B22CCC1-B3CC-418B-A010-9589231D7F86@klankschap.nl> Zou iemand ook eens kunnen kijken wat of dat er uit de random generatoren komt van zowel de standaard python distributie als bijv pypy? Ik krijg verschillende resultaten wanneer ik de random.jumpahead() functie gebruik. .Floris import random random.seed(12345) for i in xrange(10): print random.random() print randomState = random.getstate() for i in xrange(10): random.setstate(randomState) random.jumpahead(1) randomState = random.getstate() print random.random() ''' standard python: 0.416619872545 0.0101691694571 0.825206509254 0.2986398552 0.368411689488 0.193661349045 0.566008168729 0.161687823929 0.124266884284 0.43293626801 jumpahead() 0.94861718596 0.466389725591 0.440309106388 0.756595610966 0.329954203719 0.207243180479 0.982769966933 0.856141036147 0.746277878413 0.304000958341 pypy 0.416619872545 0.0101691694571 0.825206509254 0.2986398552 0.368411689488 0.193661349045 0.566008168729 0.161687823929 0.124266884284 0.43293626801 jumpahead() 0.41362858709 0.482594587067 0.363386428038 0.0122210322735 0.218894401377 0.786381037234 0.535611315209 0.545681381301 0.0153701629836 0.136216130724 ''' -------------- next part -------------- An HTML attachment was scrubbed... URL: From marcs at ziggo.nl Tue Mar 17 00:32:45 2015 From: marcs at ziggo.nl (Marc Stevens) Date: Tue, 17 Mar 2015 00:32:45 +0100 Subject: [python-nl] Eenvoudig beginners vraagje Message-ID: <759DDDB4-4BF3-45B3-86FE-F0BFA64EDDFE@ziggo.nl> Hoe onderschep ik een error melding als bij de invoer van een getal als een letter word ingegeven? Bijv: import math x=int(raw_input(?geef een getal in?)) wortel=math.sqrt(x) print x ------------- volgend deel ------------ Een HTML-bijlage is gescrubt... URL: From dorian.hoxha at gmail.com Tue Mar 17 01:09:31 2015 From: dorian.hoxha at gmail.com (Dorian Hoxha) Date: Tue, 17 Mar 2015 01:09:31 +0100 Subject: [python-nl] Eenvoudig beginners vraagje In-Reply-To: <759DDDB4-4BF3-45B3-86FE-F0BFA64EDDFE@ziggo.nl> References: <759DDDB4-4BF3-45B3-86FE-F0BFA64EDDFE@ziggo.nl> Message-ID: Hi Marc. Try this: while True: try: x = int(raw_input("give a number:") break except (ValueError, KeyError): print "x must be a number, while you entered %s" % x math.sqrt root = (x) print x See docs to learn more: https://docs.python.org/2/library/exceptions.html (python2.7) 2015-03-17 0:32 GMT+01:00 Marc Stevens : > Hoe onderschep ik een error melding als bij de invoer van een getal als > een letter word ingegeven? > Bijv: > > > import math > > x=int(raw_input(?geef een getal in?)) > wortel=math.sqrt(x) > print x > > _______________________________________________ > Python-nl mailing list > Python-nl at python.org > https://mail.python.org/mailman/listinfo/python-nl > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dorian.hoxha at gmail.com Tue Mar 17 01:10:53 2015 From: dorian.hoxha at gmail.com (Dorian Hoxha) Date: Tue, 17 Mar 2015 01:10:53 +0100 Subject: [python-nl] Eenvoudig beginners vraagje In-Reply-To: References: <759DDDB4-4BF3-45B3-86FE-F0BFA64EDDFE@ziggo.nl> Message-ID: This link is better: https://docs.python.org/2/tutorial/errors.html On Tue, Mar 17, 2015 at 1:09 AM, Dorian Hoxha wrote: > Hi Marc. Try this: > > while True: > try: > x = int(raw_input("give a number:") > break > except (ValueError, KeyError): > print "x must be a number, while you entered %s" % x > math.sqrt root = (x) > print x > > See docs to learn more: https://docs.python.org/2/library/exceptions.html > (python2.7) > > > > 2015-03-17 0:32 GMT+01:00 Marc Stevens : > >> Hoe onderschep ik een error melding als bij de invoer van een getal als >> een letter word ingegeven? >> Bijv: >> >> >> import math >> >> x=int(raw_input(?geef een getal in?)) >> wortel=math.sqrt(x) >> print x >> >> _______________________________________________ >> Python-nl mailing list >> Python-nl at python.org >> https://mail.python.org/mailman/listinfo/python-nl >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From python-nl at warddr.eu Tue Mar 17 05:11:12 2015 From: python-nl at warddr.eu (Ward De Ridder) Date: Tue, 17 Mar 2015 05:11:12 +0100 Subject: [python-nl] Eenvoudig beginners vraagje In-Reply-To: References: <759DDDB4-4BF3-45B3-86FE-F0BFA64EDDFE@ziggo.nl> Message-ID: <20150317041112.GA1465@ks3261884.kimsufi.com> Hoewel dit antwoord met try en catch zeker zal werken, lijkt dit me in dit geval niet de beste oplossing. Er bestaat in python een isdigit functie [1], die je kan gebruiken als test of een string enkel uit getallen bestaat. Aan de hand daarvan kan je kijken of je input valid is of niet. Voor complexere inputvalidatie is er altijd nog de regular expression, maar dat is een beetje moeilijker [2]. Just my 2 cents Ward [1] http://www.tutorialspoint.com/python/string_isdigit.htm [2] https://docs.python.org/2/library/re.html nog een beetje code: x=raw_input("geef een getal in: ") if x.isdigit(): wortel=math.sqrt(int(x)) print wortel else: print "invalid input" On Tue, Mar 17, 2015 at 01:10:53AM +0100, Dorian Hoxha wrote: > This link is better: > https://docs.python.org/2/tutorial/errors.html > > > On Tue, Mar 17, 2015 at 1:09 AM, Dorian Hoxha > wrote: > > > Hi Marc. Try this: > > > > while True: > > try: > > x = int(raw_input("give a number:") > > break > > except (ValueError, KeyError): > > print "x must be a number, while you entered %s" % x > > math.sqrt root = (x) > > print x > > > > See docs to learn more: https://docs.python.org/2/library/exceptions.html > > (python2.7) > > > > > > > > 2015-03-17 0:32 GMT+01:00 Marc Stevens : > > > >> Hoe onderschep ik een error melding als bij de invoer van een getal als > >> een letter word ingegeven? > >> Bijv: > >> > >> > >> import math > >> > >> x=int(raw_input(?geef een getal in?)) > >> wortel=math.sqrt(x) > >> print x > >> > >> _______________________________________________ > >> Python-nl mailing list > >> Python-nl at python.org > >> https://mail.python.org/mailman/listinfo/python-nl > >> > >> > > > _______________________________________________ > Python-nl mailing list > Python-nl at python.org > https://mail.python.org/mailman/listinfo/python-nl From vm at klankschap.nl Tue Mar 17 10:51:22 2015 From: vm at klankschap.nl (Floris van Manen) Date: Tue, 17 Mar 2015 10:51:22 +0100 Subject: [python-nl] Eenvoudig beginners vraagje In-Reply-To: References: <759DDDB4-4BF3-45B3-86FE-F0BFA64EDDFE@ziggo.nl> Message-ID: > On 17 Mar 2015, at 01:09, Dorian Hoxha wrote: > > while True: > try: > x = int(raw_input("give a number:") > break > except (ValueError, KeyError): > print "x must be a number, while you entered %s" % x > math.sqrt root = (x) > print x Er lopen wat dingen door elkaar. Je vraagt een getal, maar eigenlijk wil je een integer. Als je iets niet-integer invult, zal x geen waarde hebben, die kun je later dus ook niet printen. Bovendien moet je nadat je een fout hebt gemeld niet alsnog die ongedefinieerde waarde gebruiken voor de berekening van de sqrt. while True: try: x = raw_input(?Give an integer number:? print math.sqrt( int(x) ) except (ValueError, KeyError): print "You entered a non-integer %s" % x -------------- next part -------------- An HTML attachment was scrubbed... URL: From motoom at xs4all.nl Tue Mar 17 11:39:19 2015 From: motoom at xs4all.nl (Michiel Overtoom) Date: Tue, 17 Mar 2015 11:39:19 +0100 Subject: [python-nl] Eenvoudig beginners vraagje In-Reply-To: <20150317041112.GA1465@ks3261884.kimsufi.com> References: <759DDDB4-4BF3-45B3-86FE-F0BFA64EDDFE@ziggo.nl> <20150317041112.GA1465@ks3261884.kimsufi.com> Message-ID: <7BC8B711-3C1F-4BCB-AAC5-13701AE1FFD6@xs4all.nl> On Mar 17, 2015, at 05:11, Ward De Ridder wrote: > Hoewel dit antwoord met try en catch zeker zal werken, lijkt dit me in dit geval niet de beste oplossing. > Er bestaat in python een isdigit functie [1], die je kan gebruiken als test of een string enkel uit getallen bestaat. Aan de hand daarvan kan je kijken of je input valid is of niet. Pythonischer is het om ervan uit te gaan dat de input wel goed zal zijn en alle validatie aan int() over te laten in dit geval. Scheelt een hoop code. Vang echter wel een eventuele exception af, mocht het mis gaan. "It is easier to obtain forgiveness than permission." Groets, -- "You can't actually make computers run faster, you can only make them do less." - RiderOfGiraffes