On 17Nov2012 03:12, Steven D'Aprano
wrote:
| Oh for the day I can drop support for Python 2.4 and 2.5...
|
|
| I have some code that needs to run in any version of Python from 2.4
| onwards. Yes, it must be a single code base.
|
| I wish to catch an exception and bind the exception to a name
Oh for the day I can drop support for Python 2.4 and 2.5...
I have some code that needs to run in any version of Python from 2.4
onwards. Yes, it must be a single code base.
I wish to catch an exception and bind the exception to a name.
In Python 2.6 onwards, I can do:
try:
something()
e
On Fri, Nov 16, 2012 at 6:30 PM, Steven D'Aprano
wrote:
> Does anyone use StandardError in their own code? In Python 2, I normally
> inherit from StandardError rather than Exception. Should I stop and just
> inherit from Exception in both 2 and 3?
According to the docs, StandardError is for built
The exception hierarchy in Python 3 is shallower than in Python 2.
Here is a partial list of exceptions in Python 2:
BaseException
+-- SystemExit
+-- KeyboardInterrupt
+-- GeneratorExit
+-- Exception
+-- StandardError
|+-- AttributeError
|+-- ImportError
|
On Fri, Nov 16, 2012 at 5:33 PM, Nobody wrote:
> If you need to support either, you can parse it as ISO-8859-1 then
> explicitly convert C1 codes to their Windows-1252 equivalents as a
> post-processing step, e.g. using the .translate() method.
Or just create a custom codec by taking the one in
L
On Fri, 16 Nov 2012 13:44:03 -0800, buck wrote:
> When a user agent [browser] would otherwise use a character encoding given
> in the first column [ISO-8859-1, aka latin1] of the following table to
> either convert content to Unicode characters or convert Unicode characters
> to bytes, it must ins
On Fri, Nov 16, 2012 at 4:27 PM, wrote:
> They are indeed undefined: ftp://std.dkuug.dk/JTC1/sc2/wg3/docs/n411.pdf
>
> """ The shaded positions in the code table correspond
> to bit combinations that do not represent graphic
> characters. Their use is outside the scope of
> ISO/IEC 88
On Thu, 15 Nov 2012 20:07:38 -0500, Roy Smith wrote:
>>> gethostbyname() and getaddrinfo() use the NSS (name-service switch)
>> mechanism, which is configured via /etc/nsswitch.conf. Depending upon
>> configuration, hostnames can be looked up via a plain text file
>> (/etc/hosts), Berkeley DB file
On 11/16/2012 06:27 PM, b...@yelp.com wrote:
> (doublespaced nonsense deleted. GoogleGropups strikes again.)
> This creates a non-reversible encoding, and loss of data, which isn't
> acceptable for my application.
So tell us more about your application. If you have data which is
invalid, and yo
On Friday, November 16, 2012 2:34:32 PM UTC-8, Ian wrote:
> On Fri, Nov 16, 2012 at 2:44 PM, wrote:
>
> > Latin1 has a block of 32 undefined characters.
>
>
> These characters are not undefined. 0x80-0x9f are the C1 control
> codes in Latin-1, much as 0x00-0x1f are the C0 control codes, and
>
Hello,
I'm interested in refining some tests I do for a hobby of mine beyond the
traditional 'one factor at a time' (OFAT) method. I have been looking at
'design of experiment' (DoE) methods and they look promising. The problem
is that most of the software packages that aid in the setup and anal
On Fri, Nov 16, 2012 at 2:44 PM, wrote:
> Latin1 has a block of 32 undefined characters.
These characters are not undefined. 0x80-0x9f are the C1 control
codes in Latin-1, much as 0x00-0x1f are the C0 control codes, and
their Unicode mappings are well defined.
http://tools.ietf.org/html/rfc134
On 11/16/2012 2:37 PM, Eric Frederich wrote:
So I inspected the process through /proc//maps
That seemed to show what libraries had been loaded (though there is
probably an easier way to do this).
In any case, I found that if I import smtplib before logging in I see
these get loaded...
/o
Latin1 has a block of 32 undefined characters.
Windows-1252 (aka cp1252) fills in 27 of these characters but leaves five
undefined: 0x81, 0x8D, 0x8F, 0x90, 0x9D
The byte 0x81 decoded with latin gives the unicode 0x81.
Decoding the same byte with windows-1252 yields a stack trace with
`UnicodeDec
bruceg113...@gmail.com wrote:
On Thursday, November 15, 2012 11:16:08 PM UTC-5, Ethan Furman wrote:
Emile van Sebille wrote:
Using a decorator works when named arguments are not used. When named
arguments are used, unexpected keyword error is reported. Is there a
simple fix?
Extend def wrap
On Tuesday, November 13, 2012 4:12:52 PM UTC+5:30, Peter Otten wrote:
> subhabangal...@gmail.com wrote:
>
>
>
> > Dear Group,
>
> > To improve my code writing I am trying to read good codes. Now, I have
>
> > received a code,as given below,(apology for slight indentation errors) the
>
> > cod
Eric Frederich writes:
> I created some bindings to a 3rd party library.
> I have found that when I run Python and import smtplib it works fine.
> If I first log into the 3rd party application using my bindings however I
> get a bunch of errors.
>
> What do you think this 3rd party login could be
So I inspected the process through /proc//maps
That seemed to show what libraries had been loaded (though there is
probably an easier way to do this).
In any case, I found that if I import smtplib before logging in I see these
get loaded...
/opt/foo/python27/lib/python2.7/lib-dynload/_ssl.so
On Nov 16, 7:08 pm, Roy Smith wrote:
> These days, if I was writing something that needed a config file and I
> didn't want to do "import settings" for whatever reason, I would go with
> YAML. It seems to give an attractive mix of:
>
> * supporting complex data structures
> * easy to for humans t
> There is a ready made and well tested lazy decorator at
> http://pypi.python.org/pypi/lazy. I even has a better name. ;-)
I was ignorantly unaware of this module. You've saved me a few lines of code
every time I want to achieve lazy loading - thanks :)
> Since people seem to come up with the
On Thursday, November 15, 2012 11:16:08 PM UTC-5, Ethan Furman wrote:
> Emile van Sebille wrote:
>
>
> >
>
> >> Using a decorator works when named arguments are not used. When named
>
> >> arguments are used, unexpected keyword error is reported. Is there a
>
> >> simple fix?
>
> >
>
> >
Ulrich Eckhardt wrote:
> in general importing configuration data by loading and
> executing code is a questionable approach. The problem is in particular
> that the code parser is always more strict with the syntax than a
> configuration file should be. Also, it presents the danger of code
>
On 11/16/12 07:04, Thomas Bach wrote:
> On Fri, Nov 16, 2012 at 01:48:49PM +0100, chip9munk wrote:
>> configparser has four functions: get, getboolean, getfloat and getint.
>>
>> how do I get list from cfg file?!
>
> AFAIK you have to parse the list yourself. Something like
>
> my_list = [ s.stri
On 11/16/2012 2:04 PM, Thomas Bach wrote:
On Fri, Nov 16, 2012 at 01:48:49PM +0100, chip9munk wrote:
configparser has four functions: get, getboolean, getfloat and getint.
how do I get list from cfg file?!
AFAIK you have to parse the list yourself. Something like
my_list = [ s.strip() for s
On 11/16/2012 2:02 PM, Ulrich Eckhardt wrote:
Am 16.11.2012 13:06, schrieb chip9munk:
I would like to use conf file to get all the variables in my code. And
it works great. I use the following (simple example):
execfile("example.conf", config)
print config["value1"]
and it works like a ch
Am 16.11.2012 13:06, schrieb chip9munk:
I would like to use conf file to get all the variables in my code. And
it works great. I use the following (simple example):
execfile("example.conf", config)
print config["value1"]
and it works like a charm.
This works, but in general importing con
On Fri, Nov 16, 2012 at 01:48:49PM +0100, chip9munk wrote:
> configparser has four functions: get, getboolean, getfloat and getint.
>
> how do I get list from cfg file?!
AFAIK you have to parse the list yourself. Something like
my_list = [ s.strip() for s in cp.get('section', 'option').split(','
On 11/16/2012 1:35 PM, rusi wrote:
And there may be better options (allows nested sections)
http://www.voidspace.org.uk/python/configobj.html
but it does not seem to work with python 3
I have an issue...
configparser has four functions: get, getboolean, getfloat and getint.
how do I get list
On 16.11.2012, at 11:54, Andriy Kornatskyy wrote:
>> Subject: Re: Lazy Attribute
>> From: ste...@epy.co.at
>> Date: Fri, 16 Nov 2012 11:45:32 +0100
>> To: python-list@python.org
>>
>> On 16.11.2012, at 11:29, Steven D'Aprano wrote:
>>
>>> I'm very vaguely leaning towards this as the least-worst
On Nov 16, 5:15 pm, chip9munk <"chip9munk[SSSpAm"@gmail.com> wrote:
> ok, I've got it:http://docs.python.org/3.1/library/configparser.html
>
> works like a charm!
>
> Sorry for the unnecessary question. :/
Not an issue.
And there may be better options (allows nested sections)
http://www.voidspace
ok, I've got it:
http://docs.python.org/3.1/library/configparser.html
works like a charm!
Sorry for the unnecessary question. :/
--
http://mail.python.org/mailman/listinfo/python-list
Hi all!
I would like to use conf file to get all the variables in my code. And
it works great. I use the following (simple example):
execfile("example.conf", config)
print config["value1"]
and it works like a charm.
Now the problem is I do not know how to edit the conf file...
let us say
On 15.11.2012, at 20:33, Andriy Kornatskyy wrote:
> A lazy attribute is an attribute that is calculated on demand and only once.
>
> The post below shows how you can use lazy attribute in your Python class:
>
> http://mindref.blogspot.com/2012/11/python-lazy-attribute.html
>
> Comments or sugge
I believe it is not valid relate a lazy attribute as something `cached` since
it cause confusion (e.g. delete of attribute cause cached item to be
re-evaluated...), `cached` and `lazy` have completely different semantic
meaning... however might overlap, as we see.
Andriy
On 16.11.2012, at 11:29, Steven D'Aprano wrote:
> I'm very vaguely leaning towards this as the least-worst solution to
> invalidating the cached value:
>
> refresh(obj, 'attr') # pass the instance and the name
This it exactly how lazy handles invalidation.
http://lazy.readthedocs.org/en/lates
On Thu, 15 Nov 2012 17:10:27 -0800, alex23 wrote:
> On Nov 16, 3:05 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>> > ``1/0`` is shorter. ;-)
>>
>> It is also guaranteed to run, unlike assert.
>
> Only if they actively pass the command line switch to turn it off,
Not necessarily
On Thu, 15 Nov 2012 15:46:19 -0700, Ian Kelly wrote:
> Although you don't go into it in the blog entry, what I like about your
> approach of replacing the descriptor with an attribute is that, in
> addition to being faster, it makes it easy to force the object to lazily
> reevaluate the attribute,
This is very minor use case. Unlikely useful to add any checks for None, or
translate one exception to the other... with pretty much the same outcome: it
makes sense in objects only.
Thanks.
Andriy
> From: rousl...@msn.com
> Subject: Re: Lazy Attribute
Same applies to properties... they are seen as an object attributes.
Thanks.
Andriy
> From: steve+comp.lang.pyt...@pearwood.info
> Subject: Re: Lazy Attribute
> Date: Fri, 16 Nov 2012 09:04:39 +
> To: python-list@python.org
>
> On Fri, 16 Nov 2012 1
from wheezy.core.descriptors import attribute as lazy
@lazy
def display_name...
Thanks.
Andriy Kornatskyy
> Date: Fri, 16 Nov 2012 09:56:41 +0200
> From: s...@mweb.co.za
> To: python-list@python.org
> Subject: Re: Lazy Attribute
>
> On 2012/11/16 09:49
On 11/16/2012 04:32 AM, Rouslan Korneychuk wrote:
On 11/16/2012 02:49 AM, Andriy Kornatskyy wrote:
If accessing the descriptor on the class object has no special
meaning, then the custom is to return the descriptor object itself, as
properties do.
If I would satisfy this, I will be forced to c
On 11/16/2012 02:49 AM, Andriy Kornatskyy wrote:
If accessing the descriptor on the class object has no special
meaning, then the custom is to return the descriptor object itself, as
properties do.
If I would satisfy this, I will be forced to check for None 99.9% of the use
cases (it is not No
On Fri, 16 Nov 2012 10:49:07 +0300, Andriy Kornatskyy wrote:
> Ian,
>
> Thank you for the comments.
>
>> The name "attribute" is not very descriptive. Why not "lazy_attribute"
>> instead?
>
> It just shorter and still descriptive.
It is not descriptive. EVERYTHING accessed used dot notation ob
On Fri, Nov 16, 2012 at 12:28 AM, wrote:
> Can someone explain the below behavior please?
>
re1 = re.compile(r'(?:((?:1000|1010|1020))[ ]*?[\,]?[ ]*?){1,3}')
re.findall(re_obj,'1000,1020,1000')
> ['1000']
re.findall(re_obj,'1000,1020, 1000')
> ['1020', '1000']
Try removing the gro
krishna.k.kish...@gmail.com writes:
> Can someone explain the below behavior please?
>
> >>> re1 = re.compile(r'(?:((?:1000|1010|1020))[ ]*?[\,]?[ ]*?){1,3}')
> >>> re.findall(re_obj,'1000,1020,1000')
> ['1000']
> >>> re.findall(re_obj,'1000,1020, 1000')
> ['1020', '1000']
>
> However when I use
On 2012/11/16 09:49 AM, Andriy Kornatskyy wrote:
The name "attribute" is not very descriptive. Why not "lazy_attribute" instead?
It just shorter and still descriptive.
Shorter, but not descriptive.
--
Regards
Alex
--
http://mail.python.org/mailman/listinfo/python-list
46 matches
Mail list logo