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
`from collections import defaultdict` <@Jettie> this better, agree :taco:
2019-03-02T07:36:04.289700
Jung
pythondev_help_Jung_2019-03-02T07:36:04.289700
1,551,512,164.2897
11,721
pythondev
help
apologies for the bad advice :disappointed:
2019-03-02T07:43:45.290000
Vanita
pythondev_help_Vanita_2019-03-02T07:43:45.290000
1,551,512,625.29
11,722
pythondev
help
How do we identify if a function can take function as an argument? what am i trying to do - learn decorators
2019-03-02T07:52:40.290900
Lanelle
pythondev_help_Lanelle_2019-03-02T07:52:40.290900
1,551,513,160.2909
11,723
pythondev
help
I have one Model with those fields: name clicks cost impressions breakdown And need to fill this Model with different data according to breakdown field. is any other way to used those fields once[name clicks cost impressions] and to change only breakdown? once with breakdown='age' ex: name = 3 clicks = 4 cost =5 impressions =6 breakdown = 'age' agedata = Model(name = name, clicks = clicks, cost =cost, impressions =impressions, breakdown = breakdown) agedata.save() and once with breakdown='gender' ex: name = 4 clicks = 7 cost =9 impressions =8 breakdown = 'gender' genderdata = Model(name = name, clicks = clicks, cost =cost, impressions =impressions, breakdown = breakdown) genderdata.save() and once with breakdown='region' ex: name = 5 clicks = 6 cost =8 impressions =2 breakdown = 'region' genderdata = Model(name = name, clicks = clicks, cost =cost, impressions =impressions, breakdown = breakdown) regiondata.save()
2019-03-02T08:38:57.291400
Lourie
pythondev_help_Lourie_2019-03-02T08:38:57.291400
1,551,515,937.2914
11,724
pythondev
help
updating the offending dependency fixed the issue.
2019-03-02T09:53:39.294100
Deangelo
pythondev_help_Deangelo_2019-03-02T09:53:39.294100
1,551,520,419.2941
11,725
pythondev
help
<@Lanelle> maybe by checking if function argument has `hasattr(obj, '__call__')`
2019-03-02T09:54:16.294900
Soo
pythondev_help_Soo_2019-03-02T09:54:16.294900
1,551,520,456.2949
11,726
pythondev
help
<@Lourie> you can make use of `*args and **kwargs`
2019-03-02T10:11:37.296000
Soo
pythondev_help_Soo_2019-03-02T10:11:37.296000
1,551,521,497.296
11,727
pythondev
help
Can you refer to example as a sample?
2019-03-02T10:12:36.297100
Lourie
pythondev_help_Lourie_2019-03-02T10:12:36.297100
1,551,521,556.2971
11,728
pythondev
help
```def foo(required, *args, **kwargs): print(required) if args: print(args) if kwargs: print(kwargs)```
2019-03-02T10:15:07.297500
Soo
pythondev_help_Soo_2019-03-02T10:15:07.297500
1,551,521,707.2975
11,729
pythondev
help
All of fields are required in different calls
2019-03-02T10:27:57.298500
Lourie
pythondev_help_Lourie_2019-03-02T10:27:57.298500
1,551,522,477.2985
11,730
pythondev
help
<@Lanelle> python is not strongly typed, and everything in Python is a first class object, so any function can technically take another function as an argument
2019-03-02T11:06:58.300000
Ashley
pythondev_help_Ashley_2019-03-02T11:06:58.300000
1,551,524,818.3
11,731
pythondev
help
<@Lourie> avoid making a "god object". If your function does something different depending on what arguments are passed to it, you should break it up into different functions
2019-03-02T11:10:38.301800
Ashley
pythondev_help_Ashley_2019-03-02T11:10:38.301800
1,551,525,038.3018
11,732
pythondev
help
Or perhaps consider making this a class where you can have methods and can make incremental changes to the state of the object
2019-03-02T11:11:52.302700
Ashley
pythondev_help_Ashley_2019-03-02T11:11:52.302700
1,551,525,112.3027
11,733
pythondev
help
when running `urllib.request.urlopen("<http://learncodethehardway.org/words.txt>").readlines()` it outputs results with a 'b' in front? (Ex: `[b'test']`) Is there a reason it does that? And how can I remove the b from the results?
2019-03-02T11:52:31.304200
Annabell
pythondev_help_Annabell_2019-03-02T11:52:31.304200
1,551,527,551.3042
11,734
pythondev
help
That's just debug output format, indicating it's a byte string instead of unicode. It's not part of the actual content, same as the quotes.
2019-03-02T12:07:38.305700
Sasha
pythondev_help_Sasha_2019-03-02T12:07:38.305700
1,551,528,458.3057
11,735
pythondev
help
React is a JavaScript framework for designing responsive web pages.
2019-03-02T12:13:26.305800
Valeri
pythondev_help_Valeri_2019-03-02T12:13:26.305800
1,551,528,806.3058
11,736
pythondev
help
That makes sense because when I run `', '.join([b'test'])` I get this error: "TypeError: sequence item 0: expected str instance, bytes found" If I converted it to unicode would it work?
2019-03-02T12:20:37.307000
Annabell
pythondev_help_Annabell_2019-03-02T12:20:37.307000
1,551,529,237.307
11,737
pythondev
help
Yep. If it's a text file it's likely just ASCII to start with, or maybe UTF-8.
2019-03-02T12:36:06.307900
Sasha
pythondev_help_Sasha_2019-03-02T12:36:06.307900
1,551,530,166.3079
11,738
pythondev
help
Or if you wanted to just keep them as byte strings, you can use `b', '.join()`.
2019-03-02T12:39:23.308400
Sasha
pythondev_help_Sasha_2019-03-02T12:39:23.308400
1,551,530,363.3084
11,739
pythondev
help
Awesome. That helped me out a lot. Thanks for helping me through it. <https://stackoverflow.com/questions/4981977/how-to-handle-response-encoding-from-urllib-request-urlopen> ``` a = urllib.request.urlopen("<http://learncodethehardway.org/words.txt>").readlines() &gt;&gt;&gt; a[0] b'account\n' &gt;&gt;&gt; a[0].decode('utf-8').strip()`'account' 'account' ```
2019-03-02T12:50:08.309500
Annabell
pythondev_help_Annabell_2019-03-02T12:50:08.309500
1,551,531,008.3095
11,740
pythondev
help
How can I execute distributed complex workflow using celery? If celery does not support this then what are other options? If I have multiple microservices and If I want to orchestrate a workflow from one service using celery. How can I do this?
2019-03-02T13:12:57.310600
Barney
pythondev_help_Barney_2019-03-02T13:12:57.310600
1,551,532,377.3106
11,741
pythondev
help
have N producers that create tasks and M workers
2019-03-02T13:28:02.311000
Jettie
pythondev_help_Jettie_2019-03-02T13:28:02.311000
1,551,533,282.311
11,742
pythondev
help
now you're distributed
2019-03-02T13:28:07.311200
Jettie
pythondev_help_Jettie_2019-03-02T13:28:07.311200
1,551,533,287.3112
11,743
pythondev
help
does anyone know a work around to install ctypes on macos?
2019-03-02T15:25:27.311900
Susie
pythondev_help_Susie_2019-03-02T15:25:27.311900
1,551,540,327.3119
11,744
pythondev
help
<@Barney> We're going to need more information about what exactly you're hoping to accomplish. "Orchestrate a workflow" is so broad it's effectively meaningless when coming up with solutions. What is the workflow? How does it need to be orchestrated?
2019-03-02T15:28:14.313100
Carmen
pythondev_help_Carmen_2019-03-02T15:28:14.313100
1,551,540,494.3131
11,745
pythondev
help
``` from ..appTwo import views urlpatterns = [ path('',views.index), path('admin/', admin.site.urls), ] ```
2019-03-02T16:12:00.315600
Lael
pythondev_help_Lael_2019-03-02T16:12:00.315600
1,551,543,120.3156
11,746
pythondev
help
ValueError: attempted relative import beyond top-level package
2019-03-02T16:12:24.316000
Lael
pythondev_help_Lael_2019-03-02T16:12:24.316000
1,551,543,144.316
11,747
pythondev
help
How to fix it in django?
2019-03-02T16:12:49.316700
Lael
pythondev_help_Lael_2019-03-02T16:12:49.316700
1,551,543,169.3167
11,748
pythondev
help
I have this in AppTwo.views ```def index(request): return HttpResponse("&lt;em&gt;My Second Project&lt;/em&gt;") ```
2019-03-02T16:13:46.317300
Lael
pythondev_help_Lael_2019-03-02T16:13:46.317300
1,551,543,226.3173
11,749
pythondev
help
<@Lael> It appears that you are aiming for a certain directory, but are landing somewhere else. This article will help you understand pros/cons for absolute vs. relative imports. <https://realpython.com/absolute-vs-relative-python-imports/>
2019-03-02T16:57:38.320900
Marla
pythondev_help_Marla_2019-03-02T16:57:38.320900
1,551,545,858.3209
11,750
pythondev
help
hi, aside from packaged libs and projects means for reuse, is *setup.py* recommended for a web service?
2019-03-02T18:20:21.322700
Deangelo
pythondev_help_Deangelo_2019-03-02T18:20:21.322700
1,551,550,821.3227
11,751
pythondev
help
what is the appropriate typing hint to set as the return value in this case? ``` from typing import * def my_function(some_model: 'SomeModel') -&gt; : return some_model.objects.create() ```
2019-03-02T19:04:11.324600
Helga
pythondev_help_Helga_2019-03-02T19:04:11.324600
1,551,553,451.3246
11,752
pythondev
help
`Off-topic` Hello , folks! I'm looking for a way to easy deploy python/php scripts on virtual machines (mostly google cloud), the goal is to run each script with different arguments. I was thinking about docker containers and maybe kubernetes, but how to automate running scripts with different arguments?
2019-03-02T19:14:48.325000
Karen
pythondev_help_Karen_2019-03-02T19:14:48.325000
1,551,554,088.325
11,753
pythondev
help
That's almost an impossible question to answer without more context
2019-03-02T20:06:59.325700
Jonas
pythondev_help_Jonas_2019-03-02T20:06:59.325700
1,551,557,219.3257
11,754
pythondev
help
Kubernetes is great for deploying containers. If you want different arguments then just make a new k8s deployment with them
2019-03-02T20:08:13.327200
Jonas
pythondev_help_Jonas_2019-03-02T20:08:13.327200
1,551,557,293.3272
11,755
pythondev
help
If they are a short lived "job" rather than a service, use a k8s job
2019-03-02T20:08:31.327900
Jonas
pythondev_help_Jonas_2019-03-02T20:08:31.327900
1,551,557,311.3279
11,756
pythondev
help
If it's a cronjob running at specific times, use a k8s cronjob. However if you are struggling with this question i would read up more on deployment pipelines
2019-03-02T20:09:26.329600
Jonas
pythondev_help_Jonas_2019-03-02T20:09:26.329600
1,551,557,366.3296
11,757
pythondev
help
`'SomeModel'` as a string if you are using &lt; Python 3.7. This is similar to how Django requires strings for ForeignKey references where the model is not yet declared. If you are on 3.7+, `PEP563` suggests including: `from __future__ import annotations` This allows for setting the return value as the model itself instead of a string, as in `SomeModel`.
2019-03-02T21:55:22.329900
Marla
pythondev_help_Marla_2019-03-02T21:55:22.329900
1,551,563,722.3299
11,758
pythondev
help
:thumbsup: so even though your not technically getting the model back, because a new instance was created, it is correct to set the type hint as the model in this case?
2019-03-02T22:19:03.330100
Helga
pythondev_help_Helga_2019-03-02T22:19:03.330100
1,551,565,143.3301
11,759
pythondev
help
If we check the type of a newly created instance of a model, we see that it’s `&lt;class 'SomeModel'&gt;`. We can also check `isinstance(my_function(SomeModel), SomeModel)` and get `True` I believe the model name to be the correct annotation, but someone may know more specifically.
2019-03-02T22:29:55.330300
Marla
pythondev_help_Marla_2019-03-02T22:29:55.330300
1,551,565,795.3303
11,760
pythondev
help
thank you!
2019-03-02T23:17:58.330500
Helga
pythondev_help_Helga_2019-03-02T23:17:58.330500
1,551,568,678.3305
11,761
pythondev
help
celery has canvas for workflow. but what if I have multiple microservices and each service have different tasks. I want to orchestrate the workflow of that multiple tasks. workflow means there are series of tasks it will execute in chain some of the task should run in parallel some tasks are also dependent to each other. How can I do this?
2019-03-03T00:33:25.331100
Barney
pythondev_help_Barney_2019-03-03T00:33:25.331100
1,551,573,205.3311
11,762
pythondev
help
This could be a silly question but does anyone have any idea to convert First Class functions into normal class or class objects?
2019-03-03T01:47:37.333100
Myles
pythondev_help_Myles_2019-03-03T01:47:37.333100
1,551,577,657.3331
11,763
pythondev
help
You may want to expand on what you are really wanting to do. There are a number of ways to mix things up... you can assign attributes to functions like `func.foo`, or you can have a class behave like a function by defining the `__call__` method, etc.
2019-03-03T01:53:17.334800
Sasha
pythondev_help_Sasha_2019-03-03T01:53:17.334800
1,551,577,997.3348
11,764
pythondev
help
Hi all! Is anyone here familiar with Pinax (Django) project? I just started with Django and wonder if this project can be of any help for me?
2019-03-03T06:06:33.336600
Blanch
pythondev_help_Blanch_2019-03-03T06:06:33.336600
1,551,593,193.3366
11,765
pythondev
help
Hi! Quick question! My browser is running a python script for me but I cannot see what goes wrong since everything happens in the backgroud, is there a way to open a terminal window and see the execution of the python script whilst it occurs?
2019-03-03T13:23:08.338500
Cheri
pythondev_help_Cheri_2019-03-03T13:23:08.338500
1,551,619,388.3385
11,766
pythondev
help
The python script occurs locally
2019-03-03T13:23:14.338800
Cheri
pythondev_help_Cheri_2019-03-03T13:23:14.338800
1,551,619,394.3388
11,767
pythondev
help
Anyone understands what is going on here?
2019-03-03T14:06:23.339700
Cheri
pythondev_help_Cheri_2019-03-03T14:06:23.339700
1,551,621,983.3397
11,768
pythondev
help
Well, it looks like it's decoding some sort of packet protocol which consists of a 4-byte binary length and then a chunk of JSON data.
2019-03-03T14:13:56.341100
Sasha
pythondev_help_Sasha_2019-03-03T14:13:56.341100
1,551,622,436.3411
11,769
pythondev
help
I started my Django project and have little problem. It will be car-sharing app and i want not-owner of race users be able to join. Can i use permission, to give them permission to only "participants" field of model?
2019-03-03T15:09:53.344000
Waltraud
pythondev_help_Waltraud_2019-03-03T15:09:53.344000
1,551,625,793.344
11,770
pythondev
help
I have a collection of tuples in format of `(x, (a,b))`, now I want to filter the collection using a function that is only based on `x` e.g. the first element of the tuple, how to do that?
2019-03-03T15:26:21.345600
Lanny
pythondev_help_Lanny_2019-03-03T15:26:21.345600
1,551,626,781.3456
11,771
pythondev
help
Maybe something like `filter(lambda a: real_filter(a[0]), data)`?
2019-03-03T15:30:10.346200
Sasha
pythondev_help_Sasha_2019-03-03T15:30:10.346200
1,551,627,010.3462
11,772
pythondev
help
Ah. Effectively, you have multiple tasks defined in different microservices, but the tasks are interdependent between the microservices. If the microservice codebases are separate, I don't think there's any way for you to use canvas to declare the task dependencies. You'd have to setup something where a task makes a call to the next microservice in its dependency chain, so that that service can initiate the next task.
2019-03-03T15:35:14.346800
Carmen
pythondev_help_Carmen_2019-03-03T15:35:14.346800
1,551,627,314.3468
11,773
pythondev
help
That works. Thanks!
2019-03-03T15:35:17.347000
Lanny
pythondev_help_Lanny_2019-03-03T15:35:17.347000
1,551,627,317.347
11,774
pythondev
help
A slightly better way might be to have an orchestrator microservice that centralizes all the calls to each microservice, and makes sure that they each get called at the appropriate time when a task is completed.
2019-03-03T15:36:19.347200
Carmen
pythondev_help_Carmen_2019-03-03T15:36:19.347200
1,551,627,379.3472
11,775
pythondev
help
I want a `set` of tuple elements where `(1,2)` is the same as `(2,1`). Is a custom set overriding the default set equality the only way of achieving this?
2019-03-03T17:09:57.348900
Lanny
pythondev_help_Lanny_2019-03-03T17:09:57.348900
1,551,632,997.3489
11,776
pythondev
help
You could also have a wrapper class which overrides equality for its objects but still use a regular set. Note that in both cases you may need to also override the hash calculation.
2019-03-03T17:33:15.350100
Sasha
pythondev_help_Sasha_2019-03-03T17:33:15.350100
1,551,634,395.3501
11,777
pythondev
help
So are else statements even necessary? I think i was talking to you guys the other day and it seemed like they weren't
2019-03-03T20:25:43.351000
Demetrice
pythondev_help_Demetrice_2019-03-03T20:25:43.351000
1,551,644,743.351
11,778
pythondev
help
So for example. In this code. Is the else statement needed?
2019-03-03T20:25:53.351300
Demetrice
pythondev_help_Demetrice_2019-03-03T20:25:53.351300
1,551,644,753.3513
11,779
pythondev
help
None
2019-03-03T20:26:02.351400
Demetrice
pythondev_help_Demetrice_2019-03-03T20:26:02.351400
1,551,644,762.3514
11,780
pythondev
help
It very much depends on the code in question. In that specific case, no, leaving out the else won't harm the logic of the function, and it doesn't even harm the readability of the function very much.
2019-03-03T20:59:03.353100
Carmen
pythondev_help_Carmen_2019-03-03T20:59:03.353100
1,551,646,743.3531
11,781
pythondev
help
I'd tend to disagree in this case, since omitting the `else` would make it return `None` instead of `False`, which is not quite the same thing.
2019-03-03T22:28:33.354300
Sasha
pythondev_help_Sasha_2019-03-03T22:28:33.354300
1,551,652,113.3543
11,782
pythondev
help
Ah, now I was thinking only about the else itself, not removing the code within the else branch. Effectively, shift the `return False` to always run as the last line of the function.
2019-03-03T22:34:12.355300
Carmen
pythondev_help_Carmen_2019-03-03T22:34:12.355300
1,551,652,452.3553
11,783
pythondev
help
Oh, gotcha, agreed.
2019-03-03T22:45:11.355700
Sasha
pythondev_help_Sasha_2019-03-03T22:45:11.355700
1,551,653,111.3557
11,784
pythondev
help
Just use `frozenset([1, 2])`. Frozensets are like regular sets, but they are hashable and immutable
2019-03-03T23:17:55.358700
Johana
pythondev_help_Johana_2019-03-03T23:17:55.358700
1,551,655,075.3587
11,785
pythondev
help
anyone have ideas on how to efficiently turn this into a bulk_create method, is this possible with a foreign key?
2019-03-03T23:24:40.358900
Helga
pythondev_help_Helga_2019-03-03T23:24:40.358900
1,551,655,480.3589
11,786
pythondev
help
Hi everyone, I am totally new here and it is my pleasure to join this channel. I am using &gt;Django-Channel 2 and I have a question how can I filter users that was already registered to sending information and not just to all of them, just subset of them! thank you
2019-03-04T00:02:11.361600
Dorian
pythondev_help_Dorian_2019-03-04T00:02:11.361600
1,551,657,731.3616
11,787
pythondev
help
Hi all, I want to import csv_utils.py file into kafka.py. However this code isn't work and throw module not found error. I am using Mac but my code should also run on Windows/Linux because of distributing. Because of that, I couldn't find a solution for me on Stackoverflow etc. How can I relativly import this util ? Application scripts utils csv_utils.py tests kafka.py from scripts.utils.csv_utils import CsvUtils
2019-03-04T03:02:21.363700
Shirly
pythondev_help_Shirly_2019-03-04T03:02:21.363700
1,551,668,541.3637
11,788
pythondev
help
Do you have `__init__.py` files to indicate that the subdirectories are modules?
2019-03-04T03:09:54.364200
Sasha
pythondev_help_Sasha_2019-03-04T03:09:54.364200
1,551,668,994.3642
11,789
pythondev
help
Yes I have
2019-03-04T03:10:07.364400
Shirly
pythondev_help_Shirly_2019-03-04T03:10:07.364400
1,551,669,007.3644
11,790
pythondev
help
how you run script (kafka.py ?) ?
2019-03-04T03:12:00.365500
Remedios
pythondev_help_Remedios_2019-03-04T03:12:00.365500
1,551,669,120.3655
11,791
pythondev
help
show please command
2019-03-04T03:12:14.365800
Remedios
pythondev_help_Remedios_2019-03-04T03:12:14.365800
1,551,669,134.3658
11,792
pythondev
help
so, probably you should try to run this kafka.py inside `scripts` folder. for example: ``` python -m tests.kafka ```
2019-03-04T03:15:08.366700
Remedios
pythondev_help_Remedios_2019-03-04T03:15:08.366700
1,551,669,308.3667
11,793
pythondev
help
I am in tests folder and I run locust -f kafka.py .....
2019-03-04T03:27:43.367200
Shirly
pythondev_help_Shirly_2019-03-04T03:27:43.367200
1,551,670,063.3672
11,794
pythondev
help
inside `tests` folder you have not access to `utils` and you cannot relative import this. if you want use relative import as you wrote `from scripts.utils.csv_utils import CsvUtils` you need to run script outside `scripts` folder.
2019-03-04T03:31:14.369200
Remedios
pythondev_help_Remedios_2019-03-04T03:31:14.369200
1,551,670,274.3692
11,795
pythondev
help
if you will run locust/script like `python -m scripts.tests.kafka` then you will be able to import like you want
2019-03-04T03:32:19.370400
Remedios
pythondev_help_Remedios_2019-03-04T03:32:19.370400
1,551,670,339.3704
11,796
pythondev
help
if you want use relative import as you wrote `from scripts.utils.csv_utils import CsvUtils` you need to run script outside `scripts` folder.
2019-03-04T03:33:32.370700
Shirly
pythondev_help_Shirly_2019-03-04T03:33:32.370700
1,551,670,412.3707
11,797
pythondev
help
I tried this, its also not working for me. Throws same error
2019-03-04T03:33:48.371200
Shirly
pythondev_help_Shirly_2019-03-04T03:33:48.371200
1,551,670,428.3712
11,798
pythondev
help
however I didn't use sys.path.append or something. Could it be ?
2019-03-04T03:34:27.372100
Shirly
pythondev_help_Shirly_2019-03-04T03:34:27.372100
1,551,670,467.3721
11,799
pythondev
help
you can use sys.path for this. but it will be trick (for me it not good idea) for example ``` import sys from pathlib import Path file = Path(__file__).resolve() parent, root = file.parent, file.parents[1] sys.path.append(str(root)) ```
2019-03-04T03:35:40.372700
Remedios
pythondev_help_Remedios_2019-03-04T03:35:40.372700
1,551,670,540.3727
11,800
pythondev
help
Hello everyone. ``` from collections import defaultdict In [70]: example = defaultdict(list) In [71]: example['numbers'] Out[71]: [] In [72]: example['numbers'].append('first') In [73]: example['numbers'].append('second') In [74]: example['numbers'].append('third') In [75]: example['colors'] Out[75]: [] In [76]: example['colors'].append('blue') In [77]: example['colors'].append('black') In [78]: example['colors'].append('yellow') In [79]: example Out[79]: defaultdict(list, {'numbers': ['first', 'second', 'third'], 'colors': ['blue', 'black', 'yellow']}) In [80]: type(example) Out[80]: collections.defaultdict ``` Do you know how `example` to write to csv file?
2019-03-04T04:37:05.373500
Jung
pythondev_help_Jung_2019-03-04T04:37:05.373500
1,551,674,225.3735
11,801
pythondev
help
sorry not sure how `frozenset` helps here. In the set, I want to treat `(1,2)` the same as `(2,1)`.
2019-03-04T04:59:45.373600
Lanny
pythondev_help_Lanny_2019-03-04T04:59:45.373600
1,551,675,585.3736
11,802
pythondev
help
<@Jettie> Maybe you know?
2019-03-04T05:00:08.373800
Jung
pythondev_help_Jung_2019-03-04T05:00:08.373800
1,551,675,608.3738
11,803
pythondev
help
csv.DictWriter?
2019-03-04T05:03:32.374000
Jettie
pythondev_help_Jettie_2019-03-04T05:03:32.374000
1,551,675,812.374
11,804
pythondev
help
So I have the following module that has the accompanying docstring explaining what it is supposed to do. I'm stuck at line 29 since I don't know what to do next to successfully return the number of duplicates alongside the vowels in the string in tuple format.
2019-03-04T05:08:18.374200
Jamey
pythondev_help_Jamey_2019-03-04T05:08:18.374200
1,551,676,098.3742
11,805
pythondev
help
I would store vowels encountered in a dict and the number of occurence as value
2019-03-04T05:15:18.375000
Jimmy
pythondev_help_Jimmy_2019-03-04T05:15:18.375000
1,551,676,518.375
11,806
pythondev
help
then listing the keys would find all the vowels
2019-03-04T05:15:58.375400
Jimmy
pythondev_help_Jimmy_2019-03-04T05:15:58.375400
1,551,676,558.3754
11,807
pythondev
help
and the values all the occurence
2019-03-04T05:16:10.375700
Jimmy
pythondev_help_Jimmy_2019-03-04T05:16:10.375700
1,551,676,570.3757
11,808
pythondev
help
<@Jettie> ``` import csv with open('names.csv', 'w', newline='') as csvfile: fieldnames = ['first_name', 'last_name'] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() writer.writerow({'first_name': 'Baked', 'last_name': 'Beans'}) writer.writerow({'first_name': 'Lovely', 'last_name': 'Spam'}) writer.writerow({'first_name': 'Wonderful', 'last_name': 'Spam'}) ``` But <https://docs.python.org/3/library/csv.html#csv.DictWriter> ``` In [102]: example['numbers'] Out[102]: ['first', 'second', 'third'] ``` How to get headers I know. Ok. But how to get like this: ``` writer.writerow({'first_name': 'Baked', 'last_name': 'Beans'}) ``` I don't understand.
2019-03-04T05:16:51.375800
Jung
pythondev_help_Jung_2019-03-04T05:16:51.375800
1,551,676,611.3758
11,809
pythondev
help
you need to create a dict for each row, keys should be just keys from your defaultdict, and values should be Nth elements of each list
2019-03-04T05:37:10.376000
Jettie
pythondev_help_Jettie_2019-03-04T05:37:10.376000
1,551,677,830.376
11,810
pythondev
help
I want to use google cloud pub/sub with grpc call in python. How can I implement? can someone provide good resources for this?
2019-03-04T05:45:57.376600
Barney
pythondev_help_Barney_2019-03-04T05:45:57.376600
1,551,678,357.3766
11,811
pythondev
help
Hello everyone. ``` In [83]: types = [] In [84]: types.append('some text') In [85]: types.append('12') In [86]: types.append('15.5') In [87]: types.append('True') In [88]: types.append('1/1/2019') In [89]: types Out[89]: ['some text', '12', '15.5', 'True', '1/1/2019'] ``` Guys, I have such a list, how can I understand, is it possible to change the data type to another? For example: ``` In [90]: types[0] Out[90]: 'some text' In [91]: type(types[0]) Out[91]: str ``` It only `str`, Ok. But ``` In [92]: int(types[1]) Out[92]: 12 ``` will be `int` ``` In [93]: float(types[1]) Out[93]: 12.0 ``` etc `bool` and `datetype` Is there a library for this? Or only I can like: ``` In [95]: for i in types: ...: try: ...: if int(i): ...: print('int =&gt;' + str(i)) ...: except ValueError: ...: pass int =&gt;12 ``` Do I need many `if and elif`? And check every element?
2019-03-04T06:04:26.376800
Jung
pythondev_help_Jung_2019-03-04T06:04:26.376800
1,551,679,466.3768
11,812
pythondev
help
what types are you checking for?
2019-03-04T06:06:52.377100
Mica
pythondev_help_Mica_2019-03-04T06:06:52.377100
1,551,679,612.3771
11,813
pythondev
help
it's impossible to do that in the general case
2019-03-04T06:07:04.377500
Jonas
pythondev_help_Jonas_2019-03-04T06:07:04.377500
1,551,679,624.3775
11,814
pythondev
help
i.e to know what types a primitive string _could_ be
2019-03-04T06:07:12.378000
Jonas
pythondev_help_Jonas_2019-03-04T06:07:12.378000
1,551,679,632.378
11,815
pythondev
help
it could be anything. so yes, you would need to convert them and see if it works
2019-03-04T06:07:27.378400
Jonas
pythondev_help_Jonas_2019-03-04T06:07:27.378400
1,551,679,647.3784
11,816
pythondev
help
````for conversion_func in (int, datetime.datetime, float): try: conversion_func(your_input) except ValueError: pass```
2019-03-04T06:07:54.379100
Jonas
pythondev_help_Jonas_2019-03-04T06:07:54.379100
1,551,679,674.3791
11,817
pythondev
help
the solution to this is: don't do this. If you're learning and playing around then fair enough <@Jung>, but if not... re-think what you are doing.
2019-03-04T06:08:55.380000
Jonas
pythondev_help_Jonas_2019-03-04T06:08:55.380000
1,551,679,735.38
11,818
pythondev
help
:disappointed: I can't make that.
2019-03-04T06:14:24.380100
Jung
pythondev_help_Jung_2019-03-04T06:14:24.380100
1,551,680,064.3801
11,819
pythondev
help
``` with open('eggs.csv', 'w', newline='') as csvfile: spamwriter = csv.writer(csvfile, delimiter='\t') spamwriter.writerow(heads) for i in range(m_iter): rez = [] for head in heads: rez.append(d[head][i]) spamwriter.writerow(rez) ```
2019-03-04T06:57:09.380300
Jung
pythondev_help_Jung_2019-03-04T06:57:09.380300
1,551,682,629.3803
11,820