Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Albert-Jan Roskam via Tutor


- Original Message -

> From: Alan Gauld 
> To: tutor@python.org
> Cc: 
> Sent: Friday, May 22, 2015 1:44 AM
> Subject: Re: [Tutor] ls *.py[co] >> .hidden
> 
> On 21/05/15 17:57, Emile van Sebille wrote:
>>  On 5/21/2015 9:28 AM, Albert-Jan Roskam via Tutor wrote:
>>>  I just created an alias for this:
>>>  alias hidepycs="ls *.py[co] > .hidden"
>> 
>>  Close -- try
>> 
>>  alias ls='ls --hide=*.py[co]'
>> 
> 
> I thought we'd established that this was to
> control visibility in the File Manager GUI
> not the CLI? So an 'ls' flag isn't going to
> help there.


Yes, it was about the visibility in Nautilius. Much easier on the eye when the 
bytecode files are not visible. 

Also, I sometimes accidentally open a .pyc when I intend to open the 
corresponding .py.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Cameron Simpson

On 21May2015 17:52, Laura Creighton  wrote:

If you keep appending the results of ls to your .hidden file
it will grow to enormous size. [...]

sort -u .hidden >newhidden #or whatever you want to call it
mv newhidden .hidden


Or:

 sort -u -o .hidden .hidden

Cheers,
Cameron Simpson 

[...] post-block actions should be allowed everywhere, not just on
subroutines. The ALWAYS keyword was agreed upon as a good way of doing
this, although POST was also suggested. This lead to the semi-inevitable
rehash of the try- catch exception handling debate. According to John
Porter, "There is no try, there is only do. :-)"
- from the perl6 development discussion
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] https://trinket.io

2015-05-21 Thread memilanuk

On 05/21/2015 01:02 AM, Albert-Jan Roskam via Tutor wrote:

Not sure whether I like this better than IPython Notebook, though.



I was given to understand that the target use / demographic was a bit 
different than with iPython...


Monte


--
Shiny!  Let's be bad guys.

Reach me @ memilanuk (at) gmail dot com

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


Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Alan Gauld

On 21/05/15 17:57, Emile van Sebille wrote:

On 5/21/2015 9:28 AM, Albert-Jan Roskam via Tutor wrote:

I just created an alias for this:
alias hidepycs="ls *.py[co] > .hidden"


Close -- try

alias ls='ls --hide=*.py[co]'



I thought we'd established that this was to
control visibility in the File Manager GUI
not the CLI? So an 'ls' flag isn't going to
help there.

Or am I missing something?

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
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] ls *.py[co] >> .hidden

2015-05-21 Thread Danny Yoo
>> I just created an alias for this:
>> alias hidepycs="ls *.py[co] > .hidden"
>
> Close -- try
>
> alias ls='ls --hide=*.py[co]'
>
> and when you want to see them use ls -a.


+1 to Emile's approach.  This seems to be the right approach, using
the "--hide" option built into ls:

   --hide=PATTERN
  do not list implied entries matching shell PATTERN
(overridden by -a or -A)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Danny Yoo
> ls *.pyc *.pso >> .hidden
>
> should work
>
> root@localhost:~# mkdir hide_test

[My response is completely off topic of Python; apologies.]

Hi Bod,

Be careful about running as 'root' for normal exploratory programming
or system usage.  'root' should be treated as an emergency-mode kind
of thing.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Laura Creighton
In a message of Thu, 21 May 2015 15:54:20 +0100, Bod Soutar writes:

>ls *.pyc *.pso >> .hidden
>
>should work
>
>root@localhost:~# mkdir hide_test
>root@localhost:~# cd hide_test/
>root@localhost:~/hide_test# touch a.pyc b.pyc c.pyo d.py e.txt
>root@localhost:~/hide_test# ls
>a.pyc  b.pyc  c.pyo  d.py  e.txt
>root@localhost:~/hide_test# ls *.pyc *.pyo >> .hidden
>root@localhost:~/hide_test# cat .hidden
>a.pyc
>b.pyc
>c.pyo
>root@localhost:~/hide_test#
>
>As this adds specific results of ls you will need to schedule the
>command through cron to get it to automatically add new files
>
>-- Bodsda

If you keep appending the results of ls to your .hidden file
it will grow to enormous size.  (Cron will be happy to do that
for you. :) ) So, if all you care about
is the files you have _today_  then use > not >> so that the
file is recreated.  If, on the other hand, you want your .hidden
to list files that you had at one time, don't happen to have now,
but want to have hidden if ever you should make them again, then
you need to periodically run the commands
sort -u .hidden >newhidden #or whatever you want to call it
mv newhidden .hidden

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


Re: [Tutor] Getting import to use a variable name

2015-05-21 Thread Jim Mooney Py3.4.3winXP
On 20 May 2015 at 01:02, Peter Otten <__pete...@web.de> wrote:

> If you start with an object dir() gives you a list of attribute names. To
> get the actual attributes use
>
> attribute = getattr(object, attribute_name)
>
> Then print the attributes' docstring with
>
> print(attribute_name, attribute.__doc__)
>

Thanks. That will save a lot of scrolling - and saving scrolling and typing
is half the battle ;')

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


Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Emile van Sebille

On 5/21/2015 9:28 AM, Albert-Jan Roskam via Tutor wrote:

I just created an alias for this:
alias hidepycs="ls *.py[co] > .hidden"


Close -- try

alias ls='ls --hide=*.py[co]'

and when you want to see them use ls -a.

Emile



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


Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Albert-Jan Roskam via Tutor


- Original Message -

> From: Steven D'Aprano 
> To: tutor@python.org
> Cc: 
> Sent: Thursday, May 21, 2015 6:11 PM
> Subject: Re: [Tutor] ls *.py[co] >> .hidden
> 
> On Thu, May 21, 2015 at 03:54:20PM +0100, Bod Soutar wrote:
> 
>>  ls *.pyc *.pso >> .hidden
>> 
>>  should work
> [...]
>>  As this adds specific results of ls you will need to schedule the
>>  command through cron to get it to automatically add new files
> 
> Yes, but that's the point isn't it? If Nautilus understands regular 
> expressions, then instead of listing every single .pyc file by name, 
> potentially thousands of them, you just need a single entry:
> 
> .*pyc
> 
> to hide *every* .pyc file. Or use .*py[co] for .pyc and .pyo files.
> 
> If Nautilus *doesn't* understand regular expressions, well, that's just 
> another example of why Gnome is not good enough for serious work.
> 
> This suggests that Nautilus doesn't accept wildcards:
> 
> http://ubuntuforums.org/showthread.php?t=1730696


You're right, I just tried it:


# does NOT work:

echo *.py[co] > .hidden

# works (but you need a cronjob):

ls *.py[co] > .hidden

I just created an alias for this:
alias hidepycs="ls *.py[co] > .hidden"


No idea whether there exists some sneaky way to make Nautilius understand 
regexes. I could make an enhancement request, but with Debian this would become 
effective like 15 years later :-)

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


Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Steven D'Aprano
On Thu, May 21, 2015 at 03:54:20PM +0100, Bod Soutar wrote:

> ls *.pyc *.pso >> .hidden
> 
> should work
[...]
> As this adds specific results of ls you will need to schedule the
> command through cron to get it to automatically add new files

Yes, but that's the point isn't it? If Nautilus understands regular 
expressions, then instead of listing every single .pyc file by name, 
potentially thousands of them, you just need a single entry:

.*pyc

to hide *every* .pyc file. Or use .*py[co] for .pyc and .pyo files.

If Nautilus *doesn't* understand regular expressions, well, that's just 
another example of why Gnome is not good enough for serious work.

This suggests that Nautilus doesn't accept wildcards:

http://ubuntuforums.org/showthread.php?t=1730696



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


Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Bod Soutar
On 21 May 2015 at 15:39, Steven D'Aprano  wrote:
> On Thu, May 21, 2015 at 12:55:13PM +, Albert-Jan Roskam via Tutor wrote:
>> Hi,
>>
>> I would like to hide .pyc and .pyo files because they are visually
>> distracting. Is the aforementioned command the best way? [1].
>
> It isn't clear what you mean by "hide them".
>
> If you mean that you want to use the ls command to get a directory
> listing, but just not see the .pyc files, then all you need is:
>
> ls *.py
>
> which will list the .py files and nothing else.
>
> You can remove the .pyc and .pyo files, or move them elsewhere:
>
> rm *.py[co]
>
> mv *.py[co] some/other/directory/
>
> and let Python recreate them as needed.
>
> If you're using a GUI file manager, there may be an option to hide
> certain files. I know that KDE 3, at least, hides files starting with a
> leading dot, and backup files ending with ~ so it's quite likely that
> there's a way to hide .pyc and .pyo files. Check the documentation for
> your GUI file manager.
>
> The command you give:
>
> ls *.py[co] >> .hidden
>
> doesn't hide anything. It lists the .pyc and .pyo files, but rather than
> printing to the terminal, it appends them to a file called .hidden in
> the current directory.
>
> Ah, wait, I see! Nautilus uses the .hidden file to suppress the display
> of those files.
>
> I wonder whether putting a single line:
>
> .*py[co]
>
> inside .hidden will work? You need to try it, or ask a Gnome expert.
>
>
>
> --
> Steve
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

ls *.pyc *.pso >> .hidden

should work

root@localhost:~# mkdir hide_test
root@localhost:~# cd hide_test/
root@localhost:~/hide_test# touch a.pyc b.pyc c.pyo d.py e.txt
root@localhost:~/hide_test# ls
a.pyc  b.pyc  c.pyo  d.py  e.txt
root@localhost:~/hide_test# ls *.pyc *.pyo >> .hidden
root@localhost:~/hide_test# cat .hidden
a.pyc
b.pyc
c.pyo
root@localhost:~/hide_test#

As this adds specific results of ls you will need to schedule the
command through cron to get it to automatically add new files

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


Re: [Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Steven D'Aprano
On Thu, May 21, 2015 at 12:55:13PM +, Albert-Jan Roskam via Tutor wrote:
> Hi,
> 
> I would like to hide .pyc and .pyo files because they are visually 
> distracting. Is the aforementioned command the best way? [1].

It isn't clear what you mean by "hide them".

If you mean that you want to use the ls command to get a directory 
listing, but just not see the .pyc files, then all you need is:

ls *.py

which will list the .py files and nothing else.

You can remove the .pyc and .pyo files, or move them elsewhere:

rm *.py[co]

mv *.py[co] some/other/directory/

and let Python recreate them as needed.

If you're using a GUI file manager, there may be an option to hide 
certain files. I know that KDE 3, at least, hides files starting with a 
leading dot, and backup files ending with ~ so it's quite likely that 
there's a way to hide .pyc and .pyo files. Check the documentation for 
your GUI file manager.

The command you give:

ls *.py[co] >> .hidden

doesn't hide anything. It lists the .pyc and .pyo files, but rather than 
printing to the terminal, it appends them to a file called .hidden in 
the current directory.

Ah, wait, I see! Nautilus uses the .hidden file to suppress the display 
of those files.

I wonder whether putting a single line:

.*py[co]

inside .hidden will work? You need to try it, or ask a Gnome expert.



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


[Tutor] ls *.py[co] >> .hidden

2015-05-21 Thread Albert-Jan Roskam via Tutor
Hi,

I would like to hide .pyc and .pyo files because they are visually distracting. 
Is the aforementioned command the best way? [1]. 

I know Python 3 uses __pycache__ (much better!), but I also need Python 2. And 
not writing bytecode files altogether using 
what's-that-environment-var-called-again is not an option for me. I use Debian 
Linux (Jessie, since today, yaaayy!)

 
Regards,


Albert-Jan


[1] 
http://superuser.com/questions/200730/hiding-files-of-a-certain-extension-pyc-from-nautilus

 



~~

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:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] https://trinket.io

2015-05-21 Thread Albert-Jan Roskam via Tutor
Hi,

Wired.com features trinket.io [1] and I thought it'd be nice to share this 
here: https://trinket.io. Not sure whether I like this better than IPython 
Notebook, though.

Regards,
Albert-Jan

[1] http://www.wired.com/2015/05/running-python-browser-awesome-think
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor