arting
> with the one in the stdlib. You may want to find out if any of these
> packages fits your needs before reinventing the wheel ?
Right, ConfigParser should do the trick for simpler things.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
this object:
class Prefs (object) :
def __init__ (self) :
self.values = { 'test': 1, ... }
def save (self, f) :
pickle.dump(self.values, f)
def load (self, f) :
self.values = pickle.load(f)
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
relative file names, so you can just put them
anywhere you want with:
zlFile = open(os.path.join(DESTDIR, zItem), 'wb')
or change the current directory, but the first way should be preferred.
> print "Finished"
> &&&
>
> This works, but I want to be able to specify a different output
> location.
>
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
g your string in chars and getting the
bytes values with ord (described here:
http://docs.python.org/lib/built-in-funcs.html) :
byte0 = ord(s[0])
byte1 = ord(s[1])
si = (byte0 << 8) | byte1 # or maybe the inverse ?
or use the struct module:
http://docs.python.org/lib/module-struct.html
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
> how to read that line number from a text file? etc.)|
if you read the file with readlines(), just lines[lineno]
you'll find more infos in the following sections:
http://docs.python.org/lib/bltin-file-objects.html
http://docs.python.org/lib/string-methods.html
http://docs.python.org/lib/module-random.html
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
ttribute, finds it in the class members, and then creates an
instance member with the result. Things would be different with a mutable
type implementing the += operator.
I discovered this in a middle of a project and it was hard to track all these
assignments in my code to correct them, so I'd suggest to always access class
members through the class instead of the instance, unless you have no choice
or know exactly what you are doing.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
number that
> does'nt start with:
>
>
>
> 281
>
> 713
>
> 832
>
>
>
> or
>
>
>
> 1281
>
> 1713
>
> 1832
>
>
>
>
>
> is long distance any, help would be appreciated.
sounds like str.startswith() is enough for yo
uot;Amortized" part of "Amortized Worst Case".
Individual actions may take surprisingly long, depending on the history of
the container.
Also note that 5 items is a lot for a human being, not for a modern
computer.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
You can dynamically add objects to a module:
>>> import os
>>> os.foo = 'bar'
>>> os.foo
'bar'
>>> setattr(os, 'foo2', 'bar2')
>>> os.foo2
'bar2'
and for the loading part you can use the __import__ builti
tp://alleg.sourceforge.net/ )
or SDL, another good one with the same purpose:
http://www.libsdl.org/
http://www.pygame.org/news.html
both are (imho) very good and easy to learn, but they are C libraries so some
knowledge of this language might help you to understand them.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
sing is in the wrong context, what is the right
> one?
What problems did you have exactly ?
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
you can restrict the set of functions the user can give, excluding
those which are not supposed to be called this way.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
le(r'.*')
^ this is to avoid matching a tag name starting with table
(like )
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
.sub(r'\4', line)
print "'%s' -> '%s' '%s' '%s' '%s'" % (line, func_vis, func_type,
func_name, func_args)
It might be hard to read but will avoid a lot of obscure parsing code. I can't
tell if it makes the
in dotted_attr.split('.') :
obj = getattr(obj, attr)
return obj
a = A()
print 'a.b.c = %s' % get_dotted_attr(a, 'b.c')
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
f = open(filename)
print f.read()
f.close()
f_list.close()
If you get an error, please post the full error message with the backtrace.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
re
But imho escaping the quote in the first part would be more readable than
using triple quotes:
>>> name = "Frank's Laundry"
>>> re.sub(r"([\"'])", r"\\\1", name)
"Frank\\'s Laundry"
You'll find a list of all the standard modules in the python docs, including
this one:
http://docs.python.org/modindex.html
http://docs.python.org/lib/module-re.html
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
ll have
to run the same python version) so carefully read the docs first. I'd choose
the first solution, eventually using the pickle module to avoid encoding
problems.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
tm2.tm_mon - 1)
then (m1 - m2) gives the difference in months
(see the time modules docs for more infos)
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
is your choice. You can use named params or a vararg list
(which will preserve params order).
But in your example you're only using class attributes, so __new__ is not
involved and they are just created once for all in the order you write them:
a, b, c.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
> On Mon, Jun 23, 2008 at 9:59 AM, Cédric Lucantis <[EMAIL PROTECTED]> wrote:
> > Yes a checksuite should be kept separate from the 'real' code. You can
> > run it locally by setting the PYTHONPATH environment variable :
> >
> > PYTHONPATH=/path/to/your/
s a checksuite should be kept separate from the 'real' code. You can run it
locally by setting the PYTHONPATH environment variable :
PYTHONPATH=/path/to/your/modules python checksuite.py
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
enerate some code defining this
value as a global variable, to make it accessible to the rest of your own
code. Ideally, your app would also provide a command line option or an
environment variable to override this hard-coded setting at runtime.
But maybe the distutils tools have some features fo
...
>
Do you mean setting stdin in non-blocking mode ? On unix you can do it with
the fcntl module (you'll find more infos in the libc docs) :
fcntl.fcntl(sys.stdin, fcntl.F_SETFL, os.O_NONBLOCK)
and catch IOErrors with errno = EAGAIN. But I don't know how to do it in a
portable way, sug
ne
style you've chosen at cygwin installation time. (See
http://en.wikipedia.org/wiki/Newline#Common_problems)
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
nt major/minor version numbers (so 2.4 +
2.5 is OK, but _not_ 2.4.2 + 2.4.4). Everything go in different directories,
and a version specific executable is also installed (python2.5,
python3.0...). The main one (python) is just a link to one of them.
--
Cédric Lucantis
--
http://mail.python.org/ma
.846290\n'
> to an array of floats.
>
string = '0.906366 2.276152 0.01336980.773141'
array = [float(s) for s in string.split()]
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
Le Thursday 19 June 2008 15:13:39 John Dann, vous avez écrit :
> Many thanks for the speedy replies.
>
> On Thu, 19 Jun 2008 14:14:02 +0200, Cédric Lucantis <[EMAIL PROTECTED]>
>
> wrote:
> >Le Thursday 19 June 2008 13:54:03 John Dann, vous avez écrit :
> >&g
printing the method object itself without
calling it : print serlink.openPort()
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
lly know py2exe but I bet it can handle it without problem.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
;
'panel' is local to your __init__ function, so it's not available elsewhere.
You should store it as an instance attribute instead :
# in __init__:
self.panel = wx.Panel(self)
# in OnBrowse
self.panel.database.SetLabel(patrh)
note that unlike some other languages, panel and self.panel are two distinct
variables, so you should replace _all_ references to panel by self.panel.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
the function
accepts varargs like *args, **kwargs, but I don't know where these are
defined.
Note that I never found any doc about that and merely guessed it by playing
with func objects, so consider all this possibly wrong or subject to change.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
else :
ret[-1] += car
return ret
# test
for s in ('foo, bar, baz',
'foo, "bar, baz", blurf',
'foo, bar(baz, blurf), mumble') :
print "'%s' => '%s'" % (s, mysplit(s))
# result
'foo, bar, baz' => '['foo', 'bar', 'baz']'
'foo, "bar, baz", blurf' => '['foo', 'bar, baz', 'blurf']'
'foo, bar(baz, blurf), mumble' => '['foo', 'bar(baz, blurf)', 'mumble']'
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
.com'.strip('cmowz.')
> 'example'
> .??? --> --- 'www.example.com'.strip('cmowz.')
> 'exaple'
> --
I don't see any string method to do that, but you can use a regexp :
>>> re.sub('[cmowz.]', '', 'www.example.com')
'exaple'
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
say something
is wrong with your script but we'll need more infos to help. Can you post the
whole function ?
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
sting)
{
if (op->ob_refcnt <= 0)
/* XXX(twouters) cast refcount to long until %zd is
universally available */
fprintf(fp, "", (long)op->ob_refcnt, op);
}
}
I don't really understand its pur
ent to
use the float constructor directly:
dummy = PyFloat_FromDouble(internal_list([i]))
PS: always use Py_CLEAR(dummy) instead of Py_DECREF(dummy); dummy=NULL;
(though it doesn't really matter in this simple case - see
http://docs.python.org/api/countingRefs.html)
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
or with the 'types' module, but
it won't work as the except handler only accepts Exception classes. It sounds
like you're confusing with some other error, what is the exact message of
your 'NoneType error' ? The exception type you want to catch should be at the
beginning
endly manual :)
http://docs.python.org/lib/module-socket.html
and if you want to know more about socket themselves, the gnu libc info page
is a good starting point as the python module is basically an interface to
it:
http://www.gnu.org/software/libc/manual/html_node/Sockets.html#Sockets
date.__new__(cls, y, m, d)
return self
The general rule is to do your initialization in __new__ for immutable types
and in __init__ for mutable ones. See the chapter 3 of the reference manual
(data model) for more infos.
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
on-mode
python-newt
python-selinux
python-semanage
python-support
python-tk
python2.4
python2.4-doc
python2.4-minimal
thanks,
--
Cédric Lucantis
--
http://mail.python.org/mailman/listinfo/python-list
41 matches
Mail list logo