I have a function that return's x variables How do I check if all the the
values returned are not None/False/0/''
Here is the same program to demonstrate this , but I felt this can be
better any suggestions ?
# vi file.py
import random
import string
def return_x_values():
" returns x
I have two possible values for Z_block in the block code i.e
disk_object.data.data.di_data[0] or block.data.data.di_data.data[0][0]
def get_block():
''' Get Z block ''
if block.data.data.di_data.data[0][0] is not None:
Z_block = block.data.data.di_data.data[0][0]
else:
>
>
> is a perfectly good pattern to use.
>
Thanks looks nice :)
>
>
> >
> >
> > I am a Linux user on Python 2.7
>
> Have you considered moving to Python 3?
>
Not yet , but Is there something that I need to consider in the current
context?
Regards,
Ganesh
--
https://mail.python.org/mailma
How to join each elements with a delimiter at (1) beginning and end of the
list and (2) connecting all elements of the list
Example :
>>> value_list = [1, 2, 3, 4, 56, 's'] I want this to be converted in
this from '||1||2||3||4||56||s||'
Here is my solution
>>> values = '||' + '||'.join(ma
Hello Team ,
I need you input on the below hello world program. I a m trying to add a
python binding which will return the character for the given index . I am
on Python 2.7 and linux
Example :
>> string ='helloworld'
>>dda_hello(5)
>> 'w'
/*
+ * Hello world example for python bindings
+
>
>
>
> Py_BuildValue with an "s" expects a C string - that is, a pointer to
> char, not just a single character. You'd need to do something like
> this:
>
> char buf[2] = {char1, 0};
> return Py_BuildValue("s", buf);
>
> ChrisA
Thanks Chris for the clue's it worked, I was just wondering ho
Hi Team,
Iam on python 2.7 and Linux.
Iam pretty new to C Python extension , I was able to export few simple
modules to python and it look like the cool thing to do , but Iam stuck
for with a problem now , Iam not able to figure out how to export
fun_addr_from_addr()
to Python. I would need s
On Thu, Sep 1, 2016 at 12:32 PM, dieter wrote:
> Ganesh Pal writes:
>
> > Iam pretty new to C Python extension , I was able to export few simple
> > modules to python and it look like the cool thing to do ...
>
> Maybe, it is a good idea to have a look at "cython
C code.
I want to use C/Python API <https://docs.python.org/2/c-api/>
On Thu, Sep 1, 2016 at 6:32 PM, Stefan Behnel wrote:
> Ganesh Pal schrieb am 01.09.2016 um 14:30:
> > On Thu, Sep 1, 2016 at 12:32 PM, dieter wrote:
> >> Ganesh Pal writes:
> >>> Iam pretty
I am on python 2.7 and Linux
I have the stdout in the below form , I need to write a function to get
hostname for the given id.
Example:
>>> stdout
'hostname-1 is array with id 1\nhostname-2 is array with id 2\nhostname-3
is array with id 3\n'
def get_hostname(id)
return id
what's a
print mo.group(1)
...
RX-145-1 is array id 1 (.*) is array with id 3 None
RX-145-2 is array id 2 (.*) is array with id 3 None
RX-145-3 is array id 3 (.*) is array with id 3 None
---
Looks like Iam
Thanks , and it has to be re.match()
On Thu, Sep 22, 2016 at 12:18 AM, MRAB wrote:
> On 2016-09-21 19:35, Ganesh Pal wrote:
>
>> Thanks Steve for the clues , quickly tried out # Version 1 doesn't seen
>> to work.
>>
>>
>> for line in hostname:
>&g
912 and
>>> c1 = c1[0:-5] + ':8912'
>>> c1
'3,5,340058112:8912'
>>>
Any better suggestion to improve this piece of code and make it look more /
pythonic
Regards,
Ganesh Pal
--
https://mail.python.org/mailman/listinfo/python-list
Dear Python friends,
Any suggestion on how to add exception and make the below program look
better , I am using Python 2.7 and Linux
def create_files_append():
""" """
try:
os.makedir
I was trying to write a function that will return me the unique number
associated with each employee id.The command has the output in the below
pattern
Linux-Box-1# employee_details ls
List of names:
100910bd9 s7018
100d60003 s7019
110610bd3 s7020
100d60002 s7021
Linux-Box-1# employee_details
On Mon, Nov 28, 2016 at 1:16 PM, Steven D'Aprano <
[email protected]> wrote:
>
>
> There is no need to return True. The function either succeeds, or it
> raises an
> exception, so there is no need to return any value at all.
>
>
I returned True here ,because based on the result
turn False
return emp_unum
PS : [Edited the above code with else condition]
Regards,
Ganesh
On Mon, Nov 28, 2016 at 8:38 PM, Ganesh Pal wrote:
>
>
> I was trying to write a function that will return me the unique number
> associated with each employee id.The command has the
[email protected]> wrote:
> On Tuesday 29 November 2016 02:18, Ganesh Pal wrote:
>
> > On Mon, Nov 28, 2016 at 1:16 PM, Steven D'Aprano <
> > [email protected]> wrote:
> >
> >>
> >>
> >> There is no need to return Tr
On Wed, Nov 30, 2016 at 7:33 PM, Dennis Lee Bieber
wrote:
> On Wed, 30 Nov 2016 18:56:21 +0530, g thakuri
> declaimed
> the following:
>
> >Dear Python friends,
> >
> >I have a simple question , need your suggestion the same
> >
> >I would want to avoid using multiple split in the below code , w
-g groupname] [-d] [-m] [-u] [-v]
Failed, Retrying in 4 seconds...
Case 3: Assuming my command threw an exception say OSError , how do I
retry a command only for a specific exception / error
I am on Python 2.7 and Linux
Regards,
Ganesh Pal
--
https://mail.python.org/mailman/listinfo/python-list
On Fri, Mar 16, 2018 at 11:21 AM, Steven D'Aprano <
[email protected]> wrote:
> On Fri, 16 Mar 2018 11:04:22 +0530, Ganesh Pal wrote:
>
> > All that I am trying to do here is write a generic function that will
> > re-retry
> > the command
Please ensure quoted text is quoted, and new text you write is unquoted.
> That way you are more likely to get useful
>
Sorry , Steve I didn't realize but thanks for pointing out I will take care
I was on a mobile phone and messed the quoted text
>Something like this should do it. It gives up imm
Hi Team,
Just a quick suggestion, on string formatting with .format() which of the
below is better , given both give the same result .
>>> attempts = 1
>>> msg2 = "Hello"
>>> print "Retry attempt:{0} for error:{1}".format(attempts,msg2)
Retry attempt:1 for error:Hello
OR
>>> attempts = 1
>>> ms
>
>
> Or maybe they're not giving the same result. I'm a little confused here.
>
>
Thanks Chris, for the reply they appear to give the same result .
--
https://mail.python.org/mailman/listinfo/python-list
Hello Python friends,
How do I split the below regex , so that it fits within the character
limit of 79 words
pattern = [
r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',
r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',
>
> Or maybe they're not giving the same result. I'm a little confused here.
>
My Bad and Apologies , I should be fined for pasting wrong question.
Actually I wanted to know if its ok to use just empty {} with .format()
or use {} with values i.e {0} {1} both will give the same results anyway
Hello Team,
I have a list of tuple say [(1, 2, 1412734464L, 280), (2, 5, 1582956032L,
351), (3, 4, 969216L, 425)] . I need to convert the above as
['1,2,1412734464:280',
'2,5,1582956032:351', '3,4,969216:425']
Here is my Solution , Any suggestion or optimizations are welcome .
Solution
I have to test a standalone tool from a python script and I am using
os.system() to run the tool . I need to take decision based on the return
value of the standalone tool .
But since os.system merely throws the output value to STDOUT & returns the
exit status (0 => no error) of the shell , how c
On Thu, May 10, 2018, 22:31 Rob Gaddi
>
>
> By not using os.system, it's been superseded for reasons exactly like
> yours. https://docs.python.org/3/library/subprocess.html is your friend.
>
Can someone please help me understand this better for me with a program .
Will the returncode of subproc
Hi Team,
I wanted to parse a file and extract few feilds that are present after "="
in a text file .
Example , form the below line I need to extract the values present after
--struct =, --loc=, --size= and --log_file=
Sample input
line = '06/12/2018 11:13:23 AM python toolname.py --struct=d
On Wed, Jun 13, 2018 at 5:59 PM, Rhodri James wrote:
> On 13/06/18 09:08, Ganesh Pal wrote:
>
>> Hi Team,
>>
>> I wanted to parse a file and extract few feilds that are present after "="
>> in a text file .
>>
>>
>> Example , form
>
{'struct': 'data_block', 'log_file': '/var/1000111/test18.log', 'loc':
> '0', 'size': '8'}
>
>
MARB, as usual the solution you you look nice, Thanks for the excellent
solutions
>>> regex = re.compile (r"--(struct|loc|size|mirror|l
og_file)\s*=\s*([^\s]+)")
>>> regex.findall (line)
[('struct
*How do I check few specific/selected keys in a dictionary and extract
their values if they are not empty*
*Example : Extract the values for key "one","three","seven" and "nine” if
they are not empty*
*Input :*
*o_num = {'one': 1,*
* 'three': 3,*
* 'bar': None,*
*
k] is not None}
TypeError: unsupported operand type(s) for &: 'set' and 'list'
Example :
>>>print {k: o_num[k] for k in wanted and o_num.keys() if o_num[k] is not
None}
{'nine': 9, 'five': 5, 'three': 3, 'one': 1}
On
Hi Team
I need to write the values of an ordered dictionary into a file . All
values should be in a single row with a header list
*Example:*
*student = [("NAME", "John"),*
* ("AGE", 28),*
* ("SCORE", 13),*
* ("YEAR", 2018),*
* ("FEE", 250)]*
*st
Dear python Friends,
I need a quick suggestion on the below code.
def modify_various_line(f):
""" Try modifiying various line """
try:
f.write('0123456789abcdef')
f.seek(5) # Go to the 6th byte in the file
print f.read(1)
f.seek(-3, 2) # Go to the 3rd
>
>
>
> (1) Since this function always returns True (if it returns at all), what
> is the point? There's no point checking the return result, since it's
> always true, so why bother returning anything?
>
>
If I don't return anything from a function it returns None. But would it
be better if for
I have one of the dictionary values in the below format
'/usr/local/ABCD/EDF/ASASAS/GTH/HELLO/MELLO/test04_Failures.log'
'/usr/local/ABCD/EDF/GTH/HEL/OOLO/MELLO/test02_Failures.log'
'/usr/local/ABCD/EDF/GTH/BEL/LO/MELLO/test03_Failures.log'
I need to extract the file name in the path example, say
> The dictionary is irrelevant to your question. It doesn't matter whether
> the path came from a dict, a list, read directly from stdin, an
> environment variable, extracted from a CSV file, or plucked directly from
> outer space by the programmer. The process remains the same regardless of
> wher
Hi Team,
Iam on python 2.7.10 and Linux.
I have a python function where the similar kind of pattern repeating 100
of times
Sample code snippet:
test01_log = os.path.join(LOG_DIR, "test01.log")
cls.get_baddr['test01'] = failure.run_tool(
test01_log, object="inode", offset="1
I m on python 2.7 and Linux , I have a simple code need suggestion if I
I could replace sys.exit(1) with raise SystemExit .
==Actual code==
def main():
try:
create_logdir()
create_dataset()
unittest.main()
except Exception as e:
logging.exception(e)
>
>
> No; raise SystemExit is equivalent to sys.exit(0); you would need raise
> SystemExit(1) to return 1.
>
Thanks will replace SystemExit with SystemExit(1) .
> Why do you want to do this, though? What do you think you gain from it?
>
Iam trying to have a single exit point for many function
Hi Team,
Iam on python 2.7 and Linux . I need inputs on the below program ,
Iam skipping the unittest from setUpClass in following way # raise
unittest.SkipTest(message)
The test are getting skipped but I have two problem .
(1) This script is in turn read by other scripts which consid
>
> > Hi Team,
> >
> > Iam on python 2.7 and Linux . I need inputs on the below program ,
>
> "I am" is two words, not one. I hope you wouldn't write "Youare"
> or "Heis" :-) Whenever you write "Iam", I read it as the name "Ian", which
> is very distracting.
>
>
I am lazy fellow and you are sm
Dear Python friends,
I am on Python 2.7 and Linux . I am trying to extract the address
"1,5,147456:8192" from the below stdout using re.search
(Pdb) stdout
'linux-host-machine-1: Block Address for 1,5,27320320:8192 (block
1,5,147456:8192) --\nlinux-host-machine-1: magic
0xdeaff2fe mark_c
Dear Python friends,
I am on Python 2.7 and Linux . I am trying to extract the address
"1,5,147456:8192" from the below stdout using re.search
(Pdb) stdout
'linux-host-machine-1: Block Address for 1,5,27320320:8192 (block
1,5,147456:8192) --\nlinux-host-machine-1: magic
0xdeaff2fe mark_c
> Perhaps:
> map(int, re.search(search_pat, stdout).groups())
>
>
>
Thanks Albert map saved me many lines of code but map returns a list I
will have to convert the list to string again
Below is how Iam planning to teh conversion
>>> block = map(int, re.search(search_pat, stdout).groups())
>>> p
;, '1375772672', '8192')
(Pdb) matched.group()
'Block Address for 1,0,1376034816:8192 (block *1,0,1375772672:8192*'
Regards,
Ganesh
On Sun, May 29, 2016 at 11:53 AM, Ganesh Pal wrote:
>
>
>
>> Perhaps:
>> map(int, re.search(search_pa
Hi ,
Trying to extract the '1,1,114688:8192' pattern form the below output.
pdb>stdout:
'3aae5d0-1: Parent Block for 1,1,19169280:8192 (block 1,1,114688:8192)
--\n3aae5d0-1:
magic 0xdeaff2fe mark_cookie
0x\ngpal-3aae5d0-1: super.status
3super.cookie
On Sun, May 29, 2016 at 10:32 PM, Matt Wheeler wrote:
>
>
> This doesn't seem to exactly match your code below, i.e. your code is
> attempting to construct a tuple from groups 1 through 4. To meet this
> specification I could just `return re.search('(?<=\(block
> )[^(]*(?=\))', stdout).group()`
>
Thanks works fine : )
--
https://mail.python.org/mailman/listinfo/python-list
Hello Team,
I am on python 2.7 and Linux , I want to form the below sample
command so that I could run it on the shell.
Command is --> run_parallel -za1 -s 'daemon -cf xyz; sleep 1'
Here is how I formed the command and it seems to look fine and work
fine , but I think it could still be better
On Jul 10, 2016 11:14 PM, "Ian Kelly" wrote:
> They're correct, but using them before single quotes in a string
> delimited by double quotes is unnecessary.
Thanks .
> > 3. Iam running sleep command on the cluster i.e , how could I make it
> > look Python or its fine to have sleep ?
>
> I don't
>
>
>
> cmd = "run_parallel -za" + str(number) + \
> > ... " -s" + " \'daemon -cf xyz; sleep 1\'"
>
> cmd = "run_parallel -za{} -s 'daemon -cf xyz; sleep 1'".format(number)
>
>
How will I format number to strings using .format ??
Example
>>> str(num)
'100'
>>> cmd = "run_parallel -z
Hi Team ,
I am a Linux user on python 2,6 . I have a very simple question
I was going the zen of python by Tim peters and found an example that
demonstrates Explicit is better than implicit
"""Load the cat, dog, and mouse models so we can edit instances of them."""
def load():
from menageri
Hello team,
I am a python 2.7 user on Linux. I will need feedback on the below program
as I'm new to oops .
#!/usr/bin/python
class System(object):
'''Doc - Inside Class '''
def __init__(self, params=None):
if params is None:
self.params = {'id': '1',
Sorry for reposting, typo in the subject line !
On Fri, Nov 23, 2018, 19:11 Ganesh Pal Hello team,
>
> I am a python 2.7 user on Linux. I will need feedback on the below program
> as I'm new to oops .
>
> #!/usr/bin/python
>
>
> class System(object):
>
>
On Fri, Nov 23, 2018, 19:30 Bob Gailer What kind of feedback do you want?
>
Wanted to know if there is any problem in the code and if you can review it
:-)
>
--
https://mail.python.org/mailman/listinfo/python-list
How to remove " from the starting and ending of a string , before
comparison . Here is an example and my solution wtih eval ( I am advised
not to use this one) , please suggest an alternative . I am on linux and
python 2.7
g1@X1:/tmp$ cat file2.py
#!/usr/bin/python
# Case 1 - server2 file is "'/f
].startswith("\"") and stat['server2'].endswith("\""):
...stat['server2'] = ast.literal_eval(stat['server2'])
...
>>>
I tried startswith() and endswith(), doesn't seem to work ?. Is there
a simpler way ?
Regards,
Hello team,
I need suggestion to improve the below code , Iam on Linux and python 2.7
if not os.path.ismount("/tmp"):
sys.exit("/tmp not mounted.")
else:
if create_dataset() and check_permission():
try:
run_full_back_up()
run_partial_back_up()
except
On Wed, Dec 2, 2015 at 6:00 PM, Chris Angelico wrote:
> If both the functions return true values, yes. You have an indentation
> error there, but I'm assuming you meant to have the try/except
> indented further.
>
Correct I had meant to have try/except indented further.
>> 2. Can I have a if sta
Hi Team ,
I would need few tips from your past experiences on how to store
the test logs
My requirement is to capture log under /var/log/ directory every time
the test is run . The test will create one small log files which are
around 1KB in size .
Here is how I plan to approach this ,
> Finally. sys.exit accepts an integer, not a string.
>
Most of code uses sys.exit("some error message") , I did notice
that the error message is not displayed by sys .exit("some error
message") , do u mean that using string is not advisable with
sys.exit ?
How to I display error messages wi
> Wrong question; if you want to use sys.exit() in a way similar to C display
> the error message first and invoke sys.exit() afterwards with a numerical
> argument.
>
> --
oh ok , got it thanks :)
--
https://mail.python.org/mailman/listinfo/python-list
Hello Team,
Iam on python 2.7 and linux. Iam trying to understand the python unit
test frame work and also trying to fix the below code , any help in
this regard would be appreciated ?
# Sample code starts here
inject_failure = {}
report = ""
ClassIsSetup = False
ClassCleanup = F
+python list . sorry I accidentally did a reply to Peter.
On Dec 11, 2015 3:57 AM, "Ganesh Pal" wrote:
>
>
> > Drop the habit to sprinkle sys.exit() all over the place. A well-behaved
> > application has one exit point, at the end of the main module.
>
I was u
On Thu, Dec 10, 2015 at 9:20 PM, Peter Otten <[email protected]> wrote:
> Ganesh Pal wrote:
>
> I recommend that you reread the unittest documentation.
>
> setUpClass() should be a class method, and if it succeeds you can release
> the ressources it required in the cor
Hi Team,
Iam on linux and python 2.7 . I have a bunch of functions which I
have run sequentially .
I have put them in a list and Iam calling the functions in the list as
shown below , this works fine for me , please share your
opinion/views on the same
Sample code :
def print1():
print "
Iam on python 2.7 and linux .I need to know if we need to place the
modules in a particular or it doesn't matter at all
order while writing the program
For Example
import os
import shlex
import subprocess
import time
import sys
import logging
import plaftform.cluster
from util import run
def
def run_scanner():
"""
Mount /filesystems and run scanner
"""
for cmd in [" mount /filesystems ", " scanner_start"]:
try:
out, err, ret = run(cmd, timeout=3600)
if ret != 0:
logging.error("Can't run %s got %s (%d)!" % (cmd, err,
> (Polite people would *ask* a *question*.)
I am a polite person , sorry if the wording was harsh.
> (“_a non-zero_”, with a space in-between. “anon” can be misunderstood as
an
> abbreviation for “anonymous”.)
It was a typo.
> Most simple solution for this: Do not use a loop. More "complicate
Thanks to Don , Chris and Carl for sharing your view on this topic .
--
https://mail.python.org/mailman/listinfo/python-list
Hello Team,
I have written a small program using python unit test framework . I
need your guidance to find out
1. If I have used the fixtures and classes properly ( first oop program) :) )
2. why does unittest2.SkipTest not print the message when the failures
are encountered ?
3. Also sys.stderr
Apologies, looks like I did a reply instead of reply-all. So
forwarding this email , please provide guidance on the same
-- Forwarded message --
From: Ganesh Pal
Date: Thu, Jan 7, 2016 at 12:26 PM
Subject: Re: python unit test framework sample code
To: Terry Reedy
> Unless
Totally stuck with this
On Jan 10, 2016 7:11 PM, "Ganesh Pal" wrote:
> Apologies, looks like I did a reply instead of reply-all. So
> forwarding this email , please provide guidance on the same
>
> -- Forwarded message ----------
> From: Ganesh Pal
> Date:
Hi Team,
Iam on python 2.6 and Linux , I had replaced print out, err ret with
logging.info(out, err ,ret) in the below code . I am getting
"TypeError: not all arguments converted during string formatting"
error any quick suggestion
try:
out, err, ret = run(cmd, timeout=60)
I think logging.info(out) works the problem is when I add
logging.info(out,err,ret) ,may be there is a better way to supply this
arguments
On Wed, Feb 17, 2016 at 7:28 PM, Ganesh Pal wrote:
> Hi Team,
>
>
> Iam on python 2.6 and Linux , I had replaced print out, err ret with
>
On Wed, Feb 17, 2016 at 7:32 PM, Chris Angelico wrote:
> The print statement/function happily accepts multiple arguments, and
> will join them according to a set of predefined rules. The logging
> functions don't have those rules, so they take one message and some
> optional parameters. Try this,
Hello team,
Please provide your guidance on how to proceed with the below test ,
Iam on python 2.6 and Linux. I have a linitation to use python 2.6 and
unittest2
try:
import unittest2 as unittest
except ImportError:
import unittest
class isiCorruptTest(unittest.TestCase):
corrupt_
Hi Team,
Iam on python 2.6 , need input on the below piece of code.
EXIT_STATUS_ERROR=1
def create_dataset():
"""
"""
logging.info("Dataset create.Started !!!")
try:
if os.path.ismount("/nfs_mount"):
touch_file("inode_fixcrc.txt")
logging.inf
On Sun, Feb 21, 2016 at 10:37 PM, Ben Finney wrote:
> What result do you get when running that code? What empirical reason do
> you have to think it would work or not work?
I wanted to know was is it good to have if else with in a try expect
block , I was checking more from the programming pers
On Sun, Feb 21, 2016 at 10:33 PM, Ben Finney wrote:
> You are already supplying a custom message to ‘self.skipTest’::
>
> except Exception as exc:
> logging.error(exc)
> raise unittest.SkipTest("Failure running Integrity Scan ")
>
> So you can change that message by including
what would be the easiest way to remove the lines in the leading
numbers 1.e 1 ,2, 19 from this file using python ?
1 import os
2 Suite = "Test Mail"
3
4 def sendMail(x):
5 text = x
6 sendmail_location = "/home/prasad/onefs/share/sendmail" #
sendmail location
7 p =
Thanks it works fine :)
On Fri, Feb 26, 2016 at 5:01 PM, Peter Heitzer
wrote:
> Ganesh Pal wrote:
>>what would be the easiest way to remove the lines in the leading
>>numbers 1.e 1 ,2, 19 from this file using python ?
> import sys,re
> for line in sys.stdin:
>
Iam on python 2.6 and Linux , I need input on the below program ,
here is the spinet of my program
filename='/tmp2/2.txt'
def check_file():
"""
Run the command parallel on all the machines , if there is a
file named /tmp/file2.txt extract file2.txt
"""
global filename
bad
changed baddr="" to file ="" in the example program , sorry for the typo
> filename='/tmp2/2.txt'
>
> def check_file():
> """
> Run the command parallel on all the machines , if there is a
> file named /tmp/file2.txt extract file2.txt
>
> """
> global filename
> file = ''
>
>>
> what is run(...)
>
The run (_ is a wrapper it uses suprocess.Popen and returns stdout
,error and extitcod e
> not a good idea to have catchall exception
how to fix this ?
>
>> > return False
>> > if __name__ == '__main__':
>> > main()
>> >
>> --
>>
> copy and paste your tr
Iam on python 2.6 and Linux , need your suggestion on the usage of try
and except in this program and
Modified code:
#!/usr/bin/env python
"""
"""
import os
import shlex
import subprocess
import sys
import time
import logging
import run
import pdb
def run_cmd_and_verify(cmd, timeo
Iam really sorry , I will have to resend my question again , because
the earlier post had mistakes and formatting was bad , so apologies
for top posting will try to avoid such mistakes in future.
Iam on python 2.6 and Linux , need your suggestion on the usage of try
and except in this program
#
Iam on python 2.6 , need inputs on the common mistakes in this program
, may be you suggest what need to be improved from
1. usage of try- expect
2. Return of True/ False
3. Other improvement
#!/usr/bin/env python
"""
"""
import os
import shlex
import subprocess
import sys
import time
import lo
On Mon, Feb 29, 2016 at 9:59 PM, Ian Kelly wrote:
> On Mon, Feb 29, 2016 at 8:18 AM, Ganesh Pal wrote:
>> Iam on python 2.6
>> 1. usage of try- expect
>
> try-except in every single function is a code smell. You should only
> be using it where you're actually goin
On Mon, Feb 29, 2016 at 10:10 PM, Dennis Lee Bieber
wrote:
> Ask yourself: Will my program still work if I remove all the assert
> statements. If the answer is "No", then you should not be using an assert.
You meant if the answer is "NO" then I should be using asset ?
> Can your
> No, Dennis was correct. You should assume that "assert" can
> potentially be replaced with "pass" and your program will continue to
> work.
Thanks Chris for clarifying Dennis point of view ,
>>try:
>>if not run_cmd_and_verify(cmd, timeout=3600):
>
> Since your vers
> I have tried down the code to
Read "I have tried down the code to " as I have trimmed down the code as below
Ganesh
--
https://mail.python.org/mailman/listinfo/python-list
>> How do we reraise the exception in python , I have used raise not
>> sure how to reraise the exception
>
> raise with no arguments will reraise the exception currently being handled.
>
> except Exception:
> logging.error("something went wrong")
> raise
Thanks Ian for taking time and lo
On Mar 1, 2016 12:06 AM, "Chris Angelico" wrote
>
> You're falling into the trap of assuming that the only exception you
> can ever get is the one that you're planning for, and then handling.
Ok sure !
> ALL exceptions as though they were that one. Instead catch ONLY the
> exception that you're
On Tue, Mar 1, 2016 at 2:41 AM, Martin A. Brown wrote:
> Please read below. I will take a stab at explaining the gaps of
> understanding you seem to have (others have tried already, but I'll
> try, as well).
>
> I am going to give you four different functions which demonstrate
> how to use excep
Hi Team ,
Iam new to Fabric and Iam using the fab command-line tool to run a set
of task on Linux clients.
I just started coding and Iam pretty new to fabric, Iam hoping I will be
able to launch my fabric scripts from both Windows and Linux Machine .
Installing Cygwin might help in wi
On Tue, Oct 28, 2014 at 5:00 PM, Robin Becker wrote:
>
> I found fabric on windows quite hard, but I have managed to use it. For
> ssh I think I had to use the putty tools eg plink to do remote work.
>
> On the other hand I find plumbum much easier
>
> http://tomerfiliba.com/blog/Plumbum/
>
>
Than
1 - 100 of 171 matches
Mail list logo