« first day (3692 days earlier)      last day (1248 days later) » 

12:00 AM
That may involve storing the dtype in the grades_type table, too. Thanks for the interesting problem; I'll put some time aside to work on this issue
 
12:10 AM
eh, ignore me, I'm trying to push an old project into the context of redshift now and second-guessing myself. rbrb :)
 
 
2 hours later…
2:15 AM
Is there some ungodly way to get the name of a python argument as a string within the callee, for example def foo(some_specific_variable_name) where the magic would let me get the string some_specific_variable.
I'm trying to DRY up some code with my_wacky_function(some_class,"some_class")
could possibly get ._name...
 
2:35 AM
recbg
the problem with typing is more and more the hideous syntax. How do you specify a callable that takes keywords arguments x, y, and z - well, you wont
should be able to write
 def foo(bar: [int]?, baz: (a: int, /, b: double, *, c: <T>) -> [<T>])
or similar
 
@erotavlas et al, here is my department pairing solution
def pair(d):
    """d = {department_name: employee_count}"""

    n = sum(d.values())
    first_half = []
    answer = []
    items = sorted(d.items(), key=operator.itemgetter(1))
    for i, (name,count) in enumerate(items):
        k = min(count, (n//2)-len(answer))
        answer.extend([name]*k)
        first_half.append(name)
        d[name] -= k
        if len(answer) >= n//2: break

    answer = [answer, []]
    a = answer[1]
    for k in first_half[::-1]:
        if not d[k]: continue
        a.extend([k]*d[k])
definitely has some room for a few minor optimizations in the dict traversal, but this is the basic idea. I modified a sequence matching algorithm (instead of matching two sequences, I went for maximal unmatch)
@roganjosh yup! that's very close to my use case. Thanks for the suggestions - they did point me in some interesting and useful ways
 
 
1 hour later…
3:57 AM
stackoverflow.com/questions/64971740/… high rep users get special treatment?
this could have easily been marked as dupe and downvoted for someone with 100 reps, laurel
 
hammered
 
sorry if that was rude, but my assumption was proven false
 
 
1 hour later…
5:10 AM
hello
 
hello
 
 
3 hours later…
7:56 AM
cbg-ning folks
 
8:07 AM
how goes it?
 
Hello,
c = zlib.decompress(base64.b64decode("H4sIAAAAAAAEACtmyGBIZMhjKAHTALXiaIAOAAAA"), 16 + zlib.MAX_WBITS).decode('utf-8')
output is : shantha
Hw get back "H4sIAAAAAAAEACtmyGBIZMhjKAHTALXiaIAOAAAA" ?
c = zlib.decompress(base64.b64encode("shantha"), 16 + zlib.MAX_WBITS).encode('utf-8')
This line throws - TypeError: a bytes-like object is required, not 'str'
 
note what the .decode('utf-8') is used on.
You might want to run the first code without the .decode('utf-8') to see what it does.
 
Without decode it throws -zlib.error: Error -3 while decompressing data: incorrect header check
 
can you show the line you ran?
 
you want to compress it, not decompress it
 
8:15 AM
c = zlib.decompress(base64.b64decode("H4sIAAAAAAAEACtmyGBIZMhjKAHTALXiaIAOAAAA"))
compress it back and get the same string -"H4sIAAAAAAAEACtmyGBIZMhjKAHTALXiaIAOAAAA"
 
nvm, I misunderstood
 
you removed the second argument, , 16 + zlib.MAX_WBITS that time, im assuming it was important. thats why that errored out
 
@owgitt zlib.decompress(base64.b64decode("H4sIAAAAAAAEACtmyGBIZMhjKAHTALXiaIAOAAAA"), 16 + zlib.MAX_WBITS)
 
@MisterMiyagi This time I got b's\x00h\x00a\x00n\x00t\x00h\x00a\x00'
 
Right, so the innermost action must be something akin to "blablabla".encode('utf-8').
Also take note that the output of your initial code is not shantha. That is what you get by pretty printing. The actual output contains some unprintable characters.
 
8:25 AM
@MisterMiyagi I am not doing any pretty printing here -

c= zlib.decompress(base64.b64decode("H4sIAAAAAAAEACtmyGBIZMhjKAHTALXiaIAOAAAA"), 16 + zlib.MAX_WBITS)
print(c)
It directly outputs "shantha" here.
 
print does pretty printing.
 
printing "hides" the problem here
 
try print(repr(c)), for example
 
I added a draft common question but I'm not sure I'm finding the correct canonicals for this sopython.com/canon/142/file-not-found-with-os-listdir-dir
 
@MisterMiyagi print(repr(c)) this still prints shantha
@MisterMiyagi Sorry. This time it is - s h a n t h a
 
8:30 AM
your repr doesn't show b's\x00h\x00a\x00n\x00t\x00h\x00a\x00' ? Im..perplexed, that doesnt sound right.
 
No. I am using pycharm IDE.
 
@tripleee Your text says os.path.listdir(dir), should it be os.listdir ?
 
@ParitoshSingh yup, thanks for noticing
 
It's a common issue I wrestle with on SO..the question seems wildly different to the dupe/canonical target, but the answer is correct for both questions. As for your selected dupes, only the first one feels off to me. "how can i list contents of directory in python".
Hows this? link
 
the first one is actually the least relevant one; it seems that the UI reorders the links (by date?)
 
8:39 AM
Ah i see
 
@owgitt PyCharm truthfully outputs 's\x00h\x00a\x00n\x00t\x00h\x00a\x00' for me. Either way, if it doesn't for you, consider to use a REPL directly.
 
@ParitoshSingh that's a good one, thanks
 
@MisterMiyagi That output " s h a n t h a" is for this line:
c = zlib.decompress(base64.b64decode("H4sIAAAAAAAEACtmyGBIZMhjKAHTALXiaIAOAAAA"), 16 + zlib.MAX_WBITS).decode('utf-8')
This one -

c= zlib.decompress(base64.b64decode("H4sIAAAAAAAEACtmyGBIZMhjKAHTALXiaIAOAAAA"), 16 + zlib.MAX_WBITS) is resulting in b's\x00h\x00a\x00n\x00t\x00h\x00a\x00'
 
Huh, if you want to dig further into this, you could read up on terminal encodings. If you just want to proceed with the task, I recommend to work with the bytes instad of the str.
 
Hey, How can I get back shantha from this- b's\x00h\x00a\x00n\x00t\x00h\x00a\x00'
 
8:50 AM
by decoding it. b's\x00h\x00a\x00n\x00t\x00h\x00a\x00'.decode('utf-8')
 
@MisterMiyagi Thanks a lot. Tried that! output is - s h a n t h a . why not it just "shantha"
 
That depends on how your terminal reacts to the null bytes. That's the \x00 thingies.
Note: It could be that your initial encoding was UTF-16, not UTF-8. The Null Bytes would be padding in this case. Compare b's\x00h\x00a\x00n\x00t\x00h\x00a\x00'.decode('utf-16')
 
9:42 AM
i am getting an error while running a exe file which was built using pyinstaller, the error is : "ERROR:icu_util.cc(133)] Invalid file descriptor to ICU data received", the modules in my python file are:- cefpython3, platform, json, sys
 
Which challenge site was using the class Solution: pattern anti-pattern?
 
what?
 
There is a challenge site expecting solutions to be written using a class Solution:. A question on the main site is attracting some confusion, because people are wondering about this pattern. I'd like to clear up the confusion.
 
leetcode
 
10:00 AM
thanks
 
not sure learners will take kindly if people are against leetcode, sadly 90% of interview questions are taken as is there
 
I want to iterate over a directory and compare each element with elements from a list, can you give me some suggestions how to do that ?
 
what have you tried so far?
you have already mentioned the two steps you need to do
 
thinking about using zip
 
why zip?
 
10:08 AM
it could be better if you paste input and expected output
 
@Praveen no idea but ICU is what is used for locale support
for filename in os.listdir(directory): if filename in list_of_elements: print('found', directory)
 
@tripleee thanks, did not think of that
 
I guess print('found', filename) actually
 
So weird I just tried to solve a problem the exact same way I tried to solve it last time, but last time it didn't work and now it did. I feel like just giving some time inbetween tries to solve something sometimes helps.
 
Hello there, can somebody help me out pls? codesandbox.io/s/useeffect-forked-3csw7?file=/src/Example.jsx
 
10:21 AM
@Tolima that doesn't look like Python code at all
 
oh sorry i waited 2 days in javascript room but no activity there
 
@Tolima probably work on how you are asking for help then; bursting in and asking people to look at a link is not very good form
explain what you are trying to do and where you are stuck
 
okay i have a text "Hover me" , when i logged in and hover it it changes color as i want, but i want it to lose its onmouseover function after i logout,i tried to removeAttribute("onclick") but no solution
 
@Tolima in the JavaScript room obviously, duh
 
hahh okay :D this is my first experience in chat
 
 
2 hours later…
12:41 PM
How do I know all the exceptions which I need to catch? Currently I have this, and the list keeps expanding and it's quite annoying. I'm thinking about just doing except Exception as e. but that is bad form as I heard, but having to add the new exception every time a new one pops up is also super annoying, also why does requests throw so many different exceptions, that's so annoying, it would be nice if it just threw, didn't work. That's it.
try:
	request.get(url)
except (ConnectionRefusedError, requests.exceptions.ConnectTimeout, requests.exceptions.ConnectionError, json.decoder.JSONDecodeError) as e:
	log.exception(e)
	do_more_stuff()
latest addition was ConnectionRefusedError
 
why not just catch Exception?
 
I thought it's an antipattern, but I'm thinking of doing that
I kinda miss Javas throws function annotation, that was kinda neat
 
If you have a look at requests.readthedocs.io/en/master/_modules/requests/exceptions - you can work out the hierarchy - looks like you might want the generic RequestException ?
 
Bare except: is an anti-pattern. Catching Exception is fine for retrying and such.
 
@MisterMiyagi I see
@JonClements Thanks for that, but how come ConnectionRefusedError is not in there?
 
12:47 PM
'cos it's a builtin exception - not a requests one...
 
I mean I get that, but unfortunate they didn't just include it in their list
 
I s'spose it depends on how requests catches/re-throws stuff... it looks like you should only really want requests.exceptions.ConnectionError depending what requests catches
not sure how your example code could ever product a json.decoder.JSONDecodeError though...
or requests.exceptions.ConnectTimeout unless you're specifying a timeout as I think the default value for that is None
 
1:15 PM
I have no problem catching Exception as long as I re-raise it afterwards
 
@JonClements ah yeah, sry I had a timeout specified and a json decode of the response. But I think I will go with catching Exception
 
1:42 PM
morning cabbages, folks
 
hey doc :)
 
long time puppy. Potato?
 
2:26 PM
@Hakaishin It's only an anti-pattern in so far as if you then handle the exception carelessly you might mask real exceptions in your code that reveal (e.g.) a bug in your algorithm. If you (e.g.) want to catch and report on each exception that occurs in the body of a loop then what else could you use?
 
2:46 PM
@inspectorG4dget same old thanks :)
 
@annyeongkre please don't ask for help with fresh questions on the main site as per our rules
 
I recently found a string of xfactor auditions by a candidate with poor performance evaluations, that happens to share my name. My morning has been... interesting
 
How to render image in rectangle in Pygame?
 
:(
soon we'll reach "how to import Pygame?"
@annyeongkre that question sounds like something you can put in google
 
3:00 PM
And it even yields a hit on stackoverflow main...
 
I used to gidf ppl, but now I'm too lazy for that
 
In fact, there's a question on the main page right now asking the same thing... ;-)
 
@Hakaishin what's gidf?
"google it, dude-friend"?
 
Lol, this is getting meta: cse.google.de/…
 
3:05 PM
man, sometimes in homeoffice I forgot I'm logged into the pc at work and actually on the company network and I want to google non work related things, but luckily I just remembered :P
 
user14463336
3:28 PM
hi
 
3:56 PM
anyone set up pycharm for remote interpreters over SSH before? I could use a hand setting it up
my local files aren't going where they're supposed to (on the remote server) and execution is suffering as a result
@Mikhail yes there is (a very ungodly way) to do this. I did something similar in pystitia
 
@inspectorG4dget what you mean not going where you want? Is there a problem of them going to the default tmp folder?
 
@Hakaishin I have a project space set up on the remote server and I'd like my files to go from localhost:workspace/project_name/ to server:workspace/project_name/
 
why? what's wrong with tmp?
I've been just using the default settings just fine
 
I guess I have an XY problem. Hang on
yup. I had to futz around with the permissions for a bit FML
 
4:17 PM
I love how some projects have bigger planning horizons than whole countries: The SQLite project was started on 2000-05-09. The future is always hard to predict, but the intent of the developers is to support SQLite through the year 2050. Design decisions are made with that objective in mind
 
yowza!
 
"The primary developers of SQLite live in different regions of the world. SQLite can survive a continental catastrophe". Tsk tsk, only planning for a continental catastrophe in this, the year of the global catastrophe
We need at least one SQLite developer living at the bottom of a salt mine, and one on the ISS, and one on a deep sea floor research base
 
and one on the moon and mars :D
 
Do we have a dupe for "user doesn't know what 1.2e-3 means"?
^ stackoverflow.com/questions/64990596/… unclear or no MCVE or very confused
 
4:39 PM
Lately I've been playing a game where the objective is to earn an astronomical amount of points. At one point I ticked over from 9.99e999,999,999 points into 1.0e1.0e9 points.
 
idle game?
 
Yeah :-)
I'm curious what data type they're using to hold the number, since floats run out at around 1.7e308 or so
 
Ordinal Markup?
 
hmm, that page is broken for me
 
4:43 PM
works for me
 
@Kevin interestingly, that name is almost the same as an Ordinal Markup thing
 
Looks like the really really big number type is Decimal, defined at break_eternity.js:194. The layer attribute leads me to believe that the number is stored as a sequence of <number>e<number>e<number> chains, just the way they're printed
Around 1e1e9, it executes code containing the comment //don't even pretend mantissa is meaningful. I'm glad they're honest about the precision of their type :-)
1.001e1e9 is pretty much equal to 1.999e1e9 when it comes to the kinds of things they're trying to do with those values
 
5:04 PM
A while back I tried Ordinal Markup for about fifteen minutes, but I couldn't figure out how to make meaningful progress
For better or worse, incrementreeverse is pretty linear, so that hasn't been much of a problem. Except for the Bosons layer, where you have to guess which Challenge you'll be able to finish with your current resources, and if you're wrong, you waste up to five minutes of your time
Boy I really hate bosons
Give me neutrinos any day, you have nine buttons and you can click them in whatever order you want. The nice colors appear and the number goes up and my one serotonin molecule activates its turbo drive
 
5:45 PM
I asked Will McGugan to join the chat - he is doing some cool things with his new rich module.
He didn't know this chat existed
 
Color and styling, tables with box drawing characters, progress bars... Nice stuff.
Alas, the blink style doesn't work on my console :-(
 
Wrong OS?
 
Most likely yeah
 
:(
Is powershell a different entity than the cmd shell, or does the former live inside the latter?
I mean, is it possible that it would work on one but not the other?
 
@PaulMcG I didn't know that project existed... it's got quite a range of stuff there... definitely going to have to play with that later :)
 
5:56 PM
You can open powershell within cmd and it doesn't spawn a new window, so they must share at least some underlying structure.
 
I've integrated it with littletable to make nice tabular output easy using the Table.present() method.
 
Powershell also refuses to blink so I'm guessing it's a limitation of the windows console API
It would be easy enough to blank out and overwrite a region of the console in an infinite loop, but I imagine things get quite hairy when you need to account for the scroll window and such
Windows Console styles appear to be quuite limited compared to ANSI SGR
We basically just get eight colors and bold and underline
 
6:16 PM
meh... 8 colours and text styling is overkill... one doesn't need anything more than green on black...
 
Declaring variables with types that are obvious from the usage is getting tiresome (C# gig). list_of_parts = new List<Part>(); Forgot to declare the variable as List<Part>! No, you forgot to infer the type, C# compiler!
Maybe I'll write a pre-processor to do all these obvious type inferences for me, and I'll call it C#++.
 
@Will - welcome!
 
The new Windows terminal has much better support for colour and style. Alas no blink though.
 
Hello :)
 
👋
 
7:08 PM
Well I did it after all - added text search to littletable. 200 lines of added code and some class refactoring, 120 lines of added unit tests. Search only works for words, not phrases, but prefix flags like '+', '-', '++' and '--' are supported. (My demo searches IMDB descriptions of Star Trek:TOS episodes like "++spock --kirk" to find those eps where Spock was the focal character.)
To @roganjosh's question earlier, no I don't know where this is all headed, or why.
Not uploaded to pypi yet, just pushed to github.
I guess I missed the implications of the TravisCI free vs. pay tier changes, but man it is dog slow getting my tests to run now!
 
numpy's account ran out of travis credits a few days ago
 
Actually, I had a perfect use-case for your talents today. I have a database of over 20K unique customer names but many are in the form of "Company & X - (Manchester)" and "Company and X - (Birmingham)". They are the same company, but the data contains no decent aggregator fields. It's totally out of my domain and I just don't have time to faff with learning fuzzy string matching (or whatever) because I have to deliver something by Friday
This means I have no logical thing to groupby on with a pandas df. If you could approach groupby in an approach that could handle my problem in a way that I don't need to fully understand how string matches work, but could sense-check strong matches, I'd have installed the library immediately
As it happens, I managed to botch something where I could identify 11 parent companies and filter them out into distinct groups by just taking the first "word" of their name and ignoring case. It's "good enough" for me for now, but there's hundreds of distinct companies in that pool of 20K names
Sorry, my second comment was a bit of a word salad because I've just shifted out of a Java problem I'm working on when I heard the ping :P
^ side note, I'm sick of reading guides that open with "we'll start with a simple example" when all I want to do is requests.get(<url_string_here>) and the example is 50 lines :(
 
7:23 PM
I just did a blog post on fuzzy groupby, but it is for the itertools method, not pandas DataFrame.
I also did something similar a few weeks ago while doing some littletable dabbling, scanning owner names of FCC broadcast licenses by US state. Many of these listings have variants like "ABC Corp", "ABC Corp.", "ABC CORP", and "ABC Corporation". I'm pretty sure this kind of data scrubbing is a pervasive problem in any ML work.
 
So sure it's an issue and never one that can be properly pre-empted
I can always do case-insensitive matches and get rid of the &/and problem et al. but it sucks as an approach
If I could have pulled out 50 distinct parent companies of branches from a list of (let's say) 500, it would have been much better than the 11 I can take forwards with confidence that the search terms are not pulling in noise
 
@roganjosh That's pretty much what I resorted to.
 
7:39 PM
@PaulMcG you have a blog?
 
^. I just clicked your link on your SO profile but it took me to something else
 
hi guys I was trying to do a problem on leetcode but I'm not familari with this function definition syntax

# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
I'm assuming that l1 and l2 are ListNode parameters?
 
@erotavlas arguments of ListNode type, pinky-swear
 
but I never seen the -> used after the function declaration
is that return type?
 
@erotavlas yes, also pinky-swear
 
7:50 PM
I pinky swear thats the first time I've seen a python function explicitly indicate a return type, is this normal?
 
As of 3.5, yes
scratch that, 3.0
 
ok
 
that's partly what people mean when they talk about typing
 
@erotavlas: I'm somewhat curious about that Yelp problem you posted yesterday. Any updates on that front?
 
@inspectorG4dget no I haven't had a chance to work on a solution, but I think @Kevin wrote something and posted it
 
7:56 PM
Did I mention we're hiring? Nothing in Python right now, but C# is required ... careers.labster.com/jobs
 
@inspectorG4dget pastebin.com/UaPPnjcN
 
@erotavlas yup. I was just curious what the correct solution was and how your friend did
 
oh yeah
 
@holdenweb I am disqualified from that position by my need for glasses
 
8:00 PM
my need for glasses would indicate that I don't see sharp C#
 
i've been resisting getting glasses, I'm squinting all day long
 
Contact lenses all the way (deliberately ignores all the "sub-optimal" moments)
 
i'm afraid my eyes will deteriorate further if I use glasses/contacts
because then the eye muscles will slowly degrade, and the lens will slowly fix into another shape and then there is no way back
 
Sure. Straining the eyes to focus on things that you can't properly see is a well-known way to keep your eyes in shape
 
thankfully, my prescription is for distance vision and is pretty minor. So I don't always need to wear my glasses and they're not critical for computer work. There are times when I do need them though, and they really save the day then
 
8:07 PM
there's supposed to be exercises you can do for your eyes that will help but I've been too lazy to do them
 
8:22 PM
Sorry guys, I nodded off (up around 4:30 this morning with the pup and couldn't go back to sleep).
My blog post is here thingspython.wordpress.com/2020/10/30/… (fuzzy groupby is in part II)
 
thanks
 
hello
 
is it me you're looking for?
 
I want to get the enerjy consumption of a cloud using an algorithm ACO in python
can you help and guide me??
 
Where are you at in solving the problem, and what do you want help on?
It's way too broad to guide you through the whole project. You need to be more specific on the problems you face
 
8:31 PM
welcome to the python chatroom. If you have a specific question that can go on stackoverflow.com, it's best to post there to get more eyes on it (and wait at least a few days before posting it here). If you have a much less specific question, please feel free to ask it here, and anyone who knows will probably speak up
 
thanks A similar example or site that explains how to do it
What is the objective function like?
 
Ant Colony Optimisation is not really my thing. I suspect you will get decent search results if you googled "Ant colony optimisation python networks" or something similar
 
cabbage, @will
Long time no see!
 
I really don't understand what "it" is. I understand ACO (I assume you mean Ant Colony Optimization), which is often used in searching a subset/permutation space. As such, I'm not sure how it applies to power consumption in a cloud. That part really confuses me
 
Energy consumptionØŸ Execution time ØŸThroughputØŸ
 
8:35 PM
@holdenweb 👋
 
How do you know the energy consumption of the servers processing your requests?
 
in cloud computing energy consumption
 
without knowing anything else, all I can say is this: these metaheuristic algorithms are used to maximize or minimize objective functions that correlate with some real-world goal. So as long as your objective function correlates with what you're trying to optimize for, you should be good
 
Here's a thing I wanted to solicit feedback on.
I've added an interesting feature to my Rich library which captures output from the shell and converts it to HTML. Was wondering if anyone could think of any practical use for...
 
@Salio I imagine execution time is measured by the wallclock and not the CPU. How is throughput measured?
 
8:38 PM
Try this:

python -m rich.ansi $SHELL

Use your shell, open Python etc. Then Ctrl+D

Now open "stdout.html" for an HTML record of your shell session.
 
@WillMcGugan blogging my code
 
I do not know exactly but I think simulation
this article:Energy-aware workflow scheduling and optimization in clouds using
bat algorithm
how do it?
 
Hey @Salio, I don't think we're going to be able to help you given where you're currently at. Be sure to check out our guidelines: sopython.com/chatroom for when and how to ask questions here.
 
my last two cents' worth: that's a bt algorithm, not an ACO. And wikipedia says that the author released a MATLAB/Octave demo, which you should therefore be able to piggyback off of
 
@WillMcGugan I'm working on a little blogging system: It might be useful there ...
 
8:43 PM
cbg
 
@holdenweb I was thinking that. Better than screenshots.
 
Just did my first sprint demo: drive.google.com/drive/my-drive
 
@inspectorG4dge this article use 4 algorithm
ACO and BAT and RANDOM ..
 
@holdenweb actually, if you could add a commandline switch to create screenshots... I know some teachers like to post their example code as screenshots to force students to not copy/paste
 
I'll add that as a feature request, but it will be fairly low priority.
 
8:48 PM
@holdenweb oops! I think someone posted a message just as I was clicking on the reply button. That message was actually meant for @will XD
but also, potato? It's been a non-auto-incrementing loop while
 
@holdenweb that link just resolves to my own GoogleDrive btw
Actually, not even "resolves". It is a link to a personal drive :P
 
It's not public. I need to request access
 
@inspectorG4dget It seemed like a reasonable request for a teacher who wanted to publish code for students, so ... github.com/holdenweb/as_blog/issues/7
 
@holdenweb I fully second that
 
8:55 PM
Bummer, it was sup[posed to be "anyone with the link". Please hold.
 
ultra power feature: it captures the graphic as if it were on the IDE of choice (choosable through a cmdline switch)
 
Permissions fixed.
 
quick question, im trying to make a large single form file into a module. My first step was that I created an nlp_module folder and an __init__.py and place the file nlp_module.py into it. For now this module folder is sitting in the same directory as the nlp_module folder use to which also contains a script that imports nlp_module. When I try to import nlp_module I get errors (I'll write em out next post). Do you have to install a local module to be able to import
 
@holdenweb I didn't quite understand what you were saying right at the end there
 
structure:
nlp_module
   __init__.py`
   nlp_module.py
 
9:00 PM
Oh, dear, I didn't realise the sweary bit was still in there. Erp, I hope I haven't published a rehearsal!
 
Sorry guys, deleted: going to have to re-record this. :-(
 
__init__.py file content:

__version__='0.0.0'

import nlp_module
nlp_module for now has all the content of the original script, basically a bunch of functions atm
I get the error in my stacktrace on import npl_module:
ModuleNotFoundError: No module named 'nlp_module'
 
@holdenweb lol, I liked it, if that's any consolation :P
Demos are much more fun that way!
 
You will import nlp_module.py with import nlp_module.nlp_module. What you would need to do what you say in __init_.py would be from .nlp_module import * or something like it. You want the symbols from nlp_module.py in the namespace of the nlp_module package.
 
9:07 PM
@holdenweb I missed a bugrit? :( :P
 
so if my project is currently organized like:
root
    project
        script.py (calls nlp_module)
        nlp_module
 
@roganjosh Seconded. I like the way Zoz swears in this talk
 
should script.py be able to import nlp_module just like import nlp_module
trying that and trying import project.nlp_module both failed with the error I gave above
 
@AndrasDeak 7, to be precise :P
 
@Skyler try `from .nlp_module import nlp_module`
what does the structure of `nlp_module` look like? Is that a dir?
 
9:13 PM
what I posted above:
nlp_module
   __init__.py
   nlp_module.py
 
i guess overall it would look like:
 
import .nlp_module.nlp_module
 
root
    project
        script.py (calls nlp_module)
        nlp_module
            __init__.py
            nlp_module.py
ok ill try that now
 
@sadmicrowave Relative imports don't work outside packages.
 
9:16 PM
and that should be in the __init__.py or in the script
 
So you'd need root/project/__init__.py as well.
 
@holdenweb but if I do that in the __init__.py it should work since that's part of the package right
 
None of this is anything you couldn't try. Could we start seeing questions like "why doesn't X do Y", please? To much stabbing around tends to irritate me.
 
yea, once I tried that i got something funky where it looked like it was installing
there are some nltk stuff in the package and it checks to see if it needs to install a package and gives a message back
those passed, but then it somehow said cant import name nlp_module
and gave an ImportError this time
 
Sorry, these descriptions don't contain actionable information. What are you looking to find out?
 
9:28 PM
a bit more context: module calls made in the script act kind of stupid because I have to do this work in a cloudera workbench which is kinda like a Spyder instance. I think line of code in the script file itself gets executed as though its sitting in root.
it seems like doing import project.nlp_module is finding the nlp_module.py file
but that I can't seem to get it to import through the init.py (that is what is throwing the error)
EDIT: I think each line of code in the script file [...]
(which is what im trying to figure out, since the goal is to break this one py file into many parts)
 
9:44 PM
What is a "Spyder instance"?
 
i think cloudera is like Spyder
(Spyder IDE)
 
I know from past issues myself that Spyder can resolve imports in a way that is totally broken when you move outside of Spyder. A certain person helped me figure that out, but it was a major release back so I'm not even sure if those wonky mechanics still exist
 
yea, when I've gotten to work a bit more on solo projects I've done most of my refactoring work in another environment but always had imports break if i had to come back to cloudera. Sounds like the same problem
 
Just tested in Spyder 4 - still a thing:
May 26 at 19:58, by roganjosh
Feb 21 '18 at 20:50, by roganjosh
I found something unusual with Spyder/iPython yesterday through using logging that I now need to look up. Within Spyder, it's perfectly ok to have logger = logging.handlers.RotatingFileHandler (it even auto-completes for me) but running python my_script.py with exactly the same version of Python will fail; it only accepts from logging.handlers import RotatingFileHandler. Any ideas what Spyder/iPython is doing here in the broader sense?
I probably can't help you with your specific problem, but maybe that helps others understand the issue (if, indeed, it is a similar thing)
 
I understand the issue... :P
 
9:53 PM
Well you would, because you were the "certain person" :P I just didn't want to drag you in directly
 
Just to be clear, I mean that the issue is spyder
 
It's just a bit funky and out-there. Let your hair down!
 
@Skyler I'd recommend you study exactly how the proper Python import mechanism works. then you'll stand some chance of understanding the differences on cloudera (whatever they may be).
 
In particular the issue I remember was that import scipy would automatically import scipy.optimize etc. which is actually a subpackage that needs a specific import. But that sounds different from Skyler's issue: developing in a proper environment should still work in spyder (barring other bugs)
 
I'm not the person to help with imports, but they mentioned Spyder and that's one concrete example where I know that Spyder's imports won't work outside of a "Spyder instance" (if I interpret that phrase correctly). In which case, have you tried this, @Skyler?
Specifically:
import logging
logger = logging.handlers.RotatingFileHandler('something')
^ Broken outside of Spyder
 
10:01 PM
that line of code works
or at least doesnt throw any errors
 
oh, now I see the message you quoted explains this exactly. I just phased out when I saw loggers being mentioned.
 
in the cloudera workbench
 
nvm, I'm going to make a post - just a min
sorry that did a hatchet job on my formatting
 
@sadmicrowave formatting in chat sucks. We have a guide
If you want block code formatting, though, you'll need to post that as a separate post than the stuff you want as normal text
After having a "where'd that just go?!" moment, and then finding you reduced it to "nvm, I'm going to make a post - just a min" - it is perhaps better that you ask that on the main site, but we have rules about bringing questions from main into chat - specifically that you should wait 48 hours
 
10:28 PM
@Skyler I haven't used cloudera but searching "cloudera ipython" gives the first result summary of "Cloudera does not support IPython or Jupyter notebooks on CDH". I think I'm ill-equipped to help with this one, sorry. I suspect it takes some domain knowledge about how it's resolving that import
 
@roganjosh thanks I realized how much it was when I pasted it - definitely enough for a post on its own
 
You missed the point I made about the room rules :(
 
the 48 hour part - got it
 
Yet you posted it here
 
yep, mistake after reading through it - thanks for the input
 
10:34 PM
No worries - I feel a bit nasty for moving that message but it really does lead to duplicate convos if we don't focus the efforts on your question as comments on the main site. Apologies for moving it :/
 
no prob at all
rules is rules
 
11:06 PM
Am I misreading this comment trail or should I flag?
Actually, I don't know what I'd flag for. Ignore me. Rbrb.
 

« first day (3692 days earlier)      last day (1248 days later) »