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
|
<@Gregorio> generally cross-posting questions is frowned upon here. Thanks! :slightly_smiling_face:
|
2017-08-30T13:41:06.000716
|
Patty
|
pythondev_help_Patty_2017-08-30T13:41:06.000716
| 1,504,100,466.000716 | 91,503 |
pythondev
|
help
|
oh sorry <@Patty>. I didn’t get any response in <#C0L7UUTGR|numpy>. But I’ll move it there.
|
2017-08-30T13:41:57.000240
|
Gregorio
|
pythondev_help_Gregorio_2017-08-30T13:41:57.000240
| 1,504,100,517.00024 | 91,504 |
pythondev
|
help
|
<@Suellen> are you in <#C0L7UUTGR|numpy> ? :slightly_smiling_face:
|
2017-08-30T13:42:14.000382
|
Gregorio
|
pythondev_help_Gregorio_2017-08-30T13:42:14.000382
| 1,504,100,534.000382 | 91,505 |
pythondev
|
help
|
How can i show a message"time out" in template on django. After 10sec
|
2017-08-30T14:54:38.000153
|
Georgetta
|
pythondev_help_Georgetta_2017-08-30T14:54:38.000153
| 1,504,104,878.000153 | 91,506 |
pythondev
|
help
|
<@Georgetta>, is this a template rendering issue?
|
2017-08-30T15:03:37.000422
|
Meg
|
pythondev_help_Meg_2017-08-30T15:03:37.000422
| 1,504,105,417.000422 | 91,507 |
pythondev
|
help
|
or are you loading something with ajax
|
2017-08-30T15:03:45.000423
|
Meg
|
pythondev_help_Meg_2017-08-30T15:03:45.000423
| 1,504,105,425.000423 | 91,508 |
pythondev
|
help
|
None of them
|
2017-08-30T15:05:41.000062
|
Georgetta
|
pythondev_help_Georgetta_2017-08-30T15:05:41.000062
| 1,504,105,541.000062 | 91,509 |
pythondev
|
help
|
Just im showed some charts, but sometimes pages takes time to load,
|
2017-08-30T15:06:31.000719
|
Georgetta
|
pythondev_help_Georgetta_2017-08-30T15:06:31.000719
| 1,504,105,591.000719 | 91,510 |
pythondev
|
help
|
And i want to add smth where need more than 10sec showed messaged Time out
|
2017-08-30T15:07:05.000692
|
Georgetta
|
pythondev_help_Georgetta_2017-08-30T15:07:05.000692
| 1,504,105,625.000692 | 91,511 |
pythondev
|
help
|
<@Meg>
|
2017-08-30T15:08:11.000443
|
Georgetta
|
pythondev_help_Georgetta_2017-08-30T15:08:11.000443
| 1,504,105,691.000443 | 91,512 |
pythondev
|
help
|
originally posted in <#C33EUEV5M|help-es> but getting no responses.
Having an issue w/ Azure Service Bus subscription filters. They do not seem to work properly when there are more than one. Error messages from SO are in English. If anyone recognizes them, please advise.
|
2017-08-30T15:15:16.000483
|
Deedee
|
pythondev_help_Deedee_2017-08-30T15:15:16.000483
| 1,504,106,116.000483 | 91,513 |
pythondev
|
help
|
<@Georgetta>, you need to give alot more information about what you're trying to do and how and where the bottleneck is. right now, you're being very vague and nondescript.
|
2017-08-30T15:46:10.000318
|
Meg
|
pythondev_help_Meg_2017-08-30T15:46:10.000318
| 1,504,107,970.000318 | 91,514 |
pythondev
|
help
|
For tips on asking clear questions: <https://stackoverflow.com/help/how-to-ask>
|
2017-08-30T15:46:48.000101
|
Beula
|
pythondev_help_Beula_2017-08-30T15:46:48.000101
| 1,504,108,008.000101 | 91,515 |
pythondev
|
help
|
Is this not kosher?
```
debug = True
logger = logging.getLogger(__name__)
if debug:
debugger = partial(logger.debug)
else:
debugger = lambda x: None
```
PyCharm says do not assign a lambda expression, use a def.
|
2017-08-30T15:52:15.000008
|
Meghan
|
pythondev_help_Meghan_2017-08-30T15:52:15.000008
| 1,504,108,335.000008 | 91,516 |
pythondev
|
help
|
For its PEP 8 checks.
|
2017-08-30T15:52:25.000688
|
Meghan
|
pythondev_help_Meghan_2017-08-30T15:52:25.000688
| 1,504,108,345.000688 | 91,517 |
pythondev
|
help
|
Since it's just a no-op, I would just `# noqa` it and move along
|
2017-08-30T15:53:23.000272
|
Beula
|
pythondev_help_Beula_2017-08-30T15:53:23.000272
| 1,504,108,403.000272 | 91,518 |
pythondev
|
help
|
```
Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier.
Yes:
def f(x): return 2*x
No:
f = lambda x: 2*x
The first form means that the name of the resulting function object is specifically 'f' instead of the generic '<lambda>'. This is more useful for tracebacks and string representations in general. The use of the assignment statement eliminates the sole benefit a lambda expression can offer over an explicit def statement (i.e. that it can be embedded inside a larger expression)```
|
2017-08-30T15:53:27.000465
|
Patty
|
pythondev_help_Patty_2017-08-30T15:53:27.000465
| 1,504,108,407.000465 | 91,519 |
pythondev
|
help
|
Also, changed the first two lines around, because next to one another.
|
2017-08-30T15:53:29.000179
|
Meghan
|
pythondev_help_Meghan_2017-08-30T15:53:29.000179
| 1,504,108,409.000179 | 91,520 |
pythondev
|
help
|
# noqa?
|
2017-08-30T15:53:47.000563
|
Meghan
|
pythondev_help_Meghan_2017-08-30T15:53:47.000563
| 1,504,108,427.000563 | 91,521 |
pythondev
|
help
|
he meant `#noop`
|
2017-08-30T15:53:55.000180
|
Patty
|
pythondev_help_Patty_2017-08-30T15:53:55.000180
| 1,504,108,435.00018 | 91,522 |
pythondev
|
help
|
oh
|
2017-08-30T15:54:06.000121
|
Meghan
|
pythondev_help_Meghan_2017-08-30T15:54:06.000121
| 1,504,108,446.000121 | 91,523 |
pythondev
|
help
|
or `#noqa` meaning no need to check because its a no-op
|
2017-08-30T15:54:37.000087
|
Patty
|
pythondev_help_Patty_2017-08-30T15:54:37.000087
| 1,504,108,477.000087 | 91,524 |
pythondev
|
help
|
ok
|
2017-08-30T15:54:44.000334
|
Meghan
|
pythondev_help_Meghan_2017-08-30T15:54:44.000334
| 1,504,108,484.000334 | 91,525 |
pythondev
|
help
|
`# noqa` disables the inspection for the line
|
2017-08-30T15:54:48.000446
|
Beula
|
pythondev_help_Beula_2017-08-30T15:54:48.000446
| 1,504,108,488.000446 | 91,526 |
pythondev
|
help
|
PyCharm apparently doesn't concern itself for such comments, instead complains it's mispelled. :slightly_smiling_face:
|
2017-08-30T15:55:50.000742
|
Meghan
|
pythondev_help_Meghan_2017-08-30T15:55:50.000742
| 1,504,108,550.000742 | 91,527 |
pythondev
|
help
|
anyone know, in pycharm or others, is it possible to not have a toold window docked to the side, but have it places like a normal tab i can have with the rest of my tabs/buffers?
|
2017-08-30T16:33:52.000197
|
Bruno
|
pythondev_help_Bruno_2017-08-30T16:33:52.000197
| 1,504,110,832.000197 | 91,528 |
pythondev
|
help
|
like a regular file ?
|
2017-08-30T16:34:45.000135
|
Ciera
|
pythondev_help_Ciera_2017-08-30T16:34:45.000135
| 1,504,110,885.000135 | 91,529 |
pythondev
|
help
|
I don't think it's possible
|
2017-08-30T16:34:49.000327
|
Ciera
|
pythondev_help_Ciera_2017-08-30T16:34:49.000327
| 1,504,110,889.000327 | 91,530 |
pythondev
|
help
|
yea.
|
2017-08-30T16:35:14.000309
|
Bruno
|
pythondev_help_Bruno_2017-08-30T16:35:14.000309
| 1,504,110,914.000309 | 91,531 |
pythondev
|
help
|
i didnt think it was but i was looking. couldnt find anything.
|
2017-08-30T16:35:28.000660
|
Bruno
|
pythondev_help_Bruno_2017-08-30T16:35:28.000660
| 1,504,110,928.00066 | 91,532 |
pythondev
|
help
|
question about unit tests (don't everyone scream at once) - I am working with some open-source software and we've extended some of its base modules to meet our custom requirements. In the process we've written our own unit tests contained in our custom / extended modules and the all pass, but the core system contains unit tests that fail. this is a bummer because our CI declares a failed build, altho it's because of a change in workflow, not failing code. Is there an easy way to pass these tests without monkey-patching or totally rewriting them?
|
2017-08-30T16:35:54.000122
|
Susann
|
pythondev_help_Susann_2017-08-30T16:35:54.000122
| 1,504,110,954.000122 | 91,533 |
pythondev
|
help
|
using `unittest2` module
|
2017-08-30T16:36:17.000165
|
Susann
|
pythondev_help_Susann_2017-08-30T16:36:17.000165
| 1,504,110,977.000165 | 91,534 |
pythondev
|
help
|
window tiing manager for the win! (i3)
|
2017-08-30T16:37:56.000052
|
Bruno
|
pythondev_help_Bruno_2017-08-30T16:37:56.000052
| 1,504,111,076.000052 | 91,535 |
pythondev
|
help
|
Do their tests pass with their own code? Or do your changes cause it to fail?
|
2017-08-30T16:43:56.000622
|
Meghan
|
pythondev_help_Meghan_2017-08-30T16:43:56.000622
| 1,504,111,436.000622 | 91,536 |
pythondev
|
help
|
our changes cause it to fail
|
2017-08-30T16:50:58.000175
|
Susann
|
pythondev_help_Susann_2017-08-30T16:50:58.000175
| 1,504,111,858.000175 | 91,537 |
pythondev
|
help
|
on their CI (I'm using Odoo btw so the CI is their own Runbot) it has a passing build
|
2017-08-30T16:51:21.000537
|
Susann
|
pythondev_help_Susann_2017-08-30T16:51:21.000537
| 1,504,111,881.000537 | 91,538 |
pythondev
|
help
|
and our custom modules depend on their core ones except they often extend the functionality; e.g. Sale Order does not require a payment method in core. Our customizations require a payment method with a sale order.
|
2017-08-30T16:52:10.000249
|
Susann
|
pythondev_help_Susann_2017-08-30T16:52:10.000249
| 1,504,111,930.000249 | 91,539 |
pythondev
|
help
|
I'm trying to avoid wrapping their tests in a `@unittest.skip()` decorator but it seems to be the only option unless I rewrite them
|
2017-08-30T16:53:29.000561
|
Susann
|
pythondev_help_Susann_2017-08-30T16:53:29.000561
| 1,504,112,009.000561 | 91,540 |
pythondev
|
help
|
If I have some Sequence `seq`, I can send each of the values to a function one at at time with `f(*seq)`. What is this unwrapping called, and is there a function that does this in the standard library?
|
2017-08-31T04:58:06.000074
|
Lanita
|
pythondev_help_Lanita_2017-08-31T04:58:06.000074
| 1,504,155,486.000074 | 91,541 |
pythondev
|
help
|
unpacking
|
2017-08-31T04:58:50.000431
|
Suellen
|
pythondev_help_Suellen_2017-08-31T04:58:50.000431
| 1,504,155,530.000431 | 91,542 |
pythondev
|
help
|
sequences are unpacked via a star, `*[1, 2, 3] -> 1, 2, 3`
|
2017-08-31T04:59:26.000029
|
Suellen
|
pythondev_help_Suellen_2017-08-31T04:59:26.000029
| 1,504,155,566.000029 | 91,543 |
pythondev
|
help
|
mappings are unpacked via a double star: `**{'a': 1, 'b': 2} -> a=1, b=2`
|
2017-08-31T04:59:49.000273
|
Suellen
|
pythondev_help_Suellen_2017-08-31T04:59:49.000273
| 1,504,155,589.000273 | 91,544 |
pythondev
|
help
|
e.g.
```
def unpacked(f):
def wrapper(arg, **kwargs):
return f(*arg, **kwargs)
return wrapper
# I can now do
map(unpacked("{}: {}".format), some_dict.items())
```
|
2017-08-31T04:59:50.000481
|
Lanita
|
pythondev_help_Lanita_2017-08-31T04:59:50.000481
| 1,504,155,590.000481 | 91,545 |
pythondev
|
help
|
This function is kind of useful since I find myself wanting to send sequences of objects into functions often
|
2017-08-31T05:00:42.000169
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:00:42.000169
| 1,504,155,642.000169 | 91,546 |
pythondev
|
help
|
this is nice
|
2017-08-31T05:01:44.000506
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:01:44.000506
| 1,504,155,704.000506 | 91,547 |
pythondev
|
help
|
but you can use a star too
|
2017-08-31T05:01:53.000198
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:01:53.000198
| 1,504,155,713.000198 | 91,548 |
pythondev
|
help
|
```
>>> print(*some_dict.items())
('a', 1) ('b', 2) ('c', 3)
```
|
2017-08-31T05:02:01.000040
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:02:01.000040
| 1,504,155,721.00004 | 91,549 |
pythondev
|
help
|
ooh
|
2017-08-31T05:02:38.000112
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:02:38.000112
| 1,504,155,758.000112 | 91,550 |
pythondev
|
help
|
`map("{}: {}".format, *some_dict.items())` works just fine
|
2017-08-31T05:02:57.000504
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:02:57.000504
| 1,504,155,777.000504 | 91,551 |
pythondev
|
help
|
the star operator is easily one of the coolest things about python...
|
2017-08-31T05:03:21.000436
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:03:21.000436
| 1,504,155,801.000436 | 91,552 |
pythondev
|
help
|
it is!
|
2017-08-31T05:03:57.000342
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:03:57.000342
| 1,504,155,837.000342 | 91,553 |
pythondev
|
help
|
I've really been missing it when playing around with ML-style languages (mostly because I've attempted the problem from the wrong approach, but... you still have standard libraries containing functions such as e.g. `fmap6` because there's no unpacking-style syntax available)
|
2017-08-31T05:05:37.000020
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:05:37.000020
| 1,504,155,937.00002 | 91,554 |
pythondev
|
help
|
(like this: <https://hackage.haskell.org/package/functor-utils-1.1/docs/Data-Functor-Utils.html> ...not that it has anything to do with python)
|
2017-08-31T05:07:01.000230
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:07:01.000230
| 1,504,156,021.00023 | 91,555 |
pythondev
|
help
|
oh no, not haskell
|
2017-08-31T05:07:34.000103
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:07:34.000103
| 1,504,156,054.000103 | 91,556 |
pythondev
|
help
|
...wait, that `*some_dict.items()` solution isn't the same...
|
2017-08-31T05:08:22.000398
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:08:22.000398
| 1,504,156,102.000398 | 91,557 |
pythondev
|
help
|
well, what do you need it to be?
|
2017-08-31T05:09:10.000207
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:09:10.000207
| 1,504,156,150.000207 | 91,558 |
pythondev
|
help
|
I want to send every key-value pair to "{}: {}".format
|
2017-08-31T05:10:57.000086
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:10:57.000086
| 1,504,156,257.000086 | 91,559 |
pythondev
|
help
|
`*some_dict.items()` unpacks a dictionary into pairs of.. keys and values :slightly_smiling_face:
|
2017-08-31T05:11:34.000134
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:11:34.000134
| 1,504,156,294.000134 | 91,560 |
pythondev
|
help
|
```
d = {
"hello": 42,
"world": 43,
"foo": 9,
}
def print_map(*args):
print(list(map(*args)))
print_map(lambda x: "{}: {}".format(*x), d.items())
# ['hello: 42', 'world: 43', 'foo: 9']
print_map("{}: {}".format, *d.items())
# ['world: hello', '43: 42']
```
|
2017-08-31T05:12:00.000221
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:12:00.000221
| 1,504,156,320.000221 | 91,561 |
pythondev
|
help
|
:open_mouth:
|
2017-08-31T05:12:15.000282
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:12:15.000282
| 1,504,156,335.000282 | 91,562 |
pythondev
|
help
|
```
>>> print(list(map('{}: {}'.format, *d.items())))
['hello: world', '42: 43']
>>> print(*d.items())
('hello', 42) ('world', 43) ('foo', 9)
```
|
2017-08-31T05:13:29.000014
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:13:29.000014
| 1,504,156,409.000014 | 91,563 |
pythondev
|
help
|
your stuff is broken, yo
|
2017-08-31T05:13:36.000142
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:13:36.000142
| 1,504,156,416.000142 | 91,564 |
pythondev
|
help
|
```
print(list(map('{}: {}'.format, *d.items())))
# ['hello: foo', '42: 9']
```
|
2017-08-31T05:15:00.000012
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:15:00.000012
| 1,504,156,500.000012 | 91,565 |
pythondev
|
help
|
python 3.5.2
|
2017-08-31T05:15:16.000195
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:15:16.000195
| 1,504,156,516.000195 | 91,566 |
pythondev
|
help
|
so, my problem of finding a decorator that turns a function into a function that first unpacks its args still remains :slightly_smiling_face:
|
2017-08-31T05:17:14.000268
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:17:14.000268
| 1,504,156,634.000268 | 91,567 |
pythondev
|
help
|
I'd say the problem of why a value is disappearing from the dict is more pressing :slightly_smiling_face:
|
2017-08-31T05:18:21.000425
|
Gabriele
|
pythondev_help_Gabriele_2017-08-31T05:18:21.000425
| 1,504,156,701.000425 | 91,568 |
pythondev
|
help
|
Oh, map is lazy... I need to figure out when it binds the values
|
2017-08-31T05:21:14.000323
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:21:14.000323
| 1,504,156,874.000323 | 91,569 |
pythondev
|
help
|
when it's run... fuck that could lead to some nasty bugs if I'm not careful
|
2017-08-31T05:23:11.000283
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:23:11.000283
| 1,504,156,991.000283 | 91,570 |
pythondev
|
help
|
I'm not sure I understand what you are trying to do :smile:
|
2017-08-31T05:23:15.000268
|
Ciera
|
pythondev_help_Ciera_2017-08-31T05:23:15.000268
| 1,504,156,995.000268 | 91,571 |
pythondev
|
help
|
oh, I see what's going on
|
2017-08-31T05:23:26.000350
|
Gabriele
|
pythondev_help_Gabriele_2017-08-31T05:23:26.000350
| 1,504,157,006.00035 | 91,572 |
pythondev
|
help
|
can't explain it in words, but it makes sense now
|
2017-08-31T05:24:08.000296
|
Gabriele
|
pythondev_help_Gabriele_2017-08-31T05:24:08.000296
| 1,504,157,048.000296 | 91,573 |
pythondev
|
help
|
```
|
2017-08-31T05:24:12.000003
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:24:12.000003
| 1,504,157,052.000003 | 91,574 |
pythondev
|
help
|
> can't explain it in words
Functional programming ITT
|
2017-08-31T05:24:19.000278
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:24:19.000278
| 1,504,157,059.000278 | 91,575 |
pythondev
|
help
|
:smile:
|
2017-08-31T05:24:28.000291
|
Gabriele
|
pythondev_help_Gabriele_2017-08-31T05:24:28.000291
| 1,504,157,068.000291 | 91,576 |
pythondev
|
help
|
```
seq = [1,2,3]
map_object = map(print, seq)
seq.append(4)
list(map_object) # will print 1 2 3 4
```
This wasn't obvious to me
|
2017-08-31T05:24:34.000311
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:24:34.000311
| 1,504,157,074.000311 | 91,577 |
pythondev
|
help
|
I think also the star operator doesn't do precisely what is needed here
|
2017-08-31T05:26:49.000178
|
Gabriele
|
pythondev_help_Gabriele_2017-08-31T05:26:49.000178
| 1,504,157,209.000178 | 91,578 |
pythondev
|
help
|
<@Lanita> nice little mutability example you have there
|
2017-08-31T05:30:13.000038
|
Vada
|
pythondev_help_Vada_2017-08-31T05:30:13.000038
| 1,504,157,413.000038 | 91,579 |
pythondev
|
help
|
By the way, while we're talking about map...
What are the pitfalls of doing `list(some_map_object)` when you really want `[x for x in some_map_object]`?
|
2017-08-31T05:32:17.000199
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:32:17.000199
| 1,504,157,537.000199 | 91,580 |
pythondev
|
help
|
I don't have any good non-complicated examples of when they're not the same, but I've found this "bug" in my own code many times
|
2017-08-31T05:32:40.000254
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:32:40.000254
| 1,504,157,560.000254 | 91,581 |
pythondev
|
help
|
they are the same?
|
2017-08-31T05:34:33.000385
|
Suellen
|
pythondev_help_Suellen_2017-08-31T05:34:33.000385
| 1,504,157,673.000385 | 91,582 |
pythondev
|
help
|
*always*?
|
2017-08-31T05:35:55.000100
|
Lanita
|
pythondev_help_Lanita_2017-08-31T05:35:55.000100
| 1,504,157,755.0001 | 91,583 |
pythondev
|
help
|
in py2.x the internal variable, in your case `x` is leaked, and is usable after your list comprehension (it was fixed in 3.x)
|
2017-08-31T05:36:30.000246
|
Carri
|
pythondev_help_Carri_2017-08-31T05:36:30.000246
| 1,504,157,790.000246 | 91,584 |
pythondev
|
help
|
Hi I am need some help with a regex expression. I am trying to extract the language code from the url with this expression '[^/]\w{1}' and it works. What I need is to assign it to a variable language_code = re.match( '[^/]\w{1}' ) However, this doesn't work because I don't want to provide a string to match to as an argument. I just want to get the two letters from the string.
|
2017-08-31T11:11:12.000489
|
Jeanette
|
pythondev_help_Jeanette_2017-08-31T11:11:12.000489
| 1,504,177,872.000489 | 91,585 |
pythondev
|
help
|
I'm not sure I'm understanding what you are saying, can you show that part of your code?
|
2017-08-31T11:12:15.000054
|
Meghan
|
pythondev_help_Meghan_2017-08-31T11:12:15.000054
| 1,504,177,935.000054 | 91,586 |
pythondev
|
help
|
Why would you not provide the string as an argument?
|
2017-08-31T11:12:32.000231
|
Meghan
|
pythondev_help_Meghan_2017-08-31T11:12:32.000231
| 1,504,177,952.000231 | 91,587 |
pythondev
|
help
|
Also, regex could be the wrong way for this. Regex really should be used when other string manipulation can't do what you want easily.
|
2017-08-31T11:13:08.000463
|
Meghan
|
pythondev_help_Meghan_2017-08-31T11:13:08.000463
| 1,504,177,988.000463 | 91,588 |
pythondev
|
help
|
request = context['request']
#<WSGIRequest: GET '/bg/news'>
language = re.match('[^/]\w{1}')
language_code = language.group(0)
|
2017-08-31T11:17:01.000360
|
Jeanette
|
pythondev_help_Jeanette_2017-08-31T11:17:01.000360
| 1,504,178,221.00036 | 91,589 |
pythondev
|
help
|
match needs a second argument, the string to match to
|
2017-08-31T11:17:24.000033
|
Jeanette
|
pythondev_help_Jeanette_2017-08-31T11:17:24.000033
| 1,504,178,244.000033 | 91,590 |
pythondev
|
help
|
e.g. language = re.match('[^/]\w{1}', 'bg')
|
2017-08-31T11:17:38.000361
|
Jeanette
|
pythondev_help_Jeanette_2017-08-31T11:17:38.000361
| 1,504,178,258.000361 | 91,591 |
pythondev
|
help
|
<@Jeanette> it also is useful to use code formatting in slack: <https://get.slack.help/hc/en-us/articles/202288908-Format-your-messages#code-blocks>
|
2017-08-31T11:19:26.000533
|
Patty
|
pythondev_help_Patty_2017-08-31T11:19:26.000533
| 1,504,178,366.000533 | 91,592 |
pythondev
|
help
|
<@Jeanette> but, if you're not providing a second argument, what are you matching your regex against?
|
2017-08-31T11:20:35.000139
|
Suellen
|
pythondev_help_Suellen_2017-08-31T11:20:35.000139
| 1,504,178,435.000139 | 91,593 |
pythondev
|
help
|
The second argument is the string, you have to provide that.
|
2017-08-31T11:20:59.000246
|
Meghan
|
pythondev_help_Meghan_2017-08-31T11:20:59.000246
| 1,504,178,459.000246 | 91,594 |
pythondev
|
help
|
only the first two letters between the slashes
|
2017-08-31T11:30:15.000346
|
Jeanette
|
pythondev_help_Jeanette_2017-08-31T11:30:15.000346
| 1,504,179,015.000346 | 91,595 |
pythondev
|
help
|
Is the url format always the same? If so, just split on slashes.
|
2017-08-31T11:30:55.000171
|
Meghan
|
pythondev_help_Meghan_2017-08-31T11:30:55.000171
| 1,504,179,055.000171 | 91,596 |
pythondev
|
help
|
```language = url.split('/')[1]```
|
2017-08-31T11:31:54.000251
|
Meghan
|
pythondev_help_Meghan_2017-08-31T11:31:54.000251
| 1,504,179,114.000251 | 91,597 |
pythondev
|
help
|
the urls always starts with the language code e.g: /en/blog/first-post/
|
2017-08-31T11:32:00.000238
|
Jeanette
|
pythondev_help_Jeanette_2017-08-31T11:32:00.000238
| 1,504,179,120.000238 | 91,598 |
pythondev
|
help
|
That is splitting on slashes, which returns a list of strings, and taking the 1 index. You'll want to do this for the other pieces too most likely.
|
2017-08-31T11:34:06.000730
|
Meghan
|
pythondev_help_Meghan_2017-08-31T11:34:06.000730
| 1,504,179,246.00073 | 91,599 |
pythondev
|
help
|
I will try it thank you!
|
2017-08-31T11:38:22.000059
|
Jeanette
|
pythondev_help_Jeanette_2017-08-31T11:38:22.000059
| 1,504,179,502.000059 | 91,600 |
pythondev
|
help
|
You're welcome.
|
2017-08-31T11:38:26.000060
|
Meghan
|
pythondev_help_Meghan_2017-08-31T11:38:26.000060
| 1,504,179,506.00006 | 91,601 |
pythondev
|
help
|
If you are taking parameters after that, such as a sort order, or number of items to show, you'll probably want to convert it to a dictionary for those, that too should be easy.
|
2017-08-31T11:39:00.000259
|
Meghan
|
pythondev_help_Meghan_2017-08-31T11:39:00.000259
| 1,504,179,540.000259 | 91,602 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.