Re: [Tutor] Interacting with stderr

2014-08-28 Thread Alan Gauld

On 28/08/14 07:30, Cameron Simpson wrote:


On a tutor list, what's our stance on exploring the operation at a lower
level so the OP gets a better feel for what's going on? I'm aware we
don't need to agree on that stance:-)


Its OK if the OP will understand it.

Just explaining the detail of itself is not always helpful when
dealing with a real programming beginner. But if the OP (or a subsequent 
participant) demonstrates that a fuller explanation

of the mechanisms involved is worthwhile then by akll means do so.

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

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


[Tutor] Regression analysis using statsmodels: linear combinations

2014-08-28 Thread Shakoor Hajat
Hello

I would very much appreciate any help with the following query:

I am running a regression analysis  in Python using statsmodels and wish to
obtain the combined effect of a number of the explanatory variables in the
model.  I could simply sum the individual coefficients to obtain my effect
estimate but this wouldn't work for the standard errors due to covariance.
Is there a straightforward way in statsmodels to derive the linear
combination of coefficients?

Many thanks in advance.

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


Re: [Tutor] debug and execute python code in Mac

2014-08-28 Thread William Ray Wing
On Aug 27, 2014, at 8:08 PM, Sebastian Silva  wrote:

> I stumbled today upon this IDE for the mac http://plotdevice.io/
> 
> From the looks of it, it seems like a nice tool for teaching/learning Python. 
> Too bad it's mac only. If you try it, do share your experience. I don't use 
> non-free operating systems, so I can't try it myself.
> 
> Regards,
> 
> Sebastian

Just as an aside — Apple has stopped charging for OS-X.

-Bill

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


Re: [Tutor] debug and execute python code in Mac

2014-08-28 Thread Chris “Kwpolska” Warrick
On Thu, Aug 28, 2014 at 2:41 PM, William Ray Wing  wrote:
> On Aug 27, 2014, at 8:08 PM, Sebastian Silva  
> wrote:
>> Too bad it's mac only. If you try it, do share your experience. I don't use 
>> non-free operating systems, so I can't try it myself.
>
> Just as an aside — Apple has stopped charging for OS-X.

Sebastan probably meant “free” as in Stallman:
http://www.gnu.org/philosophy/free-sw.html

(most people believe free = $0.  FSF people, however, want to steal
that word for their concept.  Not very successful at that, as you can
see.)

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Interacting with stderr

2014-08-28 Thread Crush
So, are yall done arguing haha...jk! Seriously, thank you for taking the time 
to pick this issue apart with me. Cameron your "learning" comment was right on; 
my ultimate goal in posting here is to learn and of course to figure out my 
code. 

As far as the pipe in...

"avconv -v verbose -re -analyzeduration 1000 
-ihttp://localhost:6498/ms2/1382097438004/0MediaPlayer+0+/octoshape+hVV+octolive.americaone.com+V+aone+V+live+V+ONECONNXTDEMO1_HD_flv/aoneliveONECONNXTDEMO1HDflv
 -c:v rawvideo -c:a pcm_s16le -ar 48000 -f nut - | ./bmdplay -m 12 -f pipe:0"

...it has to be there. Currently, i am running a shell script that is handling 
this decoding process i.e. the real long avconv/bmdplay command. So you are 
saying leave the shell script and invoke it from a python script...something 
like "p = subprocess.Popen("./my_script.sh")? How will the above allow me to 
interact with stderr in oppose to running the avconv/bmdplay command directly 
in python? 

As far as not using "shell=True," if I dont have it set to True, the terminal 
hangs and will not display stderr to the screen as it is currently does. 

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


Re: [Tutor] Regression analysis using statsmodels: linear combinations

2014-08-28 Thread Alan Gauld

On 28/08/14 12:20, Shakoor Hajat wrote:


I would very much appreciate any help with the following query:
I am running a regression analysis  in Python using statsmodels and wish
to obtain the combined effect of a number of the explanatory variables
in the model.  I could simply sum the individual coefficients to obtain
my effect estimate but this wouldn't work for the standard errors due to
covariance.  Is there a straightforward way in statsmodels to derive the
linear combination of coefficients?


This list is for people learning the basic python language and
standard library. This question looks a tad advanced for that
audience. In fact I suspect that many(most?) of the folks on
this list (including me) have only a hazy idea what you are
talking about in your post.

However there are some data analysts amongst us so they may
be able to help.

If we knew what toolkits you were using to do the analysis we
might be able to suggest a better forum? eg numpy, RPy or pandas?
Also what version of Python you had( 2 or 3?).

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

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


[Tutor] Tutoring

2014-08-28 Thread abid saied
Hi,

would anyone like to provide some face to face guidance/tutoring? My post code 
is BL3 2LR, I’m happy to offer a nice meal, my wife makes some really good 
curries!

thanks.


Abid Saied
abidsa...@gmail.com



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


Re: [Tutor] Tutoring

2014-08-28 Thread Alan Gauld

On 28/08/14 13:02, abid saied wrote:


would anyone like to provide some face to face guidance/tutoring?

> My post code is BL3 2LR,

That looks like a UK post code? Are you in the UK?

This list is international in membership, we have folks from
the US, Canada, Australia, India, Japan, all over in fact.

We don't normally do 1 on 1 tutorship but if you are lucky and
somebody volunteers that's OK.

But if you want to post questions here we will all do our best to answer 
them.


> I’m happy to offer a nice meal, my wife makes some

really good curries!


Yum... :-)

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

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


[Tutor] Import from project's lib directory?

2014-08-28 Thread leam hall
python 2.4.3 on Red Hat Linux.

I'm starting a project and want to break the scripts into "input",
"output", and "ddl". I'd like to have a "lib" library directory for
local modules. The library directory would be at the same level as the
others.

How do I get the library modules?

  import '../lib/mymodule'

Fails on syntax.

Thanks!

Leam
-- 
Mind on a Mission
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Import from project's lib directory?

2014-08-28 Thread Danny Yoo
On Thu, Aug 28, 2014 at 11:03 AM, leam hall  wrote:
> python 2.4.3 on Red Hat Linux.
>
> I'm starting a project and want to break the scripts into "input",
> "output", and "ddl". I'd like to have a "lib" library directory for
> local modules. The library directory would be at the same level as the
> others.
>
> How do I get the library modules?
>
>   import '../lib/mymodule'


You're looking for relative imports:

https://docs.python.org/2.5/whatsnew/pep-328.html

So for your case, perhaps:

from ..lib import mymodule

Alternatively, perhaps refer to the modules by toplevel package
instead of relative path?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Import from project's lib directory?

2014-08-28 Thread leam hall
On Thu, Aug 28, 2014 at 2:19 PM, Danny Yoo  wrote:
> On Thu, Aug 28, 2014 at 11:03 AM, leam hall  wrote:
>> python 2.4.3 on Red Hat Linux.
>>
>> I'm starting a project and want to break the scripts into "input",
>> "output", and "ddl". I'd like to have a "lib" library directory for
>> local modules. The library directory would be at the same level as the
>> others.
>>
>> How do I get the library modules?
>>
>>   import '../lib/mymodule'
>
>
> You're looking for relative imports:
>
> https://docs.python.org/2.5/whatsnew/pep-328.html
>
> So for your case, perhaps:
>
> from ..lib import mymodule
>
> Alternatively, perhaps refer to the modules by toplevel package
> instead of relative path?


Fails on both Python 2.4 and 2.6 with either ".lib" or "..lib".

### code
#!/usr/bin/env python

from ..lib import mymodule


In python/ddl, referencing ../lib/mymodule.py

 ./import_test.py
Traceback (most recent call last):
  File "./import_test.py", line 3, in 
from .lib import mymodule
ValueError: Attempted relative import in non-package


 ls ../lib
mymodule.py


-- 
Mind on a Mission
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Import from project's lib directory?

2014-08-28 Thread Danny Yoo
>
> Fails on both Python 2.4 and 2.6 with either ".lib" or "..lib".
>
> ### code
> #!/usr/bin/env python
>
> from ..lib import mymodule
> 
>
> In python/ddl, referencing ../lib/mymodule.py
>
>  ./import_test.py
> Traceback (most recent call last):
>   File "./import_test.py", line 3, in 
> from .lib import mymodule
> ValueError: Attempted relative import in non-package


The word "package" has a technical meaning.  Here's a description:

https://docs.python.org/2/tutorial/modules.html#packages

Can you use packages to structure your code directory?  You'll need
"__init__.py" files in the directories that are to be treated as
packages.


If you can structure your program into packages, then intra-package
imports should work:

https://docs.python.org/2/tutorial/modules.html#intra-package-references
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Import from project's lib directory?

2014-08-28 Thread leam hall
On Thu, Aug 28, 2014 at 3:27 PM, Danny Yoo  wrote:
>>
>> Fails on both Python 2.4 and 2.6 with either ".lib" or "..lib".
>>
>> ### code
>> #!/usr/bin/env python
>>
>> from ..lib import mymodule
>> 
>>
>> In python/ddl, referencing ../lib/mymodule.py
>>
>>  ./import_test.py
>> Traceback (most recent call last):
>>   File "./import_test.py", line 3, in 
>> from .lib import mymodule
>> ValueError: Attempted relative import in non-package
>
>
> The word "package" has a technical meaning.  Here's a description:
>
> https://docs.python.org/2/tutorial/modules.html#packages
>
> Can you use packages to structure your code directory?  You'll need
> "__init__.py" files in the directories that are to be treated as
> packages.
>
>
> If you can structure your program into packages, then intra-package
> imports should work:
>
> https://docs.python.org/2/tutorial/modules.html#intra-package-references

I put empty __init.py__ files in both directories and a few parents.
Still no go.

-- 
Mind on a Mission
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Import from project's lib directory?

2014-08-28 Thread Alan Gauld

On 28/08/14 19:03, leam hall wrote:

python 2.4.3 on Red Hat Linux.

I'm starting a project and want to break the scripts into "input",
"output", and "ddl". I'd like to have a "lib" library directory for
local modules. The library directory would be at the same level as the
others.

How do I get the library modules?


Add lib to the sys.path list?

That may not be viable if you need it to be portable across systems, 
although using os.getcwd to locate the current folder or an

environment variable to store the app root folder might be
options there.

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

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


Re: [Tutor] Interacting with stderr

2014-08-28 Thread Cameron Simpson

On 28Aug2014 09:42, Crush  wrote:

As far as the pipe in...

"avconv -v verbose -re -analyzeduration 1000 
-ihttp://localhost:6498/ms2/1382097438004/0MediaPlayer+0+/octoshape+hVV+octolive.americaone.com+V+aone+V+live+V+ONECONNXTDEMO1_HD_flv/aoneliveONECONNXTDEMO1HDflv
 -c:v rawvideo -c:a pcm_s16le -ar 48000 -f nut - | ./bmdplay -m 12 -f pipe:0"

...it has to be there.


Indeed. We're not arguing about that. Leave it there for.


Currently, i am running a shell script that is handling this decoding process i.e. the real 
long avconv/bmdplay command. So you are saying leave the shell script and invoke it from a 
python script...something like "p = subprocess.Popen("./my_script.sh")? How 
will the above allow me to interact with stderr in oppose to running the avconv/bmdplay 
command directly in python?


No, we're no saying that.

You could (and presumably do) have this long incantation in your shell script.  
As far as the Python stuff goes, that does not change anything: you can invoke 
your shell script or invoke your long command directly. Either way you need to 
grab the stderr on the fly and work with it.


Personally, I would keep the pipeline in the shell script where it is easier to 
edit and invoke the script from Python (easier to read). Your call.



As far as not using "shell=True," if I dont have it set to True, the terminal 
hangs and will not display stderr to the screen as it is currently does.


Let's tackle shell=True later.

What you need to do is examine stderr before the shell script/pipeline is 
complete, and for that you need to separate starting the process, reading 
stderr, and waiting for process completion into distinct parts, which was what 
my example code was doing. I'll recite it again here:


  from subprocess import Popen, PIPE

  P = Popen("avconv ... lots of arguments...", shell=True, stderr=PIPE)

  for line in P.stderr:
  ... examine the line from stderr ...

  # ok, we have read all of stderr now
  xit = P.wait()
  if xit != 0:
  ... command was unsuccessful, complain, maybe abort ...

Please try adapting your Python code to that and see where you end up.
Put a print statement as the first line in the for-loop so you can see if you 
are receiving stderr lines as intended.


Cheers,
Cameron Simpson 

As soon as we started programming, we found to our surprise that it wasn't as
easy to get programs right as we had thought. Debugging had to be discovered.
I can remember the exact instant when I realized that a large part of my life
from then on was going to be spent in finding mistakes in my own programs.
- Maurice Wilkes discovers debugging, 1949
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Quick question for Tutor admin.

2014-08-28 Thread Crush
Am I allowed to attach screen shots to my emails?

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


Re: [Tutor] Import from project's lib directory?

2014-08-28 Thread Cameron Simpson

On 28Aug2014 22:36, Alan Gauld  wrote:

On 28/08/14 19:03, leam hall wrote:

python 2.4.3 on Red Hat Linux.

I'm starting a project and want to break the scripts into "input",
"output", and "ddl". I'd like to have a "lib" library directory for
local modules. The library directory would be at the same level as the
others.

How do I get the library modules?


Add lib to the sys.path list?

That may not be viable if you need it to be portable across systems, 
although using os.getcwd to locate the current folder or an

environment variable to store the app root folder might be
options there.


I tend to modify $PYTHONPATH outside the script. It means the script is not 
responsible for figuring this stuff out, and it also makes it easier to run the 
"development" version when working.


For example, if I'm off modifying stuff in a copy of the code I test it by 
issuing the command:


  dev python -m the.python.module arguments...

"dev" is a short shell script of my own whose purpose it to set things up to 
run "here", and then run the command supplied ("python").


Among other things it prepends "$PWD/lib/python" to $PYTHONPATH, as that is 
where my modules live. In this way it runs the hacked module instead of running 
the "official" version.  The OP would prepend "$PWD/lib" in the same scenario.


Cheers,
Cameron Simpson 

Invoking the supernatural can explain anything, and hence explains nothing.
- University of Utah bioengineering professor Gregory Clark
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Regression analysis using statsmodels: linear combinations

2014-08-28 Thread Cameron Simpson

On 28Aug2014 17:41, Alan Gauld  wrote:

On 28/08/14 12:20, Shakoor Hajat wrote:

I would very much appreciate any help with the following query:
I am running a regression analysis  in Python using statsmodels and wish
to obtain the combined effect of a number of the explanatory variables
in the model.  I could simply sum the individual coefficients to obtain
my effect estimate but this wouldn't work for the standard errors due to
covariance.  Is there a straightforward way in statsmodels to derive the
linear combination of coefficients?


This list is for people learning the basic python language and
standard library. This question looks a tad advanced for that
audience. In fact I suspect that many(most?) of the folks on
this list (including me) have only a hazy idea what you are
talking about in your post.

However there are some data analysts amongst us so they may
be able to help.

If we knew what toolkits you were using to do the analysis we
might be able to suggest a better forum? eg numpy, RPy or pandas?
Also what version of Python you had( 2 or 3?).


It looks like he's using this:

  http://statsmodels.sourceforge.net/

Works in python 2 and 3, but does not seem to have a dedicated mailing list.

Shakoor, if you get no responses here, ask again on python-list: I know there 
are some statistics and floating point savvy people there.


Cheers,
Cameron Simpson 

To be positive: To be mistaken at the top of one's voice.
Ambrose Bierce (1842-1914), U.S. author. The Devil's Dictionary (1881-1906).
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Quick question for Tutor admin.

2014-08-28 Thread Cameron Simpson

On 28Aug2014 18:25, Crush  wrote:

Am I allowed to attach screen shots to my emails?


I am not the list admin, but generally no.

Please insert plain text into your posts. Many lists strip attachments, and 
many people on technical lists are (deliberately) working in a purely text 
environment.


If your screenshot is inherently graphical, publish it elsewhere (eg save it to 
Dropbox and get a "public link") and mention the link in your post, with some 
textual description.


But for text, we like it inline in the message itself.

Cheers,
Cameron Simpson 

in rec.moto, jsh wrote:

Dan Nitschke wrote:
> Ged Martin wrote:
> > On Sat, 17 May 1997 16:53:33 +, Dan Nitschke scribbled:
> > >(And you stay *out* of my dreams, you deviant little
> > >weirdo.)
> > Yeah, yeah, that's what you're saying in _public_
> Feh. You know nothing of my dreams. I dream entirely in text (New Century
> Schoolbook bold oblique 14 point), and never in color. I once dreamed I
> was walking down a flowchart of my own code, and a waterfall of semicolons
> was chasing me. (I hid behind a global variable until they went by.)
You write code in a proportional serif? No wonder you got extra
semicolons falling all over the place.

No, I *dream* about writing code in a proportional serif font.
It's much more exciting than my real life.
/* dan: THE Anti-Ged -- Ignorant Yank (tm) #1, none-%er #7 */
Dan Nitschke  pedan...@best.com  nitsc...@redbrick.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Quick question for Tutor admin.

2014-08-28 Thread Danny Yoo
On Thu, Aug 28, 2014 at 3:25 PM, Crush  wrote:
> Am I allowed to attach screen shots to my emails?


Hi Bo,

If the informational content can be represented textually, then please
try to avoid screenshots in favor of copy-and-paste.

There are a few reasons for it.  But one major reason why text is
preferable because search engines work effectively with text.

If I see a question that uses a certain unusual term, the first
instinct I have is to enter that term into a search engine.  As a
concrete example, see:

https://mail.python.org/pipermail/tutor/2014-August/102347.html

As a point of confession: for the message above, I knew absolutely
nothing about what the questioner was asking about.  But I do know how
to use a search engine fairly well.  :P


This sort of archaeology becomes much harder if screenshots are the
norm.  So try to avoid them, at least for technical forums where UI is
not the focus.  Thanks!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Regression analysis using statsmodels: linear combinations

2014-08-28 Thread Cameron Simpson

On 29Aug2014 08:45, Cameron Simpson  wrote:

It looks like he's using this:
 http://statsmodels.sourceforge.net/
Works in python 2 and 3, but does not seem to have a dedicated mailing list.


Hmm. There's a mailing list here:

  https://groups.google.com/forum/?hl=en#!forum/pystatsmodels

That is probably the best place to ask.

Cheers,
Cameron Simpson 

My computer always does exactly what I tell it to do but sometimes I have
trouble finding out what it was that I told it to do.
- Dick Wexelblat 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Quick question for Tutor admin.

2014-08-28 Thread Alan Gauld

On 28/08/14 23:25, Crush wrote:

Am I allowed to attach screen shots to my emails?


We can't stop you, but we prefer text.
Not least because some members can't receive anything but text.
Also some pay by the byte and images tend to be big and thus expensive.
So you would limit the visibility and hence the potential numbers
who can respond.

If its a shot of your terminal session then you can simply
cut n paste the text from the Terminal into your mail.
Many other dev tools/editors permit the same.

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

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