Re: AES Encryption/Decryption

2018-11-02 Thread Peter via Python-list

On 3/11/2018 1:42 AM, Jeff M wrote:

Python newbie here, looking for code samples for encrypting and decrypting 
functions, using AES.  See lots of stuff on the interwebs, but lots of comments 
back an forth about bugs, or implemented incorrect, etc...

I need to encrypt some strings that will be passed around in URL, and then also 
some PII data at rest.

Thanks.

Although not specifically what you asked about, it's also useful to be 
aware of the new secrets module in Python 3.6.

Peter



--
https://mail.python.org/mailman/listinfo/python-list


Mixing R and Python in the same Jupyter Notebook and finding Python code within an RMarkdown document

2018-11-02 Thread Spencer Graves

Hello, All:


  Two questions:


        1.  Is it feasible to mix R and Python code in the same 
Jupyter notebook?  If yes, can you please point me to an example?



        2.  How can one find Python code from within and R Markdown 
document?



          ** "https://github.com/sbgraves237/radioMonitor"; 
includes "radioMonitor-init2018-10-11.Rmd" that shows it's possible to 
mix R and Python snippets in the same R Markdown (*.Rmd) document.  
However, "radioMonitor0_1.Rmd" calls 'system("py idle0_1.py")' in an R 
snippet, which does what I want (namely recording 5 seconds of whatever 
is connected to "audio in" or something similar on your computer and 
writing it to "KKFI2018-10-12t13_16-5sec.wav".



  Thanks,
  Spencer Graves

--
https://mail.python.org/mailman/listinfo/python-list


Re: pyglet, i don't understand why this code isn't working

2018-11-02 Thread songbird
Peter Otten wrote:
> songbird wrote:
>> MRAB wrote:
>>> On 2018-11-02 19:58, songbird wrote:
 
hello,  :)
 
>
>>> [snip]
>>> In __init__ you initialise self.animation_initial_turn_it_off to True.
>>>
>>> Nowhere in your code do you change it, so it remains True.
>> 
>>   i wish it were that easy...
>> 
>>   see my_sprite.py
>
> It *is* that that easy. Just spot the typo in 
>
>> self.animation_initial_turn_if_off = False
>> ^^

  i just did...  1 minute ago, learnin how to use debugger
and there it was.

  lol

  thanks  :)


  songbird
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyglet, i don't understand why this code isn't working

2018-11-02 Thread Peter Otten
songbird wrote:

> MRAB wrote:
>> On 2018-11-02 19:58, songbird wrote:
>>> 
>>>hello,  :)
>>> 

>> [snip]
>> In __init__ you initialise self.animation_initial_turn_it_off to True.
>>
>> Nowhere in your code do you change it, so it remains True.
> 
>   i wish it were that easy...
> 
>   see my_sprite.py

It *is* that that easy. Just spot the typo in 

> self.animation_initial_turn_if_off = False
> ^^


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyglet, i don't understand why this code isn't working

2018-11-02 Thread songbird
MRAB wrote:
> On 2018-11-02 19:58, songbird wrote:
>> 
>>hello,  :)
>> 
>>my question is below, a bit of background first.
>> i'm very new to python and picking it up by working
>> on a project for fun.
>> 
>>please don't critique my style or lack of
>> classes/objects in the code yet - i'm way too new.  :)
>> 
>> 
>>my current project is at:
>> 
>>https://salsa.debian.org/ant-guest/gfpoken-in-python/
>>https://salsa.debian.org/ant-guest/gfpoken-in-python/tree/next
>> 
>>i'm using pyglet (most recent version) and gtk...
>> in Debian Linux testing.
>> 
>>my question is that in on_animation_end in the my_sprite.py
>> class doesn't seem to work as i'd expect.
>> 
>>i never reach:   print ("Do we Ever get here?") statement.
>> 
>>and i'm curious if i've just messed up something obvious
>> here or if my problem is elsewhere?
>> 
> [snip]
> In __init__ you initialise self.animation_initial_turn_it_off to True.
>
> Nowhere in your code do you change it, so it remains True.

  i wish it were that easy...

  see my_sprite.py 

...
def on_animation_end (self):

# we're already running when initialised so we
# have to shut it off until we restart it again
# but we only have to do this once as from then on
# each animation will check the global flag to see
# if it should run
#print ("AF AC ", self.animation_foo, self.animation_count)
self.animation_foo = False
self.animation_count += 1
if ((self.animation_initial_turn_it_off == True) and
(self.animation_running == True)):
print ("initial shut down animation AR True")
pyglet.clock.unschedule(self._animate)
self.animation_initial_turn_if_off = False
^^

self.animation_running = False
pprint.pprint(MySprite.__mro__)
pprint.pprint(MySprite.on_animation_end)
elif ((self.animation_initial_turn_it_off == True) and
(self.animation_running == False)):
# we shouldn't get here, but just in case
# just turn it off again...
#print ("initial shut down animation AR False")
self.animation_initial_turn_if_off = False
...


  songbird
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyglet, i don't understand why this code isn't working

2018-11-02 Thread MRAB

On 2018-11-02 19:58, songbird wrote:


   hello,  :)

   my question is below, a bit of background first.
i'm very new to python and picking it up by working
on a project for fun.

   please don't critique my style or lack of
classes/objects in the code yet - i'm way too new.  :)


   my current project is at:

   https://salsa.debian.org/ant-guest/gfpoken-in-python/
   https://salsa.debian.org/ant-guest/gfpoken-in-python/tree/next

   i'm using pyglet (most recent version) and gtk...
in Debian Linux testing.

   my question is that in on_animation_end in the my_sprite.py
class doesn't seem to work as i'd expect.

   i never reach:   print ("Do we Ever get here?") statement.

   and i'm curious if i've just messed up something obvious
here or if my problem is elsewhere?


[snip]
In __init__ you initialise self.animation_initial_turn_it_off to True.

Nowhere in your code do you change it, so it remains True.
--
https://mail.python.org/mailman/listinfo/python-list


Re: FW: error code

2018-11-02 Thread MRAB

On 2018-11-02 17:53, Steve Gonzales wrote:
[snip]

Hello Python,

I have installed c:\Python37 to my path and I still experience this issue 
"'python' is not recognized as an internal or external command,
operable program or batch file.".  I just installed the latest python version 
win 64bit using the newest sublime editor.  Hopefully you can recommend a fix.


Use the Python launcher "py".

[snip]
--
https://mail.python.org/mailman/listinfo/python-list


pyglet, i don't understand why this code isn't working

2018-11-02 Thread songbird


  hello,  :)

  my question is below, a bit of background first.
i'm very new to python and picking it up by working
on a project for fun.

  please don't critique my style or lack of
classes/objects in the code yet - i'm way too new.  :)


  my current project is at:

  https://salsa.debian.org/ant-guest/gfpoken-in-python/
  https://salsa.debian.org/ant-guest/gfpoken-in-python/tree/next

  i'm using pyglet (most recent version) and gtk...
in Debian Linux testing.

  my question is that in on_animation_end in the my_sprite.py
class doesn't seem to work as i'd expect.

  i never reach:   print ("Do we Ever get here?") statement.

  and i'm curious if i've just messed up something obvious
here or if my problem is elsewhere?

  i don't really quite understand subclasses/super yet so
perhaps i've abused it?

  the overall issue is that i'm trying to turn off and on
the animation and while i can do it in code like below i
haven't yet been able to figure out how to get that into
my other code...

  thanks for your input/consideration.  :)

  p.s. if you don't know the game gfpoken it is in 
debian/linux and it is a mirror puzzle game.  the
man page is there.  i haven't written help screen or
directions yet, but you click on things to the right
and place them on the grid on the left until the output
of the animation matches the colored arrows.

  it is mostly done other than some directions, checking
the boards for matching/winning, winning game screen and 
help.  just trying to iron this issue out...


=
import pyglet

marble_roll_image = pyglet.image.load('green_marbles.png')
marble_seq = pyglet.image.ImageGrid(marble_roll_image, 1, 16)
anim = pyglet.image.Animation.from_image_sequence(marble_seq, 0.1, True)
marble_anim_sprite = pyglet.sprite.Sprite(anim)

window = pyglet.window.Window()

def test_off (dt, sprite):
pyglet.clock.unschedule(sprite._animate)

def test_on (dt, sprite):
pyglet.clock.schedule(sprite._animate)


pyglet.clock.schedule_once(test_off, 5, marble_anim_sprite)
pyglet.clock.schedule_once(test_on, 10, marble_anim_sprite)


@window.event
def on_draw():
window.clear()
marble_anim_sprite.draw()


@marble_anim_sprite.event
def on_animation_end ():

print ("on_animation_end ")


pyglet.app.run()
=


  songbird
-- 
https://mail.python.org/mailman/listinfo/python-list


amusing error message

2018-11-02 Thread songbird
  hello,  :)

  this is just a bit of amusement, i'll post my
current question in another thread...

  please don't critique my style or lack of
classes/objects in the code yet - i'm way too new.  :)

  my current project is at:

  https://salsa.debian.org/ant-guest/gfpoken-in-python/
  https://salsa.debian.org/ant-guest/gfpoken-in-python/tree/next

  i'm using pyglet (most recent version) and gtk...


  the amusing bit:

  working on my git next branch...


  in my_sprite.py if i take the self out of on_animation_end parentheses i get 
this error message:

TypeError: The 'on_animation_end' event was dispatched with 0 arguments, but 
the handler 'on_animation_end' at /home/me/src/salsa/ngfp/my_sprite.py:23 is 
written with 0 arguments.

  0 <> 0!   :)


  songbird
-- 
https://mail.python.org/mailman/listinfo/python-list


FW: error code

2018-11-02 Thread Steve Gonzales
I just subscribed.

From: Steve Gonzales
Sent: Friday, November 02, 2018 7:20 AM
To: 'python-list@python.org' 
Subject: error code

Hello Python,

I have installed c:\Python37 to my path and I still experience this issue 
"'python' is not recognized as an internal or external command,
operable program or batch file.".  I just installed the latest python version 
win 64bit using the newest sublime editor.  Hopefully you can recommend a fix.

Best Regards,

Steve Gonzales
Manager - Predictive Solutions
(office)714-993-9394 ext. 21310
(direct)714-646-7707
[cid:image001.jpg@01D3C521.6937E5E0]
Predict the Future of Your Flight 
Operations

CONFIDENTIALITY NOTICE: This e-mail and any transmitted files are private and 
confidential and are solely for the use of the recipient(s) to whom it is 
addressed. Any unauthorized review, use, disclosure, distribution or copying of 
this communication is strictly forbidden. If you have received this 
communication in error, please delete and immediately notify the sender via the 
e-mail return address. Thank you for your compliance.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: introduction

2018-11-02 Thread songbird
Dariet Kamukama wrote:
> hey hw is every body here, am new to the group and want to learn python

  i'm good, thanks...  :)

  i'm also a beginner with python.

  do you have other programming experience?

  i have a fair amount of non OOP experience in
mostly functional types like C or Pascal.

  some Lisp, assembler, algol, sql, fortran, many
other bits of this and that (shell languages, awk,
sed, lex, yacc, etc.)...

  all i can say about learning a new language is 
that i need to have a project to work on to make 
it interesting so i've picked a project and am 
working on it and picking up ideas as i go and 
have time to study more.

  i'm woefully bad at OOP concepts and it takes
me a while for things to sink in.

  i see familiar names here from other lists i've 
been reading and writing to a few.  :)


  songbird
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: introduction

2018-11-02 Thread Dariet Kamukama
hey hw is every body here, am new to the group and want to learn python
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: AES Encryption/Decryption

2018-11-02 Thread Lutz Horn
On Fri, Nov 02, 2018 at 07:42:24AM -0700, Jeff M wrote:
> Python newbie here, looking for code samples for encrypting and
> decrypting functions, using AES.  See lots of stuff on the interwebs,
> but lots of comments back an forth about bugs, or implemented
> incorrect, etc...
> 
> I need to encrypt some strings that will be passed around in URL, and
> then also some PII data at rest.

Use https://pypi.org/project/cryptography/

Lutz
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: AES Encryption/Decryption

2018-11-02 Thread Christian Heimes
On 02/11/2018 15.42, Jeff M wrote:
> Python newbie here, looking for code samples for encrypting and decrypting 
> functions, using AES.  See lots of stuff on the interwebs, but lots of 
> comments back an forth about bugs, or implemented incorrect, etc...
> 
> I need to encrypt some strings that will be passed around in URL, and then 
> also some PII data at rest.

Don't use raw AES. It's hard to get it right in the first place.

I'd recommend Fernet if you want something based on AES. Fernet is a
good high level algorithm that combines AES, safe padding, block mode,
and MAC in a sane and safe message format.
https://cryptography.io/en/latest/fernet/

Christian


-- 
https://mail.python.org/mailman/listinfo/python-list


AES Encryption/Decryption

2018-11-02 Thread Jeff M
Python newbie here, looking for code samples for encrypting and decrypting 
functions, using AES.  See lots of stuff on the interwebs, but lots of comments 
back an forth about bugs, or implemented incorrect, etc...

I need to encrypt some strings that will be passed around in URL, and then also 
some PII data at rest.

Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list