sina sareth via Tutor | 13 Feb 01:02 2016

AWS /Django/Apache/Python/Github

Hi ThereHow are you looking for good videos on the deploy apps with Python Framework. I wonder if somebody
has any good videos. Thanks 
Sina
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Brianna Hulbert | 12 Feb 19:51 2016
Picon

question

Hi,

I am new to python and just downloaded it onto my computer. The window
comes up however there is no menu bar across the top that says file, edit,
format, run, options, etc. I was wondering how to get that to appear.

Thank you
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

richard kappler | 12 Feb 16:16 2016
Picon

Buffer code review

I have a two script test env set to simulate a controller in production.
The controller creates xml data from a camera tunnel as packages roll
through it, sends these xml messages over tcp to a different machine.

To simulate this in our test environment, I take a log of all the xml
messages, read them out line by line with script1, which writes them to
another log with a time.sleep(0.1) between each line being read to simulate
the rate at which packages pass through the camera tunnel.

Script2 checks file size to see if file has new data, if so, reads the
data, adds an stx and etx, then sends it out over tcp to a machine with a
splunk instance for data collection and analysis.

I will append the script below, but here is the problem. I included a
buffer because there are times when Script2 is reading while Script1 is
writing, so Script2 may not get a full line/message as detected by matching
open/close tags. In that case, the partial line is put in the buffer until
the next read, of which the first line is appended to the buffer and, if
there are matching open/close tags, sent on and the buffer cleared.

Most (literally over 99%) of the time this works fine, but on rare
occasions something goes wrong and I lose a message. The only messages that
are lost are ones that have gone through the buffer. It's rare (26 of 907
through buffer failed, of 17,000+ total messages), but it's still a data
loss so I need to figure out what it is I'm doing not so well here.

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

(Continue reading)

richard kappler | 12 Feb 15:56 2016
Picon

Re: declare a variable inside a class

On Fri, Feb 12, 2016 at 2:23 AM, Ian Winstanley <ianwinstanley8 <at> gmail.com>
wrote:

> To refer to a class variable you need to put the class name first for
> example MyClass.xslt
>

That indeed did the trick, thanks Ian.

regards, Richard

--

-- 

*Java is like Alzheimers; it starts slow and eventually, it takes away all
of your memory.*
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Nicholas Tomasic | 11 Feb 23:56 2016
Picon

Python for Grade 12 Calculus

Hi,

I'm a 12th grade Calculus teacher at a school in Toronto, Ontario, and I'm
thinking about incorporating Python into an Independent Study Project for
two of my students. Both are passionate about coding with Python and I'm
thinking of asking them to produce something that can either a) calculate
derivatives of simple functions or b) assign 1 student the product rule,
one the quotient rule, and have them write a program that can tackle
derivatives in those forms.

The problem is: I know very little about Python.

Unfortunately, I don't have a specific question but I'm looking for any
valuable insights or suggestions.

I appreciate any information you can give me on the subject.

Thanks so much,

Nick Tomasic
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

richard kappler | 11 Feb 21:28 2016
Picon

declare a variable inside a class

Trying to optimize the modular input we wrote for Splunk, the basic
structure (dictated by Splunk) is the entire script is a class with
numerous methods within. The modular input reads a tcp stream, starts a new
thread for each source, reads the messages from that source into a buffer,
checks for stx and etx, formats it using an xslt and sends the result out
to splunk.

The method that actually formats the messages opens the xslt file, then
uses it to format the message. Clever boy that I am, I figured it would be
better to open the xslt file once, rather than once per message, so I moved
the line

xslt = ('path/to/xslt.file')

out of the method it was in and up to the top level of the class, to wit:

class MyClass():

    xslt = ('path/to/xslt.file')

   def a_bunch-of-methods():

and so on.

Obviously this didn't work, when the formatting method was called, it
through an exception that the variable xslt wasn't defined. This is my
first not-a-toy try at OOP, I could use a clue.

regards, Richard

(Continue reading)

Swift, Robert | 11 Feb 19:03 2016

Need help with audio manipulation

I was wondering how to write a code that would take a recorded audio and
place these values into a numpy array? I have written various codes that
can record and playback sound and work properly. I need the recorded audio
to be accessed from a numpy array so I can process the sound and manipulate
it to play back the inverse of the array for a noise cancelling affect. Any
ideas would be great.

Thanks,

Robert
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Anshu Kumar | 11 Feb 14:01 2016
Picon

mock file reader object

Hi,

I need to mock file reader object , i tried using  <at> patch('__builtin__.open')
but it will patch my all file open readers.

More precisely i have code something like below

def restore_segments_and_lines_json(segments_file_path,lines_file_path,deleted_segment_ids):
    with open(segments_file_path, "rb") as segments_reader:
        segments = segments_reader.read()

    with open(lines_file_path, "rb") as lines_reader:
        lines = lines_readers.read()

    """ Do some processing with lines and segments"""

    logger.info("updating segments file")
    with open(segments_file_path, "wb") as segments_writer:
        segments_writer.write(segments, segments_writer)

    logger.info("updating lines file")
    with open(lines_file_path, "wb") as lines_writer:
        lines_writer.write(lines, lines_writer)

I need to mock two different file read and file write opens, can i get
some suggestion.

Thanks in advance,

Anshu
(Continue reading)

Chelsea G | 9 Feb 16:34 2016
Picon

Help with date range

So what I am trying to do is take in a csv file and the format of the csv
file is:
something, something1, something2,something3, something4, something5,
something6, something7.
Then in the csv file I want to search for a certain range of dates like
1/3/2016 - 2/3/2016. I can get individual dates but not a range of dates. I
have an if elif statement to read row5 which is the date row. My if
statement is the initial pass at returning the values within the date range
and then my elif is the parameter and if there is no parameter passed in
then it returns all data. I am having some trouble trying to pass in a date
range parameter. The piece of code is under the def populate_dict function
the date_choice part. Here is the code:

import csvimport jsonimport sysimport osfrom collections import
defaultdictfrom collections import Counter

UPPER_LIMIT = 5
LOWER_LIMIT = 4
class dictionary():
    def __init__(self):
	self.dict = defaultdict(list)
	self.counted_dict = defaultdict(list)
	self.grouped_dict = defaultdict(list)
	self.total_dict = defaultdict(list)

    def populate_dict(self, filename, date_choice, key_choice):
        with open(filename, 'rb') as f:
            reader = csv.reader(f)
            next(reader, None) #
            for row in reader:
(Continue reading)

Ek Esawi | 8 Feb 02:36 2016
Picon

genfromtxt vs. reading csv to a list or dictionary

Hi all—

I normally need to convert csv and text files to a Numpy array. I tried to
do the same thing using (1) reader=DictReader(MyFile), (2)
reader=csv.readre(MyFile), or (3) genfromtxt (MyFile ,……).  The first two
is after I open the file. They produce a list of lists, list of tuples or
list of dictionaries which later are converted to an array.

The question is which one is the fastest and/or most efficient most
flexible? The genformtext function is nice b/c you can setup formatting of
various column which I often need to do b/c my files contain both string
and numeric values (integer and float).

Thanks in advance--EKE
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
boB Stepp | 6 Feb 22:54 2016
Picon

Re: Need help with two similar test cases that I have written. One works and the other fails

On Sat, Feb 6, 2016 at 10:07 AM, Anubhav Yadav <anubhav1691 <at> gmail.com> wrote:

> class TestCase(unittest.TestCase):
>     def test_red_temperature_simulation(self):
>         """
>         Method to test the red_temperature_simulation method
>         """
>         for i in range(100000):
>             self.assertLess(red_temperature_simulation(), 100.0) and \
>                 self.assertGreater(red_temperature_simulation(), 103.0)

Is this really what you want (And similarly in your other test
method.)?  If I am reading things correctly, you are calling
red_temperature_simulation *twice*, which will *usually* give you two
*separate* values, which you then attempt to compare.  Shouldn't you
first do:

for i in range(100000):
    value_to_test = red_temperature_simulation()
    (self.assertLess(value_to_test, 100.0) <Which logic op?>
        self.assertGreater(value_to_test, 103.0))
?

If my understanding is indeed correct, then I will leave it to you to
figure out which logic operator ("and" or "or") makes sense here!
~(:>))

--

-- 
boB
_______________________________________________
(Continue reading)


Gmane