Re: how to read list from file

2013-10-06 Thread Jussi Piitulainen
Harvey Greenberg writes: > On Saturday, October 5, 2013 7:24:39 PM UTC-6, Tim Chase wrote: > > >>> s = "[{'a':1, 'b':2}, [1,2,3], 10]" > > >>> import ast > > >>> print repr(ast.literal_eval(s)) > > [{'a': 1, 'b': 2}, [1, 2, 3], 10] > > that didn't work. printing it looks like the list bec

Re: Overriding of the type.__call__() method in a metaclass

2013-10-06 Thread Marco Buttu
On 10/07/2013 04:27 AM, Steven D'Aprano wrote: On Sun, 06 Oct 2013 20:17:33 +0200, Marco Buttu wrote: > > >>> class FooMeta(type): >... def __call__(metacls, name, bases, namespace): >...print("FooMeta.__call__()") ... > From what I undestood, at the end of the class statement..

Re: Strange extra f added to bytes object

2013-10-06 Thread Robert Jackson
Thank you all. It was unfortunate that it was f since I thought it was some strange mistaken hex nibble. All very clear and helpful. On Sun, Oct 6, 2013 at 9:07 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Sun, 06 Oct 2013 20:39:39 -0400, Ned Batchelder wrote: > > >

Re: Variable arguments (*args, **kwargs): seeking elegance

2013-10-06 Thread Steven D'Aprano
On Sat, 05 Oct 2013 21:04:25 -0700, John Ladasky wrote: > Hi folks, > > I'm trying to make some of Python class definitions behave like the ones > I find in professional packages, such as Matplotlib. A Matplotlib class > can often have a very large number of arguments -- some of which may be > o

Re: Overriding of the type.__call__() method in a metaclass

2013-10-06 Thread Steven D'Aprano
On Sun, 06 Oct 2013 20:17:33 +0200, Marco Buttu wrote: > Hi all, I have a question about class creation and the __call__ method. > I have the following metaclass: > > >>> class FooMeta(type): > ... def __call__(metacls, name, bases, namespace): > ...print("FooMeta.__call__()") At t

Re: Select fails when cookie tried to get a numeric value

2013-10-06 Thread Piet van Oostrum
Νίκος Αλεξόπουλος writes: > i use 'cgi', but i noticed you used 'mod-wsgi'. > I want to ask you why you chose the latter? Is the latter better than > the former? > > Is it faster? Does it bahave the same way? > I my code works works with cgi, which it does, will the same code works > with mod-wcg

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread galeomaga
https://docs.google.com/file/d/0B2D69u2pweEvelh1T25ra19oZEU/edit?usp=sharing no matter call tail directly in python or using the script of tail all failed it seems it can not read next line -- https://mail.python.org/mailman/listinfo/python-list

Re: HEX to ASCII

2013-10-06 Thread Piet van Oostrum
markot...@gmail.com writes: > problem is : Traceback (most recent call last): > File "C:\Users\Marko\Desktop\hacker.org\XOR cypher.py", line 35, in > > print("Key-" + str(võti) + ": " + str("".join(tulemus2))) > TypeError: sequence item 0: expected str instance, bytes found > > If i

Re: class implementation

2013-10-06 Thread Steven D'Aprano
On Sun, 06 Oct 2013 06:15:51 -0700, markotaht wrote: > There is this class file, it has its functions and variables. What's a class file? Do you mean a file containing only a single class? > Now im > greating my program, that uses the funcions from the class. They are called "methods". >

Re: Strange extra f added to bytes object

2013-10-06 Thread Steven D'Aprano
On Sun, 06 Oct 2013 20:39:39 -0400, Ned Batchelder wrote: > When Python displays a string, is uses A byte string. > the ASCII character if it can, and a hex escape if it can't. When you > use a hex value that is a valid ASCII character, it will display the > character. Obviously for Python 2 t

Re: Odd-length string

2013-10-06 Thread Piet van Oostrum
markot...@gmail.com writes: > I fixed this problem but encountered new problem. Problem was that some parts > that came throug my decryption were 00 or 0 the first symbol so the program > didnt show them. > > NEw problem is : Traceback (most recent call last): > File "C:\Users\Marko\Desktop\h

Re: Strange extra f added to bytes object

2013-10-06 Thread Joel Goldstick
On Sun, Oct 6, 2013 at 8:38 PM, MRAB wrote: > On 06/10/2013 23:47, Robert Jackson wrote: >> >> I am very new to python so I'll apologize up front if this is some >> boneheaded thing. I am using python and pyserial to talk to an embedded >> pic processor in a piece of scientific equipment. I some

Re: Strange extra f added to bytes object

2013-10-06 Thread Terry Reedy
On 10/6/2013 6:47 PM, Robert Jackson wrote: I am very new to python so I'll apologize up front if this is some Welcome to a mostly great language. boneheaded thing. I am using python and pyserial to talk to an embedded pic processor in a piece of scientific equipment. I sometimes find the w

Re: Strange extra f added to bytes object

2013-10-06 Thread Ian Kelly
On Sun, Oct 6, 2013 at 6:39 PM, Joel Goldstick wrote: >> "f" is the same as \x66; nothing has been changed. > > really? I would expect that \x66 = 0110 0110 and f = The f here is the ASCII character f, not the hex digit f: >>> bin(ord(b'f')) '0b1100110' -- https://mail.python.org/mailman/l

Re: Strange extra f added to bytes object

2013-10-06 Thread Ned Batchelder
On 10/6/13 6:47 PM, Robert Jackson wrote: I am very new to python so I'll apologize up front if this is some boneheaded thing. I am using python and pyserial to talk to an embedded pic processor in a piece of scientific equipment. I sometimes find the when I construct the bytes object to writ

Re: Strange extra f added to bytes object

2013-10-06 Thread Joel Goldstick
On Sun, Oct 6, 2013 at 8:32 PM, Peter Pearson wrote: > On Sun, 6 Oct 2013 18:47:38 -0400, Robert Jackson wrote: >> --089e0160b7be912b9e04e81a52b2 >> Content-Type: text/plain; charset=ISO-8859-1 >> >> I am very new to python > [snip] > > Welcome. > > >> . . . I sometimes find the >> when I constru

Re: Strange extra f added to bytes object

2013-10-06 Thread MRAB
On 06/10/2013 23:47, Robert Jackson wrote: I am very new to python so I'll apologize up front if this is some boneheaded thing. I am using python and pyserial to talk to an embedded pic processor in a piece of scientific equipment. I sometimes find the when I construct the bytes object to write

Re: Strange extra f added to bytes object

2013-10-06 Thread Peter Pearson
On Sun, 6 Oct 2013 18:47:38 -0400, Robert Jackson wrote: > --089e0160b7be912b9e04e81a52b2 > Content-Type: text/plain; charset=ISO-8859-1 > > I am very new to python [snip] Welcome. > . . . I sometimes find the > when I construct the bytes object to write it adds an extra f to the first > byte.

Strange extra f added to bytes object

2013-10-06 Thread Robert Jackson
I am very new to python so I'll apologize up front if this is some boneheaded thing. I am using python and pyserial to talk to an embedded pic processor in a piece of scientific equipment. I sometimes find the when I construct the bytes object to write it adds an extra f to the first byte. For e

Re: nginx config: different projects in different directories

2013-10-06 Thread Roy Smith
In article , Jabba Laci wrote: > The problem is I can't > figure out how to configure nginx for this. This is a python mailing list. You would do better asking nginx questions on an nginx mailing list. -- https://mail.python.org/mailman/listinfo/python-list

Re: Database statements via python but database left intact

2013-10-06 Thread Piet van Oostrum
Νίκος Αλεξόπουλος writes: > i will use con.commit() from now and on because yesterdays i lost 3 > hours trying to identify what was wrong with my MySQL statements in > python and it turned out to be for no good reason. That shows how important it is to study the software that you are using, and

Re: Variable arguments (*args, **kwargs): seeking elegance

2013-10-06 Thread Peter Cacioppi
On Saturday, October 5, 2013 9:04:25 PM UTC-7, John Ladasky wrote: > Hi folks, > > > > I'm trying to make some of Python class definitions behave like the ones I > find in professional packages, such as Matplotlib. A Matplotlib class can > often have a very large number of arguments -- some o

nginx config: different projects in different directories

2013-10-06 Thread Jabba Laci
Hi, I'm playing with Flask and I would like to try it in production environment too. I managed to bring Flask together with uwsgi and nginx. My Flask application is available at the address localhost:81 . I would like to add several applications and I want them to be available under different URL

Re: class implementation

2013-10-06 Thread Terry Reedy
On 10/6/2013 9:15 AM, markot...@gmail.com wrote: There is this class file, it has its functions and variables. Now im greating my program, that uses the funcions from the class. BUt there are some functions missing from the class. So i want to add some extra funtions to the class, whidout alte

Re: Odd-length string

2013-10-06 Thread Terry Reedy
On 10/6/2013 10:37 AM, markot...@gmail.com wrote: NEw problem is : Traceback (most recent call last): File "C:\Users\Marko\Desktop\hacker.org\XOR cypher.py", line 35, in print("Key-" + str(võti) + ": " + str("".join(tulemus2))) TypeError: sequence item 0: expected str instance, bytes fo

Re: HEX to ASCII

2013-10-06 Thread MRAB
On 06/10/2013 20:07, markot...@gmail.com wrote: problem is : Traceback (most recent call last): File "C:\Users\Marko\Desktop\hacker.org\XOR cypher.py", line 35, in print("Key-" + str(võti) + ": " + str("".join(tulemus2))) TypeError: sequence item 0: expected str instance, bytes found

Re: HEX to ASCII

2013-10-06 Thread Peter Otten
markot...@gmail.com wrote: > problem is : Traceback (most recent call last): > File "C:\Users\Marko\Desktop\hacker.org\XOR cypher.py", line 35, in > > print("Key-" + str(võti) + ": " + str("".join(tulemus2))) > TypeError: sequence item 0: expected str instance, bytes found > > If i tak

HEX to ASCII

2013-10-06 Thread markotaht
problem is : Traceback (most recent call last): File "C:\Users\Marko\Desktop\hacker.org\XOR cypher.py", line 35, in print("Key-" + str(võti) + ": " + str("".join(tulemus2))) TypeError: sequence item 0: expected str instance, bytes found If i take away the join command i get this: Key

Re: Overriding of the type.__call__() method in a metaclass

2013-10-06 Thread Peter Otten
Marco Buttu wrote: > Hi all, I have a question about class creation and the __call__ method. > I have the following metaclass: > > >>> class FooMeta(type): > ... def __call__(metacls, name, bases, namespace): > ... print("FooMeta.__call__()") > > > From what I undestood, at the en

Overriding of the type.__call__() method in a metaclass

2013-10-06 Thread Marco Buttu
Hi all, I have a question about class creation and the __call__ method. I have the following metaclass: >>> class FooMeta(type): ... def __call__(metacls, name, bases, namespace): ... print("FooMeta.__call__()") From what I undestood, at the end of the class statement happens some

Re: how to read list from file

2013-10-06 Thread Ravi Sahni
On Sun, Oct 6, 2013 at 10:27 PM, Harvey Greenberg wrote: > On Saturday, October 5, 2013 7:08:08 PM UTC-6, Harvey Greenberg wrote: >> I am looping as for L in file.readlines(), where file is csv. >> >> >> >> L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that the >> first item is a

Re: how to read list from file

2013-10-06 Thread Mark Lawrence
On 06/10/2013 17:57, Harvey Greenberg wrote: On Saturday, October 5, 2013 7:08:08 PM UTC-6, Harvey Greenberg wrote: I am looping as for L in file.readlines(), where file is csv. L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that the first item is a dir and 2nd is a list, so

Re: how to read list from file

2013-10-06 Thread Harvey Greenberg
On Saturday, October 5, 2013 7:08:08 PM UTC-6, Harvey Greenberg wrote: > I am looping as for L in file.readlines(), where file is csv. > > > > L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that the first > item is a dir and 2nd is a list, so parsing with split doesn't work. Is

Re: Database statements via python but database left intact

2013-10-06 Thread Νίκος Αλεξόπουλος
Στις 6/10/2013 6:52 μμ, ο/η Adam Tauno Williams έγραψε: Are you sure that you're committing your changes (either by having autocommit set or using an explicit con.commit() call)? http://geert.vanderkelen.org/dont-forget-the-commit-in-mysql/ I dont think that is the issue, because up until now i

Re: how to read list from file

2013-10-06 Thread Ravi Sahni
On Sun, Oct 6, 2013 at 10:11 PM, Harvey Greenberg wrote: > On Saturday, October 5, 2013 7:24:39 PM UTC-6, Tim Chase wrote: >> Python 2.7.3 (default, Jan 2 2013, 13:56:14) >> [GCC 4.7.2] on linux2 >> Type "help", "copyright", "credits" or "license" for more >> information. >> >>> s = "[{

Re: how to read list from file

2013-10-06 Thread Harvey Greenberg
On Sunday, October 6, 2013 10:41:33 AM UTC-6, Harvey Greenberg wrote: > On Saturday, October 5, 2013 7:24:39 PM UTC-6, Tim Chase wrote: > > > On 2013-10-05 18:08, Harvey Greenberg wrote: > > > > > > > I am looping as for L in file.readlines(), where file is csv. > > > > > > > > > > > > >

Re: how to read list from file

2013-10-06 Thread Harvey Greenberg
On Saturday, October 5, 2013 7:24:39 PM UTC-6, Tim Chase wrote: > On 2013-10-05 18:08, Harvey Greenberg wrote: > > > I am looping as for L in file.readlines(), where file is csv. > > > > > > L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that > > > the first item is a dir and 2

Re: Database statements via python but database left intact

2013-10-06 Thread Adam Tauno Williams
>>> Are you sure that you're committing your changes (either by having >>> autocommit set or using an explicit con.commit() call)? >>> http://geert.vanderkelen.org/dont-forget-the-commit-in-mysql/ >> I dont think that is the issue, because up until now i never used >commit and >> all transaction we

Re: Database statements via python but database left intact

2013-10-06 Thread Νίκος Αλεξόπουλος
Στις 6/10/2013 12:45 πμ, ο/η Zero Piraeus έγραψε: : On Sun, Oct 06, 2013 at 12:02:14AM +0300, Νίκος Αλεξόπουλος wrote: I neved had though of than an engine type could make so much mess. MyISAM is the way to go then for my web development? Why InnoDB failed to execute the queries? Because you

Re: Database statements via python but database left intact

2013-10-06 Thread Adam Tauno Williams
>I neved had though of than an engine type could make so much mess. Because your app and how it is written is broken. >MyISAM is the way to go then for my web development? >Why InnoDB failed to execute the queries? No, nothing failed. Your app is broken. You are depending on auto commit - and

Re: Database statements via python but database left intact

2013-10-06 Thread Zero Piraeus
: On Sun, Oct 06, 2013 at 12:02:14AM +0300, Νίκος Αλεξόπουλος wrote: > I neved had though of than an engine type could make so much mess. > MyISAM is the way to go then for my web development? > Why InnoDB failed to execute the queries? Because you didn't commit. MyISAM doesn't support transactio

Re: Select fails when cookie tried to get a numeric value

2013-10-06 Thread Denis McMahon
On Sun, 06 Oct 2013 08:20:35 +0300, Νίκος Αλεξόπουλος wrote: > Thank you Denis, i didn't knew about sessions up until i saw you post. > Your code is very advanced for me to read but i will try to "decode it" > I though that if we want to read something from our visitor, something > we want, we hav

Re: Odd-length string

2013-10-06 Thread Mark Lawrence
On 06/10/2013 15:37, markot...@gmail.com wrote: I fixed this problem but encountered new problem. Problem was that some parts that came throug my decryption were 00 or 0 the first symbol so the program didnt show them. NEw problem is : Traceback (most recent call last): File "C:\Users\Marko

Re: Odd-length string

2013-10-06 Thread markotaht
I fixed this problem but encountered new problem. Problem was that some parts that came throug my decryption were 00 or 0 the first symbol so the program didnt show them. NEw problem is : Traceback (most recent call last): File "C:\Users\Marko\Desktop\hacker.org\XOR cypher.py", line 35, in

Re: Odd-length string

2013-10-06 Thread Peter Otten
markot...@gmail.com wrote: > print("Key-" + str(võti) + ": " + str(unhexlify("".join(tulemus > > IM getting this error on this line. This is the print line of a decryption > program. I wanti it to convert the tulemus which is in HEX to ASCII so i > could read it. I could use online translator

Re: Database engine bindings for Python (was: Database statements via python but database left intact)

2013-10-06 Thread Roy Smith
In article , Chris Angelico wrote: > I would hope that an absence of libpq could simply result in a > courteous exception when the module's imported, but maybe that'd be > hard to implement. It works fine. I've had this in production for a while: # Psycopg2 is only needed for a single hacky l

Re: Odd-length string

2013-10-06 Thread Roy Smith
In article <0f1b6cd6-3025-4bdc-8f80-73a51a7ed...@googlegroups.com>, markot...@gmail.com wrote: > print("Key-" + str(võti) + ": " + str(unhexlify("".join(tulemus > > IM getting this error on this line. This is the print line of a decryption > program. I wanti it to convert the tulemus which

Re: Database engine bindings for Python (was: Database statements via python but database left intact)

2013-10-06 Thread Chris Angelico
On Sun, Oct 6, 2013 at 8:10 PM, Chris “Kwpolska” Warrick wrote: > It would require Postgres around people’s (or at least packagers’) > systems, and it often gets messy when we have such requirements. I would hope that an absence of libpq could simply result in a courteous exception when the modul

Re: Image manipulation

2013-10-06 Thread Chris “Kwpolska” Warrick
On Sun, Oct 6, 2013 at 3:19 PM, wrote: > Image consists of pixels. Each pixel has its RGBA values. In python whidout > any extra downloadable modules, is there a way to get those values. I know > PIG has it but i hav Python 3.3.2 so PIG wont do. PIG? Did you mean PIL? In that case, go use Pi

Re: Image manipulation

2013-10-06 Thread markotaht
Image consists of pixels. Each pixel has its RGBA values. In python whidout any extra downloadable modules, is there a way to get those values. I know PIG has it but i hav Python 3.3.2 so PIG wont do. In java under swingx there is a command called .getRGB() and whit some manipulation to that val

Re: class implementation

2013-10-06 Thread markotaht
There is this class file, it has its functions and variables. Now im greating my program, that uses the funcions from the class. BUt there are some functions missing from the class. So i want to add some extra funtions to the class, whidout altering the original source code, but by extending it

Odd-length string

2013-10-06 Thread markotaht
print("Key-" + str(võti) + ": " + str(unhexlify("".join(tulemus IM getting this error on this line. This is the print line of a decryption program. I wanti it to convert the tulemus which is in HEX to ASCII so i could read it. I could use online translators for the line, but since i have 255

Re: Database statements via python but database left intact

2013-10-06 Thread Chris “Kwpolska” Warrick
On Sun, Oct 6, 2013 at 1:36 PM, rusi wrote: > On Sunday, October 6, 2013 2:35:24 PM UTC+5:30, Chris “Kwpolska” Warrick > wrote: >> So, instead of this, maybe we should work on getting psycopg2 to the >> top result on Googling “python sql”, or even “python mysql” with an >> anti-MySQL ad? (like vi

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Chris Angelico
On Sun, Oct 6, 2013 at 10:31 PM, Mark Lawrence wrote: > > How do I know that you're not trying to send me to a rouge site? > I assure you, the background color is most distinctly white. They probably contract with Google for their white pixel supply: http://www.google.com.au/technology/pigeonr

Re: Database statements via python but database left intact

2013-10-06 Thread rusi
On Sunday, October 6, 2013 2:35:24 PM UTC+5:30, Chris “Kwpolska” Warrick wrote: > So, instead of this, maybe we should work on getting psycopg2 to the > top result on Googling “python sql”, or even “python mysql” with an > anti-MySQL ad? (like vim was doing some time ago on Googling “emacs”) Do yo

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Mark Lawrence
On 06/10/2013 12:15, Chris Angelico wrote: On Sun, Oct 6, 2013 at 10:13 PM, Mark Lawrence wrote: Good point, but at least this time I typed "rogue" correctly, unlike on the tutor mailing list :) Obligatory TVTropes link. http://tvtropes.org/pmwiki/pmwiki.php/Main/RougeAnglesOfSatin ChrisA

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Chris Angelico
On Sun, Oct 6, 2013 at 10:13 PM, Mark Lawrence wrote: > Good point, but at least this time I typed "rogue" correctly, unlike on the > tutor mailing list :) Obligatory TVTropes link. http://tvtropes.org/pmwiki/pmwiki.php/Main/RougeAnglesOfSatin ChrisA -- https://mail.python.org/mailman/listinfo

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Mark Lawrence
On 06/10/2013 12:03, Chris Angelico wrote: On Sun, Oct 6, 2013 at 9:36 PM, Mark Lawrence wrote: Also note that a bare except is extremely bad practice, e.g. you can't stop rogue programs with a CTRL-C Or to be more accurate, a Ctrl-C will cause a jump to your except clause. Since, in this ins

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Chris Angelico
On Sun, Oct 6, 2013 at 9:36 PM, Mark Lawrence wrote: > Also note that a bare except is extremely bad practice, e.g. you can't stop > rogue programs with a CTRL-C Or to be more accurate, a Ctrl-C will cause a jump to your except clause. Since, in this instance, that's going to emit and die, Ctrl-C

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread Mark Lawrence
On 06/10/2013 05:06, Steven D'Aprano wrote: On Sat, 05 Oct 2013 20:17:32 -0700, galeomaga wrote: if __name__ == '__main__': try: thread.start_new_thread( readfile, ("Thread-1", ) ) except: print "Error: unable to start thread" Why not? If you

Re: Database engine bindings for Python (was: Database statements via python but database left intact)

2013-10-06 Thread Chris “Kwpolska” Warrick
Reposting what I said in the other thread: On Sun, Oct 6, 2013 at 12:51 AM, Chris Angelico wrote: > On Sun, Oct 6, 2013 at 8:39 AM, Ned Batchelder wrote: >> Now is a good time to go read about transactions, and committing, and the >> difference between MyISAM and InnoDB. Please don't ask more a

Re: Database statements via python but database left intact

2013-10-06 Thread Chris “Kwpolska” Warrick
On Sun, Oct 6, 2013 at 12:51 AM, Chris Angelico wrote: > On Sun, Oct 6, 2013 at 8:39 AM, Ned Batchelder wrote: >> Now is a good time to go read about transactions, and committing, and the >> difference between MyISAM and InnoDB. Please don't ask more about it here. > > It's because of threads li

Re: How to streamingly read text file and display whenever updated text

2013-10-06 Thread galeomaga
I can start thread and no exception error print, and I do not know how to use tail in python script I need to cope with MySQL in python later as all file path stored in it, it is to monitor all text files -- https://mail.python.org/mailman/listinfo/python-list

Re: Variable arguments (*args, **kwargs): seeking elegance

2013-10-06 Thread Peter Otten
John Ladasky wrote: > Hi folks, > > I'm trying to make some of Python class definitions behave like the ones I > find in professional packages, such as Matplotlib. A Matplotlib class can > often have a very large number of arguments -- some of which may be > optional, some of which will assume d