« first day (3419 days earlier)      last day (1529 days later) » 

12:26 AM
@Aran-Fey Drat and yay! Your get_python_type function returns Number for my age (annotated: Number) parameter. I can map that, at least! (But more on why that's a "drat" next…) And ❤️ it correctly maps tags: Iterable[str]collections.abc.Iterable (and similar with sets/frozensets/etc.) which I can also directly map without issue. Thank you again!
On the "drat" of `Number`:

from inspect import isabstract
from numbers import Number

isabstract(Number)  # False
Number.__class__  # abc.ABCMeta
^ had me blinking, dumbfounded at my REPL for a few moments.
 
1:24 AM
@amcgregor looks like it's a fairly empty class, with no abstractmethods...
therefore... you can instantiate it! :)
 
 
2 hours later…
3:03 AM
Hi everyone is there anyone django developers here?
 
3:56 AM
Greetings all, I would like to take guidance from experts recently I completed python basics and advance concepts, could anyone guide me on projects related to python basics and advance level only where I could practice things
I tried looking online but I am getting very hi-fi projects and I need to start from starting any guidance is greatly appreciated here
 
@AaronHall Absolutely, but where one is attempting to typecast to concrete types, types which seem to support instantiation (and do… with no arguments!) and operation in the typical method of passing the value to typecast, fail, and "muddy the waters". If it's not concrete, and it's not abstract (as in: an abstract base class for int, float, &c.)… what is it? More to the point: how do I detect it?
Are there more things like this I need to worry about people using as annotations? Where's the end?! youtube.com/watch?v=wNFMPhKIZXg
 
4:50 AM
Hi everyone I need one help
 
@RavinderSingh13 Maybe you could start with automate the boring stuff book by Al sweigart
@G.Lakshmi Not me
 
I wrote a script for getting one column names from an excel sheet
import xlrd

loc = ("names.xlsx")

wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
sheet.cell_value(0, 3)

for i in range(sheet.nrows):
    print(sheet.cell_value(i, 3))
Now I want to get only university words from that coulmn how can I do it can anyone help
only sentences having "university" should come how can I query them
 
5:06 AM
@TejasShetty can you help me?
 
@G.Lakshmi before the last print statement, use an if loop to check if value contains the word you want
 
if you dont mind can you show one statement how actually I tried but not came
 
show me what you tried
 
Yes I got @variable I wrote loop like this if 'university' in str(sheet.cell_value(i, 3)):
 
what is the output without if loop?
 
5:17 AM
all the sentences in the 3rd column
 
can you see university in there?
 
yes
in some of them
 
for i in range(sheet.nrows):
    if 'university' in str(sheet.cell_value(i, 3)):
        print(sheet.cell_value(i, 3))
 
@variable I am having an excel sheet containing names in 1st column and organizations in 3rd column and now I am getting the organizations having "university" in them and now I want to get the names from 1st column having "university" in third column
Yes I got that I did as you said @variable thankyou
 
SO what do you want now?
 
5:22 AM
@variable I am having an excel sheet containing names in 1st column and organizations in 3rd column and now I am getting the organizations having "university" in them and now I want to get the names from 1st column having "university" in third column
 
for i in range(sheet.nrows):
    if 'university' in str(sheet.cell_value(i, 3)):
        print(sheet.cell_value(i, 3))
        print(sheet.cell_value(i, 1))
 
will these be again uploaded to another excel sheet @variable is that possible.
 
I am having difficulty understanding you gramatically
 
now I am getting the names and organizations right with the script right now I want to upload these to a new excel sheet is it possible?
 
yes
 
5:25 AM
how is there any script for that to automate.
 
cbg guys o/
 
@G.Lakshmi Refer to this for code examples: geeksforgeeks.org/writing-excel-sheet-using-python
 
@TheNamesAlc So do I. Did you check the answer that I posted?
 
Yes Thankyou @variable and another last doubt can I write a script for querying the names in this directory : myaccount.umn.edu/…
 
Does that website expose some web api that you can call to and get the results in form of a JSON or XML? If not then, you will have to call the same url as you pasted above (with the url parameters for the search). By call I mean - import requests and do -> response = requests.get('url') so you have that website in the response object. Now you can look at python package like beutifulsoup to parse that page and extract the table that you are interested in.
 
5:35 AM
can you share any tutorial for that @variable
or if you dont mind can you guide me without any API calls
 
cbg :)
 
1. Example on how to make a GET request in python - geeksforgeeks.org/get-post-requests-using-python
 
@variable I already read that the main doubt querying names from the directory shared is the requirement but in that names are not there how can I get them can you please explain if you dont mind
 
2. Parsing of html is called web scrapping. beutifulsoup is one such tool (pypi.org/project/beautifulsoup4) - Example of how to parse the html contents to get the table can be found on google/stackoverflow
If you serach by a name then you will get the name
ENter some name and click on search
 
Yes I got the table matched with the name I have given
but I need all the only names present in that site how
 
5:59 AM
you will have to write an email to the university for that requesting for data
 
which data
@variable
I want to get the names from this myaccount.umn.edu/…
How can I write a script can you help me?
 
@G.Lakshmi follow the point 1 & 2 I shared with you above
 
Yes I am having now names in a html table
 
6:18 AM
So you can loop through the names. What is the problem?
 
I wrote the code like this
import requests
import lxml.html as lh
import pandas as pd
URL = "https://myaccount.umn.edu/lookup?SET_INSTITUTION=UMNTC&type=name&CN=University+of+Minnesota&campus=a&role=any"
r = requests.get(URL)
doc = lh.fromstring(page.content)
tr_elements = doc.xpath('//tr')

#Create empty list
col=[]
i=0
#For each row, store each first element (header) and an empty list
for t in tr_elements[0]:
i+=1
name=t.text_content()
print '%d:"%s"' %(i,name)
col.append((name,[]))
but getting error as File "scrap.py", line 16
print '%d:"%s"' %(i,name)
^
SyntaxError: invalid syntax
 
Use gist.github.com to share long code. @G.Lakshmi
 
You should spend a day reading python tutorial as you are missing whitespaces after teh for loop
 
Ok
 
cbg-ning
 
6:30 AM
@variable as you said with beautiful soup I had tried but I am not getting can you see my code once gist.github.com/glakshmi-nyros/c6a8cc1eda6110eb5200198f1ab1961a
 
6:45 AM
Hi everyone, I was trying to pull google reviews data using selenium and it seemed that the code was working as it opened the correct site and all
However, its freezing in the middle of execution
Here is the geckodriver log for the same
1582612720670	mozrunner::runner	INFO	Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-foreground" "-no-remote" "-profile" "/var/folders/xw/0jz1mq096w93y6n3y8nwby6r0000gp/T/rust_mozprofilePP1QF8"
1582612725920	addons.webextension.doh-rollout@mozilla.org	WARN	Loading extension 'doh-rollout@mozilla.org': Reading manifest: Invalid extension permission: networkStatus
1582612726318	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
Can anyone tell me why its happening?
 
@G.Lakshmi you code is incorrect try:
gdp_table = soup.find("table")
gdp_table_data = gdp_table.findAll("tr") # contains 2 rows
 
yes I tried still i am getting same error
File "scrap.py", line 12, in <module>
gdp_table_data = gdp_table.tbody.find_all("tr") # contains 2 rows
AttributeError: 'NoneType' object has no attribute 'find_all'
yes I understood ok
 
user11585758
guys np.random.shuffle() throwing None type error
 
even now getting this error
Traceback (most recent call last):
File "scrap.py", line 16, in <module>
for td in gdp_table_data[0].find_all("td"):
IndexError: list index out of range
@variable
 
why using [0]?
 
user11585758
6:54 AM
I found answer but for random not numpy ,
 
@G.Lakshmi - Sorry I havent worked much with this but it is basic python so please try solving it
 
@variable if I didnt kept [0] I am getting error like this Traceback (most recent call last):
File "scrap.py", line 16, in <module>
for td in gdp_table_data.find_all("td"):
File "/home/nyros/.local/lib/python3.6/site-packages/bs4/element.py", line 2081, in __getattr__
"ResultSet object has no attribute '%s'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?" % key
AttributeError: ResultSet object has no attribute 'find_all'. You're probably treating a list of elements like a single element. Did you call find_all() when
 
Its 'findAll' not 'find_all' @G.Lakshmi
 
cbg
 
@RaphX then getting error like this
Traceback (most recent call last):
File "scrap.py", line 16, in <module>
for td in gdp_table_data.findAll("td"):
File "/home/nyros/.local/lib/python3.6/site-packages/bs4/element.py", line 2081, in __getattr__
"ResultSet object has no attribute '%s'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?" % key
AttributeError: ResultSet object has no attribute 'findAll'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?
 
7:05 AM
Have you done a google search for your error?
 
yes
 
Actually @RaphX I am trying to scrap only the names from this myaccount.umn.edu/… website by following this pluralsight.com/guides/extracting-data-html-beautifulsoup tutorial
Can you guide or help me If you dont mind
 
user11585758
when i used
valid_dataset = np.random.shuffle(valid_dataset)
It throws error saying "Nonetype object is not iterable"
 
user11585758
Oh that problem is solved , What i was doing was putting valid_dataset of type list into shuffle which thrown error, after i change to np.array() and used that code , it is not
 
user11585758
7:17 AM
oh i think it is not solved
 
I am unable to reproduce the error i.e. its working for me @G.Lakshmi
 
is it @RaphX share your code once
 
I am writing a class that inherits from unittest.TestCase. My class has the __init__method that initializes couple of instance variables. I was wondering if I have to explicitly call super().__init__() also? It works fine even if I dont call the super().__init__()
 
Why would you ever not call your parent constructor?
 
Just asking.
 
7:23 AM
Its the same code snippet as given in the site @G.Lakshmi
 
user11585758
Help!
 
@RaphX That one is working but I am following that site code for doing this myaccount.umn.edu/…
can you help please
 
user11585758
after changing list into numpy array then shuffling again didnt solved , showing same error
 
Just I want to get the names in the table in the site which I shared now
 
user11585758
phew its solved , actually np.random.shuffle() when used in variable returned none. It is in place by default, just calling solved ans showing type of numpy array
 
7:41 AM
Can soemone give me example of why one would inherit from class that inherits from unittest.TestCase. My example is - if the derived class X that is inherited from Y and Y inherits from unittest.TestCase. This will allow us to add tests via X while ensureing that tests in Y always run. Have I got this right?
 
7:53 AM
Hi! Anyone know how I annotate in a function signature that a dataframe is expected? Do I write object? E.g. def get_chunked_dfs(df: object, size: int)->list: where df is actually expected to be a dataframe?
 
@variable If you have a class A with a subclass B, then Y could contain all tests for A and X all tests for B. That way all the tests in Y will run for both A and B.
@QHarr df: pandas.DataFrame?
 
Oh... that might be a good idea!
@Aran-Fey Thanks. Doh. One further question please.... Does python have an equivalent of a sub i.e. a set of instructions that don't return anything (unlike a func)? I am writing them as def foo: without an explicit return though I understand implicitly this will return None
I'm unsure of the correct terminology to use to look this up.
 
no, all functions (and callables in general) have a return value in python
 
ok.... so the right term might be methods but that kinda implies classes?
Or I just write as I am but having None as return?
 
can someone help me for the script for scrapping only names from this myaccount.umn.edu/… website
 
8:02 AM
essentially, in python lingo, "the right term" is meaningless since every function has a return, and the concept of returnless functions doesn't exist. Keep writing it the way you're writing with an implicit None, it's fine
 
cbg
Python 3.7.5 (default, Nov 20 2019, 09:21:52)
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> x = json.loads('[{"foo":"bar"}, {"foo":"bar"}]')
>>> next(iter(x[0].keys())) is next(iter(x[1].keys()))
True
 
@ParitoshSingh Many thanks
 
can anyone verify this on Python 3.6, thanks?
 
Thanks to all. Very helpful.
 
@AnttiHaapala True on 3.6.10
 
8:04 AM
good
 
on my machine at least.
 
3.5? :D
 
@AnttiHaapala syntax error: true
 
@superv ...
 
don't have 3.5 handy im afraid :P
 
8:06 AM
that's ok :D
targetting 3.6 but just wondering that it didnt change in some minor version
 
@AnttiHaapala True
 
btw, Python 2.7
 
on 3.5.9
False on 2.7.17
 
@AnttiHaapala I meant the result of your code. True on 3.7.5
 
@RaphX can you help me if you dont mind?
 
8:08 AM
@superv you wrote syntax error: true. that was, weird.
 
@ParitoshSingh I used the python shell, so I got that from there. I had to try python idle to get the right answer. :)
@shad0w_wa1k3r Thanks for yesterday. It worked but I couldn't get the contract object in the template but I can see it when I print it to the console. I installed the debugger to figure out what the problem might be, but I can't figure it out. I looked at the template but I dont see anything wrong?
 
Would anyone be able to help me with this?
 
@superv You may have forgotten to add it to the context of your template?
 
can someone help me for the script for scrapping only names from this myaccount.umn.edu/… website
I wrote this code https://gist.github.com/glakshmi-nyros/c6a8cc1eda6110eb5200198f1ab1961a but I am getting nothing when I run this code
 
@Gmanc2 Please fix your indentation.
People are much less likely to help if you provide a code sample that doesn't run without cleaning it up first.
 
What line contains indentation errors?
 
    if not end:
    ^
IndentationError: unexpected indent
 
The gist has been updated
thank you
 
8:35 AM
Am I drunk or is that completely different code now Guess I'm drunk
 
I cannot reproduce your problem. Changing the first code line to end = True doesn't enter the block, as expected.
 
I had a spacing error in my source code.
how would I make this if statement after its executed once wait 30 seconds to execute again?
 
with a loop and a time.sleep(30)?
 
I have other parts of my program that will sleep if that is executed. I need just the if statement to wait 30 seconds before it is able to be called again
Specificly I need the client.messages.create(to=number, from_="", body="Intruder Detected:\n") to not be able to be called again for 30 seconds
 
Every time that line is executed, store the current time in a variable. Before that line is executed, check if 30 seconds have passed since the last call.
 
8:46 AM
With a timer or?
My brain is dead I've been fixing this for almost 6 hours lol
 
Sounds like a good time to leave it for a bit and do something else then... always helps in programming :)
 
@Gmanc2 no, with a current_time = time.monotonic()
 
@Gmanc2 what do you mean by "able to be called again"? The if statement cannot influence when it is called. What do you want to happen if it is called too early?
 
Okay basically client.messages.create sends a message via an api. my program is in a constant loop recording a video that when the video detects a face it sends me a text with that message. It spams over 300 messages so the if statement I added only makes it send 1 but I need to do it in an interval which I chose to be 30 seconds. I cant figure out how to do it though.
 
so then why don't you just call the if statement only every 30 seconds?
your main loop should be able to time that.
 
8:56 AM
@shad0w_wa1k3r I did had it there but it was displaying the data that I inputted through the admin page. It looks like it is hardcoded and it doesn't change with the data from the form. I am thinking is it because I am not looping on the template?
<ul>
    <li> insurance : {{contract.insurance_required}}</li>
    <li> other terms: {{contract.other_terms}}</li>
    </ul>
That is what I have on the template.
 
@superv And what do you pass in the context dictionary?
Give me a dpaste link to your updated view function
 
@MisterMiyagi Thank you! https://gist.github.com/gmanc2/cb938aadddec228dfb4e37610d25fd89
would this be efficient or is there a better way?
 
@shad0w_wa1k3r here: dpaste.com/02F18WM. I think Its in the context dictionary or ?
 
20 hours ago, by shad0w_wa1k3r
@superv In your nested else, you forgot to return a response. You can just dedent the last return from under the outer else. See mine - http://dpaste.com/1QFETVF.
 
@Gmanc2 A Timer will fire only once. If you are going to use threading anyways, use a regular Thread and add a loop with time.sleep(30) to your function. Sleeping inside inside this thread won't affect the rest of your program.
 
9:04 AM
Also, note that there's no contract variable you are passing to your template, it is contract_form. So, I'm not sure where you are getting or implying that variable within your template.
 
@MisterMiyagi I'm not sure how to implement that, could you show me an example?
 
@Gmanc2 This is common in JavaScript but comes in two similar but different forms debounce and throttle. Searching for either term shows a variety of code samples, so you can write your own.
 
@Gmanc2 like this:
def message():
    while True:
        if objCount[CLASSES[15]] >= 1:
            ...
        time.sleep(30)

watchdog = threading.Thread(message, daemon=True)
watchdog.start()
Note that the daemon is set so that the thread does not keep your program alive. This might seem unexpected if you test it in isolation (i.e. there is nothing else to your program to keep it alive).
 
@MisterMiyagi Thank you, that makes much more sense I get "Expected type 'None', got '() -> None' instead" though.
 
ah, it's got to be ...Thread(target=message, ...
 
9:13 AM
Do I still need to call the function or will the daemon take care of that?
 
@shad0w_wa1k3r, sorry the code I gave earlier was the not the correct one. I had fixed the return in the else statement you mentioned earlier. Do you mean i should have done 'contract':contract instead of contract_form?
 
@Gmanc2 the thread does. See the docs
 
@superv I need to take a look at the new template code to be sure.
 
The "test" is each message sent
 
Hello I am having statement like this print(sheet.cell_value(i, 3))
which will print all the strings in a column now I want to print the count of those strings
 
9:18 AM
@shad0w_wa1k3r The updated views: dpaste.com/1EP859P
 
If I use this print(count(sheet.cell_value(i, 3)))
NameError: name 'count' is not defined
I am getting this error can anyone help me
 
@Gmanc2 you wanted it ti repeat the task, no? it should print every 30 seconds at most.
 
Its repeating the task every call. It seems to not be waiting
 
what do you mean by "every call"? it's called only once
@G.Lakshmi are you confused why you get the error, or are you asking how to get the count/length of something?
 
@G.Lakshmi It goes without saying that count doesn't exist... what is it you expect that to be doing?
 
9:22 AM
Yes I need count of that
 
The count of what? What does it mean to count a cell?
 
generally, the "size" of a collection is queried using len
 
Whenever the video detects a face it's doing the message.create its not waiting 30 seconds
 
MCVE, please...
 
MCVE?
 
9:24 AM
when I print using print(sheet.cell_value(i, 3)) the o/p will be like this
Chemical Engineering and Materials Science, University of Minnesota
Food Science and Nutrition, University of Minnesota
Food Science and Nutrition, University of Minnesota
Medicinal Chemistry, University of Minnesota
Now I need count of those printing strings
 
user10984358
@Gmanc2 so you have a detect function which when detects a face calls the message function? I guess you placed the snippet miyagi gave in that part
 
@Gmanc2 google it
 
@TheNamesAlc Correct
 
@superv You don't have (or don't define) a contract variable in your else clause, hence you can't see the data in the template.
 
user10984358
if that is the case move the sleep to the detect function
 
9:27 AM
@G.Lakshmi So you've got 2 with 1 and 1 with 2 ?
 
Notice the 2 different return statements. The last return statement only happens if the form validation is invalid or if it's not a POST request.
 
what are you saying @JonClements
 
I put a 50 point bounty on a question, then solved it. The bounty is still going. What do I do? (I know I can't get the bounty back.)
 
Also, it should actually give you a NameError so either your code is not updated or there's something else that's missing.
 
I need count of the strings printing thats it @JonClements
 
9:28 AM
What is the correct stackoverflow way of dealing with this situation?
 
@JonathonPhilipChambers If there's an answer worthy of the bounty, award it. Otherwise just forget about it. Not much else you can do, really.
 
Kevin'd
 
and especially don't give it if there are only bad answers.
@JonathonPhilipChambers wait for a good answer and give the bounty to that
 
Thing is, I know the CORRECT answer now
I want the correct answer known
 
@JonathonPhilipChambers I'd self answer then and accept it so others can find out what worked for you
 
9:31 AM
you'll answer it and accept your answer.
 
@TheNamesAlc The problem is that that function also controls other aspects of the video so I cant have it sleep
 
Okay. What will happen to the bounty though?
 
@G.Lakshmi use a Counter
 
Does it disappear into the ether?
 
@JonathonPhilipChambers yes
 
9:32 AM
@roganjosh how? can you guide me
 
from collections import Counter
Counter(['a', 'b', 'c', 'a'])
--> Counter({'a': 2, 'b': 1, 'c': 1})
 
it does not mean others can't propose a better way within the bounty period
 
@JonathonPhilipChambers I'm not exactly sure how it works, but I think there are some circumstances in which the bounty is automatically awared to the highest-scoring answer
 
Fair point. I guess if someone copied my answer with slight grammatical improvements, they'd be awarded
 
If someone copies your answer they get banned
 
9:33 AM
@JonathonPhilipChambers but if someone else posts an upvoted answer they might get half the bounty automatically. If that doesn't happen the bounty disappears
 
Okay, I'll just answer myself and see what happens
 
And yes, you can flag cheaters for mod attention
 
user10984358
@Gmanc2 where ever you want this function to be called do what Aran-Fey said, see if 30 seconds have passed then call it
 
@roganjosh actually I had wrote a script for getting one column names consisting string "university" and I am printing them linely now I need count of them see this gist.github.com/glakshmi-nyros/c6a8cc1eda6110eb5200198f1ab1961a
 
@shad0w_wa1k3r Thanks for the clarification. I read someone (i cant't remember now) that when you call save() on an object. It should save and return the value of the data. Shouldn't the line 12 from your dpaste code does that?
 
9:36 AM
@G.Lakshmi So you'll need to build a list of cell values, or perhaps the library allows you to take a single column
 
@JonathonPhilipChambers go for that... and then since it's effectively lost to you anyway - let the bounty keep running and if you see something pop up that's better or if nothing else does come along, then you might want to consider seeing if you can award the bounty to Orvar if they ended up pushing you in the right direction as a kind of thank you.
 
I didnt get you what list of cell values @roganjosh
 
@G.Lakshmi This is a spreadsheet, yes?
 
yes excel sheet
 
Ok, so you have these book titles in a column. Does the library allow you to grab all values in a column rather than iterating single cells?
 
9:38 AM
yes it allows
 
Ok, so that gives you your list
Then call Counter() on that list of strings
 
... suppose that depends if there's more than one line in cells for that column...
 
means you are saying Counter(print(sheet.cell_value(i, 3)) )
right?
 
No, because i is an individual row index. That's not a list
 
what library as you using here? Is it xlrd or something else?
 
9:40 AM
xlrd only
 
@shad0w_wa1k3r I got unbounderror when I added the contract variable. I find that strange as it is defined in the if statement
 
Counter is not defined coming @roganjosh
 
It really sounds like you might have an easier time if you're doing stuff like this installing pandas and then just doing a value_counts() on that column
 
@G.Lakshmi if you print something, it "displays" the thing and then returns a None. you can't take the output like that. Also, make sure you're taking a pause and absorbing what's actually happening in the code that you're writing.
 
@superv That variable is only defined if your if statement block gets executed, else it is not defined at all.
 
9:41 AM
@G.Lakshmi any guesses as to why that would be coming? Python is literally communicating with you with error messages, take a pause, and try to understand how it's working.
 
Hi all, for a static method, does it make any difference between using ClassName.staticmtdname() vs self.staticmtdname() or from outside the class using instance.staticmtdname() vs ClassName.staticmtdname()?
 
@JonClements can I do this with pandas
 
Just want to know pythonic way
 
@G.Lakshmi untested:
import xlrd
loc = ("names.xlsx")

wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
sheet.cell_value(0, 3)

from collections import Counter

titles = [str(sheet.cell_value(i, 3)) for i in range(sheet.nrows)
          if 'University' in str(sheet.cell_value(i, 3))]

counts = Counter(titles)
@G.Lakshmi yes you can do this with pandas
 
@variable basic difference is memory allocation in between static and instance
 
9:43 AM
@variable No, the whole point of staticmethod is making those two behave the same way
 
how can I do this with pandas can you help
 
But let's not try doing that when you're saying that Counter is undefined and the import was in the 3 lines of code that I originally posted
 
@shad0w_wa1k3r Thanks. What would be the right way to define it and pass it to the template? I am a bit confused right now :)
 
breakfast time anyway, rbrb for a bit
 
@ShriSamarth how is that?
 
9:44 AM
@roganjosh it is saying every word count in a sentence
I need only one value count of all sentences that are printing
@JonClements how can I do this with pandas
 
Do you have pandas installed?
 
yes installed
 
So you want to use pandas to read your excel workbook... see: pandas.pydata.org/pandas-docs/stable/reference/api/…
 
@superv Please take a look at lines 19 & 24 & maybe you'll understand what i was trying to say - dpaste.com/3BH3XC1
 
9:52 AM
@ShriSamarth where does it say about memory allocation?
 
there will not be any script to use from scratch @JonClements
 
Static Method → Since static methods can access only static variables, memory is allocated only once and that is at the time of class Loading.

Non-Static → These are also known as Instance methods. Memory is allocated every time that method is called for a particular instance of the class.
In non static - Memory is allocated multiple time whenever method is calling.

If any method wants to be execute multiple time that can be declare as non static.

and in static - Memory is allocated only once at the time of class loading.

If any method wants to be execute only once in the program that can be declare as static .
 
Stop worrying about memory allocation of methods, it's irrelevant
 
@ShriSamarth - I am pasting my question again for you to reconsider. I have not asked difference between static and instance methods. FOR A STATIC METHOD, does it make any difference between using ClassName.staticmtdname() vs self.staticmtdname() or from outside the class using instance.staticmtdname() vs ClassName.staticmtdname()?
 
In manual memory management its matter but nowdays almost all complier smart to manage memory automatically
 
10:00 AM
@G.Lakshmi that suggests one of two things to me. Either you aren't building a list of book titles (which my example code does) and are instead calling Counter on individual titles, or you have a spreadsheet that has words separated into multiple columns
 
my column contains strings Department of Chemistry, University of Washington
like this @roganjosh
 
@variable remember when I told you you were asking too many random questions? You've been doing it again for a week. Please go back to not asking.
 
@JonClements we'll see. My upvote was points for effort. It was definitely a push in the wrong direction though.
 
@G.Lakshmi please print(titles[:3]) for me from my example code and show the output
 
['Earth and Environmental Science, University of Minnesota', 'Chemistry, University of Minnesota', 'Civil Engineering, University of Minnesota Duluth']
this output
 
10:09 AM
Ok, that works fine with Counter. It's showing each title counted once and your original post showed duplicate book titles. If that isn't what you want, then you need to be specific on the expected output - what exactly is it that you want to count?
 
@AndrasDeak seriously? I thought this was a good point
 
@variable seriously.
 
@roganjosh I want to get all the strings even with duplicates also
 
@variable yes, self allows to override the staticmethod in inherited classes. ClassName always points to one specific implementation.
 
That's not specific. From that list of 3 items, what should the output look like?
 
10:10 AM
with your code I am getting like this Counter({'Chemistry, University of Minnesota': 70, 'Chemical Engineering and Materials Science, University of Minnesota': 30, 'University of Minnesota': 24}
I need to get 70+30+24= something only
 
len(titles)?
 
@MisterMiyagi nice. thank you
 
But all of this is pointless because you already had that with sheet.nrows. I'm so confused
 
@ShriSamarth that's grossly misleading, to say the least.
Static methods are not restricted to static variables (there is no such thing in Python, anyways) and will allocate memory on every call. Looking up a static method still goes through the descriptor, which will allocate memory.
 
@G.Lakshmi ok. So the point was to filter out strings that don't contain "University". In that case, just len(titles) and get rid of Counter
 
10:15 AM
staticmethods are also not in the slightest related to how often a method is/can be called.
 
Ok @roganjosh Thank you
 
Is it memory efficient to use an instance variable when it needs to be used by multiple methods in the class?
I mean, rather than passing as argument everytime, does instance variable improve performance?
 
premature optimization is the root of all evil.
 
@variable "does ... improve performance" and "is ... memory efficient" are two completely different questions.
 
10:28 AM
Ok I want to write pythonic and efficient code
Performance can be seen later. thanks.
 
@shad0w_wa1k3r When I understood what you were implied at before, I just didn't know the right way to do it. I followed your instruction but I got multipleObjectReturned, so I added pk=pk to the get function but still the contract fields didn't update with the data from the form. From line 12 in your dpaste code, I thought that variable contract refers to the lowercase instance of the model or is that assumption wrong?
 
@variable then it's up to taste and depends on context. I personally would probably rather opt to pass all arguments into the function
as soon as you start having states all over your application it gets hard to test and debug
 
If ever the justification to introduce extra complexity on the readability of code is because it saves one "pointer equivalent" worth of memory, then it's already hopeless. You must not base this particular decision on "efficiency", this is purely in the realm of "readibility"
Personally i also agree with Arne.
 
<3
 
@variable let me remind you that you have been warned before. And I remind you that Andras is Antti in Finnish...
 
10:37 AM
@roganjosh not sure... it's got the isnan there but complicates it by wanting indices instead of a boolean array
 
@JonClements I thought that too, but it encompasses the problem the OP has and then takes it to what I assume to be the natural conclusion
Oh well, there's rep to be had with np.isnan(arr) :P
 
What does super do in python
 
@superv assumption is correct, but what you need to understand is that you need to fetch a corresponding contract instance in order to render / expect it in the template. Or if / when you don't expect the contract object, then handle it accordingly in the template.
 
@Govind75 did you read the manual?
 
I just want to confirm my understanding
Does it allow me to use the class I am inheriting's methods
 
10:43 AM
Yes
 
Okay, cheers
 
@shad0w_wa1k3r Thanks for that. Could it be that the issue if from the template then as i feel I should loop through the model for the object I need? Does that even make sense because I was comparing my code with the SO reference you gave yesterday and I don't see any difference.
 
@Govind75 Hettinger's blog is always worth a read: rhettinger.wordpress.com/2011/05/26/super-considered-super
 
@superv yes, you can loop and get the data you need in the template. Try that.
 
@JonClements I'll read it now :)
 
10:47 AM
@Govind75 among other things.
 
@Govind75 try this - for multiple inheritence, super is cooperative:
class A():
    def __init__(self):
        print('A.__init__')
        super().__init__()
class B():
    def __init__(self):
        print('B.__init__')
        super().__init__()
class C(A, B):
    def __init__(self):
        print('C.__init__')
        super().__init__()

c = C()
 
@AndrasDeak - which rule did I break to get kicked out please?
 
@variable The one where two room owners told you to stop asking random questions
 
Sounds like a new rule then
 
@variable please review my message history aimed at you to remember what you're doing wrong
Repeating myself would be just as noisy.
 
@shad0w_wa1k3r Sorry for the stress. I guess the problem was from my detailview all along as I added .first() in line 42 and 43. I have updated the dpaste link to include the detailview and detail.html where I have looped through the model objects. It is still not displaying the objects in the template. I could see that the objects from the form are saved in the contract model. I just need to display them now. Thanks for your time once again.
 
11:53 AM
have a list of 33,000 names and their institutions/companies (mostly universities). I'd like to collect emails by making queries against university directories. And I need an automated solution by using a script. is it possible?
for example this is an university directory home.www.upenn.edu/directories
 
Sure it's possible, but if you don't know much about web scraping or how websites work then it's gonna be difficult
 

« first day (3419 days earlier)      last day (1529 days later) »