Re: Static analysis tools

2012-10-11 Thread Tim Leslie
On 12 October 2012 04:25, Dan Stromberg  wrote:
>
> I'm familiar with pylint, and have recently played with pyflakes and flake8.
> I've also heard of pychecker.
>
> Are there others, perhaps including some that aren't written in Python, but
> still check Python?

Another one I've found useful for stylistic checking is pep8:

https://github.com/jcrocholl/pep8

I find it to be complementary to the types of checks performed by
pylint and use both of them in tandem on large projects I work on.

Cheers,

Tim

>
> We're considering doing static analysis of a large CPython 3.2 project, but
> so far the traditional 3 seem to be coming up a little short for Python 3
> compatibility.  Especially, they don't seem to understand PEP 3102 AKA
> Keyword Only Arguments, and we really like Keyword Only Arguments.
>
> Opensource would be great,but we'd also be willing to pay for a suitable
> tool.
>
> Windows or *ix tools would be fine.
>
> Any suggestions about things to check into?
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dynamic assigments

2011-03-24 Thread Tim Leslie
On 25 March 2011 13:51, scattered  wrote:
> Here is another possibility: you are using Python *interactively* in
> solving cryptograms (as a matter of fact - I was doing exactly this
> yesterday in trying to solve some Playfair ciphers). You have a
> ciphertext that is a stream of letters in the range A...Z. You need to
> consult frequencies of letters, pairs of letters, triples of letters,
> and quadruples of letters that occur. So, you write a script that
> steps through the cipher text, creates a dictionary which records
> frequencies of strings of length <= 4, and, as an added convienence,
> creates bindings of frequencies to these strings. Thus - if you want
> to know how often, say, EFW occurs in the ciphertext you just type EFW
> (rather than freq["EFW"])

And what happens when you want to know the frequency of "if", "def",
"for" or any other variable which matches a keyword?

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: weighted mean; weighted standard error of the mean (sem)

2010-09-09 Thread Tim Leslie
On 10 September 2010 11:43, C Barrington-Leigh  wrote:
>
>> The best place to ask about numpy related stuff is the numpy mailing list at:
>>
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>> This is also the best place to present a patch if you have code to
>> contribute. In my experience the numpy devs are always happy to have
>> new contributors, but be sure to discuss the problem first, as the
>> folk over there might be able to provide a solution which doesn't
>> require a new patch.
>
>
> Thanks, Tim,
>
> Ooops -- the sem() I mentioned is  sciypy.stats.sem, not in numpy...
> Does your advice hold?
> Thanks,

For discussion out that function you probably want the scipy-user
mailing list. For completeness, here's the full list of related
mailing lists:

http://www.scipy.org/Mailing_Lists

Cheers,

Tim

> c
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: weighted mean; weighted standard error of the mean (sem)

2010-09-09 Thread Tim Leslie
On 10 September 2010 10:36, C Barrington-Leigh  wrote:
>
> Most immediately, I'd love to get code for weighted sem. I'll write it
> otherwise, but if I do I'd love to know whom to bug to get it
> incorporated into numpy.sem ...

The best place to ask about numpy related stuff is the numpy mailing list at:

http://mail.scipy.org/mailman/listinfo/numpy-discussion

This is also the best place to present a patch if you have code to
contribute. In my experience the numpy devs are always happy to have
new contributors, but be sure to discuss the problem first, as the
folk over there might be able to provide a solution which doesn't
require a new patch.

Cheers,

Tim

>
> Thanks!
>
> None of them have this basic function. Has anyone written one?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "is not" operator?

2010-07-08 Thread Tim Leslie
On Fri, Jul 9, 2010 at 12:16 PM, Jack Diederich  wrote:
>
> The right way to think about python syntax is not to consider what is
> obvious to an LL(1) compiler, or what makes sense in English, but
> rather "what was the obvious way to write an LL(1) syntax if you are a
> Dutchman who speaks English?"

+1 QOTW

>
> Hope-that-clears-things-up-ly,
>
> -Jack
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question...

2008-09-29 Thread Tim Leslie
On Tue, Sep 30, 2008 at 12:04 PM, Ken D'Ambrosio <[EMAIL PROTECTED]> wrote:
> First, apologies for such a newbie question; if there's a better forum (I've
> poked around, some) feel free to point it out to me.  Anyway, a mere 25-odd
> years after first hearing about OOP, I've finally decided to go to it, by
> way of Python.  But this puzzles me:
>
> import commands

free = commands.getoutput("free")
# free is now a string, representing the output from the "free" command

for line in free:
  print line,

This isn't doing what you think. Since free is a string, when you
iterate over it, you get a single character each time, so your line
variable isn't actually a line of the output, but a single character.
When you run "print line," this prints the character, followed by a
space. The comma at the end of the print statement tells it to put a
space after the output rather than a newline.

What you probably wanted to do is split up your output on the newline character.

for line in free.split("\n"):
print line

Of course, your string already has all the newlines it needs in it, so
if all you want is to see the output of the "free" command you can
just do:

print free

HTH,

Tim

>
> Gives:
>  t o t a l   u s e d  f r e e
> s h a r e d b u f f e r s   c a c h e d
> M e m : 5 1 5 9 9 2   4 6 0 4 5 2 5 5 5
> 4 0
>   0 7 7 5 1 6 9 1 8 8 4
> - / +   b u f f e r s / c a c h e :   2 9 1 0 5 2   2 2 4 9
> 4 0
>
> Why are there spaces between everything?  And how do I keep it from
> happening?  *confused*
>
> Thanks much,
>
> -Ken
> ** Posted from http://www.teranews.com **
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: matrix algebra

2008-09-22 Thread Tim Leslie
On Mon, Sep 22, 2008 at 6:02 PM, Al Kabaila <[EMAIL PROTECTED]> wrote:
> Hi,
>
> My OS is Linux (openSUSE 10.3) and my interest in retirement is Python
> applications to Structural Analysis of  Civil Engineering structures,
> currently in 2 dimensions only (under GPL). Modern Structural Analysis is
> highly matrix oriented, but requires only a few basic matrix operations,
> namely matrix creation, transposition, multiplication, invertion and
> linear equation solution. For stability analysis one would require
> Eigenvalues and Eigenvectors. In 3 dimensions, additionally highly
> desirable would be vector algebra. The packages do have all these
> functions, but currently only the basic functions are in the wrapper.
>
> There are several packages for matrix algebra. I tried Numeric, numpy and
> numarray. All three are very good, but each uses different syntax. Not a
> good thing for teaching...  So I wrote a little python wrapper (under GPL)
> to unify all packages with the same simple and transparent syntax.

There is no need for a wrapper. Both numarray and Numeric have been
deprecated in favour of numpy, so numpy is the only one you need to
use. Numpy should have all the tools you need. If you find something
missing, there's a good chance it's included in scipy (which  is built
on top of numpy). For full details see www.scipy.org.

Cheers,

Tim

> Currently it deals with the Numeric, numpy and numarray and covers creation
> of zero filled matrices, transposition, matrix multiplication, solution of
> equations and inversion.
>
> This is a very active newsgroup that incudes such giants as Frederik Lundh
> and countless others. I wonder:
>
> 1. Is there any interest in matrix algebra "for the masses" (I mean interest
> in a wrapper for a subset of functions of the packages with a unified
> simple syntax)?
> 2. What other matrix operations would be required for your area of interest?
> 3. What other matrix packages, if any, should one include in the wrapper?
>
> A copy of the wrapper is stored in a small, public svn repository. If you
> would like to download it, please contact me by email at. Of course, if
> there is interest, I would be delighted to upload it to a generally
> accessible repository.  Finally, if this is a re-invention of the wheel
> (which it may well be), would you kindly let me know?
>
> akabaila [at] pcug [dot] org [dot] au.
>
> I would be very happy to send you the checkout instructions, but I should
> discuss that with the people who run the repository. My home page that I
> quote with my signature is not a repository nor does it have the current
> programs.
>
> OldAl.
>
> --
> Al Kabaila (Dr)
> http://akabaila.pcug.org.au/StructuralAnalysis
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Rubik's cube translation

2008-03-30 Thread Tim Leslie
On Mon, Mar 31, 2008 at 12:24 PM,  <[EMAIL PROTECTED]> wrote:
> How do I get a Rubik's cube translation out of this:
>
>  >>> a= numpy.array([[0,1,2],[3,4,5],[6,7,8]])
>  >>> a
>  array([[0, 1, 2],
>[3, 4, 5],
>[6, 7, 8]])
>  >>> a[:,0],a[:,1],a[:,2] #no good
>  (array([0, 3, 6]), array([1, 4, 7]), array([2, 5, 8]))
>  >>>
>
>  I need [[ 6, 3, 0 ], [ 7, 4, 1 ], [ 8, 5, 2 ]].
>
>  >>> c= numpy.array([[ 6, 3, 0 ], [ 7, 4, 1 ], [ 8, 5, 2 ]])
>  >>> c
>  array([[6, 3, 0],
>[7, 4, 1],
>[8, 5, 2]])

In [10]: numpy.rot90(a, 3)
Out[10]:
array([[6, 3, 0],
   [7, 4, 1],
   [8, 5, 2]])

Tim

>  --
>  http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why did no one tell me about import antigravity?

2007-12-05 Thread Tim Leslie
On 5 Dec 2007 10:08:48 GMT, Adrian Cherry <[EMAIL PROTECTED]> wrote:
> Ant <[EMAIL PROTECTED]> wrote in news:52f0eca3-e807-4890-b21d-
> [EMAIL PROTECTED]:
>
> > Python on xkcd:
> >
> > http://xkcd.com/353/
> >
>
> Another good comic from xkcd, I'm surprised by the muted response
> on here. Don't forget to check out the alt. text on the comic
>
> Alt text: "I wrote 20 short programs in Python yesterday. It was
> wonderful. Perl, I'm leaving you."
>

+1 QOTW

Tim

>
> Regards
>
> Adrian
>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with following python code

2007-06-11 Thread Tim Leslie
On 6/12/07, why? <[EMAIL PROTECTED]> wrote:
> I've been having problem with the following code. It's supposed to
> print the prime numbers  between 10 and 100. But i'm not getting any
> output, i.e. i guess the outer 'for' loop is being traversed only
> once. I would be greatful if you could help me out. Thanx!
> >>> f=1
> >>> for i in range(10,100):

You need to switch these two lines to reset the flag each time around
the outer loop.

Cheers,

Tim

> ... for j in range(2,i):
> ... if i%j==0:
> ... f=0
> ... break
> ... else: continue
> ... if f==1:
> ... print i,
> ...
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String parsing

2007-05-08 Thread Tim Leslie
On 8 May 2007 18:09:52 -0700, HMS Surprise <[EMAIL PROTECTED]> wrote:
>
> The string below is a piece of a longer string of about 2
> characters returned from a web page. I need to isolate the number at
> the end of the line containing 'LastUpdated'. I can find
> 'LastUpdated'  with .find but not sure about how to isolate the
> number. 'LastUpdated' is guaranteed to occur only once. Would
> appreciate it if one of you string parsing whizzes would take a stab
> at it.
>

Does this help?

In [7]: s = ''

In [8]: int(s.split("=")[-1].split('"')[1])
Out[8]: 1178658863

There's probably a hundred different ways of doing this, but this is
the first that came to mind.

Cheers,

Tim

> Thanks,
>
> jh
>
>
>
> 
> 
> 
> 
> 
> 
> 
>  align="center"
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: function with list argument defaulting to [] - what's going on here???

2007-04-15 Thread Tim Leslie
On 14 Apr 2007 20:20:42 -0700, Paddy <[EMAIL PROTECTED]> wrote:
> On Apr 15, 3:58 am, Steven D'Aprano
> <[EMAIL PROTECTED]> wrote:
> > On Sat, 14 Apr 2007 17:33:11 -0800, Troy Melhase wrote:
> > > On 4/14/07, Mike <[EMAIL PROTECTED]> wrote:
> > >> While trying to write a recursive function involving lists, I came
> > >> across some (to me) odd behavior which I don't quite understand. Here's
> > >> a trivial function showing the problem.
> >
> > > fromhttp://docs.python.org/ref/function.html:
> >
> > > Default parameter values are evaluated when the function definition is
> > > executed. This means that the expression is evaluated once, when the
> > > function is defined, and that that same ``pre-computed'' value is used
> > > for each call. This is especially important to understand when a
> > > default parameter is a mutable object, such as a list or a dictionary:
> > > if the function modifies the object (e.g. by appending an item to a
> > > list), the default value is in effect modified.
> >
> > This comes up so often that I wonder whether Python should issue a warning
> > when it sees [] or {} as a default argument.
> >
> > What do people think? A misuse or good use of warnings?
> >
> > --
> > Steven.
>
> I wonder if it is a check done by Pylint or PyChecker?

It is a check done by pylint

Tim

>
> - Paddy.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Computing FFT with Python NumPy 1.0

2006-11-01 Thread Tim Leslie
On 1 Nov 2006 16:04:59 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I recently installed Python 2.5 on Windows and also installed numpy
> 1.0.  I'd like to compute an FFT on an array of numbers but I can't
> seem to access the FFT function.  I'm fairly new to Python (obviously)
> and I can't seem to find documentation to match my distribution of
> numpy and I can't figure out how to access the FFT function.
>
> Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
>
> IDLE 1.2
> >>> from numpy import *
> >>> a=array((1,2,3,2,1,2,3,2,1))
> >>> fft(a)
>
> Traceback (most recent call last):
>   File "", line 1, in 
> fft(a)
> TypeError: 'module' object is not callable
> >>>
>
> Help appreciated thanks.

The fft routines now live in numpy.fft.

>>> from numpy.fft import fft
>>> from numpy import array
>>> a=array((1,2,3,2,1,2,3,2,1))
>>> fft(a)
array([ 17.+0.j,  -1.15270364-0.41954982j,
-3.37938524-2.83564091j,   0.5   +0.8660254j ,
 0.03208889+0.18198512j,   0.03208889-0.18198512j,
 0.5   -0.8660254j ,  -3.37938524+2.83564091j,
-1.15270364+0.41954982j])


>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: round not rounding to 0 places

2006-08-16 Thread Tim Leslie
On 16 Aug 2006 00:19:24 -0700, Fuzzydave <[EMAIL PROTECTED]> wrote:
> I have been using a round command in a few places to round
> a value to zero decimal places using the following format,
>
> round('+value+', 0)
>
> but this consistantly returns the rounded result of the value
> to one decimal place with a zero
>
> EG:
>
> 4.97 is returned as 5.0 when i want it returned as 5, does
> anyone know why this is and if i can get the round to make
> the value 5?

round returns a float. You probably want to convert it to an int.

>>> int(round(4.97))
5

Cheers,

Tim

>
> David P
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a time series analysis package in python - advice or assistance sought

2006-07-06 Thread Tim Leslie
Hi Ray,

As a first step you might want to look at numpy/scipy/matplotlib

numpy (numpy.scipy.org) provides the underlying data structures (array
and matrices among other things) you require. This will handle all
your vector stuff, reading/writing to and from files, "loop macros",
etc.

scipy (www.scipy.org) provides a set of scientific programming
libraries, including stats, fft and many other things. Have a look
around and see if it already does what you want.

matplotlib (http://matplotlib.sourceforge.net/) takes care of all your
plotting needs, and plays nice with numpy and scipy.

HTH

Tim

On 7/7/06, Ray Tomes <[EMAIL PROTECTED]> wrote:
> Hi Folks
>
> I am an old codger who has much experience with computers
> in the distant past before all this object oriented stuff.
> Also I have loads of software in such languages as FORTRAN
> and BASIC, QBASIC etc that is very useful except that it
> really doesn't like to run on modern operating systems and
> has hopeless graphics resolution and lack of ease of use in
> some ways.
>
> My desire is to get all the facilities available in my
> old programs working in a modern platform with flexible
> and high-res graphics and easy to use. Ideally I might
> find some good coders that are interested in the subject
> who would assist me, alternatively some help in getting
> started because there is so much info and so many resources
> and libraries etc that I don't know where to start.
>
> My package will have the following capabilities:
> 1. Able to read time series data in a variety of formats.
> 2. Able to create, manipulate and save time series files.
> 3. Able to do vector arithmetic on time series, including
> dozens of functions.
> 4. Loop and macro facilities to simplify repetitive stuff.
> 5. Flexible high-resolution graphic presentation.
> 6. Built in functions to include:
> FFT / fourier analysis, MESA / maximum entropy spectral analysis,
> multiple regression, canonical correlation etc etc etc.
> I have code for all these mostly in FORTRAN, some QBASIC.
>
> The applications of the package include:
> 1. Analysis of time series data from many branches of science.
> 2. Economic / business models including forecasting.
> 3. Markets, stocks, commodities forecasting.
> 4. Interdisciplinary causal analysis.
> 5. Many more
>
> If you are seriously interested in this, then please contact
> me by email at ray(at)tomes(dot)biz which is the email from
> which this message was sent without the ".remove" part (anti-
> spam measure).
>
> Ray Tomes
> http://ray.tomes.biz/
> http://www.cyclesresearchinstitute.org/
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Q's: pythonD and range(1,12)

2006-03-13 Thread Tim Leslie
On 3/14/06, John Savage <[EMAIL PROTECTED]> wrote:
I've very new to python, and am currently toying with pythonD. Couldsomeone please explain the rationale behind python designers' thinkingin deciding the function "range(1,12)" should return the sequence 1 to
11 rather than the more intuitively-useful 1 to 12??The range() function maps closely to a very common idiom in c-like languages.for (i = a; i < b; i++) { do_stuff(i); }in a C-like language is the same as
for i in range(a, b): do_stuff(i)in python. Another way to think about it is to notice that if you do range(10), you get exactly 10 items in your list (starting at 0), so going from 0 to n-1 is the correct way to go. Having the "start from zero" case work intuitively is the starting point and being able to specify a different starting value to zero simply generalises on this.
Are you sure you need your range to start at 1? It's a common newbie error to start counting from 1 instead of zero in some places, but I won't accuse you of such an error without seeing more context :-)HTH
Tim After downloading the substantial distribution .zip file, I'm intrigued
to find it includes 3 files of identical size and creation date, differingapparently only in name (python, python2.4 and python24.exe) and each ofexactly 2,597,888 bytes. What possible purpose could be served by such
triplication that couldn't more efficiently be done by other means?Naive but curious minds wish to know!--John Savage   (my news address is not valid for email)--
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: A Moronicity of Guido van Rossum

2005-09-29 Thread Tim Leslie
On 29 Sep 2005 07:24:17 -0700, Xah Lee <[EMAIL PROTECTED]> wrote:
Of course, you begin to write things like Java, in three thousand wordsjust to state you are a moron.

+1 QOTW.

Tim
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Does a function like isset() exist in Python?

2005-06-22 Thread Tim Leslie
On 6/23/05, Patrick Fitzsimmons <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I'm sure I should know this, but I can't find it in the manual.
> 
> Is there a function in Python like the function in PHP isset()?  It
> should take a variable name and return True or False depending on
> whether the variable is initialized.

There's no direct function to acheive this however you can find out
the answer by looking in locals() and globals() dictionaries. Before
doing this though you should consider why you want to do it. A lot of
this time when this kind of thing comes up the problem can better be
solved by rearranging the code such that you don't need to check
isset() in the first place.

Tim

> 
> Thanks for any help,
> Patrick
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why python on debian without the module profile?

2005-06-13 Thread Tim Leslie
My understanding is that there are licence issues (someone please
correct me if I'm wrong). The moral of the story is that there's a
seperate (non-free) package for the profiler:

http://packages.debian.org/testing/python/python2.4-profiler

HTH

Tim

On 6/13/05, kyo guan <[EMAIL PROTECTED]> wrote:
> Hi All:
> 
> Python 2.4.1 (#2, May  5 2005, 11:32:06)
> [GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import hotshot,hotshot.stats
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "/usr/lib/python2.4/hotshot/stats.py", line 3, in ?
> import profile
> ImportError: No module named profile
> >>>
> 
> 
> 
> Python 2.3.5 (#2, May  4 2005, 08:51:39)
> [GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import hotshot,hotshot.stats
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "/usr/lib/python2.3/hotshot/stats.py", line 3, in ?
> import profile
> ImportError: No module named profile
> >>>
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generalized Linear Least Squares Problems

2005-05-31 Thread Tim Leslie
On 31 May 2005 03:12:49 -0700, venkat <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I want to solve linear least sqaure problem( min||c-Ax||2 subject to
> Bx=d ). How do I do it in python. lapack has a routine for doing this
> (DGGLSE). Can I access this from python?
>

Check out scipy, in particular the linear algebra package.

http://www.scipy.org/documentation/apidocs/scipy/scipy.linalg.html

Cheers,

Tim
 
> TIA,
> venkat.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: prime number

2005-05-29 Thread Tim Leslie
On 29 May 2005 19:55:32 -0700, lostinpython
<[EMAIL PROTECTED]> wrote:
> I'm having trouble writing a program that figures out a prime number.
> Does anyone have an idea on how to write it?  All I know is that n > 2
> is prim if no number between 2 and sqrt of n (inclusivly) evenly
> divides n.

This sounds remarkably like a homework problem, so I'm not going to
give you a full answer. Perhaps if you could be more specific about
which part's giving you trouble we could help you out with that.

If it finding square roots? is it checking for divisibility? is it
getting the loop to run through correctly? Is it some other problem?

Tim

> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __init__() not called automatically

2005-05-25 Thread Tim Leslie
On 25 May 2005 21:31:57 -0700, Sriek <[EMAIL PROTECTED]> wrote:
> hi,
> i come from a c++ background. i ws happy to find myself on quite
> familiar grounds with Python. But, what surprised me was the fact that
> the __init__(), which is said to be the equivlent of the constructor in
> c++, is not automatically called. I'm sure there must be ample reason
> for this. I would like to know why this is so? This is my view is more
> burden on the programmer.

>>> class C:
... def __init__(self): print "Hello"
...
>>> c = C()
Hello

This looks like __init__ being called automatically to me. Are you
doing something different?

> Similarly, why do we have to explicitly use the 'self' keyword
> everytime?

http://www.python.org/doc/faq/general.html#why-must-self-be-used-explicitly-in-method-definitions-and-calls

> 
> Every kind of help would be welcome.

No worries,

Tim

> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda

2005-02-08 Thread Tim Leslie
Short answer:

lambda is a python keyword which allows you to create anonymous
functions which may be considered a useful thing to have in certain
cases*.

Long answer:

To be provided by someone else who isn't meant to be working right now.

Tim

* There is much debate as to just how useful lambda functions are and
they are likely to be removed from the language in the distant futute
(python 3)


On Tue, 8 Feb 2005 17:43:32 -0800, e <[EMAIL PROTECTED]> wrote:
> Question: WHAT IS LAMBDA? I can't figure out what it does from any
> documentation i've found anywhere. i doubt i need it but i still want to
> know what the heck it is/does/fixes/whatever!
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: lambda

2005-01-13 Thread Tim Leslie
Because if it takes more than a single line it deserves a name. Also,
if you have more than one line in this function, how do you plan to
reference it if not by name?

Tim


On Thu, 13 Jan 2005 20:53:09 +1000, Egor Bolonev <[EMAIL PROTECTED]> wrote:
> why functions created with lambda forms cannot contain statements?
> 
> how to get unnamed function with statements?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list