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
|
yup . I know basic programming .
|
2017-07-20T12:08:26.035169
|
Helene
|
pythondev_help_Helene_2017-07-20T12:08:26.035169
| 1,500,552,506.035169 | 86,603 |
pythondev
|
help
|
understood
|
2017-07-20T12:08:31.038331
|
Meg
|
pythondev_help_Meg_2017-07-20T12:08:31.038331
| 1,500,552,511.038331 | 86,604 |
pythondev
|
help
|
but my concepts of object oriented programming are not so cool .
|
2017-07-20T12:08:48.048837
|
Helene
|
pythondev_help_Helene_2017-07-20T12:08:48.048837
| 1,500,552,528.048837 | 86,605 |
pythondev
|
help
|
can you suggest some good resources ?
|
2017-07-20T12:28:48.763606
|
Helene
|
pythondev_help_Helene_2017-07-20T12:28:48.763606
| 1,500,553,728.763606 | 86,606 |
pythondev
|
help
|
Hoping others come along that are newer than I am with their resources they used :smile:
|
2017-07-20T12:31:51.873261
|
Beula
|
pythondev_help_Beula_2017-07-20T12:31:51.873261
| 1,500,553,911.873261 | 86,607 |
pythondev
|
help
|
and can you share some advanced resources you use ?
|
2017-07-20T12:45:49.360914
|
Helene
|
pythondev_help_Helene_2017-07-20T12:45:49.360914
| 1,500,554,749.360914 | 86,608 |
pythondev
|
help
|
May be something may help
|
2017-07-20T12:45:58.366579
|
Helene
|
pythondev_help_Helene_2017-07-20T12:45:58.366579
| 1,500,554,758.366579 | 86,609 |
pythondev
|
help
|
You can go through the python tutorial, otherwise I just look at stuff as they come up. <https://docs.python.org/3/tutorial/index.html>
Later when you know Python better, Effective Python is a good book - but again, after you know the language and can appreciate the tips
|
2017-07-20T12:54:40.666871
|
Beula
|
pythondev_help_Beula_2017-07-20T12:54:40.666871
| 1,500,555,280.666871 | 86,610 |
pythondev
|
help
|
Exactly how much water should be in the paddy for my summer crop of rice? I need agricultural advice.
|
2017-07-20T15:16:08.607561
|
Thomasina
|
pythondev_help_Thomasina_2017-07-20T15:16:08.607561
| 1,500,563,768.607561 | 86,611 |
pythondev
|
help
|
and getting stackoverflow working for you is also a skill that should be honed.
|
2017-07-20T15:28:16.985827
|
Levi
|
pythondev_help_Levi_2017-07-20T15:28:16.985827
| 1,500,564,496.985827 | 86,612 |
pythondev
|
help
|
`from stackoverflow import fibonacci`
|
2017-07-20T15:28:47.002596
|
Levi
|
pythondev_help_Levi_2017-07-20T15:28:47.002596
| 1,500,564,527.002596 | 86,613 |
pythondev
|
help
|
if you want to understand OOP, I would recommend learning Java. Java is a statically typed language, but all of it is object oriented and must be inside of a class.
|
2017-07-20T15:33:48.161372
|
Aide
|
pythondev_help_Aide_2017-07-20T15:33:48.161372
| 1,500,564,828.161372 | 86,614 |
pythondev
|
help
|
Has any one here ever tried to implement a SDN using python ?
|
2017-07-20T17:21:06.792078
|
Hyman
|
pythondev_help_Hyman_2017-07-20T17:21:06.792078
| 1,500,571,266.792078 | 86,615 |
pythondev
|
help
|
<@Hyman> sdn?
|
2017-07-20T21:47:36.115755
|
Signe
|
pythondev_help_Signe_2017-07-20T21:47:36.115755
| 1,500,587,256.115755 | 86,616 |
pythondev
|
help
|
Software Defined Networking
|
2017-07-20T21:51:23.158524
|
Marcie
|
pythondev_help_Marcie_2017-07-20T21:51:23.158524
| 1,500,587,483.158524 | 86,617 |
pythondev
|
help
|
<https://en.wikipedia.org/wiki/Software-defined_networking>
|
2017-07-20T21:51:42.162339
|
Marcie
|
pythondev_help_Marcie_2017-07-20T21:51:42.162339
| 1,500,587,502.162339 | 86,618 |
pythondev
|
help
|
Hi.
I have a time in a string format as
`2017-07-21T02:16:51.449-07:00`
I am seeking this to convert it into unix-timestamp.
Anybody have any idea ?
|
2017-07-21T05:21:15.754414
|
Florene
|
pythondev_help_Florene_2017-07-21T05:21:15.754414
| 1,500,614,475.754414 | 86,619 |
pythondev
|
help
|
```
$ pip install arrow
... then, in Python ...
t = arrow.get('2017-07-21T02:16:51.449-07:00')
print(t.timestamp)
```
|
2017-07-21T05:23:19.797604
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T05:23:19.797604
| 1,500,614,599.797604 | 86,620 |
pythondev
|
help
|
If that doesn't work, you can use `arrow.get` with a specific format string
|
2017-07-21T05:24:26.820668
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T05:24:26.820668
| 1,500,614,666.820668 | 86,621 |
pythondev
|
help
|
I recommend `arrow` over standard library functionality.
|
2017-07-21T05:24:39.825307
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T05:24:39.825307
| 1,500,614,679.825307 | 86,622 |
pythondev
|
help
|
<@Gabriele> : Thanks for response!
that worked :slightly_smiling_face:
i hope there's no problem in using that...
|
2017-07-21T07:24:34.047863
|
Florene
|
pythondev_help_Florene_2017-07-21T07:24:34.047863
| 1,500,621,874.047863 | 86,623 |
pythondev
|
help
|
shouldn't be
|
2017-07-21T07:24:51.052547
|
Meg
|
pythondev_help_Meg_2017-07-21T07:24:51.052547
| 1,500,621,891.052547 | 86,624 |
pythondev
|
help
|
since its intended to be as close as a drop in replacement
|
2017-07-21T07:25:04.056155
|
Meg
|
pythondev_help_Meg_2017-07-21T07:25:04.056155
| 1,500,621,904.056155 | 86,625 |
pythondev
|
help
|
Also it does consider
`07:00`
from the time, right ? which i think is the timezone, right ?
|
2017-07-21T07:25:22.060679
|
Florene
|
pythondev_help_Florene_2017-07-21T07:25:22.060679
| 1,500,621,922.060679 | 86,626 |
pythondev
|
help
|
specifically it's -7:00, and yes
|
2017-07-21T07:25:33.063742
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:25:33.063742
| 1,500,621,933.063742 | 86,627 |
pythondev
|
help
|
so, java had a really crappy time/calendar library in the standard library for years before it pulled in `joda-time` into the core API
|
2017-07-21T07:25:40.065736
|
Meg
|
pythondev_help_Meg_2017-07-21T07:25:40.065736
| 1,500,621,940.065736 | 86,628 |
pythondev
|
help
|
now, if only python could do something similar...
|
2017-07-21T07:25:49.067819
|
Meg
|
pythondev_help_Meg_2017-07-21T07:25:49.067819
| 1,500,621,949.067819 | 86,629 |
pythondev
|
help
|
I think the success of pypi has meant that standard library development has stagnated somewhat, which is a shame
|
2017-07-21T07:26:34.080297
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:26:34.080297
| 1,500,621,994.080297 | 86,630 |
pythondev
|
help
|
we have a poor selection of date/time libraries, and nothing much of use for multimedia generally. But hey, we have `dbm` for "databases", `nntplib` for all the newsgroups we need to access regularly, and `sunau` for reading ancient audio files, so it's not all bad
|
2017-07-21T07:28:53.117323
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:28:53.117323
| 1,500,622,133.117323 | 86,631 |
pythondev
|
help
|
is this sarcasm? :disappointed:
|
2017-07-21T07:32:14.173790
|
Suellen
|
pythondev_help_Suellen_2017-07-21T07:32:14.173790
| 1,500,622,334.17379 | 86,632 |
pythondev
|
help
|
just a little
|
2017-07-21T07:32:23.176477
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:32:23.176477
| 1,500,622,343.176477 | 86,633 |
pythondev
|
help
|
sqlite and shelve / dbm modules aren't bad
|
2017-07-21T07:32:31.178481
|
Suellen
|
pythondev_help_Suellen_2017-07-21T07:32:31.178481
| 1,500,622,351.178481 | 86,634 |
pythondev
|
help
|
they are very much OK
|
2017-07-21T07:32:35.179679
|
Suellen
|
pythondev_help_Suellen_2017-07-21T07:32:35.179679
| 1,500,622,355.179679 | 86,635 |
pythondev
|
help
|
sqlite is great
|
2017-07-21T07:32:39.180965
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:32:39.180965
| 1,500,622,359.180965 | 86,636 |
pythondev
|
help
|
But I do think Python would be better if there was more effort spent on getting good packages into the standard library
|
2017-07-21T07:33:26.193166
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:33:26.193166
| 1,500,622,406.193166 | 86,637 |
pythondev
|
help
|
yeah.. maybe.. but it's not that easy
|
2017-07-21T07:33:41.196982
|
Suellen
|
pythondev_help_Suellen_2017-07-21T07:33:41.196982
| 1,500,622,421.196982 | 86,638 |
pythondev
|
help
|
say you want a better datetime. what do you pick?
|
2017-07-21T07:33:51.199637
|
Suellen
|
pythondev_help_Suellen_2017-07-21T07:33:51.199637
| 1,500,622,431.199637 | 86,639 |
pythondev
|
help
|
Arrow? Why not Delorean?
|
2017-07-21T07:33:59.201581
|
Suellen
|
pythondev_help_Suellen_2017-07-21T07:33:59.201581
| 1,500,622,439.201581 | 86,640 |
pythondev
|
help
|
That's not the sort of thing you need to answer immediately in a chat... you'd get a few knowledgeable people, they'd discuss it for a bit, find use cases, check code quality, etc
|
2017-07-21T07:34:32.211009
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:34:32.211009
| 1,500,622,472.211009 | 86,641 |
pythondev
|
help
|
There's going to be a huge debase, because it's not like it's clear which of the two is massively better.
|
2017-07-21T07:34:37.212464
|
Suellen
|
pythondev_help_Suellen_2017-07-21T07:34:37.212464
| 1,500,622,477.212464 | 86,642 |
pythondev
|
help
|
Doesn't matter. This happens already for other PEPs. There's a discussion, then a decision is made
|
2017-07-21T07:35:06.220121
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:35:06.220121
| 1,500,622,506.220121 | 86,643 |
pythondev
|
help
|
But PyPI provides an illusion of a democracy, where you can chose whatever you want.
|
2017-07-21T07:36:15.238709
|
Suellen
|
pythondev_help_Suellen_2017-07-21T07:36:15.238709
| 1,500,622,575.238709 | 86,644 |
pythondev
|
help
|
Python and PEPs isn't a democracy at all
|
2017-07-21T07:36:33.243676
|
Suellen
|
pythondev_help_Suellen_2017-07-21T07:36:33.243676
| 1,500,622,593.243676 | 86,645 |
pythondev
|
help
|
so maybe it's a calculated decision -- to not introduce some things into stdlib
|
2017-07-21T07:36:57.250101
|
Suellen
|
pythondev_help_Suellen_2017-07-21T07:36:57.250101
| 1,500,622,617.250101 | 86,646 |
pythondev
|
help
|
PyPI wouldn't go away. Users are always free to reinvent the wheel
|
2017-07-21T07:37:01.251272
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:37:01.251272
| 1,500,622,621.251272 | 86,647 |
pythondev
|
help
|
And yeah, it probably is a calculated decision; one I disagree with
|
2017-07-21T07:37:09.253314
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:37:09.253314
| 1,500,622,629.253314 | 86,648 |
pythondev
|
help
|
If you're gonna say that batteries are included, they should be good batteries, ones suitable for powering modern software
|
2017-07-21T07:37:36.260151
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:37:36.260151
| 1,500,622,656.260151 | 86,649 |
pythondev
|
help
|
Reasons for importing something inside of a function?. Besides avoiding circular imports
|
2017-07-21T07:56:09.564426
|
Mariano
|
pythondev_help_Mariano_2017-07-21T07:56:09.564426
| 1,500,623,769.564426 | 86,650 |
pythondev
|
help
|
Maybe it's not relevant to anything else in the program
|
2017-07-21T07:56:43.574336
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:56:43.574336
| 1,500,623,803.574336 | 86,651 |
pythondev
|
help
|
Generally speaking I avoid it if possible
|
2017-07-21T07:56:51.576671
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:56:51.576671
| 1,500,623,811.576671 | 86,652 |
pythondev
|
help
|
I have just done it for avoiding circular imports on some celery tasks. But i have seem it on open source projects
|
2017-07-21T07:57:44.591684
|
Mariano
|
pythondev_help_Mariano_2017-07-21T07:57:44.591684
| 1,500,623,864.591684 | 86,653 |
pythondev
|
help
|
it you're trying to limit the number of imports, I can understand
|
2017-07-21T07:58:32.605714
|
Meg
|
pythondev_help_Meg_2017-07-21T07:58:32.605714
| 1,500,623,912.605714 | 86,654 |
pythondev
|
help
|
especially highly specific imports
|
2017-07-21T07:58:39.608021
|
Meg
|
pythondev_help_Meg_2017-07-21T07:58:39.608021
| 1,500,623,919.608021 | 86,655 |
pythondev
|
help
|
It also violates PEP8
|
2017-07-21T07:58:49.611105
|
Patty
|
pythondev_help_Patty_2017-07-21T07:58:49.611105
| 1,500,623,929.611105 | 86,656 |
pythondev
|
help
|
but isn't there a bit of a penalty in doing so?
|
2017-07-21T07:58:50.611231
|
Meg
|
pythondev_help_Meg_2017-07-21T07:58:50.611231
| 1,500,623,930.611231 | 86,657 |
pythondev
|
help
|
performance penalty, that is
|
2017-07-21T07:58:58.613864
|
Meg
|
pythondev_help_Meg_2017-07-21T07:58:58.613864
| 1,500,623,938.613864 | 86,658 |
pythondev
|
help
|
because that method gets hit
|
2017-07-21T07:59:07.616321
|
Meg
|
pythondev_help_Meg_2017-07-21T07:59:07.616321
| 1,500,623,947.616321 | 86,659 |
pythondev
|
help
|
has to import a dependency before continuing execution
|
2017-07-21T07:59:15.618808
|
Meg
|
pythondev_help_Meg_2017-07-21T07:59:15.618808
| 1,500,623,955.618808 | 86,660 |
pythondev
|
help
|
I read that imports are expensives
|
2017-07-21T07:59:19.619948
|
Mariano
|
pythondev_help_Mariano_2017-07-21T07:59:19.619948
| 1,500,623,959.619948 | 86,661 |
pythondev
|
help
|
they can be
|
2017-07-21T07:59:38.625625
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T07:59:38.625625
| 1,500,623,978.625625 | 86,662 |
pythondev
|
help
|
and some people leave the more expensive ones in functions that arent often called, thats a main reason i see it too
|
2017-07-21T08:00:49.649741
|
Patty
|
pythondev_help_Patty_2017-07-21T08:00:49.649741
| 1,500,624,049.649741 | 86,663 |
pythondev
|
help
|
hellooo friends
|
2017-07-21T08:01:18.659372
|
Kandis
|
pythondev_help_Kandis_2017-07-21T08:01:18.659372
| 1,500,624,078.659372 | 86,664 |
pythondev
|
help
|
anybody knows what this means
|
2017-07-21T08:01:37.665433
|
Kandis
|
pythondev_help_Kandis_2017-07-21T08:01:37.665433
| 1,500,624,097.665433 | 86,665 |
pythondev
|
help
|
i saw this code in here:
|
2017-07-21T08:01:59.672387
|
Kandis
|
pythondev_help_Kandis_2017-07-21T08:01:59.672387
| 1,500,624,119.672387 | 86,666 |
pythondev
|
help
|
first link in google by query numpy arrange
|
2017-07-21T08:03:32.701375
|
Luana
|
pythondev_help_Luana_2017-07-21T08:03:32.701375
| 1,500,624,212.701375 | 86,667 |
pythondev
|
help
|
<https://docs.scipy.org/doc/numpy/reference/generated/numpy.arange.html>
|
2017-07-21T08:03:34.701813
|
Luana
|
pythondev_help_Luana_2017-07-21T08:03:34.701813
| 1,500,624,214.701813 | 86,668 |
pythondev
|
help
|
or did you ask something specific?
|
2017-07-21T08:03:51.706996
|
Luana
|
pythondev_help_Luana_2017-07-21T08:03:51.706996
| 1,500,624,231.706996 | 86,669 |
pythondev
|
help
|
what about t**2?? <@Luana>
|
2017-07-21T08:06:29.756314
|
Kandis
|
pythondev_help_Kandis_2017-07-21T08:06:29.756314
| 1,500,624,389.756314 | 86,670 |
pythondev
|
help
|
t power of 2
|
2017-07-21T08:07:47.780338
|
Luana
|
pythondev_help_Luana_2017-07-21T08:07:47.780338
| 1,500,624,467.780338 | 86,671 |
pythondev
|
help
|
but t is an array?
|
2017-07-21T08:08:25.791908
|
Samuel
|
pythondev_help_Samuel_2017-07-21T08:08:25.791908
| 1,500,624,505.791908 | 86,672 |
pythondev
|
help
|
how does t**2 and t**3 work in this image <@Luana>
|
2017-07-21T08:09:19.808779
|
Kandis
|
pythondev_help_Kandis_2017-07-21T08:09:19.808779
| 1,500,624,559.808779 | 86,673 |
pythondev
|
help
|
may be overloaded `__pow__`
|
2017-07-21T08:10:15.826710
|
Luana
|
pythondev_help_Luana_2017-07-21T08:10:15.826710
| 1,500,624,615.82671 | 86,674 |
pythondev
|
help
|
I haven’t work with numpy yet :slightly_smiling_face:
|
2017-07-21T08:10:50.837545
|
Luana
|
pythondev_help_Luana_2017-07-21T08:10:50.837545
| 1,500,624,650.837545 | 86,675 |
pythondev
|
help
|
:eyes:
|
2017-07-21T08:11:14.844755
|
Kandis
|
pythondev_help_Kandis_2017-07-21T08:11:14.844755
| 1,500,624,674.844755 | 86,676 |
pythondev
|
help
|
the function applies to every element of the original array
|
2017-07-21T08:27:44.162361
|
Suellen
|
pythondev_help_Suellen_2017-07-21T08:27:44.162361
| 1,500,625,664.162361 | 86,677 |
pythondev
|
help
|
so you see three plots: `y = x^1`, `y = x^2` and `y = x^3`
|
2017-07-21T08:28:19.174283
|
Suellen
|
pythondev_help_Suellen_2017-07-21T08:28:19.174283
| 1,500,625,699.174283 | 86,678 |
pythondev
|
help
|
I have here a very small unit test program which is supposed to test
that an object throws an AttributeError exception when a nonexistent
attribute lookup is attempted.
```
"""
It works fine, but I had to put the attribute access in a function.
I'd rather not define that function and use the assertRaises as follows:
self.assertRaises(AttributeError, lambda item: item.donation)
However, this gives me a "TypeError: <lambda>() takes exactly 1 argument (0 given)"
Is this somehow possible without helper function?
"""
import unittest
class Person(object):
pass
class MyTestCase(unittest.TestCase):
def testNonexistentAttibute(self):
def bombfunc():
p = Person()
p.name = "Joe"
p.money = 2800
p.money += p.donation # boom!
self.assertRaises(AttributeError, bombfunc)
self.assertRaises(AttributeError, lambda item: item.donation) # How to make this work?
if __name__ == "__main__":
unittest.main()
```
|
2017-07-21T10:00:21.673414
|
Ruben
|
pythondev_help_Ruben_2017-07-21T10:00:21.673414
| 1,500,631,221.673414 | 86,679 |
pythondev
|
help
|
I know you can use a `with` block in some other test packages, but to be honest this seems like a weird thing to be testing for
|
2017-07-21T10:04:21.814254
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:04:21.814254
| 1,500,631,461.814254 | 86,680 |
pythondev
|
help
|
You could probably use `self.assertIn("donation", item.__dict__)` or some similar abomination if you really want a one-liner
|
2017-07-21T10:06:22.885754
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:06:22.885754
| 1,500,631,582.885754 | 86,681 |
pythondev
|
help
|
<@Gabriele> Yeah it sounds weird, but actually the object under test is some kind of container giving both attribute and keyed lookup access to a set of properties, and I need to test whether the right exceptions are thrown during lookup of a nonexistent property.
|
2017-07-21T10:14:24.161608
|
Ruben
|
pythondev_help_Ruben_2017-07-21T10:14:24.161608
| 1,500,632,064.161608 | 86,682 |
pythondev
|
help
|
Sounds like a bad idea to me. But if I had to write tests for it, I'd just use the __dict__ check directly. Or `hasattr`.
|
2017-07-21T10:16:49.245549
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:16:49.245549
| 1,500,632,209.245549 | 86,683 |
pythondev
|
help
|
<@Gabriele> Bad idea? You have a better idea? Thanks for the `hasattr` tip! This is what it's all about, the `Bunch` object: <https://github.com/motoom/bunch>
|
2017-07-21T10:20:30.373050
|
Ruben
|
pythondev_help_Ruben_2017-07-21T10:20:30.373050
| 1,500,632,430.37305 | 86,684 |
pythondev
|
help
|
I think that is unnecessarily blurring the lines between a container and a type. If you don't know what attributes a type has, then you don't really know what interface it provides, which makes it a very awkward object to work with
|
2017-07-21T10:21:21.402618
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:21:21.402618
| 1,500,632,481.402618 | 86,685 |
pythondev
|
help
|
<@Gabriele> I use it declutter my source code. Basically it is a `dict` like object where you don't have to type `["` and `"]` all the time. So I can write:```
|
2017-07-21T10:23:03.461371
|
Ruben
|
pythondev_help_Ruben_2017-07-21T10:23:03.461371
| 1,500,632,583.461371 | 86,686 |
pythondev
|
help
|
```for r in bunched(recordset): # Where recordset is fetch_all() of DictCursor
if r.salary < 3000:
print r.name, "could use a raise"
```
|
2017-07-21T10:24:36.514624
|
Ruben
|
pythondev_help_Ruben_2017-07-21T10:24:36.514624
| 1,500,632,676.514624 | 86,687 |
pythondev
|
help
|
Psycopg2 has a `NamedTupleCursor`, which provides the same syntax.
|
2017-07-21T10:25:11.534439
|
Ruben
|
pythondev_help_Ruben_2017-07-21T10:25:11.534439
| 1,500,632,711.534439 | 86,688 |
pythondev
|
help
|
In that case, at least the schema is documented elsewhere. But I don't like it.
|
2017-07-21T10:26:04.565260
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:26:04.565260
| 1,500,632,764.56526 | 86,689 |
pythondev
|
help
|
The alternative would be:
```
for r in recordset:
if r["salary"] < 3000:
print r["name"], "could use a raise"
```
You prefer that?
|
2017-07-21T10:27:03.600478
|
Ruben
|
pythondev_help_Ruben_2017-07-21T10:27:03.600478
| 1,500,632,823.600478 | 86,690 |
pythondev
|
help
|
Maybe
|
2017-07-21T10:27:49.627957
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:27:49.627957
| 1,500,632,869.627957 | 86,691 |
pythondev
|
help
|
I can work like that. You have a job for me? :stuck_out_tongue_winking_eye:
|
2017-07-21T10:28:08.639557
|
Ruben
|
pythondev_help_Ruben_2017-07-21T10:28:08.639557
| 1,500,632,888.639557 | 86,692 |
pythondev
|
help
|
In the general case, yes. It's not exactly a great hardship. In a database context, it might be nice to have a type that directly reflects the DB schema - which is what we have ORM for
|
2017-07-21T10:28:32.653471
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:28:32.653471
| 1,500,632,912.653471 | 86,693 |
pythondev
|
help
|
btw, the `NamedTupleCursor` gets its attribute names from the fields behind the *SELECT*. I.e. `select name, salary from Employees` would result in *.name* and *.salary* attributes on the tuples in the resultset.
|
2017-07-21T10:29:33.689487
|
Ruben
|
pythondev_help_Ruben_2017-07-21T10:29:33.689487
| 1,500,632,973.689487 | 86,694 |
pythondev
|
help
|
I just really dislike things that attempt to cut down on a bit of typing by ruining the interface. Several parsers do it, like BeautifulSoup. lxml.objectify is even worse
|
2017-07-21T10:30:25.720812
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:30:25.720812
| 1,500,633,025.720812 | 86,695 |
pythondev
|
help
|
I wouldn't call it ruining. It makes the code more readable to me. I prefer dot notation over index lookup with a string.
|
2017-07-21T10:31:34.762088
|
Ruben
|
pythondev_help_Ruben_2017-07-21T10:31:34.762088
| 1,500,633,094.762088 | 86,696 |
pythondev
|
help
|
The dot notation and the index lookup carry different information. `x.y` implies that `y` _must_ exist. `x["y"]` implies that a value for "y" might exist, if someone added it earlier.
|
2017-07-21T10:33:07.816673
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:33:07.816673
| 1,500,633,187.816673 | 86,697 |
pythondev
|
help
|
Except xml node is not a container, but an object :confused:
|
2017-07-21T10:33:33.832134
|
Suellen
|
pythondev_help_Suellen_2017-07-21T10:33:33.832134
| 1,500,633,213.832134 | 86,698 |
pythondev
|
help
|
Ah, we have a different view on that too. When I see `x["y"]` in code, I assume the programmer knows that an *y* value is present, or should be present (punishable by KeyError). When I see `x.get(y)`, then I know the programmer is trying to communicate to me that *y* perhaps does not exist in *x*.
|
2017-07-21T10:34:42.873174
|
Ruben
|
pythondev_help_Ruben_2017-07-21T10:34:42.873174
| 1,500,633,282.873174 | 86,699 |
pythondev
|
help
|
it's an object that contains an arbitrary number of other objects
|
2017-07-21T10:34:57.881984
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:34:57.881984
| 1,500,633,297.881984 | 86,700 |
pythondev
|
help
|
<@Ruben> But the point is that you see it's a dict, and that the contents vary
|
2017-07-21T10:35:31.902663
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:35:31.902663
| 1,500,633,331.902663 | 86,701 |
pythondev
|
help
|
Obviously you can make assumptions if you know what's been added, but the syntax tells you the nature of the structure you're working with
|
2017-07-21T10:35:48.912684
|
Gabriele
|
pythondev_help_Gabriele_2017-07-21T10:35:48.912684
| 1,500,633,348.912684 | 86,702 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.