Wrote a little "user-friedly" wrapper for ConfigParser for a KDE's
SuperKaramba widget.
( http://www.kde-look.org/content/show.php?content=32185)
I was using 2.4.x python docs as reference and
ConfigParser.re ad('non-existent-filename') returns [] in 2.4.x
One user with 2.3.x reported an error stemming from my use of
len(cfgObject.r ead('potentiall y-non-existent-filename'))
File "/home/web/Downloads/afoto-1.5b6.skz/localConf.py", line 53, in load
TypeError: len() of unsized object
Can anyone tell me what cfgObject.read( 'potentially-non-existent-filename')
returns in 2.3.x?
My output:
>>import ConfigParser cfg = ConfigParser.Co nfigParser() a = cfg.read('adsfa sfdasfd') a, len(a), type(a)
([], 0, <type 'list'>)
Thx in advance.
Daniel. 4 1864
On Thu, Jul 20, 2006 at 10:50:40AM -0700, Danil Dotsenko wrote:
Wrote a little "user-friedly" wrapper for ConfigParser for a KDE's
SuperKaramba widget.
(http://www.kde-look.org/content/show.php?content=32185)
I was using 2.4.x python docs as reference and
ConfigParser.re ad('non-existent-filename') returns [] in 2.4.x
http://docs.python.org/lib/RawConfigParser-objects.html
That agrees with the docs since read returns a list of successfully parsed
filenames. Note the docs also say this was added in 2.4.
>
One user with 2.3.x reported an error stemming from my use of
len(cfgObject.r ead('potentiall y-non-existent-filename'))
File "/home/web/Downloads/afoto-1.5b6.skz/localConf.py", line 53, in load
TypeError: len() of unsized object
Can anyone tell me what cfgObject.read( 'potentially-non-existent-filename')
returns in 2.3.x?
I suspect it never returns anything which means you are getting None instead
of a list, which would give you the exception above.
>
My output:
>import ConfigParser cfg = ConfigParser.Co nfigParser() a = cfg.read('adsfa sfdasfd') a, len(a), type(a)
([], 0, <type 'list'>)
Thx in advance.
Daniel.
-- http://mail.python.org/mailman/listinfo/python-list
Danil Dotsenko wrote:
Chris Lambacher wrote:
>On Thu, Jul 20, 2006 at 10:50:40AM -0700, Danil Dotsenko wrote:
>>Wrote a little "user-friedly" wrapper for ConfigParser for a KDE's SuperKaramb a widget. (http://www.kde-look.org/content/show.php?content=32185)
I was using 2.4.x python docs as reference and ConfigParser. read('non-existent-filename') returns [] in 2.4.x
http://docs.python.org/lib/RawConfigParser-objects.html That agrees with the docs since read returns a list of successfully parsed filenames. Note the docs also say this was added in 2.4.
I just looked at the http://www.python.org/doc/2.3.5/lib/...r-objects.html
(note the version number) and see the following:
"If none of the named files exist, the ConfigParser instance will contain
an empty dataset." Which to me means []. To the least of it, the statement
should be clarified, but I would still kindly prefer to have someone
respond / confirm the procedure bellow gives different results in 2.3.x.
>>>import ConfigParser cfg = ConfigParser.Co nfigParser() a = cfg.read('adsfa sfdasfd') a, len(a), type(a) ([], 0, <type 'list'>)
Thx in advance.
Python 2.3.5 (#2, Jun 13 2006, 23:12:55)
[GCC 4.1.2 20060613 (prerelease) (Debian 4.1.1-4)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
Â*>>import ConfigParser
Â*>>cfg = ConfigParser.Co nfigParser()
Â*>>a = cfg.read('adsfa sfdasfd')
Â*>>a
Â*>>type(a)
<type 'NoneType'>
Â*>>len(a)
Traceback (most recent call last):
Â* File "<stdin>", line 1, in ?
TypeError: len() of unsized object
Â*>>Â*
Chris Lambacher wrote:
On Thu, Jul 20, 2006 at 10:50:40AM -0700, Danil Dotsenko wrote:
>Wrote a little "user-friedly" wrapper for ConfigParser for a KDE's SuperKaramba widget. (http://www.kde-look.org/content/show.php?content=32185)
I was using 2.4.x python docs as reference and ConfigParser.r ead('non-existent-filename') returns [] in 2.4.x
http://docs.python.org/lib/RawConfigParser-objects.html
That agrees with the docs since read returns a list of successfully parsed
filenames. Note the docs also say this was added in 2.4.
I just looked at the http://www.python.org/doc/2.3.5/lib/...r-objects.html
(note the version number) and see the following:
"If none of the named files exist, the ConfigParser instance will contain an
empty dataset." Which to me means []. To the least of it, the statement
should be clarified, but I would still kindly prefer to have someone
respond / confirm the procedure bellow gives different results in 2.3.x.
>>import ConfigParser cfg = ConfigParser.Co nfigParser() a = cfg.read('adsfa sfdasfd') a, len(a), type(a)
([], 0, <type 'list'>)
Thx in advance.
On Thu, Jul 20, 2006 at 02:01:08PM -0700, Danil Dotsenko wrote:
Chris Lambacher wrote:
On Thu, Jul 20, 2006 at 10:50:40AM -0700, Danil Dotsenko wrote:
Wrote a little "user-friedly" wrapper for ConfigParser for a KDE's
SuperKaramba widget.
(http://www.kde-look.org/content/show.php?content=32185)
I was using 2.4.x python docs as reference and
ConfigParser.re ad('non-existent-filename') returns [] in 2.4.x
http://docs.python.org/lib/RawConfigParser-objects.html
That agrees with the docs since read returns a list of successfully parsed
filenames. Note the docs also say this was added in 2.4.
I just looked at the http://www.python.org/doc/2.3.5/lib/...r-objects.html
(note the version number) and see the following:
"If none of the named files exist, the ConfigParser instance will contain an
empty dataset." Which to me means []. To the least of it, the statement
should be clarified, but I would still kindly prefer to have someone
respond / confirm the procedure bellow gives different results in 2.3.x.
That says nothing about the return value. It says that the ConfigParser
object will contain an empty data set, ie:
config.sections () == []
NOT
config.read(['doesnotexist.c fg']) == []
since config.read does not explicitly return anything, and therefore you get
None.
>
>import ConfigParser cfg = ConfigParser.Co nfigParser() a = cfg.read('adsfa sfdasfd') a, len(a), type(a)
([], 0, <type 'list'>)
Thx in advance.
-- http://mail.python.org/mailman/listinfo/python-list This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Greg Krohn |
last post by:
I'm trying to subclass ConfigParser so I can use a custom __read method (the
custom format doesn't conform to RFC 822) when needed. Needless to say, it's
not working as expected.
In the following code, I bind __read_ini to __read and override __read so it
can choose between __read_ini and __read_custom. But it seems that
__read_custom never gets called when I expect it to aways be called. I have
a feeling this has to do with me not...
|
by: Martin Maney |
last post by:
Summary: with batteries like these, get a longer extension cord?
<transcript from interactive session>
Python 2.2.1 (#1, Sep 7 2002, 14:34:30)
on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ConfigParser import ConfigParser
>>> cp = ConfigParser()
|
by: Roy H. Berger |
last post by:
If I want to subclass ConfigParser and changed the optionxform method
to not return things in lower case wouldn't I just need the following
code in my subclasss module?
from ConfigParser import *
class MyConfigParser(ConfigParser):
def __init__(self, defaults=None):
ConfigParser.__init__(self, defaults)
|
by: Manlio Perillo |
last post by:
Regards.
Since sections in CongiParser files are delimited by , why
there is not an escape (and unescape) function for escaping
&, characters to &, [ and ] ?
Thanks Manlio Perillo
|
by: rzed |
last post by:
I am working with PythonCard in one of my apps. For its purposes, it
uses an .ini file that is passed to ConfigParser. For my app, I also
need configuration information, but for various reasons, I'd rather
use a syntax that ConfigParser can't handle.
I know I can maintain two separate configuration files, and if I have
to I will, but I'd rather avoid that, if possible, and a solution
that suits my purposes is quite straightforward. I...
| |
by: Terry Carroll |
last post by:
It looks like ConfigParser will accept a list to be writing to the
*.ini file; but when reading it back in, it treats it as a string.
Example:
###############################
import ConfigParser
def whatzit(thingname, thing):
print thingname, "value:", thing
print thingname, "length:", len(thing)
|
by: pipehappy |
last post by:
Hello everyone:
I came across the module ConfigParser and can use it correctly.
import ConfigParser
fp = open('test.cfg','w+')
config = ConfigParser.ConfigParser()
config.readfp(fp)
config.add_section('test')
config.set('test', 'haha', 'hehe')
|
by: tony.ha |
last post by:
Hello I use ConfigParser as show below to read a config.txt file;
from ConfigParser import ConfigParser
config = ConfigParser()
config.read('config.txt')
items = config.items('FV')
for item in items:
module_name = item
print module_name
|
by: jamitwidme |
last post by:
Hello. I am a novice programmer and have a question
I have a configuration file(configuration.cfg)
I read this from reading.py using ConfigParser
When I use ConfigParser.get() function, it returns a string.
I want to call a function that has the same name as the string from
the configuration file.
configuration.cfg
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |