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
Methanar
Sep 26, 2013

by the sex ghost

Empress Brosephine posted:

So I finished Python Crash Course and loved it; what should I read next to improve my skills?

Get a job using it.

Adbot
ADBOT LOVES YOU

CarForumPoster
Jun 26, 2013

⚡POWER⚡

Empress Brosephine posted:

So I finished Python Crash Course and loved it; what should I read next to improve my skills? Is it worth learning more than the blade level of skills with Flask?

Thanks all.

Find a project you want to do to solve some problem and do it.

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
I like Click but I don't like stacking up ten different decorators. Are there any good examples of Click based interfaces but created programatically without decorators?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Boris Galerkin posted:

I like Click but I don't like stacking up ten different decorators. Are there any good examples of Click based interfaces but created programatically without decorators?

You can write a decorator that applies decorators.

Hollow Talk
Feb 2, 2014

Thermopyle posted:

You can write a decorator that applies decorators.

New thread title?

the yeti
Mar 29, 2008

memento disco



(Mis?)Using Jenkins to automate non-build manual processes e.g, refreshing tables, monitoring tasks with python.

Should I shrug, clone down the repo, let pipenv or poetry or whatever install packages from scratch, just to run a script every half an hour?

cinci zoo sniper
Mar 15, 2013




the yeti posted:

(Mis?)Using Jenkins to automate non-build manual processes e.g, refreshing tables, monitoring tasks with python.

Should I shrug, clone down the repo, let pipenv or poetry or whatever install packages from scratch, just to run a script every half an hour?

Come again? And yeah that's an okay-ish use for Jenkins, we deliberated to do the same at my company too.

the yeti
Mar 29, 2008

memento disco



cinci zoo sniper posted:

Come again? And yeah that's an okay-ish use for Jenkins, we deliberated to do the same at my company too.

Sorry, I mean to say it seems like extra complexity or convolution to have Jenkins rebuild a python virtual environment from scratch every time it goes to execute a script.

EVIL Gibson
Mar 23, 2001

Internet of Things is just someone else's computer that people can't help attaching cameras and door locks to!
:vapes:
Switchblade Switcharoo

the yeti posted:

Sorry, I mean to say it seems like extra complexity or convolution to have Jenkins rebuild a python virtual environment from scratch every time it goes to execute a script.

Like when it's making a build which will be deployed or make a virtual env literally each time you run butts_check.py?

I use the concept of the virtual environment to limit all the bullshit cruft years of python use does to an OS. If you rebuild the virtual env and do the jenkin pulls for the bare minimum libraries it needs to run the package, then you are getting rid of debug/testing/just bullshit libraries that really should not be in production

the yeti
Mar 29, 2008

memento disco



EVIL Gibson posted:

Like when it's making a build which will be deployed or make a virtual env literally each time you run butts_check.py?

I use the concept of the virtual environment to limit all the bullshit cruft years of python use does to an OS. If you rebuild the virtual env and do the jenkin pulls for the bare minimum libraries it needs to run the package, then you are getting rid of debug/testing/just bullshit libraries that really should not be in production

I was thinking of your latter example— I might be misunderstanding how Jenkins works as it was literally just dropped in my lap to figure out, but I understood that each time it ran a task it was in a clean, isolated work area, hence the need to rebuild the virtual environment each time.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Rebuilding it is fine.

Virtualenvs are at their best when they're ephermal.

Dominoes
Sep 20, 2007

Thermopyle posted:

Rebuilding it is fine.

Virtualenvs are at their best when they're ephermal.
I think the intent behind Poetry, Pipenv, and related features in PyCharm is to abstract them. I don't like directly micromanaging them; feels like a hassle. The only information required to set up a project's dependencies should be a config file that mainly lists dependencies, like pipfile, pyproject.TOML etc. Shouldn't have to manually create/destroy/activate/deactivate environments.

Those who've used Poetry: What do you think compared to Pipenv? Any warts like Pipenv's slow locking and dependency-resolution probs?

Dominoes fucked around with this message at 21:28 on Jun 5, 2019

the yeti
Mar 29, 2008

memento disco



Dominoes posted:

Those who've used Poetry: What do you think compared to Pipenv? Any warts like Pipenv's slow locking and dependency-resolution probs?

The thing I really dislike about poetry right off the bat is that if you search for a package like sqlalchemy during the init process, you max out the search result list with every random fork out there and seemingly have no way to pick the right one. It also crashes if you try to guess the actual package name 3 times.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dominoes posted:

I think the intent behind Poetry, Pipenv, and related features in PyCharm is to abstract them. I don't like directly micromanaging them; feels like a hassle. The only information required to set up a project's dependencies should be a config file that mainly lists dependencies, like pipfile, pyproject.TOML etc. Shouldn't have to manually create/destroy/activate/deactivate environments.

Those who've used Poetry: What do you think compared to Pipenv? Any warts like Pipenv's slow locking and dependency-resolution probs?

Yeah. All this manually creating, activating, deactivating environments and installing packages is all kind of bullshit that I don't want to have to care about.

What I'd like is if I could have a config file in a project directory and then anything run from that directory uses the packages and interpreter version specified in the config file. I don't care how it does it behind the scenes, just take care of it for me.

If I type the command to "install" a package the main point of that command should be to add that package to the config file. Whether it installs it at that time or not is not very important to me. If I specify an interpreter that is not on my system, then it should set that up.

The python command should really be just a script that checks the config file in the current working directory and sets the environment up as required.

No one has done this completely yet and it makes me sad.

Nippashish
Nov 2, 2005

Let me see you dance!

Thermopyle posted:

The python command should really be just a script that checks the config file in the current working directory and sets the environment up as required.

I have a run.sh script that I copy around from project to project that does almost exactly this. Sometimes I add in a few project specific environment variables, but other than that been pretty much unchanged since I originally wrote it like 7 years ago.

Not the most elegant solution but it works for me.

Dominoes
Sep 20, 2007

Thermopyle posted:

No one has done this completely yet and it makes me sad.
What do you suppose the technical limitations on this are?

Nippashish posted:

I have a run.sh script that I copy around from project to project that does almost exactly this.
Post it here.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dominoes posted:

What do you suppose the technical limitations on this are?

Post it here.

I haven't looked into it in detail, but just from various things I've read over the years I think it's like a lot of open sores software...

It's not exactly technical limitations that are the blockers here. It's more that no one has taken a lead on idea, investigated all the edge cases, done a bunch of experimentation, done advocacy to get stakeholders on board, etc.

Doing all of that is not always enough to get stuff done, sometimes technical limitations rear their head whilst in the process of all of that (see Larry Hastings and his work on the GIL), but all that stuff is really the first blocker on most of the things we think python (and not just python) should do or have but does not.

I don't want to dismiss the technical side, but my understanding is not that there are insurmountable obstacles that require The Master Programmer to solve, just that there are a bajillion edge cases to address. I mean, look at the tools that are kinda similar to what I propose. pipenv and poetry both have been worked on for years and still are kinda clunky in a lot of ways.

Now that I write it down it kinda makes me want to take the lead. On the other hand, I always get irritated when I have to start delving into the guts of python packaging for whatever reason...


Nippashish posted:

I have a run.sh script that I copy around from project to project that does almost exactly this. Sometimes I add in a few project specific environment variables, but other than that been pretty much unchanged since I originally wrote it like 7 years ago.

Not the most elegant solution but it works for me.

It's funny you say that and really that this whole subject has come up now. I've recently been really customizing my powershell prompt (based on oh-my-posh), environment, aliases, etc and it's gotten me thinking about tackling this whole issue.

Dominoes
Sep 20, 2007

Thermopyle posted:

Pipenv and poetry both have been worked on for years and still are kinda clunky in a lot of ways.
I think diving in here is at the core of the issue. Why aren't they resounding successes?

quote:

Now that I write it down it kinda makes me want to take the lead.
Do it bro.

Dominoes fucked around with this message at 11:19 on Jun 6, 2019

susan b buffering
Nov 14, 2016

The PEP for a local packages directory at least seems like a promising step forward.

Dominoes
Sep 20, 2007

skull mask mcgee posted:

The PEP for a local packages directory at least seems like a promising step forward.
Agree.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
I have a form on a site that I would like to be able to swipe a credit card and then use the data to auto fill the forms (first name last name expir etc). Is this possible? I wrote the code that can decipher the data of the card swipe and assign it to variables I just can’t figure out a way to auto fill a form without submitting it. Thanks goons

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Oh man, it sounds like you're opening yourself to a large host of legal and financial troubles.

Just integrate Stripe or BrainTree into your frontend. Handling credit card data yourself opens you to PCI audits and all sorts of headaches.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
It’s actually for employee ids, I think credit card just made it make more sense? Does that sound right? Lol.

E; to clarify the cards store full name and worker ID, it would just be a way for them to “log In “ easier

Empress Brosephine fucked around with this message at 01:55 on Jun 7, 2019

Proteus Jones
Feb 28, 2013



Empress Brosephine posted:

It’s actually for employee ids, I think credit card just made it make more sense? Does that sound right? Lol.

E; to clarify the cards store full name and worker ID, it would just be a way for them to “log In “ easier

Basically you need a mag-stripe reader? Or are they RFID?

Either way, have you checked with the reader manufacturer? They may have an API you can use to read data events from the reader.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Empress Brosephine posted:

It’s actually for employee ids, I think credit card just made it make more sense? Does that sound right? Lol.

E; to clarify the cards store full name and worker ID, it would just be a way for them to “log In “ easier

Oh.

Well, this will be a javascript thing, not a python thing, since it will have to be done in the browser. You'll have to check with the reader manufacturer for API documentation.

porksmash
Sep 30, 2008
Most mag stripe/swipe readers/barcode scanners pretend to be keyboards and spit out characters really fast on a successful read - is that the case here? Open up notepad and swipe an ID. If so your job is handling input, which is probably a heck of a lot easier than integrating with device drivers/API

Regardless it would still be javascript as Thermopyle said, since this is all happening client-side.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
I’ll check out javascript then. Yeah it’s just taking the keyboard read from the usb card swiped.

Ahz
Jun 17, 2001
PUT MY CART BACK? I'M BETTER THAN THAT AND YOU! WHERE IS MY BUTLER?!
The reader can probably also be programmed to throw in arbitrary keyboard signals or characters after a successful swipe, things you can then listen directly for in javascript to process events.

QuarkJets
Sep 8, 2008

Ahz posted:

The reader can probably also be programmed to throw in arbitrary keyboard signals or characters after a successful swipe, things you can then listen directly for in javascript to process events.

Is this something you can set? So you could have it emit a pair of UTF-8 poop emojis at the end of a swipe and then check for that?

Ahz
Jun 17, 2001
PUT MY CART BACK? I'M BETTER THAN THAT AND YOU! WHERE IS MY BUTLER?!

QuarkJets posted:

Is this something you can set? So you could have it emit a pair of UTF-8 poop emojis at the end of a swipe and then check for that?

Depends on the vendor. Most scanners I see which emulate a keyboard have docs on how to do so.

the yeti
Mar 29, 2008

memento disco



Type hinting!

I have:

def myfunc() -> Dict[str, Tuple[pendulum.Date, pendulum.Datetime, pendulum.Datetime]]:
#blah

The tooltip when I mouse over it in pycharm gives:

def myfunc() -> Dict[str, Tuple[Date, Any, Any]]

How do I tell if I’m not doing that correctly, or if it’s a quirk in pycharm, or in pendulum?

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
You’re doing it correctly, assuming your dict maps a string to a tuple of 3 things. The type hunter in pycharm just doesn’t know what those pendulum types are, probably because the pendulum author(s) haven’t included a file with that information.

the yeti
Mar 29, 2008

memento disco



Thanks, yeah I’m not too familiar with grownup packaging, so there’s a file the package should feed the type hinter for those things ?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

the yeti posted:

Thanks, yeah I’m not too familiar with grownup packaging, so there’s a file the package should feed the type hinter for those things ?

It's just that pendulum hasn't specified types for the stuff. You can fix it yourself by creating type stubs if you want.

Dominoes
Sep 20, 2007

Using third-party packages in optionally-typed languages raises inconveniences like this.

General_Failure
Apr 17, 2005
I may have been hit by a pip typesquatting attack.

I only just noticed it. There was a file in my home called "typesquating-attack" with that spelling. The contents said something like "You have been hacked since" followed by the date and time. April 4th. I just shut it down after seeing that. I have a suspicion it may have been from a package I accidentally installed and removed shortly after called "tensoflow". Any tips on this?

e: looks like the package was removed from pypi

e: again. It's supposed to be typosquatting. A typo in typosquatting for a post about a typosquatting attack with a typo in typosquatting.

General_Failure fucked around with this message at 01:21 on Jun 21, 2019

CarForumPoster
Jun 26, 2013

⚡POWER⚡

General_Failure posted:

I may have been hit by a pip typesquatting attack.

I only just noticed it. There was a file in my home called "typesquating-attack" with that spelling. The contents said something like "You have been hacked since" followed by the date and time. April 4th. I just shut it down after seeing that. I have a suspicion it may have been from a package I accidentally installed and removed shortly after called "tensoflow". Any tips on this?

e: looks like the package was removed from pypi

Thanks for posting about this, I didnt know this was a thing.

General_Failure
Apr 17, 2005

CarForumPoster posted:

Thanks for posting about this, I didnt know this was a thing.

Neither did I until today. I'm going to be a bit more observant with my typing in the future.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

CarForumPoster posted:

Thanks for posting about this, I didnt know this was a thing.

I swear I've posted warnings about this multiple times in this thread! THANKS FOR NOT READING MY WORDS!

(or maybe I'm dreaming and only thought about posting this)

Adbot
ADBOT LOVES YOU

mbt
Aug 13, 2012

Looking into the easiest way to make a headerless window appear as an overlay on key press. I'm thinking just make two separate threads and have the window check a global for keypress every so often. I've done this with pyfirmata updating a graph on pulse trigger but that was more of a time factor thing

Tkinter I think can do it, I've considered qt5 but that introduces a lot of complexity for a tiny 100x300 window.

I started going down the ctypes route to just draw an overlay directly but that's probably a bit too much.

Anyone ever made something like this?

Edit: I take that back. I used matplotlib and in my loop paused every 0.001 to poll keypress info and redraw accordingly. That worked well and is reasonably intuitive

Edit2: yeah tkinter is fine I just gave it a thread and used the always amazing lib called keyboard

mbt fucked around with this message at 20:30 on Jun 17, 2019

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