Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51371
| Path | csiph.com!aioe.org!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <devyncjohnson@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'feedback.': 0.04; 'argument': 0.05; '"""': 0.07; 'class,': 0.07; 'plenty': 0.07; 'python3': 0.07; 'arguments': 0.09; 'arguments,': 0.09; 'collier': 0.09; 'subject:module': 0.09; 'try:': 0.09; 'python': 0.11; 'def': 0.12; 'wrote': 0.14; 'amd': 0.16; 'arg': 0.16; 'behave': 0.16; 'command,': 0.16; 'command-line': 0.16; 'command.': 0.16; 'edt': 0.16; 'itself,': 0.16; 'likewise': 0.16; 'ls:': 0.16; 'non-trivial': 0.16; 'printout': 0.16; 'self.args': 0.16; 'somehow,': 0.16; 'true:': 0.16; 'x86_64': 0.16; 'wrote:': 0.18; 'module': 0.19; 'thu,': 0.19; 'user.': 0.19; 'not,': 0.20; 'command': 0.22; '>>>': 0.22; 'import': 0.22; 'coding': 0.22; 'email addr:gmail.com>': 0.22; 'shell': 0.22; 'header:User- Agent:1': 0.23; '>>>': 0.24; 'module,': 0.24; 'passes': 0.24; 'processor': 0.24; 'decide': 0.24; 'looks': 0.24; '>': 0.26; 'this:': 0.26; 'pass': 0.26; 'certain': 0.27; 'header:In- Reply-To:1': 0.27; 'idea': 0.28; 'point': 0.28; 'am,': 0.29; 'unix': 0.29; '(like': 0.30; 'program,': 0.31; 'code': 0.31; 'getting': 0.31; 'received:10.0.0': 0.31; "skip:' 10": 0.31; '25,': 0.31; 'directly,': 0.31; 'omitted': 0.31; 'pipe': 0.31; 'allows': 0.31; 'file': 0.32; 'class': 0.32; 'lists': 0.32; 'linux': 0.33; 'framework': 0.33; 'style': 0.33; 'skip:_ 10': 0.34; 'problem': 0.35; 'basic': 0.35; 'advice': 0.35; 'except': 0.35; 'possible.': 0.35; 'something': 0.35; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'module.': 0.36; 'method': 0.36; "i'll": 0.36; 'possible': 0.36; 'received:10.0': 0.36; 'list': 0.37; 'received:10': 0.37; 'easily': 0.37; 'feedback': 0.38; 'thank': 0.38; 'fri': 0.38; 'jason': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'called': 0.40; 'users': 0.40; 'even': 0.60; 'commands': 0.60; 'break': 0.61; "you're": 0.61; "you've": 0.63; 'real': 0.63; 'such': 0.63; 'provide': 0.64; 'more': 0.64; 'worth': 0.66; 'close': 0.67; 'useful.': 0.68; 'gotten': 0.74; 'jul': 0.74; 'complexity': 0.84; 'url:ls': 0.84; 'contents.': 0.91; 'do:': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=nsnH64gyK2mEiu0ThGZkVMGmJ9UlOlV9aZ1VNGuHCek=; b=Do1r1yNO1487NISrIK6NltrYedNAHy4Ti915Pihsh+wNhUtfZa1i5A26ka8Y7nxlnw E5KObjNMZG/GtWLrpFaLKpvzSDXxXQRNRdb3DOrkHihVXFUQYxH+msdt8mZQS9KrR9X8 Hu7NsByGUlv7tgD3JEOeoyEXvh0ftoBxrpCB7w9UgWNHFBQLffNo8idzqKgY1OeOVnUD hMBRbaSS0gvyY66xCGGbdQcyCIC93UdShYRxfBS9A+UmC+zCPj11+Wwxk8e/2nPF/nmT BXY7sqqGahGVunaxUO37oh8nfQFt2hIT6/FxEIv1syNRDy4KhjiNV223tF9vncRNdoby CQJQ== |
| X-Received | by 10.182.148.100 with SMTP id tr4mr46169738obb.53.1374948397599; Sat, 27 Jul 2013 11:06:37 -0700 (PDT) |
| Date | Sat, 27 Jul 2013 14:06:34 -0400 |
| From | Devyn Collier Johnson <devyncjohnson@gmail.com> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 |
| MIME-Version | 1.0 |
| To | Python Mailing List <python-list@python.org> |
| Subject | Re: Critic my module |
| References | <51F1270E.6000704@Gmail.com> <CAEk9e3p87UrDo_6jMzvVM_eyDO85ZeRUJYVO5KngnK+q95ea7A@mail.gmail.com> |
| In-Reply-To | <CAEk9e3p87UrDo_6jMzvVM_eyDO85ZeRUJYVO5KngnK+q95ea7A@mail.gmail.com> |
| Content-Type | multipart/alternative; boundary="------------030608070902020201030102" |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5183.1374948401.3114.python-list@python.org> (permalink) |
| Lines | 324 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1374948401 news.xs4all.nl 15916 [2001:888:2000:d::a6]:52316 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:51371 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 07/27/2013 11:14 AM, Jason Swails wrote:
> You've gotten plenty of good advice from people discussing the coding
> and coding style itself, I'll provide some feedback from the vantage
> point of a perspective user.
>
>
> On Thu, Jul 25, 2013 at 9:24 AM, Devyn Collier Johnson
> <devyncjohnson@gmail.com <mailto:devyncjohnson@gmail.com>> wrote:
>
> Aloha Python Users!
>
> I made a Python3 module that allows users to use certain Linux
> shell commands from Python3 more easily than using os.system(),
> subprocess.Popen(), or subprocess.getoutput(). This module (once
> placed with the other modules) can be used like this
>
> import boash; boash.ls <http://boash.ls>()
>
>
> I actually wrote a program recently in which I wanted access to unix
> "ls" command, and I wanted it to behave as close to the real, UNIX
> "ls" as possible.
>
> This would seem like a perfect use-case for your module, but the
> problem is that the 'ls' command in your module does not behave much
> like the real 'ls' command. You never let any of the 'system'
> commands in your module access any arguments. More often than not, I
> use "ls" with several command-line arguments, like:
>
> ls --color=auto -lthr dir_basename*/
>
> Even if you're just spawning 'ls' directly, this is actually
> non-trivial to implement. You need globbing on all non-option
> arguments, you may want to pass up the return code somehow, depending
> on what the user wants to do:
>
> [bash ]$ ls nodir
> ls: nodir: No such file or directory
> [bash ]$ echo $?
> 1
>
> Also, 'ls' in the terminal behaves like "ls -C" when called from your
> module. In the framework of my program, my 'ls' command looks like this:
>
> class ls(Action):
> """
> Lists directory contents. Like UNIX 'ls'
> """
> needs_parm = False
> def init(self, arg_list):
> from glob import glob
> self.args = []
> # Process the argument list to mimic the real ls as much as possible
> while True:
> try:
> arg = arg_list.get_next_string()
> if not arg.startswith('-'):
> # Glob this argument
> globarg = glob(arg)
> if len(globarg) > 0:
> self.args.extend(globarg)
> else:
> self.args.append(arg)
> else:
> self.args.append(arg)
> except NoArgument:
> break
>
> def __str__(self):
> from subprocess import Popen, PIPE
> process = Popen(['/bin/ls', '-C'] + self.args, stdout=PIPE,
> stderr=PIPE)
> out, err = process.communicate('')
> process.wait()
> return out + err
>
> [I have omitted the Action base class, which processes the user
> command-line arguments and passes it to the init() method in arg_list
> -- this listing was just to give you a basic idea of the complexity of
> getting a true-er 'ls' command].
>
> Your 'uname' command is likewise limited (and the printout looks strange:
>
> >>> print(platform.uname())
> ('Linux', 'Batman', '3.3.8-gentoo', '#1 SMP Fri Oct 5 14:14:57 EDT
> 2012', 'x86_64', 'AMD FX(tm)-6100 Six-Core Processor')
>
> Whereas:
>
> [bash $] uname -a
> Linux Batman 3.3.8-gentoo #1 SMP Fri Oct 5 14:14:57 EDT 2012 x86_64
> AMD FX(tm)-6100 Six-Core Processor AuthenticAMD GNU/Linux
>
> You may want to change that to:
>
> def uname():
> print(' '.join(platform.uname()))
>
> Although again, oftentimes people want only something specific from
> uname (like -m or -n).
>
> HTH,
> Jason
>
For now, I will decide if it would be worth my time to make such a
module seeing that many feel that it may not be useful. Thank you all
for your feedback.
Mahalo,
DCJ
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Critic my module Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-27 14:06 -0400
csiph-web