Re: [Tutor] Recreating the help module

2012-07-24 Thread Peter Otten
M Nickey wrote:

> Hey all,
> 
> I'm trying to recreate the 'help' on various modules that are available.
> So far, I have a bit of code and it seems to be working for the most part.
> I can get the modules available but I also want to be able to print the
> information that is available for each module.
> 
> Current output:
> ['__add__', '__class__', '__contains__', ... 'partition', 'replace',
> ['rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split',
> ['splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate',
> ['upper', 'zfill']
> str(object) -> string
> 
> Return a nice string representation of the object.
> If the argument is a string, the return value is the same object.
> 
> Desired result:
> ['__add__', '__class__', '__contains__', ... 'partition', 'replace',
> ['rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split',
> ['splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate',
> ['upper', 'zfill']
> 
> atof(s):
> Return the floating point number represented by the st
> atof(s) -> float
> 
> I'm close (I think) but I just can figure out how to grab that part of the
> documentation. Any advice?

I'm guessing you want the functions in the string module rather than the 
methods of the str type? 

If so: you can get the module object from the name with the __import__() 
builtin function:

> Code:
> import os
> import string
> import inspect
> 
> def getDirName():
> modList = []

  module_name = "string"
  module = __import__(module_name) 
  cwd = dir(module)

> print cwd
> info = inspect.getdoc(cwd[35])
> print info
> return
> 
> if __name__ == '__main__':
> getDirName()

There's one complication with __import__(), it always gives you the toplevel 
package, e. g. to get the os.path module you have to do

package = __import__("os.path")
module = getattr(package, "path")

You might also take a look into the source of the pydoc module.

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


[Tutor] Recreating the help module

2012-07-24 Thread M Nickey
Hey all,

I'm trying to recreate the 'help' on various modules that are available. So 
far, I have a bit of code and it seems to be working for the most part. I can 
get the modules available but I also want to be able to print the information 
that is available for each module.

Current output:
['__add__', '__class__', '__contains__', ... 'partition', 'replace', 'rfind', 
'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 
'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
str(object) -> string

Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

Desired result:
['__add__', '__class__', '__contains__', ... 'partition', 'replace', 'rfind', 
'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 
'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']

atof(s):
Return the floating point number represented by the st
atof(s) -> float

I'm close (I think) but I just can figure out how to grab that part of the 
documentation. Any advice?


Code:
import os
import string
import inspect

def getDirName():
modList = []
manPage = 'string'   #used as a place holder for now...   
cwd = dir(manPage)
print cwd
info = inspect.getdoc(cwd[35])  
print info
return

if __name__ == '__main__':
getDirName()

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


Re: [Tutor] where is my MySQL database

2012-07-24 Thread Michael Janßen
On 25 July 2012 00:51, Zhenzhen  wrote:

> hi, I'm working on setting up my database for django by editing the
> following file:
> mysite/settings.py
>
> for the field "name", I am suppose to put down the full path of my mySQL
> database.
>

for mysql, it needs to be the database name, specified in the CREATE TABLE
statement. With sqlite3, it would be indeed the filename (an non-existent
filename, sqlite3 would create the file)


> I did create a few databases in MySQL, however, I don't seem to be able
> to find them anywhere.
>
> I have tried 'grep datadir /etc/my.cnf' but found out my.cnf file doesn't
> even exist in my /etc/ directory.
>

for me it is /etc/mysql/my.cnf

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


Re: [Tutor] where is my MySQL database

2012-07-24 Thread Alan Gauld

On 24/07/12 23:51, Zhenzhen wrote:

hi, I'm working on setting up my database for django by editing the
following file:
mysite/settings.py

for the field "name", I am suppose to put down the full path of my mySQL
database.



This doesn't have much to do with learing Python, or even Django...

You might get a better response from a MySql mailing list or forum.
OTOH There are MySql users here too so you may get lucky.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

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


[Tutor] where is my MySQL database

2012-07-24 Thread Zhenzhen
hi, I'm working on setting up my database for django by editing the
following file:
mysite/settings.py

for the field "name", I am suppose to put down the full path of my mySQL
database.

I did create a few databases in MySQL, however, I don't seem to be able to
find them anywhere.

I have tried 'grep datadir /etc/my.cnf' but found out my.cnf file doesn't
even exist in my /etc/ directory.

Is there something wrong with mySQL installation? Thanks!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] measuring the start up time of an event-driven program

2012-07-24 Thread Stefan Behnel
Albert-Jan Roskam, 24.07.2012 11:18:
> I would like to test how long it takes for two versions of the same
> program to start up and be ready to receive commands. The program is
> SPSS version-very-old vs. SPSS version-latest.
> 
> Normally I'd just fire the program up in a subprocess and measure the
> time before and after finishing. But this kind of program is never
> finished. It's looping until infinity and waiting for events/commands. I
> tried wrapping it in a "while True" loop, and break out of the loop and
> terminate the program (using ctypes) if the retcode of the process is
> equal to zero. But that doesn't work.

Is it really looping or is it just sitting and waiting for input? You might
be able to provide some input that makes it terminate.

Stefan

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


Re: [Tutor] measuring the start up time of an event-driven program

2012-07-24 Thread Michael Janßen
On 24 July 2012 11:18, Albert-Jan Roskam  wrote:

> I would like to test how long it takes for two versions of the same
> program to start up and be ready to receive commands. The program is SPSS
> version-very-old vs. SPSS version-latest.
>
> Normally I'd just fire the program up in a subprocess and measure the time
> before and after finishing. But this kind of program is never finished.
> It's looping until infinity and waiting for events/commands. I tried
> wrapping it in a "while True" loop, and break out of the loop and terminate
> the program (using ctypes) if the retcode of the process is equal to zero.
> But that doesn't work.
>

So, the question is, what defines your end point for timing. I'd say, you
could either check if the program *looks* like being ready (
http://sikuli.org/ could help here) or if it doesn't use up cpu anymore.

Both ways, I'd except a fair amount of overhead and for the cpu-usage way
bogus results also. Both problems could perhaps be addressed by enough
timing runs.

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


Re: [Tutor] measuring the start up time of an event-driven program

2012-07-24 Thread Albert-Jan Roskam
From: Steven D'Aprano 

To: tutor@python.org 
>Sent: Tuesday, July 24, 2012 11:48 AM
>Subject: Re: [Tutor] measuring the start up time of an event-driven program
> 
>On Tue, Jul 24, 2012 at 02:18:43AM -0700, Albert-Jan Roskam wrote:
>> Hi,
>> 
>> I would like to test how long it takes for two versions of the same 
>> program to start up and be ready to receive commands. The program is 
>> SPSS version-very-old vs. SPSS version-latest.
>
>I don't think this is a Python question. I think this is a "what tools 
>does my operating system provide for fine testing of process startup 
>time?" question.
>
>I'm not an expert, but I suspect that the answer will be, "none". Which 
>OS are you using?
>===> I am using Windows 7, but I'd find it interesting to hear about Linux 
>tools too (though I couldn't use them in this particular case). Would be cool 
>if such a tool could differentiate between the various processes involved. In 
>this case stats.exe (frontend) and spssengine.exe (backend).
>
>If the SPSS app has the ability to run commands specified from a 
>script, and then automatically exit, perhaps you can approximate 
>start-up time as "start-up, run an empty script, and exit" time, 
>assuming that running the script and exiting will be negligible.
>
>===> Well, I actually do that too. But the full-fledged app has a GUI 
>programmed in (I think) C++ (old version) or Java (new version). The latter is 
>markedly slower. People work with the GUI based spss all the time. Only when 
>their code is final, people *might* use the scripting facility.
>
>Or, if the app is slow enough (I'm looking at you Chrome, fastest way to 
>browse the web my arse) perhaps you could just time it with a 
>stop-watch.
>
>===> ;-))) Yeah, good idea (I mean the stop-watch, not Chrome --I don't like 
>Google's information obesity).
>
>> I want to know how long the user on average needs to wait before he 
>> can start doing analyses in SPSS. If it takes way much longer in the 
>> new version, the user might be more inclined not to close the program 
>> after use, which may lead to a lack of concurrent licenses.
>
>If you have to measure the difference to notice the difference, the 
>average user won't notice the difference.
>
>===> Good point. But it is noticeable, and now I'd like to quantify that. 
>Something like: "ceteris paribus it takes 2.2 times longer to start up the new 
>version, as compared with the old version"
>
>==> And of course: Thanks!
>
>-- 
>Steven
>___
>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] measuring the start up time of an event-driven program

2012-07-24 Thread Steven D'Aprano
On Tue, Jul 24, 2012 at 02:18:43AM -0700, Albert-Jan Roskam wrote:
> Hi,
> 
> I would like to test how long it takes for two versions of the same 
> program to start up and be ready to receive commands. The program is 
> SPSS version-very-old vs. SPSS version-latest.

I don't think this is a Python question. I think this is a "what tools 
does my operating system provide for fine testing of process startup 
time?" question.

I'm not an expert, but I suspect that the answer will be, "none". Which 
OS are you using?

If the SPSS app has the ability to run commands specified from a 
script, and then automatically exit, perhaps you can approximate 
start-up time as "start-up, run an empty script, and exit" time, 
assuming that running the script and exiting will be negligible.

Or, if the app is slow enough (I'm looking at you Chrome, fastest way to 
browse the web my arse) perhaps you could just time it with a 
stop-watch.


> I want to know how long the user on average needs to wait before he 
> can start doing analyses in SPSS. If it takes way much longer in the 
> new version, the user might be more inclined not to close the program 
> after use, which may lead to a lack of concurrent licenses.

If you have to measure the difference to notice the difference, the 
average user won't notice the difference.



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


[Tutor] measuring the start up time of an event-driven program

2012-07-24 Thread Albert-Jan Roskam
Hi,

I would like to test how long it takes for two versions of the same program to 
start up and be ready to receive commands. The program is SPSS version-very-old 
vs. SPSS version-latest.

Normally I'd just fire the program up in a subprocess and measure the time 
before and after finishing. But this kind of program is never finished. It's 
looping until infinity and waiting for events/commands. I tried wrapping it in 
a "while True" loop, and break out of the loop and terminate the program (using 
ctypes) if the retcode of the process is equal to zero. But that doesn't work. 


I know that, in case of spss, there is a Python api available, but this would 
measure the start-up time of spss without the graphical interface, only the 
backend. That's not what I want. I want to know how long the user on average 
needs to wait before he can start doing analyses in SPSS. If it takes way much 
longer in the new version, the user might be more inclined not to close the 
program after use, which may lead to a lack of concurrent licenses.

 
Thanks!


Regards,
Albert-Jan


~~
All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a 
fresh water system, and public health, what have the Romans ever done for us?
~~ ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor