Re: refresing the edited python function
On 19/08/2013 10:55 AM, Sudheer Joseph wrote: I have been using ipython and ipython with qtconsole and working on a code with functions. Each time I make a modification in function I have to quit IPTHON console (in both with and with out qt console ) and reload the function freshly. If I need to see the changed I made in the function. I tried below options del function name import the module again by issuing "from xxx.py import yy" This doesn't re-import the module if xxx has already been imported. It simply rebinds xxx.yy to yy. import xxx.py This also doesn't re-import the module if it has already been imported. When you import a module, or a function from a module, a module object is created and stored in sys.modules. Any subsequent 'import ' calls will return a reference to that module object, and won't reload from file at all. You can easily verify this by creating a test module 'foo' with a single line of `print('loading foo')` and then trying this from the console: In [1]: import foo loading foo In [2]: del foo In [3]: import foo In [4]: Note that you only see 'loading foo' the first time you import the module. In order to have the module loaded again rather than returning the existing reference, you would use `reload(foo)`: In [5]: reload(foo) loading foo So: in order to be able to use functions from a re-loaded module, you should always refer to them via the module object, and not import them directly: >>> import xxx >>> xxx.yy() # original code # ...modify function `yy` in your source file >>> reload(xxx) >>> xxx.yy() # new code Or: you can reload the module and then rebind the functions: >>> from xxx import yy >>> yy() # original code # ...modify function `yy` in your source file >>> reload(xxx) >>> from xxx import yy >>> yy() # new code Hope this helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: default python os x
Ah, I see. Thank you! On 2013-08-20 05:39:56 +, Steven D'Aprano said: On Mon, 19 Aug 2013 22:24:46 +0200, Uwe Rangs wrote: My workflow at the moment is to set a link: mv python python_old ln -s /usr/local/bin/python3.2 python But is this a good idea? You should never change the system Python, since that runs the risk of breaking system tools that expect a particular version. If there are any system tools that run "python", they may break. Instead, set a personal alias. For example, in my ~/.bashrc file, I have the following: export PYTHONPATH="/home/steve/python/:/home/steve/python/utilities" export PYTHONSTARTUP=/home/steve/python/utilities/startup.py alias python=python2.7 alias python3=python3.3 alias python1.5='env -u PYTHONSTARTUP python1.5' alias python2.0='env -u PYTHONSTARTUP python2.0' alias python2.1='env -u PYTHONSTARTUP python2.1' alias python2.2='env -u PYTHONSTARTUP python2.2' alias python2.3='env -u PYTHONSTARTUP python2.3' alias python3.4="env -u PYTHONPATH ~/python/cpython/python" So, for me, and me alone, typing "python" refers to Python 2.7 instead of the system Python, which happens to be 2.4 on my server and 2.6 on my laptop. "python1.5" etc unsets the startup file environment variable, since my startup file assumes 2.4 or better. "python3.4" points to a local copy in my home directory. Otherwise, python3.3, python3.2, etc. work as expected. -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing variables non-deterministic?
Le mardi 20 août 2013 08:55:18 UTC+2, Antoon Pardon a écrit : > > > > > > > > > If you consider the implementation of sin and cos functions, they usually > > > reduce the argument modulo π to something in the first quadrant, and then > > > use symmetry to adjust the value. So changing the value of pi could, in > > > principle, change the implementation of sin, cos and tan. > > > > Yes there is this aspect, which is a fair point. > > > > -- > > Antoon Pardon - Not really, see my previous post. This is only a geometric interpretation, useless for calculation. Consequence of an implementation: common trick to use and/or define pi: >>> const_pi = 4 * atan(1) >>> const_pi 3.141592653589793 jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing variables non-deterministic?
Op 20-08-13 09:31, wxjmfa...@gmail.com schreef: > Le mardi 20 août 2013 08:55:18 UTC+2, Antoon Pardon a écrit : >> >>> >> > >> >> >> >>> If you consider the implementation of sin and cos functions, they usually >> >>> reduce the argument modulo π to something in the first quadrant, and then >> >>> use symmetry to adjust the value. So changing the value of pi could, in >> >>> principle, change the implementation of sin, cos and tan. >> >> >> >> Yes there is this aspect, which is a fair point. >> >> >> >> -- >> >> Antoon Pardon > > - > > Not really, see my previous post. This is only a geometric > interpretation, useless for calculation. No it is not. Steven is correct that if for example you want the value of sin(10), that in a typical implementation this will be reduced to calculating -sin(10 - 3π). This for two reasons. It is faster to first reduce the argument within the first kwadrant, do the series expansion and then correct for sign than to expand the series with the original argument and it is more acurate because first reducing asures that all terms will stay relatively small while using the original arguments can intrduce some large terms that will have to cancel each other but that will reduce acuracy. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Beginer of python,could I write a personal blog using cherrtpy?
I'v seen 《byte of python》《head first python》~ Could I read cherrypy's offical document and then I write a personal blog using cherrypy? -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? (syntax for functools.partial-like functionality)
On 20 Aug 2013 07:22, "Steven D'Aprano" wrote: > > On Tue, 20 Aug 2013 00:49:16 +0100, Fábio Santos wrote: > > > I had an idea for a handy syntax which I thought of while designing a > > language for fun. This would be a syntax for creating, from a function, > > a function which is just like it but with some parameters pre-filled. > > The usage is much like functools.partials, and my proposed syntax is > > like this: > > > > def spam(a, b, c): > > ... > > > > spam_with_defaults = spam{1, 2} > > > Handy it may be, but why is this usage important enough to deserve new > syntax? The barrier to entry for new syntax is very high. For example, > Enums are a common, and standard, feature in many programming languages. > Enums will be introduced to Python in 3.4, but even they don't get > special syntax. > > > > -- > Steven I do realize that syntax in python is practically written in stone, but I have seen changes come by if they have good reasons. For example, keyword-only argument syntax was added. I suggested this because I thought it would be the most practical way to create partial functions. Lambda is too verbose and kind of ugly, and its purpose is not to create partials, functools.partial does not allow argument "insertion" (the star thing) nor unpacking. Maybe I saw this as common usage but it is really a special case. I see myself needing this kind of advanced partials _very_ often. -- http://mail.python.org/mailman/listinfo/python-list
Replace blanks with letter
I'm trying to replace the blank(_) with the letter typed in by the user, in the appropriate blank(_) spot where the letter should be (where is in the letters list). letters='abcdefg' blanks='_ '*len(letters) print('type letter from a to g') print(blanks) input1=input() for i in range(len(letters)): if letters[i] in input1: blanks = blanks[:i] + letters[i] + blanks[i+1:] What am I doing wrong in this code? Thanks Eric -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginer of python,could I write a personal blog using cherrtpy?
On Tue, 20 Aug 2013 01:14:27 -0700, leafonsword wrote: > I'v seen 《byte of python》《head first python》~ Could I read cherrypy's > offical document and then I write a personal blog using cherrypy? It is certainly possible to create a blog using CherryPy. http://docs.cherrypy.org/stable/appendix/success.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? (syntax for functools.partial-like functionality)
On Tue, Aug 20, 2013 at 2:28 AM, Fábio Santos wrote: > I do realize that syntax in python is practically written in stone, but I > have seen changes come by if they have good reasons. For example, > keyword-only argument syntax was added. > > I suggested this because I thought it would be the most practical way to > create partial functions. Lambda is too verbose and kind of ugly, and its > purpose is not to create partials, functools.partial does not allow argument > "insertion" (the star thing) nor unpacking. I think that if you're doing argument insertion, then your partial application is overly complex in the way that it modifies the original argspec. You should be looking at it as a new function, not as a partial application that prevents you from easily supplying a doc string for it. If you want to specify an arbitrary combination of arguments in your partial application, you can already do that using keyword arguments. The exception would be if the function being partially applied takes a *args argument and you want to specify some of those arguments using partial without specifying earlier arguments. That seems like an abuse of partial application to me. Tuple unpacking in function signatures was a feature in Python 2, and it was intentionally removed in Python 3, so this is very unlikely to happen. See PEP 3113. Besides which, the syntax you suggest for this is unintuitive. spam_unpacking = spam{1, (*, *)} To me, this reads that spam_unpacking will take two positional arguments that will be packed into the second argument sent to spam (b), and that the third argument to spam (c) is not specified here. I don't think that's what you intended. -- http://mail.python.org/mailman/listinfo/python-list
Re: Replace blanks with letter
On 20 Aug 2013 09:42, wrote: > > I'm trying to replace the blank(_) with the letter typed in by the user, in the appropriate blank(_) spot where the letter should be (where is in the letters list). > > letters='abcdefg' > blanks='_ '*len(letters) > print('type letter from a to g') > print(blanks) > input1=input() > for i in range(len(letters)): > if letters[i] in input1: > blanks = blanks[:i] + letters[i] + blanks[i+1:] > > > What am I doing wrong in this code? > > Thanks > Eric First, don't use range(len(iterable)). It's bad practise, and you will have to use iterable[i] all the time. Try for i, letter in enumerate(letters): If you are modifying a string in-place, you could change it into a list, then back. blankslst = list(blanks) ... blankslst[i] = letters[i] # or 'letter' if you used enumerate() ... blanks = ''.join(blankslst) Now, why are you not printing the `blanks` string again? -- http://mail.python.org/mailman/listinfo/python-list
Re: Replace blanks with letter
eschneide...@comcast.net wrote: > I'm trying to replace the blank(_) with the letter typed in by the user, > in the appropriate blank(_) spot where the letter should be (where is in > the letters list). > > letters='abcdefg' > blanks='_ '*len(letters) > print('type letter from a to g') > print(blanks) > input1=input() > for i in range(len(letters)): > if letters[i] in input1: > blanks = blanks[:i] + letters[i] + blanks[i+1:] > > > What am I doing wrong in this code? `blanks` has two chars per letter in `letters`. If you change the initial value to blanks = "_" * len(letters) your code should work. If you think the output looks better with spaces you have to adjust the indices -- or you add spaces for printing only with print(" ".join(blanks)) -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing variables non-deterministic?
Le mardi 20 août 2013 09:55:44 UTC+2, Antoon Pardon a écrit : > Op 20-08-13 09:31, wxjmfa...@gmail.com schreef: > > > Le mardi 20 août 2013 08:55:18 UTC+2, Antoon Pardon a écrit : > > >> > > >>> > > >> > > > > > >> > > >> > > >> > > >>> If you consider the implementation of sin and cos functions, they usually > > >> > > >>> reduce the argument modulo π to something in the first quadrant, and then > > >> > > >>> use symmetry to adjust the value. So changing the value of pi could, in > > >> > > >>> principle, change the implementation of sin, cos and tan. > > >> > > >> > > >> > > >> Yes there is this aspect, which is a fair point. > > >> > > >> > > >> > > >> -- > > >> > > >> Antoon Pardon > > > > > > - > > > > > > Not really, see my previous post. This is only a geometric > > > interpretation, useless for calculation. > > > > No it is not. Steven is correct that if for example you > > want the value of sin(10), that in a typical implementation > > this will be reduced to calculating -sin(10 - 3π). > > > > This for two reasons. It is faster to first reduce the argument > > within the first kwadrant, do the series expansion and then > > correct for sign than to expand the series with the original > > argument and it is more acurate because first reducing asures > > that all terms will stay relatively small while using the > > original arguments can intrduce some large terms that will > > have to cancel each other but that will reduce acuracy. > > > > -- > > Antoon Pardon Ok. Fine. I was aware of the serie expansion, not about the reduction. jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? (syntax for functools.partial-like functionality)
On 20 Aug 2013 10:14, "Ian Kelly" wrote: > > On Tue, Aug 20, 2013 at 2:28 AM, Fábio Santos wrote: > > I do realize that syntax in python is practically written in stone, but I > > have seen changes come by if they have good reasons. For example, > > keyword-only argument syntax was added. > > > > I suggested this because I thought it would be the most practical way to > > create partial functions. Lambda is too verbose and kind of ugly, and its > > purpose is not to create partials, functools.partial does not allow argument > > "insertion" (the star thing) nor unpacking. > > I think that if you're doing argument insertion, then your partial > application is overly complex in the way that it modifies the original > argspec. You should be looking at it as a new function, not as a > partial application that prevents you from easily supplying a doc > string for it. If you want to specify an arbitrary combination of > arguments in your partial application, you can already do that using > keyword arguments. The exception would be if the function being > partially applied takes a *args argument and you want to specify some > of those arguments using partial without specifying earlier arguments. > That seems like an abuse of partial application to me. > > Tuple unpacking in function signatures was a feature in Python 2, and > it was intentionally removed in Python 3, so this is very unlikely to > happen. See PEP 3113. Besides which, the syntax you suggest for this > is unintuitive. > >spam_unpacking = spam{1, (*, *)} > > To me, this reads that spam_unpacking will take two positional > arguments that will be packed into the second argument sent to spam > (b), and that the third argument to spam (c) is not specified here. I > don't think that's what you intended. No, that syntax was meant to take a tuple and break it into two arguments. It does read terribly. Anyway, good points were made and I have seen the light. I've changed my mind. This is a bad idea. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where to suggest improvements in the official Python documentation?
@Joel Goldstick > Joel Goldstick > > http://joelgoldstick.com My specific question was that the Python documentation's tutorial isn't clear when it comes to lambda forms. I just wanted something to be done so it becomes clear for future readers who are not familiar with functional paradigm. I wanted to make a suggestion about adding a link to functional programming to add some clarity. -- http://mail.python.org/mailman/listinfo/python-list
Re: Where to suggest improvements in the official Python documentation?
On Tue, Aug 20, 2013 at 10:22 AM, Aseem Bansal wrote: > @Joel Goldstick >> Joel Goldstick >> >> http://joelgoldstick.com > > My specific question was that the Python documentation's tutorial isn't clear > when it comes to lambda forms. I just wanted something to be done so it > becomes clear for future readers who are not familiar with functional > paradigm. I wanted to make a suggestion about adding a link to functional > programming to add some clarity. In my first post above I provided the link for bug reports for python (including documentation). This is a volunteer list which is not officially part of the python.org site. You might try going to that link to learn how to submit change requests. > -- > http://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
monitor multicast traffic/IP
Folks: I am a Network Engineer, but have been trying to teach myself Python since Cisco will be leverage it on new high end models, yet I am very new to programming and Python; however, I have a need to have the ability to monitor traffic, more specificity multicast packets from a few sources. Just need some direction or pointers as to what to look for, what to review or what can be leveraged to start developing this app. In addition, can someone direct me to resources for procedural style of coding in Python? I am not grasping OOP concepts very well. I have played around with C and BASIC back in High School, but that was many years ago. Thank you -- http://mail.python.org/mailman/listinfo/python-list
RE: refresing the edited python function
alex23 > > On 19/08/2013 10:55 AM, Sudheer Joseph wrote: > > I have been using ipython and ipython with qtconsole and working on a > > code with functions. Each time I make a modification in function > > I have to quit IPTHON console (in both with and with out qt console ) > > and reload the function freshly. If I need to see the changed I made in > > the function. I tried below options > > > del function name > > import the module again by issuing "from xxx.py import yy" > > This doesn't re-import the module if xxx has already been imported. It > simply rebinds xxx.yy to yy. > > > import xxx.py > > This also doesn't re-import the module if it has already been imported. > > When you import a module, or a function from a module, a module object > is created and stored in sys.modules. Any subsequent 'import ' > calls will return a reference to that module object, and won't reload > from file at all. > > You can easily verify this by creating a test module 'foo' with a single > line of `print('loading foo')` and then trying this from the console: > > In [1]: import foo > loading foo > > In [2]: del foo > > In [3]: import foo > > In [4]: > > Note that you only see 'loading foo' the first time you import the > module. In order to have the module loaded again rather than returning > the existing reference, you would use `reload(foo)`: > > In [5]: reload(foo) > loading foo > > So: in order to be able to use functions from a re-loaded module, you > should always refer to them via the module object, and not import them > directly: > > >>> import xxx > >>> xxx.yy() # original code > # ...modify function `yy` in your source file > >>> reload(xxx) > >>> xxx.yy() # new code > > Or: you can reload the module and then rebind the functions: > > >>> from xxx import yy > >>> yy() # original code > # ...modify function `yy` in your source file > >>> reload(xxx) > >>> from xxx import yy > >>> yy() # new code > > Hope this helps. > > -- In Python 3 the reload built-in was moved to the imp module. So use imp.reload() instead. ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: refresing the edited python function
- Original Message - > Hi, > I have been using ipython and ipython with qtconsole and working on a > code with functions. Each time I make a modification in function > I have to quit IPTHON console (in both with and with out qt console ) > and reload the function freshly. If I need to see the changed I made > in the function. I tried below options > del function name > import the module again by issuing "from xxx.py import yy" > import xxx.py > make changes > reload(xxx.py) > this works only if the the function in the code has same name as the > code. But even this do not reflect the changes made by editing the > code. > So what is the standard way to update the function for further tests > after an edit? > with best regards, > Sudheer Hi, My "standard" way ;) : 1/ create a file 2/ edit the code 3/ run ipython (with %pdb on) 4/ within ipython "run myfile.py" 5/ check / introspect /debug 6/ change the code 7/ exit ipython 8/ reenter ipython 9/ using the ipython shell history, reexecute the file (2 key press) and go back to 5/ I used to reload my objects, it's been useful until one time when I lost a lot of time because of some nasty side effect. In the end it's not worth it. Always quit the shell, always. JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Found a grammar error in PEP 5. How to suggest correction?
In PEP 5 it is 4. Add an an optional warning mode to the parser that will inform There are 2 `an`s here. How to suggest a correction for this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Found a grammar error in PEP 5. How to suggest correction?
On Tue, Aug 20, 2013 at 1:14 PM, Aseem Bansal wrote: > In PEP 5 it is > > 4. Add an an optional warning mode to the parser that will inform > > There are 2 `an`s here. How to suggest a correction for this? > -- > http://mail.python.org/mailman/listinfo/python-list You already asked this question. Here is your answer: http://docs.python.org/2/bugs.html#documentation-bugs shows this: f you find a bug in this documentation or would like to propose an improvement, please send an e-mail to d...@python.org describing the bug and where you found it. If you have a suggestion how to fix it, include that as well. d...@python.org is a mailing list run by volunteers; your request will be noticed, even if it takes a while to be processed. Of course, if you want a more persistent record of your issue, you can use the issue tracker for documentation bugs as well. By the way, I found this link by going to google and searching for "how to submit documentation bug to python.org" Come on Aseem. Pick up your game a little bit. You actually have the opportunity to get the documentation changed for the better, or you can just keep asking the same question. -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Found a grammar error in PEP 5. How to suggest correction?
@Joel Goldstick That is the documentation and this is about the PEP. I didn't realize that the same works for both. I'll do that. -- http://mail.python.org/mailman/listinfo/python-list
Re: monitor multicast traffic/IP
wrote: I am a Network Engineer, but have been trying to teach myself Python since Cisco will be leverage it on new high end models, yet I am very new to programming and Python; however, I have a need to have the ability to monitor traffic, more specificity multicast packets from a few sources. Take a look at ImPacket and Pcapy [1+2]. Using one slightly modified sample therein, I was able to sniff out all mcast traffic here with this command: python sniff.py %PCAP_DEVICE% "ip[16] >= 224" I'm on a quiet home LAN, so not much mcasts here: Ether: 1c:bd:b9:c0:63:c6 -> 01:00:5e:00:00:01 IP 10.0.0.10 -> 224.0.0.1 110a eef5 Ether: 1c:bd:b9:c0:63:c6 -> 01:00:5e:00:00:01 IP 10.0.0.10 -> 224.0.0.1 110a eef5 [1] http://corelabs.coresecurity.com/index.php?module=Wiki&action=view&type=tool&name=Impacket [2] http://corelabs.coresecurity.com/index.php?module=Wiki&action=view&type=tool&name=Pcapy --gv -- http://mail.python.org/mailman/listinfo/python-list
Re: Found a grammar error in PEP 5. How to suggest correction?
On 8/20/2013 1:14 PM, Aseem Bansal wrote: In PEP 5 it is 4. Add an an optional warning mode to the parser that will inform There are 2 `an`s here. Fixed. How to suggest a correction for this? You just did. If this list does not work, or for non-trivial suggestions, go to bugs.python.org or email d...@python.org. See http://docs.python.org/3/bugs.html -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Found a grammar error in PEP 5. How to suggest correction?
On Tue, Aug 20, 2013 at 4:05 PM, Terry Reedy wrote: > On 8/20/2013 1:14 PM, Aseem Bansal wrote: >> >> In PEP 5 it is >> >> 4. Add an an optional warning mode to the parser that will inform >> >> There are 2 `an`s here. > > > Fixed. > > >> How to suggest a correction for this? > > > You just did. If this list does not work, or for non-trivial suggestions, go > to bugs.python.org or email d...@python.org. See > http://docs.python.org/3/bugs.html > -- > Terry Jan Reedy > > -- > http://mail.python.org/mailman/listinfo/python-list Hey Terry, Aseem! that's great! -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Replace blanks with letter
Is there also a way to have the code remember what I typed and not stop after the first letter the user types? For example, if I typed 'a' once, thus returning 'a__', and then typed in 'b', I want the code to return 'ab_' and so on. I wasn't clear about this part in my original post. Thanks for the help. Eric -- http://mail.python.org/mailman/listinfo/python-list
Re: Replace blanks with letter
eschneide...@comcast.net wrote: > Is there also a way to have the code remember what I typed and not stop after > the first letter the user types? For example, if I typed 'a' once, thus > returning 'a__', and then typed in 'b', I want the code to return > 'ab_' and so on. I wasn't clear about this part in my original post. > Thanks for the help. First you need some kind of loop. There's only one call to input() in your present code, so the question is meaningless. Roughly speaking, make sure the following line is NOT in your loop: blanks='_ '*len(letters) -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
How to keep cookies when making http requests (Python 2.7)
Hi everybody, I am trying to write a simple Python script to solve the "riddle" at: http://quiz.gambitresearch.com/ The quiz is quite easy to solve, one needs to evaluate the expression between the curly brackets (say that the expression has value ) and go to the web page: http://quiz.gambitresearch/job/ You have to be fast enough, because with the page there is an associated cookie that expires 1 sec after the first request, therefore you need to be quick to access the /job/ page. [I know that this is the correct solution because with a friend we wrote a small script in JavaScript and could access the page with the email address] As an exercise I have decided to try doing the same with Python. First I have tried with the following code: #START SCRIPT import re import urllib2 regex = re.compile(r'\{(.*)\}') base_address = "http://quiz.gambitresearch.com/"; base_h = urllib2.urlopen(base_address) base_page = base_h.read() val = str(eval(regex.findall(base_page)[0])) job_address = base_address + "job/" + val job_h = urllib2.urlopen(job_address) job_page = job_h.read() print job_page #END SCRIPT job_page has the following content now: "WRONG! (Have you enabled cookies?)" Trying to solve the issues with the cookies I found the "requests" module that in theory should work. I therefore rewrote the above script to use request: #START SCRIPT: import re import requests regex = re.compile(r'\{(.*)\}') base_address = "http://quiz.gambitresearch.com/"; s = requests.Session() base_h = s.get('http://quiz.gambitresearch.com/') base_page = base_h.text val = eval( regex.findall( base_page )[0] ) job_address = base_address + "job/" + str(val) job_h = s.get( job_address ) job_page = job_h.text print job_page #END SCRIPT # print job_page produces "Wrong!". According to the manual using Session() the cookies should be enabled and persistent for all the session. In fact the cookies in base_h.cookies and in job_h.cookies seem to be the same: base_h.cookies == job_h.cookies #returns True So, why does this script fail to access the job page? How can I change it so that I it works as intended and job_page prints the content of the page that displays the email address to use for the job applications? Thanks a lot in advance for the help! Best Wishes, Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Found a grammar error in PEP 5. How to suggest correction?
@ Terry Jan Reedy, @Joel Goldstick The problem with that documentation link is that it says the bugs in that documentation should be mailed at that e-mail address. But the PEPs are not the part of the documentation. I am saying that PEPs are not its part because when I downloaded the documentation it did not contain the PEPs. So the information in the documentation is misleading because it doesn't include the PEPs in the downloaded version but the e-mail address is used to accept PEP bugs according to you people. peps at python dot org is the e-mail suggested in PEP1 for contacting the PEP editors. I e-mailed there and got a reply. -- http://mail.python.org/mailman/listinfo/python-list
PEPs should be included with the documentation download
Currently the documentation download includes a lot of things but PEPs are not its part. I wanted to suggest that PEPs should be included in the download. They are very much relevant to Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to keep cookies when making http requests (Python 2.7)
Luca Cerone writes: > ... Python has a module for cookie handling: "cookielib" ("cookiejar" in Python 3). "urllib2" has a standard way to integrate with this module. However, I do not know the details (check the documentation for the modules). I have used "cookielib" externally to "urllib2". It looks like this: from urllib2 import urlopen, Request from cookielib import CookieJar cookies = CookieJar() r = Request(...) cookies.add_cookie_header(r) # set the cookies R = urlopen(r, ...) # make the request cookies.extract_cookies(R, r) # remember the new cookies -- http://mail.python.org/mailman/listinfo/python-list
Any Django users in Reims (France) ?
Bonjour, Je cherche des dev Django dans la région de Reims (France) pour organiser des rencontres sympas et échanger sur notre plateforme préférée voire développer ensemble nos excellentes idées. A votre écoute, Fabrice -- http://mail.python.org/mailman/listinfo/python-list
Basic Python Query
Hi all, Please see the below code. class Test(threading.Thread): def StartThread(self): Lock = threading.Lock() self.start() class Test1(threading.Thread): def __init__(self): threading.Thread.__init__ ( self ) self.Lock = threading.Lock() self.start() if __name__ == '__main__': instance = Test() instance.StartThread() instance1= Test1() instance1.start() Please clarify the questions below with respect to above code 1.Difference between def StartThread(self) and def __init__(self): 2 instance = Test() ,when this is called ,the code flow goes inside the threading module ,But instance1= Test1() ,the code flow goes inside the class Test1 When we call the both classes in same way ,How does the flow is different for both. 3. Lets say self is passed explicitly for all the methods Like def method1(self) method2() def method2(self): method3() def method(self) method4() def method4(self) What does self holds in method4 ,Is it self argument from method1? Sorry i'm confused with self argument.Please clarify if its valid question. Best Regards, Chandan-- http://mail.python.org/mailman/listinfo/python-list