Page 16 of 23

Re: Python tricks

Posted: October 10th, 2019, 3:40 pm
by FaridMoussaoui
that's python IDE is easier

Re: Python tricks

Posted: October 11th, 2019, 7:51 am
by Cuchulainn
that's python IDE is easier
I sugested pyCharm. My student loves it! No looking back, goodbye VS and parallels for her. We keep the infrastructure threshold low. The rest is plain sailing.
Merci, Farid.

Re: Python tricks

Posted: October 17th, 2019, 1:56 pm
by Cuchulainn
Is this a bug in Python?
import pandas as pd
from pandas import datetime, period_range

#compiles
#myRange = pd.period_range('2000-01-01', periods=12, freq='T')
#ts  = pd.Series(range(12), index=myRange)

#NOT compile
range = pd.period_range('2000-01-01', periods=12, freq='T')
ts  = pd.Series(range(12), index=range)

ts.index = ts.index.astype('datetime64[ns]')
data_higher_freq = ts.resample('5T').sum()

Re: Python tricks

Posted: October 17th, 2019, 2:52 pm
by FaridMoussaoui
Is this a bug in Python?
Isn't python, it is the developer. What about using a square bracket instead of a parenthese .....

Re: Python tricks

Posted: October 17th, 2019, 4:51 pm
by Cuchulainn
Even more interesting I accidentally had a range() function and this is the one that resample() sees. Ouch
Very bad.I am accidentally or deliberately overriding what is in essence an (undocumented) Python keyword 'range'.

Q: The ability to override core Python functions with impunity,feature or bug?

Code:
 
def range(i):
    print ("range")
    return 1/0

 

Re: Python tricks

Posted: October 17th, 2019, 4:58 pm
by Cuchulainn
Is this a bug in Python?
Isn't python, it is the developer. What about using a square bracket instead of a parenthese .....
range is a function, not an object
?

Re: Python tricks

Posted: October 20th, 2019, 8:49 am
by tags
Is this a bug in Python?
Isn't python, it is the developer. What about using a square bracket instead of a parenthese .....
range is a function, not an object
?
Python allows built-in functions overloading. Bad or good is mental masturbation. That's just the way it is. Programmer is supposed to have come through the list of these built-in functions at some point, and understands it is usually bad practice to use those name to create object/functions/etc. To somewhat circumvent the issue, programmer can use scope/namespace tricks.

import builtins
builtins.range(10)
#range(0, 10)


 

Re: Python tricks

Posted: October 20th, 2019, 9:56 am
by Cuchulainn
Nice. So, one can put functions and so on in modules which is good practice. System decomposition into independent and loosely coupled modules is recommended before jumping head first into coding marathons.

Re: Python tricks

Posted: November 1st, 2019, 4:45 pm
by ISayMoo

Re: Python tricks

Posted: November 23rd, 2019, 1:23 pm
by tags
Python 3.8 introduced the Walrus operator.
What are the cons according to you Wilmotters?

Re: Python tricks

Posted: February 14th, 2020, 4:18 pm
by Cuchulainn
Am getting issues when installing packages in Pycharm, VS and Anaconda.
Any ideas?
Collecting clawpack
  Using cached clawpack-5.6.1.tar.gz (5.7 MB)
ERROR: The tar file (C:\Users\ABC\AppData\Local\Temp\pip-unpack-vv069ogw\clawpack-5.6.1.tar.gz) has a file (C:\Users\ABC1\AppData\Local\Temp\pip-install-3y0_4wxk\clawpack\pyclaw/
development/point_wise_rs/pyWrapperForRiemannSolver/aux.npy) trying to install outside target directory (C:\Users\ABC\AppData\Local\Temp\pip-install-3y0_4wxk\clawpack)
----- Failed to install 'clawpack' -----


Re: Python tricks

Posted: February 14th, 2020, 6:35 pm
by FaridMoussaoui
Who is user "ABC1"? a typo in your target directory?

Re: Python tricks

Posted: February 14th, 2020, 7:31 pm
by Cuchulainn
Who is user "ABC1"? a typo in your target directory?
No, I changed the real name to ABC. That directory exists.

BTW my problem is well-known.

https://stackoverflow.com/questions/52949531/could-not-install-packages-due-to-an-environmenterror-errno-13/53916143

Re: Python tricks

Posted: February 14th, 2020, 7:57 pm
by FaridMoussaoui
That's not the correct link. Your error arise in the pip file unpacking.py

Re: Python tricks

Posted: February 14th, 2020, 8:36 pm
by Cuchulainn
That's not the correct link. Your error arise in the pip file unpacking.py
uh! Is that a bug in Python?
What next?