Re: [Tutor] Class decorator on a derived class not initialising the base classes using super - TypeError

2014-02-24 Thread Sangeeth Saravanaraj
Peter, Spir - thanks for your time and effort! I am posting this query to few more Python mailers. Thank you, Sangeeth On Tue, Feb 25, 2014 at 5:22 AM, spir wrote: > On 02/24/2014 08:19 PM, Sangeeth Saravanaraj wrote: > >> Sorry, I should have described what I was trying! >> >> I want to cre

Re: [Tutor] Class decorator on a derived class not initialising the base classes using super - TypeError

2014-02-24 Thread spir
On 02/24/2014 08:19 PM, Sangeeth Saravanaraj wrote: Sorry, I should have described what I was trying! I want to create a decorator which should do the following things: - When an object of the decorated class is created, the objects name (say the value of the incoming "id" argument) sho

Re: [Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Danny Yoo
Last comment (apologies for being so fragmented!). I don't know why the literal strings there are raw there. Altogether, I'd expect: # cmd1 = ['sphinx-apidoc', '-f', '-F', '-H', title, '-A', author, '-V', version,

Re: [Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Danny Yoo
There are a few issues there. I'd also recommend not trying to shell-quote these manually, # in the argument list of os.subprocess: r'-H', '"%s"' % title, r'-A', '"%s"' % author, r'-V', '"%s"' % version, Rather, just do the simpler thing: r'-H', title, r'-A', author,

Re: [Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Peter Otten
Peter Otten wrote: >> r'-f -F', >> r'-H', '"%s"' % title, > > "title" becomes \"title\", i. e. Python puts in an extra effort to have > the quotes survive the subsequent parsing process of the shell: > print subprocess.list2cmdline(['"title"']) > \"title\" Forget that :( Danny spotted th

Re: [Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Peter Otten
Albert-Jan Roskam wrote: > Hi, > > In the code below, cmd1 and cmd2 are equivalent, as in: " ".join(cmd1) == > cmd2. But the first example returns a code 2, whereas the second runs > successfully. What is the difference? I prefer using a list as it looks a > little cleaner. Btw, shell=True is nee

Re: [Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Danny Yoo
> cmd1 = [r'sphinx-apidoc', >r'-f -F', This part looks suspicious. Are you sure you don't mean: '-f', '-F' here? They need to be separate arguments. Also, you mention: > Btw, shell=True is needed here. Why do you need shell expansion on the arguments? This can be dangerous u

[Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Albert-Jan Roskam
Hi, In the code below, cmd1 and cmd2 are equivalent, as in: " ".join(cmd1) == cmd2. But the first example returns a code 2, whereas the second runs successfully. What is the difference? I prefer using a list as it looks a little cleaner. Btw, shell=True is needed here. # Python 2.7.3 (default, J

Re: [Tutor] Class decorator on a derived class not initialising the base classes using super - TypeError

2014-02-24 Thread Peter Otten
Sangeeth Saravanaraj wrote: > On Mon, Feb 24, 2014 at 10:53 PM, Peter Otten <__pete...@web.de> wrote: > >> Sangeeth Saravanaraj wrote: >> >> > I am trying to capture an object initiation and deletion events using >> > the __call__() and __del__() methods with the following approach. >> >> Note th

Re: [Tutor] Class decorator on a derived class not initialising the base classes using super - TypeError

2014-02-24 Thread Sangeeth Saravanaraj
On Mon, Feb 24, 2014 at 10:53 PM, Peter Otten <__pete...@web.de> wrote: > Sangeeth Saravanaraj wrote: > > > I am trying to capture an object initiation and deletion events using the > > __call__() and __del__() methods with the following approach. > > Note that there is no guarantee that __dell__

Re: [Tutor] i dont understand this code

2014-02-24 Thread Danny Yoo
It's also a bit unreasonable to ask us to reverse-engineer code that is orginally CRC-16 code. Whoever you got this code from is violating the GPL by stripping out the comments or the COPYRIGHT license from the original sources. This is perhaps unintentional. Please ask them to correct the probl

Re: [Tutor] How to perform a google advanced search using python

2014-02-24 Thread Danny Yoo
> Ah yes, here you go: > > https://developers.google.com/custom-search/?csw=1 Also see the "Indexable file types" help topic: https://support.google.com/webmasters/answer/35287?hl=en ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] Class decorator on a derived class not initialising the base classes using super - TypeError

2014-02-24 Thread Peter Otten
Sangeeth Saravanaraj wrote: > I am trying to capture an object initiation and deletion events using the > __call__() and __del__() methods with the following approach. Note that there is no guarantee that __dell__ will ever be called. Usually it is better to introduce a weakref with callback. >

Re: [Tutor] os.symlink can't find target

2014-02-24 Thread Bob Williams
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 24/02/14 16:56, Mark Lawrence wrote: > On 24/02/2014 16:36, Peter Otten wrote: >> Bob Williams wrote: >> [...] >>> Thanks, >> >> os.symlink(existing_file, symlink_to_create) >> >> fails with that error if the directory that shall contain the new

Re: [Tutor] os.symlink can't find target

2014-02-24 Thread Bob Williams
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 24/02/14 16:36, Peter Otten wrote: > os.symlink(existing_file, symlink_to_create) > > fails with that error if the directory that shall contain the new > symlink does not exist. You can create it before making the symlink > with > Peter, Many tha

Re: [Tutor] os.symlink can't find target

2014-02-24 Thread Mark Lawrence
On 24/02/2014 16:36, Peter Otten wrote: Bob Williams wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 My operating system is Linux (openSUSE 13.1). I'm trying to create symlinks. The following code: if pathList[j][-3:] == "mp3": linkName1 = pathList[j][0:-3] + "mp3" linkName2 =

Re: [Tutor] I can't understand where python class methods come from

2014-02-24 Thread voger
Thank you all for your responses. My first post on the list an I already got more than I asked for. :) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

[Tutor] Class decorator on a derived class not initialising the base classes using super - TypeError

2014-02-24 Thread Sangeeth Saravanaraj
I am trying to capture an object initiation and deletion events using the __call__() and __del__() methods with the following approach. class A(object): def __init__(self, klass): print "A::__init__()" self._klass = klass def __call__(self): print "A::__call__()"

Re: [Tutor] os.symlink can't find target

2014-02-24 Thread Peter Otten
Bob Williams wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > My operating system is Linux (openSUSE 13.1). > > I'm trying to create symlinks. The following code: > > if pathList[j][-3:] == "mp3": > linkName1 = pathList[j][0:-3] + "mp3" > linkName2 = destPath + linkName1[len

[Tutor] os.symlink can't find target

2014-02-24 Thread Bob Williams
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 My operating system is Linux (openSUSE 13.1). I'm trying to create symlinks. The following code: if pathList[j][-3:] == "mp3": linkName1 = pathList[j][0:-3] + "mp3" linkName2 = destPath + linkName1[len(sourcePath):] print 'Creating link %

Re: [Tutor] How to perform a google advanced search using python

2014-02-24 Thread Steven D'Aprano
On Mon, Feb 24, 2014 at 04:37:36PM +0800, Xenai Hatsotep wrote: > I have a python program which performs a simple google search. What i > really want to do is perform an advanced search such that i can search > for pdf files and ppt files in google. Any help on this subject would > be very help

[Tutor] How to perform a google advanced search using python

2014-02-24 Thread Xenai Hatsotep
I have a python program which performs a simple google search. What i really want to do is perform an advanced search such that i can search for pdf files and ppt files in google. Any help on this subject would be very helpful. I have attached the search.py program i'm using with this mail. impo

Re: [Tutor] Tutor Digest, Vol 120, Issue 20

2014-02-24 Thread MS K MAGUNGA
hey guys your tutorials really have me a lot and i managed to pass python and i would like you to continue sending me those tutorials so i can do more practice as far as the future is concerned.. I would also like to enroll on the java tutorials that's if you provide them... THANKS IN ADVA

Re: [Tutor] I can't understand where python class methods come from

2014-02-24 Thread spir
On 02/23/2014 10:59 PM, voger wrote: I have a really hard time understanding where methods are defined in python classes. My first contact with programming was with C++ and Java and even if I was messing with them in a very amateurish level, I could find where each class was defined and what meth

Re: [Tutor] Function help

2014-02-24 Thread Peter Otten
Scott W Dunning wrote: > > On Feb 23, 2014, at 2:26 AM, Peter Otten <__pete...@web.de> wrote: >> If you want to make rows with more or less stars, or stars in other >> colors you could add parameters: >> >> def star_row(numstars, starcolor): >>for i in range(numstars): >>fillstar(sta

Re: [Tutor] Function help

2014-02-24 Thread Alan Gauld
On 24/02/14 02:04, Scott W Dunning wrote: *Also, does anyone know anything about turtle where I can try and move the starting point to the upper left hand corner? * dir() and help() are your friends. After doing dir(turtle) I spooted this likely looking candidate and ran help on it: ---

Re: [Tutor] Function help

2014-02-24 Thread Scott W Dunning
On Feb 23, 2014, at 2:26 AM, Peter Otten <__pete...@web.de> wrote: > which still shows a repetetive pattern and thus you can simplify it with > another loop. You should be able to find a way to write that loop with two > star_row() calls on a single iteration, but can you do it with a single call

Re: [Tutor] Function help

2014-02-24 Thread Scott W Dunning
On Feb 23, 2014, at 2:26 AM, Peter Otten <__pete...@web.de> wrote: > If you want to make rows with more or less stars, or stars in other colors > you could add parameters: > > def star_row(numstars, starcolor): >for i in range(numstars): >fillstar(starcolor) >space(25) > > Y

Re: [Tutor] Function help

2014-02-24 Thread Scott W Dunning
On Feb 23, 2014, at 2:26 AM, Peter Otten <__pete...@web.de> wrote > a programmer would think "for loop” immediately That’s what I thought. It just seemed like way to much to keep repeating everything over and over. I knew there had to be a better way we just haven’t learned loops in school yet.

Re: [Tutor] Function help

2014-02-24 Thread Scott W Dunning
On Feb 23, 2014, at 5:31 AM, Dave Angel wrote: > > Welcome to the tutor forum also, Scott. You'll find it works very > similarly to python-list, and has many of the same people on it. > I'm not sure how you tried to attach source, but please be aware > that this is a text list - anything othe