« first day (2667 days earlier)      last day (2506 days later) » 

00:01
cbg, folks
Yes it worked. :D May not be perfect but it's a distinct improvement:
Now to create a function to right align text and it should be good : )
00:09
What is that for?
@Simon there should be a format option for that
cbg all
cbg
49 mins ago, by Simon
I am trying to centre text in a terminal, because it's rounding incorrectly I believe am getting the following output as a result:
Nice job @Simon
so far of course ;)
@cᴏʟᴅsᴘᴇᴇᴅ A module I'm building for aligning text in a terminal.
00:11
@AndrasDeak No I get that, but I was asking what Simon was doing it for.
Eh, but why?
Assignment? Or, just practice?
str.center()
>>> for i in range(10): print((i*"@").center(30))
...

              @
              @@
             @@@
             @@@@
            @@@@@
            @@@@@@
           @@@@@@@
           @@@@@@@@
          @@@@@@@@@
@cᴏʟᴅsᴘᴇᴇᴅ Practice, practice practice
Cool, next I am going to work on a complex piece of software that parses simple, human-like input then turns it into python script.
00:12
@cᴏʟᴅsᴘᴇᴇᴅ ah, I misunderstood your question with you not being in the habit of reading the transcript and all :P
if the batteries are included, use those and don't craft one yourself :P
Ironical, it will have syntax too.
@Mr.Zeus if your idea of "human-like" is "simple", I'm curious as to the kind of humans you know ;)
3
Those of the world that won't survive the attack of A.I. due to that fact that they can't even use the command-line.
Oooh, windows users!
00:16
@AndrasDeak :O, jk I am with you.
for i in range(1, 20, 2): print('{: ^30s}'.format('@' * i))
          @
         @@@
        @@@@@
       @@@@@@@
      @@@@@@@@@
     @@@@@@@@@@@
    @@@@@@@@@@@@@
   @@@@@@@@@@@@@@@
  @@@@@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@@
That's beautiful!
Isn't it great that there is two conversations going on at the same time.
the point is not the triangle; the point is to find a consistent method of centering (i.e. it should be nice with both even and odd lengths)
part of the problem is that you can't center a triangle like that on a rectangular grid
boo... fine! Why must it be that have to read
00:18
but A for effort ;)
@ByteCommander Thank you for that function. I might use it : /
@piRSquared And thank you too.
@AndrasDeak Well, I read at least the last 20-30 messages to get some context ;)
I have gotten confused by all the green beans on SO, is this a good practice:
`if __name__ == "__main__":`
Sorry I don't mean to interrupt the convo.
Yes, definitely
It's good practice if used correctly, i.e. at the bottom of a module that can be executed but should also be importable
00:26
And there's no priority lane here. If there's much crosstalk, we can start using directed replies
@Mr.Zeus importing runs everything at the top level, so whatever you don't want to run on import goes in there
Hah!
for i in range(10): print(f'{" ".join("@"*i):^30}')
          @
         @ @
        @ @ @
       @ @ @ @
      @ @ @ @ @
     @ @ @ @ @ @
    @ @ @ @ @ @ @
   @ @ @ @ @ @ @ @
  @ @ @ @ @ @ @ @ @
Just making sure I am right.
Ok, so it is good if it is put the bottom of a module, else do not.
YAY!
Also multiprocessing can bite you real good if you forget to protect your executed code like that
(Maybe just on windows)
00:31
If anyone is interested here is my original: dpaste.com/09VPSD6 and the new one suggesting center(): dpaste.com/2NEHDEB attempt at centring in command window
Does that also apply to multithreading? XD @AndrasDeak, haters gona' hate
uuuuh I have no idea and I don't want to guess (even though I have a guess)
Nope, it's only multiprocessing and only on windows
@piRSquared It's cool but not what I had in mind when I started
00:38
@Simon Yeah, sorry about that. Just entertaining myself mostly.
@piRSquared Don't apologise it's great! Especially if you are having a good time. It's just one of the problems I was facing not the only problem I was attempting to solve
By the way @AndrasDeak, here is some sample HLCode code: say "this is a echo script", forever ( get input as $1, say $1 )
HLCode?
"Human-Like Code"
oooh, sorry, it didn't click
00:41
It may never come to fruition, but might as well dream, while I can.
It would have probably been better if the syntax was like this: please say "this is a echo script", forever
Here is a python equivalent:
print("this is a echo script")
while True:
$1 = input("")
print($1)
sadly that's a SyntaxError
It won't indent, yam it.
formatting guide linked from the room rules
00:46
+1 for both comments
Thanks man
Now I can't edit it... wow just wow.
type yes "this is a(n) echo script" in bash
@Mr.Zeus Next time add one comment saying "Here is a python equivalent: " and add your code in a new message using ctrl+k.
I know, but I tried typing it in the browser
you can always practice in the sandbox
00:49
I had no idea that we had that.
By the way @cᴏʟᴅsᴘᴇᴇᴅ, I was talking about the piece of software I am going to work on.
you can (should) read the faq and help linked in the bottom right of the desktop view
I would like to take the HLC("Human-like code") as a command line args. but I think it may be a bad idea, suggestions.
Rubarb, all.
Kinda abbrupt, sorry.
01:39
I have a package that should be executable (i.e. it has a __main__.py), but I also want to provide a separate script that executes the package. The project structure is essentially like this:
project/
    project_package/
        __main__.py
        __init__.py
        other_stuff.py
    command_line_interface.py
My problem is, where should I put the code for the command line interface? If I put it in command_line_interface.py, I can't access it from __main__.py. If I put it in __main__.py, well, I don't know how to execute the package as __main__ from within python. How do I solve this?
I tried to add another command_line_interface.py inside the package, but for some reason I couldn't correctly from . import * there. The __init__.py never ran.
01:57
I don't know if this helps.
I'd prefer if the package were self-contained, but I may have to resort to that if I can't find another solution
Sorry idk. Late night rhubarb all.
02:14
@Rawing Thanks for the improvements, much appreciated :)
No problem :)
btw, you can remove the "As Rawing mentioned in a comment" part if you'd like. I'd rather see an answer with minimal fluff than an answer in which I'm credited :)
Make sense, since you've deleted your comment.
 
5 hours later…
07:27
@Rawing I have an opinion on crediting folks. It is my opinion and I'm not upset if others don't share it. That preamble out of the way. I think it is important to foster a culture that readily gives credit to those who offer advice, come up with ideas, or generally do useful stuff. I've seen too often others completely rip off ideas as if they are their own and that actually perturbs me. In my opinion, I'd leave your name and credit to you at the expense of purity.
Building comradery and community is worth the price of a little fluff. </end_soapbox>
08:15
cabbage
Hey cabbage @piRSquared
How was your week?
Busy as usual. Wifes birthday last week, 1st born's this week, flying next week, rebuilding work project like my job depends on it (-:
fun stuff
08:29
haha
I've been busy too.
I'm watching a netflix series travelers. I'm not sure how I feel about it yet.
How have things been?
Fighting to get GPUs
for mining
Hah! For fun?
or profit?
Hopefully for profit... if not, I'll play mario kart on a 18*12 meters screen! :D
Hi-res
laurel
08:32
The market is incredibly tight.
yeah, I imagine non-profitable... but then I haven't been paying attention
09:01
Even not thinking about profit, it is incredibly hard to get GPUs
how many gpus are you looking for?
09:25
@Rawing __main__.py should not know about the script outside the package to work correctly. from . import * will not work unless the parent package has already been imported
You'd put the code for the command line interface in a module inside project_package, then call runpy.run_module('project_package') in the script outside the package
09:55
600 @piRSquared
 
2 hours later…
11:50
@vaultah Do I really need that extra module? Is there something wrong with putting that code into __main__.py and starting it with runpy.run_module('project_package', run_name='__main__')?
In fact I don't even need to set run_name='__main__'; I can just remove the if __name__ == '__main__' check in __main__.py
@Rawing probably not
Alright, thanks. Solved my problem with a single line of code 👍
 
1 hour later…
13:25
Hello everyone. This is my first time in the "Third Place" here. It's awesome to be here.
13:54
here is an example where the least ideal solution is selected as the accepted answer
Which goes to show, that we should always be careful to blindly take the "green check mark" answer
that question is too unclear to even judge what the best answer is :/
at the very least checking for isinstance and replacing that ' 123' is at least a much better start than anything else there
jjj
jjj
14:44
Do you ever try to take on some of the unanswered questions? Some of them can be pretty difficult
'course, the easy ones get answered right away
Trying to convince a gold badge holder that * unrolls the iterator (its argument) immediately
Yayness
jjj
jjj
@Rawing Right, obviously couchpalm. But is it really worth the effort anyway? Especially with the older questions. Probably the OP found the other way round, right?
I don't know, but I don't think there's much traffic on questions older than a few hours. You probably have to consider yourself lucky if you get more than an upvote and a green check mark from the OP.
15:00
@vaultah yeah...:)
@Rawing can confirm
Answer is still a lot more practical than my silly Counter one though...
I routinely answer not-so-fresh posts and it's crickets galore
@JonClements heh, did that discussion generate an auto flag?
it's jut Ppppphuppy Pppphowerrr!
jjj
jjj
:) I dunno, maybe I should be more determined to learn and contribute for contributions' sake
@vaultah don't know - just travelling and thought I'd have a look at Python questions while waiting...
it feels so fun to see +n where n = 2 * 2 (mod 10) in my rep notifications
15:36
@vaultah From a programming perspective it's not a hard task to not unpack the iterable while it's passed to a built-in function and destroy the main purpose behind the built-in functions which is giving the user more performance. That's the only thing that came in my mind when the OP asked about. And then I just told you that it's worth to take a look at the source to be 100% sure.
The least thing that you could learn from this short discussion could be a little more thinking out side the box and not just talking based on trained data like a neural net at its best. (just a friendly suggestion though)
Nope, I'm not continuing this discussion here. That behaviour can be fully described by example (as I did), but if you want to look in the source, check the CALL_FUNCTION_EX opcode. Thanks for your friendly suggestion, though. I don't know what made you think I was "talking based on trained data like a neural net at its best" but thanks 👍
16:37
I really want to know what that guy with the tuple question is really trying to do...
yes....me too.
*turple
I lol'd at that too
turple turple
link please?
The chances are also much more likely that they created this structure themselves
Because I don't know what source of truth would have generated that for them
16:38
Ah, this one I guess.
Oh right... they're going to use a list for that now.... that hasn't enlightened me much... :)
It just got more perplexing
@idjaw To be fair, generating a 100 deep nested tuple is fairly impressive stuff in itself... can't imagine someone fairly new to Python managing that by accident...
lol
@idjaw wonder if we'll get a new question: "I have a list [[[1, 2], 2], 3] and...."? :p
16:41
hahah......we've seen it happen many times
Oh wait... I meant I have a lirst... :p
 
2 hours later…
wim
wim
18:40
huh, just got voting reversal rep. wonder who I ticked off! :)
@wim stuff happens? :p
@wim you still west of the pond ?
 
2 hours later…
Dan
Dan
21:03
cabbage y'all
does anyone know of a good tutorial for creating a setup.py installer for a cli script? I.e. not just a package to be imported by others, but an actual script needing to be installed to system/user path to be used via cli?
i keep find weird tutorials that either assume main() can be called without passing any command-line parameters or that only work on linux and not also on windows
I know nothing about distributing python projects, but something you said sounds weird to me - why can't your main() be called without command-line arguments? Isn't that where you parse the command line arguments?
Dan
Dan
@Rawing this is true, so long as it can get them if called through something else that works for me
@Rawing if this is all I need to do then I will follow that
but Windows has no concept of /usr/bin nor /usr/local/bin
even if you know of a project on github with a command-line tool that has a setup.py installer for it, that would be very helpful
python 2.7
@Dan Windows has the concept of system %PATH%
which is essentially the same
there's also the console_scripts entry point, which seems to be used by flask
Dan
Dan
21:20
@Rawing what confuses me between the two is functions vs scripts
this is a script
needs to be run from OS command line, not from python interpreter
but the example is unclear and it removed the ".py" extension, which on Windows does not work
that may work on Linux
but in Windows, if I associate the file with Python, even when I run from shell it launches a new shell
if there is an error, this new one will close immediately before user can read anything
I want it to be in system/user path and be able to be called with command line paramters
maybe i'm overcomplicating this, just easier to understand with an example
yes this is problem with scripts --> Windows does not read the shebang
and thus does not know how to execute script
and even if I associate script with Python in Windows, won't work in virtual environment
I'll try console_scripts, I just don't think I understand
21:40
just spent an hour reading up on unittest framework. and applied your feedback to my script. It worked . thanks so much. — adbSOeh 2 hours ago
Someone took my advice to read some docuementation! \o/
6
21:56
When I run mypy against this I get this error: "error: Incompatible return value type (got "TextIO", expected "Dict[str, Dict[str, Any]]")". I can't figure out why the return type is TextIO.
oops, sorry I forgot to add the file path in the example, but still same error.
I want my gui to remember certain information until the next time the pc reboots. I am not happy about having to create a text file in the same directory, as I would like it to be hidden. I thought about creating/altering some regedit data, but it might cause some troubles when the gui is ran on a mac.
- Any ideas?
A file is pretty much the only option I think
22:14
Really? That sucks. I hope that it is possible to hide a file then using python.
Great, that is possible.
 
1 hour later…
23:31
o_O

« first day (2667 days earlier)      last day (2506 days later) »