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
Proteus Jones
Feb 28, 2013



oliveoil posted:

The Python documentation says "Long integers are now stored internally either in base 2**15 or in base 2**30": https://docs.python.org/2.7/whatsnew/2.7.html#optimizations

What does that mean? I have never seen "base 2 to some power" used before. 2**15 = 32,768 and I really doubt this means that Python uses a base-32,768 number representation.

http://stackoverflow.com/questions/9860588/maximum-value-for-long-integer

Adbot
ADBOT LOVES YOU

Proteus Jones
Feb 28, 2013



When I see how far it's come in a relatively short amount of time, I keep wanting to give VisualCode a spin on macOS. But then I remember how addicted I am to the integrated console and debugging stuff in PyCharm.

Proteus Jones
Feb 28, 2013



You are triggering me so hard with that unpaired open paren.

E: Well, he was. I feel much better now.

Proteus Jones fucked around with this message at 00:14 on Apr 18, 2017

Proteus Jones
Feb 28, 2013



huhu posted:

In Pycharm, is there a way to run code and then and then leave some sort of a command line to continue playing around with it?

It's got a full featured debugger if that's what you're asking. Also has an integrated terminal and python console.

Proteus Jones
Feb 28, 2013



Yes

Grab the community edition and give it a spin.

Proteus Jones
Feb 28, 2013



huhu posted:

I've been using PyCharm for awhile now I'm just not sure how to phrase my question in Google so I'm asking here.


I highlight the entire file and do this and it gives errors.

Edit: Found it
http://stackoverflow.com/questions/21516027/running-code-in-pycharms-console

Huh.

I just tested it using the copy and paste method and it works fine. But if that method works for you.

code:
<a bunch of pasted code>

>>>print (validation_file_name)
1- Validation 04.27.2017 04.24 PM.csv

Proteus Jones
Feb 28, 2013



underage at the vape shop posted:

Tkinter can suck my nuts, it's like they designed it to be a pain.

You speak truth.

Proteus Jones
Feb 28, 2013



Thermopyle posted:

Here's a pretty elite variation on Python.


and


Eternally morally vigilant.

These file descriptions are fantastic

Proteus Jones
Feb 28, 2013



Thermopyle posted:

I came across this neat theme for PyCharm, and because I'm always fiddling with stuff, I decided to try it out.

It's called Material Theme and it's pretty great and customizable.



I'm actually most impressed by the fact that it's very thorough and doesn't seem to break anything...which is, IME, not par for the course when it comes to open source themes for stuff.

I also added the Code Glance plugin (just search the Plugins in Settings) which adds the "minimap" of the code in your files like SublimeText does. It also seems to work well without slowdowns or anything.

Look to the right side in this screenshot:



I like the look of that Material Theme. I'll have to give it a go later.

I've been rocking Code Glance for a while, and that minimap is worth it's weight in gold.


From the screen shot I see you're on a Mac. Did you upgrade yet? Any gotchas or caveats you found with Python (specifically Anaconda if you use it) or PyCharm?

Proteus Jones
Feb 28, 2013



QuarkJets posted:

Learned today that PyCharm's debugger can display huge arrays in a separate window as a table of cells. I always thought this was something that pycharm lacked but I was just totally wrong

Yeah, it was an embarrassingly long time before I stumbled across that.

Proteus Jones
Feb 28, 2013



baka kaba posted:

Assuming PyCharm has the same basic debugging capabilities as IntelliJ, you can add breakpoints wherever, then right-click them and uncheck pause execution (or whatever), and add your own print statement in the "execute this" bit - you can include variables and all that. It's like adding print statements without sticking them in the code

But stepping through and watching what happens is your best bet

It has all that. My absolute favorite thing is the just being able to display variable contents at various break points. It’s been invaluable in helping me zero in on logical errors I’ve made.

Proteus Jones
Feb 28, 2013



Quick question for the thread.

MacOS is my primary and I use PyCharm. I mostly do network automation scripts to make my life a little easier for certain tasks.

I’ve recently purchased a gaming laptop and it seems like it would make a decent platform (7700HQ, 32GB, 1TB SSD) since the thing is a beast. However, my only real Windows exposure, beyond using RDP jump servers as an end user, is for gaming. Everything else (work, home, etc...) is pretty much macOS. I usually run my programs from Linux VMs, but I don’t use anything that limits them to a UNIX platform (like pexpect) anymore.

So my question is: which Python does everyone use?

Windows Python distrib
Using Python in my Ubuntu install on WSL

(Anaconda may be an option, but I imagine that may not work since I do use the scripts in a business context. But then again, not to generate revenue. I stopped using it to err on the side of caution about a year ago)

Proteus Jones fucked around with this message at 00:36 on Apr 28, 2018

Proteus Jones
Feb 28, 2013



vikingstrike posted:

Pretty sure Anaconda is Ok for use even in commercial work

Huh. For some reason I always thought it was a free for educational/personal, but required licensing for commercial. I’ll have to look at it again.

Thermopyle posted:

If you run into some weird case, it's easy to switch which python interpreter you're using.

In other words, you're not committing yourself to anything, so just use the easiest to get started option...the windows installer.

Cripes. I must be tired, of course I can do this.

Proteus Jones
Feb 28, 2013



QuarkJets posted:

NumbaPro used to require a license for commercial use, but in the last year or two they completely open sourced it; Numba is now BSD-2 and conda is BSD-3. Each package that you install beyond that you need to check on a per-case basis, as any of them could have a commercial-restricting license

PyCharm requires a license for commercial entities, it's like $100 and comes with extra web development features

I already pay for PyCharm, so that's sorted.

I'll have to check, but I'm 99% certain all the packages I use are open source. That's good to know since I cut my teeth with anaconda. I think from a familiarity perspective (especially since I'm not as familiar with Windows) I may try that first.

Thanks for the info all

Proteus Jones
Feb 28, 2013



Boris Galerkin posted:

Speaking of environments



I can’t stop giggling over “ANOTHER PIP??”

Proteus Jones
Feb 28, 2013



bamhand posted:

I think it's a dataframe? I'm modifying some old code where I'm just changing the source of the data but trying to keep the plots the same. This is what was working before (also I'm pretty new to python in general):

a1 = self.est_data_obj.tsa_data[self.est_data_obj.endog][self.est_data_obj.bgn_obs : self.est_data_obj.end_obs]
a2 = self.reg_results.fittedvalues[self.est_data_obj.bgn_obs : self.est_data_obj.end_obs]
a1.plot(
title='In-sample Fit Chart',
linewidth=1,
linestyle='-',
marker='d',
markersize=5,
fillstyle='none',
color='cornflowerblue',
label='Original Dependent Values')

a2.plot(
kind='line',
linewidth=1,
marker='o',
markersize=5,
fillstyle='none',
linestyle='-',
color='red',
label='Predicted Dependent Values')

plt.xlabel('Date')
plt.ylabel(self.var_dic[self.est_data_obj.endog], size=10)
plt.legend()
plt.show()


This is the new code I added for changing the data, where sd2df creates a dataframe from saspy:

a = self.sas.sd2df("reg_out", "work").loc[:,["date","heloc2","pred"]]
a=a.loc[a["heloc2"].notnull(),]

Use the code tags. It makes it infinitely easier to read your code.

code:

	a1 = self.est_data_obj.tsa_data[self.est_data_obj.endog][self.est_data_obj.bgn_obs : self.est_data_obj.end_obs]
        a2 = self.reg_results.fittedvalues[self.est_data_obj.bgn_obs : self.est_data_obj.end_obs]
        a1.plot(
                        title='In-sample Fit Chart', 
                        linewidth=1,
                        linestyle='-', 
                        marker='d',
                        markersize=5,
                        fillstyle='none',
                        color='cornflowerblue', 
                        label='Original Dependent Values')

        a2.plot(
                        kind='line',
                        linewidth=1,
                        marker='o',
                        markersize=5,
                        fillstyle='none',
                        linestyle='-', 
                        color='red', 
                        label='Predicted Dependent Values')
                        
        plt.xlabel('Date')
        plt.ylabel(self.var_dic[self.est_data_obj.endog], size=10)
        plt.legend() 
        plt.show()

Proteus Jones
Feb 28, 2013



I’m not sure a 0 or 1 will work with the program selection, since it’s implied that it’s more or less a gradient on Most Preferred to Least Preferred. And the goal is to get everyone as close to Most Preferred as you can.

It will work on the pair/don’t pair, though.

E: Hmmm... or maybe settle the program assignations prior to the matrix creation?

Proteus Jones fucked around with this message at 03:11 on Jun 2, 2018

Proteus Jones
Feb 28, 2013



SurgicalOntologist posted:

The 0 or 1 are the variables that the program is solving for; the objective function is the dot product of those variables and a vector of preference strength.

Edit: at least, that's the base of the objective function. Could add other considerations as long as they can be linearized (or quadtratic with the right solver, etc.).

Yep. I completely misread.

:doh:

Proteus Jones
Feb 28, 2013



Boris Galerkin posted:

I'm using the new PyCharm 2017.2 now with (better?) pipenv support so I'm playing around with pipenv as well. Whenever I install a package a dialog screen shows up in the corner telling me that my pipfile is out of date and that I should run either "pipenv lock" or "pipenv update." Both options are clickable links and I've tried clicking both of them now and they both seem to update my Pipfile the same way.

What's the difference between these two commands and which one is the correct one to use after I install a package?

PyCharm 2018.2 is the latest. It just dropped 6 days ago.

It also calls out pipenv support as a new feature.

quote:

Support for pipenv

Pipenv simplifies your application's dependency management. PyCharm 2018.2 will automatically create a pipenv when you open a project with a Pipfile, and makes it easy to create new projects with pipenvs

https://www.jetbrains.com/pycharm/whatsnew/

Proteus Jones
Feb 28, 2013



I was impressed with Tree House classes when I went to brush up a couple years ago.

However, it's anywhere from $25 to $200/mo depending on which plan you want. So it might not be economically feasible if you can't get work to pay for it.

https://teamtreehouse.com/account/enrollment

Proteus Jones
Feb 28, 2013



Mister Fister posted:

Thanks for the suggestion! Looks like it focuses on python for web development rather than data science/analytics though.

My bad. I didn't look at the current courses. For some reason I thought they had some data courses.

Maybe that was Coursera, I remember looking at that around the same time.

Proteus Jones
Feb 28, 2013



QuarkJets posted:

I've heard that Automate the Boring Stuff is a good book for beginners and may be right up your alley

Is that book still stuck on 2.7 or has it moved to the modern era?

Proteus Jones
Feb 28, 2013



QuarkJets posted:

No idea! IMO it doesn't matter to a newbie anyway, because the fundamentals are the same

True enough

Proteus Jones
Feb 28, 2013



Boris Galerkin posted:

Also it looks like it's only affecting macOS

Thank you for your sacrifice. I was going to install this later today. I guess I'll stick with 2018 until they roll out a fix.

Proteus Jones
Feb 28, 2013



Boris Galerkin posted:

I was gonna look into setting up a server to do this for what I had in mind remotely, but if google gives me 1000 free things a month then witchcraft it is.

Same.

I have a ton of personal documents I was going to scan in and use a commercial OCR on the PDFs to index them, but with 1000 free a month I may try to whip up a script to process the scan folder and compare.

Proteus Jones
Feb 28, 2013



shrike82 posted:

If you login to your accounts page, you should be shown a bundle page with a bunch of links to download the ebooks in various formats. Enjoy!

Yeah, I can still access books I bought years ago through my account. Check that first.

Proteus Jones
Feb 28, 2013



Bundy posted:

I'm self taught and embrace a variety of sources. I may or may not be representative.

:same:

Reference books were the last thing I kept using dead-tree versions for, but now that I have a 34” ultra wide monitor, I’ve fully converted to having various eBooks and webpages on the standby in the right side of the screen. Still *tons* of real-estate for PyCharm.

Proteus Jones
Feb 28, 2013



PierreTheMime posted:

Hopefully quick Python installation question: I've installed 3.7.3 onto a Windows server, confirmed the path is set, and restarted it. I can now execute commands from command line, PowerShell, etc. locally just fine, but the same commands produce a "Can't find a default Python" error if I attempt to execute them as a remote batch job.

The remote user has administrative rights, any ideas of what I might be missing?

The only thing I can think of off the top of my head the $PATH for python is not being passed to the remote user an environment setting.

What happens when you execute with the full pathname to python in the script?

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.

Proteus Jones
Feb 28, 2013



QuarkJets posted:

Yeah I think 2.6 is CentOS 6 era. Yikes, but I can't honestly say that my orgs don't have any older servers kicking around for stupid/bad reasons

If you're allowed to install software, then you could at least set up a virtual environment with a newer version of python. I'd use Anaconda for this but everyone has their own preferences

One note re: Anaconda. If it’s in a corporate environment I’m pretty sure you need to pay for a license, so if budget is an issue it may not be an option.

Proteus Jones
Feb 28, 2013



pmchem posted:

I don't think that's the case? They sell Anaconda Enterprise but it's for the plus-up in features related to deployment/management of installations.

You’re right, I was mistaking it with a different free-for-individual-paid-for-commercial product. Sorry for the confusion.

Proteus Jones
Feb 28, 2013



unpacked robinhood posted:

Given a document's hash, could you store it into it's own metadata, I think it's impossible but there may be clever workarounds ?
No. Once you add the hash, the file's hash changes. It's a dog chasing its own tail.

Proteus Jones
Feb 28, 2013



Bruegels Fuckbooks posted:

I like TUI. Granted it's a retronym (e.g. people didn't call text based user interfaces TUI back in the day.) https://en.wikipedia.org/wiki/Text-based_user_interface

I remember them being called CURSES interfaces in the mid/late 90s early '00s, since a large amount of them were built (at least in BSD/Linux) using the curses terminal control library.

Proteus Jones
Feb 28, 2013



This poo poo is why I ended giving up and just importing pexpect for interactive PTY sessions (note spawnu() doesn't work in Windows version of pexpect since no PTY support) (it may work if launched from bash w/WSL)

Proteus Jones
Feb 28, 2013



in regards to
code:
pexpect.exceptions.TIMEOUT: Timeout exceeded.
I remember this punching me in the dick a bit a couple years ago.

I'll see if I can dig up my old hacky scripts and see how I dealt with it. I'm pretty sure I had to make some kind of accommodation due to some lovely links to some of the devices I was touching with the script.

Proteus Jones
Feb 28, 2013



Bad Munki posted:

Yeah, wrapping the % in a space on either side makes that example work as expected. Why.

I'm not sure if you need the leftmost space, but the right-most is needed since the cursor appears one space past the symbol in most shells and CLIs. I remember it being an issue with the password prompt for the old Cisco Catalysts I was touching. I usually had to define that expect statement as

code:
child.expect('[P|p]assword:'). 
# the "[P|p]" is because Cisco uses different cases depending on IOS version/hardware
I can't believe this flew under my radar for so long, but I just came across Paramiko and it looks so much simpler than pexpect.pxssh. I'm going to play around with it a bit.

Proteus Jones fucked around with this message at 05:43 on Jun 16, 2020

Proteus Jones
Feb 28, 2013



CarForumPoster posted:

Is this like a production, customer facing app or just something you want for you?

A little more googling indicates that GIMP can: read DNGs, read file metadata, have python plugins made for it and call those plugins from the command line. Maybe try and see if GIMP's GUI can open and view the metadata and if so try that?

Maybe ImageMagick? It supports digital negatives and I would imagine there's at least one library out there that integrates it. At the worst invoke the command directly in Python.

GIMP seems like a big install to just rip EXIF out of files.

Another thought is that from my (very cursory) reading, DNF is really just a TIFF variation. So maybe there's python stuff to manipulate/import TIFF metadata. Since you're not actually interacting with the pixels themselves and just want EXIF it shouldn't matter that it's TIFF-but-really-a-negative.

Proteus Jones fucked around with this message at 03:05 on Jun 17, 2020

Proteus Jones
Feb 28, 2013



QuarkJets posted:

Yeah the entirety of the software development world is pretty lovely

Also lazy as gently caress.

Adbot
ADBOT LOVES YOU

Proteus Jones
Feb 28, 2013



I pay for it myself. I'm not usually a fan of sub models that are more than $20/yr or so, but PyCharm is one of the exceptions for me. Worth every single penny.

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