On Sun, Oct 16, 2011 at 3:44 PM, <tutor-requ...@python.org> wrote: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to > tutor-requ...@python.org > > You can reach the person managing the list at > tutor-ow...@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tutor digest..." > > > Today's Topics: > > 1. Re: Bounded Linear Search (tog...@users.sourceforge.net) > 2. Re: Can I set LD_LIBRARY_PATH within a .py file? > (Albert-Jan Roskam) > 3. Re: Socket and Ports (Jacob Bender) > 4. 6 random numbers (ADRIAN KELLY) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 16 Oct 2011 19:04:41 +0200 > From: tog...@users.sourceforge.net > To: tutor@python.org > Subject: Re: [Tutor] Bounded Linear Search > Message-ID: <j7f2ra$7dp$1...@dough.gmane.org> > Content-Type: text/plain; charset="ISO-8859-1" > > Peter Otten wrote: > > > To verify that the algorithm is correct now you could walk through > > increasingly more complex sample data, which may be possible in this > case, > > but rarely ever for an entire script. Instead the common approach is to > > pick a few samples along with the expected outcomes, feed them to your > > function and verify that they give the expected output > > > > def unique_values(items): > > ... > > return uniq > > > > assert unique_values([42, 42]) == [42] > > assert unique_values([1, 2, 3, 2]) == [1, 2, 3] > > Thanks for the tip and where I was failing to see > > Togan > > > > ------------------------------ > > Message: 2 > Date: Sun, 16 Oct 2011 11:25:44 -0700 (PDT) > From: Albert-Jan Roskam <fo...@yahoo.com> > To: Hugo Arts <hugo.yo...@gmail.com> > Cc: Python Mailing List <tutor@python.org> > Subject: Re: [Tutor] Can I set LD_LIBRARY_PATH within a .py file? > Message-ID: > <1318789544.84883.yahoomail...@web110709.mail.gq1.yahoo.com> > Content-Type: text/plain; charset="iso-8859-1" > > Hi Hugo, > ? > You are absolutely right. Thank you! It took me a lot of reading and > tinkering to find out that typing the following in the terminal works: > export LD_LIBRARY_PATH=\path\to\the\lib > python main.py # contains import to my program + calls to the functions in > it. > ? > I find it strange though, that ctypes.CDLL() does not accept library names > *with the full path*. In Linux, you could do it, but it seems that all the > dependencies of the libary in that non-standard location are looked for ONLY > in that non-standard location. > > Cheers!! > Albert-Jan > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > All right, but apart from the sanitation, the medicine, education, wine, > public order, irrigation, roads, a fresh water system, and public health, > what have the Romans ever done for us? > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > From: Hugo Arts <hugo.yo...@gmail.com> > >To: Albert-Jan Roskam <fo...@yahoo.com> > >Cc: Python Mailing List <tutor@python.org> > >Sent: Sunday, October 16, 2011 1:22 AM > >Subject: Re: [Tutor] Can I set LD_LIBRARY_PATH within a .py file? > > > >On Sat, Oct 15, 2011 at 9:51 PM, Albert-Jan Roskam <fo...@yahoo.com> > wrote: > >> Hello, > >> Can I set the LD_LIBRARY_PATH environment variable (on-the-fly) within a > .py > >> file? > >> I would like to use an .so-file that lives in a non-standard location. > >> > >> This does not work: > >> try: > >> ?? os.environ["LD_LIBRARY_PATH"]? += (":" + path) > >> except KeyError: > >> ?? os.environ["LD_LIBRARY_PATH"] = path > >> Currently, I can only run the program in the terminal: > >> export LD_LIBRARY_PATH=/home/dude/Desktop/test > >> python /home/dude/Desktop/testLoadLibLinux.py > >> This works (yaaayy!), but I'd like to run the .py file directly. > >> Is this possible? I also don't? like the fact that I can't test the .py > file > >> in Idle. > >> Perhaps a complicating factor is a bug in LD_LIBRARY_PATH > >> in Linux Ubuntu 10 (the version I'm using): > >> https://bugs.edge.launchpad.net/ubuntu/+source/xorg/+bug/366728 > >> https://bugs.launchpad.net/ubuntu/+source/xorg/+bug/366728/comments/21 > >> solution: > >> sudo gedit /etc/X11/Xsession.options > >> (change "use-ssh-agent" into "no-use-ssh-agent") > >> > >> Thank you in advance for your thoughts! > >> > >> Cheers!! > >> Albert-Jan > >> > > > >Alright, I'm not going to pretend to be an expert on this one, a bit > >of this is speculation and inference from what I know about dynamic > >linking. In short, I don't think you can modify LD_LIBRARY_PATH on the > >fly and have it actually work. The reason for this is that the linker > >runs and finds all the libraries *before* the python process actually > >starts. So by the time you go and modify the environment, all > >libraries have already been linked, and your modified variable is > >never even read by the linker. > > > >So the best you can do is write a tiny wrapper to set LD_LIBRARY_PATH > >and then run your actual script through it. Or you could set the > >environment variable and then fork(), I suppose, since the child will > >inherit the modified environment. But the wrapper is your simplest > >option. > > > >HTH, > >Hugo > > > > > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20111016/792dc422/attachment-0001.html > > > > ------------------------------ > > Message: 3 > Date: Sun, 16 Oct 2011 15:00:04 -0400 > From: Jacob Bender <benderjaco...@gmail.com> > To: Hugo Arts <hugo.yo...@gmail.com> > Cc: Python Tutor <tutor@python.org>, bob gailer <bgai...@gmail.com> > Subject: Re: [Tutor] Socket and Ports > Message-ID: > <cacub+d0y_juphufxgnd9qtgystzcjegt73yuxwtslchykly...@mail.gmail.com > > > Content-Type: text/plain; charset="iso-8859-1" > > Thank you, and I'm not planning on executing any data I receive from > anybody. So I should be pretty safe... > > On Sun, Oct 16, 2011 at 10:48 AM, Hugo Arts <hugo.yo...@gmail.com> wrote: > > > On Sun, Oct 16, 2011 at 4:20 PM, bob gailer <bgai...@gmail.com> wrote: > > > On 10/16/2011 8:28 AM, Jacob Bender wrote: > > >> > > >> Dear Tutors, > > >> > > >> I've been having an issue with socket. I wanted to use it for > > >> transmitting strings over the Internet. > > > > > > That's good, because strings is all you can transmit. > > > > > >> The problem is that my friend insists that allowing python to transmit > > and > > >> receive information via an Internet port is a bad idea. He claimed > that > > I > > >> could(and probably would) receive information that wouldn't > necessarily > > do > > >> my computer any good(in a nutshell). > > > > > > I am not the expert on this issue. My view: > > > > > > once you establish a socket connection then you wait to receive data. > All > > > the socket software (Python or other) does is receive a string. What > you > > do > > > with it is up to you. If you apply eval or exec to it than anything > could > > > happen. No one can IMHO cause any action via socket. > > > > > > > vulnerabilities in the lower level stack notwithstanding, of course. > > But in essence, using sockets in python is not any more dangerous than > > using sockets in any other language. You have to watch what you're > > doing and be careful with the data you receive, but as long as you do > > that you shouldn't be in any danger. > > > > Hugo > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20111016/a2d911bb/attachment-0001.html > > > > ------------------------------ > > >Message: 4 > >Date: Sun, 16 Oct 2011 19:43:06 +0000 > >From: ADRIAN KELLY <kellyadr...@hotmail.com> > >To: <tutor@python.org> > >Subject: [Tutor] 6 random numbers > >Message-ID: <dub103-w54ebdc0822317f0df7e1bfa9...@phx.gbl> > >Content-Type: text/plain; charset="iso-8859-1" > > > > > >hello all, > >anyone know how i would go about printing 6 random numbers, i know i could > copy and paste 6 times (which would work) but i was >thinking about a while > loop, ie. while lottery_numbers.count is <7. > >Is it possible to code this? is it possible to count random variables? i > am trying to keep the program as simple as possible, cheers > > > >any help would be welcome, > > > >import random > >lottery_numbers=random.randrange(1,42) > >print lottery_numbers >
In fact it is. I notice, however, that you include 2 arguments in the randrange method, which only takes 1 argument. To do this, this code should work: times = 1 while times < 7: import random lottery_numbers=random.randrange(1, 42) print lottery_numbers times+=1 > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20111016/4c9e4d5c/attachment.html > > > > ------------------------------ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > End of Tutor Digest, Vol 92, Issue 77 > ************************************* >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor