Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24643 > unrolled thread

code review

Started by"Littlefield, Tyler" <tyler@tysdomain.com>
First post2012-06-28 20:57 -0600
Last post2012-07-06 10:37 +0100
Articles 20 on this page of 134 — 34 participants

Back to article view | Back to comp.lang.python


Contents

  code review "Littlefield, Tyler" <tyler@tysdomain.com> - 2012-06-28 20:57 -0600
    Re: code review alex23 <wuwei23@gmail.com> - 2012-06-28 20:58 -0700
      Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-06-29 07:31 +0000
        Re: code review Chris Angelico <rosuav@gmail.com> - 2012-06-29 17:42 +1000
        Re: code review "Littlefield, Tyler" <tyler@tysdomain.com> - 2012-06-29 09:03 -0600
          Re: code review Alister <alister.ware@ntlworld.com> - 2012-06-29 19:41 +0000
            Re: code review MRAB <python@mrabarnett.plus.com> - 2012-06-29 21:09 +0100
            Re: code review "Martin P. Hellwig" <martin.hellwig@gmail.com> - 2012-06-29 13:27 -0700
              Re: code review Alister <alister.ware@ntlworld.com> - 2012-06-29 20:43 +0000
                Re: code review Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-06-29 19:02 -0400
                Re: code review Terry Reedy <tjreedy@udel.edu> - 2012-06-29 23:02 -0400
            Re: code review "Littlefield, Tyler" <tyler@tysdomain.com> - 2012-06-29 14:49 -0600
              Re: code review Alister <alister.ware@ntlworld.com> - 2012-06-30 09:31 +0000
                Re: code review Alister <alister.ware@ntlworld.com> - 2012-06-30 09:36 +0000
            Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-06-30 02:28 +0000
              Re: code review Alister <alister.ware@ntlworld.com> - 2012-06-30 09:22 +0000
            Re: code review Terry Reedy <tjreedy@udel.edu> - 2012-06-29 23:00 -0400
          Re: code review Alister <alister.ware@ntlworld.com> - 2012-06-30 10:04 +0000
            Re: code review Peter Otten <__peter__@web.de> - 2012-06-30 12:29 +0200
              Re: code review Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-30 20:39 +0200
                Re: code review Thomas Jollans <t@jollybox.de> - 2012-06-30 21:38 +0200
                  Re: code review Alister <alister.ware@ntlworld.com> - 2012-06-30 20:30 +0000
                    Re: code review Thomas Jollans <t@jollybox.de> - 2012-06-30 22:50 +0200
                      Re: code review Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2012-06-30 23:07 +0200
                        Re: code review Thomas Jollans <t@jollybox.de> - 2012-06-30 23:35 +0200
                        Re: code review Terry Reedy <tjreedy@udel.edu> - 2012-06-30 17:47 -0400
                        Re: code review Thomas Jollans <t@jollybox.de> - 2012-07-01 00:05 +0200
                          Re: code review Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2012-07-01 01:03 +0200
                          Re: code review Ben Finney <ben+python@benfinney.id.au> - 2012-07-01 10:08 +1000
                            Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-01 10:37 +1000
                              Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-01 03:23 +0000
                                Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-01 13:48 +1000
                                  Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-01 06:54 +0000
                                    Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-01 16:59 +1000
                                    Re: code review Terry Reedy <tjreedy@udel.edu> - 2012-07-01 05:55 -0400
                                      Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-02 01:26 +0000
                                        Re: code review Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-13 12:30 +0000
                                          Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-13 15:04 +0000
                                            Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-14 01:36 +1000
                                              Re: code review rusi <rustompmody@gmail.com> - 2012-07-13 09:24 -0700
                                            Re: code review Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-13 16:39 -0400
                                            Re: code review Duncan Booth <duncan.booth@invalid.invalid> - 2012-07-16 10:43 +0000
                                              Re: code review Ben Finney <ben+python@benfinney.id.au> - 2012-07-16 21:34 +1000
                                              Re: code review Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-17 10:54 +0000
                                          Re: code review Terry Reedy <tjreedy@udel.edu> - 2012-07-13 19:09 -0400
                                          Re: code review Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-14 03:26 -0600
                                          Re: code review Terry Reedy <tjreedy@udel.edu> - 2012-07-14 16:42 -0400
                                Re: code review rusi <rustompmody@gmail.com> - 2012-06-30 21:07 -0700
                                  Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-01 14:20 +1000
                              Re: code review Ben Finney <ben+python@benfinney.id.au> - 2012-07-01 17:28 +1000
                                Re: code review Thomas Jollans <t@jollybox.de> - 2012-07-01 09:46 +0200
                                  Re: code review HoneyMonster <nobody@someplace.invalid> - 2012-07-01 20:53 +0000
                                Re: code review Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-01 05:18 -0400
                                  Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-02 00:41 +0000
                                    Re: code review Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-01 21:40 -0400
                                Re: code review Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-01 13:41 -0400
                                Re: code review John O'Hagan <research@johnohagan.com> - 2012-07-02 14:43 +1000
                            Re: Re: code review Evan Driscoll <driscoll@cs.wisc.edu> - 2012-06-30 23:45 -0500
                              Re: Re: code review Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-07-01 08:57 +0200
                              Re: code review Alister <alister.ware@ntlworld.com> - 2012-07-01 09:54 +0000
                                Re: Re: code review Evan Driscoll <driscoll@cs.wisc.edu> - 2012-07-01 10:48 -0500
                                  Re: Re: code review lars van gemerden <lars@rational-it.com> - 2012-07-06 04:22 -0700
                                  Re: Re: code review lars van gemerden <lars@rational-it.com> - 2012-07-06 04:22 -0700
                                    Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-06 13:58 +0000
                                      Re: code review Roy Smith <roy@panix.com> - 2012-07-13 08:32 -0700
                            Re: code review Evan Driscoll <driscoll@cs.wisc.edu> - 2012-06-30 23:57 -0500
                              Re: code review Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-07-01 09:04 +0200
                          Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-01 02:06 +0000
                            Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-01 12:20 +1000
                              Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-01 04:17 +0000
                                Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-01 14:23 +1000
                                  Re: code review Steven D'Aprano <steve+usenet@pearwood.info> - 2012-07-01 06:27 +0000
                                    Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-01 16:33 +1000
                                      Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-02 01:28 +0000
                                        Re: code review Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-07-01 21:50 -0400
                                          Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-02 07:29 +0000
                                        Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-02 12:04 +1000
                                          Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-02 08:11 +0000
                                            Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-02 18:20 +1000
                                              Re: code review Rick Johnson <rantingrickjohnson@gmail.com> - 2012-07-02 08:57 -0700
                                                Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-03 02:42 +1000
                                                  Re: code review Rick Johnson <rantingrickjohnson@gmail.com> - 2012-07-02 11:22 -0700
                                                    Re: code review Thomas Jollans <t@jollybox.de> - 2012-07-02 21:06 +0200
                                                      Re: code review Rick Johnson <rantingrickjohnson@gmail.com> - 2012-07-02 12:35 -0700
                                                    Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-03 07:57 +1000
                                                  Re: code review Neil Cerutti <neilc@norwich.edu> - 2012-07-03 12:19 +0000
                                        Re: code review Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-02 01:20 -0400
                                        Re: code review Thomas Jollans <t@jollybox.de> - 2012-07-02 16:41 +0200
                                        Re: code review Terry Reedy <tjreedy@udel.edu> - 2012-07-02 11:33 -0400
                            Re: code review Thomas Jollans <t@jollybox.de> - 2012-07-01 09:35 +0200
                              Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-02 00:43 +0000
                                Re: code review Thomas Jollans <t@jollybox.de> - 2012-07-02 16:26 +0200
                            Re: code review Rick Johnson <rantingrickjohnson@gmail.com> - 2012-07-02 08:16 -0700
                              Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-03 02:55 +1000
                                Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-03 00:57 +0000
                                  Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-03 11:22 +1000
                                  Re: code review John O'Hagan <research@johnohagan.com> - 2012-07-03 12:25 +1000
                                    Re: code review Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-03 04:11 +0000
                                      Re: code review Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-03 02:09 -0400
                                        Re: code review Roy Smith <roy@panix.com> - 2012-07-03 08:33 -0400
                                      Re: code review Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-03 16:53 +0100
                                      Re: code review Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-03 17:32 -0400
                                    Re: code review rusi <rustompmody@gmail.com> - 2012-07-02 22:10 -0700
                                      Re: code review Ben Finney <ben+python@benfinney.id.au> - 2012-07-03 15:46 +1000
                                      Re: code review John O'Hagan <research@johnohagan.com> - 2012-07-04 00:59 +1000
                                  Re: code review Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-03 16:50 +0100
                                    Re: code review Paul Rudin <paul.nospam@rudin.co.uk> - 2012-07-04 10:29 +0100
                                      Re: code review Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-04 17:25 +0100
                                  Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-04 01:53 +1000
                                  Re: code review Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-03 17:05 +0100
                                  Re: code review Dave Angel <d@davea.name> - 2012-07-03 16:13 -0400
                                  Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-04 07:54 +1000
                                  Re: code review Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-04 09:28 +0100
                          Re: code review rusi <rustompmody@gmail.com> - 2012-06-30 19:37 -0700
                        Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-01 09:25 +1000
                        Re: code review Thomas Jollans <t@jollybox.de> - 2012-07-01 01:50 +0200
                    Re: code review "Martin P. Hellwig" <martin.hellwig@gmail.com> - 2012-06-30 14:48 -0700
                    Re: code review Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-02 13:16 -0600
              Re: code review Alister <alister.ware@ntlworld.com> - 2012-06-30 20:25 +0000
            Re: code review Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2012-07-03 23:23 +0530
              Re: code review John Gordon <gordon@panix.com> - 2012-07-03 18:18 +0000
                Re: code review Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-03 12:27 -0600
                Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-04 07:51 +1000
            Re: code review Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-03 12:19 -0600
            Re: code review kushal.kumaran+python@gmail.com - 2012-07-04 08:27 +0530
            Re: code review Chris Angelico <rosuav@gmail.com> - 2012-07-04 13:53 +1000
            Re: code review Simon Cropper <simoncropper@fossworkflowguides.com> - 2012-07-04 14:55 +1000
            Re: code review "Littlefield, Tyler" <tyler@tysdomain.com> - 2012-07-03 23:39 -0600
              Re: code review alex23 <wuwei23@gmail.com> - 2012-07-03 23:17 -0700
                Re: code review rusi <rustompmody@gmail.com> - 2012-07-04 00:05 -0700
            Apology for OT posts (was: code review) John O'Hagan <research@johnohagan.com> - 2012-07-06 12:06 +1000
            Re: Apology for OT posts Simon Cropper <simoncropper@fossworkflowguides.com> - 2012-07-06 15:30 +1000
            Re: Apology for OT posts Chris Angelico <rosuav@gmail.com> - 2012-07-06 17:45 +1000
            Re: Apology for OT posts Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-07-06 10:37 +0100

Page 1 of 7  [1] 2 3 4 5 6 7  Next page →


#24643 — code review

From"Littlefield, Tyler" <tyler@tysdomain.com>
Date2012-06-28 20:57 -0600
Subjectcode review
Message-ID<mailman.1623.1340939177.4697.python-list@python.org>
Hello all:
I was curious if someone wouldn't mind poking at some code.
I have an idea for a game I want to write (and if this works I want to 
use this as a framework for another project), but I'd like to make sure 
I'm doing things correctly/there's not a better way to do things. My 
concern is I'm going to get way far into this, then realize I totally 
broke something. So, if someone wouldn't mind taking a peek I'd 
appreciate it. My concerns are:
1) style/cleanlyness: does everything look ok?
2) Workability: is there a better way to do what is there?
3) Speed: am I doing something that could be improved? I don't want to 
spend a ton of time looking for non-existent bottlenecks and trying to 
improve on them, but if I'm doing something that's bad, I'd like to fix it.

The project page is at:
http://code.google.com/p/pymud
Any information is greatly appreciated.

-- 
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.

[toc] | [next] | [standalone]


#24644

Fromalex23 <wuwei23@gmail.com>
Date2012-06-28 20:58 -0700
Message-ID<6c39594f-79cb-4d4f-967e-bbc3f68cdbdf@f8g2000pbf.googlegroups.com>
In reply to#24643
On Jun 29, 12:57 pm, "Littlefield, Tyler" <ty...@tysdomain.com> wrote:
> I was curious if someone wouldn't mind poking at some code.
> The project page is at:http://code.google.com/p/pymud
> Any information is greatly appreciated.

I couldn't find any actual code at that site, the git repository is
currently empty.

[toc] | [prev] | [next] | [standalone]


#24645

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2012-06-29 07:31 +0000
Message-ID<4fed59b7$0$29978$c3e8da3$5496439d@news.astraweb.com>
In reply to#24644
On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:

> On Jun 29, 12:57 pm, "Littlefield, Tyler" <ty...@tysdomain.com> wrote:
>> I was curious if someone wouldn't mind poking at some code. The project
>> page is at:http://code.google.com/p/pymud Any information is greatly
>> appreciated.
> 
> I couldn't find any actual code at that site, the git repository is
> currently empty.

Given that all code contains bugs, that's the best sort of repository!



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#24647

FromChris Angelico <rosuav@gmail.com>
Date2012-06-29 17:42 +1000
Message-ID<mailman.1625.1340955740.4697.python-list@python.org>
In reply to#24645
On Fri, Jun 29, 2012 at 5:31 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Given that all code contains bugs, that's the best sort of repository!

Only in the sense that a cheese shop can be lauded for its cleanliness...

But I am somewhat curious to see the OP's actual code. MUDs are my
personal specialty.

ChrisA

[toc] | [prev] | [next] | [standalone]


#24656

From"Littlefield, Tyler" <tyler@tysdomain.com>
Date2012-06-29 09:03 -0600
Message-ID<mailman.1631.1340982202.4697.python-list@python.org>
In reply to#24645
On 6/29/2012 1:31 AM, Steven D'Aprano wrote:
> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
>
>> On Jun 29, 12:57 pm, "Littlefield, Tyler" <ty...@tysdomain.com> wrote:
>>> I was curious if someone wouldn't mind poking at some code. The project
>>> page is at:http://code.google.com/p/pymud Any information is greatly
>>> appreciated.
>> I couldn't find any actual code at that site, the git repository is
>> currently empty.

OOPS, sorry. Apparently I'm not as good with git as I thought. 
Everything's in the repo now.

[toc] | [prev] | [next] | [standalone]


#24673

FromAlister <alister.ware@ntlworld.com>
Date2012-06-29 19:41 +0000
Message-ID<rxnHr.474392$2B2.452770@fx30.am4>
In reply to#24656
On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote:

> On 6/29/2012 1:31 AM, Steven D'Aprano wrote:
>> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
>>
>>> On Jun 29, 12:57 pm, "Littlefield, Tyler" <ty...@tysdomain.com> wrote:
>>>> I was curious if someone wouldn't mind poking at some code. The
>>>> project page is at:http://code.google.com/p/pymud Any information is
>>>> greatly appreciated.
>>> I couldn't find any actual code at that site, the git repository is
>>> currently empty.
> 
> OOPS, sorry. Apparently I'm not as good with git as I thought.
> Everything's in the repo now.

I am no expert but from what have picked up so far

from x import 

 is frowned upon in most cases 

also this section in main strikes me as a bit odd and convoluted

    w = world()
    serv = server(client)
    w.server = serv
    serv.world = w

I think you are cross referencing classes & would be better to 
investigate inheritance.


-- 
The bogosity meter just pegged.

[toc] | [prev] | [next] | [standalone]


#24674

FromMRAB <python@mrabarnett.plus.com>
Date2012-06-29 21:09 +0100
Message-ID<mailman.1640.1341000547.4697.python-list@python.org>
In reply to#24673
On 29/06/2012 20:41, Alister wrote:
> On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote:
>
>> On 6/29/2012 1:31 AM, Steven D'Aprano wrote:
>>> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
>>>
>>>> On Jun 29, 12:57 pm, "Littlefield, Tyler" <ty...@tysdomain.com> wrote:
>>>>> I was curious if someone wouldn't mind poking at some code. The
>>>>> project page is at:http://code.google.com/p/pymud Any information is
>>>>> greatly appreciated.
>>>> I couldn't find any actual code at that site, the git repository is
>>>> currently empty.
>>
>> OOPS, sorry. Apparently I'm not as good with git as I thought.
>> Everything's in the repo now.
>
> I am no expert but from what have picked up so far
>
> from x import
>
>   is frowned upon in most cases
>
I think you mean:

     from x import *

> also this section in main strikes me as a bit odd and convoluted
>
>      w = world()
>      serv = server(client)
>      w.server = serv
>      serv.world = w
>
> I think you are cross referencing classes & would be better to
> investigate inheritance.
>
>

[toc] | [prev] | [next] | [standalone]


#24676

From"Martin P. Hellwig" <martin.hellwig@gmail.com>
Date2012-06-29 13:27 -0700
Message-ID<1b4644e1-f406-4ced-b753-7038babad778@googlegroups.com>
In reply to#24673
On Friday, 29 June 2012 20:41:11 UTC+1, Alister  wrote:
> On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote:
> 
> > On 6/29/2012 1:31 AM, Steven D'Aprano wrote:
> >> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
> >>
> >>> On Jun 29, 12:57 pm, "Littlefield, Tyler" <ty...@tysdomain.com> wrote:
> >>>> I was curious if someone wouldn't mind poking at some code. The
> >>>> project page is at:http://code.google.com/p/pymud Any information is
> >>>> greatly appreciated.
> >>> I couldn't find any actual code at that site, the git repository is
> >>> currently empty.
> > 
> > OOPS, sorry. Apparently I'm not as good with git as I thought.
> > Everything's in the repo now.
> 
> I am no expert but from what have picked up so far
> 
> from x import 
> 
>  is frowned upon in most cases 

from x import * is frowned upon, however, from x import y is fine IMHO.
> 
> also this section in main strikes me as a bit odd and convoluted
> 
>     w = world()
>     serv = server(client)
>     w.server = serv
>     serv.world = w
> 
> I think you are cross referencing classes & would be better to 
> investigate inheritance.
> 

Generally speaking, read PEP8 and apply it please, there are tools like pylint that can help you with that. It also seems you are doing things quite java like, but I guess that is just a thing of getting used to python.

If you are planning to let your code being used like a framework that is extended by others, try to avoid more advanced functions just because they seem handy, always ask yourself is it clearer?

Try to unit-test your code and try to gain some decent code coverage, that will increase maturity of your code rather quickly.

But for the rest it looks like you are good in organizing it all in sub-modules, which is a very nice thing to see.

Good luck!

-- 
mph

[toc] | [prev] | [next] | [standalone]


#24677

FromAlister <alister.ware@ntlworld.com>
Date2012-06-29 20:43 +0000
Message-ID<qroHr.310016$a15.50490@fx11.am4>
In reply to#24676
On Fri, 29 Jun 2012 13:27:54 -0700, Martin P. Hellwig wrote:

> On Friday, 29 June 2012 20:41:11 UTC+1, Alister  wrote:
>> On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote:
>> 
>> > On 6/29/2012 1:31 AM, Steven D'Aprano wrote:
>> >> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
>> >>
>> >>> On Jun 29, 12:57 pm, "Littlefield, Tyler" <ty...@tysdomain.com>
>> >>> wrote:
>> >>>> I was curious if someone wouldn't mind poking at some code. The
>> >>>> project page is at:http://code.google.com/p/pymud Any information
>> >>>> is greatly appreciated.
>> >>> I couldn't find any actual code at that site, the git repository is
>> >>> currently empty.
>> > 
>> > OOPS, sorry. Apparently I'm not as good with git as I thought.
>> > Everything's in the repo now.
>> 
>> I am no expert but from what have picked up so far
>> 
>> from x import
>> 
>>  is frowned upon in most cases
> 
> from x import * is frowned upon, however, from x import y is fine IMHO.
>> 
well I said I was no expert & picking things up. re investigation I see 
your reasoning and yes it was the from X import * I was thinking of.
 
Although a simple import X retaining the name-space ref does make it easy 
to identify the origins of a function (at the expense of more typing)
-- 
Flying is the second greatest feeling you can have.  The greatest feeling?
Landing...  Landing is the greatest feeling you can have.

[toc] | [prev] | [next] | [standalone]


#24680

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2012-06-29 19:02 -0400
Message-ID<mailman.1644.1341011107.4697.python-list@python.org>
In reply to#24677
On Fri, 29 Jun 2012 20:43:02 GMT, Alister <alister.ware@ntlworld.com>
declaimed the following in gmane.comp.python.general:

> Although a simple import X retaining the name-space ref does make it easy 
> to identify the origins of a function (at the expense of more typing)

	Well, there is the middle point...

import some_long_module_name as slmn

which retains the individual namespace, but reduces the amount of
typing.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#24685

FromTerry Reedy <tjreedy@udel.edu>
Date2012-06-29 23:02 -0400
Message-ID<mailman.1648.1341025508.4697.python-list@python.org>
In reply to#24677
On 6/29/2012 4:43 PM, Alister wrote:

>> from x import * is frowned upon, however, from x import y is fine IMHO.
>>>
> well I said I was no expert & picking things up. re investigation I see
> your reasoning and yes it was the from X import * I was thinking of.
>
> Although a simple import X retaining the name-space ref does make it easy
> to identify the origins of a function (at the expense of more typing)

import tkinter as tk
for example, to minimize extra typing while identifying source.
___
Terry Jan Reedy


[toc] | [prev] | [next] | [standalone]


#24678

From"Littlefield, Tyler" <tyler@tysdomain.com>
Date2012-06-29 14:49 -0600
Message-ID<mailman.1642.1341002951.4697.python-list@python.org>
In reply to#24673
I am no expert but from what have picked up so far from x import is 
frowned upon in most cases also this section in main strikes me as a bit 
odd and convoluted w = world() serv = server(client) w.server = serv 
serv.world = w I think you are cross referencing classes & would be 
better to investigate inheritance.

 From what I understand and how I've always employed it, inheritance is 
ment when you wish to give a class characteristics of another class. All 
I'm doing here is setting the world and server classes on each other, so 
they can call one another. This probably isn't needed in case of 
serv.server = w, but for sure the other way around.

-- 
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.

[toc] | [prev] | [next] | [standalone]


#24690

FromAlister <alister.ware@ntlworld.com>
Date2012-06-30 09:31 +0000
Message-ID<dIzHr.369954$of1.147939@fx06.am4>
In reply to#24678
On Fri, 29 Jun 2012 14:49:11 -0600, Littlefield, Tyler wrote:

> I am no expert but from what have picked up so far from x import is
> frowned upon in most cases also this section in main strikes me as a bit
> odd and convoluted w = world() serv = server(client) w.server = serv
> serv.world = w I think you are cross referencing classes & would be
> better to investigate inheritance.
> 
>  From what I understand and how I've always employed it, inheritance is
> ment when you wish to give a class characteristics of another class. All
> I'm doing here is setting the world and server classes on each other, so
> they can call one another. This probably isn't needed in case of
> serv.server = w, but for sure the other way around.

I was not too sure of exactly why the code looked odd.
as mentioned in another post I should really have referred to the 
circular references.

I am new to python (about 6 months of home hacking), I looked at the code 
to see if it could improve my knowledge & my responses have been intended 
to spark a 2 way discussion of the pro's & cons of the approach.
So far that seems to be working, I expect by the end of this I will have 
learnt much about real world python apps.







-- 
Nobody ever died from oven crude poisoning.

[toc] | [prev] | [next] | [standalone]


#24691

FromAlister <alister.ware@ntlworld.com>
Date2012-06-30 09:36 +0000
Message-ID<RMzHr.369956$of1.145070@fx06.am4>
In reply to#24690
On Sat, 30 Jun 2012 09:31:53 +0000, Alister wrote:

> On Fri, 29 Jun 2012 14:49:11 -0600, Littlefield, Tyler wrote:
> 
>> I am no expert but from what have picked up so far from x import is
>> frowned upon in most cases also this section in main strikes me as a
>> bit odd and convoluted w = world() serv = server(client) w.server =
>> serv serv.world = w I think you are cross referencing classes & would
>> be better to investigate inheritance.
>> 
>>  From what I understand and how I've always employed it, inheritance is
>> ment when you wish to give a class characteristics of another class.
>> All I'm doing here is setting the world and server classes on each
>> other, so they can call one another. This probably isn't needed in case
>> of serv.server = w, but for sure the other way around.
> 
> I was not too sure of exactly why the code looked odd.
> as mentioned in another post I should really have referred to the
> circular references.
> 
> I am new to python (about 6 months of home hacking), I looked at the
> code to see if it could improve my knowledge & my responses have been
> intended to spark a 2 way discussion of the pro's & cons of the
> approach.
> So far that seems to be working, I expect by the end of this I will have
> learnt much about real world python apps.

perhaps now is a good time for me to look at the rest of the modules to 
see if i can work out exactly what these circular references do.
btw where or what is pants.py? 



-- 
If the path be beautiful, let us not ask where it leads.
		-- Anatole France

[toc] | [prev] | [next] | [standalone]


#24683

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2012-06-30 02:28 +0000
Message-ID<4fee6464$0$29988$c3e8da3$5496439d@news.astraweb.com>
In reply to#24673
On Fri, 29 Jun 2012 19:41:11 +0000, Alister wrote:

> also this section in main strikes me as a bit odd and convoluted
> 
>     w = world()
>     serv = server(client)
>     w.server = serv
>     serv.world = w
> 
> I think you are cross referencing classes & would be better to
> investigate inheritance.

What you show above is composition, and is a perfectly valid technique, 
and in fact should often be *preferred* to inheritance.

The only slightly dubious part, and I stress *slightly*, is that there is 
a circular reference: w refers to serv, and serv refers back to w. While 
legitimate, it is a very slight "code smell" that should be investigated. 
If there is a way to get the same result without the circular reference, 
that would be preferred.

For example, perhaps server methods that need to know the world could 
take it as an explicit argument, rather than fetching it implicitly from 
server.world.

Or, a moderately advanced technique, use a weak-ref instead.

Inheritance should only be used to model "is-a" relationships. For 
example, Herbie the Love Bug is a Volkswagen Beetle, so inheritance is 
appropriate.

http://en.wikipedia.org/wiki/Herbie


class Vehicle(object):
    pass

class Car(Vehicle):
    pass

class Beetle(Car):
    pass

herbie = Beetle()

Composition should be used to model "has-a" relationships. For example, a 
car has an engine, it is not a kind of engine, and so inheritance is 
inappropriate and composition should be used. I would re-write the Car 
class as follows:

class Engine(object):
    pass

class Car(Vehicle):
    def __init__(self):
        self.engine = Engine()

So now we can talk about Herbie's engine:

herbie.engine  # Herbie, being a car, has an engine, he is not an engine



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#24689

FromAlister <alister.ware@ntlworld.com>
Date2012-06-30 09:22 +0000
Message-ID<jzzHr.369821$of1.48625@fx06.am4>
In reply to#24683
On Sat, 30 Jun 2012 02:28:52 +0000, Steven D'Aprano wrote:

> On Fri, 29 Jun 2012 19:41:11 +0000, Alister wrote:
> 
>> also this section in main strikes me as a bit odd and convoluted
>> 
>>     w = world()
>>     serv = server(client)
>>     w.server = serv serv.world = w
>> 
>> I think you are cross referencing classes & would be better to
>> investigate inheritance.
> 
> What you show above is composition, and is a perfectly valid technique,
> and in fact should often be *preferred* to inheritance.
> 
> The only slightly dubious part, and I stress *slightly*, is that there
> is a circular reference: w refers to serv, and serv refers back to w.
> While legitimate, it is a very slight "code smell" that should be
> investigated.
> If there is a way to get the same result without the circular reference,
> that would be preferred.
> 
> For example, perhaps server methods that need to know the world could
> take it as an explicit argument, rather than fetching it implicitly from
> server.world.
> 
> Or, a moderately advanced technique, use a weak-ref instead.
> 
> Inheritance should only be used to model "is-a" relationships. For
> example, Herbie the Love Bug is a Volkswagen Beetle, so inheritance is
> appropriate.
> 
> http://en.wikipedia.org/wiki/Herbie
> 
> 
> class Vehicle(object):
>     pass
> 
> class Car(Vehicle):
>     pass
> 
> class Beetle(Car):
>     pass
> 
> herbie = Beetle()
> 
> Composition should be used to model "has-a" relationships. For example,
> a car has an engine, it is not a kind of engine, and so inheritance is
> inappropriate and composition should be used. I would re-write the Car
> class as follows:
> 
> class Engine(object):
>     pass
> 
> class Car(Vehicle):
>     def __init__(self):
>         self.engine = Engine()
> 
> So now we can talk about Herbie's engine:
> 
> herbie.engine  # Herbie, being a car, has an engine, he is not an engine

I probably was not to clear (due to my own inexperience) it was the 
circular references that grabbed my attention, it may be OK but suggests 
to me there may be a better approach.




-- 
((lambda (foo) (bar foo)) (baz))

[toc] | [prev] | [next] | [standalone]


#24684

FromTerry Reedy <tjreedy@udel.edu>
Date2012-06-29 23:00 -0400
Message-ID<mailman.1647.1341025257.4697.python-list@python.org>
In reply to#24673
On 6/29/2012 4:49 PM, Littlefield, Tyler wrote:
> I am no expert but from what have picked up so far from x import is
> frowned upon in most cases

from x import *
# frowned on by many as reader will not necessarily know what that 
imports, conflicts are possible, and if you import * twice, reader may 
really not know what came from where

from x import y,x  # fine, common, used in stdlib
import x as y  # ditto
from x import y as z  # ditto
-- 
Terry Jan Reedy


[toc] | [prev] | [next] | [standalone]


#24692

FromAlister <alister.ware@ntlworld.com>
Date2012-06-30 10:04 +0000
Message-ID<EaAHr.369967$of1.132220@fx06.am4>
In reply to#24656
On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote:

> On 6/29/2012 1:31 AM, Steven D'Aprano wrote:
>> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
>>
>>> On Jun 29, 12:57 pm, "Littlefield, Tyler" <ty...@tysdomain.com> wrote:
>>>> I was curious if someone wouldn't mind poking at some code. The
>>>> project page is at:http://code.google.com/p/pymud Any information is
>>>> greatly appreciated.
>>> I couldn't find any actual code at that site, the git repository is
>>> currently empty.
> 
> OOPS, sorry. Apparently I'm not as good with git as I thought.
> Everything's in the repo now.

I think I may be on firmer grounds with the next few:

isValidPassword can be simplified to

def isValidPassword(password:
	count=len(password)
	return count>= mud.minpass and count<= mud.maxpass

( I used count to save finding the length of password twice although it 
probably makes no difference in this scenario)

similar construct can be used for isValidUser

def isValidUser(name):
	if name.isalpha():
		count=len(name)
		return count>=mud.minname and count >mud.maxname
	return False


-- 
No one wants war.
		-- Kirk, "Errand of Mercy", stardate 3201.7

[toc] | [prev] | [next] | [standalone]


#24693

FromPeter Otten <__peter__@web.de>
Date2012-06-30 12:29 +0200
Message-ID<mailman.1651.1341052165.4697.python-list@python.org>
In reply to#24692
Alister wrote:

> I think I may be on firmer grounds with the next few:
> 
> isValidPassword can be simplified to
> 
> def isValidPassword(password:
>         count=len(password)
>         return count>= mud.minpass and count<= mud.maxpass
> 
> ( I used count to save finding the length of password twice although it 
> probably makes no difference in this scenario)

If you spell it

def is_valid_password(password):
    return mud.minpass <= len(password) <= mud.maxpass

it is even easier to see that you are performing an interval check.

[toc] | [prev] | [next] | [standalone]


#24698

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-06-30 20:39 +0200
Message-ID<2662370.TGmo96CKe1@PointedEars.de>
In reply to#24693
Peter Otten wrote:

> If you spell it
> 
> def is_valid_password(password):
>     return mud.minpass <= len(password) <= mud.maxpass
> 
> it is even easier to see that you are performing an interval check.

This is probably a tautology around here, but *what* *a* *great* 
*programming* *language*.

-- 
PointedEars

Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


Page 1 of 7  [1] 2 3 4 5 6 7  Next page →

Back to top | Article view | comp.lang.python


csiph-web