Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
The Fool
Oct 16, 2003


huhu posted:

I started developing with Sublime Text and then switched to PyCharm since I've been working mostly with Python. However, my new job has me focusing on Flask apps and PyCharm seems to be a bit lacking when it comes to dealing with HTML, CSS, and JS. I miss all the awesome plugins that come with Sublime Text as well. Am I missing something or should I be looking at something else to be developing Flask stuff?

I feel like I might be saying this too often at this point, but have you considered VSCode accepted Christ as your Lord and Savior

https://code.visualstudio.com/docs/languages/python

Adbot
ADBOT LOVES YOU

The Fool
Oct 16, 2003


This was my favorite line from that:

quote:

Vigil deleted a function. Won't that cause the functions that call it to fail?

It would seem that those functions appear to be corrupted as well. Run Vigil again and it will take care of that for you. Several invocations may be required to fully excise all bugs from your code.

The Fool
Oct 16, 2003


Yes and there are a lot of them.

Some of them are actually good.

The Fool
Oct 16, 2003


Also try postman: https://www.getpostman.com/

The Fool
Oct 16, 2003


I don’t use pycharm, but I would start here: https://www.jetbrains.com/help/pycharm/debugging.html

The Fool
Oct 16, 2003


Yeah, Basic Auth doesn't work for Sharepoint.


You can do user auth if you're using the Sharepoint CSOM: https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/complete-basic-operations-using-sharepoint-client-library-code

The "correct" way is to use an app registration and authentication token through the graph api: https://docs.microsoft.com/en-us/onedrive/developer/rest-api/ https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/app-registration

edit: just realized this was a the python thread, here's something python specific that my help: https://github.com/vgrem/Office365-REST-Python-Client

The Fool fucked around with this message at 18:23 on May 14, 2018

The Fool
Oct 16, 2003


jonwayne is a pro though

The Fool
Oct 16, 2003


I love me some elk.



Oh wait, wrong forum.


ELK is good too, if you want a super low effort self hosted ELK style setup and have any docker experience, it is super easy to get Graylog setup in containers.

The Fool
Oct 16, 2003


Can someone explain the __future__ library to my like I'm an idiot.

I've done some googling, but I'm still not sure I get the point.

The Fool
Oct 16, 2003


Like if I wanted a 3 feature in 2.7?

The Fool
Oct 16, 2003


At work in am receiving a backup of an Sql database, but I will not be getting control of any of the existing infrastructure or front end.

I was thinking about throwing up a quick and dirty Django front end, but have no idea how to set up the orm to handle an existing database.

Is there an accepted best practice? Should I just build out a new table structure that I can import the data into, or is there a better way?

The Fool
Oct 16, 2003


Forget about Python specifically for a little bit and try sketching the problem out on paper first.

In plain language, write out the logic needed to solve the problem step by step, be as granular as possible.

Then you can start replacing your logical steps with actual Python code.

The Fool
Oct 16, 2003


DRF supports token authentication.

https://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication

The Fool
Oct 16, 2003


I understand PHP has a pretty bad package management situation too.

The Fool
Oct 16, 2003


Thermopyle posted:

I'm wanting to create a server process that other processes can subscribe to to get a stream of events from. Note that these are processes all on one machine.

The thing is...I'm feeling kinda lazy and don't really want to wire up something with sockets or wtf ever. Is there anything pre-built to make this easier that I should look at? Anyone else done something like this and have any tips they want to share?

Friend of mine did a similar thing using twisted, might be worth looking at.

The Fool
Oct 16, 2003


The benefit is to be able to develop in an environment as close to production as possible. With Docker you can deploy the same configurations as production without a bunch of admin overhead.

You also wouldn't develop "inside a container", you'd either push your code through vc and a hook would bring it in to docker, or your dev docker configuration would have a volume pointing at your code on your workstation.

The Fool
Oct 16, 2003


Hadlock posted:

I may write up an OP for one here later this week. Watching developers gently caress around with "dockers" is like a sweaty nerd trying to figure out how to finger bang an unlucky girl in the back of a car for the first time

...probably need a love line thread for them

We have a devops thread but it's overly broad and generic

I think a docker/container specific thread would be a good idea. The topic has come up quite a bit in the last week across multiple IT and dev threads.

The Fool
Oct 16, 2003


I absolutely prefer reading to videos. Don't do dead trees anymore though, all online. Usually whatever random blog I ended up at after a half-assed Google search.


If find the inaccuracies of the blog forcing me to think harder is better for my learning process.

The Fool
Oct 16, 2003


StashAugustine posted:

Hey I'm doing some work with python on Ubuntu. What's a good text editor for that? Gedit is kinda lovely about indentation sometimes (or maybe I'm just dumb)

https://code.visualstudio.com/docs/setup/linux

The Fool
Oct 16, 2003


Mycroft Holmes posted:

i'm doing some homework and could use some help.

i've got an array of strings and i need to display the first letter of each string. i think the best way to do this would be a for..in loop, but i'm not sure how.

strings are arrays of characters

The Fool
Oct 16, 2003


Mycroft Holmes posted:

I am aware of that. I need a section of code that works regardless of how many strings are in the array

Then maybe I didn't understand which part you needed help with.

In broad strokes:
You use your for loop to loop through your array of strings.
For each string in your array, you display the first character of the string.


Mycroft Holmes posted:

i also have another array that is a list of vowels. I need to count how many times the vowels in array 2 appear in the array 1. How can I do this?

there are better ways to do this, but the naive way would be to use two loops:
use a for loop each vowel, then loop through your string comparing the current letter to current vowel
if you get a match, increment a counter

The Fool
Oct 16, 2003


Mycroft Holmes posted:

ok, so i've got

code:
for b in a:
    string1.append(a[0][0])
    a[0][0] + 1
so i should have it select a[0][0] and then increment to a[1][0]. how do i do that?


Python code:

for x in range(0,len(a)):

Then x will be a number that automatically increments for the length of a.

Then you can access the first element of your second dimension by a[x][0]

The Fool fucked around with this message at 20:11 on Jun 25, 2019

The Fool
Oct 16, 2003


Mycroft Holmes posted:

cool, that works. Now, the strings are of variable length. how do i print only the last letter of the string? is there a function for that?

Someone else answered that already further up.

The Fool
Oct 16, 2003


Assuming a is a list of words

Make a counter that starts at 0
Loop through a for each word
Check the letter count of each word
Increment your counter by the number of letters
When the loop is over, print the final count

The Fool
Oct 16, 2003


Wallet posted:

The list of vowels posted has both capital and lowercase (for whatever reason) so I assume that's not the issue.

I believe he was counting just 'E' or just 'e', and I assume he needed the count of both.

The Fool
Oct 16, 2003


I'm merging a couple csv's with pandas and am having issues with numbers getting rounded up when using pandas.read_csv.

For example: 1904.9999 becomes 1905

Any suggestions? I spent a couple hours on google trying to figure this out and nothing I've tried has worked.

The Fool
Oct 16, 2003


float_precision on it's own wasn't working, but adding the other two arguments did.

Thanks.

The Fool
Oct 16, 2003


Krakkles posted:

Dumb question I can’t figure out: how do you get PyCharm on windows to see packages installed to python on ubuntu/WSL?

I found jetbrains’ instructions to get the interpreter setup, and that’s working fine, but PyCharm still can’t resolve a bunch of references because it doesn’t see, for example, that Django is installed.

I miss my MacBook.

You don't, you'll have to install those packages in windows as well.

There is a way to symlink stuff between WSL and windows, but it'll be a huge pain in the rear end and probably not work right.

The Fool
Oct 16, 2003


You can't have hyperv installed at all if you want to run virtual box.

Also, docker toolbox is legacy and not recommended.

The Fool
Oct 16, 2003


ImageMagick?

The Fool
Oct 16, 2003


C++ does a better job of keeping you from getting lost at sea.

The Fool
Oct 16, 2003



I’ve used the obs virtual cam at work with Skype/teams and zoom with no issues.

Was fun to do fancy transitions between sharing my desktop and my webcam or to throw up a white screen with the company logo.

The Fool
Oct 16, 2003


Pandas question:
I have a dataframe that I am doing groupby().agg() on to merge duplicate ID's and sum specific columns.

It has a bunch of columns, but I only need to sum 3 of them.

This all works. My question is, how can I do this without having to specify every single column in the dataframe?

The Fool
Oct 16, 2003


CarForumPoster posted:

Could you provide an input, expected output and example bit of code and what the output? I'm not sure why you'd specify all column names to accomplish that.

Given a table with the following columns that matter, and a bunch of columns that I don't need to process at all:
pre:
 id | a | b | total
----|---|---|--------
 1  | 0 | 3 | 3
 2  | 1 | 0 | 1
 2  | 0 | 3 | 3
 3  | 2 | 0 | 2
 4  | 0 | 2 | 2
I need to merge common id's and sum the columns a, b, and total, the other columns not shown contain metadata about the person represented by the id number and is the same in rows with matching id's

end result looking like this:
pre:
 id | a | b | total
----|---|---|--------
 1  | 0 | 3 | 3
 2  | 1 | 3 | 4
 3  | 2 | 0 | 2
 4  | 0 | 2 | 2
I currently use
code:
table = table.groupby(['ID']).agg({
    'First Name': 'first',
    'Middle Name': 'first',
    'Last Name': 'first',
    'Suffix': 'first',
    'A': 'sum',
    'B': 'sum',
    'Total': 'sum',
    'ID': 'first'
}).reset_index(drop=True)
But I actually have quite a few more columns than that.

My issue is that if I don't explicitly list every single column, they are not present in the resulting dataframe.

The Fool
Oct 16, 2003


That'll work a treat, thanks.

Didn't occur to me to built the dict like that, I was assuming pandas would have some flag somewhere that would do it automatically.

The Fool
Oct 16, 2003


Last two projects I’ve been able to get away with using pandas as a orm and it’s been great.

Going to be super annoyed the next time I need to do something more complicated.

The Fool
Oct 16, 2003


Flask probably

e: a link - https://dev.to/nagatodev/getting-started-with-flask-1kn1

The Fool
Oct 16, 2003


I did freecodecamp when it was just javascript and it was well designed, they have a bunch of other stuff now including some python courses:


https://www.freecodecamp.org/learn

The Fool
Oct 16, 2003


If what you're working with is loaded into a dict would something like deepdiff work?

Adbot
ADBOT LOVES YOU

The Fool
Oct 16, 2003


dehumanize yourself and write a terraform provider

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply