gestion #3:
--
Break the problem down even smaller (Rustom Mody appears to have
beat me to the punch on that suggestion, so I'll just point to his
email.)
Hint #1:
----
What is the value of your variable totalScores each time through the
loop? Does it ever get reset?
Good luck with your degubbing!
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
en(cmd, stdout=devnull, stderr=devnull)
retcode = proc.wait()
if retcode != 0:
raise FlamingHorribleDeath
You will have to define FlamingHorribleDeath or figure out what you
want to do in the event of the various different types of
failureif you don't then, you'll just see this:
NameError: name 'FlamingHorribleDeath' is not defined
Good luck,
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
ontent.com/tLDP/python-tldp/master/docs/ldptool-man.rst
[7] https://raw.githubusercontent.com/DavidGamba/grepp/master/grepp.adoc
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
e(fname)
logger.info("Computed MD5 hash digest %s", digest)
print('%s %s' % (digest, fname,))
return os.EX_OK
if __name__ == '__main__':
if len(sys.argv) == 1:
sys.exit(main(os.getcwd()))
else:
sys.exit(main(sys.argv[1]))
# -- end of file
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
tion:
votes = [72, 72, 72, 72, 96, 96, 96, 48, 48, 53, 26, 26, 26, 26,
31, 31, 31, 68, 68, 91]
But, don't bother!
Your function can handle votes that have a float weight:
>>> weight([(4, 1.3), (1, 1),])
2.695652173913044
Have fun!
-Martin
--
Martin A. Brow
UCCESS in every program.
Clearly, in my above example the contents of the run() function look strange.
Usually it has more different kinds of stuff in it.
Anyway, best of luck!
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
string.
>>> a = '"string1",'
>>> ea = eval(a)
>>> len(ea), type(ea)
(1, )
>>> b = '"string1","string2",'
>>> eb = eval(b)
>>> len(eb), type(eb)
(2, )
>>> c = '"string1","string2","string3",'
>>> ec = eval(c)
>>> len(ec), type(ec)
(3, )
Good luck in your continuing Python explorations,
-Martin
P.S. Where do your double-quoted strings come from, anyway?
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
surprisingly, it does.
>
>Thank you! It is so much better than the one I have created.
>Possibly I'll delete my own module from pypi. :-)
I'm glad to have been able to help, László.
And, even if you don't delete your new module, you have certainly
stimulated quite a discus
It occurred to me this morning, after
you posted your new library:
https://pypi.python.org/pypi/intervaltree
This handles overlapping ranges nicely and provides some tools for
managing them. Before posting this, I checked that it works with
datetime types, and, unsurprisingly, it does.
Hap
= set
[test100]
# -- no way to capture baddr=lin_02; must reproduce contents of lin_02
object = baddr
offset = 100
size = 5
optype = set
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
run_tool(logfile, **kw):
logger.info('%s would execute with %r', logfile, kw)
def addLogFilename(d, logdir):
'''put the logfile name into the test case data dictionary'''
for casename, args in d.items():
args['logfile'] = os.path.join(logdir, casename + '.log')
return d
def main():
testcases = createTestCases(LOG_DIR)
get_baddr = dict()
for casename, kw in testcases.items():
# -- yank the logfile name out of the dictionary, before calling func
logfile = kw.pop('logfile')
get_baddr[casename] = run_tool(logfile, **kw)
if __name__ == '__main__':
main()
# -- end of file
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
uot;
> using __file__ so that the program works wherever you launch
> "python code.py"
>
> Is it the correct way to handle this problem ?
Ayup, I would say so. My suggested technique:
here = os.path.dirname(os.path.abspath(__file__))
foo = os.path.join(here, 'foo.txt
cription, I'd give you
this example for loop that produces the same outcome.
list1 = list()
for n in num.split():
list1.append(int(n))
The map function is quite useful, so it's a good one to learn early.
Good luck,
-Martin
[0] https://docs.python.org/3/library/functions.html#input
[1] https://mail.python.org/mailman/listinfo/tutor/
[2] https://docs.python.org/3/library/functions.html#map
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
ute__, __getitem__, __gt__,
__init__, __iter__, __le__, __len__, __lt__, __ne__,
__repr__, __setitem__ and __sizeof__
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
I find the addition of a few characters makes this assignment much
clearer to me.
# -- if len(d) > 1, ValueError will be raised
#
(key,) = d.keys()
And thank you for the reply Chris,
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
ay benefit from:
The Python Cookbook (O'Reilly)
http://shop.oreilly.com/product/0636920027072.do
Python Module of the Week
https://pymotw.com/3/
I'm making those recommendations because I know and have used these
and also because of your Perl background.
Good luck,
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
and-formatting-parameters
Judging from your example, you definitely want to use
quoting=csv.QUOTE_NONE, because you don't want the module to do much
more than split('\t').
Good luck,
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
.org/3/library/functions.html#zip
Toy example:
import string
alpha = string.ascii_lowercase
nums = range(len(alpha))
for N, A in zip(nums, alpha):
print(N, A)
Good luck,
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
s.lru_cache can help you with how
they solved the problem of mapping entry count to memory usage.
Good luck,
-Martin
[0] https://docs.python.org/3/library/functools.html#functools.lru_cache
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
lauses to the above block with appropriate
handling, or (re-)raising the caught exception.
Comments on shelling out to other programs and using exceptions
---
Exceptions are great for catching logic errors, type errors,
filesystem err
True
>loop. so the socket will keep in close_wait
>
>I fond the issue. it's my own stupid issue.
>i did "continue" if no data received.
>just break from it then it will be fine
Well, I'm glad you found the issue.
Best of luck,
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
g SO_REUSEADDR). This is the most likely problem.
Suggestion:
man 7 socket
Look for SO_REUSEADDR. Then, apply what you have learned to your
code.
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
ub.com/jsommers/switchyard
NS-3, the researcher's toolkit
https://www.nsnam.org/
https://www.nsnam.org/wiki/Python_bindings
Good luck,
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
tps://pypi.python.org/pypi/adns-python/1.2.1
And, there are Python bindings. I have been quite happy using the
adns tools (and tools built on the Python bindings) for mass lookups
(millions of DNS names). It works very nicely.
Just sharing knowledge of an existing tool,
-Martin
--
Mart
s of that method.
Good luck,
-Martin
* I was tempted to joke about these two guarantees, but I think
that undermines my basic message. To wit, you can probably rely
on this naming technique about as much as you can rely on your
system clock. I'll assume that you aren&
):
now = time.time()
who = random.choice(players)
marbles = random.randint(0, 100)
record[who].append((marbles, now))
for whom, marblehistory in record.items():
print(whom, end=": ")
pprint.pprint(marblehistory)
if __name__ == '__main__':
import sys
if len(sys.argv) > 1:
count = int(sys.argv[1])
else:
count = 30
marblegame(count)
# -- end of file
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
Run the code on
the command-line.
* How much time have you taken to work out what the interpreter is
telling you?
Good luck,
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
make sure that you
are running the same code that you are working on. Then, if you
are still experiencing syntax errors, study the lines that the
interpreter is complaining about. And, of course, send the list an
email.
Best of luck,
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
yntax.
Your code has, unfortunately, suffered a colonectomy.
When you transplant a colon, it is more likely to function properly
again. For example:
except socket.error as e:
Good luck,
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
e incompetent hospital-radio trained Martin Brown (Stevens)
P.P.S. In case it is not utterly clear, I am not the above author.
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
*$'
token 4: ./xml/name.xml
token 5: test.xml
Try this (untested):
> cmd = ["diff", "-w", "-I", "^[[:space:]]*$", "./xml/%s.xml" % name,
> "test.xml"]
But, perhaps the xmldiff module will be what you want.
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
the point
nicely.
* If you break the individual computations into functions, then
you only run the specific computation when it's needed. In the
original example, all of the computations were run AND then, one
of the results was selected. It may not matter, since computers
are so fast, but, practicing basic parsimony can avoid little
obvious performance hazards like this.
* In short, longer, but much much clearer.
Good luck,
-Martin
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
t;--- the first place we could detect it
> File "spam", line 5, in _validate <--- where we actually detect it
Yes, indeed! Our stock in trade. I never liked function 'that'. I
much prefer function 'this'.
-Martin
Q: Who is Snow White's brother?
A: Egg white. Get the yolk?
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
y sample
log data must have been more homogeneous than the data on which I
derived my mental bookmarks for textual compression efficiencies
of around 15% for zlib and 12% for bz2. I have no mental bookmark
for lzma yet, but 7% is an outrageously good compression ratio.
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
34 matches
Mail list logo