« first day (3549 days earlier)      last day (1382 days later) » 
01:00 - 19:0019:00 - 00:00

1:42 AM
@roganjosh Actually this problem is why I decided to pursue my degree (before this I was a completely self-taught DBA/Backend Dev). Processing the json, csv, barcodes, pdf (most of which were images files), and manual entries which had the expiration date info - kinda pushed me towards IS whether I liked it or not :)
And yes, I found a solution. And yes, I'm still not happy with it (it was not elegant in any sense - its elegant-er now but still far from perfect). And yes, I still sit up some nights trying to just figure out how to make it a little better :)
With food itself (I have a more general approach including a lot of warehouse goods which can have expiration or regulations which require inspections) the true answer would be better industry standards or regulations on what should be in a barcode (label) which describes food but we can only do so much as engineers
 
2:04 AM
just popping in to say cbg :)
I didnt even know meta SE was linked as much, I thought it was just there :/, ohh well
 
 
1 hour later…
3:30 AM
hello all
 
 
2 hours later…
5:46 AM
hello everyone! I've just dropped in
 
Hello
 
 
2 hours later…
8:08 AM
Hello, Is there a global variable $ equivalent to ruby in python?
 
I don't know what $ does in ruby, but yes, python has global variables
 
I have use a variable through-out all the classes upon initiation
 
I'm... not sure what exactly that means. Could you cobble together a bit of demo code?
 
if I declare a variable like this $name = 5, it can be used on the remaining classes - and you dont need to initiate anywhere like constructor, etc.,
 
So all you need is a global variable?
 
8:13 AM
yeah
 
Ok. What's preventing you from creating one?
You know how to create variables? Do it in the global scope and bam you have a global variable.
 
By ruby, do you mean ruby on rails? And by $ equivalent, do you mean you want to create a per-request global variable, valid during that request only?
 
weird question, but I was presuming a web backend context, in which case the answer would be quite different.
 
I get this error - [pyflakes] local variable 'i' defined in enclosing scope on line 3 referenced before assignment
 
8:18 AM
put global i inside incrementor
 
The global i should be within the method where you want to use that global variable.
 
FWIW, why don't you use a class attribute?
a global seems excessive
 
so, where to init the value for i
 
Oh, you haven't initialized it yet? Then yeah, use a class attribute
 
I have to set like
global i = 0
 
8:19 AM
Also, don't call TestClass.incrementor(self). Use self.incrementor()
 
ah okay
 
class TestClass:
  i = 0

  @classmethod
  def incrementor(cls):
    cls.i += 1
    return cls.i
 
this makes sense; thank you @MisterMiyagi and @Aran-Fey. Sry am new to Python
 
 
1 hour later…
9:47 AM
@LinkBerest It's cool that you managed to make progress within your own sphere though :) It's a shame in the broader sense of the industry in that the barcoding system cannot work to carry such info. We need to switch to QR codes, or the like, and be done with it. Then it's just a quick scan with the phone when putting it in the fridge and it can all be fixed. Tis a nice dream :)
 
10:28 AM
Hey guys are any of you familiar with the flask-migrate package
 
I use it a lot. Whether I can answer to its wizardry is a different matter. What's up?
 
You're a wizard, @roganjosh
 
Woohoo, no more living under a staircase!
 
@roganjosh well i am following the flask mega tutorial
and when i use the flask db migrate -m "users table"
 
TIL df['col'].value_counts(bins=10) is the same as df.groupby(pd.cut(df['col'], bins=10)).count()
 
10:38 AM
I get this dpaste.com/31H03RV while in it i should be getting dpaste.com/2CTSYRP
 
Ok, well how did you get that second snippet?
 
and I am not sure why I have been following it really closely but it doesnt seem to work right and I have also tried removing the app.db and migration fill and redoing b¡to same result
 
Ah, ok
 
I have started that to learn more and learn pagination along the way as you told last time
 
ok, now this becomes a bit confusing
Because you're not using the ORM (unless you've since changed), so you're not going to get any migration if your Users table doesn't inherit from db.Model
 
10:41 AM
Ah, pagination
 
@roganjosh Ok well right now i am not on the previous project i am literally doing the same as the tutorial in a different project to learn
 
So firstly, you'll need to correct my mindset about whether or not you are now using flask-sqlalchemy
 
@roganjosh I am not in the project we were on before I have stopped with that for a bit to follow this tutorial blog.miguelgrinberg.com/post/… and will go back to it when I am done
I am doing the tutorial as it states so using flask-sqlalchemy as in the tutorial
 
Ok. Have you imported Users into views.py?
 
there is no views.py I have a init.py
as well as config.py
 
10:47 AM
Please show me your __init__.py. It's been quite a while since I followed the tutorial but I feel like your project should already have been broken up into views.py and models.py by this point
 
dpaste.com/36RXGJN this is the init.py dpaste.com/1PZE69G this is models.py dpaste.com/18MR749 and this is config.py
 
Ok, import Users from your models into __init__.py
Then re-run your migrations
 
@roganjosh Mate honestly if ever able to I owe you a beer for all the times you have helped me... Sorry Im such a rookie forgetting basic imports
 
What a happy coincidence! The pubs over here are opening up today :P Has it worked, or are you asking how to do the import?
 
@roganjosh it worked mate
lol next time I go to UK will buy you a drink
 
10:56 AM
Perfect :) If you're interested, flask-migrate leverages Alembic and, specifically, autogenerate which is the magical part
 
@roganjosh excellent thanks will read up on that now lol keen to find out more
 
11:12 AM
@Kwsswart you're using flask-session in your other project, right?
I'm anticipating 2 headaches for you that you'll run into pretty quickly in any reasonable project outside of the Mega tutorial
 
@roganjosh yeah man
@roganjosh what headaches you anticipating
 
Give me a min :P I've since ripped out one of the pain-points from my own project, so I need to dig out the code :)
The first I can tell you straight away. If you use SQL-backed sessions (which I believe I recommended to you over a file-based session) then your sessions table will not be included in your migrations
For that, you'll need:
 
@Kwsswart tip: use backticks around double-underscore names to protect them from being rendered as boldface markdown in chat.
 
from flask_session import Session, SqlAlchemySessionInterface

session = Session()

session.init_app(app)
SqlAlchemySessionInterface(app, db, "sessions", "sess_")
 
@AndrasDeak cheers mate will do
@roganjosh this is to include in migrations
?
 
11:23 AM
Yes, otherwise your sessions table will not be detected in your migrations
Obviously there could be any amount of code in the spaces in what I posted, so you'll need to adapt that to fit whatever your own codebase looks like
 
@roganjosh cheers mate will make sure to remember... I have a feeling when i am done the tutorial i may redo that project or heavily edit code because going through it i am noticing alot of room for improvement in the project i was doing
which do you guys prefer django or flask and why?
 
I don't think that's a particularly useful question. You know which I prefer already, and my only answer to the other part is probably "because of familiarity". I can't sensibly benchmark them
 
@roganjosh Lol i have noticed
Only asking because in the cs50 course i am doing once i have gone through flask it goes into django and goes into it alot and i am curious as to when you would use one of the other
 
Well, Flask on its own is not particularly useful. As you can see, you need to build it up with extensions. Django is all bundled in
So it's perhaps easier to teach concepts if the single library covers all the parts. No idea tbh.
 
@roganjosh fair enough I am sure will build preference once i have learnt them both
 
11:44 AM
Anyway, the second pain point is huge, and should be covered in the tutorial IMO. When you make constraints on your database (such as unique columns, indexes, etc.) then they need a naming scheme. If any of your migrations try to alter these, then applying the migrations will crap itself and you're stuffed. I don't think such an oversight can be easily reversed, either
For that, you'll want something like this:
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import MetaData
naming_convention = {
    "ix": 'ix_%(column_0_label)s',
    "uq": "uq_%(table_name)s_%(column_0_name)s",
    "ck": "ck_%(table_name)s_%(column_0_name)s",
    "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
    "pk": "pk_%(table_name)s"
}

db = SQLAlchemy(metadata=MetaData(naming_convention=naming_convention))
 
@roganjosh this allows it to alter the constraints when upgrading?
 
Yes. If there is no consistent naming scheme for the constraints themselves then you won't be able to alter them in migrations
 
@roganjosh thank you man i appreciate the heads up
 
I now have more thoughts on gotya's with the setup. I think I'll try contact Miguel
 
12:04 PM
@roganjosh whats gotya?
how do you contact people personally on stack.overflow
 
@Kwsswart Read it phonetically :) The kind of thing you might (if English is your first language) say if you were playing hide-and-seek with a child. Basically, unanticipated issues. And there isn't a way. I'll probably raise as an issue on his GitHub
Maybe "gotchya". Hmm
 
@roganjosh oh lol i thought it might have been some form of acronym
 
12:50 PM
@roganjosh gotcha?
 
A happy medium :)
 
Especially in the pitfall sense
 
1:07 PM
Huh, spellcheck recognises gotcha so I'm all out of excuses :P
 
I've learned some time ago that using type(name, bases, namespace) is subtly wrong, and types.new_class should be used instead. Of course, I haven't done so. Needing to supply a namespace initialiser instead of a namespace seems like so much work. Has anyone used new_class and is comfortable with it?
 
user12867493
Is there a way to split a string with multiple variities, e.g. both . and ... e.g. a.b...c. = [a.,b...,c.]?
 
So confused
 
@MisterMiyagi Wow, I didn't even realize that the 3rd argument isn't interpreted as a dict of class attributes. That's a PITA for sure
 
@Daniil are you asking how to unpack the list into variable names?
Where is the string?
 
user12867493
1:22 PM
@roganjosh No, so a.b...c. is a string, I want to .split() it into [a.,b...,c.], but AFAIK .split() takes only one arguement
 
user12867493
So how can I split both by . and ...?
 
But it isn't a string. You're going to need to clarify this with an MCVE because your question suggests that you're assigning to a string
 
user12867493
@roganjosh It is a string
 
No it isn't
 
user12867493
I just said it was
 
1:25 PM
Where are the quotation marks?
Single, double, whatever. They don't exist in your question
 
user12867493
There are no quotation marks since it's an input
 
user12867493
a=input()
 
user12867493
I input a as a.b...c.
 
user12867493
print(type(a)) gives <class 'str'>
 
@Aran-Fey Everytime I try to use it, I remember that little detail. Then stop trying to use it. :/
 
1:27 PM
@Daniil That's great. I'm still going to go back to asking for an MCVE
 
user12867493
@roganjosh I gave an MCVE, didn't I?
 
user12867493
What more do you want?
 
@Daniil So you want to split "a.b...c" to ["a.", "b...", "c."], is that correct?
 
user12867493
@MisterMiyagi Yes
 
@Daniil so ask that. If your question is dubious you won't get answers.
[a.,b...,c.] is not a valid result and we prefer not to guess in the face of ambiguity
 
1:33 PM
Nor is a.b...c. = a valid assignment
On re-reading, I think that the = was the most confusing part for me. I think --> might be better if you're suggesting some transformation
 
@Daniil I think you have to re.split with lookbehinds/(aheads?)
 
user12867493
@AndrasDeak Thanks for the idea
 
> error: look-behind requires fixed-width pattern
that might be a problem
matching the actual characters (rather than lookbehinds) means that when you split you lose the separator
>>> import re
...
... s = 'a.b...c.'
... re.split(r'(?<=\.)(?!\.|$)', s)
['a.', 'b...', 'c.']
potential other edge cases not excluded...
it has a positive lookbehind for a dot and then a negative lookahead for a dot or the end of string
 
2:02 PM
@Daniil you seem to have left minutes after asking the question so ^
unclear, probably just confused stackoverflow.com/questions/62729617/…
 
@AndrasDeak Keep in mind that this won't work in older python versions - the ability to split on 0-width matches is pretty new
 
@Aran-Fey ah, good to know, thanks. I don't really use regex so I didn't know.
But they won't be able to do this without 0-width matches I think
Unless they manually put the dots back
 
user12867493
2:20 PM
@AndrasDeak Thanks :)
 
2:51 PM
I'm kind of confused by the weird interface of types.new_class and types.prepare_class. When are functions like that even useful? Is there something I'm missing about the class creation process?
What would be wrong with something simple like this:
def create_class(name, bases, attrs, metaclass=None, **kwargs):
    if metaclass is None:
        metaclass = type

    bases = resolve_bases(bases)

    return metaclass(name, bases, attrs, **kwargs)
 
user12867493
3:14 PM
I got a coding problem and not sure why my code isn't working
 
user12867493
The problem:
 
user12867493
> There are currently 𝑛 packages for delivery in the mail office. The weight of each package is either 50 kg or 100 kg. It is known that no more than 150 kg can be transported by car in one trip.

What is the smallest number of courier trips needed to deliver all the packages?
 
user12867493
e.g. 50 100 50 50 = 2
 
user12867493
100 100 100 = 3
 
user12867493
My code: (b is the input)
 
user12867493
3:15 PM
b=b.split(' ')
b = list(map(int, b))
if b.count(50) < 3:
    x=0
    y=b.count(50)
else:
    x=b.count(50)/3
    y=(b.count(50)/3 -1)%3
z=b.count(100)
if z<y:
    z+=(y-z)
x+=z
print(int(x))
 
user12867493
So what I do is count the 50's first, divide it by 3 (since 3 50's in a trip), if there are less than 3 then combine them with the 100's, if there are less 100's than there are 50's then add the 50's on
 
How is it not working?
 
user12867493
My code isn't accepted though.
 
user12867493
Wrong answer on test x, I can't view test x though
 
ugh
 
user12867493
3:19 PM
I changed z+=(y-z) to z+=1, now it's Wrong answer on test x+1 :)
 
Even with the explanation, those single-letter variable names make it hard to comprehend
 
@Aran-Fey do you know of a guide for writing readable code? :P
 
I have absolutely no idea what x, y or z are
@AndrasDeak no good ones :P
 
user12867493
x = the trips to deliver the 50's, y = the remaining 50's after the initial delivery, z = trips to deliver the 100's
 
You can probably make the most of it by pairing 50s with 100s as much as possible. Are you doing that?
you an easily generate test cases for yourself that you solve on paper
 
user12867493
3:23 PM
@AndrasDeak How can I do that?
 
Take the minimum of the count of 50s and 100s, those can be deducted from the total. Then ship the rest (either 50s or 100s only).
 
I think you're going about it backwards. It makes no sense to me why you need a special case for less than 3 50kg packages. You should start by pairing 50s with 100s, not pairing 50s with other 50s
 
I don't know if there are edge cases where this is suboptimal
my hunch is that maximising the number of full trips (with as many 100s as possible) is optimal
 
user12867493
Still wrong answer
 
user12867493
import math
b = input()
b = b.split(' ')
b = list(map(int, b))
x = min(b.count(50), b.count(100))
y = max(b.count(50), b.count(100))
if y == b.count(50):
    y = y - x
    y = math.ceil(y / 150)
    y += x
else:
    y += x
print(y)
 
3:30 PM
there are quite a few thngs there which neither of us said, so I don't find it surprising
 
user12867493
? I did what you told me
 
y = max(b.count(50), b.count(100))
if y == b.count(50):
those are two things I never said
anyway, I'm off now
 
user12867493
> Take the minimum of the count of 50s and 100s, those can be deducted from the total. Then ship the rest (either 50s or 100s only).
 
OK, I guess that can be a convoluted way to check which one gives the minimum. Not how I'd approach it. And as Aran said these variable names are terrible to read so you'd be better off using something more informative.
 
Say you have X 100kg packages and Y 50kg packages. Each 100kg package is a trip, so you need at least X trips. Each one of those trips can carry a 50kg package, so after you've done X trips, you're left with Y-X 50kg packages. Now you do trips carrying 3 50kg packages until you've delivered them all.
 
user12867493
3:34 PM
How would I write that though?
 
:I
This is like high school level math at this point
 
user12867493
I am in high school :P
 
trips = X + math.ceil(max(0, Y-X)/3)
 
user12867493
Thanks
 
user12867493
Maybe not, it gives a wrong answer
 
3:43 PM
For which input?
 
user12867493
100, 100, 100
 
user12867493
Should be 3, it gives 1
 
Sounds like you mixed up X and Y
 
user12867493
What are they supposed to be?
 
This is why good variable names are important (and yes, I know I came up with those)
X is the number of 100kg packages
 
user12867493
3:46 PM
👍 Submitting now
 
user12867493
Accepted, thanks
 
user12867493
3:59 PM
@Aran-Fey Can you help me with something else please if you're free?
 
Just ask your question. Even if I'm not free, someone else might. If I say no, there's still half a dozen other people here. So really, just post your problem
 
user12867493
I am given a number n, I want to find the next number after n where the sum of the digits in even positions in its number is equal to the sum of the digits in odd positions.
 
guys is it ok if I ask a mysql question here?
 
user12867493
e.g. 123123 = 123134
 
user12867493
My code:
 
user12867493
4:05 PM
num=int(input())
while True:
    num+=1
    lst=[int(i) for i in str(num)]
    odd=lst[::2]
    even=lst[1::2]
    if sum(odd)==sum(even):
        print(num)
        exit()
 
user12867493
I got time limit exceeded, n has a big constraint
 
user12867493
n can go up to n to the power of 100
 
user12867493
Is there any way to reduce the time?
 
user12867493

SQL

Got a SQL question? Any SQL flavor here, just ask. Indicate yo...
 
Instead of blindly incrementing the last digit (i.e. doing num += 1), you should increment only those digits that help you reduce the gap between odd and even.
As far as I can tell, the difficult part is what happens when you have to increment a digit above 9. When that happens, you decrease one sum by 9 while increasing the other sum by 1.
 
4:11 PM
hey, if i want to print the terminal 0 0 0 0 how would you do this?
ive tried print(myarray) but this gives [0,0,0,0] which isnt the right format
 
Actually, it gets even more complicated when your number gets one digit longer, because then even and odd digits are suddenly swapped
 
ive also tried print(" ".join(str(line))) but same output really
 
So overall I'd recommend skipping that challenge. It might teach you math, but it won't teach you programming
...much like the earlier one with the packages
@Permian print(*line). Argument unpacking, look it up
@PedroSpinola Sure, if it's related to python
 
@Aran-Fey thank you so much
 
If you want to create a string like "0 0 0 0", you'd do ' '.join(map(str, line))
 
4:19 PM
not directly @Aran-Fey but sql room is empty :( although I'm trying to install mysql to work with a py script :P
 
Well, maybe post an SO question then?
 
@Daniil can you slow down now?
 
@PedroSpinola given that it's a question about installation difficulties (seemingly) then no, it's not appropriate for this room
 
Jun 27 at 15:57, by Andras Deak
because we already have a user who uses this room as a code challenge site solving resource, and I'm getting tired of doing this again
oh hey, that message was exactly directed at you
 
alright
 
user12867493
4:31 PM
@AndrasDeak To who?
 
@Daniil 1: guess. 2: check the corresponding transcript
 
dMd
Hello guys
 
@dMd please don't ask for help here with fresh questions on the main site as per our rules
 
dMd
i've been having troubles resolving it for some weeks now
 
you also have an answer, which is a good sign
 
4:41 PM
hi! I'm getting an TypeError: unsupported operand type(s) for -: 'decimal.Decimal' and 'float' error for {{ form.sugars.data - 22.5 }} but it works well when I change 22.5 for 22
could anyone help me?
 
@DanielGarcíaBaena that's presumably because decimal.Decimal is exact, and float is inexact. In case of half-integers both are exact. You can probably switch to decimal.Decimal('22.5') instead of 22.5
 
the problem is that 0.1 is not exactly 0.1
 
I tried but now I get this: jinja2.exceptions.UndefinedError: 'decimal' is undefined
 
>>> format(0.1, '.20f')
'0.10000000000000000555'
@DanielGarcíaBaena then import it...
 
4:44 PM
but where? This is an HTML file
 
the other option is converting both to floats, only for printing...
@DanielGarcíaBaena OK, that's a jinja thing, I'll let others respond
 
sorry, I'm not a front developer
how can I convert them both to float?
 
@DanielGarcíaBaena do you understand the ramifications of changing your data from Decimal to decimal?
 
I think so
 
4:47 PM
what I do not understand is how to import Decimal inside of a HTML document
 
If you understand the risks of changing from an exact representation to an inexact one (which is probably fine for presenting in a document, with some potential rounding), you can call float on your Decimal to get the nearest inexact float.
and that doesn't need any imports in your jinja template because float is a built-in
 
yeah, it's only for showing some results
 
then your only risk is getting 0.10000000000000000555 printed if you're not careful enough
 
exactly
should I do something like float(form.sugars.data) then?
 
with the aforementioned caveats: probably
>>> float(Decimal('0.3')) - 0.2 - 0.1
-2.7755575615628914e-17
that's probably why subtraction is not supported between Decimal and float instances
 
4:52 PM
that's what I was thinking
let me try
 
you should probably consider specifying some explicit format to print that value anyway
 
nope, same error: jinja2.exceptions.UndefinedError: 'Decimal' is undefined
for {{ form.sugars.data - float(Decimal('22.5')) }}
it's weird
 
ugh
 
user12867493
@AndrasDeak Oh, it was to you
 
2 mins ago, by Daniel García Baena
should I do something like float(form.sugars.data) then?
why not do ^ that if you ask about ^ that?
 
4:54 PM
I tried too
 
And what happened?
 
jinja2.exceptions.UndefinedError: 'float' is undefined
{{ float(form.sugars.data) - 22.5 }}
 
Ah... as I said, that's a jinja thing then, and I'll let others answer
I expected built-ins to work, clearly they don't
 
so easy with int and so weird with float
xD
 
odds are you could google solutions to "jinja undefinederror" in 5 minutes
 
4:56 PM
I'm on it right now
I just didn't expect this kind of error
 
Why are we doing math inside a template to begin with?
 
It's two errors. One is the availability of function names in the template, the other is arithmetic between Decimals and floats.
 
it's a really simple math operation
it looks like a bug
should I create a Python function and call it from the template?
It would be a pretty stupid function...
 
@DanielGarcíaBaena that's not a bug in Decimal
 
Why would you make a function for something you can control just by what you pass to the template?
 
5:04 PM
how?
 
By rounding off the number, no?
 
I cannot round it, I need the first decimal
 
You're suggesting calling float in the template, so I'm somewhat confused
 
I need the result for this: {{ form.sugars.data - 22.5 }}
but I always get this: TypeError: unsupported operand type(s) for -: 'decimal.Decimal' and 'float'
 
What kind of precision do you need?
 
5:07 PM
one decimal number
 
@roganjosh to be fair I suggested that
 
@AndrasDeak Apologies, I wasn't intending to step on toes
Taking a second look at the discussion
 
nah, I just have no idea how jinja works, I was only talking about the conversion to or from Decimal
 
I've looked through it again and I'm left with:
17 mins ago, by Aran-Fey
Why are we doing math inside a template to begin with?
This issue needs to be fixed on the backend and I'm properly confused about what this is all about
 
so you propose creating a function for subtracting this two values on back?
 
5:18 PM
Yes, I guess. It doesn't matter how you fix it (whether that involves a new function)
 
I was creating it but I saw this like a too easy thing for a function
 
It really doesn't need to be a function. The point is that you should calculate the value in the backend, and the frontend should only display the result
 
yeah, it would be the best thing to do
anyway, I still doesn't understand why it works for int and not for float
ok, this finally works
for the template: {{ decimalMinusFloat(form.sugars.data, 22.5) }}
 
@DanielGarcíaBaena Decimal is used for arbitrary precision math. float for limited precision. Mixing the two is usually not desirable wrong.
 
for the back function:
def decimalMinusFloat(first, last) :
    return float(first) - last
 
5:27 PM
@DanielGarcíaBaena so you've created the function
 
yes, I cannot imagine any other option
 
Fixing it before sending the value to the frontend? I'm guessing you did app.jinja_env.globals.update() and added the function?
 
@MisterMiyagi I see... There's no way to cast to float from Decimal on the template?
 
@DanielGarcíaBaena because ints are exact
 
@roganjosh sure
it works with the new function but I would still find more "elegant" something like float(someDecimal) - 22.5
don't know the English equivalent but this is like matar moscas a cañonazos
 
5:31 PM
So instead of passing your own super-specific function into the template, pass float into the template. Easy.
 
unfortunately most of us don't speak Spanish/Portuguese
 
None of the makes any sense to me anyway, since you can always just fix it on the backend. You've just invented a problem
 
@DanielGarcíaBaena see english.stackexchange.com/questions/100218/…. Short term is "overkill"
 
@Aran-Fey but how? It's not my variable, it's from form
@AndrasDeak it definitely sounds funnier in Spanish
 
Is this going to go anywhere? I feel like we've exhausted this conversation
 
5:34 PM
Yeah, same. Just go with whatever works at this point and let's move on
 
ok, thanks anyway
 
5:52 PM
guys, I need help it's my first time running python code on linux. I'm using Sublime Text, and when trying to run a script I was running completely fine on windows, I get [Finished in 0.2s with exit code -11]
couldn't find an answer in google looks like some advanced error message there might be something wrong with my python maybe?
 
@PedroSpinola What kind of script, how are you exactly running it, etc.
 
I'm running it using a sublime text build system for python3
 
in other words, please provide an MCVE
 
when I run sys.version I get 3.8.0 (default, Oct 28 2019, 16:14:01)
[GCC 8.3.0]
It is a proprietary code Andras so I can't post it here. Is it possible to find what line exactly is generating the error?
 
@PedroSpinola yes, read the traceback, if any. If there's no traceback figure out how you're doing it wrong.
if your environment behaves weirdly always go back to vanilla python executed from a shell
 
5:54 PM
there's no traceback
all it says is :
 
no need to repost it
 
there's some path and dir info
but I suppose it's ok too
 
okay
 
I get similar problem
 
I've helped all I could.
 
5:56 PM
when running code from shell
 
good luck
 
Segmentation fault (core dumped)
 
that's more interesting
That's not something I can guide you to fix, so I think you should ask a coworker.
 
@PedroSpinola Have you tried running a debugger?
 
for now I have tried to output error to output.txt but it's empty
 
6:01 PM
Is this a python extension written in C or something? That could explain why you are getting a seg fault.
 
I don't know C at all
but I'm using some modules
I've read this can be the reason but when I try importing all current modules in a different py file it gives no error
gonna learn how to debug this line by line
 
please do
 
@PedroSpinola Does this "path and dir info" start with "Traceback (most recent call last)" by any chance?
 
@PedroSpinola equivalently you can try coming up with a non-proprietary MCVE.
 
no mister
 
6:03 PM
until that happens we won't be able to help you
 
I understand Andras. Will see what I can do. What I find very strange is it was working perfectly on windows python
same coode, exactly
 
We have exactly zero information about what your code looks like, so I don't find it hard to imagine that there's a difference between the two cases.
when you'll have debugged it or come up with an MCVE, you'll know
 
@PedroSpinola Could run gdb on the python script, and run a backtrace to get the full stack trace. This answer may help: stackoverflow.com/questions/2663841/…
 
@PedroSpinola A Segfault implies interfacing with some third-party, compiled library. These usually differ majorly between OS'.
 
Do we really want to go out of our way to get into all of this?
 
6:08 PM
No, just wanted to clear up what seems like a major mistake in making assumptions for debugging.
 
Pedro's the one who isn't a dev, contemplated paying someone to build their MVP, then decided to go for it and try learning the basics needed (which is great!). They are likely missing a lot of fundamentals (what a segfault is and how they (don't) happen in python, how to debug code, how to create an MCVE), each of which would need a 30-minute lecture at best
 
Ah. That's some useful information. I might have committed a major mistake in making assumptions for debugging.
 
brief cbg
 
6:24 PM
cbg..
 
cbg
 
6:42 PM
had to reinstall linux because I did something wrong which messed mint completely
@AndrasDeak I'm not shying away from lectures at all. That's not what I said yesterday. I contemplated hiring because I was kind of in panic by the complexity of the task, but this panic and fear was superseded already and I'm confident
thanks @RoadRunner and @MisterMiyagi too, I'll take a look into those as soon as my linux is running fine again
I'm not asking for no lecture, nor do I intend to exploit your good will whatsoever...
 
@PedroSpinola I know, but this is not the right place for that. But I know you know this, I was just telling the others.
 
6:57 PM
not the right place for what @AndrasDeak?
 
To have those lectures :)
 
I don't need 'em if I can learn online. I didn't ask nobody here how to debug at no time, because I know I can use google for that.
 
yup
Learning to debug and learning how to create MCVEs go hand in hand
 
01:00 - 19:0019:00 - 00:00

« first day (3549 days earlier)      last day (1382 days later) »