On Mon, 2009-07-13 at 11:10 +0300, Shlomi Fish wrote:

> 4. Hiding Code By Using .pyc's
> ------------------------------
[... snipped ...]
> Python knows the identifiers of the variables at run-time. For example:
> 
> <<<<<<<<<<<<<<<<<<<<<<
> shlomi:~$ cat exec-test.py 
> #!/usr/bin/env python
> 
> import sys
> 
> a = "I am a"
> b = "I'm b"
> 
> exec(sys.stdin.readline())
> shlomi:~$ python exec-test.py 
> print a
> I am a
> shlomi:~$ python exec-test.py 
> print b
> I'm b
> shlomi:~$ 
> >>>>>>>>>>>>>>>>>>>>>>

Notes:
1. You did not indicate which of the "output" lines is input and which -
output.
The 'print a' and 'print b' are inputs to the script and should have
been flagged as such (tricky to do in plain text E-mail, I know).
2. You can force Python to create a *.pyc file and examine it using
'strings':
2.1. Rename exec-test.py as exec_test.py
2.2. python
     >>> import exec_test   # import exec-test causes syntax error
     (enter any input)
     >>> (CTRL-D)
2.3. $ strings exec_test.pyc
     I am as
     I'm b(
     syst
     stdint
     readline(
     exec_test.pys
     <module>

                                                --- Omer


-- 
Linux Mint is insecure by design as it won't accept contributions (bug
reports) from Israelis who choose to defend themselves against suicide
bombers: http://eclelef.blogspot.com/2009/05/palestine_03.html
My own blog is at http://www.zak.co.il/tddpirate/

My opinions, as expressed in this E-mail message, are mine alone.
They do not represent the official policy of any organization with which
I may be affiliated in any way.
WARNING TO SPAMMERS:  at http://www.zak.co.il/spamwarning.html

_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl

Reply via email to