Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-11 Thread Marko Rauhamaa
Chris Angelico : > Definitely agree with this. Having a way to declare that a name is > "truly constant" would be extremely handy; I don't think it would be all that handy. I'm afraid all this type hinting will turn Python into a poor man's Java. > Maybe, but I honestly don't miss 'switch' all t

Re: Descriptors vs Property

2016-03-11 Thread Ian Kelly
On Fri, Mar 11, 2016 at 11:24 PM, Veek. M wrote: > Ian Kelly wrote: > >> On Fri, Mar 11, 2016 at 10:59 PM, Veek. M wrote: >>> Also, what's this bit: >>> self.default = default if default else type() >> >> If the default parameter has a truthy value, it gets set to >> self.default. Otherwise, the

Re: Descriptors vs Property

2016-03-11 Thread Chris Angelico
On Sat, Mar 12, 2016 at 5:24 PM, Veek. M wrote: >> Also, what's this bit: >> self.default = default if default else type() > But type() just gives me: > TypeError: type() takes 1 or 3 arguments > on py2,3 Check out the context of the original line of code and see what it's doing. It isn't the sam

Re: Descriptors vs Property

2016-03-11 Thread Veek. M
Ian Kelly wrote: > On Fri, Mar 11, 2016 at 10:59 PM, Veek. M wrote: >> A property uses the @property decorator and has @foo.setter >> @foo.deleter. >> >> A descriptor follows the descriptor protocol and implements the >> __get__ __set__ __delete__ methods. >> >> But they both do essentially the s

Re: Descriptors vs Property

2016-03-11 Thread Veek. M
Veek. M wrote: > A property uses the @property decorator and has @foo.setter > @foo.deleter. > > A descriptor follows the descriptor protocol and implements the > __get__ __set__ __delete__ methods. > > But they both do essentially the same thing, allow us to do: > foo = 10 > del foo > x = foo >

Re: Descriptors vs Property

2016-03-11 Thread Ian Kelly
On Fri, Mar 11, 2016 at 10:59 PM, Veek. M wrote: > A property uses the @property decorator and has @foo.setter > @foo.deleter. > > A descriptor follows the descriptor protocol and implements the __get__ > __set__ __delete__ methods. > > But they both do essentially the same thing, allow us to do:

Re: Descriptors vs Property

2016-03-11 Thread Chris Angelico
On Sat, Mar 12, 2016 at 4:59 PM, Veek. M wrote: > A property uses the @property decorator and has @foo.setter > @foo.deleter. > > A descriptor follows the descriptor protocol and implements the __get__ > __set__ __delete__ methods. > > But they both do essentially the same thing, allow us to do: >

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-11 Thread Steven D'Aprano
On Sat, 12 Mar 2016 12:10 pm, Dennis Lee Bieber wrote: > On Fri, 11 Mar 2016 22:24:45 +, BartC declaimed the > following: > >>On 11/03/2016 21:59, Mark Lawrence wrote: >>> On 11/03/2016 18:57, BartC wrote: >> >>> def test(): >>> s="" >>> for i in range(1000): >>> s+="*

Descriptors vs Property

2016-03-11 Thread Veek. M
A property uses the @property decorator and has @foo.setter @foo.deleter. A descriptor follows the descriptor protocol and implements the __get__ __set__ __delete__ methods. But they both do essentially the same thing, allow us to do: foo = 10 del foo x = foo So why do we have two ways of doin

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-11 Thread Rustom Mody
On Saturday, March 12, 2016 at 7:50:43 AM UTC+5:30, Chris Angelico wrote: > On Sat, Mar 12, 2016 at 12:16 PM, BartC wrote: > > You'd be surprised how much any kind of program relies on adhoc integer > > operations. It doesn't need to work with large int arrays for them to be > > important. (Look a

Psycopg2 to create a record using a FK

2016-03-11 Thread Aaron Christensen
Hello, I am running the following versions of software: Python 3.5 psycopg2==2.6.1 Postgres 9.4.5 I have 2 tables. Table User has UserId (serial PK), LastName, FirstName, Gender, DateOfBirth, and DateEnrolled. Table UserProfile has UserProfileId (serial, PK), UserId (FK), DateEntered, FaveNumb

Re: Encapsulation in Python

2016-03-11 Thread Rick Johnson
On Friday, March 11, 2016 at 9:48:22 AM UTC-6, Ian wrote: > On Thu, Mar 10, 2016 at 5:45 PM, Rick Johnson wrote: > > Many times, i would have preferred to define my module space > > across multiple files, multiple files that could share state > > without resorting to the yoga-style "import contorti

Re: Encapsulation in Python

2016-03-11 Thread Rick Johnson
On Friday, March 11, 2016 at 9:48:22 AM UTC-6, Ian wrote: > On Thu, Mar 10, 2016 at 5:45 PM, Rick Johnson > The honorable Rick Johnson wrote: > > Many times, i would have preferred to define my module space > > across multiple files, multiple files that could share state > > without resorting to th

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-11 Thread Chris Angelico
On Sat, Mar 12, 2016 at 12:16 PM, BartC wrote: > On 11/03/2016 21:36, Chris Angelico wrote: >> >> constants, and can then perform all the other optimizations you >> describe (since functions are themselves immutable, all you need is an >> identity check on the function object itself, and everythin

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-11 Thread BartC
On 11/03/2016 21:36, Chris Angelico wrote: On Sat, Mar 12, 2016 at 5:57 AM, BartC wrote: Functions are dynamic. That is, you don't know the F in F() is actually a function, even if it was defined a few lines previously, because it could have been rebound to something else. That means a runt

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-11 Thread Michael Torrie
On 03/11/2016 03:24 PM, BartC wrote: > On 11/03/2016 21:59, Mark Lawrence wrote: >> On 11/03/2016 18:57, BartC wrote: > >> def test(): >> s="" >> for i in range(1000): >> s+="*" >> print (len(s)) >> >> test() > >> The minor snag that you might like to correct with your

Re: Encapsulation in Python

2016-03-11 Thread Rick Johnson
(NOTE: My apologies to the group if this same message was sent twice. From my end, it appears to have been lost, so i'm sending again. Thanks) On Thursday, March 10, 2016 at 1:36:48 PM UTC-6, Mark Lawrence wrote: > On 10/03/2016 14:57, Dan Strohl via Python-list wrote: > >> I've been studying Obj

Re: Encapsulation in Python

2016-03-11 Thread Gregory Ewing
Rick Johnson wrote: I have witnessed the mayhem that occurs when a language does not mandate module encapsulation (Ruby, i'm looking directly at you), and while i agree with the Python designers that modules must *ALWAYS* be mandatory, i am not convinced that module space should be so strictl

Re: Encapsulation in Python

2016-03-11 Thread Rick Johnson
On Friday, March 11, 2016 at 3:28:40 AM UTC-6, Steven D'Aprano wrote: > That's one theory. Another theory is: no they shouldn't, all attributes > should be public. That most accurately models actual physical objects and > maximizes the usefulness of the attribute. > > People over-use private, and

Re: Where is Python 3.6 installer for Win64?

2016-03-11 Thread Terry Reedy
On 3/11/2016 2:37 PM, Tim Golden wrote: On 11/03/2016 19:24, Giga Image wrote: On Soruceforge, Python for Windows Extension, I noticed that they already haven a installer for Python 3.6. Where do I find Python 3.6 installer for Win64. I couldn't find it on Python.org/download page. The pywin3

Re: Perl to Python again

2016-03-11 Thread Fillmore
On 3/11/2016 7:12 PM, Martin A. Brown wrote: Aside from your csv question today, many of your questions could be answered by reading through the manual documenting the standard datatypes (note, I am assuming you are using Python 3). are you accusing me of being lazy? if that's your accusatio

Re: Perl to Python again

2016-03-11 Thread Martin A. Brown
Good afternoon Fillmore, > So, now I need to split a string in a way that the first element > goes into a string and the others in a list: > > while($line = ) { > >my ($s,@values) = split /\t/,$line; > > I am trying with: > > for line in sys.stdin: >s,values = line.strip().split("\t") >

Re: Perl to Python again

2016-03-11 Thread sohcahtoa82
On Friday, March 11, 2016 at 3:42:36 PM UTC-8, Fillmore wrote: > So, now I need to split a string in a way that the first element goes > into a string and the others in a list: > > while($line = ) { > > my ($s,@values) = split /\t/,$line; > > I am trying with: > > for line in sys.stdin:

Re: Encapsulation in Python

2016-03-11 Thread Rick Johnson
On Thursday, March 10, 2016 at 1:36:48 PM UTC-6, Mark Lawrence wrote: > On 10/03/2016 14:57, Dan Strohl via Python-list wrote: > >> I've been studying Object Oriented Theory using Java. Theoretically, all > >> attributes should be private, meaning no one except the methods itself can > >> access th

Re: Hello

2016-03-11 Thread Steven D'Aprano
On Sat, 12 Mar 2016 09:53 am, Larry Martell wrote: > Many years ago (c. 1985) I was at a job interview and the interviewer > asked me what the first thing I would do when I am presented with a new > problem that I had to code up. I gave all sorts of answers like 'do a top > down analysis of the pr

Perl to Python again

2016-03-11 Thread Fillmore
So, now I need to split a string in a way that the first element goes into a string and the others in a list: while($line = ) { my ($s,@values) = split /\t/,$line; I am trying with: for line in sys.stdin: s,values = line.strip().split("\t") print(s) but no luck: ValueError: t

Re: argparse

2016-03-11 Thread Ian Kelly
On Fri, Mar 11, 2016 at 4:18 PM, Fillmore wrote: > > Playing with ArgumentParser. I can't find a way to override the -h and > --help options so that it provides my custom help message. > > -h, --help show this help message and exit > > Here is what I am trying: > > parser = argparse.Argu

Re: argparse

2016-03-11 Thread Fillmore
On 3/11/2016 6:26 PM, Larry Martell wrote: am I missing something obvious? https://docs.python.org/2/library/argparse.html#usage you rock! -- https://mail.python.org/mailman/listinfo/python-list

Re: argparse

2016-03-11 Thread Larry Martell
On Fri, Mar 11, 2016 at 6:18 PM, Fillmore wrote: > > > Playing with ArgumentParser. I can't find a way to override the -h and --help > options so that it provides my custom help message. > > -h, --help show this help message and exit > > Here is what I am trying: > > parser = argparse.A

Re: argparse

2016-03-11 Thread Bob Gailer
On Mar 11, 2016 6:20 PM, "Fillmore" wrote: > > > Playing with ArgumentParser. I can't find a way to override the -h and --help options so that it provides my custom help message. > > -h, --help show this help message and exit > > Here is what I am trying: > > parser = argparse.ArgumentPa

argparse

2016-03-11 Thread Fillmore
Playing with ArgumentParser. I can't find a way to override the -h and --help options so that it provides my custom help message. -h, --help show this help message and exit Here is what I am trying: parser = argparse.ArgumentParser("csresolver.py",add_help=False) parser.add_argumen

Re: Hello

2016-03-11 Thread Larry Martell
On Fri, Mar 11, 2016 at 4:49 AM, Steven D'Aprano wrote: > On Fri, 11 Mar 2016 02:28 pm, rubengoods...@yahoo.com wrote: > > > I am having trouble installing the Python software. > > Make sure your computer is turned on. I can't tell you how many times I've > tried to install Python, and I type com

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-11 Thread Mark Lawrence
On 11/03/2016 22:24, BartC wrote: On 11/03/2016 21:59, Mark Lawrence wrote: On 11/03/2016 18:57, BartC wrote: def test(): s="" for i in range(1000): s+="*" print (len(s)) test() The minor snag that you might like to correct with your microbenchmark, which any e

Re: hasattr() or "x in y"?

2016-03-11 Thread Grant Edwards
On 2016-03-11, Charles T. Smith wrote: > On Fri, 11 Mar 2016 22:00:41 +, Grant Edwards wrote: > >> Since they behave differently, perhaps the question ought to be "which >> does what you want to do?" > > For parsed msgs, I had this: > > elif hasattr (msg.msgBody, 'request'): > >

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-11 Thread BartC
On 11/03/2016 21:59, Mark Lawrence wrote: On 11/03/2016 18:57, BartC wrote: def test(): s="" for i in range(1000): s+="*" print (len(s)) test() The minor snag that you might like to correct with your microbenchmark, which any experienced Python programmer knows,

Re: hasattr() or "x in y"?

2016-03-11 Thread Charles T. Smith
On Fri, 11 Mar 2016 22:00:41 +, Grant Edwards wrote: > Since they behave differently, perhaps the question ought to be "which > does what you want to do?" For parsed msgs, I had this: elif hasattr (msg.msgBody, 'request'): It occurred to me that this was less abstruse:

Re: hasattr() or "x in y"?

2016-03-11 Thread Mark Lawrence
On 11/03/2016 22:00, Grant Edwards wrote: On 2016-03-11, Charles T. Smith wrote: From the performance point of view, which is better: - hasattr() - x in y Dunno, is red an even or odd color? How many pancakes does it take to cover a doghouse? "x" in "asdf" False "x" in "xyz" True

Re: hasattr() or "x in y"?

2016-03-11 Thread Grant Edwards
On 2016-03-11, Charles T. Smith wrote: > From the performance point of view, which is better: > - hasattr() > - x in y Dunno, is red an even or odd color? How many pancakes does it take to cover a doghouse? >>> "x" in "asdf" False >>> "x" in "xyz" True >>> "asdf".hasattr("x") Traceback (most

Re: hasattr() or "x in y"?

2016-03-11 Thread Mark Lawrence
On 11/03/2016 21:53, Charles T. Smith wrote: On Fri, 11 Mar 2016 21:44:27 +, Charles T. Smith wrote: From the performance point of view, which is better: - hasattr() - x in y TIA cts I just realized that "in" won't look back through the class hierarchy... that clearly makes them not in

Re: hasattr() or "x in y"?

2016-03-11 Thread Chris Angelico
On Sat, Mar 12, 2016 at 8:53 AM, Charles T. Smith wrote: > On Fri, 11 Mar 2016 21:44:27 +, Charles T. Smith wrote: > >> From the performance point of view, which is better: - hasattr() >> - x in y >> >> TIA >> cts > > > I just realized that "in" won't look back through the class hierarchy... >

Re: hasattr() or "x in y"?

2016-03-11 Thread Charles T. Smith
On Fri, 11 Mar 2016 21:44:27 +, Charles T. Smith wrote: > From the performance point of view, which is better: - hasattr() > - x in y > > TIA > cts I just realized that "in" won't look back through the class hierarchy... that clearly makes them not interchangable, but given we're only inter

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-11 Thread Mark Lawrence
On 11/03/2016 18:57, BartC wrote: Anyway, I've listed some of the stumbling blocks I think that Python has in making it bit faster: http://pastebin.com/WfUfK3bc The String Append Benchmark This is a microbenchmark, but makes use of a technique I use extensively (creating a file for example

Re: hasattr() or "x in y"?

2016-03-11 Thread Chris Angelico
On Sat, Mar 12, 2016 at 8:44 AM, Charles T. Smith wrote: > From the performance point of view, which is better: > - hasattr() > - x in y > Mu. They do completely different things. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

hasattr() or "x in y"?

2016-03-11 Thread Charles T. Smith
>From the performance point of view, which is better: - hasattr() - x in y TIA cts -- https://mail.python.org/mailman/listinfo/python-list

The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-11 Thread Chris Angelico
On Sat, Mar 12, 2016 at 5:57 AM, BartC wrote: > Anyway, I've listed some of the stumbling blocks I think that Python has in > making it bit faster: http://pastebin.com/WfUfK3bc > Much easier to discuss text that's inline, so I'm taking this out of pastebin. > Functions are dynamic. That is, you

Re: issue with CVS module

2016-03-11 Thread Fillmore
On 3/11/2016 2:41 PM, Fillmore wrote: I have a TSV file containing a few strings like this (double quotes are part of the string): A big thank you to everyone who helped with this and with other questions. My porting of one of my Perl scripts to Python is over now that the two scripts produ

Re: issue with CVS module

2016-03-11 Thread Fillmore
On 3/11/2016 4:15 PM, Mark Lawrence wrote: https://docs.python.org/3/library/csv.html#csv.Dialect.doublequote thanks, but my TSV is not using any particular dialect as far as I understand... Thank you, anyway -- https://mail.python.org/mailman/listinfo/python-list

Re: issue with CVS module

2016-03-11 Thread Fillmore
On 3/11/2016 4:14 PM, MRAB wrote: >>> import csv >>> s = '"Please preserve my doublequotes"\ttext1\ttext2' >>> reader = csv.reader([s], delimiter='\t', quotechar=None) >>> for row in reader: ... print(row[0]) ... "Please preserve my doublequotes" >>> This worked! thank you MRAB --

Re: issue with csv module (subject module name spelling correction, too)

2016-03-11 Thread Martin A. Brown
Good afternoon Fillmore, import csv s = '"Please preserve my doublequotes"\ttext1\ttext2' reader = csv.reader([s], delimiter='\t') > How do I instruct the reader to preserve my doublequotes? Change the quoting used by the dialect on the csv reader instance: reader = csv.reader

Re: issue with CVS module

2016-03-11 Thread Mark Lawrence
On 11/03/2016 19:41, Fillmore wrote: I have a TSV file containing a few strings like this (double quotes are part of the string): '"pragma: CacheHandler=08616B7E907744E026C9F044250EA55844CCFD52"' After Python and the CVS module has read the file and re-printed the value, the string has become:

Re: issue with CVS module

2016-03-11 Thread MRAB
On 2016-03-11 20:49, Fillmore wrote: On 3/11/2016 2:41 PM, Fillmore wrote: Is there some directive I can give CVS reader to tell it to stop screwing with my text? OK, I think I reproduced my problem at the REPL: >>> import csv >>> s = '"Please preserve my doublequotes"\ttext1\ttext2' >>

Re: issue with CVS module

2016-03-11 Thread Ben Finney
Fillmore writes: > Possibly, but I am having a hard time letting it know that it should > leave each and every char alone You're using the wrong module, then. To use the ‘csv’ module is to have the sequence of characters parsed to extract component values, which cannot also “leave each and every

Re: issue with CVS module

2016-03-11 Thread mm0fmf
On 11/03/2016 20:32, Fillmore wrote: myReader = csv.reader(csvfile, delimiter='\t',quotechar='') From reading that the quotechar is null. You have a single quote and single quote with nothing in the middle. Try this: myReader = csv.reader(csvfile, delimiter='\t',quotechar="'") i.e doublequ

Re: issue with CVS module

2016-03-11 Thread Fillmore
On 3/11/2016 2:41 PM, Fillmore wrote: Is there some directive I can give CVS reader to tell it to stop screwing with my text? OK, I think I reproduced my problem at the REPL: >>> import csv >>> s = '"Please preserve my doublequotes"\ttext1\ttext2' >>> reader = csv.reader([s], delimiter='\t') >

Re: issue with CVS module

2016-03-11 Thread Fillmore
On 3/11/2016 3:05 PM, Joel Goldstick wrote: Enter the python shell. Import csv then type help(csv) It is highly configurable Possibly, but I am having a hard time letting it know that it should leave each and every char alone, ignore quoting and just handle strings as strings. I tried pl

Re: issue with CVS module

2016-03-11 Thread Joel Goldstick
On Fri, Mar 11, 2016 at 2:41 PM, Fillmore wrote: > > I have a TSV file containing a few strings like this (double quotes are > part of the string): > > '"pragma: CacheHandler=08616B7E907744E026C9F044250EA55844CCFD52"' > > After Python and the CVS module has read the file and re-printed the > valu

Re: non printable (moving away from Perl)

2016-03-11 Thread Ben Finney
Fillmore writes: > On 3/11/2016 2:23 PM, MRAB wrote: > > Python 3 (Unicode) strings have an .isprintable method: > > > > mystring.isprintable() > > my strings are UTF-8. Will it work there too? You need to always be clear on the difference between text (the Python 3 ‘str’ type) versus bytes. It

Re: Where is Python 3.6 installer for Win64?

2016-03-11 Thread Giga Image
On Friday, March 11, 2016 at 11:38:09 AM UTC-8, Tim Golden wrote: > On 11/03/2016 19:24, Giga Image wrote: > > On Soruceforge, Python for Windows Extension, I noticed that they > > already haven a installer for Python 3.6. > > > > Where do I find Python 3.6 installer for Win64. I couldn't find it o

issue with CVS module

2016-03-11 Thread Fillmore
I have a TSV file containing a few strings like this (double quotes are part of the string): '"pragma: CacheHandler=08616B7E907744E026C9F044250EA55844CCFD52"' After Python and the CVS module has read the file and re-printed the value, the string has become: 'pragma: CacheHandler=08616B7E90

Re: non printable (moving away from Perl)

2016-03-11 Thread Fillmore
On 3/11/2016 2:23 PM, MRAB wrote: On 2016-03-11 00:07, Fillmore wrote: Here's another handy Perl regex which I am not sure how to translate to Python. I use it to avoid processing lines that contain funny chars... if ($string =~ /[^[:print:]]/) {next OUTER;} :) Python 3 (Unicode) strings h

Re: Where is Python 3.6 installer for Win64?

2016-03-11 Thread Tim Golden
On 11/03/2016 19:24, Giga Image wrote: On Soruceforge, Python for Windows Extension, I noticed that they already haven a installer for Python 3.6. Where do I find Python 3.6 installer for Win64. I couldn't find it on Python.org/download page. The pywin32 crew are always ahead of the game: they

Where is Python 3.6 installer for Win64?

2016-03-11 Thread Giga Image
On Soruceforge, Python for Windows Extension, I noticed that they already haven a installer for Python 3.6. Where do I find Python 3.6 installer for Win64. I couldn't find it on Python.org/download page. Thanks! -- https://mail.python.org/mailman/listinfo/python-list

Re: non printable (moving away from Perl)

2016-03-11 Thread MRAB
On 2016-03-11 00:07, Fillmore wrote: Here's another handy Perl regex which I am not sure how to translate to Python. I use it to avoid processing lines that contain funny chars... if ($string =~ /[^[:print:]]/) {next OUTER;} :) Python 3 (Unicode) strings have an .isprintable method: mystri

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-11 Thread BartC
On 11/03/2016 05:29, Steven D'Aprano wrote: On Fri, 11 Mar 2016 06:26 am, Mark Lawrence wrote: No mention of speed anywhere, but then what does that silly old Tim Peters know about anything? The truth is, most people don't -- most Python code uses very little of the dynamic features that ge

Re: non printable (moving away from Perl)

2016-03-11 Thread Ian Kelly
On Fri, Mar 11, 2016 at 9:34 AM, Wolfgang Maier wrote: > On 11.03.2016 15:23, Fillmore wrote: >> >> On 03/11/2016 07:13 AM, Wolfgang Maier wrote: >>> >>> One lesson for Perl regex users is that in Python many things can be >>> solved without regexes. >>> How about defining: >>> >>> printable = {ch

Re: Encapsulation in Python

2016-03-11 Thread jmp
On 03/10/2016 02:41 PM, Ben Mezger wrote: Hi all, I've been studying Object Oriented Theory using Java. Theoretically, all attributes should be private, meaning no one except the methods itself can access the attribute; public class Foo { private int bar; ... Normally in Java, we wou

Re: non printable (moving away from Perl)

2016-03-11 Thread Wolfgang Maier
On 11.03.2016 15:23, Fillmore wrote: On 03/11/2016 07:13 AM, Wolfgang Maier wrote: One lesson for Perl regex users is that in Python many things can be solved without regexes. How about defining: printable = {chr(n) for n in range(32, 127)} then using: if (set(my_string) - set(printable)):

Re: Encapsulation in Python

2016-03-11 Thread Ian Kelly
On Thu, Mar 10, 2016 at 5:45 PM, Rick Johnson wrote: > Many times, i would have preferred to define my module space > across multiple files, multiple files that could share state > without resorting to the yoga-style "import contortions", > and/or the dreaded "circular import nightmares" that plag

Re: non printable (moving away from Perl)

2016-03-11 Thread Peter Otten
Fillmore wrote: > On 03/11/2016 07:13 AM, Wolfgang Maier wrote: >> One lesson for Perl regex users is that in Python many things can be >> solved without regexes. How about defining: >> >> printable = {chr(n) for n in range(32, 127)} >> >> then using: >> >> if (set(my_string) - set(printable)): >>

Re: Encapsulation in Python

2016-03-11 Thread Ian Kelly
On Fri, Mar 11, 2016 at 2:29 AM, dieter wrote: > If you are really interested to enforce Java encapsulation policies > (access to attributes via "getter/setter" only), you will need > to use your own "metaclass". > > The "metaclass" has a similar relation to a class as a class to > an instance: i.

RE: Remote Rsponse Socket Connection

2016-03-11 Thread Joaquin Alzola
> I received this from a socket connection. This is the received data: > > Adding more info --> the response is a mixture of hex numbers + ascii > > [...] > > How is the best way to decode such reply from server? >https://docs.python.org/3/library/struct.html#examples Thank Marko will take alook i

Re: non printable (moving away from Perl)

2016-03-11 Thread Fillmore
On 03/11/2016 07:13 AM, Wolfgang Maier wrote: One lesson for Perl regex users is that in Python many things can be solved without regexes. How about defining: printable = {chr(n) for n in range(32, 127)} then using: if (set(my_string) - set(printable)): break seems computationally heav

Re: Remote Rsponse Socket Connection

2016-03-11 Thread Marko Rauhamaa
Joaquin Alzola : > I received this from a socket connection. This is the received data: > > Adding more info --> the response is a mixture of hex numbers + ascii > > [...] > > How is the best way to decode such reply from server? https://docs.python.org/3/library/struct.html#examples Marko --

Re: Remote Rsponse Socket Connection

2016-03-11 Thread Andrew Berg
On 2016.03.11 07:17, Joaquin Alzola wrote: > HI Guys > > I received this from a socket connection. This is the received data: > > Adding more info --> the response is a mixture of hex numbers + ascii > > From python function --> data = s.recv(2048) > > b'\x01\x00\x00D\x00\x00\x01\x18\x00\x00\x0

RE: Remote Rsponse Socket Connection

2016-03-11 Thread Joaquin Alzola
HI Guys I received this from a socket connection. This is the received data: Adding more info --> the response is a mixture of hex numbers + ascii >From python function --> data = s.recv(2048) b'\x01\x00\x00D\x00\x00\x01\x18\x00\x00\x00\x00p2E\xe1+\xe8xG\x00\x00\x01\x08@\x00\x00\x0bmmm\x00\x00\

Re: non printable (moving away from Perl)

2016-03-11 Thread Marko Rauhamaa
Wolfgang Maier : > On 11.03.2016 13:13, Wolfgang Maier wrote: >> One lesson for Perl regex users is that in Python many things can be >> solved without regexes. How about defining: >> >> printable = {chr(n) for n in range(32, 127)} >> >> then using: >> >> if (set(my_string) - set(printable)): >>

Re:

2016-03-11 Thread Igor Korot
Hi, On Fri, Mar 11, 2016 at 6:10 AM, Swetha Reddy wrote: > Hi, i just downloaded the python software. when i search for it in my > downloads, a folder called python 3.5.1 ( 32 bit ) Setup is seen. But when > i try to open it, it has only three options : Modify, Repair and uninstall. > there are n

Re: non printable (moving away from Perl)

2016-03-11 Thread Wolfgang Maier
On 11.03.2016 13:13, Wolfgang Maier wrote: One lesson for Perl regex users is that in Python many things can be solved without regexes. How about defining: printable = {chr(n) for n in range(32, 127)} then using: if (set(my_string) - set(printable)): break Err, I meant: if (set(my_str

Re: non printable (moving away from Perl)

2016-03-11 Thread Wolfgang Maier
One lesson for Perl regex users is that in Python many things can be solved without regexes. How about defining: printable = {chr(n) for n in range(32, 127)} then using: if (set(my_string) - set(printable)): break On 11.03.2016 01:07, Fillmore wrote: Here's another handy Perl regex wh

Re: Text input with keyboard, via input methods

2016-03-11 Thread Rustom Mody
On Friday, March 11, 2016 at 10:21:35 AM UTC+5:30, Larry Hudson wrote: > On 03/09/2016 11:54 PM, Rustom Mody wrote: > [...] > > In between these two extremes we have many possibilities > > - ibus/gchar etc > > - compose key > > - alternate keyboard layouts > > > > Using all these levels judiciously

Re: (unknown)

2016-03-11 Thread Mark Lawrence
On 11/03/2016 11:10, Swetha Reddy wrote: Hi, i just downloaded the python software. when i search for it in my downloads, a folder called python 3.5.1 ( 32 bit ) Setup is seen. But when i try to open it, it has only three options : Modify, Repair and uninstall. there are no other files of python

Re: HDF5 data set, unable to read contents

2016-03-11 Thread Peter Otten
varun...@gmail.com wrote: > Hello everyone, > > I recently came across a package called matrix2latex which simplifies the > creation of very large tables. So, I saved my data in .mat format using > the '-v7.3' extension so that they can be read by python. > > Now, when I try to read these files,

[no subject]

2016-03-11 Thread Swetha Reddy
Hi, i just downloaded the python software. when i search for it in my downloads, a folder called python 3.5.1 ( 32 bit ) Setup is seen. But when i try to open it, it has only three options : Modify, Repair and uninstall. there are no other files of python in my computer except this. Where can i get

Re: context managers inline?

2016-03-11 Thread jmp
On 03/10/2016 07:59 PM, Neal Becker wrote: sohcahto...@gmail.com wrote: On Thursday, March 10, 2016 at 10:33:47 AM UTC-8, Neal Becker wrote: Is there a way to ensure resource cleanup with a construct such as: x = load (open ('my file', 'rb)) Is there a way to ensure this file gets closed?

Re: Other difference with Perl: Python scripts in a pipe

2016-03-11 Thread Jussi Piitulainen
Alan Bawden writes: > Fillmore writes: > >> On 3/10/2016 7:08 PM, INADA Naoki wrote: > ... >> I don't like it. It makes Python not so good for command-line utilities >> > > You can easily restore the standard Unix command-line-friendly behavior > by doing: > > import signal > signal.signal(

Re: Hello

2016-03-11 Thread Steven D'Aprano
On Fri, 11 Mar 2016 02:28 pm, rubengoods...@yahoo.com wrote: > I am having trouble installing the Python software. Make sure your computer is turned on. I can't tell you how many times I've tried to install Python, and I type commands and click icons and nothing happens. It's really frustrating w

Re: HDF5 data set, unable to read contents

2016-03-11 Thread dieter
varun...@gmail.com writes: > I recently came across a package called matrix2latex which simplifies the > creation of very large tables. So, I saved my data in .mat format using the > '-v7.3' extension so that they can be read by python. > > Now, when I try to read these files, I'm having some pr

Re: Encapsulation in Python

2016-03-11 Thread Steven D'Aprano
On Fri, 11 Mar 2016 12:41 am, Ben Mezger wrote: > Hi all, > > I've been studying Object Oriented Theory using Java. Theoretically, all > attributes should be private, meaning no one except the methods itself > can access the attribute; (Note: in the following, when I say "encapsulation", I am ac

Re: a clarification on the "global" statement sought

2016-03-11 Thread Chris Angelico
On Fri, Mar 11, 2016 at 8:09 PM, Charles T. Smith wrote: > "Python deals with variables the other way around. >They are local, if not otherwise declared. >... > def f(): > print(s) > s = "I love Paris in the summer!" > f() > ... > As there is no local variable

Re: Encapsulation in Python

2016-03-11 Thread dieter
Ben Mezger writes: > I've been studying Object Oriented Theory using Java. Theoretically, all > attributes should be private, meaning no one except the methods itself > can access the attribute; > > public class Foo { > private int bar; > ... > > Normally in Java, we would write getters a

Re: a clarification on the "global" statement sought

2016-03-11 Thread Peter Otten
Charles T. Smith wrote: > On Fri, 11 Mar 2016 19:29:20 +1100, Chris Angelico wrote: > >> Usefully? Never. >> >> Simple question - simple answer :) >> >> ChrisA > > > Right, that was the expected answer as well. I just ran into that in > legacy code, checked out the documentation and couldn't

Re: a clarification on the "global" statement sought

2016-03-11 Thread eryk sun
On Fri, Mar 11, 2016 at 2:13 AM, Charles T. Smith wrote: > When might a "global" statement be used in the outermost level of a module? You wouldn't need this in a normal module, because locals and globals are the same. It may be useful if you're using exec with separate locals and globals, and ne

Re: context managers inline?

2016-03-11 Thread Jussi Piitulainen
Paul Rubin writes: > Jussi Piitulainen writes: >> return ModeIO(f.read()) > > These suggestions involving f.read() assume the file contents are small > enough to reasonably slurp into memory. That's unlike the original > where "load" receives a stream and might process it piecewise. If y

Re: a clarification on the "global" statement sought

2016-03-11 Thread Charles T. Smith
On Fri, 11 Mar 2016 08:31:22 +, Mark Lawrence wrote: > Never. Hopefully this > http://www.python-course.eu/python3_global_vs_local_variables.php can > explain it better than I can :) The article is good, I'm glad to have confirmed what I have so empirical stumbled over. ... Irrespective of t

Re: How to program round this poplib error?

2016-03-11 Thread dieter
c...@isbd.net writes: > I have a (fairly simple) Python program that scans through a > 'catchall' E-Mail address for things that *might* be for me. It sends > anything that could be for me to my main E-Mail and discards the rest. > > However I *occasionally* get an error from it as follows:- > >

Remote Rsponse Socket Connection

2016-03-11 Thread Joaquin Alzola
HI Guys I received this from a socket connection. This is the received data: >From python function --> data = s.recv(2048) b'\x01\x00\x00D\x00\x00\x01\x18\x00\x00\x00\x00p2E\xe1+\xe8xG\x00\x00\x01\x08@\x00\x00\x0bmmm\x00\x00\x00\x01(@\x00\x00\x16mmm.xx.com\x00\x00\x00\x00\x01\x0c@\x00\x00\x0

Re: a clarification on the "global" statement sought

2016-03-11 Thread Charles T. Smith
On Fri, 11 Mar 2016 19:29:20 +1100, Chris Angelico wrote: > Usefully? Never. > > Simple question - simple answer :) > > ChrisA Right, that was the expected answer as well. I just ran into that in legacy code, checked out the documentation and couldn't really make that out. So I figured I bet

Re: Other difference with Perl: Python scripts in a pipe

2016-03-11 Thread Ethan Furman
On 03/10/2016 04:26 PM, Fillmore wrote: On 3/10/2016 7:08 PM, INADA Naoki wrote: No. I see it usually. Python's zen says: Errors should never pass silently. Unless explicitly silenced. When failed to write to stdout, Python should raise Exception. You can silence explicitly when it's

Re: a clarification on the "global" statement sought

2016-03-11 Thread Mark Lawrence
On 11/03/2016 08:13, Charles T. Smith wrote: When might a "global" statement be used in the outermost level of a module? Never. Hopefully this http://www.python-course.eu/python3_global_vs_local_variables.php can explain it better than I can :) (whereby, I assume a module is equivalent to

Re: a clarification on the "global" statement sought

2016-03-11 Thread Chris Angelico
On Fri, Mar 11, 2016 at 7:13 PM, Charles T. Smith wrote: > When might a "global" statement be used in the outermost level of a module? > > (whereby, I assume a module is equivalent to a python file, correct?) > Usefully? Never. Simple question - simple answer :) ChrisA -- https://mail.python.o

  1   2   >