On Saturday, 16 March 2019 16:50:23 UTC+11, dieter wrote:
> Martin De Kauwe writes:
>
> > I'm trying to write a script that will make a checkout from a svn repo and
> > build the result for the user. However, when I attempt to interface with
> > the shell it ask
Hi,
I'm trying to write a script that will make a checkout from a svn repo and
build the result for the user. However, when I attempt to interface with the
shell it asks the user for their filename and I don't know how to capture this
with my implementation.
user = "XXX578"
root="https://trac
On Tuesday, September 18, 2012 8:31:09 AM UTC+10, Wanderer wrote:
> I need to divide a 512x512 image array with the first horizontal and vertical
> division 49 pixels in. Then every 59 pixels in after that. hsplit and vsplit
> want to start at the edges and create a bunch of same size arrays. Is
Trying to follow the suggestion this would be the alternate
implementation.
import sys
sys.path.append("/Users/mdekauwe/Desktop/")
import params
#params.py contains
#apples = 12.0
#cats = 14.0
#dogs = 1.3
fname = "test.asc"
try:
ofile = open(fname, 'w')
except IOError:
raise IOError("Can
Hi,
Tim yes I had a feeling my posting might be read as ambiguous! Sorry I
was trying to quickly think of a good example. Essentially I have a
set of .ini parameter files which I read into my program using
configobj, I then replace the default module parameters if the user
file is different (in my
Hi,
If I wanted to print an entire module, skipping the attributes
starting with "__" is there an *optimal* way? Currently I am doing
something like this. Note I am just using sys here to make the point
import sys
data = []
for attr in sys.__dict__.keys():
if not attr.startswith('__') and no
what is a .raw file, do you mean a flat binary?
--
http://mail.python.org/mailman/listinfo/python-list
yes thanks both work nicely, I will ponder the suggestions.
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
So i want to replace multiple lines in a text file and I have reasoned
the best way to do this is with a dictionary. I have simplified my
example and broadly I get what I want however I am now printing my
replacement string and part of the original expression. I am guessing
that I will need to
what is the character limit on a one liner :P. Very interesting
jesting apart, any more?
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 21, 9:43 pm, Jean-Michel Pichavant
wrote:
> Martin De Kauwe wrote:
> >> Sorry, are you trying to say that it is not practical to write correct
> >> code that isn't buggy? Well, you're honest, at least, still I can't help
> >> but feel that
On Mar 19, 8:40 pm, Steven D'Aprano wrote:
> On Sat, 19 Mar 2011 01:38:10 -0700, Martin De Kauwe wrote:
> >> Why don't you do the range check *before* storing it in state? That way
> >> you can identify the calculation that was wrong, instead of merely
> &
> Sorry, are you trying to say that it is not practical to write correct
> code that isn't buggy? Well, you're honest, at least, still I can't help
> but feel that you're admitting defeat before even starting.
No. What I am saying is the code is written has been well tested and
*appears* to be wo
> assert all(x >= 0 for x in (a, b, c, d, e, f, g, h, i, j))
yep neat!
> Why don't you do the range check *before* storing it in state? That way
> you can identify the calculation that was wrong, instead of merely
> noticing that at some point some unknown calculation went wrong.
I guess no r
> dir() has to do a bit a computation. I would be tempted to give 'state'
> a set of attributes to check. Call it 'nonnegatives'.
> for attr in nonnegatives:
> if ...
>
> This allows for attributes not subject to that check.
>
> --
> Terry Jan Reedy
Agreed. I was trying to just write a
> Offhand, my only quibble is that sys.exit is not helpful for debugging.
> Much better to raise an error:
>
> if not self.funcTable.get(attribute, lambda x: True)(value):
> raise ValueError ('error out of bound')
>
> or define a subclass of ValueError just for this purpose.
> Don't check for bounds, fix any bug in the code that would set your
> values out of bounds and use asserts while debugging.
>
whilst that is a nice idea in practice this just is not a practical
solution.
> Otherwise if you really need dynamic checks, it will cost you cpu, for
> sure.
Yes I a
Hi,
if one has a set of values which should never step outside certain
bounds (for example if the values were negative then they wouldn't be
physically meaningful) is there a nice way to bounds check? I
potentially have 10 or so values I would like to check at the end of
each iteration. However as
Hi,
I have been working on re-writing a model in python and have been
trying to adopt some of the advise offered on here to recent
questions. However I am not sure how easy on the eye my final
structure is and would appreciate any constructive comments/
suggestions. So broadly the model estimates
On Mar 9, 12:53 pm, "Rhodri James"
wrote:
> On Wed, 09 Mar 2011 01:00:29 -0000, Martin De Kauwe
> wrote:
>
> > class BaseClass(object):
> > def __init__(self, a, b, c, d):
> > self.a = a
> > self.b = b
> > self.
On Mar 9, 11:50 am, "Rhodri James"
wrote:
> On Wed, 09 Mar 2011 00:29:18 -0000, Martin De Kauwe
> wrote:
>
>
>
>
>
>
>
> > On Mar 9, 10:20 am, Ethan Furman wrote:
> [snip]
> >> Just make sure and call the parent's constructor,
On Mar 9, 10:20 am, Ethan Furman wrote:
> Martin De Kauwe wrote:
> > Hi,
>
> > I think this might be obvious? I have a base class which contains X
> > objects which other classes inherit e.g.
>
> > class BaseClass(object):
> > def _
Hi,
I think this might be obvious? I have a base class which contains X
objects which other classes inherit e.g.
class BaseClass(object):
def __init__(self, something, something_else):
self.something = something
self.something_else = something_else
# etc
Typically I w
On Mar 2, 3:30 am, Robert Kern wrote:
> On 2/28/11 10:03 AM, Fred Marshall wrote:
>
> > I'm interested in developing Python-based programs, including an engineering
> > app. ... re-writing from Fortran and C versions. One of the objectives
> > would to
> > be make reasonable use of the available
On Mar 1, 3:03 am, Fred Marshall
wrote:
> I'm interested in developing Python-based programs, including an
> engineering app. ... re-writing from Fortran and C versions. One of the
> objectives would to be make reasonable use of the available structure
> (objects, etc.). So, I'd like to read a c
I managed to get it to work like it explained, apologies not sure what
I did wrong earlier, odd.
Anyway thanks a lot for all of the suggestions + help
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 14, 8:57 pm, Martin De Kauwe wrote:
> On Feb 14, 8:51 pm, Dave Angel wrote:
>
>
>
>
>
> > On 01/-10/-28163 02:59 PM, Martin De Kauwe wrote:
>
> > >
>
> > > from other_model import OtherSubModel
> > > class Model:
>
> > >
On Feb 14, 6:10 pm, aspineux wrote:
> On 14 fév, 06:47, Wang Coeus wrote:
>
> > Hi all,
> > I am new to python. Currently I encountered a problem, please help me to
> > solve this. Thanks in advance!
> > I have a file like below:
>
> ConfigParser Library does exacly what you want but with .ini fi
On Feb 14, 8:51 pm, Dave Angel wrote:
> On 01/-10/-28163 02:59 PM, Martin De Kauwe wrote:
>
> >
>
> > from other_model import OtherSubModel
> > class Model:
>
> > def __init__(self):
>
> > # included other external modules (i.e.
On Feb 14, 7:12 pm, Terry Reedy wrote:
> On 2/13/2011 8:33 PM, Martin De Kauwe wrote:
>
> > Cool! Thanks this seems straight forward, however if I do it this way
> > then once I change it (i.e. after reading user param file) I can't
> > pass the changed version to
On Feb 14, 12:02 pm, Terry Reedy wrote:
> On 2/13/2011 6:16 PM, Martin De Kauwe wrote:
>
>
>
>
>
> > I think I got it, did you mean something like this?
>
> > class Constants:
>
> > radius_of_earth = 6.37122E+6
> > days_as_yrs = 1.0 / 365.
On Feb 14, 10:16 am, Martin De Kauwe wrote:
> On Feb 13, 6:35 pm, Terry Reedy wrote:
>
>
>
>
>
> > On 2/12/2011 9:20 PM, Martin De Kauwe wrote:
>
> > > On Feb 13, 5:12 am, Terry Reedy wrote:
> > >> On 2/12/2011 1:24 AM, Martin De Kauwe wrote:
>
On Feb 13, 6:35 pm, Terry Reedy wrote:
> On 2/12/2011 9:20 PM, Martin De Kauwe wrote:
>
> > On Feb 13, 5:12 am, Terry Reedy wrote:
> >> On 2/12/2011 1:24 AM, Martin De Kauwe wrote:
>
> >>> The point of this posting was just to ask those that know, whether it
&
On Feb 13, 5:12 am, Terry Reedy wrote:
> On 2/12/2011 1:24 AM, Martin De Kauwe wrote:
>
> > The point of this posting was just to ask those that know, whether it
> > was a bad idea to use the class object in the way I had or was that
> > OK? And if I should have jus
Hi,
Is there a better way to unpack more than one dictionary in a function
than...
def unpack_dicts(f):
def wrapper(*old_dicts):
dict={}
for d in old_dicts:
dict.update(d)
return f(**dict)
return wrapper
@unpack_dicts
def some_func(a=None, b=None, c=No
On Feb 12, 8:06 pm, Martin De Kauwe wrote:
> On Feb 12, 7:21 pm, Andrea Crotti wrote:
>
> > Il giorno 12/feb/2011, alle ore 00.45, Martin De Kauwe ha scritto:
>
> > > Hi,
>
> > > yes I read a .INI file using ConfigParser, just similar sections (in
> > &g
On Feb 12, 7:21 pm, Andrea Crotti wrote:
> Il giorno 12/feb/2011, alle ore 00.45, Martin De Kauwe ha scritto:
>
> > Hi,
>
> > yes I read a .INI file using ConfigParser, just similar sections (in
> > my opinion) to make one object which i can then pass to different
>
On Feb 12, 7:22 pm, John Nagle wrote:
> On 2/11/2011 6:56 AM, Martin De Kauwe wrote:
>
> > Hi,
>
> > I have a series of parameter values which i need to pass throughout my
> > code (>100), in C I would use a structure for example. However in
> > python it is n
Steven,
You make some good points and I don't disagree with you. The code is
just a transfer from some older c++ code which had all sorts of
windows menus etc, which isn't required and would make it impossible
to run (again and again). It is not an especially complicated model,
and no doubt there
On Feb 12, 11:13 am, Steven D'Aprano wrote:
> On Fri, 11 Feb 2011 10:15:27 -0800, Dan Stromberg wrote:
> > I'd use a class rather than a dictionary - because with a class, pylint
> > (and perhaps PyChecker and pyflakes?) should be able to detect typos
> > upfront.
>
> *Some* typos. Certainly not
Sorry I should have added a little more example to help with clarity?
So after reading the .INI file I then initialise the objects I
described e.g.
def initialise_simulation(self):
"""Set the initial conditions.
using values from the .ini value set the C and N pools
and other misc st
Hi,
yes I read a .INI file using ConfigParser, just similar sections (in
my opinion) to make one object which i can then pass to different
classes. E.G.
class Dict2Obj:
""" Turn a dictionary into an object.
The only purpose of this is that I think it is neater to reference
values
x.s
On Feb 12, 2:40 am, Andrea Crotti wrote:
> On Feb 11, 3:56 pm, Martin De Kauwe wrote:
>
> > Hi,
>
> > I have a series of parameter values which i need to pass throughout my
> > code (>100), in C I would use a structure for example. However in
> > python
Hi,
I have a series of parameter values which i need to pass throughout my
code (>100), in C I would use a structure for example. However in
python it is not clear to me if it would be better to use a dictionary
or build a class object? Personally I think accessing the values is
neater (visually)
On Feb 4, 8:41 pm, Marco Nawijn wrote:
> On Feb 4, 3:43 am, Martin De Kauwe wrote:
>
>
>
>
>
> > Hi,
>
> > I am translating some c++ code to python and just wanted to ask some
> > advise on structure. The original has everything declared globally and
&g
Hi,
I am translating some c++ code to python and just wanted to ask some
advise on structure. The original has everything declared globally and
nothing passed via function (I assume, but don't know, that this isn't
just standard c++ practice!). So given this, I have a pretty much
clean slate as I
46 matches
Mail list logo