Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-13 Thread Huy Ton That
Thank you all,

I was taking a look at the module decimal.py as you cited, and it makes
sense now. Looks very useful to make tools without having to instantiate
anything.

On Mon, Sep 13, 2010 at 7:05 AM, Steven D'Aprano st...@pearwood.infowrote:

 On Mon, 13 Sep 2010 12:29:07 pm Huy Ton That wrote:
  Hm, thanks guys; I just had to verify I was thinking sanely about it.
  I am going to pick up classmethods next. Do any of you have common
  design patterns for the usage. They are just items I haven't
  integrated in my coding, and I want to be certain I'm off on the
  right foot (:

 The most common use for classmethods is to implement alternative
 constructors. For example, in the Decimal class starting in version 2.7
 and 3.1, you have two constructors:

  from decimal import Decimal
  Decimal(1.2345)
 Decimal('1.2345')
  Decimal.from_float(1.2345)
 Decimal('1.2344307220832633902318775653839111328125')

 from_float is a class method.


 --
 Steven D'Aprano
 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] classmethod, staticmethod functions (decorator related)

2010-09-12 Thread Huy Ton That
Hm, thanks guys; I just had to verify I was thinking sanely about it. I am
going to pick up classmethods next. Do any of you have common design
patterns for the usage. They are just items I haven't integrated in my
coding, and I want to be certain I'm off on the right foot (:


On Sun, Sep 12, 2010 at 9:01 PM, Alan Gauld alan.ga...@btinternet.comwrote:

 Steven D'Aprano st...@pearwood.info wrote


  A little more information... static methods are quite common[1] in Java
 and C++, where people feel the need (or in the case of Java, are forced
 by the language) to make every function a method.


 static methods in C++ are normally reserved for use as class
 methods (although with the pollution from Java that is slowly
 changing). Java OTOH has made them much more common but
 as substitutes for functions as well as true class methods - yeck!

 They are also found in a slightly different guise in Delphi.

 Python classmethods are more powerful and useful than either.

 Alan G.

 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] classmethod, staticmethod functions (decorator related)

2010-09-10 Thread Huy Ton That
I am reading the decorator section within Expert Python Programming and I am
very confused in the first example, of a method that was done before
decorators. It reads:

class WhatFor(object):
def it(cls):
print 'work with %s' % cls
it = classmethod(it)
def uncommon():
print 'I could be a global function'
uncommon = staticmethod(uncommon)

But I can't seem to understand the above. Under what circumstance would
staticmethod be useful? I am just deriving that you are not passing self.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Question about Dictionaries

2010-08-16 Thread Huy Ton That
What do you mean by subclass?

On Aug 16, 2010 3:26 PM, Emile van Sebille em...@fenx.com wrote:

On 8/16/2010 10:44 AM Chorn, Guillaume said...



 Hi All,

 I know that I can look up the value for a particular key in a
 dictionary, but can...
Yes.  But you'll need to implement it.  There are likely modules out there
that'll do this, but it'd take more time to look up and evaluate than to
simply write and implement exactly what you need.



 I understand that this could be problematic from the standpoint
 of multiple keys having the sa...
So, in untested code you'd have a function something like:

result = []

for ky, val in dict.items():
 if val == targetval:
 result.append(ky)
return result

If you need repeated access such that iterating over a large dict frequently
impacts performance, you could subclass dict and maintain a second index
allowing instant access to the keys associated with a specific value.

HTH,

Emile



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] string to list

2010-08-05 Thread Huy Ton That
Speaking of which, is there some place you or anyone can recommend on
picking up all the constructs for list comprehension  generator
comprehension. I've perused the python.org documents and have just been
building them according to example.

How can I pick up more advanced usage?

I mostly catch myself using it to return a list of functions like:

 class foo(object):
... def __init__(self, bar):
... self.bar = bar
...
 [(foo(i)) for i in range(0,10)]
[__main__.foo object at 0x00C54FD0, __main__.foo object at 0x00C54FF0,
__ma
in__.foo object at 0x00C54F50, __main__.foo object at 0x00C54F30,
__main__.f
oo object at 0x00C59050, __main__.foo object at 0x00C59070, __main__.foo
obj
ect at 0x00C590B0, __main__.foo object at 0x00C590D0, __main__.foo
object at
 0x00C59110, __main__.foo object at 0x00C59130]

On Thu, Aug 5, 2010 at 3:25 AM, James Mills prolo...@shortcircuit.net.auwrote:

 On Thu, Aug 5, 2010 at 2:38 PM, Vikram K kpguy1...@gmail.com wrote:
  Suppose i have this string:
  z = 'AT/CG'
 
  How do i get this list:
 
  zlist = ['A','T/C','G']

  import re
  z = 'AT/CG'
  [x for x in re.split(([A-Z]\/[A-Z])|([A-Z]), z) if x]
 ['A', 'T/C', 'G']
 

 cheers
 James

 --
 -- James Mills
 --
 -- Problems are solved by method
 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to get str() to use my function?

2010-08-04 Thread Huy Ton That
You could write __str__ function

 class card(object):
... def __init__(self, card1, card2):
... self.card1, self.card2 = card1, card2
... def __str__(self):
... return str(str(self.card1)+','+str(self.card2))
...
 a = card(0,0)
 str(a)
'0,0'

On Wed, Aug 4, 2010 at 10:37 AM, Alex Hall mehg...@gmail.com wrote:

 Hi all,
 I have a card class. A card object simply consists of a pair of
 numbers; 0,0 might be the ace of clubs, for example. I have a toString
 method in my card class. Is there a way to just say str(card) instead
 of card.toString()? Maybe some sort of basic, built-in function to
 override? TIA. Oh, what about doing the same with operators? For
 example, could I get the program to call my own math functions when it
 sees a card object in a math expression, like
 if(card1==card2)

 --
 Have a great day,
 Alex (msg sent from GMail website)
 mehg...@gmail.com; http://www.facebook.com/mehgcap
 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to get str() to use my function?

2010-08-04 Thread Huy Ton That
These are special method names.

View section 3.4 and below here

http://docs.python.org/reference/datamodel.html

On Wed, Aug 4, 2010 at 11:37 AM, Alex Hall mehg...@gmail.com wrote:

 It worked, thanks. Is there a list of these functions somewhere? That
 is, the functions that map implicitly to operators or implied uses?
 For example, printing will call __str__, as will a cal to str(). What
 about math or comparison operators? I have heard of __eq__, __gt__,
 and so on, but I tried to implement one and I got an error saying that
 it required three arguments. It did, but only because the first was
 self. I put the function inside my card class:
  def __eq__(self, card1, card2):
  return(card1.rank==card2.rank)
  #end def __eq__
 For some reason it is still looking for three arguments...


 On 8/4/10, Huy Ton That huyslo...@gmail.com wrote:
  You could write __str__ function
 
  class card(object):
  ... def __init__(self, card1, card2):
  ... self.card1, self.card2 = card1, card2
  ... def __str__(self):
  ... return str(str(self.card1)+','+str(self.card2))
  ...
  a = card(0,0)
  str(a)
  '0,0'
 
  On Wed, Aug 4, 2010 at 10:37 AM, Alex Hall mehg...@gmail.com wrote:
 
  Hi all,
  I have a card class. A card object simply consists of a pair of
  numbers; 0,0 might be the ace of clubs, for example. I have a toString
  method in my card class. Is there a way to just say str(card) instead
  of card.toString()? Maybe some sort of basic, built-in function to
  override? TIA. Oh, what about doing the same with operators? For
  example, could I get the program to call my own math functions when it
  sees a card object in a math expression, like
  if(card1==card2)
 
  --
  Have a great day,
  Alex (msg sent from GMail website)
  mehg...@gmail.com; http://www.facebook.com/mehgcap
  ___
  Tutor maillist  -  Tutor@python.org
  To unsubscribe or change subscription options:
  http://mail.python.org/mailman/listinfo/tutor
 
 


 --
 Have a great day,
 Alex (msg sent from GMail website)
 mehg...@gmail.com; http://www.facebook.com/mehgcap

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] getattr()

2010-08-04 Thread Huy Ton That
*You can do like below Pete. Where globals has a reference to all
functions in this space.*

def output(data, format=text):

output_function = getattr(globals()['FUNCTION'], output_%s %
format, statsout.output_text)
return output_function(data)


On Wed, Aug 4, 2010 at 3:18 PM, Pete pkoe...@xs4all.nl wrote:

 Hey Huy,

 thanks. But what is the first parameter in this case? (Note there is
 nothing here I'm trying to accomplish except understand).

 In the original example, 'statsout' is the name of the module. In this case
 there is no module so why can you substitute 'output_text'?

 thanks,

 Pete

 On 2010-08-04, at 3:09 PM, Huy Ton That wrote:

 If it is in the same code, and the namespace isn't a module or another
 class you could do this:

 def output_text(data):
 return_value = This is text:  + data
 return return_value

 def output(data, format=text):
 output_function = getattr(output_text, output_%s % format,
 output_text)
 return output_function(data)

 -HTH

 Huy

 On Wed, Aug 4, 2010 at 1:23 PM, Pete pkoe...@xs4all.nl wrote:

 Hi,

 I'm trying to understand the syntax for reflection in python. I was
 wondering about this.

 From the example on diveintopython:

http://diveintopython.org/power_of_introspection/index.html

 import statsout
 def output(data, format=text):
 output_function = getattr(statsout, output_%s % format, 
 statsout.output_text)
 return output_function(data)


 I was wondering about how to make this work if the function that you are
 trying to call is not in a module. Is that possible?

 Something like this:

  def output_text(data):


 return_value = This is text:  + data
 return return_value


 def output(data, format=text):
 output_function = getattr(*, output_%s % format, 
 statsout.output_text)
 return output_function(data)


 What I can't figure out is what to put in place of *. I've tried
 globals()['__name__'], in various forms, to no avail.

 Any pointers would be appreciated.

 thanks,

 Pete


 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor




 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] getattr()

2010-08-04 Thread Huy Ton That
Oh, that's right, I should have tried to example in the interpreter instead
of in my head:P

Say Bob,

Is that the preferred method over something like:

 import __main__ as main

On Wed, Aug 4, 2010 at 3:32 PM, bob gailer bgai...@gmail.com wrote:

  On 8/4/2010 1:23 PM, Pete wrote:

 Hi,

  I'm trying to understand the syntax for reflection in python. I was
 wondering about this.

  From the example on diveintopython:

 http://diveintopython.org/power_of_introspection/index.html

  import statsout
 def output(data, format=text):
 output_function = getattr(statsout, output_%s % format, 
 statsout.output_text)
 return output_function(data)

I was wondering about how to make this work if the function that you
 are trying to call is not in a module.


 Everything in Python is in a module. I suspect you mean not in an imported
 module, e.g. in the main module. Whose __name__ is '__main__'. A reference
 to the main module can be found:

 import sys
 main = sys.modules['__main__']

  Is that possible?

  Something like this:

  def output_text(data):

 return_value = This is text:  + data
 return return_value

   def output(data, format=text):
 output_function = getattr(*, output_%s % format, 
 statsout.output_text)
 return output_function(data)


  What I can't figure out is what to put in place of *. I've tried
 globals()['__name__'], in various forms, to no avail.


 Replace those stars with main as derived above.

 globals()['output_text'] will also give you a reference to the function.

 --
 Bob Gailer
 919-636-4239
 Chapel Hill NC


 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] getattr()

2010-08-04 Thread Huy Ton That
I have a side question,

I am using python 2.7.

Why do you use class A: instead of class A(object): ?

-Huy

On Wed, Aug 4, 2010 at 4:08 PM, bob gailer bgai...@gmail.com wrote:

 On 8/4/2010 4:04 PM, bob gailer wrote:

 On 8/4/2010 3:44 PM, Huy Ton That wrote:

 Oh, that's right, I should have tried to example in the interpreter
 instead of in my head:P

 Say Bob,

 Is that the preferred method over something like:


 I would prefer to create a class and make these functions class methods.

 class A:
  def output_text(self, data):return data
  def output_hex(self, data):return '\\x' + data
  def __getattr__(self, name):
return self.output_text
 a = A()
 data='bar'
 print a.output_text(data)
 print a.output_hex(data)
 print a.foo(data)

  I just realized my answer does not accomodate your looking for the
 function by name. Please stand by


 --
 Bob Gailer
 919-636-4239
 Chapel Hill NC


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Where to start with Unit Testing

2010-08-02 Thread Huy Ton That
Thanks additionally for your insight gems.

Without reading too much into it, it was quite simple to create a series of
test classes which just run some expected assertion values on a small
scenario of inputs and what's expected.

I usually find that I learn best by dabbling around in source code, then
writing some code to test what I think I know.

I'll try to integrate this and commit this to memory with time where I won't
have to look back as much (:


On Sun, Aug 1, 2010 at 9:25 AM, Mac Ryan quasipe...@gmail.com wrote:

 On Sun, 2010-08-01 at 03:30 -0400, Huy Ton That wrote:
  Hi all,
 
  Do any of you have any feedback, strategies and best practices related
  to unit testing within Python. This is a relatively new topic for me.
  I was thinking of starting with reading the documentation associate
  with the unittest module.

 My answer falls in the category feedback (I was also going to mention
 the diveintopython page, but somebody else has done that already!), so
 you should be aware what follows is highly subjective...

 JUST THINK... IN PYTHON!
   IMO, unit testing is really easy to pick up. It really does not
 amount to much more than taking note (in python) of what you are
 thinking when you are coding.
   If you are anything like me, when you code you keep on formulating
 rules in your head, in the line of when everything works as expected,
 if the methods iterates four times, then this method must return X or
 when everything works as expected, if a user enter a value over 212
 then the script must throw this exception, etc...
   * the when everything works as expected translates in this test
 pass when...
   * the if X translates in your test case (i.e. the scenario you are
 testing for)
  * the then Y translates in the outcome of my test case must be Y

 TESTING IS VALUABLE IN THE LONG RUN
   At times, designing and coding a test is a time-consuming activity,
 and if the code is particularly straightforward you might be tempted to
 skip the unit testing altogether. In my experience - however - unit
 testing is never as useful on the spot as it is three months from now,
 when you will have/want/choose to modify a little bit of your old code,
 and all of a sudden everything will break. In the latter scenario, your
 test suite will be an invaluable asset.

 FUNCTIONAL PROGRAMMING WINS
   The most difficult thing in writing a test, is replicating the state
 of the environment needed for the test to happen. This is especially
 (but not uniquely) true for DB-driven applications, when you might wish
 to perform test on methods that interact with the DB. In that case you
 have to create a test DB, populate it with ~credible data, etc...
   The most functional (as in functional programming, i.e.
 machine-state independent) is your code, the easiest is to write a test.
 Example: if you need to check a method that validate the postal code of
 an address based on the name of the city, it is easier to test a method
 that is invoked with validate_postal_code(code, city) rather than one
 that is invoked with validate_postal_address(user) and that will have
 to retrieve the full address of a user from a DB, and extract the city
 and postal address from it.

 MVC WINS
   I never test UI's. I know it is bad... but it is simply too
 time-consuming for me (I'll be very glad if somebody reading this will
 show me how one can make it snappier!). This means - at least for me -
 that writing tests become extremely easier for me if I keep separated
 the presentation layer from all the rest of the stuff.

 EVERY BUG IS A TEST YET NOT WRITTEN
   A program that passes all its tests is not necessarily a bug-free
 program. But once you find a new bug, try to make a point of writing a
 new test that check for that particular scenario in which said bug is
 happening.

 TEST-DRIVEN IS BETTER
   What I find useful (although not always applicable) is to start my
 programming session by writing the tests before I write the code to be
 tested. This somehow reconnect to my previously articulated just
 think... in python! point: you are however *already doing a list of
 rules* in your head, before writing code, so you could well write it
 down directly in code. All you need is to create a mock method/function
 in your code with the same signature you are using in your test. For
 example. You could write tests in the form:

assertEqual(better_square_root(9), 3)
assertRaises(ValueError, better_square_root, -4)

 and then write in your module:

def my_better_square_root(number):
pass

 all your tests will of course initially fail, but then you will keep on
 working on the code of my_better_square_root until all your tests pass.

 Well, these are just my two ¢... As stated in the beginning: highly
 subjective, so keep your mind open for other (possibly opposite)
 opinions too! :)

 HTH,
 Mac.


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change

Re: [Tutor] Where to start with Unit Testing

2010-08-02 Thread Huy Ton That
One final note, that I thought might be useful to others.

I've just discovered doctest, which allows you to run tests on your embedded
function/class documentation.

Check it out here:
http://docs.python.org/tutorial/stdlib.html#quality-control

On Sun, Aug 1, 2010 at 3:30 AM, Huy Ton That huyslo...@gmail.com wrote:

 Hi all,

 Do any of you have any feedback, strategies and best practices related to
 unit testing within Python. This is a relatively new topic for me. I was
 thinking of starting with reading the documentation associate with the
 unittest module.

 -Huy

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Where to start with Unit Testing

2010-08-01 Thread Huy Ton That
Hi all,

Do any of you have any feedback, strategies and best practices related to
unit testing within Python. This is a relatively new topic for me. I was
thinking of starting with reading the documentation associate with the
unittest module.

-Huy
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Where to start with Unit Testing

2010-08-01 Thread Huy Ton That
All these responses are incredible, I will go through them on my venture to
bring unit testing under my belt.

I have never done formal unit testing in my programming career, I've just
gone through way of general debugging and utilizing version control such as
Mercurial.

On Sun, Aug 1, 2010 at 9:42 PM, David Hutto smokefl...@gmail.com wrote:

 On Sun, Aug 1, 2010 at 9:39 PM, David Hutto smokefl...@gmail.com wrote:
  On Sun, Aug 1, 2010 at 9:31 PM, David Hutto smokefl...@gmail.com
 wrote:
  On Sun, Aug 1, 2010 at 9:11 PM, Che M pine...@hotmail.com wrote:
 
 
   The idea of unit testing/test driven development has remained
   foreign to me throughout my time trying to learn Python--by choice.
   I want to make desktop GUI applications and I don't use MVC, so
   the idea of writing tests strikes me as far more work--and a major
   delayer of getting to an application that actually does something--
   than simply using the software myself and noting problems.  It
   sounds like TDD is probably the most proper way to go about things,
   but, in the interest of getting something out of Python to warrant
 the
   time I've put into it, I favor a good enough approach for now.
 
  Writers just call this a rough draft. Perfection is in the revisions
  that come after a little thought.
 
  Well, I don't see what I'm doing as a rough draft, as I am attempting
  to hone it to perfection (that is, a working app)--just without unit
  testing.
 
  Every time you try to perfect is a revision of your initial 'written'
  algorithm. From concept forward is your revisions. Notice that svn and
  cvs are called revisions. How quickly is a different story. To you,
  your writing and rewriting, but each rewrite is a revision of the
  initial concept. And as far as i can tell, if you want to be the unit
  test yourself, it's fine, but unit testing might be inappropriate for
  something like this. But basically unit testing would be a script that
  inputs the possible combinations of requests to the original script,
  which should be tested like chefs do soups-intermittently as you
  design it. So the tests are really what you put or type as input given
  directly to the script , right?.
 
 
 
 
  A different analogy comes to my mind; I once saw two different sets of
  people analyze data.  One did it by hand:  visually inspecting
 thousands
  of signals herself and typing Y or N to accept or reject each signal.
 The
  other did it with an automated system that accepted or rejected signals
  based on fuzzy logic.
 
  This depends on your need for control, do you need to manually accept,
  or can you just detect the signal, and let the program proceedl. Do
  you want the local nuclear plant to have their system throw an error,
  without a human response?
 
  In an important interpretation, the automated system
  was far better, and yet the first scientist was done with her analysis
 and
  accepted for publication before the second team even had the bugs
 worked
  out of the automated system!
 
  Like you state below, the automated system used, evolved from manually
  designed systems, so automation is the easy way, but sometimes not the
  best, depending on the circumstance and priority level of the
  information being received.
 
  Yes, I think the slow-but-more-proper team
  did the more correct thing, but there is something to be said for good
  enough, too (it works for evolution, for example).
 
 
 
 
 
 
  ___
  Tutor maillist  -  Tutor@python.org
  To unsubscribe or change subscription options:
  http://mail.python.org/mailman/listinfo/tutor
 
 
 
 
  Disclaimer: I have no clue what unit testing is, nor have I had to use it
 yet.
 

 But it would be a series of function instances from a module, right?
 Not to butt in on the OP.
 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Problem with input() and unicode string

2010-07-28 Thread Huy Ton That
You can do:

input(unicode('Introduce el año:', 'latin-1').encode('latin-1'))

Maybe someone could explain it better than I can.

HTH,

Huy

On Wed, Jul 28, 2010 at 12:05 PM, Alex abc...@yahoo.co.uk wrote:

 Hello, I have a problem with this code:

 # -*- coding: latin-1 -*-
 year = u'año, ò, ó, ç'
 print year
 year = input(u'Introduce el año:')
 print year
 raw_input()

 The first print statement works as expected, both in IDLE and when
 double-clicking the file for a console view.
 The second one works in IDLE, but just flashes by when double-clicking the
 file, due to an error report I can't see.
 I believe the problem is that input prompt doesn't support unicode strings,
 which means I can't use my language for prompts?
 Could someone please tell me how to fix it or provide a workaround?
 Thanx.

 Using Python 2.7 under win32.


 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] django help....

2010-07-26 Thread Huy Ton That
I highly recommend www.djangobook.com

The continuity is very good, and along the side of the book are comment
boxes with further insight from users.

After getting to about chapter 4, you should be able to toggle between
djangoproject.com's documentation and the rest of the djangobook for further
insight.

On Mon, Jul 26, 2010 at 9:03 AM, Dipo Elegbede delegb...@dudupay.comwrote:

 hi,

 I am doing reading on django

 what ook would you recommend for a beginner?

 I have been trying to work with the documentations but get stock in between
 and totally become lost.

 this continous break is giving me too much headache to move on and i am
 getting discouraged.

 Please recommend a book for starters.

 Thanks.

 --
 Elegbede Muhammed Oladipupo
 OCA
 +2348077682428
 +2347042171716
 www.dudupay.com
 Mobile Banking Solutions | Transaction Processing | Enterprise Application
 Development

 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python Documentation Clarification

2010-07-12 Thread Huy Ton That
This is going to sound silly, but I realized there are some areas within the
documentation that do not make absolute sense to me.

e.g.

compile(source, filename, mode[, flags[, dont_inherit]])

I see within this built in function, the first argument can be what they
define as source, the second argument as the filename and the third as the
mode.

But what confuses me is sometimes I see a bracket, above as [, flags[,
dont_inherit]]. Is this an optional argument like flags=dont_inherit?

Just not grokking it correctly and I can't seem to track down where the
documentation formatting is defined within the python.org documentation...
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python Documentation Clarification

2010-07-12 Thread Huy Ton That
Proverbial Ah-ha moment all. This clarifies things greatly (:

Thanks you all!!

On Mon, Jul 12, 2010 at 11:29 AM, Nick Raptis airsc...@otenet.gr wrote:



 compile(source, filename, mode[, flags[, dont_inherit]])

 I see within this built in function, the first argument can be what they
 define as source, the second argument as the filename and the third as the
 mode.

 But what confuses me is sometimes I see a bracket, above as [, flags[,
 dont_inherit]]. Is this an optional argument like flags=dont_inherit?


  Brackets do indeed mean optional arguments.
 So you can do
 compile(source, filename, mode, flags=whatever, dont_inherit=True)
 or something.

 The nested brackets most likely show that (in your example), dont_inherit
 is optional, but can be used only if you (optionally) also provide the flags
 argument.

 Of course, don't take my word for it and read the rest of the description
 in the documentation.

 Also read here:
 http://docs.python.org/reference/introduction.html?highlight=brackets
 http://docs.python.org/reference/introduction.html?highlight=brackets#notation

 Nick
 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Django Read

2010-07-08 Thread Huy Ton That
I've went through the djangobook myself, and found it quite readable. This
would be my recommendation as well.

Be sure to read the sidebar comments; if you ever feel stuck, someone else
may have addressed the question/answer for you!

-Lee

On Thu, Jul 8, 2010 at 9:31 AM, Jeff Johnson j...@dcsoftware.com wrote:

 On 07/08/2010 06:06 AM, Nick Raptis wrote:

 There actually aren't that many books on django around yet which is a
 pity.
 You should definitely read The django book:
 http://www.djangobook.com/en/2.0/
 either on the online version on that link, or it's printed counterpart
 (yes, it's really the same book):
 http://www.amazon.com/Definitive-Guide-Django-Development-Second/dp/143021936X/

 The printed one is a bit more updated (1.1) and pays off it's money
 because of it's great reference section :)

 Nick

 On 07/08/2010 03:48 PM, Dipo Elegbede wrote:

 Hi all,

 I have done a little basic on python and have to start working on a
 major django platform.
 I'm starting new and would like recommendations on books I can read.

 Kindly help me out. I want to get my hands dirty as fast as I can so
 that I can be part of the project.

 Thanks and Best regards,


  I have six books on my bookshelf for Django.  There are others I don't
 have.  Django 1.0 Template Development is my favorite.  Many of them walk
 you through building apps step by step.  Do a search on Amazon.  That is
 where I got most of them.

 --
 Jeff

 ---

 Jeff Johnson
 j...@dcsoftware.com



 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor