Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: Dealing with multiple context managers
Post: RE: Dealing with multiple context managers
Thanks, so they can essentially share a context manager. Maybe I can also use asynccontextmanager to get the structure I want. |
|
heras |
General Coding Help |
5 |
4,602 |
Nov-15-2018, 04:57 PM |
|
|
Thread: Dealing with multiple context managers
Post: RE: Dealing with multiple context managers
Thanks for your suggestion nilamo. So the unavoidable seems to be that you have to pick one master context and embed all the lesser contexts in it? I will give it a try but I think it will be difficul... |
|
heras |
General Coding Help |
5 |
4,602 |
Nov-14-2018, 10:40 PM |
|
|
Thread: Storing chart objects in a dictionary
Post: RE: Storing chart objects in a dictionary
chart = n will make chart point to the key(s) of the dictionary which is a string, but you want the value associated with that key. Try this:
chart = d[n] |
|
heras |
General Coding Help |
2 |
2,514 |
Nov-14-2018, 10:26 PM |
|
|
Thread: Dealing with multiple context managers
Post: Dealing with multiple context managers
Hi,
How do you structure code around multiple context managers? I looking to make something like this:
#main.py
import file_io.py
import rest_api.py
main():
main program flow here
read someth... |
|
heras |
General Coding Help |
5 |
4,602 |
Nov-14-2018, 10:07 PM |
|
|
Thread: Automating putty for daily repetitive task
Post: RE: Automating putty for daily repetitive task
From your description it sounds like you are connecting to a linux machine. Once you have connected with putty, can you run the command uname -a and tell us the output?
So you run:
my_file.sh BR0001
... |
|
heras |
Bar |
4 |
13,107 |
Sep-01-2018, 10:25 PM |
|
|
Thread: Automating putty for daily repetitive task
Post: RE: Automating putty for daily repetitive task
Alternatively, if the remote machine is Unix-like, you may be able to set up a cron job. Cron can run scheduled tasks for you removing the need to SSH into the machine at all.
What is the nature of t... |
|
heras |
Bar |
4 |
13,107 |
Aug-30-2018, 07:21 PM |
|
|
Thread: Time complexity of dict vs attributes
Post: RE: Time complexity of dict vs attributes
So
len_cumsum = len(self.data[dest+'_cumsum'])will ask whatever object is associated with dest+'_cumsum' for its length.
len_cumsum = len(self.data[dest+'_cumsum'][:])will recreate the list inside le... |
|
heras |
General Coding Help |
6 |
3,704 |
Aug-24-2018, 10:16 PM |
|
|
Thread: Time complexity of dict vs attributes
Post: RE: Time complexity of dict vs attributes
You are brilliant!
A small test:
>>> a = {'as': [1,2,3,4,5,6]}
>>> a
{'as': [1, 2, 3, 4, 5, 6]}
>>> len(a['as'])
6
>>> len(a['as'][:])
6I will see if I can figure o... |
|
heras |
General Coding Help |
6 |
3,704 |
Aug-24-2018, 09:20 PM |
|
|
Thread: .pyplot has not attribute zlim
Post: RE: .pyplot has not attribute zlim
Just a shot in the dark ... maybe try plt.set_zlim(0,7.5)?
https://matplotlib.org/examples/mplot3d/...demo3.html |
|
heras |
General Coding Help |
5 |
9,767 |
Aug-24-2018, 09:13 PM |
|
|
Thread: Time complexity of dict vs attributes
Post: RE: Time complexity of dict vs attributes
I've simplified the code some more, hoping to make it more clear. This time I profiled both running over 20.000 values. Most of the time is spent in the simple_moving_average method of the dict versio... |
|
heras |
General Coding Help |
6 |
3,704 |
Aug-24-2018, 08:13 PM |
|
|
Thread: Yield Keyword
Post: RE: Yield Keyword
return instead of yield would exit the function and forget about a and b (try it!). yield will return a value while retaining the state of the function in memory until the next time fib() is called. I... |
|
heras |
General Coding Help |
6 |
4,109 |
Aug-23-2018, 08:39 PM |
|
|
Thread: Time complexity of dict vs attributes
Post: Time complexity of dict vs attributes
Hi,
I was going over some data. To store results I manually added empty list attributes to a class as needed. In order to make this dynamic I added a dict attribute that would store the series name(k... |
|
heras |
General Coding Help |
6 |
3,704 |
Aug-23-2018, 08:12 PM |
|
|
Thread: Methods of running a script on Linux distro
Post: RE: Methods of running a script on Linux distro
I would like to point out that you should use sudo judiciously, i.e. only if you need to. In this case it was not required and chmod as normal user would have been sufficient. |
|
heras |
General Coding Help |
6 |
3,794 |
Aug-21-2018, 09:11 PM |
|
|
Thread: Methods of running a script on Linux distro
Post: RE: Methods of running a script on Linux distro
Normally you would chmod +x script.py to make it executable without having to specify python on the command line explicitly. |
|
heras |
General Coding Help |
6 |
3,794 |
Aug-21-2018, 05:12 PM |
|
|
Thread: Help with tic-tac-toe project
Post: RE: Help with tic-tac-toe project
Hi,
Here are some ideas you might consider for your program:
>>> board = [['']*3]*3
>>> board
[['', '', ''], ['', '', ''], ['', '', '']]
>>> for row in board: #compare rows... |
|
heras |
General Coding Help |
3 |
2,351 |
Aug-15-2018, 03:27 PM |
|
|
Thread: Trouble with "Weather Program" Assignment
Post: RE: Trouble with "Weather Program" Assignment
I would do two things, especially when things aren't working.
- Use separate program lines to do things. One to read the line and the next to split the result.
- Put print statements/functions after e... |
|
heras |
Homework |
5 |
8,949 |
Aug-06-2018, 03:16 PM |
|
|
Thread: Trouble with "Weather Program" Assignment
Post: RE: Trouble with "Weather Program" Assignment
What is the error message? |
|
heras |
Homework |
5 |
8,949 |
Aug-05-2018, 05:24 PM |
|
|
Thread: How to plot data to the same figure for every run?
Post: RE: How to plot data to the same figure for every ...
Hi,
I'm sorry that was incorrect. The following works for me:
import matplotlib.pyplot as plt
plt.ion() # This puts plt in interactive mode
plt.plot([1,2,3,4])
input("Press enter")
plt.plot([2,4,1,3... |
|
heras |
Data Science |
3 |
4,678 |
Aug-03-2018, 04:21 PM |
|
|
Thread: How to plot data to the same figure for every run?
Post: RE: How to plot data to the same figure for every ...
Use plt.draw() instead of plt.show(). Each call to plt.draw() will replot the image, for example after adding more data to it. |
|
heras |
Data Science |
3 |
4,678 |
Aug-02-2018, 10:31 AM |
|
|
Thread: Emulate slicing for a method
Post: RE: Emulate slicing for a method
It looks like pandas indeed does use classes for this as seen here. It also looks like a complex project! |
|
heras |
Data Science |
5 |
3,195 |
Jul-30-2018, 10:36 AM |