« first day (4062 days earlier)      last day (869 days later) » 

6:38 AM
cbg folks
 
6:57 AM
cbg
@ParitoshSingh btw, I ended up using pynput instead :) (for the question i asked like three days or so ago)
work better than I thought it would
 
7:14 AM
cbg guys
 
 
1 hour later…
8:27 AM
Trying to wrap my head around heapq again....
The docs say "heap.sort() maintains the heap invariant" – does that mean that e.g heap[1] is the second smallest item? That doesn't seem sensible to me with all the effort of heapifying.
 
No. heap[0] is the largest item, but other than that you can't easily draw any conclusions based on index. The list represents a tree like this.
Actually, heap[0] might be the smallest item. Dunno if heapq is a min-heap or a max-heap
 
so yeah, heap invariant simply implies the parent child relation, it doesn't force an order amongst children of the same level. just order in the hierarchy between different levels
 
8:42 AM
So, does that quote from the docs make sense to you? It's there for 15 years now according to git.
 
Makes sense to me, but all its presence achieves is that it makes me mad at the terrible design of the module. Something like that should be an implementation detail hidden inside a Heap class. Nobody cares.
 
lemme see docs..
 
I'm wondering whether heapq just more efficiently maintains the sort because it doesn't have to deal with arbitrary data.
 
I dont see why it needs the excalamation mark, but otherwise it seems fine to me.
if someone knows and cares what heap invariant is, this is relevant to them. If someone doesnt know, its just some random jargon
 
8:59 AM
Ah, should have read everything. The heap invariant is a weaker constraint than a proper sort, so sort implies heap but not the other way around.
 
yes. did docs mention this?
i didnt see it if they did
 
No, but your linked Q&A had something to that effect.
So a heap can be [0, 1, 2] and [0, 2, 1] but a sort can only be the former.
 
9:19 AM
so, I'm using argparse on 3.8, and it seems like I can't print_help() (looked into the docs and it should work normally...). Here my code
Traceback (most recent call last):
  File "pip-bundle", line 136, in <module>
    main()
  File "pip-bundle", line 53, in main
    args.print_help()
AttributeError: 'Namespace' object has no attribute 'print_help'
the error I get ^
 
Pretty sure it's parser.print_help()
 
@Aran-Fey yeah, but it's defined in the parser_args function. Do you think I should return only parser instead of parser.args or merge the main function with the parser_args function? (so that I can easily access both print_help and the args I already set)
I tried to just return parser but then the subcommand I used wouldn't work
 
Yeah, turn the parse_args function into a create_parser function
Alternative solution: Throw argparse in the bin and use typer
 
The FastAPI stack strikes again!
I've been pretty happy with click as an alternative to argparse.
But usually I just stick with argparse and try to keep things simple.
 
I didn't even know click or typer. I wouldn't mind using those since (based on the docs and review) it looks pretty good and easier to use, but, the main goal I have for this current project is to have a single file script, without third party deps/reqs (beside pip, but I'll add support for no pip setup too I guess)
oh, the woes of only depending on local python packages
 
9:34 AM
argparse should be fine for that.
 
@Aran-Fey Thanks, I'll try this :)
 
argparse is fine, typer seems nice, besides that it relies on typing clown emoji
 
🤡
 
@MisterMiyagi yeah, and it works fine for me, but got to tinker to make print_help work with my current code (I'm not lazy!) instead of reworking the whole thing
here it would be nice to just have a single function return an object that has both print_help and support for the subcommand stuff
or I'm I obliged to use a class? (I don't mind but more typing...)
 
Wondering what problem you had getting the help to work. Usually it's there out of the box via the -h flag.
 
9:36 AM
yeah, I wondered too myself. I vaguely recall using it on an old project but for some arcane reason, this doesn't work on 3.8 on this specific code
 
@NordineLotfi That's a bad idea. args is an object that tells you what the user wants from you. It's not an object that's responsible for doing anything.
 
I don't think I've ever explicitly called print_help outside of testing poking around in argparse's internals.
 
@Aran-Fey I see :o
@MisterMiyagi yeah, but wouldn't you do this if you wanted to print "help" when eg: no args are submitted or something?
(this is some of my use case here)
 
argparse should already do that for you.
 
9:39 AM
If a required parameter is missing, argparse should directly inform about it and exit.
 
@Hakaishin argh, I did!
 
mvce or bust :D
 
@MisterMiyagi code (posted it earlier)
error:
Traceback (most recent call last):
  File "pip-bundle", line 136, in <module>
    main()
  File "pip-bundle", line 48, in main
    if args.subcommand == "create":
AttributeError: 'ArgumentParserWithDefaults' object has no attribute 'subcommand'
@Hakaishin does that count as one? :P
 
it's missing c :D
 
by c, you mean "complete"?
 
9:45 AM
yes
pretty sure the errors stems from the part you are leaving out
 
I think it is? the question is basically "why is print_help not working"
no, I didn't leave anything out...this is my full code
also using 3.8
 
@NordineLotfi Use required=True for the subparsers.
 
@NordineLotfi sry my bad, I missed the link
 
@MisterMiyagi Alright, works! Thanks :)
@Hakaishin no worries
btw, anyone know any decent python script/module for formatting code's tab/space? (I can use sed but it doesn't handle every corner case, like full blown editor would...)
saw one called reindent but this was mostly for tab to space instead of (my aim) space to tab
 
How about using a full blown editor? :P
 
9:53 AM
ah, I knew someone would say that :D
 
@NordineLotfi history is written by the winners, even if it's wrong. I agree with you that tabs would make more sense, but every major player decided that it's spaces. So I would not try to go down the tabs route
 
@MisterMiyagi I don't mind but, this would be useful when working on server and stuff that don't have GUI/Screen
 
@NordineLotfi pycharms remote host tab is very useful for that
 
@Hakaishin I don't want to do the "tab vs space" args (no pun intended) here honestly. just was curious of any existing solution since I already know of one, although it handle the reverse of what I want
@Hakaishin yeah but, I don't always use pycharm...(I hop editor a lot, for some reasons)
 
@NordineLotfi just a cautionary warning :)
 
9:55 AM
I guess I'll end up doing it myself if no contender appear hmm
yeah, that's fair
 
10:06 AM
"Python does not support 'yield from' inside async function" They promised me hoverboards and jetpacks... 😭
 
10:30 AM
I had a similar reaction when I learned that you can't convert any if/for/while block to a list/dict/tuple expression :/
 
i dont get that actually
 
11:04 AM
@NordineLotfi everyone reading your code dodged a bullet
 
@AndrasDeak what do you mean by that?
 
the cases where you're sorry you can't cram more into a comprehension are ones that are probably best left in a full loop for readability
 
oh. Yeah you're right, and I do agree with you. I just voiced that it was disappointing that using expression had limitation compared to normal loop/if block
 
Cbg all
 
11:52 AM
cbg
 
cbg
 
12:13 PM
cbg
 
user15071942
12:42 PM
How can I post code here?
 
You just did, didn't you?
 
@Roman Try reading this
 
user15071942
It was too messy the code :/, gonna read thanks
 
user15071942
Im trying to reduce this code, the for loops are very similar
 
user15071942
if not (cell_values[cell] in ["?", 0]):
            for index in neighbours_position:
                neighbour = (cell_digits[0] + index[0], cell_digits[1] + index[1])
                if (0 <= cell_digits[0] + index[0] < height) and (0 <= cell_digits[1] + index[1] < width) and cell_values[neighbour] == "?":
                    neighbours.append(neighbour)
        elif cell_values[cell] == "?":
            for index in neighbours_position:
                neighbour = (cell_digits[0] + index[0], cell_digits[1] + index[1])
 
user15071942
12:47 PM
Ok, the elif is referred to the first one, sorry about that
 
user15071942
Basically my cell can have a integer different from 0, 0 or ?
I just want neighbours for ? and ints !=0
 
user15071942
but the neighbours for cell with int !=0 have one more restriction
 
You could pull the cell_values[cell] == "?" check into the loop.
That'll be slightly less performant, but I doubt that code is performant to begin with.
 
user15071942
I thought it too, the performance was ok, But i coudn't figure out anything to remove these ueseless checks and these repeated code simultanesouly
 
if cell_values[cell] != 0:
    for index in neighbours_position:
        neighbour = (cell_digits[0] + index[0], cell_digits[1] + index[1])
        if (0 <= cell_digits[0] + index[0] < height) and (0 <= cell_digits[1] + index[1] < width) and (cell_values[cell] == "?" or cell_values[neighbour] == "?"):
            neighbours.append(neighbour)
This should be equivalent, give or take a typo.
 
1:20 PM
That code would benefit from some readability improvements. Something like replacing (0 <= cell_digits[0] + index[0] < height) and (0 <= cell_digits[1] + index[1] < width) with is_in_range(neighbor)
 
lis = [1, 3, 5, 6, 2, ]
is it a valid list initialization ??
what is the difference?
lis = [1, 3, 5, 6, 2, ]
lis = [1, 3, 5, 6, 2]
 
trailing comma
python can happily ignore them, so yes, both valid
 
Trailing commas are allowed so that you can do
lis = [
    'foo',
    'bar',
    'baz',
]
 
^ its a life saver
 
The specification is a bit arcane, but the optional trailing comma is documented at docs.python.org/3/reference/expressions.html#expression-lists. It doesn't do anything.
This also means that f(a,b,) is valid, as well as {a:b,}
 
1:33 PM
so I can use either one, and there is no significant difference?
 
A trailing comma sneakily consumes 1 byte of storage, slowly nibbling away all the knowledge of humanity...
 
:o
but think of all the bytes saved in diffs
 
There is no significant difference.
 
That's what they want you to think.,
 
I see what you did there
 
1:35 PM
You can use the dis module to disassemble the list literal and see that the byte code it generates is 100% identical in both cases
>>> import dis
>>> dis.dis("[1,2,3]")
  1           0 LOAD_CONST               0 (1)
              2 LOAD_CONST               1 (2)
              4 LOAD_CONST               2 (3)
              6 BUILD_LIST               3
              8 RETURN_VALUE
>>> dis.dis("[1,2,3,]")
  1           0 LOAD_CONST               0 (1)
              2 LOAD_CONST               1 (2)
              4 LOAD_CONST               2 (3)
              6 BUILD_LIST               3
              8 RETURN_VALUE
 
@Kevin btw, offtopic but, you don't mind If i send one or two email about python to you? (not for asking for help but mostly about advice/etc on something you would relate to, given you use windows + python) + asking here would need me to type a lot more than the RO would want me to or I guess I could just use a gist and link it to you here.
 
I will be happy to read a gist. Email can be Plan B.
 
alright, gist is fine with me too :)
 
Aran-Fey has identified the most typical use-case for trailing commas: when creating multi-line lists, it's useful to allow the final value to have a comma too. If you add new elements to the list later, you are less likely to make a concatenation typo, diff tools will produce cleaner-looking reports about what lines changed, and the code just looks nicer (IMO)
And by "concatenation typo" I mean mistakes like:
>>> foo = [
... "a",
... "b"
... "c"
... ]
>>> foo
['a', 'bc']
 
Why is that even a feature?
 
1:42 PM
Comes in handy when mixing r and f strings with regular ones.
 
fr'eal'
 
Just add a +?
 
There goes another two bytes...,
'{'f'{a}''}'
 
My random guess is that intentional string concatenation was the easiest way to make multiline string constants before triple-quoted strings were introduced. But I don't know if that's true, because I don't know if string concatenation actually preceded triple quoted strings
 
Alright, the + might have an advantage...
 
1:46 PM
I also use & recommend automatic literal string concatenation. :)
@Kevin I have vague memories that's correct. In any case, the auto-concatenation is a very early feature, almost certainly coded by Guido himself. OTOH, triple-quoted strings are a pretty old feature, too.
 
In my pre-Python days I recall using "+" and line continuations a lot in order to put HTML boilerplate together. It was likely either Perl or PHP.
I knew PHP was janky while I was using it, but it didn't make much difference because I produced only janky code regardless of language
It is written: a bad carpenter can build an ugly house using either a hammer or a shoe
 
user15071942
@MisterMiyagi Great, thanks
 
Incidentally, JSON does not permit trailing commas, although some browsers ignore them. stackoverflow.com/q/201782/4014959 Of course, that's only an issue if you're creating JSON by hand, rather than using the json module. But I guess it might also come up if you're subclassing JSONEncoder
 
@PM2Ring wait, it doesn't? truly, I vaguely recall seeing some python code on gist.github that had a couple trailing comma, and was also using the json module (tried it and it work If i recall right)
 
Let's see...
>>> import json
>>> json.loads("[1,2,3]")
[1, 2, 3]
>>> json.loads("[1,2,3,]")
Traceback (most recent call last):
<snip>
json.decoder.JSONDecodeError: Expecting value: line 1 column 8 (char 7)
 
1:56 PM
hmm, intriguing
 
It's fine to define e.g. a dict with trailing comma and encode that to JSON. The trailing comma only exists for the Python parser, it is not part of the actual dict that is encoded by JSON.
 
that would make more sense if that was what I saw back then, yeah
 
@NordineLotfi Truly. But if you have a Python dict literal with trailing commas, and convert it with json.dump, the trailing commas are irrelevant, because the Python interpreter will eat them, they won't exist in the actual Python dict object.
 
The json module does not guarantee 100% adherence to the JSON specification, so perhaps it could understand trailing commas if it wished, but there isn't much user demand for it
 
@PM2Ring I see. That make sense yeah :) guess I didn't saw it was using a dict or such thing
 
2:01 PM
The craziest "feature" of JSON is that it permits an object to have duplicate keys. There are a few ways of dealing with that in Python, but they're not fun.
 
I don't think json.org mentions any restrictions on name uniqueness, but docs.python.org/3/library/… implies that the formal RFC does discuss the topic
 
There's always JSON5.
 
@Kevin the usual, punch the source advice applies
 
I'm confused by that opening sentence in the Python docs, because the "but" doesn't seem to actually indicate a contradiction or anything. It's like saying "your car's user manual says you should not drive it into a swimming pool full of jello, but it does not mandate how you should escape safely once you are immersed in gelatin".
 
An example question with dupe JSON keys: stackoverflow.com/q/29321677/4014959 There's also a good answer on the topic by Poke, somewhere.
@davidism Funky! Like the Jackson 5. :)
 
2:09 PM
The gelatin escape procedure is undocumented because jello pools are not an intended use case for cars
Ah, perhaps it's because "should" here is defined under rfc2119 terms. datatracker.ietf.org/doc/html/rfc2119#section-3
When your car manual says "you should avoid jello pools while driving", it may actually mean "never drive into a jello pool for any reason", whereas the rfc2119 interpretation would be "drive into a jello pool only when you have a very good reason to do so"
So when the JSON spec says "The names within an object SHOULD be unique", it means that you can emit duplicate names while still being RFC-compliant. The document goes on to say that JSON-reading programs are free to do nasty things to your output, and may god have mercy on your soul, etc... But you're still allowed to do it.
 
Right. A compliant reader has to accept JSON with dupe keys, but it's free to do whatever it likes with the dupe key, value pairs.
Of course, in Python it's easy to make objects that aren't dupes, but they look like dupes when you see their repr. Eg,
Jul 17 '18 at 19:48, by PM 2Ring
class Spam:
    def __init__(self, x):
        self.x = x
    def __repr__(self): return '"spam"'

print({Spam(u) for u in range(4)})
#output
{"spam", "spam", "spam", "spam"}
 
The Python docs seem a bit grumpy that they have to choose which nasty behavior to enact on duplicate-name input. "Oh, make me the bad guy, I see how it is Mr RFC. Too good to get your hands dirty"
4
'We threw a dart at the board and it landed on "silently ignore some keys". We were an inch away from "erase the computer's BIOS", so consider yourself lucky'
 
2:28 PM
It's almost impossible to work on code that handles JSON dupe keys without constantly muttering "which yamming idiot thought this would be a good idea?..."
 
It's called JavaScript Object Notation for a reason...
 
I am familiar with this feeling, whenever I write a greasemonkey userscript for a web page that has duplicate ids, and classes that are seemingly unique but not guaranteed to be
 
I read the Object part as Abject in this context
 
<div class="the_one_and_only_content_pane">: you are doing it wrong
 
Yeah, you really need to use multiple classes. It doesn't solve the problem, but it helps. XML has namespaces, but I haven't really used them, except for when they've been imposed from above, eg in EPUB docs.
 
2:38 PM
I had a rather irritating time with Python's XML libs the other day, because it didn't handle default namespaces the way I expected it to
I forget the precise details, but it turns out that root.find("foobar") is not guaranteed to return something useful just because your document has a <foobar> section inside the root
 
I don't have good memories of the Python XML modules. They're closely related to their Java ancestors, and the docs virtually assume that you know Java, and how to handle XML in Java.
 
You gotta do root.find("foobar", {"": None}) or root.find("{some arcane stuff goes here}foobar")
 
That sounds familiar.
 
Yeah, the documentation pretty frankly explains that it's a straightforward port from Java. Don't expect elegant Pythonisms here, ye who enter
 
Most of my XML work these days is with SVG, which is a fairly benign form of XML. OTOH, I'm mostly just generating SVG, not trying to parse it.
 
2:45 PM
@Kevin this remind me of how selenium handle it's Xpath/CSS/etc. The syntax look a bit similar to this, and isn't always straightforward either. The docs also don't always have detail about a particular feature, but if you look at the java api instead, you'd notice it's way more detailed...I think there a pattern here
 
For the time being I retract my previous statement, because the page I linked doesn't actually mention "java" at any point. But I definitely did see that word mentioned somewhere in the week that I was doing XML work.
Maybe it's in one of the other xml-related docs. Maybe it was in a speech bubble of that day's Garfield. Who can say?
 
Inspired by the scripts used to display MathJax in chat, I wrote some JavaScript that converts SVG code into an image. But it doesn't try to find the SVG itself, the user has to select it.
It works ok, but then I decided it's probably not a good idea to encourage people to dump large chunks of SVG into chat. :) But at least I learned some interesting stuff along the way, including how to add a button to chat that works on both desktop & mobile.
 
@NordineLotfi Reminds me of how tkinter's documentation is rather patchy, but you can almost always figure out what it's capable of by reading the tcl documentation
 
@Kevin Ha! good one. I do recall we talked about this a couple months ago or so too
 
The tkinter built-in docs are pretty extensive, but a bit arcane. Still, it's generally worthwhile calling help() on tkinter objects.
 
2:51 PM
@PM2Ring was that recommended on math.SE by any chance? I vaguely recall some RO there recommended me some userscript for that, but not sure if it was using SVG
 
I've got half a mind to write the world's most beautiful tkinter guide, but odds are pretty good that I would merely add another fifty pages to the world's pile of frustratingly incomplete tkinter guides
 
then I would probably be it's first reader
honestly there isn't ever enough docs when it comes to programming. In constrast, there is too many incomplete or in-existant docs
 
@Kevin This one briefly mentions Java: docs.python.org/3/library/xml.dom.html#accessor-methods And this one does too, but a bit more vaguely: docs.python.org/3/library/xml.sax.html
 
Partial vindication! I'm grateful.
 
@NordineLotfi I came up with the idea for an SVG renderer myself. I don't know how the MathJax renderer works. But there are a couple of MathJax userscripts & bookmarks that get used in the chatrooms of math.SE, physics.SE, etc, since those sites support Mathjax, but the chatrooms don't support it natively.
 
3:01 PM
@PM2Ring I see :D I wouldn't mind trying it, especially since I sometimes use one there.
 
3:14 PM
@NordineLotfi Sorry, I don't know what you mean. Here's the site that has the MathJax bookmarklets: math.ucla.edu/~robjohn/math/mathjax.html
 
@PM2Ring I think I already use this one. I meant to "try" the one you made that use SVG.
 
@NordineLotfi Oh. I don't know if I should make that available. As I said, if it gets loose, it might encourage people to post large amounts of SVG source in chat rooms. And the chat room owners would hate me. :)
 
ah, alright then. That's understandable :)
 
But if I change my mind, I'll let you know. ;)
 
Thanks, I appreciate :o
 
3:25 PM
It's a bit frustrating because the main sites & chatrooms do support displaying SVG files, but Imgur won't host them. So you need to host them elsewhere, eg Github.
 
Posting the source of small SVG diagrams would be ok. But SVG can get pretty verbose, especially when not handwritten. The following anim is pretty simple, and it's fairly compact handwritten code, but it's still >70 lines.
 
3:45 PM
@PM2Ring please don't mess with paralell lines
 
8*8 = 13*5, if you posit the existence of theoretical "dark numbers"
 
it is more 2/3=3/5
 
All the objects in that scene are rigid, and have correct geometry, except for the large pink 5×8 "triangle", which morphs slightly.
 
2/3=2/5=5/8 actually
better would be animation of proof of pythagore
 
Here's a direct link to the source: gist.github.com/PM2Ring/…
@XavierCombelle I've done a few of those, but not in SVG.
 
3:57 PM
Prooves of the Pythatorean theorem make my brain hurt, no matter what form they take. I think it's better for my health if I just accept it on blind faith alone
That's just how right triangles are
 
I feel the same about a lot of maths concept...except for things like "infinite number" and such
I guess I'll have to make a list one of these days to see where I'm standing
 
I don't have too much trouble with infinity. Whenever anyone says "you can't imagine infinity", I think "pfft... Maybe you can't"
My qualia is just built different B-)
 
exactly
 
Or maybe I'm lying, but it's an unfalsifiable lie, so you may as well accept it as true, or find more productive hills to die on
 
US president Garfield devised a proof of Pythagoras using a trapezium. But it's basically a proof using a square, cut in half. ;) maa.org/press/periodicals/convergence/…
 
4:06 PM
Despite my claimed proficiency with infinities, my cubescore is about three. My mind's eye has astigmatic peripheral vision.
 
I get confused enough just trying to spin 3 planes in 3D. This answer has a link to an interactive Sage 3D anim in the 3rd last paragraph. astronomy.stackexchange.com/a/47554/16685
 
Not very related problem: In the last few days I've been trying to define a particular recursive function. I think I've at least come up with a formalized definition, but I haven't explored its practical results yet.
A and C are constant real numbers greater than zero.
[potential condition: A <= 1, if that makes the problem easier to solve.]
for any x, f(-x) = f(x)
for any x, f(x) = f((x-C)/A)/A - f(x - 2*C)
f(0) = 1
Does f have a closed form solution? Is it consistently defined? what does it look like when you graph it?
 
4:30 PM
I think there are values of A and C where f(x) = 1 is a valid solution, and perhaps f(x) = some_constant*x + 1. But in the general case I think you end up with a recursive explosion where all the subcalls hover around zero without ever returning a useful value
 
Ok, so 2*f(C)=1/A :)
 
Yeah. I was hoping that once we had symbolic solutions for f(0) and f(-C) and f(C), we could figure out symbolic solutions for other values from there. Even if we can only get to, say, f(k*C) for integer values of k. or f(C*(2^k)) or something.
 
4:54 PM
Perhaps it makes sense to start just by asking, "which values of x are in the set of finitely-calculable solutions?" without asking what those solutions are. Then you can say "0 is in the solution set; x is in the solution set if both |(x-C)/A| and |x - 2*C| are in the solution set"
 
5:05 PM
I was looking at group theory because you can often (always?) define a group by saying "here is some function f(a,b). as long as X and Y are members of the group, so is Z=f(X,Y)", and from there generate as many members as you please. But we sort of have the opposite of that, because it's Z that has a simple expression, and X&Y that are calculated from some arbitrary function.
If that sounds confusing, it's because I'm confused
 
It might be worthwhile to ask on math.SE. There are some experts on functional equations there. But (of course) you have to post a reasonable solution attempt. It also helps to explain the context where the problem arises.
 
5:35 PM
uhm, working with enum type here: wondering if there is better ways than the following one to make a enum dict (if that's even the right name for this thing):
 def custom_enum(typename, items_dict):
    ...:     class_definition = """
    ...: from enum import Enum
    ...:
    ...: class {}(Enum):
    ...:     {}""".format(typename, '\n    '.join(['{} = {}'.format(k, v) for k, v in items_dict.items()]))
    ...:
    ...:     namespace = dict(__name__='enum_%s' % typename)
    ...:     exec(class_definition, namespace)
    ...:     result = namespace[typename]
    ...:     result._source = class_definition
    ...:     return result
it works fine so I'm just curious of other alternative
(copy pasted from ipython...should I clean it or?)
I use it like this:
MyEnum = custom_enum('Button', {'left': 1, 'right': 3})
mouse.press(MyEnum.left); mouse.release(MyEnum.left)
(using it with the pynput module if anyone was wondering)
 
Is there any reason why you don't just write the proper class definition?
 
There isn't actually; I'm actually curious to know a simpler alternative if possible :)
 
class Button(Enum):
    left = 1
    right = 3
:P
 
FWIW, by default Enums are not sealed. So you should be able to run your enum-from-dict via a simple loop instead of exec magic.
 
5:40 PM
cbg-evening
 
@MisterMiyagi wait, how do I use this? I imported the enum module but it still throw an error Name Enum not defined
cbg!
 
@NordineLotfi from enum import Enum
 
ah. Thanks, this works :D
 
@MisterMiyagi MisterMiyagi making unfounded claims again, I see... 🧐
Anyways, @NordineLotfi, if you want to there's a functional Enum API as well.
Button = enum.Enum('Button', {'left': 1, 'right': 3}) should work.
 
:o this is nice, Thanks. I only found out today about the enum type, so yeah
it's weird though, how come it doesn't have a simple workflow like other type. eg: int(), etc?
I mean having to import it just to use it is a bit weird when you're used to other normal types
nvm, this explain it
 
5:57 PM
Not sure what you mean by "normal" type. Enum isn't exactly common in daily use, but it's no further away from use than deque, Popen or similar.
 
 
3 hours later…
8:58 PM
Hello Guys
I installed a package to Python packages
The package is installed to a different folder even though all packages install to default path that is the Python path in Ubuntu
When I try to import this package, I always get error not found module
Any recommendation to solve this issue please?
Even if I copy and past the package to python site-packages in default path, I still get not found Module
It only happens with this issue though not others.
 
To confirm: If you do python -c "import this_module" it crashes with an ImportError, and when you do python -m pip install this-module it says the package is already installed?
 
@Aran-Fey. I checked with command pip show package. I am able to see the package. However, when I import a submodule from the package, I got error not found.
 
Well that's an entirely different problem. Either the package wasn't installed correctly, or you're trying to access something that simply doesn't exist
 
I checked that subpackage and it exists. So all exists, but not able to import
Never had this issue before
 
and python -m pip show package?
 
9:09 PM
`from package import package.sub_package`give error
ModuleNotFoundError: No module named 'sub_package'
 
Uhh, from package import package.sub_package is a syntax error
 
@Arne. Yeah, it's there.
 
@Avra A common cause of this is your pip command pointing to a different python interpreter from what you're using to run your script
 
@Aran-Fey. Sorry I made a mistake.
`from package import sub_package`give error
ModuleNotFoundError: No module named 'sub_package'
 
@Avra Does import package work?
 
9:11 PM
the name you install it with pip is not necessarily the one you need to import, are you sure you're using the right name?
 
@evantkchong. Yep it works.
 
@Avra Any chance you could share the package name and the submodule you're trying to import? :)
 
@Avra Ok. That's still strange though, because usually the error message should look more like ImportError: cannot import name 'sub_package' from 'package'. With an import like that, python doesn't even know whether sub_package is a package or just an attribute of package. So if that's really the error you're getting, then something must be broken inside of package - it must be trying to do import sub_package or something similar
So my guess is that the package maintainers released some broken code.
 
@Aran-Fey. Yeah. Probably the package is broken
@Arne. It's the same and I checked the path from pip show
Most likely it's broken then
 
And you didn't accidentally name something package.py in your current directory...?
it would probably raise the error Aran mentioned, just making sure
It would also help if we knew whether "the package" means "numpy" or "denvercoder9/throwaway_thing on github"
 
9:31 PM
Hello Andras, it seems the issue raised from naming errors from the package itself. I am working on it. It's not from Python
submodules names called are not correct
This is back to author
 
@AndrasDeak Uh I'm working through the errors with avra in a different room
 
Ah, OK, thanks for the heads-up. Good luck.
 
@AndrasDeak Yeah I think the package is fine, but it could benefit from some documentation so users know what classes are available without looking at source
Okay problems resolved I think
 
@evantkchong. Thanks evan for resolving issue.
 
 
2 hours later…
11:42 PM
hello
 

« first day (4062 days earlier)      last day (869 days later) »