« first day (3966 days earlier)      last day (999 days later) » 

12:49 AM
Cbg
 
cbg
 
1:06 AM
Uh I just hate it when I am answering a question and the other person posts faster because me having to deal with the captcha...
 
maybe they solved the captcha faster ;)
 
Nah I don't think so, I think it's that something with my computer, maybe some virus protection..
 
ohh, ok, I assumed captcha was from SO
 
Not sure lol
Anyway I could answer even faster lol
I mean sometimes it just fails me because I miss a single block which contains maybe like a pixel of what the object it wants me to select..
 
 
2 hours later…
3:45 AM
When do you pass object to a class definition? What is this called?
class Foo(object):
    pass
 
that is not needed in python 3 in case you were not aware
 
Ah so this is from python 2.x
Thank you
 
it works in python 3 as well, its just that it you dont have to do that explicitly, new style classes is what it is called
 
 
4 hours later…
7:26 AM
cbg
 
 
2 hours later…
8:57 AM
Hey guys, how can I ensure that {"model": "test", "model2": ['test', 'test2]} this dict.values() always returns a list??

@property
def grid_attrs(self):
for attr_key, attr_value in self.product.attrs.items():
# Now, let's ensure that "some_key" always return a list.
# what if attr_value is already a list? or what is attr_value is a single string, we can't loop like this [item for item in attr_value]

if isinstance(attr_value, list):
print('list')
if isinstance(attr_value, str):
print('single value')
 
I don't understand the question. First you ask about dict.values(), but then you show a piece of code that never calls dict.values() at all and instead tries to convert the values inside the dict to lists
Is the question "Given a dict like for example {"model": "test", "model2": ['test', 'test2]}, how can I ensure that all values in the dict are lists? i.e. I want to convert that dict to {"model": ["test"], "model2": ['test', 'test2]}"?
 
want to convert that dict to {"model": ["test"], "model2": ['test', 'test2]}", that's right
 
Do you want to create a new dict or modify the self.product.attrs dict?
 
i want to modify it
 
Ok. The problem I see is that you're trying to do it in a property getter, and that's really not the right place for code that modifies something
 
9:09 AM
cbg
hey guys am I being an idiot? with this line i keep receiving the error
OSError: [Errno 22] Invalid argument: 'seedlist.jsonlines'
with open("seedlist.jsonlines", "a") as dest:
and cannot figure why
 
You essentially want something like this, just don't put it inside a getter
demo_dict = {'key1': 'foo', 'key2': ['bar', 'baz']}

for key, value in demo_dict.items():
    if isinstance(value, str):
        value = [value]
    else:
        try:
            value = list(value)
        except TypeError:
            value = [value]

    demo_dict[key] = value
 
@Kwsswart have you accidentally called something open?
 
No I havent
 
Are you sure... what does help(open) show you?
 
And you don't have any open brackets so this is somehow becoming the argument to something else?
I'm not even sure how the latter can happen when using "with" (I would have thought that would error first) but... it's not easy to see any other way you could be getting that error
 
9:42 AM
strange when I removed the file from the directory it seemed to work but i thought "a" was to append info to file
 
"a" is to append, it creates a file if one doesn't exist however, iirc.
however, i doubt that was the issue. if you keep the file back in the directory does it keep working now?
 
Thats what I thought hence why I dont understand why removing the file would stop the error
 
yeah no, keep the file there, and try again. i can bet a few quatloos it keeps working
 
10:26 AM
@Aran-Fey
Everything becomes a list {'Model': ['N', 'X', '.', 'H', 'D', 'G', 'E', 'L', '.', '0', '0', '9'], 'Gamintojas': ['A', 'c', 'e', 'r'], 'refurbished': ['F', 'a', 'l', 's', 'e']}
 
...using what code? Because mine doesn't do that
 
def grid_attrs(self):
for attr_key, attr_value in self.product.attrs.items():
# Now, let's ensure that "some_key" always return a list.
# what if attr_value is already a list? or what is attr_value is a single string, we can't loop like this [item for item in attr_value] without checking first

if isinstance(attr_value, str):
attr_value = list(attr_value)

try:
attr_value = list(attr_value)
except TypeError:
attr_value = list(attr_value)

self.product.attrs[attr_key] = attr_value

print(self.product.attrs)
 
Umm, why do you have 3 branches when all of them do the same attr_value = list(attr_value)?
 
what do you mean?
is there a difference between attr_value = list(attr_value) and attr_value = [attr_value]?
 
@DziuGas please can you read our formatting guide and use that for your code? You can also practice in the sandbox if necessary
 
10:31 AM
I posted a working piece of code for you. All you have to do is copy-paste it and rename some variables. I don't know why you decided to rewrite it, or not to use it, but I cannot make this any easier for you.
 
Any explanation pls?
 
Explanation for what?
 
is there any difference between [] ant list()?
 
Yes. ['foo'] creates a list that contains 'foo'. list('foo') iterates over 'foo' and stores every element in a list, so it becomes ['f', 'o', 'o']
 
oh, got it
so list() iterates every char in the string right
and then creates that ugly format as [f,o,o...]
 
10:40 AM
@DziuGas it's not an ugly format. It's a list
 
@DziuGas yes. list() iterates on whatever is passed to it to make a list from it.
[my_stuff] does no iteration, as aran said. it just makes a list with a single item, my_stuff. very different from list()
 
11:02 AM
@DziuGas this is not the first time that I see regulars making irritated remarks about your activity here. You should at least be able to copy-paste ready-made solutions. You'll have to improve how you ask for help and how you use the time of the volunteers here, because patience is a non-renewable resource.
 
11:13 AM
Hi Everyone, I am Hamza. I am glad to meet you all. I am learning Data Science and Machine Learning. Nice to meet you all!!
 
Welcome to the room
 
how to skip the first few elements of a list?
example i get a list of files using listdir and sort the list using ctime. i want to skip the first 10 elements of the list (the newest ones) and start treating from the 11th item.
 
your_list[11:]
 
i understand that is slicing but what does it mean the colon?
 
the slicing syntax is [start_position: end_position: step_size] The colon is part of the slicing syntax.
implicitly, start is 0, end is whatever is the end of the list, and step size is 1. so when you write [11:] it's equivalent to [11: end_of_your_list]
 
11:19 AM
if you understand it is slicing, then how did you not know what the colon is for?
without the colon, it is just indexing, so you are aware of the term
 
@python_user your_list[10:]? :p
 
@danidar this question reminds me of, where is the magic? readthesequences.com/The-Simple-Truth
 
@JonClements ahh nice catch, RIP me, danidar use 10 as suggested by Jon
 
those pesky off-by-0 errors
 
11:29 AM
@ParitoshSingh seems you were right it hasnt stopped again really strange
 
 
1 hour later…
12:58 PM
Python
It's pretty good.
 
that is random :D
 
Every single morning I have the urge to write "Python" and nothing else, but I resist because it doesn't seem useful to do so
Perhaps my monkey hindbrain thinks that speaking the True Name of the thing will imbue it with greater power
 
I am tempted to look back at the transcript to see if you have sneaked Python as the first message of the day
 
Really it makes about as much sense as saying "good morning", it's not as if my wishes can control how good or bad the morning will be. I may as well send my positive vibes to a particular object
 
1:17 PM
@Kevin someones a fan of the eragon series :P
 
I remember enjoying the first book, fairly good even when disregarding the "written by a 15 year old!" marketing
 
yeah the first was awesome, second and 3 were good
4th I never read
 
tbh probably i am biased as ready it when i was like 14 15 thus i enjoyed them all havent read them in a long time though
 
 
1 hour later…
2:46 PM
Cbg
 
Be kind and avoid sarcasm -- tone is hard to decipher online.
 
Sensible
 
Anyone here used dynamixel ? This thing refuses to make my sandwich correctly.
 
@Kevin Is that sarcasm?
 
@DNikolz Not sure if figure of speech and this is some python library or actual toaster model :D
 
2:59 PM
nub
 
google tells me not figure of speech and there is an actual sandwich making task at hand XD
 
@Hakaishin Just make sure the instructions are clear
 
@Aran-Fey No, and neither is this sentence, and also this sentence is not a paradox nor an internally consistent statement of uncertain truth value
I've dabbled a small amount in robotics but I haven't used or heard of dynamixel specifically
My computer just bluescreened while I was browsing their website and I choose to believe it was their fault. Therefore I recommend switching to a different actuator provider.
 
if their website does that to your computer... imagine what the automaton might do if you let it in your house and leave it free to roam around while you're asleep...
 
Get to cleaning.
 
3:08 PM
Disobeying the three laws of robotics to fold my towels into thirds, rather than into quarters like I like
 
@Kevin reasonable
 
Embrace the robots. If they can cause error without resolution, that's the real hazard
 
@Kevin quarter camp unite
 
Luckily it enters an infinite loop on the first towel, trying to calculate the nonrepeating base two representation of 1/3
 
3:25 PM
hi, is __name__ == "__main__" necessary if I'm just writing the program for myself?`
 
@Kevin which way does it leave the open end of the toilet roll hanging?
Over or under is a big part of the human character. I'm less concerned about the towels
 
 
That's it. We need rid of AI immediately. What a grim future!
 
I'm partial to over myself but under is justifiable in households that have cats or toddlers or other beings that might bat downwards at the amusing rotatable device
In the post-scarcity future, each square will be 3d printed individually, and the question will cease to be meaningful
 
Argh you guys smell funny
 
3:35 PM
You can't prove that >_>
If you think we stink because we probably don't know enough about dynamixel to answer your sandwich-making question, I welcome you to ask anyway and maybe we can puzzle it out anyway
 
The fibre cables add weight to megatrons motor systems, causing a mis-calculation with the chopping.. It killed my cat
 
@Kevin You haven't switched to using the three seashells yet? :p
 
They can't penetrate the tinfoil jumpsuit I use to repel government beams
 
@RoyalFrog no. Without context, we can't give a better answer than that
 
@DNikolz welcome. Please stop this. You're welcome to engage in chat that makes sense.
 
3:41 PM
@RoyalFrog have you asked yourself what if __name__ == '__main__' actually does, and researched it?
 
Experimental approach: try writing programs without it, and see if something bad happens
 
Found an admin.. okk
 
You've got 3 ROs (including me) and 1 moderator (from a quick scan of the online members). You shouldn't be under any illusion that this would be acceptable when we're not around
 
@DNikolz final warning
 
 
2 hours later…
5:36 PM
Hi everyone, is there a way to use record_path argument for multiple list of dicts at once ? referring to this document: towardsdatascience.com/…
If not, is the only way to have common fields for 2 or more dataframes while doing this and then merging?
 
If you're asking "am I allowed to call json_normalize more than once and give it the same record_path argument each time?", I don't see why not
 
5:57 PM
I suspect I'm oversimplifying. If you could provide some examples of typical input and desired output, maybe we can work out an approach.
 
 
5 hours later…
11:20 PM
Did the code block font for the mains just changed or am I paranoid?
 

« first day (3966 days earlier)      last day (999 days later) »