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
Mark Larson
Dec 27, 2003

Interesting...

bob dobbs is dead posted:

slightly comedy option: make a csv, do a COPY, if your rdbms is chill with that

TBH I did think about that. COPY would probably be the fastest way. But it'd only be really useful once, for the bulk load. From then on I'd need to check constraints, do a insert/update etc.

Adbot
ADBOT LOVES YOU

cinci zoo sniper
Mar 15, 2013




Mark Larson posted:

TBH I did think about that. COPY would probably be the fastest way. But it'd only be really useful once, for the bulk load. From then on I'd need to check constraints, do a insert/update etc.

You can have really good performance with SQLAlchemy.

code:
SQLAlchemy ORM: Total time for 100000 records 6.89754080772 secs
SQLAlchemy ORM pk given: Total time for 100000 records 4.09481811523 secs
SQLAlchemy ORM bulk_save_objects(): Total time for 100000 records 1.65821218491 secs
SQLAlchemy ORM bulk_insert_mappings(): Total time for 100000 records 0.466513156891 secs
SQLAlchemy Core: Total time for 100000 records 0.21024107933 secs
sqlite3: Total time for 100000 records 0.137335062027 sec
This is on inserts.

cinci zoo sniper
Mar 15, 2013




E2: SQLAlchemy should be able to be able to handle inserts with missing keys by default.

cinci zoo sniper fucked around with this message at 19:42 on Aug 22, 2018

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost
bulk inserts is good as hell on sqlalchemy but still doesnt beat copy, but thats ok cuz it does a lot more than copy

rtfm on bulk insert manual in sqlalchemy, it's got all the drat options. and then introspect into the code cuz the manual for sqlalchemy is actually just ok

cinci zoo sniper
Mar 15, 2013




I mean okay it's not beating metal like COPY sure but if this is the expected performance baseline then Python might not be the right tool for the job.

Hollow Talk
Feb 2, 2014
SQLAlchemy can handle missing keys automatically as long as it's always the same key that is missing within the same transaction, I think. This isn't particularly pretty but it deals with arbitrary missing keys and replaces them with 0 because of the defaultdict w/ int used.

code:
from collections import defaultdict

from sqlalchemy import create_engine, Table, MetaData, Column, Integer

engine = create_engine('sqlite:////dev/shm/foo.sqlite3')

meta = MetaData()
table = Table('data_with_default', meta,
              Column('a', Integer),
              Column('b', Integer),
              Column('c', Integer),
              Column('d', Integer),
              Column('e', Integer),
              Column('f', Integer))

meta.drop_all(engine)
meta.create_all(engine)

fields = [x.key for x in table.columns]  # get all column names
data1 = [{'a': 1, 'b': 2, 'c': 3, 'e': 5}] * 1000000  # missing 'd'
data2 = [{'a': 1, 'b': 2, 'c': 3, 'd': 4}] * 1000000  # missing 'e'
data3 = [{'a': 1, 'b': 2, 'c': 3, 'd': 4}] * 1000000  # missing 'f'
data = iter(defaultdict(int, x) for x in data1 + data2 + data3)
_data = [dict(zip(fields, [d[x] for x in fields])) for d in data]

insert_statement = table.insert().values()

with engine.begin() as conn:
    conn.execute(insert_statement, _data)
If you are fine with NULL-Values in your database, you can omit the defaultdict and just use this directly instead of the defaultdict detour:

code:
_data = [dict(zip(fields, [d.get(x) for x in fields])) for d in data1 + data2 + data3]
Use nested dict comprehensions or for loops or whatever to create the actual list of dicts that holds the rows you get and extract from the JSON. Or am I missing something here? :confused:

Hollow Talk fucked around with this message at 22:42 on Aug 22, 2018

Mark Larson
Dec 27, 2003

Interesting...
E: nvm, variable assignment in bash isn't as simple as I thought.

Mark Larson fucked around with this message at 02:24 on Aug 23, 2018

Sad Panda
Sep 22, 2004

I'm a Sad Panda.
Which is more Pythonic, collecting and assigning your variables at the top of a function or interleaved and just before you use them? I assume it's in one of the PEPs but my Googling is letting me down

Python code:
def my_function():
    my_name = 'panda'
    fav_animal = 'lion'
    colour = 'blue'
    a_number = 4

    stuff_using_variables()
v

Python code:
def my_function():
    my_name = 'panda'
    stuff_using_my_name()
    fav_animal = 'lion'
    stuff_using_fav_animal()
    colour = 'blue'
    stuff_using_colour()
    a_number = 4
    stuff_using_a_number()

Eela6
May 25, 2007
Shredded Hen
I think you should declare something as close to where it is used as possible.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

I feel like it depends how you're structuring things really. If you have a sequence of steps, where it's do this then this then this, I think it makes sense to do all the setup/config first, so it's not mixed in with the logic and interrupting the flow. You get a nice, readable sequence of actions, especially if you name things well

But if you have a bunch of distinct actions, or stuff you want to conceptually separate as pieces of logic to make it easier to follow, it probably makes more sense to keep them self-contained. So you'd assign in the section that's gonna use it, instead of having a bunch of unrelated variables all stuck together at the top of the function

It's a judgement call really, and in short functions it probably doesn't matter anyway. I guess my general rule is, do I want to keep all this logic together, or break it up with blank lines? If it's the former then maybe it would be better with the setup pulled out, if it's the latter then maybe I should treat each section like its own, short little function

Dunno what's pythonic though :dogcited:

cinci zoo sniper
Mar 15, 2013




Pythonic code is nice for earning karma on SO, but not much else, in my opinion.

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost
that sort of stylistic poo poo is for reducing debug surface

does it eliminate your responsibility to test the fuckin code? no. does it even reduce the empirical debug surface? usually no. bigger factor is fuckin up a couple dozen times so you run out of ways to gently caress it up and getting the automated tests going and not fuckin up on the automated tests and not fuckin up on the deploy, if theres a deploy

Dominoes
Sep 20, 2007

Sad Panda posted:

Which is more Pythonic, collecting and assigning your variables at the top of a function or interleaved and just before you use them? I assume it's in one of the PEPs but my Googling is letting me down

...

I recommend not concerning yourself with general rules like this. Write code that works and is easy to read; getting distracted by minutiae and absolute standards is a common time-wasting trap.

Dominoes fucked around with this message at 08:01 on Aug 23, 2018

cinci zoo sniper
Mar 15, 2013




bob dobbs is dead posted:

that sort of stylistic poo poo is for reducing debug surface

does it eliminate your responsibility to test the fuckin code? no. does it even reduce the empirical debug surface? usually no. bigger factor is fuckin up a couple dozen times so you run out of ways to gently caress it up and getting the automated tests going and not fuckin up on the automated tests and not fuckin up on the deploy, if theres a deploy

Compact code that is easier to reason about != Pythonic code. Latter includes former, but also a load of in my opinion professionally unnecessary philosophy that may or may not align with maintainability and target goals of the codebase.

In other words, I think that it is okay to stumble into Pythonic code, but I do reject the notion that you must actively pursue it, as in that it is a deciding factor in what your code ends up being.

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost

Dominoes posted:

I recommend not concerning yourself with general rules like this. Write code that works and is easy to read; getting distracted by minutiae and absolute standards is a common time-wasting trap.

best time spent is in exploring for moar bugs

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I never use pylint in real time because it's super distracting, and I'm too lazy/in a hurry to figure out what I want silenced.

cinci zoo sniper
Mar 15, 2013




dougdrums posted:

I never use pylint in real time because it's super distracting, and I'm too lazy/in a hurry to figure out what I want silenced.

I sincerely hope you are the only person who sees your code.

a forbidden love
Apr 28, 2005

"It was never meant to beep boop be"

Your insight to having things installed in certain IDE's working folders (or pathfile in any case) triggered me to check each IDE's settings. I finally found the problem in Anacondas settings. In case anyone ever has the same issue and you think it might be the same thing, what I ended up doing to have the library update is:

Go into Anaconda's "Environments" tab and then searching for the library under the "Not installed" filter.
Check the radio button of the library and then select "apply".

That's it. Now I can access and import the package from any IDE. It's weird that it would prevent that one specific package and not the rest. The rest installed the same way with no issue. Whatever, I'm just glad I can use the package now.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

cinci zoo sniper posted:

I sincerely hope you are the only person who sees your code.

... in real time ...

I can be the only person that sees my code, especially with python. Sometimes I just want my computer to do a thing right now, and python is 100% the thing for that. I've slowly started to use python in lieu of grep awk xargs shell script nonsense, it's always an improvement. I find it's tough to get fancy with python's syntax, outside of like comprehensions with multiple binds. Also I don't know perl.

E: Seems like my real problem was that I have 'save on focus change' and 'lint on save' both set in my settings.

dougdrums fucked around with this message at 14:02 on Aug 23, 2018

Dominoes
Sep 20, 2007

dougdrums posted:

I never use pylint in real time because it's super distracting, and I'm too lazy/in a hurry to figure out what I want silenced.
If you've like perspective and know JS, check out the default ESlint/TSLint configs that are bundled with CreateReactApp. Significant impediment to writing code; I'd argue it's more difficult to get JS code that uses them to compile than Rust code, which has a notoriously picky compiler. I believe its intent is to address code standardization among large teams, and JS's history of multiple styles, some better than others.

Thermopyle
Jul 1, 2003

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

The point of writing pythonic code is the same as the point of PEP8 or the point of the rules in CRA.

It's not that any particular rule of PEP8 or particular style of being pythonic is the best way of doing anything.

The point is consistency across the industry. If you do things that are not the way most people are used to them then others are going to have a harder time getting up to speed on your code, help you get will be more difficult to come by, tools will help you less, etc...

If you're so sure that you won't need any of that then do whatever the f you want. Be careful though, my guess is that the majority of people who think they don't need other people to look at their code or any of the other reasons for consistency are wrong.

If you're so hung up on your personal style that you can't just make PEP8 or being pythonic your personal style then you might just have other problems.

It's very easy to come up with instances of what is considered pythonic being a less optimal way of doing something, but being optimal in all cases is not the point.

Thermopyle fucked around with this message at 17:56 on Aug 24, 2018

cinci zoo sniper
Mar 15, 2013




My main issue with Pythonic code is two fold - it’s vaguely defined and people are zealous about it. PEP8 or whatever is fine, you chuck it into your toolchain and tick off the boxes on review.

Thermopyle
Jul 1, 2003

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

People are zealous about everything. If you let that put you off from a concept you're going to be missing out on a lot of useful stuff!

Thermopyle
Jul 1, 2003

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

"Pythonic" is like porn.

If it's not pythonic i'll know it when I see it.

cinci zoo sniper
Mar 15, 2013




Thermopyle posted:

People are zealous about everything. If you let that put you off from a concept you're going to be missing out on a lot of useful stuff!

I mean from them “perfect is the enemy of good” angle.

Thermopyle posted:

"Pythonic" is like porn.

If it's not pythonic i'll know it when I see it.

:nallears:

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
Python is changing dramatically, it always been kinda vague but now in 2018 it's clear that "pythonic" has no meaning whatsoever.

(yes, I'm looking at assignment expressions here)

Hadlock
Nov 9, 2004

I am writing some glue code microservice for a pushbutton deploy thing for our sales people to launch a temporary copy of our product with the customer's company name as the subdomain and attached to a sales-ready db.

It is Bootstrap + Flask on Python 3.6-ish, the python portion of the code is maybe 200 lines right now. I can't see this growing much beyond 500 ever.

I need to persist the state of this thing somewhere to disk, and retrieve from it; primarily the dns entries, k8s namespaces, clusters ids and aliases, creation time, salesperson/creator, and expiry date. I'm sure I will stuff a couple of other things in there as time goes on.

If I were doing this in Go I would use BoltDB (now bbolt). I know Flask meshes very nicely with sqlalchemy and sqlite as a sort of microservice holy-trinity, that seems like gross overkill for storing maybe 5 dicts and a couple of lists worth of data? Am I wrong?

I am thinking of going with pickleDB, it has no external dependencies and looks dead-simple.

Thoughts/honest brutal feedback?

edmund745
Jun 5, 2010
I am trying to figure out how to tell if a given window exists, and can't find any way in Python that works.

I have a file named file_1.py, that opens window_1. Only one instance of window_1 is ever open at a time, and it is the main/root window, that cannot be closed without closing down everything else.
I have another file named file_2.py, that opens window_2.
window_1 has a button on it, that when clicked, opens window_2.
That much works.

The problem I have is that I want some way to make sure that ONLY one instance of window_2 is ever open at once.
This was easy to do in VB.net, but I can't find any way that works in Python.

I have found a few pages that claim to do this, but nothing they have works.
Like this page:
https://stackoverflow.com/questions/17371700/python-tkinter-check-to-see-if-a-window-is-open
This method doesn't work, the [open-window2] button still opens multiple instances of window2.

Other pages show this method, but it doesn't work either?
https://stackoverflow.com/questions/111155/how-do-i-handle-the-window-close-event-in-tkinter
If window_2 is created in one function in file_2.py, and the callback function is another function in file_2.py, then,,,,, the IDE won't accept any references in the callback function to window_2, since it is local to another function.
And if you declare window_2 as a global in file_2, then it is displayed at the same time that the main window_1 starts up, even though the button to display window_2 was never clicked on...

I have also seen pages that claim that you don't destroy windows in python, you just minimize them, iconify them or move them off screen. Is that really the way this matter is usually handled? And even if so, how does that handle the issue of multiple instances of the same window being created?

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost

Hadlock posted:

I am writing some glue code microservice for a pushbutton deploy thing for our sales people to launch a temporary copy of our product with the customer's company name as the subdomain and attached to a sales-ready db.

It is Bootstrap + Flask on Python 3.6-ish, the python portion of the code is maybe 200 lines right now. I can't see this growing much beyond 500 ever.

I need to persist the state of this thing somewhere to disk, and retrieve from it; primarily the dns entries, k8s namespaces, clusters ids and aliases, creation time, salesperson/creator, and expiry date. I'm sure I will stuff a couple of other things in there as time goes on.

If I were doing this in Go I would use BoltDB (now bbolt). I know Flask meshes very nicely with sqlalchemy and sqlite as a sort of microservice holy-trinity, that seems like gross overkill for storing maybe 5 dicts and a couple of lists worth of data? Am I wrong?

I am thinking of going with pickleDB, it has no external dependencies and looks dead-simple.

Thoughts/honest brutal feedback?

shelf
normal pickle
normal files
"sqlite competes w/ fopen, not oracle" is true and you're saying it's losing the competition to fopen

QuarkJets
Sep 8, 2008

edmund745 posted:

I am trying to figure out how to tell if a given window exists, and can't find any way in Python that works.

I have a file named file_1.py, that opens window_1. Only one instance of window_1 is ever open at a time, and it is the main/root window, that cannot be closed without closing down everything else.
I have another file named file_2.py, that opens window_2.
window_1 has a button on it, that when clicked, opens window_2.
That much works.

The problem I have is that I want some way to make sure that ONLY one instance of window_2 is ever open at once.
This was easy to do in VB.net, but I can't find any way that works in Python.

I have found a few pages that claim to do this, but nothing they have works.
Like this page:
https://stackoverflow.com/questions/17371700/python-tkinter-check-to-see-if-a-window-is-open
This method doesn't work, the [open-window2] button still opens multiple instances of window2.

Other pages show this method, but it doesn't work either?
https://stackoverflow.com/questions/111155/how-do-i-handle-the-window-close-event-in-tkinter
If window_2 is created in one function in file_2.py, and the callback function is another function in file_2.py, then,,,,, the IDE won't accept any references in the callback function to window_2, since it is local to another function.
And if you declare window_2 as a global in file_2, then it is displayed at the same time that the main window_1 starts up, even though the button to display window_2 was never clicked on...

I have also seen pages that claim that you don't destroy windows in python, you just minimize them, iconify them or move them off screen. Is that really the way this matter is usually handled? And even if so, how does that handle the issue of multiple instances of the same window being created?

Create an instance of window 2 and have its GUI be hidden. Then the button just hides/unhides this always-existing window 2.

edmund745
Jun 5, 2010

QuarkJets posted:

Create an instance of window 2 and have its GUI be hidden. Then the button just hides/unhides this always-existing window 2.

God gently caress it all. I did it again.... shortly after I posted, I finally realized from a couple different websites how to do this...
I was assuming that you would create a new instance of any child window you wanted, and then destroy() it when you didn't want to see it. Because that's how VC++, VB, Java, etc. does it....

A common problem I am seeing is that a lot of pages are saying how to use some distant, ancient dialect of python. The general ideas might be correct, but the syntax they give is wrong. At least for me?
Like this page:
https://www.tutorialspoint.com/python/tk_toplevel.htm
It says to call .withdraw(), but that doesn't work for me. I had to use wm_withdraw().
And .deiconify() doesn't work either, but wm_deiconify() does.

--------

I think my main problem is that I keep trying to look for things that Python simply doesn't have...
I looked for a couple hours for a way to check if a given child window was open, and there doesn't seem to be any easy way to do that?
The last thing I was trying to do was figure out if there was any way for a Python program to give a list of all the open child windows it had.... and again, there doesn't seem to be any easy way to do that?

QuarkJets
Sep 8, 2008

edmund745 posted:

God gently caress it all. I did it again.... shortly after I posted, I finally realized from a couple different websites how to do this...
I was assuming that you would create a new instance of any child window you wanted, and then destroy() it when you didn't want to see it. Because that's how VC++, VB, Java, etc. does it....

A common problem I am seeing is that a lot of pages are saying how to use some distant, ancient dialect of python. The general ideas might be correct, but the syntax they give is wrong. At least for me?
Like this page:
https://www.tutorialspoint.com/python/tk_toplevel.htm
It says to call .withdraw(), but that doesn't work for me. I had to use wm_withdraw().
And .deiconify() doesn't work either, but wm_deiconify() does.

--------

I think my main problem is that I keep trying to look for things that Python simply doesn't have...
I looked for a couple hours for a way to check if a given child window was open, and there doesn't seem to be any easy way to do that?
The last thing I was trying to do was figure out if there was any way for a Python program to give a list of all the open child windows it had.... and again, there doesn't seem to be any easy way to do that?

While you could iterate through __globals__ and try to identify the kinds of objects that you want (lol don't do this) what you should do instead is either A) do the thing that I recommended, because then you don't need a list of all of the open child windows because there's only ever 1 child window per parent and it exists so long as its parent exists, the button just hides or reveals it, or B) create your own list of child windows, and every time that the user requests a child window just add it to your list (but I thought you only ever wanted 1? If you want to potentially have more than 1 open then yeah, have the parent keep a list of its children, bing bang boom)

To do option A, you'd define a class that controls the main window, and it contains 1 instance of the child window, and when the user hits a button it tells that child window to hide or unhide. That's it. To get extra fancy you wrap a try/except block around the hide/unhide option, to catch cases where the child window has somehow been destroyed and needs to be recreated. No lists of child windows necessary, no lists of anything necessary really, you just have 1 window and 1 child window

Note that this hide/unhide idea is something you can do in Java too, it's the thing that makes the most sense when you never want to have more than 1 child window

QuarkJets fucked around with this message at 01:41 on Aug 26, 2018

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop
I've discovered that I really don't like the asyncio pattern, and it's super-common for any io-bound library. Network programming is inherently non-linear, stop trying to pretend it is (await, threads with blocking IO, etc) So much python meta-magic spent obscuring what's really going on, and in the end you just write poo poo and throw "await" statements when it barfs an error at you.

My actual question:

Normally, when I have two interacting IO streams, I would put them both on the same event loop, register one with the other (or both through a router) then use calls to initiate an action on the other. However, when one is using loop.add_reader(fd, callback) and the other is parked in an await, how do they interact? Specifically, what happens to the awaiting function when the file-descriptor based one wants something to happen? await read() shouldn't be a problem, but I have no idea what the sequence would be for an await write().

du -hast
Mar 12, 2003

BEHEAD THOSE WHO INSULT GENTOO
I would imagine this is too obscure for anyone to help, but I am having some trouble.

I am using Selenium WebDriver with Python, and am trying to click a specific (javascript) link in a tr in a nested table in this old-as-gently caress HTML

Here's the HTML:

code:
<table>
<tr><td width=20></td><td width=260><b>Range</b></td><td width=60><b>#</b></td><td width=60><b>Server</b></td><td><b>Comment</b></td><td><b>Action</b></td></tr>
<tr><td></td><td>1.1.1.1/29 (Thing19) <b>n/a</b></td><td>8</td><td>n/a</td><td>TEST_1</td><td><a href="javascript:editips(20969)">Edit</a>&nbsp;<a href="javascript:delips(20969)">Del</a></td></tr>
<tr><td></td><td> 2.2.2.2/29  (Thing69) <b>n/a</b></td><td>8</td><td>n/a</td><td>TEST_2</td><td><a href="javascript:editips(20970)">Edit</a>&nbsp;<a href="javascript:delips(20970)">Del</a></td></tr>
<tr><td></td><td>3.3.3.3/29  (Thing420) <b>n/a</b></td><td>8</td><td>n/a</td><td>TEST_3</td><td><a href="javascript:editips(20971)">Edit</a>&nbsp;<a href="javascript:delips(20971)">Del</a></td></tr>
</table>
This is a table that is nested in a zillion tables. What I am hoping to do is click the second link "java script:delips(XXXXX)" on each of these lines. My goal though is to delete by the IPs in the first <td>. The overall goal will be to make a loop that allows me to delete a list of IPs automatically (by automatically hitting the final "java script:delips" link. Also, note that in general I will not have the trailing number (like delips(20969)). I am sure somehow there is a way to search by table row, find the IP that I want to delete, then use selenium to click the second link in order to do this.

I've been able to find how to capture the contents of a specific <td>, but since the list may be as long as 500 IP blocks, and I do not know the (XXXX) in the delips() so my goal is to find the IP, move over to the final <href>. Note that the number of <td>'s is the same in each line.

Any guess on how I would do this?

Wallet
Jun 19, 2006

du -hast posted:

I would imagine this is too obscure for anyone to help, but I am having some trouble.

I am using Selenium WebDriver with Python, and am trying to click a specific (javascript) link in a tr in a nested table in this old-as-gently caress HTML

Any guess on how I would do this?

I'm not sure I 100% follow what you're trying to do, but can you not get what you're after using an xpath like
code:
//tr[td [starts-with(text(),'1.1.1.1/29')]]/td[last()]/a[last()]
or something similar (changing the ip to whatever you're looking for, obviously)? I'm not particularly familiar with Selenium, but that seems like it should work if the structure is stable.

Wallet fucked around with this message at 17:17 on Aug 26, 2018

Thermopyle
Jul 1, 2003

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

Hadlock posted:

I am writing some glue code microservice for a pushbutton deploy thing for our sales people to launch a temporary copy of our product with the customer's company name as the subdomain and attached to a sales-ready db.

It is Bootstrap + Flask on Python 3.6-ish, the python portion of the code is maybe 200 lines right now. I can't see this growing much beyond 500 ever.

I need to persist the state of this thing somewhere to disk, and retrieve from it; primarily the dns entries, k8s namespaces, clusters ids and aliases, creation time, salesperson/creator, and expiry date. I'm sure I will stuff a couple of other things in there as time goes on.

If I were doing this in Go I would use BoltDB (now bbolt). I know Flask meshes very nicely with sqlalchemy and sqlite as a sort of microservice holy-trinity, that seems like gross overkill for storing maybe 5 dicts and a couple of lists worth of data? Am I wrong?

I am thinking of going with pickleDB, it has no external dependencies and looks dead-simple.

Thoughts/honest brutal feedback?



I like shelve and its in the standard library.

edmund745
Jun 5, 2010

QuarkJets posted:

...To do option A, you'd define a class that controls the main window, and it contains 1 instance of the child window, and when the user hits a button it tells that child window to hide or unhide. That's it. To get extra fancy you wrap a try/except block around the hide/unhide option, to catch cases where the child window has somehow been destroyed and needs to be recreated. No lists of child windows necessary, no lists of anything necessary really, you just have 1 window and 1 child window...
I had a problem but I already edited the files so I can't show the code...

Does it make any difference if you declare the Toplevel widgets inside a class? I was declaring them in the root level of the files.

It worked in the first attempt, but when I coped the two .py files into another folder and tried to make something useful out of them, it no longer worked right.

Specifically what went wrong was that when the first window opened, it would also open a small phantom window with no attributes set.
As long as I left the phantom window alone, the second window would open and close repeatedly.
If I closed the phantom window, the second window would also close, and after closing the phantom window (if window-2 was either open or closed at the time) then the second window wouldn't open anymore.

,,,,,,,

Also while searching Google for "python try except", I got the Google code challenge! :D ,,,,,,,,,Or does everybody get these now?
I declined to take it.
They'd probably just hire me as a contractor, and gently caress that.
I aint takin no lousy 100K job where I gotta live in a 300K neighborhood, or face a 4-hour commute.

CarForumPoster
Jun 26, 2013

⚡POWER⚡

edmund745 posted:

Also while searching Google for "python try except", I got the Google code challenge! :D ,,,,,,,,,Or does everybody get these now?
I declined to take it.
They'd probably just hire me as a contractor, and gently caress that.
I aint takin no lousy 100K job where I gotta live in a 300K neighborhood, or face a 4-hour commute.

I have googled exactly that previously and didn't get it.

edmund745
Jun 5, 2010

CarForumPoster posted:

I have googled exactly that previously and didn't get it.
Maybe it's a lifetime average sort of thing? Most of what I do search for is digital electronics (part datasheets) and programming stuff.

I can see the interview now...
Google person: "Hello! We're so glad you could meet us today! How is your day going?"
me: blah-blah-blah-blah-blah-blah-blah-blah-blah-
Google person: "Well! You are certainly talkative for someone who is, uhhh..." (shuffles a three-inch-tall stack of papers) "...you're autistic, aren't you?"
me: "oh! , , , , , , , , -um. . . yea! . . ."

Adbot
ADBOT LOVES YOU

CarForumPoster
Jun 26, 2013

⚡POWER⚡

edmund745 posted:

Maybe it's a lifetime average sort of thing? Most of what I do search for is digital electronics (part datasheets) and programming stuff.

I can see the interview now...
Google person: "Hello! We're so glad you could meet us today! How is your day going?"
me: blah-blah-blah-blah-blah-blah-blah-blah-blah-
Google person: "Well! You are certainly talkative for someone who is, uhhh..." (shuffles a three-inch-tall stack of papers) "...you're autistic, aren't you?"
me: "oh! , , , , , , , , -um. . . yea! . . ."

I've known multiple google engineers and I doubt this would exclude you.

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