workspace
stringclasses
1 value
channel
stringclasses
1 value
sentences
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
sentence_id
stringlengths
44
53
timestamp
float64
1.5B
1.56B
__index_level_0__
int64
0
106k
pythondev
help
<@Zack> that's a bit tricky to do since I have no way of accessing the salt from the `login_user` method
2018-03-12T17:55:55.000309
Hans
pythondev_help_Hans_2018-03-12T17:55:55.000309
1,520,877,355.000309
38,524
pythondev
help
<@Porsha> I'm presently working on the API endpoints. No login form so far. So I just input the data as `JSON` via `Postman`
2018-03-12T17:56:46.000041
Hans
pythondev_help_Hans_2018-03-12T17:56:46.000041
1,520,877,406.000041
38,525
pythondev
help
Think this snippet has a working bcrypt login example
2018-03-12T17:58:24.000604
Porsha
pythondev_help_Porsha_2018-03-12T17:58:24.000604
1,520,877,504.000604
38,526
pythondev
help
yeah you can extract the salt but that might be getting too in the weeds here
2018-03-12T17:59:40.000551
Zack
pythondev_help_Zack_2018-03-12T17:59:40.000551
1,520,877,580.000551
38,527
pythondev
help
Just use the simple function `hashed = bcrypt.hashpw(password, bcrypt.gensalt())`
2018-03-12T18:00:14.000468
Porsha
pythondev_help_Porsha_2018-03-12T18:00:14.000468
1,520,877,614.000468
38,528
pythondev
help
I mean there’s some very basic boundries here - there’s the password as it goes into the registration function, and the resulting hash, those need to be logged
2018-03-12T18:00:16.000342
Zack
pythondev_help_Zack_2018-03-12T18:00:16.000342
1,520,877,616.000342
38,529
pythondev
help
generates a random salt
2018-03-12T18:00:41.000316
Porsha
pythondev_help_Porsha_2018-03-12T18:00:41.000316
1,520,877,641.000316
38,530
pythondev
help
then when checking the password, there’s the retrieved hash from your database, and the password the user provided that you are passing into bcrypt’s `checkpw`
2018-03-12T18:00:58.000424
Zack
pythondev_help_Zack_2018-03-12T18:00:58.000424
1,520,877,658.000424
38,531
pythondev
help
log those as well
2018-03-12T18:01:00.000602
Zack
pythondev_help_Zack_2018-03-12T18:01:00.000602
1,520,877,660.000602
38,532
pythondev
help
run a full round through your tests, and observe the values, something won’t match
2018-03-12T18:01:18.000455
Zack
pythondev_help_Zack_2018-03-12T18:01:18.000455
1,520,877,678.000455
38,533
pythondev
help
either the passwords you are are passing in don’t match, or something is happening with the hash value between storing it on registration and retrieving on verification
2018-03-12T18:01:45.000371
Zack
pythondev_help_Zack_2018-03-12T18:01:45.000371
1,520,877,705.000371
38,534
pythondev
help
<@Zack> From what I can see when running the tests, basically the `login_user` method isn't running the `check_password`. As shown by the output below
2018-03-12T18:19:15.000055
Hans
pythondev_help_Hans_2018-03-12T18:19:15.000055
1,520,878,755.000055
38,535
pythondev
help
I’m guessing maybe nothing is returned by this? `for user_record in self.userdb`
2018-03-12T18:25:04.000308
Zack
pythondev_help_Zack_2018-03-12T18:25:04.000308
1,520,879,104.000308
38,536
pythondev
help
that’s a weird construction too - usually you’d want to try and look up the user by the login email and retrieve a single record
2018-03-12T18:25:45.000137
Zack
pythondev_help_Zack_2018-03-12T18:25:45.000137
1,520,879,145.000137
38,537
pythondev
help
Sample entries of how the data is being stored. I'm using data structures at the moment instead of an actual database. ``` self.userdb = [{ 'id': '4', 'first_name': 'Joy', 'last_name': 'Chips', 'email': '<mailto:joychips@aol.com|joychips@aol.com>', 'password':...
2018-03-12T18:29:51.000049
Hans
pythondev_help_Hans_2018-03-12T18:29:51.000049
1,520,879,391.000049
38,538
pythondev
help
So the idea is that `self.userdb` is a list, within which each `user` record is stored as a dictionary.
2018-03-12T18:30:23.000322
Hans
pythondev_help_Hans_2018-03-12T18:30:23.000322
1,520,879,423.000322
38,539
pythondev
help
You're storing the pw as plain text
2018-03-12T18:30:34.000431
Porsha
pythondev_help_Porsha_2018-03-12T18:30:34.000431
1,520,879,434.000431
38,540
pythondev
help
That's why I run `for user_record in self.userdb`
2018-03-12T18:30:48.000007
Hans
pythondev_help_Hans_2018-03-12T18:30:48.000007
1,520,879,448.000007
38,541
pythondev
help
the pw needs to be passed through the bcrypt hash function before being stored in the dict
2018-03-12T18:31:13.000359
Porsha
pythondev_help_Porsha_2018-03-12T18:31:13.000359
1,520,879,473.000359
38,542
pythondev
help
Yes. It's sample data to show what I'm doing. When I run the test, I submit fresh user data that has a hashed password
2018-03-12T18:31:28.000390
Hans
pythondev_help_Hans_2018-03-12T18:31:28.000390
1,520,879,488.00039
38,543
pythondev
help
I just don't have sample data reflecting that because the data is non-persistent.
2018-03-12T18:31:57.000294
Hans
pythondev_help_Hans_2018-03-12T18:31:57.000294
1,520,879,517.000294
38,544
pythondev
help
I just wanted to show <@Zack> why I was using `for user_record in self.userdb`
2018-03-12T18:32:25.000084
Hans
pythondev_help_Hans_2018-03-12T18:32:25.000084
1,520,879,545.000084
38,545
pythondev
help
But I'm assuming you're trying to simulate a password in a database?
2018-03-12T18:32:29.000058
Porsha
pythondev_help_Porsha_2018-03-12T18:32:29.000058
1,520,879,549.000058
38,546
pythondev
help
Yes. I am.
2018-03-12T18:32:40.000207
Hans
pythondev_help_Hans_2018-03-12T18:32:40.000207
1,520,879,560.000207
38,547
pythondev
help
oh, so this is what is wrong then
2018-03-12T18:32:59.000355
Zack
pythondev_help_Zack_2018-03-12T18:32:59.000355
1,520,879,579.000355
38,548
pythondev
help
So where the plain text password is, is where the hashed password should go.
2018-03-12T18:33:02.000461
Hans
pythondev_help_Hans_2018-03-12T18:33:02.000461
1,520,879,582.000461
38,549
pythondev
help
the value in the “database” needs to be the hash from registration
2018-03-12T18:33:18.000231
Zack
pythondev_help_Zack_2018-03-12T18:33:18.000231
1,520,879,598.000231
38,550
pythondev
help
ok cool. Probably easier to decouple the database from any classes and store a hashed password
2018-03-12T18:33:27.000323
Porsha
pythondev_help_Porsha_2018-03-12T18:33:27.000323
1,520,879,607.000323
38,551
pythondev
help
yeah
2018-03-12T18:33:28.000004
Zack
pythondev_help_Zack_2018-03-12T18:33:28.000004
1,520,879,608.000004
38,552
pythondev
help
<@Zack> exactly
2018-03-12T18:33:28.000128
Hans
pythondev_help_Hans_2018-03-12T18:33:28.000128
1,520,879,608.000128
38,553
pythondev
help
really - you aren’t saving yourself anything using this plaintext stand-in - you should set up a real database connection
2018-03-12T18:33:57.000225
Zack
pythondev_help_Zack_2018-03-12T18:33:57.000225
1,520,879,637.000225
38,554
pythondev
help
yeah, you’ll have to set it up, and yeah you’ll have to learn how to mock it in your tests (or use an in-memory sqlite version) but it’ll remove a lot of differences otherwise
2018-03-12T18:34:40.000019
Zack
pythondev_help_Zack_2018-03-12T18:34:40.000019
1,520,879,680.000019
38,555
pythondev
help
<@Zack> Yes I know but it was required of me to do it without a database first, then write code for a database later.
2018-03-12T18:34:45.000276
Hans
pythondev_help_Hans_2018-03-12T18:34:45.000276
1,520,879,685.000276
38,556
pythondev
help
ah, okay, makes sense
2018-03-12T18:35:04.000245
Zack
pythondev_help_Zack_2018-03-12T18:35:04.000245
1,520,879,704.000245
38,557
pythondev
help
you can still mock the database with a basic dictionary
2018-03-12T18:35:10.000144
Porsha
pythondev_help_Porsha_2018-03-12T18:35:10.000144
1,520,879,710.000144
38,558
pythondev
help
So right now, I'd just like to figure out how to submit hashed passwords and login a user based on whether the hashed version of the entered password exists.
2018-03-12T18:35:58.000025
Hans
pythondev_help_Hans_2018-03-12T18:35:58.000025
1,520,879,758.000025
38,559
pythondev
help
<@Porsha> yes. But I have to store multiple users. A nested dict structure would be tricky to go through. A list was easier to operate on.
2018-03-12T18:36:42.000437
Hans
pythondev_help_Hans_2018-03-12T18:36:42.000437
1,520,879,802.000437
38,560
pythondev
help
you’ll want to write users to the list as part of the registration
2018-03-12T18:36:54.000245
Zack
pythondev_help_Zack_2018-03-12T18:36:54.000245
1,520,879,814.000245
38,561
pythondev
help
your registration function will need to store the hashed value, not the plain text one, just as if it were in a real database
2018-03-12T18:37:32.000347
Zack
pythondev_help_Zack_2018-03-12T18:37:32.000347
1,520,879,852.000347
38,562
pythondev
help
<@Zack> I think it does that. Just that I have sample data from when I was still using plain text passwords. Maybe the hashed password is being converted to a string given how dictionaries store stuff?
2018-03-12T18:39:19.000099
Hans
pythondev_help_Hans_2018-03-12T18:39:19.000099
1,520,879,959.000099
38,563
pythondev
help
dunno, there’s a simple mistake somewhere. just start logging everything under the sun, or try using the debugger to step through and check values everywhere
2018-03-12T18:40:37.000354
Zack
pythondev_help_Zack_2018-03-12T18:40:37.000354
1,520,880,037.000354
38,564
pythondev
help
everybody does these simple mistakes, it’s just a matter of dumping all the data and seeing where your assumptions aren’t matching up with reality
2018-03-12T18:41:09.000297
Zack
pythondev_help_Zack_2018-03-12T18:41:09.000297
1,520,880,069.000297
38,565
pythondev
help
take nothing for granted
2018-03-12T18:41:19.000335
Zack
pythondev_help_Zack_2018-03-12T18:41:19.000335
1,520,880,079.000335
38,566
pythondev
help
the first rule of debugging - the longer it’s taking to find the problem, the dumber the answer is. :stuck_out_tongue:
2018-03-12T18:41:42.000009
Zack
pythondev_help_Zack_2018-03-12T18:41:42.000009
1,520,880,102.000009
38,567
pythondev
help
usually because you are saying to yourself, “well that must be okay, no need to look at that”
2018-03-12T18:42:01.000175
Zack
pythondev_help_Zack_2018-03-12T18:42:01.000175
1,520,880,121.000175
38,568
pythondev
help
for example you have your `if user_email == email:` - are you sure this works as expected?
2018-03-12T18:42:29.000333
Zack
pythondev_help_Zack_2018-03-12T18:42:29.000333
1,520,880,149.000333
38,569
pythondev
help
I’d still say <@Porsha> is right though, might be better to try and mimic the look up more properly with a dictionary, or at least separate out the lookup of your exact user in another function that you can test separately
2018-03-12T18:43:20.000072
Zack
pythondev_help_Zack_2018-03-12T18:43:20.000072
1,520,880,200.000072
38,570
pythondev
help
cool! write a test that replicates it, and fix it! :slightly_smiling_face:
2018-03-12T18:48:18.000304
Zack
pythondev_help_Zack_2018-03-12T18:48:18.000304
1,520,880,498.000304
38,571
pythondev
help
<@Zack> thanks. Will do.
2018-03-12T18:50:08.000193
Hans
pythondev_help_Hans_2018-03-12T18:50:08.000193
1,520,880,608.000193
38,572
pythondev
help
Can I re-use variable names in different for loops?
2018-03-12T23:06:04.000224
Cheree
pythondev_help_Cheree_2018-03-12T23:06:04.000224
1,520,895,964.000224
38,573
pythondev
help
yes
2018-03-12T23:14:22.000253
Verline
pythondev_help_Verline_2018-03-12T23:14:22.000253
1,520,896,462.000253
38,574
pythondev
help
it can get confusing though, so consider that when you name your variables
2018-03-12T23:14:58.000176
Verline
pythondev_help_Verline_2018-03-12T23:14:58.000176
1,520,896,498.000176
38,575
pythondev
help
Hi guys. I am about to learn Python to code Module and Scripts. Can anyone share me the best document related to my directions that i should read?
2018-03-13T01:58:30.000044
Delma
pythondev_help_Delma_2018-03-13T01:58:30.000044
1,520,906,310.000044
38,576
pythondev
help
Hey there, I am currently trying to build a source package directly from my python code (without running python setup.py sdist). Is there some way to do that? If yes where can I read about it?
2018-03-13T04:40:58.000187
Iola
pythondev_help_Iola_2018-03-13T04:40:58.000187
1,520,916,058.000187
38,577
pythondev
help
There is probably something that can be done if you take a look at `setuptools`
2018-03-13T04:46:03.000506
Micki
pythondev_help_Micki_2018-03-13T04:46:03.000506
1,520,916,363.000506
38,578
pythondev
help
I'm a bit curious about your use case
2018-03-13T04:46:22.000448
Micki
pythondev_help_Micki_2018-03-13T04:46:22.000448
1,520,916,382.000448
38,579
pythondev
help
<@Micki> I was looking into `disutils.core -&gt; setup`
2018-03-13T04:47:04.000028
Iola
pythondev_help_Iola_2018-03-13T04:47:04.000028
1,520,916,424.000028
38,580
pythondev
help
<@Micki> Well I want the my program to package up and spit out a model (as in machine learning model) as a tar.gz file that can then be loaded
2018-03-13T04:48:16.000040
Iola
pythondev_help_Iola_2018-03-13T04:48:16.000040
1,520,916,496.00004
38,581
pythondev
help
the python packaging ecosystem is kind of a mess with duck typing of duck typing of packages. It might become tricky :slightly_smiling_face:
2018-03-13T04:48:25.000097
Micki
pythondev_help_Micki_2018-03-13T04:48:25.000097
1,520,916,505.000097
38,582
pythondev
help
<@Micki> And I don’t want to call an external shell command just for the packaging
2018-03-13T04:48:58.000208
Iola
pythondev_help_Iola_2018-03-13T04:48:58.000208
1,520,916,538.000208
38,583
pythondev
help
maybe this can be of help <https://docs.python.org/3.6/library/zipimport.html>
2018-03-13T04:49:55.000299
Micki
pythondev_help_Micki_2018-03-13T04:49:55.000299
1,520,916,595.000299
38,584
pythondev
help
it might allow you to bypass the packaging and load the zip files directly
2018-03-13T04:50:19.000152
Micki
pythondev_help_Micki_2018-03-13T04:50:19.000152
1,520,916,619.000152
38,585
pythondev
help
<@Micki> I mean it works if I call `python setup.py sdist`, I just don’t want to call it from console, I want my program to spit out the package directly
2018-03-13T04:50:28.000333
Iola
pythondev_help_Iola_2018-03-13T04:50:28.000333
1,520,916,628.000333
38,586
pythondev
help
ah yeah ok
2018-03-13T04:51:20.000409
Micki
pythondev_help_Micki_2018-03-13T04:51:20.000409
1,520,916,680.000409
38,587
pythondev
help
maybe running the command in a subprocess is the easiest way
2018-03-13T04:51:41.000345
Micki
pythondev_help_Micki_2018-03-13T04:51:41.000345
1,520,916,701.000345
38,588
pythondev
help
<@Micki> Yeah I tried that but I was wondering if this is really the way to go. I mean I cannot possibly be the only one who has this requirement
2018-03-13T04:52:30.000185
Iola
pythondev_help_Iola_2018-03-13T04:52:30.000185
1,520,916,750.000185
38,589
pythondev
help
<@Micki> I mean running a shell command from a subprocess seems kind of stupid to me. There has to be a more elegant way
2018-03-13T04:53:32.000270
Iola
pythondev_help_Iola_2018-03-13T04:53:32.000270
1,520,916,812.00027
38,590
pythondev
help
I have never done that but yeah maybe someone else has :slightly_smiling_face:
2018-03-13T04:53:33.000401
Micki
pythondev_help_Micki_2018-03-13T04:53:33.000401
1,520,916,813.000401
38,591
pythondev
help
<@Micki> I hope, but thank for helping!
2018-03-13T04:53:51.000469
Iola
pythondev_help_Iola_2018-03-13T04:53:51.000469
1,520,916,831.000469
38,592
pythondev
help
well on the other hand it allows you to be sure the standard packaging still works :smile:
2018-03-13T04:53:58.000379
Micki
pythondev_help_Micki_2018-03-13T04:53:58.000379
1,520,916,838.000379
38,593
pythondev
help
What’s the best way to check if a module has been imported? I’m currently setting a variable as the library and then doing an IF statement to see if it’s there. How can I expand this for checking for multiple modules without having a tonne of variables?
2018-03-13T12:13:27.000807
Celinda
pythondev_help_Celinda_2018-03-13T12:13:27.000807
1,520,943,207.000807
38,594
pythondev
help
``` import foo assert 'foo' in locals() ```
2018-03-13T12:14:23.000026
Garrett
pythondev_help_Garrett_2018-03-13T12:14:23.000026
1,520,943,263.000026
38,595
pythondev
help
Why do you want to do this, though?
2018-03-13T12:14:40.000893
Garrett
pythondev_help_Garrett_2018-03-13T12:14:40.000893
1,520,943,280.000893
38,596
pythondev
help
usually if an import fails it will raise an `ImportError` you don't really need to check it
2018-03-13T12:14:46.000527
Micki
pythondev_help_Micki_2018-03-13T12:14:46.000527
1,520,943,286.000527
38,597
pythondev
help
Well that's if it fails to import
2018-03-13T12:15:02.000943
Garrett
pythondev_help_Garrett_2018-03-13T12:15:02.000943
1,520,943,302.000943
38,598
pythondev
help
Because I want to make sure the script imports all the modules it needs on first boot
2018-03-13T12:15:05.000273
Celinda
pythondev_help_Celinda_2018-03-13T12:15:05.000273
1,520,943,305.000273
38,599
pythondev
help
You could need to check that an import is the correct import
2018-03-13T12:15:15.000375
Garrett
pythondev_help_Garrett_2018-03-13T12:15:15.000375
1,520,943,315.000375
38,600
pythondev
help
<@Celinda> Won't it fail to run without the imports?
2018-03-13T12:15:27.000098
Garrett
pythondev_help_Garrett_2018-03-13T12:15:27.000098
1,520,943,327.000098
38,601
pythondev
help
Hm very true
2018-03-13T12:15:44.000568
Celinda
pythondev_help_Celinda_2018-03-13T12:15:44.000568
1,520,943,344.000568
38,602
pythondev
help
This sounds more...paranoid...than Python usually expects/encourages :slightly_smiling_face:
2018-03-13T12:16:03.000635
Garrett
pythondev_help_Garrett_2018-03-13T12:16:03.000635
1,520,943,363.000635
38,603
pythondev
help
Not sure how your script is set up but I thing python does all the import at launch
2018-03-13T12:16:53.000582
Micki
pythondev_help_Micki_2018-03-13T12:16:53.000582
1,520,943,413.000582
38,604
pythondev
help
if they are defined at the top level
2018-03-13T12:17:07.000291
Micki
pythondev_help_Micki_2018-03-13T12:17:07.000291
1,520,943,427.000291
38,605
pythondev
help
Yeah I’ve done that, I just don’t want to send it over to another user and get the whole ‘Why isn’t it running’ etc
2018-03-13T12:17:26.000629
Celinda
pythondev_help_Celinda_2018-03-13T12:17:26.000629
1,520,943,446.000629
38,606
pythondev
help
Was trying to automate it to save that pain
2018-03-13T12:17:35.000047
Celinda
pythondev_help_Celinda_2018-03-13T12:17:35.000047
1,520,943,455.000047
38,607
pythondev
help
If the import fails, the whole thing should fail to run...including your import-checking statements
2018-03-13T12:18:01.000453
Garrett
pythondev_help_Garrett_2018-03-13T12:18:01.000453
1,520,943,481.000453
38,608
pythondev
help
btw you'd have a list of requirements to install the modules anyway
2018-03-13T12:18:25.000039
Patrick
pythondev_help_Patrick_2018-03-13T12:18:25.000039
1,520,943,505.000039
38,609
pythondev
help
Could I just create a script using PIP to install all the modules first?
2018-03-13T12:18:42.000918
Celinda
pythondev_help_Celinda_2018-03-13T12:18:42.000918
1,520,943,522.000918
38,610
pythondev
help
Put all of the 3rd party modules in a `requirements.txt` file and have them install them with `pip install -r requirements.txt`
2018-03-13T12:19:25.000926
Garrett
pythondev_help_Garrett_2018-03-13T12:19:25.000926
1,520,943,565.000926
38,611
pythondev
help
Ah fantastic, That’ll do it nicely.
2018-03-13T12:20:43.000540
Celinda
pythondev_help_Celinda_2018-03-13T12:20:43.000540
1,520,943,643.00054
38,612
pythondev
help
or you could use `pipenv`
2018-03-13T12:21:16.000720
Terrence
pythondev_help_Terrence_2018-03-13T12:21:16.000720
1,520,943,676.00072
38,613
pythondev
help
to handle requirements, it’s a lot tidier and neater than storing a `requirements.txt`
2018-03-13T12:21:40.000295
Terrence
pythondev_help_Terrence_2018-03-13T12:21:40.000295
1,520,943,700.000295
38,614
pythondev
help
you can also use it to separate packages for development and production.
2018-03-13T12:21:59.000417
Terrence
pythondev_help_Terrence_2018-03-13T12:21:59.000417
1,520,943,719.000417
38,615
pythondev
help
Yeah but that introduces having to install `pipenv` after you've installed `pip` (which comes standard in all new Python's)
2018-03-13T12:22:42.000968
Garrett
pythondev_help_Garrett_2018-03-13T12:22:42.000968
1,520,943,762.000968
38,616
pythondev
help
If you're worried about people having issues running something, don't introduce yet another dependency
2018-03-13T12:23:10.000895
Garrett
pythondev_help_Garrett_2018-03-13T12:23:10.000895
1,520,943,790.000895
38,617
pythondev
help
true, but surely having a package manager that can handle dependency issues, such as OS specific packages, that can benefit you?
2018-03-13T12:24:51.000832
Terrence
pythondev_help_Terrence_2018-03-13T12:24:51.000832
1,520,943,891.000832
38,618
pythondev
help
Depends on what you're doing
2018-03-13T12:25:26.000093
Garrett
pythondev_help_Garrett_2018-03-13T12:25:26.000093
1,520,943,926.000093
38,619
pythondev
help
Are you going to do a lot of Python development? Then maybe `pipenv` is the right choice for you. Or maybe Docker or some other form of container-ish tooling is
2018-03-13T12:25:55.000007
Garrett
pythondev_help_Garrett_2018-03-13T12:25:55.000007
1,520,943,955.000007
38,620
pythondev
help
Is this the first and last Python thing you're messing with? Why bother, then?
2018-03-13T12:26:05.000198
Garrett
pythondev_help_Garrett_2018-03-13T12:26:05.000198
1,520,943,965.000198
38,621
pythondev
help
fair enough, yh for smaller projects you probably won’t see most of the benefits. Docker is a good shout though requires more setup up than running `pipenv`
2018-03-13T12:27:15.000213
Terrence
pythondev_help_Terrence_2018-03-13T12:27:15.000213
1,520,944,035.000213
38,622
pythondev
help
Yeah, I'm not proposing Docker as a lighterweight alternative to `pipenv`
2018-03-13T12:28:13.000878
Garrett
pythondev_help_Garrett_2018-03-13T12:28:13.000878
1,520,944,093.000878
38,623