Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος
Στις 9/10/2013 7:53 πμ, ο/η Ian Kelly έγραψε: On Tue, Oct 8, 2013 at 8:18 AM, Νίκος Αλεξόπουλος wrote: Also i have set: ookie['ID']['expires'] = 60*60*24*365 #this cookie will expire in a year The Expires attribute takes a date. If you're passing an interval in seconds then you sho

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Steven D'Aprano
On Tue, 08 Oct 2013 21:28:25 -0400, Terry Reedy wrote: > On 10/8/2013 6:30 PM, Steven D'Aprano wrote: >> On Tue, 08 Oct 2013 15:14:33 +, Neil Cerutti wrote: >> >>> In any case, "\ud800\udc01" isn't a valid unicode string. >> >> I don't think this is correct. Can you show me where the standard

Re: Can ay one help me on pysvn , i want to capture the log and status of checkout call .....

2013-10-08 Thread Mark Lawrence
On 09/10/2013 07:09, bab mis wrote: To repeat what I've said recently on the tutor mailing list, sorry but if you want us to do your work you'll have to send a suitably sized cheque to the PSF, where the size refers to the amount written in words and numbers and not the physical dimensions.

Re: Applying 4x4 transformation to 3-element vector with numpy

2013-10-08 Thread John Nagle
On 10/8/2013 10:36 PM, Christian Gollwitzer wrote: > Dear John, > > Am 09.10.13 07:28, schrieb John Nagle: >> This is the basic transformation of 3D graphics. Take >> a 3D point, make it 4D by adding a 1 on the end, multiply >> by a transformation matrix to get a new 4-element vector, >> disc

Can ay one help me on pysvn , i want to capture the log and status of checkout call .....

2013-10-08 Thread bab mis
-- https://mail.python.org/mailman/listinfo/python-list

Re: class-private names and the Zen of Python

2013-10-08 Thread Marco Buttu
On 10/09/2013 01:00 AM, Oscar Benjamin wrote: > On Tue, 08 Oct 2013 12:13:48 +0200, Marco Buttu wrote: > > > Another question is: where is the place in which this transformation > > occurs? Is it at the parser level, before the dictionary attribute is > > gave as argument to the metaclass?

Re: Applying 4x4 transformation to 3-element vector with numpy

2013-10-08 Thread Christian Gollwitzer
Dear John, Am 09.10.13 07:28, schrieb John Nagle: This is the basic transformation of 3D graphics. Take a 3D point, make it 4D by adding a 1 on the end, multiply by a transformation matrix to get a new 4-element vector, discard the last element. Is there some way to do that in numpy wi

Applying 4x4 transformation to 3-element vector with numpy

2013-10-08 Thread John Nagle
This is the basic transformation of 3D graphics. Take a 3D point, make it 4D by adding a 1 on the end, multiply by a transformation matrix to get a new 4-element vector, discard the last element. Is there some way to do that in numpy without adding the extra element and then discarding it?

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Steven D'Aprano
On Tue, 08 Oct 2013 23:27:51 +0100, Rob Day wrote: > print("imploring epsilon decamp graveyard's") # Chosen by fair random > sampling, guaranteed to be random > > Comments don't count as code, right? ;) "cat cat cat cat..." That's the trouble with random, you can never quite tell. -- Steven

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Ian Kelly
On Tue, Oct 8, 2013 at 8:18 AM, Νίκος Αλεξόπουλος wrote: > Also i have set: > ookie['ID']['expires'] = 60*60*24*365 #this cookie will expire in > a year The Expires attribute takes a date. If you're passing an interval in seconds then you should use the Max-Age attribute instead. That

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Roy Smith
In article , Chris Angelico wrote: > On Wed, Oct 9, 2013 at 12:38 PM, Roy Smith wrote: > > If you're willing to accept a sub-optimal random number generator: > > > > # Python-2, sorry > > import os > > print list(set(open('/usr/share/dict/words')))[os.getpid():][:4] > > So that steps by your p

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Chris Angelico
On Wed, Oct 9, 2013 at 12:38 PM, Roy Smith wrote: > If you're willing to accept a sub-optimal random number generator: > > # Python-2, sorry > import os > print list(set(open('/usr/share/dict/words')))[os.getpid():][:4] So that steps by your pid? That's going to drastically reduce the entropy in

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Roy Smith
On Monday, October 7, 2013 8:17:21 PM UTC-10, Chris Angelico wrote: > > print(*__import__("random").sample(open("/usr/share/dict/words").read().spli > > t("\n"),4)) In article <68365e43-498f-4ad2-bac3-6a0293815...@googlegroups.com>, sprucebond...@gmail.com wrote: > import random as r > print(*

ANN: RPQueue 0.22

2013-10-08 Thread Josiah Carlson
Hello everyone, For those of you who didn't know, if you are interested in a Redis-backed time and/or fifo-queue with priorities, retries, etc., to be used with Python, one exists and is mature: it's called RPQueue, and it seeks to simplify your life of task execution. The recent changelog entries

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Steven D'Aprano
On Wed, 09 Oct 2013 01:52:44 +0300, Νίκος Αλεξόπουλος wrote: > Is there something i can try to isolate the problem and make it work? Of course there is. That is part of the job of the developer: hard work trying dozens, maybe hundreds of different things until you isolate the problem. There ar

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Terry Reedy
On 10/8/2013 6:30 PM, Steven D'Aprano wrote: On Tue, 08 Oct 2013 15:14:33 +, Neil Cerutti wrote: In any case, "\ud800\udc01" isn't a valid unicode string. I don't think this is correct. Can you show me where the standard says that Unicode strings[1] may not contain surrogates? I think tha

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Steven D'Aprano
On Tue, 08 Oct 2013 13:47:14 -0400, Joel Goldstick wrote: > Yes! there is a very simple and comprehensive way to learn about your > visitors. Use Google Analytics. Its free, you only need a google > account to open an analytics account. http://images.wikia.com/darkheresy/images/0/0c/Its_a_trap.

Re: class implementation

2013-10-08 Thread Cameron Simpson
On 08Oct2013 01:20, markot...@gmail.com wrote: > I cant just subclassing doesent work. It seem the init method of the source > class also calls out another class. And the problem is, i can subclass the > other class to with the required function but the end result is that it > doesent work, sin

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Ned Batchelder
On 10/8/13 6:52 PM, Νίκος Αλεξόπουλος wrote: Στις 8/10/2013 10:29 μμ, ο/η Denis McMahon έγραψε: On Tue, 08 Oct 2013 19:04:37 +0300, Νίκος Αλεξόπουλος wrote: Can you help me with this particuler problem please? Unfortunately I can't, because I am unable to reproduce the problem you describe.

Re: class implementation

2013-10-08 Thread Rhodri James
On Tue, 08 Oct 2013 15:05:26 +0100, wrote: Parent class is at the link. Please quote some context when you reply. What link? Then again, I'm not about to click on some random link someone posts to a newsgroup. Apart from being one of the classic ways to get a virus onto my computer, it

Re: class-private names and the Zen of Python

2013-10-08 Thread Oscar Benjamin
On Oct 8, 2013 2:26 PM, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > > On Tue, 08 Oct 2013 12:13:48 +0200, Marco Buttu wrote: > > > Another question is: where is the place in which this transformation > > occurs? Is it at the parser level, before the dictionary attribute is >

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος
Στις 8/10/2013 10:29 μμ, ο/η Denis McMahon έγραψε: On Tue, 08 Oct 2013 19:04:37 +0300, Νίκος Αλεξόπουλος wrote: Can you help me with this particuler problem please? Unfortunately I can't, because I am unable to reproduce the problem you describe. When I load my test page in the browser, then

Re: Re for Apache log file format

2013-10-08 Thread Cameron Simpson
On 08Oct2013 10:59, Skip Montanaro wrote: | > Aiui apache log format uses space as delimiter, encapsulates strings in | > '"' characters, and uses '-' as an empty field. | | Specifying the field delimiter as a space, you might be able to use | the csv module to read these. I haven't done any Apac

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Steven D'Aprano
On Tue, 08 Oct 2013 15:14:33 +, Neil Cerutti wrote: > In any case, "\ud800\udc01" isn't a valid unicode string. I don't think this is correct. Can you show me where the standard says that Unicode strings[1] may not contain surrogates? I think that is a critical point, and the FAQ conflates

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Rob Day
On 08/10/13 07:17, Chris Angelico wrote: Who's up for some fun? Implement an XKCD-936-compliant password generator in Python 3, in less code than this: print(*__import__("random").sample(open("/usr/share/dict/words").read().split("\n"),4)) print("imploring epsilon decamp graveyard's") # Chose

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Steven D'Aprano
On Tue, 08 Oct 2013 18:00:58 +0100, MRAB wrote: > The only time you should get a surrogate pair in a Unicode string is in > a narrow build, which doesn't exist in Python 3.3 and later. Incorrect. py> sys.version '3.3.0rc3 (default, Sep 27 2012, 18:44:58) \n[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Terry Reedy
On 10/8/2013 5:47 PM, Terry Reedy wrote: On 10/8/2013 9:52 AM, Steven D'Aprano wrote: But reading the previous entry in the FAQs: http://www.unicode.org/faq/utf_bom.html#utf8-4 I interpret this as meaning that I should be able to encode valid pairs of surrogates. It says you should be able

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Terry Reedy
On 10/8/2013 9:52 AM, Steven D'Aprano wrote: I think this is a bug in Python's UTF-8 handling, but I'm not sure. If I've read the Unicode FAQs correctly, you cannot encode *lone* surrogate code points into UTF-8: http://www.unicode.org/faq/utf_bom.html#utf8-5 Sure enough, using Python 3.3: py

Re: Formal-ity and the Church-Turing thesis

2013-10-08 Thread Chris Angelico
On Wed, Oct 9, 2013 at 12:11 AM, Steven D'Aprano wrote: > On Tue, 08 Oct 2013 18:16:01 +0530, Ravi Sahni wrote: > >>> So in that sense, computers are Turing Machines. Anything a physical >>> computing device can compute, a Turing Machine could too. The converse >>> is not true though: a Turing Mac

Re: converting letters to numbers

2013-10-08 Thread Dave Angel
On 8/10/2013 10:28, kjaku...@gmail.com wrote: > I have to define a function add(c1, c2), where c1 and c2 are capital letters; > the return value should be the sum (obtained by converting the letters to > numbers, adding mod 26, then converting back to a capital letter). > > All I have so far is

How to help us to help you (was: Image manipulation)

2013-10-08 Thread Ben Finney
markot...@gmail.com writes: > Well english isnt my native language, and there are things i just dont > know how to explain in any language. I sympathise with attempting to explain things in a foreign language. Sorry that you have that difficulty here. But the rest of Steven's advice is sound: yo

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Chris Angelico
On Wed, Oct 9, 2013 at 7:27 AM, wrote: > On Tuesday, October 8, 2013 5:47:56 AM UTC-10, rand...@fastmail.us wrote: >> Importing random as r doesn't actually save anything, since " as r" is >> the same five characters you saved from the one use of it. > > I realize, it just looks nicer than the or

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread sprucebondera
On Tuesday, October 8, 2013 5:47:56 AM UTC-10, rand...@fastmail.us wrote: > Importing random as r doesn't actually save anything, since " as r" is > the same five characters you saved from the one use of it. I realize, it just looks nicer than the original __import__, and since it doesn't add any

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Denis McMahon
On Tue, 08 Oct 2013 19:04:37 +0300, Νίκος Αλεξόπουλος wrote: > Can you help me with this particuler problem please? Unfortunately I can't, because I am unable to reproduce the problem you describe. When I load my test page in the browser, then replace it with something else by entering an addr

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Joel Goldstick
On Tue, Oct 8, 2013 at 12:04 PM, Νίκος Αλεξόπουλος wrote: > Στις 8/10/2013 6:55 μμ, ο/η Denis McMahon έγραψε: > >> On Tue, 08 Oct 2013 13:04:34 +0300, Νίκος Αλεξόπουλος wrote: >> >>> I use this code to retrive or set a cookie to the visitor's browser if >>> present and identify him bu it. >> >> Br

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread wxjmfauth
>>> sys.version '3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)]' >>> '\ud800'.encode('utf-8') Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position 0: surrogates not allowed

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Tobiah
On 10/07/2013 11:17 PM, Chris Angelico wrote: Who's up for some fun? Implement an XKCD-936-compliant password generator in Python 3, in less code than this: print(*__import__("random").sample(open("/usr/share/dict/words").read().split("\n"),4)) Second challenge: Use it for generating all your p

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Joel Goldstick
On Tue, Oct 8, 2013 at 1:30 PM, Νίκος Αλεξόπουλος wrote: > Is there any better way to identif a previous visitor? i tried cookies which > failed for me for the reason i opened this thread and host like follows: > > # try to locate the visitor > cur.execute('''SELECT

Re: Formal-ity and the Church-Turing thesis

2013-10-08 Thread Mark Janssen
>> I don't have an infinite stack to implement >> lambda calculus, but... > > And then > >> But this is not a useful formalism. Any particular Program implements >> a DFA, even as it runs on a TM. The issue of whether than TM is >> finite or not can be dismissed because a simple calculation can >

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Tobiah
On 10/08/2013 09:07 AM, Tim Chase wrote: On 2013-10-08 15:36, Denis McMahon wrote: On Tue, 08 Oct 2013 08:33:48 -0400, Roy Smith wrote: In the old days, it used to be /usr/dict/words. Port Python to v6, and save another 6 characters :-) Doesn't matter where it is, a link to it exists at "/w"

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος
Is there any better way to identif a previous visitor? i tried cookies which failed for me for the reason i opened this thread and host like follows: # try to locate the visitor cur.execute('''SELECT * FROM visitors WHERE counterID = %s and host = %s''', (cID, host) )

Re: parsing email from stdin

2013-10-08 Thread Andreas Perstinger
On 08.10.2013 17:25, Antoon Pardon wrote: Op 08-10-13 16:24, Andreas Perstinger schreef: Looking at the docs, I've found there is also "message_from_binary_file" which works for me with your code. http://docs.python.org/3/library/email.parser.html#email.message_from_binary_file I can't try t

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread MRAB
On 08/10/2013 16:23, Pete Forman wrote: Steven D'Aprano writes: I think this is a bug in Python's UTF-8 handling, but I'm not sure. [snip] py> s = '\ud800\udc01' py> s.encode('utf-8') Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'utf-8' codec can't encode cha

Re: class-private names and the Zen of Python

2013-10-08 Thread Ned Batchelder
On 10/8/13 7:15 AM, Marco Buttu wrote: Also, as Terry mentions, no one has ever assigned the two names you show, Sincerely, I can not now if someone has assigned (or will assegne) in such way... If you explain more about what you are building, and where this crops up as a problem, we can

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Tim Chase
On 2013-10-08 17:17, Chris Angelico wrote: > Who's up for some fun? Implement an XKCD-936-compliant password > generator in Python 3, in less code than this: > > print(*__import__("random").sample(open("/usr/share/dict/words").read().split("\n"),4)) > > Second challenge: Use it for generating all

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Tim Chase
On 2013-10-08 15:36, Denis McMahon wrote: > On Tue, 08 Oct 2013 08:33:48 -0400, Roy Smith wrote: > > In the old days, it used to be /usr/dict/words. Port Python to > > v6, and save another 6 characters :-) > > Doesn't matter where it is, a link to it exists at "/w" now ;) You prodigal...wasting

Re: converting letters to numbers

2013-10-08 Thread Mark Lawrence
On 08/10/2013 15:28, kjaku...@gmail.com wrote: I have to define a function add(c1, c2), where c1 and c2 are capital letters; the return value should be the sum (obtained by converting the letters to numbers, adding mod 26, then converting back to a capital letter). I'd say the requirement is

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος
Στις 8/10/2013 6:55 μμ, ο/η Denis McMahon έγραψε: On Tue, 08 Oct 2013 13:04:34 +0300, Νίκος Αλεξόπουλος wrote: I use this code to retrive or set a cookie to the visitor's browser if present and identify him bu it. You are aware that using cookies to track a user who doesn't want to be tracked

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Denis McMahon
On Tue, 08 Oct 2013 13:04:34 +0300, Νίκος Αλεξόπουλος wrote: > I use this code to retrive or set a cookie to the visitor's browser if > present and identify him bu it. You are aware that using cookies to track a user who doesn't want to be tracked won't work, because he'll just tell his browser

Re: Re for Apache log file format

2013-10-08 Thread Skip Montanaro
> Aiui apache log format uses space as delimiter, encapsulates strings in > '"' characters, and uses '-' as an empty field. Specifying the field delimiter as a space, you might be able to use the csv module to read these. I haven't done any Apache log file work since long before the csv module was

Re: converting letters to numbers

2013-10-08 Thread random832
On Tue, Oct 8, 2013, at 11:44, kjaku...@gmail.com wrote: > def add(c1, c2): > ans = '' This only makes sense if your answer is going to be multiple characters. > for i in c1 + c2: This line concatenates the strings together. > ans += chrord(i)-65))%26) + 65) The way you are

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Neil Cerutti
On 2013-10-08, Neil Cerutti wrote: > In any case, "\ud800\udc01" isn't a valid unicode string. In a > perfect world it would automatically get converted to > '\u00010001' without intervention. This last paragraph is erroneous. I must have had a typo in my testing. -- Neil Cerutti -- https://ma

Re: Re for Apache log file format

2013-10-08 Thread Denis McMahon
On Mon, 07 Oct 2013 23:33:31 -0700, Sam Giraffe wrote: > I am trying to split up the re pattern for Apache log file format and > seem to be having some trouble in getting Python to understand > multi-line pattern: Aiui apache log format uses space as delimiter, encapsulates strings in '"' charac

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread random832
On Tue, Oct 8, 2013, at 2:45, sprucebond...@gmail.com wrote: > On Monday, October 7, 2013 8:17:21 PM UTC-10, Chris Angelico wrote: > > print(*__import__("random").sample(open("/usr/share/dict/words").read().split("\n"),4)) > > # 87 > > import random as r > print(*r.sample(open("/usr/share/dict/wo

Re: converting letters to numbers

2013-10-08 Thread kjakupak
On Tuesday, October 8, 2013 11:36:51 AM UTC-4, rand...@fastmail.us wrote: > > > > Your description says capital letters, but 'a' is a lowercase letter. > > > > Does "mod 26" means A is 1, or is it 0? i.e., is A+A = B or is it A? > > > > What should your function do if the letter isn't a ca

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Denis McMahon
On Tue, 08 Oct 2013 08:33:48 -0400, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> On Tue, Oct 8, 2013 at 5:48 PM, wrote: >> > And if we were actually trying then that filename should just be >> > "/w". >> > Would get rid of another 19 chars. >> >> I'm working this on the assum

Re: converting letters to numbers

2013-10-08 Thread random832
On Tue, Oct 8, 2013, at 10:28, kjaku...@gmail.com wrote: > I have to define a function add(c1, c2), where c1 and c2 are capital > letters; the return value should be the sum (obtained by converting the > letters to numbers, adding mod 26, then converting back to a capital > letter). > > All I hav

Re: parsing email from stdin

2013-10-08 Thread Antoon Pardon
Op 08-10-13 16:24, Andreas Perstinger schreef: On 08.10.2013 14:20, Antoon Pardon wrote: As I don't know what encoding these messages will be in, I thought it would be prudent to read stdin as binary data. Using python 3.3 on a debian box I have the following code. #!/usr/bin/python3 import s

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Pete Forman
Steven D'Aprano writes: > I think this is a bug in Python's UTF-8 handling, but I'm not sure. [snip] > py> s = '\ud800\udc01' > py> s.encode('utf-8') > Traceback (most recent call last): > File "", line 1, in > UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in > position 0:

Re: Encoding of surrogate code points to UTF-8

2013-10-08 Thread Neil Cerutti
On 2013-10-08, Steven D'Aprano wrote: > py> c = '\N{LINEAR B SYLLABLE B038 E}' > py> surr_pair = c.encode('utf-16be') > py> print(surr_pair) > b'\xd8\x00\xdc\x01' > > and then use those same values as the code points, I ought to be able to > encode to UTF-8, as if it were the same \N{LINEAR B SYL

Re: converting letters to numbers

2013-10-08 Thread Joel Goldstick
You wrote this: def add(c1, c2): ord(c1) - ord('a') + 1 ord(c2) - ord('a') + 1 First of all, this looks like homework. People will help you with concepts here, but most frown on just providing answers. With that in mind look at this: >>> ord('A') 65 >>> ord('a') 97 >>> In your assignm

Re: Image manipulation

2013-10-08 Thread markotaht
I rembembered a bit too late, are there any good tutorials for Pillow? ImageTk.PhotoImage() keeps giving me error that there isnt such a method. -- https://mail.python.org/mailman/listinfo/python-list

Re: Image manipulation

2013-10-08 Thread markotaht
teisipäev, 8. oktoober 2013 17:26.33 UTC+3 kirjutas Steven D'Aprano: > On Tue, 08 Oct 2013 07:15:46 -0700, markotaht wrote: > > > > > First helpful advice i have gotten from this forum > > > > If you insist on dropping cryptic comments with bad spelling, incoherent > > sentences, and a comp

Re: JUST GOT HACKED

2013-10-08 Thread Pat Johnson
>From what I gather he was viewing files uploaded to the ftp folder and found >this warning.html file contained within... So my take on it is, someone just >uploaded it and this guy is freaking out making a buffoon out of himself. -- https://mail.python.org/mailman/listinfo/python-list

Re: converting letters to numbers

2013-10-08 Thread kjakupak
On Tuesday, October 8, 2013 10:47:39 AM UTC-4, Robert Day wrote: > On 08/10/13 15:28, kjaku...@gmail.com wrote: > > Can you give some expected outputs? For example, add('A', 'B') should > > presumably return 'C', and add('M', 'B') should presumably return 'O', > > but what about add('A', 'A')

Re: JUST GOT HACKED

2013-10-08 Thread Pat Johnson
I don't think you are allowed to use the word dumbass to describe anyone or anything buddy. On Tuesday, October 1, 2013 9:42:31 AM UTC-4, Ferrous Cranus wrote: > Στις 1/10/2013 4:27 μμ, ο/η Chris “Kwpolska” Warrick έγραψε: > > > On Tue, Oct 1, 2013 at 3:15 PM, Νίκος wrote: > > >> Στις 1/10/2

Re: converting letters to numbers

2013-10-08 Thread Robert Day
On 08/10/13 15:28, kjaku...@gmail.com wrote: I have to define a function add(c1, c2), where c1 and c2 are capital letters; the return value should be the sum (obtained by converting the letters to numbers, adding mod 26, then converting back to a capital letter). Can you give some expected out

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος
Στις 8/10/2013 2:08 μμ, ο/η Ian Kelly έγραψε: This question is really about HTTP, not Python, so you'd have better luck asking elsewhere. The most likely possibility is that the domain doesn't match. For example, the cookie is set for the domain www.foo.com, and the other webpage is linking to

Re: parsing email from stdin

2013-10-08 Thread Andreas Perstinger
On 08.10.2013 14:20, Antoon Pardon wrote: As I don't know what encoding these messages will be in, I thought it would be prudent to read stdin as binary data. Using python 3.3 on a debian box I have the following code. #!/usr/bin/python3 import sys from email import message_from_file sys.stdi

Re: Image manipulation

2013-10-08 Thread Steven D'Aprano
On Tue, 08 Oct 2013 07:15:46 -0700, markotaht wrote: > First helpful advice i have gotten from this forum If you insist on dropping cryptic comments with bad spelling, incoherent sentences, and a complete lack of any context, it might be the last advice you get too. Please help us to help you.

converting letters to numbers

2013-10-08 Thread kjakupak
I have to define a function add(c1, c2), where c1 and c2 are capital letters; the return value should be the sum (obtained by converting the letters to numbers, adding mod 26, then converting back to a capital letter). All I have so far is: def add(c1, c2): ord(c1) - ord('a') + 1 ord(c

Re: Formal-ity and the Church-Turing thesis

2013-10-08 Thread Robert Day
On 08/10/13 14:11, Steven D'Aprano wrote: On Tue, 08 Oct 2013 18:16:01 +0530, Ravi Sahni wrote: Presently Sir, I wish to ask single question: What you mean "wave our hands"?? It is an idiom very common in Australia. (It may not be well known in the rest of the English-speaking world.) It mea

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος
Στις 8/10/2013 2:08 μμ, ο/η Ian Kelly έγραψε: On Tue, Oct 8, 2013 at 4:04 AM, Νίκος Αλεξόπουλος wrote: I use this code to retrive or set a cookie to the visitor's browser if present and identify him bu it. All work well except the situation where the user visits my webpage by clicking a backli

Re: Image manipulation

2013-10-08 Thread markotaht
First helpful advice i have gotten from this forum -- https://mail.python.org/mailman/listinfo/python-list

Re: class implementation

2013-10-08 Thread markotaht
Parent class is at the link. -- https://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing and Multithreading

2013-10-08 Thread Grant Edwards
On 2013-10-08, Mark Lawrence wrote: > On 08/10/2013 06:34, Chandru Rajendran wrote: >> Hi all, >> >> Please give me an idea about Multiprocessing and Multithreading. >> >> Thanks & Regards, >> >> Chandru >> > > I'll assume that you're a newbie so I'll keep it simple. > Multiprocessing is about mo

Encoding of surrogate code points to UTF-8

2013-10-08 Thread Steven D'Aprano
I think this is a bug in Python's UTF-8 handling, but I'm not sure. If I've read the Unicode FAQs correctly, you cannot encode *lone* surrogate code points into UTF-8: http://www.unicode.org/faq/utf_bom.html#utf8-5 Sure enough, using Python 3.3: py> surr = '\udc80' py> surr.encode('utf-8') Tra

Re: Formal-ity and the Church-Turing thesis

2013-10-08 Thread rusi
On Tuesday, October 8, 2013 6:31:21 PM UTC+5:30, Ravi Sahni wrote: > On Tue, Oct 8, 2013 at 11:14 AM, rusi wrote: > > To explain at length will be too long and OT (off-topic) for this list. > > I'll just give you a link and you tell me what you make of it: > > http://sloan.stanford.edu/mousesite/S

Re: class-private names and the Zen of Python

2013-10-08 Thread Steven D'Aprano
On Tue, 08 Oct 2013 12:13:48 +0200, Marco Buttu wrote: > In the following case: > > >>> class Foo: > ... _Foo__a = 100 > ... __a = 33 > ... > >>> Foo._Foo__a > 33 > > I think this behavior, for a user who does not know the convention, > could be a surprise. Yes, you are correct. It s

Re: Formal-ity and the Church-Turing thesis

2013-10-08 Thread Steven D'Aprano
On Tue, 08 Oct 2013 18:16:01 +0530, Ravi Sahni wrote: >> So in that sense, computers are Turing Machines. Anything a physical >> computing device can compute, a Turing Machine could too. The converse >> is not true though: a Turing Machine with infinite tape can compute >> things where a real phys

Re: Formal-ity and the Church-Turing thesis

2013-10-08 Thread Ravi Sahni
On Tue, Oct 8, 2013 at 11:14 AM, rusi wrote: > To explain at length will be too long and OT (off-topic) for this list. > I'll just give you a link and you tell me what you make of it: > http://sloan.stanford.edu/mousesite/Secondary/Whorfframe2.html I am trying to read link. Very new idea: Buildi

Re: Re for Apache log file format

2013-10-08 Thread Neil Cerutti
On 2013-10-08, Sam Giraffe wrote: > > Hi, > > I am trying to split up the re pattern for Apache log file format and seem > to be having some trouble in getting Python to understand multi-line > pattern: > > #!/usr/bin/python > > import re > > #this is a single line > string = '192.168.122.3 - - [2

Re: Formal-ity and the Church-Turing thesis

2013-10-08 Thread Ravi Sahni
On Tue, Oct 8, 2013 at 1:20 PM, Steven D'Aprano wrote: > On Tue, 08 Oct 2013 10:46:50 +0530, Ravi Sahni wrote: > >> On Tue, Oct 8, 2013 at 8:47 AM, rusi wrote: >>> I can only say how ironic it sounds to someone who is familiar with the >>> history of our field: Turing was not a computer scientist

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread Roy Smith
In article , Chris Angelico wrote: > On Tue, Oct 8, 2013 at 5:48 PM, wrote: > > And if we were actually trying then that filename should just be "/w". > > Would get rid of another 19 chars. > > I'm working this on the assumption that the dictionary file already > exists (that's where it is o

parsing email from stdin

2013-10-08 Thread Antoon Pardon
I want to do some postprocessing on messages from a particular mailbox. So I use getmail which will fetch the messages and feed them to stdin of my program. As I don't know what encoding these messages will be in, I thought it would be prudent to read stdin as binary data. Using python 3.3 on a

Re: class-private names and the Zen of Python

2013-10-08 Thread Marco Buttu
On 10/08/2013 01:07 PM, Ned Batchelder wrote: On 10/8/13 6:13 AM, Marco Buttu wrote: >>> class Foo: ... _Foo__a = 100 ... __a = 33 ... >>> Foo._Foo__a 33 ... You also get a "problem" if you do this: >>> class Foo: ... a = 100 ... a = 33 ... >>> Foo.a

Re: Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Ian Kelly
On Tue, Oct 8, 2013 at 4:04 AM, Νίκος Αλεξόπουλος wrote: > I use this code to retrive or set a cookie to the visitor's browser if > present and identify him bu it. > > All work well except the situation where the user visits my webpage by > clicking a backlink on another wbpage. > > Then for some

Re: class-private names and the Zen of Python

2013-10-08 Thread Ned Batchelder
On 10/8/13 6:13 AM, Marco Buttu wrote: In the following case: >>> class Foo: ... _Foo__a = 100 ... __a = 33 ... >>> Foo._Foo__a 33 I think this behavior, for a user who does not know the convention, could be a surprise. Should be raising an exception (in order to inform the user the t

Re: class-private names and the Zen of Python

2013-10-08 Thread Marco Buttu
On 10/08/2013 12:36 PM, Terry Reedy wrote: On 10/8/2013 6:13 AM, Marco Buttu wrote: In the following case: >>> class Foo: ... _Foo__a = 100 ... __a = 33 ... >>> Foo._Foo__a 33 I think this behavior, for a user who does not know the convention, could be a surprise. No one qualified

Re: class-private names and the Zen of Python

2013-10-08 Thread Terry Reedy
On 10/8/2013 6:13 AM, Marco Buttu wrote: In the following case: >>> class Foo: ... _Foo__a = 100 ... __a = 33 ... >>> Foo._Foo__a 33 I think this behavior, for a user who does not know the convention, could be a surprise. No one qualified to use such names would do such a thing , so

Re: class implementation

2013-10-08 Thread Dave Angel
On 8/10/2013 04:20, markot...@gmail.com wrote: > I cant just subclassing doesent work. I can't parse that "sentence." > It seem the init method of the source class also calls out another class. And the problem is, i can subclass the other class to with the required function but the end result i

Re: Re for Apache log file format

2013-10-08 Thread Andreas Perstinger
On 08.10.2013 08:33, Sam Giraffe wrote: #this is a single line string = '192.168.122.3 - - [29/Sep/2013:03:52:33 -0700] "GET / HTTP/1.0" 302 276 "-" "check_http/v1.4.16 (nagios-plugins 1.4.16)"' #trying to break up the pattern match for easy to read code pattern = re.compile(r'(?P\d{1,3}\.\d{1,3

class-private names and the Zen of Python

2013-10-08 Thread Marco Buttu
In the following case: >>> class Foo: ... _Foo__a = 100 ... __a = 33 ... >>> Foo._Foo__a 33 I think this behavior, for a user who does not know the convention, could be a surprise. Should be raising an exception (in order to inform the user the transformation of the name __a have been

Cookie gets changed when hit comes from a referrer

2013-10-08 Thread Νίκος Αλεξόπουλος
# initialize cookie and retrieve cookie from clients browser cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) if cookie.get('ID') is not None: cookieID = cookie['ID'].value else: cookieID = random.randrange(0, ) cookie['ID'] = cookieID cookie['ID'

Re: Tail recursion to while iteration in 2 easy steps

2013-10-08 Thread Jussi Piitulainen
Alain Ketterlin writes: > Antoon Pardon writes: > > > Op 07-10-13 19:15, Alain Ketterlin schreef: > > [...] > >> That's fine. My point was: you can't at the same time have full > >> dynamicity *and* procedural optimizations (like tail call opt). > >> Everybody should be clear about the trade-off.

Re: Tail recursion to while iteration in 2 easy steps

2013-10-08 Thread Antoon Pardon
Op 07-10-13 23:27, random...@fastmail.us schreef: > On Sat, Oct 5, 2013, at 3:39, Antoon Pardon wrote: >> What does this mean? >> >> Does it mean that a naive implementation would arbitrarily mess up >> stack traces and he wasn't interested in investigating more >> sophisticated implementations? >>

Re: inserting or updating appropriately

2013-10-08 Thread Ben Finney
Νίκος Αλεξόπουλος writes: > Error is: ProgrammingError(ProgrammingError(1064, "You have an error > in your SQL syntax; check the manual that corresponds to your MySQL > server version for the right syntax to use near 'WHERE counterID = 1 > and cookieID = '3815'' at line 3"),) This is an error fr

Re: inserting or updating appropriately

2013-10-08 Thread Νίκος Αλεξόπουλος
Στις 8/10/2013 12:15 μμ, ο/η Νίκος Αλεξόπουλος έγραψε: Hello, i'am trying to insert a new record or update an existing one in case counterID(stands for the page's URL) and cookieID(random number) is the same: try: # if first time for webpage; create new record( primary key is autom

Re: Tail recursion to while iteration in 2 easy steps

2013-10-08 Thread Steven D'Aprano
On Mon, 07 Oct 2013 20:27:13 -0700, Mark Janssen wrote: But even putting that aside, even if somebody wrote such a description, it would be reductionism gone mad. What possible light on the problem would be shined by a long, long list of machine code operations, even if written

inserting or updating appropriately

2013-10-08 Thread Νίκος Αλεξόπουλος
Hello, i'am trying to insert a new record or update an existing one in case counterID(stands for the page's URL) and cookieID(random number) is the same: try: # if first time for webpage; create new record( primary key is automatic, hit is defaulted ), if page exists then update reco

  1   2   >