« first day (4314 days earlier)      last day (624 days later) » 

12:41 AM
I am using the Data Science for Dummies book to learn data science, but I am having the following issues:

https://repo.anaconda.com/archive/ is supposed to have the right version with Windows Version 5.2.0, but that requires that you install an old Python edition, which is not what is used in the tutorials. Therefore, I used what they have in the screenshots in the book (March 2019 edition).
Once I got this version of Anaconda installed, I have to change my Jupyter notebook edition to 5.5.0. On Anaconda Navigator, I clicked the settings icon and said I wanted to change Jupyter to version 5
You can also find my question here: stackoverflow.com/questions/73271956/…
I am new to this chat, so if I accidentally said something off-topic, I apologize in advance.
Oh, I am sorry, I didn't know questions on the main website weren't allowed. I am removing my message if possible.
I cannot remove my message on here, so just ignore this one.
 
stackoverflow.com/questions/17980509/… Any better canonical for these?
stackoverflow.com/questions/36584297/… related (getting rather than setting)
 
1:30 AM
stackoverflow.com/questions/46908007/… surely there's a canonical for this?
 
 
1 hour later…
2:44 AM
stackoverflow.com/questions/12595051/… how in the hell is this at +470/-3
duplicate (should be duplicate of stackoverflow.com/questions/647769 ; I misidentified it) stackoverflow.com/questions/33963760
 
3:03 AM
stackoverflow.com/questions/647769/… more suitable; I did edit that into the hammer
oh wait you did, ofc, anyway it's fixed
 
 
2 hours later…
4:53 AM
Heh I have my flag denied for this answer it really should be a comment, did nothing to answer OP's question because OP's code imported a module for Windows usage
it's a blank assertion without links to supporting documentation
this answer is by far the most blatant not an answer and still not treated as one, I supposed only spam is really not an answer
 
 
1 hour later…
5:58 AM
Hi guys, is it ok if I copy someone's code answer and explain it, especially if the user is asking for an explanation?
 
6:57 AM
@DialFrost has the original answer been made aware and given ample time to do it themselves?
 
@roganjosh Yes the person has been made aware, but they haven't been given ample time yet, so I guess I'll wait
 
 
2 hours later…
8:51 AM
@KarlKnechtel nice, didn't know :o Also yeah, I think you can probably set up a domain-less site on github pages if you want to play around with what I mentioned, unless you want to wait until you figure out how to integrate your content in a blogging format.
@AndrasDeak--СлаваУкраїні That sounds like the kind of stuff I always get stuck on :) relatable
 
 
2 hours later…
11:15 AM
is there a way I can avoid the if's here? something with a dict?
def foobar(x):
    if x == -100:
        return foo
    if 0 <= x < 10:
        return bar
    if 10 <= x < 20:
        return qux
    if 20 <= x <= 30:
        return foobarqux
    return 1
I have a set of ranges, and I have to return a single value based on where it is
not sure if it is relevant, but this will be used as df['column'].apply(foobar), maybe some vectorized alternative exists?
 
@Jake elif?
Ah, you return
 
yeah, I meant to remove the whole if part, at least make it less verbose
there really is not a pattern to the ranges or the values I return, so I am not looking for a math solution
 
You could loop over an iterable of range objects and results but that wouldn't be much more readable
 
pandas.Series.between does what I want, but when I use it consecutively it messes up the output (cuz I assign the result to the same column as the one I operate on)
 
@Jake Not really. You could use a list pairing the ranges and the result and loop over that, but it will just be another kind of clunky. Depends on the size a bit.
 
11:29 AM
I have around 10 such conditions
 
One way to copy a class object is -

class Foo:
def __init__(self):
self.a, self.b = 1, 2

def copy(self):
newFoo = Foo()
newFoo.a, newFoo.b = self.a, self.b

But as parameteres in Foo grow, this becomes painful.
 
Use the builtin copy module.
 
you just use copy.copy
 
Or directly copy __dict__.
 
11:30 AM
@Jake Then I'd use a loop simply because it's more apparent then that you're doing the same logic repeatedly.
 
alright then, thanks you two
 
there were many possible reasons, low chance: (VmWare, SourceTree), medium chance: (line ending conversion, corrupted timestamps - this one definitely happened, for the very unknown reason I committed files with one hh:mm but after checkout like 15 of 1000 files had other hh:mm which diff showed as changed file), and finally most suspected - some heave combo of each commit had hundreds deleted, renamed, changed files, same for folders which somehow magically created unrecoverable failure

but yes in general empty commit is what I had in mind when was saying "snapshotify" or self-sustained c
 
Second, if I have a class representation, how can I construct a class using that?
 
In the general case, you cannot.
 
Say I have the Foo.repr()
 
11:32 AM
Reprs can be arbitrary.
 
Is there anything I can do
Metaclasses or something?
 
Make the reprs of the objects you care about meaningful.
You should try to make the repr equivalent to an expression literal that constructs it. For example, the repr of range(12, 16, 1) is an expression literal that produces an equal object.
 
You can create new types using type(name, bases, dict, **kwds). Not sure if that helps.
 
In general, objects that reference external state are not unambiguously meaningful to copy and the same extends to re-recreating them from a repr.
For example, "copying" an open file could mean multiple things: opening the file again, creating a new file handle for the same fd, or just returning the identical object.
 
oh, by any chance is there way to make root folder of your project, which is located in same folder with .git folder, to have version in it's name without bugging git too much?
spend more than half of day trying to make windows folder symbolic links to get together with git and with sourcetree, enabled developer mode etc, yet git persisted to think of shortcut as file
again, feels noticeably more reliable to have version as top folder name than to rely on batching
 
11:38 AM
Can I add methods in type(name, bases, dict, )
 
It might be an interesting project: Given a string like "Foo(bar=1, baz=True, qux='idk')", use type to construct a Foo type, with attributes bar, baz, & qux.
@Grasshopper Yes. Calling type() should be able to do anything that a proper class block can do
 
Thanks, thats what I want
I was searching but wasn't able to find correct direction. Now I have one - type(..)
 
@Kevin You need types.new_class for that these days, technically.
 
I actually want to create something similar to pickle.load()
 
Foo = type("Foo", (), {"frobnicate": (lambda self: print("Frobnicated."))})
x = Foo()
x.frobnicate() #output: `Frobnicated.`
 
11:42 AM
@halt9k why not use git branch instead? then you could just use a version name for specific branch. Btw, I don't know Windows as much as Unix but, I think shortcut on Windows are actually just file with a reference to the destination, clearly written. But with symbolic links, it's on an inode/fs level, so it's different. See here: superuser.com/questions/253935/…
 
@MisterMiyagi Oh interesting
 
@halt9k also, to add to the "setting up git + symlink on windows":stackoverflow.com/a/16754068/12349101
 
idea is to be able in fast one-click to create 7z backup for future use which does not contain git ifself
but conatins version in name
 
Is there a way to "inherit" signal handlers? My usecase is that I need to fixup a library that highjacks SIGTERM and SIGINT for graceful shutdown but misses to run the default actions afterwards; is there some way to trigger the "default" signal behaviour after the special handling?
For SIGINT the default is an actual handler function that I can just call and it raises KeyboardInterrupt properly. But for SIGTERM the default ist just the signal.SIG_DFL enum.
 
@halt9k I'm not sure how this fit with git if you want to do 7z backup without having to use git later on? Then again I also had plans to use git with different backup scheme so I think I could guess it hmm. Ever tried git-annex?
 
11:48 AM
Iactually want to create something similar to pickle.load() but with json
 
@Grasshopper As a rough guideline, pickle works by storing the fully qualified name of a factory and its arguments to restore objects. That scheme should work out of the box with JSON as well.
E.g. for range(12, 16) you would store ["range", [12, 16]].
 
sometimes need to send all project or to store it in exact way as it was send and to reduce chance of errors - therefore version in folder name and desired clean state of all files

full compressed project size is about 150 MB, which make it practical to separate git from these backups
 
You can probably repurpose the output of __reduce__ for that as well.
 
When creating a pickle-like method, don't forget to handle referential loops. x = []; x.append(x) for example.
 
git-annex seems quite for other task
I'd just like to have some setting in git which says project is in this (external folder)
and instead of batching archives, to batch this setting update from project folder
 
11:58 AM
@halt9k but I get backing it up in a single file, as I also wanted to do the same (see here and here for related answers I made) but how do you plan on doing it while removing git from the said backup? by only using the top layer/head of the repository?
or do you want to just back the whole git repo in a single archive and then just extract it without having to use git to do so (since you can abuse the compression feature and delta encoding of git to compress files, depending on how you do it)
 
don't want to back up git repo much, it's anyway feels not reliable enough
goal is to have clean project folder without any additional files in it, but to constantly change this folder name to match version
and problem is git does not like folder renames in general
 
reject modernity, go back to _final_final_(9).zip
 
@PeterT with it you at least 100% sure that extracted files will be same as compressed (if checksum used)
 
unlike git hashes somehow?
 
with git it's so much more mess than expected
for example, it changes timestamps on files
 
12:07 PM
I'm not the biggest fan of git myself, but "back to zips" somehow doesn't strike me as better, but it's up to you what you use
 
may be refusing not to use UI was mistake, but that's like go back to _final_final_(9).zip, but with command line instead
it's not a DOS times after all
at this point best is that symbolic link approach, simple and clean... and not working
ah, symbolic link was not auto-updating too after project folder rename, so it's not as best as hoped
 
Proposal: don't do anything special with folder names and symbolic links, etc. Create a program, one_click_deploy.py, that creates a zip archive of your project, excludes all the git parts from it, and adds the version number to the top directory.
 
basically what I use, but chance of error without version in folder name is simply higher
feels like a downgrade from times when did not used git at all, but with version well visible
 
No, there's no chance of error. All you're doing is clicking one_click_deploy.py.
 
12:16 PM
@Kevin for example, there is change of forgetting to update version in file or in other source used for it
@Kevin actually, where version is taken from in your way?
 
Good question. I think you can do it with tags in git.
But to be honest I'd probably find that irritating and I would have a version.txt file somewhere instead ;-)
 
usually I use git describe, usually with some format like {tag-name}-{num_commits_after_tag}-{short_hash}
 
@AndrasDeak--СлаваУкраїні seems touched this, though not sure if git-archive supports password protect as easy as 7z archive one-click pack
 
some people like to use dates instead
 
@PeterT almost sure it's horrible
 
12:22 PM
I don't know, I think for regularly released software it's helpful. I think e.g. the ubuntu version scheme a lot more useful than Debians
 
@PeterT I mean so many ways to get timestamps messed up and they will emerge in most undesirable and unexpected moment
one step away from version right in folder name :)
though yep, may be easiest one is to name a root file instead of whole folder
 
Regarding "forgetting to update version in file or in other source". Ideally, your project's version number is defined in exactly one place. If you have a hundred .html files and they all end with <p>MyCoolLib 1.2.3 copyright 2022 Grasshopper Inc</p>, it will be troublesome to rename them all when you move to 1.2.4.
Better to use a template engine of some kind
@halt9k Try to design your project so it doesn't need correct timestamps to work properly.
 
it's already this way, they became annoyance when sourcetree diff did not recognised same files and unexpectedly showed two commits as not same while only difference were timestamps
if it's not about timestamps, but about versions - they certanly help to have all clean
 
Or, maybe I'm misunderstanding the point. If you're saying "I can't use git because it will change the 'last modified at' metadata of every file", try not to depend on that metadata. If you're saying "I don't like putting time-related data in file names because it's easy to misinterpret 'MyCoolLib_08_09_2022' as Sept 8 instead of Aug 9", that's a valid concern
 
whole point was this:
goal is to have clean project folder without any additional files in it, but to constantly change this folder name to match version
and timestamp reliability question is just simplification for programs like beyond compare to work faster, it's not critical in general
 
12:47 PM
if you can make a simple reproducible example using a couple tiny files and a simple git repo, that would be easier to explain
 
cabbage
 
I'm less interested in replicatable code and more interested in a concrete use case.
 
@halt9k I've just gone through the history of that conversation... and I'm mightily confused.
We seem to have started out at merging/rebasing and now we're at version-naming folders?
Besides a description of what you want to build (version-named folders) what exactly is the problem you are trying to solve?
 
that's 3 separate questions - rebase trouble, workaround git restriction on folder renames, and not as reliable as desired git timestamps
 
Something like, "I am the tech lead of MyCoolLib. Whenever I finish developing a major feature, I make a zip archive of the project and email it to my user, Alice. Alice has been complaining that it's hard to distinguish between the dozens of MyCoolLib.zip that I have sent her"
 
12:55 PM
don't know, but while it's not the best approach, something along the way of "here a default, normal git repo with a single commit, and here what I want to do based on this workflow" would speak volume compared to this confusing back and forth
 
@Kevin Oooh, packaging! :hearts:
 
:Nordine are you under windows or some unix/linux ?
 
@Kevin hey have not said i'm tech lead! other than that, Alice exists LOL
 
i think first things first: don't change your folder name of the project for any reason
 
Or perhaps, "When I finish working on a major feature for MyCoolLib, I often forget to increase the version number by one before I email the deployment to Alice. I would like a highly visible reminder of what version number I'm currently in. It would be nice if it was visible in every explorer window and shell prompt."
 
12:57 PM
those things are not just frivolous things to change every release, they will (or should) form the basis of your whole project structure in any case
 
@XavierCombelle under Windows 10 (don't know the release version) based on what was said earlier :)
 
The latter use case might be solved more easily by putting a sticky note at eye level
 
next: in the absence of the folder name to keep track of releases, why not just track that via code? you should have the freedom to do anything you like in your one_click_deploy script, including tracking the version of the "last" released file for example
have it warn if the version hasnt been bumped. voila.
 
I wonder if you can configure Outlook/gmail/etc to put up a message box every time you start writing an email to Alice. "Have you double checked your version number? [Yes | No]"
 
i should also mention third...there's actually tools that assist with bumping versions automatically too, though i can't say i've used them myself. for python packages, there's one called versioneer, and there's others too
 
1:00 PM
@XavierCombelle ha, but I'm on linux though. Didn't notice you tagged me (thought you meant to tag halt9k instead)
 
you could essentially completely forget about having to maintain versions if you wanted to go that far.
 
@Kevin I have not said my lib is cool! But sure you got other close!
 
@NordineLotfi you can do a bash script
 
Coolness is on the development roadmap, should be ready by v2.0.0
 
except the project uses zero-ver... oops!
 
1:03 PM
$MAIN="git_project"
cd $MAIN; cp * $VERSION
 
@XavierCombelle hmm? yeah I know that, but this isn't something I'm solving or having problem with, it's halt9k who asked earlier afterall.
 
scripting is current solution, just less clean than desired
and after all, why flexible folder name is so big deal to ask from git
or may be masked folder name, when git takes two unique folders with prefix as same
 
@halt9k its because git does "everything" based on the idea that a file's path matters. essentially, git doesnt even care about folders per se, but the total sum of a path in its structure that gives us a unique file
which is frankly a very reasonable assumption to make. imagine your program files folder constantly having every single folder change each time an update happened. it would be one heck of a dumpster fire to deal with
things rely on paths to find files. changing one of the folders essentially changes the path to the file, so naturally it should break things.
 
@ParitoshSingh btw when you update very old project, that's exactly what is happening - total restructure every version
 
sure, and we know what kind of monumental decision that is. it shouldnt be made trivially for each release. something as large as "reorganizing old code" is where we take that call
logically speaking, at that point wouldn't you rather have git actually figure out the linkages from old structure to new, and do its best to construct a diff that's workable? this is the kind of stuff git can achieve because it tracks the totality of a path + file inside a project, and is sensitive to folder changes.
 
1:18 PM
probably would like to have strictly to order git to reroute, so it did not take such changes as renames at all and you could freely change names and move files
like .gitignore but .gitrenames
 
isn't that backwards though. git should know when the folder structure changes.
 
1:46 PM
Does git care about absolute paths? Or paths relative to the .git directory? Or something else?
If the directory MyCoolProjectv1 contains main.py and .git, it would be nice if I could move MyCoolProjectv1 from "C:/programming/python" to "C:/users/kevin/projects" without breaking anything
 
Git repos start at the repo's directory. Doesn't care about anything higher up.
 
On a completely different git issue - is there a nice way to reverse a PR merge and throw it back at the person that raised the PR? I merged something and then spotted a mistake that I want them to take ownership of. That's my fault for missing it, but now "revert" seems to just want me to take ownership of it in a new PR. It feels like there should be some way for me to roll it back into a review stage of the original PR
 
@roganjosh once merged you need new commits that revert the earlier commits unless you want to change history
if you hate other people (and yourself) you can move main back to where it was before the PR :P
 
It's my repo and it's not really a case of hating them, but I think they need to have it back at them to actually learn something. I know my mistake; they don't know theirs
 
The "hate them" part is about everyone else holding a clone being out of sync and having PRs start off of the wrong (stale) branch
Changing what main points to is equivalent to a force push.
 
1:53 PM
If it's a faff I'll just fix it myself. It seems like something that should be trivially reversible but it apparently isn't :(
 
it's trivially reversible if you ignore history
 
If you merged then it should be sufficient to git-revert the merge commit.
The diff might be huge, but as far as git is concerned it's still just one operation.
 
@MisterMiyagi but that will be authored by roganjosh
 
Revert on the main git page just takes me to a new page to open a new PR. I haven't tried the CLI
 
one commit merging the PR, one reverting
@roganjosh there's your problem
 
1:55 PM
Delete repository, start a new one
 
@Kevin "Look what you've made me do with your copy/paste malarky!"
 
@AndrasDeak--СлаваУкраїні Don't think there's a way around that. Josh would own the merge as well to begin with.
 
Simply keep your repository inside a meta-repository so you can easily meta-revert any actions that can't be reverted normally
 
It's not a big issue over all, it's just not ideal from my perspective of trying to teach someone something, make them aware of their mistake and have a good opportunity to fix it
 
1:56 PM
You certainly didn't teach them good reviewing habits! :P
 
oof
But true
 
Hm, but what if you need to revert a change in the meta-repository?
 
meta-repo?
it's not the "repo" part that I didn't understand
 
@roganjosh It might help them to see that you own the "oops, I should not have merged that". Makes it less of a "you messed up, mortal!" situation and more of a "we're all just mortals around here".
 
Keep a meta-meta-repository to track your meta-repository. But no meta^3-repository. That's just silly.
 
1:58 PM
ah, I missed Kevin's message, nevermind
@MisterMiyagi yeah, I'd open a PR to revert it
 
@MisterMiyagi that's the angle I will go for. One part was correct in the first pass, then I reviewed to ask for things to be changed from if type(thing) == to isinstance() and they then copy/pasted it. It is my fault for missing the extra change but I don't wanna handle it in isolation and I'm more than happy to accept my failure here
 
If this is on github you can both check "changes since my last review", and tick out files that you've reviewed, which will open up automatically when changed by subsequent commits.
 
2:30 PM
testString = "Stan says hello to Margot from Estoria."
pattern = "Stan|hello|Margot|Estonia"
replace = "Unknown"
re.sub(pattern, replace, testString)
this returns the following error: name 're' is not defined
 
@thecoolgeek you're missing an "import re" then
 
Awesome, it now works, thanks! This group is very helpful.
 
you also have a typo in Estonia
 
Yeah, I saw that and fixed it.
 
2:59 PM
#1
x = None
for i in range(n):
    y = f(i)
    if x is None:
        x = y
        continue
    x = g(x, y)
#2
x = None
for i in range(n):
    y = f(i)
    if x is None:
        x = y
    else:
        x = g(x, y)
#3
del x
for i in range(n):
    y = f(i)
    try:
        x = g(x, y)
    except NameError:
        x = y
Are there objective arguments for one style 1, 2 or 3?
 
definitely not the one with del x and NameError
 
Yes, but why
 
It's better form to have all the relevant names defined rather than relying on "undefined". This is not JS.
#4
x = f(0)
for i in range(1, n):
    y = f(i)
    x = g(x, y)
 
But also: Python prefers EAFP over LBYL
 
3:03 PM
@AndrasDeak--СлаваУкраїні Yes, but the f call is very long and lots of arguments. That's why it should only appear once. DRY principle. Should have mentioned that
 
ys = [f(i) for i in range(n)]
x = functools.reduce(g, ys)
 
@AndrasDeak--СлаваУкраїні 😅 Like I said - I agree. But I'm looking for objective arguments. To explain how this isn't like if key in dict: dict[key] = 123 LBYL style
 
if it's long and has a lot of arguments put it in a function, a lambda or some state object
 
@Aran-Fey Dammit I should have mentioned that too: y is big so I cannot accumulate them for large n
 
Aran's solution only works with ys as a generator.
You've basically unrolled reduce(g, map(f, range(n)).
 
3:07 PM
What do you mean it only works with a generator?
 
*also
 
ah, that makes more sense
 
Yes, that's how I read it. With a generator this actually should work
I'll give it a try thanks
Any ideas how to objectively reject the try-except NameError variant?
 
FWIW, catching NameError is extremely uncommon as far as I can tell. You're not asking Python for forgiveness with that, you're asking to pass the bandaid after shooting yourself.
Names are generally treated as a static thing in programs, treating them dynamically is in the same ballpark as mucking with globals/locals.
 
Me, who does that all the time: i.imgflip.com/2zo1ki.jpg
 
3:12 PM
Potential argument against #3: exceptions are relatively slow. [citation needed]
 
Still sounds like one could simply reply: Oh so it only comes down to personal preference
 
Source: revealed to me in a dream
 
@Kevin Actually they're pretty fast in 3.11. :P
@rattlesnake Everything comes down to personal preference.
 
Still too slow!
 
Ludicrous speed?
 
3:14 PM
Take us to plaid
 
The NameError solution can stop working if someone adds a global x variable. You can work around that, but that requires additional boilerplate code. Using None as a sentinel value is just better
 
I suspect some scope trickery is possible to guard against the global x variable scenario, but I think explaining further would violate the Hippocratic Oath
 
@Kevin you could shadow the global name with x = None... oh
 
@MisterMiyagi I don't think this is as uncommon as you think iirc. I seen a lot of stuff on github that does it, heck, I do it all the time, and I'm mildly proud of it
 
3:21 PM
then again, I can kind of see how this can become broken, especially when importing it or depending on something that does this. Can become broken in unexpected ways I guess
 
And arguments for/against #1 vs #2?
 
I thought we agreed that #3 was best on account of no 3-volume treatise having been published to refute it
 
I have never wrapped a NameError so my anecdata is that it doesn't happen. I could imagine for Py 2/3 compatibility but I've never had to do that
 
Pop quiz! from foo import something_that_doesnt_exist raises what kind of exception?
 
definitely instance of ImportError
which one though...
at least I hope so :D
 
3:24 PM
I am reminded of:
Jul 20 at 12:41, by Kevin
Don't think I've seen except NameError: before... It kind of makes sense though
 
@AndrasDeak--СлаваУкраїні Well, there aren't exactly very many of those...
 
@Aran-Fey true, but I don't know those two by heart
 
fair
 
Lot of wiggle room in that "kind of", but take it as you will
 
But yeah, it's an ImportError
 
3:26 PM
(by "two" I meant two subclasses, so 3 classes overall)
 
There's only ImportError and ModuleNotFoundError though?
 
@rattlesnake the continue approach consumes 1 additional IQ of my brain resources, because I have to mentally draw a dotted line from the continue to the statement where control will resume
 
>>> ImportError.__subclasses__()
[<class 'ModuleNotFoundError'>, <class 'zipimport.ZipImportError'>]
 
Oho, interesting
 
This brain resource cost scales by distance. If I have to scroll up two pages to find the nearest enclosing loop, I might just give up halfway through and have a nap instead
 
3:31 PM
@Kevin Ha, interesting. For me, it's more work to read the if/else approach because it's longer and both blocks are indented. With if/continue I feel like I can forget about the if block once I reached continue and then read the final line
 
Valid
 
I agree with your argument, too, though. If you have to search for the loop beginning then that's not pleasant either
 
just convert that loop into recursion
 
👍 Thanks for your insights everyone. It was a pleasure as always
@AndrasDeak--СлаваУкраїні You're talking about the functional approach with reduce yes?
 
Of course not, that one still has a loop.
 
3:35 PM
You mean the loop inside the generator?
 
and inside functools.reduce, yes
 
 
2 hours later…
Yen
5:31 PM
hi
how to deal with ,int() argument must be a string, a bytes-like object or a number
 
@Yen pass a string, bytes-like object or number
 
Hi there
I need assistance regrading selenium library.
Every time I send a get request to website, the site redirects me towards the press & hold captcha . Is there any solution to solve that.
 
@AbdulRehman sounds like they don't want you to scrape their website
 
yes but I want to scrape the text. Is there anyway to that
 
Yeah, you might be able to pay for an API they offer
Technically not scraping that way
 
5:43 PM
They don't have any Api, is there some other way from which I can scrapped their data.
 
@AbdulRehman unfortunately we don't allow fresh questions on the main site here, see sopython.com/chatroom
 
where can I ask the fresh question? Kindly guide me
 
You already have: on the main site
 
Yen
5:57 PM
@AndrasDeak--СлаваУкраїні hi, can you please give me an example for that
 
6:20 PM
There's a site whose TOS allows you to do a reasonable amount of scraping if you're participating in their bug bounty program. I don't think there's any way to mark yourself as a "nice" web crawler, so I'm scared I'll get mega-banned by their anti-scraping tech
"Our records indicate that a web agent from your IP address failed 10,000 CAPTCHAs in the last 24 hours. Due to good past behavior, we've elected to reverse your ban. Or rather, one of them. Please file 9,999 more appeals before using our site again"
And I'm sure Google will know about the 10,000 failed captchas. In order to log into my gmail, I'll have to enter my password, and one-time 2FA PIN, and mother's maiden name, and a 30 second clip of the song of my people, and mail them my birth certificate
 
5 factor auth
 
"A Google associate is at your front door. Please let them in. They will hold your hand while you click I'm Not A Robot, to verify that you possess flesh and blood"
"To more effectively verify the presence of blood, they will attempt to raise your heart rate. They have a choice of seduction, or terror. Please do not resist in either case"
 
That's all well and good but will they help me identify where traffic lights begin and end? I never know whether to tag the pole or just the lights themselves
#FirstWorldProblems
 
I just tag the lights and the housing for the lights
 
Yen
  for i in range(count):
        start_new =
             int(self.data.get(f'applicationruntime_set-{i}-
                start_new') or str(start_new))
         if start_new is not None :
                 int(start_new)
 
6:31 PM
It can clearly never be None
 
Yen
Hi , i need little help , i am really stuggling to solve none type
 
Possibly part of the problem is: int(whatever) does nothing unless you assign the result to something
>>> x = "123"
>>> int(x)
123
>>> type(x)
<class 'str'>
>>> x = int(x)
>>> type(x)
<class 'int'>
 
What do you mean, solve NoneType? How is NoneType causing you problems?
 
@Kevin it goes to start_new in a broken assignment over multiple lines
 
I'm wary of an assignment statement that has the same name on both the left part and the right part. Particularly when it's the only statement that assigns anything to that name. It's possible to ensure that it never raises a NameError, but I'd rather just avoid the situation entirely
@roganjosh Hmm, so it does. Ok, then my first comment only applies to the final line.
Of course, as you say, since start_new is never None, that line will never execute.
I do like to cross bridges before I get to them.
 
6:38 PM
Belt and braces approach, but forgot the trousers
 
Yen
for i in range(count):
    start_new =int(self.data.get(f'applicationruntime_set-{i}-start_new') or str(start_new))
    start_old =int(self.data.get(f'applicationruntime_set-{i}-start_old') or str(end_new))
    end_new =int(self.data.get(f'applicationruntime_set-{i}-end_new') or str(end_new))
    end_old =int(self.data.get(f'applicationruntime_set-{i}-end_old') or str(end_old))
    if start_new is not None:
         int(start_new)
    if end_new is not None:
          int(end_new)
    if end_new is not None:
this is my full code
 
No it's not. You never defined count.
(among other things)
 
Yen
i missed that
count = int(self.data.getlist('applicationruntime_set-TOTAL_FORMS')[0])
this will be the count
 
Ok, now it's not complete because you never defined self.
 
6:42 PM
she was a girl
 
Aug 3 at 22:22, by Andras Deak -- Слава Україні
start_new = self.data.get(f'applicationruntime_set-{i}-start_new')
if start_new is not None:
    start_new = int(start_new)
# now start_new is either None or an int
 
She said see you later boy
 
Aug 3 at 22:14, by Andras Deak -- Слава Україні
If you don't understand what I mean, say so and we'll discuss further to reach a common understanding. Ignoring what I say and doing something random and wrong doesn't benefit either of us at all.
 
He wasn't good enough for her
 
Yen
yes i missed that
sorry for that
 
6:44 PM
If you can provide code that I can copy and paste into a file on my machine, and run it, and see an error message that involves NoneType, I will put 100% effort into fixing the problem. This offer is rescinded if the next code you share is incomplete.
 
@Yen it seems that 5 days later you are back to square one. At this point I must ask you to stop asking for help here and read a good python tutorial, preferably one aimed at programming beginners.
until you obtain a fundamental understanding of programming concepts you are only wasting your time here (and, sorry to say, ours too)
 
Yen
can you please give me a link for referance
 
@Aran-Fey lalala superstar
@Yen I don't have any personal recommendations. We have a list here, I don't have any experience with the recommendations there.
 
Yen
thanks
@AndrasDeak--СлаваУкраїні this does not solve the issue
 
Prove it :-)
 
Yen
6:56 PM
ok, after for looping the count the start_data=self.data.get(value) and None value, so the none type error still there
 
7:13 PM
@Yen if you don't want Nones, why do you use a method that will fall back to giving you Nones?
 
That's not very conducive for them to stop asking here
 
@AndrasDeak--СлаваУкраїні Not sure how I feel about this song. I suppose it's one of the songs ever made
 
@Aran-Fey does it give you emotions? Or emos for short?
 
It does. I'm just not sure which ones
 
Yen
@MisterMiyagi can you tell me the method name
 
7:28 PM
Let me give an excerpt of the next couple of hours:
1.we figure out that they are using data.get with no default because that was one of my recommendations on August 3
2. we replay about 85% of our lengthy discussion on August 3
3. we try to figure out what the ostensibly real use case is this time
4. if the kind helping souls prevail through the confusion, we write code for Yen that does what we think they need
5. Yen leaves in success

Then again 5 days later they come back because the requirements weren't complete and/or one line needs changing, but without a fundamental understanding of
Motivation: 1. chat.stackoverflow.com/transcript/message/55015603#55015603 (and surrounding context, obviously), 2. their most recent code block with things like if start_new is not None: int(start_new). They really need to learn some basics first.
 
I think I'll go ahead and count start_data=self.data.get(value) and None as "the next code [Yen] share[s]", and trigger my help rescindment clause. Rescindscion? Rescindation?
 
Yen
i understand , i have to learn
 
7:51 PM
Kevin sits at the bottom of the mountain. He says to you, "I will teach you the secret to enlightenment, but only if you write me a very good haiku". You hand him your best effort. He inspects it and says, "Hmm, not enough references to the four seasons. Sorry! No enlightenment today". You try to protest, but he has already laid down and fallen asleep.
 
Andras watches all of this from the stairs carved into the mountain. He says to you, "Pay no attention to that strange vagrant. The secret to enlightenment is in my hut at the top of the mountain. Meet me there." With that, he sprints effortlessly up the stairs, taking five steps at a time. In only a few moments, he is a distant speck, obscured by the clouds that wreath the peak.
@NordineLotfi Ooh, I love a good tech koan
 
8:14 PM
yeah, those are nice. I don't know if this was on purpose though but what you said really read like a koans. I mean I know how to do haiku (not great ones I might add) but koans seems a bit too mystical to me.
 
The mysticalness is a selling point, for me. I want the reader to get the impression that I'm privy to the secrets of the cosmos. But I don't want to explain any cosmic secrets, which brings us to selling point #2: if the reader is terribly confused by the story, you can just say, "that's the point :-)"
 
8:32 PM
yeah, I see what you mean. I kind of like the open-ending of it too, so I can think whatever it may mean. Also slightly related?: github.com/gregmalcolm/python_koans
 
most of the vim ones seem to be on the nose
 
yeah, those are :D especially if you use Vim.
 
9:26 PM
I wished for git restore to support a -p switch, and then I checked and it supports a -p switch. I should've wished for something more expensive...
 

« first day (4314 days earlier)      last day (624 days later) »