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 | if f.eof: | 2017-11-30T09:47:57.000615 | Winnie | pythondev_help_Winnie_2017-11-30T09:47:57.000615 | 1,512,035,277.000615 | 101,603 |
pythondev | help | but i'm just a noob so take this with a grain of salt : ) | 2017-11-30T09:48:01.000685 | Ora | pythondev_help_Ora_2017-11-30T09:48:01.000685 | 1,512,035,281.000685 | 101,604 |
pythondev | help | I can see where you're coming from but I'm looking for a less hacky solution :stuck_out_tongue: | 2017-11-30T09:48:40.000218 | Winnie | pythondev_help_Winnie_2017-11-30T09:48:40.000218 | 1,512,035,320.000218 | 101,605 |
pythondev | help | ahhhh okay, thanks for that. Ill have a look into it :slightly_smiling_face: | 2017-11-30T09:51:58.000011 | Robbin | pythondev_help_Robbin_2017-11-30T09:51:58.000011 | 1,512,035,518.000011 | 101,606 |
pythondev | help | ```
In [1]: from functools import partial
In [2]: with open('testfile', 'rb') as f:
...: total = 0
...: reader = partial(f.read, 64) # 64 bytes per read
...: for block in iter(reader, b''): # till nothing left...
...: total += len(block)
...: print(f'Read {total} bytes!')
Read 13... | 2017-11-30T09:52:28.000198 | Suellen | pythondev_help_Suellen_2017-11-30T09:52:28.000198 | 1,512,035,548.000198 | 101,607 |
pythondev | help | > One useful application of the second form of iter() is to read lines of a file until a certain line is reached. The following example reads a file until the readline() method returns an empty string:
> with open('mydata.txt') as fp:
> for line in iter(fp.readline, ''):
> process_line(line) | 2017-11-30T09:53:38.000570 | Suellen | pythondev_help_Suellen_2017-11-30T09:53:38.000570 | 1,512,035,618.00057 | 101,608 |
pythondev | help | So you literally read until you can't anymore (and emptiness is returned) | 2017-11-30T09:54:10.001153 | Suellen | pythondev_help_Suellen_2017-11-30T09:54:10.001153 | 1,512,035,650.001153 | 101,609 |
pythondev | help | Text files have a nice shortcut, which is just:
`for line in f:` | 2017-11-30T09:55:04.000395 | Suellen | pythondev_help_Suellen_2017-11-30T09:55:04.000395 | 1,512,035,704.000395 | 101,610 |
pythondev | help | hmm | 2017-11-30T09:58:20.000082 | Winnie | pythondev_help_Winnie_2017-11-30T09:58:20.000082 | 1,512,035,900.000082 | 101,611 |
pythondev | help | I think I'm doing something the wrong way | 2017-11-30T09:58:26.000230 | Winnie | pythondev_help_Winnie_2017-11-30T09:58:26.000230 | 1,512,035,906.00023 | 101,612 |
pythondev | help | the are at least of few ways to do this | 2017-11-30T09:59:43.000813 | Suellen | pythondev_help_Suellen_2017-11-30T09:59:43.000813 | 1,512,035,983.000813 | 101,613 |
pythondev | help | I've used that method on bin files also, just substitute iter(fp.read(numbytes), '') | 2017-11-30T10:05:27.001020 | Sirena | pythondev_help_Sirena_2017-11-30T10:05:27.001020 | 1,512,036,327.00102 | 101,614 |
pythondev | help | it should yes | 2017-11-30T10:06:23.000868 | Ciera | pythondev_help_Ciera_2017-11-30T10:06:23.000868 | 1,512,036,383.000868 | 101,615 |
pythondev | help | `fp.read(numbytes)` won't work | 2017-11-30T10:07:54.000596 | Suellen | pythondev_help_Suellen_2017-11-30T10:07:54.000596 | 1,512,036,474.000596 | 101,616 |
pythondev | help | `iter()` expects a function that it will call | 2017-11-30T10:08:30.000596 | Suellen | pythondev_help_Suellen_2017-11-30T10:08:30.000596 | 1,512,036,510.000596 | 101,617 |
pythondev | help | `fp.read(n)` returns an integer, so you need to bound `n` to `fp.read` without calling it: `functools.partial(fp.read, n)` | 2017-11-30T10:08:57.000464 | Suellen | pythondev_help_Suellen_2017-11-30T10:08:57.000464 | 1,512,036,537.000464 | 101,618 |
pythondev | help | it's the same thing as `lambda: fp.read(64)` | 2017-11-30T10:09:26.000166 | Suellen | pythondev_help_Suellen_2017-11-30T10:09:26.000166 | 1,512,036,566.000166 | 101,619 |
pythondev | help | ah, I think I probably stuffed it in a lambda then | 2017-11-30T10:10:57.000541 | Sirena | pythondev_help_Sirena_2017-11-30T10:10:57.000541 | 1,512,036,657.000541 | 101,620 |
pythondev | help | :slightly_smiling_face: | 2017-11-30T10:11:13.000171 | Suellen | pythondev_help_Suellen_2017-11-30T10:11:13.000171 | 1,512,036,673.000171 | 101,621 |
pythondev | help | I just looked back through my old project to see how I did it, and I ended up rewriting around that particular line, so it's not there anymore, but I definitely had a loop terminating on reading a file and returning empty string or raising StopIteration or something like that if it didn't work | 2017-11-30T10:12:48.000278 | Sirena | pythondev_help_Sirena_2017-11-30T10:12:48.000278 | 1,512,036,768.000278 | 101,622 |
pythondev | help | `for blk in iter(lambda: fbin.read(numbytes), ''):` should do it | 2017-11-30T10:15:02.000110 | Sirena | pythondev_help_Sirena_2017-11-30T10:15:02.000110 | 1,512,036,902.00011 | 101,623 |
pythondev | help | or even `b''` ! | 2017-11-30T10:15:35.000014 | Suellen | pythondev_help_Suellen_2017-11-30T10:15:35.000014 | 1,512,036,935.000014 | 101,624 |
pythondev | help | Yesterday I did some work with Redis and subscribed to 'notifications' channel. And for about 10 minutes couldn't understand why the hell I didn't receive ANY notifications I was clearly sending! | 2017-11-30T10:16:45.000784 | Suellen | pythondev_help_Suellen_2017-11-30T10:16:45.000784 | 1,512,037,005.000784 | 101,625 |
pythondev | help | Turns out Redis is all binary and it's actually `b'notifications'`... | 2017-11-30T10:17:13.000201 | Suellen | pythondev_help_Suellen_2017-11-30T10:17:13.000201 | 1,512,037,033.000201 | 101,626 |
pythondev | help | <@Suellen> this is what I was doing. Perhaps there's a more pythonic way?
```
with open(filename) as f:
while True:
role = {}
line = f.readline()
if line:
mode = "name"
role[mode] = line.strip()
else:
break
... | 2017-11-30T10:28:55.000861 | Winnie | pythondev_help_Winnie_2017-11-30T10:28:55.000861 | 1,512,037,735.000861 | 101,627 |
pythondev | help | oops, just noticed this thread. I think so yeah, but if you write Europe/Amsterdam, it might return `Europe/Amsterdam` as the timezone rather than CET. I think a lot of those timezone fields are not super standardized so it depends what libs are underneath, and I only really have experience on the Linux side of those l... | 2017-11-30T10:38:36.000500 | Sirena | pythondev_help_Sirena_2017-11-30T10:38:36.000500 | 1,512,038,316.0005 | 101,628 |
pythondev | help | Not sure for what project of your it is <@Jesusa> but my initial approach would be to trust datetime or others date library and investigate if you get bugs | 2017-11-30T10:40:05.000584 | Ciera | pythondev_help_Ciera_2017-11-30T10:40:05.000584 | 1,512,038,405.000584 | 101,629 |
pythondev | help | you may find this reference useful. It looks like CET is used for standard and daylight both, as is Europe/Amsterdam, and they are the same values for GMT offsets | 2017-11-30T10:41:40.000717 | Sirena | pythondev_help_Sirena_2017-11-30T10:41:40.000717 | 1,512,038,500.000717 | 101,630 |
pythondev | help | <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones> | 2017-11-30T10:41:43.000035 | Sirena | pythondev_help_Sirena_2017-11-30T10:41:43.000035 | 1,512,038,503.000035 | 101,631 |
pythondev | help | <@Ciera> yea I was thinking that's the easiest way... though for creating an automated trading sytem i prefer not to deliberately wait for known potential bugs :slightly_smiling_face: | 2017-11-30T11:11:18.000132 | Jesusa | pythondev_help_Jesusa_2017-11-30T11:11:18.000132 | 1,512,040,278.000132 | 101,632 |
pythondev | help | <@Sirena> linux here too, and i also considered a GMT offset, but the problem is that I think that's the actual one that might change. maybe if i could mock changing the system time, I could figure it out? | 2017-11-30T11:12:49.001414 | Jesusa | pythondev_help_Jesusa_2017-11-30T11:12:49.001414 | 1,512,040,369.001414 | 101,633 |
pythondev | help | I think that in general it's going to work fine with either CET or Europe/Amsterdam | 2017-11-30T11:13:27.001373 | Sirena | pythondev_help_Sirena_2017-11-30T11:13:27.001373 | 1,512,040,407.001373 | 101,634 |
pythondev | help | it sounds like CET is technically deprecated but still supported | 2017-11-30T11:14:21.000262 | Sirena | pythondev_help_Sirena_2017-11-30T11:14:21.000262 | 1,512,040,461.000262 | 101,635 |
pythondev | help | and for a trading system, yah you'll definitely want to mock it and check a bunch of boundary cases | 2017-11-30T11:14:58.001250 | Sirena | pythondev_help_Sirena_2017-11-30T11:14:58.001250 | 1,512,040,498.00125 | 101,636 |
pythondev | help | Give me a minute, I'm checking things out. | 2017-11-30T11:30:45.000799 | Glinda | pythondev_help_Glinda_2017-11-30T11:30:45.000799 | 1,512,041,445.000799 | 101,637 |
pythondev | help | First off you have two statements: ``` if line.startswith("Alternate: "):
role_dictionary[mode] = buff.strip()
mode = "alt1"
buff = ""
line = line[11:]``` | 2017-11-30T11:34:30.000594 | Glinda | pythondev_help_Glinda_2017-11-30T11:34:30.000594 | 1,512,041,670.000594 | 101,638 |
pythondev | help | Do you mean to redine `mode` *after* using it in `role[mode] = buff.strip()` | 2017-11-30T11:35:19.000799 | Glinda | pythondev_help_Glinda_2017-11-30T11:35:19.000799 | 1,512,041,719.000799 | 101,639 |
pythondev | help | <@Winnie> | 2017-11-30T11:35:32.000616 | Glinda | pythondev_help_Glinda_2017-11-30T11:35:32.000616 | 1,512,041,732.000616 | 101,640 |
pythondev | help | Without seeing what your data looks like this is a bit more readable | 2017-11-30T11:49:58.001331 | Glinda | pythondev_help_Glinda_2017-11-30T11:49:58.001331 | 1,512,042,598.001331 | 101,641 |
pythondev | help | I could also combine these lines ```
for line in file:
# if line starts with alternate save the normal description
if line.startswith("Alternate: "):
role_dictionary[alt2_mode] = build_line(line, len(alt2_mode))
# if line starts with 2nd alternate save the alternate
elif line.startswith("2nd Alt... | 2017-11-30T11:51:06.001077 | Glinda | pythondev_help_Glinda_2017-11-30T11:51:06.001077 | 1,512,042,666.001077 | 101,642 |
pythondev | help | I want to build a simple API, does someone knows between falcon and flask, with framework is better if I'm looking one that has a good ORM and it's easy to create routes and all that stuff? | 2017-11-30T11:51:24.000791 | Shanda | pythondev_help_Shanda_2017-11-30T11:51:24.000791 | 1,512,042,684.000791 | 101,643 |
pythondev | help | Django and DRF is pretty great if you want to go the Django route. | 2017-11-30T11:52:19.000499 | Louis | pythondev_help_Louis_2017-11-30T11:52:19.000499 | 1,512,042,739.000499 | 101,644 |
pythondev | help | I'd recommend flask because `sql-alchemy` is really easy to work with flask, and routing is super easy. But I'm not familiar with falcon so it could be evne easier. | 2017-11-30T11:52:22.000595 | Glinda | pythondev_help_Glinda_2017-11-30T11:52:22.000595 | 1,512,042,742.000595 | 101,645 |
pythondev | help | <https://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask> miguelgrinberg is the go to guy onflask | 2017-11-30T11:53:26.000655 | Glinda | pythondev_help_Glinda_2017-11-30T11:53:26.000655 | 1,512,042,806.000655 | 101,646 |
pythondev | help | His `Flask Mega-Tutorial` is the go to standard. | 2017-11-30T11:53:41.000766 | Glinda | pythondev_help_Glinda_2017-11-30T11:53:41.000766 | 1,512,042,821.000766 | 101,647 |
pythondev | help | falcon is built for speed and the community has all sorts of modifications and add-ons. If you're looking to do more manual work and reading source code, then falcon may be your bag. I agree with Pi though Django (or Flask) has the parts to get you going. | 2017-11-30T11:56:53.000948 | Seema | pythondev_help_Seema_2017-11-30T11:56:53.000948 | 1,512,043,013.000948 | 101,648 |
pythondev | help | miguel is great, if you start to drink the juice, you'll end up being a full fledged microservices guru :wink: | 2017-11-30T11:59:44.000959 | Seema | pythondev_help_Seema_2017-11-30T11:59:44.000959 | 1,512,043,184.000959 | 101,649 |
pythondev | help | Miguel Grinberg is about to release the fully updated version of his Flask book. | 2017-11-30T12:03:30.000979 | Louvenia | pythondev_help_Louvenia_2017-11-30T12:03:30.000979 | 1,512,043,410.000979 | 101,650 |
pythondev | help | I'm so ready:pineapple: | 2017-11-30T12:03:55.000147 | Glinda | pythondev_help_Glinda_2017-11-30T12:03:55.000147 | 1,512,043,435.000147 | 101,651 |
pythondev | help | Thanks guys! flask sound like a good option then!
<@Glinda> <@Seema> <@Louis> | 2017-11-30T12:05:04.000531 | Shanda | pythondev_help_Shanda_2017-11-30T12:05:04.000531 | 1,512,043,504.000531 | 101,652 |
pythondev | help | Django is more robust and I hope to eventually learn it, but so many other things on my plate and no current need. :disappointed: | 2017-11-30T12:10:00.000078 | Glinda | pythondev_help_Glinda_2017-11-30T12:10:00.000078 | 1,512,043,800.000078 | 101,653 |
pythondev | help | <@Winnie> | 2017-11-30T12:11:48.001426 | Glinda | pythondev_help_Glinda_2017-11-30T12:11:48.001426 | 1,512,043,908.001426 | 101,654 |
pythondev | help | If you considered Falcon, you should look at Hug (<https://github.com/timothycrosley/hug>). It's built on top of Falcon and makes it easier/more friendly to use...but only works with python3 | 2017-11-30T13:27:27.000352 | Jenise | pythondev_help_Jenise_2017-11-30T13:27:27.000352 | 1,512,048,447.000352 | 101,655 |
pythondev | help | any ideas why? | 2017-11-30T13:43:38.000755 | Dominick | pythondev_help_Dominick_2017-11-30T13:43:38.000755 | 1,512,049,418.000755 | 101,656 |
pythondev | help | <https://stackoverflow.com/questions/11283625/bash-overwrite-last-terminal-line> | 2017-11-30T13:51:20.000864 | Glinda | pythondev_help_Glinda_2017-11-30T13:51:20.000864 | 1,512,049,880.000864 | 101,657 |
pythondev | help | Last time I worked with command line progress bars it was something to do with sending the output to the beginning of the same line | 2017-11-30T13:51:47.000171 | Glinda | pythondev_help_Glinda_2017-11-30T13:51:47.000171 | 1,512,049,907.000171 | 101,658 |
pythondev | help | <@Dominick> | 2017-11-30T13:59:37.000729 | Glinda | pythondev_help_Glinda_2017-11-30T13:59:37.000729 | 1,512,050,377.000729 | 101,659 |
pythondev | help | I've seen that behavior difference between a regular PowerShell window and the ISE output window with DISM before. Never stopped to figure out why it happens though. | 2017-11-30T14:21:51.000765 | Dorris | pythondev_help_Dorris_2017-11-30T14:21:51.000765 | 1,512,051,711.000765 | 101,660 |
pythondev | help | <@Glinda> hmmm - thanks. that would probably require me to get into the `tqdm` code which i don't really want to do. it's not a huge deal, i just like to see it printed in the terminal when i'm at my desk but it makes my logs look like shit :slightly_smiling_face: | 2017-11-30T14:36:58.001259 | Dominick | pythondev_help_Dominick_2017-11-30T14:36:58.001259 | 1,512,052,618.001259 | 101,661 |
pythondev | help | Looks like, in bash you use carriage return for the same line, test it with this.
```echo -n "Old line"
echo -e "\r new line"``` | 2017-11-30T14:43:39.000131 | Glinda | pythondev_help_Glinda_2017-11-30T14:43:39.000131 | 1,512,053,019.000131 | 101,662 |
pythondev | help | ```def _term_move_up(): # pragma: no cover
return '' if (os.name == 'nt') and (colorama is None) else '\x1b[A'``` | 2017-11-30T14:44:29.001106 | Glinda | pythondev_help_Glinda_2017-11-30T14:44:29.001106 | 1,512,053,069.001106 | 101,663 |
pythondev | help | This char `\x1b[A'` is equal to `\r\n` | 2017-11-30T14:45:10.000231 | Glinda | pythondev_help_Glinda_2017-11-30T14:45:10.000231 | 1,512,053,110.000231 | 101,664 |
pythondev | help | Hello guys, seems like I can’t init object which have the constructor, in my pytest
```
@pytest.fixture()
def client():
client = Client('one', 'two')
return client
def test_client(client):
one, two = client.one, client.two
assert ('one', 'two') == (one, two)
```
but seems that I can’t init the object via pyt... | 2017-11-30T14:59:41.000007 | Bella | pythondev_help_Bella_2017-11-30T14:59:41.000007 | 1,512,053,981.000007 | 101,665 |
pythondev | help | maybe someone have a suggestions? | 2017-11-30T15:08:01.000496 | Bella | pythondev_help_Bella_2017-11-30T15:08:01.000496 | 1,512,054,481.000496 | 101,666 |
pythondev | help | maybe it's something else? | 2017-11-30T15:11:07.001266 | Suellen | pythondev_help_Suellen_2017-11-30T15:11:07.001266 | 1,512,054,667.001266 | 101,667 |
pythondev | help | what kind of error are you getting? | 2017-11-30T15:11:18.000153 | Suellen | pythondev_help_Suellen_2017-11-30T15:11:18.000153 | 1,512,054,678.000153 | 101,668 |
pythondev | help | <@Suellen> Thanks! one minute please. | 2017-11-30T15:23:24.000634 | Bella | pythondev_help_Bella_2017-11-30T15:23:24.000634 | 1,512,055,404.000634 | 101,669 |
pythondev | help | how to implement a lazy property? | 2017-11-30T15:41:50.000318 | Jesusa | pythondev_help_Jesusa_2017-11-30T15:41:50.000318 | 1,512,056,510.000318 | 101,670 |
pythondev | help | aren't they all lazy? | 2017-11-30T15:43:21.000645 | Suellen | pythondev_help_Suellen_2017-11-30T15:43:21.000645 | 1,512,056,601.000645 | 101,671 |
pythondev | help | ah i meant like... compute once | 2017-11-30T15:43:52.000155 | Jesusa | pythondev_help_Jesusa_2017-11-30T15:43:52.000155 | 1,512,056,632.000155 | 101,672 |
pythondev | help | but only when called | 2017-11-30T15:43:56.000272 | Jesusa | pythondev_help_Jesusa_2017-11-30T15:43:56.000272 | 1,512,056,636.000272 | 101,673 |
pythondev | help | there are built-in caching decorators | 2017-11-30T15:44:03.000032 | Frieda | pythondev_help_Frieda_2017-11-30T15:44:03.000032 | 1,512,056,643.000032 | 101,674 |
pythondev | help | :open_mouth: | 2017-11-30T15:44:26.000283 | Jesusa | pythondev_help_Jesusa_2017-11-30T15:44:26.000283 | 1,512,056,666.000283 | 101,675 |
pythondev | help | I guess property + caching | 2017-11-30T15:44:30.000297 | Jesusa | pythondev_help_Jesusa_2017-11-30T15:44:30.000297 | 1,512,056,670.000297 | 101,676 |
pythondev | help | double decorator | 2017-11-30T15:44:35.000471 | Jesusa | pythondev_help_Jesusa_2017-11-30T15:44:35.000471 | 1,512,056,675.000471 | 101,677 |
pythondev | help | you can decorate as much as you want | 2017-11-30T15:45:11.000495 | Frieda | pythondev_help_Frieda_2017-11-30T15:45:11.000495 | 1,512,056,711.000495 | 101,678 |
pythondev | help | from functools import lru_cache
class A():
@property
@lru_cache(None)
def x(self):
print(1)
return 1 | 2017-11-30T15:46:52.000656 | Jesusa | pythondev_help_Jesusa_2017-11-30T15:46:52.000656 | 1,512,056,812.000656 | 101,679 |
pythondev | help | this is not cached though | 2017-11-30T15:46:56.000092 | Jesusa | pythondev_help_Jesusa_2017-11-30T15:46:56.000092 | 1,512,056,816.000092 | 101,680 |
pythondev | help | oops it is | 2017-11-30T15:47:21.000444 | Jesusa | pythondev_help_Jesusa_2017-11-30T15:47:21.000444 | 1,512,056,841.000444 | 101,681 |
pythondev | help | A().x twice | 2017-11-30T15:47:24.000694 | Jesusa | pythondev_help_Jesusa_2017-11-30T15:47:24.000694 | 1,512,056,844.000694 | 101,682 |
pythondev | help | too bad that this doesn't work: `lazy_property = property(lru_cache(maxsize=None))` :disappointed: | 2017-11-30T15:48:49.000183 | Jesusa | pythondev_help_Jesusa_2017-11-30T15:48:49.000183 | 1,512,056,929.000183 | 101,683 |
pythondev | help | hey folks. I've got some dates in my db stored as `"Wed Nov 29 2017"` and a form submitting dates as `29 November, 2017`. I can't change the format of the form submission. How would you go about converting the form dates to match the dates in the DB? | 2017-11-30T17:19:03.000207 | Corrinne | pythondev_help_Corrinne_2017-11-30T17:19:03.000207 | 1,512,062,343.000207 | 101,684 |
pythondev | help | timedate is about to be your friend, I think | 2017-11-30T17:20:48.000212 | Sirena | pythondev_help_Sirena_2017-11-30T17:20:48.000212 | 1,512,062,448.000212 | 101,685 |
pythondev | help | or datetime even | 2017-11-30T17:21:04.000533 | Sirena | pythondev_help_Sirena_2017-11-30T17:21:04.000533 | 1,512,062,464.000533 | 101,686 |
pythondev | help | apparently my brain is wrong-endian today | 2017-11-30T17:21:20.000138 | Sirena | pythondev_help_Sirena_2017-11-30T17:21:20.000138 | 1,512,062,480.000138 | 101,687 |
pythondev | help | Looking through the docs now :face_with_rolling_eyes: | 2017-11-30T17:22:13.000094 | Corrinne | pythondev_help_Corrinne_2017-11-30T17:22:13.000094 | 1,512,062,533.000094 | 101,688 |
pythondev | help | <@Corrinne> also maybe look into storing dates as `dates` instead of `strings` | 2017-11-30T17:25:04.000175 | Edie | pythondev_help_Edie_2017-11-30T17:25:04.000175 | 1,512,062,704.000175 | 101,689 |
pythondev | help | `dt.date(2017, 11, 29).strftime('%d %B, %Y')` | 2017-11-30T17:25:05.000182 | Sirena | pythondev_help_Sirena_2017-11-30T17:25:05.000182 | 1,512,062,705.000182 | 101,690 |
pythondev | help | will probably get you close, after you figure out entering your month correctly | 2017-11-30T17:25:18.000007 | Sirena | pythondev_help_Sirena_2017-11-30T17:25:18.000007 | 1,512,062,718.000007 | 101,691 |
pythondev | help | Was thinking maybe i could split the form date and re-arrange it to query the db :thinking_face: | 2017-11-30T17:27:21.000433 | Corrinne | pythondev_help_Corrinne_2017-11-30T17:27:21.000433 | 1,512,062,841.000433 | 101,692 |
pythondev | help | what DB are you using | 2017-11-30T17:28:05.000629 | Edie | pythondev_help_Edie_2017-11-30T17:28:05.000629 | 1,512,062,885.000629 | 101,693 |
pythondev | help | mongodb + mongoengine | 2017-11-30T17:28:16.000131 | Corrinne | pythondev_help_Corrinne_2017-11-30T17:28:16.000131 | 1,512,062,896.000131 | 101,694 |
pythondev | help | @julian haven't worked with mongo in a while, but it supports date types (<https://docs.mongodb.com/manual/reference/method/Date/>) and pymongo appears to allow queries against dates: <https://stackoverflow.com/a/26366914/1948982> | 2017-11-30T17:30:53.000089 | Edie | pythondev_help_Edie_2017-11-30T17:30:53.000089 | 1,512,063,053.000089 | 101,695 |
pythondev | help | `dt.datetime.strptime('Wed Nov 29 2017', '%a %b %d %Y').strftime('%d %B, %Y')` | 2017-11-30T17:31:57.000404 | Sirena | pythondev_help_Sirena_2017-11-30T17:31:57.000404 | 1,512,063,117.000404 | 101,696 |
pythondev | help | that seems to work | 2017-11-30T17:32:02.000197 | Sirena | pythondev_help_Sirena_2017-11-30T17:32:02.000197 | 1,512,063,122.000197 | 101,697 |
pythondev | help | sorry the first linke was suppose to be: <https://docs.mongodb.com/v3.0/reference/bson-types/#date> | 2017-11-30T17:32:03.000118 | Edie | pythondev_help_Edie_2017-11-30T17:32:03.000118 | 1,512,063,123.000118 | 101,698 |
pythondev | help | I'm storing the dates in the DB as strings which might be an issue. Might see if I can change it to store as a dateTimeField | 2017-11-30T17:32:13.000456 | Corrinne | pythondev_help_Corrinne_2017-11-30T17:32:13.000456 | 1,512,063,133.000456 | 101,699 |
pythondev | help | My solution was to split the form date, rearrange it and query the db using __contains. Seems to work ok | 2017-11-30T17:50:37.000681 | Corrinne | pythondev_help_Corrinne_2017-11-30T17:50:37.000681 | 1,512,064,237.000681 | 101,700 |
pythondev | help | ``` if request.method == "POST":
split_date = request.form["date_choice"].split()
formatted_date = split_date[1][0:3] + " " + split_date[0] + " " + split_date[2]
req_data = Data.objects(owner=session_id, dateTime__contains=formatted_date)
for data in req_data:
print(data.p... | 2017-11-30T17:50:45.000248 | Corrinne | pythondev_help_Corrinne_2017-11-30T17:50:45.000248 | 1,512,064,245.000248 | 101,701 |
pythondev | help | <@Corrinne> If you're going to split the dates like this using string slices. You really should validate your `formatted_date` Nate posted a much better way of doing it. I'm not sure how your form is validating the string, and since you can't change that (or stop them from changing) probably best you validate it other ... | 2017-11-30T20:04:40.000275 | Glinda | pythondev_help_Glinda_2017-11-30T20:04:40.000275 | 1,512,072,280.000275 | 101,702 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.