« first day (3719 days earlier)      last day (1232 days later) » 

1:13 AM
Anyone happen to know how to "shorten" list unpacking? For example, suppose I have some list myList with some large number of elements, and I want to unpack it like x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9, x_10 = myList. I recall there being a way to shorten this... maybe it used the fact the indices are incremented by 1? It's been a long time since I've done any Python, so I don't recall.
 
@KeithMadison you can't (and shouldn't) unpack into n different variables. What do you plan on doing with those variables later?
wherever you'd use x_4 you could (and should) just use my_list[3]
this seems to be related to this new question of yours which exemplifies exactly why you shouldn't do this: because you end up with these monster expressions with no way to handle them nicely
instead go three lines back and define x, y, z and t arrays and use those dynamically
(which seems to be exactly what one of your answerers is suggesting)
 
1:37 AM
@AndrasDeak Thanks for the suggestions. These two questions are unrelated, actually. Someone asked me, and I couldn't remember how I'd seen this done before.
 
Tell them I said don't. And if someone else tells them "use eval" or "use globals" then slap them with a fresh trout.
6
madness lies that way
 
Oops, I meant exec. Minor detail. And that can't assign names inside a function if I recall correctly
 
2:06 AM
cbg
 
2:18 AM
cbg
 
 
1 hour later…
3:47 AM
@skuzzy I appreciate the explanation and the logical way with which you approach making the graphs. It has been hit and trial for me so far. Would you please point me to any resources that helped you understand the logic?
 
4:05 AM
cbg all, can anyone tell me why the generator version of the path function gives me a Time Limit Error on leetcode? how is that different from the one that returns the list (this passes all test cases) so its not a logic error I am asking?pastebin.com/w8XPkYnn
is my generator not equivalent to that?
 
4:17 AM
rephunter hat is an abomination which encourages the worst kind of fgitwing
they really should change the trigger to something else because as it stands that hat favors quantity over quality
 
5:13 AM
@python_learner The generator version is not equivalent. In your non-generator version, you return at line 24. In you generator version, you yield from parents + [node] but then continue on to yield from the right and left nodes. Make those yields in an else clause and then I think you will be more equivalent.
 
thanks for the suggestion Paul, I moved the yield from calls to an else and still times out :(
even if it did continue to the left and right node, shouldnt they at one point reach the base condition?if node is None:
this also happened when I tried doing a generator version for a dfs in a different code site, I cant find where I am going wrong
 
5:43 AM
I'm still puzzling over this too.
 
do let me know if you can figure this out, I could call it a day since it passed but I would very much want to know :D leetcode link : leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree
 
If you are timing out, then you are visiting more nodes than you need to. In the non-generator case, you still visit unnecessary nodes - if the node is found in the left path, you still visit the right path. You could change lines 25 and 26 to res.extend(path(node.left, val, parents + [node]) or path(node.right, val, parents + [node])) so that if the target value is found by following the left branch, the right isn't even checked. Unf. you can't do that in the generator.
I'm pretty sure I solved this same problem on hackerrank, but I have in the past couple of years been moving away from recursion since function calls in Python are so expensive, and instead using a tovisit deque.
 
I will take that suggestion but the non generator version "as is" runs without Timing out and hence the problem I am facing
 
Understood
 
isnt recursion about stacks? why use a deque?
 
5:52 AM
A deque can be used as a stack.
append and pop are like push and pop for FIFO. append and popleft are for LIFO.
 
cant you use a normal list for that?
ahh got it
 
Using a deque gives you some nice symmetry - the traversal code is identical for DFS and BFS, except for pop vs popleft. If you use a list, you can do pop() and pop(0). Python lists are less efficient at pop(0) than deque.popleft.
 
I had this exact confusion last night thinking all I had to do was that change for bfs vs dfs :D
 
Gah, I got them backwards - deque.append and deque.pop are LIFO, use popleft for FIFO.
Stack normally being LIFO
 
one code site showed 0.5 seconds more time when I did pop(0) than popleft with a deque
 
5:58 AM
Because lists are implemented as C arrays, and so when doing pop(0), Python moves elements 1-N all down one place.
 
make sense, melon very much
 
Whereas deque is supposed to be super-efficient at head and tail add and remove - I presume this is a doubly-linked list, or similar
 
I will try to see if the generator version runs on hackerrank
I guess hackerank has a BST version and not a non BST
which would have even less time constraints due to BST property
 
 
4 hours later…
10:08 AM
@roganjosh Hmmmmmmm, will make it green then.
 
I mean, I'm not really the guy for UI/UX but that is definitely confusing :P Green probably makes more sense, but I'm not sure what it does tbh
 
It adds from yesterdays to todays list
 
Perhaps an arrow would be better there then? Or something similar.
 
@BožoStojković Hmmmmmm arrow never occurred to me, well thanks, ill make it an arrow
 
Just a suggestion :)
Also, is there an ability to edit the plans? If yes, there should be a pen icon or similar. If not, you should consider adding it in.
 
10:19 AM
@BožoStojković Well for version 1 not yet. Maybe over the next release.
 
@AndrasDeak We're probably talking about the same thing, but my take is that slowing down to conserve battery life was not unreasonable, given that most people wouldn't know what speed their 'phone ran in the first place. As you say, room for opinions on that one, though.
 
as an ex owner of an iphone I found out they did provide a toggle for that after the controversy
 
=
Sorry, that last is a message from my grandson.
 
10:41 AM
@holdenweb the elusive "cat grandson walked over the keyboard" ;)
 
@PaulMcG Yeah, I get the impression that Go is rather lower level than Python but significantly higher than C.
@AndrasDeak :)
 
11:03 AM
@holdenweb I can only dream what the next Python will be able to do :O I imagine it being half sentient :D
 
C++ was the next C and where did that leave us?
 
C++ was rushed to standardisation way too quickly
 
user13727121
11:26 AM
is there a way to format my numbers into currency? The ones on the web are sorta complex to comprehend...
 
@CoreVisional example?
 
f'{num:.2f}€'?
 
It's probably not a float, right? ;)
 
user13727121
like, i want to change the currency type of this price print("${:,.2f}".format(customer_one_total)), the number is 575.56
 
@AndrasDeak I win :P
 
11:29 AM
@CoreVisional make the currency another format field
@Aran-Fey nobody wins :(
 
user13727121
OH MY GOD, i just needed to type in the currency type I want by replacing $. Thank you by the way for the response
 
@CoreVisional make sure to read stackoverflow.com/questions/3730019/…
>>> income = 0.1  # austerity
... budget = 0
... for month in range(10):
...     budget += income
... print(f'I now have {int(budget)} complete money.')
I now have 0 complete money.
because
>>> budget
0.9999999999999999
 
Came back to talk about more SQLite ;) Should I be handling date queries with SQLite or Python? SQLite seems to be more easier because in python if i wanted to choose any date greater than today, ill have to do some looping through the database and get the maximum date and then proceed accordingly
But in SQLite there might just be some easy query for that, but cant figure out which function to use.
 
I would expect database libraries to expose the full functionality of the underlying database engine. Perhaps I'm being optimistic.
ugh, I can't type this week
 
user13727121
@AndrasDeak "A solution that works in just about any language is to use integers instead", answer to that question. But in those codes, you're using int yet it still prints out 0.999...
 
11:44 AM
Andras used an int and a float. The trick is to use only ints.
 
user13727121
Yes, sorry, I misread, I was mainly looking at the result of the budget and wondered why didn't it round off, only to realize it doesn't round on its own, sorry. Also, should I display the two decimals when it comes to price or should I use int and that will do?
 
@CoreVisional when they say "use int" they don't mean "call int() on your float currency values". They mean the internal representation of your currency values should be integral.
 
Perhaps, something like this make sense
SELECT * FROM tasks
    WHERE date(`Date`) <= date('2020-12-31');
 
@CoreVisional my example showed that using float income is inherently flawed
if you have non-integer money in a float you've already lost information
 
Wait, anyway to get ALL the dates greater than today?
 
user13727121
11:52 AM
@AndrasDeak thank you, I just tried it out by only printing out the price without any formatting function, it printed out a lot of decimals.
 
12:41 PM
@CoreVisional It doesn't matter how many decimals a float is printed as. float is inherently lossy for decimal data. Definitely use a non-lossy format such as int, decimal.Decimal or fractions.Fraction.
Also strongly consider to use iso4217 when dealing with currencies, not just generic money.
 
1:18 PM
Guys help me out here please. SELECT * FROM tasks; gives
[('Climb a mountain', '2020-12-21', 0),
('Ride a horse', '2020-12-21', 0),
('Jump a tree', '2020-12-21', 0),
('Fearless', '2020-12-21', 0),
('Create a new one', '2020-12-21', 0),
('Jump like a maniac', '2020-12-31', 0),
('Abandon the project', '2020-12-20', 1),
('Create a new one', '2020-12-20', 1),
('Try to sue life', '2020-12-31', 1)]
SELECT * FROM tasks WHERE `Date` BETWEEN date('2020-12-21') AND date('2021-02-15') gives
 
what is it that you expect?
 
[('Climb a mountain', '2020-12-21', 0),
('Ride a horse', '2020-12-21', 0),
('Jump a tree', '2020-12-21', 0),
('Fearless', '2020-12-21', 0),
('Create a new one', '2020-12-21', 0),
('Jump like a maniac', '2020-12-31', 0),
('Try to sue life', '2020-12-31', 1)]
But when I do the same with variables like....
c.execute(f"SELECT * FROM tasks WHERE date(`Date`) BETWEEN date({today}) AND date(?)", (nxt,))
I get the wrong query
 
@CoolCloud don't. Format. Queries.
 
if you already using f string why even pass the second arg
 
@python_learner NO. Wrong conclusion.
 
1:23 PM
@python_learner I just wrote it out for pasting here
 
I mean its already vulnerable to injections, that was the point I wanted to make
 
c.execute("SELECT * FROM tasks WHERE date(`Date`) BETWEEN date(?) AND date(?)", (today,nxt))
Seems better
 
@python_learner wrong point
@CoolCloud yes. Might also quote your strings.
 
well I will sit back and listen, ignore what I said cool cloud
 
Both queries are supposed to be same. When I use variables I get a diff output
 
1:27 PM
So the value of today is what? And nxt is what? And the output is what?
 
Hmmmm seems as though there was some problem with using f. Once I changed it back to placeholders it worked
@Aran-Fey today is the string of date of today and nxt is some random date from future.
@python_learner Well this made sense now :p Thanks!
 
For future reference, showing us those values is far more useful than describing them to us
 
This is actually why, removing and trying to re write the code can solve the issue at times.
@Aran-Fey Just so you mentioned it, today = '2020-12-21' and nxt = '2021-02-15'
 
@python_learner it's just that if you see an injection vulnerability the point shoud be to remove it, not that you might as well make it worse :P
 
@AndrasDeak I get it :p lol, hopefully next time it will be "injection-free"
 
1:32 PM
fair enough, I usually get a working system then worry about stuff, I am yet to work on real world app with db's so I am clueless as to how bad these can be
 
@python_learner FOR ME, it seems pretty bad, maybe due to the lack of experience, just been about 7 months with python and its still a mystery to me.
 
@python_learner only as bad as the most evil person who comes across your site. I.e. very.
@CoolCloud it's not a matter of hope.
 
1:51 PM
@CoolCloud - the point is to develop good habits, esp. when learning to work with SQL. NEVER EVER EVER do c.execute("string with placeholders".format(value, value)") or c.execute(f"f-string which has the {same} injection {vulnerability}"). Instead get in the habit of c.execute("SQL with placeholders", (tuple, of, values)). The latter will do all the necessary escaping to defeat injection attempts.
(And @AndrasDeak, the execute method should take care of adding quotes where necessary.)
 
@PaulMcG that's what I said ;)
Or at least tried
 
Sorry, I misread that - I thought you were saying that they should put quotes around the placeholders.
 
Yeah, looking back it wasn't clear
I didn't want to make it obvious that the original probably broke due to quotes, lest they "fix" it by quoting in the f-string
 
2:24 PM
@holdenweb - certainly "lower level" by the variety of signed and unsigned ints by size, and float32 v. float64, and exposing by-value v. by-reference semantics, and using pointers (though pointer arithmetic is not allowed). Exception "handling" relies heavily on the "return a status code" model (though unlike C, you can return multiple values from a function, so you don't have to use an output arg for the function value when the function returns a status - you can return val, status).
Syntax-wise, golang benefits from an additional 50 years of compiler development (and not having to be backwards compat with old C syntax). You still have braces, but ()'s around if conditions and for-loop init;cond;incr are not required, no semicolons are required. Actually helpful error messages. And tuning for build speed is a Prime Directive (their blog says that the whole thing started while Rob Pike was waiting for an hour-long build to complete).
Having a native map type is nice. And auto-delegate to contained type, if you squint your eyes, borders on inheritance. Strings are all UTF-8 (but you can get the underlying bytes if needed). Slices as a view to an underlying array, and using array[inclusive_lower:exclusive_upper] (as well as the related default forms) are a step up.
Lastly, a number of abusable syntaxes are no longer allowed. then and else clauses on if statements must be enclosed in braces. No ternary operator. switch cases now default to no-fallthrough, so missing break bugs are history. x++ is a statement, not an expression. And no assignment expressions.
 
2:38 PM
<3 no asspressions
 
how accurate is this pypi.org/project/big-O-calculator ? if anyone has used this
 
2:54 PM
That seems like a completely pointless module tbh. Why on earth would anyone implement and time a sorting function in python when sorted exists?
 
I was just browsing leetcode and one comment mentioned for a particular case Tim Sort is O(n) so I wanted to check using some modules
 
just to be sure - you know that python's sorted uses timsort, right?
 
yeah I did, I was interested in the part where some guy mentioned it ran in O(N) for that problem I thought it was O(nlogn) always
 
Are you sure that module can generate the kind of input data you need?
 
I guess not, not an useful module after all
 
3:22 PM
@PaulMcG Your right. But how to use placeholders with column names?
@python_learner is it hard to understand the big O notation? I was thinking about taking a look at it
 
there are 100 of videos out there if you want to understand that
finding big o is easier than writing code in that big o :p
 
Hmmm, I need to take a look definitely.
 
idk if actual devs use big o in their code as much as interviewers ask, I guess its more about knowing big o for most common operations so you know if there is a better way or not, thats how I see this
most common operations are in stdlib, eg sort, substring matching
 
Hmmm interviews matter i guess :p
 
3:57 PM
Hey anyone know any room where I can ask questions related to C or is this place okay?
 
There seems to be this one, don't know how active it is though
 
4:09 PM
@user541396 why would this place be OK?
 
user13415013
Hello guys. Hows the days going :) ?
 
4:54 PM
late morning cabbages, folks. Had to go get a COVID test this morning
 
ouch, is it a state / city thing to get tested regularly?
I mean I dont see many people in my place getting tested now
 
@inspectorG4dget PCR or antibody?
 
no. G4dgetGirl is a school teacher and got a notification of potential high-risk contact from school. Since we live together, it's just prudent to get it done
 
Ah. Hope she'll dodge it!
 
Quick check: are there any considerations I need to make when releasing a package internally, where the repo name doesn't match the package name? For example, for the company repo I'll have to call it "library-that-does-xyz" but in setup.py I have setuptools.setup(name="thisisawesome"). I think not but I always seem to get bitten on packaging :/
 
4:57 PM
@AndrasDeak It was a nasal swab. So I wanna say it's an antibody test, but I really don't know (if anyone knows, I'd love to learn)
 
could be either
PCR protocol is pharynx through nose and throat, but they might also just be sloppy
 
@AndrasDeak fingers crossed. Doing some very rough math, the probabilities are very low. But it's hard to be any degree of certain
mine was just through the nose, so I guess it's antibody, then
 
@CoolCloud execute() placeholders are for substituting in values, not table or column names. Values are typically where SQL injection attacks occur, when directly subbing in a value entered by a user (cf. Bobby Tables).
 
@CoolCloud For table or column names, you will have to cross-reference what's being submitted by the user with the database schema. It's not accurate being told that you should never use formatting in query strings because parameterization simply can't be done for table/column names. You just have to be sure you're doing these checks before executing anything
 
now where's Antti's boldface explanation of a whitelist :P
 
5:03 PM
In the case of parameters, there is, however, no excuse to not be using placeholders
 
not sure why I'm surprised
 
@roganjosh there needs to be no relation between the name of a distribution and the installed package.
(even if there should be)
 
I don't think there is at all, but that's where I don't necessarily know if such references can somehow creep in without me knowing it
 
why can't I wear multiple hats?! waaaa'
 
@Arne can you think of a simple example where this could happen so I know roughly what I need to be looking out for?
 
5:08 PM
I might have misunderstood you, actually. what I said is that the setup-kwarg-targets name and packages can be distinct, I think the name you upload a package with is always the one you pick for name.
 
Aha, ok, that makes sense. And I think I might not have been very clear in my initial question sorry. Ok, so I think I'm fine
 
I'll try to find some time to play around with upload names, I'm actually curious now how a pypi will react if the tarball name and the metadata have different opinions.
one thing I didn't try to break as of yet =)
 
Well as long as it's not just on my behalf; I'm just trying to preempt stuff
:P
 
no worries, I do actually enjoy distributing code, and understanding how it works
 
Hmm, my Enter key has stopped working in VSCode. Looks like it's time for some epic one-liners and a spot of golfing
6
 
5:49 PM
@roganjosh are you able to copy/paste a newline?
 
I fixed it just by shutting it down and starting it again :) The classic off/on smashing it on the problem-solving front once again
 
6:36 PM
@roganjosh So to sum up, values have to be inserted through placeholders and for column names after whitelisting, format or f strings can be used?
@roganjosh U know whats the most annoying thing VSCode does(for me?). When pressing Alt+F4 it just closes, without ANY warning, I checked settings and couldn't find ANYTHING.
 
6:57 PM
@CoolCloud That's a Windows thing, not a VSCode thing.
 
7:08 PM
@CoolCloud correct
 
Not even just a windows thing.
 
7:36 PM
So you're saying when alt+f4 is pressed there is no way of asking for weather your sure you want to quit?
@roganjosh Next time it will be injection free;)
 
@CoolCloud It may well be. But this is one area where I think it's healthy to always have at least some background anxiety to make sure you're exploring all angles. It's not an area where you want to be complacent and believe you're covered on every angle
 
@roganjosh Hmmmm sure :D
 
@PaulMcG Ultimately the lack of exception handling rendered it too low-level for my elevated tastes.
 
Any libraries for playing music other than pygame that supports threading? pygame cant play more than one music at a time. Though there is an option for it, but using that option, for some odd reason, I cant get them to load my file.
 
I've only just started playing with it, and know nothing about music, but I've been impressed with Sonic Pi, and there's a python-sonic SDK.
It's definitely asynchronously polyphonic.
 
7:50 PM
@holdenweb Chill with the words xD. Means what?
@holdenweb Can it load music? Seems like they can create musical notes and all
 
 
1 hour later…
9:08 PM
Hi, are questions like "how can I develop APIs?" off-topic for SO?
 
Not off-topic, but too broad.
 
yup
 
how can I learn how to start developing APIs, to design user friendly codes for users to send some of their input parameters to a software...
 
API design isn't a simple question-answer kind of thing.
 
There are very nice APIs to do so which are designed to be used in engineering softwares which allow users to do parametric studies, etc...
 
9:11 PM
So you are thinking of writing a library that people will use in their own code? As opposed to a REST service that responds to a REST API over HTTP.
 
@enthu well first you'll need to distinguish between a web API and the software API. Which is it?
 
"API" used to mean just the software library type. But this newfangled internet thing has messed everything up.
 
@roganjosh you read my mind?! I was typing this: By API, I do not mean a web site API which first come in the search results. I want an API to interact with softwares
 
The intermewebs haven't messed up anything. At all. Blasphemy.
 
@PaulMcG yes a very specific library to be used by users to send some of their parameters to the softwares, instead of using GUIs, they code what they want and call the software
 
9:14 PM
This guy has been around a while, give this presentation a look: fwdinnovations.net/whitepaper/APIDesign.pdf Found by googling for "software api design principles"
The first 3 or 4 links appear to be more about software APIs, before the Web API stuff starts cropping up.
 
@enthu in which case, it's a really tough question to answer. I spent a lot of time looking at other python libraries on github to get a vague idea of what I should shoot for. But even then, there is so much flexibility that it's hard to pin down
 
I think a lot boils down to "put yourself in the user's shoes" where in this case, the "user" is the developer who is going to use your library.
 
@PaulMcG thanks, the author is a software engineer... worries me if developing APIs demands more in depth software knowledge...
 
Are there libraries that you have used that you liked? Why did you like them? Are there libraries that you liked, but parts annoyed you? What was annoying?
 
@roganjosh I saw some APIs developed using C# or .NET... I am not sure. But were too heavy and time consuming to run!
 
9:17 PM
If the user knows where you live and has a two-by-four, should you be afraid?
 
I've read this guy's work - I think this is probably targeted at API design, not lower-level implementation.
 
@PaulMcG Not annoying. In my field, engineers usually use many softwares. They use some to design structures, some to design foundations. Other ones to prepare drawings and reports. If I prepare an API to send such parameter to different sotwares, that would ease most of our work.
 
@enthu they're not directly helpful if you're working in Python but it does change your thinking a bit to see how they work. For example, I learned quite a lot about "programming to an interface" from Java, even if I don't like the language at all
 
@roganjosh I do not like it as well, I have developed most of GUIs in my field with tkinter python... does most of what I need in an ugly way though
 
This sounds like the Facade pattern, in which numerous complex functions are front-ended with a consolidated (and hopefully simpler) interface. Usually this means that the Facade makes some simplifying assumptions or scope decisions.
Like "I want to use library X, but I really want to just focus on feature Y of X, and leave out the 47 other features that are not relevant to my field." Or "There is this general purpose n-dimensional geometry library, but I want to front-end with an API to support just 2-dimensional Euclidean operations"
You might start off drawing some pictures, the 30,000' (or 10,000m) view of your different libraries that you want to give access to. Now put your API between the user and these libraries, and see how your API provides some added value, some simplification of the user experience, or some required synchronization (I need to use the output from library A to call library B).
 
9:26 PM
@PaulMcG Or the other way, there is a software with n graphical features and the users needs to do lots of work by mouse. I want to design a software API with n python codes which allows the user do repetitive work in just one F5 click!
@PaulMcG Actually I know the added values which are given to the users in my field by designing an API for them. The problem is that I do not know where I should start.
 
I happen to actually need to write a python library that will communicate via a RESTful API with a Java server I'm writing in tandem. I have a file where I've just written completely non-existent python code that pretends the library exists, just to think how I'd like to be able to use it. I'm now building the python library around that. No idea if that's helpful or the best approach, but it's working for me
 
I'm sorry, I think you misconstrued what I meant by "added value". You of course know that you are adding value by providing this API (which I'm not sure is really the right term, now that you are talking about things like F5 clicks). I mean, in what way does your program make it easier to use your API, vs. just using library X directly? For me to do my F5 click, how do I define just what I want that F5 to do? Is it the same every time? Do I need to somehow send some kind of parameter(s)?
If F5 is fixed and automates some repetitive drudgery task, then that's the API. "Login. Hit the F5 Key. Logout."
On the other hand, if F5 is supposed to be configurable, and the configuration is as complicated or more complicated than just calling library X, then you really haven't added any value. They might as well just use library X directly.
I'm guessing you are thinking of something in the middle of these 2 extremes.
 
@PaulMcG I am more close to this. Some of civil engineering design is repeating. Just changing the dimensions of a structure, run the software, prepare report, exit! The current GUI usage of the softwares is too resource consuming. Designing an API would decrease the production time. This is what I expect from an API...
Moreover, coding design regulations with the API will decrease the human errors which occur doing things with GUI. API will help the engineer to do things faster in a more accurate way.
 
This sounds like it would be a plugin to an existing design software package.
 
@enthu Do you actually want to create an API or UI? The former is commonly targeted at code, and the latter at people.
 
9:37 PM
@PaulMcG that is right. but not all our softwares have the plugin feature. that is why I think designing an API which communicates with some softwares would do the work.
@MisterMiyagi I want it to be an API with some codes. Making it a UI will be then much easy using tkinter.
let me give an explanation:
A civil engineer needs to design a steel beam and prepare drawings and design reports.
If he wants to do it in the current procedures, first he needs to define materials in the software menus, then he needs to draw a beam with mouse, then he needs to assign loads on it. then he needs to run the design. then he needs to prepare drawings. then he needs to type a report in ms word! it will take him a whole working day!
Now I want to prepare an API like this:
Import pyAPI as pas
pas.beam(h,t,L, mat, boundary)
pas.run
pas.draw
pas.report
this will be so much efficient!
 
There goes job security!
 
the API calls the design software by pas.run, the drawing software with pas.draw, etc. no need to do repetetive work
@AndrasDeak Actually such automation has caused shifting to newer generation of civil engineers who understand codes more. some softwares do lots of such work in a few seconds.
 
So this is a start, now follow the data. I didn't see the loads anywhere, is that one of the arguments to beam()? Are all beams the same (I-beam, T-beam, box-beam, other beam)? You'll have to get back some result from calling beam() that you then use for run, draw, and report. Maybe an instance of a class? Maybe just a dict?
 
for instance, in the past all the design work were done by hand and paper. now there are softwares which design every single part of a building in a few seconds
@PaulMcG You are right, just wanted to give an abstract of the analysis flow in my field. Types of a beam are much varied and the API should have more codes. I think definition of geometry and materials and loads should have different classes.
 
@enthu That looks more like a script or generally automation.
wait, is pyAPI the thing you want to write, or the thing you want to use?
 
9:50 PM
So this could be one of the simplifying scope assumptions. Instead of all possible kinds of beams, just choose beams of a single type, a box beam would be easy because the cross-section is easily parameterized.
pyAPI is the thing he wants to write for other people to use, which will simplify their lives.
 
I do not know the exact difference between an API, script, etc...
pyAPI is what I want to write to help the user do the GUI things he wants to do with a few lines of code...
 
Once you get into many types of beams, materials, geometry, etc. your program will get very complicated.
 
@PaulMcG that is fine, for a start point a rectangular beam will be sufficient. but type of beam stands for the second record since I do not know how to make kind of pyAPI to pass a rectangular cs beam to a software
 
You will really need to get clear in your mind what you want this code to do, then research the software you are going to interact with and see what they offer in terms of external interface. A beam modeling software might accept a file containing the beam definition, material, and loads. Then your code would take the parameters, create that file, and then run the beam model. Since you have the dimensions, then use a drawing package to draw the beam, or do it yourself with a Python graphics pkg.
So do this thinking before writing any code. What software(s) will I interact with and how do I pass data in and get results out? What are the steps I'll go through with each one? How will I present the results? Probably write this as just a straight up automation script for a project with a limited scope (just rect box beams, for example). Write it again for I-beam and/or T-beam, then step back and see if there are commonalities that can be abstracted out.
Then you might start to see some "API" for Beam Design Automation, which you could then use to refactor your previous work.
 
@PaulMcG I see... what about softwares which do not have a tailored external interface? I mean, some of our softwares work with simple text input files, some other have defined their APIs but it is very simple and do not cover everything, some other work with data files like ms access files; some other do not show to have any of these because they have not thought about such automation...
 
10:07 PM
There are some (painful) methods for automating UI interactions. I've used pywinauto in the past to automate mouse clicks in a browser to cheat at a web game. Selenium is used to automate browser interactions too. But dig a little deeper in the software docs. There may be external interfaces that you are just not aware of at the moment.
 
@PaulMcG thanks indeed, fantastic starting point for me indeed...
 
And certainly, the more you can automate a painful repetitive task, that is certainly a win, even if it is just your own productivity. I wrote some Python macros for iTerm on the Mac to automate connecting to multiple test servers, one per terminal pane. Was a big productivity win, even though I was the only one who used it.
 
@PaulMcG not very professional in view of a software engineer or professional coder, I have developed some codes to automate my design work using python, or ms excel spread sheet. that is magic. I feel how automation can improve quality of work. Then I wrote some bigger codes using API language of our softwares (python, autolisp, tcl, etc), that was another step for me...
that is why I came to the point that I need to design a scripting system or API to make usage of our softwares more automated... I feel the value of win you are talking about.
 
Gah, Tcl! My old nemesis!
(Btw, Python automation of iTerms is incredibly easy, and worth the 1/2 day investment to learn, for those here on Macs.)
 
@PaulMcG opensees is one of the perfect structural engineering free-wares which is written using tcl. it is a product of Berkeley and hundreds of papers and projects are built upon it... so fast...
odd world! I am trying to make codes to automate some gui procedures, there are some people in my field for instance who are interested to make gui interfaces for some of our field's python or tcl codes! :)) not everyone seem to be satisfied!
 
10:21 PM
some people like clicky clicky
 

« first day (3719 days earlier)      last day (1232 days later) »